Merge "egl: Call loseCurrent after eglReleaseThread"
diff --git a/aidl/binder/android/os/PersistableBundle.aidl b/aidl/binder/android/os/PersistableBundle.aidl
new file mode 100644
index 0000000..94e8607
--- /dev/null
+++ b/aidl/binder/android/os/PersistableBundle.aidl
@@ -0,0 +1,20 @@
+/*
+**
+** Copyright 2014, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+package android.os;
+
+parcelable PersistableBundle cpp_header "binder/PersistableBundle.h";
diff --git a/build/tablet-7in-hdpi-1024-dalvik-heap.mk b/build/tablet-7in-hdpi-1024-dalvik-heap.mk
index 5bbd2b0..7fd34b5 100644
--- a/build/tablet-7in-hdpi-1024-dalvik-heap.mk
+++ b/build/tablet-7in-hdpi-1024-dalvik-heap.mk
@@ -18,7 +18,7 @@
 
 PRODUCT_PROPERTY_OVERRIDES += \
     dalvik.vm.heapstartsize=8m \
-    dalvik.vm.heapgrowthlimit=64m \
+    dalvik.vm.heapgrowthlimit=80m \
     dalvik.vm.heapsize=384m \
     dalvik.vm.heaptargetutilization=0.75 \
     dalvik.vm.heapminfree=512k \
diff --git a/cmds/atrace/Android.mk b/cmds/atrace/Android.mk
index 028ca8f..bfb3838 100644
--- a/cmds/atrace/Android.mk
+++ b/cmds/atrace/Android.mk
@@ -16,5 +16,8 @@
     libcutils \
     libutils \
     libz \
+    libbase
+
+LOCAL_INIT_RC := atrace.rc
 
 include $(BUILD_EXECUTABLE)
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp
index 34dc9fe..66f3fda 100644
--- a/cmds/atrace/atrace.cpp
+++ b/cmds/atrace/atrace.cpp
@@ -23,10 +23,14 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/sendfile.h>
 #include <time.h>
+#include <unistd.h>
 #include <zlib.h>
 
+#include <memory>
+
 #include <binder/IBinder.h>
 #include <binder/IServiceManager.h>
 #include <binder/Parcel.h>
@@ -34,13 +38,16 @@
 #include <cutils/properties.h>
 
 #include <utils/String8.h>
+#include <utils/Timers.h>
+#include <utils/Tokenizer.h>
 #include <utils/Trace.h>
+#include <android-base/file.h>
 
 using namespace android;
 
 #define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))
 
-enum { MAX_SYS_FILES = 8 };
+enum { MAX_SYS_FILES = 10 };
 
 const char* k_traceTagsProperty = "debug.atrace.tags.enableflags";
 const char* k_traceAppCmdlineProperty = "debug.atrace.app_cmdlines";
@@ -77,16 +84,28 @@
     { "webview",    "WebView",          ATRACE_TAG_WEBVIEW, { } },
     { "wm",         "Window Manager",   ATRACE_TAG_WINDOW_MANAGER, { } },
     { "am",         "Activity Manager", ATRACE_TAG_ACTIVITY_MANAGER, { } },
+    { "sm",         "Sync Manager",     ATRACE_TAG_SYNC_MANAGER, { } },
     { "audio",      "Audio",            ATRACE_TAG_AUDIO, { } },
     { "video",      "Video",            ATRACE_TAG_VIDEO, { } },
     { "camera",     "Camera",           ATRACE_TAG_CAMERA, { } },
     { "hal",        "Hardware Modules", ATRACE_TAG_HAL, { } },
+    { "app",        "Application",      ATRACE_TAG_APP, { } },
     { "res",        "Resource Loading", ATRACE_TAG_RESOURCES, { } },
     { "dalvik",     "Dalvik VM",        ATRACE_TAG_DALVIK, { } },
     { "rs",         "RenderScript",     ATRACE_TAG_RS, { } },
+    { "bionic",     "Bionic C Library", ATRACE_TAG_BIONIC, { } },
+    { "power",      "Power Management", ATRACE_TAG_POWER, { } },
+    { "pm",         "Package Manager",  ATRACE_TAG_PACKAGE_MANAGER, { } },
+    { "ss",         "System Server",    ATRACE_TAG_SYSTEM_SERVER, { } },
+    { "database",   "Database",         ATRACE_TAG_DATABASE, { } },
     { "sched",      "CPU Scheduling",   0, {
         { REQ,      "/sys/kernel/debug/tracing/events/sched/sched_switch/enable" },
         { REQ,      "/sys/kernel/debug/tracing/events/sched/sched_wakeup/enable" },
+        { OPT,      "/sys/kernel/debug/tracing/events/sched/sched_blocked_reason/enable" },
+    } },
+    { "irq",        "IRQ Events",   0, {
+        { REQ,      "/sys/kernel/debug/tracing/events/irq/enable" },
+        { OPT,      "/sys/kernel/debug/tracing/events/ipi/enable" },
     } },
     { "freq",       "CPU Frequency",    0, {
         { REQ,      "/sys/kernel/debug/tracing/events/power/cpu_frequency/enable" },
@@ -99,8 +118,14 @@
         { REQ,      "/sys/kernel/debug/tracing/events/power/cpu_idle/enable" },
     } },
     { "disk",       "Disk I/O",         0, {
-        { REQ,      "/sys/kernel/debug/tracing/events/ext4/ext4_sync_file_enter/enable" },
-        { REQ,      "/sys/kernel/debug/tracing/events/ext4/ext4_sync_file_exit/enable" },
+        { OPT,      "/sys/kernel/debug/tracing/events/f2fs/f2fs_sync_file_enter/enable" },
+        { OPT,      "/sys/kernel/debug/tracing/events/f2fs/f2fs_sync_file_exit/enable" },
+        { OPT,      "/sys/kernel/debug/tracing/events/f2fs/f2fs_write_begin/enable" },
+        { OPT,      "/sys/kernel/debug/tracing/events/f2fs/f2fs_write_end/enable" },
+        { OPT,      "/sys/kernel/debug/tracing/events/ext4/ext4_da_write_begin/enable" },
+        { OPT,      "/sys/kernel/debug/tracing/events/ext4/ext4_da_write_end/enable" },
+        { OPT,      "/sys/kernel/debug/tracing/events/ext4/ext4_sync_file_enter/enable" },
+        { OPT,      "/sys/kernel/debug/tracing/events/ext4/ext4_sync_file_exit/enable" },
         { REQ,      "/sys/kernel/debug/tracing/events/block/block_rq_issue/enable" },
         { REQ,      "/sys/kernel/debug/tracing/events/block/block_rq_complete/enable" },
     } },
@@ -116,6 +141,24 @@
     { "workq",      "Kernel Workqueues", 0, {
         { REQ,      "/sys/kernel/debug/tracing/events/workqueue/enable" },
     } },
+    { "memreclaim", "Kernel Memory Reclaim", 0, {
+        { REQ,      "/sys/kernel/debug/tracing/events/vmscan/mm_vmscan_direct_reclaim_begin/enable" },
+        { REQ,      "/sys/kernel/debug/tracing/events/vmscan/mm_vmscan_direct_reclaim_end/enable" },
+        { REQ,      "/sys/kernel/debug/tracing/events/vmscan/mm_vmscan_kswapd_wake/enable" },
+        { REQ,      "/sys/kernel/debug/tracing/events/vmscan/mm_vmscan_kswapd_sleep/enable" },
+    } },
+    { "regulators",  "Voltage and Current Regulators", 0, {
+        { REQ,      "/sys/kernel/debug/tracing/events/regulator/enable" },
+    } },
+    { "binder_driver", "Binder Kernel driver", 0, {
+        { REQ,      "/sys/kernel/debug/tracing/events/binder/binder_transaction/enable" },
+        { REQ,      "/sys/kernel/debug/tracing/events/binder/binder_transaction_received/enable" },
+    } },
+    { "binder_lock", "Binder global lock trace", 0, {
+        { REQ,      "/sys/kernel/debug/tracing/events/binder/binder_lock/enable" },
+        { REQ,      "/sys/kernel/debug/tracing/events/binder/binder_locked/enable" },
+        { REQ,      "/sys/kernel/debug/tracing/events/binder/binder_unlock/enable" },
+    } },
 };
 
 /* Command line options */
@@ -125,6 +168,7 @@
 static bool g_compress = false;
 static bool g_nohup = false;
 static int g_initialSleepSecs = 0;
+static const char* g_categoriesFile = NULL;
 static const char* g_kernelTraceFuncs = NULL;
 static const char* g_debugAppCmdLine = "";
 
@@ -172,6 +216,12 @@
 static const char* k_tracePath =
     "/sys/kernel/debug/tracing/trace";
 
+static const char* k_traceStreamPath =
+    "/sys/kernel/debug/tracing/trace_pipe";
+
+static const char* k_traceMarkerPath =
+    "/sys/kernel/debug/tracing/trace_marker";
+
 // Check whether a file exists.
 static bool fileExists(const char* filename) {
     return access(filename, F_OK) != -1;
@@ -234,6 +284,32 @@
     return _writeStr(filename, str, O_APPEND|O_WRONLY);
 }
 
+static void writeClockSyncMarker()
+{
+  char buffer[128];
+  int len = 0;
+  int fd = open(k_traceMarkerPath, O_WRONLY);
+  if (fd == -1) {
+      fprintf(stderr, "error opening %s: %s (%d)\n", k_traceMarkerPath,
+              strerror(errno), errno);
+      return;
+  }
+  float now_in_seconds = systemTime(CLOCK_MONOTONIC) / 1000000000.0f;
+
+  len = snprintf(buffer, 128, "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds);
+  if (write(fd, buffer, len) != len) {
+      fprintf(stderr, "error writing clock sync marker %s (%d)\n", strerror(errno), errno);
+  }
+
+  int64_t realtime_in_ms = systemTime(CLOCK_REALTIME) / 1000000;
+  len = snprintf(buffer, 128, "trace_event_clock_sync: realtime_ts=%" PRId64 "\n", realtime_in_ms);
+  if (write(fd, buffer, len) != len) {
+      fprintf(stderr, "error writing clock sync marker %s (%d)\n", strerror(errno), errno);
+  }
+
+  close(fd);
+}
+
 // Enable or disable a kernel option by writing a "1" or a "0" into a /sys
 // file.
 static bool setKernelOptionEnable(const char* filename, bool enable)
@@ -322,11 +398,56 @@
     return writeStr(k_traceBufferSizePath, str);
 }
 
+// Read the trace_clock sysfs file and return true if it matches the requested
+// value.  The trace_clock file format is:
+// local [global] counter uptime perf
+static bool isTraceClock(const char *mode)
+{
+    int fd = open(k_traceClockPath, O_RDONLY);
+    if (fd == -1) {
+        fprintf(stderr, "error opening %s: %s (%d)\n", k_traceClockPath,
+            strerror(errno), errno);
+        return false;
+    }
+
+    char buf[4097];
+    ssize_t n = read(fd, buf, 4096);
+    close(fd);
+    if (n == -1) {
+        fprintf(stderr, "error reading %s: %s (%d)\n", k_traceClockPath,
+            strerror(errno), errno);
+        return false;
+    }
+    buf[n] = '\0';
+
+    char *start = strchr(buf, '[');
+    if (start == NULL) {
+        return false;
+    }
+    start++;
+
+    char *end = strchr(start, ']');
+    if (end == NULL) {
+        return false;
+    }
+    *end = '\0';
+
+    return strcmp(mode, start) == 0;
+}
+
 // Enable or disable the kernel's use of the global clock.  Disabling the global
 // clock will result in the kernel using a per-CPU local clock.
+// Any write to the trace_clock sysfs file will reset the buffer, so only
+// update it if the requested value is not the current value.
 static bool setGlobalClockEnable(bool enable)
 {
-    return writeStr(k_traceClockPath, enable ? "global" : "local");
+    const char *clock = enable ? "global" : "local";
+
+    if (isTraceClock(clock)) {
+        return true;
+    }
+
+    return writeStr(k_traceClockPath, clock);
 }
 
 static bool setPrintTgidEnableIfPresent(bool enable)
@@ -407,42 +528,33 @@
 // kernel.
 static bool verifyKernelTraceFuncs(const char* funcs)
 {
-    int fd = open(k_ftraceFilterPath, O_RDONLY);
-    if (fd == -1) {
-        fprintf(stderr, "error opening %s: %s (%d)\n", k_ftraceFilterPath,
+    std::string buf;
+    if (!android::base::ReadFileToString(k_ftraceFilterPath, &buf)) {
+         fprintf(stderr, "error opening %s: %s (%d)\n", k_ftraceFilterPath,
             strerror(errno), errno);
-        return false;
+         return false;
     }
 
-    char buf[4097];
-    ssize_t n = read(fd, buf, 4096);
-    close(fd);
-    if (n == -1) {
-        fprintf(stderr, "error reading %s: %s (%d)\n", k_ftraceFilterPath,
-            strerror(errno), errno);
-        return false;
-    }
-
-    buf[n] = '\0';
-    String8 funcList = String8::format("\n%s", buf);
+    String8 funcList = String8::format("\n%s",buf.c_str());
 
     // Make sure that every function listed in funcs is in the list we just
-    // read from the kernel.
+    // read from the kernel, except for wildcard inputs.
     bool ok = true;
     char* myFuncs = strdup(funcs);
     char* func = strtok(myFuncs, ",");
     while (func) {
-        String8 fancyFunc = String8::format("\n%s\n", func);
-        bool found = funcList.find(fancyFunc.string(), 0) >= 0;
-        if (!found || func[0] == '\0') {
-            fprintf(stderr, "error: \"%s\" is not a valid kernel function "
-                "to trace.\n", func);
-            ok = false;
+        if (!strchr(func, '*')) {
+            String8 fancyFunc = String8::format("\n%s\n", func);
+            bool found = funcList.find(fancyFunc.string(), 0) >= 0;
+            if (!found || func[0] == '\0') {
+                fprintf(stderr, "error: \"%s\" is not a valid kernel function "
+                        "to trace.\n", func);
+                ok = false;
+            }
         }
         func = strtok(NULL, ",");
     }
     free(myFuncs);
-
     return ok;
 }
 
@@ -486,6 +598,52 @@
     return ok;
 }
 
+static bool setCategoryEnable(const char* name, bool enable)
+{
+    for (int i = 0; i < NELEM(k_categories); i++) {
+        const TracingCategory& c = k_categories[i];
+        if (strcmp(name, c.name) == 0) {
+            if (isCategorySupported(c)) {
+                g_categoryEnables[i] = enable;
+                return true;
+            } else {
+                if (isCategorySupportedForRoot(c)) {
+                    fprintf(stderr, "error: category \"%s\" requires root "
+                            "privileges.\n", name);
+                } else {
+                    fprintf(stderr, "error: category \"%s\" is not supported "
+                            "on this device.\n", name);
+                }
+                return false;
+            }
+        }
+    }
+    fprintf(stderr, "error: unknown tracing category \"%s\"\n", name);
+    return false;
+}
+
+static bool setCategoriesEnableFromFile(const char* categories_file)
+{
+    if (!categories_file) {
+        return true;
+    }
+    Tokenizer* tokenizer = NULL;
+    if (Tokenizer::open(String8(categories_file), &tokenizer) != NO_ERROR) {
+        return false;
+    }
+    bool ok = true;
+    while (!tokenizer->isEol()) {
+        String8 token = tokenizer->nextToken(" ");
+        if (token.isEmpty()) {
+            tokenizer->skipDelimiters(" ");
+            continue;
+        }
+        ok &= setCategoryEnable(token.string(), true);
+    }
+    delete tokenizer;
+    return ok;
+}
+
 // Set all the kernel tracing settings to the desired state for this trace
 // capture.
 static bool setUpTrace()
@@ -493,6 +651,7 @@
     bool ok = true;
 
     // Set up the tracing options.
+    ok &= setCategoriesEnableFromFile(g_categoriesFile);
     ok &= setTraceOverwriteEnable(g_traceOverwrite);
     ok &= setTraceBufferSizeKB(g_traceBufferSizeKB);
     ok &= setGlobalClockEnable(true);
@@ -569,6 +728,31 @@
     setTracingEnabled(false);
 }
 
+// Read data from the tracing pipe and forward to stdout
+static void streamTrace()
+{
+    char trace_data[4096];
+    int traceFD = open(k_traceStreamPath, O_RDWR);
+    if (traceFD == -1) {
+        fprintf(stderr, "error opening %s: %s (%d)\n", k_traceStreamPath,
+                strerror(errno), errno);
+        return;
+    }
+    while (!g_traceAborted) {
+        ssize_t bytes_read = read(traceFD, trace_data, 4096);
+        if (bytes_read > 0) {
+            write(STDOUT_FILENO, trace_data, bytes_read);
+            fflush(stdout);
+        } else {
+            if (!g_traceAborted) {
+                fprintf(stderr, "read returned %zd bytes err %d (%s)\n",
+                        bytes_read, errno, strerror(errno));
+            }
+            break;
+        }
+    }
+}
+
 // Read the current kernel trace and write it to stdout.
 static void dumpTrace()
 {
@@ -581,30 +765,34 @@
 
     if (g_compress) {
         z_stream zs;
-        uint8_t *in, *out;
-        int result, flush;
+        memset(&zs, 0, sizeof(zs));
 
-        bzero(&zs, sizeof(zs));
-        result = deflateInit(&zs, Z_DEFAULT_COMPRESSION);
+        int result = deflateInit(&zs, Z_DEFAULT_COMPRESSION);
         if (result != Z_OK) {
             fprintf(stderr, "error initializing zlib: %d\n", result);
             close(traceFD);
             return;
         }
 
-        const size_t bufSize = 64*1024;
-        in = (uint8_t*)malloc(bufSize);
-        out = (uint8_t*)malloc(bufSize);
-        flush = Z_NO_FLUSH;
+        constexpr size_t bufSize = 64*1024;
+        std::unique_ptr<uint8_t> in(new uint8_t[bufSize]);
+        std::unique_ptr<uint8_t> out(new uint8_t[bufSize]);
+        if (!in || !out) {
+            fprintf(stderr, "couldn't allocate buffers\n");
+            close(traceFD);
+            return;
+        }
 
-        zs.next_out = out;
+        int flush = Z_NO_FLUSH;
+
+        zs.next_out = reinterpret_cast<Bytef*>(out.get());
         zs.avail_out = bufSize;
 
         do {
 
             if (zs.avail_in == 0) {
                 // More input is needed.
-                result = read(traceFD, in, bufSize);
+                result = read(traceFD, in.get(), bufSize);
                 if (result < 0) {
                     fprintf(stderr, "error reading trace: %s (%d)\n",
                             strerror(errno), errno);
@@ -613,14 +801,14 @@
                 } else if (result == 0) {
                     flush = Z_FINISH;
                 } else {
-                    zs.next_in = in;
+                    zs.next_in = reinterpret_cast<Bytef*>(in.get());
                     zs.avail_in = result;
                 }
             }
 
             if (zs.avail_out == 0) {
                 // Need to write the output.
-                result = write(STDOUT_FILENO, out, bufSize);
+                result = write(STDOUT_FILENO, out.get(), bufSize);
                 if ((size_t)result < bufSize) {
                     fprintf(stderr, "error writing deflated trace: %s (%d)\n",
                             strerror(errno), errno);
@@ -628,7 +816,7 @@
                     zs.avail_out = bufSize; // skip the final write
                     break;
                 }
-                zs.next_out = out;
+                zs.next_out = reinterpret_cast<Bytef*>(out.get());
                 zs.avail_out = bufSize;
             }
 
@@ -640,7 +828,7 @@
 
         if (zs.avail_out < bufSize) {
             size_t bytes = bufSize - zs.avail_out;
-            result = write(STDOUT_FILENO, out, bytes);
+            result = write(STDOUT_FILENO, out.get(), bytes);
             if ((size_t)result < bytes) {
                 fprintf(stderr, "error writing deflated trace: %s (%d)\n",
                         strerror(errno), errno);
@@ -651,9 +839,6 @@
         if (result != Z_OK) {
             fprintf(stderr, "error cleaning up zlib: %d\n", result);
         }
-
-        free(in);
-        free(out);
     } else {
         ssize_t sent = 0;
         while ((sent = sendfile(STDOUT_FILENO, traceFD, NULL, 64*1024*1024)) > 0);
@@ -685,30 +870,6 @@
     sigaction(SIGTERM, &sa, NULL);
 }
 
-static bool setCategoryEnable(const char* name, bool enable)
-{
-    for (int i = 0; i < NELEM(k_categories); i++) {
-        const TracingCategory& c = k_categories[i];
-        if (strcmp(name, c.name) == 0) {
-            if (isCategorySupported(c)) {
-                g_categoryEnables[i] = enable;
-                return true;
-            } else {
-                if (isCategorySupportedForRoot(c)) {
-                    fprintf(stderr, "error: category \"%s\" requires root "
-                            "privileges.\n", name);
-                } else {
-                    fprintf(stderr, "error: category \"%s\" is not supported "
-                            "on this device.\n", name);
-                }
-                return false;
-            }
-        }
-    }
-    fprintf(stderr, "error: unknown tracing category \"%s\"\n", name);
-    return false;
-}
-
 static void listSupportedCategories()
 {
     for (int i = 0; i < NELEM(k_categories); i++) {
@@ -728,15 +889,21 @@
                         "separated list of cmdlines\n"
                     "  -b N            use a trace buffer size of N KB\n"
                     "  -c              trace into a circular buffer\n"
+                    "  -f filename     use the categories written in a file as space-separated\n"
+                    "                    values in a line\n"
                     "  -k fname,...    trace the listed kernel functions\n"
                     "  -n              ignore signals\n"
                     "  -s N            sleep for N seconds before tracing [default 0]\n"
-                    "  -t N            trace for N seconds [defualt 5]\n"
+                    "  -t N            trace for N seconds [default 5]\n"
                     "  -z              compress the trace dump\n"
                     "  --async_start   start circular trace and return immediatly\n"
                     "  --async_dump    dump the current contents of circular trace buffer\n"
                     "  --async_stop    stop tracing and dump the current contents of circular\n"
                     "                    trace buffer\n"
+                    "  --stream        stream trace to stdout as it enters the trace buffer\n"
+                    "                    Note: this can take significant CPU time, and is best\n"
+                    "                    used for measuring things that are not affected by\n"
+                    "                    CPU performance, like pagecache usage.\n"
                     "  --list_categories\n"
                     "                  list the available tracing categories\n"
             );
@@ -748,6 +915,7 @@
     bool traceStart = true;
     bool traceStop = true;
     bool traceDump = true;
+    bool traceStream = false;
 
     if (argc == 2 && 0 == strcmp(argv[1], "--help")) {
         showHelp(argv[0]);
@@ -762,10 +930,11 @@
             {"async_stop",      no_argument, 0,  0 },
             {"async_dump",      no_argument, 0,  0 },
             {"list_categories", no_argument, 0,  0 },
+            {"stream",          no_argument, 0,  0 },
             {           0,                0, 0,  0 }
         };
 
-        ret = getopt_long(argc, argv, "a:b:ck:ns:t:z",
+        ret = getopt_long(argc, argv, "a:b:cf:k:ns:t:z",
                           long_options, &option_index);
 
         if (ret < 0) {
@@ -791,6 +960,10 @@
                 g_traceOverwrite = true;
             break;
 
+            case 'f':
+                g_categoriesFile = optarg;
+            break;
+
             case 'k':
                 g_kernelTraceFuncs = optarg;
             break;
@@ -819,11 +992,14 @@
                     g_traceOverwrite = true;
                 } else if (!strcmp(long_options[option_index].name, "async_stop")) {
                     async = true;
-                    traceStop = false;
+                    traceStart = false;
                 } else if (!strcmp(long_options[option_index].name, "async_dump")) {
                     async = true;
                     traceStart = false;
                     traceStop = false;
+                } else if (!strcmp(long_options[option_index].name, "stream")) {
+                    traceStream = true;
+                    traceDump = false;
                 } else if (!strcmp(long_options[option_index].name, "list_categories")) {
                     listSupportedCategories();
                     exit(0);
@@ -849,8 +1025,10 @@
     ok &= startTrace();
 
     if (ok && traceStart) {
-        printf("capturing trace...");
-        fflush(stdout);
+        if (!traceStream) {
+            printf("capturing trace...");
+            fflush(stdout);
+        }
 
         // We clear the trace after starting it because tracing gets enabled for
         // each CPU individually in the kernel. Having the beginning of the trace
@@ -859,7 +1037,8 @@
         // another.
         ok = clearTrace();
 
-        if (ok && !async) {
+        writeClockSyncMarker();
+        if (ok && !async && !traceStream) {
             // Sleep to allow the trace to be captured.
             struct timespec timeLeft;
             timeLeft.tv_sec = g_traceDurationSeconds;
@@ -870,6 +1049,10 @@
                 }
             } while (nanosleep(&timeLeft, &timeLeft) == -1 && errno == EINTR);
         }
+
+        if (traceStream) {
+            streamTrace();
+        }
     }
 
     // Stop the trace and restore the default settings.
diff --git a/cmds/atrace/atrace.rc b/cmds/atrace/atrace.rc
new file mode 100644
index 0000000..74c8d43
--- /dev/null
+++ b/cmds/atrace/atrace.rc
@@ -0,0 +1,67 @@
+## Permissions to allow system-wide tracing to the kernel trace buffer.
+##
+on boot
+
+# Allow writing to the kernel trace log.
+    chmod 0222 /sys/kernel/debug/tracing/trace_marker
+
+# Allow the shell group to enable (some) kernel tracing.
+    chown root shell /sys/kernel/debug/tracing/trace_clock
+    chown root shell /sys/kernel/debug/tracing/buffer_size_kb
+    chown root shell /sys/kernel/debug/tracing/options/overwrite
+    chown root shell /sys/kernel/debug/tracing/options/print-tgid
+    chown root shell /sys/kernel/debug/tracing/events/sched/sched_switch/enable
+    chown root shell /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable
+    chown root shell /sys/kernel/debug/tracing/events/sched/sched_blocked_reason/enable
+    chown root shell /sys/kernel/debug/tracing/events/power/cpu_frequency/enable
+    chown root shell /sys/kernel/debug/tracing/events/power/cpu_idle/enable
+    chown root shell /sys/kernel/debug/tracing/events/power/clock_set_rate/enable
+    chown root shell /sys/kernel/debug/tracing/events/cpufreq_interactive/enable
+    chown root shell /sys/kernel/debug/tracing/events/vmscan/mm_vmscan_direct_reclaim_begin/enable
+    chown root shell /sys/kernel/debug/tracing/events/vmscan/mm_vmscan_direct_reclaim_end/enable
+    chown root shell /sys/kernel/debug/tracing/events/vmscan/mm_vmscan_kswapd_wake/enable
+    chown root shell /sys/kernel/debug/tracing/events/vmscan/mm_vmscan_kswapd_sleep/enable
+    chown root shell /sys/kernel/debug/tracing/events/binder/binder_transaction/enable
+    chown root shell /sys/kernel/debug/tracing/events/binder/binder_transaction_received/enable
+    chown root shell /sys/kernel/debug/tracing/events/binder/binder_lock/enable
+    chown root shell /sys/kernel/debug/tracing/events/binder/binder_locked/enable
+    chown root shell /sys/kernel/debug/tracing/events/binder/binder_unlock/enable
+
+    chown root shell /sys/kernel/debug/tracing/tracing_on
+
+    chmod 0664 /sys/kernel/debug/tracing/trace_clock
+    chmod 0664 /sys/kernel/debug/tracing/buffer_size_kb
+    chmod 0664 /sys/kernel/debug/tracing/options/overwrite
+    chmod 0664 /sys/kernel/debug/tracing/options/print-tgid
+    chmod 0664 /sys/kernel/debug/tracing/events/sched/sched_switch/enable
+    chmod 0664 /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable
+    chmod 0664 /sys/kernel/debug/tracing/events/sched/sched_blocked_reason/enable
+    chmod 0664 /sys/kernel/debug/tracing/events/power/cpu_frequency/enable
+    chmod 0664 /sys/kernel/debug/tracing/events/power/cpu_idle/enable
+    chmod 0664 /sys/kernel/debug/tracing/events/power/clock_set_rate/enable
+    chmod 0664 /sys/kernel/debug/tracing/events/cpufreq_interactive/enable
+    chmod 0664 /sys/kernel/debug/tracing/events/vmscan/mm_vmscan_direct_reclaim_begin/enable
+    chmod 0664 /sys/kernel/debug/tracing/events/vmscan/mm_vmscan_direct_reclaim_end/enable
+    chmod 0664 /sys/kernel/debug/tracing/events/vmscan/mm_vmscan_kswapd_wake/enable
+    chmod 0664 /sys/kernel/debug/tracing/events/vmscan/mm_vmscan_kswapd_sleep/enable
+    chmod 0664 /sys/kernel/debug/tracing/tracing_on
+    chmod 0664 /sys/kernel/debug/tracing/events/binder/binder_transaction/enable
+    chmod 0664 /sys/kernel/debug/tracing/events/binder/binder_transaction_received/enable
+    chmod 0664 /sys/kernel/debug/tracing/events/binder/binder_lock/enable
+    chmod 0664 /sys/kernel/debug/tracing/events/binder/binder_locked/enable
+    chmod 0664 /sys/kernel/debug/tracing/events/binder/binder_unlock/enable
+
+    # Tracing disabled by default
+    write /sys/kernel/debug/tracing/tracing_on 0
+
+# Allow only the shell group to read and truncate the kernel trace.
+    chown root shell /sys/kernel/debug/tracing/trace
+    chmod 0660 /sys/kernel/debug/tracing/trace
+
+on property:persist.debug.atrace.boottrace=1
+    start boottrace
+
+# Run atrace with the categories written in a file
+service boottrace /system/bin/atrace --async_start -f /data/misc/boottrace/categories
+    disabled
+    oneshot
diff --git a/cmds/bugreport/Android.mk b/cmds/bugreport/Android.mk
index f476f5e..ced5d30 100644
--- a/cmds/bugreport/Android.mk
+++ b/cmds/bugreport/Android.mk
@@ -1,10 +1,12 @@
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES:= bugreport.c
+LOCAL_SRC_FILES:= bugreport.cpp
 
 LOCAL_MODULE:= bugreport
 
+LOCAL_CFLAGS := -Wall
+
 LOCAL_SHARED_LIBRARIES := libcutils
 
 include $(BUILD_EXECUTABLE)
diff --git a/cmds/bugreport/bugreport.c b/cmds/bugreport/bugreport.c
deleted file mode 100644
index 4a0b511..0000000
--- a/cmds/bugreport/bugreport.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <cutils/properties.h>
-#include <cutils/sockets.h>
-
-int main(int argc, char *argv[]) {
-    char buffer[65536];
-    int i, s;
-
-    /* start the dumpstate service */
-    property_set("ctl.start", "dumpstate");
-
-    /* socket will not be available until service starts */
-    for (i = 0; i < 10; i++) {
-        s = socket_local_client("dumpstate",
-                             ANDROID_SOCKET_NAMESPACE_RESERVED,
-                             SOCK_STREAM);
-        if (s >= 0)
-            break;
-        /* try again in 1 second */
-        sleep(1);
-    }
-
-    if (s < 0) {
-        fprintf(stderr, "Failed to connect to dumpstate service\n");
-        exit(1);
-    }
-
-    while (1) {
-        int length = read(s, buffer, sizeof(buffer));
-        if (length <= 0)
-            break;
-        fwrite(buffer, 1, length, stdout);
-    }
-
-    close(s);
-    return 0;
-}
diff --git a/cmds/bugreport/bugreport.cpp b/cmds/bugreport/bugreport.cpp
new file mode 100644
index 0000000..6892b57
--- /dev/null
+++ b/cmds/bugreport/bugreport.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <cutils/properties.h>
+#include <cutils/sockets.h>
+
+// This program will trigger the dumpstate service to start a call to
+// dumpstate, then connect to the dumpstate local client to read the
+// output. All of the dumpstate output is written to stdout, including
+// any errors encountered while reading/writing the output.
+int main() {
+  // Start the dumpstate service.
+  property_set("ctl.start", "dumpstate");
+
+  // Socket will not be available until service starts.
+  int s;
+  for (int i = 0; i < 20; i++) {
+    s = socket_local_client("dumpstate", ANDROID_SOCKET_NAMESPACE_RESERVED,
+                            SOCK_STREAM);
+    if (s >= 0)
+      break;
+    // Try again in 1 second.
+    sleep(1);
+  }
+
+  if (s == -1) {
+    printf("Failed to connect to dumpstate service: %s\n", strerror(errno));
+    return 1;
+  }
+
+  // Set a timeout so that if nothing is read in 3 minutes, we'll stop
+  // reading and quit. No timeout in dumpstate is longer than 60 seconds,
+  // so this gives lots of leeway in case of unforeseen time outs.
+  struct timeval tv;
+  tv.tv_sec = 3 * 60;
+  tv.tv_usec = 0;
+  if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) {
+    printf("WARNING: Cannot set socket timeout: %s\n", strerror(errno));
+  }
+
+  while (1) {
+    char buffer[65536];
+    ssize_t bytes_read = TEMP_FAILURE_RETRY(read(s, buffer, sizeof(buffer)));
+    if (bytes_read == 0) {
+      break;
+    } else if (bytes_read == -1) {
+      // EAGAIN really means time out, so change the errno.
+      if (errno == EAGAIN) {
+        errno = ETIMEDOUT;
+      }
+      printf("\nBugreport read terminated abnormally (%s).\n", strerror(errno));
+      break;
+    }
+
+    ssize_t bytes_to_send = bytes_read;
+    ssize_t bytes_written;
+    do {
+      bytes_written = TEMP_FAILURE_RETRY(write(STDOUT_FILENO,
+                                               buffer + bytes_read - bytes_to_send,
+                                               bytes_to_send));
+      if (bytes_written == -1) {
+        printf("Failed to write data to stdout: read %zd, trying to send %zd (%s)\n",
+               bytes_read, bytes_to_send, strerror(errno));
+        return 1;
+      }
+      bytes_to_send -= bytes_written;
+    } while (bytes_written != 0 && bytes_to_send > 0);
+  }
+
+  close(s);
+  return 0;
+}
diff --git a/cmds/dumpstate/Android.mk b/cmds/dumpstate/Android.mk
index 9065ee1..4560415 100644
--- a/cmds/dumpstate/Android.mk
+++ b/cmds/dumpstate/Android.mk
@@ -1,6 +1,6 @@
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
-LOCAL_SRC_FILES := libdumpstate_default.c
+LOCAL_SRC_FILES := libdumpstate_default.cpp
 LOCAL_MODULE := libdumpstate.default
 include $(BUILD_STATIC_LIBRARY)
 
@@ -10,12 +10,13 @@
 LOCAL_CFLAGS := -DFWDUMP_$(BOARD_WLAN_DEVICE)
 endif
 
-LOCAL_SRC_FILES := dumpstate.c utils.c
+LOCAL_SRC_FILES := dumpstate.cpp utils.cpp
 
 LOCAL_MODULE := dumpstate
 
-LOCAL_SHARED_LIBRARIES := libcutils liblog libselinux
+LOCAL_SHARED_LIBRARIES := libcutils liblog libselinux libbase
 LOCAL_HAL_STATIC_LIBRARIES := libdumpstate
-LOCAL_CFLAGS += -Wall -Wno-unused-parameter -std=gnu99
+LOCAL_CFLAGS += -Wall -Werror -Wno-unused-parameter
+LOCAL_INIT_RC := dumpstate.rc
 
 include $(BUILD_EXECUTABLE)
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c
deleted file mode 100644
index 3c79ae9..0000000
--- a/cmds/dumpstate/dumpstate.c
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/resource.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <sys/capability.h>
-#include <linux/prctl.h>
-
-#include <cutils/properties.h>
-
-#include "private/android_filesystem_config.h"
-
-#define LOG_TAG "dumpstate"
-#include <cutils/log.h>
-
-#include "dumpstate.h"
-
-/* read before root is shed */
-static char cmdline_buf[16384] = "(unknown)";
-static const char *dump_traces_path = NULL;
-
-static char screenshot_path[PATH_MAX] = "";
-
-/* dumps the current system state to stdout */
-static void dumpstate() {
-    time_t now = time(NULL);
-    char build[PROPERTY_VALUE_MAX], fingerprint[PROPERTY_VALUE_MAX];
-    char radio[PROPERTY_VALUE_MAX], bootloader[PROPERTY_VALUE_MAX];
-    char network[PROPERTY_VALUE_MAX], date[80];
-    char build_type[PROPERTY_VALUE_MAX];
-
-    property_get("ro.build.display.id", build, "(unknown)");
-    property_get("ro.build.fingerprint", fingerprint, "(unknown)");
-    property_get("ro.build.type", build_type, "(unknown)");
-    property_get("ro.baseband", radio, "(unknown)");
-    property_get("ro.bootloader", bootloader, "(unknown)");
-    property_get("gsm.operator.alpha", network, "(unknown)");
-    strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", localtime(&now));
-
-    printf("========================================================\n");
-    printf("== dumpstate: %s\n", date);
-    printf("========================================================\n");
-
-    printf("\n");
-    printf("Build: %s\n", build);
-    printf("Build fingerprint: '%s'\n", fingerprint); /* format is important for other tools */
-    printf("Bootloader: %s\n", bootloader);
-    printf("Radio: %s\n", radio);
-    printf("Network: %s\n", network);
-
-    printf("Kernel: ");
-    dump_file(NULL, "/proc/version");
-    printf("Command line: %s\n", strtok(cmdline_buf, "\n"));
-    printf("\n");
-
-    run_command("UPTIME", 10, "uptime", NULL);
-    dump_file("MEMORY INFO", "/proc/meminfo");
-    run_command("CPU INFO", 10, "top", "-n", "1", "-d", "1", "-m", "30", "-t", NULL);
-    run_command("PROCRANK", 20, "procrank", NULL);
-    dump_file("VIRTUAL MEMORY STATS", "/proc/vmstat");
-    dump_file("VMALLOC INFO", "/proc/vmallocinfo");
-    dump_file("SLAB INFO", "/proc/slabinfo");
-    dump_file("ZONEINFO", "/proc/zoneinfo");
-    dump_file("PAGETYPEINFO", "/proc/pagetypeinfo");
-    dump_file("BUDDYINFO", "/proc/buddyinfo");
-    dump_file("FRAGMENTATION INFO", "/d/extfrag/unusable_index");
-
-
-    dump_file("KERNEL WAKELOCKS", "/proc/wakelocks");
-    dump_file("KERNEL WAKE SOURCES", "/d/wakeup_sources");
-    dump_file("KERNEL CPUFREQ", "/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state");
-    dump_file("KERNEL SYNC", "/d/sync");
-
-    run_command("PROCESSES", 10, "ps", "-P", NULL);
-    run_command("PROCESSES AND THREADS", 10, "ps", "-t", "-p", "-P", NULL);
-    run_command("PROCESSES (SELINUX LABELS)", 10, "ps", "-Z", NULL);
-    run_command("LIBRANK", 10, "librank", NULL);
-
-    do_dmesg();
-
-    run_command("LIST OF OPEN FILES", 10, SU_PATH, "root", "lsof", NULL);
-
-    if (screenshot_path[0]) {
-        ALOGI("taking screenshot\n");
-        run_command(NULL, 10, "/system/bin/screencap", "-p", screenshot_path, NULL);
-        ALOGI("wrote screenshot: %s\n", screenshot_path);
-    }
-
-    for_each_pid(do_showmap, "SMAPS OF ALL PROCESSES");
-    for_each_tid(show_wchan, "BLOCKED PROCESS WAIT-CHANNELS");
-
-    // dump_file("EVENT LOG TAGS", "/etc/event-log-tags");
-    run_command("SYSTEM LOG", 20, "logcat", "-v", "threadtime", "-d", "*:v", NULL);
-    run_command("EVENT LOG", 20, "logcat", "-b", "events", "-v", "threadtime", "-d", "*:v", NULL);
-    run_command("RADIO LOG", 20, "logcat", "-b", "radio", "-v", "threadtime", "-d", "*:v", NULL);
-
-
-    /* show the traces we collected in main(), if that was done */
-    if (dump_traces_path != NULL) {
-        dump_file("VM TRACES JUST NOW", dump_traces_path);
-    }
-
-    /* only show ANR traces if they're less than 15 minutes old */
-    struct stat st;
-    char anr_traces_path[PATH_MAX];
-    property_get("dalvik.vm.stack-trace-file", anr_traces_path, "");
-    if (!anr_traces_path[0]) {
-        printf("*** NO VM TRACES FILE DEFINED (dalvik.vm.stack-trace-file)\n\n");
-    } else if (stat(anr_traces_path, &st)) {
-        printf("*** NO ANR VM TRACES FILE (%s): %s\n\n", anr_traces_path, strerror(errno));
-    } else {
-        dump_file("VM TRACES AT LAST ANR", anr_traces_path);
-    }
-
-    /* slow traces for slow operations */
-    if (anr_traces_path[0] != 0) {
-        int tail = strlen(anr_traces_path)-1;
-        while (tail > 0 && anr_traces_path[tail] != '/') {
-            tail--;
-        }
-        int i = 0;
-        while (1) {
-            sprintf(anr_traces_path+tail+1, "slow%02d.txt", i);
-            if (stat(anr_traces_path, &st)) {
-                // No traces file at this index, done with the files.
-                break;
-            }
-            dump_file("VM TRACES WHEN SLOW", anr_traces_path);
-            i++;
-        }
-    }
-
-    dump_file("NETWORK DEV INFO", "/proc/net/dev");
-    dump_file("QTAGUID NETWORK INTERFACES INFO", "/proc/net/xt_qtaguid/iface_stat_all");
-    dump_file("QTAGUID NETWORK INTERFACES INFO (xt)", "/proc/net/xt_qtaguid/iface_stat_fmt");
-    dump_file("QTAGUID CTRL INFO", "/proc/net/xt_qtaguid/ctrl");
-    dump_file("QTAGUID STATS INFO", "/proc/net/xt_qtaguid/stats");
-
-    dump_file("NETWORK ROUTES", "/proc/net/route");
-    dump_file("NETWORK ROUTES IPV6", "/proc/net/ipv6_route");
-
-    /* TODO: Make last_kmsg CAP_SYSLOG protected. b/5555691 */
-    dump_file("LAST KMSG", "/proc/last_kmsg");
-    dump_file("LAST PANIC CONSOLE", "/data/dontpanic/apanic_console");
-    dump_file("LAST PANIC THREADS", "/data/dontpanic/apanic_threads");
-
-    run_command("SYSTEM SETTINGS", 20, SU_PATH, "root", "sqlite3",
-            "/data/data/com.android.providers.settings/databases/settings.db",
-            "pragma user_version; select * from system; select * from secure; select * from global;", NULL);
-
-    /* The following have a tendency to get wedged when wifi drivers/fw goes belly-up. */
-    run_command("NETWORK INTERFACES", 10, SU_PATH, "root", "netcfg", NULL);
-    run_command("IP RULES", 10, "ip", "rule", "show", NULL);
-    run_command("IP RULES v6", 10, "ip", "-6", "rule", "show", NULL);
-    run_command("ROUTE TABLE 60", 10, "ip", "route", "show", "table", "60", NULL);
-    run_command("ROUTE TABLE 61 v6", 10, "ip", "-6", "route", "show", "table", "60", NULL);
-    run_command("ROUTE TABLE 61", 10, "ip", "route", "show", "table", "61", NULL);
-    run_command("ROUTE TABLE 61 v6", 10, "ip", "-6", "route", "show", "table", "61", NULL);
-    dump_file("ARP CACHE", "/proc/net/arp");
-    run_command("IPTABLES", 10, SU_PATH, "root", "iptables", "-L", "-nvx", NULL);
-    run_command("IP6TABLES", 10, SU_PATH, "root", "ip6tables", "-L", "-nvx", NULL);
-    run_command("IPTABLE NAT", 10, SU_PATH, "root", "iptables", "-t", "nat", "-L", "-nvx", NULL);
-    /* no ip6 nat */
-    run_command("IPTABLE RAW", 10, SU_PATH, "root", "iptables", "-t", "raw", "-L", "-nvx", NULL);
-    run_command("IP6TABLE RAW", 10, SU_PATH, "root", "ip6tables", "-t", "raw", "-L", "-nvx", NULL);
-
-    run_command("WIFI NETWORKS", 20,
-            SU_PATH, "root", "wpa_cli", "IFNAME=wlan0", "list_networks", NULL);
-
-#ifdef FWDUMP_bcmdhd
-    run_command("DUMP WIFI INTERNAL COUNTERS", 20,
-            SU_PATH, "root", "wlutil", "counters", NULL);
-#endif
-    dump_file("INTERRUPTS (1)", "/proc/interrupts");
-
-    property_get("dhcp.wlan0.gateway", network, "");
-    if (network[0])
-        run_command("PING GATEWAY", 10, "ping", "-c", "3", "-i", ".5", network, NULL);
-    property_get("dhcp.wlan0.dns1", network, "");
-    if (network[0])
-        run_command("PING DNS1", 10, "ping", "-c", "3", "-i", ".5", network, NULL);
-    property_get("dhcp.wlan0.dns2", network, "");
-    if (network[0])
-        run_command("PING DNS2", 10, "ping", "-c", "3", "-i", ".5", network, NULL);
-#ifdef FWDUMP_bcmdhd
-    run_command("DUMP WIFI STATUS", 20,
-            SU_PATH, "root", "dhdutil", "-i", "wlan0", "dump", NULL);
-    run_command("DUMP WIFI INTERNAL COUNTERS", 20,
-            SU_PATH, "root", "wlutil", "counters", NULL);
-#endif
-    dump_file("INTERRUPTS (2)", "/proc/interrupts");
-
-    print_properties();
-
-    run_command("VOLD DUMP", 10, "vdc", "dump", NULL);
-    run_command("SECURE CONTAINERS", 10, "vdc", "asec", "list", NULL);
-
-    run_command("FILESYSTEMS & FREE SPACE", 10, "df", NULL);
-
-    run_command("PACKAGE SETTINGS", 20, SU_PATH, "root", "cat", "/data/system/packages.xml", NULL);
-    dump_file("PACKAGE UID ERRORS", "/data/system/uiderrors.txt");
-
-    run_command("LAST RADIO LOG", 10, "parse_radio_log", "/proc/last_radio_log", NULL);
-
-    printf("------ BACKLIGHTS ------\n");
-    printf("LCD brightness=");
-    dump_file(NULL, "/sys/class/leds/lcd-backlight/brightness");
-    printf("Button brightness=");
-    dump_file(NULL, "/sys/class/leds/button-backlight/brightness");
-    printf("Keyboard brightness=");
-    dump_file(NULL, "/sys/class/leds/keyboard-backlight/brightness");
-    printf("ALS mode=");
-    dump_file(NULL, "/sys/class/leds/lcd-backlight/als");
-    printf("LCD driver registers:\n");
-    dump_file(NULL, "/sys/class/leds/lcd-backlight/registers");
-    printf("\n");
-
-    /* Binder state is expensive to look at as it uses a lot of memory. */
-    dump_file("BINDER FAILED TRANSACTION LOG", "/sys/kernel/debug/binder/failed_transaction_log");
-    dump_file("BINDER TRANSACTION LOG", "/sys/kernel/debug/binder/transaction_log");
-    dump_file("BINDER TRANSACTIONS", "/sys/kernel/debug/binder/transactions");
-    dump_file("BINDER STATS", "/sys/kernel/debug/binder/stats");
-    dump_file("BINDER STATE", "/sys/kernel/debug/binder/state");
-
-    printf("========================================================\n");
-    printf("== Board\n");
-    printf("========================================================\n");
-
-    dumpstate_board();
-    printf("\n");
-
-    /* Migrate the ril_dumpstate to a dumpstate_board()? */
-    char ril_dumpstate_timeout[PROPERTY_VALUE_MAX] = {0};
-    property_get("ril.dumpstate.timeout", ril_dumpstate_timeout, "30");
-    if (strnlen(ril_dumpstate_timeout, PROPERTY_VALUE_MAX - 1) > 0) {
-        if (0 == strncmp(build_type, "user", PROPERTY_VALUE_MAX - 1)) {
-            // su does not exist on user builds, so try running without it.
-            // This way any implementations of vril-dump that do not require
-            // root can run on user builds.
-            run_command("DUMP VENDOR RIL LOGS", atoi(ril_dumpstate_timeout),
-                    "vril-dump", NULL);
-        } else {
-            run_command("DUMP VENDOR RIL LOGS", atoi(ril_dumpstate_timeout),
-                    SU_PATH, "root", "vril-dump", NULL);
-        }
-    }
-
-    printf("========================================================\n");
-    printf("== Android Framework Services\n");
-    printf("========================================================\n");
-
-    /* the full dumpsys is starting to take a long time, so we need
-       to increase its timeout.  we really need to do the timeouts in
-       dumpsys itself... */
-    run_command("DUMPSYS", 60, "dumpsys", NULL);
-
-    printf("========================================================\n");
-    printf("== Checkins\n");
-    printf("========================================================\n");
-
-    run_command("CHECKIN BATTERYSTATS", 30, "dumpsys", "batterystats", "-c", NULL);
-    run_command("CHECKIN MEMINFO", 30, "dumpsys", "meminfo", "--checkin", NULL);
-    run_command("CHECKIN NETSTATS", 30, "dumpsys", "netstats", "--checkin", NULL);
-    run_command("CHECKIN PROCSTATS", 30, "dumpsys", "procstats", "-c", NULL);
-    run_command("CHECKIN USAGESTATS", 30, "dumpsys", "usagestats", "-c", NULL);
-
-    printf("========================================================\n");
-    printf("== Running Application Activities\n");
-    printf("========================================================\n");
-
-    run_command("APP ACTIVITIES", 30, "dumpsys", "activity", "all", NULL);
-
-    printf("========================================================\n");
-    printf("== Running Application Services\n");
-    printf("========================================================\n");
-
-    run_command("APP SERVICES", 30, "dumpsys", "activity", "service", "all", NULL);
-
-    printf("========================================================\n");
-    printf("== Running Application Providers\n");
-    printf("========================================================\n");
-
-    run_command("APP SERVICES", 30, "dumpsys", "activity", "provider", "all", NULL);
-
-
-    printf("========================================================\n");
-    printf("== dumpstate: done\n");
-    printf("========================================================\n");
-}
-
-static void usage() {
-    fprintf(stderr, "usage: dumpstate [-b soundfile] [-e soundfile] [-o file [-d] [-p] [-z]] [-s] [-q]\n"
-            "  -o: write to file (instead of stdout)\n"
-            "  -d: append date to filename (requires -o)\n"
-            "  -z: gzip output (requires -o)\n"
-            "  -p: capture screenshot to filename.png (requires -o)\n"
-            "  -s: write output to control socket (for init)\n"
-            "  -b: play sound file instead of vibrate, at beginning of job\n"
-            "  -e: play sound file instead of vibrate, at end of job\n"
-            "  -q: disable vibrate\n"
-            "  -B: send broadcast when finished (requires -o and -p)\n"
-		);
-}
-
-static void sigpipe_handler(int n) {
-    (void)n;
-    exit(EXIT_FAILURE);
-}
-
-int main(int argc, char *argv[]) {
-    struct sigaction sigact;
-    int do_add_date = 0;
-    int do_compress = 0;
-    int do_vibrate = 1;
-    char* use_outfile = 0;
-    char* begin_sound = 0;
-    char* end_sound = 0;
-    int use_socket = 0;
-    int do_fb = 0;
-    int do_broadcast = 0;
-
-    if (getuid() != 0) {
-        // Old versions of the adb client would call the
-        // dumpstate command directly. Newer clients
-        // call /system/bin/bugreport instead. If we detect
-        // we're being called incorrectly, then exec the
-        // correct program.
-        return execl("/system/bin/bugreport", "/system/bin/bugreport", NULL);
-    }
-    ALOGI("begin\n");
-
-    memset(&sigact, 0, sizeof(sigact));
-    sigact.sa_handler = sigpipe_handler;
-    sigaction(SIGPIPE, &sigact, NULL);
-
-    /* set as high priority, and protect from OOM killer */
-    setpriority(PRIO_PROCESS, 0, -20);
-    FILE *oom_adj = fopen("/proc/self/oom_adj", "w");
-    if (oom_adj) {
-        fputs("-17", oom_adj);
-        fclose(oom_adj);
-    }
-
-    /* very first thing, collect stack traces from Dalvik and native processes (needs root) */
-    dump_traces_path = dump_traces();
-
-    int c;
-    while ((c = getopt(argc, argv, "b:de:ho:svqzpB")) != -1) {
-        switch (c) {
-            case 'b': begin_sound = optarg;  break;
-            case 'd': do_add_date = 1;       break;
-            case 'e': end_sound = optarg;    break;
-            case 'o': use_outfile = optarg;  break;
-            case 's': use_socket = 1;        break;
-            case 'v': break;  // compatibility no-op
-            case 'q': do_vibrate = 0;        break;
-            case 'z': do_compress = 6;       break;
-            case 'p': do_fb = 1;             break;
-            case 'B': do_broadcast = 1;      break;
-            case '?': printf("\n");
-            case 'h':
-                usage();
-                exit(1);
-        }
-    }
-
-    FILE *vibrator = 0;
-    if (do_vibrate) {
-        /* open the vibrator before dropping root */
-        vibrator = fopen("/sys/class/timed_output/vibrator/enable", "w");
-        if (vibrator) fcntl(fileno(vibrator), F_SETFD, FD_CLOEXEC);
-    }
-
-    /* read /proc/cmdline before dropping root */
-    FILE *cmdline = fopen("/proc/cmdline", "r");
-    if (cmdline != NULL) {
-        fgets(cmdline_buf, sizeof(cmdline_buf), cmdline);
-        fclose(cmdline);
-    }
-
-    if (prctl(PR_SET_KEEPCAPS, 1) < 0) {
-        ALOGE("prctl(PR_SET_KEEPCAPS) failed: %s\n", strerror(errno));
-        return -1;
-    }
-
-    /* switch to non-root user and group */
-    gid_t groups[] = { AID_LOG, AID_SDCARD_R, AID_SDCARD_RW,
-            AID_MOUNT, AID_INET, AID_NET_BW_STATS };
-    if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) {
-        ALOGE("Unable to setgroups, aborting: %s\n", strerror(errno));
-        return -1;
-    }
-    if (setgid(AID_SHELL) != 0) {
-        ALOGE("Unable to setgid, aborting: %s\n", strerror(errno));
-        return -1;
-    }
-    if (setuid(AID_SHELL) != 0) {
-        ALOGE("Unable to setuid, aborting: %s\n", strerror(errno));
-        return -1;
-    }
-
-    struct __user_cap_header_struct capheader;
-    struct __user_cap_data_struct capdata[2];
-    memset(&capheader, 0, sizeof(capheader));
-    memset(&capdata, 0, sizeof(capdata));
-    capheader.version = _LINUX_CAPABILITY_VERSION_3;
-    capheader.pid = 0;
-
-    capdata[CAP_TO_INDEX(CAP_SYSLOG)].permitted = CAP_TO_MASK(CAP_SYSLOG);
-    capdata[CAP_TO_INDEX(CAP_SYSLOG)].effective = CAP_TO_MASK(CAP_SYSLOG);
-    capdata[0].inheritable = 0;
-    capdata[1].inheritable = 0;
-
-    if (capset(&capheader, &capdata[0]) < 0) {
-        ALOGE("capset failed: %s\n", strerror(errno));
-        return -1;
-    }
-
-    char path[PATH_MAX], tmp_path[PATH_MAX];
-    pid_t gzip_pid = -1;
-
-    if (use_socket) {
-        redirect_to_socket(stdout, "dumpstate");
-    } else if (use_outfile) {
-        strlcpy(path, use_outfile, sizeof(path));
-        if (do_add_date) {
-            char date[80];
-            time_t now = time(NULL);
-            strftime(date, sizeof(date), "-%Y-%m-%d-%H-%M-%S", localtime(&now));
-            strlcat(path, date, sizeof(path));
-        }
-        if (do_fb) {
-            strlcpy(screenshot_path, path, sizeof(screenshot_path));
-            strlcat(screenshot_path, ".png", sizeof(screenshot_path));
-        }
-        strlcat(path, ".txt", sizeof(path));
-        if (do_compress) strlcat(path, ".gz", sizeof(path));
-        strlcpy(tmp_path, path, sizeof(tmp_path));
-        strlcat(tmp_path, ".tmp", sizeof(tmp_path));
-        gzip_pid = redirect_to_file(stdout, tmp_path, do_compress);
-    }
-
-    if (begin_sound) {
-        play_sound(begin_sound);
-    } else if (vibrator) {
-        fputs("150", vibrator);
-        fflush(vibrator);
-    }
-
-    dumpstate();
-
-    if (end_sound) {
-        play_sound(end_sound);
-    } else if (vibrator) {
-        int i;
-        for (i = 0; i < 3; i++) {
-            fputs("75\n", vibrator);
-            fflush(vibrator);
-            usleep((75 + 50) * 1000);
-        }
-        fclose(vibrator);
-    }
-
-    /* wait for gzip to finish, otherwise it might get killed when we exit */
-    if (gzip_pid > 0) {
-        fclose(stdout);
-        waitpid(gzip_pid, NULL, 0);
-    }
-
-    /* rename the (now complete) .tmp file to its final location */
-    if (use_outfile && rename(tmp_path, path)) {
-        fprintf(stderr, "rename(%s, %s): %s\n", tmp_path, path, strerror(errno));
-    }
-
-    if (do_broadcast && use_outfile && do_fb) {
-        run_command(NULL, 5, "/system/bin/am", "broadcast", "--user", "0",
-                "-a", "android.intent.action.BUGREPORT_FINISHED",
-                "--es", "android.intent.extra.BUGREPORT", path,
-                "--es", "android.intent.extra.SCREENSHOT", screenshot_path,
-                "--receiver-permission", "android.permission.DUMP", NULL);
-    }
-
-    ALOGI("done\n");
-
-    return 0;
-}
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
new file mode 100644
index 0000000..afb1255
--- /dev/null
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -0,0 +1,905 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/capability.h>
+#include <sys/prctl.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#include <cutils/properties.h>
+
+#include "private/android_filesystem_config.h"
+
+#define LOG_TAG "dumpstate"
+#include <cutils/log.h>
+
+#include "dumpstate.h"
+
+/* read before root is shed */
+static char cmdline_buf[16384] = "(unknown)";
+static const char *dump_traces_path = NULL;
+
+static char screenshot_path[PATH_MAX] = "";
+
+#define PSTORE_LAST_KMSG "/sys/fs/pstore/console-ramoops"
+#define ALT_PSTORE_LAST_KMSG "/sys/fs/pstore/console-ramoops-0"
+
+#define RAFT_DIR "/data/misc/raft/"
+#define TOMBSTONE_DIR "/data/tombstones"
+#define TOMBSTONE_FILE_PREFIX TOMBSTONE_DIR "/tombstone_"
+/* Can accomodate a tombstone number up to 9999. */
+#define TOMBSTONE_MAX_LEN (sizeof(TOMBSTONE_FILE_PREFIX) + 4)
+#define NUM_TOMBSTONES  10
+
+typedef struct {
+  char name[TOMBSTONE_MAX_LEN];
+  int fd;
+} tombstone_data_t;
+
+static tombstone_data_t tombstone_data[NUM_TOMBSTONES];
+
+/* Get the fds of any tombstone that was modified in the last half an hour. */
+static void get_tombstone_fds(tombstone_data_t data[NUM_TOMBSTONES]) {
+    time_t thirty_minutes_ago = time(NULL) - 60*30;
+    for (size_t i = 0; i < NUM_TOMBSTONES; i++) {
+        snprintf(data[i].name, sizeof(data[i].name), "%s%02zu", TOMBSTONE_FILE_PREFIX, i);
+        int fd = TEMP_FAILURE_RETRY(open(data[i].name,
+                                         O_RDONLY | O_CLOEXEC | O_NOFOLLOW | O_NONBLOCK));
+        struct stat st;
+        if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode) &&
+                (time_t) st.st_mtime >= thirty_minutes_ago) {
+            data[i].fd = fd;
+        } else {
+            close(fd);
+            data[i].fd = -1;
+        }
+    }
+}
+
+static void dump_dev_files(const char *title, const char *driverpath, const char *filename)
+{
+    DIR *d;
+    struct dirent *de;
+    char path[PATH_MAX];
+
+    d = opendir(driverpath);
+    if (d == NULL) {
+        return;
+    }
+
+    while ((de = readdir(d))) {
+        if (de->d_type != DT_LNK) {
+            continue;
+        }
+        snprintf(path, sizeof(path), "%s/%s/%s", driverpath, de->d_name, filename);
+        dump_file(title, path);
+    }
+
+    closedir(d);
+}
+
+static bool skip_not_stat(const char *path) {
+    static const char stat[] = "/stat";
+    size_t len = strlen(path);
+    if (path[len - 1] == '/') { /* Directory? */
+        return false;
+    }
+    return strcmp(path + len - sizeof(stat) + 1, stat); /* .../stat? */
+}
+
+static const char mmcblk0[] = "/sys/block/mmcblk0/";
+unsigned long worst_write_perf = 20000; /* in KB/s */
+
+//
+//  stat offsets
+// Name            units         description
+// ----            -----         -----------
+// read I/Os       requests      number of read I/Os processed
+#define __STAT_READ_IOS      0
+// read merges     requests      number of read I/Os merged with in-queue I/O
+#define __STAT_READ_MERGES   1
+// read sectors    sectors       number of sectors read
+#define __STAT_READ_SECTORS  2
+// read ticks      milliseconds  total wait time for read requests
+#define __STAT_READ_TICKS    3
+// write I/Os      requests      number of write I/Os processed
+#define __STAT_WRITE_IOS     4
+// write merges    requests      number of write I/Os merged with in-queue I/O
+#define __STAT_WRITE_MERGES  5
+// write sectors   sectors       number of sectors written
+#define __STAT_WRITE_SECTORS 6
+// write ticks     milliseconds  total wait time for write requests
+#define __STAT_WRITE_TICKS   7
+// in_flight       requests      number of I/Os currently in flight
+#define __STAT_IN_FLIGHT     8
+// io_ticks        milliseconds  total time this block device has been active
+#define __STAT_IO_TICKS      9
+// time_in_queue   milliseconds  total wait time for all requests
+#define __STAT_IN_QUEUE     10
+#define __STAT_NUMBER_FIELD 11
+//
+// read I/Os, write I/Os
+// =====================
+//
+// These values increment when an I/O request completes.
+//
+// read merges, write merges
+// =========================
+//
+// These values increment when an I/O request is merged with an
+// already-queued I/O request.
+//
+// read sectors, write sectors
+// ===========================
+//
+// These values count the number of sectors read from or written to this
+// block device.  The "sectors" in question are the standard UNIX 512-byte
+// sectors, not any device- or filesystem-specific block size.  The
+// counters are incremented when the I/O completes.
+#define SECTOR_SIZE 512
+//
+// read ticks, write ticks
+// =======================
+//
+// These values count the number of milliseconds that I/O requests have
+// waited on this block device.  If there are multiple I/O requests waiting,
+// these values will increase at a rate greater than 1000/second; for
+// example, if 60 read requests wait for an average of 30 ms, the read_ticks
+// field will increase by 60*30 = 1800.
+//
+// in_flight
+// =========
+//
+// This value counts the number of I/O requests that have been issued to
+// the device driver but have not yet completed.  It does not include I/O
+// requests that are in the queue but not yet issued to the device driver.
+//
+// io_ticks
+// ========
+//
+// This value counts the number of milliseconds during which the device has
+// had I/O requests queued.
+//
+// time_in_queue
+// =============
+//
+// This value counts the number of milliseconds that I/O requests have waited
+// on this block device.  If there are multiple I/O requests waiting, this
+// value will increase as the product of the number of milliseconds times the
+// number of requests waiting (see "read ticks" above for an example).
+#define S_TO_MS 1000
+//
+
+static int dump_stat_from_fd(const char *title __unused, const char *path, int fd) {
+    unsigned long long fields[__STAT_NUMBER_FIELD];
+    bool z;
+    char *cp, *buffer = NULL;
+    size_t i = 0;
+    FILE *fp = fdopen(fd, "rb");
+    getline(&buffer, &i, fp);
+    fclose(fp);
+    if (!buffer) {
+        return -errno;
+    }
+    i = strlen(buffer);
+    while ((i > 0) && (buffer[i - 1] == '\n')) {
+        buffer[--i] = '\0';
+    }
+    if (!*buffer) {
+        free(buffer);
+        return 0;
+    }
+    z = true;
+    for (cp = buffer, i = 0; i < (sizeof(fields) / sizeof(fields[0])); ++i) {
+        fields[i] = strtoull(cp, &cp, 10);
+        if (fields[i] != 0) {
+            z = false;
+        }
+    }
+    if (z) { /* never accessed */
+        free(buffer);
+        return 0;
+    }
+
+    if (!strncmp(path, mmcblk0, sizeof(mmcblk0) - 1)) {
+        path += sizeof(mmcblk0) - 1;
+    }
+
+    printf("%s: %s\n", path, buffer);
+    free(buffer);
+
+    if (fields[__STAT_IO_TICKS]) {
+        unsigned long read_perf = 0;
+        unsigned long read_ios = 0;
+        if (fields[__STAT_READ_TICKS]) {
+            unsigned long long divisor = fields[__STAT_READ_TICKS]
+                                       * fields[__STAT_IO_TICKS];
+            read_perf = ((unsigned long long)SECTOR_SIZE
+                           * fields[__STAT_READ_SECTORS]
+                           * fields[__STAT_IN_QUEUE] + (divisor >> 1))
+                                        / divisor;
+            read_ios = ((unsigned long long)S_TO_MS * fields[__STAT_READ_IOS]
+                           * fields[__STAT_IN_QUEUE] + (divisor >> 1))
+                                        / divisor;
+        }
+
+        unsigned long write_perf = 0;
+        unsigned long write_ios = 0;
+        if (fields[__STAT_WRITE_TICKS]) {
+            unsigned long long divisor = fields[__STAT_WRITE_TICKS]
+                                       * fields[__STAT_IO_TICKS];
+            write_perf = ((unsigned long long)SECTOR_SIZE
+                           * fields[__STAT_WRITE_SECTORS]
+                           * fields[__STAT_IN_QUEUE] + (divisor >> 1))
+                                        / divisor;
+            write_ios = ((unsigned long long)S_TO_MS * fields[__STAT_WRITE_IOS]
+                           * fields[__STAT_IN_QUEUE] + (divisor >> 1))
+                                        / divisor;
+        }
+
+        unsigned queue = (fields[__STAT_IN_QUEUE]
+                             + (fields[__STAT_IO_TICKS] >> 1))
+                                 / fields[__STAT_IO_TICKS];
+
+        if (!write_perf && !write_ios) {
+            printf("%s: perf(ios) rd: %luKB/s(%lu/s) q: %u\n",
+                   path, read_perf, read_ios, queue);
+        } else {
+            printf("%s: perf(ios) rd: %luKB/s(%lu/s) wr: %luKB/s(%lu/s) q: %u\n",
+                   path, read_perf, read_ios, write_perf, write_ios, queue);
+        }
+
+        /* bugreport timeout factor adjustment */
+        if ((write_perf > 1) && (write_perf < worst_write_perf)) {
+            worst_write_perf = write_perf;
+        }
+    }
+    return 0;
+}
+
+/* Copied policy from system/core/logd/LogBuffer.cpp */
+
+#define LOG_BUFFER_SIZE (256 * 1024)
+#define LOG_BUFFER_MIN_SIZE (64 * 1024UL)
+#define LOG_BUFFER_MAX_SIZE (256 * 1024 * 1024UL)
+
+static bool valid_size(unsigned long value) {
+    if ((value < LOG_BUFFER_MIN_SIZE) || (LOG_BUFFER_MAX_SIZE < value)) {
+        return false;
+    }
+
+    long pages = sysconf(_SC_PHYS_PAGES);
+    if (pages < 1) {
+        return true;
+    }
+
+    long pagesize = sysconf(_SC_PAGESIZE);
+    if (pagesize <= 1) {
+        pagesize = PAGE_SIZE;
+    }
+
+    // maximum memory impact a somewhat arbitrary ~3%
+    pages = (pages + 31) / 32;
+    unsigned long maximum = pages * pagesize;
+
+    if ((maximum < LOG_BUFFER_MIN_SIZE) || (LOG_BUFFER_MAX_SIZE < maximum)) {
+        return true;
+    }
+
+    return value <= maximum;
+}
+
+static unsigned long property_get_size(const char *key) {
+    unsigned long value;
+    char *cp, property[PROPERTY_VALUE_MAX];
+
+    property_get(key, property, "");
+    value = strtoul(property, &cp, 10);
+
+    switch(*cp) {
+    case 'm':
+    case 'M':
+        value *= 1024;
+    /* FALLTHRU */
+    case 'k':
+    case 'K':
+        value *= 1024;
+    /* FALLTHRU */
+    case '\0':
+        break;
+
+    default:
+        value = 0;
+    }
+
+    if (!valid_size(value)) {
+        value = 0;
+    }
+
+    return value;
+}
+
+/* timeout in ms */
+static unsigned long logcat_timeout(const char *name) {
+    static const char global_tuneable[] = "persist.logd.size"; // Settings App
+    static const char global_default[] = "ro.logd.size";       // BoardConfig.mk
+    char key[PROP_NAME_MAX];
+    unsigned long property_size, default_size;
+
+    default_size = property_get_size(global_tuneable);
+    if (!default_size) {
+        default_size = property_get_size(global_default);
+    }
+
+    snprintf(key, sizeof(key), "%s.%s", global_tuneable, name);
+    property_size = property_get_size(key);
+
+    if (!property_size) {
+        snprintf(key, sizeof(key), "%s.%s", global_default, name);
+        property_size = property_get_size(key);
+    }
+
+    if (!property_size) {
+        property_size = default_size;
+    }
+
+    if (!property_size) {
+        property_size = LOG_BUFFER_SIZE;
+    }
+
+    /* Engineering margin is ten-fold our guess */
+    return 10 * (property_size + worst_write_perf) / worst_write_perf;
+}
+
+/* End copy from system/core/logd/LogBuffer.cpp */
+
+/* dumps the current system state to stdout */
+static void dumpstate() {
+    unsigned long timeout;
+    time_t now = time(NULL);
+    char build[PROPERTY_VALUE_MAX], fingerprint[PROPERTY_VALUE_MAX];
+    char radio[PROPERTY_VALUE_MAX], bootloader[PROPERTY_VALUE_MAX];
+    char network[PROPERTY_VALUE_MAX], date[80];
+    char build_type[PROPERTY_VALUE_MAX];
+
+    property_get("ro.build.display.id", build, "(unknown)");
+    property_get("ro.build.fingerprint", fingerprint, "(unknown)");
+    property_get("ro.build.type", build_type, "(unknown)");
+    property_get("ro.baseband", radio, "(unknown)");
+    property_get("ro.bootloader", bootloader, "(unknown)");
+    property_get("gsm.operator.alpha", network, "(unknown)");
+    strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", localtime(&now));
+
+    printf("========================================================\n");
+    printf("== dumpstate: %s\n", date);
+    printf("========================================================\n");
+
+    printf("\n");
+    printf("Build: %s\n", build);
+    printf("Build fingerprint: '%s'\n", fingerprint); /* format is important for other tools */
+    printf("Bootloader: %s\n", bootloader);
+    printf("Radio: %s\n", radio);
+    printf("Network: %s\n", network);
+
+    printf("Kernel: ");
+    dump_file(NULL, "/proc/version");
+    printf("Command line: %s\n", strtok(cmdline_buf, "\n"));
+    printf("\n");
+
+    dump_dev_files("TRUSTY VERSION", "/sys/bus/platform/drivers/trusty", "trusty_version");
+    run_command("UPTIME", 10, "uptime", NULL);
+    dump_files("UPTIME MMC PERF", mmcblk0, skip_not_stat, dump_stat_from_fd);
+    dump_emmc_ecsd("/d/mmc0/mmc0:0001/ext_csd");
+    dump_file("MEMORY INFO", "/proc/meminfo");
+    run_command("CPU INFO", 10, "top", "-b", "-n", "1", "-H", "-s", "6",
+                "-o", "pid,tid,user,pr,ni,%cpu,s,virt,res,pcy,cmd,name", NULL);
+    run_command("PROCRANK", 20, SU_PATH, "root", "procrank", NULL);
+    dump_file("VIRTUAL MEMORY STATS", "/proc/vmstat");
+    dump_file("VMALLOC INFO", "/proc/vmallocinfo");
+    dump_file("SLAB INFO", "/proc/slabinfo");
+    dump_file("ZONEINFO", "/proc/zoneinfo");
+    dump_file("PAGETYPEINFO", "/proc/pagetypeinfo");
+    dump_file("BUDDYINFO", "/proc/buddyinfo");
+    dump_file("FRAGMENTATION INFO", "/d/extfrag/unusable_index");
+
+    dump_file("KERNEL WAKELOCKS", "/proc/wakelocks");
+    dump_file("KERNEL WAKE SOURCES", "/d/wakeup_sources");
+    dump_file("KERNEL CPUFREQ", "/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state");
+    dump_file("KERNEL SYNC", "/d/sync");
+
+    run_command("PROCESSES AND THREADS", 10, "ps", "-A", "-T", "-Z",
+                "-O", "pri,nice,rtprio,sched,pcy", NULL);
+    run_command("LIBRANK", 10, "librank", NULL);
+
+    do_dmesg();
+
+    run_command("LIST OF OPEN FILES", 10, SU_PATH, "root", "lsof", NULL);
+    for_each_pid(do_showmap, "SMAPS OF ALL PROCESSES");
+    for_each_tid(show_wchan, "BLOCKED PROCESS WAIT-CHANNELS");
+    for_each_pid(show_showtime, "PROCESS TIMES (pid cmd user system iowait+percentage)");
+
+    if (screenshot_path[0]) {
+        ALOGI("taking screenshot\n");
+        run_command(NULL, 10, "/system/bin/screencap", "-p", screenshot_path, NULL);
+        ALOGI("wrote screenshot: %s\n", screenshot_path);
+    }
+
+    // dump_file("EVENT LOG TAGS", "/etc/event-log-tags");
+    // calculate timeout
+    timeout = logcat_timeout("main") + logcat_timeout("system") + logcat_timeout("crash");
+    if (timeout < 20000) {
+        timeout = 20000;
+    }
+    run_command("SYSTEM LOG", timeout / 1000, "logcat", "-v", "threadtime",
+                                                        "-v", "printable",
+                                                        "-d",
+                                                        "*:v", NULL);
+    timeout = logcat_timeout("events");
+    if (timeout < 20000) {
+        timeout = 20000;
+    }
+    run_command("EVENT LOG", timeout / 1000, "logcat", "-b", "events",
+                                                       "-v", "threadtime",
+                                                       "-v", "printable",
+                                                       "-d",
+                                                       "*:v", NULL);
+    timeout = logcat_timeout("radio");
+    if (timeout < 20000) {
+        timeout = 20000;
+    }
+    run_command("RADIO LOG", timeout / 1000, "logcat", "-b", "radio",
+                                                       "-v", "threadtime",
+                                                       "-v", "printable",
+                                                       "-d",
+                                                       "*:v", NULL);
+
+    run_command("LOG STATISTICS", 10, "logcat", "-b", "all", "-S", NULL);
+
+    run_command("RAFT LOGS", 600, SU_PATH, "root", "logcompressor", "-r", RAFT_DIR, NULL);
+
+    /* show the traces we collected in main(), if that was done */
+    if (dump_traces_path != NULL) {
+        dump_file("VM TRACES JUST NOW", dump_traces_path);
+    }
+
+    /* only show ANR traces if they're less than 15 minutes old */
+    struct stat st;
+    char anr_traces_path[PATH_MAX];
+    property_get("dalvik.vm.stack-trace-file", anr_traces_path, "");
+    if (!anr_traces_path[0]) {
+        printf("*** NO VM TRACES FILE DEFINED (dalvik.vm.stack-trace-file)\n\n");
+    } else {
+      int fd = TEMP_FAILURE_RETRY(open(anr_traces_path,
+                                       O_RDONLY | O_CLOEXEC | O_NOFOLLOW | O_NONBLOCK));
+      if (fd < 0) {
+          printf("*** NO ANR VM TRACES FILE (%s): %s\n\n", anr_traces_path, strerror(errno));
+      } else {
+          dump_file_from_fd("VM TRACES AT LAST ANR", anr_traces_path, fd);
+      }
+    }
+
+    /* slow traces for slow operations */
+    if (anr_traces_path[0] != 0) {
+        int tail = strlen(anr_traces_path)-1;
+        while (tail > 0 && anr_traces_path[tail] != '/') {
+            tail--;
+        }
+        int i = 0;
+        while (1) {
+            sprintf(anr_traces_path+tail+1, "slow%02d.txt", i);
+            if (stat(anr_traces_path, &st)) {
+                // No traces file at this index, done with the files.
+                break;
+            }
+            dump_file("VM TRACES WHEN SLOW", anr_traces_path);
+            i++;
+        }
+    }
+
+    int dumped = 0;
+    for (size_t i = 0; i < NUM_TOMBSTONES; i++) {
+        if (tombstone_data[i].fd != -1) {
+            dumped = 1;
+            dump_file_from_fd("TOMBSTONE", tombstone_data[i].name, tombstone_data[i].fd);
+            tombstone_data[i].fd = -1;
+        }
+    }
+    if (!dumped) {
+        printf("*** NO TOMBSTONES to dump in %s\n\n", TOMBSTONE_DIR);
+    }
+
+    dump_file("NETWORK DEV INFO", "/proc/net/dev");
+    dump_file("QTAGUID NETWORK INTERFACES INFO", "/proc/net/xt_qtaguid/iface_stat_all");
+    dump_file("QTAGUID NETWORK INTERFACES INFO (xt)", "/proc/net/xt_qtaguid/iface_stat_fmt");
+    dump_file("QTAGUID CTRL INFO", "/proc/net/xt_qtaguid/ctrl");
+    dump_file("QTAGUID STATS INFO", "/proc/net/xt_qtaguid/stats");
+
+    if (!stat(PSTORE_LAST_KMSG, &st)) {
+        /* Also TODO: Make console-ramoops CAP_SYSLOG protected. */
+        dump_file("LAST KMSG", PSTORE_LAST_KMSG);
+    } else if (!stat(ALT_PSTORE_LAST_KMSG, &st)) {
+        dump_file("LAST KMSG", ALT_PSTORE_LAST_KMSG);
+    } else {
+        /* TODO: Make last_kmsg CAP_SYSLOG protected. b/5555691 */
+        dump_file("LAST KMSG", "/proc/last_kmsg");
+    }
+
+    /* kernels must set CONFIG_PSTORE_PMSG, slice up pstore with device tree */
+    run_command("LAST LOGCAT", 10, "logcat", "-L",
+                                             "-b", "all",
+                                             "-v", "threadtime",
+                                             "-v", "printable",
+                                             "-d",
+                                             "*:v", NULL);
+
+    /* The following have a tendency to get wedged when wifi drivers/fw goes belly-up. */
+
+    run_command("NETWORK INTERFACES", 10, "ip", "link", NULL);
+
+    run_command("IPv4 ADDRESSES", 10, "ip", "-4", "addr", "show", NULL);
+    run_command("IPv6 ADDRESSES", 10, "ip", "-6", "addr", "show", NULL);
+
+    run_command("IP RULES", 10, "ip", "rule", "show", NULL);
+    run_command("IP RULES v6", 10, "ip", "-6", "rule", "show", NULL);
+
+    dump_route_tables();
+
+    run_command("ARP CACHE", 10, "ip", "-4", "neigh", "show", NULL);
+    run_command("IPv6 ND CACHE", 10, "ip", "-6", "neigh", "show", NULL);
+
+    run_command("IPTABLES", 10, SU_PATH, "root", "iptables", "-L", "-nvx", NULL);
+    run_command("IP6TABLES", 10, SU_PATH, "root", "ip6tables", "-L", "-nvx", NULL);
+    run_command("IPTABLE NAT", 10, SU_PATH, "root", "iptables", "-t", "nat", "-L", "-nvx", NULL);
+    /* no ip6 nat */
+    run_command("IPTABLE RAW", 10, SU_PATH, "root", "iptables", "-t", "raw", "-L", "-nvx", NULL);
+    run_command("IP6TABLE RAW", 10, SU_PATH, "root", "ip6tables", "-t", "raw", "-L", "-nvx", NULL);
+
+    run_command("WIFI NETWORKS", 20,
+            SU_PATH, "root", "wpa_cli", "IFNAME=wlan0", "list_networks", NULL);
+
+#ifdef FWDUMP_bcmdhd
+    run_command("ND OFFLOAD TABLE", 5,
+            SU_PATH, "root", "wlutil", "nd_hostip", NULL);
+
+    run_command("DUMP WIFI INTERNAL COUNTERS (1)", 20,
+            SU_PATH, "root", "wlutil", "counters", NULL);
+
+    run_command("ND OFFLOAD STATUS (1)", 5,
+            SU_PATH, "root", "wlutil", "nd_status", NULL);
+
+#endif
+    dump_file("INTERRUPTS (1)", "/proc/interrupts");
+
+    run_command("NETWORK DIAGNOSTICS", 10, "dumpsys", "connectivity", "--diag", NULL);
+
+#ifdef FWDUMP_bcmdhd
+    run_command("DUMP WIFI STATUS", 20,
+            SU_PATH, "root", "dhdutil", "-i", "wlan0", "dump", NULL);
+
+    run_command("DUMP WIFI INTERNAL COUNTERS (2)", 20,
+            SU_PATH, "root", "wlutil", "counters", NULL);
+
+    run_command("ND OFFLOAD STATUS (2)", 5,
+            SU_PATH, "root", "wlutil", "nd_status", NULL);
+#endif
+    dump_file("INTERRUPTS (2)", "/proc/interrupts");
+
+    print_properties();
+
+    run_command("VOLD DUMP", 10, "vdc", "dump", NULL);
+    run_command("SECURE CONTAINERS", 10, "vdc", "asec", "list", NULL);
+
+    run_command("FILESYSTEMS & FREE SPACE", 10, "df", NULL);
+
+    run_command("LAST RADIO LOG", 10, "parse_radio_log", "/proc/last_radio_log", NULL);
+
+    printf("------ BACKLIGHTS ------\n");
+    printf("LCD brightness=");
+    dump_file(NULL, "/sys/class/leds/lcd-backlight/brightness");
+    printf("Button brightness=");
+    dump_file(NULL, "/sys/class/leds/button-backlight/brightness");
+    printf("Keyboard brightness=");
+    dump_file(NULL, "/sys/class/leds/keyboard-backlight/brightness");
+    printf("ALS mode=");
+    dump_file(NULL, "/sys/class/leds/lcd-backlight/als");
+    printf("LCD driver registers:\n");
+    dump_file(NULL, "/sys/class/leds/lcd-backlight/registers");
+    printf("\n");
+
+    /* Binder state is expensive to look at as it uses a lot of memory. */
+    dump_file("BINDER FAILED TRANSACTION LOG", "/sys/kernel/debug/binder/failed_transaction_log");
+    dump_file("BINDER TRANSACTION LOG", "/sys/kernel/debug/binder/transaction_log");
+    dump_file("BINDER TRANSACTIONS", "/sys/kernel/debug/binder/transactions");
+    dump_file("BINDER STATS", "/sys/kernel/debug/binder/stats");
+    dump_file("BINDER STATE", "/sys/kernel/debug/binder/state");
+
+    printf("========================================================\n");
+    printf("== Board\n");
+    printf("========================================================\n");
+
+    dumpstate_board();
+    printf("\n");
+
+    /* Migrate the ril_dumpstate to a dumpstate_board()? */
+    char ril_dumpstate_timeout[PROPERTY_VALUE_MAX] = {0};
+    property_get("ril.dumpstate.timeout", ril_dumpstate_timeout, "30");
+    if (strnlen(ril_dumpstate_timeout, PROPERTY_VALUE_MAX - 1) > 0) {
+        if (0 == strncmp(build_type, "user", PROPERTY_VALUE_MAX - 1)) {
+            // su does not exist on user builds, so try running without it.
+            // This way any implementations of vril-dump that do not require
+            // root can run on user builds.
+            run_command("DUMP VENDOR RIL LOGS", atoi(ril_dumpstate_timeout),
+                    "vril-dump", NULL);
+        } else {
+            run_command("DUMP VENDOR RIL LOGS", atoi(ril_dumpstate_timeout),
+                    SU_PATH, "root", "vril-dump", NULL);
+        }
+    }
+
+    printf("========================================================\n");
+    printf("== Android Framework Services\n");
+    printf("========================================================\n");
+
+    /* the full dumpsys is starting to take a long time, so we need
+       to increase its timeout.  we really need to do the timeouts in
+       dumpsys itself... */
+    run_command("DUMPSYS", 60, "dumpsys", NULL);
+
+    printf("========================================================\n");
+    printf("== Checkins\n");
+    printf("========================================================\n");
+
+    run_command("CHECKIN BATTERYSTATS", 30, "dumpsys", "batterystats", "-c", NULL);
+    run_command("CHECKIN MEMINFO", 30, "dumpsys", "meminfo", "--checkin", NULL);
+    run_command("CHECKIN NETSTATS", 30, "dumpsys", "netstats", "--checkin", NULL);
+    run_command("CHECKIN PROCSTATS", 30, "dumpsys", "procstats", "-c", NULL);
+    run_command("CHECKIN USAGESTATS", 30, "dumpsys", "usagestats", "-c", NULL);
+    run_command("CHECKIN PACKAGE", 30, "dumpsys", "package", "--checkin", NULL);
+
+    printf("========================================================\n");
+    printf("== Running Application Activities\n");
+    printf("========================================================\n");
+
+    run_command("APP ACTIVITIES", 30, "dumpsys", "activity", "all", NULL);
+
+    printf("========================================================\n");
+    printf("== Running Application Services\n");
+    printf("========================================================\n");
+
+    run_command("APP SERVICES", 30, "dumpsys", "activity", "service", "all", NULL);
+
+    printf("========================================================\n");
+    printf("== Running Application Providers\n");
+    printf("========================================================\n");
+
+    run_command("APP SERVICES", 30, "dumpsys", "activity", "provider", "all", NULL);
+
+
+    printf("========================================================\n");
+    printf("== dumpstate: done\n");
+    printf("========================================================\n");
+}
+
+static void usage() {
+    fprintf(stderr, "usage: dumpstate [-b soundfile] [-e soundfile] [-o file [-d] [-p] [-z]] [-s] [-q]\n"
+            "  -o: write to file (instead of stdout)\n"
+            "  -d: append date to filename (requires -o)\n"
+            "  -p: capture screenshot to filename.png (requires -o)\n"
+            "  -s: write output to control socket (for init)\n"
+            "  -b: play sound file instead of vibrate, at beginning of job\n"
+            "  -e: play sound file instead of vibrate, at end of job\n"
+            "  -q: disable vibrate\n"
+            "  -B: send broadcast when finished (requires -o and -p)\n"
+                );
+}
+
+static void sigpipe_handler(int n) {
+    // don't complain to stderr or stdout
+    _exit(EXIT_FAILURE);
+}
+
+static void vibrate(FILE* vibrator, int ms) {
+    fprintf(vibrator, "%d\n", ms);
+    fflush(vibrator);
+}
+
+int main(int argc, char *argv[]) {
+    struct sigaction sigact;
+    int do_add_date = 0;
+    int do_vibrate = 1;
+    char* use_outfile = 0;
+    int use_socket = 0;
+    int do_fb = 0;
+    int do_broadcast = 0;
+
+    if (getuid() != 0) {
+        // Old versions of the adb client would call the
+        // dumpstate command directly. Newer clients
+        // call /system/bin/bugreport instead. If we detect
+        // we're being called incorrectly, then exec the
+        // correct program.
+        return execl("/system/bin/bugreport", "/system/bin/bugreport", NULL);
+    }
+
+    ALOGI("begin\n");
+
+    /* clear SIGPIPE handler */
+    memset(&sigact, 0, sizeof(sigact));
+    sigact.sa_handler = sigpipe_handler;
+    sigaction(SIGPIPE, &sigact, NULL);
+
+    /* set as high priority, and protect from OOM killer */
+    setpriority(PRIO_PROCESS, 0, -20);
+    FILE *oom_adj = fopen("/proc/self/oom_adj", "we");
+    if (oom_adj) {
+        fputs("-17", oom_adj);
+        fclose(oom_adj);
+    }
+
+    /* parse arguments */
+    int c;
+    while ((c = getopt(argc, argv, "dho:svqzpB")) != -1) {
+        switch (c) {
+            case 'd': do_add_date = 1;       break;
+            case 'o': use_outfile = optarg;  break;
+            case 's': use_socket = 1;        break;
+            case 'v': break;  // compatibility no-op
+            case 'q': do_vibrate = 0;        break;
+            case 'p': do_fb = 1;             break;
+            case 'B': do_broadcast = 1;      break;
+            case '?': printf("\n");
+            case 'h':
+                usage();
+                exit(1);
+        }
+    }
+
+    // If we are going to use a socket, do it as early as possible
+    // to avoid timeouts from bugreport.
+    if (use_socket) {
+        redirect_to_socket(stdout, "dumpstate");
+    }
+
+    /* open the vibrator before dropping root */
+    FILE *vibrator = 0;
+    if (do_vibrate) {
+        vibrator = fopen("/sys/class/timed_output/vibrator/enable", "we");
+        if (vibrator) {
+            vibrate(vibrator, 150);
+        }
+    }
+
+    /* read /proc/cmdline before dropping root */
+    FILE *cmdline = fopen("/proc/cmdline", "re");
+    if (cmdline != NULL) {
+        fgets(cmdline_buf, sizeof(cmdline_buf), cmdline);
+        fclose(cmdline);
+    }
+
+    /* collect stack traces from Dalvik and native processes (needs root) */
+    dump_traces_path = dump_traces();
+
+    /* Get the tombstone fds here while we are running as root. */
+    get_tombstone_fds(tombstone_data);
+
+    /* ensure we will keep capabilities when we drop root */
+    if (prctl(PR_SET_KEEPCAPS, 1) < 0) {
+        ALOGE("prctl(PR_SET_KEEPCAPS) failed: %s\n", strerror(errno));
+        return -1;
+    }
+
+    /* switch to non-root user and group */
+    gid_t groups[] = { AID_LOG, AID_SDCARD_R, AID_SDCARD_RW,
+            AID_MOUNT, AID_INET, AID_NET_BW_STATS, AID_READPROC };
+    if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) {
+        ALOGE("Unable to setgroups, aborting: %s\n", strerror(errno));
+        return -1;
+    }
+    if (setgid(AID_SHELL) != 0) {
+        ALOGE("Unable to setgid, aborting: %s\n", strerror(errno));
+        return -1;
+    }
+    if (setuid(AID_SHELL) != 0) {
+        ALOGE("Unable to setuid, aborting: %s\n", strerror(errno));
+        return -1;
+    }
+
+    struct __user_cap_header_struct capheader;
+    struct __user_cap_data_struct capdata[2];
+    memset(&capheader, 0, sizeof(capheader));
+    memset(&capdata, 0, sizeof(capdata));
+    capheader.version = _LINUX_CAPABILITY_VERSION_3;
+    capheader.pid = 0;
+
+    capdata[CAP_TO_INDEX(CAP_SYSLOG)].permitted = CAP_TO_MASK(CAP_SYSLOG);
+    capdata[CAP_TO_INDEX(CAP_SYSLOG)].effective = CAP_TO_MASK(CAP_SYSLOG);
+    capdata[0].inheritable = 0;
+    capdata[1].inheritable = 0;
+
+    if (capset(&capheader, &capdata[0]) < 0) {
+        ALOGE("capset failed: %s\n", strerror(errno));
+        return -1;
+    }
+
+    /* redirect output if needed */
+    char path[PATH_MAX], tmp_path[PATH_MAX];
+    pid_t gzip_pid = -1;
+
+    if (!use_socket && use_outfile) {
+        strlcpy(path, use_outfile, sizeof(path));
+        if (do_add_date) {
+            char date[80];
+            time_t now = time(NULL);
+            strftime(date, sizeof(date), "-%Y-%m-%d-%H-%M-%S", localtime(&now));
+            strlcat(path, date, sizeof(path));
+        }
+        if (do_fb) {
+            strlcpy(screenshot_path, path, sizeof(screenshot_path));
+            strlcat(screenshot_path, ".png", sizeof(screenshot_path));
+        }
+        strlcat(path, ".txt", sizeof(path));
+        strlcpy(tmp_path, path, sizeof(tmp_path));
+        strlcat(tmp_path, ".tmp", sizeof(tmp_path));
+        redirect_to_file(stdout, tmp_path);
+    }
+
+    dumpstate();
+
+    /* done */
+    if (vibrator) {
+        for (int i = 0; i < 3; i++) {
+            vibrate(vibrator, 75);
+            usleep((75 + 50) * 1000);
+        }
+        fclose(vibrator);
+    }
+
+    /* wait for gzip to finish, otherwise it might get killed when we exit */
+    if (gzip_pid > 0) {
+        fclose(stdout);
+        waitpid(gzip_pid, NULL, 0);
+    }
+
+    /* rename the (now complete) .tmp file to its final location */
+    if (use_outfile && rename(tmp_path, path)) {
+        fprintf(stderr, "rename(%s, %s): %s\n", tmp_path, path, strerror(errno));
+    }
+
+    /* tell activity manager we're done */
+    if (do_broadcast && use_outfile && do_fb) {
+        const char *args[] = { "/system/bin/am", "broadcast", "--user", "0",
+                "-a", "android.intent.action.BUGREPORT_FINISHED",
+                "--es", "android.intent.extra.BUGREPORT", path,
+                "--es", "android.intent.extra.SCREENSHOT", screenshot_path,
+                "--receiver-permission", "android.permission.DUMP", NULL };
+        run_command_always(NULL, 5, args);
+    }
+
+    ALOGI("done\n");
+
+    return 0;
+}
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h
index 67bbd7e..3063ec2 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -17,6 +17,18 @@
 #ifndef _DUMPSTATE_H_
 #define _DUMPSTATE_H_
 
+/* When defined, skips the real dumps and just print the section headers.
+   Useful when debugging dumpstate itself. */
+//#define _DUMPSTATE_DRY_RUN_
+
+#ifdef _DUMPSTATE_DRY_RUN_
+#define ON_DRY_RUN_RETURN(X) return X
+#endif
+#ifndef _DUMPSTATE_DRY_RUN_
+#define ON_DRY_RUN_RETURN(X)
+#endif
+
+
 #include <time.h>
 #include <unistd.h>
 #include <stdbool.h>
@@ -24,23 +36,47 @@
 
 #define SU_PATH "/system/xbin/su"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef void (for_each_pid_func)(int, const char *);
 typedef void (for_each_tid_func)(int, int, const char *);
 
 /* prints the contents of a file */
-int dump_file(const char *title, const char* path);
+int dump_file(const char *title, const char *path);
+
+/* prints the contents of the fd
+ * fd must have been opened with the flag O_NONBLOCK.
+ */
+int dump_file_from_fd(const char *title, const char *path, int fd);
+
+/* calls skip to gate calling dump_from_fd recursively
+ * in the specified directory. dump_from_fd defaults to
+ * dump_file_from_fd above when set to NULL. skip defaults
+ * to false when set to NULL. dump_from_fd will always be
+ * called with title NULL.
+ */
+int dump_files(const char *title, const char *dir,
+        bool (*skip)(const char *path),
+        int (*dump_from_fd)(const char *title, const char *path, int fd));
 
 /* forks a command and waits for it to finish -- terminate args with NULL */
 int run_command(const char *title, int timeout_seconds, const char *command, ...);
 
+/* forks a command and waits for it to finish
+   first element of args is the command, and last must be NULL.
+   command is always ran, even when _DUMPSTATE_DRY_RUN_ is defined. */
+int run_command_always(const char *title, int timeout_seconds, const char *args[]);
+
 /* prints all the system properties */
 void print_properties();
 
 /* redirect output to a service control socket */
 void redirect_to_socket(FILE *redirect, const char *service);
 
-/* redirect output to a file, optionally gzipping; returns gzip pid */
-pid_t redirect_to_file(FILE *redirect, char *path, int gzip_level);
+/* redirect output to a file */
+void redirect_to_file(FILE *redirect, char *path);
 
 /* dump Dalvik and native stack traces, return the trace file location (NULL if none) */
 const char *dump_traces();
@@ -54,16 +90,29 @@
 /* Displays a blocked processes in-kernel wait channel */
 void show_wchan(int pid, int tid, const char *name);
 
+/* Displays a processes times */
+void show_showtime(int pid, const char *name);
+
 /* Runs "showmap" for a process */
 void do_showmap(int pid, const char *name);
 
 /* Gets the dmesg output for the kernel */
 void do_dmesg();
 
+/* Prints the contents of all the routing tables, both IPv4 and IPv6. */
+void dump_route_tables();
+
 /* Play a sound via Stagefright */
-void play_sound(const char* path);
+void play_sound(const char *path);
 
 /* Implemented by libdumpstate_board to dump board-specific info */
 void dumpstate_board();
 
+/* dump eMMC Extended CSD data */
+void dump_emmc_ecsd(const char *ext_csd_path);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _DUMPSTATE_H_ */
diff --git a/cmds/dumpstate/dumpstate.rc b/cmds/dumpstate/dumpstate.rc
new file mode 100644
index 0000000..4cd1803
--- /dev/null
+++ b/cmds/dumpstate/dumpstate.rc
@@ -0,0 +1,10 @@
+on boot
+    # Allow bugreports access to eMMC 5.0 stats
+    chown root mount /sys/kernel/debug/mmc0/mmc0:0001/ext_csd
+    chmod 0440 /sys/kernel/debug/mmc0/mmc0:0001/ext_csd
+
+service dumpstate /system/bin/dumpstate -s
+    class main
+    socket dumpstate stream 0660 shell log
+    disabled
+    oneshot
diff --git a/cmds/dumpstate/libdumpstate_default.c b/cmds/dumpstate/libdumpstate_default.cpp
similarity index 99%
rename from cmds/dumpstate/libdumpstate_default.c
rename to cmds/dumpstate/libdumpstate_default.cpp
index fd840df..415ecdc 100644
--- a/cmds/dumpstate/libdumpstate_default.c
+++ b/cmds/dumpstate/libdumpstate_default.cpp
@@ -19,4 +19,3 @@
 void dumpstate_board(void)
 {
 }
-
diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c
deleted file mode 100644
index 670e09c..0000000
--- a/cmds/dumpstate/utils.c
+++ /dev/null
@@ -1,595 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <poll.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/inotify.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <sys/klog.h>
-#include <time.h>
-#include <unistd.h>
-#include <sys/prctl.h>
-
-#include <cutils/debugger.h>
-#include <cutils/properties.h>
-#include <cutils/sockets.h>
-#include <private/android_filesystem_config.h>
-
-#include <selinux/android.h>
-
-#include "dumpstate.h"
-
-/* list of native processes to include in the native dumps */
-static const char* native_processes_to_dump[] = {
-        "/system/bin/drmserver",
-        "/system/bin/mediaserver",
-        "/system/bin/sdcard",
-        "/system/bin/surfaceflinger",
-        NULL,
-};
-
-static void __for_each_pid(void (*helper)(int, const char *, void *), const char *header, void *arg) {
-    DIR *d;
-    struct dirent *de;
-
-    if (!(d = opendir("/proc"))) {
-        printf("Failed to open /proc (%s)\n", strerror(errno));
-        return;
-    }
-
-    printf("\n------ %s ------\n", header);
-    while ((de = readdir(d))) {
-        int pid;
-        int fd;
-        char cmdpath[255];
-        char cmdline[255];
-
-        if (!(pid = atoi(de->d_name))) {
-            continue;
-        }
-
-        sprintf(cmdpath,"/proc/%d/cmdline", pid);
-        memset(cmdline, 0, sizeof(cmdline));
-        if ((fd = open(cmdpath, O_RDONLY)) < 0) {
-            strcpy(cmdline, "N/A");
-        } else {
-            read(fd, cmdline, sizeof(cmdline) - 1);
-            close(fd);
-        }
-        helper(pid, cmdline, arg);
-    }
-
-    closedir(d);
-}
-
-static void for_each_pid_helper(int pid, const char *cmdline, void *arg) {
-    for_each_pid_func *func = arg;
-    func(pid, cmdline);
-}
-
-void for_each_pid(for_each_pid_func func, const char *header) {
-    __for_each_pid(for_each_pid_helper, header, func);
-}
-
-static void for_each_tid_helper(int pid, const char *cmdline, void *arg) {
-    DIR *d;
-    struct dirent *de;
-    char taskpath[255];
-    for_each_tid_func *func = arg;
-
-    sprintf(taskpath, "/proc/%d/task", pid);
-
-    if (!(d = opendir(taskpath))) {
-        printf("Failed to open %s (%s)\n", taskpath, strerror(errno));
-        return;
-    }
-
-    func(pid, pid, cmdline);
-
-    while ((de = readdir(d))) {
-        int tid;
-        int fd;
-        char commpath[255];
-        char comm[255];
-
-        if (!(tid = atoi(de->d_name))) {
-            continue;
-        }
-
-        if (tid == pid)
-            continue;
-
-        sprintf(commpath,"/proc/%d/comm", tid);
-        memset(comm, 0, sizeof(comm));
-        if ((fd = open(commpath, O_RDONLY)) < 0) {
-            strcpy(comm, "N/A");
-        } else {
-            char *c;
-            read(fd, comm, sizeof(comm) - 1);
-            close(fd);
-
-            c = strrchr(comm, '\n');
-            if (c) {
-                *c = '\0';
-            }
-        }
-        func(pid, tid, comm);
-    }
-
-    closedir(d);
-}
-
-void for_each_tid(for_each_tid_func func, const char *header) {
-    __for_each_pid(for_each_tid_helper, header, func);
-}
-
-void show_wchan(int pid, int tid, const char *name) {
-    char path[255];
-    char buffer[255];
-    int fd;
-    char name_buffer[255];
-
-    memset(buffer, 0, sizeof(buffer));
-
-    sprintf(path, "/proc/%d/wchan", tid);
-    if ((fd = open(path, O_RDONLY)) < 0) {
-        printf("Failed to open '%s' (%s)\n", path, strerror(errno));
-        return;
-    }
-
-    if (read(fd, buffer, sizeof(buffer)) < 0) {
-        printf("Failed to read '%s' (%s)\n", path, strerror(errno));
-        goto out_close;
-    }
-
-    snprintf(name_buffer, sizeof(name_buffer), "%*s%s",
-             pid == tid ? 0 : 3, "", name);
-
-    printf("%-7d %-32s %s\n", tid, name_buffer, buffer);
-
-out_close:
-    close(fd);
-    return;
-}
-
-void do_dmesg() {
-    printf("------ KERNEL LOG (dmesg) ------\n");
-    /* Get size of kernel buffer */
-    int size = klogctl(KLOG_SIZE_BUFFER, NULL, 0);
-    if (size <= 0) {
-        printf("Unexpected klogctl return value: %d\n\n", size);
-        return;
-    }
-    char *buf = (char *) malloc(size + 1);
-    if (buf == NULL) {
-        printf("memory allocation failed\n\n");
-        return;
-    }
-    int retval = klogctl(KLOG_READ_ALL, buf, size);
-    if (retval < 0) {
-        printf("klogctl failure\n\n");
-        free(buf);
-        return;
-    }
-    buf[retval] = '\0';
-    printf("%s\n\n", buf);
-    free(buf);
-    return;
-}
-
-void do_showmap(int pid, const char *name) {
-    char title[255];
-    char arg[255];
-
-    sprintf(title, "SHOW MAP %d (%s)", pid, name);
-    sprintf(arg, "%d", pid);
-    run_command(title, 10, SU_PATH, "root", "showmap", arg, NULL);
-}
-
-/* prints the contents of a file */
-int dump_file(const char *title, const char* path) {
-    char buffer[32768];
-    int fd = open(path, O_RDONLY);
-    if (fd < 0) {
-        int err = errno;
-        if (title) printf("------ %s (%s) ------\n", title, path);
-        printf("*** %s: %s\n", path, strerror(err));
-        if (title) printf("\n");
-        return -1;
-    }
-
-    if (title) printf("------ %s (%s", title, path);
-
-    if (title) {
-        struct stat st;
-        if (memcmp(path, "/proc/", 6) && memcmp(path, "/sys/", 5) && !fstat(fd, &st)) {
-            char stamp[80];
-            time_t mtime = st.st_mtime;
-            strftime(stamp, sizeof(stamp), "%Y-%m-%d %H:%M:%S", localtime(&mtime));
-            printf(": %s", stamp);
-        }
-        printf(") ------\n");
-    }
-
-    int newline = 0;
-    for (;;) {
-        int ret = read(fd, buffer, sizeof(buffer));
-        if (ret > 0) {
-            newline = (buffer[ret - 1] == '\n');
-            ret = fwrite(buffer, ret, 1, stdout);
-        }
-        if (ret <= 0) break;
-    }
-
-    close(fd);
-    if (!newline) printf("\n");
-    if (title) printf("\n");
-    return 0;
-}
-
-/* forks a command and waits for it to finish */
-int run_command(const char *title, int timeout_seconds, const char *command, ...) {
-    fflush(stdout);
-    clock_t start = clock();
-    pid_t pid = fork();
-
-    /* handle error case */
-    if (pid < 0) {
-        printf("*** fork: %s\n", strerror(errno));
-        return pid;
-    }
-
-    /* handle child case */
-    if (pid == 0) {
-        const char *args[1024] = {command};
-        size_t arg;
-
-        /* make sure the child dies when dumpstate dies */
-        prctl(PR_SET_PDEATHSIG, SIGKILL);
-
-        va_list ap;
-        va_start(ap, command);
-        if (title) printf("------ %s (%s", title, command);
-        for (arg = 1; arg < sizeof(args) / sizeof(args[0]); ++arg) {
-            args[arg] = va_arg(ap, const char *);
-            if (args[arg] == NULL) break;
-            if (title) printf(" %s", args[arg]);
-        }
-        if (title) printf(") ------\n");
-        fflush(stdout);
-
-        execvp(command, (char**) args);
-        printf("*** exec(%s): %s\n", command, strerror(errno));
-        fflush(stdout);
-        _exit(-1);
-    }
-
-    /* handle parent case */
-    for (;;) {
-        int status;
-        pid_t p = waitpid(pid, &status, WNOHANG);
-        float elapsed = (float) (clock() - start) / CLOCKS_PER_SEC;
-        if (p == pid) {
-            if (WIFSIGNALED(status)) {
-                printf("*** %s: Killed by signal %d\n", command, WTERMSIG(status));
-            } else if (WIFEXITED(status) && WEXITSTATUS(status) > 0) {
-                printf("*** %s: Exit code %d\n", command, WEXITSTATUS(status));
-            }
-            if (title) printf("[%s: %.1fs elapsed]\n\n", command, elapsed);
-            return status;
-        }
-
-        if (timeout_seconds && elapsed > timeout_seconds) {
-            printf("*** %s: Timed out after %.1fs (killing pid %d)\n", command, elapsed, pid);
-            kill(pid, SIGTERM);
-            return -1;
-        }
-
-        usleep(100000);  // poll every 0.1 sec
-    }
-}
-
-size_t num_props = 0;
-static char* props[2000];
-
-static void print_prop(const char *key, const char *name, void *user) {
-    (void) user;
-    if (num_props < sizeof(props) / sizeof(props[0])) {
-        char buf[PROPERTY_KEY_MAX + PROPERTY_VALUE_MAX + 10];
-        snprintf(buf, sizeof(buf), "[%s]: [%s]\n", key, name);
-        props[num_props++] = strdup(buf);
-    }
-}
-
-static int compare_prop(const void *a, const void *b) {
-    return strcmp(*(char * const *) a, *(char * const *) b);
-}
-
-/* prints all the system properties */
-void print_properties() {
-    size_t i;
-    num_props = 0;
-    property_list(print_prop, NULL);
-    qsort(&props, num_props, sizeof(props[0]), compare_prop);
-
-    printf("------ SYSTEM PROPERTIES ------\n");
-    for (i = 0; i < num_props; ++i) {
-        fputs(props[i], stdout);
-        free(props[i]);
-    }
-    printf("\n");
-}
-
-/* redirect output to a service control socket */
-void redirect_to_socket(FILE *redirect, const char *service) {
-    int s = android_get_control_socket(service);
-    if (s < 0) {
-        fprintf(stderr, "android_get_control_socket(%s): %s\n", service, strerror(errno));
-        exit(1);
-    }
-    if (listen(s, 4) < 0) {
-        fprintf(stderr, "listen(control socket): %s\n", strerror(errno));
-        exit(1);
-    }
-
-    struct sockaddr addr;
-    socklen_t alen = sizeof(addr);
-    int fd = accept(s, &addr, &alen);
-    if (fd < 0) {
-        fprintf(stderr, "accept(control socket): %s\n", strerror(errno));
-        exit(1);
-    }
-
-    fflush(redirect);
-    dup2(fd, fileno(redirect));
-    close(fd);
-}
-
-/* redirect output to a file, optionally gzipping; returns gzip pid (or -1) */
-pid_t redirect_to_file(FILE *redirect, char *path, int gzip_level) {
-    char *chp = path;
-
-    /* skip initial slash */
-    if (chp[0] == '/')
-        chp++;
-
-    /* create leading directories, if necessary */
-    while (chp && chp[0]) {
-        chp = strchr(chp, '/');
-        if (chp) {
-            *chp = 0;
-            mkdir(path, 0770);  /* drwxrwx--- */
-            *chp++ = '/';
-        }
-    }
-
-    int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-    if (fd < 0) {
-        fprintf(stderr, "%s: %s\n", path, strerror(errno));
-        exit(1);
-    }
-
-    pid_t gzip_pid = -1;
-    if (gzip_level > 0) {
-        int fds[2];
-        if (pipe(fds)) {
-            fprintf(stderr, "pipe: %s\n", strerror(errno));
-            exit(1);
-        }
-
-        fflush(redirect);
-        fflush(stdout);
-
-        gzip_pid = fork();
-        if (gzip_pid < 0) {
-            fprintf(stderr, "fork: %s\n", strerror(errno));
-            exit(1);
-        }
-
-        if (gzip_pid == 0) {
-            dup2(fds[0], STDIN_FILENO);
-            dup2(fd, STDOUT_FILENO);
-
-            close(fd);
-            close(fds[0]);
-            close(fds[1]);
-
-            char level[10];
-            snprintf(level, sizeof(level), "-%d", gzip_level);
-            execlp("gzip", "gzip", level, NULL);
-            fprintf(stderr, "exec(gzip): %s\n", strerror(errno));
-            _exit(-1);
-        }
-
-        close(fd);
-        close(fds[0]);
-        fd = fds[1];
-    }
-
-    dup2(fd, fileno(redirect));
-    close(fd);
-    return gzip_pid;
-}
-
-static bool should_dump_native_traces(const char* path) {
-    for (const char** p = native_processes_to_dump; *p; p++) {
-        if (!strcmp(*p, path)) {
-            return true;
-        }
-    }
-    return false;
-}
-
-/* dump Dalvik and native stack traces, return the trace file location (NULL if none) */
-const char *dump_traces() {
-    const char* result = NULL;
-
-    char traces_path[PROPERTY_VALUE_MAX] = "";
-    property_get("dalvik.vm.stack-trace-file", traces_path, "");
-    if (!traces_path[0]) return NULL;
-
-    /* move the old traces.txt (if any) out of the way temporarily */
-    char anr_traces_path[PATH_MAX];
-    strlcpy(anr_traces_path, traces_path, sizeof(anr_traces_path));
-    strlcat(anr_traces_path, ".anr", sizeof(anr_traces_path));
-    if (rename(traces_path, anr_traces_path) && errno != ENOENT) {
-        fprintf(stderr, "rename(%s, %s): %s\n", traces_path, anr_traces_path, strerror(errno));
-        return NULL;  // Can't rename old traces.txt -- no permission? -- leave it alone instead
-    }
-
-    /* make the directory if necessary */
-    char anr_traces_dir[PATH_MAX];
-    strlcpy(anr_traces_dir, traces_path, sizeof(anr_traces_dir));
-    char *slash = strrchr(anr_traces_dir, '/');
-    if (slash != NULL) {
-        *slash = '\0';
-        if (!mkdir(anr_traces_dir, 0775)) {
-            chown(anr_traces_dir, AID_SYSTEM, AID_SYSTEM);
-            chmod(anr_traces_dir, 0775);
-            if (selinux_android_restorecon(anr_traces_dir, 0) == -1) {
-                fprintf(stderr, "restorecon failed for %s: %s\n", anr_traces_dir, strerror(errno));
-            }
-        } else if (errno != EEXIST) {
-            fprintf(stderr, "mkdir(%s): %s\n", anr_traces_dir, strerror(errno));
-            return NULL;
-        }
-    }
-
-    /* create a new, empty traces.txt file to receive stack dumps */
-    int fd = open(traces_path, O_CREAT | O_WRONLY | O_TRUNC | O_NOFOLLOW, 0666);  /* -rw-rw-rw- */
-    if (fd < 0) {
-        fprintf(stderr, "%s: %s\n", traces_path, strerror(errno));
-        return NULL;
-    }
-    int chmod_ret = fchmod(fd, 0666);
-    if (chmod_ret < 0) {
-        fprintf(stderr, "fchmod on %s failed: %s\n", traces_path, strerror(errno));
-        close(fd);
-        return NULL;
-    }
-
-    /* walk /proc and kill -QUIT all Dalvik processes */
-    DIR *proc = opendir("/proc");
-    if (proc == NULL) {
-        fprintf(stderr, "/proc: %s\n", strerror(errno));
-        goto error_close_fd;
-    }
-
-    /* use inotify to find when processes are done dumping */
-    int ifd = inotify_init();
-    if (ifd < 0) {
-        fprintf(stderr, "inotify_init: %s\n", strerror(errno));
-        goto error_close_fd;
-    }
-
-    int wfd = inotify_add_watch(ifd, traces_path, IN_CLOSE_WRITE);
-    if (wfd < 0) {
-        fprintf(stderr, "inotify_add_watch(%s): %s\n", traces_path, strerror(errno));
-        goto error_close_ifd;
-    }
-
-    struct dirent *d;
-    int dalvik_found = 0;
-    while ((d = readdir(proc))) {
-        int pid = atoi(d->d_name);
-        if (pid <= 0) continue;
-
-        char path[PATH_MAX];
-        char data[PATH_MAX];
-        snprintf(path, sizeof(path), "/proc/%d/exe", pid);
-        ssize_t len = readlink(path, data, sizeof(data) - 1);
-        if (len <= 0) {
-            continue;
-        }
-        data[len] = '\0';
-
-        if (!strcmp(data, "/system/bin/app_process")) {
-            /* skip zygote -- it won't dump its stack anyway */
-            snprintf(path, sizeof(path), "/proc/%d/cmdline", pid);
-            int fd = open(path, O_RDONLY);
-            len = read(fd, data, sizeof(data) - 1);
-            close(fd);
-            if (len <= 0) {
-                continue;
-            }
-            data[len] = '\0';
-            if (!strcmp(data, "zygote")) {
-                continue;
-            }
-
-            ++dalvik_found;
-            if (kill(pid, SIGQUIT)) {
-                fprintf(stderr, "kill(%d, SIGQUIT): %s\n", pid, strerror(errno));
-                continue;
-            }
-
-            /* wait for the writable-close notification from inotify */
-            struct pollfd pfd = { ifd, POLLIN, 0 };
-            int ret = poll(&pfd, 1, 200);  /* 200 msec timeout */
-            if (ret < 0) {
-                fprintf(stderr, "poll: %s\n", strerror(errno));
-            } else if (ret == 0) {
-                fprintf(stderr, "warning: timed out dumping pid %d\n", pid);
-            } else {
-                struct inotify_event ie;
-                read(ifd, &ie, sizeof(ie));
-            }
-        } else if (should_dump_native_traces(data)) {
-            /* dump native process if appropriate */
-            if (lseek(fd, 0, SEEK_END) < 0) {
-                fprintf(stderr, "lseek: %s\n", strerror(errno));
-            } else {
-                dump_backtrace_to_file(pid, fd);
-            }
-        }
-    }
-
-    if (dalvik_found == 0) {
-        fprintf(stderr, "Warning: no Dalvik processes found to dump stacks\n");
-    }
-
-    static char dump_traces_path[PATH_MAX];
-    strlcpy(dump_traces_path, traces_path, sizeof(dump_traces_path));
-    strlcat(dump_traces_path, ".bugreport", sizeof(dump_traces_path));
-    if (rename(traces_path, dump_traces_path)) {
-        fprintf(stderr, "rename(%s, %s): %s\n", traces_path, dump_traces_path, strerror(errno));
-        goto error_close_ifd;
-    }
-    result = dump_traces_path;
-
-    /* replace the saved [ANR] traces.txt file */
-    rename(anr_traces_path, traces_path);
-
-error_close_ifd:
-    close(ifd);
-error_close_fd:
-    close(fd);
-    return result;
-}
-
-void play_sound(const char* path) {
-    run_command(NULL, 5, "/system/bin/stagefright", "-o", "-a", path, NULL);
-}
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp
new file mode 100644
index 0000000..f5183d1
--- /dev/null
+++ b/cmds/dumpstate/utils.cpp
@@ -0,0 +1,1038 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/inotify.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <sys/klog.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/prctl.h>
+
+#include <android-base/file.h>
+#include <cutils/debugger.h>
+#include <cutils/properties.h>
+#include <cutils/sockets.h>
+#include <private/android_filesystem_config.h>
+
+#include <selinux/android.h>
+
+#include "dumpstate.h"
+
+static const int64_t NANOS_PER_SEC = 1000000000;
+
+/* list of native processes to include in the native dumps */
+static const char* native_processes_to_dump[] = {
+        "/system/bin/drmserver",
+        "/system/bin/mediaserver",
+        "/system/bin/sdcard",
+        "/system/bin/surfaceflinger",
+        NULL,
+};
+
+static uint64_t nanotime() {
+    struct timespec ts;
+    clock_gettime(CLOCK_MONOTONIC, &ts);
+    return (uint64_t)ts.tv_sec * NANOS_PER_SEC + ts.tv_nsec;
+}
+
+void for_each_userid(void (*func)(int), const char *header) {
+    ON_DRY_RUN_RETURN();
+    DIR *d;
+    struct dirent *de;
+
+    if (header) printf("\n------ %s ------\n", header);
+    func(0);
+
+    if (!(d = opendir("/data/system/users"))) {
+        printf("Failed to open /data/system/users (%s)\n", strerror(errno));
+        return;
+    }
+
+    while ((de = readdir(d))) {
+        int userid;
+        if (de->d_type != DT_DIR || !(userid = atoi(de->d_name))) {
+            continue;
+        }
+        func(userid);
+    }
+
+    closedir(d);
+}
+
+static void __for_each_pid(void (*helper)(int, const char *, void *), const char *header, void *arg) {
+    DIR *d;
+    struct dirent *de;
+
+    if (!(d = opendir("/proc"))) {
+        printf("Failed to open /proc (%s)\n", strerror(errno));
+        return;
+    }
+
+    printf("\n------ %s ------\n", header);
+    while ((de = readdir(d))) {
+        int pid;
+        int fd;
+        char cmdpath[255];
+        char cmdline[255];
+
+        if (!(pid = atoi(de->d_name))) {
+            continue;
+        }
+
+        memset(cmdline, 0, sizeof(cmdline));
+
+        snprintf(cmdpath, sizeof(cmdpath), "/proc/%d/cmdline", pid);
+        if ((fd = TEMP_FAILURE_RETRY(open(cmdpath, O_RDONLY | O_CLOEXEC))) >= 0) {
+            TEMP_FAILURE_RETRY(read(fd, cmdline, sizeof(cmdline) - 2));
+            close(fd);
+            if (cmdline[0]) {
+                helper(pid, cmdline, arg);
+                continue;
+            }
+        }
+
+        // if no cmdline, a kernel thread has comm
+        snprintf(cmdpath, sizeof(cmdpath), "/proc/%d/comm", pid);
+        if ((fd = TEMP_FAILURE_RETRY(open(cmdpath, O_RDONLY | O_CLOEXEC))) >= 0) {
+            TEMP_FAILURE_RETRY(read(fd, cmdline + 1, sizeof(cmdline) - 4));
+            close(fd);
+            if (cmdline[1]) {
+                cmdline[0] = '[';
+                size_t len = strcspn(cmdline, "\f\b\r\n");
+                cmdline[len] = ']';
+                cmdline[len+1] = '\0';
+            }
+        }
+        if (!cmdline[0]) {
+            strcpy(cmdline, "N/A");
+        }
+        helper(pid, cmdline, arg);
+    }
+
+    closedir(d);
+}
+
+static void for_each_pid_helper(int pid, const char *cmdline, void *arg) {
+    for_each_pid_func *func = (for_each_pid_func*) arg;
+    func(pid, cmdline);
+}
+
+void for_each_pid(for_each_pid_func func, const char *header) {
+    ON_DRY_RUN_RETURN();
+    __for_each_pid(for_each_pid_helper, header, (void *) func);
+}
+
+static void for_each_tid_helper(int pid, const char *cmdline, void *arg) {
+    DIR *d;
+    struct dirent *de;
+    char taskpath[255];
+    for_each_tid_func *func = (for_each_tid_func*) arg;
+
+    sprintf(taskpath, "/proc/%d/task", pid);
+
+    if (!(d = opendir(taskpath))) {
+        printf("Failed to open %s (%s)\n", taskpath, strerror(errno));
+        return;
+    }
+
+    func(pid, pid, cmdline);
+
+    while ((de = readdir(d))) {
+        int tid;
+        int fd;
+        char commpath[255];
+        char comm[255];
+
+        if (!(tid = atoi(de->d_name))) {
+            continue;
+        }
+
+        if (tid == pid)
+            continue;
+
+        sprintf(commpath,"/proc/%d/comm", tid);
+        memset(comm, 0, sizeof(comm));
+        if ((fd = TEMP_FAILURE_RETRY(open(commpath, O_RDONLY | O_CLOEXEC))) < 0) {
+            strcpy(comm, "N/A");
+        } else {
+            char *c;
+            TEMP_FAILURE_RETRY(read(fd, comm, sizeof(comm) - 2));
+            close(fd);
+
+            c = strrchr(comm, '\n');
+            if (c) {
+                *c = '\0';
+            }
+        }
+        func(pid, tid, comm);
+    }
+
+    closedir(d);
+}
+
+void for_each_tid(for_each_tid_func func, const char *header) {
+    ON_DRY_RUN_RETURN();
+    __for_each_pid(for_each_tid_helper, header, (void *) func);
+}
+
+void show_wchan(int pid, int tid, const char *name) {
+    ON_DRY_RUN_RETURN();
+    char path[255];
+    char buffer[255];
+    int fd, ret, save_errno;
+    char name_buffer[255];
+
+    memset(buffer, 0, sizeof(buffer));
+
+    sprintf(path, "/proc/%d/wchan", tid);
+    if ((fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_CLOEXEC))) < 0) {
+        printf("Failed to open '%s' (%s)\n", path, strerror(errno));
+        return;
+    }
+
+    ret = TEMP_FAILURE_RETRY(read(fd, buffer, sizeof(buffer)));
+    save_errno = errno;
+    close(fd);
+
+    if (ret < 0) {
+        printf("Failed to read '%s' (%s)\n", path, strerror(save_errno));
+        return;
+    }
+
+    snprintf(name_buffer, sizeof(name_buffer), "%*s%s",
+             pid == tid ? 0 : 3, "", name);
+
+    printf("%-7d %-32s %s\n", tid, name_buffer, buffer);
+
+    return;
+}
+
+// print time in centiseconds
+static void snprcent(char *buffer, size_t len, size_t spc,
+                     unsigned long long time) {
+    static long hz; // cache discovered hz
+
+    if (hz <= 0) {
+        hz = sysconf(_SC_CLK_TCK);
+        if (hz <= 0) {
+            hz = 1000;
+        }
+    }
+
+    // convert to centiseconds
+    time = (time * 100 + (hz / 2)) / hz;
+
+    char str[16];
+
+    snprintf(str, sizeof(str), " %llu.%02u",
+             time / 100, (unsigned)(time % 100));
+    size_t offset = strlen(buffer);
+    snprintf(buffer + offset, (len > offset) ? len - offset : 0,
+             "%*s", (spc > offset) ? (int)(spc - offset) : 0, str);
+}
+
+// print permille as a percent
+static void snprdec(char *buffer, size_t len, size_t spc, unsigned permille) {
+    char str[16];
+
+    snprintf(str, sizeof(str), " %u.%u%%", permille / 10, permille % 10);
+    size_t offset = strlen(buffer);
+    snprintf(buffer + offset, (len > offset) ? len - offset : 0,
+             "%*s", (spc > offset) ? (int)(spc - offset) : 0, str);
+}
+
+void show_showtime(int pid, const char *name) {
+    ON_DRY_RUN_RETURN();
+    char path[255];
+    char buffer[1023];
+    int fd, ret, save_errno;
+
+    memset(buffer, 0, sizeof(buffer));
+
+    sprintf(path, "/proc/%d/stat", pid);
+    if ((fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_CLOEXEC))) < 0) {
+        printf("Failed to open '%s' (%s)\n", path, strerror(errno));
+        return;
+    }
+
+    ret = TEMP_FAILURE_RETRY(read(fd, buffer, sizeof(buffer)));
+    save_errno = errno;
+    close(fd);
+
+    if (ret < 0) {
+        printf("Failed to read '%s' (%s)\n", path, strerror(save_errno));
+        return;
+    }
+
+    // field 14 is utime
+    // field 15 is stime
+    // field 42 is iotime
+    unsigned long long utime = 0, stime = 0, iotime = 0;
+    if (sscanf(buffer,
+               "%*u %*s %*s %*d %*d %*d %*d %*d %*d %*d %*d "
+               "%*d %*d %llu %llu %*d %*d %*d %*d %*d %*d "
+               "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d "
+               "%*d %*d %*d %*d %*d %*d %*d %*d %*d %llu ",
+               &utime, &stime, &iotime) != 3) {
+        return;
+    }
+
+    unsigned long long total = utime + stime;
+    if (!total) {
+        return;
+    }
+
+    unsigned permille = (iotime * 1000 + (total / 2)) / total;
+    if (permille > 1000) {
+        permille = 1000;
+    }
+
+    // try to beautify and stabilize columns at <80 characters
+    snprintf(buffer, sizeof(buffer), "%-6d%s", pid, name);
+    if ((name[0] != '[') || utime) {
+        snprcent(buffer, sizeof(buffer), 57, utime);
+    }
+    snprcent(buffer, sizeof(buffer), 65, stime);
+    if ((name[0] != '[') || iotime) {
+        snprcent(buffer, sizeof(buffer), 73, iotime);
+    }
+    if (iotime) {
+        snprdec(buffer, sizeof(buffer), 79, permille);
+    }
+    puts(buffer); // adds a trailing newline
+
+    return;
+}
+
+void do_dmesg() {
+    printf("------ KERNEL LOG (dmesg) ------\n");
+    ON_DRY_RUN_RETURN();
+    /* Get size of kernel buffer */
+    int size = klogctl(KLOG_SIZE_BUFFER, NULL, 0);
+    if (size <= 0) {
+        printf("Unexpected klogctl return value: %d\n\n", size);
+        return;
+    }
+    char *buf = (char *) malloc(size + 1);
+    if (buf == NULL) {
+        printf("memory allocation failed\n\n");
+        return;
+    }
+    int retval = klogctl(KLOG_READ_ALL, buf, size);
+    if (retval < 0) {
+        printf("klogctl failure\n\n");
+        free(buf);
+        return;
+    }
+    buf[retval] = '\0';
+    printf("%s\n\n", buf);
+    free(buf);
+    return;
+}
+
+void do_showmap(int pid, const char *name) {
+    char title[255];
+    char arg[255];
+
+    sprintf(title, "SHOW MAP %d (%s)", pid, name);
+    sprintf(arg, "%d", pid);
+    run_command(title, 10, SU_PATH, "root", "showmap", arg, NULL);
+}
+
+static int _dump_file_from_fd(const char *title, const char *path, int fd) {
+    if (title) printf("------ %s (%s", title, path);
+
+    if (title) {
+        struct stat st;
+        if (memcmp(path, "/proc/", 6) && memcmp(path, "/sys/", 5) && !fstat(fd, &st)) {
+            char stamp[80];
+            time_t mtime = st.st_mtime;
+            strftime(stamp, sizeof(stamp), "%Y-%m-%d %H:%M:%S", localtime(&mtime));
+            printf(": %s", stamp);
+        }
+        printf(") ------\n");
+    }
+
+    bool newline = false;
+    fd_set read_set;
+    struct timeval tm;
+    while (1) {
+        FD_ZERO(&read_set);
+        FD_SET(fd, &read_set);
+        /* Timeout if no data is read for 30 seconds. */
+        tm.tv_sec = 30;
+        tm.tv_usec = 0;
+        uint64_t elapsed = nanotime();
+        int ret = TEMP_FAILURE_RETRY(select(fd + 1, &read_set, NULL, NULL, &tm));
+        if (ret == -1) {
+            printf("*** %s: select failed: %s\n", path, strerror(errno));
+            newline = true;
+            break;
+        } else if (ret == 0) {
+            elapsed = nanotime() - elapsed;
+            printf("*** %s: Timed out after %.3fs\n", path,
+                   (float) elapsed / NANOS_PER_SEC);
+            newline = true;
+            break;
+        } else {
+            char buffer[65536];
+            ssize_t bytes_read = TEMP_FAILURE_RETRY(read(fd, buffer, sizeof(buffer)));
+            if (bytes_read > 0) {
+                fwrite(buffer, bytes_read, 1, stdout);
+                newline = (buffer[bytes_read-1] == '\n');
+            } else {
+                if (bytes_read == -1) {
+                    printf("*** %s: Failed to read from fd: %s", path, strerror(errno));
+                    newline = true;
+                }
+                break;
+            }
+        }
+    }
+    close(fd);
+
+    if (!newline) printf("\n");
+    if (title) printf("\n");
+    return 0;
+}
+
+/* prints the contents of a file */
+int dump_file(const char *title, const char *path) {
+    if (title) printf("------ %s (%s) ------\n", title, path);
+    ON_DRY_RUN_RETURN(0);
+
+    int fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_NONBLOCK | O_CLOEXEC));
+    if (fd < 0) {
+        int err = errno;
+        printf("*** %s: %s\n", path, strerror(err));
+        if (title) printf("\n");
+        return -1;
+    }
+    return _dump_file_from_fd(title, path, fd);
+}
+
+/* calls skip to gate calling dump_from_fd recursively
+ * in the specified directory. dump_from_fd defaults to
+ * dump_file_from_fd above when set to NULL. skip defaults
+ * to false when set to NULL. dump_from_fd will always be
+ * called with title NULL.
+ */
+int dump_files(const char *title, const char *dir,
+        bool (*skip)(const char *path),
+        int (*dump_from_fd)(const char *title, const char *path, int fd)) {
+    DIR *dirp;
+    struct dirent *d;
+    char *newpath = NULL;
+    const char *slash = "/";
+    int fd, retval = 0;
+
+    if (title) {
+        printf("------ %s (%s) ------\n", title, dir);
+    }
+    ON_DRY_RUN_RETURN(0);
+
+    if (dir[strlen(dir) - 1] == '/') {
+        ++slash;
+    }
+    dirp = opendir(dir);
+    if (dirp == NULL) {
+        retval = -errno;
+        fprintf(stderr, "%s: %s\n", dir, strerror(errno));
+        return retval;
+    }
+
+    if (!dump_from_fd) {
+        dump_from_fd = dump_file_from_fd;
+    }
+    for (; ((d = readdir(dirp))); free(newpath), newpath = NULL) {
+        if ((d->d_name[0] == '.')
+         && (((d->d_name[1] == '.') && (d->d_name[2] == '\0'))
+          || (d->d_name[1] == '\0'))) {
+            continue;
+        }
+        asprintf(&newpath, "%s%s%s%s", dir, slash, d->d_name,
+                 (d->d_type == DT_DIR) ? "/" : "");
+        if (!newpath) {
+            retval = -errno;
+            continue;
+        }
+        if (skip && (*skip)(newpath)) {
+            continue;
+        }
+        if (d->d_type == DT_DIR) {
+            int ret = dump_files(NULL, newpath, skip, dump_from_fd);
+            if (ret < 0) {
+                retval = ret;
+            }
+            continue;
+        }
+        fd = TEMP_FAILURE_RETRY(open(newpath, O_RDONLY | O_NONBLOCK | O_CLOEXEC));
+        if (fd < 0) {
+            retval = fd;
+            printf("*** %s: %s\n", newpath, strerror(errno));
+            continue;
+        }
+        (*dump_from_fd)(NULL, newpath, fd);
+    }
+    closedir(dirp);
+    if (title) {
+        printf("\n");
+    }
+    return retval;
+}
+
+/* fd must have been opened with the flag O_NONBLOCK. With this flag set,
+ * it's possible to avoid issues where opening the file itself can get
+ * stuck.
+ */
+int dump_file_from_fd(const char *title, const char *path, int fd) {
+    ON_DRY_RUN_RETURN(0);
+    int flags = fcntl(fd, F_GETFL);
+    if (flags == -1) {
+        printf("*** %s: failed to get flags on fd %d: %s\n", path, fd, strerror(errno));
+        return -1;
+    } else if (!(flags & O_NONBLOCK)) {
+        printf("*** %s: fd must have O_NONBLOCK set.\n", path);
+        return -1;
+    }
+    return _dump_file_from_fd(title, path, fd);
+}
+
+bool waitpid_with_timeout(pid_t pid, int timeout_seconds, int* status) {
+    sigset_t child_mask, old_mask;
+    sigemptyset(&child_mask);
+    sigaddset(&child_mask, SIGCHLD);
+
+    if (sigprocmask(SIG_BLOCK, &child_mask, &old_mask) == -1) {
+        printf("*** sigprocmask failed: %s\n", strerror(errno));
+        return false;
+    }
+
+    struct timespec ts;
+    ts.tv_sec = timeout_seconds;
+    ts.tv_nsec = 0;
+    int ret = TEMP_FAILURE_RETRY(sigtimedwait(&child_mask, NULL, &ts));
+    int saved_errno = errno;
+    // Set the signals back the way they were.
+    if (sigprocmask(SIG_SETMASK, &old_mask, NULL) == -1) {
+        printf("*** sigprocmask failed: %s\n", strerror(errno));
+        if (ret == 0) {
+            return false;
+        }
+    }
+    if (ret == -1) {
+        errno = saved_errno;
+        if (errno == EAGAIN) {
+            errno = ETIMEDOUT;
+        } else {
+            printf("*** sigtimedwait failed: %s\n", strerror(errno));
+        }
+        return false;
+    }
+
+    pid_t child_pid = waitpid(pid, status, WNOHANG);
+    if (child_pid != pid) {
+        if (child_pid != -1) {
+            printf("*** Waiting for pid %d, got pid %d instead\n", pid, child_pid);
+        } else {
+            printf("*** waitpid failed: %s\n", strerror(errno));
+        }
+        return false;
+    }
+    return true;
+}
+
+/* forks a command and waits for it to finish */
+int run_command(const char *title, int timeout_seconds, const char *command, ...) {
+    fflush(stdout);
+
+    const char *args[1024] = {command};
+    size_t arg;
+    va_list ap;
+    va_start(ap, command);
+    if (title) printf("------ %s (%s", title, command);
+    for (arg = 1; arg < sizeof(args) / sizeof(args[0]); ++arg) {
+        args[arg] = va_arg(ap, const char *);
+        if (args[arg] == NULL) break;
+        if (title) printf(" %s", args[arg]);
+    }
+    if (title) printf(") ------\n");
+    fflush(stdout);
+
+    ON_DRY_RUN_RETURN(0);
+
+    return run_command_always(title, timeout_seconds, args);
+}
+
+/* forks a command and waits for it to finish */
+int run_command_always(const char *title, int timeout_seconds, const char *args[]) {
+    const char *command = args[0];
+
+    uint64_t start = nanotime();
+    pid_t pid = fork();
+
+    /* handle error case */
+    if (pid < 0) {
+        printf("*** fork: %s\n", strerror(errno));
+        return pid;
+    }
+
+    /* handle child case */
+    if (pid == 0) {
+
+        /* make sure the child dies when dumpstate dies */
+        prctl(PR_SET_PDEATHSIG, SIGKILL);
+
+        /* just ignore SIGPIPE, will go down with parent's */
+        struct sigaction sigact;
+        memset(&sigact, 0, sizeof(sigact));
+        sigact.sa_handler = SIG_IGN;
+        sigaction(SIGPIPE, &sigact, NULL);
+
+        execvp(command, (char**) args);
+        printf("*** exec(%s): %s\n", command, strerror(errno));
+        fflush(stdout);
+        _exit(-1);
+    }
+
+    /* handle parent case */
+    int status;
+    bool ret = waitpid_with_timeout(pid, timeout_seconds, &status);
+    uint64_t elapsed = nanotime() - start;
+    if (!ret) {
+        if (errno == ETIMEDOUT) {
+            printf("*** %s: Timed out after %.3fs (killing pid %d)\n", command,
+                   (float) elapsed / NANOS_PER_SEC, pid);
+        } else {
+            printf("*** %s: Error after %.4fs (killing pid %d)\n", command,
+                   (float) elapsed / NANOS_PER_SEC, pid);
+        }
+        kill(pid, SIGTERM);
+        if (!waitpid_with_timeout(pid, 5, NULL)) {
+            kill(pid, SIGKILL);
+            if (!waitpid_with_timeout(pid, 5, NULL)) {
+                printf("*** %s: Cannot kill %d even with SIGKILL.\n", command, pid);
+            }
+        }
+        return -1;
+    }
+
+    if (WIFSIGNALED(status)) {
+        printf("*** %s: Killed by signal %d\n", command, WTERMSIG(status));
+    } else if (WIFEXITED(status) && WEXITSTATUS(status) > 0) {
+        printf("*** %s: Exit code %d\n", command, WEXITSTATUS(status));
+    }
+    if (title) printf("[%s: %.3fs elapsed]\n\n", command, (float)elapsed / NANOS_PER_SEC);
+
+    return status;
+}
+
+size_t num_props = 0;
+static char* props[2000];
+
+static void print_prop(const char *key, const char *name, void *user) {
+    (void) user;
+    if (num_props < sizeof(props) / sizeof(props[0])) {
+        char buf[PROPERTY_KEY_MAX + PROPERTY_VALUE_MAX + 10];
+        snprintf(buf, sizeof(buf), "[%s]: [%s]\n", key, name);
+        props[num_props++] = strdup(buf);
+    }
+}
+
+static int compare_prop(const void *a, const void *b) {
+    return strcmp(*(char * const *) a, *(char * const *) b);
+}
+
+/* prints all the system properties */
+void print_properties() {
+    printf("------ SYSTEM PROPERTIES ------\n");
+    ON_DRY_RUN_RETURN();
+    size_t i;
+    num_props = 0;
+    property_list(print_prop, NULL);
+    qsort(&props, num_props, sizeof(props[0]), compare_prop);
+
+    for (i = 0; i < num_props; ++i) {
+        fputs(props[i], stdout);
+        free(props[i]);
+    }
+    printf("\n");
+}
+
+/* redirect output to a service control socket */
+void redirect_to_socket(FILE *redirect, const char *service) {
+    int s = android_get_control_socket(service);
+    if (s < 0) {
+        fprintf(stderr, "android_get_control_socket(%s): %s\n", service, strerror(errno));
+        exit(1);
+    }
+    fcntl(s, F_SETFD, FD_CLOEXEC);
+    if (listen(s, 4) < 0) {
+        fprintf(stderr, "listen(control socket): %s\n", strerror(errno));
+        exit(1);
+    }
+
+    struct sockaddr addr;
+    socklen_t alen = sizeof(addr);
+    int fd = accept(s, &addr, &alen);
+    if (fd < 0) {
+        fprintf(stderr, "accept(control socket): %s\n", strerror(errno));
+        exit(1);
+    }
+
+    fflush(redirect);
+    dup2(fd, fileno(redirect));
+    close(fd);
+}
+
+/* redirect output to a file */
+void redirect_to_file(FILE *redirect, char *path) {
+    char *chp = path;
+
+    /* skip initial slash */
+    if (chp[0] == '/')
+        chp++;
+
+    /* create leading directories, if necessary */
+    while (chp && chp[0]) {
+        chp = strchr(chp, '/');
+        if (chp) {
+            *chp = 0;
+            mkdir(path, 0770);  /* drwxrwx--- */
+            *chp++ = '/';
+        }
+    }
+
+    int fd = TEMP_FAILURE_RETRY(open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC,
+                                     S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH));
+    if (fd < 0) {
+        fprintf(stderr, "%s: %s\n", path, strerror(errno));
+        exit(1);
+    }
+
+    TEMP_FAILURE_RETRY(dup2(fd, fileno(redirect)));
+    close(fd);
+}
+
+static bool should_dump_native_traces(const char* path) {
+    for (const char** p = native_processes_to_dump; *p; p++) {
+        if (!strcmp(*p, path)) {
+            return true;
+        }
+    }
+    return false;
+}
+
+/* dump Dalvik and native stack traces, return the trace file location (NULL if none) */
+const char *dump_traces() {
+    ON_DRY_RUN_RETURN(NULL);
+    const char* result = NULL;
+
+    char traces_path[PROPERTY_VALUE_MAX] = "";
+    property_get("dalvik.vm.stack-trace-file", traces_path, "");
+    if (!traces_path[0]) return NULL;
+
+    /* move the old traces.txt (if any) out of the way temporarily */
+    char anr_traces_path[PATH_MAX];
+    strlcpy(anr_traces_path, traces_path, sizeof(anr_traces_path));
+    strlcat(anr_traces_path, ".anr", sizeof(anr_traces_path));
+    if (rename(traces_path, anr_traces_path) && errno != ENOENT) {
+        fprintf(stderr, "rename(%s, %s): %s\n", traces_path, anr_traces_path, strerror(errno));
+        return NULL;  // Can't rename old traces.txt -- no permission? -- leave it alone instead
+    }
+
+    /* create a new, empty traces.txt file to receive stack dumps */
+    int fd = TEMP_FAILURE_RETRY(open(traces_path, O_CREAT | O_WRONLY | O_TRUNC | O_NOFOLLOW | O_CLOEXEC,
+                                     0666));  /* -rw-rw-rw- */
+    if (fd < 0) {
+        fprintf(stderr, "%s: %s\n", traces_path, strerror(errno));
+        return NULL;
+    }
+    int chmod_ret = fchmod(fd, 0666);
+    if (chmod_ret < 0) {
+        fprintf(stderr, "fchmod on %s failed: %s\n", traces_path, strerror(errno));
+        close(fd);
+        return NULL;
+    }
+
+    /* Variables below must be initialized before 'goto' statements */
+    int dalvik_found = 0;
+    int ifd, wfd = -1;
+
+    /* walk /proc and kill -QUIT all Dalvik processes */
+    DIR *proc = opendir("/proc");
+    if (proc == NULL) {
+        fprintf(stderr, "/proc: %s\n", strerror(errno));
+        goto error_close_fd;
+    }
+
+    /* use inotify to find when processes are done dumping */
+    ifd = inotify_init();
+    if (ifd < 0) {
+        fprintf(stderr, "inotify_init: %s\n", strerror(errno));
+        goto error_close_fd;
+    }
+
+    wfd = inotify_add_watch(ifd, traces_path, IN_CLOSE_WRITE);
+    if (wfd < 0) {
+        fprintf(stderr, "inotify_add_watch(%s): %s\n", traces_path, strerror(errno));
+        goto error_close_ifd;
+    }
+
+    struct dirent *d;
+    while ((d = readdir(proc))) {
+        int pid = atoi(d->d_name);
+        if (pid <= 0) continue;
+
+        char path[PATH_MAX];
+        char data[PATH_MAX];
+        snprintf(path, sizeof(path), "/proc/%d/exe", pid);
+        ssize_t len = readlink(path, data, sizeof(data) - 1);
+        if (len <= 0) {
+            continue;
+        }
+        data[len] = '\0';
+
+        if (!strncmp(data, "/system/bin/app_process", strlen("/system/bin/app_process"))) {
+            /* skip zygote -- it won't dump its stack anyway */
+            snprintf(path, sizeof(path), "/proc/%d/cmdline", pid);
+            int cfd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_CLOEXEC));
+            len = read(cfd, data, sizeof(data) - 1);
+            close(cfd);
+            if (len <= 0) {
+                continue;
+            }
+            data[len] = '\0';
+            if (!strncmp(data, "zygote", strlen("zygote"))) {
+                continue;
+            }
+
+            ++dalvik_found;
+            uint64_t start = nanotime();
+            if (kill(pid, SIGQUIT)) {
+                fprintf(stderr, "kill(%d, SIGQUIT): %s\n", pid, strerror(errno));
+                continue;
+            }
+
+            /* wait for the writable-close notification from inotify */
+            struct pollfd pfd = { ifd, POLLIN, 0 };
+            int ret = poll(&pfd, 1, 5000);  /* 5 sec timeout */
+            if (ret < 0) {
+                fprintf(stderr, "poll: %s\n", strerror(errno));
+            } else if (ret == 0) {
+                fprintf(stderr, "warning: timed out dumping pid %d\n", pid);
+            } else {
+                struct inotify_event ie;
+                read(ifd, &ie, sizeof(ie));
+            }
+
+            if (lseek(fd, 0, SEEK_END) < 0) {
+                fprintf(stderr, "lseek: %s\n", strerror(errno));
+            } else {
+                dprintf(fd, "[dump dalvik stack %d: %.3fs elapsed]\n",
+                        pid, (float)(nanotime() - start) / NANOS_PER_SEC);
+            }
+        } else if (should_dump_native_traces(data)) {
+            /* dump native process if appropriate */
+            if (lseek(fd, 0, SEEK_END) < 0) {
+                fprintf(stderr, "lseek: %s\n", strerror(errno));
+            } else {
+                static uint16_t timeout_failures = 0;
+                uint64_t start = nanotime();
+
+                /* If 3 backtrace dumps fail in a row, consider debuggerd dead. */
+                if (timeout_failures == 3) {
+                    dprintf(fd, "too many stack dump failures, skipping...\n");
+                } else if (dump_backtrace_to_file_timeout(pid, fd, 20) == -1) {
+                    dprintf(fd, "dumping failed, likely due to a timeout\n");
+                    timeout_failures++;
+                } else {
+                    timeout_failures = 0;
+                }
+                dprintf(fd, "[dump native stack %d: %.3fs elapsed]\n",
+                        pid, (float)(nanotime() - start) / NANOS_PER_SEC);
+            }
+        }
+    }
+
+    if (dalvik_found == 0) {
+        fprintf(stderr, "Warning: no Dalvik processes found to dump stacks\n");
+    }
+
+    static char dump_traces_path[PATH_MAX];
+    strlcpy(dump_traces_path, traces_path, sizeof(dump_traces_path));
+    strlcat(dump_traces_path, ".bugreport", sizeof(dump_traces_path));
+    if (rename(traces_path, dump_traces_path)) {
+        fprintf(stderr, "rename(%s, %s): %s\n", traces_path, dump_traces_path, strerror(errno));
+        goto error_close_ifd;
+    }
+    result = dump_traces_path;
+
+    /* replace the saved [ANR] traces.txt file */
+    rename(anr_traces_path, traces_path);
+
+error_close_ifd:
+    close(ifd);
+error_close_fd:
+    close(fd);
+    return result;
+}
+
+void dump_route_tables() {
+    ON_DRY_RUN_RETURN();
+    const char* const RT_TABLES_PATH = "/data/misc/net/rt_tables";
+    dump_file("RT_TABLES", RT_TABLES_PATH);
+    FILE* fp = fopen(RT_TABLES_PATH, "re");
+    if (!fp) {
+        printf("*** %s: %s\n", RT_TABLES_PATH, strerror(errno));
+        return;
+    }
+    char table[16];
+    // Each line has an integer (the table number), a space, and a string (the table name). We only
+    // need the table number. It's a 32-bit unsigned number, so max 10 chars. Skip the table name.
+    // Add a fixed max limit so this doesn't go awry.
+    for (int i = 0; i < 64 && fscanf(fp, " %10s %*s", table) == 1; ++i) {
+        run_command("ROUTE TABLE IPv4", 10, "ip", "-4", "route", "show", "table", table, NULL);
+        run_command("ROUTE TABLE IPv6", 10, "ip", "-6", "route", "show", "table", table, NULL);
+    }
+    fclose(fp);
+}
+
+void dump_emmc_ecsd(const char *ext_csd_path) {
+    // List of interesting offsets
+    struct hex {
+        char str[2];
+    };
+    static const size_t EXT_CSD_REV = 192 * sizeof(hex);
+    static const size_t EXT_PRE_EOL_INFO = 267 * sizeof(hex);
+    static const size_t EXT_DEVICE_LIFE_TIME_EST_TYP_A = 268 * sizeof(hex);
+    static const size_t EXT_DEVICE_LIFE_TIME_EST_TYP_B = 269 * sizeof(hex);
+
+    std::string buffer;
+    if (!android::base::ReadFileToString(ext_csd_path, &buffer)) {
+        return;
+    }
+
+    printf("------ %s Extended CSD ------\n", ext_csd_path);
+
+    if (buffer.length() < (EXT_CSD_REV + sizeof(hex))) {
+        printf("*** %s: truncated content %zu\n\n", ext_csd_path, buffer.length());
+        return;
+    }
+
+    int ext_csd_rev = 0;
+    std::string sub = buffer.substr(EXT_CSD_REV, sizeof(hex));
+    if (sscanf(sub.c_str(), "%2x", &ext_csd_rev) != 1) {
+        printf("*** %s: EXT_CSD_REV parse error \"%s\"\n\n",
+               ext_csd_path, sub.c_str());
+        return;
+    }
+
+    static const char *ver_str[] = {
+        "4.0", "4.1", "4.2", "4.3", "Obsolete", "4.41", "4.5", "5.0"
+    };
+    printf("rev 1.%d (MMC %s)\n",
+           ext_csd_rev,
+           (ext_csd_rev < (int)(sizeof(ver_str) / sizeof(ver_str[0]))) ?
+               ver_str[ext_csd_rev] :
+               "Unknown");
+    if (ext_csd_rev < 7) {
+        printf("\n");
+        return;
+    }
+
+    if (buffer.length() < (EXT_PRE_EOL_INFO + sizeof(hex))) {
+        printf("*** %s: truncated content %zu\n\n", ext_csd_path, buffer.length());
+        return;
+    }
+
+    int ext_pre_eol_info = 0;
+    sub = buffer.substr(EXT_PRE_EOL_INFO, sizeof(hex));
+    if (sscanf(sub.c_str(), "%2x", &ext_pre_eol_info) != 1) {
+        printf("*** %s: PRE_EOL_INFO parse error \"%s\"\n\n",
+               ext_csd_path, sub.c_str());
+        return;
+    }
+
+    static const char *eol_str[] = {
+        "Undefined",
+        "Normal",
+        "Warning (consumed 80% of reserve)",
+        "Urgent (consumed 90% of reserve)"
+    };
+    printf("PRE_EOL_INFO %d (MMC %s)\n",
+           ext_pre_eol_info,
+           eol_str[(ext_pre_eol_info < (int)
+                       (sizeof(eol_str) / sizeof(eol_str[0]))) ?
+                           ext_pre_eol_info : 0]);
+
+    for (size_t lifetime = EXT_DEVICE_LIFE_TIME_EST_TYP_A;
+            lifetime <= EXT_DEVICE_LIFE_TIME_EST_TYP_B;
+            lifetime += sizeof(hex)) {
+        int ext_device_life_time_est;
+        static const char *est_str[] = {
+            "Undefined",
+            "0-10% of device lifetime used",
+            "10-20% of device lifetime used",
+            "20-30% of device lifetime used",
+            "30-40% of device lifetime used",
+            "40-50% of device lifetime used",
+            "50-60% of device lifetime used",
+            "60-70% of device lifetime used",
+            "70-80% of device lifetime used",
+            "80-90% of device lifetime used",
+            "90-100% of device lifetime used",
+            "Exceeded the maximum estimated device lifetime",
+        };
+
+        if (buffer.length() < (lifetime + sizeof(hex))) {
+            printf("*** %s: truncated content %zu\n", ext_csd_path, buffer.length());
+            break;
+        }
+
+        ext_device_life_time_est = 0;
+        sub = buffer.substr(lifetime, sizeof(hex));
+        if (sscanf(sub.c_str(), "%2x", &ext_device_life_time_est) != 1) {
+            printf("*** %s: DEVICE_LIFE_TIME_EST_TYP_%c parse error \"%s\"\n",
+                   ext_csd_path,
+                   (unsigned)((lifetime - EXT_DEVICE_LIFE_TIME_EST_TYP_A) /
+                              sizeof(hex)) + 'A',
+                   sub.c_str());
+            continue;
+        }
+        printf("DEVICE_LIFE_TIME_EST_TYP_%c %d (MMC %s)\n",
+               (unsigned)((lifetime - EXT_DEVICE_LIFE_TIME_EST_TYP_A) /
+                          sizeof(hex)) + 'A',
+               ext_device_life_time_est,
+               est_str[(ext_device_life_time_est < (int)
+                           (sizeof(est_str) / sizeof(est_str[0]))) ?
+                               ext_device_life_time_est : 0]);
+    }
+
+    printf("\n");
+}
diff --git a/cmds/flatland/Android.mk b/cmds/flatland/Android.mk
index 5e57f02..c295167 100644
--- a/cmds/flatland/Android.mk
+++ b/cmds/flatland/Android.mk
@@ -1,3 +1,4 @@
+local_target_dir := $(TARGET_OUT_DATA)/local/tmp
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
@@ -11,6 +12,10 @@
 
 LOCAL_MODULE_TAGS := tests
 
+LOCAL_MODULE_PATH := $(local_target_dir)
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := flatland
+LOCAL_MODULE_STEM_64 := flatland64
 LOCAL_SHARED_LIBRARIES := \
     libEGL      \
     libGLESv2   \
diff --git a/cmds/flatland/GLHelper.cpp b/cmds/flatland/GLHelper.cpp
index 05d082b..3155766 100644
--- a/cmds/flatland/GLHelper.cpp
+++ b/cmds/flatland/GLHelper.cpp
@@ -201,14 +201,16 @@
 
 bool GLHelper::createNamedSurfaceTexture(GLuint name, uint32_t w, uint32_t h,
         sp<GLConsumer>* glConsumer, EGLSurface* surface) {
-    sp<BufferQueue> bq = new BufferQueue(mGraphicBufferAlloc);
-    sp<GLConsumer> glc = new GLConsumer(bq, name,
-            GL_TEXTURE_EXTERNAL_OES, false);
+    sp<IGraphicBufferProducer> producer;
+    sp<IGraphicBufferConsumer> consumer;
+    BufferQueue::createBufferQueue(&producer, &consumer, mGraphicBufferAlloc);
+    sp<GLConsumer> glc = new GLConsumer(consumer, name,
+            GL_TEXTURE_EXTERNAL_OES, false, true);
     glc->setDefaultBufferSize(w, h);
     glc->setDefaultMaxBufferCount(3);
     glc->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER);
 
-    sp<ANativeWindow> anw = new Surface(bq);
+    sp<ANativeWindow> anw = new Surface(producer);
     EGLSurface s = eglCreateWindowSurface(mDisplay, mConfig, anw.get(), NULL);
     if (s == EGL_NO_SURFACE) {
         fprintf(stderr, "eglCreateWindowSurface error: %#x\n", eglGetError());
diff --git a/cmds/flatland/Main.cpp b/cmds/flatland/Main.cpp
index c0e5b3d..c47b0c8 100644
--- a/cmds/flatland/Main.cpp
+++ b/cmds/flatland/Main.cpp
@@ -73,7 +73,7 @@
         },
     },
 
-    { "3:2 Single Static Window",
+    { "4:3 Single Static Window",
         2048, 1536, { 1536 },
         {
             {   // Window
@@ -117,7 +117,7 @@
         },
     },
 
-    { "3:2 App -> Home Transition",
+    { "4:3 App -> Home Transition",
         2048, 1536, { 1536 },
         {
             {   // Wallpaper
@@ -173,7 +173,7 @@
         },
     },
 
-    { "3:2 SurfaceView -> Home Transition",
+    { "4:3 SurfaceView -> Home Transition",
         2048, 1536, { 1536 },
         {
             {   // Wallpaper
@@ -206,8 +206,8 @@
 
 static const ShaderDesc shaders[] = {
     {
-        name: "Blit",
-        vertexShader: {
+        .name="Blit",
+        .vertexShader={
             "precision mediump float;",
             "",
             "attribute vec4 position;",
@@ -223,7 +223,7 @@
             "    texCoords = uvToTex * uv;",
             "}",
         },
-        fragmentShader: {
+        .fragmentShader={
             "#extension GL_OES_EGL_image_external : require",
             "precision mediump float;",
             "",
@@ -240,8 +240,8 @@
     },
 
     {
-        name: "Gradient",
-        vertexShader: {
+        .name="Gradient",
+        .vertexShader={
             "precision mediump float;",
             "",
             "attribute vec4 position;",
@@ -257,7 +257,7 @@
             "    interp = (uvToInterp * uv).x;",
             "}",
         },
-        fragmentShader: {
+        .fragmentShader={
             "precision mediump float;",
             "",
             "varying float interp;",
diff --git a/cmds/installd/Android.mk b/cmds/installd/Android.mk
index e11b4f8..d0bd4a8 100644
--- a/cmds/installd/Android.mk
+++ b/cmds/installd/Android.mk
@@ -1,21 +1,24 @@
 LOCAL_PATH := $(call my-dir)
 
-common_src_files := \
-    commands.c utils.c
+common_src_files := commands.cpp utils.cpp
+common_cflags := -Wall -Werror
 
 #
 # Static library used in testing and executable
 #
 
 include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-    $(common_src_files)
-
 LOCAL_MODULE := libinstalld
-
 LOCAL_MODULE_TAGS := eng tests
+LOCAL_SRC_FILES := $(common_src_files)
+LOCAL_CFLAGS := $(common_cflags)
+LOCAL_SHARED_LIBRARIES := \
+    libbase \
+    liblogwrap \
+    libselinux \
 
+LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
+LOCAL_CLANG := true
 include $(BUILD_STATIC_LIBRARY)
 
 #
@@ -23,21 +26,19 @@
 #
 
 include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-    installd.c \
-    $(common_src_files)
-
+LOCAL_MODULE := installd
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := $(common_cflags)
+LOCAL_SRC_FILES := installd.cpp $(common_src_files)
 LOCAL_SHARED_LIBRARIES := \
+    libbase \
     libcutils \
     liblog \
-    libselinux
+    liblogwrap \
+    libselinux \
 
-LOCAL_STATIC_LIBRARIES := \
-    libdiskusage
-
-LOCAL_MODULE := installd
-
-LOCAL_MODULE_TAGS := optional
-
+LOCAL_STATIC_LIBRARIES := libdiskusage
+LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
+LOCAL_INIT_RC := installd.rc
+LOCAL_CLANG := true
 include $(BUILD_EXECUTABLE)
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c
deleted file mode 100644
index 669f403..0000000
--- a/cmds/installd/commands.c
+++ /dev/null
@@ -1,1316 +0,0 @@
-/*
-** Copyright 2008, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-**     http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
-
-#include <inttypes.h>
-#include <sys/capability.h>
-#include "installd.h"
-#include <diskusage/dirsize.h>
-#include <selinux/android.h>
-
-/* Directory records that are used in execution of commands. */
-dir_rec_t android_data_dir;
-dir_rec_t android_asec_dir;
-dir_rec_t android_app_dir;
-dir_rec_t android_app_private_dir;
-dir_rec_t android_app_lib_dir;
-dir_rec_t android_media_dir;
-dir_rec_array_t android_system_dirs;
-
-int install(const char *pkgname, uid_t uid, gid_t gid, const char *seinfo)
-{
-    char pkgdir[PKG_PATH_MAX];
-    char libsymlink[PKG_PATH_MAX];
-    char applibdir[PKG_PATH_MAX];
-    struct stat libStat;
-
-    if ((uid < AID_SYSTEM) || (gid < AID_SYSTEM)) {
-        ALOGE("invalid uid/gid: %d %d\n", uid, gid);
-        return -1;
-    }
-
-    if (create_pkg_path(pkgdir, pkgname, PKG_DIR_POSTFIX, 0)) {
-        ALOGE("cannot create package path\n");
-        return -1;
-    }
-
-    if (create_pkg_path(libsymlink, pkgname, PKG_LIB_POSTFIX, 0)) {
-        ALOGE("cannot create package lib symlink origin path\n");
-        return -1;
-    }
-
-    if (create_pkg_path_in_dir(applibdir, &android_app_lib_dir, pkgname, PKG_DIR_POSTFIX)) {
-        ALOGE("cannot create package lib symlink dest path\n");
-        return -1;
-    }
-
-    if (mkdir(pkgdir, 0751) < 0) {
-        ALOGE("cannot create dir '%s': %s\n", pkgdir, strerror(errno));
-        return -1;
-    }
-    if (chmod(pkgdir, 0751) < 0) {
-        ALOGE("cannot chmod dir '%s': %s\n", pkgdir, strerror(errno));
-        unlink(pkgdir);
-        return -1;
-    }
-
-    if (lstat(libsymlink, &libStat) < 0) {
-        if (errno != ENOENT) {
-            ALOGE("couldn't stat lib dir: %s\n", strerror(errno));
-            return -1;
-        }
-    } else {
-        if (S_ISDIR(libStat.st_mode)) {
-            if (delete_dir_contents(libsymlink, 1, 0) < 0) {
-                ALOGE("couldn't delete lib directory during install for: %s", libsymlink);
-                return -1;
-            }
-        } else if (S_ISLNK(libStat.st_mode)) {
-            if (unlink(libsymlink) < 0) {
-                ALOGE("couldn't unlink lib directory during install for: %s", libsymlink);
-                return -1;
-            }
-        }
-    }
-
-    if (symlink(applibdir, libsymlink) < 0) {
-        ALOGE("couldn't symlink directory '%s' -> '%s': %s\n", libsymlink, applibdir,
-                strerror(errno));
-        unlink(pkgdir);
-        return -1;
-    }
-
-    if (selinux_android_setfilecon(pkgdir, pkgname, seinfo, uid) < 0) {
-        ALOGE("cannot setfilecon dir '%s': %s\n", pkgdir, strerror(errno));
-        unlink(libsymlink);
-        unlink(pkgdir);
-        return -errno;
-    }
-
-    if (chown(pkgdir, uid, gid) < 0) {
-        ALOGE("cannot chown dir '%s': %s\n", pkgdir, strerror(errno));
-        unlink(libsymlink);
-        unlink(pkgdir);
-        return -1;
-    }
-
-    return 0;
-}
-
-int uninstall(const char *pkgname, userid_t userid)
-{
-    char pkgdir[PKG_PATH_MAX];
-
-    if (create_pkg_path(pkgdir, pkgname, PKG_DIR_POSTFIX, userid))
-        return -1;
-
-    remove_profile_file(pkgname);
-
-    /* delete contents AND directory, no exceptions */
-    return delete_dir_contents(pkgdir, 1, NULL);
-}
-
-int renamepkg(const char *oldpkgname, const char *newpkgname)
-{
-    char oldpkgdir[PKG_PATH_MAX];
-    char newpkgdir[PKG_PATH_MAX];
-
-    if (create_pkg_path(oldpkgdir, oldpkgname, PKG_DIR_POSTFIX, 0))
-        return -1;
-    if (create_pkg_path(newpkgdir, newpkgname, PKG_DIR_POSTFIX, 0))
-        return -1;
-
-    if (rename(oldpkgdir, newpkgdir) < 0) {
-        ALOGE("cannot rename dir '%s' to '%s': %s\n", oldpkgdir, newpkgdir, strerror(errno));
-        return -errno;
-    }
-    return 0;
-}
-
-int fix_uid(const char *pkgname, uid_t uid, gid_t gid)
-{
-    char pkgdir[PKG_PATH_MAX];
-    struct stat s;
-    int rc = 0;
-
-    if ((uid < AID_SYSTEM) || (gid < AID_SYSTEM)) {
-        ALOGE("invalid uid/gid: %d %d\n", uid, gid);
-        return -1;
-    }
-
-    if (create_pkg_path(pkgdir, pkgname, PKG_DIR_POSTFIX, 0)) {
-        ALOGE("cannot create package path\n");
-        return -1;
-    }
-
-    if (stat(pkgdir, &s) < 0) return -1;
-
-    if (s.st_uid != 0 || s.st_gid != 0) {
-        ALOGE("fixing uid of non-root pkg: %s %" PRIu32 " %" PRIu32 "\n", pkgdir, s.st_uid, s.st_gid);
-        return -1;
-    }
-
-    if (chmod(pkgdir, 0751) < 0) {
-        ALOGE("cannot chmod dir '%s': %s\n", pkgdir, strerror(errno));
-        unlink(pkgdir);
-        return -errno;
-    }
-    if (chown(pkgdir, uid, gid) < 0) {
-        ALOGE("cannot chown dir '%s': %s\n", pkgdir, strerror(errno));
-        unlink(pkgdir);
-        return -errno;
-    }
-
-    return 0;
-}
-
-int delete_user_data(const char *pkgname, userid_t userid)
-{
-    char pkgdir[PKG_PATH_MAX];
-
-    if (create_pkg_path(pkgdir, pkgname, PKG_DIR_POSTFIX, userid))
-        return -1;
-
-    /* delete contents, excluding "lib", but not the directory itself */
-    return delete_dir_contents(pkgdir, 0, "lib");
-}
-
-int make_user_data(const char *pkgname, uid_t uid, userid_t userid, const char* seinfo)
-{
-    char pkgdir[PKG_PATH_MAX];
-    char applibdir[PKG_PATH_MAX];
-    char libsymlink[PKG_PATH_MAX];
-    struct stat libStat;
-
-    // Create the data dir for the package
-    if (create_pkg_path(pkgdir, pkgname, PKG_DIR_POSTFIX, userid)) {
-        return -1;
-    }
-    if (create_pkg_path(libsymlink, pkgname, PKG_LIB_POSTFIX, userid)) {
-        ALOGE("cannot create package lib symlink origin path\n");
-        return -1;
-    }
-    if (create_pkg_path_in_dir(applibdir, &android_app_lib_dir, pkgname, PKG_DIR_POSTFIX)) {
-        ALOGE("cannot create package lib symlink dest path\n");
-        return -1;
-    }
-
-    if (mkdir(pkgdir, 0751) < 0) {
-        ALOGE("cannot create dir '%s': %s\n", pkgdir, strerror(errno));
-        return -errno;
-    }
-    if (chmod(pkgdir, 0751) < 0) {
-        ALOGE("cannot chmod dir '%s': %s\n", pkgdir, strerror(errno));
-        unlink(pkgdir);
-        return -errno;
-    }
-
-    if (lstat(libsymlink, &libStat) < 0) {
-        if (errno != ENOENT) {
-            ALOGE("couldn't stat lib dir for non-primary: %s\n", strerror(errno));
-            unlink(pkgdir);
-            return -1;
-        }
-    } else {
-        if (S_ISDIR(libStat.st_mode)) {
-            if (delete_dir_contents(libsymlink, 1, 0) < 0) {
-                ALOGE("couldn't delete lib directory during install for non-primary: %s",
-                        libsymlink);
-                unlink(pkgdir);
-                return -1;
-            }
-        } else if (S_ISLNK(libStat.st_mode)) {
-            if (unlink(libsymlink) < 0) {
-                ALOGE("couldn't unlink lib directory during install for non-primary: %s",
-                        libsymlink);
-                unlink(pkgdir);
-                return -1;
-            }
-        }
-    }
-
-    if (symlink(applibdir, libsymlink) < 0) {
-        ALOGE("couldn't symlink directory for non-primary '%s' -> '%s': %s\n", libsymlink,
-                applibdir, strerror(errno));
-        unlink(pkgdir);
-        return -1;
-    }
-
-    if (selinux_android_setfilecon(pkgdir, pkgname, seinfo, uid) < 0) {
-        ALOGE("cannot setfilecon dir '%s': %s\n", pkgdir, strerror(errno));
-        unlink(libsymlink);
-        unlink(pkgdir);
-        return -errno;
-    }
-
-    if (chown(pkgdir, uid, uid) < 0) {
-        ALOGE("cannot chown dir '%s': %s\n", pkgdir, strerror(errno));
-        unlink(libsymlink);
-        unlink(pkgdir);
-        return -errno;
-    }
-
-    return 0;
-}
-
-int delete_user(userid_t userid)
-{
-    char data_path[PKG_PATH_MAX];
-    if (create_user_path(data_path, userid)) {
-        return -1;
-    }
-    if (delete_dir_contents(data_path, 1, NULL)) {
-        return -1;
-    }
-
-    char media_path[PATH_MAX];
-    if (create_user_media_path(media_path, userid) == -1) {
-        return -1;
-    }
-    if (delete_dir_contents(media_path, 1, NULL) == -1) {
-        return -1;
-    }
-
-    return 0;
-}
-
-int delete_cache(const char *pkgname, userid_t userid)
-{
-    char cachedir[PKG_PATH_MAX];
-
-    if (create_pkg_path(cachedir, pkgname, CACHE_DIR_POSTFIX, userid))
-        return -1;
-
-        /* delete contents, not the directory, no exceptions */
-    return delete_dir_contents(cachedir, 0, 0);
-}
-
-/* Try to ensure free_size bytes of storage are available.
- * Returns 0 on success.
- * This is rather simple-minded because doing a full LRU would
- * be potentially memory-intensive, and without atime it would
- * also require that apps constantly modify file metadata even
- * when just reading from the cache, which is pretty awful.
- */
-int free_cache(int64_t free_size)
-{
-    cache_t* cache;
-    int64_t avail;
-    DIR *d;
-    struct dirent *de;
-    char tmpdir[PATH_MAX];
-    char *dirpos;
-
-    avail = data_disk_free();
-    if (avail < 0) return -1;
-
-    ALOGI("free_cache(%" PRId64 ") avail %" PRId64 "\n", free_size, avail);
-    if (avail >= free_size) return 0;
-
-    cache = start_cache_collection();
-
-    // Collect cache files for primary user.
-    if (create_user_path(tmpdir, 0) == 0) {
-        //ALOGI("adding cache files from %s\n", tmpdir);
-        add_cache_files(cache, tmpdir, "cache");
-    }
-
-    // Search for other users and add any cache files from them.
-    snprintf(tmpdir, sizeof(tmpdir), "%s%s", android_data_dir.path,
-            SECONDARY_USER_PREFIX);
-    dirpos = tmpdir + strlen(tmpdir);
-    d = opendir(tmpdir);
-    if (d != NULL) {
-        while ((de = readdir(d))) {
-            if (de->d_type == DT_DIR) {
-                const char *name = de->d_name;
-                    /* always skip "." and ".." */
-                if (name[0] == '.') {
-                    if (name[1] == 0) continue;
-                    if ((name[1] == '.') && (name[2] == 0)) continue;
-                }
-                if ((strlen(name)+(dirpos-tmpdir)) < (sizeof(tmpdir)-1)) {
-                    strcpy(dirpos, name);
-                    //ALOGI("adding cache files from %s\n", tmpdir);
-                    add_cache_files(cache, tmpdir, "cache");
-                } else {
-                    ALOGW("Path exceeds limit: %s%s", tmpdir, name);
-                }
-            }
-        }
-        closedir(d);
-    }
-
-    // Collect cache files on external storage for all users (if it is mounted as part
-    // of the internal storage).
-    strcpy(tmpdir, android_media_dir.path);
-    dirpos = tmpdir + strlen(tmpdir);
-    d = opendir(tmpdir);
-    if (d != NULL) {
-        while ((de = readdir(d))) {
-            if (de->d_type == DT_DIR) {
-                const char *name = de->d_name;
-                    /* skip any dir that doesn't start with a number, so not a user */
-                if (name[0] < '0' || name[0] > '9') {
-                    continue;
-                }
-                if ((strlen(name)+(dirpos-tmpdir)) < (sizeof(tmpdir)-1)) {
-                    strcpy(dirpos, name);
-                    if (lookup_media_dir(tmpdir, "Android") == 0
-                            && lookup_media_dir(tmpdir, "data") == 0) {
-                        //ALOGI("adding cache files from %s\n", tmpdir);
-                        add_cache_files(cache, tmpdir, "cache");
-                    }
-                } else {
-                    ALOGW("Path exceeds limit: %s%s", tmpdir, name);
-                }
-            }
-        }
-        closedir(d);
-    }
-
-    clear_cache_files(cache, free_size);
-    finish_cache_collection(cache);
-
-    return data_disk_free() >= free_size ? 0 : -1;
-}
-
-int move_dex(const char *src, const char *dst)
-{
-    char src_dex[PKG_PATH_MAX];
-    char dst_dex[PKG_PATH_MAX];
-
-    if (validate_apk_path(src)) return -1;
-    if (validate_apk_path(dst)) return -1;
-
-    if (create_cache_path(src_dex, src)) return -1;
-    if (create_cache_path(dst_dex, dst)) return -1;
-
-    ALOGV("move %s -> %s\n", src_dex, dst_dex);
-    if (rename(src_dex, dst_dex) < 0) {
-        ALOGE("Couldn't move %s: %s\n", src_dex, strerror(errno));
-        return -1;
-    } else {
-        return 0;
-    }
-}
-
-int rm_dex(const char *path)
-{
-    char dex_path[PKG_PATH_MAX];
-
-    if (validate_apk_path(path)) return -1;
-    if (create_cache_path(dex_path, path)) return -1;
-
-    ALOGV("unlink %s\n", dex_path);
-    if (unlink(dex_path) < 0) {
-        ALOGE("Couldn't unlink %s: %s\n", dex_path, strerror(errno));
-        return -1;
-    } else {
-        return 0;
-    }
-}
-
-int get_size(const char *pkgname, userid_t userid, const char *apkpath,
-             const char *libdirpath, const char *fwdlock_apkpath, const char *asecpath,
-             int64_t *_codesize, int64_t *_datasize, int64_t *_cachesize,
-             int64_t* _asecsize)
-{
-    DIR *d;
-    int dfd;
-    struct dirent *de;
-    struct stat s;
-    char path[PKG_PATH_MAX];
-
-    int64_t codesize = 0;
-    int64_t datasize = 0;
-    int64_t cachesize = 0;
-    int64_t asecsize = 0;
-
-        /* count the source apk as code -- but only if it's not
-         * on the /system partition and its not on the sdcard.
-         */
-    if (validate_system_app_path(apkpath) &&
-            strncmp(apkpath, android_asec_dir.path, android_asec_dir.len) != 0) {
-        if (stat(apkpath, &s) == 0) {
-            codesize += stat_size(&s);
-        }
-    }
-        /* count the forward locked apk as code if it is given
-         */
-    if (fwdlock_apkpath != NULL && fwdlock_apkpath[0] != '!') {
-        if (stat(fwdlock_apkpath, &s) == 0) {
-            codesize += stat_size(&s);
-        }
-    }
-        /* count the cached dexfile as code */
-    if (!create_cache_path(path, apkpath)) {
-        if (stat(path, &s) == 0) {
-            codesize += stat_size(&s);
-        }
-    }
-
-        /* add in size of any libraries */
-    if (libdirpath != NULL && libdirpath[0] != '!') {
-        d = opendir(libdirpath);
-        if (d != NULL) {
-            dfd = dirfd(d);
-            codesize += calculate_dir_size(dfd);
-            closedir(d);
-        }
-    }
-
-        /* compute asec size if it is given
-         */
-    if (asecpath != NULL && asecpath[0] != '!') {
-        if (stat(asecpath, &s) == 0) {
-            asecsize += stat_size(&s);
-        }
-    }
-
-    if (create_pkg_path(path, pkgname, PKG_DIR_POSTFIX, userid)) {
-        goto done;
-    }
-
-    d = opendir(path);
-    if (d == NULL) {
-        goto done;
-    }
-    dfd = dirfd(d);
-
-    /* most stuff in the pkgdir is data, except for the "cache"
-     * directory and below, which is cache, and the "lib" directory
-     * and below, which is code...
-     */
-    while ((de = readdir(d))) {
-        const char *name = de->d_name;
-
-        if (de->d_type == DT_DIR) {
-            int subfd;
-            int64_t statsize = 0;
-            int64_t dirsize = 0;
-                /* always skip "." and ".." */
-            if (name[0] == '.') {
-                if (name[1] == 0) continue;
-                if ((name[1] == '.') && (name[2] == 0)) continue;
-            }
-            if (fstatat(dfd, name, &s, AT_SYMLINK_NOFOLLOW) == 0) {
-                statsize = stat_size(&s);
-            }
-            subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
-            if (subfd >= 0) {
-                dirsize = calculate_dir_size(subfd);
-            }
-            if(!strcmp(name,"lib")) {
-                codesize += dirsize + statsize;
-            } else if(!strcmp(name,"cache")) {
-                cachesize += dirsize + statsize;
-            } else {
-                datasize += dirsize + statsize;
-            }
-        } else if (de->d_type == DT_LNK && !strcmp(name,"lib")) {
-            // This is the symbolic link to the application's library
-            // code.  We'll count this as code instead of data, since
-            // it is not something that the app creates.
-            if (fstatat(dfd, name, &s, AT_SYMLINK_NOFOLLOW) == 0) {
-                codesize += stat_size(&s);
-            }
-        } else {
-            if (fstatat(dfd, name, &s, AT_SYMLINK_NOFOLLOW) == 0) {
-                datasize += stat_size(&s);
-            }
-        }
-    }
-    closedir(d);
-done:
-    *_codesize = codesize;
-    *_datasize = datasize;
-    *_cachesize = cachesize;
-    *_asecsize = asecsize;
-    return 0;
-}
-
-
-int create_cache_path(char path[PKG_PATH_MAX], const char *src)
-{
-    char *tmp;
-    int srclen;
-    int dstlen;
-
-    srclen = strlen(src);
-
-        /* demand that we are an absolute path */
-    if ((src == 0) || (src[0] != '/') || strstr(src,"..")) {
-        return -1;
-    }
-
-    if (srclen > PKG_PATH_MAX) {        // XXX: PKG_NAME_MAX?
-        return -1;
-    }
-
-    dstlen = srclen + strlen(DALVIK_CACHE_PREFIX) +
-        strlen(DALVIK_CACHE_POSTFIX) + 1;
-
-    if (dstlen > PKG_PATH_MAX) {
-        return -1;
-    }
-
-    sprintf(path,"%s%s%s",
-            DALVIK_CACHE_PREFIX,
-            src + 1, /* skip the leading / */
-            DALVIK_CACHE_POSTFIX);
-
-    for(tmp = path + strlen(DALVIK_CACHE_PREFIX); *tmp; tmp++) {
-        if (*tmp == '/') {
-            *tmp = '@';
-        }
-    }
-
-    return 0;
-}
-
-static void run_dexopt(int zip_fd, int odex_fd, const char* input_file_name,
-    const char* output_file_name)
-{
-    /* platform-specific flags affecting optimization and verification */
-    char dexopt_flags[PROPERTY_VALUE_MAX];
-    property_get("dalvik.vm.dexopt-flags", dexopt_flags, "");
-    ALOGV("dalvik.vm.dexopt-flags=%s\n", dexopt_flags);
-
-    static const char* DEX_OPT_BIN = "/system/bin/dexopt";
-    static const int MAX_INT_LEN = 12;      // '-'+10dig+'\0' -OR- 0x+8dig
-    char zip_num[MAX_INT_LEN];
-    char odex_num[MAX_INT_LEN];
-
-    sprintf(zip_num, "%d", zip_fd);
-    sprintf(odex_num, "%d", odex_fd);
-
-    ALOGV("Running %s in=%s out=%s\n", DEX_OPT_BIN, input_file_name, output_file_name);
-    execl(DEX_OPT_BIN, DEX_OPT_BIN, "--zip", zip_num, odex_num, input_file_name,
-        dexopt_flags, (char*) NULL);
-    ALOGE("execl(%s) failed: %s\n", DEX_OPT_BIN, strerror(errno));
-}
-
-static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
-    const char* output_file_name, const char *pkgname)
-{
-    char dex2oat_flags[PROPERTY_VALUE_MAX];
-    property_get("dalvik.vm.dex2oat-flags", dex2oat_flags, "");
-    ALOGV("dalvik.vm.dex2oat-flags=%s\n", dex2oat_flags);
-
-    static const char* DEX2OAT_BIN = "/system/bin/dex2oat";
-    static const int MAX_INT_LEN = 12;      // '-'+10dig+'\0' -OR- 0x+8dig
-    char zip_fd_arg[strlen("--zip-fd=") + MAX_INT_LEN];
-    char zip_location_arg[strlen("--zip-location=") + PKG_PATH_MAX];
-    char oat_fd_arg[strlen("--oat-fd=") + MAX_INT_LEN];
-    char oat_location_arg[strlen("--oat-name=") + PKG_PATH_MAX];
-    char profile_file[strlen("--profile-file=") + PKG_PATH_MAX];
-
-    sprintf(zip_fd_arg, "--zip-fd=%d", zip_fd);
-    sprintf(zip_location_arg, "--zip-location=%s", input_file_name);
-    sprintf(oat_fd_arg, "--oat-fd=%d", oat_fd);
-    sprintf(oat_location_arg, "--oat-location=%s", output_file_name);
-    if (strcmp(pkgname, "*") != 0) {
-        snprintf(profile_file, sizeof(profile_file), "--profile-file=%s/%s",
-                 DALVIK_CACHE_PREFIX "profiles", pkgname);
-    } else {
-        strcpy(profile_file, "--no-profile-file");
-    }
-
-    ALOGV("Running %s in=%s out=%s\n", DEX2OAT_BIN, input_file_name, output_file_name);
-    execl(DEX2OAT_BIN, DEX2OAT_BIN,
-          zip_fd_arg, zip_location_arg,
-          oat_fd_arg, oat_location_arg,
-          profile_file,
-          strlen(dex2oat_flags) > 0 ? dex2oat_flags : NULL,
-          (char*) NULL);
-    ALOGE("execl(%s) failed: %s\n", DEX2OAT_BIN, strerror(errno));
-}
-
-static int wait_child(pid_t pid)
-{
-    int status;
-    pid_t got_pid;
-
-    while (1) {
-        got_pid = waitpid(pid, &status, 0);
-        if (got_pid == -1 && errno == EINTR) {
-            printf("waitpid interrupted, retrying\n");
-        } else {
-            break;
-        }
-    }
-    if (got_pid != pid) {
-        ALOGW("waitpid failed: wanted %d, got %d: %s\n",
-            (int) pid, (int) got_pid, strerror(errno));
-        return 1;
-    }
-
-    if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
-        return 0;
-    } else {
-        return status;      /* always nonzero */
-    }
-}
-
-int dexopt(const char *apk_path, uid_t uid, int is_public,
-           const char *pkgname)
-{
-    struct utimbuf ut;
-    struct stat apk_stat, dex_stat;
-    char out_path[PKG_PATH_MAX];
-    char persist_sys_dalvik_vm_lib[PROPERTY_VALUE_MAX];
-    char *end;
-    int res, zip_fd=-1, out_fd=-1;
-
-    if (strlen(apk_path) >= (PKG_PATH_MAX - 8)) {
-        return -1;
-    }
-
-    /* The command to run depend on the value of persist.sys.dalvik.vm.lib */
-    property_get("persist.sys.dalvik.vm.lib.1", persist_sys_dalvik_vm_lib, "libdvm.so");
-
-    /* Before anything else: is there a .odex file?  If so, we have
-     * precompiled the apk and there is nothing to do here.
-     */
-    sprintf(out_path, "%s%s", apk_path, ".odex");
-    if (stat(out_path, &dex_stat) == 0) {
-        return 0;
-    }
-
-    if (create_cache_path(out_path, apk_path)) {
-        return -1;
-    }
-
-    memset(&apk_stat, 0, sizeof(apk_stat));
-    stat(apk_path, &apk_stat);
-
-    zip_fd = open(apk_path, O_RDONLY, 0);
-    if (zip_fd < 0) {
-        ALOGE("installd cannot open '%s' for input during dexopt\n", apk_path);
-        return -1;
-    }
-
-    unlink(out_path);
-    out_fd = open(out_path, O_RDWR | O_CREAT | O_EXCL, 0644);
-    if (out_fd < 0) {
-        ALOGE("installd cannot open '%s' for output during dexopt\n", out_path);
-        goto fail;
-    }
-    if (fchmod(out_fd,
-               S_IRUSR|S_IWUSR|S_IRGRP |
-               (is_public ? S_IROTH : 0)) < 0) {
-        ALOGE("installd cannot chmod '%s' during dexopt\n", out_path);
-        goto fail;
-    }
-    if (fchown(out_fd, AID_SYSTEM, uid) < 0) {
-        ALOGE("installd cannot chown '%s' during dexopt\n", out_path);
-        goto fail;
-    }
-
-    // Create profile file if there is a package name present.
-    if (strcmp(pkgname, "*") != 0) {
-        create_profile_file(pkgname, uid);
-    }
-
-
-    ALOGV("DexInv: --- BEGIN '%s' ---\n", apk_path);
-
-    pid_t pid;
-    pid = fork();
-    if (pid == 0) {
-        /* child -- drop privileges before continuing */
-        if (setgid(uid) != 0) {
-            ALOGE("setgid(%d) failed in installd during dexopt\n", uid);
-            exit(64);
-        }
-        if (setuid(uid) != 0) {
-            ALOGE("setuid(%d) failed in installd during dexopt\n", uid);
-            exit(65);
-        }
-        // drop capabilities
-        struct __user_cap_header_struct capheader;
-        struct __user_cap_data_struct capdata[2];
-        memset(&capheader, 0, sizeof(capheader));
-        memset(&capdata, 0, sizeof(capdata));
-        capheader.version = _LINUX_CAPABILITY_VERSION_3;
-        if (capset(&capheader, &capdata[0]) < 0) {
-            ALOGE("capset failed: %s\n", strerror(errno));
-            exit(66);
-        }
-        if (flock(out_fd, LOCK_EX | LOCK_NB) != 0) {
-            ALOGE("flock(%s) failed: %s\n", out_path, strerror(errno));
-            exit(67);
-        }
-
-        if (strncmp(persist_sys_dalvik_vm_lib, "libdvm", 6) == 0) {
-            run_dexopt(zip_fd, out_fd, apk_path, out_path);
-        } else if (strncmp(persist_sys_dalvik_vm_lib, "libart", 6) == 0) {
-            run_dex2oat(zip_fd, out_fd, apk_path, out_path, pkgname);
-        } else {
-            exit(69);   /* Unexpected persist.sys.dalvik.vm.lib value */
-        }
-        exit(68);   /* only get here on exec failure */
-    } else {
-        res = wait_child(pid);
-        if (res == 0) {
-            ALOGV("DexInv: --- END '%s' (success) ---\n", apk_path);
-        } else {
-            ALOGE("DexInv: --- END '%s' --- status=0x%04x, process failed\n", apk_path, res);
-            goto fail;
-        }
-    }
-
-    ut.actime = apk_stat.st_atime;
-    ut.modtime = apk_stat.st_mtime;
-    utime(out_path, &ut);
-
-    close(out_fd);
-    close(zip_fd);
-    return 0;
-
-fail:
-    if (out_fd >= 0) {
-        close(out_fd);
-        unlink(out_path);
-    }
-    if (zip_fd >= 0) {
-        close(zip_fd);
-    }
-    return -1;
-}
-
-void mkinnerdirs(char* path, int basepos, mode_t mode, int uid, int gid,
-        struct stat* statbuf)
-{
-    while (path[basepos] != 0) {
-        if (path[basepos] == '/') {
-            path[basepos] = 0;
-            if (lstat(path, statbuf) < 0) {
-                ALOGV("Making directory: %s\n", path);
-                if (mkdir(path, mode) == 0) {
-                    chown(path, uid, gid);
-                } else {
-                    ALOGW("Unable to make directory %s: %s\n", path, strerror(errno));
-                }
-            }
-            path[basepos] = '/';
-            basepos++;
-        }
-        basepos++;
-    }
-}
-
-int movefileordir(char* srcpath, char* dstpath, int dstbasepos,
-        int dstuid, int dstgid, struct stat* statbuf)
-{
-    DIR *d;
-    struct dirent *de;
-    int res;
-
-    int srcend = strlen(srcpath);
-    int dstend = strlen(dstpath);
-
-    if (lstat(srcpath, statbuf) < 0) {
-        ALOGW("Unable to stat %s: %s\n", srcpath, strerror(errno));
-        return 1;
-    }
-
-    if ((statbuf->st_mode&S_IFDIR) == 0) {
-        mkinnerdirs(dstpath, dstbasepos, S_IRWXU|S_IRWXG|S_IXOTH,
-                dstuid, dstgid, statbuf);
-        ALOGV("Renaming %s to %s (uid %d)\n", srcpath, dstpath, dstuid);
-        if (rename(srcpath, dstpath) >= 0) {
-            if (chown(dstpath, dstuid, dstgid) < 0) {
-                ALOGE("cannot chown %s: %s\n", dstpath, strerror(errno));
-                unlink(dstpath);
-                return 1;
-            }
-        } else {
-            ALOGW("Unable to rename %s to %s: %s\n",
-                srcpath, dstpath, strerror(errno));
-            return 1;
-        }
-        return 0;
-    }
-
-    d = opendir(srcpath);
-    if (d == NULL) {
-        ALOGW("Unable to opendir %s: %s\n", srcpath, strerror(errno));
-        return 1;
-    }
-
-    res = 0;
-
-    while ((de = readdir(d))) {
-        const char *name = de->d_name;
-            /* always skip "." and ".." */
-        if (name[0] == '.') {
-            if (name[1] == 0) continue;
-            if ((name[1] == '.') && (name[2] == 0)) continue;
-        }
-
-        if ((srcend+strlen(name)) >= (PKG_PATH_MAX-2)) {
-            ALOGW("Source path too long; skipping: %s/%s\n", srcpath, name);
-            continue;
-        }
-
-        if ((dstend+strlen(name)) >= (PKG_PATH_MAX-2)) {
-            ALOGW("Destination path too long; skipping: %s/%s\n", dstpath, name);
-            continue;
-        }
-
-        srcpath[srcend] = dstpath[dstend] = '/';
-        strcpy(srcpath+srcend+1, name);
-        strcpy(dstpath+dstend+1, name);
-
-        if (movefileordir(srcpath, dstpath, dstbasepos, dstuid, dstgid, statbuf) != 0) {
-            res = 1;
-        }
-
-        // Note: we will be leaving empty directories behind in srcpath,
-        // but that is okay, the package manager will be erasing all of the
-        // data associated with .apks that disappear.
-
-        srcpath[srcend] = dstpath[dstend] = 0;
-    }
-
-    closedir(d);
-    return res;
-}
-
-int movefiles()
-{
-    DIR *d;
-    int dfd, subfd;
-    struct dirent *de;
-    struct stat s;
-    char buf[PKG_PATH_MAX+1];
-    int bufp, bufe, bufi, readlen;
-
-    char srcpkg[PKG_NAME_MAX];
-    char dstpkg[PKG_NAME_MAX];
-    char srcpath[PKG_PATH_MAX];
-    char dstpath[PKG_PATH_MAX];
-    int dstuid=-1, dstgid=-1;
-    int hasspace;
-
-    d = opendir(UPDATE_COMMANDS_DIR_PREFIX);
-    if (d == NULL) {
-        goto done;
-    }
-    dfd = dirfd(d);
-
-        /* Iterate through all files in the directory, executing the
-         * file movements requested there-in.
-         */
-    while ((de = readdir(d))) {
-        const char *name = de->d_name;
-
-        if (de->d_type == DT_DIR) {
-            continue;
-        } else {
-            subfd = openat(dfd, name, O_RDONLY);
-            if (subfd < 0) {
-                ALOGW("Unable to open update commands at %s%s\n",
-                        UPDATE_COMMANDS_DIR_PREFIX, name);
-                continue;
-            }
-
-            bufp = 0;
-            bufe = 0;
-            buf[PKG_PATH_MAX] = 0;
-            srcpkg[0] = dstpkg[0] = 0;
-            while (1) {
-                bufi = bufp;
-                while (bufi < bufe && buf[bufi] != '\n') {
-                    bufi++;
-                }
-                if (bufi < bufe) {
-                    buf[bufi] = 0;
-                    ALOGV("Processing line: %s\n", buf+bufp);
-                    hasspace = 0;
-                    while (bufp < bufi && isspace(buf[bufp])) {
-                        hasspace = 1;
-                        bufp++;
-                    }
-                    if (buf[bufp] == '#' || bufp == bufi) {
-                        // skip comments and empty lines.
-                    } else if (hasspace) {
-                        if (dstpkg[0] == 0) {
-                            ALOGW("Path before package line in %s%s: %s\n",
-                                    UPDATE_COMMANDS_DIR_PREFIX, name, buf+bufp);
-                        } else if (srcpkg[0] == 0) {
-                            // Skip -- source package no longer exists.
-                        } else {
-                            ALOGV("Move file: %s (from %s to %s)\n", buf+bufp, srcpkg, dstpkg);
-                            if (!create_move_path(srcpath, srcpkg, buf+bufp, 0) &&
-                                    !create_move_path(dstpath, dstpkg, buf+bufp, 0)) {
-                                movefileordir(srcpath, dstpath,
-                                        strlen(dstpath)-strlen(buf+bufp),
-                                        dstuid, dstgid, &s);
-                            }
-                        }
-                    } else {
-                        char* div = strchr(buf+bufp, ':');
-                        if (div == NULL) {
-                            ALOGW("Bad package spec in %s%s; no ':' sep: %s\n",
-                                    UPDATE_COMMANDS_DIR_PREFIX, name, buf+bufp);
-                        } else {
-                            *div = 0;
-                            div++;
-                            if (strlen(buf+bufp) < PKG_NAME_MAX) {
-                                strcpy(dstpkg, buf+bufp);
-                            } else {
-                                srcpkg[0] = dstpkg[0] = 0;
-                                ALOGW("Package name too long in %s%s: %s\n",
-                                        UPDATE_COMMANDS_DIR_PREFIX, name, buf+bufp);
-                            }
-                            if (strlen(div) < PKG_NAME_MAX) {
-                                strcpy(srcpkg, div);
-                            } else {
-                                srcpkg[0] = dstpkg[0] = 0;
-                                ALOGW("Package name too long in %s%s: %s\n",
-                                        UPDATE_COMMANDS_DIR_PREFIX, name, div);
-                            }
-                            if (srcpkg[0] != 0) {
-                                if (!create_pkg_path(srcpath, srcpkg, PKG_DIR_POSTFIX, 0)) {
-                                    if (lstat(srcpath, &s) < 0) {
-                                        // Package no longer exists -- skip.
-                                        srcpkg[0] = 0;
-                                    }
-                                } else {
-                                    srcpkg[0] = 0;
-                                    ALOGW("Can't create path %s in %s%s\n",
-                                            div, UPDATE_COMMANDS_DIR_PREFIX, name);
-                                }
-                                if (srcpkg[0] != 0) {
-                                    if (!create_pkg_path(dstpath, dstpkg, PKG_DIR_POSTFIX, 0)) {
-                                        if (lstat(dstpath, &s) == 0) {
-                                            dstuid = s.st_uid;
-                                            dstgid = s.st_gid;
-                                        } else {
-                                            // Destination package doesn't
-                                            // exist...  due to original-package,
-                                            // this is normal, so don't be
-                                            // noisy about it.
-                                            srcpkg[0] = 0;
-                                        }
-                                    } else {
-                                        srcpkg[0] = 0;
-                                        ALOGW("Can't create path %s in %s%s\n",
-                                                div, UPDATE_COMMANDS_DIR_PREFIX, name);
-                                    }
-                                }
-                                ALOGV("Transfering from %s to %s: uid=%d\n",
-                                    srcpkg, dstpkg, dstuid);
-                            }
-                        }
-                    }
-                    bufp = bufi+1;
-                } else {
-                    if (bufp == 0) {
-                        if (bufp < bufe) {
-                            ALOGW("Line too long in %s%s, skipping: %s\n",
-                                    UPDATE_COMMANDS_DIR_PREFIX, name, buf);
-                        }
-                    } else if (bufp < bufe) {
-                        memcpy(buf, buf+bufp, bufe-bufp);
-                        bufe -= bufp;
-                        bufp = 0;
-                    }
-                    readlen = read(subfd, buf+bufe, PKG_PATH_MAX-bufe);
-                    if (readlen < 0) {
-                        ALOGW("Failure reading update commands in %s%s: %s\n",
-                                UPDATE_COMMANDS_DIR_PREFIX, name, strerror(errno));
-                        break;
-                    } else if (readlen == 0) {
-                        break;
-                    }
-                    bufe += readlen;
-                    buf[bufe] = 0;
-                    ALOGV("Read buf: %s\n", buf);
-                }
-            }
-            close(subfd);
-        }
-    }
-    closedir(d);
-done:
-    return 0;
-}
-
-int linklib(const char* pkgname, const char* asecLibDir, int userId)
-{
-    char pkgdir[PKG_PATH_MAX];
-    char libsymlink[PKG_PATH_MAX];
-    struct stat s, libStat;
-    int rc = 0;
-
-    if (create_pkg_path(pkgdir, pkgname, PKG_DIR_POSTFIX, userId)) {
-        ALOGE("cannot create package path\n");
-        return -1;
-    }
-    if (create_pkg_path(libsymlink, pkgname, PKG_LIB_POSTFIX, userId)) {
-        ALOGE("cannot create package lib symlink origin path\n");
-        return -1;
-    }
-
-    if (stat(pkgdir, &s) < 0) return -1;
-
-    if (chown(pkgdir, AID_INSTALL, AID_INSTALL) < 0) {
-        ALOGE("failed to chown '%s': %s\n", pkgdir, strerror(errno));
-        return -1;
-    }
-
-    if (chmod(pkgdir, 0700) < 0) {
-        ALOGE("linklib() 1: failed to chmod '%s': %s\n", pkgdir, strerror(errno));
-        rc = -1;
-        goto out;
-    }
-
-    if (lstat(libsymlink, &libStat) < 0) {
-        if (errno != ENOENT) {
-            ALOGE("couldn't stat lib dir: %s\n", strerror(errno));
-            rc = -1;
-            goto out;
-        }
-    } else {
-        if (S_ISDIR(libStat.st_mode)) {
-            if (delete_dir_contents(libsymlink, 1, 0) < 0) {
-                rc = -1;
-                goto out;
-            }
-        } else if (S_ISLNK(libStat.st_mode)) {
-            if (unlink(libsymlink) < 0) {
-                ALOGE("couldn't unlink lib dir: %s\n", strerror(errno));
-                rc = -1;
-                goto out;
-            }
-        }
-    }
-
-    if (symlink(asecLibDir, libsymlink) < 0) {
-        ALOGE("couldn't symlink directory '%s' -> '%s': %s\n", libsymlink, asecLibDir,
-                strerror(errno));
-        rc = -errno;
-        goto out;
-    }
-
-out:
-    if (chmod(pkgdir, s.st_mode) < 0) {
-        ALOGE("linklib() 2: failed to chmod '%s': %s\n", pkgdir, strerror(errno));
-        rc = -errno;
-    }
-
-    if (chown(pkgdir, s.st_uid, s.st_gid) < 0) {
-        ALOGE("failed to chown '%s' : %s\n", pkgdir, strerror(errno));
-        return -errno;
-    }
-
-    return rc;
-}
-
-static void run_idmap(const char *target_apk, const char *overlay_apk, int idmap_fd)
-{
-    static const char *IDMAP_BIN = "/system/bin/idmap";
-    static const size_t MAX_INT_LEN = 32;
-    char idmap_str[MAX_INT_LEN];
-
-    snprintf(idmap_str, sizeof(idmap_str), "%d", idmap_fd);
-
-    execl(IDMAP_BIN, IDMAP_BIN, "--fd", target_apk, overlay_apk, idmap_str, (char*)NULL);
-    ALOGE("execl(%s) failed: %s\n", IDMAP_BIN, strerror(errno));
-}
-
-// Transform string /a/b/c.apk to (prefix)/a@b@c.apk@(suffix)
-// eg /a/b/c.apk to /data/resource-cache/a@b@c.apk@idmap
-static int flatten_path(const char *prefix, const char *suffix,
-        const char *overlay_path, char *idmap_path, size_t N)
-{
-    if (overlay_path == NULL || idmap_path == NULL) {
-        return -1;
-    }
-    const size_t len_overlay_path = strlen(overlay_path);
-    // will access overlay_path + 1 further below; requires absolute path
-    if (len_overlay_path < 2 || *overlay_path != '/') {
-        return -1;
-    }
-    const size_t len_idmap_root = strlen(prefix);
-    const size_t len_suffix = strlen(suffix);
-    if (SIZE_MAX - len_idmap_root < len_overlay_path ||
-            SIZE_MAX - (len_idmap_root + len_overlay_path) < len_suffix) {
-        // additions below would cause overflow
-        return -1;
-    }
-    if (N < len_idmap_root + len_overlay_path + len_suffix) {
-        return -1;
-    }
-    memset(idmap_path, 0, N);
-    snprintf(idmap_path, N, "%s%s%s", prefix, overlay_path + 1, suffix);
-    char *ch = idmap_path + len_idmap_root;
-    while (*ch != '\0') {
-        if (*ch == '/') {
-            *ch = '@';
-        }
-        ++ch;
-    }
-    return 0;
-}
-
-int idmap(const char *target_apk, const char *overlay_apk, uid_t uid)
-{
-    ALOGV("idmap target_apk=%s overlay_apk=%s uid=%d\n", target_apk, overlay_apk, uid);
-
-    int idmap_fd = -1;
-    char idmap_path[PATH_MAX];
-
-    if (flatten_path(IDMAP_PREFIX, IDMAP_SUFFIX, overlay_apk,
-                idmap_path, sizeof(idmap_path)) == -1) {
-        ALOGE("idmap cannot generate idmap path for overlay %s\n", overlay_apk);
-        goto fail;
-    }
-
-    unlink(idmap_path);
-    idmap_fd = open(idmap_path, O_RDWR | O_CREAT | O_EXCL, 0644);
-    if (idmap_fd < 0) {
-        ALOGE("idmap cannot open '%s' for output: %s\n", idmap_path, strerror(errno));
-        goto fail;
-    }
-    if (fchown(idmap_fd, AID_SYSTEM, uid) < 0) {
-        ALOGE("idmap cannot chown '%s'\n", idmap_path);
-        goto fail;
-    }
-    if (fchmod(idmap_fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) < 0) {
-        ALOGE("idmap cannot chmod '%s'\n", idmap_path);
-        goto fail;
-    }
-
-    pid_t pid;
-    pid = fork();
-    if (pid == 0) {
-        /* child -- drop privileges before continuing */
-        if (setgid(uid) != 0) {
-            ALOGE("setgid(%d) failed during idmap\n", uid);
-            exit(1);
-        }
-        if (setuid(uid) != 0) {
-            ALOGE("setuid(%d) failed during idmap\n", uid);
-            exit(1);
-        }
-        if (flock(idmap_fd, LOCK_EX | LOCK_NB) != 0) {
-            ALOGE("flock(%s) failed during idmap: %s\n", idmap_path, strerror(errno));
-            exit(1);
-        }
-
-        run_idmap(target_apk, overlay_apk, idmap_fd);
-        exit(1); /* only if exec call to idmap failed */
-    } else {
-        int status = wait_child(pid);
-        if (status != 0) {
-            ALOGE("idmap failed, status=0x%04x\n", status);
-            goto fail;
-        }
-    }
-
-    close(idmap_fd);
-    return 0;
-fail:
-    if (idmap_fd >= 0) {
-        close(idmap_fd);
-        unlink(idmap_path);
-    }
-    return -1;
-}
-
-int restorecon_data(const char* pkgName, const char* seinfo, uid_t uid)
-{
-    struct dirent *entry;
-    DIR *d;
-    struct stat s;
-    char *userdir;
-    char *primarydir;
-    char *pkgdir;
-    int ret = 0;
-
-    // SELINUX_ANDROID_RESTORECON_DATADATA flag is set by libselinux. Not needed here.
-    unsigned int flags = SELINUX_ANDROID_RESTORECON_RECURSE;
-
-    if (!pkgName || !seinfo) {
-        ALOGE("Package name or seinfo tag is null when trying to restorecon.");
-        return -1;
-    }
-
-    if (asprintf(&primarydir, "%s%s%s", android_data_dir.path, PRIMARY_USER_PREFIX, pkgName) < 0) {
-        return -1;
-    }
-
-    // Relabel for primary user.
-    if (selinux_android_restorecon_pkgdir(primarydir, seinfo, uid, flags) < 0) {
-        ALOGE("restorecon failed for %s: %s\n", primarydir, strerror(errno));
-        ret |= -1;
-    }
-
-    if (asprintf(&userdir, "%s%s", android_data_dir.path, SECONDARY_USER_PREFIX) < 0) {
-        free(primarydir);
-        return -1;
-    }
-
-    // Relabel package directory for all secondary users.
-    d = opendir(userdir);
-    if (d == NULL) {
-        free(primarydir);
-        free(userdir);
-        return -1;
-    }
-
-    while ((entry = readdir(d))) {
-        if (entry->d_type != DT_DIR) {
-            continue;
-        }
-
-        const char *user = entry->d_name;
-        // Ignore "." and ".."
-        if (!strcmp(user, ".") || !strcmp(user, "..")) {
-            continue;
-        }
-
-        // user directories start with a number
-        if (user[0] < '0' || user[0] > '9') {
-            ALOGE("Expecting numbered directory during restorecon. Instead got '%s'.", user);
-            continue;
-        }
-
-        if (asprintf(&pkgdir, "%s%s/%s", userdir, user, pkgName) < 0) {
-            continue;
-        }
-
-        if (stat(pkgdir, &s) < 0) {
-            free(pkgdir);
-            continue;
-        }
-
-        if (selinux_android_restorecon_pkgdir(pkgdir, seinfo, uid, flags) < 0) {
-            ALOGE("restorecon failed for %s: %s\n", pkgdir, strerror(errno));
-            ret |= -1;
-        }
-        free(pkgdir);
-    }
-
-    closedir(d);
-    free(primarydir);
-    free(userdir);
-    return ret;
-}
diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp
new file mode 100644
index 0000000..5ecadef
--- /dev/null
+++ b/cmds/installd/commands.cpp
@@ -0,0 +1,1843 @@
+/*
+** Copyright 2008, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include "installd.h"
+
+#include <android-base/stringprintf.h>
+#include <android-base/logging.h>
+#include <cutils/sched_policy.h>
+#include <diskusage/dirsize.h>
+#include <logwrap/logwrap.h>
+#include <system/thread_defs.h>
+#include <selinux/android.h>
+
+#include <inttypes.h>
+#include <sys/capability.h>
+#include <sys/file.h>
+#include <unistd.h>
+
+using android::base::StringPrintf;
+
+/* Directory records that are used in execution of commands. */
+dir_rec_t android_data_dir;
+dir_rec_t android_asec_dir;
+dir_rec_t android_app_dir;
+dir_rec_t android_app_private_dir;
+dir_rec_t android_app_lib_dir;
+dir_rec_t android_media_dir;
+dir_rec_t android_mnt_expand_dir;
+dir_rec_array_t android_system_dirs;
+
+static const char* kCpPath = "/system/bin/cp";
+
+int install(const char *uuid, const char *pkgname, uid_t uid, gid_t gid, const char *seinfo)
+{
+    if ((uid < AID_SYSTEM) || (gid < AID_SYSTEM)) {
+        ALOGE("invalid uid/gid: %d %d\n", uid, gid);
+        return -1;
+    }
+
+    std::string _pkgdir(create_data_user_package_path(uuid, 0, pkgname));
+    const char* pkgdir = _pkgdir.c_str();
+
+    if (mkdir(pkgdir, 0751) < 0) {
+        ALOGE("cannot create dir '%s': %s\n", pkgdir, strerror(errno));
+        return -1;
+    }
+    if (chmod(pkgdir, 0751) < 0) {
+        ALOGE("cannot chmod dir '%s': %s\n", pkgdir, strerror(errno));
+        unlink(pkgdir);
+        return -1;
+    }
+
+    if (selinux_android_setfilecon(pkgdir, pkgname, seinfo, uid) < 0) {
+        ALOGE("cannot setfilecon dir '%s': %s\n", pkgdir, strerror(errno));
+        unlink(pkgdir);
+        return -errno;
+    }
+
+    if (chown(pkgdir, uid, gid) < 0) {
+        ALOGE("cannot chown dir '%s': %s\n", pkgdir, strerror(errno));
+        unlink(pkgdir);
+        return -1;
+    }
+
+    return 0;
+}
+
+int uninstall(const char *uuid, const char *pkgname, userid_t userid)
+{
+    std::string _pkgdir(create_data_user_package_path(uuid, userid, pkgname));
+    const char* pkgdir = _pkgdir.c_str();
+
+    /* delete contents AND directory, no exceptions */
+    return delete_dir_contents(pkgdir, 1, NULL);
+}
+
+int renamepkg(const char *oldpkgname, const char *newpkgname)
+{
+    char oldpkgdir[PKG_PATH_MAX];
+    char newpkgdir[PKG_PATH_MAX];
+
+    if (create_pkg_path(oldpkgdir, oldpkgname, PKG_DIR_POSTFIX, 0))
+        return -1;
+    if (create_pkg_path(newpkgdir, newpkgname, PKG_DIR_POSTFIX, 0))
+        return -1;
+
+    if (rename(oldpkgdir, newpkgdir) < 0) {
+        ALOGE("cannot rename dir '%s' to '%s': %s\n", oldpkgdir, newpkgdir, strerror(errno));
+        return -errno;
+    }
+    return 0;
+}
+
+int fix_uid(const char *uuid, const char *pkgname, uid_t uid, gid_t gid)
+{
+    struct stat s;
+
+    if ((uid < AID_SYSTEM) || (gid < AID_SYSTEM)) {
+        ALOGE("invalid uid/gid: %d %d\n", uid, gid);
+        return -1;
+    }
+
+    std::string _pkgdir(create_data_user_package_path(uuid, 0, pkgname));
+    const char* pkgdir = _pkgdir.c_str();
+
+    if (stat(pkgdir, &s) < 0) return -1;
+
+    if (s.st_uid != 0 || s.st_gid != 0) {
+        ALOGE("fixing uid of non-root pkg: %s %" PRIu32 " %" PRIu32 "\n", pkgdir, s.st_uid, s.st_gid);
+        return -1;
+    }
+
+    if (chmod(pkgdir, 0751) < 0) {
+        ALOGE("cannot chmod dir '%s': %s\n", pkgdir, strerror(errno));
+        unlink(pkgdir);
+        return -errno;
+    }
+    if (chown(pkgdir, uid, gid) < 0) {
+        ALOGE("cannot chown dir '%s': %s\n", pkgdir, strerror(errno));
+        unlink(pkgdir);
+        return -errno;
+    }
+
+    return 0;
+}
+
+int delete_user_data(const char *uuid, const char *pkgname, userid_t userid)
+{
+    std::string _pkgdir(create_data_user_package_path(uuid, userid, pkgname));
+    const char* pkgdir = _pkgdir.c_str();
+
+    return delete_dir_contents(pkgdir, 0, NULL);
+}
+
+int make_user_data(const char *uuid, const char *pkgname, uid_t uid, userid_t userid, const char* seinfo)
+{
+    std::string _pkgdir(create_data_user_package_path(uuid, userid, pkgname));
+    const char* pkgdir = _pkgdir.c_str();
+
+    if (mkdir(pkgdir, 0751) < 0) {
+        ALOGE("cannot create dir '%s': %s\n", pkgdir, strerror(errno));
+        return -errno;
+    }
+    if (chmod(pkgdir, 0751) < 0) {
+        ALOGE("cannot chmod dir '%s': %s\n", pkgdir, strerror(errno));
+        unlink(pkgdir);
+        return -errno;
+    }
+
+    if (selinux_android_setfilecon(pkgdir, pkgname, seinfo, uid) < 0) {
+        ALOGE("cannot setfilecon dir '%s': %s\n", pkgdir, strerror(errno));
+        unlink(pkgdir);
+        return -errno;
+    }
+
+    if (chown(pkgdir, uid, uid) < 0) {
+        ALOGE("cannot chown dir '%s': %s\n", pkgdir, strerror(errno));
+        unlink(pkgdir);
+        return -errno;
+    }
+
+    return 0;
+}
+
+int copy_complete_app(const char *from_uuid, const char *to_uuid,
+        const char *package_name, const char *data_app_name, appid_t appid,
+        const char* seinfo) {
+    std::vector<userid_t> users = get_known_users(from_uuid);
+
+    // Copy app
+    {
+        std::string from(create_data_app_package_path(from_uuid, data_app_name));
+        std::string to(create_data_app_package_path(to_uuid, data_app_name));
+        std::string to_parent(create_data_app_path(to_uuid));
+
+        char *argv[] = {
+            (char*) kCpPath,
+            (char*) "-F", /* delete any existing destination file first (--remove-destination) */
+            (char*) "-p", /* preserve timestamps, ownership, and permissions */
+            (char*) "-R", /* recurse into subdirectories (DEST must be a directory) */
+            (char*) "-P", /* Do not follow symlinks [default] */
+            (char*) "-d", /* don't dereference symlinks */
+            (char*) from.c_str(),
+            (char*) to_parent.c_str()
+        };
+
+        LOG(DEBUG) << "Copying " << from << " to " << to;
+        int rc = android_fork_execvp(ARRAY_SIZE(argv), argv, NULL, false, true);
+
+        if (rc != 0) {
+            LOG(ERROR) << "Failed copying " << from << " to " << to
+                    << ": status " << rc;
+            goto fail;
+        }
+
+        if (selinux_android_restorecon(to.c_str(), SELINUX_ANDROID_RESTORECON_RECURSE) != 0) {
+            LOG(ERROR) << "Failed to restorecon " << to;
+            goto fail;
+        }
+    }
+
+    // Copy private data for all known users
+    for (auto user : users) {
+        std::string from(create_data_user_package_path(from_uuid, user, package_name));
+        std::string to(create_data_user_package_path(to_uuid, user, package_name));
+        std::string to_parent(create_data_user_path(to_uuid, user));
+
+        // Data source may not exist for all users; that's okay
+        if (access(from.c_str(), F_OK) != 0) {
+            LOG(INFO) << "Missing source " << from;
+            continue;
+        }
+
+        std::string user_path(create_data_user_path(to_uuid, user));
+        if (fs_prepare_dir(user_path.c_str(), 0771, AID_SYSTEM, AID_SYSTEM) != 0) {
+            LOG(ERROR) << "Failed to prepare user target " << user_path;
+            goto fail;
+        }
+
+        uid_t uid = multiuser_get_uid(user, appid);
+        if (make_user_data(to_uuid, package_name, uid, user, seinfo) != 0) {
+            LOG(ERROR) << "Failed to create package target " << to;
+            goto fail;
+        }
+
+        char *argv[] = {
+            (char*) kCpPath,
+            (char*) "-F", /* delete any existing destination file first (--remove-destination) */
+            (char*) "-p", /* preserve timestamps, ownership, and permissions */
+            (char*) "-R", /* recurse into subdirectories (DEST must be a directory) */
+            (char*) "-P", /* Do not follow symlinks [default] */
+            (char*) "-d", /* don't dereference symlinks */
+            (char*) from.c_str(),
+            (char*) to_parent.c_str()
+        };
+
+        LOG(DEBUG) << "Copying " << from << " to " << to;
+        int rc = android_fork_execvp(ARRAY_SIZE(argv), argv, NULL, false, true);
+
+        if (rc != 0) {
+            LOG(ERROR) << "Failed copying " << from << " to " << to
+                    << ": status " << rc;
+            goto fail;
+        }
+    }
+
+    if (restorecon_data(to_uuid, package_name, seinfo, multiuser_get_uid(0, appid)) != 0) {
+        LOG(ERROR) << "Failed to restorecon";
+        goto fail;
+    }
+
+    // We let the framework scan the new location and persist that before
+    // deleting the data in the old location; this ordering ensures that
+    // we can recover from things like battery pulls.
+    return 0;
+
+fail:
+    // Nuke everything we might have already copied
+    {
+        std::string to(create_data_app_package_path(to_uuid, data_app_name));
+        if (delete_dir_contents(to.c_str(), 1, NULL) != 0) {
+            LOG(WARNING) << "Failed to rollback " << to;
+        }
+    }
+    for (auto user : users) {
+        std::string to(create_data_user_package_path(to_uuid, user, package_name));
+        if (delete_dir_contents(to.c_str(), 1, NULL) != 0) {
+            LOG(WARNING) << "Failed to rollback " << to;
+        }
+    }
+    return -1;
+}
+
+int make_user_config(userid_t userid)
+{
+    if (ensure_config_user_dirs(userid) == -1) {
+        return -1;
+    }
+
+    return 0;
+}
+
+int delete_user(const char *uuid, userid_t userid)
+{
+    int status = 0;
+
+    std::string data_path(create_data_user_path(uuid, userid));
+    if (delete_dir_contents(data_path.c_str(), 1, NULL) != 0) {
+        status = -1;
+    }
+
+    std::string media_path(create_data_media_path(uuid, userid));
+    if (delete_dir_contents(media_path.c_str(), 1, NULL) != 0) {
+        status = -1;
+    }
+
+    // Config paths only exist on internal storage
+    if (uuid == nullptr) {
+        char config_path[PATH_MAX];
+        if ((create_user_config_path(config_path, userid) != 0)
+                || (delete_dir_contents(config_path, 1, NULL) != 0)) {
+            status = -1;
+        }
+    }
+
+    return status;
+}
+
+int delete_cache(const char *uuid, const char *pkgname, userid_t userid)
+{
+    std::string _cachedir(
+            create_data_user_package_path(uuid, userid, pkgname) + CACHE_DIR_POSTFIX);
+    const char* cachedir = _cachedir.c_str();
+
+    /* delete contents, not the directory, no exceptions */
+    return delete_dir_contents(cachedir, 0, NULL);
+}
+
+int delete_code_cache(const char *uuid, const char *pkgname, userid_t userid)
+{
+    std::string _codecachedir(
+            create_data_user_package_path(uuid, userid, pkgname) + CODE_CACHE_DIR_POSTFIX);
+    const char* codecachedir = _codecachedir.c_str();
+
+    struct stat s;
+
+    /* it's okay if code cache is missing */
+    if (lstat(codecachedir, &s) == -1 && errno == ENOENT) {
+        return 0;
+    }
+
+    /* delete contents, not the directory, no exceptions */
+    return delete_dir_contents(codecachedir, 0, NULL);
+}
+
+/* Try to ensure free_size bytes of storage are available.
+ * Returns 0 on success.
+ * This is rather simple-minded because doing a full LRU would
+ * be potentially memory-intensive, and without atime it would
+ * also require that apps constantly modify file metadata even
+ * when just reading from the cache, which is pretty awful.
+ */
+int free_cache(const char *uuid, int64_t free_size)
+{
+    cache_t* cache;
+    int64_t avail;
+    DIR *d;
+    struct dirent *de;
+    char tmpdir[PATH_MAX];
+    char *dirpos;
+
+    std::string data_path(create_data_path(uuid));
+
+    avail = data_disk_free(data_path);
+    if (avail < 0) return -1;
+
+    ALOGI("free_cache(%" PRId64 ") avail %" PRId64 "\n", free_size, avail);
+    if (avail >= free_size) return 0;
+
+    cache = start_cache_collection();
+
+    // Special case for owner on internal storage
+    if (uuid == nullptr) {
+        std::string _tmpdir(create_data_user_path(nullptr, 0));
+        add_cache_files(cache, _tmpdir.c_str(), "cache");
+    }
+
+    // Search for other users and add any cache files from them.
+    std::string _tmpdir(create_data_path(uuid) + "/" + SECONDARY_USER_PREFIX);
+    strcpy(tmpdir, _tmpdir.c_str());
+
+    dirpos = tmpdir + strlen(tmpdir);
+    d = opendir(tmpdir);
+    if (d != NULL) {
+        while ((de = readdir(d))) {
+            if (de->d_type == DT_DIR) {
+                const char *name = de->d_name;
+                    /* always skip "." and ".." */
+                if (name[0] == '.') {
+                    if (name[1] == 0) continue;
+                    if ((name[1] == '.') && (name[2] == 0)) continue;
+                }
+                if ((strlen(name)+(dirpos-tmpdir)) < (sizeof(tmpdir)-1)) {
+                    strcpy(dirpos, name);
+                    //ALOGI("adding cache files from %s\n", tmpdir);
+                    add_cache_files(cache, tmpdir, "cache");
+                } else {
+                    ALOGW("Path exceeds limit: %s%s", tmpdir, name);
+                }
+            }
+        }
+        closedir(d);
+    }
+
+    // Collect cache files on external storage for all users (if it is mounted as part
+    // of the internal storage).
+    strcpy(tmpdir, android_media_dir.path);
+    dirpos = tmpdir + strlen(tmpdir);
+    d = opendir(tmpdir);
+    if (d != NULL) {
+        while ((de = readdir(d))) {
+            if (de->d_type == DT_DIR) {
+                const char *name = de->d_name;
+                    /* skip any dir that doesn't start with a number, so not a user */
+                if (name[0] < '0' || name[0] > '9') {
+                    continue;
+                }
+                if ((strlen(name)+(dirpos-tmpdir)) < (sizeof(tmpdir)-1)) {
+                    strcpy(dirpos, name);
+                    if (lookup_media_dir(tmpdir, "Android") == 0
+                            && lookup_media_dir(tmpdir, "data") == 0) {
+                        //ALOGI("adding cache files from %s\n", tmpdir);
+                        add_cache_files(cache, tmpdir, "cache");
+                    }
+                } else {
+                    ALOGW("Path exceeds limit: %s%s", tmpdir, name);
+                }
+            }
+        }
+        closedir(d);
+    }
+
+    clear_cache_files(data_path, cache, free_size);
+    finish_cache_collection(cache);
+
+    return data_disk_free(data_path) >= free_size ? 0 : -1;
+}
+
+int move_dex(const char *src, const char *dst, const char *instruction_set)
+{
+    char src_dex[PKG_PATH_MAX];
+    char dst_dex[PKG_PATH_MAX];
+
+    if (validate_apk_path(src)) {
+        ALOGE("invalid apk path '%s' (bad prefix)\n", src);
+        return -1;
+    }
+    if (validate_apk_path(dst)) {
+        ALOGE("invalid apk path '%s' (bad prefix)\n", dst);
+        return -1;
+    }
+
+    if (create_cache_path(src_dex, src, instruction_set)) return -1;
+    if (create_cache_path(dst_dex, dst, instruction_set)) return -1;
+
+    ALOGV("move %s -> %s\n", src_dex, dst_dex);
+    if (rename(src_dex, dst_dex) < 0) {
+        ALOGE("Couldn't move %s: %s\n", src_dex, strerror(errno));
+        return -1;
+    } else {
+        return 0;
+    }
+}
+
+int rm_dex(const char *path, const char *instruction_set)
+{
+    char dex_path[PKG_PATH_MAX];
+
+    if (validate_apk_path(path) && validate_system_app_path(path)) {
+        ALOGE("invalid apk path '%s' (bad prefix)\n", path);
+        return -1;
+    }
+
+    if (create_cache_path(dex_path, path, instruction_set)) return -1;
+
+    ALOGV("unlink %s\n", dex_path);
+    if (unlink(dex_path) < 0) {
+        if (errno != ENOENT) {
+            ALOGE("Couldn't unlink %s: %s\n", dex_path, strerror(errno));
+        }
+        return -1;
+    } else {
+        return 0;
+    }
+}
+
+int get_size(const char *uuid, const char *pkgname, int userid, const char *apkpath,
+             const char *libdirpath, const char *fwdlock_apkpath, const char *asecpath,
+             const char *instruction_set, int64_t *_codesize, int64_t *_datasize,
+             int64_t *_cachesize, int64_t* _asecsize)
+{
+    DIR *d;
+    int dfd;
+    struct dirent *de;
+    struct stat s;
+    char path[PKG_PATH_MAX];
+
+    int64_t codesize = 0;
+    int64_t datasize = 0;
+    int64_t cachesize = 0;
+    int64_t asecsize = 0;
+
+    /* count the source apk as code -- but only if it's not
+     * on the /system partition and its not on the sdcard. */
+    if (validate_system_app_path(apkpath) &&
+            strncmp(apkpath, android_asec_dir.path, android_asec_dir.len) != 0) {
+        if (stat(apkpath, &s) == 0) {
+            codesize += stat_size(&s);
+            if (S_ISDIR(s.st_mode)) {
+                d = opendir(apkpath);
+                if (d != NULL) {
+                    dfd = dirfd(d);
+                    codesize += calculate_dir_size(dfd);
+                    closedir(d);
+                }
+            }
+        }
+    }
+
+    /* count the forward locked apk as code if it is given */
+    if (fwdlock_apkpath != NULL && fwdlock_apkpath[0] != '!') {
+        if (stat(fwdlock_apkpath, &s) == 0) {
+            codesize += stat_size(&s);
+        }
+    }
+
+    /* count the cached dexfile as code */
+    if (!create_cache_path(path, apkpath, instruction_set)) {
+        if (stat(path, &s) == 0) {
+            codesize += stat_size(&s);
+        }
+    }
+
+    /* add in size of any libraries */
+    if (libdirpath != NULL && libdirpath[0] != '!') {
+        d = opendir(libdirpath);
+        if (d != NULL) {
+            dfd = dirfd(d);
+            codesize += calculate_dir_size(dfd);
+            closedir(d);
+        }
+    }
+
+    /* compute asec size if it is given */
+    if (asecpath != NULL && asecpath[0] != '!') {
+        if (stat(asecpath, &s) == 0) {
+            asecsize += stat_size(&s);
+        }
+    }
+
+    std::vector<userid_t> users;
+    if (userid == -1) {
+        users = get_known_users(uuid);
+    } else {
+        users.push_back(userid);
+    }
+
+    for (auto user : users) {
+        std::string _pkgdir(create_data_user_package_path(uuid, user, pkgname));
+        const char* pkgdir = _pkgdir.c_str();
+
+        d = opendir(pkgdir);
+        if (d == NULL) {
+            PLOG(WARNING) << "Failed to open " << pkgdir;
+            continue;
+        }
+        dfd = dirfd(d);
+
+        /* most stuff in the pkgdir is data, except for the "cache"
+         * directory and below, which is cache, and the "lib" directory
+         * and below, which is code...
+         */
+        while ((de = readdir(d))) {
+            const char *name = de->d_name;
+
+            if (de->d_type == DT_DIR) {
+                int subfd;
+                int64_t statsize = 0;
+                int64_t dirsize = 0;
+                    /* always skip "." and ".." */
+                if (name[0] == '.') {
+                    if (name[1] == 0) continue;
+                    if ((name[1] == '.') && (name[2] == 0)) continue;
+                }
+                if (fstatat(dfd, name, &s, AT_SYMLINK_NOFOLLOW) == 0) {
+                    statsize = stat_size(&s);
+                }
+                subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+                if (subfd >= 0) {
+                    dirsize = calculate_dir_size(subfd);
+                }
+                if(!strcmp(name,"lib")) {
+                    codesize += dirsize + statsize;
+                } else if(!strcmp(name,"cache")) {
+                    cachesize += dirsize + statsize;
+                } else {
+                    datasize += dirsize + statsize;
+                }
+            } else if (de->d_type == DT_LNK && !strcmp(name,"lib")) {
+                // This is the symbolic link to the application's library
+                // code.  We'll count this as code instead of data, since
+                // it is not something that the app creates.
+                if (fstatat(dfd, name, &s, AT_SYMLINK_NOFOLLOW) == 0) {
+                    codesize += stat_size(&s);
+                }
+            } else {
+                if (fstatat(dfd, name, &s, AT_SYMLINK_NOFOLLOW) == 0) {
+                    datasize += stat_size(&s);
+                }
+            }
+        }
+        closedir(d);
+    }
+    *_codesize = codesize;
+    *_datasize = datasize;
+    *_cachesize = cachesize;
+    *_asecsize = asecsize;
+    return 0;
+}
+
+int create_cache_path(char path[PKG_PATH_MAX], const char *src, const char *instruction_set)
+{
+    char *tmp;
+    int srclen;
+    int dstlen;
+
+    srclen = strlen(src);
+
+        /* demand that we are an absolute path */
+    if ((src == 0) || (src[0] != '/') || strstr(src,"..")) {
+        return -1;
+    }
+
+    if (srclen > PKG_PATH_MAX) {        // XXX: PKG_NAME_MAX?
+        return -1;
+    }
+
+    dstlen = srclen + strlen(DALVIK_CACHE_PREFIX) +
+        strlen(instruction_set) +
+        strlen(DALVIK_CACHE_POSTFIX) + 2;
+
+    if (dstlen > PKG_PATH_MAX) {
+        return -1;
+    }
+
+    sprintf(path,"%s%s/%s%s",
+            DALVIK_CACHE_PREFIX,
+            instruction_set,
+            src + 1, /* skip the leading / */
+            DALVIK_CACHE_POSTFIX);
+
+    for(tmp = path + strlen(DALVIK_CACHE_PREFIX) + strlen(instruction_set) + 1; *tmp; tmp++) {
+        if (*tmp == '/') {
+            *tmp = '@';
+        }
+    }
+
+    return 0;
+}
+
+static int split_count(const char *str)
+{
+  char *ctx;
+  int count = 0;
+  char buf[PROPERTY_VALUE_MAX];
+
+  strncpy(buf, str, sizeof(buf));
+  char *pBuf = buf;
+
+  while(strtok_r(pBuf, " ", &ctx) != NULL) {
+    count++;
+    pBuf = NULL;
+  }
+
+  return count;
+}
+
+static int split(char *buf, const char **argv)
+{
+  char *ctx;
+  int count = 0;
+  char *tok;
+  char *pBuf = buf;
+
+  while((tok = strtok_r(pBuf, " ", &ctx)) != NULL) {
+    argv[count++] = tok;
+    pBuf = NULL;
+  }
+
+  return count;
+}
+
+static void run_patchoat(int input_fd, int oat_fd, const char* input_file_name,
+    const char* output_file_name, const char *pkgname __unused, const char *instruction_set)
+{
+    static const int MAX_INT_LEN = 12;      // '-'+10dig+'\0' -OR- 0x+8dig
+    static const unsigned int MAX_INSTRUCTION_SET_LEN = 7;
+
+    static const char* PATCHOAT_BIN = "/system/bin/patchoat";
+    if (strlen(instruction_set) >= MAX_INSTRUCTION_SET_LEN) {
+        ALOGE("Instruction set %s longer than max length of %d",
+              instruction_set, MAX_INSTRUCTION_SET_LEN);
+        return;
+    }
+
+    /* input_file_name/input_fd should be the .odex/.oat file that is precompiled. I think*/
+    char instruction_set_arg[strlen("--instruction-set=") + MAX_INSTRUCTION_SET_LEN];
+    char output_oat_fd_arg[strlen("--output-oat-fd=") + MAX_INT_LEN];
+    char input_oat_fd_arg[strlen("--input-oat-fd=") + MAX_INT_LEN];
+    const char* patched_image_location_arg = "--patched-image-location=/system/framework/boot.art";
+    // The caller has already gotten all the locks we need.
+    const char* no_lock_arg = "--no-lock-output";
+    sprintf(instruction_set_arg, "--instruction-set=%s", instruction_set);
+    sprintf(output_oat_fd_arg, "--output-oat-fd=%d", oat_fd);
+    sprintf(input_oat_fd_arg, "--input-oat-fd=%d", input_fd);
+    ALOGV("Running %s isa=%s in-fd=%d (%s) out-fd=%d (%s)\n",
+          PATCHOAT_BIN, instruction_set, input_fd, input_file_name, oat_fd, output_file_name);
+
+    /* patchoat, patched-image-location, no-lock, isa, input-fd, output-fd */
+    char* argv[7];
+    argv[0] = (char*) PATCHOAT_BIN;
+    argv[1] = (char*) patched_image_location_arg;
+    argv[2] = (char*) no_lock_arg;
+    argv[3] = instruction_set_arg;
+    argv[4] = output_oat_fd_arg;
+    argv[5] = input_oat_fd_arg;
+    argv[6] = NULL;
+
+    execv(PATCHOAT_BIN, (char* const *)argv);
+    ALOGE("execv(%s) failed: %s\n", PATCHOAT_BIN, strerror(errno));
+}
+
+static bool check_boolean_property(const char* property_name, bool default_value = false) {
+    char tmp_property_value[PROPERTY_VALUE_MAX];
+    bool have_property = property_get(property_name, tmp_property_value, nullptr) > 0;
+    if (!have_property) {
+        return default_value;
+    }
+    return strcmp(tmp_property_value, "true") == 0;
+}
+
+static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
+    const char* output_file_name, int swap_fd, const char *instruction_set,
+    bool vm_safe_mode, bool debuggable, bool post_bootcomplete, bool use_jit)
+{
+    static const unsigned int MAX_INSTRUCTION_SET_LEN = 7;
+
+    if (strlen(instruction_set) >= MAX_INSTRUCTION_SET_LEN) {
+        ALOGE("Instruction set %s longer than max length of %d",
+              instruction_set, MAX_INSTRUCTION_SET_LEN);
+        return;
+    }
+
+    char dex2oat_Xms_flag[PROPERTY_VALUE_MAX];
+    bool have_dex2oat_Xms_flag = property_get("dalvik.vm.dex2oat-Xms", dex2oat_Xms_flag, NULL) > 0;
+
+    char dex2oat_Xmx_flag[PROPERTY_VALUE_MAX];
+    bool have_dex2oat_Xmx_flag = property_get("dalvik.vm.dex2oat-Xmx", dex2oat_Xmx_flag, NULL) > 0;
+
+    char dex2oat_compiler_filter_flag[PROPERTY_VALUE_MAX];
+    bool have_dex2oat_compiler_filter_flag = property_get("dalvik.vm.dex2oat-filter",
+                                                          dex2oat_compiler_filter_flag, NULL) > 0;
+
+    char dex2oat_threads_buf[PROPERTY_VALUE_MAX];
+    bool have_dex2oat_threads_flag = property_get(post_bootcomplete
+                                                      ? "dalvik.vm.dex2oat-threads"
+                                                      : "dalvik.vm.boot-dex2oat-threads",
+                                                  dex2oat_threads_buf,
+                                                  NULL) > 0;
+    char dex2oat_threads_arg[PROPERTY_VALUE_MAX + 2];
+    if (have_dex2oat_threads_flag) {
+        sprintf(dex2oat_threads_arg, "-j%s", dex2oat_threads_buf);
+    }
+
+    char dex2oat_isa_features_key[PROPERTY_KEY_MAX];
+    sprintf(dex2oat_isa_features_key, "dalvik.vm.isa.%s.features", instruction_set);
+    char dex2oat_isa_features[PROPERTY_VALUE_MAX];
+    bool have_dex2oat_isa_features = property_get(dex2oat_isa_features_key,
+                                                  dex2oat_isa_features, NULL) > 0;
+
+    char dex2oat_isa_variant_key[PROPERTY_KEY_MAX];
+    sprintf(dex2oat_isa_variant_key, "dalvik.vm.isa.%s.variant", instruction_set);
+    char dex2oat_isa_variant[PROPERTY_VALUE_MAX];
+    bool have_dex2oat_isa_variant = property_get(dex2oat_isa_variant_key,
+                                                 dex2oat_isa_variant, NULL) > 0;
+
+    const char *dex2oat_norelocation = "-Xnorelocate";
+    bool have_dex2oat_relocation_skip_flag = false;
+
+    char dex2oat_flags[PROPERTY_VALUE_MAX];
+    int dex2oat_flags_count = property_get("dalvik.vm.dex2oat-flags",
+                                 dex2oat_flags, NULL) <= 0 ? 0 : split_count(dex2oat_flags);
+    ALOGV("dalvik.vm.dex2oat-flags=%s\n", dex2oat_flags);
+
+    // If we booting without the real /data, don't spend time compiling.
+    char vold_decrypt[PROPERTY_VALUE_MAX];
+    bool have_vold_decrypt = property_get("vold.decrypt", vold_decrypt, "") > 0;
+    bool skip_compilation = (have_vold_decrypt &&
+                             (strcmp(vold_decrypt, "trigger_restart_min_framework") == 0 ||
+                             (strcmp(vold_decrypt, "1") == 0)));
+
+    bool generate_debug_info = check_boolean_property("debug.generate-debug-info");
+
+    static const char* DEX2OAT_BIN = "/system/bin/dex2oat";
+
+    static const char* RUNTIME_ARG = "--runtime-arg";
+
+    static const int MAX_INT_LEN = 12;      // '-'+10dig+'\0' -OR- 0x+8dig
+
+    char zip_fd_arg[strlen("--zip-fd=") + MAX_INT_LEN];
+    char zip_location_arg[strlen("--zip-location=") + PKG_PATH_MAX];
+    char oat_fd_arg[strlen("--oat-fd=") + MAX_INT_LEN];
+    char oat_location_arg[strlen("--oat-location=") + PKG_PATH_MAX];
+    char instruction_set_arg[strlen("--instruction-set=") + MAX_INSTRUCTION_SET_LEN];
+    char instruction_set_variant_arg[strlen("--instruction-set-variant=") + PROPERTY_VALUE_MAX];
+    char instruction_set_features_arg[strlen("--instruction-set-features=") + PROPERTY_VALUE_MAX];
+    char dex2oat_Xms_arg[strlen("-Xms") + PROPERTY_VALUE_MAX];
+    char dex2oat_Xmx_arg[strlen("-Xmx") + PROPERTY_VALUE_MAX];
+    char dex2oat_compiler_filter_arg[strlen("--compiler-filter=") + PROPERTY_VALUE_MAX];
+    bool have_dex2oat_swap_fd = false;
+    char dex2oat_swap_fd[strlen("--swap-fd=") + MAX_INT_LEN];
+
+    sprintf(zip_fd_arg, "--zip-fd=%d", zip_fd);
+    sprintf(zip_location_arg, "--zip-location=%s", input_file_name);
+    sprintf(oat_fd_arg, "--oat-fd=%d", oat_fd);
+    sprintf(oat_location_arg, "--oat-location=%s", output_file_name);
+    sprintf(instruction_set_arg, "--instruction-set=%s", instruction_set);
+    sprintf(instruction_set_variant_arg, "--instruction-set-variant=%s", dex2oat_isa_variant);
+    sprintf(instruction_set_features_arg, "--instruction-set-features=%s", dex2oat_isa_features);
+    if (swap_fd >= 0) {
+        have_dex2oat_swap_fd = true;
+        sprintf(dex2oat_swap_fd, "--swap-fd=%d", swap_fd);
+    }
+
+    // use the JIT if either it's specified as a dexopt flag or if the property is set
+    use_jit = use_jit || check_boolean_property("debug.usejit");
+    if (have_dex2oat_Xms_flag) {
+        sprintf(dex2oat_Xms_arg, "-Xms%s", dex2oat_Xms_flag);
+    }
+    if (have_dex2oat_Xmx_flag) {
+        sprintf(dex2oat_Xmx_arg, "-Xmx%s", dex2oat_Xmx_flag);
+    }
+    if (skip_compilation) {
+        strcpy(dex2oat_compiler_filter_arg, "--compiler-filter=verify-none");
+        have_dex2oat_compiler_filter_flag = true;
+        have_dex2oat_relocation_skip_flag = true;
+    } else if (vm_safe_mode) {
+        strcpy(dex2oat_compiler_filter_arg, "--compiler-filter=interpret-only");
+        have_dex2oat_compiler_filter_flag = true;
+    } else if (use_jit) {
+        strcpy(dex2oat_compiler_filter_arg, "--compiler-filter=verify-at-runtime");
+        have_dex2oat_compiler_filter_flag = true;
+    } else if (have_dex2oat_compiler_filter_flag) {
+        sprintf(dex2oat_compiler_filter_arg, "--compiler-filter=%s", dex2oat_compiler_filter_flag);
+    }
+
+    // Check whether all apps should be compiled debuggable.
+    if (!debuggable) {
+        char prop_buf[PROPERTY_VALUE_MAX];
+        debuggable =
+                (property_get("dalvik.vm.always_debuggable", prop_buf, "0") > 0) &&
+                (prop_buf[0] == '1');
+    }
+
+    ALOGV("Running %s in=%s out=%s\n", DEX2OAT_BIN, input_file_name, output_file_name);
+
+    const char* argv[7  // program name, mandatory arguments and the final NULL
+                     + (have_dex2oat_isa_variant ? 1 : 0)
+                     + (have_dex2oat_isa_features ? 1 : 0)
+                     + (have_dex2oat_Xms_flag ? 2 : 0)
+                     + (have_dex2oat_Xmx_flag ? 2 : 0)
+                     + (have_dex2oat_compiler_filter_flag ? 1 : 0)
+                     + (have_dex2oat_threads_flag ? 1 : 0)
+                     + (have_dex2oat_swap_fd ? 1 : 0)
+                     + (have_dex2oat_relocation_skip_flag ? 2 : 0)
+                     + (generate_debug_info ? 1 : 0)
+                     + (debuggable ? 1 : 0)
+                     + dex2oat_flags_count];
+    int i = 0;
+    argv[i++] = DEX2OAT_BIN;
+    argv[i++] = zip_fd_arg;
+    argv[i++] = zip_location_arg;
+    argv[i++] = oat_fd_arg;
+    argv[i++] = oat_location_arg;
+    argv[i++] = instruction_set_arg;
+    if (have_dex2oat_isa_variant) {
+        argv[i++] = instruction_set_variant_arg;
+    }
+    if (have_dex2oat_isa_features) {
+        argv[i++] = instruction_set_features_arg;
+    }
+    if (have_dex2oat_Xms_flag) {
+        argv[i++] = RUNTIME_ARG;
+        argv[i++] = dex2oat_Xms_arg;
+    }
+    if (have_dex2oat_Xmx_flag) {
+        argv[i++] = RUNTIME_ARG;
+        argv[i++] = dex2oat_Xmx_arg;
+    }
+    if (have_dex2oat_compiler_filter_flag) {
+        argv[i++] = dex2oat_compiler_filter_arg;
+    }
+    if (have_dex2oat_threads_flag) {
+        argv[i++] = dex2oat_threads_arg;
+    }
+    if (have_dex2oat_swap_fd) {
+        argv[i++] = dex2oat_swap_fd;
+    }
+    if (generate_debug_info) {
+        argv[i++] = "--generate-debug-info";
+    }
+    if (debuggable) {
+        argv[i++] = "--debuggable";
+    }
+    if (dex2oat_flags_count) {
+        i += split(dex2oat_flags, argv + i);
+    }
+    if (have_dex2oat_relocation_skip_flag) {
+        argv[i++] = RUNTIME_ARG;
+        argv[i++] = dex2oat_norelocation;
+    }
+    // Do not add after dex2oat_flags, they should override others for debugging.
+    argv[i] = NULL;
+
+    execv(DEX2OAT_BIN, (char * const *)argv);
+    ALOGE("execv(%s) failed: %s\n", DEX2OAT_BIN, strerror(errno));
+}
+
+static int wait_child(pid_t pid)
+{
+    int status;
+    pid_t got_pid;
+
+    while (1) {
+        got_pid = waitpid(pid, &status, 0);
+        if (got_pid == -1 && errno == EINTR) {
+            printf("waitpid interrupted, retrying\n");
+        } else {
+            break;
+        }
+    }
+    if (got_pid != pid) {
+        ALOGW("waitpid failed: wanted %d, got %d: %s\n",
+            (int) pid, (int) got_pid, strerror(errno));
+        return 1;
+    }
+
+    if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
+        return 0;
+    } else {
+        return status;      /* always nonzero */
+    }
+}
+
+/*
+ * Whether dexopt should use a swap file when compiling an APK.
+ *
+ * If kAlwaysProvideSwapFile, do this on all devices (dex2oat will make a more informed decision
+ * itself, anyways).
+ *
+ * Otherwise, read "dalvik.vm.dex2oat-swap". If the property exists, return whether it is "true".
+ *
+ * Otherwise, return true if this is a low-mem device.
+ *
+ * Otherwise, return default value.
+ */
+static bool kAlwaysProvideSwapFile = false;
+static bool kDefaultProvideSwapFile = true;
+
+static bool ShouldUseSwapFileForDexopt() {
+    if (kAlwaysProvideSwapFile) {
+        return true;
+    }
+
+    // Check the "override" property. If it exists, return value == "true".
+    char dex2oat_prop_buf[PROPERTY_VALUE_MAX];
+    if (property_get("dalvik.vm.dex2oat-swap", dex2oat_prop_buf, "") > 0) {
+        if (strcmp(dex2oat_prop_buf, "true") == 0) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    // Shortcut for default value. This is an implementation optimization for the process sketched
+    // above. If the default value is true, we can avoid to check whether this is a low-mem device,
+    // as low-mem is never returning false. The compiler will optimize this away if it can.
+    if (kDefaultProvideSwapFile) {
+        return true;
+    }
+
+    bool is_low_mem = check_boolean_property("ro.config.low_ram");
+    if (is_low_mem) {
+        return true;
+    }
+
+    // Default value must be false here.
+    return kDefaultProvideSwapFile;
+}
+
+/*
+ * Computes the odex file for the given apk_path and instruction_set.
+ * /system/framework/whatever.jar -> /system/framework/oat/<isa>/whatever.odex
+ *
+ * Returns false if it failed to determine the odex file path.
+ */
+static bool calculate_odex_file_path(char path[PKG_PATH_MAX],
+                                     const char *apk_path,
+                                     const char *instruction_set)
+{
+    if (strlen(apk_path) + strlen("oat/") + strlen(instruction_set)
+        + strlen("/") + strlen("odex") + 1 > PKG_PATH_MAX) {
+      ALOGE("apk_path '%s' may be too long to form odex file path.\n", apk_path);
+      return false;
+    }
+
+    strcpy(path, apk_path);
+    char *end = strrchr(path, '/');
+    if (end == NULL) {
+      ALOGE("apk_path '%s' has no '/'s in it?!\n", apk_path);
+      return false;
+    }
+    const char *apk_end = apk_path + (end - path); // strrchr(apk_path, '/');
+
+    strcpy(end + 1, "oat/");       // path = /system/framework/oat/\0
+    strcat(path, instruction_set); // path = /system/framework/oat/<isa>\0
+    strcat(path, apk_end);         // path = /system/framework/oat/<isa>/whatever.jar\0
+    end = strrchr(path, '.');
+    if (end == NULL) {
+      ALOGE("apk_path '%s' has no extension.\n", apk_path);
+      return false;
+    }
+    strcpy(end + 1, "odex");
+    return true;
+}
+
+static void SetDex2OatAndPatchOatScheduling(bool set_to_bg) {
+    if (set_to_bg) {
+        if (set_sched_policy(0, SP_BACKGROUND) < 0) {
+            ALOGE("set_sched_policy failed: %s\n", strerror(errno));
+            exit(70);
+        }
+        if (setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_BACKGROUND) < 0) {
+            ALOGE("setpriority failed: %s\n", strerror(errno));
+            exit(71);
+        }
+    }
+}
+
+int dexopt(const char *apk_path, uid_t uid, const char *pkgname, const char *instruction_set,
+           int dexopt_needed, const char* oat_dir, int dexopt_flags)
+{
+    struct utimbuf ut;
+    struct stat input_stat;
+    char out_path[PKG_PATH_MAX];
+    char swap_file_name[PKG_PATH_MAX];
+    const char *input_file;
+    char in_odex_path[PKG_PATH_MAX];
+    int res, input_fd=-1, out_fd=-1, swap_fd=-1;
+    bool is_public = (dexopt_flags & DEXOPT_PUBLIC) != 0;
+    bool vm_safe_mode = (dexopt_flags & DEXOPT_SAFEMODE) != 0;
+    bool debuggable = (dexopt_flags & DEXOPT_DEBUGGABLE) != 0;
+    bool boot_complete = (dexopt_flags & DEXOPT_BOOTCOMPLETE) != 0;
+    bool use_jit = (dexopt_flags & DEXOPT_USEJIT) != 0;
+
+    if ((dexopt_flags & ~DEXOPT_MASK) != 0) {
+        LOG_FATAL("dexopt flags contains unknown fields\n");
+    }
+
+    // Early best-effort check whether we can fit the the path into our buffers.
+    // Note: the cache path will require an additional 5 bytes for ".swap", but we'll try to run
+    // without a swap file, if necessary.
+    if (strlen(apk_path) >= (PKG_PATH_MAX - 8)) {
+        ALOGE("apk_path too long '%s'\n", apk_path);
+        return -1;
+    }
+
+    if (oat_dir != NULL && oat_dir[0] != '!') {
+        if (validate_apk_path(oat_dir)) {
+            ALOGE("invalid oat_dir '%s'\n", oat_dir);
+            return -1;
+        }
+        if (calculate_oat_file_path(out_path, oat_dir, apk_path, instruction_set)) {
+            return -1;
+        }
+    } else {
+        if (create_cache_path(out_path, apk_path, instruction_set)) {
+            return -1;
+        }
+    }
+
+    switch (dexopt_needed) {
+        case DEXOPT_DEX2OAT_NEEDED:
+            input_file = apk_path;
+            break;
+
+        case DEXOPT_PATCHOAT_NEEDED:
+            if (!calculate_odex_file_path(in_odex_path, apk_path, instruction_set)) {
+                return -1;
+            }
+            input_file = in_odex_path;
+            break;
+
+        case DEXOPT_SELF_PATCHOAT_NEEDED:
+            input_file = out_path;
+            break;
+
+        default:
+            ALOGE("Invalid dexopt needed: %d\n", dexopt_needed);
+            exit(72);
+    }
+
+    memset(&input_stat, 0, sizeof(input_stat));
+    stat(input_file, &input_stat);
+
+    input_fd = open(input_file, O_RDONLY, 0);
+    if (input_fd < 0) {
+        ALOGE("installd cannot open '%s' for input during dexopt\n", input_file);
+        return -1;
+    }
+
+    unlink(out_path);
+    out_fd = open(out_path, O_RDWR | O_CREAT | O_EXCL, 0644);
+    if (out_fd < 0) {
+        ALOGE("installd cannot open '%s' for output during dexopt\n", out_path);
+        goto fail;
+    }
+    if (fchmod(out_fd,
+               S_IRUSR|S_IWUSR|S_IRGRP |
+               (is_public ? S_IROTH : 0)) < 0) {
+        ALOGE("installd cannot chmod '%s' during dexopt\n", out_path);
+        goto fail;
+    }
+    if (fchown(out_fd, AID_SYSTEM, uid) < 0) {
+        ALOGE("installd cannot chown '%s' during dexopt\n", out_path);
+        goto fail;
+    }
+
+    // Create a swap file if necessary.
+    if (ShouldUseSwapFileForDexopt()) {
+        // Make sure there really is enough space.
+        size_t out_len = strlen(out_path);
+        if (out_len + strlen(".swap") + 1 <= PKG_PATH_MAX) {
+            strcpy(swap_file_name, out_path);
+            strcpy(swap_file_name + strlen(out_path), ".swap");
+            unlink(swap_file_name);
+            swap_fd = open(swap_file_name, O_RDWR | O_CREAT | O_EXCL, 0600);
+            if (swap_fd < 0) {
+                // Could not create swap file. Optimistically go on and hope that we can compile
+                // without it.
+                ALOGE("installd could not create '%s' for swap during dexopt\n", swap_file_name);
+            } else {
+                // Immediately unlink. We don't really want to hit flash.
+                unlink(swap_file_name);
+            }
+        } else {
+            // Swap file path is too long. Try to run without.
+            ALOGE("installd could not create swap file for path %s during dexopt\n", out_path);
+        }
+    }
+
+    ALOGV("DexInv: --- BEGIN '%s' ---\n", input_file);
+
+    pid_t pid;
+    pid = fork();
+    if (pid == 0) {
+        /* child -- drop privileges before continuing */
+        if (setgid(uid) != 0) {
+            ALOGE("setgid(%d) failed in installd during dexopt\n", uid);
+            exit(64);
+        }
+        if (setuid(uid) != 0) {
+            ALOGE("setuid(%d) failed in installd during dexopt\n", uid);
+            exit(65);
+        }
+        // drop capabilities
+        struct __user_cap_header_struct capheader;
+        struct __user_cap_data_struct capdata[2];
+        memset(&capheader, 0, sizeof(capheader));
+        memset(&capdata, 0, sizeof(capdata));
+        capheader.version = _LINUX_CAPABILITY_VERSION_3;
+        if (capset(&capheader, &capdata[0]) < 0) {
+            ALOGE("capset failed: %s\n", strerror(errno));
+            exit(66);
+        }
+        SetDex2OatAndPatchOatScheduling(boot_complete);
+        if (flock(out_fd, LOCK_EX | LOCK_NB) != 0) {
+            ALOGE("flock(%s) failed: %s\n", out_path, strerror(errno));
+            exit(67);
+        }
+
+        if (dexopt_needed == DEXOPT_PATCHOAT_NEEDED
+            || dexopt_needed == DEXOPT_SELF_PATCHOAT_NEEDED) {
+            run_patchoat(input_fd, out_fd, input_file, out_path, pkgname, instruction_set);
+        } else if (dexopt_needed == DEXOPT_DEX2OAT_NEEDED) {
+            const char *input_file_name = strrchr(input_file, '/');
+            if (input_file_name == NULL) {
+                input_file_name = input_file;
+            } else {
+                input_file_name++;
+            }
+            run_dex2oat(input_fd, out_fd, input_file_name, out_path, swap_fd,
+                        instruction_set, vm_safe_mode, debuggable, boot_complete, use_jit);
+        } else {
+            ALOGE("Invalid dexopt needed: %d\n", dexopt_needed);
+            exit(73);
+        }
+        exit(68);   /* only get here on exec failure */
+    } else {
+        res = wait_child(pid);
+        if (res == 0) {
+            ALOGV("DexInv: --- END '%s' (success) ---\n", input_file);
+        } else {
+            ALOGE("DexInv: --- END '%s' --- status=0x%04x, process failed\n", input_file, res);
+            goto fail;
+        }
+    }
+
+    ut.actime = input_stat.st_atime;
+    ut.modtime = input_stat.st_mtime;
+    utime(out_path, &ut);
+
+    close(out_fd);
+    close(input_fd);
+    if (swap_fd != -1) {
+        close(swap_fd);
+    }
+    return 0;
+
+fail:
+    if (out_fd >= 0) {
+        close(out_fd);
+        unlink(out_path);
+    }
+    if (input_fd >= 0) {
+        close(input_fd);
+    }
+    return -1;
+}
+
+int mark_boot_complete(const char* instruction_set)
+{
+  char boot_marker_path[PKG_PATH_MAX];
+  sprintf(boot_marker_path,"%s%s/.booting", DALVIK_CACHE_PREFIX, instruction_set);
+
+  ALOGV("mark_boot_complete : %s", boot_marker_path);
+  if (unlink(boot_marker_path) != 0) {
+      ALOGE("Unable to unlink boot marker at %s, error=%s", boot_marker_path,
+            strerror(errno));
+      return -1;
+  }
+
+  return 0;
+}
+
+void mkinnerdirs(char* path, int basepos, mode_t mode, int uid, int gid,
+        struct stat* statbuf)
+{
+    while (path[basepos] != 0) {
+        if (path[basepos] == '/') {
+            path[basepos] = 0;
+            if (lstat(path, statbuf) < 0) {
+                ALOGV("Making directory: %s\n", path);
+                if (mkdir(path, mode) == 0) {
+                    chown(path, uid, gid);
+                } else {
+                    ALOGW("Unable to make directory %s: %s\n", path, strerror(errno));
+                }
+            }
+            path[basepos] = '/';
+            basepos++;
+        }
+        basepos++;
+    }
+}
+
+int movefileordir(char* srcpath, char* dstpath, int dstbasepos,
+        int dstuid, int dstgid, struct stat* statbuf)
+{
+    DIR *d;
+    struct dirent *de;
+    int res;
+
+    int srcend = strlen(srcpath);
+    int dstend = strlen(dstpath);
+
+    if (lstat(srcpath, statbuf) < 0) {
+        ALOGW("Unable to stat %s: %s\n", srcpath, strerror(errno));
+        return 1;
+    }
+
+    if ((statbuf->st_mode&S_IFDIR) == 0) {
+        mkinnerdirs(dstpath, dstbasepos, S_IRWXU|S_IRWXG|S_IXOTH,
+                dstuid, dstgid, statbuf);
+        ALOGV("Renaming %s to %s (uid %d)\n", srcpath, dstpath, dstuid);
+        if (rename(srcpath, dstpath) >= 0) {
+            if (chown(dstpath, dstuid, dstgid) < 0) {
+                ALOGE("cannot chown %s: %s\n", dstpath, strerror(errno));
+                unlink(dstpath);
+                return 1;
+            }
+        } else {
+            ALOGW("Unable to rename %s to %s: %s\n",
+                srcpath, dstpath, strerror(errno));
+            return 1;
+        }
+        return 0;
+    }
+
+    d = opendir(srcpath);
+    if (d == NULL) {
+        ALOGW("Unable to opendir %s: %s\n", srcpath, strerror(errno));
+        return 1;
+    }
+
+    res = 0;
+
+    while ((de = readdir(d))) {
+        const char *name = de->d_name;
+            /* always skip "." and ".." */
+        if (name[0] == '.') {
+            if (name[1] == 0) continue;
+            if ((name[1] == '.') && (name[2] == 0)) continue;
+        }
+
+        if ((srcend+strlen(name)) >= (PKG_PATH_MAX-2)) {
+            ALOGW("Source path too long; skipping: %s/%s\n", srcpath, name);
+            continue;
+        }
+
+        if ((dstend+strlen(name)) >= (PKG_PATH_MAX-2)) {
+            ALOGW("Destination path too long; skipping: %s/%s\n", dstpath, name);
+            continue;
+        }
+
+        srcpath[srcend] = dstpath[dstend] = '/';
+        strcpy(srcpath+srcend+1, name);
+        strcpy(dstpath+dstend+1, name);
+
+        if (movefileordir(srcpath, dstpath, dstbasepos, dstuid, dstgid, statbuf) != 0) {
+            res = 1;
+        }
+
+        // Note: we will be leaving empty directories behind in srcpath,
+        // but that is okay, the package manager will be erasing all of the
+        // data associated with .apks that disappear.
+
+        srcpath[srcend] = dstpath[dstend] = 0;
+    }
+
+    closedir(d);
+    return res;
+}
+
+int movefiles()
+{
+    DIR *d;
+    int dfd, subfd;
+    struct dirent *de;
+    struct stat s;
+    char buf[PKG_PATH_MAX+1];
+    int bufp, bufe, bufi, readlen;
+
+    char srcpkg[PKG_NAME_MAX];
+    char dstpkg[PKG_NAME_MAX];
+    char srcpath[PKG_PATH_MAX];
+    char dstpath[PKG_PATH_MAX];
+    int dstuid=-1, dstgid=-1;
+    int hasspace;
+
+    d = opendir(UPDATE_COMMANDS_DIR_PREFIX);
+    if (d == NULL) {
+        goto done;
+    }
+    dfd = dirfd(d);
+
+        /* Iterate through all files in the directory, executing the
+         * file movements requested there-in.
+         */
+    while ((de = readdir(d))) {
+        const char *name = de->d_name;
+
+        if (de->d_type == DT_DIR) {
+            continue;
+        } else {
+            subfd = openat(dfd, name, O_RDONLY);
+            if (subfd < 0) {
+                ALOGW("Unable to open update commands at %s%s\n",
+                        UPDATE_COMMANDS_DIR_PREFIX, name);
+                continue;
+            }
+
+            bufp = 0;
+            bufe = 0;
+            buf[PKG_PATH_MAX] = 0;
+            srcpkg[0] = dstpkg[0] = 0;
+            while (1) {
+                bufi = bufp;
+                while (bufi < bufe && buf[bufi] != '\n') {
+                    bufi++;
+                }
+                if (bufi < bufe) {
+                    buf[bufi] = 0;
+                    ALOGV("Processing line: %s\n", buf+bufp);
+                    hasspace = 0;
+                    while (bufp < bufi && isspace(buf[bufp])) {
+                        hasspace = 1;
+                        bufp++;
+                    }
+                    if (buf[bufp] == '#' || bufp == bufi) {
+                        // skip comments and empty lines.
+                    } else if (hasspace) {
+                        if (dstpkg[0] == 0) {
+                            ALOGW("Path before package line in %s%s: %s\n",
+                                    UPDATE_COMMANDS_DIR_PREFIX, name, buf+bufp);
+                        } else if (srcpkg[0] == 0) {
+                            // Skip -- source package no longer exists.
+                        } else {
+                            ALOGV("Move file: %s (from %s to %s)\n", buf+bufp, srcpkg, dstpkg);
+                            if (!create_move_path(srcpath, srcpkg, buf+bufp, 0) &&
+                                    !create_move_path(dstpath, dstpkg, buf+bufp, 0)) {
+                                movefileordir(srcpath, dstpath,
+                                        strlen(dstpath)-strlen(buf+bufp),
+                                        dstuid, dstgid, &s);
+                            }
+                        }
+                    } else {
+                        char* div = strchr(buf+bufp, ':');
+                        if (div == NULL) {
+                            ALOGW("Bad package spec in %s%s; no ':' sep: %s\n",
+                                    UPDATE_COMMANDS_DIR_PREFIX, name, buf+bufp);
+                        } else {
+                            *div = 0;
+                            div++;
+                            if (strlen(buf+bufp) < PKG_NAME_MAX) {
+                                strcpy(dstpkg, buf+bufp);
+                            } else {
+                                srcpkg[0] = dstpkg[0] = 0;
+                                ALOGW("Package name too long in %s%s: %s\n",
+                                        UPDATE_COMMANDS_DIR_PREFIX, name, buf+bufp);
+                            }
+                            if (strlen(div) < PKG_NAME_MAX) {
+                                strcpy(srcpkg, div);
+                            } else {
+                                srcpkg[0] = dstpkg[0] = 0;
+                                ALOGW("Package name too long in %s%s: %s\n",
+                                        UPDATE_COMMANDS_DIR_PREFIX, name, div);
+                            }
+                            if (srcpkg[0] != 0) {
+                                if (!create_pkg_path(srcpath, srcpkg, PKG_DIR_POSTFIX, 0)) {
+                                    if (lstat(srcpath, &s) < 0) {
+                                        // Package no longer exists -- skip.
+                                        srcpkg[0] = 0;
+                                    }
+                                } else {
+                                    srcpkg[0] = 0;
+                                    ALOGW("Can't create path %s in %s%s\n",
+                                            div, UPDATE_COMMANDS_DIR_PREFIX, name);
+                                }
+                                if (srcpkg[0] != 0) {
+                                    if (!create_pkg_path(dstpath, dstpkg, PKG_DIR_POSTFIX, 0)) {
+                                        if (lstat(dstpath, &s) == 0) {
+                                            dstuid = s.st_uid;
+                                            dstgid = s.st_gid;
+                                        } else {
+                                            // Destination package doesn't
+                                            // exist...  due to original-package,
+                                            // this is normal, so don't be
+                                            // noisy about it.
+                                            srcpkg[0] = 0;
+                                        }
+                                    } else {
+                                        srcpkg[0] = 0;
+                                        ALOGW("Can't create path %s in %s%s\n",
+                                                div, UPDATE_COMMANDS_DIR_PREFIX, name);
+                                    }
+                                }
+                                ALOGV("Transfering from %s to %s: uid=%d\n",
+                                    srcpkg, dstpkg, dstuid);
+                            }
+                        }
+                    }
+                    bufp = bufi+1;
+                } else {
+                    if (bufp == 0) {
+                        if (bufp < bufe) {
+                            ALOGW("Line too long in %s%s, skipping: %s\n",
+                                    UPDATE_COMMANDS_DIR_PREFIX, name, buf);
+                        }
+                    } else if (bufp < bufe) {
+                        memcpy(buf, buf+bufp, bufe-bufp);
+                        bufe -= bufp;
+                        bufp = 0;
+                    }
+                    readlen = read(subfd, buf+bufe, PKG_PATH_MAX-bufe);
+                    if (readlen < 0) {
+                        ALOGW("Failure reading update commands in %s%s: %s\n",
+                                UPDATE_COMMANDS_DIR_PREFIX, name, strerror(errno));
+                        break;
+                    } else if (readlen == 0) {
+                        break;
+                    }
+                    bufe += readlen;
+                    buf[bufe] = 0;
+                    ALOGV("Read buf: %s\n", buf);
+                }
+            }
+            close(subfd);
+        }
+    }
+    closedir(d);
+done:
+    return 0;
+}
+
+int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId)
+{
+    struct stat s, libStat;
+    int rc = 0;
+
+    std::string _pkgdir(create_data_user_package_path(uuid, userId, pkgname));
+    std::string _libsymlink(_pkgdir + PKG_LIB_POSTFIX);
+
+    const char* pkgdir = _pkgdir.c_str();
+    const char* libsymlink = _libsymlink.c_str();
+
+    if (stat(pkgdir, &s) < 0) return -1;
+
+    if (chown(pkgdir, AID_INSTALL, AID_INSTALL) < 0) {
+        ALOGE("failed to chown '%s': %s\n", pkgdir, strerror(errno));
+        return -1;
+    }
+
+    if (chmod(pkgdir, 0700) < 0) {
+        ALOGE("linklib() 1: failed to chmod '%s': %s\n", pkgdir, strerror(errno));
+        rc = -1;
+        goto out;
+    }
+
+    if (lstat(libsymlink, &libStat) < 0) {
+        if (errno != ENOENT) {
+            ALOGE("couldn't stat lib dir: %s\n", strerror(errno));
+            rc = -1;
+            goto out;
+        }
+    } else {
+        if (S_ISDIR(libStat.st_mode)) {
+            if (delete_dir_contents(libsymlink, 1, NULL) < 0) {
+                rc = -1;
+                goto out;
+            }
+        } else if (S_ISLNK(libStat.st_mode)) {
+            if (unlink(libsymlink) < 0) {
+                ALOGE("couldn't unlink lib dir: %s\n", strerror(errno));
+                rc = -1;
+                goto out;
+            }
+        }
+    }
+
+    if (symlink(asecLibDir, libsymlink) < 0) {
+        ALOGE("couldn't symlink directory '%s' -> '%s': %s\n", libsymlink, asecLibDir,
+                strerror(errno));
+        rc = -errno;
+        goto out;
+    }
+
+out:
+    if (chmod(pkgdir, s.st_mode) < 0) {
+        ALOGE("linklib() 2: failed to chmod '%s': %s\n", pkgdir, strerror(errno));
+        rc = -errno;
+    }
+
+    if (chown(pkgdir, s.st_uid, s.st_gid) < 0) {
+        ALOGE("failed to chown '%s' : %s\n", pkgdir, strerror(errno));
+        return -errno;
+    }
+
+    return rc;
+}
+
+static void run_idmap(const char *target_apk, const char *overlay_apk, int idmap_fd)
+{
+    static const char *IDMAP_BIN = "/system/bin/idmap";
+    static const size_t MAX_INT_LEN = 32;
+    char idmap_str[MAX_INT_LEN];
+
+    snprintf(idmap_str, sizeof(idmap_str), "%d", idmap_fd);
+
+    execl(IDMAP_BIN, IDMAP_BIN, "--fd", target_apk, overlay_apk, idmap_str, (char*)NULL);
+    ALOGE("execl(%s) failed: %s\n", IDMAP_BIN, strerror(errno));
+}
+
+// Transform string /a/b/c.apk to (prefix)/a@b@c.apk@(suffix)
+// eg /a/b/c.apk to /data/resource-cache/a@b@c.apk@idmap
+static int flatten_path(const char *prefix, const char *suffix,
+        const char *overlay_path, char *idmap_path, size_t N)
+{
+    if (overlay_path == NULL || idmap_path == NULL) {
+        return -1;
+    }
+    const size_t len_overlay_path = strlen(overlay_path);
+    // will access overlay_path + 1 further below; requires absolute path
+    if (len_overlay_path < 2 || *overlay_path != '/') {
+        return -1;
+    }
+    const size_t len_idmap_root = strlen(prefix);
+    const size_t len_suffix = strlen(suffix);
+    if (SIZE_MAX - len_idmap_root < len_overlay_path ||
+            SIZE_MAX - (len_idmap_root + len_overlay_path) < len_suffix) {
+        // additions below would cause overflow
+        return -1;
+    }
+    if (N < len_idmap_root + len_overlay_path + len_suffix) {
+        return -1;
+    }
+    memset(idmap_path, 0, N);
+    snprintf(idmap_path, N, "%s%s%s", prefix, overlay_path + 1, suffix);
+    char *ch = idmap_path + len_idmap_root;
+    while (*ch != '\0') {
+        if (*ch == '/') {
+            *ch = '@';
+        }
+        ++ch;
+    }
+    return 0;
+}
+
+int idmap(const char *target_apk, const char *overlay_apk, uid_t uid)
+{
+    ALOGV("idmap target_apk=%s overlay_apk=%s uid=%d\n", target_apk, overlay_apk, uid);
+
+    int idmap_fd = -1;
+    char idmap_path[PATH_MAX];
+
+    if (flatten_path(IDMAP_PREFIX, IDMAP_SUFFIX, overlay_apk,
+                idmap_path, sizeof(idmap_path)) == -1) {
+        ALOGE("idmap cannot generate idmap path for overlay %s\n", overlay_apk);
+        goto fail;
+    }
+
+    unlink(idmap_path);
+    idmap_fd = open(idmap_path, O_RDWR | O_CREAT | O_EXCL, 0644);
+    if (idmap_fd < 0) {
+        ALOGE("idmap cannot open '%s' for output: %s\n", idmap_path, strerror(errno));
+        goto fail;
+    }
+    if (fchown(idmap_fd, AID_SYSTEM, uid) < 0) {
+        ALOGE("idmap cannot chown '%s'\n", idmap_path);
+        goto fail;
+    }
+    if (fchmod(idmap_fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) < 0) {
+        ALOGE("idmap cannot chmod '%s'\n", idmap_path);
+        goto fail;
+    }
+
+    pid_t pid;
+    pid = fork();
+    if (pid == 0) {
+        /* child -- drop privileges before continuing */
+        if (setgid(uid) != 0) {
+            ALOGE("setgid(%d) failed during idmap\n", uid);
+            exit(1);
+        }
+        if (setuid(uid) != 0) {
+            ALOGE("setuid(%d) failed during idmap\n", uid);
+            exit(1);
+        }
+        if (flock(idmap_fd, LOCK_EX | LOCK_NB) != 0) {
+            ALOGE("flock(%s) failed during idmap: %s\n", idmap_path, strerror(errno));
+            exit(1);
+        }
+
+        run_idmap(target_apk, overlay_apk, idmap_fd);
+        exit(1); /* only if exec call to idmap failed */
+    } else {
+        int status = wait_child(pid);
+        if (status != 0) {
+            ALOGE("idmap failed, status=0x%04x\n", status);
+            goto fail;
+        }
+    }
+
+    close(idmap_fd);
+    return 0;
+fail:
+    if (idmap_fd >= 0) {
+        close(idmap_fd);
+        unlink(idmap_path);
+    }
+    return -1;
+}
+
+int restorecon_data(const char* uuid, const char* pkgName,
+                    const char* seinfo, uid_t uid)
+{
+    struct dirent *entry;
+    DIR *d;
+    struct stat s;
+    int ret = 0;
+
+    // SELINUX_ANDROID_RESTORECON_DATADATA flag is set by libselinux. Not needed here.
+    unsigned int flags = SELINUX_ANDROID_RESTORECON_RECURSE;
+
+    if (!pkgName || !seinfo) {
+        ALOGE("Package name or seinfo tag is null when trying to restorecon.");
+        return -1;
+    }
+
+    // Special case for owner on internal storage
+    if (uuid == nullptr) {
+        std::string path(create_data_user_package_path(nullptr, 0, pkgName));
+
+        if (selinux_android_restorecon_pkgdir(path.c_str(), seinfo, uid, flags) < 0) {
+            PLOG(ERROR) << "restorecon failed for " << path;
+            ret |= -1;
+        }
+    }
+
+    // Relabel package directory for all secondary users.
+    std::string userdir(create_data_path(uuid) + "/" + SECONDARY_USER_PREFIX);
+    d = opendir(userdir.c_str());
+    if (d == NULL) {
+        return -1;
+    }
+
+    while ((entry = readdir(d))) {
+        if (entry->d_type != DT_DIR) {
+            continue;
+        }
+
+        const char *user = entry->d_name;
+        // Ignore "." and ".."
+        if (!strcmp(user, ".") || !strcmp(user, "..")) {
+            continue;
+        }
+
+        // user directories start with a number
+        if (user[0] < '0' || user[0] > '9') {
+            ALOGE("Expecting numbered directory during restorecon. Instead got '%s'.", user);
+            continue;
+        }
+
+        std::string pkgdir(StringPrintf("%s%s/%s", userdir.c_str(), user, pkgName));
+        if (stat(pkgdir.c_str(), &s) < 0) {
+            continue;
+        }
+
+        if (selinux_android_restorecon_pkgdir(pkgdir.c_str(), seinfo, s.st_uid, flags) < 0) {
+            PLOG(ERROR) << "restorecon failed for " << pkgdir;
+            ret |= -1;
+        }
+    }
+
+    closedir(d);
+    return ret;
+}
+
+int create_oat_dir(const char* oat_dir, const char* instruction_set)
+{
+    char oat_instr_dir[PKG_PATH_MAX];
+
+    if (validate_apk_path(oat_dir)) {
+        ALOGE("invalid apk path '%s' (bad prefix)\n", oat_dir);
+        return -1;
+    }
+    if (fs_prepare_dir(oat_dir, S_IRWXU | S_IRWXG | S_IXOTH, AID_SYSTEM, AID_INSTALL)) {
+        return -1;
+    }
+    if (selinux_android_restorecon(oat_dir, 0)) {
+        ALOGE("cannot restorecon dir '%s': %s\n", oat_dir, strerror(errno));
+        return -1;
+    }
+    snprintf(oat_instr_dir, PKG_PATH_MAX, "%s/%s", oat_dir, instruction_set);
+    if (fs_prepare_dir(oat_instr_dir, S_IRWXU | S_IRWXG | S_IXOTH, AID_SYSTEM, AID_INSTALL)) {
+        return -1;
+    }
+    return 0;
+}
+
+int rm_package_dir(const char* apk_path)
+{
+    if (validate_apk_path(apk_path)) {
+        ALOGE("invalid apk path '%s' (bad prefix)\n", apk_path);
+        return -1;
+    }
+    return delete_dir_contents(apk_path, 1 /* also_delete_dir */ , NULL /* exclusion_predicate */);
+}
+
+int link_file(const char* relative_path, const char* from_base, const char* to_base) {
+    char from_path[PKG_PATH_MAX];
+    char to_path[PKG_PATH_MAX];
+    snprintf(from_path, PKG_PATH_MAX, "%s/%s", from_base, relative_path);
+    snprintf(to_path, PKG_PATH_MAX, "%s/%s", to_base, relative_path);
+
+    if (validate_apk_path_subdirs(from_path)) {
+        ALOGE("invalid app data sub-path '%s' (bad prefix)\n", from_path);
+        return -1;
+    }
+
+    if (validate_apk_path_subdirs(to_path)) {
+        ALOGE("invalid app data sub-path '%s' (bad prefix)\n", to_path);
+        return -1;
+    }
+
+    const int ret = link(from_path, to_path);
+    if (ret < 0) {
+        ALOGE("link(%s, %s) failed : %s", from_path, to_path, strerror(errno));
+        return -1;
+    }
+
+    return 0;
+}
+
+int calculate_oat_file_path(char path[PKG_PATH_MAX], const char *oat_dir, const char *apk_path,
+        const char *instruction_set) {
+    const char *file_name_start;
+    const char *file_name_end;
+
+    file_name_start = strrchr(apk_path, '/');
+    if (file_name_start == NULL) {
+         ALOGE("apk_path '%s' has no '/'s in it\n", apk_path);
+        return -1;
+    }
+    file_name_end = strrchr(apk_path, '.');
+    if (file_name_end < file_name_start) {
+        ALOGE("apk_path '%s' has no extension\n", apk_path);
+        return -1;
+    }
+
+    // Calculate file_name
+    int file_name_len = file_name_end - file_name_start - 1;
+    char file_name[file_name_len + 1];
+    memcpy(file_name, file_name_start + 1, file_name_len);
+    file_name[file_name_len] = '\0';
+
+    // <apk_parent_dir>/oat/<isa>/<file_name>.odex
+    snprintf(path, PKG_PATH_MAX, "%s/%s/%s.odex", oat_dir, instruction_set, file_name);
+    return 0;
+}
diff --git a/cmds/installd/installd.c b/cmds/installd/installd.c
deleted file mode 100644
index a078e1c..0000000
--- a/cmds/installd/installd.c
+++ /dev/null
@@ -1,641 +0,0 @@
-/*
-** Copyright 2008, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License"); 
-** you may not use this file except in compliance with the License. 
-** You may obtain a copy of the License at 
-**
-**     http://www.apache.org/licenses/LICENSE-2.0 
-**
-** Unless required by applicable law or agreed to in writing, software 
-** distributed under the License is distributed on an "AS IS" BASIS, 
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-** See the License for the specific language governing permissions and 
-** limitations under the License.
-*/
-
-#include <sys/capability.h>
-#include <linux/prctl.h>
-#include <selinux/android.h>
-#include <selinux/avc.h>
-
-#include "installd.h"
-
-
-#define BUFFER_MAX    1024  /* input buffer for commands */
-#define TOKEN_MAX     8     /* max number of arguments in buffer */
-#define REPLY_MAX     256   /* largest reply allowed */
-
-static int do_ping(char **arg, char reply[REPLY_MAX])
-{
-    return 0;
-}
-
-static int do_install(char **arg, char reply[REPLY_MAX])
-{
-    return install(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3]); /* pkgname, uid, gid, seinfo */
-}
-
-static int do_dexopt(char **arg, char reply[REPLY_MAX])
-{
-        /* apk_path, uid, is_public, pkgname */
-    return dexopt(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3]);
-}
-
-static int do_move_dex(char **arg, char reply[REPLY_MAX])
-{
-    return move_dex(arg[0], arg[1]); /* src, dst */
-}
-
-static int do_rm_dex(char **arg, char reply[REPLY_MAX])
-{
-    return rm_dex(arg[0]); /* pkgname */
-}
-
-static int do_remove(char **arg, char reply[REPLY_MAX])
-{
-    return uninstall(arg[0], atoi(arg[1])); /* pkgname, userid */
-}
-
-static int do_rename(char **arg, char reply[REPLY_MAX])
-{
-    return renamepkg(arg[0], arg[1]); /* oldpkgname, newpkgname */
-}
-
-static int do_fixuid(char **arg, char reply[REPLY_MAX])
-{
-    return fix_uid(arg[0], atoi(arg[1]), atoi(arg[2])); /* pkgname, uid, gid */
-}
-
-static int do_free_cache(char **arg, char reply[REPLY_MAX]) /* TODO int:free_size */
-{
-    return free_cache((int64_t)atoll(arg[0])); /* free_size */
-}
-
-static int do_rm_cache(char **arg, char reply[REPLY_MAX])
-{
-    return delete_cache(arg[0], atoi(arg[1])); /* pkgname, userid */
-}
-
-static int do_get_size(char **arg, char reply[REPLY_MAX])
-{
-    int64_t codesize = 0;
-    int64_t datasize = 0;
-    int64_t cachesize = 0;
-    int64_t asecsize = 0;
-    int res = 0;
-
-        /* pkgdir, userid, apkpath */
-    res = get_size(arg[0], atoi(arg[1]), arg[2], arg[3], arg[4], arg[5],
-            &codesize, &datasize, &cachesize, &asecsize);
-
-    /*
-     * Each int64_t can take up 22 characters printed out. Make sure it
-     * doesn't go over REPLY_MAX in the future.
-     */
-    snprintf(reply, REPLY_MAX, "%" PRId64 " %" PRId64 " %" PRId64 " %" PRId64,
-            codesize, datasize, cachesize, asecsize);
-    return res;
-}
-
-static int do_rm_user_data(char **arg, char reply[REPLY_MAX])
-{
-    return delete_user_data(arg[0], atoi(arg[1])); /* pkgname, userid */
-}
-
-static int do_mk_user_data(char **arg, char reply[REPLY_MAX])
-{
-    return make_user_data(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3]);
-                             /* pkgname, uid, userid, seinfo */
-}
-
-static int do_rm_user(char **arg, char reply[REPLY_MAX])
-{
-    return delete_user(atoi(arg[0])); /* userid */
-}
-
-static int do_movefiles(char **arg, char reply[REPLY_MAX])
-{
-    return movefiles();
-}
-
-static int do_linklib(char **arg, char reply[REPLY_MAX])
-{
-    return linklib(arg[0], arg[1], atoi(arg[2]));
-}
-
-static int do_idmap(char **arg, char reply[REPLY_MAX])
-{
-    return idmap(arg[0], arg[1], atoi(arg[2]));
-}
-
-static int do_restorecon_data(char **arg, char reply[REPLY_MAX] __attribute__((unused)))
-{
-    return restorecon_data(arg[0], arg[1], atoi(arg[2]));
-                             /* pkgName, seinfo, uid*/
-}
-
-struct cmdinfo {
-    const char *name;
-    unsigned numargs;
-    int (*func)(char **arg, char reply[REPLY_MAX]);
-};
-
-struct cmdinfo cmds[] = {
-    { "ping",                 0, do_ping },
-    { "install",              4, do_install },
-    { "dexopt",               4, do_dexopt },
-    { "movedex",              2, do_move_dex },
-    { "rmdex",                1, do_rm_dex },
-    { "remove",               2, do_remove },
-    { "rename",               2, do_rename },
-    { "fixuid",               3, do_fixuid },
-    { "freecache",            1, do_free_cache },
-    { "rmcache",              2, do_rm_cache },
-    { "getsize",              6, do_get_size },
-    { "rmuserdata",           2, do_rm_user_data },
-    { "movefiles",            0, do_movefiles },
-    { "linklib",              3, do_linklib },
-    { "mkuserdata",           4, do_mk_user_data },
-    { "rmuser",               1, do_rm_user },
-    { "idmap",                3, do_idmap },
-    { "restorecondata",       3, do_restorecon_data },
-};
-
-static int readx(int s, void *_buf, int count)
-{
-    char *buf = _buf;
-    int n = 0, r;
-    if (count < 0) return -1;
-    while (n < count) {
-        r = read(s, buf + n, count - n);
-        if (r < 0) {
-            if (errno == EINTR) continue;
-            ALOGE("read error: %s\n", strerror(errno));
-            return -1;
-        }
-        if (r == 0) {
-            ALOGE("eof\n");
-            return -1; /* EOF */
-        }
-        n += r;
-    }
-    return 0;
-}
-
-static int writex(int s, const void *_buf, int count)
-{
-    const char *buf = _buf;
-    int n = 0, r;
-    if (count < 0) return -1;
-    while (n < count) {
-        r = write(s, buf + n, count - n);
-        if (r < 0) {
-            if (errno == EINTR) continue;
-            ALOGE("write error: %s\n", strerror(errno));
-            return -1;
-        }
-        n += r;
-    }
-    return 0;
-}
-
-
-/* Tokenize the command buffer, locate a matching command,
- * ensure that the required number of arguments are provided,
- * call the function(), return the result.
- */
-static int execute(int s, char cmd[BUFFER_MAX])
-{
-    char reply[REPLY_MAX];
-    char *arg[TOKEN_MAX+1];
-    unsigned i;
-    unsigned n = 0;
-    unsigned short count;
-    int ret = -1;
-
-    // ALOGI("execute('%s')\n", cmd);
-
-        /* default reply is "" */
-    reply[0] = 0;
-
-        /* n is number of args (not counting arg[0]) */
-    arg[0] = cmd;
-    while (*cmd) {
-        if (isspace(*cmd)) {
-            *cmd++ = 0;
-            n++;
-            arg[n] = cmd;
-            if (n == TOKEN_MAX) {
-                ALOGE("too many arguments\n");
-                goto done;
-            }
-        }
-        cmd++;
-    }
-
-    for (i = 0; i < sizeof(cmds) / sizeof(cmds[0]); i++) {
-        if (!strcmp(cmds[i].name,arg[0])) {
-            if (n != cmds[i].numargs) {
-                ALOGE("%s requires %d arguments (%d given)\n",
-                     cmds[i].name, cmds[i].numargs, n);
-            } else {
-                ret = cmds[i].func(arg + 1, reply);
-            }
-            goto done;
-        }
-    }
-    ALOGE("unsupported command '%s'\n", arg[0]);
-
-done:
-    if (reply[0]) {
-        n = snprintf(cmd, BUFFER_MAX, "%d %s", ret, reply);
-    } else {
-        n = snprintf(cmd, BUFFER_MAX, "%d", ret);
-    }
-    if (n > BUFFER_MAX) n = BUFFER_MAX;
-    count = n;
-
-    // ALOGI("reply: '%s'\n", cmd);
-    if (writex(s, &count, sizeof(count))) return -1;
-    if (writex(s, cmd, count)) return -1;
-    return 0;
-}
-
-/**
- * Initialize all the global variables that are used elsewhere. Returns 0 upon
- * success and -1 on error.
- */
-void free_globals() {
-    size_t i;
-
-    for (i = 0; i < android_system_dirs.count; i++) {
-        if (android_system_dirs.dirs[i].path != NULL) {
-            free(android_system_dirs.dirs[i].path);
-        }
-    }
-
-    free(android_system_dirs.dirs);
-}
-
-int initialize_globals() {
-    // Get the android data directory.
-    if (get_path_from_env(&android_data_dir, "ANDROID_DATA") < 0) {
-        return -1;
-    }
-
-    // Get the android app directory.
-    if (copy_and_append(&android_app_dir, &android_data_dir, APP_SUBDIR) < 0) {
-        return -1;
-    }
-
-    // Get the android protected app directory.
-    if (copy_and_append(&android_app_private_dir, &android_data_dir, PRIVATE_APP_SUBDIR) < 0) {
-        return -1;
-    }
-
-    // Get the android app native library directory.
-    if (copy_and_append(&android_app_lib_dir, &android_data_dir, APP_LIB_SUBDIR) < 0) {
-        return -1;
-    }
-
-    // Get the sd-card ASEC mount point.
-    if (get_path_from_env(&android_asec_dir, "ASEC_MOUNTPOINT") < 0) {
-        return -1;
-    }
-
-    // Get the android media directory.
-    if (copy_and_append(&android_media_dir, &android_data_dir, MEDIA_SUBDIR) < 0) {
-        return -1;
-    }
-
-    // Take note of the system and vendor directories.
-    android_system_dirs.count = 2;
-
-    android_system_dirs.dirs = calloc(android_system_dirs.count, sizeof(dir_rec_t));
-    if (android_system_dirs.dirs == NULL) {
-        ALOGE("Couldn't allocate array for dirs; aborting\n");
-        return -1;
-    }
-
-    // system
-    if (get_path_from_env(&android_system_dirs.dirs[0], "ANDROID_ROOT") < 0) {
-        free_globals();
-        return -1;
-    }
-
-    // append "app/" to dirs[0]
-    char *system_app_path = build_string2(android_system_dirs.dirs[0].path, APP_SUBDIR);
-    android_system_dirs.dirs[0].path = system_app_path;
-    android_system_dirs.dirs[0].len = strlen(system_app_path);
-
-    // vendor
-    // TODO replace this with an environment variable (doesn't exist yet)
-    android_system_dirs.dirs[1].path = "/vendor/app/";
-    android_system_dirs.dirs[1].len = strlen(android_system_dirs.dirs[1].path);
-
-    return 0;
-}
-
-int initialize_directories() {
-    int res = -1;
-
-    // Read current filesystem layout version to handle upgrade paths
-    char version_path[PATH_MAX];
-    snprintf(version_path, PATH_MAX, "%s.layout_version", android_data_dir.path);
-
-    int oldVersion;
-    if (fs_read_atomic_int(version_path, &oldVersion) == -1) {
-        oldVersion = 0;
-    }
-    int version = oldVersion;
-
-    // /data/user
-    char *user_data_dir = build_string2(android_data_dir.path, SECONDARY_USER_PREFIX);
-    // /data/data
-    char *legacy_data_dir = build_string2(android_data_dir.path, PRIMARY_USER_PREFIX);
-    // /data/user/0
-    char *primary_data_dir = build_string3(android_data_dir.path, SECONDARY_USER_PREFIX, "0");
-    if (!user_data_dir || !legacy_data_dir || !primary_data_dir) {
-        goto fail;
-    }
-
-    // Make the /data/user directory if necessary
-    if (access(user_data_dir, R_OK) < 0) {
-        if (mkdir(user_data_dir, 0711) < 0) {
-            goto fail;
-        }
-        if (chown(user_data_dir, AID_SYSTEM, AID_SYSTEM) < 0) {
-            goto fail;
-        }
-        if (chmod(user_data_dir, 0711) < 0) {
-            goto fail;
-        }
-    }
-    // Make the /data/user/0 symlink to /data/data if necessary
-    if (access(primary_data_dir, R_OK) < 0) {
-        if (symlink(legacy_data_dir, primary_data_dir)) {
-            goto fail;
-        }
-    }
-
-    if (version == 0) {
-        // Introducing multi-user, so migrate /data/media contents into /data/media/0
-        ALOGD("Upgrading /data/media for multi-user");
-
-        // Ensure /data/media
-        if (fs_prepare_dir(android_media_dir.path, 0770, AID_MEDIA_RW, AID_MEDIA_RW) == -1) {
-            goto fail;
-        }
-
-        // /data/media.tmp
-        char media_tmp_dir[PATH_MAX];
-        snprintf(media_tmp_dir, PATH_MAX, "%smedia.tmp", android_data_dir.path);
-
-        // Only copy when upgrade not already in progress
-        if (access(media_tmp_dir, F_OK) == -1) {
-            if (rename(android_media_dir.path, media_tmp_dir) == -1) {
-                ALOGE("Failed to move legacy media path: %s", strerror(errno));
-                goto fail;
-            }
-        }
-
-        // Create /data/media again
-        if (fs_prepare_dir(android_media_dir.path, 0770, AID_MEDIA_RW, AID_MEDIA_RW) == -1) {
-            goto fail;
-        }
-
-        if (selinux_android_restorecon(android_media_dir.path, 0)) {
-            goto fail;
-        }
-
-        // /data/media/0
-        char owner_media_dir[PATH_MAX];
-        snprintf(owner_media_dir, PATH_MAX, "%s0", android_media_dir.path);
-
-        // Move any owner data into place
-        if (access(media_tmp_dir, F_OK) == 0) {
-            if (rename(media_tmp_dir, owner_media_dir) == -1) {
-                ALOGE("Failed to move owner media path: %s", strerror(errno));
-                goto fail;
-            }
-        }
-
-        // Ensure media directories for any existing users
-        DIR *dir;
-        struct dirent *dirent;
-        char user_media_dir[PATH_MAX];
-
-        dir = opendir(user_data_dir);
-        if (dir != NULL) {
-            while ((dirent = readdir(dir))) {
-                if (dirent->d_type == DT_DIR) {
-                    const char *name = dirent->d_name;
-
-                    // skip "." and ".."
-                    if (name[0] == '.') {
-                        if (name[1] == 0) continue;
-                        if ((name[1] == '.') && (name[2] == 0)) continue;
-                    }
-
-                    // /data/media/<user_id>
-                    snprintf(user_media_dir, PATH_MAX, "%s%s", android_media_dir.path, name);
-                    if (fs_prepare_dir(user_media_dir, 0770, AID_MEDIA_RW, AID_MEDIA_RW) == -1) {
-                        goto fail;
-                    }
-                }
-            }
-            closedir(dir);
-        }
-
-        version = 1;
-    }
-
-    // /data/media/obb
-    char media_obb_dir[PATH_MAX];
-    snprintf(media_obb_dir, PATH_MAX, "%sobb", android_media_dir.path);
-
-    if (version == 1) {
-        // Introducing /data/media/obb for sharing OBB across users; migrate
-        // any existing OBB files from owner.
-        ALOGD("Upgrading to shared /data/media/obb");
-
-        // /data/media/0/Android/obb
-        char owner_obb_path[PATH_MAX];
-        snprintf(owner_obb_path, PATH_MAX, "%s0/Android/obb", android_media_dir.path);
-
-        // Only move if target doesn't already exist
-        if (access(media_obb_dir, F_OK) != 0 && access(owner_obb_path, F_OK) == 0) {
-            if (rename(owner_obb_path, media_obb_dir) == -1) {
-                ALOGE("Failed to move OBB from owner: %s", strerror(errno));
-                goto fail;
-            }
-        }
-
-        version = 2;
-    }
-
-    if (ensure_media_user_dirs(0) == -1) {
-        ALOGE("Failed to setup media for user 0");
-        goto fail;
-    }
-    if (fs_prepare_dir(media_obb_dir, 0770, AID_MEDIA_RW, AID_MEDIA_RW) == -1) {
-        goto fail;
-    }
-
-    // Persist layout version if changed
-    if (version != oldVersion) {
-        if (fs_write_atomic_int(version_path, version) == -1) {
-            ALOGE("Failed to save version to %s: %s", version_path, strerror(errno));
-            goto fail;
-        }
-    }
-
-    // Success!
-    res = 0;
-
-fail:
-    free(user_data_dir);
-    free(legacy_data_dir);
-    free(primary_data_dir);
-    return res;
-}
-
-static void drop_privileges() {
-    if (prctl(PR_SET_KEEPCAPS, 1) < 0) {
-        ALOGE("prctl(PR_SET_KEEPCAPS) failed: %s\n", strerror(errno));
-        exit(1);
-    }
-
-    if (setgid(AID_INSTALL) < 0) {
-        ALOGE("setgid() can't drop privileges; exiting.\n");
-        exit(1);
-    }
-
-    if (setuid(AID_INSTALL) < 0) {
-        ALOGE("setuid() can't drop privileges; exiting.\n");
-        exit(1);
-    }
-
-    struct __user_cap_header_struct capheader;
-    struct __user_cap_data_struct capdata[2];
-    memset(&capheader, 0, sizeof(capheader));
-    memset(&capdata, 0, sizeof(capdata));
-    capheader.version = _LINUX_CAPABILITY_VERSION_3;
-    capheader.pid = 0;
-
-    capdata[CAP_TO_INDEX(CAP_DAC_OVERRIDE)].permitted |= CAP_TO_MASK(CAP_DAC_OVERRIDE);
-    capdata[CAP_TO_INDEX(CAP_CHOWN)].permitted        |= CAP_TO_MASK(CAP_CHOWN);
-    capdata[CAP_TO_INDEX(CAP_SETUID)].permitted       |= CAP_TO_MASK(CAP_SETUID);
-    capdata[CAP_TO_INDEX(CAP_SETGID)].permitted       |= CAP_TO_MASK(CAP_SETGID);
-    capdata[CAP_TO_INDEX(CAP_FOWNER)].permitted       |= CAP_TO_MASK(CAP_FOWNER);
-
-    capdata[0].effective = capdata[0].permitted;
-    capdata[1].effective = capdata[1].permitted;
-    capdata[0].inheritable = 0;
-    capdata[1].inheritable = 0;
-
-    if (capset(&capheader, &capdata[0]) < 0) {
-        ALOGE("capset failed: %s\n", strerror(errno));
-        exit(1);
-    }
-}
-
-static int log_callback(int type, const char *fmt, ...) {
-    va_list ap;
-    int priority;
-
-    switch (type) {
-    case SELINUX_WARNING:
-        priority = ANDROID_LOG_WARN;
-        break;
-    case SELINUX_INFO:
-        priority = ANDROID_LOG_INFO;
-        break;
-    default:
-        priority = ANDROID_LOG_ERROR;
-        break;
-    }
-    va_start(ap, fmt);
-    LOG_PRI_VA(priority, "SELinux", fmt, ap);
-    va_end(ap);
-    return 0;
-}
-
-int main(const int argc, const char *argv[]) {
-    char buf[BUFFER_MAX];
-    struct sockaddr addr;
-    socklen_t alen;
-    int lsocket, s, count;
-    int selinux_enabled = (is_selinux_enabled() > 0);
-
-    ALOGI("installd firing up\n");
-
-    union selinux_callback cb;
-    cb.func_log = log_callback;
-    selinux_set_callback(SELINUX_CB_LOG, cb);
-
-    if (initialize_globals() < 0) {
-        ALOGE("Could not initialize globals; exiting.\n");
-        exit(1);
-    }
-
-    if (initialize_directories() < 0) {
-        ALOGE("Could not create directories; exiting.\n");
-        exit(1);
-    }
-
-    if (selinux_enabled && selinux_status_open(true) < 0) {
-        ALOGE("Could not open selinux status; exiting.\n");
-        exit(1);
-    }
-
-    drop_privileges();
-
-    lsocket = android_get_control_socket(SOCKET_PATH);
-    if (lsocket < 0) {
-        ALOGE("Failed to get socket from environment: %s\n", strerror(errno));
-        exit(1);
-    }
-    if (listen(lsocket, 5)) {
-        ALOGE("Listen on socket failed: %s\n", strerror(errno));
-        exit(1);
-    }
-    fcntl(lsocket, F_SETFD, FD_CLOEXEC);
-
-    for (;;) {
-        alen = sizeof(addr);
-        s = accept(lsocket, &addr, &alen);
-        if (s < 0) {
-            ALOGE("Accept failed: %s\n", strerror(errno));
-            continue;
-        }
-        fcntl(s, F_SETFD, FD_CLOEXEC);
-
-        ALOGI("new connection\n");
-        for (;;) {
-            unsigned short count;
-            if (readx(s, &count, sizeof(count))) {
-                ALOGE("failed to read size\n");
-                break;
-            }
-            if ((count < 1) || (count >= BUFFER_MAX)) {
-                ALOGE("invalid size %d\n", count);
-                break;
-            }
-            if (readx(s, buf, count)) {
-                ALOGE("failed to read command\n");
-                break;
-            }
-            buf[count] = 0;
-            if (selinux_enabled && selinux_status_updated() > 0) {
-                selinux_android_seapp_context_reload();
-            }
-            if (execute(s, buf)) break;
-        }
-        ALOGI("closing connection\n");
-        close(s);
-    }
-
-    return 0;
-}
diff --git a/cmds/installd/installd.cpp b/cmds/installd/installd.cpp
new file mode 100644
index 0000000..30e4f8b
--- /dev/null
+++ b/cmds/installd/installd.cpp
@@ -0,0 +1,736 @@
+/*
+** Copyright 2008, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include "installd.h"
+
+#include <android-base/logging.h>
+
+#include <sys/capability.h>
+#include <sys/prctl.h>
+#include <selinux/android.h>
+#include <selinux/avc.h>
+
+#define BUFFER_MAX    1024  /* input buffer for commands */
+#define TOKEN_MAX     16    /* max number of arguments in buffer */
+#define REPLY_MAX     256   /* largest reply allowed */
+
+static char* parse_null(char* arg) {
+    if (strcmp(arg, "!") == 0) {
+        return nullptr;
+    } else {
+        return arg;
+    }
+}
+
+static int do_ping(char **arg __unused, char reply[REPLY_MAX] __unused)
+{
+    return 0;
+}
+
+static int do_install(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return install(parse_null(arg[0]), arg[1], atoi(arg[2]), atoi(arg[3]), arg[4]); /* uuid, pkgname, uid, gid, seinfo */
+}
+
+static int do_dexopt(char **arg, char reply[REPLY_MAX] __unused)
+{
+    /* apk_path, uid, pkgname, instruction_set, dexopt_needed, oat_dir, dexopt_flags */
+    return dexopt(arg[0], atoi(arg[1]), arg[2], arg[3], atoi(arg[4]),
+                  arg[5], atoi(arg[6]));
+}
+
+static int do_mark_boot_complete(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return mark_boot_complete(arg[0] /* instruction set */);
+}
+
+static int do_move_dex(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return move_dex(arg[0], arg[1], arg[2]); /* src, dst, instruction_set */
+}
+
+static int do_rm_dex(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return rm_dex(arg[0], arg[1]); /* pkgname, instruction_set */
+}
+
+static int do_remove(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return uninstall(parse_null(arg[0]), arg[1], atoi(arg[2])); /* uuid, pkgname, userid */
+}
+
+static int do_rename(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return renamepkg(arg[0], arg[1]); /* oldpkgname, newpkgname */
+}
+
+static int do_fixuid(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return fix_uid(parse_null(arg[0]), arg[1], atoi(arg[2]), atoi(arg[3])); /* uuid, pkgname, uid, gid */
+}
+
+static int do_free_cache(char **arg, char reply[REPLY_MAX] __unused) /* TODO int:free_size */
+{
+    return free_cache(parse_null(arg[0]), (int64_t)atoll(arg[1])); /* uuid, free_size */
+}
+
+static int do_rm_cache(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return delete_cache(parse_null(arg[0]), arg[1], atoi(arg[2])); /* uuid, pkgname, userid */
+}
+
+static int do_rm_code_cache(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return delete_code_cache(parse_null(arg[0]), arg[1], atoi(arg[2])); /* uuid, pkgname, userid */
+}
+
+static int do_get_size(char **arg, char reply[REPLY_MAX])
+{
+    int64_t codesize = 0;
+    int64_t datasize = 0;
+    int64_t cachesize = 0;
+    int64_t asecsize = 0;
+    int res = 0;
+
+        /* uuid, pkgdir, userid, apkpath */
+    res = get_size(parse_null(arg[0]), arg[1], atoi(arg[2]), arg[3], arg[4], arg[5], arg[6],
+            arg[7], &codesize, &datasize, &cachesize, &asecsize);
+
+    /*
+     * Each int64_t can take up 22 characters printed out. Make sure it
+     * doesn't go over REPLY_MAX in the future.
+     */
+    snprintf(reply, REPLY_MAX, "%" PRId64 " %" PRId64 " %" PRId64 " %" PRId64,
+            codesize, datasize, cachesize, asecsize);
+    return res;
+}
+
+static int do_rm_user_data(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return delete_user_data(parse_null(arg[0]), arg[1], atoi(arg[2])); /* uuid, pkgname, userid */
+}
+
+static int do_cp_complete_app(char **arg, char reply[REPLY_MAX] __unused)
+{
+    // from_uuid, to_uuid, package_name, data_app_name, appid, seinfo
+    return copy_complete_app(parse_null(arg[0]), parse_null(arg[1]), arg[2], arg[3], atoi(arg[4]), arg[5]);
+}
+
+static int do_mk_user_data(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return make_user_data(parse_null(arg[0]), arg[1], atoi(arg[2]), atoi(arg[3]), arg[4]);
+                             /* uuid, pkgname, uid, userid, seinfo */
+}
+
+static int do_mk_user_config(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return make_user_config(atoi(arg[0])); /* userid */
+}
+
+static int do_rm_user(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return delete_user(parse_null(arg[0]), atoi(arg[1])); /* uuid, userid */
+}
+
+static int do_movefiles(char **arg __unused, char reply[REPLY_MAX] __unused)
+{
+    return movefiles();
+}
+
+static int do_linklib(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return linklib(parse_null(arg[0]), arg[1], arg[2], atoi(arg[3]));
+}
+
+static int do_idmap(char **arg, char reply[REPLY_MAX] __unused)
+{
+    return idmap(arg[0], arg[1], atoi(arg[2]));
+}
+
+static int do_restorecon_data(char **arg, char reply[REPLY_MAX] __attribute__((unused)))
+{
+    return restorecon_data(parse_null(arg[0]), arg[1], arg[2], atoi(arg[3]));
+                             /* uuid, pkgName, seinfo, uid*/
+}
+
+static int do_create_oat_dir(char **arg, char reply[REPLY_MAX] __unused)
+{
+    /* oat_dir, instruction_set */
+    return create_oat_dir(arg[0], arg[1]);
+}
+
+static int do_rm_package_dir(char **arg, char reply[REPLY_MAX] __unused)
+{
+    /* oat_dir */
+    return rm_package_dir(arg[0]);
+}
+
+static int do_link_file(char **arg, char reply[REPLY_MAX] __unused)
+{
+    /* relative_path, from_base, to_base */
+    return link_file(arg[0], arg[1], arg[2]);
+}
+
+struct cmdinfo {
+    const char *name;
+    unsigned numargs;
+    int (*func)(char **arg, char reply[REPLY_MAX]);
+};
+
+struct cmdinfo cmds[] = {
+    { "ping",                 0, do_ping },
+    { "install",              5, do_install },
+    { "dexopt",               7, do_dexopt },
+    { "markbootcomplete",     1, do_mark_boot_complete },
+    { "movedex",              3, do_move_dex },
+    { "rmdex",                2, do_rm_dex },
+    { "remove",               3, do_remove },
+    { "rename",               2, do_rename },
+    { "fixuid",               4, do_fixuid },
+    { "freecache",            2, do_free_cache },
+    { "rmcache",              3, do_rm_cache },
+    { "rmcodecache",          3, do_rm_code_cache },
+    { "getsize",              8, do_get_size },
+    { "rmuserdata",           3, do_rm_user_data },
+    { "cpcompleteapp",        6, do_cp_complete_app },
+    { "movefiles",            0, do_movefiles },
+    { "linklib",              4, do_linklib },
+    { "mkuserdata",           5, do_mk_user_data },
+    { "mkuserconfig",         1, do_mk_user_config },
+    { "rmuser",               2, do_rm_user },
+    { "idmap",                3, do_idmap },
+    { "restorecondata",       4, do_restorecon_data },
+    { "createoatdir",         2, do_create_oat_dir },
+    { "rmpackagedir",         1, do_rm_package_dir },
+    { "linkfile",             3, do_link_file }
+};
+
+static int readx(int s, void *_buf, int count)
+{
+    char *buf = (char *) _buf;
+    int n = 0, r;
+    if (count < 0) return -1;
+    while (n < count) {
+        r = read(s, buf + n, count - n);
+        if (r < 0) {
+            if (errno == EINTR) continue;
+            ALOGE("read error: %s\n", strerror(errno));
+            return -1;
+        }
+        if (r == 0) {
+            ALOGE("eof\n");
+            return -1; /* EOF */
+        }
+        n += r;
+    }
+    return 0;
+}
+
+static int writex(int s, const void *_buf, int count)
+{
+    const char *buf = (const char *) _buf;
+    int n = 0, r;
+    if (count < 0) return -1;
+    while (n < count) {
+        r = write(s, buf + n, count - n);
+        if (r < 0) {
+            if (errno == EINTR) continue;
+            ALOGE("write error: %s\n", strerror(errno));
+            return -1;
+        }
+        n += r;
+    }
+    return 0;
+}
+
+
+/* Tokenize the command buffer, locate a matching command,
+ * ensure that the required number of arguments are provided,
+ * call the function(), return the result.
+ */
+static int execute(int s, char cmd[BUFFER_MAX])
+{
+    char reply[REPLY_MAX];
+    char *arg[TOKEN_MAX+1];
+    unsigned i;
+    unsigned n = 0;
+    unsigned short count;
+    int ret = -1;
+
+    // ALOGI("execute('%s')\n", cmd);
+
+        /* default reply is "" */
+    reply[0] = 0;
+
+        /* n is number of args (not counting arg[0]) */
+    arg[0] = cmd;
+    while (*cmd) {
+        if (isspace(*cmd)) {
+            *cmd++ = 0;
+            n++;
+            arg[n] = cmd;
+            if (n == TOKEN_MAX) {
+                ALOGE("too many arguments\n");
+                goto done;
+            }
+        }
+        if (*cmd) {
+          cmd++;
+        }
+    }
+
+    for (i = 0; i < sizeof(cmds) / sizeof(cmds[0]); i++) {
+        if (!strcmp(cmds[i].name,arg[0])) {
+            if (n != cmds[i].numargs) {
+                ALOGE("%s requires %d arguments (%d given)\n",
+                     cmds[i].name, cmds[i].numargs, n);
+            } else {
+                ret = cmds[i].func(arg + 1, reply);
+            }
+            goto done;
+        }
+    }
+    ALOGE("unsupported command '%s'\n", arg[0]);
+
+done:
+    if (reply[0]) {
+        n = snprintf(cmd, BUFFER_MAX, "%d %s", ret, reply);
+    } else {
+        n = snprintf(cmd, BUFFER_MAX, "%d", ret);
+    }
+    if (n > BUFFER_MAX) n = BUFFER_MAX;
+    count = n;
+
+    // ALOGI("reply: '%s'\n", cmd);
+    if (writex(s, &count, sizeof(count))) return -1;
+    if (writex(s, cmd, count)) return -1;
+    return 0;
+}
+
+/**
+ * Initialize all the global variables that are used elsewhere. Returns 0 upon
+ * success and -1 on error.
+ */
+void free_globals() {
+    size_t i;
+
+    for (i = 0; i < android_system_dirs.count; i++) {
+        if (android_system_dirs.dirs[i].path != NULL) {
+            free(android_system_dirs.dirs[i].path);
+        }
+    }
+
+    free(android_system_dirs.dirs);
+}
+
+int initialize_globals() {
+    // Get the android data directory.
+    if (get_path_from_env(&android_data_dir, "ANDROID_DATA") < 0) {
+        return -1;
+    }
+
+    // Get the android app directory.
+    if (copy_and_append(&android_app_dir, &android_data_dir, APP_SUBDIR) < 0) {
+        return -1;
+    }
+
+    // Get the android protected app directory.
+    if (copy_and_append(&android_app_private_dir, &android_data_dir, PRIVATE_APP_SUBDIR) < 0) {
+        return -1;
+    }
+
+    // Get the android app native library directory.
+    if (copy_and_append(&android_app_lib_dir, &android_data_dir, APP_LIB_SUBDIR) < 0) {
+        return -1;
+    }
+
+    // Get the sd-card ASEC mount point.
+    if (get_path_from_env(&android_asec_dir, "ASEC_MOUNTPOINT") < 0) {
+        return -1;
+    }
+
+    // Get the android media directory.
+    if (copy_and_append(&android_media_dir, &android_data_dir, MEDIA_SUBDIR) < 0) {
+        return -1;
+    }
+
+    // Get the android external app directory.
+    if (get_path_from_string(&android_mnt_expand_dir, "/mnt/expand/") < 0) {
+        return -1;
+    }
+
+    // Take note of the system and vendor directories.
+    android_system_dirs.count = 4;
+
+    android_system_dirs.dirs = (dir_rec_t*) calloc(android_system_dirs.count, sizeof(dir_rec_t));
+    if (android_system_dirs.dirs == NULL) {
+        ALOGE("Couldn't allocate array for dirs; aborting\n");
+        return -1;
+    }
+
+    dir_rec_t android_root_dir;
+    if (get_path_from_env(&android_root_dir, "ANDROID_ROOT") < 0) {
+        ALOGE("Missing ANDROID_ROOT; aborting\n");
+        return -1;
+    }
+
+    android_system_dirs.dirs[0].path = build_string2(android_root_dir.path, APP_SUBDIR);
+    android_system_dirs.dirs[0].len = strlen(android_system_dirs.dirs[0].path);
+
+    android_system_dirs.dirs[1].path = build_string2(android_root_dir.path, PRIV_APP_SUBDIR);
+    android_system_dirs.dirs[1].len = strlen(android_system_dirs.dirs[1].path);
+
+    android_system_dirs.dirs[2].path = strdup("/vendor/app/");
+    android_system_dirs.dirs[2].len = strlen(android_system_dirs.dirs[2].path);
+
+    android_system_dirs.dirs[3].path = strdup("/oem/app/");
+    android_system_dirs.dirs[3].len = strlen(android_system_dirs.dirs[3].path);
+
+    return 0;
+}
+
+int initialize_directories() {
+    int res = -1;
+
+    // Read current filesystem layout version to handle upgrade paths
+    char version_path[PATH_MAX];
+    snprintf(version_path, PATH_MAX, "%s.layout_version", android_data_dir.path);
+
+    int oldVersion;
+    if (fs_read_atomic_int(version_path, &oldVersion) == -1) {
+        oldVersion = 0;
+    }
+    int version = oldVersion;
+
+    // /data/user
+    char *user_data_dir = build_string2(android_data_dir.path, SECONDARY_USER_PREFIX);
+    // /data/data
+    char *legacy_data_dir = build_string2(android_data_dir.path, PRIMARY_USER_PREFIX);
+    // /data/user/0
+    char *primary_data_dir = build_string3(android_data_dir.path, SECONDARY_USER_PREFIX, "0");
+    if (!user_data_dir || !legacy_data_dir || !primary_data_dir) {
+        goto fail;
+    }
+
+    // Make the /data/user directory if necessary
+    if (access(user_data_dir, R_OK) < 0) {
+        if (mkdir(user_data_dir, 0711) < 0) {
+            goto fail;
+        }
+        if (chown(user_data_dir, AID_SYSTEM, AID_SYSTEM) < 0) {
+            goto fail;
+        }
+        if (chmod(user_data_dir, 0711) < 0) {
+            goto fail;
+        }
+    }
+    // Make the /data/user/0 symlink to /data/data if necessary
+    if (access(primary_data_dir, R_OK) < 0) {
+        if (symlink(legacy_data_dir, primary_data_dir)) {
+            goto fail;
+        }
+    }
+
+    if (version == 0) {
+        // Introducing multi-user, so migrate /data/media contents into /data/media/0
+        ALOGD("Upgrading /data/media for multi-user");
+
+        // Ensure /data/media
+        if (fs_prepare_dir(android_media_dir.path, 0770, AID_MEDIA_RW, AID_MEDIA_RW) == -1) {
+            goto fail;
+        }
+
+        // /data/media.tmp
+        char media_tmp_dir[PATH_MAX];
+        snprintf(media_tmp_dir, PATH_MAX, "%smedia.tmp", android_data_dir.path);
+
+        // Only copy when upgrade not already in progress
+        if (access(media_tmp_dir, F_OK) == -1) {
+            if (rename(android_media_dir.path, media_tmp_dir) == -1) {
+                ALOGE("Failed to move legacy media path: %s", strerror(errno));
+                goto fail;
+            }
+        }
+
+        // Create /data/media again
+        if (fs_prepare_dir(android_media_dir.path, 0770, AID_MEDIA_RW, AID_MEDIA_RW) == -1) {
+            goto fail;
+        }
+
+        if (selinux_android_restorecon(android_media_dir.path, 0)) {
+            goto fail;
+        }
+
+        // /data/media/0
+        char owner_media_dir[PATH_MAX];
+        snprintf(owner_media_dir, PATH_MAX, "%s0", android_media_dir.path);
+
+        // Move any owner data into place
+        if (access(media_tmp_dir, F_OK) == 0) {
+            if (rename(media_tmp_dir, owner_media_dir) == -1) {
+                ALOGE("Failed to move owner media path: %s", strerror(errno));
+                goto fail;
+            }
+        }
+
+        // Ensure media directories for any existing users
+        DIR *dir;
+        struct dirent *dirent;
+        char user_media_dir[PATH_MAX];
+
+        dir = opendir(user_data_dir);
+        if (dir != NULL) {
+            while ((dirent = readdir(dir))) {
+                if (dirent->d_type == DT_DIR) {
+                    const char *name = dirent->d_name;
+
+                    // skip "." and ".."
+                    if (name[0] == '.') {
+                        if (name[1] == 0) continue;
+                        if ((name[1] == '.') && (name[2] == 0)) continue;
+                    }
+
+                    // /data/media/<user_id>
+                    snprintf(user_media_dir, PATH_MAX, "%s%s", android_media_dir.path, name);
+                    if (fs_prepare_dir(user_media_dir, 0770, AID_MEDIA_RW, AID_MEDIA_RW) == -1) {
+                        goto fail;
+                    }
+                }
+            }
+            closedir(dir);
+        }
+
+        version = 1;
+    }
+
+    // /data/media/obb
+    char media_obb_dir[PATH_MAX];
+    snprintf(media_obb_dir, PATH_MAX, "%sobb", android_media_dir.path);
+
+    if (version == 1) {
+        // Introducing /data/media/obb for sharing OBB across users; migrate
+        // any existing OBB files from owner.
+        ALOGD("Upgrading to shared /data/media/obb");
+
+        // /data/media/0/Android/obb
+        char owner_obb_path[PATH_MAX];
+        snprintf(owner_obb_path, PATH_MAX, "%s0/Android/obb", android_media_dir.path);
+
+        // Only move if target doesn't already exist
+        if (access(media_obb_dir, F_OK) != 0 && access(owner_obb_path, F_OK) == 0) {
+            if (rename(owner_obb_path, media_obb_dir) == -1) {
+                ALOGE("Failed to move OBB from owner: %s", strerror(errno));
+                goto fail;
+            }
+        }
+
+        version = 2;
+    }
+
+    if (ensure_media_user_dirs(nullptr, 0) == -1) {
+        ALOGE("Failed to setup media for user 0");
+        goto fail;
+    }
+    if (fs_prepare_dir(media_obb_dir, 0770, AID_MEDIA_RW, AID_MEDIA_RW) == -1) {
+        goto fail;
+    }
+
+    if (ensure_config_user_dirs(0) == -1) {
+        ALOGE("Failed to setup misc for user 0");
+        goto fail;
+    }
+
+    if (version == 2) {
+        ALOGD("Upgrading to /data/misc/user directories");
+
+        char misc_dir[PATH_MAX];
+        snprintf(misc_dir, PATH_MAX, "%smisc", android_data_dir.path);
+
+        char keychain_added_dir[PATH_MAX];
+        snprintf(keychain_added_dir, PATH_MAX, "%s/keychain/cacerts-added", misc_dir);
+
+        char keychain_removed_dir[PATH_MAX];
+        snprintf(keychain_removed_dir, PATH_MAX, "%s/keychain/cacerts-removed", misc_dir);
+
+        DIR *dir;
+        struct dirent *dirent;
+        dir = opendir(user_data_dir);
+        if (dir != NULL) {
+            while ((dirent = readdir(dir))) {
+                const char *name = dirent->d_name;
+
+                // skip "." and ".."
+                if (name[0] == '.') {
+                    if (name[1] == 0) continue;
+                    if ((name[1] == '.') && (name[2] == 0)) continue;
+                }
+
+                uint32_t user_id = atoi(name);
+
+                // /data/misc/user/<user_id>
+                if (ensure_config_user_dirs(user_id) == -1) {
+                    goto fail;
+                }
+
+                char misc_added_dir[PATH_MAX];
+                snprintf(misc_added_dir, PATH_MAX, "%s/user/%s/cacerts-added", misc_dir, name);
+
+                char misc_removed_dir[PATH_MAX];
+                snprintf(misc_removed_dir, PATH_MAX, "%s/user/%s/cacerts-removed", misc_dir, name);
+
+                uid_t uid = multiuser_get_uid(user_id, AID_SYSTEM);
+                gid_t gid = uid;
+                if (access(keychain_added_dir, F_OK) == 0) {
+                    if (copy_dir_files(keychain_added_dir, misc_added_dir, uid, gid) != 0) {
+                        ALOGE("Some files failed to copy");
+                    }
+                }
+                if (access(keychain_removed_dir, F_OK) == 0) {
+                    if (copy_dir_files(keychain_removed_dir, misc_removed_dir, uid, gid) != 0) {
+                        ALOGE("Some files failed to copy");
+                    }
+                }
+            }
+            closedir(dir);
+
+            if (access(keychain_added_dir, F_OK) == 0) {
+                delete_dir_contents(keychain_added_dir, 1, 0);
+            }
+            if (access(keychain_removed_dir, F_OK) == 0) {
+                delete_dir_contents(keychain_removed_dir, 1, 0);
+            }
+        }
+
+        version = 3;
+    }
+
+    // Persist layout version if changed
+    if (version != oldVersion) {
+        if (fs_write_atomic_int(version_path, version) == -1) {
+            ALOGE("Failed to save version to %s: %s", version_path, strerror(errno));
+            goto fail;
+        }
+    }
+
+    // Success!
+    res = 0;
+
+fail:
+    free(user_data_dir);
+    free(legacy_data_dir);
+    free(primary_data_dir);
+    return res;
+}
+
+static int log_callback(int type, const char *fmt, ...) {
+    va_list ap;
+    int priority;
+
+    switch (type) {
+    case SELINUX_WARNING:
+        priority = ANDROID_LOG_WARN;
+        break;
+    case SELINUX_INFO:
+        priority = ANDROID_LOG_INFO;
+        break;
+    default:
+        priority = ANDROID_LOG_ERROR;
+        break;
+    }
+    va_start(ap, fmt);
+    LOG_PRI_VA(priority, "SELinux", fmt, ap);
+    va_end(ap);
+    return 0;
+}
+
+int main(const int argc __unused, char *argv[]) {
+    char buf[BUFFER_MAX];
+    struct sockaddr addr;
+    socklen_t alen;
+    int lsocket, s;
+    int selinux_enabled = (is_selinux_enabled() > 0);
+
+    setenv("ANDROID_LOG_TAGS", "*:v", 1);
+    android::base::InitLogging(argv);
+
+    ALOGI("installd firing up\n");
+
+    union selinux_callback cb;
+    cb.func_log = log_callback;
+    selinux_set_callback(SELINUX_CB_LOG, cb);
+
+    if (initialize_globals() < 0) {
+        ALOGE("Could not initialize globals; exiting.\n");
+        exit(1);
+    }
+
+    if (initialize_directories() < 0) {
+        ALOGE("Could not create directories; exiting.\n");
+        exit(1);
+    }
+
+    if (selinux_enabled && selinux_status_open(true) < 0) {
+        ALOGE("Could not open selinux status; exiting.\n");
+        exit(1);
+    }
+
+    lsocket = android_get_control_socket(SOCKET_PATH);
+    if (lsocket < 0) {
+        ALOGE("Failed to get socket from environment: %s\n", strerror(errno));
+        exit(1);
+    }
+    if (listen(lsocket, 5)) {
+        ALOGE("Listen on socket failed: %s\n", strerror(errno));
+        exit(1);
+    }
+    fcntl(lsocket, F_SETFD, FD_CLOEXEC);
+
+    for (;;) {
+        alen = sizeof(addr);
+        s = accept(lsocket, &addr, &alen);
+        if (s < 0) {
+            ALOGE("Accept failed: %s\n", strerror(errno));
+            continue;
+        }
+        fcntl(s, F_SETFD, FD_CLOEXEC);
+
+        ALOGI("new connection\n");
+        for (;;) {
+            unsigned short count;
+            if (readx(s, &count, sizeof(count))) {
+                ALOGE("failed to read size\n");
+                break;
+            }
+            if ((count < 1) || (count >= BUFFER_MAX)) {
+                ALOGE("invalid size %d\n", count);
+                break;
+            }
+            if (readx(s, buf, count)) {
+                ALOGE("failed to read command\n");
+                break;
+            }
+            buf[count] = 0;
+            if (selinux_enabled && selinux_status_updated() > 0) {
+                selinux_android_seapp_context_reload();
+            }
+            if (execute(s, buf)) break;
+        }
+        ALOGI("closing connection\n");
+        close(s);
+    }
+
+    return 0;
+}
diff --git a/cmds/installd/installd.h b/cmds/installd/installd.h
index 3e9caf3..8c48b88 100644
--- a/cmds/installd/installd.h
+++ b/cmds/installd/installd.h
@@ -2,16 +2,16 @@
 **
 ** Copyright 2008, The Android Open Source Project
 **
-** Licensed under the Apache License, Version 2.0 (the "License"); 
-** you may not use this file except in compliance with the License. 
-** You may obtain a copy of the License at 
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
 **
-**     http://www.apache.org/licenses/LICENSE-2.0 
+**     http://www.apache.org/licenses/LICENSE-2.0
 **
-** Unless required by applicable law or agreed to in writing, software 
-** distributed under the License is distributed on an "AS IS" BASIS, 
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-** See the License for the specific language governing permissions and 
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
 ** limitations under the License.
 */
 
@@ -31,6 +31,8 @@
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <string>
+#include <vector>
 
 #include <cutils/fs.h>
 #include <cutils/sockets.h>
@@ -40,7 +42,7 @@
 
 #include <private/android_filesystem_config.h>
 
-#if INCLUDE_SYS_MOUNT_FOR_STATFS
+#if defined(__APPLE__)
 #include <sys/mount.h>
 #else
 #include <sys/statfs.h>
@@ -59,8 +61,10 @@
 #define PKG_LIB_POSTFIX        "/lib"
 
 #define CACHE_DIR_POSTFIX      "/cache"
+#define CODE_CACHE_DIR_POSTFIX "/code_cache"
 
 #define APP_SUBDIR             "app/" // sub-directory under ANDROID_DATA
+#define PRIV_APP_SUBDIR        "priv-app/" // sub-directory under ANDROID_DATA
 
 #define APP_LIB_SUBDIR         "app-lib/" // sub-directory under ANDROID_DATA
 
@@ -81,6 +85,31 @@
 #define PKG_NAME_MAX  128   /* largest allowed package name */
 #define PKG_PATH_MAX  256   /* max size of any path we use */
 
+/* dexopt needed flags matching those in dalvik.system.DexFile */
+#define DEXOPT_DEX2OAT_NEEDED        1
+#define DEXOPT_PATCHOAT_NEEDED       2
+#define DEXOPT_SELF_PATCHOAT_NEEDED  3
+
+/****************************************************************************
+ * IMPORTANT: These values are passed from Java code. Keep them in sync with
+ * frameworks/base/services/core/java/com/android/server/pm/Installer.java
+ ***************************************************************************/
+constexpr int DEXOPT_PUBLIC       = 1 << 1;
+constexpr int DEXOPT_SAFEMODE     = 1 << 2;
+constexpr int DEXOPT_DEBUGGABLE   = 1 << 3;
+constexpr int DEXOPT_BOOTCOMPLETE = 1 << 4;
+constexpr int DEXOPT_USEJIT       = 1 << 5;
+
+/* all known values for dexopt flags */
+constexpr int DEXOPT_MASK =
+    DEXOPT_PUBLIC
+    | DEXOPT_SAFEMODE
+    | DEXOPT_DEBUGGABLE
+    | DEXOPT_BOOTCOMPLETE
+    | DEXOPT_USEJIT;
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
+
 /* data structures */
 
 typedef struct {
@@ -99,6 +128,7 @@
 extern dir_rec_t android_data_dir;
 extern dir_rec_t android_asec_dir;
 extern dir_rec_t android_media_dir;
+extern dir_rec_t android_mnt_expand_dir;
 extern dir_rec_array_t android_system_dirs;
 
 typedef struct cache_dir_struct {
@@ -130,20 +160,27 @@
 
 /* util.c */
 
-int create_pkg_path_in_dir(char path[PKG_PATH_MAX],
-                                const dir_rec_t* dir,
-                                const char* pkgname,
-                                const char* postfix);
-
 int create_pkg_path(char path[PKG_PATH_MAX],
                     const char *pkgname,
                     const char *postfix,
                     userid_t userid);
 
-int create_user_path(char path[PKG_PATH_MAX],
-                    userid_t userid);
+std::string create_data_path(const char* volume_uuid);
 
-int create_user_media_path(char path[PKG_PATH_MAX], userid_t userid);
+std::string create_data_app_path(const char* volume_uuid);
+
+std::string create_data_app_package_path(const char* volume_uuid, const char* package_name);
+
+std::string create_data_user_path(const char* volume_uuid, userid_t userid);
+
+std::string create_data_user_package_path(const char* volume_uuid,
+        userid_t user, const char* package_name);
+
+std::string create_data_media_path(const char* volume_uuid, userid_t userid);
+
+std::vector<userid_t> get_known_users(const char* volume_uuid);
+
+int create_user_config_path(char path[PKG_PATH_MAX], userid_t userid);
 
 int create_move_path(char path[PKG_PATH_MAX],
                      const char* pkgname,
@@ -152,23 +189,26 @@
 
 int is_valid_package_name(const char* pkgname);
 
-int create_cache_path(char path[PKG_PATH_MAX], const char *src);
+int create_cache_path(char path[PKG_PATH_MAX], const char *src,
+                      const char *instruction_set);
 
 int delete_dir_contents(const char *pathname,
                         int also_delete_dir,
-                        const char *ignore);
+                        int (*exclusion_predicate)(const char *name, const int is_dir));
 
 int delete_dir_contents_fd(int dfd, const char *name);
 
+int copy_dir_files(const char *srcname, const char *dstname, uid_t owner, gid_t group);
+
 int lookup_media_dir(char basepath[PATH_MAX], const char *dir);
 
-int64_t data_disk_free();
+int64_t data_disk_free(const std::string& data_path);
 
 cache_t* start_cache_collection();
 
 void add_cache_files(cache_t* cache, const char *basepath, const char *cachedir);
 
-void clear_cache_files(cache_t* cache, int64_t free_size);
+void clear_cache_files(const std::string& data_path, cache_t* cache, int64_t free_size);
 
 void finish_cache_collection(cache_t* cache);
 
@@ -181,36 +221,53 @@
 int copy_and_append(dir_rec_t* dst, const dir_rec_t* src, const char* suffix);
 
 int validate_apk_path(const char *path);
+int validate_apk_path_subdirs(const char *path);
 
 int append_and_increment(char** dst, const char* src, size_t* dst_size);
 
-char *build_string2(char *s1, char *s2);
-char *build_string3(char *s1, char *s2, char *s3);
+char *build_string2(const char *s1, const char *s2);
+char *build_string3(const char *s1, const char *s2, const char *s3);
 
 int ensure_dir(const char* path, mode_t mode, uid_t uid, gid_t gid);
-int ensure_media_user_dirs(userid_t userid);
-int create_profile_file(const char *pkgname, gid_t gid);
-void remove_profile_file(const char *pkgname);
+int ensure_media_user_dirs(const char* uuid, userid_t userid);
+int ensure_config_user_dirs(userid_t userid);
 
 /* commands.c */
 
-int install(const char *pkgname, uid_t uid, gid_t gid, const char *seinfo);
-int uninstall(const char *pkgname, userid_t userid);
+int install(const char *uuid, const char *pkgname, uid_t uid, gid_t gid, const char *seinfo);
+int uninstall(const char *uuid, const char *pkgname, userid_t userid);
 int renamepkg(const char *oldpkgname, const char *newpkgname);
-int fix_uid(const char *pkgname, uid_t uid, gid_t gid);
-int delete_user_data(const char *pkgname, userid_t userid);
-int make_user_data(const char *pkgname, uid_t uid, userid_t userid, const char* seinfo);
-int delete_user(userid_t userid);
-int delete_cache(const char *pkgname, userid_t userid);
-int move_dex(const char *src, const char *dst);
-int rm_dex(const char *path);
+int fix_uid(const char *uuid, const char *pkgname, uid_t uid, gid_t gid);
+int delete_user_data(const char *uuid, const char *pkgname, userid_t userid);
+int make_user_data(const char *uuid, const char *pkgname, uid_t uid,
+        userid_t userid, const char* seinfo);
+int copy_complete_app(const char* from_uuid, const char *to_uuid,
+        const char *package_name, const char *data_app_name, appid_t appid,
+        const char* seinfo);
+int make_user_config(userid_t userid);
+int delete_user(const char *uuid, userid_t userid);
+int delete_cache(const char *uuid, const char *pkgname, userid_t userid);
+int delete_code_cache(const char *uuid, const char *pkgname, userid_t userid);
+int move_dex(const char *src, const char *dst, const char *instruction_set);
+int rm_dex(const char *path, const char *instruction_set);
 int protect(char *pkgname, gid_t gid);
-int get_size(const char *pkgname, userid_t userid, const char *apkpath, const char *libdirpath,
-             const char *fwdlock_apkpath, const char *asecpath, int64_t *codesize,
-             int64_t *datasize, int64_t *cachesize, int64_t *asecsize);
-int free_cache(int64_t free_size);
-int dexopt(const char *apk_path, uid_t uid, int is_public, const char *pkgName);
+int get_size(const char *uuid, const char *pkgname, int userid,
+        const char *apkpath, const char *libdirpath,
+        const char *fwdlock_apkpath, const char *asecpath,
+        const char *instruction_set, int64_t *codesize, int64_t *datasize,
+        int64_t *cachesize, int64_t *asecsize);
+int free_cache(const char *uuid, int64_t free_size);
+int dexopt(const char *apk_path, uid_t uid, const char *pkgName, const char *instruction_set,
+           int dexopt_needed, const char* oat_dir, int dexopt_flags);
+int mark_boot_complete(const char *instruction_set);
 int movefiles();
-int linklib(const char* target, const char* source, int userId);
+int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId);
 int idmap(const char *target_path, const char *overlay_path, uid_t uid);
-int restorecon_data();
+int restorecon_data(const char *uuid, const char* pkgName, const char* seinfo, uid_t uid);
+int create_oat_dir(const char* oat_dir, const char *instruction_set);
+int rm_package_dir(const char* apk_path);
+int calculate_oat_file_path(char path[PKG_PATH_MAX], const char *oat_dir, const char *apk_path,
+                            const char *instruction_set);
+int move_package_dir(char path[PKG_PATH_MAX], const char *oat_dir, const char *apk_path,
+                            const char *instruction_set);
+int link_file(const char *relative_path, const char *from_base, const char *to_base);
diff --git a/cmds/installd/installd.rc b/cmds/installd/installd.rc
new file mode 100644
index 0000000..5e4c925
--- /dev/null
+++ b/cmds/installd/installd.rc
@@ -0,0 +1,3 @@
+service installd /system/bin/installd
+    class main
+    socket installd stream 600 system system
diff --git a/cmds/installd/tests/Android.mk b/cmds/installd/tests/Android.mk
index 4faf3c0..38a9f69 100644
--- a/cmds/installd/tests/Android.mk
+++ b/cmds/installd/tests/Android.mk
@@ -1,21 +1,20 @@
 # Build the unit tests for installd
 LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 
 # Build the unit tests.
 test_src_files := \
     installd_utils_test.cpp
 
 shared_libraries := \
+    libbase \
     libutils \
     libcutils \
-    libstlport
 
 static_libraries := \
     libinstalld \
     libdiskusage \
-    libgtest \
-    libgtest_main
 
 c_includes := \
     frameworks/native/cmds/installd
@@ -27,5 +26,6 @@
     $(eval LOCAL_SRC_FILES := $(file)) \
     $(eval LOCAL_C_INCLUDES := $(c_includes)) \
     $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \
+    $(eval LOCAL_CLANG := true) \
     $(eval include $(BUILD_NATIVE_TEST)) \
 )
diff --git a/cmds/installd/tests/installd_utils_test.cpp b/cmds/installd/tests/installd_utils_test.cpp
index 0b182af..5e397f9 100644
--- a/cmds/installd/tests/installd_utils_test.cpp
+++ b/cmds/installd/tests/installd_utils_test.cpp
@@ -17,19 +17,18 @@
 #include <stdlib.h>
 #include <string.h>
 
-#define LOG_TAG "utils_test"
-#include <utils/Log.h>
-
 #include <gtest/gtest.h>
 
-extern "C" {
 #include "installd.h"
-}
+
+#undef LOG_TAG
+#define LOG_TAG "utils_test"
 
 #define TEST_DATA_DIR "/data/"
 #define TEST_APP_DIR "/data/app/"
 #define TEST_APP_PRIVATE_DIR "/data/app-private/"
 #define TEST_ASEC_DIR "/mnt/asec/"
+#define TEST_EXPAND_DIR "/mnt/expand/"
 
 #define TEST_SYSTEM_DIR1 "/system/app/"
 #define TEST_SYSTEM_DIR2 "/vendor/app/"
@@ -49,25 +48,28 @@
 class UtilsTest : public testing::Test {
 protected:
     virtual void SetUp() {
-        android_app_dir.path = TEST_APP_DIR;
+        android_app_dir.path = (char*) TEST_APP_DIR;
         android_app_dir.len = strlen(TEST_APP_DIR);
 
-        android_app_private_dir.path = TEST_APP_PRIVATE_DIR;
+        android_app_private_dir.path = (char*) TEST_APP_PRIVATE_DIR;
         android_app_private_dir.len = strlen(TEST_APP_PRIVATE_DIR);
 
-        android_data_dir.path = TEST_DATA_DIR;
+        android_data_dir.path = (char*) TEST_DATA_DIR;
         android_data_dir.len = strlen(TEST_DATA_DIR);
 
-        android_asec_dir.path = TEST_ASEC_DIR;
+        android_asec_dir.path = (char*) TEST_ASEC_DIR;
         android_asec_dir.len = strlen(TEST_ASEC_DIR);
 
+        android_mnt_expand_dir.path = (char*) TEST_EXPAND_DIR;
+        android_mnt_expand_dir.len = strlen(TEST_EXPAND_DIR);
+
         android_system_dirs.count = 2;
 
         android_system_dirs.dirs = (dir_rec_t*) calloc(android_system_dirs.count, sizeof(dir_rec_t));
-        android_system_dirs.dirs[0].path = TEST_SYSTEM_DIR1;
+        android_system_dirs.dirs[0].path = (char*) TEST_SYSTEM_DIR1;
         android_system_dirs.dirs[0].len = strlen(TEST_SYSTEM_DIR1);
 
-        android_system_dirs.dirs[1].path = TEST_SYSTEM_DIR2;
+        android_system_dirs.dirs[1].path = (char*) TEST_SYSTEM_DIR2;
         android_system_dirs.dirs[1].len = strlen(TEST_SYSTEM_DIR2);
     }
 
@@ -101,6 +103,11 @@
     EXPECT_EQ(0, validate_apk_path(internal1))
             << internal1 << " should be allowed as a valid path";
 
+    // b/16888084
+    const char *path2 = TEST_APP_DIR "example.com/example.apk";
+    EXPECT_EQ(0, validate_apk_path(path2))
+            << path2 << " should be allowed as a valid path";
+
     const char *badint1 = TEST_APP_DIR "../example.apk";
     EXPECT_EQ(-1, validate_apk_path(badint1))
             << badint1 << " should be rejected as a invalid path";
@@ -109,9 +116,18 @@
     EXPECT_EQ(-1, validate_apk_path(badint2))
             << badint2 << " should be rejected as a invalid path";
 
-    const char *badint3 = TEST_APP_DIR "example.com/pkg.apk";
-    EXPECT_EQ(-1, validate_apk_path(badint3))
-            << badint3 << " should be rejected as a invalid path";
+    // Only one subdir should be allowed.
+    const char *bad_path3 = TEST_APP_DIR "example.com/subdir/pkg.apk";
+    EXPECT_EQ(-1, validate_apk_path(bad_path3))
+            << bad_path3 << " should be rejected as a invalid path";
+
+    const char *bad_path4 = TEST_APP_DIR "example.com/subdir/../pkg.apk";
+    EXPECT_EQ(-1, validate_apk_path(bad_path4))
+            << bad_path4 << " should be rejected as a invalid path";
+
+    const char *bad_path5 = TEST_APP_DIR "example.com1/../example.com2/pkg.apk";
+    EXPECT_EQ(-1, validate_apk_path(bad_path5))
+            << bad_path5 << " should be rejected as a invalid path";
 }
 
 TEST_F(UtilsTest, IsValidApkPath_Private) {
@@ -120,6 +136,11 @@
     EXPECT_EQ(0, validate_apk_path(private1))
             << private1 << " should be allowed as a valid path";
 
+    // b/16888084
+    const char *path2 = TEST_APP_DIR "example.com/example.apk";
+    EXPECT_EQ(0, validate_apk_path(path2))
+            << path2 << " should be allowed as a valid path";
+
     const char *badpriv1 = TEST_APP_PRIVATE_DIR "../example.apk";
     EXPECT_EQ(-1, validate_apk_path(badpriv1))
             << badpriv1 << " should be rejected as a invalid path";
@@ -128,9 +149,18 @@
     EXPECT_EQ(-1, validate_apk_path(badpriv2))
             << badpriv2 << " should be rejected as a invalid path";
 
-    const char *badpriv3 = TEST_APP_PRIVATE_DIR "example.com/pkg.apk";
-    EXPECT_EQ(-1, validate_apk_path(badpriv3))
-            << badpriv3 << " should be rejected as a invalid path";
+    // Only one subdir should be allowed.
+    const char *bad_path3 = TEST_APP_PRIVATE_DIR "example.com/subdir/pkg.apk";
+    EXPECT_EQ(-1, validate_apk_path(bad_path3))
+            << bad_path3 << " should be rejected as a invalid path";
+
+    const char *bad_path4 = TEST_APP_PRIVATE_DIR "example.com/subdir/../pkg.apk";
+    EXPECT_EQ(-1, validate_apk_path(bad_path4))
+            << bad_path4 << " should be rejected as a invalid path";
+
+    const char *bad_path5 = TEST_APP_PRIVATE_DIR "example.com1/../example.com2/pkg.apk";
+    EXPECT_EQ(-1, validate_apk_path(bad_path5))
+            << bad_path5 << " should be rejected as a invalid path";
 }
 
 
@@ -218,6 +248,24 @@
             << badapp3 << " should be rejected not a system path";
 }
 
+TEST_F(UtilsTest, CheckSystemApp_Subdir) {
+    const char *sysapp = TEST_SYSTEM_DIR1 "com.example/com.example.apk";
+    EXPECT_EQ(0, validate_system_app_path(sysapp))
+            << sysapp << " should be allowed as a system path";
+
+    const char *badapp = TEST_SYSTEM_DIR1 "com.example/subdir/com.example.apk";
+    EXPECT_EQ(-1, validate_system_app_path(badapp))
+            << badapp << " should be rejected not a system path";
+
+    const char *badapp1 = TEST_SYSTEM_DIR1 "com.example/subdir/../com.example.apk";
+    EXPECT_EQ(-1, validate_system_app_path(badapp1))
+            << badapp1 << " should be rejected not a system path";
+
+    const char *badapp2 = TEST_SYSTEM_DIR1 "com.example1/../com.example2/com.example.apk";
+    EXPECT_EQ(-1, validate_system_app_path(badapp2))
+            << badapp2 << " should be rejected not a system path";
+}
+
 TEST_F(UtilsTest, GetPathFromString_NullPathFail) {
     dir_rec_t test1;
     EXPECT_EQ(-1, get_path_from_string(&test1, (const char *) NULL))
@@ -273,6 +321,7 @@
 
     const char *prefix = TEST_DATA_DIR PRIMARY_USER_PREFIX;
     size_t offset = strlen(prefix);
+
     EXPECT_STREQ(pkgname, path + offset)
              << "Package path should be a really long string of a's";
 }
@@ -323,40 +372,6 @@
             << "Package path should be in /data/user/";
 }
 
-TEST_F(UtilsTest, CreatePkgPathInDir_ProtectedDir) {
-    char path[PKG_PATH_MAX];
-
-    dir_rec_t dir;
-    dir.path = "/data/app-private/";
-    dir.len = strlen(dir.path);
-
-    EXPECT_EQ(0, create_pkg_path_in_dir(path, &dir, "com.example.package", ".apk"))
-            << "Should successfully create package path.";
-
-    EXPECT_STREQ("/data/app-private/com.example.package.apk", path)
-            << "Package path should be in /data/app-private/";
-}
-
-TEST_F(UtilsTest, CreatePersonaPath_Primary) {
-    char path[PKG_PATH_MAX];
-
-    EXPECT_EQ(0, create_user_path(path, 0))
-            << "Should successfully build primary user path.";
-
-    EXPECT_STREQ("/data/data/", path)
-            << "Primary user should have correct path";
-}
-
-TEST_F(UtilsTest, CreatePersonaPath_Secondary) {
-    char path[PKG_PATH_MAX];
-
-    EXPECT_EQ(0, create_user_path(path, 1))
-            << "Should successfully build primary user path.";
-
-    EXPECT_STREQ("/data/user/1/", path)
-            << "Primary user should have correct path";
-}
-
 TEST_F(UtilsTest, CreateMovePath_Primary) {
     char path[PKG_PATH_MAX];
 
@@ -386,7 +401,7 @@
     dir_rec_t dst;
     dir_rec_t src;
 
-    src.path = "/data/";
+    src.path = (char*) "/data/";
     src.len = strlen(src.path);
 
     EXPECT_EQ(0, copy_and_append(&dst, &src, "app/"))
@@ -434,4 +449,54 @@
             << "String should fail because it's too large to fit";
 }
 
+TEST_F(UtilsTest, CreateDataPath) {
+    EXPECT_EQ("/data", create_data_path(nullptr));
+    EXPECT_EQ("/mnt/expand/57f8f4bc-abf4-655f-bf67-946fc0f9f25b",
+            create_data_path("57f8f4bc-abf4-655f-bf67-946fc0f9f25b"));
+}
+
+TEST_F(UtilsTest, CreateDataAppPath) {
+    EXPECT_EQ("/data/app", create_data_app_path(nullptr));
+
+    EXPECT_EQ("/mnt/expand/57f8f4bc-abf4-655f-bf67-946fc0f9f25b/app",
+            create_data_app_path("57f8f4bc-abf4-655f-bf67-946fc0f9f25b"));
+}
+
+TEST_F(UtilsTest, CreateDataUserPath) {
+    EXPECT_EQ("/data/data", create_data_user_path(nullptr, 0));
+    EXPECT_EQ("/data/user/10", create_data_user_path(nullptr, 10));
+
+    EXPECT_EQ("/mnt/expand/57f8f4bc-abf4-655f-bf67-946fc0f9f25b/user/0",
+            create_data_user_path("57f8f4bc-abf4-655f-bf67-946fc0f9f25b", 0));
+    EXPECT_EQ("/mnt/expand/57f8f4bc-abf4-655f-bf67-946fc0f9f25b/user/10",
+            create_data_user_path("57f8f4bc-abf4-655f-bf67-946fc0f9f25b", 10));
+}
+
+TEST_F(UtilsTest, CreateDataMediaPath) {
+    EXPECT_EQ("/data/media/0", create_data_media_path(nullptr, 0));
+    EXPECT_EQ("/data/media/10", create_data_media_path(nullptr, 10));
+
+    EXPECT_EQ("/mnt/expand/57f8f4bc-abf4-655f-bf67-946fc0f9f25b/media/0",
+            create_data_media_path("57f8f4bc-abf4-655f-bf67-946fc0f9f25b", 0));
+    EXPECT_EQ("/mnt/expand/57f8f4bc-abf4-655f-bf67-946fc0f9f25b/media/10",
+            create_data_media_path("57f8f4bc-abf4-655f-bf67-946fc0f9f25b", 10));
+}
+
+TEST_F(UtilsTest, CreateDataAppPackagePath) {
+    EXPECT_EQ("/data/app/com.example", create_data_app_package_path(nullptr, "com.example"));
+
+    EXPECT_EQ("/mnt/expand/57f8f4bc-abf4-655f-bf67-946fc0f9f25b/app/com.example",
+            create_data_app_package_path("57f8f4bc-abf4-655f-bf67-946fc0f9f25b", "com.example"));
+}
+
+TEST_F(UtilsTest, CreateDataUserPackagePath) {
+    EXPECT_EQ("/data/data/com.example", create_data_user_package_path(nullptr, 0, "com.example"));
+    EXPECT_EQ("/data/user/10/com.example", create_data_user_package_path(nullptr, 10, "com.example"));
+
+    EXPECT_EQ("/mnt/expand/57f8f4bc-abf4-655f-bf67-946fc0f9f25b/user/0/com.example",
+            create_data_user_package_path("57f8f4bc-abf4-655f-bf67-946fc0f9f25b", 0, "com.example"));
+    EXPECT_EQ("/mnt/expand/57f8f4bc-abf4-655f-bf67-946fc0f9f25b/user/10/com.example",
+            create_data_user_package_path("57f8f4bc-abf4-655f-bf67-946fc0f9f25b", 10, "com.example"));
+}
+
 }
diff --git a/cmds/installd/utils.c b/cmds/installd/utils.cpp
similarity index 71%
rename from cmds/installd/utils.c
rename to cmds/installd/utils.cpp
index 671d031..a98fec5 100644
--- a/cmds/installd/utils.c
+++ b/cmds/installd/utils.cpp
@@ -16,134 +16,149 @@
 
 #include "installd.h"
 
+#include <android-base/stringprintf.h>
+#include <android-base/logging.h>
+
 #define CACHE_NOISY(x) //x
 
-int create_pkg_path_in_dir(char path[PKG_PATH_MAX],
-                                const dir_rec_t* dir,
-                                const char* pkgname,
-                                const char* postfix)
-{
-     const size_t postfix_len = strlen(postfix);
+using android::base::StringPrintf;
 
-     const size_t pkgname_len = strlen(pkgname);
-     if (pkgname_len > PKG_NAME_MAX) {
-         return -1;
-     }
-
-     if (is_valid_package_name(pkgname) < 0) {
-         return -1;
-     }
-
-     if ((pkgname_len + dir->len + postfix_len) >= PKG_PATH_MAX) {
-         return -1;
-     }
-
-     char *dst = path;
-     size_t dst_size = PKG_PATH_MAX;
-
-     if (append_and_increment(&dst, dir->path, &dst_size) < 0
-             || append_and_increment(&dst, pkgname, &dst_size) < 0
-             || append_and_increment(&dst, postfix, &dst_size) < 0) {
-         ALOGE("Error building APK path");
-         return -1;
-     }
-
-     return 0;
+/**
+ * Check that given string is valid filename, and that it attempts no
+ * parent or child directory traversal.
+ */
+static bool is_valid_filename(const std::string& name) {
+    if (name.empty() || (name == ".") || (name == "..")
+            || (name.find('/') != std::string::npos)) {
+        return false;
+    } else {
+        return true;
+    }
 }
 
 /**
- * Create the package path name for a given package name with a postfix for
- * a certain userid. Returns 0 on success, and -1 on failure.
+ * Create the path name where package app contents should be stored for
+ * the given volume UUID and package name.  An empty UUID is assumed to
+ * be internal storage.
  */
-int create_pkg_path(char path[PKG_PATH_MAX],
-                    const char *pkgname,
-                    const char *postfix,
-                    userid_t userid)
-{
-    size_t userid_len;
-    char* userid_prefix;
-    if (userid == 0) {
-        userid_prefix = PRIMARY_USER_PREFIX;
-        userid_len = 0;
-    } else {
-        userid_prefix = SECONDARY_USER_PREFIX;
-        userid_len = snprintf(NULL, 0, "%d", userid);
-    }
+std::string create_data_app_package_path(const char* volume_uuid,
+        const char* package_name) {
+    CHECK(is_valid_filename(package_name));
+    CHECK(is_valid_package_name(package_name) == 0);
 
-    const size_t prefix_len = android_data_dir.len + strlen(userid_prefix)
-            + userid_len + 1 /*slash*/;
-    char prefix[prefix_len + 1];
+    return StringPrintf("%s/%s",
+            create_data_app_path(volume_uuid).c_str(), package_name);
+}
 
-    char *dst = prefix;
-    size_t dst_size = sizeof(prefix);
+/**
+ * Create the path name where package data should be stored for the given
+ * volume UUID, package name, and user ID. An empty UUID is assumed to be
+ * internal storage.
+ */
+std::string create_data_user_package_path(const char* volume_uuid,
+        userid_t user, const char* package_name) {
+    CHECK(is_valid_filename(package_name));
+    CHECK(is_valid_package_name(package_name) == 0);
 
-    if (append_and_increment(&dst, android_data_dir.path, &dst_size) < 0
-            || append_and_increment(&dst, userid_prefix, &dst_size) < 0) {
-        ALOGE("Error building prefix for APK path");
+    return StringPrintf("%s/%s",
+            create_data_user_path(volume_uuid, user).c_str(), package_name);
+}
+
+int create_pkg_path(char path[PKG_PATH_MAX], const char *pkgname,
+        const char *postfix, userid_t userid) {
+    if (is_valid_package_name(pkgname) != 0) {
+        path[0] = '\0';
         return -1;
     }
 
-    if (userid != 0) {
-        int ret = snprintf(dst, dst_size, "%d/", userid);
-        if (ret < 0 || (size_t) ret != userid_len + 1) {
-            ALOGW("Error appending UID to APK path");
-            return -1;
-        }
+    std::string _tmp(create_data_user_package_path(nullptr, userid, pkgname) + postfix);
+    const char* tmp = _tmp.c_str();
+    if (strlen(tmp) >= PKG_PATH_MAX) {
+        path[0] = '\0';
+        return -1;
+    } else {
+        strcpy(path, tmp);
+        return 0;
     }
+}
 
-    dir_rec_t dir;
-    dir.path = prefix;
-    dir.len = prefix_len;
+std::string create_data_path(const char* volume_uuid) {
+    if (volume_uuid == nullptr) {
+        return "/data";
+    } else {
+        CHECK(is_valid_filename(volume_uuid));
+        return StringPrintf("/mnt/expand/%s", volume_uuid);
+    }
+}
 
-    return create_pkg_path_in_dir(path, &dir, pkgname, postfix);
+/**
+ * Create the path name for app data.
+ */
+std::string create_data_app_path(const char* volume_uuid) {
+    return StringPrintf("%s/app", create_data_path(volume_uuid).c_str());
 }
 
 /**
  * Create the path name for user data for a certain userid.
- * Returns 0 on success, and -1 on failure.
  */
-int create_user_path(char path[PKG_PATH_MAX],
-                    userid_t userid)
-{
-    size_t userid_len;
-    char* userid_prefix;
-    if (userid == 0) {
-        userid_prefix = PRIMARY_USER_PREFIX;
-        userid_len = 0;
+std::string create_data_user_path(const char* volume_uuid, userid_t userid) {
+    std::string data(create_data_path(volume_uuid));
+    if (volume_uuid == nullptr) {
+        if (userid == 0) {
+            return StringPrintf("%s/data", data.c_str());
+        } else {
+            return StringPrintf("%s/user/%u", data.c_str(), userid);
+        }
     } else {
-        userid_prefix = SECONDARY_USER_PREFIX;
-        userid_len = snprintf(NULL, 0, "%d/", userid);
+        return StringPrintf("%s/user/%u", data.c_str(), userid);
     }
-
-    char *dst = path;
-    size_t dst_size = PKG_PATH_MAX;
-
-    if (append_and_increment(&dst, android_data_dir.path, &dst_size) < 0
-            || append_and_increment(&dst, userid_prefix, &dst_size) < 0) {
-        ALOGE("Error building prefix for user path");
-        return -1;
-    }
-
-    if (userid != 0) {
-        if (dst_size < userid_len + 1) {
-            ALOGE("Error building user path");
-            return -1;
-        }
-        int ret = snprintf(dst, dst_size, "%d/", userid);
-        if (ret < 0 || (size_t) ret != userid_len) {
-            ALOGE("Error appending userid to path");
-            return -1;
-        }
-    }
-    return 0;
 }
 
 /**
  * Create the path name for media for a certain userid.
+ */
+std::string create_data_media_path(const char* volume_uuid, userid_t userid) {
+    return StringPrintf("%s/media/%u", create_data_path(volume_uuid).c_str(), userid);
+}
+
+std::vector<userid_t> get_known_users(const char* volume_uuid) {
+    std::vector<userid_t> users;
+
+    // We always have an owner
+    users.push_back(0);
+
+    std::string path(create_data_path(volume_uuid) + "/" + SECONDARY_USER_PREFIX);
+    DIR* dir = opendir(path.c_str());
+    if (dir == NULL) {
+        // Unable to discover other users, but at least return owner
+        PLOG(ERROR) << "Failed to opendir " << path;
+        return users;
+    }
+
+    struct dirent* ent;
+    while ((ent = readdir(dir))) {
+        if (ent->d_type != DT_DIR) {
+            continue;
+        }
+
+        char* end;
+        userid_t user = strtol(ent->d_name, &end, 10);
+        if (*end == '\0' && user != 0) {
+            LOG(DEBUG) << "Found valid user " << user;
+            users.push_back(user);
+        }
+    }
+    closedir(dir);
+
+    return users;
+}
+
+/**
+ * Create the path name for config for a certain userid.
  * Returns 0 on success, and -1 on failure.
  */
-int create_user_media_path(char path[PATH_MAX], userid_t userid) {
-    if (snprintf(path, PATH_MAX, "%s%d", android_media_dir.path, userid) > PATH_MAX) {
+int create_user_config_path(char path[PATH_MAX], userid_t userid) {
+    if (snprintf(path, PATH_MAX, "%s%d", "/data/misc/user/", userid) > PATH_MAX) {
         return -1;
     }
     return 0;
@@ -152,7 +167,7 @@
 int create_move_path(char path[PKG_PATH_MAX],
     const char* pkgname,
     const char* leaf,
-    userid_t userid)
+    userid_t userid __unused)
 {
     if ((android_data_dir.len + strlen(PRIMARY_USER_PREFIX) + strlen(pkgname) + strlen(leaf) + 1)
             >= PKG_PATH_MAX) {
@@ -171,6 +186,10 @@
     const char *x = pkgname;
     int alpha = -1;
 
+    if (strlen(pkgname) > PKG_NAME_MAX) {
+        return -1;
+    }
+
     while (*x) {
         if (isalnum(*x) || (*x == '_')) {
                 /* alphanumeric or underscore are fine */
@@ -208,7 +227,8 @@
     return 0;
 }
 
-static int _delete_dir_contents(DIR *d, const char *ignore)
+static int _delete_dir_contents(DIR *d,
+                                int (*exclusion_predicate)(const char *name, const int is_dir))
 {
     int result = 0;
     struct dirent *de;
@@ -221,11 +241,13 @@
     while ((de = readdir(d))) {
         const char *name = de->d_name;
 
-            /* skip the ignore name if provided */
-        if (ignore && !strcmp(name, ignore)) continue;
+            /* check using the exclusion predicate, if provided */
+        if (exclusion_predicate && exclusion_predicate(name, (de->d_type == DT_DIR))) {
+            continue;
+        }
 
         if (de->d_type == DT_DIR) {
-            int r, subfd;
+            int subfd;
             DIR *subdir;
 
                 /* always skip "." and ".." */
@@ -234,7 +256,7 @@
                 if ((name[1] == '.') && (name[2] == 0)) continue;
             }
 
-            subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+            subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
             if (subfd < 0) {
                 ALOGE("Couldn't openat %s: %s\n", name, strerror(errno));
                 result = -1;
@@ -247,7 +269,7 @@
                 result = -1;
                 continue;
             }
-            if (_delete_dir_contents(subdir, 0)) {
+            if (_delete_dir_contents(subdir, exclusion_predicate)) {
                 result = -1;
             }
             closedir(subdir);
@@ -268,7 +290,7 @@
 
 int delete_dir_contents(const char *pathname,
                         int also_delete_dir,
-                        const char *ignore)
+                        int (*exclusion_predicate)(const char*, const int))
 {
     int res = 0;
     DIR *d;
@@ -278,7 +300,7 @@
         ALOGE("Couldn't opendir %s: %s\n", pathname, strerror(errno));
         return -errno;
     }
-    res = _delete_dir_contents(d, ignore);
+    res = _delete_dir_contents(d, exclusion_predicate);
     closedir(d);
     if (also_delete_dir) {
         if (rmdir(pathname)) {
@@ -294,7 +316,7 @@
     int fd, res;
     DIR *d;
 
-    fd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+    fd = openat(dfd, name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
     if (fd < 0) {
         ALOGE("Couldn't openat %s: %s\n", name, strerror(errno));
         return -1;
@@ -310,6 +332,104 @@
     return res;
 }
 
+static int _copy_owner_permissions(int srcfd, int dstfd)
+{
+    struct stat st;
+    if (fstat(srcfd, &st) != 0) {
+        return -1;
+    }
+    if (fchmod(dstfd, st.st_mode) != 0) {
+        return -1;
+    }
+    return 0;
+}
+
+static int _copy_dir_files(int sdfd, int ddfd, uid_t owner, gid_t group)
+{
+    int result = 0;
+    if (_copy_owner_permissions(sdfd, ddfd) != 0) {
+        ALOGE("_copy_dir_files failed to copy dir permissions\n");
+    }
+    if (fchown(ddfd, owner, group) != 0) {
+        ALOGE("_copy_dir_files failed to change dir owner\n");
+    }
+
+    DIR *ds = fdopendir(sdfd);
+    if (ds == NULL) {
+        ALOGE("Couldn't fdopendir: %s\n", strerror(errno));
+        return -1;
+    }
+    struct dirent *de;
+    while ((de = readdir(ds))) {
+        if (de->d_type != DT_REG) {
+            continue;
+        }
+
+        const char *name = de->d_name;
+        int fsfd = openat(sdfd, name, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
+        int fdfd = openat(ddfd, name, O_WRONLY | O_NOFOLLOW | O_CLOEXEC | O_CREAT, 0600);
+        if (fsfd == -1 || fdfd == -1) {
+            ALOGW("Couldn't copy %s: %s\n", name, strerror(errno));
+        } else {
+            if (_copy_owner_permissions(fsfd, fdfd) != 0) {
+                ALOGE("Failed to change file permissions\n");
+            }
+            if (fchown(fdfd, owner, group) != 0) {
+                ALOGE("Failed to change file owner\n");
+            }
+
+            char buf[8192];
+            ssize_t size;
+            while ((size = read(fsfd, buf, sizeof(buf))) > 0) {
+                write(fdfd, buf, size);
+            }
+            if (size < 0) {
+                ALOGW("Couldn't copy %s: %s\n", name, strerror(errno));
+                result = -1;
+            }
+        }
+        close(fdfd);
+        close(fsfd);
+    }
+
+    return result;
+}
+
+int copy_dir_files(const char *srcname,
+                   const char *dstname,
+                   uid_t owner,
+                   uid_t group)
+{
+    int res = 0;
+    DIR *ds = NULL;
+    DIR *dd = NULL;
+
+    ds = opendir(srcname);
+    if (ds == NULL) {
+        ALOGE("Couldn't opendir %s: %s\n", srcname, strerror(errno));
+        return -errno;
+    }
+
+    mkdir(dstname, 0600);
+    dd = opendir(dstname);
+    if (dd == NULL) {
+        ALOGE("Couldn't opendir %s: %s\n", dstname, strerror(errno));
+        closedir(ds);
+        return -errno;
+    }
+
+    int sdfd = dirfd(ds);
+    int ddfd = dirfd(dd);
+    if (sdfd != -1 && ddfd != -1) {
+        res = _copy_dir_files(sdfd, ddfd, owner, group);
+    } else {
+        res = -errno;
+    }
+    closedir(dd);
+    closedir(ds);
+    return res;
+}
+
 int lookup_media_dir(char basepath[PATH_MAX], const char *dir)
 {
     DIR *d;
@@ -360,13 +480,13 @@
     return -1;
 }
 
-int64_t data_disk_free()
+int64_t data_disk_free(const std::string& data_path)
 {
     struct statfs sfs;
-    if (statfs(android_data_dir.path, &sfs) == 0) {
+    if (statfs(data_path.c_str(), &sfs) == 0) {
         return sfs.f_bavail * sfs.f_bsize;
     } else {
-        ALOGE("Couldn't statfs %s: %s\n", android_data_dir.path, strerror(errno));
+        PLOG(ERROR) << "Couldn't statfs " << data_path;
         return -1;
     }
 }
@@ -404,7 +524,7 @@
     int8_t* res = cache->curMemBlockAvail;
     int8_t* nextPos = res + len;
     if (cache->memBlocks == NULL || nextPos > cache->curMemBlockEnd) {
-        int8_t* newBlock = malloc(CACHE_BLOCK_SIZE);
+        int8_t* newBlock = (int8_t*) malloc(CACHE_BLOCK_SIZE);
         if (newBlock == NULL) {
             return NULL;
         }
@@ -536,7 +656,7 @@
                 if ((name[1] == '.') && (name[2] == 0)) continue;
             }
 
-            subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+            subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
             if (subfd < 0) {
                 ALOGE("Couldn't openat %s: %s\n", name, strerror(errno));
                 continue;
@@ -724,7 +844,7 @@
     return lhs->modTime < rhs->modTime ? -1 : (lhs->modTime > rhs->modTime ? 1 : 0);
 }
 
-void clear_cache_files(cache_t* cache, int64_t free_size)
+void clear_cache_files(const std::string& data_path, cache_t* cache, int64_t free_size)
 {
     size_t i;
     int skip = 0;
@@ -749,7 +869,7 @@
     for (i=0; i<cache->numFiles; i++) {
         skip++;
         if (skip > 10) {
-            if (data_disk_free() > free_size) {
+            if (data_disk_free(data_path) > free_size) {
                 return;
             }
             skip = 0;
@@ -769,7 +889,7 @@
 
 void finish_cache_collection(cache_t* cache)
 {
-    size_t i;
+    CACHE_NOISY(size_t i;)
 
     CACHE_NOISY(ALOGI("clear_cache_files: %d dirs, %d files\n", cache->numDirs, cache->numFiles));
     CACHE_NOISY(
@@ -794,6 +914,33 @@
 }
 
 /**
+ * Validate that the path is valid in the context of the provided directory.
+ * The path is allowed to have at most one subdirectory and no indirections
+ * to top level directories (i.e. have "..").
+ */
+static int validate_path(const dir_rec_t* dir, const char* path, int maxSubdirs) {
+    size_t dir_len = dir->len;
+    const char* subdir = strchr(path + dir_len, '/');
+
+    // Only allow the path to have at most one subdirectory.
+    if (subdir != NULL) {
+        ++subdir;
+        if ((--maxSubdirs == 0) && strchr(subdir, '/') != NULL) {
+            ALOGE("invalid apk path '%s' (subdir?)\n", path);
+            return -1;
+        }
+    }
+
+    // Directories can't have a period directly after the directory markers to prevent "..".
+    if ((path[dir_len] == '.') || ((subdir != NULL) && (*subdir == '.'))) {
+        ALOGE("invalid apk path '%s' (trickery)\n", path);
+        return -1;
+    }
+
+    return 0;
+}
+
+/**
  * Checks whether a path points to a system app (.apk file). Returns 0
  * if it is a system app or -1 if it is not.
  */
@@ -803,11 +950,7 @@
     for (i = 0; i < android_system_dirs.count; i++) {
         const size_t dir_len = android_system_dirs.dirs[i].len;
         if (!strncmp(path, android_system_dirs.dirs[i].path, dir_len)) {
-            if (path[dir_len] == '.' || strchr(path + dir_len, '/') != NULL) {
-                ALOGE("invalid system apk path '%s' (trickery)\n", path);
-                return -1;
-            }
-            return 0;
+            return validate_path(android_system_dirs.dirs + i, path, 1);
         }
     }
 
@@ -865,7 +1008,7 @@
             // Add space for slash and terminating null.
             size_t dst_size = path_len + 2;
 
-            rec->path = malloc(dst_size);
+            rec->path = (char*) malloc(dst_size);
             if (rec->path == NULL) {
                 return -1;
             }
@@ -900,54 +1043,37 @@
 }
 
 /**
- * Check whether path points to a valid path for an APK file. An ASEC
- * directory is allowed to have one level of subdirectory names. Returns -1
- * when an invalid path is encountered and 0 when a valid path is encountered.
+ * Check whether path points to a valid path for an APK file. The path must
+ * begin with a whitelisted prefix path and must be no deeper than |maxSubdirs| within
+ * that path. Returns -1 when an invalid path is encountered and 0 when a valid path
+ * is encountered.
  */
-int validate_apk_path(const char *path)
-{
-    int allowsubdir = 0;
-    char *subdir = NULL;
-    size_t dir_len;
-    size_t path_len;
-
+static int validate_apk_path_internal(const char *path, int maxSubdirs) {
+    const dir_rec_t* dir = NULL;
     if (!strncmp(path, android_app_dir.path, android_app_dir.len)) {
-        dir_len = android_app_dir.len;
+        dir = &android_app_dir;
     } else if (!strncmp(path, android_app_private_dir.path, android_app_private_dir.len)) {
-        dir_len = android_app_private_dir.len;
+        dir = &android_app_private_dir;
     } else if (!strncmp(path, android_asec_dir.path, android_asec_dir.len)) {
-        dir_len = android_asec_dir.len;
-        allowsubdir = 1;
-    } else {
-        ALOGE("invalid apk path '%s' (bad prefix)\n", path);
-        return -1;
-    }
-
-    path_len = strlen(path);
-
-    /*
-     * Only allow the path to have a subdirectory if it's been marked as being allowed.
-     */
-    if ((subdir = strchr(path + dir_len, '/')) != NULL) {
-        ++subdir;
-        if (!allowsubdir
-                || (path_len > (size_t) (subdir - path) && (strchr(subdir, '/') != NULL))) {
-            ALOGE("invalid apk path '%s' (subdir?)\n", path);
-            return -1;
+        dir = &android_asec_dir;
+    } else if (!strncmp(path, android_mnt_expand_dir.path, android_mnt_expand_dir.len)) {
+        dir = &android_mnt_expand_dir;
+        if (maxSubdirs < 2) {
+            maxSubdirs = 2;
         }
-    }
-
-    /*
-     *  Directories can't have a period directly after the directory markers
-     *  to prevent ".."
-     */
-    if (path[dir_len] == '.'
-            || (subdir != NULL && ((*subdir == '.') || (strchr(subdir, '/') != NULL)))) {
-        ALOGE("invalid apk path '%s' (trickery)\n", path);
+    } else {
         return -1;
     }
 
-    return 0;
+    return validate_path(dir, path, maxSubdirs);
+}
+
+int validate_apk_path(const char* path) {
+    return validate_apk_path_internal(path, 1 /* maxSubdirs */);
+}
+
+int validate_apk_path_subdirs(const char* path) {
+    return validate_apk_path_internal(path, 3 /* maxSubdirs */);
 }
 
 int append_and_increment(char** dst, const char* src, size_t* dst_size) {
@@ -960,13 +1086,13 @@
     return 0;
 }
 
-char *build_string2(char *s1, char *s2) {
+char *build_string2(const char *s1, const char *s2) {
     if (s1 == NULL || s2 == NULL) return NULL;
 
     int len_s1 = strlen(s1);
     int len_s2 = strlen(s2);
     int len = len_s1 + len_s2 + 1;
-    char *result = malloc(len);
+    char *result = (char *) malloc(len);
     if (result == NULL) return NULL;
 
     strcpy(result, s1);
@@ -975,14 +1101,14 @@
     return result;
 }
 
-char *build_string3(char *s1, char *s2, char *s3) {
+char *build_string3(const char *s1, const char *s2, const char *s3) {
     if (s1 == NULL || s2 == NULL || s3 == NULL) return NULL;
 
     int len_s1 = strlen(s1);
     int len_s2 = strlen(s2);
     int len_s3 = strlen(s3);
     int len = len_s1 + len_s2 + len_s3 + 1;
-    char *result = malloc(len);
+    char *result = (char *) malloc(len);
     if (result == NULL) return NULL;
 
     strcpy(result, s1);
@@ -993,77 +1119,27 @@
 }
 
 /* Ensure that /data/media directories are prepared for given user. */
-int ensure_media_user_dirs(userid_t userid) {
-    char media_user_path[PATH_MAX];
-    char path[PATH_MAX];
-
-    // Ensure /data/media/<userid> exists
-    create_user_media_path(media_user_path, userid);
-    if (fs_prepare_dir(media_user_path, 0770, AID_MEDIA_RW, AID_MEDIA_RW) == -1) {
+int ensure_media_user_dirs(const char* uuid, userid_t userid) {
+    std::string media_user_path(create_data_media_path(uuid, userid));
+    if (fs_prepare_dir(media_user_path.c_str(), 0770, AID_MEDIA_RW, AID_MEDIA_RW) == -1) {
         return -1;
     }
 
     return 0;
 }
 
-int create_profile_file(const char *pkgname, gid_t gid) {
-    const char *profile_dir = DALVIK_CACHE_PREFIX "profiles";
-    struct stat profileStat;
-    char profile_file[PKG_PATH_MAX];
+int ensure_config_user_dirs(userid_t userid) {
+    char config_user_path[PATH_MAX];
 
-    // If we don't have a profile directory under dalvik-cache we need to create one.
-    if (stat(profile_dir, &profileStat) < 0) {
-        // Create the profile directory under dalvik-cache.
-        if (mkdir(profile_dir, 0711) < 0) {
-            ALOGE("cannot make profile dir '%s': %s\n", profile_dir, strerror(errno));
-            return -1;
-        }
+    // writable by system, readable by any app within the same user
+    const int uid = multiuser_get_uid(userid, AID_SYSTEM);
+    const int gid = multiuser_get_uid(userid, AID_EVERYBODY);
 
-        // Make the profile directory write-only for group and other. Owner can rwx it.
-        if (chmod(profile_dir, 0711) < 0) {
-            ALOGE("cannot chown profile dir '%s': %s\n", profile_dir, strerror(errno));
-            rmdir(profile_dir);
-            return -1;
-        }
-
-        if (selinux_android_restorecon(profile_dir, 0) < 0) {
-            ALOGE("cannot restorecon profile dir '%s': %s\n", profile_dir, strerror(errno));
-            rmdir(profile_dir);
-            return -1;
-        }
+    // Ensure /data/misc/user/<userid> exists
+    create_user_config_path(config_user_path, userid);
+    if (fs_prepare_dir(config_user_path, 0750, uid, gid) == -1) {
+        return -1;
     }
 
-    snprintf(profile_file, sizeof(profile_file), "%s/%s", profile_dir, pkgname);
-
-    // The 'system' user needs to be able to read the profile to determine if dex2oat
-    // needs to be run.  This is done in dalvik.system.DexFile.isDexOptNeededInternal().  So
-    // we make it world readable.  Not a problem since the dalvik cache is world
-    // readable anyway.
-
-    int fd = open(profile_file, O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW, 0664);
-
-    // Open will fail if the file already exists.  We want to ignore that.
-    if (fd >= 0) {
-        if (fchown(fd, -1, gid) < 0) {
-            ALOGE("cannot chown profile file '%s': %s\n", profile_file, strerror(errno));
-            close(fd);
-            unlink(profile_file);
-            return -1;
-        }
-
-        if (fchmod(fd, 0664) < 0) {
-            ALOGE("cannot chmod profile file '%s': %s\n", profile_file, strerror(errno));
-            close(fd);
-            unlink(profile_file);
-            return -1;
-        }
-        close(fd);
-    }
-    return 0;
-}
-
-void remove_profile_file(const char *pkgname) {
-    char profile_file[PKG_PATH_MAX];
-    snprintf(profile_file, sizeof(profile_file), "%s/%s", DALVIK_CACHE_PREFIX "profiles", pkgname);
-    unlink(profile_file);
+   return 0;
 }
diff --git a/cmds/ip-up-vpn/ip-up-vpn.c b/cmds/ip-up-vpn/ip-up-vpn.c
index 9fcc950..75b907c 100644
--- a/cmds/ip-up-vpn/ip-up-vpn.c
+++ b/cmds/ip-up-vpn/ip-up-vpn.c
@@ -46,16 +46,17 @@
 
 /*
  * The primary goal is to create a file with VPN parameters. Currently they
- * are interface, addresses, routes, DNS servers, and search domains. Each
- * parameter occupies one line in the file, and it can be an empty string or
- * space-separated values. The order and the format must be consistent with
- * com.android.server.connectivity.Vpn. Here is an example.
+ * are interface, addresses, routes, DNS servers, and search domains and VPN
+ * server address. Each parameter occupies one line in the file, and it can be
+ * an empty string or space-separated values. The order and the format must be
+ * consistent with com.android.server.connectivity.Vpn. Here is an example.
  *
  *   ppp0
  *   192.168.1.100/24
  *   0.0.0.0/0
  *   192.168.1.1 192.168.1.2
  *   example.org
+ *   192.0.2.1
  *
  * The secondary goal is to unify the outcome of VPN. The current baseline
  * is to have an interface configured with the given address and netmask
@@ -78,6 +79,7 @@
         fprintf(state, "0.0.0.0/0\n");
         fprintf(state, "%s %s\n", env("DNS1"), env("DNS2"));
         fprintf(state, "\n");
+        fprintf(state, "\n");
     } else if (argc == 2) {
         /* Invoked by racoon. */
         const char *interface = env("INTERFACE");
@@ -85,30 +87,9 @@
         const char *routes = env("SPLIT_INCLUDE_CIDR");
 
         int s = socket(AF_INET, SOCK_DGRAM, 0);
-        struct rtentry rt;
         struct ifreq ifr;
-
-        memset(&rt, 0, sizeof(rt));
         memset(&ifr, 0, sizeof(ifr));
 
-        /* Remove the old host route. There could be more than one. */
-        rt.rt_flags |= RTF_UP | RTF_HOST;
-        if (set_address(&rt.rt_dst, env("REMOTE_ADDR"))) {
-            while (!ioctl(s, SIOCDELRT, &rt));
-        }
-        if (errno != ESRCH) {
-            ALOGE("Cannot remove host route: %s", strerror(errno));
-            return 1;
-        }
-
-        /* Create a new host route. */
-        rt.rt_flags |= RTF_GATEWAY;
-        if (!set_address(&rt.rt_gateway, argv[1]) ||
-                (ioctl(s, SIOCADDRT, &rt) && errno != EEXIST)) {
-            ALOGE("Cannot create host route: %s", strerror(errno));
-            return 1;
-        }
-
         /* Bring up the interface. */
         ifr.ifr_flags = IFF_UP;
         strncpy(ifr.ifr_name, interface, IFNAMSIZ);
@@ -139,6 +120,7 @@
         fprintf(state, "%s\n", routes[0] ? routes : "0.0.0.0/0");
         fprintf(state, "%s\n", env("INTERNAL_DNS4_LIST"));
         fprintf(state, "%s\n", env("DEFAULT_DOMAIN"));
+        fprintf(state, "%s\n", env("REMOTE_ADDR"));
     } else {
         ALOGE("Cannot parse parameters");
         return 1;
diff --git a/cmds/screenshot/Android.mk b/cmds/screenshot/Android.mk
deleted file mode 100644
index 1ee7807..0000000
--- a/cmds/screenshot/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := screenshot.c
-
-LOCAL_MODULE := screenshot
-
-LOCAL_SHARED_LIBRARIES := libcutils libz liblog
-LOCAL_STATIC_LIBRARIES := libpng
-LOCAL_C_INCLUDES += external/zlib external/libpng
-
-include $(BUILD_EXECUTABLE)
diff --git a/cmds/screenshot/screenshot.c b/cmds/screenshot/screenshot.c
deleted file mode 100644
index be1ecd4..0000000
--- a/cmds/screenshot/screenshot.c
+++ /dev/null
@@ -1,171 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#include <linux/fb.h>
-
-#include <zlib.h>
-#include <png.h>
-
-#include "private/android_filesystem_config.h"
-
-#define LOG_TAG "screenshot"
-#include <utils/Log.h>
-
-void take_screenshot(FILE *fb_in, FILE *fb_out) {
-    int fb;
-    char imgbuf[0x10000];
-    struct fb_var_screeninfo vinfo;
-    png_structp png;
-    png_infop info;
-    unsigned int r,c,rowlen;
-    unsigned int bytespp,offset;
-
-    fb = fileno(fb_in);
-    if(fb < 0) {
-        ALOGE("failed to open framebuffer\n");
-        return;
-    }
-    fb_in = fdopen(fb, "r");
-
-    if(ioctl(fb, FBIOGET_VSCREENINFO, &vinfo) < 0) {
-        ALOGE("failed to get framebuffer info\n");
-        return;
-    }
-    fcntl(fb, F_SETFD, FD_CLOEXEC);
-
-    png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-    if (png == NULL) {
-        ALOGE("failed png_create_write_struct\n");
-        fclose(fb_in);
-        return;
-    }
-
-    png_init_io(png, fb_out);
-    info = png_create_info_struct(png);
-    if (info == NULL) {
-        ALOGE("failed png_create_info_struct\n");
-        png_destroy_write_struct(&png, NULL);
-        fclose(fb_in);
-        return;
-    }
-    if (setjmp(png_jmpbuf(png))) {
-        ALOGE("failed png setjmp\n");
-        png_destroy_write_struct(&png, NULL);
-        fclose(fb_in);
-        return;
-    }
-
-    bytespp = vinfo.bits_per_pixel / 8;
-    png_set_IHDR(png, info,
-        vinfo.xres, vinfo.yres, vinfo.bits_per_pixel / 4, 
-        PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
-        PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-    png_write_info(png, info);
-
-    rowlen=vinfo.xres * bytespp;
-    if (rowlen > sizeof(imgbuf)) {
-        ALOGE("crazy rowlen: %d\n", rowlen);
-        png_destroy_write_struct(&png, NULL);
-        fclose(fb_in);
-        return;
-    }
-
-    offset = vinfo.xoffset * bytespp + vinfo.xres * vinfo.yoffset * bytespp;
-    fseek(fb_in, offset, SEEK_SET);
-
-    for(r=0; r<vinfo.yres; r++) {
-        int len = fread(imgbuf, 1, rowlen, fb_in);
-        if (len <= 0) break;
-        png_write_row(png, (png_bytep)imgbuf);
-    }
-
-    png_write_end(png, info);
-    fclose(fb_in);
-    png_destroy_write_struct(&png, NULL);
-}
-
-void fork_sound(const char* path) {
-    pid_t pid = fork();
-    if (pid == 0) {
-        execl("/system/bin/stagefright", "stagefright", "-o", "-a", path, NULL);
-    }
-}
-
-void usage() {
-    fprintf(stderr,
-            "usage: screenshot [-s soundfile] filename.png\n"
-            "   -s: play a sound effect to signal success\n"
-            "   -i: autoincrement to avoid overwriting filename.png\n"
-    );
-}
-
-int main(int argc, char**argv) {
-    FILE *png = NULL;
-    FILE *fb_in = NULL;
-    char outfile[PATH_MAX] = "";
-
-    char * soundfile = NULL;
-    int do_increment = 0;
-
-    int c;
-    while ((c = getopt(argc, argv, "s:i")) != -1) {
-        switch (c) {
-            case 's': soundfile = optarg; break;
-            case 'i': do_increment = 1; break;
-            case '?':
-            case 'h':
-                usage(); exit(1);
-        }
-    }
-    argc -= optind;
-    argv += optind;
-
-    if (argc < 1) {
-        usage(); exit(1);
-    }
-
-    strlcpy(outfile, argv[0], PATH_MAX);
-    if (do_increment) {
-        struct stat st;
-        char base[PATH_MAX] = "";
-        int i = 0;
-        while (stat(outfile, &st) == 0) {
-            if (!base[0]) {
-                char *p = strrchr(outfile, '.');
-                if (p) *p = '\0';
-                strcpy(base, outfile);
-            }
-            snprintf(outfile, PATH_MAX, "%s-%d.png", base, ++i);
-        }
-    }
-
-    fb_in = fopen("/dev/graphics/fb0", "r");
-    if (!fb_in) {
-        fprintf(stderr, "error: could not read framebuffer\n");
-        exit(1);
-    }
-
-    /* switch to non-root user and group */
-    gid_t groups[] = { AID_LOG, AID_SDCARD_RW };
-    setgroups(sizeof(groups)/sizeof(groups[0]), groups);
-    setuid(AID_SHELL);
-
-    png = fopen(outfile, "w");
-    if (!png) {
-        fprintf(stderr, "error: writing file %s: %s\n",
-                outfile, strerror(errno));
-        exit(1);
-    }
-
-    take_screenshot(fb_in, png);
-
-    if (soundfile) {
-        fork_sound(soundfile);
-    }
-
-    exit(0);
-}
diff --git a/cmds/service/service.cpp b/cmds/service/service.cpp
index 97fc47c..428b87c 100644
--- a/cmds/service/service.cpp
+++ b/cmds/service/service.cpp
@@ -146,6 +146,15 @@
                                 break;
                             }
                             data.writeInt32(atoi(argv[optind++]));
+                        } else if (strcmp(argv[optind], "i64") == 0) {
+                            optind++;
+                            if (optind >= argc) {
+                                aerr << "service: no integer supplied for 'i64'" << endl;
+                                wantsUsage = true;
+                                result = 10;
+                                break;
+                            }
+                            data.writeInt64(atoll(argv[optind++]));
                         } else if (strcmp(argv[optind], "s16") == 0) {
                             optind++;
                             if (optind >= argc) {
@@ -155,6 +164,24 @@
                                 break;
                             }
                             data.writeString16(String16(argv[optind++]));
+                        } else if (strcmp(argv[optind], "f") == 0) {
+                            optind++;
+                            if (optind >= argc) {
+                                aerr << "service: no number supplied for 'f'" << endl;
+                                wantsUsage = true;
+                                result = 10;
+                                break;
+                            }
+                            data.writeFloat(atof(argv[optind++]));
+                        } else if (strcmp(argv[optind], "d") == 0) {
+                            optind++;
+                            if (optind >= argc) {
+                                aerr << "service: no number supplied for 'd'" << endl;
+                                wantsUsage = true;
+                                result = 10;
+                                break;
+                            }
+                            data.writeDouble(atof(argv[optind++]));
                         } else if (strcmp(argv[optind], "null") == 0) {
                             optind++;
                             data.writeStrongBinder(NULL);
@@ -272,9 +299,12 @@
         aout << "Usage: service [-h|-?]\n"
                 "       service list\n"
                 "       service check SERVICE\n"
-                "       service call SERVICE CODE [i32 INT | s16 STR] ...\n"
+                "       service call SERVICE CODE [i32 N | i64 N | f N | d N | s16 STR ] ...\n"
                 "Options:\n"
-                "   i32: Write the integer INT into the send parcel.\n"
+                "   i32: Write the 32-bit integer N into the send parcel.\n"
+                "   i64: Write the 64-bit integer N into the send parcel.\n"
+                "   f:   Write the 32-bit single-precision number N into the send parcel.\n"
+                "   d:   Write the 64-bit double-precision number N into the send parcel.\n"
                 "   s16: Write the UTF-16 string STR into the send parcel.\n";
 //                "   intent: Write and Intent int the send parcel. ARGS can be\n"
 //                "       action=STR data=STR type=STR launchFlags=INT component=STR categories=STR[,STR,...]\n";
diff --git a/cmds/servicemanager/Android.mk b/cmds/servicemanager/Android.mk
index 4ab8df6..7ee0dd1 100644
--- a/cmds/servicemanager/Android.mk
+++ b/cmds/servicemanager/Android.mk
@@ -18,8 +18,9 @@
 include $(BUILD_EXECUTABLE)
 
 include $(CLEAR_VARS)
-LOCAL_SHARED_LIBRARIES := liblog
+LOCAL_SHARED_LIBRARIES := liblog libselinux
 LOCAL_SRC_FILES := service_manager.c binder.c
 LOCAL_CFLAGS += $(svc_c_flags)
 LOCAL_MODULE := servicemanager
+LOCAL_INIT_RC := servicemanager.rc
 include $(BUILD_EXECUTABLE)
diff --git a/cmds/servicemanager/bctest.c b/cmds/servicemanager/bctest.c
index e02b45d..fd91633 100644
--- a/cmds/servicemanager/bctest.c
+++ b/cmds/servicemanager/bctest.c
@@ -3,6 +3,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <errno.h>
 
 #include "binder.h"
diff --git a/cmds/servicemanager/binder.c b/cmds/servicemanager/binder.c
index db7632d..3d14451 100644
--- a/cmds/servicemanager/binder.c
+++ b/cmds/servicemanager/binder.c
@@ -4,6 +4,7 @@
 #include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <errno.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -103,7 +104,7 @@
         return NULL;
     }
 
-    bs->fd = open("/dev/binder", O_RDWR);
+    bs->fd = open("/dev/binder", O_RDWR | O_CLOEXEC);
     if (bs->fd < 0) {
         fprintf(stderr,"binder: cannot open device (%s)\n",
                 strerror(errno));
@@ -112,7 +113,9 @@
 
     if ((ioctl(bs->fd, BINDER_VERSION, &vers) == -1) ||
         (vers.protocol_version != BINDER_CURRENT_PROTOCOL_VERSION)) {
-        fprintf(stderr, "binder: driver version differs from user space\n");
+        fprintf(stderr,
+                "binder: kernel driver version (%d) differs from user space version (%d)\n",
+                vers.protocol_version, BINDER_CURRENT_PROTOCOL_VERSION);
         goto fail_open;
     }
 
diff --git a/cmds/servicemanager/binder.h b/cmds/servicemanager/binder.h
index 7915fc2..881ab07 100644
--- a/cmds/servicemanager/binder.h
+++ b/cmds/servicemanager/binder.h
@@ -5,7 +5,7 @@
 #define _BINDER_H_
 
 #include <sys/ioctl.h>
-#include <linux/binder.h>
+#include <linux/android/binder.h>
 
 struct binder_state;
 
diff --git a/cmds/servicemanager/service_manager.c b/cmds/servicemanager/service_manager.c
index 79ce6ed..8596f96 100644
--- a/cmds/servicemanager/service_manager.c
+++ b/cmds/servicemanager/service_manager.c
@@ -1,13 +1,18 @@
 /* Copyright 2008 The Android Open Source Project
  */
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 #include <private/android_filesystem_config.h>
 
+#include <selinux/android.h>
+#include <selinux/avc.h>
+
 #include "binder.h"
 
 #if 0
@@ -18,49 +23,26 @@
 #include <cutils/log.h>
 #endif
 
-/* TODO:
- * These should come from a config file or perhaps be
- * based on some namespace rules of some sort (media
- * uid can register media.*, etc)
- */
-static struct {
+struct audit_data {
+    pid_t pid;
     uid_t uid;
     const char *name;
-} allowed[] = {
-    { AID_MEDIA, "media.audio_flinger" },
-    { AID_MEDIA, "media.log" },
-    { AID_MEDIA, "media.player" },
-    { AID_MEDIA, "media.camera" },
-    { AID_MEDIA, "media.audio_policy" },
-    { AID_DRM,   "drm.drmManager" },
-    { AID_NFC,   "nfc" },
-    { AID_BLUETOOTH, "bluetooth" },
-    { AID_RADIO, "radio.phone" },
-    { AID_RADIO, "radio.sms" },
-    { AID_RADIO, "radio.phonesubinfo" },
-    { AID_RADIO, "radio.simphonebook" },
-/* TODO: remove after phone services are updated: */
-    { AID_RADIO, "phone" },
-    { AID_RADIO, "sip" },
-    { AID_RADIO, "isms" },
-    { AID_RADIO, "iphonesubinfo" },
-    { AID_RADIO, "simphonebook" },
-    { AID_MEDIA, "common_time.clock" },
-    { AID_MEDIA, "common_time.config" },
-    { AID_KEYSTORE, "android.security.keystore" },
 };
 
-uint32_t svcmgr_handle;
-
-const char *str8(const uint16_t *x)
+const char *str8(const uint16_t *x, size_t x_len)
 {
     static char buf[128];
-    unsigned max = 127;
+    size_t max = 127;
     char *p = buf;
 
+    if (x_len < max) {
+        max = x_len;
+    }
+
     if (x) {
-        while (*x && max--) {
+        while ((max > 0) && (*x != '\0')) {
             *p++ = *x++;
+            max--;
         }
     }
     *p++ = 0;
@@ -76,18 +58,82 @@
     return 1;
 }
 
-int svc_can_register(uid_t uid, const uint16_t *name)
+static int selinux_enabled;
+static char *service_manager_context;
+static struct selabel_handle* sehandle;
+
+static bool check_mac_perms(pid_t spid, uid_t uid, const char *tctx, const char *perm, const char *name)
 {
-    size_t n;
+    char *sctx = NULL;
+    const char *class = "service_manager";
+    bool allowed;
+    struct audit_data ad;
 
-    if ((uid == 0) || (uid == AID_SYSTEM))
-        return 1;
+    if (getpidcon(spid, &sctx) < 0) {
+        ALOGE("SELinux: getpidcon(pid=%d) failed to retrieve pid context.\n", spid);
+        return false;
+    }
 
-    for (n = 0; n < sizeof(allowed) / sizeof(allowed[0]); n++)
-        if ((uid == allowed[n].uid) && str16eq(name, allowed[n].name))
-            return 1;
+    ad.pid = spid;
+    ad.uid = uid;
+    ad.name = name;
 
-    return 0;
+    int result = selinux_check_access(sctx, tctx, class, perm, (void *) &ad);
+    allowed = (result == 0);
+
+    freecon(sctx);
+    return allowed;
+}
+
+static bool check_mac_perms_from_getcon(pid_t spid, uid_t uid, const char *perm)
+{
+    if (selinux_enabled <= 0) {
+        return true;
+    }
+
+    return check_mac_perms(spid, uid, service_manager_context, perm, NULL);
+}
+
+static bool check_mac_perms_from_lookup(pid_t spid, uid_t uid, const char *perm, const char *name)
+{
+    bool allowed;
+    char *tctx = NULL;
+
+    if (selinux_enabled <= 0) {
+        return true;
+    }
+
+    if (!sehandle) {
+        ALOGE("SELinux: Failed to find sehandle. Aborting service_manager.\n");
+        abort();
+    }
+
+    if (selabel_lookup(sehandle, &tctx, name, 0) != 0) {
+        ALOGE("SELinux: No match for %s in service_contexts.\n", name);
+        return false;
+    }
+
+    allowed = check_mac_perms(spid, uid, tctx, perm, name);
+    freecon(tctx);
+    return allowed;
+}
+
+static int svc_can_register(const uint16_t *name, size_t name_len, pid_t spid, uid_t uid)
+{
+    const char *perm = "add";
+    return check_mac_perms_from_lookup(spid, uid, perm, str8(name, name_len)) ? 1 : 0;
+}
+
+static int svc_can_list(pid_t spid, uid_t uid)
+{
+    const char *perm = "list";
+    return check_mac_perms_from_getcon(spid, uid, perm) ? 1 : 0;
+}
+
+static int svc_can_find(const uint16_t *name, size_t name_len, pid_t spid, uid_t uid)
+{
+    const char *perm = "find";
+    return check_mac_perms_from_lookup(spid, uid, perm, str8(name, name_len)) ? 1 : 0;
 }
 
 struct svcinfo
@@ -119,7 +165,7 @@
 {
     struct svcinfo *si = (struct svcinfo* ) ptr;
 
-    ALOGI("service '%s' died\n", str8(si->name));
+    ALOGI("service '%s' died\n", str8(si->name, si->len));
     if (si->handle) {
         binder_release(bs, si->handle);
         si->handle = 0;
@@ -132,42 +178,46 @@
 };
 
 
-uint32_t do_find_service(struct binder_state *bs, const uint16_t *s, size_t len, uid_t uid)
+uint32_t do_find_service(struct binder_state *bs, const uint16_t *s, size_t len, uid_t uid, pid_t spid)
 {
-    struct svcinfo *si;
+    struct svcinfo *si = find_svc(s, len);
 
-    si = find_svc(s, len);
-    //ALOGI("check_service('%s') handle = %x\n", str8(s), si ? si->handle : 0);
-    if (si && si->handle) {
-        if (!si->allow_isolated) {
-            // If this service doesn't allow access from isolated processes,
-            // then check the uid to see if it is isolated.
-            uid_t appid = uid % AID_USER;
-            if (appid >= AID_ISOLATED_START && appid <= AID_ISOLATED_END) {
-                return 0;
-            }
-        }
-        return si->handle;
-    } else {
+    if (!si || !si->handle) {
         return 0;
     }
+
+    if (!si->allow_isolated) {
+        // If this service doesn't allow access from isolated processes,
+        // then check the uid to see if it is isolated.
+        uid_t appid = uid % AID_USER;
+        if (appid >= AID_ISOLATED_START && appid <= AID_ISOLATED_END) {
+            return 0;
+        }
+    }
+
+    if (!svc_can_find(s, len, spid, uid)) {
+        return 0;
+    }
+
+    return si->handle;
 }
 
 int do_add_service(struct binder_state *bs,
                    const uint16_t *s, size_t len,
-                   uint32_t handle, uid_t uid, int allow_isolated)
+                   uint32_t handle, uid_t uid, int allow_isolated,
+                   pid_t spid)
 {
     struct svcinfo *si;
 
-    //ALOGI("add_service('%s',%x,%s) uid=%d\n", str8(s), handle,
+    //ALOGI("add_service('%s',%x,%s) uid=%d\n", str8(s, len), handle,
     //        allow_isolated ? "allow_isolated" : "!allow_isolated", uid);
 
     if (!handle || (len == 0) || (len > 127))
         return -1;
 
-    if (!svc_can_register(uid, s)) {
+    if (!svc_can_register(s, len, spid, uid)) {
         ALOGE("add_service('%s',%x) uid=%d - PERMISSION DENIED\n",
-             str8(s), handle, uid);
+             str8(s, len), handle, uid);
         return -1;
     }
 
@@ -175,7 +225,7 @@
     if (si) {
         if (si->handle) {
             ALOGE("add_service('%s',%x) uid=%d - ALREADY REGISTERED, OVERRIDE\n",
-                 str8(s), handle, uid);
+                 str8(s, len), handle, uid);
             svcinfo_death(bs, si);
         }
         si->handle = handle;
@@ -183,7 +233,7 @@
         si = malloc(sizeof(*si) + (len + 1) * sizeof(uint16_t));
         if (!si) {
             ALOGE("add_service('%s',%x) uid=%d - OUT OF MEMORY\n",
-                 str8(s), handle, uid);
+                 str8(s, len), handle, uid);
             return -1;
         }
         si->handle = handle;
@@ -214,10 +264,10 @@
     uint32_t strict_policy;
     int allow_isolated;
 
-    //ALOGI("target=%x code=%d pid=%d uid=%d\n",
-    //  txn->target.handle, txn->code, txn->sender_pid, txn->sender_euid);
+    //ALOGI("target=%p code=%d pid=%d uid=%d\n",
+    //      (void*) txn->target.ptr, txn->code, txn->sender_pid, txn->sender_euid);
 
-    if (txn->target.handle != svcmgr_handle)
+    if (txn->target.ptr != BINDER_SERVICE_MANAGER)
         return -1;
 
     if (txn->code == PING_TRANSACTION)
@@ -229,17 +279,32 @@
     // further (since we do no outbound RPCs anyway).
     strict_policy = bio_get_uint32(msg);
     s = bio_get_string16(msg, &len);
+    if (s == NULL) {
+        return -1;
+    }
+
     if ((len != (sizeof(svcmgr_id) / 2)) ||
         memcmp(svcmgr_id, s, sizeof(svcmgr_id))) {
-        fprintf(stderr,"invalid id %s\n", str8(s));
+        fprintf(stderr,"invalid id %s\n", str8(s, len));
         return -1;
     }
 
+    if (sehandle && selinux_status_updated() > 0) {
+        struct selabel_handle *tmp_sehandle = selinux_android_service_context_handle();
+        if (tmp_sehandle) {
+            selabel_close(sehandle);
+            sehandle = tmp_sehandle;
+        }
+    }
+
     switch(txn->code) {
     case SVC_MGR_GET_SERVICE:
     case SVC_MGR_CHECK_SERVICE:
         s = bio_get_string16(msg, &len);
-        handle = do_find_service(bs, s, len, txn->sender_euid);
+        if (s == NULL) {
+            return -1;
+        }
+        handle = do_find_service(bs, s, len, txn->sender_euid, txn->sender_pid);
         if (!handle)
             break;
         bio_put_ref(reply, handle);
@@ -247,15 +312,24 @@
 
     case SVC_MGR_ADD_SERVICE:
         s = bio_get_string16(msg, &len);
+        if (s == NULL) {
+            return -1;
+        }
         handle = bio_get_ref(msg);
         allow_isolated = bio_get_uint32(msg) ? 1 : 0;
-        if (do_add_service(bs, s, len, handle, txn->sender_euid, allow_isolated))
+        if (do_add_service(bs, s, len, handle, txn->sender_euid,
+            allow_isolated, txn->sender_pid))
             return -1;
         break;
 
     case SVC_MGR_LIST_SERVICES: {
         uint32_t n = bio_get_uint32(msg);
 
+        if (!svc_can_list(txn->sender_pid, txn->sender_euid)) {
+            ALOGE("list_service() uid=%d - PERMISSION DENIED\n",
+                    txn->sender_euid);
+            return -1;
+        }
         si = svclist;
         while ((n-- > 0) && si)
             si = si->next;
@@ -274,6 +348,20 @@
     return 0;
 }
 
+
+static int audit_callback(void *data, security_class_t cls, char *buf, size_t len)
+{
+    struct audit_data *ad = (struct audit_data *)data;
+
+    if (!ad || !ad->name) {
+        ALOGE("No service manager audit data");
+        return 0;
+    }
+
+    snprintf(buf, len, "service=%s pid=%d uid=%d", ad->name, ad->pid, ad->uid);
+    return 0;
+}
+
 int main(int argc, char **argv)
 {
     struct binder_state *bs;
@@ -289,7 +377,28 @@
         return -1;
     }
 
-    svcmgr_handle = BINDER_SERVICE_MANAGER;
+    selinux_enabled = is_selinux_enabled();
+    sehandle = selinux_android_service_context_handle();
+    selinux_status_open(true);
+
+    if (selinux_enabled > 0) {
+        if (sehandle == NULL) {
+            ALOGE("SELinux: Failed to acquire sehandle. Aborting.\n");
+            abort();
+        }
+
+        if (getcon(&service_manager_context) != 0) {
+            ALOGE("SELinux: Failed to acquire service_manager context. Aborting.\n");
+            abort();
+        }
+    }
+
+    union selinux_callback cb;
+    cb.func_audit = audit_callback;
+    selinux_set_callback(SELINUX_CB_AUDIT, cb);
+    cb.func_log = selinux_log_callback;
+    selinux_set_callback(SELINUX_CB_LOG, cb);
+
     binder_loop(bs, svcmgr_handler);
 
     return 0;
diff --git a/cmds/servicemanager/servicemanager.rc b/cmds/servicemanager/servicemanager.rc
new file mode 100644
index 0000000..b70fda7
--- /dev/null
+++ b/cmds/servicemanager/servicemanager.rc
@@ -0,0 +1,10 @@
+service servicemanager /system/bin/servicemanager
+    class core
+    user system
+    group system readproc
+    critical
+    onrestart restart healthd
+    onrestart restart zygote
+    onrestart restart media
+    onrestart restart surfaceflinger
+    onrestart restart drm
diff --git a/data/etc/android.hardware.audio.output.xml b/data/etc/android.hardware.audio.output.xml
new file mode 100644
index 0000000..6ea1234
--- /dev/null
+++ b/data/etc/android.hardware.audio.output.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- This is the standard feature indicating audio output support of the device,
+     as specified in the CDD. ONLY devices that meet the CDD's requirements may
+     declare this feature. -->
+<permissions>
+    <feature name="android.hardware.audio.output" />
+</permissions>
diff --git a/data/etc/android.hardware.audio.pro.xml b/data/etc/android.hardware.audio.pro.xml
new file mode 100644
index 0000000..5328d41
--- /dev/null
+++ b/data/etc/android.hardware.audio.pro.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- This is the feature indicating professional audio, as specified by the
+     CDD. ONLY devices that meet the CDD's requirements may declare this
+     feature. -->
+<permissions>
+    <feature name="android.hardware.audio.pro" />
+</permissions>
diff --git a/data/etc/android.hardware.camera.external.xml b/data/etc/android.hardware.camera.external.xml
new file mode 100644
index 0000000..a138bcd
--- /dev/null
+++ b/data/etc/android.hardware.camera.external.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- This is the standard set of features for a Android device that can support
+an external camera being connected to it. -->
+<permissions>
+    <feature name="android.hardware.camera.any" />
+    <feature name="android.hardware.camera.external" />
+</permissions>
diff --git a/data/etc/android.hardware.camera.full.xml b/data/etc/android.hardware.camera.full.xml
new file mode 100644
index 0000000..a05dcbe
--- /dev/null
+++ b/data/etc/android.hardware.camera.full.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- This is the set of features required for a full-capability camera2 device -->
+<permissions>
+    <feature name="android.hardware.camera.any" />
+    <feature name="android.hardware.camera.level.full" />
+    <feature name="android.hardware.camera.capability.manual_sensor" />
+    <feature name="android.hardware.camera.capability.manual_post_processing" />
+</permissions>
diff --git a/data/etc/android.hardware.camera.manual_postprocessing.xml b/data/etc/android.hardware.camera.manual_postprocessing.xml
new file mode 100644
index 0000000..01796be
--- /dev/null
+++ b/data/etc/android.hardware.camera.manual_postprocessing.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- This is the set of features required for a camera2 device that supports manual postprocessing capability -->
+<permissions>
+    <feature name="android.hardware.camera.any" />
+    <feature name="android.hardware.camera.capability.manual_post_processing" />
+</permissions>
diff --git a/data/etc/android.hardware.camera.manual_sensor.xml b/data/etc/android.hardware.camera.manual_sensor.xml
new file mode 100644
index 0000000..57db5ab
--- /dev/null
+++ b/data/etc/android.hardware.camera.manual_sensor.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- This is the set of features required for a camera2 device that supports manual sensor capability-->
+<permissions>
+    <feature name="android.hardware.camera.any" />
+    <feature name="android.hardware.camera.capability.manual_sensor" />
+</permissions>
diff --git a/data/etc/android.hardware.camera.raw.xml b/data/etc/android.hardware.camera.raw.xml
new file mode 100644
index 0000000..7f31960
--- /dev/null
+++ b/data/etc/android.hardware.camera.raw.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- This is the set of features required for a camera2 device that supports raw sensor output -->
+<permissions>
+    <feature name="android.hardware.camera.any" />
+    <feature name="android.hardware.camera.capability.raw" />
+</permissions>
diff --git a/data/etc/android.hardware.ethernet.xml b/data/etc/android.hardware.ethernet.xml
new file mode 100644
index 0000000..ccadacb
--- /dev/null
+++ b/data/etc/android.hardware.ethernet.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- This is the standard feature indicating that the device includes ethernet. -->
+<permissions>
+    <feature name="android.hardware.ethernet" />
+</permissions>
+
diff --git a/data/etc/android.hardware.fingerprint.xml b/data/etc/android.hardware.fingerprint.xml
new file mode 100644
index 0000000..3181e7e
--- /dev/null
+++ b/data/etc/android.hardware.fingerprint.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- This is the standard set of features for a biometric fingerprint sensor. -->
+<permissions>
+    <feature name="android.hardware.fingerprint" />
+</permissions>
diff --git a/data/etc/android.hardware.gamepad.xml b/data/etc/android.hardware.gamepad.xml
new file mode 100644
index 0000000..98d8d42
--- /dev/null
+++ b/data/etc/android.hardware.gamepad.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- This is the standard feature indicating that the device is a compatible gamepad or includes
+     one in the box. -->
+<permissions>
+    <feature name="android.hardware.gamepad" />
+</permissions>
+
diff --git a/data/etc/android.hardware.hdmi.cec.xml b/data/etc/android.hardware.hdmi.cec.xml
new file mode 100644
index 0000000..e25ca56
--- /dev/null
+++ b/data/etc/android.hardware.hdmi.cec.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- This is the standard feature indicating that the device includes HDMI-CEC. -->
+<permissions>
+    <feature name="android.hardware.hdmi.cec" />
+</permissions>
+
diff --git a/data/etc/android.hardware.nfc.hcef.xml b/data/etc/android.hardware.nfc.hcef.xml
new file mode 100644
index 0000000..0d03023
--- /dev/null
+++ b/data/etc/android.hardware.nfc.hcef.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- This feature indicates that the device supports host-based
+     NFC-F card emulation -->
+<permissions>
+    <feature name="android.hardware.nfc.hcef" />
+</permissions>
diff --git a/data/etc/android.hardware.opengles.aep.xml b/data/etc/android.hardware.opengles.aep.xml
new file mode 100644
index 0000000..055fa7a
--- /dev/null
+++ b/data/etc/android.hardware.opengles.aep.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- This is the standard feature indicating that the device supports the
+     Android Extension Pack features. -->
+<permissions>
+    <feature name="android.hardware.opengles.aep" />
+</permissions>
+
diff --git a/data/etc/android.hardware.screen.landscape.xml b/data/etc/android.hardware.screen.landscape.xml
new file mode 100644
index 0000000..07bcd0a
--- /dev/null
+++ b/data/etc/android.hardware.screen.landscape.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- Standard feature indicating that the device supports landscape mode. -->
+<permissions>
+    <feature name="android.hardware.screen.landscape" />
+</permissions>
diff --git a/data/etc/android.hardware.screen.portrait.xml b/data/etc/android.hardware.screen.portrait.xml
new file mode 100644
index 0000000..530c6c6
--- /dev/null
+++ b/data/etc/android.hardware.screen.portrait.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- Standard feature indicating that the device supports portrait mode. -->
+<permissions>
+    <feature name="android.hardware.screen.portrait" />
+</permissions>
diff --git a/data/etc/android.hardware.sensor.heartrate.ecg.xml b/data/etc/android.hardware.sensor.heartrate.ecg.xml
new file mode 100644
index 0000000..62a0de5
--- /dev/null
+++ b/data/etc/android.hardware.sensor.heartrate.ecg.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- Feature for devices with a hardware electrocardiography(ECG) sensor. -->
+<permissions>
+    <feature name="android.hardware.sensor.heartrate.ecg" />
+</permissions>
diff --git a/data/etc/android.hardware.sensor.heartrate.xml b/data/etc/android.hardware.sensor.heartrate.xml
new file mode 100644
index 0000000..c49bfc0
--- /dev/null
+++ b/data/etc/android.hardware.sensor.heartrate.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- Feature for devices with a hardware heart rate monitor. -->
+<permissions>
+    <feature name="android.hardware.sensor.heartrate" />
+</permissions>
diff --git a/data/etc/android.hardware.sensor.hifi_sensors.xml b/data/etc/android.hardware.sensor.hifi_sensors.xml
new file mode 100644
index 0000000..bb3901c
--- /dev/null
+++ b/data/etc/android.hardware.sensor.hifi_sensors.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- Feature for devices supporting hifi sensors. -->
+<permissions>
+    <feature name="android.hardware.sensor.hifi_sensors" />
+</permissions>
diff --git a/data/etc/android.software.app_widgets.xml b/data/etc/android.software.app_widgets.xml
new file mode 100644
index 0000000..9a51b24
--- /dev/null
+++ b/data/etc/android.software.app_widgets.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<permissions>
+    <feature name="android.software.app_widgets" />
+</permissions>
diff --git a/data/etc/android.software.backup.xml b/data/etc/android.software.backup.xml
new file mode 100644
index 0000000..1ab4603
--- /dev/null
+++ b/data/etc/android.software.backup.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<permissions>
+    <feature name="android.software.backup" />
+</permissions>
diff --git a/data/etc/android.software.connectionservice.xml b/data/etc/android.software.connectionservice.xml
new file mode 100644
index 0000000..7aaf4c1
--- /dev/null
+++ b/data/etc/android.software.connectionservice.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- This is the standard set of features for devices that support the ConnectionService API. -->
+<permissions>
+    <feature name="android.software.connectionservice" />
+</permissions>
diff --git a/data/etc/android.software.device_admin.xml b/data/etc/android.software.device_admin.xml
new file mode 100644
index 0000000..7d14dc6
--- /dev/null
+++ b/data/etc/android.software.device_admin.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<permissions>
+    <feature name="android.software.device_admin" />
+</permissions>
diff --git a/data/etc/android.software.live_tv.xml b/data/etc/android.software.live_tv.xml
new file mode 100644
index 0000000..431acb0
--- /dev/null
+++ b/data/etc/android.software.live_tv.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<permissions>
+    <feature name="android.software.live_tv" />
+</permissions>
diff --git a/data/etc/android.software.managed_users.xml b/data/etc/android.software.managed_users.xml
new file mode 100644
index 0000000..56affe9
--- /dev/null
+++ b/data/etc/android.software.managed_users.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- This is the standard feature indicating that the device supports managed users. -->
+<permissions>
+    <feature name="android.software.managed_users" />
+</permissions>
diff --git a/data/etc/android.software.midi.xml b/data/etc/android.software.midi.xml
new file mode 100644
index 0000000..a03cd55
--- /dev/null
+++ b/data/etc/android.software.midi.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<permissions>
+    <feature name="android.software.midi" />
+</permissions>
diff --git a/data/etc/android.software.print.xml b/data/etc/android.software.print.xml
new file mode 100644
index 0000000..713a7f7
--- /dev/null
+++ b/data/etc/android.software.print.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<permissions>
+    <feature name="android.software.print" />
+</permissions>
diff --git a/data/etc/android.software.securely_removes_users.xml b/data/etc/android.software.securely_removes_users.xml
new file mode 100644
index 0000000..7278bcd
--- /dev/null
+++ b/data/etc/android.software.securely_removes_users.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<permissions>
+    <feature name="android.software.securely_removes_users" />
+</permissions>
\ No newline at end of file
diff --git a/data/etc/android.software.verified_boot.xml b/data/etc/android.software.verified_boot.xml
new file mode 100644
index 0000000..7a9a9c5
--- /dev/null
+++ b/data/etc/android.software.verified_boot.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<permissions>
+    <feature name="android.software.verified_boot" />
+</permissions>
\ No newline at end of file
diff --git a/data/etc/android.software.voice_recognizers.xml b/data/etc/android.software.voice_recognizers.xml
new file mode 100644
index 0000000..435eed4
--- /dev/null
+++ b/data/etc/android.software.voice_recognizers.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<permissions>
+    <feature name="android.software.voice_recognizers" notLowRam="true" />
+</permissions>
diff --git a/data/etc/android.software.webview.xml b/data/etc/android.software.webview.xml
new file mode 100644
index 0000000..d843209
--- /dev/null
+++ b/data/etc/android.software.webview.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<permissions>
+    <feature name="android.software.webview" />
+</permissions>
diff --git a/data/etc/handheld_core_hardware.xml b/data/etc/handheld_core_hardware.xml
index 4a9f2dd..50cbe9e 100644
--- a/data/etc/handheld_core_hardware.xml
+++ b/data/etc/handheld_core_hardware.xml
@@ -4,9 +4,9 @@
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
-  
+
           http://www.apache.org/licenses/LICENSE-2.0
-  
+
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,6 +23,7 @@
      devices.
 -->
 <permissions>
+    <feature name="android.hardware.audio.output" />
     <feature name="android.hardware.camera" />
     <feature name="android.hardware.location" />
     <feature name="android.hardware.location.network" />
@@ -33,14 +34,25 @@
     <feature name="android.hardware.microphone" />
     <feature name="android.hardware.screen.portrait" />
     <feature name="android.hardware.screen.landscape" />
+
+    <!-- basic system services -->
     <feature name="android.software.app_widgets" />
+    <feature name="android.software.connectionservice" />
+    <feature name="android.software.voice_recognizers" notLowRam="true" />
+    <feature name="android.software.backup" />
     <feature name="android.software.home_screen" />
     <feature name="android.software.input_methods" />
+    <feature name="android.software.print" />
+
     <!-- Feature to specify if the device supports adding device admins. -->
     <feature name="android.software.device_admin" />
+
+    <!-- Feature to specify if the device support managed users. -->
+    <feature name="android.software.managed_users" />
+
     <!-- devices with GPS must include android.hardware.location.gps.xml -->
     <!-- devices with an autofocus camera and/or flash must include either
-         android.hardware.camera.autofocus.xml or 
+         android.hardware.camera.autofocus.xml or
          android.hardware.camera.autofocus-flash.xml -->
     <!-- devices with a front facing camera must include
          android.hardware.camera.front.xml -->
diff --git a/data/etc/tablet_core_hardware.xml b/data/etc/tablet_core_hardware.xml
index 78b9736..8128165 100644
--- a/data/etc/tablet_core_hardware.xml
+++ b/data/etc/tablet_core_hardware.xml
@@ -4,9 +4,9 @@
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
-  
+
           http://www.apache.org/licenses/LICENSE-2.0
-  
+
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,6 +23,7 @@
      devices.
 -->
 <permissions>
+    <feature name="android.hardware.audio.output" />
     <feature name="android.hardware.location" />
     <feature name="android.hardware.location.network" />
     <feature name="android.hardware.sensor.compass" />
@@ -34,15 +35,25 @@
     <feature name="android.hardware.microphone" />
     <feature name="android.hardware.screen.portrait" />
     <feature name="android.hardware.screen.landscape" />
+
+    <!-- basic system services -->
     <feature name="android.software.app_widgets" />
+    <feature name="android.software.voice_recognizers" />
+    <feature name="android.software.backup" />
     <feature name="android.software.home_screen" />
     <feature name="android.software.input_methods" />
+    <feature name="android.software.print" />
+
     <!-- Feature to specify if the device supports adding device admins. -->
     <feature name="android.software.device_admin" />
+
+    <!-- Feature to specify if the device support managed users. -->
+    <feature name="android.software.managed_users" />
+
     <!-- devices with GPS must include android.hardware.location.gps.xml -->
     <!-- devices with a rear-facing camera must include one of these as appropriate:
-         android.hardware.camera.xml or 
-         android.hardware.camera.autofocus.xml or 
+         android.hardware.camera.xml or
+         android.hardware.camera.autofocus.xml or
          android.hardware.camera.autofocus-flash.xml -->
     <!-- devices with a front facing camera must include
          android.hardware.camera.front.xml -->
diff --git a/data/etc/wearable_core_hardware.xml b/data/etc/wearable_core_hardware.xml
new file mode 100644
index 0000000..346abad
--- /dev/null
+++ b/data/etc/wearable_core_hardware.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!-- These are the hardware and software components that all wearable devices
+     must include. Devices with optional hardware/software must also include
+     extra hardware/software files, per the comments below.
+
+     Wearable devices include watches, glasses, backpacks, and sweaters.
+-->
+<permissions>
+    <feature name="android.hardware.location" />
+    <feature name="android.hardware.sensor.compass" />
+    <feature name="android.hardware.sensor.accelerometer" />
+    <feature name="android.hardware.bluetooth" />
+    <feature name="android.hardware.touchscreen" />
+    <feature name="android.hardware.microphone" />
+
+    <!-- basic system services -->
+    <feature name="android.software.home_screen" />
+
+    <!-- devices that support a device administrator policy must include
+         android.software.device_admin.xml -->
+    <!-- devices with GPS must include device/google/clockwork/gps.xml -->
+    <!-- devices with an autofocus camera and/or flash must include either
+         android.hardware.camera.autofocus.xml or
+         android.hardware.camera.autofocus-flash.xml -->
+    <!-- devices with a front facing camera must include
+         android.hardware.camera.front.xml -->
+    <!-- devices with WiFi must also include android.hardware.wifi.xml -->
+    <!-- devices that support multitouch must include the most appropriate one
+         of these files:
+
+         If only partial (non-independent) pointers are supported:
+         android.hardware.touchscreen.multitouch.xml
+
+         If up to 4 independently tracked pointers are supported:
+         include android.hardware.touchscreen.multitouch.distinct.xml
+
+         If 5 or more independently tracked pointers are supported:
+         include android.hardware.touchscreen.multitouch.jazzhand.xml
+
+         ONLY ONE of the above should be included. -->
+    <!-- devices with an ambient light sensor must also include
+         android.hardware.sensor.light.xml -->
+    <!-- devices with a proximity sensor must also include
+         android.hardware.sensor.proximity.xml -->
+    <!-- Devices that have low-latency audio stacks suitable for apps like
+         VoIP may include android.hardware.audio.low_latency.xml. ONLY apps
+         that meet the requirements specified in the CDD may include this. -->
+    <!-- devices that have audio output capability as specified in the CDD must
+         also include android.hardware.audio.output.xml -->
+</permissions>
diff --git a/docs/Doxyfile b/docs/Doxyfile
new file mode 100644
index 0000000..46d6d84
--- /dev/null
+++ b/docs/Doxyfile
@@ -0,0 +1,1902 @@
+# Doxyfile 1.8.3.1
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file 
+# that follow. The default is UTF-8 which is also the encoding used for all 
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the 
+# iconv built into libc) for the transcoding. See 
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or sequence of words) that should 
+# identify the project. Note that if you do not use Doxywizard you need 
+# to put quotes around the project name if it contains spaces.
+
+PROJECT_NAME           = "NDK API"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+
+PROJECT_NUMBER         = 
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description 
+# for a project that appears at the top of each page and should give viewer 
+# a quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF          = ""
+
+# With the PROJECT_LOGO tag one can specify an logo or icon that is 
+# included in the documentation. The maximum height of the logo should not 
+# exceed 55 pixels and the maximum width should not exceed 200 pixels. 
+# Doxygen will copy the logo to the output directory.
+
+PROJECT_LOGO           = logo.png
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = 
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
+# 4096 sub-directories (in 2 levels) under the output directory of each output 
+# format and will distribute the generated files over these directories. 
+# Enabling this option can be useful when feeding doxygen a huge amount of 
+# source files, where putting all generated files in the same directory would 
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, 
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English 
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, 
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, 
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator 
+# that is used to form the text in various listings. Each string 
+# in this list, if found as the leading text of the brief description, will be 
+# stripped from the text and the result after processing the whole list, is 
+# used as the annotated text. Otherwise, the brief description is used as-is. 
+# If left blank, the following values are used ("$name" is automatically 
+# replaced with the name of the entity): "The $name class" "The $name widget" 
+# "The $name file" "is" "provides" "specifies" "contains" 
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       = "The $name class" \
+                         "The $name widget" \
+                         "The $name file" \
+                         is \
+                         provides \
+                         specifies \
+                         contains \
+                         represents \
+                         a \
+                         an \
+                         the
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
+# Doxygen will generate a detailed section even if there is only a brief 
+# description.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 
+# inherited members of a class in the documentation of that class as if those 
+# members were ordinary class members. Constructors, destructors and assignment 
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
+# path before files name in the file list and in the header files. If set 
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
+# can be used to strip a user-defined part of the path. Stripping is 
+# only done if one of the specified strings matches the left-hand part of 
+# the path. The tag can be used to show relative paths in the file list. 
+# If left blank the directory from which doxygen is run is used as the 
+# path to strip. Note that you specify absolute paths here, but also 
+# relative paths, which will be relative from the directory where doxygen is 
+# started.
+
+STRIP_FROM_PATH        = 
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
+# the path mentioned in the documentation of a class, which tells 
+# the reader which header file to include in order to use a class. 
+# If left blank only the name of the header file containing the class 
+# definition is used. Otherwise one should specify the include paths that 
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH    = 
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
+# (but less readable) file names. This can be useful if your file system 
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
+# will interpret the first line (until the first dot) of a JavaDoc-style 
+# comment as the brief description. If set to NO, the JavaDoc 
+# comments will behave just like regular Qt-style comments 
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF      = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will 
+# interpret the first line (until the first dot) of a Qt-style 
+# comment as the brief description. If set to NO, the comments 
+# will behave just like regular Qt-style comments (thus requiring 
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
+# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
+# comments) as a brief description. This used to be the default behaviour. 
+# The new default is to treat a multi-line C++ comment block as a detailed 
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
+# member inherits the documentation from any documented member that it 
+# re-implements.
+
+INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 
+# a new page for each member. If set to NO, the documentation of a member will 
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 4
+
+# This tag can be used to specify a number of aliases that acts 
+# as commands in the documentation. An alias has the form "name=value". 
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+# put the command \sideeffect (or @sideeffect) in the documentation, which 
+# will result in a user-defined paragraph with heading "Side Effects:". 
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                = 
+
+# This tag can be used to specify a number of word-keyword mappings (TCL only). 
+# A mapping has the form "name=value". For example adding 
+# "class=itcl::class" will allow you to use the command class in the 
+# itcl::class meaning.
+
+TCL_SUBST              = 
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 
+# sources only. Doxygen will then generate output that is more tailored for C. 
+# For instance, some of the names that are used will be different. The list 
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 
+# sources only. Doxygen will then generate output that is more tailored for 
+# Java. For instance, namespaces will be presented as packages, qualified 
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran 
+# sources only. Doxygen will then generate output that is more tailored for 
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL 
+# sources. Doxygen will then generate output that is tailored for 
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it 
+# parses. With this tag you can assign which parser to use for a given 
+# extension. Doxygen has a built-in mapping, but you can override or extend it 
+# using this tag. The format is ext=language, where ext is a file extension, 
+# and language is one of the parsers supported by doxygen: IDL, Java, 
+# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, 
+# C++. For instance to make doxygen treat .inc files as Fortran files (default 
+# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note 
+# that for custom extensions you also need to set FILE_PATTERNS otherwise the 
+# files are not read by doxygen.
+
+EXTENSION_MAPPING      = 
+
+# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all 
+# comments according to the Markdown format, which allows for more readable 
+# documentation. See http://daringfireball.net/projects/markdown/ for details. 
+# The output of markdown processing is further processed by doxygen, so you 
+# can mix doxygen, HTML, and XML commands with Markdown formatting. 
+# Disable only in case of backward compatibilities issues.
+
+MARKDOWN_SUPPORT       = YES
+
+# When enabled doxygen tries to link words that correspond to documented classes, 
+# or namespaces to their corresponding documentation. Such a link can be 
+# prevented in individual cases by by putting a % sign in front of the word or 
+# globally by setting AUTOLINK_SUPPORT to NO.
+
+AUTOLINK_SUPPORT       = YES
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want 
+# to include (a tag file for) the STL sources as input, then you should 
+# set this tag to YES in order to let doxygen match functions declarations and 
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 
+# func(std::string) {}). This also makes the inheritance and collaboration 
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to 
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. 
+# Doxygen will parse them like normal C++ but will assume all classes use public 
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate 
+# getter and setter methods for a property. Setting this option to YES (the 
+# default) will make doxygen replace the get and set methods by a property in 
+# the documentation. This will only work if the methods are indeed getting or 
+# setting a simple type. If this is not the case, or you want to show the 
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
+# tag is set to YES, then doxygen will reuse the documentation of the first 
+# member in the group (if any) for the other members of the group. By default 
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
+# the same type (for instance a group of public functions) to be put as a 
+# subgroup of that type (e.g. under the Public Functions section). Set it to 
+# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and 
+# unions are shown inside the group in which they are included (e.g. using 
+# @ingroup) instead of on a separate page (for HTML and Man pages) or 
+# section (for LaTeX and RTF).
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and 
+# unions with only public data fields will be shown inline in the documentation 
+# of the scope in which they are defined (i.e. file, namespace, or group 
+# documentation), provided this scope is documented. If set to NO (the default), 
+# structs, classes, and unions are shown on a separate page (for HTML and Man 
+# pages) or section (for LaTeX and RTF).
+
+INLINE_SIMPLE_STRUCTS  = NO
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum 
+# is documented as struct, union, or enum with the name of the typedef. So 
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct 
+# with name TypeT. When disabled the typedef will appear as a member of a file, 
+# namespace, or class. And the struct will be named TypeS. This can typically 
+# be useful for C code in case the coding convention dictates that all compound 
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to 
+# determine which symbols to keep in memory and which to flush to disk. 
+# When the cache is full, less often used symbols will be written to disk. 
+# For small to medium size projects (<1000 input files) the default value is 
+# probably good enough. For larger projects a too small cache size can cause 
+# doxygen to be busy swapping symbols to and from disk most of the time 
+# causing a significant performance penalty. 
+# If the system has enough physical memory increasing the cache will improve the 
+# performance by keeping more symbols in memory. Note that the value works on 
+# a logarithmic scale so increasing the size by one will roughly double the 
+# memory usage. The cache size is given by this formula: 
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, 
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+SYMBOL_CACHE_SIZE      = 0
+
+# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be 
+# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given 
+# their name and scope. Since this can be an expensive process and often the 
+# same symbol appear multiple times in the code, doxygen keeps a cache of 
+# pre-resolved symbols. If the cache is too small doxygen will become slower. 
+# If the cache is too large, memory is wasted. The cache size is given by this 
+# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, 
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+LOOKUP_CACHE_SIZE      = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+# documentation are documented, even if no documentation was available. 
+# Private class members and static file members will be hidden unless 
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal 
+# scope will be included in the documentation.
+
+EXTRACT_PACKAGE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# will be included in the documentation.
+
+EXTRACT_STATIC         = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
+# defined locally in source files will be included in the documentation. 
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. When set to YES local 
+# methods, which are defined in the implementation section but not in 
+# the interface are included in the documentation. 
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be 
+# extracted and appear in the documentation as a namespace called 
+# 'anonymous_namespace{file}', where file will be replaced with the base 
+# name of the file that contains the anonymous namespace. By default 
+# anonymous namespaces are hidden.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+# undocumented members of documented classes, files or namespaces. 
+# If set to NO (the default) these members will be included in the 
+# various overviews, but no documentation section is generated. 
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+# undocumented classes that are normally visible in the class hierarchy. 
+# If set to NO (the default) these classes will be included in the various 
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
+# friend (class|struct|union) declarations. 
+# If set to NO (the default) these declarations will be included in the 
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
+# documentation blocks found inside the body of a function. 
+# If set to NO (the default) these blocks will be appended to the 
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation 
+# that is typed after a \internal command is included. If the tag is set 
+# to NO (the default) then the documentation will be excluded. 
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+# file names in lower-case letters. If set to YES upper-case letters are also 
+# allowed. This is useful if you have classes or files whose names only differ 
+# in case and if your file system supports case sensitive file names. Windows 
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = NO
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+# will show members with their full class and namespace scopes in the 
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = YES
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+# will put a list of the files that are included by a file in the documentation 
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen 
+# will list include files with double quotes in the documentation 
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES   = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+# will sort the (detailed) documentation of file and class members 
+# alphabetically by member name. If set to NO the members will appear in 
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 
+# brief documentation of file, namespace and class members alphabetically 
+# by member name. If set to NO (the default) the members will appear in 
+# declaration order.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen 
+# will sort the (brief and detailed) documentation of class members so that 
+# constructors and destructors are listed first. If set to NO (the default) 
+# the constructors will appear in the respective orders defined by 
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. 
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO 
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the 
+# hierarchy of group names into alphabetical order. If set to NO (the default) 
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 
+# sorted by fully-qualified names, including namespaces. If set to 
+# NO (the default), the class list will be sorted only by class name, 
+# not including the namespace part. 
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. 
+# Note: This option applies only to the class list, not to the 
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to 
+# do proper type resolution of all parameters of a function it will reject a 
+# match between the prototype and the implementation of a member function even 
+# if there is only one candidate or it is obvious which candidate to choose 
+# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen 
+# will still accept a match between prototype and implementation in such cases.
+
+STRICT_PROTO_MATCHING  = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or 
+# disable (NO) the todo list. This list is created by putting \todo 
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or 
+# disable (NO) the test list. This list is created by putting \test 
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or 
+# disable (NO) the bug list. This list is created by putting \bug 
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
+# disable (NO) the deprecated list. This list is created by putting 
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional 
+# documentation sections, marked by \if section-label ... \endif 
+# and \cond section-label ... \endcond blocks.
+
+ENABLED_SECTIONS       = 
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
+# the initial value of a variable or macro consists of for it to appear in 
+# the documentation. If the initializer consists of more lines than specified 
+# here it will be hidden. Use a value of 0 to hide initializers completely. 
+# The appearance of the initializer of individual variables and macros in the 
+# documentation can be controlled using \showinitializer or \hideinitializer 
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 26
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
+# at the bottom of the documentation of classes and structs. If set to YES the 
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = YES
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page. 
+# This will remove the Files entry from the Quick Index and from the 
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the 
+# Namespaces page.  This will remove the Namespaces entry from the Quick Index 
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that 
+# doxygen should invoke to get the current version for each file (typically from 
+# the version control system). Doxygen will invoke the program by executing (via 
+# popen()) the command <command> <input-file>, where <command> is the value of 
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file 
+# provided by doxygen. Whatever the program writes to standard output 
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    = 
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed 
+# by doxygen. The layout file controls the global structure of the generated 
+# output files in an output format independent way. To create the layout file 
+# that represents doxygen's defaults, run doxygen with the -l option. 
+# You can optionally specify a file name after the option, if omitted 
+# DoxygenLayout.xml will be used as the name of the layout file.
+
+LAYOUT_FILE            = 
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files 
+# containing the references data. This must be a list of .bib files. The 
+# .bib extension is automatically appended if omitted. Using this command 
+# requires the bibtex tool to be installed. See also 
+# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style 
+# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this 
+# feature you need bibtex and perl available in the search path. Do not use 
+# file names with spaces, bibtex cannot handle them.
+
+CITE_BIB_FILES         = 
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated 
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are 
+# generated by doxygen. Possible values are YES and NO. If left blank 
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
+# potential errors in the documentation, such as not documenting some 
+# parameters in a documented function, or documenting parameters that 
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# The WARN_NO_PARAMDOC option can be enabled to get warnings for 
+# functions that are documented, but have no documentation for their parameters 
+# or return value. If set to NO (the default) doxygen will only warn about 
+# wrong or incomplete parameter documentation, but not about the absence of 
+# documentation.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that 
+# doxygen can produce. The string should contain the $file, $line, and $text 
+# tags, which will be replaced by the file and line number from which the 
+# warning originated and the warning text. Optionally the format may contain 
+# $version, which will be replaced by the version of the file (if it could 
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning 
+# and error messages should be written. If left blank the output is written 
+# to stderr.
+
+WARN_LOGFILE           = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain 
+# documented source files. You may enter file names like "myfile.cpp" or 
+# directories like "/usr/src/myproject". Separate the files or directories 
+# with spaces.
+
+INPUT                  = ../include/android
+
+# This tag can be used to specify the character encoding of the source files 
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 
+# also the default input encoding. Doxygen uses libiconv (or the iconv built 
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for 
+# the list of possible encodings.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the 
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank the following patterns are tested: 
+# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh 
+# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py 
+# *.f90 *.f *.for *.vhd *.vhdl
+
+FILE_PATTERNS          = *.c \
+                         *.cc \
+                         *.cxx \
+                         *.cpp \
+                         *.c++ \
+                         *.d \
+                         *.java \
+                         *.ii \
+                         *.ixx \
+                         *.ipp \
+                         *.i++ \
+                         *.inl \
+                         *.h \
+                         *.hh \
+                         *.hxx \
+                         *.hpp \
+                         *.h++ \
+                         *.idl \
+                         *.odl \
+                         *.cs \
+                         *.php \
+                         *.php3 \
+                         *.inc \
+                         *.m \
+                         *.markdown \
+                         *.md \
+                         *.mm \
+                         *.dox \
+                         *.py \
+                         *.f90 \
+                         *.f \
+                         *.for \
+                         *.vhd \
+                         *.vhdl
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
+# should be searched for input files as well. Possible values are YES and NO. 
+# If left blank NO is used.
+
+RECURSIVE              = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should be 
+# excluded from the INPUT source files. This way you can easily exclude a 
+# subdirectory from a directory tree whose root is specified with the INPUT tag. 
+# Note that relative paths are relative to the directory from which doxygen is 
+# run.
+
+EXCLUDE                = 
+
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or 
+# directories that are symbolic links (a Unix file system feature) are excluded 
+# from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the 
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
+# certain files from those directories. Note that the wildcards are matched 
+# against the file with absolute path, so to exclude all test directories 
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       = 
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 
+# (namespaces, classes, functions, etc.) that should be excluded from the 
+# output. The symbol name can be a fully qualified name, a word, or if the 
+# wildcard * is used, a substring. Examples: ANamespace, AClass, 
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS        = 
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# directories that contain example code fragments that are included (see 
+# the \include command).
+
+EXAMPLE_PATH           = 
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included.
+
+EXAMPLE_PATTERNS       = *
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
+# searched for input files to be used with the \include or \dontinclude 
+# commands irrespective of the value of the RECURSIVE tag. 
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or 
+# directories that contain image that are included in the documentation (see 
+# the \image command).
+
+IMAGE_PATH             = 
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should 
+# invoke to filter for each input file. Doxygen will invoke the filter program 
+# by executing (via popen()) the command <filter> <input-file>, where <filter> 
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
+# input file. Doxygen will then use the output that the filter program writes 
+# to standard output.  If FILTER_PATTERNS is specified, this tag will be 
+# ignored.
+
+INPUT_FILTER           = 
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 
+# basis.  Doxygen will compare the file name with each pattern and apply the 
+# filter if there is a match.  The filters are a list of the form: 
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 
+# info on how filters are used. If FILTER_PATTERNS is empty or if 
+# non of the patterns match the file name, INPUT_FILTER is applied.
+
+FILTER_PATTERNS        = 
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
+# INPUT_FILTER) will be used to filter the input files when producing source 
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file 
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any) 
+# and it is also possible to disable source filtering for a specific pattern 
+# using *.ext= (so without naming a filter). This option only has effect when 
+# FILTER_SOURCE_FILES is enabled.
+
+FILTER_SOURCE_PATTERNS = 
+
+# If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that 
+# is part of the input, its contents will be placed on the main page (index.html). 
+# This can be useful if you have a project on for instance GitHub and want reuse 
+# the introduction page also for the doxygen output.
+
+USE_MDFILE_AS_MAINPAGE = 
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# be generated. Documented entities will be cross-referenced with these sources. 
+# Note: To get rid of all source code in the generated output, make sure also 
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body 
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+# doxygen to hide any special comment blocks from generated source code 
+# fragments. Normal C, C++ and Fortran comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = NO
+
+# If the REFERENCED_BY_RELATION tag is set to YES 
+# then for each documented function all documented 
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES 
+# then for each documented function all documented entities 
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) 
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from 
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will 
+# link to the source code.  Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code 
+# will point to the HTML generated by the htags(1) tool instead of doxygen 
+# built-in source browser. The htags tool is part of GNU's global source 
+# tagging system (see http://www.gnu.org/software/global/global.html). You 
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+# will generate a verbatim copy of the header file for each class for 
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
+# of all compounds will be generated. Enable this if the project 
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all 
+# classes will be put under the same header in the alphabetical index. 
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = $(HTML_OUTPUT)
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard header. Note that when using a custom header you are responsible  
+# for the proper inclusion of any scripts and style sheets that doxygen 
+# needs, which is dependent on the configuration options used. 
+# It is advised to generate a default header using "doxygen -w html 
+# header.html footer.html stylesheet.css YourConfigFile" and then modify 
+# that header. Note that the header is subject to change so you typically 
+# have to redo this when upgrading to a newer version of doxygen or when 
+# changing the value of configuration settings such as GENERATE_TREEVIEW!
+
+HTML_HEADER            = $(HTML_HEADER)
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard footer.
+
+HTML_FOOTER            = $(HTML_FOOTER)
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
+# style sheet that is used by each HTML page. It can be used to 
+# fine-tune the look of the HTML output. If left blank doxygen will 
+# generate a default style sheet. Note that it is recommended to use 
+# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this 
+# tag will in the future become obsolete.
+
+HTML_STYLESHEET        = 
+
+# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional 
+# user-defined cascading style sheet that is included after the standard 
+# style sheets created by doxygen. Using this option one can overrule 
+# certain style aspects. This is preferred over using HTML_STYLESHEET 
+# since it does not replace the standard style sheet and is therefor more 
+# robust against future updates. Doxygen will copy the style sheet file to 
+# the output directory.
+
+HTML_EXTRA_STYLESHEET  = 
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or 
+# other source files which should be copied to the HTML output directory. Note 
+# that these files will be copied to the base HTML output directory. Use the 
+# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these 
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that 
+# the files will be copied as-is; there are no commands or markers available.
+
+HTML_EXTRA_FILES       = 
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. 
+# Doxygen will adjust the colors in the style sheet and background images 
+# according to this color. Hue is specified as an angle on a colorwheel, 
+# see http://en.wikipedia.org/wiki/Hue for more information. 
+# For instance the value 0 represents red, 60 is yellow, 120 is green, 
+# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. 
+# The allowed range is 0 to 359.
+
+HTML_COLORSTYLE_HUE    = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of 
+# the colors in the HTML output. For a value of 0 the output will use 
+# grayscales only. A value of 255 will produce the most vivid colors.
+
+HTML_COLORSTYLE_SAT    = 0
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to 
+# the luminance component of the colors in the HTML output. Values below 
+# 100 gradually make the output lighter, whereas values above 100 make 
+# the output darker. The value divided by 100 is the actual gamma applied, 
+# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, 
+# and 100 does not change the gamma.
+
+HTML_COLORSTYLE_GAMMA  = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML 
+# page will contain the date and time when the page was generated. Setting 
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP         = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML 
+# documentation will contain sections that can be hidden and shown after the 
+# page has loaded.
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of 
+# entries shown in the various tree structured indices initially; the user 
+# can expand and collapse entries dynamically later on. Doxygen will expand 
+# the tree to such a level that at most the specified number of entries are 
+# visible (unless a fully collapsed tree already exceeds this amount). 
+# So setting the number of entries 1 will produce a full collapsed tree by 
+# default. 0 is a special value representing an infinite number of entries 
+# and will result in a full expanded tree by default.
+
+HTML_INDEX_NUM_ENTRIES = 100
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files 
+# will be generated that can be used as input for Apple's Xcode 3 
+# integrated development environment, introduced with OSX 10.5 (Leopard). 
+# To create a documentation set, doxygen will generate a Makefile in the 
+# HTML output directory. Running make will produce the docset in that 
+# directory and running "make install" will install the docset in 
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find 
+# it at startup. 
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html 
+# for more information.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the 
+# feed. A documentation feed provides an umbrella under which multiple 
+# documentation sets from a single provider (such as a company or product suite) 
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that 
+# should uniquely identify the documentation set bundle. This should be a 
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen 
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely 
+# identify the documentation publisher. This should be a reverse domain-name 
+# style string, e.g. com.mycompany.MyDocSet.documentation.
+
+DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
+
+# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+
+DOCSET_PUBLISHER_NAME  = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
+# will be generated that can be used as input for tools like the 
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) 
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
+# be used to specify the file name of the resulting .chm file. You 
+# can add a path in front of the file if the result should not be 
+# written to the html output directory.
+
+CHM_FILE               = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
+# be used to specify the location (absolute path including file name) of 
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
+# controls if a separate .chi index file is generated (YES) or that 
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING 
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file 
+# content.
+
+CHM_INDEX_ENCODING     = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
+# controls whether a binary table of contents is generated (YES) or a 
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and 
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated 
+# that can be used as input for Qt's qhelpgenerator to generate a 
+# Qt Compressed Help (.qch) of the generated HTML documentation.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can 
+# be used to specify the file name of the resulting .qch file. 
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE               = 
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating 
+# Qt Help Project output. For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE          = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating 
+# Qt Help Project output. For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to 
+# add. For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME   = 
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the 
+# custom filter to add. For more information please see 
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters"> 
+# Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS  = 
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this 
+# project's 
+# filter section matches. 
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes"> 
+# Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS  = 
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can 
+# be used to specify the location of Qt's qhelpgenerator. 
+# If non-empty doxygen will try to run qhelpgenerator on the generated 
+# .qhp file.
+
+QHG_LOCATION           = 
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files  
+# will be generated, which together with the HTML files, form an Eclipse help 
+# plugin. To install this plugin and make it available under the help contents 
+# menu in Eclipse, the contents of the directory containing the HTML and XML 
+# files needs to be copied into the plugins directory of eclipse. The name of 
+# the directory within the plugins directory should be the same as 
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before 
+# the help appears.
+
+GENERATE_ECLIPSEHELP   = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin 
+# the directory name containing the HTML and XML files should also have 
+# this name.
+
+ECLIPSE_DOC_ID         = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) 
+# at top of each HTML page. The value NO (the default) enables the index and 
+# the value YES disables it. Since the tabs have the same information as the 
+# navigation tree you can set this option to NO if you already set 
+# GENERATE_TREEVIEW to YES.
+
+DISABLE_INDEX          = YES
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index 
+# structure should be generated to display hierarchical information. 
+# If the tag value is set to YES, a side panel will be generated 
+# containing a tree-like index structure (just like the one that 
+# is generated for HTML Help). For this to work a browser that supports 
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). 
+# Windows users are probably better off using the HTML help feature. 
+# Since the tree basically has the same information as the tab index you 
+# could consider to set DISABLE_INDEX to NO when enabling this option.
+
+GENERATE_TREEVIEW      = NO
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values 
+# (range [0,1..20]) that doxygen will group on one line in the generated HTML 
+# documentation. Note that a value of 0 will completely suppress the enum 
+# values from appearing in the overview section.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
+# used to set the initial width (in pixels) of the frame in which the tree 
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open 
+# links to external symbols imported via tag files in a separate window.
+
+EXT_LINKS_IN_WINDOW    = NO
+
+# Use this tag to change the font size of Latex formulas included 
+# as images in the HTML documentation. The default is 10. Note that 
+# when you change the font size after a successful doxygen run you need 
+# to manually remove any form_*.png images from the HTML output directory 
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images 
+# generated for formulas are transparent PNGs. Transparent PNGs are 
+# not supported properly for IE 6.0, but are supported on all modern browsers. 
+# Note that when changing this option you need to delete any form_*.png files 
+# in the HTML output before the changes have effect.
+
+FORMULA_TRANSPARENT    = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax 
+# (see http://www.mathjax.org) which uses client side Javascript for the 
+# rendering instead of using prerendered bitmaps. Use this if you do not 
+# have LaTeX installed or if you want to formulas look prettier in the HTML 
+# output. When enabled you may also need to install MathJax separately and 
+# configure the path to it using the MATHJAX_RELPATH option.
+
+USE_MATHJAX            = NO
+
+# When MathJax is enabled you can set the default output format to be used for 
+# thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and 
+# SVG. The default value is HTML-CSS, which is slower, but has the best 
+# compatibility.
+
+MATHJAX_FORMAT         = HTML-CSS
+
+# When MathJax is enabled you need to specify the location relative to the 
+# HTML output directory using the MATHJAX_RELPATH option. The destination 
+# directory should contain the MathJax.js script. For instance, if the mathjax 
+# directory is located at the same level as the HTML output directory, then 
+# MATHJAX_RELPATH should be ../mathjax. The default value points to 
+# the MathJax Content Delivery Network so you can quickly see the result without 
+# installing MathJax.  However, it is strongly recommended to install a local 
+# copy of MathJax from http://www.mathjax.org before deployment.
+
+MATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension 
+# names that should be enabled during MathJax rendering.
+
+MATHJAX_EXTENSIONS     = 
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box 
+# for the HTML output. The underlying search engine uses javascript 
+# and DHTML and should work on any modern browser. Note that when using 
+# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets 
+# (GENERATE_DOCSET) there is already a search function so this one should 
+# typically be disabled. For large projects the javascript based search engine 
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE           = NO
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be 
+# implemented using a web server instead of a web client using Javascript. 
+# There are two flavours of web server based search depending on the 
+# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for 
+# searching and an index file used by the script. When EXTERNAL_SEARCH is 
+# enabled the indexing and searching needs to be provided by external tools. 
+# See the manual for details.
+
+SERVER_BASED_SEARCH    = NO
+
+# When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP 
+# script for searching. Instead the search results are written to an XML file 
+# which needs to be processed by an external indexer. Doxygen will invoke an 
+# external search engine pointed to by the SEARCHENGINE_URL option to obtain 
+# the search results. Doxygen ships with an example indexer (doxyindexer) and 
+# search engine (doxysearch.cgi) which are based on the open source search engine 
+# library Xapian. See the manual for configuration details.
+
+EXTERNAL_SEARCH        = NO
+
+# The SEARCHENGINE_URL should point to a search engine hosted by a web server 
+# which will returned the search results when EXTERNAL_SEARCH is enabled. 
+# Doxygen ships with an example search engine (doxysearch) which is based on 
+# the open source search engine library Xapian. See the manual for configuration 
+# details.
+
+SEARCHENGINE_URL       = 
+
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed 
+# search data is written to a file for indexing by an external tool. With the 
+# SEARCHDATA_FILE tag the name of this file can be specified.
+
+SEARCHDATA_FILE        = searchdata.xml
+
+# When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the 
+# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is 
+# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple 
+# projects and redirect the results back to the right project.
+
+EXTERNAL_SEARCH_ID     = 
+
+# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen 
+# projects other than the one defined by this configuration file, but that are 
+# all added to the same external search index. Each project needs to have a 
+# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id 
+# of to a relative location where the documentation can be found. 
+# The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ...
+
+EXTRA_SEARCH_MAPPINGS  = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# generate Latex output.
+
+GENERATE_LATEX         = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# invoked. If left blank `latex' will be used as the default command name. 
+# Note that when enabling USE_PDFLATEX this option is only used for 
+# generating bitmaps for formulas in the HTML output, but not in the 
+# Makefile that is written to the output directory.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
+# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
+# LaTeX documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used 
+# by the printer. Possible values are: a4, letter, legal and 
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         = 
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
+# the generated latex document. The header should contain everything until 
+# the first chapter. If it is left blank doxygen will generate a 
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           = 
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for 
+# the generated latex document. The footer should contain everything after 
+# the last chapter. If it is left blank doxygen will generate a 
+# standard footer. Notice: only use this tag if you know what you are doing!
+
+LATEX_FOOTER           = 
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
+# contain links (just like the HTML output) instead of page references 
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
+# plain latex in the generated Makefile. Set this option to YES to get a 
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
+# command to the generated LaTeX files. This will instruct LaTeX to keep 
+# running if errors occur, instead of asking the user for help. 
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
+# include the index chapters (such as File Index, Compound Index, etc.) 
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include 
+# source code with syntax highlighting in the LaTeX output. 
+# Note that which sources are shown also depends on other settings 
+# such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE      = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the 
+# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See 
+# http://en.wikipedia.org/wiki/BibTeX for more info.
+
+LATEX_BIB_STYLE        = plain
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
+# The RTF output is optimized for Word 97 and may not look very pretty with 
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
+# RTF documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
+# will contain hyperlink fields. The RTF file will 
+# contain links (just like the HTML output) instead of page references. 
+# This makes the output suitable for online browsing using WORD or other 
+# programs which support those fields. 
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load style sheet definitions from file. Syntax is similar to doxygen's 
+# config file, i.e. a series of assignments. You only have to provide 
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    = 
+
+# Set optional variables used in the generation of an rtf document. 
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to 
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
+# then it will generate one additional man file for each entity 
+# documented in the real man page(s). These additional files 
+# only source the real man page, but without them the man command 
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will 
+# generate an XML file that captures the structure of 
+# the code including all documentation.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_SCHEMA             = 
+
+# The XML_DTD tag can be used to specify an XML DTD, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_DTD                = 
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
+# dump the program listings (including syntax highlighting 
+# and cross-referencing information) to the XML output. Note that 
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
+# generate an AutoGen Definitions (see autogen.sf.net) file 
+# that captures the structure of the code including all 
+# documentation. Note that this feature is still experimental 
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
+# generate a Perl module file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
+# nicely formatted so it can be parsed by a human reader.  This is useful 
+# if you want to understand what is going on.  On the other hand, if this 
+# tag is set to NO the size of the Perl module output will be much smaller 
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file 
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
+# This is useful so different doxyrules.make files included by the same 
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
+# evaluate all C-preprocessor directives found in the sources and include 
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
+# names in the source code. If set to NO (the default) only conditional 
+# compilation will be performed. Macro expansion can be done in a controlled 
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
+# then the macro expansion is limited to the macros specified with the 
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# pointed to by INCLUDE_PATH will be searched when a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that 
+# contain include files that are not input files but should be processed by 
+# the preprocessor.
+
+INCLUDE_PATH           = 
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
+# patterns (like *.h and *.hpp) to filter out the header-files in the 
+# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# be used.
+
+INCLUDE_FILE_PATTERNS  = 
+
+# The PREDEFINED tag can be used to specify one or more macro names that 
+# are defined before the preprocessor is started (similar to the -D option of 
+# gcc). The argument of the tag is a list of macros of the form: name 
+# or name=definition (no spaces). If the definition and the = are 
+# omitted =1 is assumed. To prevent a macro definition from being 
+# undefined via #undef or recursively expanded use the := operator 
+# instead of the = operator.
+
+PREDEFINED             = 
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
+# this tag can be used to specify a list of macro names that should be expanded. 
+# The macro definition that is found in the sources will be used. 
+# Use the PREDEFINED tag if you want to use a different macro definition that 
+# overrules the definition found in the source code.
+
+EXPAND_AS_DEFINED      = 
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
+# doxygen's preprocessor will remove all references to function-like macros 
+# that are alone on a line, have an all uppercase name, and do not end with a 
+# semicolon, because these will confuse the parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. For each 
+# tag file the location of the external documentation should be added. The 
+# format of a tag file without this location is as follows: 
+#   TAGFILES = file1 file2 ... 
+# Adding location for the tag files is done as follows: 
+#   TAGFILES = file1=loc1 "file2 = loc2" ... 
+# where "loc1" and "loc2" can be relative or absolute paths 
+# or URLs. Note that each tag file must have a unique name (where the name does 
+# NOT include the path). If a tag file is not located in the directory in which 
+# doxygen is run, you must also specify the path to the tagfile here.
+
+TAGFILES               = 
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       = 
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
+# in the class index. If set to NO only the inherited external classes 
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
+# in the modules index. If set to NO, only the current project's groups will 
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script 
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 
+# or super classes. Setting the tag to NO turns the diagrams off. Note that 
+# this option also works with HAVE_DOT disabled, but it is recommended to 
+# install and use dot, since it yields more powerful graphs.
+
+CLASS_DIAGRAMS         = NO
+
+# You can define message sequence charts within doxygen comments using the \msc 
+# command. Doxygen will then run the mscgen tool (see 
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the 
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where 
+# the mscgen tool resides. If left empty the tool is assumed to be found in the 
+# default search path.
+
+MSCGEN_PATH            = 
+
+# If set to YES, the inheritance and collaboration graphs will hide 
+# inheritance and usage relations if the target is undocumented 
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
+# available from the path. This tool is part of Graphviz, a graph visualization 
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = NO
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is 
+# allowed to run in parallel. When set to 0 (the default) doxygen will 
+# base this on the number of processors available in the system. You can set it 
+# explicitly to a value larger than 0 to get control over the balance 
+# between CPU load and processing speed.
+
+DOT_NUM_THREADS        = 0
+
+# By default doxygen will use the Helvetica font for all dot files that 
+# doxygen generates. When you want a differently looking font you can specify 
+# the font name using DOT_FONTNAME. You need to make sure dot is able to find 
+# the font, which can be done by putting it in a standard location or by setting 
+# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the 
+# directory containing the font.
+
+DOT_FONTNAME           = Helvetica
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. 
+# The default size is 10pt.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the Helvetica font. 
+# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to 
+# set the path where dot can find it.
+
+DOT_FONTPATH           = 
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect inheritance relations. Setting this tag to YES will force the 
+# CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect implementation dependencies (inheritance, containment, and 
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
+# collaboration diagrams in a style similar to the OMG's Unified Modeling 
+# Language.
+
+UML_LOOK               = NO
+
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside 
+# the class node. If there are many fields or methods and many nodes the 
+# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS 
+# threshold limits the number of items for each type to make the size more 
+# managable. Set this to 0 for no limit. Note that the threshold may be 
+# exceeded by 50% before the limit is enforced.
+
+UML_LIMIT_NUM_FIELDS   = 10
+
+# If set to YES, the inheritance and collaboration graphs will show the 
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
+# tags are set to YES then doxygen will generate a graph for each documented 
+# file showing the direct and indirect include dependencies of the file with 
+# other documented files.
+
+INCLUDE_GRAPH          = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
+# documented header file showing the documented files that directly or 
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then 
+# doxygen will generate a call dependency graph for every global function 
+# or class method. Note that enabling this option will significantly increase 
+# the time of a run. So in most cases it will be better to enable call graphs 
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH             = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then 
+# doxygen will generate a caller dependency graph for every global function 
+# or class method. Note that enabling this option will significantly increase 
+# the time of a run. So in most cases it will be better to enable caller 
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES 
+# then doxygen will show the dependencies a directory has on other directories 
+# in a graphical way. The dependency relations are determined by the #include 
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# generated by dot. Possible values are svg, png, jpg, or gif. 
+# If left blank png will be used. If you choose svg you need to set 
+# HTML_FILE_EXTENSION to xhtml in order to make the SVG files 
+# visible in IE 9+ (other browsers do not have this requirement).
+
+DOT_IMAGE_FORMAT       = png
+
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to 
+# enable generation of interactive SVG images that allow zooming and panning. 
+# Note that this requires a modern browser other than Internet Explorer. 
+# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you 
+# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files 
+# visible. Older versions of IE do not have SVG support.
+
+INTERACTIVE_SVG        = NO
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH               = 
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that 
+# contain dot files that are included in the documentation (see the 
+# \dotfile command).
+
+DOTFILE_DIRS           = 
+
+# The MSCFILE_DIRS tag can be used to specify one or more directories that 
+# contain msc files that are included in the documentation (see the 
+# \mscfile command).
+
+MSCFILE_DIRS           = 
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of 
+# nodes that will be shown in the graph. If the number of nodes in a graph 
+# becomes larger than this value, doxygen will truncate the graph, which is 
+# visualized by representing a node as a red box. Note that doxygen if the 
+# number of direct children of the root node in a graph is already larger than 
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note 
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
+# graphs generated by dot. A depth value of 3 means that only nodes reachable 
+# from the root by following a path via at most 3 edges will be shown. Nodes 
+# that lay further from the root node will be omitted. Note that setting this 
+# option to 1 or 2 may greatly reduce the computation time needed for large 
+# code bases. Also note that the size of a graph can be further restricted by 
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 
+# background. This is disabled by default, because dot on Windows does not 
+# seem to support this out of the box. Warning: Depending on the platform used, 
+# enabling this option may lead to badly anti-aliased labels on the edges of 
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 
+# files in one run (i.e. multiple -o and -T options on the command line). This 
+# makes dot run faster, but since only newer versions of dot (>1.8.10) 
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS      = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
+# generate a legend page explaining the meaning of the various boxes and 
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
+# remove the intermediate dot files that are used to generate 
+# the various graphs.
+
+DOT_CLEANUP            = YES
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..5104d81
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,13 @@
+HEADERS := $(wildcard ../include/android/*.h)
+
+all: html jd
+
+html: $(HEADERS) Doxyfile
+	mkdir -p html
+	doxygen
+
+jd: $(HEADERS) Doxyfile header.jd
+	mkdir -p jd
+	HTML_HEADER=header.jd HTML_FOOTER=footer.jd HTML_OUTPUT=jd doxygen
+	for file in jd/*.html; do mv "$${file}" "$${file/.html/.jd}"; done
+	rm -f jd/index.jd
diff --git a/opengl/libs/GLES2/gl3ext_api.in b/docs/footer.jd
similarity index 100%
rename from opengl/libs/GLES2/gl3ext_api.in
rename to docs/footer.jd
diff --git a/docs/header.jd b/docs/header.jd
new file mode 100644
index 0000000..e50f41b
--- /dev/null
+++ b/docs/header.jd
@@ -0,0 +1,3 @@
+page.title=$title
+page.customHeadTag=<link rel="stylesheet" type="text/css" href="doxygen-dac.css">
+@jd:body
diff --git a/include/android/asset_manager.h b/include/android/asset_manager.h
index f5df46b..d654839 100644
--- a/include/android/asset_manager.h
+++ b/include/android/asset_manager.h
@@ -14,6 +14,14 @@
  * limitations under the License.
  */
 
+/**
+ * @addtogroup Asset
+ * @{
+ */
+
+/**
+ * @file asset_manager.h
+ */
 
 #ifndef ANDROID_ASSET_MANAGER_H
 #define ANDROID_ASSET_MANAGER_H
@@ -23,19 +31,49 @@
 #endif
 
 struct AAssetManager;
+/**
+ * {@link AAssetManager} provides access to an application's raw assets by
+ * creating {@link AAsset} objects.
+ *
+ * AAssetManager is a wrapper to the low-level native implementation
+ * of the java {@link AAssetManager}, a pointer can be obtained using
+ * AAssetManager_fromJava().
+ *
+ * The asset hierarchy may be examined like a filesystem, using
+ * {@link AAssetDir} objects to peruse a single directory.
+ *
+ * A native {@link AAssetManager} pointer may be shared across multiple threads.
+ */
 typedef struct AAssetManager AAssetManager;
 
 struct AAssetDir;
+/**
+ * {@link AAssetDir} provides access to a chunk of the asset hierarchy as if
+ * it were a single directory. The contents are populated by the
+ * {@link AAssetManager}.
+ *
+ * The list of files will be sorted in ascending order by ASCII value.
+ */
 typedef struct AAssetDir AAssetDir;
 
 struct AAsset;
+/**
+ * {@link AAsset} provides access to a read-only asset.
+ *
+ * {@link AAsset} objects are NOT thread-safe, and should not be shared across
+ * threads.
+ */
 typedef struct AAsset AAsset;
 
-/* Available modes for opening assets */
+/** Available access modes for opening assets with {@link AAssetManager_open} */
 enum {
+    /** No specific information about how data will be accessed. **/
     AASSET_MODE_UNKNOWN      = 0,
+    /** Read chunks, and seek forward and backward. */
     AASSET_MODE_RANDOM       = 1,
+    /** Read sequentially, with an occasional forward seek. */
     AASSET_MODE_STREAMING    = 2,
+    /** Caller plans to ask for a read-only buffer with all data. */
     AASSET_MODE_BUFFER       = 3
 };
 
@@ -173,3 +211,5 @@
 #endif
 
 #endif      // ANDROID_ASSET_MANAGER_H
+
+/** @} */
diff --git a/include/android/asset_manager_jni.h b/include/android/asset_manager_jni.h
index aec2d3c..dcee17e 100644
--- a/include/android/asset_manager_jni.h
+++ b/include/android/asset_manager_jni.h
@@ -14,6 +14,14 @@
  * limitations under the License.
  */
 
+/**
+ * @addtogroup Asset
+ * @{
+ */
+
+/**
+ * @file asset_manager_jni.h
+ */
 
 #ifndef ANDROID_ASSET_MANAGER_JNI_H
 #define ANDROID_ASSET_MANAGER_JNI_H
@@ -38,3 +46,5 @@
 #endif
 
 #endif      // ANDROID_ASSET_MANAGER_JNI_H
+
+/** @} */
diff --git a/include/android/bitmap.h b/include/android/bitmap.h
index 6e18763..261e64f 100644
--- a/include/android/bitmap.h
+++ b/include/android/bitmap.h
@@ -14,6 +14,15 @@
  * limitations under the License.
  */
 
+/**
+ * @addtogroup Bitmap
+ * @{
+ */
+
+/**
+ * @file bitmap.h
+ */
+
 #ifndef ANDROID_BITMAP_H
 #define ANDROID_BITMAP_H
 
@@ -24,33 +33,52 @@
 extern "C" {
 #endif
 
-#define ANDROID_BITMAP_RESULT_SUCCESS            0
-#define ANDROID_BITMAP_RESULT_BAD_PARAMETER     -1
-#define ANDROID_BITMAP_RESULT_JNI_EXCEPTION     -2
-#define ANDROID_BITMAP_RESULT_ALLOCATION_FAILED -3
+/** AndroidBitmap functions result code. */
+enum {
+    /** Operation was successful. */
+    ANDROID_BITMAP_RESULT_SUCCESS           = 0,
+    /** Bad parameter. */
+    ANDROID_BITMAP_RESULT_BAD_PARAMETER     = -1,
+    /** JNI exception occured. */
+    ANDROID_BITMAP_RESULT_JNI_EXCEPTION     = -2,
+    /** Allocation failed. */
+    ANDROID_BITMAP_RESULT_ALLOCATION_FAILED = -3,
+};
 
-/* Backward compatibility: this macro used to be misspelled. */
+/** Backward compatibility: this macro used to be misspelled. */
 #define ANDROID_BITMAP_RESUT_SUCCESS ANDROID_BITMAP_RESULT_SUCCESS
 
+/** Bitmap pixel format. */
 enum AndroidBitmapFormat {
+    /** No format. */
     ANDROID_BITMAP_FORMAT_NONE      = 0,
+    /** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Alpha: 8 bits. **/
     ANDROID_BITMAP_FORMAT_RGBA_8888 = 1,
+    /** Red: 5 bits, Green: 6 bits, Blue: 5 bits. **/
     ANDROID_BITMAP_FORMAT_RGB_565   = 4,
+    /** Red: 4 bits, Green: 4 bits, Blue: 4 bits, Alpha: 4 bits. **/
     ANDROID_BITMAP_FORMAT_RGBA_4444 = 7,
+    /** Deprecated. */
     ANDROID_BITMAP_FORMAT_A_8       = 8,
 };
 
+/** Bitmap info, see AndroidBitmap_getInfo(). */
 typedef struct {
+    /** The bitmap width in pixels. */
     uint32_t    width;
+    /** The bitmap height in pixels. */
     uint32_t    height;
+    /** The number of byte per row. */
     uint32_t    stride;
+    /** The bitmap pixel format. See {@link AndroidBitmapFormat} */
     int32_t     format;
+    /** Unused. */
     uint32_t    flags;      // 0 for now
 } AndroidBitmapInfo;
 
 /**
- * Given a java bitmap object, fill out the AndroidBitmap struct for it.
- * If the call fails, the info parameter will be ignored
+ * Given a java bitmap object, fill out the AndroidBitmapInfo struct for it.
+ * If the call fails, the info parameter will be ignored.
  */
 int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap,
                           AndroidBitmapInfo* info);
@@ -71,7 +99,7 @@
 int AndroidBitmap_lockPixels(JNIEnv* env, jobject jbitmap, void** addrPtr);
 
 /**
- * Call this to balanace a successful call to AndroidBitmap_lockPixels
+ * Call this to balance a successful call to AndroidBitmap_lockPixels.
  */
 int AndroidBitmap_unlockPixels(JNIEnv* env, jobject jbitmap);
 
@@ -80,3 +108,5 @@
 #endif
 
 #endif
+
+/** @} */
diff --git a/include/android/choreographer.h b/include/android/choreographer.h
new file mode 100644
index 0000000..02c83dc
--- /dev/null
+++ b/include/android/choreographer.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @addtogroup Choreographer
+ * @{
+ */
+
+/**
+ * @file choreographer.h
+ */
+
+#ifndef ANDROID_CHOREOGRAPHER_H
+#define ANDROID_CHOREOGRAPHER_H
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+struct AChoreographer;
+typedef struct AChoreographer AChoreographer;
+
+/**
+ * Prototype of the function that is called when a new frame is being rendered.
+ * It's passed the time that the frame is being rendered as nanoseconds in the
+ * CLOCK_MONOTONIC time base, as well as the data pointer provided by the
+ * application that registered a callback. All callbacks that run as part of
+ * rendering a frame will observe the same frame time, so it should be used
+ * whenever events need to be synchronized (e.g. animations).
+ */
+typedef void (*AChoreographer_frameCallback)(long frameTimeNanos, void* data);
+
+/**
+ * Get the AChoreographer instance for the current thread. This must be called
+ * on an ALooper thread.
+ */
+AChoreographer* AChoreographer_getInstance();
+
+/**
+ * Post a callback to be run on the next frame. The data pointer provided will
+ * be passed to the callback function when it's called.
+ */
+void AChoreographer_postFrameCallback(AChoreographer* choreographer,
+                AChoreographer_frameCallback callback, void* data);
+/**
+ * Post a callback to be run on the frame following the specified delay. The
+ * data pointer provided will be passed to the callback function when it's
+ * called.
+ */
+void AChoreographer_postFrameCallbackDelayed(AChoreographer* choreographer,
+                AChoreographer_frameCallback callback, void* data, long delayMillis);
+__END_DECLS
+
+#endif // ANDROID_CHOREOGRAPHER_H
+
+/** @} */
diff --git a/include/android/configuration.h b/include/android/configuration.h
index 6d8784d..81f71a9 100644
--- a/include/android/configuration.h
+++ b/include/android/configuration.h
@@ -14,6 +14,15 @@
  * limitations under the License.
  */
 
+/**
+ * @addtogroup Configuration
+ * @{
+ */
+
+/**
+ * @file configuration.h
+ */
+
 #ifndef ANDROID_CONFIGURATION_H
 #define ANDROID_CONFIGURATION_H
 
@@ -24,96 +33,400 @@
 #endif
 
 struct AConfiguration;
+/**
+ * {@link AConfiguration} is an opaque type used to get and set
+ * various subsystem configurations.
+ *
+ * A {@link AConfiguration} pointer can be obtained using:
+ * - AConfiguration_new()
+ * - AConfiguration_fromAssetManager()
+ */
 typedef struct AConfiguration AConfiguration;
 
+
+/**
+ * Define flags and constants for various subsystem configurations.
+ */
 enum {
+    /** Orientation: not specified. */
     ACONFIGURATION_ORIENTATION_ANY  = 0x0000,
+    /**
+     * Orientation: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#OrientationQualifier">port</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_ORIENTATION_PORT = 0x0001,
+    /**
+     * Orientation: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#OrientationQualifier">land</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_ORIENTATION_LAND = 0x0002,
+    /** @deprecated Not currently supported or used. */
     ACONFIGURATION_ORIENTATION_SQUARE = 0x0003,
 
+    /** Touchscreen: not specified. */
     ACONFIGURATION_TOUCHSCREEN_ANY  = 0x0000,
+    /**
+     * Touchscreen: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#TouchscreenQualifier">notouch</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_TOUCHSCREEN_NOTOUCH  = 0x0001,
+    /** @deprecated Not currently supported or used. */
     ACONFIGURATION_TOUCHSCREEN_STYLUS  = 0x0002,
+    /**
+     * Touchscreen: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#TouchscreenQualifier">finger</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_TOUCHSCREEN_FINGER  = 0x0003,
 
+    /** Density: default density. */
     ACONFIGURATION_DENSITY_DEFAULT = 0,
+    /**
+     * Density: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#DensityQualifier">ldpi</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_DENSITY_LOW = 120,
+    /**
+     * Density: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#DensityQualifier">mdpi</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_DENSITY_MEDIUM = 160,
+    /**
+     * Density: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#DensityQualifier">tvdpi</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_DENSITY_TV = 213,
+    /**
+     * Density: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#DensityQualifier">hdpi</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_DENSITY_HIGH = 240,
+    /**
+     * Density: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#DensityQualifier">xhdpi</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_DENSITY_XHIGH = 320,
+    /**
+     * Density: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#DensityQualifier">xxhdpi</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_DENSITY_XXHIGH = 480,
+    /**
+     * Density: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#DensityQualifier">xxxhdpi</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_DENSITY_XXXHIGH = 640,
+    /** Density: any density. */
+    ACONFIGURATION_DENSITY_ANY = 0xfffe,
+    /** Density: no density specified. */
     ACONFIGURATION_DENSITY_NONE = 0xffff,
 
+    /** Keyboard: not specified. */
     ACONFIGURATION_KEYBOARD_ANY  = 0x0000,
+    /**
+     * Keyboard: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#ImeQualifier">nokeys</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_KEYBOARD_NOKEYS  = 0x0001,
+    /**
+     * Keyboard: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#ImeQualifier">qwerty</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_KEYBOARD_QWERTY  = 0x0002,
+    /**
+     * Keyboard: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#ImeQualifier">12key</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_KEYBOARD_12KEY  = 0x0003,
 
+    /** Navigation: not specified. */
     ACONFIGURATION_NAVIGATION_ANY  = 0x0000,
+    /**
+     * Navigation: value corresponding to the
+     * <a href="@@dacRoot/guide/topics/resources/providing-resources.html#NavigationQualifier">nonav</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_NAVIGATION_NONAV  = 0x0001,
+    /**
+     * Navigation: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#NavigationQualifier">dpad</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_NAVIGATION_DPAD  = 0x0002,
+    /**
+     * Navigation: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#NavigationQualifier">trackball</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_NAVIGATION_TRACKBALL  = 0x0003,
+    /**
+     * Navigation: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#NavigationQualifier">wheel</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_NAVIGATION_WHEEL  = 0x0004,
 
+    /** Keyboard availability: not specified. */
     ACONFIGURATION_KEYSHIDDEN_ANY = 0x0000,
+    /**
+     * Keyboard availability: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#KeyboardAvailQualifier">keysexposed</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_KEYSHIDDEN_NO = 0x0001,
+    /**
+     * Keyboard availability: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#KeyboardAvailQualifier">keyshidden</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_KEYSHIDDEN_YES = 0x0002,
+    /**
+     * Keyboard availability: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#KeyboardAvailQualifier">keyssoft</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_KEYSHIDDEN_SOFT = 0x0003,
 
+    /** Navigation availability: not specified. */
     ACONFIGURATION_NAVHIDDEN_ANY = 0x0000,
+    /**
+     * Navigation availability: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#NavAvailQualifier">navexposed</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_NAVHIDDEN_NO = 0x0001,
+    /**
+     * Navigation availability: value corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#NavAvailQualifier">navhidden</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_NAVHIDDEN_YES = 0x0002,
 
+    /** Screen size: not specified. */
     ACONFIGURATION_SCREENSIZE_ANY  = 0x00,
+    /**
+     * Screen size: value indicating the screen is at least
+     * approximately 320x426 dp units, corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#ScreenSizeQualifier">small</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_SCREENSIZE_SMALL = 0x01,
+    /**
+     * Screen size: value indicating the screen is at least
+     * approximately 320x470 dp units, corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#ScreenSizeQualifier">normal</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_SCREENSIZE_NORMAL = 0x02,
+    /**
+     * Screen size: value indicating the screen is at least
+     * approximately 480x640 dp units, corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#ScreenSizeQualifier">large</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_SCREENSIZE_LARGE = 0x03,
+    /**
+     * Screen size: value indicating the screen is at least
+     * approximately 720x960 dp units, corresponding to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#ScreenSizeQualifier">xlarge</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_SCREENSIZE_XLARGE = 0x04,
 
+    /** Screen layout: not specified. */
     ACONFIGURATION_SCREENLONG_ANY = 0x00,
+    /**
+     * Screen layout: value that corresponds to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#ScreenAspectQualifier">notlong</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_SCREENLONG_NO = 0x1,
+    /**
+     * Screen layout: value that corresponds to the
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#ScreenAspectQualifier">long</a>
+     * resource qualifier.
+     */
     ACONFIGURATION_SCREENLONG_YES = 0x2,
 
-    ACONFIGURATION_UI_MODE_TYPE_ANY = 0x00,
-    ACONFIGURATION_UI_MODE_TYPE_NORMAL = 0x01,
-    ACONFIGURATION_UI_MODE_TYPE_DESK = 0x02,
-    ACONFIGURATION_UI_MODE_TYPE_CAR = 0x03,
-    ACONFIGURATION_UI_MODE_TYPE_TELEVISION = 0x04,
-    ACONFIGURATION_UI_MODE_TYPE_APPLIANCE = 0x05,
+    ACONFIGURATION_SCREENROUND_ANY = 0x00,
+    ACONFIGURATION_SCREENROUND_NO = 0x1,
+    ACONFIGURATION_SCREENROUND_YES = 0x2,
 
+    /** UI mode: not specified. */
+    ACONFIGURATION_UI_MODE_TYPE_ANY = 0x00,
+    /**
+     * UI mode: value that corresponds to
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#UiModeQualifier">no
+     * UI mode type</a> resource qualifier specified.
+     */
+    ACONFIGURATION_UI_MODE_TYPE_NORMAL = 0x01,
+    /**
+     * UI mode: value that corresponds to
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#UiModeQualifier">desk</a> resource qualifier specified.
+     */
+    ACONFIGURATION_UI_MODE_TYPE_DESK = 0x02,
+    /**
+     * UI mode: value that corresponds to
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#UiModeQualifier">car</a> resource qualifier specified.
+     */
+    ACONFIGURATION_UI_MODE_TYPE_CAR = 0x03,
+    /**
+     * UI mode: value that corresponds to
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#UiModeQualifier">television</a> resource qualifier specified.
+     */
+    ACONFIGURATION_UI_MODE_TYPE_TELEVISION = 0x04,
+    /**
+     * UI mode: value that corresponds to
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#UiModeQualifier">appliance</a> resource qualifier specified.
+     */
+    ACONFIGURATION_UI_MODE_TYPE_APPLIANCE = 0x05,
+    /**
+     * UI mode: value that corresponds to
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#UiModeQualifier">watch</a> resource qualifier specified.
+     */
+    ACONFIGURATION_UI_MODE_TYPE_WATCH = 0x06,
+
+    /** UI night mode: not specified.*/
     ACONFIGURATION_UI_MODE_NIGHT_ANY = 0x00,
+    /**
+     * UI night mode: value that corresponds to
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#NightQualifier">notnight</a> resource qualifier specified.
+     */
     ACONFIGURATION_UI_MODE_NIGHT_NO = 0x1,
+    /**
+     * UI night mode: value that corresponds to
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#NightQualifier">night</a> resource qualifier specified.
+     */
     ACONFIGURATION_UI_MODE_NIGHT_YES = 0x2,
 
+    /** Screen width DPI: not specified. */
     ACONFIGURATION_SCREEN_WIDTH_DP_ANY = 0x0000,
 
+    /** Screen height DPI: not specified. */
     ACONFIGURATION_SCREEN_HEIGHT_DP_ANY = 0x0000,
 
+    /** Smallest screen width DPI: not specified.*/
     ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY = 0x0000,
 
+    /** Layout direction: not specified. */
     ACONFIGURATION_LAYOUTDIR_ANY  = 0x00,
+    /**
+     * Layout direction: value that corresponds to
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#LayoutDirectionQualifier">ldltr</a> resource qualifier specified.
+     */
     ACONFIGURATION_LAYOUTDIR_LTR  = 0x01,
+    /**
+     * Layout direction: value that corresponds to
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#LayoutDirectionQualifier">ldrtl</a> resource qualifier specified.
+     */
     ACONFIGURATION_LAYOUTDIR_RTL  = 0x02,
 
+    /**
+     * Bit mask for
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#MccQualifier">mcc</a>
+     * configuration.
+     */
     ACONFIGURATION_MCC = 0x0001,
+    /**
+     * Bit mask for
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#MccQualifier">mnc</a>
+     * configuration.
+     */
     ACONFIGURATION_MNC = 0x0002,
+    /**
+     * Bit mask for
+     * <a href="{@docRoot}guide/topics/resources/providing-resources.html#LocaleQualifier">locale</a>
+     * configuration.
+     */
     ACONFIGURATION_LOCALE = 0x0004,
+    /**
+     * Bit mask for
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#TouchscreenQualifier">touchscreen</a>
+     * configuration.
+     */
     ACONFIGURATION_TOUCHSCREEN = 0x0008,
+    /**
+     * Bit mask for
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#ImeQualifier">keyboard</a>
+     * configuration.
+     */
     ACONFIGURATION_KEYBOARD = 0x0010,
+    /**
+     * Bit mask for
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#KeyboardAvailQualifier">keyboardHidden</a>
+     * configuration.
+     */
     ACONFIGURATION_KEYBOARD_HIDDEN = 0x0020,
+    /**
+     * Bit mask for
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#NavigationQualifier">navigation</a>
+     * configuration.
+     */
     ACONFIGURATION_NAVIGATION = 0x0040,
+    /**
+     * Bit mask for
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#OrientationQualifier">orientation</a>
+     * configuration.
+     */
     ACONFIGURATION_ORIENTATION = 0x0080,
+    /**
+     * Bit mask for
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#DensityQualifier">density</a>
+     * configuration.
+     */
     ACONFIGURATION_DENSITY = 0x0100,
+    /**
+     * Bit mask for
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#ScreenSizeQualifier">screen size</a>
+     * configuration.
+     */
     ACONFIGURATION_SCREEN_SIZE = 0x0200,
+    /**
+     * Bit mask for
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#VersionQualifier">platform version</a>
+     * configuration.
+     */
     ACONFIGURATION_VERSION = 0x0400,
+    /**
+     * Bit mask for screen layout configuration.
+     */
     ACONFIGURATION_SCREEN_LAYOUT = 0x0800,
+    /**
+     * Bit mask for
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#UiModeQualifier">ui mode</a>
+     * configuration.
+     */
     ACONFIGURATION_UI_MODE = 0x1000,
+    /**
+     * Bit mask for
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#SmallestScreenWidthQualifier">smallest screen width</a>
+     * configuration.
+     */
     ACONFIGURATION_SMALLEST_SCREEN_SIZE = 0x2000,
+    /**
+     * Bit mask for
+     * <a href="@dacRoot/guide/topics/resources/providing-resources.html#LayoutDirectionQualifier">layout direction</a>
+     * configuration.
+     */
     ACONFIGURATION_LAYOUTDIR = 0x4000,
-
+    ACONFIGURATION_SCREEN_ROUND = 0x8000,
+    /**
+     * Constant used to to represent MNC (Mobile Network Code) zero.
+     * 0 cannot be used, since it is used to represent an undefined MNC.
+     */
     ACONFIGURATION_MNC_ZERO = 0xffff,
 };
 
@@ -130,7 +443,7 @@
 
 /**
  * Create and return a new AConfiguration based on the current configuration in
- * use in the given AssetManager.
+ * use in the given {@link AAssetManager}.
  */
 void AConfiguration_fromAssetManager(AConfiguration* out, AAssetManager* am);
 
@@ -286,6 +599,16 @@
 void AConfiguration_setScreenLong(AConfiguration* config, int32_t screenLong);
 
 /**
+ * Return the current ACONFIGURATION_SCREENROUND_* set in the configuration.
+ */
+int32_t AConfiguration_getScreenRound(AConfiguration* config);
+
+/**
+ * Set the current screen round in the configuration.
+ */
+void AConfiguration_setScreenRound(AConfiguration* config, int32_t screenRound);
+
+/**
  * Return the current ACONFIGURATION_UI_MODE_TYPE_* set in the configuration.
  */
 int32_t AConfiguration_getUiModeType(AConfiguration* config);
@@ -381,3 +704,5 @@
 #endif
 
 #endif // ANDROID_CONFIGURATION_H
+
+/** @} */
diff --git a/include/android/input.h b/include/android/input.h
index a660761..5ab4e29 100644
--- a/include/android/input.h
+++ b/include/android/input.h
@@ -14,6 +14,15 @@
  * limitations under the License.
  */
 
+/**
+ * @addtogroup Input
+ * @{
+ */
+
+/**
+ * @file input.h
+ */
+
 #ifndef _ANDROID_INPUT_H
 #define _ANDROID_INPUT_H
 
@@ -49,247 +58,271 @@
 extern "C" {
 #endif
 
-/*
+/**
  * Key states (may be returned by queries about the current state of a
  * particular key code, scan code or switch).
  */
 enum {
-    /* The key state is unknown or the requested key itself is not supported. */
+    /** The key state is unknown or the requested key itself is not supported. */
     AKEY_STATE_UNKNOWN = -1,
 
-    /* The key is up. */
+    /** The key is up. */
     AKEY_STATE_UP = 0,
 
-    /* The key is down. */
+    /** The key is down. */
     AKEY_STATE_DOWN = 1,
 
-    /* The key is down but is a virtual key press that is being emulated by the system. */
+    /** The key is down but is a virtual key press that is being emulated by the system. */
     AKEY_STATE_VIRTUAL = 2
 };
 
-/*
+/**
  * Meta key / modifer state.
  */
 enum {
-    /* No meta keys are pressed. */
+    /** No meta keys are pressed. */
     AMETA_NONE = 0,
 
-    /* This mask is used to check whether one of the ALT meta keys is pressed. */
+    /** This mask is used to check whether one of the ALT meta keys is pressed. */
     AMETA_ALT_ON = 0x02,
 
-    /* This mask is used to check whether the left ALT meta key is pressed. */
+    /** This mask is used to check whether the left ALT meta key is pressed. */
     AMETA_ALT_LEFT_ON = 0x10,
 
-    /* This mask is used to check whether the right ALT meta key is pressed. */
+    /** This mask is used to check whether the right ALT meta key is pressed. */
     AMETA_ALT_RIGHT_ON = 0x20,
 
-    /* This mask is used to check whether one of the SHIFT meta keys is pressed. */
+    /** This mask is used to check whether one of the SHIFT meta keys is pressed. */
     AMETA_SHIFT_ON = 0x01,
 
-    /* This mask is used to check whether the left SHIFT meta key is pressed. */
+    /** This mask is used to check whether the left SHIFT meta key is pressed. */
     AMETA_SHIFT_LEFT_ON = 0x40,
 
-    /* This mask is used to check whether the right SHIFT meta key is pressed. */
+    /** This mask is used to check whether the right SHIFT meta key is pressed. */
     AMETA_SHIFT_RIGHT_ON = 0x80,
 
-    /* This mask is used to check whether the SYM meta key is pressed. */
+    /** This mask is used to check whether the SYM meta key is pressed. */
     AMETA_SYM_ON = 0x04,
 
-    /* This mask is used to check whether the FUNCTION meta key is pressed. */
+    /** This mask is used to check whether the FUNCTION meta key is pressed. */
     AMETA_FUNCTION_ON = 0x08,
 
-    /* This mask is used to check whether one of the CTRL meta keys is pressed. */
+    /** This mask is used to check whether one of the CTRL meta keys is pressed. */
     AMETA_CTRL_ON = 0x1000,
 
-    /* This mask is used to check whether the left CTRL meta key is pressed. */
+    /** This mask is used to check whether the left CTRL meta key is pressed. */
     AMETA_CTRL_LEFT_ON = 0x2000,
 
-    /* This mask is used to check whether the right CTRL meta key is pressed. */
+    /** This mask is used to check whether the right CTRL meta key is pressed. */
     AMETA_CTRL_RIGHT_ON = 0x4000,
 
-    /* This mask is used to check whether one of the META meta keys is pressed. */
+    /** This mask is used to check whether one of the META meta keys is pressed. */
     AMETA_META_ON = 0x10000,
 
-    /* This mask is used to check whether the left META meta key is pressed. */
+    /** This mask is used to check whether the left META meta key is pressed. */
     AMETA_META_LEFT_ON = 0x20000,
 
-    /* This mask is used to check whether the right META meta key is pressed. */
+    /** This mask is used to check whether the right META meta key is pressed. */
     AMETA_META_RIGHT_ON = 0x40000,
 
-    /* This mask is used to check whether the CAPS LOCK meta key is on. */
+    /** This mask is used to check whether the CAPS LOCK meta key is on. */
     AMETA_CAPS_LOCK_ON = 0x100000,
 
-    /* This mask is used to check whether the NUM LOCK meta key is on. */
+    /** This mask is used to check whether the NUM LOCK meta key is on. */
     AMETA_NUM_LOCK_ON = 0x200000,
 
-    /* This mask is used to check whether the SCROLL LOCK meta key is on. */
+    /** This mask is used to check whether the SCROLL LOCK meta key is on. */
     AMETA_SCROLL_LOCK_ON = 0x400000,
 };
 
-/*
+struct AInputEvent;
+/**
  * Input events.
  *
  * Input events are opaque structures.  Use the provided accessors functions to
  * read their properties.
  */
-struct AInputEvent;
 typedef struct AInputEvent AInputEvent;
 
-/*
+/**
  * Input event types.
  */
 enum {
-    /* Indicates that the input event is a key event. */
+    /** Indicates that the input event is a key event. */
     AINPUT_EVENT_TYPE_KEY = 1,
 
-    /* Indicates that the input event is a motion event. */
+    /** Indicates that the input event is a motion event. */
     AINPUT_EVENT_TYPE_MOTION = 2
 };
 
-/*
+/**
  * Key event actions.
  */
 enum {
-    /* The key has been pressed down. */
+    /** The key has been pressed down. */
     AKEY_EVENT_ACTION_DOWN = 0,
 
-    /* The key has been released. */
+    /** The key has been released. */
     AKEY_EVENT_ACTION_UP = 1,
 
-    /* Multiple duplicate key events have occurred in a row, or a complex string is
-     * being delivered.  The repeat_count property of the key event contains the number
-     * of times the given key code should be executed.
+    /**
+     * Multiple duplicate key events have occurred in a row, or a
+     * complex string is being delivered.  The repeat_count property
+     * of the key event contains the number of times the given key
+     * code should be executed.
      */
     AKEY_EVENT_ACTION_MULTIPLE = 2
 };
 
-/*
+/**
  * Key event flags.
  */
 enum {
-    /* This mask is set if the device woke because of this key event. */
+    /** This mask is set if the device woke because of this key event. */
     AKEY_EVENT_FLAG_WOKE_HERE = 0x1,
 
-    /* This mask is set if the key event was generated by a software keyboard. */
+    /** This mask is set if the key event was generated by a software keyboard. */
     AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
 
-    /* This mask is set if we don't want the key event to cause us to leave touch mode. */
+    /** This mask is set if we don't want the key event to cause us to leave touch mode. */
     AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
 
-    /* This mask is set if an event was known to come from a trusted part
-     * of the system.  That is, the event is known to come from the user,
-     * and could not have been spoofed by a third party component. */
+    /**
+     * This mask is set if an event was known to come from a trusted
+     * part of the system.  That is, the event is known to come from
+     * the user, and could not have been spoofed by a third party
+     * component.
+     */
     AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
 
-    /* This mask is used for compatibility, to identify enter keys that are
+    /**
+     * This mask is used for compatibility, to identify enter keys that are
      * coming from an IME whose enter key has been auto-labelled "next" or
      * "done".  This allows TextView to dispatch these as normal enter keys
      * for old applications, but still do the appropriate action when
-     * receiving them. */
+     * receiving them.
+     */
     AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
 
-    /* When associated with up key events, this indicates that the key press
+    /**
+     * When associated with up key events, this indicates that the key press
      * has been canceled.  Typically this is used with virtual touch screen
      * keys, where the user can slide from the virtual key area on to the
      * display: in that case, the application will receive a canceled up
      * event and should not perform the action normally associated with the
      * key.  Note that for this to work, the application can not perform an
      * action for a key until it receives an up or the long press timeout has
-     * expired. */
+     * expired.
+     */
     AKEY_EVENT_FLAG_CANCELED = 0x20,
 
-    /* This key event was generated by a virtual (on-screen) hard key area.
+    /**
+     * This key event was generated by a virtual (on-screen) hard key area.
      * Typically this is an area of the touchscreen, outside of the regular
-     * display, dedicated to "hardware" buttons. */
+     * display, dedicated to "hardware" buttons.
+     */
     AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
 
-    /* This flag is set for the first key repeat that occurs after the
-     * long press timeout. */
+    /**
+     * This flag is set for the first key repeat that occurs after the
+     * long press timeout.
+     */
     AKEY_EVENT_FLAG_LONG_PRESS = 0x80,
 
-    /* Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long
-     * press action was executed while it was down. */
+    /**
+     * Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long
+     * press action was executed while it was down.
+     */
     AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
 
-    /* Set for AKEY_EVENT_ACTION_UP when this event's key code is still being
+    /**
+     * Set for AKEY_EVENT_ACTION_UP when this event's key code is still being
      * tracked from its initial down.  That is, somebody requested that tracking
      * started on the key down and a long press has not caused
-     * the tracking to be canceled. */
+     * the tracking to be canceled.
+     */
     AKEY_EVENT_FLAG_TRACKING = 0x200,
 
-    /* Set when a key event has been synthesized to implement default behavior
+    /**
+     * Set when a key event has been synthesized to implement default behavior
      * for an event that the application did not handle.
      * Fallback key events are generated by unhandled trackball motions
      * (to emulate a directional keypad) and by certain unhandled key presses
      * that are declared in the key map (such as special function numeric keypad
-     * keys when numlock is off). */
+     * keys when numlock is off).
+     */
     AKEY_EVENT_FLAG_FALLBACK = 0x400,
 };
 
-/*
- * Motion event actions.
- */
-
-/* Bit shift for the action bits holding the pointer index as
+/**
+ * Bit shift for the action bits holding the pointer index as
  * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
  */
 #define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
 
+/** Motion event actions */
 enum {
-    /* Bit mask of the parts of the action code that are the action itself.
-     */
+    /** Bit mask of the parts of the action code that are the action itself. */
     AMOTION_EVENT_ACTION_MASK = 0xff,
 
-    /* Bits in the action code that represent a pointer index, used with
+    /**
+     * Bits in the action code that represent a pointer index, used with
      * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP.  Shifting
      * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
      * index where the data for the pointer going up or down can be found.
      */
     AMOTION_EVENT_ACTION_POINTER_INDEX_MASK  = 0xff00,
 
-    /* A pressed gesture has started, the motion contains the initial starting location.
-     */
+    /** A pressed gesture has started, the motion contains the initial starting location. */
     AMOTION_EVENT_ACTION_DOWN = 0,
 
-    /* A pressed gesture has finished, the motion contains the final release location
+    /**
+     * A pressed gesture has finished, the motion contains the final release location
      * as well as any intermediate points since the last down or move event.
      */
     AMOTION_EVENT_ACTION_UP = 1,
 
-    /* A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and
+    /**
+     * A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and
      * AMOTION_EVENT_ACTION_UP).  The motion contains the most recent point, as well as
      * any intermediate points since the last down or move event.
      */
     AMOTION_EVENT_ACTION_MOVE = 2,
 
-    /* The current gesture has been aborted.
+    /**
+     * The current gesture has been aborted.
      * You will not receive any more points in it.  You should treat this as
      * an up event, but not perform any action that you normally would.
      */
     AMOTION_EVENT_ACTION_CANCEL = 3,
 
-    /* A movement has happened outside of the normal bounds of the UI element.
+    /**
+     * A movement has happened outside of the normal bounds of the UI element.
      * This does not provide a full gesture, but only the initial location of the movement/touch.
      */
     AMOTION_EVENT_ACTION_OUTSIDE = 4,
 
-    /* A non-primary pointer has gone down.
+    /**
+     * A non-primary pointer has gone down.
      * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
      */
     AMOTION_EVENT_ACTION_POINTER_DOWN = 5,
 
-    /* A non-primary pointer has gone up.
+    /**
+     * A non-primary pointer has gone up.
      * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
      */
     AMOTION_EVENT_ACTION_POINTER_UP = 6,
 
-    /* A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE).
+    /**
+     * A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE).
      * The motion contains the most recent point, as well as any intermediate points since
      * the last hover move event.
      */
     AMOTION_EVENT_ACTION_HOVER_MOVE = 7,
 
-    /* The motion event contains relative vertical and/or horizontal scroll offsets.
+    /**
+     * The motion event contains relative vertical and/or horizontal scroll offsets.
      * Use getAxisValue to retrieve the information from AMOTION_EVENT_AXIS_VSCROLL
      * and AMOTION_EVENT_AXIS_HSCROLL.
      * The pointer may or may not be down when this event is dispatched.
@@ -298,20 +331,25 @@
      */
     AMOTION_EVENT_ACTION_SCROLL = 8,
 
-    /* The pointer is not down but has entered the boundaries of a window or view.
-     */
+    /** The pointer is not down but has entered the boundaries of a window or view. */
     AMOTION_EVENT_ACTION_HOVER_ENTER = 9,
 
-    /* The pointer is not down but has exited the boundaries of a window or view.
-     */
+    /** The pointer is not down but has exited the boundaries of a window or view. */
     AMOTION_EVENT_ACTION_HOVER_EXIT = 10,
+
+    /* One or more buttons have been pressed. */
+    AMOTION_EVENT_ACTION_BUTTON_PRESS = 11,
+
+    /* One or more buttons have been released. */
+    AMOTION_EVENT_ACTION_BUTTON_RELEASE = 12,
 };
 
-/*
+/**
  * Motion event flags.
  */
 enum {
-    /* This flag indicates that the window that received this motion event is partly
+    /**
+     * This flag indicates that the window that received this motion event is partly
      * or wholly obscured by another visible window above it.  This flag is set to true
      * even if the event did not directly pass through the obscured area.
      * A security sensitive application can check this flag to identify situations in which
@@ -323,170 +361,513 @@
     AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1,
 };
 
-/*
+/**
  * Motion event edge touch flags.
  */
 enum {
-    /* No edges intersected */
+    /** No edges intersected. */
     AMOTION_EVENT_EDGE_FLAG_NONE = 0,
 
-    /* Flag indicating the motion event intersected the top edge of the screen. */
+    /** Flag indicating the motion event intersected the top edge of the screen. */
     AMOTION_EVENT_EDGE_FLAG_TOP = 0x01,
 
-    /* Flag indicating the motion event intersected the bottom edge of the screen. */
+    /** Flag indicating the motion event intersected the bottom edge of the screen. */
     AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
 
-    /* Flag indicating the motion event intersected the left edge of the screen. */
+    /** Flag indicating the motion event intersected the left edge of the screen. */
     AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
 
-    /* Flag indicating the motion event intersected the right edge of the screen. */
+    /** Flag indicating the motion event intersected the right edge of the screen. */
     AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
 };
 
-/*
+/**
  * Constants that identify each individual axis of a motion event.
- * Refer to the documentation on the MotionEvent class for descriptions of each axis.
+ * @anchor AMOTION_EVENT_AXIS
  */
 enum {
+    /**
+     * Axis constant: X axis of a motion event.
+     *
+     * - For a touch screen, reports the absolute X screen position of the center of
+     * the touch contact area.  The units are display pixels.
+     * - For a touch pad, reports the absolute X surface position of the center of the touch
+     * contact area. The units are device-dependent.
+     * - For a mouse, reports the absolute X screen position of the mouse pointer.
+     * The units are display pixels.
+     * - For a trackball, reports the relative horizontal displacement of the trackball.
+     * The value is normalized to a range from -1.0 (left) to 1.0 (right).
+     * - For a joystick, reports the absolute X position of the joystick.
+     * The value is normalized to a range from -1.0 (left) to 1.0 (right).
+     */
     AMOTION_EVENT_AXIS_X = 0,
+    /**
+     * Axis constant: Y axis of a motion event.
+     *
+     * - For a touch screen, reports the absolute Y screen position of the center of
+     * the touch contact area.  The units are display pixels.
+     * - For a touch pad, reports the absolute Y surface position of the center of the touch
+     * contact area. The units are device-dependent.
+     * - For a mouse, reports the absolute Y screen position of the mouse pointer.
+     * The units are display pixels.
+     * - For a trackball, reports the relative vertical displacement of the trackball.
+     * The value is normalized to a range from -1.0 (up) to 1.0 (down).
+     * - For a joystick, reports the absolute Y position of the joystick.
+     * The value is normalized to a range from -1.0 (up or far) to 1.0 (down or near).
+     */
     AMOTION_EVENT_AXIS_Y = 1,
+    /**
+     * Axis constant: Pressure axis of a motion event.
+     *
+     * - For a touch screen or touch pad, reports the approximate pressure applied to the surface
+     * by a finger or other tool.  The value is normalized to a range from
+     * 0 (no pressure at all) to 1 (normal pressure), although values higher than 1
+     * may be generated depending on the calibration of the input device.
+     * - For a trackball, the value is set to 1 if the trackball button is pressed
+     * or 0 otherwise.
+     * - For a mouse, the value is set to 1 if the primary mouse button is pressed
+     * or 0 otherwise.
+     */
     AMOTION_EVENT_AXIS_PRESSURE = 2,
+    /**
+     * Axis constant: Size axis of a motion event.
+     *
+     * - For a touch screen or touch pad, reports the approximate size of the contact area in
+     * relation to the maximum detectable size for the device.  The value is normalized
+     * to a range from 0 (smallest detectable size) to 1 (largest detectable size),
+     * although it is not a linear scale. This value is of limited use.
+     * To obtain calibrated size information, see
+     * {@link AMOTION_EVENT_AXIS_TOUCH_MAJOR} or {@link AMOTION_EVENT_AXIS_TOOL_MAJOR}.
+     */
     AMOTION_EVENT_AXIS_SIZE = 3,
+    /**
+     * Axis constant: TouchMajor axis of a motion event.
+     *
+     * - For a touch screen, reports the length of the major axis of an ellipse that
+     * represents the touch area at the point of contact.
+     * The units are display pixels.
+     * - For a touch pad, reports the length of the major axis of an ellipse that
+     * represents the touch area at the point of contact.
+     * The units are device-dependent.
+     */
     AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4,
+    /**
+     * Axis constant: TouchMinor axis of a motion event.
+     *
+     * - For a touch screen, reports the length of the minor axis of an ellipse that
+     * represents the touch area at the point of contact.
+     * The units are display pixels.
+     * - For a touch pad, reports the length of the minor axis of an ellipse that
+     * represents the touch area at the point of contact.
+     * The units are device-dependent.
+     *
+     * When the touch is circular, the major and minor axis lengths will be equal to one another.
+     */
     AMOTION_EVENT_AXIS_TOUCH_MINOR = 5,
+    /**
+     * Axis constant: ToolMajor axis of a motion event.
+     *
+     * - For a touch screen, reports the length of the major axis of an ellipse that
+     * represents the size of the approaching finger or tool used to make contact.
+     * - For a touch pad, reports the length of the major axis of an ellipse that
+     * represents the size of the approaching finger or tool used to make contact.
+     * The units are device-dependent.
+     *
+     * When the touch is circular, the major and minor axis lengths will be equal to one another.
+     *
+     * The tool size may be larger than the touch size since the tool may not be fully
+     * in contact with the touch sensor.
+     */
     AMOTION_EVENT_AXIS_TOOL_MAJOR = 6,
+    /**
+     * Axis constant: ToolMinor axis of a motion event.
+     *
+     * - For a touch screen, reports the length of the minor axis of an ellipse that
+     * represents the size of the approaching finger or tool used to make contact.
+     * - For a touch pad, reports the length of the minor axis of an ellipse that
+     * represents the size of the approaching finger or tool used to make contact.
+     * The units are device-dependent.
+     *
+     * When the touch is circular, the major and minor axis lengths will be equal to one another.
+     *
+     * The tool size may be larger than the touch size since the tool may not be fully
+     * in contact with the touch sensor.
+     */
     AMOTION_EVENT_AXIS_TOOL_MINOR = 7,
+    /**
+     * Axis constant: Orientation axis of a motion event.
+     *
+     * - For a touch screen or touch pad, reports the orientation of the finger
+     * or tool in radians relative to the vertical plane of the device.
+     * An angle of 0 radians indicates that the major axis of contact is oriented
+     * upwards, is perfectly circular or is of unknown orientation.  A positive angle
+     * indicates that the major axis of contact is oriented to the right.  A negative angle
+     * indicates that the major axis of contact is oriented to the left.
+     * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
+     * (finger pointing fully right).
+     * - For a stylus, the orientation indicates the direction in which the stylus
+     * is pointing in relation to the vertical axis of the current orientation of the screen.
+     * The range is from -PI radians to PI radians, where 0 is pointing up,
+     * -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians
+     * is pointing right.  See also {@link AMOTION_EVENT_AXIS_TILT}.
+     */
     AMOTION_EVENT_AXIS_ORIENTATION = 8,
+    /**
+     * Axis constant: Vertical Scroll axis of a motion event.
+     *
+     * - For a mouse, reports the relative movement of the vertical scroll wheel.
+     * The value is normalized to a range from -1.0 (down) to 1.0 (up).
+     *
+     * This axis should be used to scroll views vertically.
+     */
     AMOTION_EVENT_AXIS_VSCROLL = 9,
+    /**
+     * Axis constant: Horizontal Scroll axis of a motion event.
+     *
+     * - For a mouse, reports the relative movement of the horizontal scroll wheel.
+     * The value is normalized to a range from -1.0 (left) to 1.0 (right).
+     *
+     * This axis should be used to scroll views horizontally.
+     */
     AMOTION_EVENT_AXIS_HSCROLL = 10,
+    /**
+     * Axis constant: Z axis of a motion event.
+     *
+     * - For a joystick, reports the absolute Z position of the joystick.
+     * The value is normalized to a range from -1.0 (high) to 1.0 (low).
+     * <em>On game pads with two analog joysticks, this axis is often reinterpreted
+     * to report the absolute X position of the second joystick instead.</em>
+     */
     AMOTION_EVENT_AXIS_Z = 11,
+    /**
+     * Axis constant: X Rotation axis of a motion event.
+     *
+     * - For a joystick, reports the absolute rotation angle about the X axis.
+     * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
+     */
     AMOTION_EVENT_AXIS_RX = 12,
+    /**
+     * Axis constant: Y Rotation axis of a motion event.
+     *
+     * - For a joystick, reports the absolute rotation angle about the Y axis.
+     * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
+     */
     AMOTION_EVENT_AXIS_RY = 13,
+    /**
+     * Axis constant: Z Rotation axis of a motion event.
+     *
+     * - For a joystick, reports the absolute rotation angle about the Z axis.
+     * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
+     * On game pads with two analog joysticks, this axis is often reinterpreted
+     * to report the absolute Y position of the second joystick instead.
+     */
     AMOTION_EVENT_AXIS_RZ = 14,
+    /**
+     * Axis constant: Hat X axis of a motion event.
+     *
+     * - For a joystick, reports the absolute X position of the directional hat control.
+     * The value is normalized to a range from -1.0 (left) to 1.0 (right).
+     */
     AMOTION_EVENT_AXIS_HAT_X = 15,
+    /**
+     * Axis constant: Hat Y axis of a motion event.
+     *
+     * - For a joystick, reports the absolute Y position of the directional hat control.
+     * The value is normalized to a range from -1.0 (up) to 1.0 (down).
+     */
     AMOTION_EVENT_AXIS_HAT_Y = 16,
+    /**
+     * Axis constant: Left Trigger axis of a motion event.
+     *
+     * - For a joystick, reports the absolute position of the left trigger control.
+     * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
+     */
     AMOTION_EVENT_AXIS_LTRIGGER = 17,
+    /**
+     * Axis constant: Right Trigger axis of a motion event.
+     *
+     * - For a joystick, reports the absolute position of the right trigger control.
+     * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
+     */
     AMOTION_EVENT_AXIS_RTRIGGER = 18,
+    /**
+     * Axis constant: Throttle axis of a motion event.
+     *
+     * - For a joystick, reports the absolute position of the throttle control.
+     * The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed).
+     */
     AMOTION_EVENT_AXIS_THROTTLE = 19,
+    /**
+     * Axis constant: Rudder axis of a motion event.
+     *
+     * - For a joystick, reports the absolute position of the rudder control.
+     * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
+     */
     AMOTION_EVENT_AXIS_RUDDER = 20,
+    /**
+     * Axis constant: Wheel axis of a motion event.
+     *
+     * - For a joystick, reports the absolute position of the steering wheel control.
+     * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
+     */
     AMOTION_EVENT_AXIS_WHEEL = 21,
+    /**
+     * Axis constant: Gas axis of a motion event.
+     *
+     * - For a joystick, reports the absolute position of the gas (accelerator) control.
+     * The value is normalized to a range from 0.0 (no acceleration)
+     * to 1.0 (maximum acceleration).
+     */
     AMOTION_EVENT_AXIS_GAS = 22,
+    /**
+     * Axis constant: Brake axis of a motion event.
+     *
+     * - For a joystick, reports the absolute position of the brake control.
+     * The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking).
+     */
     AMOTION_EVENT_AXIS_BRAKE = 23,
+    /**
+     * Axis constant: Distance axis of a motion event.
+     *
+     * - For a stylus, reports the distance of the stylus from the screen.
+     * A value of 0.0 indicates direct contact and larger values indicate increasing
+     * distance from the surface.
+     */
     AMOTION_EVENT_AXIS_DISTANCE = 24,
+    /**
+     * Axis constant: Tilt axis of a motion event.
+     *
+     * - For a stylus, reports the tilt angle of the stylus in radians where
+     * 0 radians indicates that the stylus is being held perpendicular to the
+     * surface, and PI/2 radians indicates that the stylus is being held flat
+     * against the surface.
+     */
     AMOTION_EVENT_AXIS_TILT = 25,
+    /**
+     * Axis constant: Generic 1 axis of a motion event.
+     * The interpretation of a generic axis is device-specific.
+     */
     AMOTION_EVENT_AXIS_GENERIC_1 = 32,
+    /**
+     * Axis constant: Generic 2 axis of a motion event.
+     * The interpretation of a generic axis is device-specific.
+     */
     AMOTION_EVENT_AXIS_GENERIC_2 = 33,
+    /**
+     * Axis constant: Generic 3 axis of a motion event.
+     * The interpretation of a generic axis is device-specific.
+     */
     AMOTION_EVENT_AXIS_GENERIC_3 = 34,
+    /**
+     * Axis constant: Generic 4 axis of a motion event.
+     * The interpretation of a generic axis is device-specific.
+     */
     AMOTION_EVENT_AXIS_GENERIC_4 = 35,
+    /**
+     * Axis constant: Generic 5 axis of a motion event.
+     * The interpretation of a generic axis is device-specific.
+     */
     AMOTION_EVENT_AXIS_GENERIC_5 = 36,
+    /**
+     * Axis constant: Generic 6 axis of a motion event.
+     * The interpretation of a generic axis is device-specific.
+     */
     AMOTION_EVENT_AXIS_GENERIC_6 = 37,
+    /**
+     * Axis constant: Generic 7 axis of a motion event.
+     * The interpretation of a generic axis is device-specific.
+     */
     AMOTION_EVENT_AXIS_GENERIC_7 = 38,
+    /**
+     * Axis constant: Generic 8 axis of a motion event.
+     * The interpretation of a generic axis is device-specific.
+     */
     AMOTION_EVENT_AXIS_GENERIC_8 = 39,
+    /**
+     * Axis constant: Generic 9 axis of a motion event.
+     * The interpretation of a generic axis is device-specific.
+     */
     AMOTION_EVENT_AXIS_GENERIC_9 = 40,
+    /**
+     * Axis constant: Generic 10 axis of a motion event.
+     * The interpretation of a generic axis is device-specific.
+     */
     AMOTION_EVENT_AXIS_GENERIC_10 = 41,
+    /**
+     * Axis constant: Generic 11 axis of a motion event.
+     * The interpretation of a generic axis is device-specific.
+     */
     AMOTION_EVENT_AXIS_GENERIC_11 = 42,
+    /**
+     * Axis constant: Generic 12 axis of a motion event.
+     * The interpretation of a generic axis is device-specific.
+     */
     AMOTION_EVENT_AXIS_GENERIC_12 = 43,
+    /**
+     * Axis constant: Generic 13 axis of a motion event.
+     * The interpretation of a generic axis is device-specific.
+     */
     AMOTION_EVENT_AXIS_GENERIC_13 = 44,
+    /**
+     * Axis constant: Generic 14 axis of a motion event.
+     * The interpretation of a generic axis is device-specific.
+     */
     AMOTION_EVENT_AXIS_GENERIC_14 = 45,
+    /**
+     * Axis constant: Generic 15 axis of a motion event.
+     * The interpretation of a generic axis is device-specific.
+     */
     AMOTION_EVENT_AXIS_GENERIC_15 = 46,
+    /**
+     * Axis constant: Generic 16 axis of a motion event.
+     * The interpretation of a generic axis is device-specific.
+     */
     AMOTION_EVENT_AXIS_GENERIC_16 = 47,
 
     // NOTE: If you add a new axis here you must also add it to several other files.
     //       Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
 };
 
-/*
+/**
  * Constants that identify buttons that are associated with motion events.
  * Refer to the documentation on the MotionEvent class for descriptions of each button.
  */
 enum {
+    /** primary */
     AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0,
+    /** secondary */
     AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1,
+    /** tertiary */
     AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2,
+    /** back */
     AMOTION_EVENT_BUTTON_BACK = 1 << 3,
+    /** forward */
     AMOTION_EVENT_BUTTON_FORWARD = 1 << 4,
+    AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5,
+    AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6,
 };
 
-/*
+/**
  * Constants that identify tool types.
  * Refer to the documentation on the MotionEvent class for descriptions of each tool type.
  */
 enum {
+    /** unknown */
     AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0,
+    /** finger */
     AMOTION_EVENT_TOOL_TYPE_FINGER = 1,
+    /** stylus */
     AMOTION_EVENT_TOOL_TYPE_STYLUS = 2,
+    /** mouse */
     AMOTION_EVENT_TOOL_TYPE_MOUSE = 3,
+    /** eraser */
     AMOTION_EVENT_TOOL_TYPE_ERASER = 4,
 };
 
-/*
- * Input sources.
+/**
+ * Input source masks.
  *
  * Refer to the documentation on android.view.InputDevice for more details about input sources
  * and their correct interpretation.
  */
 enum {
+    /** mask */
     AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
 
+    /** none */
     AINPUT_SOURCE_CLASS_NONE = 0x00000000,
+    /** button */
     AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
+    /** pointer */
     AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
+    /** navigation */
     AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
+    /** position */
     AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
+    /** joystick */
     AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010,
 };
 
+/**
+ * Input sources.
+ */
 enum {
+    /** unknown */
     AINPUT_SOURCE_UNKNOWN = 0x00000000,
 
+    /** keyboard */
     AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
+    /** dpad */
     AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
+    /** gamepad */
     AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
+    /** touchscreen */
     AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
+    /** mouse */
     AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
+    /** stylus */
     AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER,
+    /** bluetooth stylus */
+    AINPUT_SOURCE_BLUETOOTH_STYLUS = 0x00008000 | AINPUT_SOURCE_STYLUS,
+    /** trackball */
     AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
+    /** touchpad */
     AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
+    /** navigation */
     AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE,
+    /** joystick */
     AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
 
+    /** any */
     AINPUT_SOURCE_ANY = 0xffffff00,
 };
 
-/*
+/**
  * Keyboard types.
  *
  * Refer to the documentation on android.view.InputDevice for more details.
  */
 enum {
+    /** none */
     AINPUT_KEYBOARD_TYPE_NONE = 0,
+    /** non alphabetic */
     AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1,
+    /** alphabetic */
     AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2,
 };
 
-/*
+/**
  * Constants used to retrieve information about the range of motion for a particular
  * coordinate of a motion event.
  *
  * Refer to the documentation on android.view.InputDevice for more details about input sources
  * and their correct interpretation.
  *
- * DEPRECATION NOTICE: These constants are deprecated.  Use AMOTION_EVENT_AXIS_* constants instead.
+ * @deprecated These constants are deprecated. Use {@link AMOTION_EVENT_AXIS AMOTION_EVENT_AXIS_*} constants instead.
  */
 enum {
+    /** x */
     AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X,
+    /** y */
     AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y,
+    /** pressure */
     AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE,
+    /** size */
     AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE,
+    /** touch major */
     AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR,
+    /** touch minor */
     AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR,
+    /** tool major */
     AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR,
+    /** tool minor */
     AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR,
+    /** orientation */
     AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION,
-} __attribute__ ((deprecated));
+};
 
 
-/*
+/**
  * Input event accessors.
  *
  * Note that most functions can only be used on input events that are of a given type.
@@ -495,10 +876,10 @@
 
 /*** Accessors for all input events. ***/
 
-/* Get the input event type. */
+/** Get the input event type. */
 int32_t AInputEvent_getType(const AInputEvent* event);
 
-/* Get the id for the device that an input event came from.
+/** Get the id for the device that an input event came from.
  *
  * Input events can be generated by multiple different input devices.
  * Use the input device id to obtain information about the input
@@ -510,272 +891,351 @@
  */
 int32_t AInputEvent_getDeviceId(const AInputEvent* event);
 
-/* Get the input event source. */
+/** Get the input event source. */
 int32_t AInputEvent_getSource(const AInputEvent* event);
 
 /*** Accessors for key events only. ***/
 
-/* Get the key event action. */
+/** Get the key event action. */
 int32_t AKeyEvent_getAction(const AInputEvent* key_event);
 
-/* Get the key event flags. */
+/** Get the key event flags. */
 int32_t AKeyEvent_getFlags(const AInputEvent* key_event);
 
-/* Get the key code of the key event.
- * This is the physical key that was pressed, not the Unicode character. */
+/**
+ * Get the key code of the key event.
+ * This is the physical key that was pressed, not the Unicode character.
+ */
 int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event);
 
-/* Get the hardware key id of this key event.
- * These values are not reliable and vary from device to device. */
+/**
+ * Get the hardware key id of this key event.
+ * These values are not reliable and vary from device to device.
+ */
 int32_t AKeyEvent_getScanCode(const AInputEvent* key_event);
 
-/* Get the meta key state. */
+/** Get the meta key state. */
 int32_t AKeyEvent_getMetaState(const AInputEvent* key_event);
 
-/* Get the repeat count of the event.
+/**
+ * Get the repeat count of the event.
  * For both key up an key down events, this is the number of times the key has
  * repeated with the first down starting at 0 and counting up from there.  For
- * multiple key events, this is the number of down/up pairs that have occurred. */
+ * multiple key events, this is the number of down/up pairs that have occurred.
+ */
 int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event);
 
-/* Get the time of the most recent key down event, in the
+/**
+ * Get the time of the most recent key down event, in the
  * java.lang.System.nanoTime() time base.  If this is a down event,
  * this will be the same as eventTime.
  * Note that when chording keys, this value is the down time of the most recently
- * pressed key, which may not be the same physical key of this event. */
+ * pressed key, which may not be the same physical key of this event.
+ */
 int64_t AKeyEvent_getDownTime(const AInputEvent* key_event);
 
-/* Get the time this event occurred, in the
- * java.lang.System.nanoTime() time base. */
+/**
+ * Get the time this event occurred, in the
+ * java.lang.System.nanoTime() time base.
+ */
 int64_t AKeyEvent_getEventTime(const AInputEvent* key_event);
 
 /*** Accessors for motion events only. ***/
 
-/* Get the combined motion event action code and pointer index. */
+/** Get the combined motion event action code and pointer index. */
 int32_t AMotionEvent_getAction(const AInputEvent* motion_event);
 
-/* Get the motion event flags. */
+/** Get the motion event flags. */
 int32_t AMotionEvent_getFlags(const AInputEvent* motion_event);
 
-/* Get the state of any meta / modifier keys that were in effect when the
- * event was generated. */
+/**
+ * Get the state of any meta / modifier keys that were in effect when the
+ * event was generated.
+ */
 int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
 
-/* Get the button state of all buttons that are pressed. */
+/** Get the button state of all buttons that are pressed. */
 int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event);
 
-/* Get a bitfield indicating which edges, if any, were touched by this motion event.
+/**
+ * Get a bitfield indicating which edges, if any, were touched by this motion event.
  * For touch events, clients can use this to determine if the user's finger was
- * touching the edge of the display. */
+ * touching the edge of the display.
+ */
 int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event);
 
-/* Get the time when the user originally pressed down to start a stream of
- * position events, in the java.lang.System.nanoTime() time base. */
+/**
+ * Get the time when the user originally pressed down to start a stream of
+ * position events, in the java.lang.System.nanoTime() time base.
+ */
 int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event);
 
-/* Get the time when this specific event was generated,
- * in the java.lang.System.nanoTime() time base. */
+/**
+ * Get the time when this specific event was generated,
+ * in the java.lang.System.nanoTime() time base.
+ */
 int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event);
 
-/* Get the X coordinate offset.
+/**
+ * Get the X coordinate offset.
  * For touch events on the screen, this is the delta that was added to the raw
  * screen coordinates to adjust for the absolute position of the containing windows
- * and views. */
+ * and views.
+ */
 float AMotionEvent_getXOffset(const AInputEvent* motion_event);
 
-/* Get the Y coordinate offset.
+/**
+ * Get the Y coordinate offset.
  * For touch events on the screen, this is the delta that was added to the raw
  * screen coordinates to adjust for the absolute position of the containing windows
- * and views. */
+ * and views.
+ */
 float AMotionEvent_getYOffset(const AInputEvent* motion_event);
 
-/* Get the precision of the X coordinates being reported.
+/**
+ * Get the precision of the X coordinates being reported.
  * You can multiply this number with an X coordinate sample to find the
- * actual hardware value of the X coordinate. */
+ * actual hardware value of the X coordinate.
+ */
 float AMotionEvent_getXPrecision(const AInputEvent* motion_event);
 
-/* Get the precision of the Y coordinates being reported.
+/**
+ * Get the precision of the Y coordinates being reported.
  * You can multiply this number with a Y coordinate sample to find the
- * actual hardware value of the Y coordinate. */
+ * actual hardware value of the Y coordinate.
+ */
 float AMotionEvent_getYPrecision(const AInputEvent* motion_event);
 
-/* Get the number of pointers of data contained in this event.
- * Always >= 1. */
+/**
+ * Get the number of pointers of data contained in this event.
+ * Always >= 1.
+ */
 size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
 
-/* Get the pointer identifier associated with a particular pointer
+/**
+ * Get the pointer identifier associated with a particular pointer
  * data index in this event.  The identifier tells you the actual pointer
  * number associated with the data, accounting for individual pointers
- * going up and down since the start of the current gesture. */
+ * going up and down since the start of the current gesture.
+ */
 int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
 
-/* Get the tool type of a pointer for the given pointer index.
+/**
+ * Get the tool type of a pointer for the given pointer index.
  * The tool type indicates the type of tool used to make contact such as a
- * finger or stylus, if known. */
+ * finger or stylus, if known.
+ */
 int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index);
 
-/* Get the original raw X coordinate of this event.
+/**
+ * Get the original raw X coordinate of this event.
  * For touch events on the screen, this is the original location of the event
  * on the screen, before it had been adjusted for the containing window
- * and views. */
+ * and views.
+ */
 float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index);
 
-/* Get the original raw X coordinate of this event.
+/**
+ * Get the original raw X coordinate of this event.
  * For touch events on the screen, this is the original location of the event
  * on the screen, before it had been adjusted for the containing window
- * and views. */
+ * and views.
+ */
 float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index);
 
-/* Get the current X coordinate of this event for the given pointer index.
+/**
+ * Get the current X coordinate of this event for the given pointer index.
  * Whole numbers are pixels; the value may have a fraction for input devices
- * that are sub-pixel precise. */
+ * that are sub-pixel precise.
+ */
 float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index);
 
-/* Get the current Y coordinate of this event for the given pointer index.
+/**
+ * Get the current Y coordinate of this event for the given pointer index.
  * Whole numbers are pixels; the value may have a fraction for input devices
- * that are sub-pixel precise. */
+ * that are sub-pixel precise.
+ */
 float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index);
 
-/* Get the current pressure of this event for the given pointer index.
+/**
+ * Get the current pressure of this event for the given pointer index.
  * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
  * although values higher than 1 may be generated depending on the calibration of
- * the input device. */
+ * the input device.
+ */
 float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index);
 
-/* Get the current scaled value of the approximate size for the given pointer index.
+/**
+ * Get the current scaled value of the approximate size for the given pointer index.
  * This represents some approximation of the area of the screen being
  * pressed; the actual value in pixels corresponding to the
  * touch is normalized with the device specific range of values
  * and scaled to a value between 0 and 1.  The value of size can be used to
- * determine fat touch events. */
+ * determine fat touch events.
+ */
 float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index);
 
-/* Get the current length of the major axis of an ellipse that describes the touch area
- * at the point of contact for the given pointer index. */
+/**
+ * Get the current length of the major axis of an ellipse that describes the touch area
+ * at the point of contact for the given pointer index.
+ */
 float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index);
 
-/* Get the current length of the minor axis of an ellipse that describes the touch area
- * at the point of contact for the given pointer index. */
+/**
+ * Get the current length of the minor axis of an ellipse that describes the touch area
+ * at the point of contact for the given pointer index.
+ */
 float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index);
 
-/* Get the current length of the major axis of an ellipse that describes the size
+/**
+ * Get the current length of the major axis of an ellipse that describes the size
  * of the approaching tool for the given pointer index.
  * The tool area represents the estimated size of the finger or pen that is
- * touching the device independent of its actual touch area at the point of contact. */
+ * touching the device independent of its actual touch area at the point of contact.
+ */
 float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index);
 
-/* Get the current length of the minor axis of an ellipse that describes the size
+/**
+ * Get the current length of the minor axis of an ellipse that describes the size
  * of the approaching tool for the given pointer index.
  * The tool area represents the estimated size of the finger or pen that is
- * touching the device independent of its actual touch area at the point of contact. */
+ * touching the device independent of its actual touch area at the point of contact.
+ */
 float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index);
 
-/* Get the current orientation of the touch area and tool area in radians clockwise from
+/**
+ * Get the current orientation of the touch area and tool area in radians clockwise from
  * vertical for the given pointer index.
  * An angle of 0 degrees indicates that the major axis of contact is oriented
  * upwards, is perfectly circular or is of unknown orientation.  A positive angle
  * indicates that the major axis of contact is oriented to the right.  A negative angle
  * indicates that the major axis of contact is oriented to the left.
  * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
- * (finger pointing fully right). */
+ * (finger pointing fully right).
+ */
 float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
 
-/* Get the value of the request axis for the given pointer index. */
+/** Get the value of the request axis for the given pointer index. */
 float AMotionEvent_getAxisValue(const AInputEvent* motion_event,
         int32_t axis, size_t pointer_index);
 
-/* Get the number of historical points in this event.  These are movements that
+/**
+ * Get the number of historical points in this event.  These are movements that
  * have occurred between this event and the previous event.  This only applies
  * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
- * Historical samples are indexed from oldest to newest. */
+ * Historical samples are indexed from oldest to newest.
+ */
 size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event);
 
-/* Get the time that a historical movement occurred between this event and
- * the previous event, in the java.lang.System.nanoTime() time base. */
+/**
+ * Get the time that a historical movement occurred between this event and
+ * the previous event, in the java.lang.System.nanoTime() time base.
+ */
 int64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event,
         size_t history_index);
 
-/* Get the historical raw X coordinate of this event for the given pointer index that
+/**
+ * Get the historical raw X coordinate of this event for the given pointer index that
  * occurred between this event and the previous motion event.
  * For touch events on the screen, this is the original location of the event
  * on the screen, before it had been adjusted for the containing window
  * and views.
  * Whole numbers are pixels; the value may have a fraction for input devices
- * that are sub-pixel precise. */
+ * that are sub-pixel precise.
+ */
 float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index,
         size_t history_index);
 
-/* Get the historical raw Y coordinate of this event for the given pointer index that
+/**
+ * Get the historical raw Y coordinate of this event for the given pointer index that
  * occurred between this event and the previous motion event.
  * For touch events on the screen, this is the original location of the event
  * on the screen, before it had been adjusted for the containing window
  * and views.
  * Whole numbers are pixels; the value may have a fraction for input devices
- * that are sub-pixel precise. */
+ * that are sub-pixel precise.
+ */
 float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index,
         size_t history_index);
 
-/* Get the historical X coordinate of this event for the given pointer index that
+/**
+ * Get the historical X coordinate of this event for the given pointer index that
  * occurred between this event and the previous motion event.
  * Whole numbers are pixels; the value may have a fraction for input devices
- * that are sub-pixel precise. */
+ * that are sub-pixel precise.
+ */
 float AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index,
         size_t history_index);
 
-/* Get the historical Y coordinate of this event for the given pointer index that
+/**
+ * Get the historical Y coordinate of this event for the given pointer index that
  * occurred between this event and the previous motion event.
  * Whole numbers are pixels; the value may have a fraction for input devices
- * that are sub-pixel precise. */
+ * that are sub-pixel precise.
+ */
 float AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index,
         size_t history_index);
 
-/* Get the historical pressure of this event for the given pointer index that
+/**
+ * Get the historical pressure of this event for the given pointer index that
  * occurred between this event and the previous motion event.
  * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
  * although values higher than 1 may be generated depending on the calibration of
- * the input device. */
+ * the input device.
+ */
 float AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index,
         size_t history_index);
 
-/* Get the current scaled value of the approximate size for the given pointer index that
+/**
+ * Get the current scaled value of the approximate size for the given pointer index that
  * occurred between this event and the previous motion event.
  * This represents some approximation of the area of the screen being
  * pressed; the actual value in pixels corresponding to the
  * touch is normalized with the device specific range of values
  * and scaled to a value between 0 and 1.  The value of size can be used to
- * determine fat touch events. */
+ * determine fat touch events.
+ */
 float AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index,
         size_t history_index);
 
-/* Get the historical length of the major axis of an ellipse that describes the touch area
+/**
+ * Get the historical length of the major axis of an ellipse that describes the touch area
  * at the point of contact for the given pointer index that
- * occurred between this event and the previous motion event. */
+ * occurred between this event and the previous motion event.
+ */
 float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index,
         size_t history_index);
 
-/* Get the historical length of the minor axis of an ellipse that describes the touch area
+/**
+ * Get the historical length of the minor axis of an ellipse that describes the touch area
  * at the point of contact for the given pointer index that
- * occurred between this event and the previous motion event. */
+ * occurred between this event and the previous motion event.
+ */
 float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index,
         size_t history_index);
 
-/* Get the historical length of the major axis of an ellipse that describes the size
+/**
+ * Get the historical length of the major axis of an ellipse that describes the size
  * of the approaching tool for the given pointer index that
  * occurred between this event and the previous motion event.
  * The tool area represents the estimated size of the finger or pen that is
- * touching the device independent of its actual touch area at the point of contact. */
+ * touching the device independent of its actual touch area at the point of contact.
+ */
 float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index,
         size_t history_index);
 
-/* Get the historical length of the minor axis of an ellipse that describes the size
+/**
+ * Get the historical length of the minor axis of an ellipse that describes the size
  * of the approaching tool for the given pointer index that
  * occurred between this event and the previous motion event.
  * The tool area represents the estimated size of the finger or pen that is
- * touching the device independent of its actual touch area at the point of contact. */
+ * touching the device independent of its actual touch area at the point of contact.
+ */
 float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index,
         size_t history_index);
 
-/* Get the historical orientation of the touch area and tool area in radians clockwise from
+/**
+ * Get the historical orientation of the touch area and tool area in radians clockwise from
  * vertical for the given pointer index that
  * occurred between this event and the previous motion event.
  * An angle of 0 degrees indicates that the major axis of contact is oriented
@@ -783,51 +1243,54 @@
  * indicates that the major axis of contact is oriented to the right.  A negative angle
  * indicates that the major axis of contact is oriented to the left.
  * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
- * (finger pointing fully right). */
+ * (finger pointing fully right).
+ */
 float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
         size_t history_index);
 
-/* Get the historical value of the request axis for the given pointer index
- * that occurred between this event and the previous motion event. */
+/**
+ * Get the historical value of the request axis for the given pointer index
+ * that occurred between this event and the previous motion event.
+ */
 float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event,
         int32_t axis, size_t pointer_index, size_t history_index);
 
 
-/*
+struct AInputQueue;
+/**
  * Input queue
  *
  * An input queue is the facility through which you retrieve input
  * events.
  */
-struct AInputQueue;
 typedef struct AInputQueue AInputQueue;
 
-/*
+/**
  * Add this input queue to a looper for processing.  See
  * ALooper_addFd() for information on the ident, callback, and data params.
  */
 void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper,
         int ident, ALooper_callbackFunc callback, void* data);
 
-/*
+/**
  * Remove the input queue from the looper it is currently attached to.
  */
 void AInputQueue_detachLooper(AInputQueue* queue);
 
-/*
+/**
  * Returns true if there are one or more events available in the
  * input queue.  Returns 1 if the queue has events; 0 if
  * it does not have events; and a negative value if there is an error.
  */
 int32_t AInputQueue_hasEvents(AInputQueue* queue);
 
-/*
+/**
  * Returns the next available event from the queue.  Returns a negative
  * value if no events are available or an error has occurred.
  */
 int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
 
-/*
+/**
  * Sends the key for standard pre-dispatching -- that is, possibly deliver
  * it to the current IME to be consumed before the app.  Returns 0 if it
  * was not pre-dispatched, meaning you can process it right now.  If non-zero
@@ -837,7 +1300,7 @@
  */
 int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
 
-/*
+/**
  * Report that dispatching has finished with the given event.
  * This must be called after receiving an event with AInputQueue_get_event().
  */
@@ -848,3 +1311,5 @@
 #endif
 
 #endif // _ANDROID_INPUT_H
+
+/** @} */
diff --git a/include/android/keycodes.h b/include/android/keycodes.h
index 1ca1332..421abe5 100644
--- a/include/android/keycodes.h
+++ b/include/android/keycodes.h
@@ -14,6 +14,15 @@
  * limitations under the License.
  */
 
+/**
+ * @addtogroup Input
+ * @{
+ */
+
+/**
+ * @file keycodes.h
+ */
+
 #ifndef _ANDROID_KEYCODES_H
 #define _ANDROID_KEYCODES_H
 
@@ -39,233 +48,696 @@
 extern "C" {
 #endif
 
-/*
+/**
  * Key codes.
  */
 enum {
+    /** Unknown key code. */
     AKEYCODE_UNKNOWN         = 0,
+    /** Soft Left key.
+     * Usually situated below the display on phones and used as a multi-function
+     * feature key for selecting a software defined function shown on the bottom left
+     * of the display. */
     AKEYCODE_SOFT_LEFT       = 1,
+    /** Soft Right key.
+     * Usually situated below the display on phones and used as a multi-function
+     * feature key for selecting a software defined function shown on the bottom right
+     * of the display. */
     AKEYCODE_SOFT_RIGHT      = 2,
+    /** Home key.
+     * This key is handled by the framework and is never delivered to applications. */
     AKEYCODE_HOME            = 3,
+    /** Back key. */
     AKEYCODE_BACK            = 4,
+    /** Call key. */
     AKEYCODE_CALL            = 5,
+    /** End Call key. */
     AKEYCODE_ENDCALL         = 6,
+    /** '0' key. */
     AKEYCODE_0               = 7,
+    /** '1' key. */
     AKEYCODE_1               = 8,
+    /** '2' key. */
     AKEYCODE_2               = 9,
+    /** '3' key. */
     AKEYCODE_3               = 10,
+    /** '4' key. */
     AKEYCODE_4               = 11,
+    /** '5' key. */
     AKEYCODE_5               = 12,
+    /** '6' key. */
     AKEYCODE_6               = 13,
+    /** '7' key. */
     AKEYCODE_7               = 14,
+    /** '8' key. */
     AKEYCODE_8               = 15,
+    /** '9' key. */
     AKEYCODE_9               = 16,
+    /** '*' key. */
     AKEYCODE_STAR            = 17,
+    /** '#' key. */
     AKEYCODE_POUND           = 18,
+    /** Directional Pad Up key.
+     * May also be synthesized from trackball motions. */
     AKEYCODE_DPAD_UP         = 19,
+    /** Directional Pad Down key.
+     * May also be synthesized from trackball motions. */
     AKEYCODE_DPAD_DOWN       = 20,
+    /** Directional Pad Left key.
+     * May also be synthesized from trackball motions. */
     AKEYCODE_DPAD_LEFT       = 21,
+    /** Directional Pad Right key.
+     * May also be synthesized from trackball motions. */
     AKEYCODE_DPAD_RIGHT      = 22,
+    /** Directional Pad Center key.
+     * May also be synthesized from trackball motions. */
     AKEYCODE_DPAD_CENTER     = 23,
+    /** Volume Up key.
+     * Adjusts the speaker volume up. */
     AKEYCODE_VOLUME_UP       = 24,
+    /** Volume Down key.
+     * Adjusts the speaker volume down. */
     AKEYCODE_VOLUME_DOWN     = 25,
+    /** Power key. */
     AKEYCODE_POWER           = 26,
+    /** Camera key.
+     * Used to launch a camera application or take pictures. */
     AKEYCODE_CAMERA          = 27,
+    /** Clear key. */
     AKEYCODE_CLEAR           = 28,
+    /** 'A' key. */
     AKEYCODE_A               = 29,
+    /** 'B' key. */
     AKEYCODE_B               = 30,
+    /** 'C' key. */
     AKEYCODE_C               = 31,
+    /** 'D' key. */
     AKEYCODE_D               = 32,
+    /** 'E' key. */
     AKEYCODE_E               = 33,
+    /** 'F' key. */
     AKEYCODE_F               = 34,
+    /** 'G' key. */
     AKEYCODE_G               = 35,
+    /** 'H' key. */
     AKEYCODE_H               = 36,
+    /** 'I' key. */
     AKEYCODE_I               = 37,
+    /** 'J' key. */
     AKEYCODE_J               = 38,
+    /** 'K' key. */
     AKEYCODE_K               = 39,
+    /** 'L' key. */
     AKEYCODE_L               = 40,
+    /** 'M' key. */
     AKEYCODE_M               = 41,
+    /** 'N' key. */
     AKEYCODE_N               = 42,
+    /** 'O' key. */
     AKEYCODE_O               = 43,
+    /** 'P' key. */
     AKEYCODE_P               = 44,
+    /** 'Q' key. */
     AKEYCODE_Q               = 45,
+    /** 'R' key. */
     AKEYCODE_R               = 46,
+    /** 'S' key. */
     AKEYCODE_S               = 47,
+    /** 'T' key. */
     AKEYCODE_T               = 48,
+    /** 'U' key. */
     AKEYCODE_U               = 49,
+    /** 'V' key. */
     AKEYCODE_V               = 50,
+    /** 'W' key. */
     AKEYCODE_W               = 51,
+    /** 'X' key. */
     AKEYCODE_X               = 52,
+    /** 'Y' key. */
     AKEYCODE_Y               = 53,
+    /** 'Z' key. */
     AKEYCODE_Z               = 54,
+    /** ',' key. */
     AKEYCODE_COMMA           = 55,
+    /** '.' key. */
     AKEYCODE_PERIOD          = 56,
+    /** Left Alt modifier key. */
     AKEYCODE_ALT_LEFT        = 57,
+    /** Right Alt modifier key. */
     AKEYCODE_ALT_RIGHT       = 58,
+    /** Left Shift modifier key. */
     AKEYCODE_SHIFT_LEFT      = 59,
+    /** Right Shift modifier key. */
     AKEYCODE_SHIFT_RIGHT     = 60,
+    /** Tab key. */
     AKEYCODE_TAB             = 61,
+    /** Space key. */
     AKEYCODE_SPACE           = 62,
+    /** Symbol modifier key.
+     * Used to enter alternate symbols. */
     AKEYCODE_SYM             = 63,
+    /** Explorer special function key.
+     * Used to launch a browser application. */
     AKEYCODE_EXPLORER        = 64,
+    /** Envelope special function key.
+     * Used to launch a mail application. */
     AKEYCODE_ENVELOPE        = 65,
+    /** Enter key. */
     AKEYCODE_ENTER           = 66,
+    /** Backspace key.
+     * Deletes characters before the insertion point, unlike {@link AKEYCODE_FORWARD_DEL}. */
     AKEYCODE_DEL             = 67,
+    /** '`' (backtick) key. */
     AKEYCODE_GRAVE           = 68,
+    /** '-'. */
     AKEYCODE_MINUS           = 69,
+    /** '=' key. */
     AKEYCODE_EQUALS          = 70,
+    /** '[' key. */
     AKEYCODE_LEFT_BRACKET    = 71,
+    /** ']' key. */
     AKEYCODE_RIGHT_BRACKET   = 72,
+    /** '\' key. */
     AKEYCODE_BACKSLASH       = 73,
+    /** ';' key. */
     AKEYCODE_SEMICOLON       = 74,
+    /** ''' (apostrophe) key. */
     AKEYCODE_APOSTROPHE      = 75,
+    /** '/' key. */
     AKEYCODE_SLASH           = 76,
+    /** '@' key. */
     AKEYCODE_AT              = 77,
+    /** Number modifier key.
+     * Used to enter numeric symbols.
+     * This key is not {@link AKEYCODE_NUM_LOCK}; it is more like {@link AKEYCODE_ALT_LEFT}. */
     AKEYCODE_NUM             = 78,
+    /** Headset Hook key.
+     * Used to hang up calls and stop media. */
     AKEYCODE_HEADSETHOOK     = 79,
-    AKEYCODE_FOCUS           = 80,   // *Camera* focus
+    /** Camera Focus key.
+     * Used to focus the camera. */
+    AKEYCODE_FOCUS           = 80,
+    /** '+' key. */
     AKEYCODE_PLUS            = 81,
+    /** Menu key. */
     AKEYCODE_MENU            = 82,
+    /** Notification key. */
     AKEYCODE_NOTIFICATION    = 83,
+    /** Search key. */
     AKEYCODE_SEARCH          = 84,
+    /** Play/Pause media key. */
     AKEYCODE_MEDIA_PLAY_PAUSE= 85,
+    /** Stop media key. */
     AKEYCODE_MEDIA_STOP      = 86,
+    /** Play Next media key. */
     AKEYCODE_MEDIA_NEXT      = 87,
+    /** Play Previous media key. */
     AKEYCODE_MEDIA_PREVIOUS  = 88,
+    /** Rewind media key. */
     AKEYCODE_MEDIA_REWIND    = 89,
+    /** Fast Forward media key. */
     AKEYCODE_MEDIA_FAST_FORWARD = 90,
+    /** Mute key.
+     * Mutes the microphone, unlike {@link AKEYCODE_VOLUME_MUTE}. */
     AKEYCODE_MUTE            = 91,
+    /** Page Up key. */
     AKEYCODE_PAGE_UP         = 92,
+    /** Page Down key. */
     AKEYCODE_PAGE_DOWN       = 93,
+    /** Picture Symbols modifier key.
+     * Used to switch symbol sets (Emoji, Kao-moji). */
     AKEYCODE_PICTSYMBOLS     = 94,
+    /** Switch Charset modifier key.
+     * Used to switch character sets (Kanji, Katakana). */
     AKEYCODE_SWITCH_CHARSET  = 95,
+    /** A Button key.
+     * On a game controller, the A button should be either the button labeled A
+     * or the first button on the bottom row of controller buttons. */
     AKEYCODE_BUTTON_A        = 96,
+    /** B Button key.
+     * On a game controller, the B button should be either the button labeled B
+     * or the second button on the bottom row of controller buttons. */
     AKEYCODE_BUTTON_B        = 97,
+    /** C Button key.
+     * On a game controller, the C button should be either the button labeled C
+     * or the third button on the bottom row of controller buttons. */
     AKEYCODE_BUTTON_C        = 98,
+    /** X Button key.
+     * On a game controller, the X button should be either the button labeled X
+     * or the first button on the upper row of controller buttons. */
     AKEYCODE_BUTTON_X        = 99,
+    /** Y Button key.
+     * On a game controller, the Y button should be either the button labeled Y
+     * or the second button on the upper row of controller buttons. */
     AKEYCODE_BUTTON_Y        = 100,
+    /** Z Button key.
+     * On a game controller, the Z button should be either the button labeled Z
+     * or the third button on the upper row of controller buttons. */
     AKEYCODE_BUTTON_Z        = 101,
+    /** L1 Button key.
+     * On a game controller, the L1 button should be either the button labeled L1 (or L)
+     * or the top left trigger button. */
     AKEYCODE_BUTTON_L1       = 102,
+    /** R1 Button key.
+     * On a game controller, the R1 button should be either the button labeled R1 (or R)
+     * or the top right trigger button. */
     AKEYCODE_BUTTON_R1       = 103,
+    /** L2 Button key.
+     * On a game controller, the L2 button should be either the button labeled L2
+     * or the bottom left trigger button. */
     AKEYCODE_BUTTON_L2       = 104,
+    /** R2 Button key.
+     * On a game controller, the R2 button should be either the button labeled R2
+     * or the bottom right trigger button. */
     AKEYCODE_BUTTON_R2       = 105,
+    /** Left Thumb Button key.
+     * On a game controller, the left thumb button indicates that the left (or only)
+     * joystick is pressed. */
     AKEYCODE_BUTTON_THUMBL   = 106,
+    /** Right Thumb Button key.
+     * On a game controller, the right thumb button indicates that the right
+     * joystick is pressed. */
     AKEYCODE_BUTTON_THUMBR   = 107,
+    /** Start Button key.
+     * On a game controller, the button labeled Start. */
     AKEYCODE_BUTTON_START    = 108,
+    /** Select Button key.
+     * On a game controller, the button labeled Select. */
     AKEYCODE_BUTTON_SELECT   = 109,
+    /** Mode Button key.
+     * On a game controller, the button labeled Mode. */
     AKEYCODE_BUTTON_MODE     = 110,
+    /** Escape key. */
     AKEYCODE_ESCAPE          = 111,
+    /** Forward Delete key.
+     * Deletes characters ahead of the insertion point, unlike {@link AKEYCODE_DEL}. */
     AKEYCODE_FORWARD_DEL     = 112,
+    /** Left Control modifier key. */
     AKEYCODE_CTRL_LEFT       = 113,
+    /** Right Control modifier key. */
     AKEYCODE_CTRL_RIGHT      = 114,
+    /** Caps Lock key. */
     AKEYCODE_CAPS_LOCK       = 115,
+    /** Scroll Lock key. */
     AKEYCODE_SCROLL_LOCK     = 116,
+    /** Left Meta modifier key. */
     AKEYCODE_META_LEFT       = 117,
+    /** Right Meta modifier key. */
     AKEYCODE_META_RIGHT      = 118,
+    /** Function modifier key. */
     AKEYCODE_FUNCTION        = 119,
+    /** System Request / Print Screen key. */
     AKEYCODE_SYSRQ           = 120,
+    /** Break / Pause key. */
     AKEYCODE_BREAK           = 121,
+    /** Home Movement key.
+     * Used for scrolling or moving the cursor around to the start of a line
+     * or to the top of a list. */
     AKEYCODE_MOVE_HOME       = 122,
+    /** End Movement key.
+     * Used for scrolling or moving the cursor around to the end of a line
+     * or to the bottom of a list. */
     AKEYCODE_MOVE_END        = 123,
+    /** Insert key.
+     * Toggles insert / overwrite edit mode. */
     AKEYCODE_INSERT          = 124,
+    /** Forward key.
+     * Navigates forward in the history stack.  Complement of {@link AKEYCODE_BACK}. */
     AKEYCODE_FORWARD         = 125,
+    /** Play media key. */
     AKEYCODE_MEDIA_PLAY      = 126,
+    /** Pause media key. */
     AKEYCODE_MEDIA_PAUSE     = 127,
+    /** Close media key.
+     * May be used to close a CD tray, for example. */
     AKEYCODE_MEDIA_CLOSE     = 128,
+    /** Eject media key.
+     * May be used to eject a CD tray, for example. */
     AKEYCODE_MEDIA_EJECT     = 129,
+    /** Record media key. */
     AKEYCODE_MEDIA_RECORD    = 130,
+    /** F1 key. */
     AKEYCODE_F1              = 131,
+    /** F2 key. */
     AKEYCODE_F2              = 132,
+    /** F3 key. */
     AKEYCODE_F3              = 133,
+    /** F4 key. */
     AKEYCODE_F4              = 134,
+    /** F5 key. */
     AKEYCODE_F5              = 135,
+    /** F6 key. */
     AKEYCODE_F6              = 136,
+    /** F7 key. */
     AKEYCODE_F7              = 137,
+    /** F8 key. */
     AKEYCODE_F8              = 138,
+    /** F9 key. */
     AKEYCODE_F9              = 139,
+    /** F10 key. */
     AKEYCODE_F10             = 140,
+    /** F11 key. */
     AKEYCODE_F11             = 141,
+    /** F12 key. */
     AKEYCODE_F12             = 142,
+    /** Num Lock key.
+     * This is the Num Lock key; it is different from {@link AKEYCODE_NUM}.
+     * This key alters the behavior of other keys on the numeric keypad. */
     AKEYCODE_NUM_LOCK        = 143,
+    /** Numeric keypad '0' key. */
     AKEYCODE_NUMPAD_0        = 144,
+    /** Numeric keypad '1' key. */
     AKEYCODE_NUMPAD_1        = 145,
+    /** Numeric keypad '2' key. */
     AKEYCODE_NUMPAD_2        = 146,
+    /** Numeric keypad '3' key. */
     AKEYCODE_NUMPAD_3        = 147,
+    /** Numeric keypad '4' key. */
     AKEYCODE_NUMPAD_4        = 148,
+    /** Numeric keypad '5' key. */
     AKEYCODE_NUMPAD_5        = 149,
+    /** Numeric keypad '6' key. */
     AKEYCODE_NUMPAD_6        = 150,
+    /** Numeric keypad '7' key. */
     AKEYCODE_NUMPAD_7        = 151,
+    /** Numeric keypad '8' key. */
     AKEYCODE_NUMPAD_8        = 152,
+    /** Numeric keypad '9' key. */
     AKEYCODE_NUMPAD_9        = 153,
+    /** Numeric keypad '/' key (for division). */
     AKEYCODE_NUMPAD_DIVIDE   = 154,
+    /** Numeric keypad '*' key (for multiplication). */
     AKEYCODE_NUMPAD_MULTIPLY = 155,
+    /** Numeric keypad '-' key (for subtraction). */
     AKEYCODE_NUMPAD_SUBTRACT = 156,
+    /** Numeric keypad '+' key (for addition). */
     AKEYCODE_NUMPAD_ADD      = 157,
+    /** Numeric keypad '.' key (for decimals or digit grouping). */
     AKEYCODE_NUMPAD_DOT      = 158,
+    /** Numeric keypad ',' key (for decimals or digit grouping). */
     AKEYCODE_NUMPAD_COMMA    = 159,
+    /** Numeric keypad Enter key. */
     AKEYCODE_NUMPAD_ENTER    = 160,
+    /** Numeric keypad '=' key. */
     AKEYCODE_NUMPAD_EQUALS   = 161,
+    /** Numeric keypad '(' key. */
     AKEYCODE_NUMPAD_LEFT_PAREN = 162,
+    /** Numeric keypad ')' key. */
     AKEYCODE_NUMPAD_RIGHT_PAREN = 163,
+    /** Volume Mute key.
+     * Mutes the speaker, unlike {@link AKEYCODE_MUTE}.
+     * This key should normally be implemented as a toggle such that the first press
+     * mutes the speaker and the second press restores the original volume. */
     AKEYCODE_VOLUME_MUTE     = 164,
+    /** Info key.
+     * Common on TV remotes to show additional information related to what is
+     * currently being viewed. */
     AKEYCODE_INFO            = 165,
+    /** Channel up key.
+     * On TV remotes, increments the television channel. */
     AKEYCODE_CHANNEL_UP      = 166,
+    /** Channel down key.
+     * On TV remotes, decrements the television channel. */
     AKEYCODE_CHANNEL_DOWN    = 167,
+    /** Zoom in key. */
     AKEYCODE_ZOOM_IN         = 168,
+    /** Zoom out key. */
     AKEYCODE_ZOOM_OUT        = 169,
+    /** TV key.
+     * On TV remotes, switches to viewing live TV. */
     AKEYCODE_TV              = 170,
+    /** Window key.
+     * On TV remotes, toggles picture-in-picture mode or other windowing functions. */
     AKEYCODE_WINDOW          = 171,
+    /** Guide key.
+     * On TV remotes, shows a programming guide. */
     AKEYCODE_GUIDE           = 172,
+    /** DVR key.
+     * On some TV remotes, switches to a DVR mode for recorded shows. */
     AKEYCODE_DVR             = 173,
+    /** Bookmark key.
+     * On some TV remotes, bookmarks content or web pages. */
     AKEYCODE_BOOKMARK        = 174,
+    /** Toggle captions key.
+     * Switches the mode for closed-captioning text, for example during television shows. */
     AKEYCODE_CAPTIONS        = 175,
+    /** Settings key.
+     * Starts the system settings activity. */
     AKEYCODE_SETTINGS        = 176,
+    /** TV power key.
+     * On TV remotes, toggles the power on a television screen. */
     AKEYCODE_TV_POWER        = 177,
+    /** TV input key.
+     * On TV remotes, switches the input on a television screen. */
     AKEYCODE_TV_INPUT        = 178,
+    /** Set-top-box power key.
+     * On TV remotes, toggles the power on an external Set-top-box. */
     AKEYCODE_STB_POWER       = 179,
+    /** Set-top-box input key.
+     * On TV remotes, switches the input mode on an external Set-top-box. */
     AKEYCODE_STB_INPUT       = 180,
+    /** A/V Receiver power key.
+     * On TV remotes, toggles the power on an external A/V Receiver. */
     AKEYCODE_AVR_POWER       = 181,
+    /** A/V Receiver input key.
+     * On TV remotes, switches the input mode on an external A/V Receiver. */
     AKEYCODE_AVR_INPUT       = 182,
+    /** Red "programmable" key.
+     * On TV remotes, acts as a contextual/programmable key. */
     AKEYCODE_PROG_RED        = 183,
+    /** Green "programmable" key.
+     * On TV remotes, actsas a contextual/programmable key. */
     AKEYCODE_PROG_GREEN      = 184,
+    /** Yellow "programmable" key.
+     * On TV remotes, acts as a contextual/programmable key. */
     AKEYCODE_PROG_YELLOW     = 185,
+    /** Blue "programmable" key.
+     * On TV remotes, acts as a contextual/programmable key. */
     AKEYCODE_PROG_BLUE       = 186,
+    /** App switch key.
+     * Should bring up the application switcher dialog. */
     AKEYCODE_APP_SWITCH      = 187,
+    /** Generic Game Pad Button #1.*/
     AKEYCODE_BUTTON_1        = 188,
+    /** Generic Game Pad Button #2.*/
     AKEYCODE_BUTTON_2        = 189,
+    /** Generic Game Pad Button #3.*/
     AKEYCODE_BUTTON_3        = 190,
+    /** Generic Game Pad Button #4.*/
     AKEYCODE_BUTTON_4        = 191,
+    /** Generic Game Pad Button #5.*/
     AKEYCODE_BUTTON_5        = 192,
+    /** Generic Game Pad Button #6.*/
     AKEYCODE_BUTTON_6        = 193,
+    /** Generic Game Pad Button #7.*/
     AKEYCODE_BUTTON_7        = 194,
+    /** Generic Game Pad Button #8.*/
     AKEYCODE_BUTTON_8        = 195,
+    /** Generic Game Pad Button #9.*/
     AKEYCODE_BUTTON_9        = 196,
+    /** Generic Game Pad Button #10.*/
     AKEYCODE_BUTTON_10       = 197,
+    /** Generic Game Pad Button #11.*/
     AKEYCODE_BUTTON_11       = 198,
+    /** Generic Game Pad Button #12.*/
     AKEYCODE_BUTTON_12       = 199,
+    /** Generic Game Pad Button #13.*/
     AKEYCODE_BUTTON_13       = 200,
+    /** Generic Game Pad Button #14.*/
     AKEYCODE_BUTTON_14       = 201,
+    /** Generic Game Pad Button #15.*/
     AKEYCODE_BUTTON_15       = 202,
+    /** Generic Game Pad Button #16.*/
     AKEYCODE_BUTTON_16       = 203,
+    /** Language Switch key.
+     * Toggles the current input language such as switching between English and Japanese on
+     * a QWERTY keyboard.  On some devices, the same function may be performed by
+     * pressing Shift+Spacebar. */
     AKEYCODE_LANGUAGE_SWITCH = 204,
+    /** Manner Mode key.
+     * Toggles silent or vibrate mode on and off to make the device behave more politely
+     * in certain settings such as on a crowded train.  On some devices, the key may only
+     * operate when long-pressed. */
     AKEYCODE_MANNER_MODE     = 205,
+    /** 3D Mode key.
+     * Toggles the display between 2D and 3D mode. */
     AKEYCODE_3D_MODE         = 206,
+    /** Contacts special function key.
+     * Used to launch an address book application. */
     AKEYCODE_CONTACTS        = 207,
+    /** Calendar special function key.
+     * Used to launch a calendar application. */
     AKEYCODE_CALENDAR        = 208,
+    /** Music special function key.
+     * Used to launch a music player application. */
     AKEYCODE_MUSIC           = 209,
+    /** Calculator special function key.
+     * Used to launch a calculator application. */
     AKEYCODE_CALCULATOR      = 210,
+    /** Japanese full-width / half-width key. */
     AKEYCODE_ZENKAKU_HANKAKU = 211,
+    /** Japanese alphanumeric key. */
     AKEYCODE_EISU            = 212,
+    /** Japanese non-conversion key. */
     AKEYCODE_MUHENKAN        = 213,
+    /** Japanese conversion key. */
     AKEYCODE_HENKAN          = 214,
+    /** Japanese katakana / hiragana key. */
     AKEYCODE_KATAKANA_HIRAGANA = 215,
+    /** Japanese Yen key. */
     AKEYCODE_YEN             = 216,
+    /** Japanese Ro key. */
     AKEYCODE_RO              = 217,
+    /** Japanese kana key. */
     AKEYCODE_KANA            = 218,
+    /** Assist key.
+     * Launches the global assist activity.  Not delivered to applications. */
     AKEYCODE_ASSIST          = 219,
+    /** Brightness Down key.
+     * Adjusts the screen brightness down. */
     AKEYCODE_BRIGHTNESS_DOWN = 220,
+    /** Brightness Up key.
+     * Adjusts the screen brightness up. */
     AKEYCODE_BRIGHTNESS_UP   = 221,
+    /** Audio Track key.
+     * Switches the audio tracks. */
     AKEYCODE_MEDIA_AUDIO_TRACK = 222,
+    /** Sleep key.
+     * Puts the device to sleep.  Behaves somewhat like {@link AKEYCODE_POWER} but it
+     * has no effect if the device is already asleep. */
+    AKEYCODE_SLEEP           = 223,
+    /** Wakeup key.
+     * Wakes up the device.  Behaves somewhat like {@link AKEYCODE_POWER} but it
+     * has no effect if the device is already awake. */
+    AKEYCODE_WAKEUP          = 224,
+    /** Pairing key.
+     * Initiates peripheral pairing mode. Useful for pairing remote control
+     * devices or game controllers, especially if no other input mode is
+     * available. */
+    AKEYCODE_PAIRING         = 225,
+    /** Media Top Menu key.
+     * Goes to the top of media menu. */
+    AKEYCODE_MEDIA_TOP_MENU  = 226,
+    /** '11' key. */
+    AKEYCODE_11              = 227,
+    /** '12' key. */
+    AKEYCODE_12              = 228,
+    /** Last Channel key.
+     * Goes to the last viewed channel. */
+    AKEYCODE_LAST_CHANNEL    = 229,
+    /** TV data service key.
+     * Displays data services like weather, sports. */
+    AKEYCODE_TV_DATA_SERVICE = 230,
+    /** Voice Assist key.
+     * Launches the global voice assist activity. Not delivered to applications. */
+    AKEYCODE_VOICE_ASSIST    = 231,
+    /** Radio key.
+     * Toggles TV service / Radio service. */
+    AKEYCODE_TV_RADIO_SERVICE = 232,
+    /** Teletext key.
+     * Displays Teletext service. */
+    AKEYCODE_TV_TELETEXT     = 233,
+    /** Number entry key.
+     * Initiates to enter multi-digit channel nubmber when each digit key is assigned
+     * for selecting separate channel. Corresponds to Number Entry Mode (0x1D) of CEC
+     * User Control Code. */
+    AKEYCODE_TV_NUMBER_ENTRY = 234,
+    /** Analog Terrestrial key.
+     * Switches to analog terrestrial broadcast service. */
+    AKEYCODE_TV_TERRESTRIAL_ANALOG = 235,
+    /** Digital Terrestrial key.
+     * Switches to digital terrestrial broadcast service. */
+    AKEYCODE_TV_TERRESTRIAL_DIGITAL = 236,
+    /** Satellite key.
+     * Switches to digital satellite broadcast service. */
+    AKEYCODE_TV_SATELLITE    = 237,
+    /** BS key.
+     * Switches to BS digital satellite broadcasting service available in Japan. */
+    AKEYCODE_TV_SATELLITE_BS = 238,
+    /** CS key.
+     * Switches to CS digital satellite broadcasting service available in Japan. */
+    AKEYCODE_TV_SATELLITE_CS = 239,
+    /** BS/CS key.
+     * Toggles between BS and CS digital satellite services. */
+    AKEYCODE_TV_SATELLITE_SERVICE = 240,
+    /** Toggle Network key.
+     * Toggles selecting broacast services. */
+    AKEYCODE_TV_NETWORK      = 241,
+    /** Antenna/Cable key.
+     * Toggles broadcast input source between antenna and cable. */
+    AKEYCODE_TV_ANTENNA_CABLE = 242,
+    /** HDMI #1 key.
+     * Switches to HDMI input #1. */
+    AKEYCODE_TV_INPUT_HDMI_1 = 243,
+    /** HDMI #2 key.
+     * Switches to HDMI input #2. */
+    AKEYCODE_TV_INPUT_HDMI_2 = 244,
+    /** HDMI #3 key.
+     * Switches to HDMI input #3. */
+    AKEYCODE_TV_INPUT_HDMI_3 = 245,
+    /** HDMI #4 key.
+     * Switches to HDMI input #4. */
+    AKEYCODE_TV_INPUT_HDMI_4 = 246,
+    /** Composite #1 key.
+     * Switches to composite video input #1. */
+    AKEYCODE_TV_INPUT_COMPOSITE_1 = 247,
+    /** Composite #2 key.
+     * Switches to composite video input #2. */
+    AKEYCODE_TV_INPUT_COMPOSITE_2 = 248,
+    /** Component #1 key.
+     * Switches to component video input #1. */
+    AKEYCODE_TV_INPUT_COMPONENT_1 = 249,
+    /** Component #2 key.
+     * Switches to component video input #2. */
+    AKEYCODE_TV_INPUT_COMPONENT_2 = 250,
+    /** VGA #1 key.
+     * Switches to VGA (analog RGB) input #1. */
+    AKEYCODE_TV_INPUT_VGA_1  = 251,
+    /** Audio description key.
+     * Toggles audio description off / on. */
+    AKEYCODE_TV_AUDIO_DESCRIPTION = 252,
+    /** Audio description mixing volume up key.
+     * Louden audio description volume as compared with normal audio volume. */
+    AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP = 253,
+    /** Audio description mixing volume down key.
+     * Lessen audio description volume as compared with normal audio volume. */
+    AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN = 254,
+    /** Zoom mode key.
+     * Changes Zoom mode (Normal, Full, Zoom, Wide-zoom, etc.) */
+    AKEYCODE_TV_ZOOM_MODE    = 255,
+    /** Contents menu key.
+     * Goes to the title list. Corresponds to Contents Menu (0x0B) of CEC User Control
+     * Code */
+    AKEYCODE_TV_CONTENTS_MENU = 256,
+    /** Media context menu key.
+     * Goes to the context menu of media contents. Corresponds to Media Context-sensitive
+     * Menu (0x11) of CEC User Control Code. */
+    AKEYCODE_TV_MEDIA_CONTEXT_MENU = 257,
+    /** Timer programming key.
+     * Goes to the timer recording menu. Corresponds to Timer Programming (0x54) of
+     * CEC User Control Code. */
+    AKEYCODE_TV_TIMER_PROGRAMMING = 258,
+    /** Help key. */
+    AKEYCODE_HELP            = 259,
+    AKEYCODE_NAVIGATE_PREVIOUS = 260,
+    AKEYCODE_NAVIGATE_NEXT   = 261,
+    AKEYCODE_NAVIGATE_IN     = 262,
+    AKEYCODE_NAVIGATE_OUT    = 263,
+    /** Primary stem key for Wear
+     * Main power/reset button on watch. */
+    AKEYCODE_STEM_PRIMARY = 264,
+    /** Generic stem key 1 for Wear */
+    AKEYCODE_STEM_1 = 265,
+    /** Generic stem key 2 for Wear */
+    AKEYCODE_STEM_2 = 266,
+    /** Generic stem key 3 for Wear */
+    AKEYCODE_STEM_3 = 267,
+    AKEYCODE_MEDIA_SKIP_FORWARD = 272,
+    AKEYCODE_MEDIA_SKIP_BACKWARD = 273,
+    AKEYCODE_MEDIA_STEP_FORWARD = 274,
+    AKEYCODE_MEDIA_STEP_BACKWARD = 275,
+    /** Put device to sleep unless a wakelock is held. */
+    AKEYCODE_SOFT_SLEEP = 276
 
     // NOTE: If you add a new keycode here you must also add it to several other files.
     //       Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
@@ -276,3 +748,5 @@
 #endif
 
 #endif // _ANDROID_KEYCODES_H
+
+/** @} */
diff --git a/include/android/looper.h b/include/android/looper.h
index 74c0383..718f703 100644
--- a/include/android/looper.h
+++ b/include/android/looper.h
@@ -14,6 +14,14 @@
  * limitations under the License.
  */
 
+/**
+ * @addtogroup Looper
+ * @{
+ */
+
+/**
+ * @file looper.h
+ */
 
 #ifndef ANDROID_LOOPER_H
 #define ANDROID_LOOPER_H
@@ -22,6 +30,7 @@
 extern "C" {
 #endif
 
+struct ALooper;
 /**
  * ALooper
  *
@@ -35,7 +44,6 @@
  *
  * A thread can have only one ALooper associated with it.
  */
-struct ALooper;
 typedef struct ALooper ALooper;
 
 /**
@@ -44,13 +52,14 @@
  */
 ALooper* ALooper_forThread();
 
+/** Option for for ALooper_prepare(). */
 enum {
     /**
-     * Option for ALooper_prepare: this looper will accept calls to
-     * ALooper_addFd() that do not have a callback (that is provide NULL
-     * for the callback).  In this case the caller of ALooper_pollOnce()
-     * or ALooper_pollAll() MUST check the return from these functions to
-     * discover when data is available on such fds and process it.
+     * This looper will accept calls to ALooper_addFd() that do not
+     * have a callback (that is provide NULL for the callback).  In
+     * this case the caller of ALooper_pollOnce() or ALooper_pollAll()
+     * MUST check the return from these functions to discover when
+     * data is available on such fds and process it.
      */
     ALOOPER_PREPARE_ALLOW_NON_CALLBACKS = 1<<0
 };
@@ -64,9 +73,9 @@
  */
 ALooper* ALooper_prepare(int opts);
 
+/** Result from ALooper_pollOnce() and ALooper_pollAll(). */
 enum {
     /**
-     * Result from ALooper_pollOnce() and ALooper_pollAll():
      * The poll was awoken using wake() before the timeout expired
      * and no callbacks were executed and no other file descriptors were ready.
      */
@@ -176,10 +185,12 @@
  *
  * Returns ALOOPER_POLL_ERROR if an error occurred.
  *
- * Returns a value >= 0 containing an identifier if its file descriptor has data
- * and it has no callback function (requiring the caller here to handle it).
- * In this (and only this) case outFd, outEvents and outData will contain the poll
- * events and data associated with the fd, otherwise they will be set to NULL.
+ * Returns a value >= 0 containing an identifier (the same identifier
+ * `ident` passed to ALooper_addFd()) if its file descriptor has data
+ * and it has no callback function (requiring the caller here to
+ * handle it).  In this (and only this) case outFd, outEvents and
+ * outData will contain the poll events and data associated with the
+ * fd, otherwise they will be set to NULL.
  *
  * This method does not return until it has finished invoking the appropriate callbacks
  * for all file descriptors that were signalled.
@@ -254,3 +265,5 @@
 #endif
 
 #endif // ANDROID_LOOPER_H
+
+/** @} */
diff --git a/include/android/multinetwork.h b/include/android/multinetwork.h
new file mode 100644
index 0000000..6c718c9
--- /dev/null
+++ b/include/android/multinetwork.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_MULTINETWORK_H
+#define ANDROID_MULTINETWORK_H
+
+#include <netdb.h>
+#include <stdlib.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/**
+ * The corresponding C type for android.net.Network#getNetworkHandle() return
+ * values.  The Java signed long value can be safely cast to a net_handle_t:
+ *
+ *     [C]    ((net_handle_t) java_long_network_handle)
+ *     [C++]  static_cast<net_handle_t>(java_long_network_handle)
+ *
+ * as appropriate.
+ */
+typedef uint64_t net_handle_t;
+
+/**
+ * The value NETWORK_UNSPECIFIED indicates no specific network.
+ *
+ * For some functions (documented below), a previous binding may be cleared
+ * by an invocation with NETWORK_UNSPECIFIED.
+ *
+ * Depending on the context it may indicate an error.  It is expressly
+ * not used to indicate some notion of the "current default network".
+ */
+#define NETWORK_UNSPECIFIED  ((net_handle_t)0)
+
+
+/**
+ * All functions below that return an int return 0 on success or -1
+ * on failure with an appropriate errno value set.
+ */
+
+
+/**
+ * Set the network to be used by the given socket file descriptor.
+ *
+ * To clear a previous socket binding invoke with NETWORK_UNSPECIFIED.
+ *
+ * This is the equivalent of:
+ *
+ *     [ android.net.Network#bindSocket() ]
+ *     https://developer.android.com/reference/android/net/Network.html#bindSocket(java.net.Socket)
+ */
+int android_setsocknetwork(net_handle_t network, int fd);
+
+
+/**
+ * Binds the current process to |network|.  All sockets created in the future
+ * (and not explicitly bound via android_setsocknetwork()) will be bound to
+ * |network|.  All host name resolutions will be limited to |network| as well.
+ * Note that if the network identified by |network| ever disconnects, all
+ * sockets created in this way will cease to work and all host name
+ * resolutions will fail.  This is by design so an application doesn't
+ * accidentally use sockets it thinks are still bound to a particular network.
+ *
+ * To clear a previous process binding invoke with NETWORK_UNSPECIFIED.
+ *
+ * This is the equivalent of:
+ *
+ *     [ android.net.ConnectivityManager#setProcessDefaultNetwork() ]
+ *     https://developer.android.com/reference/android/net/ConnectivityManager.html#setProcessDefaultNetwork(android.net.Network)
+ */
+int android_setprocnetwork(net_handle_t network);
+
+
+/**
+ * Perform hostname resolution via the DNS servers associated with |network|.
+ *
+ * All arguments (apart from |network|) are used identically as those passed
+ * to getaddrinfo(3).  Return and error values are identical to those of
+ * getaddrinfo(3), and in particular gai_strerror(3) can be used as expected.
+ * Similar to getaddrinfo(3):
+ *     - |hints| may be NULL (in which case man page documented defaults apply)
+ *     - either |node| or |service| may be NULL, but not both
+ *     - |res| must not be NULL
+ *
+ * This is the equivalent of:
+ *
+ *     [ android.net.Network#getAllByName() ]
+ *     https://developer.android.com/reference/android/net/Network.html#getAllByName(java.lang.String)
+ */
+int android_getaddrinfofornetwork(net_handle_t network,
+        const char *node, const char *service,
+        const struct addrinfo *hints, struct addrinfo **res);
+
+__END_DECLS
+
+#endif  // ANDROID_MULTINETWORK_H
diff --git a/include/android/native_activity.h b/include/android/native_activity.h
index bc70f88..d3d99cf 100644
--- a/include/android/native_activity.h
+++ b/include/android/native_activity.h
@@ -14,6 +14,14 @@
  * limitations under the License.
  */
 
+/**
+ * @addtogroup NativeActivity Native Activity
+ * @{
+ */
+
+/**
+ * @file native_activity.h
+ */
 
 #ifndef ANDROID_NATIVE_ACTIVITY_H
 #define ANDROID_NATIVE_ACTIVITY_H
@@ -31,6 +39,9 @@
 extern "C" {
 #endif
 
+/**
+ * {@link ANativeActivityCallbacks}
+ */
 struct ANativeActivityCallbacks;
 
 /**
@@ -75,17 +86,17 @@
      * Path to this application's internal data directory.
      */
     const char* internalDataPath;
-    
+
     /**
      * Path to this application's external (removable/mountable) data directory.
      */
     const char* externalDataPath;
-    
+
     /**
      * The platform's SDK version code.
      */
     int32_t sdkVersion;
-    
+
     /**
      * This is the native instance of the application.  It is not used by
      * the framework, but can be set by the application to its own instance
@@ -119,13 +130,13 @@
      * for more information.
      */
     void (*onStart)(ANativeActivity* activity);
-    
+
     /**
      * NativeActivity has resumed.  See Java documentation for Activity.onResume()
      * for more information.
      */
     void (*onResume)(ANativeActivity* activity);
-    
+
     /**
      * Framework is asking NativeActivity to save its current instance state.
      * See Java documentation for Activity.onSaveInstanceState() for more
@@ -136,19 +147,19 @@
      * entities (pointers to memory, file descriptors, etc).
      */
     void* (*onSaveInstanceState)(ANativeActivity* activity, size_t* outSize);
-    
+
     /**
      * NativeActivity has paused.  See Java documentation for Activity.onPause()
      * for more information.
      */
     void (*onPause)(ANativeActivity* activity);
-    
+
     /**
      * NativeActivity has stopped.  See Java documentation for Activity.onStop()
      * for more information.
      */
     void (*onStop)(ANativeActivity* activity);
-    
+
     /**
      * NativeActivity is being destroyed.  See Java documentation for Activity.onDestroy()
      * for more information.
@@ -160,7 +171,7 @@
      * for example, to pause a game when it loses input focus.
      */
     void (*onWindowFocusChanged)(ANativeActivity* activity, int hasFocus);
-    
+
     /**
      * The drawing window for this native activity has been created.  You
      * can use the given native window object to start drawing.
@@ -191,13 +202,13 @@
      * returning from here.
      */
     void (*onNativeWindowDestroyed)(ANativeActivity* activity, ANativeWindow* window);
-    
+
     /**
      * The input queue for this native activity's window has been created.
      * You can use the given input queue to start retrieving input events.
      */
     void (*onInputQueueCreated)(ANativeActivity* activity, AInputQueue* queue);
-    
+
     /**
      * The input queue for this native activity's window is being destroyed.
      * You should no longer try to reference this object upon returning from this
@@ -273,7 +284,17 @@
  * API for documentation.
  */
 enum {
+    /**
+     * Implicit request to show the input window, not as the result
+     * of a direct request by the user.
+     */
     ANATIVEACTIVITY_SHOW_SOFT_INPUT_IMPLICIT = 0x0001,
+
+    /**
+     * The user has forced the input method open (such as by
+     * long-pressing menu) so it should not be closed until they
+     * explicitly do so.
+     */
     ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED = 0x0002,
 };
 
@@ -290,7 +311,15 @@
  * API for documentation.
  */
 enum {
+    /**
+     * The soft input window should only be hidden if it was not
+     * explicitly shown by the user.
+     */
     ANATIVEACTIVITY_HIDE_SOFT_INPUT_IMPLICIT_ONLY = 0x0001,
+    /**
+     * The soft input window should normally be hidden, unless it was
+     * originally shown with {@link ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED}.
+     */
     ANATIVEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS = 0x0002,
 };
 
@@ -308,3 +337,4 @@
 
 #endif // ANDROID_NATIVE_ACTIVITY_H
 
+/** @} */
diff --git a/include/android/native_window.h b/include/android/native_window.h
index 2f4f2d3..cf07f1a 100644
--- a/include/android/native_window.h
+++ b/include/android/native_window.h
@@ -14,6 +14,15 @@
  * limitations under the License.
  */
 
+/**
+ * @addtogroup NativeActivity Native Activity
+ * @{
+ */
+
+/**
+ * @file native_window.h
+ */
+
 #ifndef ANDROID_NATIVE_WINDOW_H
 #define ANDROID_NATIVE_WINDOW_H
 
@@ -23,18 +32,31 @@
 extern "C" {
 #endif
 
-/*
+/**
  * Pixel formats that a window can use.
  */
 enum {
+    /** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Alpha: 8 bits. **/
     WINDOW_FORMAT_RGBA_8888          = 1,
+    /** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Unused: 8 bits. **/
     WINDOW_FORMAT_RGBX_8888          = 2,
+    /** Red: 5 bits, Green: 6 bits, Blue: 5 bits. **/
     WINDOW_FORMAT_RGB_565            = 4,
 };
 
 struct ANativeWindow;
+/**
+ * {@link ANativeWindow} is opaque type that provides access to a native window.
+ *
+ * A pointer can be obtained using ANativeWindow_fromSurface().
+ */
 typedef struct ANativeWindow ANativeWindow;
 
+/**
+ * {@link ANativeWindow} is a struct that represents a windows buffer.
+ *
+ * A pointer can be obtained using ANativeWindow_lock().
+ */
 typedef struct ANativeWindow_Buffer {
     // The number of pixels that are show horizontally.
     int32_t width;
@@ -51,7 +73,7 @@
 
     // The actual bits.
     void* bits;
-    
+
     // Do not touch.
     uint32_t reserved[6];
 } ANativeWindow_Buffer;
@@ -67,25 +89,25 @@
  */
 void ANativeWindow_release(ANativeWindow* window);
 
-/*
+/**
  * Return the current width in pixels of the window surface.  Returns a
  * negative value on error.
  */
 int32_t ANativeWindow_getWidth(ANativeWindow* window);
 
-/*
+/**
  * Return the current height in pixels of the window surface.  Returns a
  * negative value on error.
  */
 int32_t ANativeWindow_getHeight(ANativeWindow* window);
 
-/*
+/**
  * Return the current pixel format of the window surface.  Returns a
  * negative value on error.
  */
 int32_t ANativeWindow_getFormat(ANativeWindow* window);
 
-/*
+/**
  * Change the format and size of the window buffers.
  *
  * The width and height control the number of pixels in the buffers, not the
@@ -124,3 +146,5 @@
 #endif
 
 #endif // ANDROID_NATIVE_WINDOW_H
+
+/** @} */
diff --git a/include/android/native_window_jni.h b/include/android/native_window_jni.h
index b9e72ef..60a36c3 100644
--- a/include/android/native_window_jni.h
+++ b/include/android/native_window_jni.h
@@ -14,6 +14,15 @@
  * limitations under the License.
  */
 
+/**
+ * @addtogroup NativeActivity Native Activity
+ * @{
+ */
+
+/**
+ * @file native_window_jni.h
+ */
+
 #ifndef ANDROID_NATIVE_WINDOW_JNI_H
 #define ANDROID_NATIVE_WINDOW_JNI_H
 
@@ -38,3 +47,5 @@
 #endif
 
 #endif // ANDROID_NATIVE_WINDOW_H
+
+/** @} */
diff --git a/include/android/obb.h b/include/android/obb.h
index 65e9b2a..4c6d9d7 100644
--- a/include/android/obb.h
+++ b/include/android/obb.h
@@ -14,6 +14,14 @@
  * limitations under the License.
  */
 
+/**
+ * @addtogroup Storage
+ * @{
+ */
+
+/**
+ * @file obb.h
+ */
 
 #ifndef ANDROID_OBB_H
 #define ANDROID_OBB_H
@@ -25,9 +33,12 @@
 #endif
 
 struct AObbInfo;
+/** {@link AObbInfo} is an opaque type representing information for obb storage. */
 typedef struct AObbInfo AObbInfo;
 
+/** Flag for an obb file, returned by AObbInfo_getFlags(). */
 enum {
+    /** overlay */
     AOBBINFO_OVERLAY = 0x0001,
 };
 
@@ -61,3 +72,5 @@
 #endif
 
 #endif      // ANDROID_OBB_H
+
+/** @} */
diff --git a/include/android/rect.h b/include/android/rect.h
index bcd42a9..80741c0 100644
--- a/include/android/rect.h
+++ b/include/android/rect.h
@@ -14,6 +14,14 @@
  * limitations under the License.
  */
 
+/**
+ * @addtogroup NativeActivity Native Activity
+ * @{
+ */
+
+/**
+ * @file rect.h
+ */
 
 #ifndef ANDROID_RECT_H
 #define ANDROID_RECT_H
@@ -24,13 +32,24 @@
 extern "C" {
 #endif
 
+/**
+ * {@link ARect} is a struct that represents a rectangular window area.
+ *
+ * It is used with {@link
+ * ANativeActivityCallbacks::onContentRectChanged} event callback and
+ * ANativeWindow_lock() function.
+ */
 typedef struct ARect {
 #ifdef __cplusplus
     typedef int32_t value_type;
 #endif
+    /** left position */
     int32_t left;
+    /** top position */
     int32_t top;
+    /** left position */
     int32_t right;
+    /** bottom position */
     int32_t bottom;
 } ARect;
 
@@ -39,3 +58,5 @@
 #endif
 
 #endif // ANDROID_RECT_H
+
+/** @} */
diff --git a/include/android/sensor.h b/include/android/sensor.h
index 129ea3e..9472ad6 100644
--- a/include/android/sensor.h
+++ b/include/android/sensor.h
@@ -14,6 +14,14 @@
  * limitations under the License.
  */
 
+/**
+ * @addtogroup Sensor
+ * @{
+ */
+
+/**
+ * @file sensor.h
+ */
 
 #ifndef ANDROID_SENSOR_H
 #define ANDROID_SENSOR_H
@@ -34,7 +42,7 @@
  *   - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
  */
 
-/*
+/**
  * Structures and functions to receive and process sensor events in
  * native code.
  *
@@ -49,41 +57,105 @@
 #endif
 
 
-/*
- * Sensor types
- * (keep in sync with hardware/sensor.h)
+/**
+ * Sensor types.
+ * (keep in sync with hardware/sensors.h)
  */
-
 enum {
-    ASENSOR_TYPE_ACCELEROMETER      = 1,
-    ASENSOR_TYPE_MAGNETIC_FIELD     = 2,
-    ASENSOR_TYPE_GYROSCOPE          = 4,
-    ASENSOR_TYPE_LIGHT              = 5,
-    ASENSOR_TYPE_PROXIMITY          = 8
+    /**
+     * {@link ASENSOR_TYPE_ACCELEROMETER}
+     * reporting-mode: continuous
+     *
+     *  All values are in SI units (m/s^2) and measure the acceleration of the
+     *  device minus the force of gravity.
+     */
+    ASENSOR_TYPE_ACCELEROMETER       = 1,
+    /**
+     * {@link ASENSOR_TYPE_MAGNETIC_FIELD}
+     * reporting-mode: continuous
+     *
+     *  All values are in micro-Tesla (uT) and measure the geomagnetic
+     *  field in the X, Y and Z axis.
+     */
+    ASENSOR_TYPE_MAGNETIC_FIELD      = 2,
+    /**
+     * {@link ASENSOR_TYPE_GYROSCOPE}
+     * reporting-mode: continuous
+     *
+     *  All values are in radians/second and measure the rate of rotation
+     *  around the X, Y and Z axis.
+     */
+    ASENSOR_TYPE_GYROSCOPE           = 4,
+    /**
+     * {@link ASENSOR_TYPE_LIGHT}
+     * reporting-mode: on-change
+     *
+     * The light sensor value is returned in SI lux units.
+     */
+    ASENSOR_TYPE_LIGHT               = 5,
+    /**
+     * {@link ASENSOR_TYPE_PROXIMITY}
+     * reporting-mode: on-change
+     *
+     * The proximity sensor which turns the screen off and back on during calls is the
+     * wake-up proximity sensor. Implement wake-up proximity sensor before implementing
+     * a non wake-up proximity sensor. For the wake-up proximity sensor set the flag
+     * SENSOR_FLAG_WAKE_UP.
+     * The value corresponds to the distance to the nearest object in centimeters.
+     */
+    ASENSOR_TYPE_PROXIMITY           = 8,
+    /**
+     * {@link ASENSOR_TYPE_LINEAR_ACCELERATION}
+     * reporting-mode: continuous
+     *
+     *  All values are in SI units (m/s^2) and measure the acceleration of the
+     *  device not including the force of gravity.
+     */
+    ASENSOR_TYPE_LINEAR_ACCELERATION = 10
 };
 
-/*
- * Sensor accuracy measure
+/**
+ * Sensor accuracy measure.
  */
 enum {
+    /** no contact */
+    ASENSOR_STATUS_NO_CONTACT       = -1,
+    /** unreliable */
     ASENSOR_STATUS_UNRELIABLE       = 0,
+    /** low accuracy */
     ASENSOR_STATUS_ACCURACY_LOW     = 1,
+    /** medium accuracy */
     ASENSOR_STATUS_ACCURACY_MEDIUM  = 2,
+    /** high accuracy */
     ASENSOR_STATUS_ACCURACY_HIGH    = 3
 };
 
+/**
+ * Sensor Reporting Modes.
+ */
+enum {
+    /** continuous reporting */
+    AREPORTING_MODE_CONTINUOUS = 0,
+    /** reporting on change */
+    AREPORTING_MODE_ON_CHANGE = 1,
+    /** on shot reporting */
+    AREPORTING_MODE_ONE_SHOT = 2,
+    /** special trigger reporting */
+    AREPORTING_MODE_SPECIAL_TRIGGER = 3
+};
+
 /*
  * A few useful constants
  */
 
-/* Earth's gravity in m/s^2 */
+/** Earth's gravity in m/s^2 */
 #define ASENSOR_STANDARD_GRAVITY            (9.80665f)
-/* Maximum magnetic field on Earth's surface in uT */
+/** Maximum magnetic field on Earth's surface in uT */
 #define ASENSOR_MAGNETIC_FIELD_EARTH_MAX    (60.0f)
-/* Minimum magnetic field on Earth's surface in uT*/
+/** Minimum magnetic field on Earth's surface in uT*/
 #define ASENSOR_MAGNETIC_FIELD_EARTH_MIN    (30.0f)
 
-/*
+/**
  * A sensor event.
  */
 
@@ -130,6 +202,11 @@
   };
 } AUncalibratedEvent;
 
+typedef struct AHeartRateEvent {
+  float bpm;
+  int8_t status;
+} AHeartRateEvent;
+
 /* NOTE: Must match hardware/sensors.h */
 typedef struct ASensorEvent {
     int32_t version; /* sizeof(struct ASensorEvent) */
@@ -151,57 +228,147 @@
             AUncalibratedEvent uncalibrated_gyro;
             AUncalibratedEvent uncalibrated_magnetic;
             AMetaDataEvent meta_data;
+            AHeartRateEvent heart_rate;
         };
         union {
             uint64_t        data[8];
             uint64_t        step_counter;
         } u64;
     };
-    int32_t reserved1[4];
+
+    uint32_t flags;
+    int32_t reserved1[3];
 } ASensorEvent;
 
 struct ASensorManager;
+/**
+ * {@link ASensorManager} is an opaque type to manage sensors and
+ * events queues.
+ *
+ * {@link ASensorManager} is a singleton that can be obtained using
+ * ASensorManager_getInstance().
+ *
+ * This file provides a set of functions that uses {@link
+ * ASensorManager} to access and list hardware sensors, and
+ * create and destroy event queues:
+ * - ASensorManager_getSensorList()
+ * - ASensorManager_getDefaultSensor()
+ * - ASensorManager_getDefaultSensorEx()
+ * - ASensorManager_createEventQueue()
+ * - ASensorManager_destroyEventQueue()
+ */
 typedef struct ASensorManager ASensorManager;
 
+
 struct ASensorEventQueue;
+/**
+ * {@link ASensorEventQueue} is an opaque type that provides access to
+ * {@link ASensorEvent} from hardware sensors.
+ *
+ * A new {@link ASensorEventQueue} can be obtained using ASensorManager_createEventQueue().
+ *
+ * This file provides a set of functions to enable and disable
+ * sensors, check and get events, and set event rates on a {@link
+ * ASensorEventQueue}.
+ * - ASensorEventQueue_enableSensor()
+ * - ASensorEventQueue_disableSensor()
+ * - ASensorEventQueue_hasEvents()
+ * - ASensorEventQueue_getEvents()
+ * - ASensorEventQueue_setEventRate()
+ */
 typedef struct ASensorEventQueue ASensorEventQueue;
 
 struct ASensor;
+/**
+ * {@link ASensor} is an opaque type that provides information about
+ * an hardware sensors.
+ *
+ * A {@link ASensor} pointer can be obtained using
+ * ASensorManager_getDefaultSensor(),
+ * ASensorManager_getDefaultSensorEx() or from a {@link ASensorList}.
+ *
+ * This file provides a set of functions to access properties of a
+ * {@link ASensor}:
+ * - ASensor_getName()
+ * - ASensor_getVendor()
+ * - ASensor_getType()
+ * - ASensor_getResolution()
+ * - ASensor_getMinDelay()
+ * - ASensor_getFifoMaxEventCount()
+ * - ASensor_getFifoReservedEventCount()
+ * - ASensor_getStringType()
+ * - ASensor_getReportingMode()
+ * - ASensor_isWakeUpSensor()
+ */
 typedef struct ASensor ASensor;
+/**
+ * {@link ASensorRef} is a type for constant pointers to {@link ASensor}.
+ *
+ * This is used to define entry in {@link ASensorList} arrays.
+ */
 typedef ASensor const* ASensorRef;
+/**
+ * {@link ASensorList} is an array of reference to {@link ASensor}.
+ *
+ * A {@link ASensorList} can be initialized using ASensorManager_getSensorList().
+ */
 typedef ASensorRef const* ASensorList;
 
 /*****************************************************************************/
 
-/*
- * Get a reference to the sensor manager. ASensorManager is a singleton.
+/**
+ * Get a reference to the sensor manager. ASensorManager is a singleton
+ * per package as different packages may have access to different sensors.
+ *
+ * Deprecated: Use ASensorManager_getInstanceForPackage(const char*) instead.
  *
  * Example:
  *
  *     ASensorManager* sensorManager = ASensorManager_getInstance();
  *
  */
-ASensorManager* ASensorManager_getInstance();
-
+__attribute__ ((deprecated)) ASensorManager* ASensorManager_getInstance();
 
 /*
+ * Get a reference to the sensor manager. ASensorManager is a singleton
+ * per package as different packages may have access to different sensors.
+ *
+ * Example:
+ *
+ *    ASensorManager* sensorManager = ASensorManager_getInstanceForPackage("foo.bar.baz");
+ *
+ */
+ASensorManager* ASensorManager_getInstanceForPackage(const char* packageName);
+
+/**
  * Returns the list of available sensors.
  */
 int ASensorManager_getSensorList(ASensorManager* manager, ASensorList* list);
 
-/*
+/**
  * Returns the default sensor for the given type, or NULL if no sensor
- * of that type exist.
+ * of that type exists.
  */
 ASensor const* ASensorManager_getDefaultSensor(ASensorManager* manager, int type);
 
-/*
+/**
+ * Returns the default sensor with the given type and wakeUp properties or NULL if no sensor
+ * of this type and wakeUp properties exists.
+ */
+ASensor const* ASensorManager_getDefaultSensorEx(ASensorManager* manager, int type,
+        bool wakeUp);
+
+/**
  * Creates a new sensor event queue and associate it with a looper.
+ *
+ * "ident" is a identifier for the events that will be returned when
+ * calling ALooper_pollOnce(). The identifier must be >= 0, or
+ * ALOOPER_POLL_CALLBACK if providing a non-NULL callback.
  */
 ASensorEventQueue* ASensorManager_createEventQueue(ASensorManager* manager,
         ALooper* looper, int ident, ALooper_callbackFunc callback, void* data);
 
-/*
+/**
  * Destroys the event queue and free all resources associated to it.
  */
 int ASensorManager_destroyEventQueue(ASensorManager* manager, ASensorEventQueue* queue);
@@ -209,17 +376,17 @@
 
 /*****************************************************************************/
 
-/*
+/**
  * Enable the selected sensor. Returns a negative error code on failure.
  */
 int ASensorEventQueue_enableSensor(ASensorEventQueue* queue, ASensor const* sensor);
 
-/*
+/**
  * Disable the selected sensor. Returns a negative error code on failure.
  */
 int ASensorEventQueue_disableSensor(ASensorEventQueue* queue, ASensor const* sensor);
 
-/*
+/**
  * Sets the delivery rate of events in microseconds for the given sensor.
  * Note that this is a hint only, generally event will arrive at a higher
  * rate. It is an error to set a rate inferior to the value returned by
@@ -228,14 +395,14 @@
  */
 int ASensorEventQueue_setEventRate(ASensorEventQueue* queue, ASensor const* sensor, int32_t usec);
 
-/*
+/**
  * Returns true if there are one or more events available in the
  * sensor queue.  Returns 1 if the queue has events; 0 if
  * it does not have events; and a negative value if there is an error.
  */
 int ASensorEventQueue_hasEvents(ASensorEventQueue* queue);
 
-/*
+/**
  * Returns the next available events from the queue.  Returns a negative
  * value if no events are available or an error has occurred, otherwise
  * the number of events returned.
@@ -254,36 +421,63 @@
 
 /*****************************************************************************/
 
-/*
+/**
  * Returns this sensor's name (non localized)
  */
 const char* ASensor_getName(ASensor const* sensor);
 
-/*
+/**
  * Returns this sensor's vendor's name (non localized)
  */
 const char* ASensor_getVendor(ASensor const* sensor);
 
-/*
+/**
  * Return this sensor's type
  */
 int ASensor_getType(ASensor const* sensor);
 
-/*
+/**
  * Returns this sensors's resolution
  */
 float ASensor_getResolution(ASensor const* sensor);
 
-/*
+/**
  * Returns the minimum delay allowed between events in microseconds.
  * A value of zero means that this sensor doesn't report events at a
  * constant rate, but rather only when a new data is available.
  */
 int ASensor_getMinDelay(ASensor const* sensor);
 
+/**
+ * Returns the maximum size of batches for this sensor. Batches will often be
+ * smaller, as the hardware fifo might be used for other sensors.
+ */
+int ASensor_getFifoMaxEventCount(ASensor const* sensor);
+
+/**
+ * Returns the hardware batch fifo size reserved to this sensor.
+ */
+int ASensor_getFifoReservedEventCount(ASensor const* sensor);
+
+/**
+ * Returns this sensor's string type.
+ */
+const char* ASensor_getStringType(ASensor const* sensor);
+
+/**
+ * Returns the reporting mode for this sensor. One of AREPORTING_MODE_* constants.
+ */
+int ASensor_getReportingMode(ASensor const* sensor);
+
+/**
+ * Returns true if this is a wake up sensor, false otherwise.
+ */
+bool ASensor_isWakeUpSensor(ASensor const* sensor);
 
 #ifdef __cplusplus
 };
 #endif
 
 #endif // ANDROID_SENSOR_H
+
+/** @} */
diff --git a/include/android/storage_manager.h b/include/android/storage_manager.h
index bad2491..7f2ee08 100644
--- a/include/android/storage_manager.h
+++ b/include/android/storage_manager.h
@@ -14,6 +14,14 @@
  * limitations under the License.
  */
 
+/**
+ * @addtogroup Storage
+ * @{
+ */
+
+/**
+ * @file storage_manager.h
+ */
 
 #ifndef ANDROID_STORAGE_MANAGER_H
 #define ANDROID_STORAGE_MANAGER_H
@@ -25,55 +33,62 @@
 #endif
 
 struct AStorageManager;
+/**
+ * {@link AStorageManager} manages application OBB storage, a pointer
+ * can be obtained with AStorageManager_new().
+ */
 typedef struct AStorageManager AStorageManager;
 
+/**
+ * The different states of a OBB storage passed to AStorageManager_obbCallbackFunc().
+ */
 enum {
-    /*
+    /**
      * The OBB container is now mounted and ready for use. Can be returned
      * as the status for callbacks made during asynchronous OBB actions.
      */
     AOBB_STATE_MOUNTED = 1,
 
-    /*
+    /**
      * The OBB container is now unmounted and not usable. Can be returned
      * as the status for callbacks made during asynchronous OBB actions.
      */
     AOBB_STATE_UNMOUNTED = 2,
 
-    /*
+    /**
      * There was an internal system error encountered while trying to
      * mount the OBB. Can be returned as the status for callbacks made
      * during asynchronous OBB actions.
      */
     AOBB_STATE_ERROR_INTERNAL = 20,
 
-    /*
+    /**
      * The OBB could not be mounted by the system. Can be returned as the
      * status for callbacks made during asynchronous OBB actions.
      */
     AOBB_STATE_ERROR_COULD_NOT_MOUNT = 21,
 
-    /*
+    /**
      * The OBB could not be unmounted. This most likely indicates that a
      * file is in use on the OBB. Can be returned as the status for
      * callbacks made during asynchronous OBB actions.
      */
     AOBB_STATE_ERROR_COULD_NOT_UNMOUNT = 22,
 
-    /*
+    /**
      * A call was made to unmount the OBB when it was not mounted. Can be
      * returned as the status for callbacks made during asynchronous OBB
      * actions.
      */
     AOBB_STATE_ERROR_NOT_MOUNTED = 23,
 
-    /*
+    /**
      * The OBB has already been mounted. Can be returned as the status for
      * callbacks made during asynchronous OBB actions.
      */
     AOBB_STATE_ERROR_ALREADY_MOUNTED = 24,
 
-    /*
+    /**
      * The current application does not have permission to use this OBB.
      * This could be because the OBB indicates it's owned by a different
      * package. Can be returned as the status for callbacks made during
@@ -94,6 +109,16 @@
 
 /**
  * Callback function for asynchronous calls made on OBB files.
+ *
+ * "state" is one of the following constants:
+ * - {@link AOBB_STATE_MOUNTED}
+ * - {@link AOBB_STATE_UNMOUNTED}
+ * - {@link AOBB_STATE_ERROR_INTERNAL}
+ * - {@link AOBB_STATE_ERROR_COULD_NOT_MOUNT}
+ * - {@link AOBB_STATE_ERROR_COULD_NOT_UNMOUNT}
+ * - {@link AOBB_STATE_ERROR_NOT_MOUNTED}
+ * - {@link AOBB_STATE_ERROR_ALREADY_MOUNTED}
+ * - {@link AOBB_STATE_ERROR_PERMISSION_DENIED}
  */
 typedef void (*AStorageManager_obbCallbackFunc)(const char* filename, const int32_t state, void* data);
 
@@ -125,3 +150,5 @@
 #endif
 
 #endif      // ANDROID_STORAGE_MANAGER_H
+
+/** @} */
diff --git a/include/android/trace.h b/include/android/trace.h
new file mode 100644
index 0000000..e42e334
--- /dev/null
+++ b/include/android/trace.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef ANDROID_NATIVE_TRACE_H
+#define ANDROID_NATIVE_TRACE_H
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Returns true if tracing is enabled. Use this signal to avoid expensive computation only necessary
+ * when tracing is enabled.
+ */
+bool ATrace_isEnabled();
+
+/**
+ * Writes a tracing message to indicate that the given section of code has begun. This call must be
+ * followed by a corresponding call to endSection() on the same thread.
+ *
+ * Note: At this time the vertical bar character '|' and newline character '\n' are used internally
+ * by the tracing mechanism. If sectionName contains these characters they will be replaced with a
+ * space character in the trace.
+ */
+void ATrace_beginSection(const char* sectionName);
+
+/**
+ * Writes a tracing message to indicate that a given section of code has ended. This call must be
+ * preceeded by a corresponding call to beginSection(char*) on the same thread. Calling this method
+ * will mark the end of the most recently begun section of code, so care must be taken to ensure
+ * that beginSection / endSection pairs are properly nested and called from the same thread.
+ */
+void ATrace_endSection();
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif // ANDROID_NATIVE_TRACE_H
diff --git a/include/android/window.h b/include/android/window.h
index 2ab192b..436bf3a 100644
--- a/include/android/window.h
+++ b/include/android/window.h
@@ -14,6 +14,14 @@
  * limitations under the License.
  */
 
+/**
+ * @addtogroup NativeActivity Native Activity
+ * @{
+ */
+
+/**
+ * @file window.h
+ */
 
 #ifndef ANDROID_WINDOW_H
 #define ANDROID_WINDOW_H
@@ -26,28 +34,184 @@
  * Window flags, as per the Java API at android.view.WindowManager.LayoutParams.
  */
 enum {
+    /**
+     * As long as this window is visible to the user, allow the lock
+     * screen to activate while the screen is on.  This can be used
+     * independently, or in combination with {@link
+     * AWINDOW_FLAG_KEEP_SCREEN_ON} and/or {@link
+     * AWINDOW_FLAG_SHOW_WHEN_LOCKED}
+     */
     AWINDOW_FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001,
+    /** Everything behind this window will be dimmed. */
     AWINDOW_FLAG_DIM_BEHIND                 = 0x00000002,
+    /**
+     * Blur everything behind this window.
+     * @deprecated Blurring is no longer supported.
+     */
     AWINDOW_FLAG_BLUR_BEHIND                = 0x00000004,
+    /**
+     * This window won't ever get key input focus, so the
+     * user can not send key or other button events to it.  Those will
+     * instead go to whatever focusable window is behind it.  This flag
+     * will also enable {@link AWINDOW_FLAG_NOT_TOUCH_MODAL} whether or not that
+     * is explicitly set.
+     *
+     * Setting this flag also implies that the window will not need to
+     * interact with
+     * a soft input method, so it will be Z-ordered and positioned
+     * independently of any active input method (typically this means it
+     * gets Z-ordered on top of the input method, so it can use the full
+     * screen for its content and cover the input method if needed.  You
+     * can use {@link AWINDOW_FLAG_ALT_FOCUSABLE_IM} to modify this behavior.
+     */
     AWINDOW_FLAG_NOT_FOCUSABLE              = 0x00000008,
+    /** this window can never receive touch events. */
     AWINDOW_FLAG_NOT_TOUCHABLE              = 0x00000010,
+    /**
+     * Even when this window is focusable (its
+     * {@link AWINDOW_FLAG_NOT_FOCUSABLE} is not set), allow any pointer events
+     * outside of the window to be sent to the windows behind it.  Otherwise
+     * it will consume all pointer events itself, regardless of whether they
+     * are inside of the window.
+     */
     AWINDOW_FLAG_NOT_TOUCH_MODAL            = 0x00000020,
+    /**
+     * When set, if the device is asleep when the touch
+     * screen is pressed, you will receive this first touch event.  Usually
+     * the first touch event is consumed by the system since the user can
+     * not see what they are pressing on.
+     *
+     * @deprecated This flag has no effect.
+     */
     AWINDOW_FLAG_TOUCHABLE_WHEN_WAKING      = 0x00000040,
+    /**
+     * As long as this window is visible to the user, keep
+     * the device's screen turned on and bright.
+     */
     AWINDOW_FLAG_KEEP_SCREEN_ON             = 0x00000080,
+    /**
+     * Place the window within the entire screen, ignoring
+     * decorations around the border (such as the status bar).  The
+     * window must correctly position its contents to take the screen
+     * decoration into account.
+     */
     AWINDOW_FLAG_LAYOUT_IN_SCREEN           = 0x00000100,
+    /** allow window to extend outside of the screen. */
     AWINDOW_FLAG_LAYOUT_NO_LIMITS           = 0x00000200,
+    /**
+     * Hide all screen decorations (such as the status
+     * bar) while this window is displayed.  This allows the window to
+     * use the entire display space for itself -- the status bar will
+     * be hidden when an app window with this flag set is on the top
+     * layer. A fullscreen window will ignore a value of {@link
+     * AWINDOW_SOFT_INPUT_ADJUST_RESIZE}; the window will stay
+     * fullscreen and will not resize.
+     */
     AWINDOW_FLAG_FULLSCREEN                 = 0x00000400,
+    /**
+     * Override {@link AWINDOW_FLAG_FULLSCREEN} and force the
+     * screen decorations (such as the status bar) to be shown.
+     */
     AWINDOW_FLAG_FORCE_NOT_FULLSCREEN       = 0x00000800,
+    /**
+     * Turn on dithering when compositing this window to
+     * the screen.
+     * @deprecated This flag is no longer used.
+     */
     AWINDOW_FLAG_DITHER                     = 0x00001000,
+    /**
+     * Treat the content of the window as secure, preventing
+     * it from appearing in screenshots or from being viewed on non-secure
+     * displays.
+     */
     AWINDOW_FLAG_SECURE                     = 0x00002000,
+    /**
+     * A special mode where the layout parameters are used
+     * to perform scaling of the surface when it is composited to the
+     * screen.
+     */
     AWINDOW_FLAG_SCALED                     = 0x00004000,
+    /**
+     * Intended for windows that will often be used when the user is
+     * holding the screen against their face, it will aggressively
+     * filter the event stream to prevent unintended presses in this
+     * situation that may not be desired for a particular window, when
+     * such an event stream is detected, the application will receive
+     * a {@link AMOTION_EVENT_ACTION_CANCEL} to indicate this so
+     * applications can handle this accordingly by taking no action on
+     * the event until the finger is released.
+     */
     AWINDOW_FLAG_IGNORE_CHEEK_PRESSES       = 0x00008000,
+    /**
+     * A special option only for use in combination with
+     * {@link AWINDOW_FLAG_LAYOUT_IN_SCREEN}.  When requesting layout in the
+     * screen your window may appear on top of or behind screen decorations
+     * such as the status bar.  By also including this flag, the window
+     * manager will report the inset rectangle needed to ensure your
+     * content is not covered by screen decorations.
+     */
     AWINDOW_FLAG_LAYOUT_INSET_DECOR         = 0x00010000,
+    /**
+     * Invert the state of {@link AWINDOW_FLAG_NOT_FOCUSABLE} with
+     * respect to how this window interacts with the current method.
+     * That is, if FLAG_NOT_FOCUSABLE is set and this flag is set,
+     * then the window will behave as if it needs to interact with the
+     * input method and thus be placed behind/away from it; if {@link
+     * AWINDOW_FLAG_NOT_FOCUSABLE} is not set and this flag is set,
+     * then the window will behave as if it doesn't need to interact
+     * with the input method and can be placed to use more space and
+     * cover the input method.
+     */
     AWINDOW_FLAG_ALT_FOCUSABLE_IM           = 0x00020000,
+    /**
+     * If you have set {@link AWINDOW_FLAG_NOT_TOUCH_MODAL}, you
+     * can set this flag to receive a single special MotionEvent with
+     * the action
+     * {@link AMOTION_EVENT_ACTION_OUTSIDE} for
+     * touches that occur outside of your window.  Note that you will not
+     * receive the full down/move/up gesture, only the location of the
+     * first down as an {@link AMOTION_EVENT_ACTION_OUTSIDE}.
+     */
     AWINDOW_FLAG_WATCH_OUTSIDE_TOUCH        = 0x00040000,
+    /**
+     * Special flag to let windows be shown when the screen
+     * is locked. This will let application windows take precedence over
+     * key guard or any other lock screens. Can be used with
+     * {@link AWINDOW_FLAG_KEEP_SCREEN_ON} to turn screen on and display windows
+     * directly before showing the key guard window.  Can be used with
+     * {@link AWINDOW_FLAG_DISMISS_KEYGUARD} to automatically fully dismisss
+     * non-secure keyguards.  This flag only applies to the top-most
+     * full-screen window.
+     */
     AWINDOW_FLAG_SHOW_WHEN_LOCKED           = 0x00080000,
+    /**
+     * Ask that the system wallpaper be shown behind
+     * your window.  The window surface must be translucent to be able
+     * to actually see the wallpaper behind it; this flag just ensures
+     * that the wallpaper surface will be there if this window actually
+     * has translucent regions.
+     */
     AWINDOW_FLAG_SHOW_WALLPAPER             = 0x00100000,
+    /**
+     * When set as a window is being added or made
+     * visible, once the window has been shown then the system will
+     * poke the power manager's user activity (as if the user had woken
+     * up the device) to turn the screen on.
+     */
     AWINDOW_FLAG_TURN_SCREEN_ON             = 0x00200000,
+    /**
+     * When set the window will cause the keyguard to
+     * be dismissed, only if it is not a secure lock keyguard.  Because such
+     * a keyguard is not needed for security, it will never re-appear if
+     * the user navigates to another window (in contrast to
+     * {@link AWINDOW_FLAG_SHOW_WHEN_LOCKED}, which will only temporarily
+     * hide both secure and non-secure keyguards but ensure they reappear
+     * when the user moves to another UI that doesn't hide them).
+     * If the keyguard is currently active and is secure (requires an
+     * unlock pattern) than the user will still need to confirm it before
+     * seeing this window, unless {@link AWINDOW_FLAG_SHOW_WHEN_LOCKED} has
+     * also been set.
+     */
     AWINDOW_FLAG_DISMISS_KEYGUARD           = 0x00400000,
 };
 
@@ -56,3 +220,5 @@
 #endif
 
 #endif // ANDROID_WINDOW_H
+
+/** @} */
diff --git a/include/batteryservice/BatteryService.h b/include/batteryservice/BatteryService.h
index 829061a..912dcf6 100644
--- a/include/batteryservice/BatteryService.h
+++ b/include/batteryservice/BatteryService.h
@@ -18,6 +18,7 @@
 #define ANDROID_BATTERYSERVICE_H
 
 #include <binder/Parcel.h>
+#include <sys/types.h>
 #include <utils/Errors.h>
 #include <utils/String8.h>
 
@@ -43,24 +44,43 @@
     BATTERY_HEALTH_COLD = 7, // equals BatteryManager.BATTERY_HEALTH_COLD constant
 };
 
+// must be kept in sync with definitions in BatteryProperty.java
+enum {
+    BATTERY_PROP_CHARGE_COUNTER = 1, // equals BatteryProperty.CHARGE_COUNTER constant
+    BATTERY_PROP_CURRENT_NOW = 2, // equals BatteryProperty.CURRENT_NOW constant
+    BATTERY_PROP_CURRENT_AVG = 3, // equals BatteryProperty.CURRENT_AVG constant
+    BATTERY_PROP_CAPACITY = 4, // equals BatteryProperty.CAPACITY constant
+    BATTERY_PROP_ENERGY_COUNTER = 5, // equals BatteryProperty.ENERGY_COUNTER constant
+};
+
 struct BatteryProperties {
     bool chargerAcOnline;
     bool chargerUsbOnline;
     bool chargerWirelessOnline;
+    int maxChargingCurrent;
+    int maxChargingVoltage;
     int batteryStatus;
     int batteryHealth;
     bool batteryPresent;
     int batteryLevel;
     int batteryVoltage;
-    int batteryCurrentNow;
-    int batteryChargeCounter;
     int batteryTemperature;
+    int batteryCurrent;
+    int batteryCycleCount;
+    int batteryFullCharge;
     String8 batteryTechnology;
 
     status_t writeToParcel(Parcel* parcel) const;
     status_t readFromParcel(Parcel* parcel);
 };
 
+struct BatteryProperty {
+    int64_t valueInt64;
+
+    status_t writeToParcel(Parcel* parcel) const;
+    status_t readFromParcel(Parcel* parcel);
+};
+
 }; // namespace android
 
 #endif // ANDROID_BATTERYSERVICE_H
diff --git a/include/batteryservice/IBatteryPropertiesRegistrar.h b/include/batteryservice/IBatteryPropertiesRegistrar.h
index 8d28b1d..eca075d 100644
--- a/include/batteryservice/IBatteryPropertiesRegistrar.h
+++ b/include/batteryservice/IBatteryPropertiesRegistrar.h
@@ -26,6 +26,7 @@
 enum {
     REGISTER_LISTENER = IBinder::FIRST_CALL_TRANSACTION,
     UNREGISTER_LISTENER,
+    GET_PROPERTY,
 };
 
 class IBatteryPropertiesRegistrar : public IInterface {
@@ -34,6 +35,7 @@
 
     virtual void registerListener(const sp<IBatteryPropertiesListener>& listener) = 0;
     virtual void unregisterListener(const sp<IBatteryPropertiesListener>& listener) = 0;
+    virtual status_t getProperty(int id, struct BatteryProperty *val) = 0;
 };
 
 class BnBatteryPropertiesRegistrar : public BnInterface<IBatteryPropertiesRegistrar> {
diff --git a/include/binder/AppOpsManager.h b/include/binder/AppOpsManager.h
index 256cb94..042927c 100644
--- a/include/binder/AppOpsManager.h
+++ b/include/binder/AppOpsManager.h
@@ -63,7 +63,35 @@
         OP_ACCESS_NOTIFICATIONS = 25,
         OP_CAMERA = 26,
         OP_RECORD_AUDIO = 27,
-        OP_PLAY_AUDIO = 28
+        OP_PLAY_AUDIO = 28,
+        OP_READ_CLIPBOARD = 29,
+        OP_WRITE_CLIPBOARD = 30,
+        OP_TAKE_MEDIA_BUTTONS = 31,
+        OP_TAKE_AUDIO_FOCUS = 32,
+        OP_AUDIO_MASTER_VOLUME = 33,
+        OP_AUDIO_VOICE_VOLUME = 34,
+        OP_AUDIO_RING_VOLUME = 35,
+        OP_AUDIO_MEDIA_VOLUME = 36,
+        OP_AUDIO_ALARM_VOLUME = 37,
+        OP_AUDIO_NOTIFICATION_VOLUME = 38,
+        OP_AUDIO_BLUETOOTH_VOLUME = 39,
+        OP_WAKE_LOCK = 40,
+        OP_MONITOR_LOCATION = 41,
+        OP_MONITOR_HIGH_POWER_LOCATION = 42,
+        OP_GET_USAGE_STATS = 43,
+        OP_MUTE_MICROPHONE = 44,
+        OP_TOAST_WINDOW = 45,
+        OP_PROJECT_MEDIA = 46,
+        OP_ACTIVATE_VPN = 47,
+        OP_WRITE_WALLPAPER = 48,
+        OP_ASSIST_STRUCTURE = 49,
+        OP_ASSIST_SCREENSHOT = 50,
+        OP_READ_PHONE_STATE = 51,
+        OP_ADD_VOICEMAIL = 52,
+        OP_USE_SIP = 53,
+        OP_PROCESS_OUTGOING_CALLS = 54,
+        OP_USE_FINGERPRINT = 55,
+        OP_BODY_SENSORS = 56
     };
 
     AppOpsManager();
@@ -75,6 +103,7 @@
     void startWatchingMode(int32_t op, const String16& packageName,
             const sp<IAppOpsCallback>& callback);
     void stopWatchingMode(const sp<IAppOpsCallback>& callback);
+    int32_t permissionToOpCode(const String16& permission);
 
 private:
     Mutex mLock;
diff --git a/include/binder/Binder.h b/include/binder/Binder.h
index ba3ac4b..f849fd4 100644
--- a/include/binder/Binder.h
+++ b/include/binder/Binder.h
@@ -17,6 +17,8 @@
 #ifndef ANDROID_BINDER_H
 #define ANDROID_BINDER_H
 
+#include <atomic>
+#include <stdint.h>
 #include <binder/IBinder.h>
 
 // ---------------------------------------------------------------------------
@@ -69,7 +71,7 @@
 
     class Extras;
 
-            Extras*     mExtras;
+    std::atomic<Extras*> mExtras;
             void*       mReserved0;
 };
 
@@ -93,7 +95,7 @@
 
     IBinder* const          mRemote;
     RefBase::weakref_type*  mRefs;
-    volatile int32_t        mState;
+    std::atomic<int32_t>    mState;
 };
 
 }; // namespace android
diff --git a/include/binder/IAppOpsService.h b/include/binder/IAppOpsService.h
index 193e9cc..cd81efa 100644
--- a/include/binder/IAppOpsService.h
+++ b/include/binder/IAppOpsService.h
@@ -40,6 +40,7 @@
             const sp<IAppOpsCallback>& callback) = 0;
     virtual void stopWatchingMode(const sp<IAppOpsCallback>& callback) = 0;
     virtual sp<IBinder> getToken(const sp<IBinder>& clientToken) = 0;
+    virtual int32_t permissionToOpCode(const String16& permission) = 0;
 
     enum {
         CHECK_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
@@ -49,6 +50,7 @@
         START_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+4,
         STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5,
         GET_TOKEN_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6,
+        PERMISSION_TO_OP_CODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7,
     };
 
     enum {
diff --git a/include/binder/IBatteryStats.h b/include/binder/IBatteryStats.h
new file mode 100644
index 0000000..5f38186
--- /dev/null
+++ b/include/binder/IBatteryStats.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_IBATTERYSTATS_H
+#define ANDROID_IBATTERYSTATS_H
+
+#include <binder/IInterface.h>
+
+namespace android {
+
+// ----------------------------------------------------------------------
+
+class IBatteryStats : public IInterface
+{
+public:
+    DECLARE_META_INTERFACE(BatteryStats);
+
+    virtual void noteStartSensor(int uid, int sensor) = 0;
+    virtual void noteStopSensor(int uid, int sensor) = 0;
+    virtual void noteStartVideo(int uid) = 0;
+    virtual void noteStopVideo(int uid) = 0;
+    virtual void noteStartAudio(int uid) = 0;
+    virtual void noteStopAudio(int uid) = 0;
+    virtual void noteResetVideo() = 0;
+    virtual void noteResetAudio() = 0;
+    virtual void noteFlashlightOn(int uid) = 0;
+    virtual void noteFlashlightOff(int uid) = 0;
+    virtual void noteStartCamera(int uid) = 0;
+    virtual void noteStopCamera(int uid) = 0;
+    virtual void noteResetCamera() = 0;
+    virtual void noteResetFlashlight() = 0;
+
+    enum {
+        NOTE_START_SENSOR_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
+        NOTE_STOP_SENSOR_TRANSACTION,
+        NOTE_START_VIDEO_TRANSACTION,
+        NOTE_STOP_VIDEO_TRANSACTION,
+        NOTE_START_AUDIO_TRANSACTION,
+        NOTE_STOP_AUDIO_TRANSACTION,
+        NOTE_RESET_VIDEO_TRANSACTION,
+        NOTE_RESET_AUDIO_TRANSACTION,
+        NOTE_FLASHLIGHT_ON_TRANSACTION,
+        NOTE_FLASHLIGHT_OFF_TRANSACTION,
+        NOTE_START_CAMERA_TRANSACTION,
+        NOTE_STOP_CAMERA_TRANSACTION,
+        NOTE_RESET_CAMERA_TRANSACTION,
+        NOTE_RESET_FLASHLIGHT_TRANSACTION
+    };
+};
+
+// ----------------------------------------------------------------------
+
+class BnBatteryStats : public BnInterface<IBatteryStats>
+{
+public:
+    virtual status_t    onTransact( uint32_t code,
+                                    const Parcel& data,
+                                    Parcel* reply,
+                                    uint32_t flags = 0);
+};
+
+// ----------------------------------------------------------------------
+
+}; // namespace android
+
+#endif // ANDROID_IBATTERYSTATS_H
diff --git a/include/binder/IBinder.h b/include/binder/IBinder.h
index 8b84951..d98d4c5 100644
--- a/include/binder/IBinder.h
+++ b/include/binder/IBinder.h
@@ -23,8 +23,12 @@
 #include <utils/Vector.h>
 
 
+// linux/binder.h already defines this, but we can't just include it from there
+// because there are host builds that include this file.
+#ifndef B_PACK_CHARS
 #define B_PACK_CHARS(c1, c2, c3, c4) \
     ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4))
+#endif  // B_PACK_CHARS
 
 // ---------------------------------------------------------------------------
 namespace android {
@@ -81,14 +85,6 @@
                                         Parcel* reply,
                                         uint32_t flags = 0) = 0;
 
-    /**
-     * This method allows you to add data that is transported through
-     * IPC along with your IBinder pointer.  When implementing a Binder
-     * object, override it to write your desired data in to @a outData.
-     * You can then call getConstantData() on your IBinder to retrieve
-     * that data, from any process.  You MUST return the number of bytes
-     * written in to the parcel (including padding).
-     */
     class DeathRecipient : public virtual RefBase
     {
     public:
diff --git a/include/binder/IInterface.h b/include/binder/IInterface.h
index 5f9f69c..48c8b3b 100644
--- a/include/binder/IInterface.h
+++ b/include/binder/IInterface.h
@@ -28,9 +28,9 @@
 {
 public:
             IInterface();
-            sp<IBinder>         asBinder();
-            sp<const IBinder>   asBinder() const;
-            
+            static sp<IBinder>  asBinder(const IInterface*);
+            static sp<IBinder>  asBinder(const sp<IInterface>&);
+
 protected:
     virtual                     ~IInterface();
     virtual IBinder*            onAsBinder() = 0;
@@ -105,7 +105,7 @@
 
 
 #define CHECK_INTERFACE(interface, data, reply)                         \
-    if (!data.checkInterface(this)) { return PERMISSION_DENIED; }       \
+    if (!(data).checkInterface(this)) { return PERMISSION_DENIED; }     \
 
 
 // ----------------------------------------------------------------------
diff --git a/include/binder/IPCThreadState.h b/include/binder/IPCThreadState.h
index 6e0c01b..1853cff 100644
--- a/include/binder/IPCThreadState.h
+++ b/include/binder/IPCThreadState.h
@@ -22,7 +22,7 @@
 #include <binder/ProcessState.h>
 #include <utils/Vector.h>
 
-#ifdef HAVE_WIN32_PROC
+#if defined(_WIN32)
 typedef  int  uid_t;
 #endif
 
@@ -39,8 +39,8 @@
             
             status_t            clearLastError();
 
-            int                 getCallingPid() const;
-            int                 getCallingUid() const;
+            pid_t               getCallingPid() const;
+            uid_t               getCallingUid() const;
 
             void                setStrictModePolicy(int32_t policy);
             int32_t             getStrictModePolicy() const;
@@ -76,14 +76,18 @@
                                                         BpBinder* proxy); 
 
     static  void                shutdown();
-    
+
     // Call this to disable switching threads to background scheduling when
     // receiving incoming IPC calls.  This is specifically here for the
     // Android system process, since it expects to have background apps calling
     // in to it but doesn't want to acquire locks in its services while in
     // the background.
     static  void                disableBackgroundScheduling(bool disable);
-    
+
+            // Call blocks until the number of executing binder threads is less than
+            // the maximum number of binder threads threads allowed for this process.
+            void                blockUntilThreadAvailable();
+
 private:
                                 IPCThreadState();
                                 ~IPCThreadState();
@@ -101,9 +105,9 @@
             status_t            getAndExecuteCommand();
             status_t            executeCommand(int32_t command);
             void                processPendingDerefs();
-            
+
             void                clearCaller();
-            
+
     static  void                threadDestructor(void *st);
     static  void                freeBuffer(Parcel* parcel,
                                            const uint8_t* data, size_t dataSize,
@@ -114,7 +118,7 @@
     const   pid_t               mMyThreadId;
             Vector<BBinder*>    mPendingStrongDerefs;
             Vector<RefBase::weakref_type*> mPendingWeakDerefs;
-            
+
             Parcel              mIn;
             Parcel              mOut;
             status_t            mLastError;
diff --git a/include/binder/IPermissionController.h b/include/binder/IPermissionController.h
index f9d371b..4e5fb34 100644
--- a/include/binder/IPermissionController.h
+++ b/include/binder/IPermissionController.h
@@ -19,6 +19,7 @@
 #define ANDROID_IPERMISSION_CONTROLLER_H
 
 #include <binder/IInterface.h>
+#include <stdlib.h>
 
 namespace android {
 
@@ -29,11 +30,16 @@
 public:
     DECLARE_META_INTERFACE(PermissionController);
 
-    virtual bool                checkPermission(const String16& permission,
-                                                int32_t pid, int32_t uid) = 0;
-    
+    virtual bool checkPermission(const String16& permission, int32_t pid, int32_t uid) = 0;
+
+    virtual void getPackagesForUid(const uid_t uid, Vector<String16> &packages) = 0;
+
+    virtual bool isRuntimePermission(const String16& permission) = 0;
+
     enum {
-        CHECK_PERMISSION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION
+        CHECK_PERMISSION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
+        GET_PACKAGES_FOR_UID_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION + 1,
+        IS_RUNTIME_PERMISSION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION + 2
     };
 };
 
diff --git a/include/binder/IProcessInfoService.h b/include/binder/IProcessInfoService.h
new file mode 100644
index 0000000..dc62f45
--- /dev/null
+++ b/include/binder/IProcessInfoService.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_I_PROCESS_INFO_SERVICE_H
+#define ANDROID_I_PROCESS_INFO_SERVICE_H
+
+#include <binder/IInterface.h>
+
+namespace android {
+
+// ----------------------------------------------------------------------
+
+class IProcessInfoService : public IInterface {
+public:
+    DECLARE_META_INTERFACE(ProcessInfoService);
+
+    virtual status_t    getProcessStatesFromPids( size_t length,
+                                                  /*in*/ int32_t* pids,
+                                                  /*out*/ int32_t* states) = 0;
+
+    enum {
+        GET_PROCESS_STATES_FROM_PIDS = IBinder::FIRST_CALL_TRANSACTION,
+    };
+};
+
+// ----------------------------------------------------------------------
+
+class BnProcessInfoService : public BnInterface<IProcessInfoService> {
+public:
+    virtual status_t    onTransact( uint32_t code,
+                                    const Parcel& data,
+                                    Parcel* reply,
+                                    uint32_t flags = 0);
+};
+
+// ----------------------------------------------------------------------
+
+}; // namespace android
+
+#endif // ANDROID_I_PROCESS_INFO_SERVICE_H
diff --git a/include/binder/IServiceManager.h b/include/binder/IServiceManager.h
index 2c297d6..7ccd9fe 100644
--- a/include/binder/IServiceManager.h
+++ b/include/binder/IServiceManager.h
@@ -81,20 +81,6 @@
                             int32_t* outPid, int32_t* outUid);
 bool checkPermission(const String16& permission, pid_t pid, uid_t uid);
 
-
-// ----------------------------------------------------------------------
-
-class BnServiceManager : public BnInterface<IServiceManager>
-{
-public:
-    virtual status_t    onTransact( uint32_t code,
-                                    const Parcel& data,
-                                    Parcel* reply,
-                                    uint32_t flags = 0);
-};
-
-// ----------------------------------------------------------------------
-
 }; // namespace android
 
 #endif // ANDROID_ISERVICE_MANAGER_H
diff --git a/include/binder/MemoryDealer.h b/include/binder/MemoryDealer.h
index 170f20d..aa415d5 100644
--- a/include/binder/MemoryDealer.h
+++ b/include/binder/MemoryDealer.h
@@ -34,7 +34,8 @@
 class MemoryDealer : public RefBase
 {
 public:
-    MemoryDealer(size_t size, const char* name = 0);
+    MemoryDealer(size_t size, const char* name = 0,
+            uint32_t flags = 0 /* or bits such as MemoryHeapBase::READ_ONLY */ );
 
     virtual sp<IMemory> allocate(size_t size);
     virtual void        deallocate(size_t offset);
diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h
index ed2e7df..fe3aed6 100644
--- a/include/binder/Parcel.h
+++ b/include/binder/Parcel.h
@@ -17,13 +17,20 @@
 #ifndef ANDROID_PARCEL_H
 #define ANDROID_PARCEL_H
 
+#include <string>
+#include <vector>
+
+#include <android-base/unique_fd.h>
 #include <cutils/native_handle.h>
 #include <utils/Errors.h>
 #include <utils/RefBase.h>
 #include <utils/String16.h>
 #include <utils/Vector.h>
 #include <utils/Flattenable.h>
-#include <linux/binder.h>
+#include <linux/android/binder.h>
+
+#include <binder/IInterface.h>
+#include <binder/Parcelable.h>
 
 // ---------------------------------------------------------------------------
 namespace android {
@@ -60,6 +67,7 @@
     status_t            appendFrom(const Parcel *parcel,
                                    size_t start, size_t len);
 
+    bool                allowFds() const;
     bool                pushAllowFds(bool allowFds);
     void                restoreAllowFds(bool lastValue);
 
@@ -94,17 +102,63 @@
     void*               writeInplace(size_t len);
     status_t            writeUnpadded(const void* data, size_t len);
     status_t            writeInt32(int32_t val);
+    status_t            writeUint32(uint32_t val);
     status_t            writeInt64(int64_t val);
+    status_t            writeUint64(uint64_t val);
     status_t            writeFloat(float val);
     status_t            writeDouble(double val);
-    status_t            writeIntPtr(intptr_t val);
     status_t            writeCString(const char* str);
     status_t            writeString8(const String8& str);
     status_t            writeString16(const String16& str);
+    status_t            writeString16(const std::unique_ptr<String16>& str);
     status_t            writeString16(const char16_t* str, size_t len);
     status_t            writeStrongBinder(const sp<IBinder>& val);
     status_t            writeWeakBinder(const wp<IBinder>& val);
     status_t            writeInt32Array(size_t len, const int32_t *val);
+    status_t            writeByteArray(size_t len, const uint8_t *val);
+    status_t            writeBool(bool val);
+    status_t            writeChar(char16_t val);
+    status_t            writeByte(int8_t val);
+
+    // Take a UTF8 encoded string, convert to UTF16, write it to the parcel.
+    status_t            writeUtf8AsUtf16(const std::string& str);
+    status_t            writeUtf8AsUtf16(const std::unique_ptr<std::string>& str);
+
+    status_t            writeByteVector(const std::unique_ptr<std::vector<int8_t>>& val);
+    status_t            writeByteVector(const std::vector<int8_t>& val);
+    status_t            writeByteVector(const std::unique_ptr<std::vector<uint8_t>>& val);
+    status_t            writeByteVector(const std::vector<uint8_t>& val);
+    status_t            writeInt32Vector(const std::unique_ptr<std::vector<int32_t>>& val);
+    status_t            writeInt32Vector(const std::vector<int32_t>& val);
+    status_t            writeInt64Vector(const std::unique_ptr<std::vector<int64_t>>& val);
+    status_t            writeInt64Vector(const std::vector<int64_t>& val);
+    status_t            writeFloatVector(const std::unique_ptr<std::vector<float>>& val);
+    status_t            writeFloatVector(const std::vector<float>& val);
+    status_t            writeDoubleVector(const std::unique_ptr<std::vector<double>>& val);
+    status_t            writeDoubleVector(const std::vector<double>& val);
+    status_t            writeBoolVector(const std::unique_ptr<std::vector<bool>>& val);
+    status_t            writeBoolVector(const std::vector<bool>& val);
+    status_t            writeCharVector(const std::unique_ptr<std::vector<char16_t>>& val);
+    status_t            writeCharVector(const std::vector<char16_t>& val);
+    status_t            writeString16Vector(
+                            const std::unique_ptr<std::vector<std::unique_ptr<String16>>>& val);
+    status_t            writeString16Vector(const std::vector<String16>& val);
+    status_t            writeUtf8VectorAsUtf16Vector(
+                            const std::unique_ptr<std::vector<std::unique_ptr<std::string>>>& val);
+    status_t            writeUtf8VectorAsUtf16Vector(const std::vector<std::string>& val);
+
+    status_t            writeStrongBinderVector(const std::unique_ptr<std::vector<sp<IBinder>>>& val);
+    status_t            writeStrongBinderVector(const std::vector<sp<IBinder>>& val);
+
+    template<typename T>
+    status_t            writeParcelableVector(const std::unique_ptr<std::vector<std::unique_ptr<T>>>& val);
+    template<typename T>
+    status_t            writeParcelableVector(const std::vector<T>& val);
+
+    template<typename T>
+    status_t            writeNullableParcelable(const std::unique_ptr<T>& parcelable);
+
+    status_t            writeParcelable(const Parcelable& parcelable);
 
     template<typename T>
     status_t            write(const Flattenable<T>& val);
@@ -115,7 +169,7 @@
 
     // Place a native_handle into the parcel (the native_handle's file-
     // descriptors are dup'ed, so it is safe to delete the native_handle
-    // when this function returns). 
+    // when this function returns).
     // Doesn't take ownership of the native_handle.
     status_t            writeNativeHandle(const native_handle* handle);
     
@@ -128,11 +182,31 @@
     // will be closed once the parcel is destroyed.
     status_t            writeDupFileDescriptor(int fd);
 
+    // Place a file descriptor into the parcel.  This will not affect the
+    // semantics of the smart file descriptor. A new descriptor will be
+    // created, and will be closed when the parcel is destroyed.
+    status_t            writeUniqueFileDescriptor(
+                            const base::unique_fd& fd);
+
+    // Place a vector of file desciptors into the parcel. Each descriptor is
+    // dup'd as in writeDupFileDescriptor
+    status_t            writeUniqueFileDescriptorVector(
+                            const std::unique_ptr<std::vector<base::unique_fd>>& val);
+    status_t            writeUniqueFileDescriptorVector(
+                            const std::vector<base::unique_fd>& val);
+
     // Writes a blob to the parcel.
     // If the blob is small, then it is stored in-place, otherwise it is
-    // transferred by way of an anonymous shared memory region.
+    // transferred by way of an anonymous shared memory region.  Prefer sending
+    // immutable blobs if possible since they may be subsequently transferred between
+    // processes without further copying whereas mutable blobs always need to be copied.
     // The caller should call release() on the blob after writing its contents.
-    status_t            writeBlob(size_t len, WritableBlob* outBlob);
+    status_t            writeBlob(size_t len, bool mutableCopy, WritableBlob* outBlob);
+
+    // Write an existing immutable blob file descriptor to the parcel.
+    // This allows the client to send the same blob to multiple processes
+    // as long as it keeps a dup of the blob file descriptor handy for later.
+    status_t            writeDupImmutableBlobFileDescriptor(int fd);
 
     status_t            writeObject(const flat_binder_object& val, bool nullMetaData);
 
@@ -147,23 +221,85 @@
     const void*         readInplace(size_t len) const;
     int32_t             readInt32() const;
     status_t            readInt32(int32_t *pArg) const;
+    uint32_t            readUint32() const;
+    status_t            readUint32(uint32_t *pArg) const;
     int64_t             readInt64() const;
     status_t            readInt64(int64_t *pArg) const;
+    uint64_t            readUint64() const;
+    status_t            readUint64(uint64_t *pArg) const;
     float               readFloat() const;
     status_t            readFloat(float *pArg) const;
     double              readDouble() const;
     status_t            readDouble(double *pArg) const;
     intptr_t            readIntPtr() const;
     status_t            readIntPtr(intptr_t *pArg) const;
+    bool                readBool() const;
+    status_t            readBool(bool *pArg) const;
+    char16_t            readChar() const;
+    status_t            readChar(char16_t *pArg) const;
+    int8_t              readByte() const;
+    status_t            readByte(int8_t *pArg) const;
+
+    // Read a UTF16 encoded string, convert to UTF8
+    status_t            readUtf8FromUtf16(std::string* str) const;
+    status_t            readUtf8FromUtf16(std::unique_ptr<std::string>* str) const;
 
     const char*         readCString() const;
     String8             readString8() const;
+    status_t            readString8(String8* pArg) const;
     String16            readString16() const;
+    status_t            readString16(String16* pArg) const;
+    status_t            readString16(std::unique_ptr<String16>* pArg) const;
     const char16_t*     readString16Inplace(size_t* outLen) const;
     sp<IBinder>         readStrongBinder() const;
+    status_t            readStrongBinder(sp<IBinder>* val) const;
+    status_t            readNullableStrongBinder(sp<IBinder>* val) const;
     wp<IBinder>         readWeakBinder() const;
 
     template<typename T>
+    status_t            readParcelableVector(
+                            std::unique_ptr<std::vector<std::unique_ptr<T>>>* val) const;
+    template<typename T>
+    status_t            readParcelableVector(std::vector<T>* val) const;
+
+    status_t            readParcelable(Parcelable* parcelable) const;
+
+    template<typename T>
+    status_t            readParcelable(std::unique_ptr<T>* parcelable) const;
+
+    template<typename T>
+    status_t            readStrongBinder(sp<T>* val) const;
+
+    template<typename T>
+    status_t            readNullableStrongBinder(sp<T>* val) const;
+
+    status_t            readStrongBinderVector(std::unique_ptr<std::vector<sp<IBinder>>>* val) const;
+    status_t            readStrongBinderVector(std::vector<sp<IBinder>>* val) const;
+
+    status_t            readByteVector(std::unique_ptr<std::vector<int8_t>>* val) const;
+    status_t            readByteVector(std::vector<int8_t>* val) const;
+    status_t            readByteVector(std::unique_ptr<std::vector<uint8_t>>* val) const;
+    status_t            readByteVector(std::vector<uint8_t>* val) const;
+    status_t            readInt32Vector(std::unique_ptr<std::vector<int32_t>>* val) const;
+    status_t            readInt32Vector(std::vector<int32_t>* val) const;
+    status_t            readInt64Vector(std::unique_ptr<std::vector<int64_t>>* val) const;
+    status_t            readInt64Vector(std::vector<int64_t>* val) const;
+    status_t            readFloatVector(std::unique_ptr<std::vector<float>>* val) const;
+    status_t            readFloatVector(std::vector<float>* val) const;
+    status_t            readDoubleVector(std::unique_ptr<std::vector<double>>* val) const;
+    status_t            readDoubleVector(std::vector<double>* val) const;
+    status_t            readBoolVector(std::unique_ptr<std::vector<bool>>* val) const;
+    status_t            readBoolVector(std::vector<bool>* val) const;
+    status_t            readCharVector(std::unique_ptr<std::vector<char16_t>>* val) const;
+    status_t            readCharVector(std::vector<char16_t>* val) const;
+    status_t            readString16Vector(
+                            std::unique_ptr<std::vector<std::unique_ptr<String16>>>* val) const;
+    status_t            readString16Vector(std::vector<String16>* val) const;
+    status_t            readUtf8VectorFromUtf16Vector(
+                            std::unique_ptr<std::vector<std::unique_ptr<std::string>>>* val) const;
+    status_t            readUtf8VectorFromUtf16Vector(std::vector<std::string>* val) const;
+
+    template<typename T>
     status_t            read(Flattenable<T>& val) const;
 
     template<typename T>
@@ -187,6 +323,17 @@
     // in the parcel, which you do not own -- use dup() to get your own copy.
     int                 readFileDescriptor() const;
 
+    // Retrieve a smart file descriptor from the parcel.
+    status_t            readUniqueFileDescriptor(
+                            base::unique_fd* val) const;
+
+
+    // Retrieve a vector of smart file descriptors from the parcel.
+    status_t            readUniqueFileDescriptorVector(
+                            std::unique_ptr<std::vector<base::unique_fd>>* val) const;
+    status_t            readUniqueFileDescriptorVector(
+                            std::vector<base::unique_fd>* val) const;
+
     // Reads a blob from the parcel.
     // The caller should call release() on the blob after reading its contents.
     status_t            readBlob(size_t len, ReadableBlob* outBlob) const;
@@ -195,7 +342,11 @@
 
     // Explicitly close all file descriptors in the parcel.
     void                closeFileDescriptors();
-    
+
+    // Debugging: get metrics on current allocations.
+    static size_t       getGlobalAllocSize();
+    static size_t       getGlobalAllocCount();
+
 private:
     typedef void        (*release_func)(Parcel* parcel,
                                         const uint8_t* data, size_t dataSize,
@@ -238,6 +389,34 @@
     template<class T>
     status_t            writeAligned(T val);
 
+    status_t            writeRawNullableParcelable(const Parcelable*
+                                                   parcelable);
+
+    template<typename T, typename U>
+    status_t            unsafeReadTypedVector(std::vector<T>* val,
+                                              status_t(Parcel::*read_func)(U*) const) const;
+    template<typename T>
+    status_t            readNullableTypedVector(std::unique_ptr<std::vector<T>>* val,
+                                                status_t(Parcel::*read_func)(T*) const) const;
+    template<typename T>
+    status_t            readTypedVector(std::vector<T>* val,
+                                        status_t(Parcel::*read_func)(T*) const) const;
+    template<typename T, typename U>
+    status_t            unsafeWriteTypedVector(const std::vector<T>& val,
+                                               status_t(Parcel::*write_func)(U));
+    template<typename T>
+    status_t            writeNullableTypedVector(const std::unique_ptr<std::vector<T>>& val,
+                                                 status_t(Parcel::*write_func)(const T&));
+    template<typename T>
+    status_t            writeNullableTypedVector(const std::unique_ptr<std::vector<T>>& val,
+                                                 status_t(Parcel::*write_func)(T));
+    template<typename T>
+    status_t            writeTypedVector(const std::vector<T>& val,
+                                         status_t(Parcel::*write_func)(const T&));
+    template<typename T>
+    status_t            writeTypedVector(const std::vector<T>& val,
+                                         status_t(Parcel::*write_func)(T));
+
     status_t            mError;
     uint8_t*            mData;
     size_t              mDataSize;
@@ -260,16 +439,19 @@
         Blob();
         ~Blob();
 
+        void clear();
         void release();
         inline size_t size() const { return mSize; }
+        inline int fd() const { return mFd; };
+        inline bool isMutable() const { return mMutable; }
 
     protected:
-        void init(bool mapped, void* data, size_t size);
-        void clear();
+        void init(int fd, void* data, size_t size, bool isMutable);
 
-        bool mMapped;
+        int mFd; // owned by parcel so not closed when released
         void* mData;
         size_t mSize;
+        bool mMutable;
     };
 
     class FlattenableHelperInterface {
@@ -310,6 +492,7 @@
         friend class Parcel;
     public:
         inline const void* data() const { return mData; }
+        inline void* mutableData() { return isMutable() ? mData : NULL; }
     };
 
     class WritableBlob : public Blob {
@@ -317,6 +500,14 @@
     public:
         inline void* data() { return mData; }
     };
+
+private:
+    size_t mOpenAshmemSize;
+
+public:
+    // TODO: Remove once ABI can be changed.
+    size_t getBlobAshmemSize() const;
+    size_t getOpenAshmemSize() const;
 };
 
 // ---------------------------------------------------------------------------
@@ -372,6 +563,222 @@
     return NO_ERROR;
 }
 
+template<typename T>
+status_t Parcel::readStrongBinder(sp<T>* val) const {
+    sp<IBinder> tmp;
+    status_t ret = readStrongBinder(&tmp);
+
+    if (ret == OK) {
+        *val = interface_cast<T>(tmp);
+
+        if (val->get() == nullptr) {
+            return UNKNOWN_ERROR;
+        }
+    }
+
+    return ret;
+}
+
+template<typename T>
+status_t Parcel::readNullableStrongBinder(sp<T>* val) const {
+    sp<IBinder> tmp;
+    status_t ret = readNullableStrongBinder(&tmp);
+
+    if (ret == OK) {
+        *val = interface_cast<T>(tmp);
+
+        if (val->get() == nullptr && tmp.get() != nullptr) {
+            ret = UNKNOWN_ERROR;
+        }
+    }
+
+    return ret;
+}
+
+template<typename T, typename U>
+status_t Parcel::unsafeReadTypedVector(
+        std::vector<T>* val,
+        status_t(Parcel::*read_func)(U*) const) const {
+    int32_t size;
+    status_t status = this->readInt32(&size);
+
+    if (status != OK) {
+        return status;
+    }
+
+    if (size < 0) {
+        return UNEXPECTED_NULL;
+    }
+
+    val->resize(size);
+
+    for (auto& v: *val) {
+        status = (this->*read_func)(&v);
+
+        if (status != OK) {
+            return status;
+        }
+    }
+
+    return OK;
+}
+
+template<typename T>
+status_t Parcel::readTypedVector(std::vector<T>* val,
+                                 status_t(Parcel::*read_func)(T*) const) const {
+    return unsafeReadTypedVector(val, read_func);
+}
+
+template<typename T>
+status_t Parcel::readNullableTypedVector(std::unique_ptr<std::vector<T>>* val,
+                                         status_t(Parcel::*read_func)(T*) const) const {
+    const int32_t start = dataPosition();
+    int32_t size;
+    status_t status = readInt32(&size);
+    val->reset();
+
+    if (status != OK || size < 0) {
+        return status;
+    }
+
+    setDataPosition(start);
+    val->reset(new std::vector<T>());
+
+    status = unsafeReadTypedVector(val->get(), read_func);
+
+    if (status != OK) {
+        val->reset();
+    }
+
+    return status;
+}
+
+template<typename T, typename U>
+status_t Parcel::unsafeWriteTypedVector(const std::vector<T>& val,
+                                        status_t(Parcel::*write_func)(U)) {
+    if (val.size() > std::numeric_limits<int32_t>::max()) {
+        return BAD_VALUE;
+    }
+
+    status_t status = this->writeInt32(val.size());
+
+    if (status != OK) {
+        return status;
+    }
+
+    for (const auto& item : val) {
+        status = (this->*write_func)(item);
+
+        if (status != OK) {
+            return status;
+        }
+    }
+
+    return OK;
+}
+
+template<typename T>
+status_t Parcel::writeTypedVector(const std::vector<T>& val,
+                                  status_t(Parcel::*write_func)(const T&)) {
+    return unsafeWriteTypedVector(val, write_func);
+}
+
+template<typename T>
+status_t Parcel::writeTypedVector(const std::vector<T>& val,
+                                  status_t(Parcel::*write_func)(T)) {
+    return unsafeWriteTypedVector(val, write_func);
+}
+
+template<typename T>
+status_t Parcel::writeNullableTypedVector(const std::unique_ptr<std::vector<T>>& val,
+                                          status_t(Parcel::*write_func)(const T&)) {
+    if (val.get() == nullptr) {
+        return this->writeInt32(-1);
+    }
+
+    return unsafeWriteTypedVector(*val, write_func);
+}
+
+template<typename T>
+status_t Parcel::writeNullableTypedVector(const std::unique_ptr<std::vector<T>>& val,
+                                          status_t(Parcel::*write_func)(T)) {
+    if (val.get() == nullptr) {
+        return this->writeInt32(-1);
+    }
+
+    return unsafeWriteTypedVector(*val, write_func);
+}
+
+template<typename T>
+status_t Parcel::readParcelableVector(std::vector<T>* val) const {
+    return unsafeReadTypedVector<T, Parcelable>(val, &Parcel::readParcelable);
+}
+
+template<typename T>
+status_t Parcel::readParcelableVector(std::unique_ptr<std::vector<std::unique_ptr<T>>>* val) const {
+    const int32_t start = dataPosition();
+    int32_t size;
+    status_t status = readInt32(&size);
+    val->reset();
+
+    if (status != OK || size < 0) {
+        return status;
+    }
+
+    setDataPosition(start);
+    val->reset(new std::vector<T>());
+
+    status = unsafeReadTypedVector(val->get(), &Parcel::readParcelable);
+
+    if (status != OK) {
+        val->reset();
+    }
+
+    return status;
+}
+
+template<typename T>
+status_t Parcel::readParcelable(std::unique_ptr<T>* parcelable) const {
+    const int32_t start = dataPosition();
+    int32_t present;
+    status_t status = readInt32(&present);
+    parcelable->reset();
+
+    if (status != OK || !present) {
+        return status;
+    }
+
+    setDataPosition(start);
+    parcelable->reset(new T());
+
+    status = readParcelable(parcelable->get());
+
+    if (status != OK) {
+        parcelable->reset();
+    }
+
+    return status;
+}
+
+template<typename T>
+status_t Parcel::writeNullableParcelable(const std::unique_ptr<T>& parcelable) {
+    return writeRawNullableParcelable(parcelable.get());
+}
+
+template<typename T>
+status_t Parcel::writeParcelableVector(const std::vector<T>& val) {
+    return unsafeWriteTypedVector<T,const Parcelable&>(val, &Parcel::writeParcelable);
+}
+
+template<typename T>
+status_t Parcel::writeParcelableVector(const std::unique_ptr<std::vector<std::unique_ptr<T>>>& val) {
+    if (val.get() == nullptr) {
+        return this->writeInt32(-1);
+    }
+
+    return unsafeWriteTypedVector(*val, &Parcel::writeParcelable);
+}
+
 // ---------------------------------------------------------------------------
 
 inline TextOutput& operator<<(TextOutput& to, const Parcel& parcel)
diff --git a/include/binder/Parcelable.h b/include/binder/Parcelable.h
new file mode 100644
index 0000000..faf0d34
--- /dev/null
+++ b/include/binder/Parcelable.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_PARCELABLE_H
+#define ANDROID_PARCELABLE_H
+
+#include <vector>
+
+#include <utils/Errors.h>
+#include <utils/String16.h>
+
+namespace android {
+
+class Parcel;
+
+// Abstract interface of all parcelables.
+class Parcelable {
+public:
+    virtual ~Parcelable() = default;
+
+    // Write |this| parcelable to the given |parcel|.  Keep in mind that
+    // implementations of writeToParcel must be manually kept in sync
+    // with readFromParcel and the Java equivalent versions of these methods.
+    //
+    // Returns android::OK on success and an appropriate error otherwise.
+    virtual status_t writeToParcel(Parcel* parcel) const = 0;
+
+    // Read data from the given |parcel| into |this|.  After readFromParcel
+    // completes, |this| should have equivalent state to the object that
+    // wrote itself to the parcel.
+    //
+    // Returns android::OK on success and an appropriate error otherwise.
+    virtual status_t readFromParcel(const Parcel* parcel) = 0;
+};  // class Parcelable
+
+}  // namespace android
+
+#endif // ANDROID_PARCELABLE_H
diff --git a/include/binder/PersistableBundle.h b/include/binder/PersistableBundle.h
new file mode 100644
index 0000000..322fef9
--- /dev/null
+++ b/include/binder/PersistableBundle.h
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_PERSISTABLE_BUNDLE_H
+#define ANDROID_PERSISTABLE_BUNDLE_H
+
+#include <map>
+#include <set>
+#include <vector>
+
+#include <binder/Parcelable.h>
+#include <utils/String16.h>
+#include <utils/StrongPointer.h>
+
+namespace android {
+
+namespace os {
+
+/*
+ * C++ implementation of PersistableBundle, a mapping from String values to
+ * various types that can be saved to persistent and later restored.
+ */
+class PersistableBundle : public Parcelable {
+public:
+    PersistableBundle() = default;
+    virtual ~PersistableBundle() = default;
+    PersistableBundle(const PersistableBundle& bundle) = default;
+
+    status_t writeToParcel(Parcel* parcel) const override;
+    status_t readFromParcel(const Parcel* parcel) override;
+
+    bool empty() const;
+    size_t size() const;
+    size_t erase(const String16& key);
+
+    /*
+     * Setters for PersistableBundle. Adds a a key-value pair instantiated with
+     * |key| and |value| into the member map appropriate for the type of |value|.
+     * If there is already an existing value for |key|, |value| will replace it.
+     */
+    void putBoolean(const String16& key, bool value);
+    void putInt(const String16& key, int32_t value);
+    void putLong(const String16& key, int64_t value);
+    void putDouble(const String16& key, double value);
+    void putString(const String16& key, const String16& value);
+    void putBooleanVector(const String16& key, const std::vector<bool>& value);
+    void putIntVector(const String16& key, const std::vector<int32_t>& value);
+    void putLongVector(const String16& key, const std::vector<int64_t>& value);
+    void putDoubleVector(const String16& key, const std::vector<double>& value);
+    void putStringVector(const String16& key, const std::vector<String16>& value);
+    void putPersistableBundle(const String16& key, const PersistableBundle& value);
+
+    /*
+     * Getters for PersistableBundle. If |key| exists, these methods write the
+     * value associated with |key| into |out|, and return true. Otherwise, these
+     * methods return false.
+     */
+    bool getBoolean(const String16& key, bool* out) const;
+    bool getInt(const String16& key, int32_t* out) const;
+    bool getLong(const String16& key, int64_t* out) const;
+    bool getDouble(const String16& key, double* out) const;
+    bool getString(const String16& key, String16* out) const;
+    bool getBooleanVector(const String16& key, std::vector<bool>* out) const;
+    bool getIntVector(const String16& key, std::vector<int32_t>* out) const;
+    bool getLongVector(const String16& key, std::vector<int64_t>* out) const;
+    bool getDoubleVector(const String16& key, std::vector<double>* out) const;
+    bool getStringVector(const String16& key, std::vector<String16>* out) const;
+    bool getPersistableBundle(const String16& key, PersistableBundle* out) const;
+
+    /* Getters for all keys for each value type */
+    std::set<String16> getBooleanKeys() const;
+    std::set<String16> getIntKeys() const;
+    std::set<String16> getLongKeys() const;
+    std::set<String16> getDoubleKeys() const;
+    std::set<String16> getStringKeys() const;
+    std::set<String16> getBooleanVectorKeys() const;
+    std::set<String16> getIntVectorKeys() const;
+    std::set<String16> getLongVectorKeys() const;
+    std::set<String16> getDoubleVectorKeys() const;
+    std::set<String16> getStringVectorKeys() const;
+    std::set<String16> getPersistableBundleKeys() const;
+
+    friend bool operator==(const PersistableBundle& lhs, const PersistableBundle& rhs) {
+        return (lhs.mBoolMap == rhs.mBoolMap && lhs.mIntMap == rhs.mIntMap &&
+                lhs.mLongMap == rhs.mLongMap && lhs.mDoubleMap == rhs.mDoubleMap &&
+                lhs.mStringMap == rhs.mStringMap && lhs.mBoolVectorMap == rhs.mBoolVectorMap &&
+                lhs.mIntVectorMap == rhs.mIntVectorMap &&
+                lhs.mLongVectorMap == rhs.mLongVectorMap &&
+                lhs.mDoubleVectorMap == rhs.mDoubleVectorMap &&
+                lhs.mStringVectorMap == rhs.mStringVectorMap &&
+                lhs.mPersistableBundleMap == rhs.mPersistableBundleMap);
+    }
+
+    friend bool operator!=(const PersistableBundle& lhs, const PersistableBundle& rhs) {
+        return !(lhs == rhs);
+    }
+
+private:
+    status_t writeToParcelInner(Parcel* parcel) const;
+    status_t readFromParcelInner(const Parcel* parcel, size_t length);
+
+    std::map<String16, bool> mBoolMap;
+    std::map<String16, int32_t> mIntMap;
+    std::map<String16, int64_t> mLongMap;
+    std::map<String16, double> mDoubleMap;
+    std::map<String16, String16> mStringMap;
+    std::map<String16, std::vector<bool>> mBoolVectorMap;
+    std::map<String16, std::vector<int32_t>> mIntVectorMap;
+    std::map<String16, std::vector<int64_t>> mLongVectorMap;
+    std::map<String16, std::vector<double>> mDoubleVectorMap;
+    std::map<String16, std::vector<String16>> mStringVectorMap;
+    std::map<String16, PersistableBundle> mPersistableBundleMap;
+};
+
+}  // namespace os
+
+}  // namespace android
+
+#endif  // ANDROID_PERSISTABLE_BUNDLE_H
diff --git a/include/binder/ProcessInfoService.h b/include/binder/ProcessInfoService.h
new file mode 100644
index 0000000..c5ead20
--- /dev/null
+++ b/include/binder/ProcessInfoService.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_PROCESS_INFO_SERVICE_H
+#define ANDROID_PROCESS_INFO_SERVICE_H
+
+#include <binder/IProcessInfoService.h>
+#include <utils/Errors.h>
+#include <utils/Singleton.h>
+#include <sys/types.h>
+
+namespace android {
+
+// ----------------------------------------------------------------------
+
+class ProcessInfoService : public Singleton<ProcessInfoService> {
+
+    friend class Singleton<ProcessInfoService>;
+    sp<IProcessInfoService> mProcessInfoService;
+    Mutex mProcessInfoLock;
+
+    ProcessInfoService();
+
+    status_t getProcessStatesImpl(size_t length, /*in*/ int32_t* pids, /*out*/ int32_t* states);
+    void updateBinderLocked();
+
+    static const int BINDER_ATTEMPT_LIMIT = 5;
+
+public:
+
+    /**
+     * For each PID in the given "pids" input array, write the current process state
+     * for that process into the "states" output array, or
+     * ActivityManager.PROCESS_STATE_NONEXISTENT * to indicate that no process with the given PID
+     * exists.
+     *
+     * Returns NO_ERROR if this operation was successful, or a negative error code otherwise.
+     */
+    static status_t getProcessStatesFromPids(size_t length, /*in*/ int32_t* pids,
+            /*out*/ int32_t* states) {
+        return ProcessInfoService::getInstance().getProcessStatesImpl(length, /*in*/ pids,
+                /*out*/ states);
+    }
+
+};
+
+// ----------------------------------------------------------------------
+
+}; // namespace android
+
+#endif // ANDROID_PROCESS_INFO_SERVICE_H
+
diff --git a/include/binder/ProcessState.h b/include/binder/ProcessState.h
index 3bc978d..f9edc2a 100644
--- a/include/binder/ProcessState.h
+++ b/include/binder/ProcessState.h
@@ -24,6 +24,8 @@
 
 #include <utils/threads.h>
 
+#include <pthread.h>
+
 // ---------------------------------------------------------------------------
 namespace android {
 
@@ -71,25 +73,33 @@
                                 ProcessState(const ProcessState& o);
             ProcessState&       operator=(const ProcessState& o);
             String8             makeBinderThreadName();
-            
+
             struct handle_entry {
                 IBinder* binder;
                 RefBase::weakref_type* refs;
             };
-            
+
             handle_entry*       lookupHandleLocked(int32_t handle);
 
             int                 mDriverFD;
             void*               mVMStart;
-            
+
+            // Protects thread count variable below.
+            pthread_mutex_t     mThreadCountLock;
+            pthread_cond_t      mThreadCountDecrement;
+            // Number of binder threads current executing a command.
+            size_t              mExecutingThreadsCount;
+            // Maximum number for binder threads allowed for this process.
+            size_t              mMaxThreads;
+
     mutable Mutex               mLock;  // protects everything below.
-            
+
             Vector<handle_entry>mHandleToObject;
 
             bool                mManagesContexts;
             context_check_func  mBinderContextCheckFunc;
             void*               mBinderContextUserData;
-            
+
             KeyedVector<String16, sp<IBinder> >
                                 mContexts;
 
diff --git a/include/binder/Status.h b/include/binder/Status.h
new file mode 100644
index 0000000..dd61616
--- /dev/null
+++ b/include/binder/Status.h
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BINDER_STATUS_H
+#define ANDROID_BINDER_STATUS_H
+
+#include <cstdint>
+#include <sstream>
+
+#include <binder/Parcel.h>
+#include <utils/String8.h>
+
+namespace android {
+namespace binder {
+
+// An object similar in function to a status_t except that it understands
+// how exceptions are encoded in the prefix of a Parcel. Used like:
+//
+//     Parcel data;
+//     Parcel reply;
+//     status_t status;
+//     binder::Status remote_exception;
+//     if ((status = data.writeInterfaceToken(interface_descriptor)) != OK ||
+//         (status = data.writeInt32(function_input)) != OK) {
+//         // We failed to write into the memory of our local parcel?
+//     }
+//     if ((status = remote()->transact(transaction, data, &reply)) != OK) {
+//        // Something has gone wrong in the binder driver or libbinder.
+//     }
+//     if ((status = remote_exception.readFromParcel(reply)) != OK) {
+//         // The remote didn't correctly write the exception header to the
+//         // reply.
+//     }
+//     if (!remote_exception.isOk()) {
+//         // The transaction went through correctly, but the remote reported an
+//         // exception during handling.
+//     }
+//
+class Status final {
+public:
+    // Keep the exception codes in sync with android/os/Parcel.java.
+    enum Exception {
+        EX_NONE = 0,
+        EX_SECURITY = -1,
+        EX_BAD_PARCELABLE = -2,
+        EX_ILLEGAL_ARGUMENT = -3,
+        EX_NULL_POINTER = -4,
+        EX_ILLEGAL_STATE = -5,
+        EX_NETWORK_MAIN_THREAD = -6,
+        EX_UNSUPPORTED_OPERATION = -7,
+        EX_SERVICE_SPECIFIC = -8,
+
+        // This is special and Java specific; see Parcel.java.
+        EX_HAS_REPLY_HEADER = -128,
+        // This is special, and indicates to C++ binder proxies that the
+        // transaction has failed at a low level.
+        EX_TRANSACTION_FAILED = -129,
+    };
+
+    // A more readable alias for the default constructor.
+    static Status ok();
+
+    // Authors should explicitly pick whether their integer is:
+    //  - an exception code (EX_* above)
+    //  - service specific error code
+    //  - status_t
+    //
+    //  Prefer a generic exception code when possible, then a service specific
+    //  code, and finally a status_t for low level failures or legacy support.
+    //  Exception codes and service specific errors map to nicer exceptions for
+    //  Java clients.
+    static Status fromExceptionCode(int32_t exceptionCode);
+    static Status fromExceptionCode(int32_t exceptionCode,
+                                    const String8& message);
+    static Status fromExceptionCode(int32_t exceptionCode,
+                                    const char* message);
+
+    static Status fromServiceSpecificError(int32_t serviceSpecificErrorCode);
+    static Status fromServiceSpecificError(int32_t serviceSpecificErrorCode,
+                                           const String8& message);
+    static Status fromServiceSpecificError(int32_t serviceSpecificErrorCode,
+                                           const char* message);
+
+    static Status fromStatusT(status_t status);
+
+    Status() = default;
+    ~Status() = default;
+
+    // Status objects are copyable and contain just simple data.
+    Status(const Status& status) = default;
+    Status(Status&& status) = default;
+    Status& operator=(const Status& status) = default;
+
+    // Bear in mind that if the client or service is a Java endpoint, this
+    // is not the logic which will provide/interpret the data here.
+    status_t readFromParcel(const Parcel& parcel);
+    status_t writeToParcel(Parcel* parcel) const;
+
+    // Set one of the pre-defined exception types defined above.
+    void setException(int32_t ex, const String8& message);
+    // Set a service specific exception with error code.
+    void setServiceSpecificError(int32_t errorCode, const String8& message);
+    // Setting a |status| != OK causes generated code to return |status|
+    // from Binder transactions, rather than writing an exception into the
+    // reply Parcel.  This is the least preferable way of reporting errors.
+    void setFromStatusT(status_t status);
+
+    // Get information about an exception.
+    int32_t exceptionCode() const  { return mException; }
+    const String8& exceptionMessage() const { return mMessage; }
+    status_t transactionError() const {
+        return mException == EX_TRANSACTION_FAILED ? mErrorCode : OK;
+    }
+    int32_t serviceSpecificErrorCode() const {
+        return mException == EX_SERVICE_SPECIFIC ? mErrorCode : 0;
+    }
+
+    bool isOk() const { return mException == EX_NONE; }
+
+    // For logging.
+    String8 toString8() const;
+
+private:
+    Status(int32_t exceptionCode, int32_t errorCode);
+    Status(int32_t exceptionCode, int32_t errorCode, const String8& message);
+
+    // If |mException| == EX_TRANSACTION_FAILED, generated code will return
+    // |mErrorCode| as the result of the transaction rather than write an
+    // exception to the reply parcel.
+    //
+    // Otherwise, we always write |mException| to the parcel.
+    // If |mException| !=  EX_NONE, we write |mMessage| as well.
+    // If |mException| == EX_SERVICE_SPECIFIC we write |mErrorCode| as well.
+    int32_t mException = EX_NONE;
+    int32_t mErrorCode = 0;
+    String8 mMessage;
+};  // class Status
+
+// For gtest output logging
+std::stringstream& operator<< (std::stringstream& stream, const Status& s);
+
+}  // namespace binder
+}  // namespace android
+
+#endif // ANDROID_BINDER_STATUS_H
diff --git a/include/gui/BitTube.h b/include/gui/BitTube.h
index d32df84..3ecac52 100644
--- a/include/gui/BitTube.h
+++ b/include/gui/BitTube.h
@@ -48,6 +48,9 @@
     // get receive file-descriptor
     int getFd() const;
 
+    // get the send file-descriptor.
+    int getSendFd() const;
+
     // send objects (sized blobs). All objects are guaranteed to be written or the call fails.
     template <typename T>
     static ssize_t sendObjects(const sp<BitTube>& tube,
diff --git a/include/gui/BufferItem.h b/include/gui/BufferItem.h
new file mode 100644
index 0000000..145efe6
--- /dev/null
+++ b/include/gui/BufferItem.h
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_GUI_BUFFERITEM_H
+#define ANDROID_GUI_BUFFERITEM_H
+
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+#include <ui/Rect.h>
+#include <ui/Region.h>
+
+#include <system/graphics.h>
+
+#include <utils/Flattenable.h>
+#include <utils/StrongPointer.h>
+
+namespace android {
+
+class Fence;
+class GraphicBuffer;
+
+class BufferItem : public Flattenable<BufferItem> {
+    friend class Flattenable<BufferItem>;
+    size_t getPodSize() const;
+    size_t getFlattenedSize() const;
+    size_t getFdCount() const;
+    status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const;
+    status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count);
+
+    public:
+    // The default value of mBuf, used to indicate this doesn't correspond to a slot.
+    enum { INVALID_BUFFER_SLOT = -1 };
+    BufferItem();
+    ~BufferItem();
+
+    static const char* scalingModeName(uint32_t scalingMode);
+
+    // mGraphicBuffer points to the buffer allocated for this slot, or is NULL
+    // if the buffer in this slot has been acquired in the past (see
+    // BufferSlot.mAcquireCalled).
+    sp<GraphicBuffer> mGraphicBuffer;
+
+    // mFence is a fence that will signal when the buffer is idle.
+    sp<Fence> mFence;
+
+    // mCrop is the current crop rectangle for this buffer slot.
+    Rect mCrop;
+
+    // mTransform is the current transform flags for this buffer slot.
+    // refer to NATIVE_WINDOW_TRANSFORM_* in <window.h>
+    uint32_t mTransform;
+
+    // mScalingMode is the current scaling mode for this buffer slot.
+    // refer to NATIVE_WINDOW_SCALING_* in <window.h>
+    uint32_t mScalingMode;
+
+    // mTimestamp is the current timestamp for this buffer slot. This gets
+    // to set by queueBuffer each time this slot is queued. This value
+    // is guaranteed to be monotonically increasing for each newly
+    // acquired buffer.
+    union {
+        int64_t mTimestamp;
+        struct {
+            uint32_t mTimestampLo;
+            uint32_t mTimestampHi;
+        };
+    };
+
+    // mIsAutoTimestamp indicates whether mTimestamp was generated
+    // automatically when the buffer was queued.
+    bool mIsAutoTimestamp;
+
+    // mDataSpace is the current dataSpace value for this buffer slot. This gets
+    // set by queueBuffer each time this slot is queued. The meaning of the
+    // dataSpace is format-dependent.
+    android_dataspace mDataSpace;
+
+    // mFrameNumber is the number of the queued frame for this slot.
+    union {
+        uint64_t mFrameNumber;
+        struct {
+            uint32_t mFrameNumberLo;
+            uint32_t mFrameNumberHi;
+        };
+    };
+
+    union {
+        // mSlot is the slot index of this buffer (default INVALID_BUFFER_SLOT).
+        int mSlot;
+
+        // mBuf is the former name for mSlot
+        int mBuf;
+    };
+
+    // mIsDroppable whether this buffer was queued with the
+    // property that it can be replaced by a new buffer for the purpose of
+    // making sure dequeueBuffer() won't block.
+    // i.e.: was the BufferQueue in "mDequeueBufferCannotBlock" when this buffer
+    // was queued.
+    bool mIsDroppable;
+
+    // Indicates whether this buffer has been seen by a consumer yet
+    bool mAcquireCalled;
+
+    // Indicates this buffer must be transformed by the inverse transform of the screen
+    // it is displayed onto. This is applied after mTransform.
+    bool mTransformToDisplayInverse;
+
+    // Describes the portion of the surface that has been modified since the
+    // previous frame
+    Region mSurfaceDamage;
+};
+
+} // namespace android
+
+#endif
diff --git a/include/gui/BufferItemConsumer.h b/include/gui/BufferItemConsumer.h
index 52edf17..56c7a3f 100644
--- a/include/gui/BufferItemConsumer.h
+++ b/include/gui/BufferItemConsumer.h
@@ -42,8 +42,7 @@
   public:
     typedef ConsumerBase::FrameAvailableListener FrameAvailableListener;
 
-    typedef BufferQueue::BufferItem BufferItem;
-
+    enum { DEFAULT_MAX_BUFFERS = -1 };
     enum { INVALID_BUFFER_SLOT = BufferQueue::INVALID_BUFFER_SLOT };
     enum { NO_BUFFER_AVAILABLE = BufferQueue::NO_BUFFER_AVAILABLE };
 
@@ -53,8 +52,8 @@
     // access at the same time.
     // controlledByApp tells whether this consumer is controlled by the
     // application.
-    BufferItemConsumer(const sp<BufferQueue>& bq, uint32_t consumerUsage,
-            int bufferCount = BufferQueue::MIN_UNDEQUEUED_BUFFERS,
+    BufferItemConsumer(const sp<IGraphicBufferConsumer>& consumer,
+            uint32_t consumerUsage, int bufferCount = DEFAULT_MAX_BUFFERS,
             bool controlledByApp = false);
 
     virtual ~BufferItemConsumer();
@@ -75,8 +74,8 @@
     //
     // If waitForFence is true, and the acquired BufferItem has a valid fence object,
     // acquireBuffer will wait on the fence with no timeout before returning.
-    status_t acquireBuffer(BufferItem *item, nsecs_t presentWhen,
-        bool waitForFence = true);
+    status_t acquireBuffer(BufferItem* item, nsecs_t presentWhen,
+            bool waitForFence = true);
 
     // Returns an acquired buffer to the queue, allowing it to be reused. Since
     // only a fixed number of buffers may be acquired at a time, old buffers
@@ -87,14 +86,6 @@
     status_t releaseBuffer(const BufferItem &item,
             const sp<Fence>& releaseFence = Fence::NO_FENCE);
 
-    // setDefaultBufferSize is used to set the size of buffers returned by
-    // requestBuffers when a with and height of zero is requested.
-    status_t setDefaultBufferSize(uint32_t w, uint32_t h);
-
-    // setDefaultBufferFormat allows the BufferQueue to create
-    // GraphicBuffers of a defaultFormat if no format is specified
-    // in dequeueBuffer
-    status_t setDefaultBufferFormat(uint32_t defaultFormat);
 };
 
 } // namespace android
diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h
index 408956b..09300a2 100644
--- a/include/gui/BufferQueue.h
+++ b/include/gui/BufferQueue.h
@@ -17,35 +17,30 @@
 #ifndef ANDROID_GUI_BUFFERQUEUE_H
 #define ANDROID_GUI_BUFFERQUEUE_H
 
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-
-#include <binder/IBinder.h>
-
-#include <gui/IConsumerListener.h>
-#include <gui/IGraphicBufferAlloc.h>
-#include <gui/IGraphicBufferProducer.h>
+#include <gui/BufferItem.h>
+#include <gui/BufferQueueDefs.h>
 #include <gui/IGraphicBufferConsumer.h>
+#include <gui/IGraphicBufferProducer.h>
+#include <gui/IConsumerListener.h>
 
-#include <ui/Fence.h>
-#include <ui/GraphicBuffer.h>
-
-#include <utils/String8.h>
-#include <utils/Vector.h>
-#include <utils/threads.h>
+// These are only required to keep other parts of the framework with incomplete
+// dependencies building successfully
+#include <gui/IGraphicBufferAlloc.h>
 
 namespace android {
-// ----------------------------------------------------------------------------
 
-class BufferQueue : public BnGraphicBufferProducer,
-                    public BnGraphicBufferConsumer,
-                    private IBinder::DeathRecipient {
+class BufferQueue {
 public:
-    enum { MIN_UNDEQUEUED_BUFFERS = 2 };
-    enum { NUM_BUFFER_SLOTS = 32 };
-    enum { NO_CONNECTED_API = 0 };
-    enum { INVALID_BUFFER_SLOT = -1 };
-    enum { STALE_BUFFER_SLOT = 1, NO_BUFFER_AVAILABLE, PRESENT_LATER };
+    // BufferQueue will keep track of at most this value of buffers.
+    // Attempts at runtime to increase the number of buffers past this will fail.
+    enum { NUM_BUFFER_SLOTS = BufferQueueDefs::NUM_BUFFER_SLOTS };
+    // Used as a placeholder slot# when the value isn't pointing to an existing buffer.
+    enum { INVALID_BUFFER_SLOT = BufferItem::INVALID_BUFFER_SLOT };
+    // Alias to <IGraphicBufferConsumer.h> -- please scope from there in future code!
+    enum {
+        NO_BUFFER_AVAILABLE = IGraphicBufferConsumer::NO_BUFFER_AVAILABLE,
+        PRESENT_LATER = IGraphicBufferConsumer::PRESENT_LATER,
+    };
 
     // When in async mode we reserve two slots in order to guarantee that the
     // producer and consumer can run asynchronously.
@@ -67,505 +62,25 @@
     public:
         ProxyConsumerListener(const wp<ConsumerListener>& consumerListener);
         virtual ~ProxyConsumerListener();
-        virtual void onFrameAvailable();
-        virtual void onBuffersReleased();
+        virtual void onFrameAvailable(const BufferItem& item) override;
+        virtual void onFrameReplaced(const BufferItem& item) override;
+        virtual void onBuffersReleased() override;
+        virtual void onSidebandStreamChanged() override;
     private:
         // mConsumerListener is a weak reference to the IConsumerListener.  This is
         // the raison d'etre of ProxyConsumerListener.
         wp<ConsumerListener> mConsumerListener;
     };
 
-
     // BufferQueue manages a pool of gralloc memory slots to be used by
     // producers and consumers. allocator is used to allocate all the
     // needed gralloc buffers.
-    BufferQueue(const sp<IGraphicBufferAlloc>& allocator = NULL);
-    virtual ~BufferQueue();
-
-    /*
-     * IBinder::DeathRecipient interface
-     */
-
-    virtual void binderDied(const wp<IBinder>& who);
-
-    /*
-     * IGraphicBufferProducer interface
-     */
-
-    // Query native window attributes.  The "what" values are enumerated in
-    // window.h (e.g. NATIVE_WINDOW_FORMAT).
-    virtual int query(int what, int* value);
-
-    // setBufferCount updates the number of available buffer slots.  If this
-    // method succeeds, buffer slots will be both unallocated and owned by
-    // the BufferQueue object (i.e. they are not owned by the producer or
-    // consumer).
-    //
-    // This will fail if the producer has dequeued any buffers, or if
-    // bufferCount is invalid.  bufferCount must generally be a value
-    // between the minimum undequeued buffer count and NUM_BUFFER_SLOTS
-    // (inclusive).  It may also be set to zero (the default) to indicate
-    // that the producer does not wish to set a value.  The minimum value
-    // can be obtained by calling query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
-    // ...).
-    //
-    // This may only be called by the producer.  The consumer will be told
-    // to discard buffers through the onBuffersReleased callback.
-    virtual status_t setBufferCount(int bufferCount);
-
-    // requestBuffer returns the GraphicBuffer for slot N.
-    //
-    // In normal operation, this is called the first time slot N is returned
-    // by dequeueBuffer.  It must be called again if dequeueBuffer returns
-    // flags indicating that previously-returned buffers are no longer valid.
-    virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf);
-
-    // dequeueBuffer gets the next buffer slot index for the producer to use.
-    // If a buffer slot is available then that slot index is written to the
-    // location pointed to by the buf argument and a status of OK is returned.
-    // If no slot is available then a status of -EBUSY is returned and buf is
-    // unmodified.
-    //
-    // The fence parameter will be updated to hold the fence associated with
-    // the buffer. The contents of the buffer must not be overwritten until the
-    // fence signals. If the fence is Fence::NO_FENCE, the buffer may be
-    // written immediately.
-    //
-    // The width and height parameters must be no greater than the minimum of
-    // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv).
-    // An error due to invalid dimensions might not be reported until
-    // updateTexImage() is called.  If width and height are both zero, the
-    // default values specified by setDefaultBufferSize() are used instead.
-    //
-    // The pixel formats are enumerated in graphics.h, e.g.
-    // HAL_PIXEL_FORMAT_RGBA_8888.  If the format is 0, the default format
-    // will be used.
-    //
-    // The usage argument specifies gralloc buffer usage flags.  The values
-    // are enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER.  These
-    // will be merged with the usage flags specified by setConsumerUsageBits.
-    //
-    // The return value may be a negative error value or a non-negative
-    // collection of flags.  If the flags are set, the return values are
-    // valid, but additional actions must be performed.
-    //
-    // If IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION is set, the
-    // producer must discard cached GraphicBuffer references for the slot
-    // returned in buf.
-    // If IGraphicBufferProducer::RELEASE_ALL_BUFFERS is set, the producer
-    // must discard cached GraphicBuffer references for all slots.
-    //
-    // In both cases, the producer will need to call requestBuffer to get a
-    // GraphicBuffer handle for the returned slot.
-    virtual status_t dequeueBuffer(int *buf, sp<Fence>* fence, bool async,
-            uint32_t width, uint32_t height, uint32_t format, uint32_t usage);
-
-    // queueBuffer returns a filled buffer to the BufferQueue.
-    //
-    // Additional data is provided in the QueueBufferInput struct.  Notably,
-    // a timestamp must be provided for the buffer. The timestamp is in
-    // nanoseconds, and must be monotonically increasing. Its other semantics
-    // (zero point, etc) are producer-specific and should be documented by the
-    // producer.
-    //
-    // The caller may provide a fence that signals when all rendering
-    // operations have completed.  Alternatively, NO_FENCE may be used,
-    // indicating that the buffer is ready immediately.
-    //
-    // Some values are returned in the output struct: the current settings
-    // for default width and height, the current transform hint, and the
-    // number of queued buffers.
-    virtual status_t queueBuffer(int buf,
-            const QueueBufferInput& input, QueueBufferOutput* output);
-
-    // cancelBuffer returns a dequeued buffer to the BufferQueue, but doesn't
-    // queue it for use by the consumer.
-    //
-    // The buffer will not be overwritten until the fence signals.  The fence
-    // will usually be the one obtained from dequeueBuffer.
-    virtual void cancelBuffer(int buf, const sp<Fence>& fence);
-
-    // connect attempts to connect a producer API to the BufferQueue.  This
-    // must be called before any other IGraphicBufferProducer methods are
-    // called except for getAllocator.  A consumer must already be connected.
-    //
-    // This method will fail if connect was previously called on the
-    // BufferQueue and no corresponding disconnect call was made (i.e. if
-    // it's still connected to a producer).
-    //
-    // APIs are enumerated in window.h (e.g. NATIVE_WINDOW_API_CPU).
-    virtual status_t connect(const sp<IBinder>& token,
-            int api, bool producerControlledByApp, QueueBufferOutput* output);
-
-    // disconnect attempts to disconnect a producer API from the BufferQueue.
-    // Calling this method will cause any subsequent calls to other
-    // IGraphicBufferProducer methods to fail except for getAllocator and connect.
-    // Successfully calling connect after this will allow the other methods to
-    // succeed again.
-    //
-    // This method will fail if the the BufferQueue is not currently
-    // connected to the specified producer API.
-    virtual status_t disconnect(int api);
-
-    /*
-     * IGraphicBufferConsumer interface
-     */
-
-    // acquireBuffer attempts to acquire ownership of the next pending buffer in
-    // the BufferQueue.  If no buffer is pending then it returns -EINVAL.  If a
-    // buffer is successfully acquired, the information about the buffer is
-    // returned in BufferItem.  If the buffer returned had previously been
-    // acquired then the BufferItem::mGraphicBuffer field of buffer is set to
-    // NULL and it is assumed that the consumer still holds a reference to the
-    // buffer.
-    //
-    // If presentWhen is nonzero, it indicates the time when the buffer will
-    // be displayed on screen.  If the buffer's timestamp is farther in the
-    // future, the buffer won't be acquired, and PRESENT_LATER will be
-    // returned.  The presentation time is in nanoseconds, and the time base
-    // is CLOCK_MONOTONIC.
-    virtual status_t acquireBuffer(BufferItem *buffer, nsecs_t presentWhen);
-
-    // releaseBuffer releases a buffer slot from the consumer back to the
-    // BufferQueue.  This may be done while the buffer's contents are still
-    // being accessed.  The fence will signal when the buffer is no longer
-    // in use. frameNumber is used to indentify the exact buffer returned.
-    //
-    // If releaseBuffer returns STALE_BUFFER_SLOT, then the consumer must free
-    // any references to the just-released buffer that it might have, as if it
-    // had received a onBuffersReleased() call with a mask set for the released
-    // buffer.
-    //
-    // Note that the dependencies on EGL will be removed once we switch to using
-    // the Android HW Sync HAL.
-    virtual status_t releaseBuffer(int buf, uint64_t frameNumber,
-            EGLDisplay display, EGLSyncKHR fence,
-            const sp<Fence>& releaseFence);
-
-    // consumerConnect connects a consumer to the BufferQueue.  Only one
-    // consumer may be connected, and when that consumer disconnects the
-    // BufferQueue is placed into the "abandoned" state, causing most
-    // interactions with the BufferQueue by the producer to fail.
-    // controlledByApp indicates whether the consumer is controlled by
-    // the application.
-    //
-    // consumer may not be NULL.
-    virtual status_t consumerConnect(const sp<IConsumerListener>& consumer, bool controlledByApp);
-
-    // consumerDisconnect disconnects a consumer from the BufferQueue. All
-    // buffers will be freed and the BufferQueue is placed in the "abandoned"
-    // state, causing most interactions with the BufferQueue by the producer to
-    // fail.
-    virtual status_t consumerDisconnect();
-
-    // getReleasedBuffers sets the value pointed to by slotMask to a bit mask
-    // indicating which buffer slots have been released by the BufferQueue
-    // but have not yet been released by the consumer.
-    //
-    // This should be called from the onBuffersReleased() callback.
-    virtual status_t getReleasedBuffers(uint32_t* slotMask);
-
-    // setDefaultBufferSize is used to set the size of buffers returned by
-    // dequeueBuffer when a width and height of zero is requested.  Default
-    // is 1x1.
-    virtual status_t setDefaultBufferSize(uint32_t w, uint32_t h);
-
-    // setDefaultMaxBufferCount sets the default value for the maximum buffer
-    // count (the initial default is 2). If the producer has requested a
-    // buffer count using setBufferCount, the default buffer count will only
-    // take effect if the producer sets the count back to zero.
-    //
-    // The count must be between 2 and NUM_BUFFER_SLOTS, inclusive.
-    virtual status_t setDefaultMaxBufferCount(int bufferCount);
-
-    // disableAsyncBuffer disables the extra buffer used in async mode
-    // (when both producer and consumer have set their "isControlledByApp"
-    // flag) and has dequeueBuffer() return WOULD_BLOCK instead.
-    //
-    // This can only be called before consumerConnect().
-    virtual status_t disableAsyncBuffer();
-
-    // setMaxAcquiredBufferCount sets the maximum number of buffers that can
-    // be acquired by the consumer at one time (default 1).  This call will
-    // fail if a producer is connected to the BufferQueue.
-    virtual status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers);
-
-    // setConsumerName sets the name used in logging
-    virtual void setConsumerName(const String8& name);
-
-    // setDefaultBufferFormat allows the BufferQueue to create
-    // GraphicBuffers of a defaultFormat if no format is specified
-    // in dequeueBuffer.  Formats are enumerated in graphics.h; the
-    // initial default is HAL_PIXEL_FORMAT_RGBA_8888.
-    virtual status_t setDefaultBufferFormat(uint32_t defaultFormat);
-
-    // setConsumerUsageBits will turn on additional usage bits for dequeueBuffer.
-    // These are merged with the bits passed to dequeueBuffer.  The values are
-    // enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER; the default is 0.
-    virtual status_t setConsumerUsageBits(uint32_t usage);
-
-    // setTransformHint bakes in rotation to buffers so overlays can be used.
-    // The values are enumerated in window.h, e.g.
-    // NATIVE_WINDOW_TRANSFORM_ROT_90.  The default is 0 (no transform).
-    virtual status_t setTransformHint(uint32_t hint);
-
-    // dump our state in a String
-    virtual void dump(String8& result, const char* prefix) const;
-
+    static void createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
+            sp<IGraphicBufferConsumer>* outConsumer,
+            const sp<IGraphicBufferAlloc>& allocator = NULL);
 
 private:
-    // freeBufferLocked frees the GraphicBuffer and sync resources for the
-    // given slot.
-    void freeBufferLocked(int index);
-
-    // freeAllBuffersLocked frees the GraphicBuffer and sync resources for
-    // all slots.
-    void freeAllBuffersLocked();
-
-    // setDefaultMaxBufferCountLocked sets the maximum number of buffer slots
-    // that will be used if the producer does not override the buffer slot
-    // count.  The count must be between 2 and NUM_BUFFER_SLOTS, inclusive.
-    // The initial default is 2.
-    status_t setDefaultMaxBufferCountLocked(int count);
-
-    // getMinUndequeuedBufferCount returns the minimum number of buffers
-    // that must remain in a state other than DEQUEUED.
-    // The async parameter tells whether we're in asynchronous mode.
-    int getMinUndequeuedBufferCount(bool async) const;
-
-    // getMinBufferCountLocked returns the minimum number of buffers allowed
-    // given the current BufferQueue state.
-    // The async parameter tells whether we're in asynchronous mode.
-    int getMinMaxBufferCountLocked(bool async) const;
-
-    // getMaxBufferCountLocked returns the maximum number of buffers that can
-    // be allocated at once.  This value depends upon the following member
-    // variables:
-    //
-    //      mDequeueBufferCannotBlock
-    //      mMaxAcquiredBufferCount
-    //      mDefaultMaxBufferCount
-    //      mOverrideMaxBufferCount
-    //      async parameter
-    //
-    // Any time one of these member variables is changed while a producer is
-    // connected, mDequeueCondition must be broadcast.
-    int getMaxBufferCountLocked(bool async) const;
-
-    // stillTracking returns true iff the buffer item is still being tracked
-    // in one of the slots.
-    bool stillTracking(const BufferItem *item) const;
-
-    struct BufferSlot {
-
-        BufferSlot()
-        : mEglDisplay(EGL_NO_DISPLAY),
-          mBufferState(BufferSlot::FREE),
-          mRequestBufferCalled(false),
-          mFrameNumber(0),
-          mEglFence(EGL_NO_SYNC_KHR),
-          mAcquireCalled(false),
-          mNeedsCleanupOnRelease(false) {
-        }
-
-        // mGraphicBuffer points to the buffer allocated for this slot or is NULL
-        // if no buffer has been allocated.
-        sp<GraphicBuffer> mGraphicBuffer;
-
-        // mEglDisplay is the EGLDisplay used to create EGLSyncKHR objects.
-        EGLDisplay mEglDisplay;
-
-        // BufferState represents the different states in which a buffer slot
-        // can be.  All slots are initially FREE.
-        enum BufferState {
-            // FREE indicates that the buffer is available to be dequeued
-            // by the producer.  The buffer may be in use by the consumer for
-            // a finite time, so the buffer must not be modified until the
-            // associated fence is signaled.
-            //
-            // The slot is "owned" by BufferQueue.  It transitions to DEQUEUED
-            // when dequeueBuffer is called.
-            FREE = 0,
-
-            // DEQUEUED indicates that the buffer has been dequeued by the
-            // producer, but has not yet been queued or canceled.  The
-            // producer may modify the buffer's contents as soon as the
-            // associated ready fence is signaled.
-            //
-            // The slot is "owned" by the producer.  It can transition to
-            // QUEUED (via queueBuffer) or back to FREE (via cancelBuffer).
-            DEQUEUED = 1,
-
-            // QUEUED indicates that the buffer has been filled by the
-            // producer and queued for use by the consumer.  The buffer
-            // contents may continue to be modified for a finite time, so
-            // the contents must not be accessed until the associated fence
-            // is signaled.
-            //
-            // The slot is "owned" by BufferQueue.  It can transition to
-            // ACQUIRED (via acquireBuffer) or to FREE (if another buffer is
-            // queued in asynchronous mode).
-            QUEUED = 2,
-
-            // ACQUIRED indicates that the buffer has been acquired by the
-            // consumer.  As with QUEUED, the contents must not be accessed
-            // by the consumer until the fence is signaled.
-            //
-            // The slot is "owned" by the consumer.  It transitions to FREE
-            // when releaseBuffer is called.
-            ACQUIRED = 3
-        };
-
-        // mBufferState is the current state of this buffer slot.
-        BufferState mBufferState;
-
-        // mRequestBufferCalled is used for validating that the producer did
-        // call requestBuffer() when told to do so. Technically this is not
-        // needed but useful for debugging and catching producer bugs.
-        bool mRequestBufferCalled;
-
-        // mFrameNumber is the number of the queued frame for this slot.  This
-        // is used to dequeue buffers in LRU order (useful because buffers
-        // may be released before their release fence is signaled).
-        uint64_t mFrameNumber;
-
-        // mEglFence is the EGL sync object that must signal before the buffer
-        // associated with this buffer slot may be dequeued. It is initialized
-        // to EGL_NO_SYNC_KHR when the buffer is created and may be set to a
-        // new sync object in releaseBuffer.  (This is deprecated in favor of
-        // mFence, below.)
-        EGLSyncKHR mEglFence;
-
-        // mFence is a fence which will signal when work initiated by the
-        // previous owner of the buffer is finished. When the buffer is FREE,
-        // the fence indicates when the consumer has finished reading
-        // from the buffer, or when the producer has finished writing if it
-        // called cancelBuffer after queueing some writes. When the buffer is
-        // QUEUED, it indicates when the producer has finished filling the
-        // buffer. When the buffer is DEQUEUED or ACQUIRED, the fence has been
-        // passed to the consumer or producer along with ownership of the
-        // buffer, and mFence is set to NO_FENCE.
-        sp<Fence> mFence;
-
-        // Indicates whether this buffer has been seen by a consumer yet
-        bool mAcquireCalled;
-
-        // Indicates whether this buffer needs to be cleaned up by the
-        // consumer.  This is set when a buffer in ACQUIRED state is freed.
-        // It causes releaseBuffer to return STALE_BUFFER_SLOT.
-        bool mNeedsCleanupOnRelease;
-    };
-
-    // mSlots is the array of buffer slots that must be mirrored on the
-    // producer side. This allows buffer ownership to be transferred between
-    // the producer and consumer without sending a GraphicBuffer over binder.
-    // The entire array is initialized to NULL at construction time, and
-    // buffers are allocated for a slot when requestBuffer is called with
-    // that slot's index.
-    BufferSlot mSlots[NUM_BUFFER_SLOTS];
-
-    // mDefaultWidth holds the default width of allocated buffers. It is used
-    // in dequeueBuffer() if a width and height of zero is specified.
-    uint32_t mDefaultWidth;
-
-    // mDefaultHeight holds the default height of allocated buffers. It is used
-    // in dequeueBuffer() if a width and height of zero is specified.
-    uint32_t mDefaultHeight;
-
-    // mMaxAcquiredBufferCount is the number of buffers that the consumer may
-    // acquire at one time.  It defaults to 1 and can be changed by the
-    // consumer via the setMaxAcquiredBufferCount method, but this may only be
-    // done when no producer is connected to the BufferQueue.
-    //
-    // This value is used to derive the value returned for the
-    // MIN_UNDEQUEUED_BUFFERS query by the producer.
-    int mMaxAcquiredBufferCount;
-
-    // mDefaultMaxBufferCount is the default limit on the number of buffers
-    // that will be allocated at one time.  This default limit is set by the
-    // consumer.  The limit (as opposed to the default limit) may be
-    // overridden by the producer.
-    int mDefaultMaxBufferCount;
-
-    // mOverrideMaxBufferCount is the limit on the number of buffers that will
-    // be allocated at one time. This value is set by the image producer by
-    // calling setBufferCount. The default is zero, which means the producer
-    // doesn't care about the number of buffers in the pool. In that case
-    // mDefaultMaxBufferCount is used as the limit.
-    int mOverrideMaxBufferCount;
-
-    // mGraphicBufferAlloc is the connection to SurfaceFlinger that is used to
-    // allocate new GraphicBuffer objects.
-    sp<IGraphicBufferAlloc> mGraphicBufferAlloc;
-
-    // mConsumerListener is used to notify the connected consumer of
-    // asynchronous events that it may wish to react to.  It is initially set
-    // to NULL and is written by consumerConnect and consumerDisconnect.
-    sp<IConsumerListener> mConsumerListener;
-
-    // mConsumerControlledByApp whether the connected consumer is controlled by the
-    // application.
-    bool mConsumerControlledByApp;
-
-    // mDequeueBufferCannotBlock whether dequeueBuffer() isn't allowed to block.
-    // this flag is set during connect() when both consumer and producer are controlled
-    // by the application.
-    bool mDequeueBufferCannotBlock;
-
-    // mUseAsyncBuffer whether an extra buffer is used in async mode to prevent
-    // dequeueBuffer() from ever blocking.
-    bool mUseAsyncBuffer;
-
-    // mConnectedApi indicates the producer API that is currently connected
-    // to this BufferQueue.  It defaults to NO_CONNECTED_API (= 0), and gets
-    // updated by the connect and disconnect methods.
-    int mConnectedApi;
-
-    // mDequeueCondition condition used for dequeueBuffer in synchronous mode
-    mutable Condition mDequeueCondition;
-
-    // mQueue is a FIFO of queued buffers used in synchronous mode
-    typedef Vector<BufferItem> Fifo;
-    Fifo mQueue;
-
-    // mAbandoned indicates that the BufferQueue will no longer be used to
-    // consume image buffers pushed to it using the IGraphicBufferProducer
-    // interface.  It is initialized to false, and set to true in the
-    // consumerDisconnect method.  A BufferQueue that has been abandoned will
-    // return the NO_INIT error from all IGraphicBufferProducer methods
-    // capable of returning an error.
-    bool mAbandoned;
-
-    // mConsumerName is a string used to identify the BufferQueue in log
-    // messages.  It is set by the setConsumerName method.
-    String8 mConsumerName;
-
-    // mMutex is the mutex used to prevent concurrent access to the member
-    // variables of BufferQueue objects. It must be locked whenever the
-    // member variables are accessed.
-    mutable Mutex mMutex;
-
-    // mFrameCounter is the free running counter, incremented on every
-    // successful queueBuffer call, and buffer allocation.
-    uint64_t mFrameCounter;
-
-    // mBufferHasBeenQueued is true once a buffer has been queued.  It is
-    // reset when something causes all buffers to be freed (e.g. changing the
-    // buffer count).
-    bool mBufferHasBeenQueued;
-
-    // mDefaultBufferFormat can be set so it will override
-    // the buffer format when it isn't specified in dequeueBuffer
-    uint32_t mDefaultBufferFormat;
-
-    // mConsumerUsageBits contains flags the consumer wants for GraphicBuffers
-    uint32_t mConsumerUsageBits;
-
-    // mTransformHint is used to optimize for screen rotations
-    uint32_t mTransformHint;
-
-    // mConnectedProducerToken is used to set a binder death notification on the producer
-    sp<IBinder> mConnectedProducerToken;
+    BufferQueue(); // Create through createBufferQueue
 };
 
 // ----------------------------------------------------------------------------
diff --git a/include/gui/BufferQueueConsumer.h b/include/gui/BufferQueueConsumer.h
new file mode 100644
index 0000000..cde302f
--- /dev/null
+++ b/include/gui/BufferQueueConsumer.h
@@ -0,0 +1,187 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_GUI_BUFFERQUEUECONSUMER_H
+#define ANDROID_GUI_BUFFERQUEUECONSUMER_H
+
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+#include <gui/BufferQueueDefs.h>
+#include <gui/IGraphicBufferConsumer.h>
+
+namespace android {
+
+class BufferQueueCore;
+
+class BufferQueueConsumer : public BnGraphicBufferConsumer {
+
+public:
+    BufferQueueConsumer(const sp<BufferQueueCore>& core);
+    virtual ~BufferQueueConsumer();
+
+    // acquireBuffer attempts to acquire ownership of the next pending buffer in
+    // the BufferQueue. If no buffer is pending then it returns
+    // NO_BUFFER_AVAILABLE. If a buffer is successfully acquired, the
+    // information about the buffer is returned in BufferItem.  If the buffer
+    // returned had previously been acquired then the BufferItem::mGraphicBuffer
+    // field of buffer is set to NULL and it is assumed that the consumer still
+    // holds a reference to the buffer.
+    //
+    // If expectedPresent is nonzero, it indicates the time when the buffer
+    // will be displayed on screen. If the buffer's timestamp is farther in the
+    // future, the buffer won't be acquired, and PRESENT_LATER will be
+    // returned.  The presentation time is in nanoseconds, and the time base
+    // is CLOCK_MONOTONIC.
+    virtual status_t acquireBuffer(BufferItem* outBuffer,
+            nsecs_t expectedPresent, uint64_t maxFrameNumber = 0) override;
+
+    // See IGraphicBufferConsumer::detachBuffer
+    virtual status_t detachBuffer(int slot);
+
+    // See IGraphicBufferConsumer::attachBuffer
+    virtual status_t attachBuffer(int* slot, const sp<GraphicBuffer>& buffer);
+
+    // releaseBuffer releases a buffer slot from the consumer back to the
+    // BufferQueue.  This may be done while the buffer's contents are still
+    // being accessed.  The fence will signal when the buffer is no longer
+    // in use. frameNumber is used to indentify the exact buffer returned.
+    //
+    // If releaseBuffer returns STALE_BUFFER_SLOT, then the consumer must free
+    // any references to the just-released buffer that it might have, as if it
+    // had received a onBuffersReleased() call with a mask set for the released
+    // buffer.
+    //
+    // Note that the dependencies on EGL will be removed once we switch to using
+    // the Android HW Sync HAL.
+    virtual status_t releaseBuffer(int slot, uint64_t frameNumber,
+            const sp<Fence>& releaseFence, EGLDisplay display,
+            EGLSyncKHR fence);
+
+    // connect connects a consumer to the BufferQueue.  Only one
+    // consumer may be connected, and when that consumer disconnects the
+    // BufferQueue is placed into the "abandoned" state, causing most
+    // interactions with the BufferQueue by the producer to fail.
+    // controlledByApp indicates whether the consumer is controlled by
+    // the application.
+    //
+    // consumerListener may not be NULL.
+    virtual status_t connect(const sp<IConsumerListener>& consumerListener,
+            bool controlledByApp);
+
+    // disconnect disconnects a consumer from the BufferQueue. All
+    // buffers will be freed and the BufferQueue is placed in the "abandoned"
+    // state, causing most interactions with the BufferQueue by the producer to
+    // fail.
+    virtual status_t disconnect();
+
+    // getReleasedBuffers sets the value pointed to by outSlotMask to a bit mask
+    // indicating which buffer slots have been released by the BufferQueue
+    // but have not yet been released by the consumer.
+    //
+    // This should be called from the onBuffersReleased() callback.
+    virtual status_t getReleasedBuffers(uint64_t* outSlotMask);
+
+    // setDefaultBufferSize is used to set the size of buffers returned by
+    // dequeueBuffer when a width and height of zero is requested.  Default
+    // is 1x1.
+    virtual status_t setDefaultBufferSize(uint32_t width, uint32_t height);
+
+    // setDefaultMaxBufferCount sets the default value for the maximum buffer
+    // count (the initial default is 2). If the producer has requested a
+    // buffer count using setBufferCount, the default buffer count will only
+    // take effect if the producer sets the count back to zero.
+    //
+    // The count must be between 2 and NUM_BUFFER_SLOTS, inclusive.
+    virtual status_t setDefaultMaxBufferCount(int bufferCount);
+
+    // disableAsyncBuffer disables the extra buffer used in async mode
+    // (when both producer and consumer have set their "isControlledByApp"
+    // flag) and has dequeueBuffer() return WOULD_BLOCK instead.
+    //
+    // This can only be called before connect().
+    virtual status_t disableAsyncBuffer();
+
+    // setMaxAcquiredBufferCount sets the maximum number of buffers that can
+    // be acquired by the consumer at one time (default 1).  This call will
+    // fail if a producer is connected to the BufferQueue.
+    virtual status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers);
+
+    // setConsumerName sets the name used in logging
+    virtual void setConsumerName(const String8& name);
+
+    // setDefaultBufferFormat allows the BufferQueue to create
+    // GraphicBuffers of a defaultFormat if no format is specified
+    // in dequeueBuffer. The initial default is HAL_PIXEL_FORMAT_RGBA_8888.
+    virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat);
+
+    // setDefaultBufferDataSpace allows the BufferQueue to create
+    // GraphicBuffers of a defaultDataSpace if no data space is specified
+    // in queueBuffer.
+    // The initial default is HAL_DATASPACE_UNKNOWN
+    virtual status_t setDefaultBufferDataSpace(
+            android_dataspace defaultDataSpace);
+
+    // setConsumerUsageBits will turn on additional usage bits for dequeueBuffer.
+    // These are merged with the bits passed to dequeueBuffer.  The values are
+    // enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER; the default is 0.
+    virtual status_t setConsumerUsageBits(uint32_t usage);
+
+    // setTransformHint bakes in rotation to buffers so overlays can be used.
+    // The values are enumerated in window.h, e.g.
+    // NATIVE_WINDOW_TRANSFORM_ROT_90.  The default is 0 (no transform).
+    virtual status_t setTransformHint(uint32_t hint);
+
+    // Retrieve the sideband buffer stream, if any.
+    virtual sp<NativeHandle> getSidebandStream() const;
+
+    // dump our state in a String
+    virtual void dump(String8& result, const char* prefix) const;
+
+    // Functions required for backwards compatibility.
+    // These will be modified/renamed in IGraphicBufferConsumer and will be
+    // removed from this class at that time. See b/13306289.
+
+    virtual status_t releaseBuffer(int buf, uint64_t frameNumber,
+            EGLDisplay display, EGLSyncKHR fence,
+            const sp<Fence>& releaseFence) {
+        return releaseBuffer(buf, frameNumber, releaseFence, display, fence);
+    }
+
+    virtual status_t consumerConnect(const sp<IConsumerListener>& consumer,
+            bool controlledByApp) {
+        return connect(consumer, controlledByApp);
+    }
+
+    virtual status_t consumerDisconnect() { return disconnect(); }
+
+    // End functions required for backwards compatibility
+
+private:
+    sp<BufferQueueCore> mCore;
+
+    // This references mCore->mSlots. Lock mCore->mMutex while accessing.
+    BufferQueueDefs::SlotsType& mSlots;
+
+    // This is a cached copy of the name stored in the BufferQueueCore.
+    // It's updated during setConsumerName.
+    String8 mConsumerName;
+
+}; // class BufferQueueConsumer
+
+} // namespace android
+
+#endif
diff --git a/include/gui/BufferQueueCore.h b/include/gui/BufferQueueCore.h
new file mode 100644
index 0000000..99134ea
--- /dev/null
+++ b/include/gui/BufferQueueCore.h
@@ -0,0 +1,287 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_GUI_BUFFERQUEUECORE_H
+#define ANDROID_GUI_BUFFERQUEUECORE_H
+
+#include <gui/BufferItem.h>
+#include <gui/BufferQueueDefs.h>
+#include <gui/BufferSlot.h>
+
+#include <utils/Condition.h>
+#include <utils/Mutex.h>
+#include <utils/NativeHandle.h>
+#include <utils/RefBase.h>
+#include <utils/String8.h>
+#include <utils/StrongPointer.h>
+#include <utils/Trace.h>
+#include <utils/Vector.h>
+
+#include <list>
+#include <set>
+
+#define BQ_LOGV(x, ...) ALOGV("[%s] " x, mConsumerName.string(), ##__VA_ARGS__)
+#define BQ_LOGD(x, ...) ALOGD("[%s] " x, mConsumerName.string(), ##__VA_ARGS__)
+#define BQ_LOGI(x, ...) ALOGI("[%s] " x, mConsumerName.string(), ##__VA_ARGS__)
+#define BQ_LOGW(x, ...) ALOGW("[%s] " x, mConsumerName.string(), ##__VA_ARGS__)
+#define BQ_LOGE(x, ...) ALOGE("[%s] " x, mConsumerName.string(), ##__VA_ARGS__)
+
+#define ATRACE_BUFFER_INDEX(index)                                   \
+    if (ATRACE_ENABLED()) {                                          \
+        char ___traceBuf[1024];                                      \
+        snprintf(___traceBuf, 1024, "%s: %d",                        \
+                mCore->mConsumerName.string(), (index));             \
+        android::ScopedTrace ___bufTracer(ATRACE_TAG, ___traceBuf);  \
+    }
+
+namespace android {
+
+class IConsumerListener;
+class IGraphicBufferAlloc;
+class IProducerListener;
+
+class BufferQueueCore : public virtual RefBase {
+
+    friend class BufferQueueProducer;
+    friend class BufferQueueConsumer;
+
+public:
+    // Used as a placeholder slot number when the value isn't pointing to an
+    // existing buffer.
+    enum { INVALID_BUFFER_SLOT = BufferItem::INVALID_BUFFER_SLOT };
+
+    // We reserve two slots in order to guarantee that the producer and
+    // consumer can run asynchronously.
+    enum { MAX_MAX_ACQUIRED_BUFFERS = BufferQueueDefs::NUM_BUFFER_SLOTS - 2 };
+
+    // The default API number used to indicate that no producer is connected
+    enum { NO_CONNECTED_API = 0 };
+
+    typedef Vector<BufferItem> Fifo;
+
+    // BufferQueueCore manages a pool of gralloc memory slots to be used by
+    // producers and consumers. allocator is used to allocate all the needed
+    // gralloc buffers.
+    BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator = NULL);
+    virtual ~BufferQueueCore();
+
+private:
+    // Dump our state in a string
+    void dump(String8& result, const char* prefix) const;
+
+    // getMinUndequeuedBufferCountLocked returns the minimum number of buffers
+    // that must remain in a state other than DEQUEUED. The async parameter
+    // tells whether we're in asynchronous mode.
+    int getMinUndequeuedBufferCountLocked(bool async) const;
+
+    // getMinMaxBufferCountLocked returns the minimum number of buffers allowed
+    // given the current BufferQueue state. The async parameter tells whether
+    // we're in asynchonous mode.
+    int getMinMaxBufferCountLocked(bool async) const;
+
+    // getMaxBufferCountLocked returns the maximum number of buffers that can be
+    // allocated at once. This value depends on the following member variables:
+    //
+    //     mDequeueBufferCannotBlock
+    //     mMaxAcquiredBufferCount
+    //     mDefaultMaxBufferCount
+    //     mOverrideMaxBufferCount
+    //     async parameter
+    //
+    // Any time one of these member variables is changed while a producer is
+    // connected, mDequeueCondition must be broadcast.
+    int getMaxBufferCountLocked(bool async) const;
+
+    // setDefaultMaxBufferCountLocked sets the maximum number of buffer slots
+    // that will be used if the producer does not override the buffer slot
+    // count. The count must be between 2 and NUM_BUFFER_SLOTS, inclusive. The
+    // initial default is 2.
+    status_t setDefaultMaxBufferCountLocked(int count);
+
+    // freeBufferLocked frees the GraphicBuffer and sync resources for the
+    // given slot.
+    void freeBufferLocked(int slot);
+
+    // freeAllBuffersLocked frees the GraphicBuffer and sync resources for
+    // all slots.
+    void freeAllBuffersLocked();
+
+    // stillTracking returns true iff the buffer item is still being tracked
+    // in one of the slots.
+    bool stillTracking(const BufferItem* item) const;
+
+    // waitWhileAllocatingLocked blocks until mIsAllocating is false.
+    void waitWhileAllocatingLocked() const;
+
+    // validateConsistencyLocked ensures that the free lists are in sync with
+    // the information stored in mSlots
+    void validateConsistencyLocked() const;
+
+    // mAllocator is the connection to SurfaceFlinger that is used to allocate
+    // new GraphicBuffer objects.
+    sp<IGraphicBufferAlloc> mAllocator;
+
+    // mMutex is the mutex used to prevent concurrent access to the member
+    // variables of BufferQueueCore objects. It must be locked whenever any
+    // member variable is accessed.
+    mutable Mutex mMutex;
+
+    // mIsAbandoned indicates that the BufferQueue will no longer be used to
+    // consume image buffers pushed to it using the IGraphicBufferProducer
+    // interface. It is initialized to false, and set to true in the
+    // consumerDisconnect method. A BufferQueue that is abandoned will return
+    // the NO_INIT error from all IGraphicBufferProducer methods capable of
+    // returning an error.
+    bool mIsAbandoned;
+
+    // mConsumerControlledByApp indicates whether the connected consumer is
+    // controlled by the application.
+    bool mConsumerControlledByApp;
+
+    // mConsumerName is a string used to identify the BufferQueue in log
+    // messages. It is set by the IGraphicBufferConsumer::setConsumerName
+    // method.
+    String8 mConsumerName;
+
+    // mConsumerListener is used to notify the connected consumer of
+    // asynchronous events that it may wish to react to. It is initially
+    // set to NULL and is written by consumerConnect and consumerDisconnect.
+    sp<IConsumerListener> mConsumerListener;
+
+    // mConsumerUsageBits contains flags that the consumer wants for
+    // GraphicBuffers.
+    uint32_t mConsumerUsageBits;
+
+    // mConnectedApi indicates the producer API that is currently connected
+    // to this BufferQueue. It defaults to NO_CONNECTED_API, and gets updated
+    // by the connect and disconnect methods.
+    int mConnectedApi;
+
+    // mConnectedProducerToken is used to set a binder death notification on
+    // the producer.
+    sp<IProducerListener> mConnectedProducerListener;
+
+    // mSlots is an array of buffer slots that must be mirrored on the producer
+    // side. This allows buffer ownership to be transferred between the producer
+    // and consumer without sending a GraphicBuffer over Binder. The entire
+    // array is initialized to NULL at construction time, and buffers are
+    // allocated for a slot when requestBuffer is called with that slot's index.
+    BufferQueueDefs::SlotsType mSlots;
+
+    // mQueue is a FIFO of queued buffers used in synchronous mode.
+    Fifo mQueue;
+
+    // mFreeSlots contains all of the slots which are FREE and do not currently
+    // have a buffer attached
+    std::set<int> mFreeSlots;
+
+    // mFreeBuffers contains all of the slots which are FREE and currently have
+    // a buffer attached
+    std::list<int> mFreeBuffers;
+
+    // mOverrideMaxBufferCount is the limit on the number of buffers that will
+    // be allocated at one time. This value is set by the producer by calling
+    // setBufferCount. The default is 0, which means that the producer doesn't
+    // care about the number of buffers in the pool. In that case,
+    // mDefaultMaxBufferCount is used as the limit.
+    int mOverrideMaxBufferCount;
+
+    // mDequeueCondition is a condition variable used for dequeueBuffer in
+    // synchronous mode.
+    mutable Condition mDequeueCondition;
+
+    // mUseAsyncBuffer indicates whether an extra buffer is used in async mode
+    // to prevent dequeueBuffer from blocking.
+    bool mUseAsyncBuffer;
+
+    // mDequeueBufferCannotBlock indicates whether dequeueBuffer is allowed to
+    // block. This flag is set during connect when both the producer and
+    // consumer are controlled by the application.
+    bool mDequeueBufferCannotBlock;
+
+    // mDefaultBufferFormat can be set so it will override the buffer format
+    // when it isn't specified in dequeueBuffer.
+    PixelFormat mDefaultBufferFormat;
+
+    // mDefaultWidth holds the default width of allocated buffers. It is used
+    // in dequeueBuffer if a width and height of 0 are specified.
+    uint32_t mDefaultWidth;
+
+    // mDefaultHeight holds the default height of allocated buffers. It is used
+    // in dequeueBuffer if a width and height of 0 are specified.
+    uint32_t mDefaultHeight;
+
+    // mDefaultBufferDataSpace holds the default dataSpace of queued buffers.
+    // It is used in queueBuffer if a dataspace of 0 (HAL_DATASPACE_UNKNOWN)
+    // is specified.
+    android_dataspace mDefaultBufferDataSpace;
+
+    // mDefaultMaxBufferCount is the default limit on the number of buffers that
+    // will be allocated at one time. This default limit is set by the consumer.
+    // The limit (as opposed to the default limit) may be overriden by the
+    // producer.
+    int mDefaultMaxBufferCount;
+
+    // mMaxAcquiredBufferCount is the number of buffers that the consumer may
+    // acquire at one time. It defaults to 1, and can be changed by the consumer
+    // via setMaxAcquiredBufferCount, but this may only be done while no
+    // producer is connected to the BufferQueue. This value is used to derive
+    // the value returned for the MIN_UNDEQUEUED_BUFFERS query to the producer.
+    int mMaxAcquiredBufferCount;
+
+    // mBufferHasBeenQueued is true once a buffer has been queued. It is reset
+    // when something causes all buffers to be freed (e.g., changing the buffer
+    // count).
+    bool mBufferHasBeenQueued;
+
+    // mFrameCounter is the free running counter, incremented on every
+    // successful queueBuffer call and buffer allocation.
+    uint64_t mFrameCounter;
+
+    // mTransformHint is used to optimize for screen rotations.
+    uint32_t mTransformHint;
+
+    // mSidebandStream is a handle to the sideband buffer stream, if any
+    sp<NativeHandle> mSidebandStream;
+
+    // mIsAllocating indicates whether a producer is currently trying to allocate buffers (which
+    // releases mMutex while doing the allocation proper). Producers should not modify any of the
+    // FREE slots while this is true. mIsAllocatingCondition is signaled when this value changes to
+    // false.
+    bool mIsAllocating;
+
+    // mIsAllocatingCondition is a condition variable used by producers to wait until mIsAllocating
+    // becomes false.
+    mutable Condition mIsAllocatingCondition;
+
+    // mAllowAllocation determines whether dequeueBuffer is allowed to allocate
+    // new buffers
+    bool mAllowAllocation;
+
+    // mBufferAge tracks the age of the contents of the most recently dequeued
+    // buffer as the number of frames that have elapsed since it was last queued
+    uint64_t mBufferAge;
+
+    // mGenerationNumber stores the current generation number of the attached
+    // producer. Any attempt to attach a buffer with a different generation
+    // number will fail.
+    uint32_t mGenerationNumber;
+
+}; // class BufferQueueCore
+
+} // namespace android
+
+#endif
diff --git a/include/gui/BufferQueueDefs.h b/include/gui/BufferQueueDefs.h
new file mode 100644
index 0000000..83e9580
--- /dev/null
+++ b/include/gui/BufferQueueDefs.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_GUI_BUFFERQUEUECOREDEFS_H
+#define ANDROID_GUI_BUFFERQUEUECOREDEFS_H
+
+#include <gui/BufferSlot.h>
+
+namespace android {
+    class BufferQueueCore;
+
+    namespace BufferQueueDefs {
+        // BufferQueue will keep track of at most this value of buffers.
+        // Attempts at runtime to increase the number of buffers past this
+        // will fail.
+        enum { NUM_BUFFER_SLOTS = 64 };
+
+        typedef BufferSlot SlotsType[NUM_BUFFER_SLOTS];
+    } // namespace BufferQueueDefs
+} // namespace android
+
+#endif
diff --git a/include/gui/BufferQueueProducer.h b/include/gui/BufferQueueProducer.h
new file mode 100644
index 0000000..9754a89
--- /dev/null
+++ b/include/gui/BufferQueueProducer.h
@@ -0,0 +1,228 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_GUI_BUFFERQUEUEPRODUCER_H
+#define ANDROID_GUI_BUFFERQUEUEPRODUCER_H
+
+#include <gui/BufferQueueDefs.h>
+#include <gui/IGraphicBufferProducer.h>
+
+namespace android {
+
+class BufferSlot;
+
+class BufferQueueProducer : public BnGraphicBufferProducer,
+                            private IBinder::DeathRecipient {
+public:
+    friend class BufferQueue; // Needed to access binderDied
+
+    BufferQueueProducer(const sp<BufferQueueCore>& core);
+    virtual ~BufferQueueProducer();
+
+    // requestBuffer returns the GraphicBuffer for slot N.
+    //
+    // In normal operation, this is called the first time slot N is returned
+    // by dequeueBuffer.  It must be called again if dequeueBuffer returns
+    // flags indicating that previously-returned buffers are no longer valid.
+    virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf);
+
+    // setBufferCount updates the number of available buffer slots.  If this
+    // method succeeds, buffer slots will be both unallocated and owned by
+    // the BufferQueue object (i.e. they are not owned by the producer or
+    // consumer).
+    //
+    // This will fail if the producer has dequeued any buffers, or if
+    // bufferCount is invalid.  bufferCount must generally be a value
+    // between the minimum undequeued buffer count (exclusive) and NUM_BUFFER_SLOTS
+    // (inclusive).  It may also be set to zero (the default) to indicate
+    // that the producer does not wish to set a value.  The minimum value
+    // can be obtained by calling query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
+    // ...).
+    //
+    // This may only be called by the producer.  The consumer will be told
+    // to discard buffers through the onBuffersReleased callback.
+    virtual status_t setBufferCount(int bufferCount);
+
+    // dequeueBuffer gets the next buffer slot index for the producer to use.
+    // If a buffer slot is available then that slot index is written to the
+    // location pointed to by the buf argument and a status of OK is returned.
+    // If no slot is available then a status of -EBUSY is returned and buf is
+    // unmodified.
+    //
+    // The outFence parameter will be updated to hold the fence associated with
+    // the buffer. The contents of the buffer must not be overwritten until the
+    // fence signals. If the fence is Fence::NO_FENCE, the buffer may be
+    // written immediately.
+    //
+    // The width and height parameters must be no greater than the minimum of
+    // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv).
+    // An error due to invalid dimensions might not be reported until
+    // updateTexImage() is called.  If width and height are both zero, the
+    // default values specified by setDefaultBufferSize() are used instead.
+    //
+    // If the format is 0, the default format will be used.
+    //
+    // The usage argument specifies gralloc buffer usage flags.  The values
+    // are enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER.  These
+    // will be merged with the usage flags specified by setConsumerUsageBits.
+    //
+    // The return value may be a negative error value or a non-negative
+    // collection of flags.  If the flags are set, the return values are
+    // valid, but additional actions must be performed.
+    //
+    // If IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION is set, the
+    // producer must discard cached GraphicBuffer references for the slot
+    // returned in buf.
+    // If IGraphicBufferProducer::RELEASE_ALL_BUFFERS is set, the producer
+    // must discard cached GraphicBuffer references for all slots.
+    //
+    // In both cases, the producer will need to call requestBuffer to get a
+    // GraphicBuffer handle for the returned slot.
+    virtual status_t dequeueBuffer(int *outSlot, sp<Fence>* outFence,
+            bool async, uint32_t width, uint32_t height, PixelFormat format,
+            uint32_t usage);
+
+    // See IGraphicBufferProducer::detachBuffer
+    virtual status_t detachBuffer(int slot);
+
+    // See IGraphicBufferProducer::detachNextBuffer
+    virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
+            sp<Fence>* outFence);
+
+    // See IGraphicBufferProducer::attachBuffer
+    virtual status_t attachBuffer(int* outSlot, const sp<GraphicBuffer>& buffer);
+
+    // queueBuffer returns a filled buffer to the BufferQueue.
+    //
+    // Additional data is provided in the QueueBufferInput struct.  Notably,
+    // a timestamp must be provided for the buffer. The timestamp is in
+    // nanoseconds, and must be monotonically increasing. Its other semantics
+    // (zero point, etc) are producer-specific and should be documented by the
+    // producer.
+    //
+    // The caller may provide a fence that signals when all rendering
+    // operations have completed.  Alternatively, NO_FENCE may be used,
+    // indicating that the buffer is ready immediately.
+    //
+    // Some values are returned in the output struct: the current settings
+    // for default width and height, the current transform hint, and the
+    // number of queued buffers.
+    virtual status_t queueBuffer(int slot,
+            const QueueBufferInput& input, QueueBufferOutput* output);
+
+    // cancelBuffer returns a dequeued buffer to the BufferQueue, but doesn't
+    // queue it for use by the consumer.
+    //
+    // The buffer will not be overwritten until the fence signals.  The fence
+    // will usually be the one obtained from dequeueBuffer.
+    virtual void cancelBuffer(int slot, const sp<Fence>& fence);
+
+    // Query native window attributes.  The "what" values are enumerated in
+    // window.h (e.g. NATIVE_WINDOW_FORMAT).
+    virtual int query(int what, int* outValue);
+
+    // connect attempts to connect a producer API to the BufferQueue.  This
+    // must be called before any other IGraphicBufferProducer methods are
+    // called except for getAllocator.  A consumer must already be connected.
+    //
+    // This method will fail if connect was previously called on the
+    // BufferQueue and no corresponding disconnect call was made (i.e. if
+    // it's still connected to a producer).
+    //
+    // APIs are enumerated in window.h (e.g. NATIVE_WINDOW_API_CPU).
+    virtual status_t connect(const sp<IProducerListener>& listener,
+            int api, bool producerControlledByApp, QueueBufferOutput* output);
+
+    // disconnect attempts to disconnect a producer API from the BufferQueue.
+    // Calling this method will cause any subsequent calls to other
+    // IGraphicBufferProducer methods to fail except for getAllocator and connect.
+    // Successfully calling connect after this will allow the other methods to
+    // succeed again.
+    //
+    // This method will fail if the the BufferQueue is not currently
+    // connected to the specified producer API.
+    virtual status_t disconnect(int api);
+
+    // Attaches a sideband buffer stream to the IGraphicBufferProducer.
+    //
+    // A sideband stream is a device-specific mechanism for passing buffers
+    // from the producer to the consumer without using dequeueBuffer/
+    // queueBuffer. If a sideband stream is present, the consumer can choose
+    // whether to acquire buffers from the sideband stream or from the queued
+    // buffers.
+    //
+    // Passing NULL or a different stream handle will detach the previous
+    // handle if any.
+    virtual status_t setSidebandStream(const sp<NativeHandle>& stream);
+
+    // See IGraphicBufferProducer::allocateBuffers
+    virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
+            PixelFormat format, uint32_t usage);
+
+    // See IGraphicBufferProducer::allowAllocation
+    virtual status_t allowAllocation(bool allow);
+
+    // See IGraphicBufferProducer::setGenerationNumber
+    virtual status_t setGenerationNumber(uint32_t generationNumber);
+
+    // See IGraphicBufferProducer::getConsumerName
+    virtual String8 getConsumerName() const override;
+
+private:
+    // This is required by the IBinder::DeathRecipient interface
+    virtual void binderDied(const wp<IBinder>& who);
+
+    // waitForFreeSlotThenRelock finds the oldest slot in the FREE state. It may
+    // block if there are no available slots and we are not in non-blocking
+    // mode (producer and consumer controlled by the application). If it blocks,
+    // it will release mCore->mMutex while blocked so that other operations on
+    // the BufferQueue may succeed.
+    status_t waitForFreeSlotThenRelock(const char* caller, bool async,
+            int* found, status_t* returnFlags) const;
+
+    sp<BufferQueueCore> mCore;
+
+    // This references mCore->mSlots. Lock mCore->mMutex while accessing.
+    BufferQueueDefs::SlotsType& mSlots;
+
+    // This is a cached copy of the name stored in the BufferQueueCore.
+    // It's updated during connect and dequeueBuffer (which should catch
+    // most updates).
+    String8 mConsumerName;
+
+    uint32_t mStickyTransform;
+
+    // This saves the fence from the last queueBuffer, such that the
+    // next queueBuffer call can throttle buffer production. The prior
+    // queueBuffer's fence is not nessessarily available elsewhere,
+    // since the previous buffer might have already been acquired.
+    sp<Fence> mLastQueueBufferFence;
+
+    // Take-a-ticket system for ensuring that onFrame* callbacks are called in
+    // the order that frames are queued. While the BufferQueue lock
+    // (mCore->mMutex) is held, a ticket is retained by the producer. After
+    // dropping the BufferQueue lock, the producer must wait on the condition
+    // variable until the current callback ticket matches its retained ticket.
+    Mutex mCallbackMutex;
+    int mNextCallbackTicket; // Protected by mCore->mMutex
+    int mCurrentCallbackTicket; // Protected by mCallbackMutex
+    Condition mCallbackCondition;
+
+}; // class BufferQueueProducer
+
+} // namespace android
+
+#endif
diff --git a/include/gui/BufferSlot.h b/include/gui/BufferSlot.h
new file mode 100644
index 0000000..6085e11
--- /dev/null
+++ b/include/gui/BufferSlot.h
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_GUI_BUFFERSLOT_H
+#define ANDROID_GUI_BUFFERSLOT_H
+
+#include <ui/Fence.h>
+#include <ui/GraphicBuffer.h>
+
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+#include <utils/StrongPointer.h>
+
+namespace android {
+
+class Fence;
+
+struct BufferSlot {
+
+    BufferSlot()
+    : mEglDisplay(EGL_NO_DISPLAY),
+      mBufferState(BufferSlot::FREE),
+      mRequestBufferCalled(false),
+      mFrameNumber(0),
+      mEglFence(EGL_NO_SYNC_KHR),
+      mAcquireCalled(false),
+      mNeedsCleanupOnRelease(false),
+      mAttachedByConsumer(false) {
+    }
+
+    // mGraphicBuffer points to the buffer allocated for this slot or is NULL
+    // if no buffer has been allocated.
+    sp<GraphicBuffer> mGraphicBuffer;
+
+    // mEglDisplay is the EGLDisplay used to create EGLSyncKHR objects.
+    EGLDisplay mEglDisplay;
+
+    // BufferState represents the different states in which a buffer slot
+    // can be.  All slots are initially FREE.
+    enum BufferState {
+        // FREE indicates that the buffer is available to be dequeued
+        // by the producer.  The buffer may be in use by the consumer for
+        // a finite time, so the buffer must not be modified until the
+        // associated fence is signaled.
+        //
+        // The slot is "owned" by BufferQueue.  It transitions to DEQUEUED
+        // when dequeueBuffer is called.
+        FREE = 0,
+
+        // DEQUEUED indicates that the buffer has been dequeued by the
+        // producer, but has not yet been queued or canceled.  The
+        // producer may modify the buffer's contents as soon as the
+        // associated ready fence is signaled.
+        //
+        // The slot is "owned" by the producer.  It can transition to
+        // QUEUED (via queueBuffer) or back to FREE (via cancelBuffer).
+        DEQUEUED = 1,
+
+        // QUEUED indicates that the buffer has been filled by the
+        // producer and queued for use by the consumer.  The buffer
+        // contents may continue to be modified for a finite time, so
+        // the contents must not be accessed until the associated fence
+        // is signaled.
+        //
+        // The slot is "owned" by BufferQueue.  It can transition to
+        // ACQUIRED (via acquireBuffer) or to FREE (if another buffer is
+        // queued in asynchronous mode).
+        QUEUED = 2,
+
+        // ACQUIRED indicates that the buffer has been acquired by the
+        // consumer.  As with QUEUED, the contents must not be accessed
+        // by the consumer until the fence is signaled.
+        //
+        // The slot is "owned" by the consumer.  It transitions to FREE
+        // when releaseBuffer is called.
+        ACQUIRED = 3
+    };
+
+    static const char* bufferStateName(BufferState state);
+
+    // mBufferState is the current state of this buffer slot.
+    BufferState mBufferState;
+
+    // mRequestBufferCalled is used for validating that the producer did
+    // call requestBuffer() when told to do so. Technically this is not
+    // needed but useful for debugging and catching producer bugs.
+    bool mRequestBufferCalled;
+
+    // mFrameNumber is the number of the queued frame for this slot.  This
+    // is used to dequeue buffers in LRU order (useful because buffers
+    // may be released before their release fence is signaled).
+    uint64_t mFrameNumber;
+
+    // mEglFence is the EGL sync object that must signal before the buffer
+    // associated with this buffer slot may be dequeued. It is initialized
+    // to EGL_NO_SYNC_KHR when the buffer is created and may be set to a
+    // new sync object in releaseBuffer.  (This is deprecated in favor of
+    // mFence, below.)
+    EGLSyncKHR mEglFence;
+
+    // mFence is a fence which will signal when work initiated by the
+    // previous owner of the buffer is finished. When the buffer is FREE,
+    // the fence indicates when the consumer has finished reading
+    // from the buffer, or when the producer has finished writing if it
+    // called cancelBuffer after queueing some writes. When the buffer is
+    // QUEUED, it indicates when the producer has finished filling the
+    // buffer. When the buffer is DEQUEUED or ACQUIRED, the fence has been
+    // passed to the consumer or producer along with ownership of the
+    // buffer, and mFence is set to NO_FENCE.
+    sp<Fence> mFence;
+
+    // Indicates whether this buffer has been seen by a consumer yet
+    bool mAcquireCalled;
+
+    // Indicates whether this buffer needs to be cleaned up by the
+    // consumer.  This is set when a buffer in ACQUIRED state is freed.
+    // It causes releaseBuffer to return STALE_BUFFER_SLOT.
+    bool mNeedsCleanupOnRelease;
+
+    // Indicates whether the buffer was attached on the consumer side.
+    // If so, it needs to set the BUFFER_NEEDS_REALLOCATION flag when dequeued
+    // to prevent the producer from using a stale cached buffer.
+    bool mAttachedByConsumer;
+};
+
+} // namespace android
+
+#endif
diff --git a/include/gui/ConsumerBase.h b/include/gui/ConsumerBase.h
index fb21185..9307a26 100644
--- a/include/gui/ConsumerBase.h
+++ b/include/gui/ConsumerBase.h
@@ -38,15 +38,9 @@
         protected ConsumerListener {
 public:
     struct FrameAvailableListener : public virtual RefBase {
-        // onFrameAvailable() is called each time an additional frame becomes
-        // available for consumption. This means that frames that are queued
-        // while in asynchronous mode only trigger the callback if no previous
-        // frames are pending. Frames queued while in synchronous mode always
-        // trigger the callback.
-        //
-        // This is called without any lock held and can be called concurrently
-        // by multiple threads.
-        virtual void onFrameAvailable() = 0;
+        // See IConsumerListener::onFrame{Available,Replaced}
+        virtual void onFrameAvailable(const BufferItem& item) = 0;
+        virtual void onFrameReplaced(const BufferItem& /* item */) {}
     };
 
     virtual ~ConsumerBase();
@@ -62,6 +56,9 @@
     // or by OpenGL ES as a texture) then those buffer will remain allocated.
     void abandon();
 
+    // Returns true if the ConsumerBase is in the 'abandoned' state
+    bool isAbandoned();
+
     // set the name of the ConsumerBase that will be used to identify it in
     // log messages.
     void setName(const String8& name);
@@ -76,6 +73,18 @@
     // when a new frame becomes available.
     void setFrameAvailableListener(const wp<FrameAvailableListener>& listener);
 
+    // See IGraphicBufferConsumer::detachBuffer
+    status_t detachBuffer(int slot);
+
+    // See IGraphicBufferConsumer::setDefaultBufferSize
+    status_t setDefaultBufferSize(uint32_t width, uint32_t height);
+
+    // See IGraphicBufferConsumer::setDefaultBufferFormat
+    status_t setDefaultBufferFormat(PixelFormat defaultFormat);
+
+    // See IGraphicBufferConsumer::setDefaultBufferDataSpace
+    status_t setDefaultBufferDataSpace(android_dataspace defaultDataSpace);
+
 private:
     ConsumerBase(const ConsumerBase&);
     void operator=(const ConsumerBase&);
@@ -101,11 +110,16 @@
 
     // Implementation of the IConsumerListener interface.  These
     // calls are used to notify the ConsumerBase of asynchronous events in the
-    // BufferQueue.  These methods should not need to be overridden by derived
-    // classes, but if they are overridden the ConsumerBase implementation
-    // must be called from the derived class.
-    virtual void onFrameAvailable();
-    virtual void onBuffersReleased();
+    // BufferQueue.  The onFrameAvailable, onFrameReplaced, and
+    // onBuffersReleased methods should not need to be overridden by derived
+    // classes, but if they are overridden the ConsumerBase implementation must
+    // be called from the derived class. The ConsumerBase version of
+    // onSidebandStreamChanged does nothing and can be overriden by derived
+    // classes if they want the notification.
+    virtual void onFrameAvailable(const BufferItem& item) override;
+    virtual void onFrameReplaced(const BufferItem& item) override;
+    virtual void onBuffersReleased() override;
+    virtual void onSidebandStreamChanged() override;
 
     // freeBufferLocked frees up the given buffer slot.  If the slot has been
     // initialized this will release the reference to the GraphicBuffer in that
@@ -150,8 +164,8 @@
     // initialization that must take place the first time a buffer is assigned
     // to a slot.  If it is overridden the derived class's implementation must
     // call ConsumerBase::acquireBufferLocked.
-    virtual status_t acquireBufferLocked(IGraphicBufferConsumer::BufferItem *item,
-        nsecs_t presentWhen);
+    virtual status_t acquireBufferLocked(BufferItem *item, nsecs_t presentWhen,
+            uint64_t maxFrameNumber = 0);
 
     // releaseBufferLocked relinquishes control over a buffer, returning that
     // control to the BufferQueue.
diff --git a/include/gui/CpuConsumer.h b/include/gui/CpuConsumer.h
index 6f4c2ec..3b07a31 100644
--- a/include/gui/CpuConsumer.h
+++ b/include/gui/CpuConsumer.h
@@ -53,9 +53,14 @@
         uint32_t    transform;
         uint32_t    scalingMode;
         int64_t     timestamp;
+        android_dataspace dataSpace;
         uint64_t    frameNumber;
-        // Values below are only valid when using
-        // HAL_PIXEL_FORMAT_YCbCr_420_888, in which case LockedBuffer::data
+        // this is the same as format, except for formats that are compatible with
+        // a flexible format (e.g. HAL_PIXEL_FORMAT_YCbCr_420_888). In the latter
+        // case this contains that flexible format
+        PixelFormat flexFormat;
+        // Values below are only valid when using HAL_PIXEL_FORMAT_YCbCr_420_888
+        // or compatible format, in which case LockedBuffer::data
         // contains the Y channel, and stride is the Y channel stride. For other
         // formats, these will all be 0.
         uint8_t    *dataCb;
@@ -67,7 +72,7 @@
     // Create a new CPU consumer. The maxLockedBuffers parameter specifies
     // how many buffers can be locked for user access at the same time.
     CpuConsumer(const sp<IGraphicBufferConsumer>& bq,
-            uint32_t maxLockedBuffers, bool controlledByApp = false);
+            size_t maxLockedBuffers, bool controlledByApp = false);
 
     virtual ~CpuConsumer();
 
@@ -75,18 +80,6 @@
     // log messages.
     void setName(const String8& name);
 
-    // setDefaultBufferSize is used to set the size of buffers returned by
-    // requestBuffers when a width and height of zero is requested.
-    // A call to setDefaultBufferSize() may trigger requestBuffers() to
-    // be called from the client. Default size is 1x1.
-    status_t setDefaultBufferSize(uint32_t width, uint32_t height);
-
-    // setDefaultBufferFormat allows CpuConsumer's BufferQueue to create buffers
-    // of a defaultFormat if no format is specified by producer. Formats are
-    // enumerated in graphics.h; the initial default is
-    // HAL_PIXEL_FORMAT_RGBA_8888.
-    status_t setDefaultBufferFormat(uint32_t defaultFormat);
-
     // Gets the next graphics buffer from the producer and locks it for CPU use,
     // filling out the passed-in locked buffer structure with the native pointer
     // and metadata. Returns BAD_VALUE if no new buffer is available, and
@@ -106,9 +99,9 @@
 
   private:
     // Maximum number of buffers that can be locked at a time
-    uint32_t mMaxLockedBuffers;
+    size_t mMaxLockedBuffers;
 
-    status_t releaseAcquiredBufferLocked(int lockedIdx);
+    status_t releaseAcquiredBufferLocked(size_t lockedIdx);
 
     virtual void freeBufferLocked(int slotIndex);
 
@@ -129,7 +122,7 @@
     Vector<AcquiredBuffer> mAcquiredBuffers;
 
     // Count of currently locked buffers
-    uint32_t mCurrentLockedBuffers;
+    size_t mCurrentLockedBuffers;
 
 };
 
diff --git a/include/gui/GLConsumer.h b/include/gui/GLConsumer.h
index a5fdfb9..c35c7be 100644
--- a/include/gui/GLConsumer.h
+++ b/include/gui/GLConsumer.h
@@ -52,28 +52,17 @@
  * This class was previously called SurfaceTexture.
  */
 class GLConsumer : public ConsumerBase {
-protected:
-    enum { TEXTURE_EXTERNAL = 0x8D65 }; // GL_TEXTURE_EXTERNAL_OES
 public:
+    enum { TEXTURE_EXTERNAL = 0x8D65 }; // GL_TEXTURE_EXTERNAL_OES
     typedef ConsumerBase::FrameAvailableListener FrameAvailableListener;
 
-    // GLConsumer constructs a new GLConsumer object. tex indicates the
-    // name of the OpenGL ES texture to which images are to be streamed.
-    // allowSynchronousMode specifies whether or not synchronous mode can be
-    // enabled. texTarget specifies the OpenGL ES texture target to which the
-    // texture will be bound in updateTexImage. useFenceSync specifies whether
-    // fences should be used to synchronize access to buffers if that behavior
-    // is enabled at compile-time. A custom bufferQueue can be specified
-    // if behavior for queue/dequeue/connect etc needs to be customized.
-    // Otherwise a default BufferQueue will be created and used.
-    //
-    // For legacy reasons, the GLConsumer is created in a state where it is
-    // considered attached to an OpenGL ES context for the purposes of the
-    // attachToContext and detachFromContext methods. However, despite being
-    // considered "attached" to a context, the specific OpenGL ES context
-    // doesn't get latched until the first call to updateTexImage. After that
-    // point, all calls to updateTexImage must be made with the same OpenGL ES
-    // context current.
+    // GLConsumer constructs a new GLConsumer object. If the constructor with
+    // the tex parameter is used, tex indicates the name of the OpenGL ES
+    // texture to which images are to be streamed. texTarget specifies the
+    // OpenGL ES texture target to which the texture will be bound in
+    // updateTexImage. useFenceSync specifies whether fences should be used to
+    // synchronize access to buffers if that behavior is enabled at
+    // compile-time.
     //
     // A GLConsumer may be detached from one OpenGL ES context and then
     // attached to a different context using the detachFromContext and
@@ -81,9 +70,24 @@
     // purely to allow a GLConsumer to be transferred from one consumer
     // context to another. If such a transfer is not needed there is no
     // requirement that either of these methods be called.
+    //
+    // If the constructor with the tex parameter is used, the GLConsumer is
+    // created in a state where it is considered attached to an OpenGL ES
+    // context for the purposes of the attachToContext and detachFromContext
+    // methods. However, despite being considered "attached" to a context, the
+    // specific OpenGL ES context doesn't get latched until the first call to
+    // updateTexImage. After that point, all calls to updateTexImage must be
+    // made with the same OpenGL ES context current.
+    //
+    // If the constructor without the tex parameter is used, the GLConsumer is
+    // created in a detached state, and attachToContext must be called before
+    // calls to updateTexImage.
     GLConsumer(const sp<IGraphicBufferConsumer>& bq,
-            uint32_t tex, uint32_t texureTarget = TEXTURE_EXTERNAL,
-            bool useFenceSync = true, bool isControlledByApp = false);
+            uint32_t tex, uint32_t texureTarget, bool useFenceSync,
+            bool isControlledByApp);
+
+    GLConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t texureTarget,
+            bool useFenceSync, bool isControlledByApp);
 
     // updateTexImage acquires the most recently queued buffer, and sets the
     // image contents of the target texture to it.
@@ -146,7 +150,7 @@
     //
     // The frame number is an incrementing counter set to 0 at the creation of
     // the BufferQueue associated with this consumer.
-    int64_t getFrameNumber();
+    uint64_t getFrameNumber();
 
     // setDefaultBufferSize is used to set the size of buffers returned by
     // requestBuffers when a with and height of zero is requested.
@@ -193,7 +197,8 @@
 
     // These functions call the corresponding BufferQueue implementation
     // so the refactoring can proceed smoothly
-    status_t setDefaultBufferFormat(uint32_t defaultFormat);
+    status_t setDefaultBufferFormat(PixelFormat defaultFormat);
+    status_t setDefaultBufferDataSpace(android_dataspace defaultDataSpace);
     status_t setConsumerUsageBits(uint32_t usage);
     status_t setTransformHint(uint32_t hint);
 
@@ -227,7 +232,7 @@
 protected:
 
     // abandonLocked overrides the ConsumerBase method to clear
-    // mCurrentTextureBuf in addition to the ConsumerBase behavior.
+    // mCurrentTextureImage in addition to the ConsumerBase behavior.
     virtual void abandonLocked();
 
     // dumpLocked overrides the ConsumerBase method to dump GLConsumer-
@@ -236,8 +241,8 @@
 
     // acquireBufferLocked overrides the ConsumerBase method to update the
     // mEglSlots array in addition to the ConsumerBase behavior.
-    virtual status_t acquireBufferLocked(BufferQueue::BufferItem *item,
-        nsecs_t presentWhen);
+    virtual status_t acquireBufferLocked(BufferItem *item, nsecs_t presentWhen,
+            uint64_t maxFrameNumber = 0) override;
 
     // releaseBufferLocked overrides the ConsumerBase method to update the
     // mEglSlots array in addition to the ConsumerBase.
@@ -250,15 +255,15 @@
         return releaseBufferLocked(slot, graphicBuffer, mEglDisplay, eglFence);
     }
 
-    static bool isExternalFormat(uint32_t format);
+    static bool isExternalFormat(PixelFormat format);
 
     // This releases the buffer in the slot referenced by mCurrentTexture,
     // then updates state to refer to the BufferItem, which must be a
     // newly-acquired buffer.
-    status_t updateAndReleaseLocked(const BufferQueue::BufferItem& item);
+    status_t updateAndReleaseLocked(const BufferItem& item);
 
     // Binds mTexName and the current buffer to mTexTarget.  Uses
-    // mCurrentTexture if it's set, mCurrentTextureBuf if not.  If the
+    // mCurrentTexture if it's set, mCurrentTextureImage if not.  If the
     // bind succeeds, this calls doGLFenceWait.
     status_t bindTextureImageLocked();
 
@@ -271,11 +276,59 @@
     status_t checkAndUpdateEglStateLocked(bool contextCheck = false);
 
 private:
-    // createImage creates a new EGLImage from a GraphicBuffer.
-    EGLImageKHR createImage(EGLDisplay dpy,
-            const sp<GraphicBuffer>& graphicBuffer, const Rect& crop);
+    // EglImage is a utility class for tracking and creating EGLImageKHRs. There
+    // is primarily just one image per slot, but there is also special cases:
+    //  - For releaseTexImage, we use a debug image (mReleasedTexImage)
+    //  - After freeBuffer, we must still keep the current image/buffer
+    // Reference counting EGLImages lets us handle all these cases easily while
+    // also only creating new EGLImages from buffers when required.
+    class EglImage : public LightRefBase<EglImage>  {
+    public:
+        EglImage(sp<GraphicBuffer> graphicBuffer);
 
-    // freeBufferLocked frees up the given buffer slot.  If the slot has been
+        // createIfNeeded creates an EGLImage if required (we haven't created
+        // one yet, or the EGLDisplay or crop-rect has changed).
+        status_t createIfNeeded(EGLDisplay display,
+                                const Rect& cropRect,
+                                bool forceCreate = false);
+
+        // This calls glEGLImageTargetTexture2DOES to bind the image to the
+        // texture in the specified texture target.
+        void bindToTextureTarget(uint32_t texTarget);
+
+        const sp<GraphicBuffer>& graphicBuffer() { return mGraphicBuffer; }
+        const native_handle* graphicBufferHandle() {
+            return mGraphicBuffer == NULL ? NULL : mGraphicBuffer->handle;
+        }
+
+    private:
+        // Only allow instantiation using ref counting.
+        friend class LightRefBase<EglImage>;
+        virtual ~EglImage();
+
+        // createImage creates a new EGLImage from a GraphicBuffer.
+        EGLImageKHR createImage(EGLDisplay dpy,
+                const sp<GraphicBuffer>& graphicBuffer, const Rect& crop);
+
+        // Disallow copying
+        EglImage(const EglImage& rhs);
+        void operator = (const EglImage& rhs);
+
+        // mGraphicBuffer is the buffer that was used to create this image.
+        sp<GraphicBuffer> mGraphicBuffer;
+
+        // mEglImage is the EGLImage created from mGraphicBuffer.
+        EGLImageKHR mEglImage;
+
+        // mEGLDisplay is the EGLDisplay that was used to create mEglImage.
+        EGLDisplay mEglDisplay;
+
+        // mCropRect is the crop rectangle passed to EGL when mEglImage
+        // was created.
+        Rect mCropRect;
+    };
+
+    // freeBufferLocked frees up the given buffer slot. If the slot has been
     // initialized this will release the reference to the GraphicBuffer in that
     // slot and destroy the EGLImage in that slot.  Otherwise it has no effect.
     //
@@ -285,7 +338,7 @@
     // computeCurrentTransformMatrixLocked computes the transform matrix for the
     // current texture.  It uses mCurrentTransform and the current GraphicBuffer
     // to compute this matrix and stores it in mCurrentTransformMatrix.
-    // mCurrentTextureBuf must not be NULL.
+    // mCurrentTextureImage must not be NULL.
     void computeCurrentTransformMatrixLocked();
 
     // doGLFenceWaitLocked inserts a wait command into the OpenGL ES command
@@ -299,13 +352,6 @@
     // before the outstanding accesses have completed.
     status_t syncForReleaseLocked(EGLDisplay dpy);
 
-    // Normally, when we bind a buffer to a texture target, we bind a buffer
-    // that is referenced by an entry in mEglSlots.  In some situations we
-    // have a buffer in mCurrentTextureBuf, but no corresponding entry for
-    // it in our slot array.  bindUnslottedBuffer handles that situation by
-    // binding the buffer without touching the EglSlots.
-    status_t bindUnslottedBufferLocked(EGLDisplay dpy);
-
     // returns a graphic buffer used when the texture image has been released
     static sp<GraphicBuffer> getDebugTexImageBuffer();
 
@@ -315,10 +361,10 @@
     // consume buffers as hardware textures.
     static const uint32_t DEFAULT_USAGE_FLAGS = GraphicBuffer::USAGE_HW_TEXTURE;
 
-    // mCurrentTextureBuf is the graphic buffer of the current texture. It's
+    // mCurrentTextureImage is the EglImage/buffer of the current texture. It's
     // possible that this buffer is not associated with any buffer slot, so we
     // must track it separately in order to support the getCurrentBuffer method.
-    sp<GraphicBuffer> mCurrentTextureBuf;
+    sp<EglImage> mCurrentTextureImage;
 
     // mCurrentCrop is the crop rectangle that applies to the current texture.
     // It gets set each time updateTexImage is called.
@@ -346,7 +392,7 @@
 
     // mCurrentFrameNumber is the frame counter for the current texture.
     // It gets set each time updateTexImage is called.
-    int64_t mCurrentFrameNumber;
+    uint64_t mCurrentFrameNumber;
 
     uint32_t mDefaultWidth, mDefaultHeight;
 
@@ -378,17 +424,10 @@
     // EGLSlot contains the information and object references that
     // GLConsumer maintains about a BufferQueue buffer slot.
     struct EglSlot {
-        EglSlot()
-        : mEglImage(EGL_NO_IMAGE_KHR),
-          mEglFence(EGL_NO_SYNC_KHR) {
-        }
+        EglSlot() : mEglFence(EGL_NO_SYNC_KHR) {}
 
         // mEglImage is the EGLImage created from mGraphicBuffer.
-        EGLImageKHR mEglImage;
-
-        // mCropRect is the crop rectangle passed to EGL when mEglImage was
-        // created.
-        Rect mCropRect;
+        sp<EglImage> mEglImage;
 
         // mFence is the EGL sync object that must signal before the buffer
         // associated with this buffer slot may be dequeued. It is initialized
@@ -440,6 +479,7 @@
     // mReleasedTexImageBuffer is a dummy buffer used when in single buffer
     // mode and releaseTexImage() has been called
     static sp<GraphicBuffer> sReleasedTexImageBuffer;
+    sp<EglImage> mReleasedTexImage;
 };
 
 // ----------------------------------------------------------------------------
diff --git a/include/gui/GraphicBufferAlloc.h b/include/gui/GraphicBufferAlloc.h
index b08750c..69fe51e 100644
--- a/include/gui/GraphicBufferAlloc.h
+++ b/include/gui/GraphicBufferAlloc.h
@@ -33,8 +33,9 @@
 public:
     GraphicBufferAlloc();
     virtual ~GraphicBufferAlloc();
-    virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
-        PixelFormat format, uint32_t usage, status_t* error);
+    virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width,
+            uint32_t height, PixelFormat format, uint32_t usage,
+            status_t* error);
 };
 
 
diff --git a/include/gui/IConsumerListener.h b/include/gui/IConsumerListener.h
index ac2f9bb..3f39799 100644
--- a/include/gui/IConsumerListener.h
+++ b/include/gui/IConsumerListener.h
@@ -28,6 +28,8 @@
 namespace android {
 // ----------------------------------------------------------------------------
 
+class BufferItem;
+
 // ConsumerListener is the interface through which the BufferQueue notifies
 // the consumer of events that the consumer may wish to react to.  Because
 // the consumer will generally have a mutex that is locked during calls from
@@ -43,11 +45,24 @@
     // frame becomes available for consumption. This means that frames that
     // are queued while in asynchronous mode only trigger the callback if no
     // previous frames are pending. Frames queued while in synchronous mode
-    // always trigger the callback.
+    // always trigger the callback. The item passed to the callback will contain
+    // all of the information about the queued frame except for its
+    // GraphicBuffer pointer, which will always be null.
     //
     // This is called without any lock held and can be called concurrently
     // by multiple threads.
-    virtual void onFrameAvailable() = 0; /* Asynchronous */
+    virtual void onFrameAvailable(const BufferItem& item) = 0; /* Asynchronous */
+
+    // onFrameReplaced is called from queueBuffer if the frame being queued is
+    // replacing an existing slot in the queue. Any call to queueBuffer that
+    // doesn't call onFrameAvailable will call this callback instead. The item
+    // passed to the callback will contain all of the information about the
+    // queued frame except for its GraphicBuffer pointer, which will always be
+    // null.
+    //
+    // This is called without any lock held and can be called concurrently
+    // by multiple threads.
+    virtual void onFrameReplaced(const BufferItem& /* item */) {} /* Asynchronous */
 
     // onBuffersReleased is called to notify the buffer consumer that the
     // BufferQueue has released its references to one or more GraphicBuffers
@@ -57,6 +72,12 @@
     // This is called without any lock held and can be called concurrently
     // by multiple threads.
     virtual void onBuffersReleased() = 0; /* Asynchronous */
+
+    // onSidebandStreamChanged is called to notify the buffer consumer that the
+    // BufferQueue's sideband buffer stream has changed. This is called when a
+    // stream is first attached and when it is either detached or replaced by a
+    // different stream.
+    virtual void onSidebandStreamChanged() = 0; /* Asynchronous */
 };
 
 
diff --git a/include/gui/IGraphicBufferAlloc.h b/include/gui/IGraphicBufferAlloc.h
index cee41d9..f3c46ec 100644
--- a/include/gui/IGraphicBufferAlloc.h
+++ b/include/gui/IGraphicBufferAlloc.h
@@ -45,10 +45,10 @@
 class BnGraphicBufferAlloc : public BnInterface<IGraphicBufferAlloc>
 {
 public:
-    virtual status_t    onTransact( uint32_t code,
-                                    const Parcel& data,
-                                    Parcel* reply,
-                                    uint32_t flags = 0);
+    virtual status_t onTransact(uint32_t code,
+                                const Parcel& data,
+                                Parcel* reply,
+                                uint32_t flags = 0);
 };
 
 // ----------------------------------------------------------------------------
diff --git a/include/gui/IGraphicBufferConsumer.h b/include/gui/IGraphicBufferConsumer.h
index 0e35f13..60ec9cc 100644
--- a/include/gui/IGraphicBufferConsumer.h
+++ b/include/gui/IGraphicBufferConsumer.h
@@ -25,93 +25,98 @@
 #include <utils/Timers.h>
 
 #include <binder/IInterface.h>
+#include <ui/PixelFormat.h>
 #include <ui/Rect.h>
 
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
 namespace android {
 // ----------------------------------------------------------------------------
 
-class IConsumerListener;
-class GraphicBuffer;
+class BufferItem;
 class Fence;
+class GraphicBuffer;
+class IConsumerListener;
+class NativeHandle;
 
 class IGraphicBufferConsumer : public IInterface {
 
 public:
-
-    // public facing structure for BufferSlot
-    class BufferItem : public Flattenable<BufferItem> {
-        friend class Flattenable<BufferItem>;
-        size_t getPodSize() const;
-        size_t getFlattenedSize() const;
-        size_t getFdCount() const;
-        status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const;
-        status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count);
-
-    public:
-        enum { INVALID_BUFFER_SLOT = -1 };
-        BufferItem();
-
-        // mGraphicBuffer points to the buffer allocated for this slot, or is NULL
-        // if the buffer in this slot has been acquired in the past (see
-        // BufferSlot.mAcquireCalled).
-        sp<GraphicBuffer> mGraphicBuffer;
-
-        // mFence is a fence that will signal when the buffer is idle.
-        sp<Fence> mFence;
-
-        // mCrop is the current crop rectangle for this buffer slot.
-        Rect mCrop;
-
-        // mTransform is the current transform flags for this buffer slot.
-        uint32_t mTransform;
-
-        // mScalingMode is the current scaling mode for this buffer slot.
-        uint32_t mScalingMode;
-
-        // mTimestamp is the current timestamp for this buffer slot. This gets
-        // to set by queueBuffer each time this slot is queued.
-        int64_t mTimestamp;
-
-        // mIsAutoTimestamp indicates whether mTimestamp was generated
-        // automatically when the buffer was queued.
-        bool mIsAutoTimestamp;
-
-        // mFrameNumber is the number of the queued frame for this slot.
-        uint64_t mFrameNumber;
-
-        // mBuf is the slot index of this buffer
-        int mBuf;
-
-        // mIsDroppable whether this buffer was queued with the
-        // property that it can be replaced by a new buffer for the purpose of
-        // making sure dequeueBuffer() won't block.
-        // i.e.: was the BufferQueue in "mDequeueBufferCannotBlock" when this buffer
-        // was queued.
-        bool mIsDroppable;
-
-        // Indicates whether this buffer has been seen by a consumer yet
-        bool mAcquireCalled;
-
-        // Indicates this buffer must be transformed by the inverse transform of the screen
-        // it is displayed onto. This is applied after mTransform.
-        bool mTransformToDisplayInverse;
+    enum {
+        // Returned by releaseBuffer, after which the consumer must
+        // free any references to the just-released buffer that it might have.
+        STALE_BUFFER_SLOT = 1,
+        // Returned by dequeueBuffer if there are no pending buffers available.
+        NO_BUFFER_AVAILABLE,
+        // Returned by dequeueBuffer if it's too early for the buffer to be acquired.
+        PRESENT_LATER,
     };
 
-
     // acquireBuffer attempts to acquire ownership of the next pending buffer in
-    // the BufferQueue.  If no buffer is pending then it returns -EINVAL.  If a
-    // buffer is successfully acquired, the information about the buffer is
-    // returned in BufferItem.  If the buffer returned had previously been
+    // the BufferQueue.  If no buffer is pending then it returns
+    // NO_BUFFER_AVAILABLE.  If a buffer is successfully acquired, the
+    // information about the buffer is returned in BufferItem.
+    //
+    // If the buffer returned had previously been
     // acquired then the BufferItem::mGraphicBuffer field of buffer is set to
     // NULL and it is assumed that the consumer still holds a reference to the
     // buffer.
     //
-    // If presentWhen is nonzero, it indicates the time when the buffer will
+    // If presentWhen is non-zero, it indicates the time when the buffer will
     // be displayed on screen.  If the buffer's timestamp is farther in the
     // future, the buffer won't be acquired, and PRESENT_LATER will be
     // returned.  The presentation time is in nanoseconds, and the time base
     // is CLOCK_MONOTONIC.
-    virtual status_t acquireBuffer(BufferItem *buffer, nsecs_t presentWhen) = 0;
+    //
+    // If maxFrameNumber is non-zero, it indicates that acquireBuffer should
+    // only return a buffer with a frame number less than or equal to
+    // maxFrameNumber. If no such frame is available (such as when a buffer has
+    // been replaced but the consumer has not received the onFrameReplaced
+    // callback), then PRESENT_LATER will be returned.
+    //
+    // Return of NO_ERROR means the operation completed as normal.
+    //
+    // Return of a positive value means the operation could not be completed
+    //    at this time, but the user should try again later:
+    // * NO_BUFFER_AVAILABLE - no buffer is pending (nothing queued by producer)
+    // * PRESENT_LATER - the buffer's timestamp is farther in the future
+    //
+    // Return of a negative value means an error has occurred:
+    // * INVALID_OPERATION - too many buffers have been acquired
+    virtual status_t acquireBuffer(BufferItem* buffer, nsecs_t presentWhen,
+            uint64_t maxFrameNumber = 0) = 0;
+
+    // detachBuffer attempts to remove all ownership of the buffer in the given
+    // slot from the buffer queue. If this call succeeds, the slot will be
+    // freed, and there will be no way to obtain the buffer from this interface.
+    // The freed slot will remain unallocated until either it is selected to
+    // hold a freshly allocated buffer in dequeueBuffer or a buffer is attached
+    // to the slot. The buffer must have already been acquired.
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * BAD_VALUE - the given slot number is invalid, either because it is
+    //               out of the range [0, NUM_BUFFER_SLOTS) or because the slot
+    //               it refers to is not currently acquired.
+    virtual status_t detachBuffer(int slot) = 0;
+
+    // attachBuffer attempts to transfer ownership of a buffer to the buffer
+    // queue. If this call succeeds, it will be as if this buffer was acquired
+    // from the returned slot number. As such, this call will fail if attaching
+    // this buffer would cause too many buffers to be simultaneously acquired.
+    //
+    // If the buffer is successfully attached, its frameNumber is initialized
+    // to 0. This must be passed into the releaseBuffer call or else the buffer
+    // will be deallocated as stale.
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * BAD_VALUE - outSlot or buffer were NULL, or the generation number of
+    //               the buffer did not match the buffer queue.
+    // * INVALID_OPERATION - cannot attach the buffer because it would cause too
+    //                       many buffers to be acquired.
+    // * NO_MEMORY - no free slots available
+    virtual status_t attachBuffer(int *outSlot,
+            const sp<GraphicBuffer>& buffer) = 0;
 
     // releaseBuffer releases a buffer slot from the consumer back to the
     // BufferQueue.  This may be done while the buffer's contents are still
@@ -125,6 +130,18 @@
     //
     // Note that the dependencies on EGL will be removed once we switch to using
     // the Android HW Sync HAL.
+    //
+    // Return of NO_ERROR means the operation completed as normal.
+    //
+    // Return of a positive value means the operation could not be completed
+    //    at this time, but the user should try again later:
+    // * STALE_BUFFER_SLOT - see above (second paragraph)
+    //
+    // Return of a negative value means an error has occurred:
+    // * BAD_VALUE - one of the following could've happened:
+    //               * the buffer slot was invalid
+    //               * the fence was NULL
+    //               * the buffer slot specified is not in the acquired state
     virtual status_t releaseBuffer(int buf, uint64_t frameNumber,
             EGLDisplay display, EGLSyncKHR fence,
             const sp<Fence>& releaseFence) = 0;
@@ -137,24 +154,38 @@
     // the application.
     //
     // consumer may not be NULL.
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * NO_INIT - the buffer queue has been abandoned
+    // * BAD_VALUE - a NULL consumer was provided
     virtual status_t consumerConnect(const sp<IConsumerListener>& consumer, bool controlledByApp) = 0;
 
     // consumerDisconnect disconnects a consumer from the BufferQueue. All
     // buffers will be freed and the BufferQueue is placed in the "abandoned"
     // state, causing most interactions with the BufferQueue by the producer to
     // fail.
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * BAD_VALUE - no consumer is currently connected
     virtual status_t consumerDisconnect() = 0;
 
-    // getReleasedBuffers sets the value pointed to by slotMask to a bit mask
-    // indicating which buffer slots have been released by the BufferQueue
-    // but have not yet been released by the consumer.
+    // getReleasedBuffers sets the value pointed to by slotMask to a bit set.
+    // Each bit index with a 1 corresponds to a released buffer slot with that
+    // index value.  In particular, a released buffer is one that has
+    // been released by the BufferQueue but have not yet been released by the consumer.
     //
     // This should be called from the onBuffersReleased() callback.
-    virtual status_t getReleasedBuffers(uint32_t* slotMask) = 0;
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * NO_INIT - the buffer queue has been abandoned.
+    virtual status_t getReleasedBuffers(uint64_t* slotMask) = 0;
 
     // setDefaultBufferSize is used to set the size of buffers returned by
     // dequeueBuffer when a width and height of zero is requested.  Default
     // is 1x1.
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * BAD_VALUE - either w or h was zero
     virtual status_t setDefaultBufferSize(uint32_t w, uint32_t h) = 0;
 
     // setDefaultMaxBufferCount sets the default value for the maximum buffer
@@ -163,6 +194,9 @@
     // take effect if the producer sets the count back to zero.
     //
     // The count must be between 2 and NUM_BUFFER_SLOTS, inclusive.
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * BAD_VALUE - bufferCount was out of range (see above).
     virtual status_t setDefaultMaxBufferCount(int bufferCount) = 0;
 
     // disableAsyncBuffer disables the extra buffer used in async mode
@@ -170,11 +204,20 @@
     // flag) and has dequeueBuffer() return WOULD_BLOCK instead.
     //
     // This can only be called before consumerConnect().
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * INVALID_OPERATION - attempting to call this after consumerConnect.
     virtual status_t disableAsyncBuffer() = 0;
 
     // setMaxAcquiredBufferCount sets the maximum number of buffers that can
     // be acquired by the consumer at one time (default 1).  This call will
     // fail if a producer is connected to the BufferQueue.
+    //
+    // maxAcquiredBuffers must be (inclusive) between 1 and MAX_MAX_ACQUIRED_BUFFERS.
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * BAD_VALUE - maxAcquiredBuffers was out of range (see above).
+    // * INVALID_OPERATION - attempting to call this after a producer connected.
     virtual status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers) = 0;
 
     // setConsumerName sets the name used in logging
@@ -182,20 +225,37 @@
 
     // setDefaultBufferFormat allows the BufferQueue to create
     // GraphicBuffers of a defaultFormat if no format is specified
-    // in dequeueBuffer.  Formats are enumerated in graphics.h; the
-    // initial default is HAL_PIXEL_FORMAT_RGBA_8888.
-    virtual status_t setDefaultBufferFormat(uint32_t defaultFormat) = 0;
+    // in dequeueBuffer.
+    // The initial default is PIXEL_FORMAT_RGBA_8888.
+    //
+    // Return of a value other than NO_ERROR means an unknown error has occurred.
+    virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat) = 0;
+
+    // setDefaultBufferDataSpace is a request to the producer to provide buffers
+    // of the indicated dataSpace. The producer may ignore this request.
+    // The initial default is HAL_DATASPACE_UNKNOWN.
+    //
+    // Return of a value other than NO_ERROR means an unknown error has occurred.
+    virtual status_t setDefaultBufferDataSpace(
+            android_dataspace defaultDataSpace) = 0;
 
     // setConsumerUsageBits will turn on additional usage bits for dequeueBuffer.
     // These are merged with the bits passed to dequeueBuffer.  The values are
     // enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER; the default is 0.
+    //
+    // Return of a value other than NO_ERROR means an unknown error has occurred.
     virtual status_t setConsumerUsageBits(uint32_t usage) = 0;
 
     // setTransformHint bakes in rotation to buffers so overlays can be used.
     // The values are enumerated in window.h, e.g.
     // NATIVE_WINDOW_TRANSFORM_ROT_90.  The default is 0 (no transform).
+    //
+    // Return of a value other than NO_ERROR means an unknown error has occurred.
     virtual status_t setTransformHint(uint32_t hint) = 0;
 
+    // Retrieve the sideband buffer stream, if any.
+    virtual sp<NativeHandle> getSidebandStream() const = 0;
+
     // dump state into a string
     virtual void dump(String8& result, const char* prefix) const = 0;
 
diff --git a/include/gui/IGraphicBufferProducer.h b/include/gui/IGraphicBufferProducer.h
index 342ba08..9530de1 100644
--- a/include/gui/IGraphicBufferProducer.h
+++ b/include/gui/IGraphicBufferProducer.h
@@ -28,10 +28,13 @@
 #include <ui/Fence.h>
 #include <ui/GraphicBuffer.h>
 #include <ui/Rect.h>
+#include <ui/Region.h>
 
 namespace android {
 // ----------------------------------------------------------------------------
 
+class IProducerListener;
+class NativeHandle;
 class Surface;
 
 /*
@@ -54,7 +57,11 @@
     DECLARE_META_INTERFACE(GraphicBufferProducer);
 
     enum {
+        // A flag returned by dequeueBuffer when the client needs to call
+        // requestBuffer immediately thereafter.
         BUFFER_NEEDS_REALLOCATION = 0x1,
+        // A flag returned by dequeueBuffer when all mirrored slots should be
+        // released by the client. This flag should always be processed first.
         RELEASE_ALL_BUFFERS       = 0x2,
     };
 
@@ -63,67 +70,236 @@
     // buffer to the given slot index, and the client is expected to mirror the
     // slot->buffer mapping so that it's not necessary to transfer a
     // GraphicBuffer for every dequeue operation.
+    //
+    // The slot must be in the range of [0, NUM_BUFFER_SLOTS).
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * NO_INIT - the buffer queue has been abandoned.
+    // * BAD_VALUE - one of the two conditions occurred:
+    //              * slot was out of range (see above)
+    //              * buffer specified by the slot is not dequeued
     virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf) = 0;
 
     // setBufferCount sets the number of buffer slots available. Calling this
     // will also cause all buffer slots to be emptied. The caller should empty
     // its mirrored copy of the buffer slots when calling this method.
+    //
+    // This function should not be called when there are any dequeued buffer
+    // slots, doing so will result in a BAD_VALUE error returned.
+    //
+    // The buffer count should be at most NUM_BUFFER_SLOTS (inclusive), but at least
+    // the minimum undequeued buffer count (exclusive). The minimum value
+    // can be obtained by calling query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS).
+    // In particular the range is (minUndequeudBuffers, NUM_BUFFER_SLOTS].
+    //
+    // The buffer count may also be set to 0 (the default), to indicate that
+    // the producer does not wish to set a value.
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * NO_INIT - the buffer queue has been abandoned.
+    // * BAD_VALUE - one of the below conditions occurred:
+    //              * bufferCount was out of range (see above)
+    //              * client has one or more buffers dequeued
     virtual status_t setBufferCount(int bufferCount) = 0;
 
     // dequeueBuffer requests a new buffer slot for the client to use. Ownership
     // of the slot is transfered to the client, meaning that the server will not
-    // use the contents of the buffer associated with that slot. The slot index
-    // returned may or may not contain a buffer. If the slot is empty the client
-    // should call requestBuffer to assign a new buffer to that slot. The client
-    // is expected to either call cancelBuffer on the dequeued slot or to fill
-    // in the contents of its associated buffer contents and call queueBuffer.
-    // If dequeueBuffer return BUFFER_NEEDS_REALLOCATION, the client is
+    // use the contents of the buffer associated with that slot.
+    //
+    // The slot index returned may or may not contain a buffer (client-side).
+    // If the slot is empty the client should call requestBuffer to assign a new
+    // buffer to that slot.
+    //
+    // Once the client is done filling this buffer, it is expected to transfer
+    // buffer ownership back to the server with either cancelBuffer on
+    // the dequeued slot or to fill in the contents of its associated buffer
+    // contents and call queueBuffer.
+    //
+    // If dequeueBuffer returns the BUFFER_NEEDS_REALLOCATION flag, the client is
     // expected to call requestBuffer immediately.
     //
+    // If dequeueBuffer returns the RELEASE_ALL_BUFFERS flag, the client is
+    // expected to release all of the mirrored slot->buffer mappings.
+    //
     // The fence parameter will be updated to hold the fence associated with
     // the buffer. The contents of the buffer must not be overwritten until the
-    // fence signals. If the fence is NULL, the buffer may be written
+    // fence signals. If the fence is Fence::NO_FENCE, the buffer may be written
     // immediately.
     //
-    // The async parameter sets whether we're in asynchrnous mode for this
-    // deququeBuffer() call.
-    virtual status_t dequeueBuffer(int *slot, sp<Fence>* fence, bool async,
-            uint32_t w, uint32_t h, uint32_t format, uint32_t usage) = 0;
+    // The async parameter sets whether we're in asynchronous mode for this
+    // dequeueBuffer() call.
+    //
+    // The width and height parameters must be no greater than the minimum of
+    // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv).
+    // An error due to invalid dimensions might not be reported until
+    // updateTexImage() is called.  If width and height are both zero, the
+    // default values specified by setDefaultBufferSize() are used instead.
+    //
+    // If the format is 0, the default format will be used.
+    //
+    // The usage argument specifies gralloc buffer usage flags.  The values
+    // are enumerated in <gralloc.h>, e.g. GRALLOC_USAGE_HW_RENDER.  These
+    // will be merged with the usage flags specified by
+    // IGraphicBufferConsumer::setConsumerUsageBits.
+    //
+    // This call will block until a buffer is available to be dequeued. If
+    // both the producer and consumer are controlled by the app, then this call
+    // can never block and will return WOULD_BLOCK if no buffer is available.
+    //
+    // A non-negative value with flags set (see above) will be returned upon
+    // success.
+    //
+    // Return of a negative means an error has occurred:
+    // * NO_INIT - the buffer queue has been abandoned.
+    // * BAD_VALUE - both in async mode and buffer count was less than the
+    //               max numbers of buffers that can be allocated at once.
+    // * INVALID_OPERATION - cannot attach the buffer because it would cause
+    //                       too many buffers to be dequeued, either because
+    //                       the producer already has a single buffer dequeued
+    //                       and did not set a buffer count, or because a
+    //                       buffer count was set and this call would cause
+    //                       it to be exceeded.
+    // * WOULD_BLOCK - no buffer is currently available, and blocking is disabled
+    //                 since both the producer/consumer are controlled by app
+    // * NO_MEMORY - out of memory, cannot allocate the graphics buffer.
+    //
+    // All other negative values are an unknown error returned downstream
+    // from the graphics allocator (typically errno).
+    virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, bool async,
+            uint32_t w, uint32_t h, PixelFormat format, uint32_t usage) = 0;
+
+    // detachBuffer attempts to remove all ownership of the buffer in the given
+    // slot from the buffer queue. If this call succeeds, the slot will be
+    // freed, and there will be no way to obtain the buffer from this interface.
+    // The freed slot will remain unallocated until either it is selected to
+    // hold a freshly allocated buffer in dequeueBuffer or a buffer is attached
+    // to the slot. The buffer must have already been dequeued, and the caller
+    // must already possesses the sp<GraphicBuffer> (i.e., must have called
+    // requestBuffer).
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * NO_INIT - the buffer queue has been abandoned.
+    // * BAD_VALUE - the given slot number is invalid, either because it is
+    //               out of the range [0, NUM_BUFFER_SLOTS), or because the slot
+    //               it refers to is not currently dequeued and requested.
+    virtual status_t detachBuffer(int slot) = 0;
+
+    // detachNextBuffer is equivalent to calling dequeueBuffer, requestBuffer,
+    // and detachBuffer in sequence, except for two things:
+    //
+    // 1) It is unnecessary to know the dimensions, format, or usage of the
+    //    next buffer.
+    // 2) It will not block, since if it cannot find an appropriate buffer to
+    //    return, it will return an error instead.
+    //
+    // Only slots that are free but still contain a GraphicBuffer will be
+    // considered, and the oldest of those will be returned. outBuffer is
+    // equivalent to outBuffer from the requestBuffer call, and outFence is
+    // equivalent to fence from the dequeueBuffer call.
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * NO_INIT - the buffer queue has been abandoned.
+    // * BAD_VALUE - either outBuffer or outFence were NULL.
+    // * NO_MEMORY - no slots were found that were both free and contained a
+    //               GraphicBuffer.
+    virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
+            sp<Fence>* outFence) = 0;
+
+    // attachBuffer attempts to transfer ownership of a buffer to the buffer
+    // queue. If this call succeeds, it will be as if this buffer was dequeued
+    // from the returned slot number. As such, this call will fail if attaching
+    // this buffer would cause too many buffers to be simultaneously dequeued.
+    //
+    // If attachBuffer returns the RELEASE_ALL_BUFFERS flag, the caller is
+    // expected to release all of the mirrored slot->buffer mappings.
+    //
+    // A non-negative value with flags set (see above) will be returned upon
+    // success.
+    //
+    // Return of a negative value means an error has occurred:
+    // * NO_INIT - the buffer queue has been abandoned.
+    // * BAD_VALUE - outSlot or buffer were NULL, invalid combination of
+    //               async mode and buffer count override, or the generation
+    //               number of the buffer did not match the buffer queue.
+    // * INVALID_OPERATION - cannot attach the buffer because it would cause
+    //                       too many buffers to be dequeued, either because
+    //                       the producer already has a single buffer dequeued
+    //                       and did not set a buffer count, or because a
+    //                       buffer count was set and this call would cause
+    //                       it to be exceeded.
+    // * WOULD_BLOCK - no buffer slot is currently available, and blocking is
+    //                 disabled since both the producer/consumer are
+    //                 controlled by the app.
+    virtual status_t attachBuffer(int* outSlot,
+            const sp<GraphicBuffer>& buffer) = 0;
 
     // queueBuffer indicates that the client has finished filling in the
     // contents of the buffer associated with slot and transfers ownership of
-    // that slot back to the server. It is not valid to call queueBuffer on a
-    // slot that is not owned by the client or one for which a buffer associated
-    // via requestBuffer. In addition, a timestamp must be provided by the
-    // client for this buffer. The timestamp is measured in nanoseconds, and
-    // must be monotonically increasing. Its other properties (zero point, etc)
+    // that slot back to the server.
+    //
+    // It is not valid to call queueBuffer on a slot that is not owned
+    // by the client or one for which a buffer associated via requestBuffer
+    // (an attempt to do so will fail with a return value of BAD_VALUE).
+    //
+    // In addition, the input must be described by the client (as documented
+    // below). Any other properties (zero point, etc)
     // are client-dependent, and should be documented by the client.
     //
-    // The async parameter sets whether we're queuing a buffer in asynchronous mode.
+    // The slot must be in the range of [0, NUM_BUFFER_SLOTS).
     //
-    // outWidth, outHeight and outTransform are filled with the default width
-    // and height of the window and current transform applied to buffers,
-    // respectively.
+    // Upon success, the output will be filled with meaningful values
+    // (refer to the documentation below).
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * NO_INIT - the buffer queue has been abandoned.
+    // * BAD_VALUE - one of the below conditions occurred:
+    //              * fence was NULL
+    //              * scaling mode was unknown
+    //              * both in async mode and buffer count was less than the
+    //                max numbers of buffers that can be allocated at once
+    //              * slot index was out of range (see above).
+    //              * the slot was not in the dequeued state
+    //              * the slot was enqueued without requesting a buffer
+    //              * crop rect is out of bounds of the buffer dimensions
 
     struct QueueBufferInput : public Flattenable<QueueBufferInput> {
         friend class Flattenable<QueueBufferInput>;
         inline QueueBufferInput(const Parcel& parcel);
+        // timestamp - a monotonically increasing value in nanoseconds
+        // isAutoTimestamp - if the timestamp was synthesized at queue time
+        // dataSpace - description of the contents, interpretation depends on format
+        // crop - a crop rectangle that's used as a hint to the consumer
+        // scalingMode - a set of flags from NATIVE_WINDOW_SCALING_* in <window.h>
+        // transform - a set of flags from NATIVE_WINDOW_TRANSFORM_* in <window.h>
+        // async - if the buffer is queued in asynchronous mode
+        // fence - a fence that the consumer must wait on before reading the buffer,
+        //         set this to Fence::NO_FENCE if the buffer is ready immediately
+        // sticky - the sticky transform set in Surface (only used by the LEGACY
+        //          camera mode).
         inline QueueBufferInput(int64_t timestamp, bool isAutoTimestamp,
-                const Rect& crop, int scalingMode, uint32_t transform, bool async,
-                const sp<Fence>& fence)
-        : timestamp(timestamp), isAutoTimestamp(isAutoTimestamp), crop(crop),
-          scalingMode(scalingMode), transform(transform), async(async),
-          fence(fence) { }
+                android_dataspace dataSpace, const Rect& crop, int scalingMode,
+                uint32_t transform, bool async, const sp<Fence>& fence,
+                uint32_t sticky = 0)
+                : timestamp(timestamp), isAutoTimestamp(isAutoTimestamp),
+                  dataSpace(dataSpace), crop(crop), scalingMode(scalingMode),
+                  transform(transform), stickyTransform(sticky),
+                  async(async), fence(fence), surfaceDamage() { }
         inline void deflate(int64_t* outTimestamp, bool* outIsAutoTimestamp,
-                Rect* outCrop, int* outScalingMode, uint32_t* outTransform,
-                bool* outAsync, sp<Fence>* outFence) const {
+                android_dataspace* outDataSpace,
+                Rect* outCrop, int* outScalingMode,
+                uint32_t* outTransform, bool* outAsync, sp<Fence>* outFence,
+                uint32_t* outStickyTransform = NULL) const {
             *outTimestamp = timestamp;
             *outIsAutoTimestamp = bool(isAutoTimestamp);
+            *outDataSpace = dataSpace;
             *outCrop = crop;
             *outScalingMode = scalingMode;
             *outTransform = transform;
             *outAsync = bool(async);
             *outFence = fence;
+            if (outStickyTransform != NULL) {
+                *outStickyTransform = stickyTransform;
+            }
         }
 
         // Flattenable protocol
@@ -132,19 +308,30 @@
         status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const;
         status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count);
 
+        const Region& getSurfaceDamage() const { return surfaceDamage; }
+        void setSurfaceDamage(const Region& damage) { surfaceDamage = damage; }
+
     private:
         int64_t timestamp;
         int isAutoTimestamp;
+        android_dataspace dataSpace;
         Rect crop;
         int scalingMode;
         uint32_t transform;
+        uint32_t stickyTransform;
         int async;
         sp<Fence> fence;
+        Region surfaceDamage;
     };
 
     // QueueBufferOutput must be a POD structure
-    struct QueueBufferOutput {
+    struct __attribute__ ((__packed__)) QueueBufferOutput {
         inline QueueBufferOutput() { }
+        // outWidth - filled with default width applied to the buffer
+        // outHeight - filled with default height applied to the buffer
+        // outTransformHint - filled with default transform applied to the buffer
+        // outNumPendingBuffers - num buffers queued that haven't yet been acquired
+        //                        (counting the currently queued buffer)
         inline void deflate(uint32_t* outWidth,
                 uint32_t* outHeight,
                 uint32_t* outTransformHint,
@@ -174,25 +361,57 @@
     // cancelBuffer indicates that the client does not wish to fill in the
     // buffer associated with slot and transfers ownership of the slot back to
     // the server.
+    //
+    // The buffer is not queued for use by the consumer.
+    //
+    // The buffer will not be overwritten until the fence signals.  The fence
+    // will usually be the one obtained from dequeueBuffer.
     virtual void cancelBuffer(int slot, const sp<Fence>& fence) = 0;
 
     // query retrieves some information for this surface
-    // 'what' tokens allowed are that of android_natives.h
+    // 'what' tokens allowed are that of NATIVE_WINDOW_* in <window.h>
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * NO_INIT - the buffer queue has been abandoned.
+    // * BAD_VALUE - what was out of range
     virtual int query(int what, int* value) = 0;
 
     // connect attempts to connect a client API to the IGraphicBufferProducer.
     // This must be called before any other IGraphicBufferProducer methods are
-    // called except for getAllocator.
+    // called except for getAllocator. A consumer must be already connected.
     //
     // This method will fail if the connect was previously called on the
     // IGraphicBufferProducer and no corresponding disconnect call was made.
     //
-    // outWidth, outHeight and outTransform are filled with the default width
-    // and height of the window and current transform applied to buffers,
-    // respectively. The token needs to be any binder object that lives in the
-    // producer process -- it is solely used for obtaining a death notification
-    // when the producer is killed.
-    virtual status_t connect(const sp<IBinder>& token,
+    // The listener is an optional binder callback object that can be used if
+    // the producer wants to be notified when the consumer releases a buffer
+    // back to the BufferQueue. It is also used to detect the death of the
+    // producer. If only the latter functionality is desired, there is a
+    // DummyProducerListener class in IProducerListener.h that can be used.
+    //
+    // The api should be one of the NATIVE_WINDOW_API_* values in <window.h>
+    //
+    // The producerControlledByApp should be set to true if the producer is hosted
+    // by an untrusted process (typically app_process-forked processes). If both
+    // the producer and the consumer are app-controlled then all buffer queues
+    // will operate in async mode regardless of the async flag.
+    //
+    // Upon success, the output will be filled with meaningful data
+    // (refer to QueueBufferOutput documentation above).
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * NO_INIT - one of the following occurred:
+    //             * the buffer queue was abandoned
+    //             * no consumer has yet connected
+    // * BAD_VALUE - one of the following has occurred:
+    //             * the producer is already connected
+    //             * api was out of range (see above).
+    //             * output was NULL.
+    // * DEAD_OBJECT - the token is hosted by an already-dead process
+    //
+    // Additional negative errors may be returned by the internals, they
+    // should be treated as opaque fatal unrecoverable errors.
+    virtual status_t connect(const sp<IProducerListener>& listener,
             int api, bool producerControlledByApp, QueueBufferOutput* output) = 0;
 
     // disconnect attempts to disconnect a client API from the
@@ -203,7 +422,67 @@
     //
     // This method will fail if the the IGraphicBufferProducer is not currently
     // connected to the specified client API.
+    //
+    // The api should be one of the NATIVE_WINDOW_API_* values in <window.h>
+    //
+    // Disconnecting from an abandoned IGraphicBufferProducer is legal and
+    // is considered a no-op.
+    //
+    // Return of a value other than NO_ERROR means an error has occurred:
+    // * BAD_VALUE - one of the following has occurred:
+    //             * the api specified does not match the one that was connected
+    //             * api was out of range (see above).
+    // * DEAD_OBJECT - the token is hosted by an already-dead process
     virtual status_t disconnect(int api) = 0;
+
+    // Attaches a sideband buffer stream to the IGraphicBufferProducer.
+    //
+    // A sideband stream is a device-specific mechanism for passing buffers
+    // from the producer to the consumer without using dequeueBuffer/
+    // queueBuffer. If a sideband stream is present, the consumer can choose
+    // whether to acquire buffers from the sideband stream or from the queued
+    // buffers.
+    //
+    // Passing NULL or a different stream handle will detach the previous
+    // handle if any.
+    virtual status_t setSidebandStream(const sp<NativeHandle>& stream) = 0;
+
+    // Allocates buffers based on the given dimensions/format.
+    //
+    // This function will allocate up to the maximum number of buffers
+    // permitted by the current BufferQueue configuration. It will use the
+    // given format, dimensions, and usage bits, which are interpreted in the
+    // same way as for dequeueBuffer, and the async flag must be set the same
+    // way as for dequeueBuffer to ensure that the correct number of buffers are
+    // allocated. This is most useful to avoid an allocation delay during
+    // dequeueBuffer. If there are already the maximum number of buffers
+    // allocated, this function has no effect.
+    virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
+            PixelFormat format, uint32_t usage) = 0;
+
+    // Sets whether dequeueBuffer is allowed to allocate new buffers.
+    //
+    // Normally dequeueBuffer does not discriminate between free slots which
+    // already have an allocated buffer and those which do not, and will
+    // allocate a new buffer if the slot doesn't have a buffer or if the slot's
+    // buffer doesn't match the requested size, format, or usage. This method
+    // allows the producer to restrict the eligible slots to those which already
+    // have an allocated buffer of the correct size, format, and usage. If no
+    // eligible slot is available, dequeueBuffer will block or return an error
+    // as usual.
+    virtual status_t allowAllocation(bool allow) = 0;
+
+    // Sets the current generation number of the BufferQueue.
+    //
+    // This generation number will be inserted into any buffers allocated by the
+    // BufferQueue, and any attempts to attach a buffer with a different
+    // generation number will fail. Buffers already in the queue are not
+    // affected and will retain their current generation number. The generation
+    // number defaults to 0.
+    virtual status_t setGenerationNumber(uint32_t generationNumber) = 0;
+
+    // Returns the name of the connected consumer.
+    virtual String8 getConsumerName() const = 0;
 };
 
 // ----------------------------------------------------------------------------
diff --git a/include/gui/IProducerListener.h b/include/gui/IProducerListener.h
new file mode 100644
index 0000000..3848a6c
--- /dev/null
+++ b/include/gui/IProducerListener.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_GUI_IPRODUCERLISTENER_H
+#define ANDROID_GUI_IPRODUCERLISTENER_H
+
+#include <binder/IInterface.h>
+
+#include <utils/RefBase.h>
+
+namespace android {
+
+// ProducerListener is the interface through which the BufferQueue notifies the
+// producer of events that the producer may wish to react to. Because the
+// producer will generally have a mutex that is locked during calls from the
+// producer to the BufferQueue, these calls from the BufferQueue to the
+// producer *MUST* be called only when the BufferQueue mutex is NOT locked.
+
+class ProducerListener : public virtual RefBase
+{
+public:
+    ProducerListener() {}
+    virtual ~ProducerListener() {}
+
+    // onBufferReleased is called from IGraphicBufferConsumer::releaseBuffer to
+    // notify the producer that a new buffer is free and ready to be dequeued.
+    //
+    // This is called without any lock held and can be called concurrently by
+    // multiple threads.
+    virtual void onBufferReleased() = 0; // Asynchronous
+};
+
+class IProducerListener : public ProducerListener, public IInterface
+{
+public:
+    DECLARE_META_INTERFACE(ProducerListener)
+};
+
+class BnProducerListener : public BnInterface<IProducerListener>
+{
+public:
+    virtual status_t onTransact(uint32_t code, const Parcel& data,
+            Parcel* reply, uint32_t flags = 0);
+};
+
+class DummyProducerListener : public BnProducerListener
+{
+public:
+    virtual void onBufferReleased() {}
+};
+
+} // namespace android
+
+#endif
diff --git a/include/gui/ISensorServer.h b/include/gui/ISensorServer.h
index 9c8afc5..3dca2a3 100644
--- a/include/gui/ISensorServer.h
+++ b/include/gui/ISensorServer.h
@@ -30,14 +30,17 @@
 
 class Sensor;
 class ISensorEventConnection;
+class String8;
 
 class ISensorServer : public IInterface
 {
 public:
     DECLARE_META_INTERFACE(SensorServer);
 
-    virtual Vector<Sensor> getSensorList() = 0;
-    virtual sp<ISensorEventConnection> createSensorEventConnection() = 0;
+    virtual Vector<Sensor> getSensorList(const String16& opPackageName) = 0;
+    virtual sp<ISensorEventConnection> createSensorEventConnection(const String8& packageName,
+             int mode, const String16& opPackageName) = 0;
+    virtual int32_t isDataInjectionEnabled() = 0;
 };
 
 // ----------------------------------------------------------------------------
diff --git a/include/gui/ISurfaceComposer.h b/include/gui/ISurfaceComposer.h
index 5c3c99c..8c3d49e 100644
--- a/include/gui/ISurfaceComposer.h
+++ b/include/gui/ISurfaceComposer.h
@@ -22,10 +22,12 @@
 
 #include <utils/RefBase.h>
 #include <utils/Errors.h>
+#include <utils/Timers.h>
+#include <utils/Vector.h>
 
 #include <binder/IInterface.h>
 
-#include <ui/PixelFormat.h>
+#include <ui/FrameStats.h>
 
 #include <gui/IGraphicBufferAlloc.h>
 #include <gui/ISurfaceComposerClient.h>
@@ -35,9 +37,11 @@
 
 class ComposerState;
 class DisplayState;
-class DisplayInfo;
+struct DisplayInfo;
+struct DisplayStatInfo;
 class IDisplayEventConnection;
 class IMemoryHeap;
+class Rect;
 
 /*
  * This class defines the Binder IPC interface for accessing various
@@ -58,6 +62,13 @@
         eDisplayIdHdmi = 1
     };
 
+    enum Rotation {
+        eRotateNone = 0,
+        eRotate90   = 1,
+        eRotate180  = 2,
+        eRotate270  = 3
+    };
+
     /* create connection with surface flinger, requires
      * ACCESS_SURFACE_FLINGER permission
      */
@@ -100,27 +111,52 @@
     virtual bool authenticateSurfaceTexture(
             const sp<IGraphicBufferProducer>& surface) const = 0;
 
-    /* triggers screen off and waits for it to complete
+    /* set display power mode. depending on the mode, it can either trigger
+     * screen on, off or low power mode and wait for it to complete.
      * requires ACCESS_SURFACE_FLINGER permission.
      */
-    virtual void blank(const sp<IBinder>& display) = 0;
+    virtual void setPowerMode(const sp<IBinder>& display, int mode) = 0;
 
-    /* triggers screen on and waits for it to complete
-     * requires ACCESS_SURFACE_FLINGER permission.
-     */
-    virtual void unblank(const sp<IBinder>& display) = 0;
-
-    /* returns information about a display
+    /* returns information for each configuration of the given display
      * intended to be used to get information about built-in displays */
-    virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) = 0;
+    virtual status_t getDisplayConfigs(const sp<IBinder>& display,
+            Vector<DisplayInfo>* configs) = 0;
+
+    /* returns display statistics for a given display
+     * intended to be used by the media framework to properly schedule
+     * video frames */
+    virtual status_t getDisplayStats(const sp<IBinder>& display,
+            DisplayStatInfo* stats) = 0;
+
+    /* indicates which of the configurations returned by getDisplayInfo is
+     * currently active */
+    virtual int getActiveConfig(const sp<IBinder>& display) = 0;
+
+    /* specifies which configuration (of those returned by getDisplayInfo)
+     * should be used */
+    virtual status_t setActiveConfig(const sp<IBinder>& display, int id) = 0;
 
     /* Capture the specified screen. requires READ_FRAME_BUFFER permission
      * This function will fail if there is a secure window on screen.
      */
     virtual status_t captureScreen(const sp<IBinder>& display,
             const sp<IGraphicBufferProducer>& producer,
-            uint32_t reqWidth, uint32_t reqHeight,
-            uint32_t minLayerZ, uint32_t maxLayerZ) = 0;
+            Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
+            uint32_t minLayerZ, uint32_t maxLayerZ,
+            bool useIdentityTransform,
+            Rotation rotation = eRotateNone) = 0;
+
+    /* Clears the frame statistics for animations.
+     *
+     * Requires the ACCESS_SURFACE_FLINGER permission.
+     */
+    virtual status_t clearAnimationFrameStats() = 0;
+
+    /* Gets the frame statistics for animations.
+     *
+     * Requires the ACCESS_SURFACE_FLINGER permission.
+     */
+    virtual status_t getAnimationFrameStats(FrameStats* outStats) const = 0;
 };
 
 // ----------------------------------------------------------------------------
@@ -139,11 +175,15 @@
         GET_BUILT_IN_DISPLAY,
         SET_TRANSACTION_STATE,
         AUTHENTICATE_SURFACE,
-        BLANK,
-        UNBLANK,
-        GET_DISPLAY_INFO,
+        GET_DISPLAY_CONFIGS,
+        GET_ACTIVE_CONFIG,
+        SET_ACTIVE_CONFIG,
         CONNECT_DISPLAY,
         CAPTURE_SCREEN,
+        CLEAR_ANIMATION_FRAME_STATS,
+        GET_ANIMATION_FRAME_STATS,
+        SET_POWER_MODE,
+        GET_DISPLAY_STATS,
     };
 
     virtual status_t onTransact(uint32_t code, const Parcel& data,
diff --git a/include/gui/ISurfaceComposerClient.h b/include/gui/ISurfaceComposerClient.h
index cb9816f..bb79bd0 100644
--- a/include/gui/ISurfaceComposerClient.h
+++ b/include/gui/ISurfaceComposerClient.h
@@ -25,6 +25,7 @@
 
 #include <binder/IInterface.h>
 
+#include <ui/FrameStats.h>
 #include <ui/PixelFormat.h>
 
 namespace android {
@@ -46,6 +47,7 @@
         eOpaque             = 0x00000400,
         eProtectedByApp     = 0x00000800,
         eProtectedByDRM     = 0x00001000,
+        eCursorWindow       = 0x00002000,
 
         eFXSurfaceNormal    = 0x00000000,
         eFXSurfaceDim       = 0x00020000,
@@ -65,6 +67,16 @@
      * Requires ACCESS_SURFACE_FLINGER permission
      */
     virtual status_t destroySurface(const sp<IBinder>& handle) = 0;
+
+    /*
+     * Requires ACCESS_SURFACE_FLINGER permission
+     */
+    virtual status_t clearLayerFrameStats(const sp<IBinder>& handle) const = 0;
+
+    /*
+     * Requires ACCESS_SURFACE_FLINGER permission
+     */
+    virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const = 0;
 };
 
 // ----------------------------------------------------------------------------
diff --git a/include/gui/Sensor.h b/include/gui/Sensor.h
index 0c81426..8142be6 100644
--- a/include/gui/Sensor.h
+++ b/include/gui/Sensor.h
@@ -67,8 +67,16 @@
     int32_t getMinDelay() const;
     nsecs_t getMinDelayNs() const;
     int32_t getVersion() const;
-    int32_t getFifoReservedEventCount() const;
-    int32_t getFifoMaxEventCount() const;
+    uint32_t getFifoReservedEventCount() const;
+    uint32_t getFifoMaxEventCount() const;
+    const String8& getStringType() const;
+    const String8& getRequiredPermission() const;
+    bool isRequiredPermissionRuntime() const;
+    int32_t getRequiredAppOp() const;
+    int32_t getMaxDelay() const;
+    uint32_t getFlags() const;
+    bool isWakeUpSensor() const;
+    int32_t getReportingMode() const;
 
     // LightFlattenable protocol
     inline bool isFixedSize() const { return false; }
@@ -87,8 +95,16 @@
     float   mPower;
     int32_t mMinDelay;
     int32_t mVersion;
-    int32_t mFifoReservedEventCount;
-    int32_t mFifoMaxEventCount;
+    uint32_t mFifoReservedEventCount;
+    uint32_t mFifoMaxEventCount;
+    String8 mStringType;
+    String8 mRequiredPermission;
+    bool mRequiredPermissionRuntime = false;
+    int32_t mRequiredAppOp;
+    int32_t mMaxDelay;
+    uint32_t mFlags;
+    static void flattenString8(void*& buffer, size_t& size, const String8& string8);
+    static bool unflattenString8(void const*& buffer, size_t& size, String8& outputString8);
 };
 
 // ----------------------------------------------------------------------------
diff --git a/include/gui/SensorEventQueue.h b/include/gui/SensorEventQueue.h
index 0bfc7a0..e5b9fc5 100644
--- a/include/gui/SensorEventQueue.h
+++ b/include/gui/SensorEventQueue.h
@@ -23,11 +23,12 @@
 #include <utils/Errors.h>
 #include <utils/RefBase.h>
 #include <utils/Timers.h>
+#include <utils/String16.h>
 
 #include <gui/BitTube.h>
 
 // ----------------------------------------------------------------------------
-
+#define WAKE_UP_SENSOR_EVENT_NEEDS_ACK (1U << 31)
 struct ALooper;
 struct ASensorEvent;
 
@@ -52,7 +53,7 @@
 
     enum { MAX_RECEIVE_BUFFER_EVENT_COUNT = 256 };
 
-            SensorEventQueue(const sp<ISensorEventConnection>& connection);
+    SensorEventQueue(const sp<ISensorEventConnection>& connection);
     virtual ~SensorEventQueue();
     virtual void onFirstRef();
 
@@ -75,7 +76,10 @@
                           int reservedFlags) const;
     status_t disableSensor(int32_t handle) const;
     status_t flush() const;
+    // Send an ack for every wake_up sensor event that is set to WAKE_UP_SENSOR_EVENT_NEEDS_ACK.
+    void sendAck(const ASensorEvent* events, int count);
 
+    status_t injectSensorEvent(const ASensorEvent& event);
 private:
     sp<Looper> getLooper() const;
     sp<ISensorEventConnection> mSensorEventConnection;
@@ -85,6 +89,7 @@
     ASensorEvent* mRecBuffer;
     size_t mAvailable;
     size_t mConsumed;
+    uint32_t mNumAcksToSend;
 };
 
 // ----------------------------------------------------------------------------
diff --git a/include/gui/SensorManager.h b/include/gui/SensorManager.h
index 3176462..0cff46c 100644
--- a/include/gui/SensorManager.h
+++ b/include/gui/SensorManager.h
@@ -17,15 +17,20 @@
 #ifndef ANDROID_GUI_SENSOR_MANAGER_H
 #define ANDROID_GUI_SENSOR_MANAGER_H
 
+#include <map>
+
 #include <stdint.h>
 #include <sys/types.h>
 
 #include <binder/IBinder.h>
+#include <binder/IPCThreadState.h>
+#include <binder/IServiceManager.h>
 
 #include <utils/Errors.h>
 #include <utils/RefBase.h>
 #include <utils/Singleton.h>
 #include <utils/Vector.h>
+#include <utils/String8.h>
 
 #include <gui/SensorEventQueue.h>
 
@@ -40,33 +45,37 @@
 class ISensorServer;
 class Sensor;
 class SensorEventQueue;
-
 // ----------------------------------------------------------------------------
 
 class SensorManager :
-    public ASensorManager,
-    public Singleton<SensorManager>
+    public ASensorManager
 {
 public:
-    SensorManager();
+    static SensorManager& getInstanceForPackage(const String16& packageName);
     ~SensorManager();
 
     ssize_t getSensorList(Sensor const* const** list) const;
     Sensor const* getDefaultSensor(int type);
-    sp<SensorEventQueue> createEventQueue();
+    sp<SensorEventQueue> createEventQueue(String8 packageName = String8(""), int mode = 0);
+    bool isDataInjectionEnabled();
 
 private:
     // DeathRecipient interface
     void sensorManagerDied();
 
+    SensorManager(const String16& opPackageName);
     status_t assertStateLocked() const;
 
 private:
+    static Mutex sLock;
+    static std::map<String16, SensorManager*> sPackageInstances;
+
     mutable Mutex mLock;
     mutable sp<ISensorServer> mSensorServer;
     mutable Sensor const** mSensorList;
     mutable Vector<Sensor> mSensors;
     mutable sp<IBinder::DeathRecipient> mDeathObserver;
+    const String16 mOpPackageName;
 };
 
 // ----------------------------------------------------------------------------
diff --git a/include/gui/StreamSplitter.h b/include/gui/StreamSplitter.h
new file mode 100644
index 0000000..8f47eb4
--- /dev/null
+++ b/include/gui/StreamSplitter.h
@@ -0,0 +1,184 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_GUI_STREAMSPLITTER_H
+#define ANDROID_GUI_STREAMSPLITTER_H
+
+#include <gui/IConsumerListener.h>
+#include <gui/IProducerListener.h>
+
+#include <utils/Condition.h>
+#include <utils/KeyedVector.h>
+#include <utils/Mutex.h>
+#include <utils/StrongPointer.h>
+
+namespace android {
+
+class GraphicBuffer;
+class IGraphicBufferConsumer;
+class IGraphicBufferProducer;
+
+// StreamSplitter is an autonomous class that manages one input BufferQueue
+// and multiple output BufferQueues. By using the buffer attach and detach logic
+// in BufferQueue, it is able to present the illusion of a single split
+// BufferQueue, where each buffer queued to the input is available to be
+// acquired by each of the outputs, and is able to be dequeued by the input
+// again only once all of the outputs have released it.
+class StreamSplitter : public BnConsumerListener {
+public:
+    // createSplitter creates a new splitter, outSplitter, using inputQueue as
+    // the input BufferQueue. Output BufferQueues must be added using addOutput
+    // before queueing any buffers to the input.
+    //
+    // A return value other than NO_ERROR means that an error has occurred and
+    // outSplitter has not been modified. BAD_VALUE is returned if inputQueue or
+    // outSplitter is NULL. See IGraphicBufferConsumer::consumerConnect for
+    // explanations of other error codes.
+    static status_t createSplitter(const sp<IGraphicBufferConsumer>& inputQueue,
+            sp<StreamSplitter>* outSplitter);
+
+    // addOutput adds an output BufferQueue to the splitter. The splitter
+    // connects to outputQueue as a CPU producer, and any buffers queued
+    // to the input will be queued to each output. It is assumed that all of the
+    // outputs are added before any buffers are queued on the input. If any
+    // output is abandoned by its consumer, the splitter will abandon its input
+    // queue (see onAbandoned).
+    //
+    // A return value other than NO_ERROR means that an error has occurred and
+    // outputQueue has not been added to the splitter. BAD_VALUE is returned if
+    // outputQueue is NULL. See IGraphicBufferProducer::connect for explanations
+    // of other error codes.
+    status_t addOutput(const sp<IGraphicBufferProducer>& outputQueue);
+
+    // setName sets the consumer name of the input queue
+    void setName(const String8& name);
+
+private:
+    // From IConsumerListener
+    //
+    // During this callback, we store some tracking information, detach the
+    // buffer from the input, and attach it to each of the outputs. This call
+    // can block if there are too many outstanding buffers. If it blocks, it
+    // will resume when onBufferReleasedByOutput releases a buffer back to the
+    // input.
+    virtual void onFrameAvailable(const BufferItem& item);
+
+    // From IConsumerListener
+    // We don't care about released buffers because we detach each buffer as
+    // soon as we acquire it. See the comment for onBufferReleased below for
+    // some clarifying notes about the name.
+    virtual void onBuffersReleased() {}
+
+    // From IConsumerListener
+    // We don't care about sideband streams, since we won't be splitting them
+    virtual void onSidebandStreamChanged() {}
+
+    // This is the implementation of the onBufferReleased callback from
+    // IProducerListener. It gets called from an OutputListener (see below), and
+    // 'from' is which producer interface from which the callback was received.
+    //
+    // During this callback, we detach the buffer from the output queue that
+    // generated the callback, update our state tracking to see if this is the
+    // last output releasing the buffer, and if so, release it to the input.
+    // If we release the buffer to the input, we allow a blocked
+    // onFrameAvailable call to proceed.
+    void onBufferReleasedByOutput(const sp<IGraphicBufferProducer>& from);
+
+    // When this is called, the splitter disconnects from (i.e., abandons) its
+    // input queue and signals any waiting onFrameAvailable calls to wake up.
+    // It still processes callbacks from other outputs, but only detaches their
+    // buffers so they can continue operating until they run out of buffers to
+    // acquire. This must be called with mMutex locked.
+    void onAbandonedLocked();
+
+    // This is a thin wrapper class that lets us determine which BufferQueue
+    // the IProducerListener::onBufferReleased callback is associated with. We
+    // create one of these per output BufferQueue, and then pass the producer
+    // into onBufferReleasedByOutput above.
+    class OutputListener : public BnProducerListener,
+                           public IBinder::DeathRecipient {
+    public:
+        OutputListener(const sp<StreamSplitter>& splitter,
+                const sp<IGraphicBufferProducer>& output);
+        virtual ~OutputListener();
+
+        // From IProducerListener
+        virtual void onBufferReleased();
+
+        // From IBinder::DeathRecipient
+        virtual void binderDied(const wp<IBinder>& who);
+
+    private:
+        sp<StreamSplitter> mSplitter;
+        sp<IGraphicBufferProducer> mOutput;
+    };
+
+    class BufferTracker : public LightRefBase<BufferTracker> {
+    public:
+        BufferTracker(const sp<GraphicBuffer>& buffer);
+
+        const sp<GraphicBuffer>& getBuffer() const { return mBuffer; }
+        const sp<Fence>& getMergedFence() const { return mMergedFence; }
+
+        void mergeFence(const sp<Fence>& with);
+
+        // Returns the new value
+        // Only called while mMutex is held
+        size_t incrementReleaseCountLocked() { return ++mReleaseCount; }
+
+    private:
+        // Only destroy through LightRefBase
+        friend LightRefBase<BufferTracker>;
+        ~BufferTracker();
+
+        // Disallow copying
+        BufferTracker(const BufferTracker& other);
+        BufferTracker& operator=(const BufferTracker& other);
+
+        sp<GraphicBuffer> mBuffer; // One instance that holds this native handle
+        sp<Fence> mMergedFence;
+        size_t mReleaseCount;
+    };
+
+    // Only called from createSplitter
+    StreamSplitter(const sp<IGraphicBufferConsumer>& inputQueue);
+
+    // Must be accessed through RefBase
+    virtual ~StreamSplitter();
+
+    static const int MAX_OUTSTANDING_BUFFERS = 2;
+
+    // mIsAbandoned is set to true when an output dies. Once the StreamSplitter
+    // has been abandoned, it will continue to detach buffers from other
+    // outputs, but it will disconnect from the input and not attempt to
+    // communicate with it further.
+    bool mIsAbandoned;
+
+    Mutex mMutex;
+    Condition mReleaseCondition;
+    int mOutstandingBuffers;
+    sp<IGraphicBufferConsumer> mInput;
+    Vector<sp<IGraphicBufferProducer> > mOutputs;
+
+    // Map of GraphicBuffer IDs (GraphicBuffer::getId()) to buffer tracking
+    // objects (which are mostly for counting how many outputs have released the
+    // buffer, but also contain merged release fences).
+    KeyedVector<uint64_t, sp<BufferTracker> > mBuffers;
+};
+
+} // namespace android
+
+#endif
diff --git a/include/gui/Surface.h b/include/gui/Surface.h
index 6f8a97c..72f1067 100644
--- a/include/gui/Surface.h
+++ b/include/gui/Surface.h
@@ -78,6 +78,37 @@
         return surface != NULL && surface->getIGraphicBufferProducer() != NULL;
     }
 
+    /* Attaches a sideband buffer stream to the Surface's IGraphicBufferProducer.
+     *
+     * A sideband stream is a device-specific mechanism for passing buffers
+     * from the producer to the consumer without using dequeueBuffer/
+     * queueBuffer. If a sideband stream is present, the consumer can choose
+     * whether to acquire buffers from the sideband stream or from the queued
+     * buffers.
+     *
+     * Passing NULL or a different stream handle will detach the previous
+     * handle if any.
+     */
+    void setSidebandStream(const sp<NativeHandle>& stream);
+
+    /* Allocates buffers based on the current dimensions/format.
+     *
+     * This function will allocate up to the maximum number of buffers
+     * permitted by the current BufferQueue configuration. It will use the
+     * default format and dimensions. This is most useful to avoid an allocation
+     * delay during dequeueBuffer. If there are already the maximum number of
+     * buffers allocated, this function has no effect.
+     */
+    void allocateBuffers();
+
+    /* Sets the generation number on the IGraphicBufferProducer and updates the
+     * generation number on any buffers attached to the Surface after this call.
+     * See IGBP::setGenerationNumber for more information. */
+    status_t setGenerationNumber(uint32_t generationNumber);
+
+    // See IGraphicBufferProducer::getConsumerName
+    String8 getConsumerName() const;
+
 protected:
     virtual ~Surface();
 
@@ -115,12 +146,16 @@
     int dispatchSetBuffersFormat(va_list args);
     int dispatchSetScalingMode(va_list args);
     int dispatchSetBuffersTransform(va_list args);
+    int dispatchSetBuffersStickyTransform(va_list args);
     int dispatchSetBuffersTimestamp(va_list args);
     int dispatchSetCrop(va_list args);
     int dispatchSetPostTransformCrop(va_list args);
     int dispatchSetUsage(va_list args);
     int dispatchLock(va_list args);
     int dispatchUnlockAndPost(va_list args);
+    int dispatchSetSidebandStream(va_list args);
+    int dispatchSetBuffersDataSpace(va_list args);
+    int dispatchSetSurfaceDamage(va_list args);
 
 protected:
     virtual int dequeueBuffer(ANativeWindowBuffer** buffer, int* fenceFd);
@@ -135,19 +170,27 @@
     virtual int connect(int api);
     virtual int disconnect(int api);
     virtual int setBufferCount(int bufferCount);
-    virtual int setBuffersDimensions(int w, int h);
-    virtual int setBuffersUserDimensions(int w, int h);
-    virtual int setBuffersFormat(int format);
+    virtual int setBuffersDimensions(uint32_t width, uint32_t height);
+    virtual int setBuffersUserDimensions(uint32_t width, uint32_t height);
+    virtual int setBuffersFormat(PixelFormat format);
     virtual int setScalingMode(int mode);
-    virtual int setBuffersTransform(int transform);
+    virtual int setBuffersTransform(uint32_t transform);
+    virtual int setBuffersStickyTransform(uint32_t transform);
     virtual int setBuffersTimestamp(int64_t timestamp);
+    virtual int setBuffersDataSpace(android_dataspace dataSpace);
     virtual int setCrop(Rect const* rect);
     virtual int setUsage(uint32_t reqUsage);
+    virtual void setSurfaceDamage(android_native_rect_t* rects, size_t numRects);
 
 public:
     virtual int lock(ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds);
     virtual int unlockAndPost();
 
+    virtual int connect(int api, const sp<IProducerListener>& listener);
+    virtual int detachNextBuffer(sp<GraphicBuffer>* outBuffer,
+            sp<Fence>* outFence);
+    virtual int attachBuffer(ANativeWindowBuffer*);
+
 protected:
     enum { NUM_BUFFER_SLOTS = BufferQueue::NUM_BUFFER_SLOTS };
     enum { DEFAULT_FORMAT = PIXEL_FORMAT_RGBA_8888 };
@@ -185,7 +228,7 @@
 
     // mReqFormat is the buffer pixel format that will be requested at the next
     // deuque operation. It is initialized to PIXEL_FORMAT_RGBA_8888.
-    uint32_t mReqFormat;
+    PixelFormat mReqFormat;
 
     // mReqUsage is the set of buffer usage flags that will be requested
     // at the next deuque operation. It is initialized to 0.
@@ -196,6 +239,11 @@
     // a timestamp is auto-generated when queueBuffer is called.
     int64_t mTimestamp;
 
+    // mDataSpace is the buffer dataSpace that will be used for the next buffer
+    // queue operation. It defaults to HAL_DATASPACE_UNKNOWN, which
+    // means that the buffer contains some type of color data.
+    android_dataspace mDataSpace;
+
     // mCrop is the crop rectangle that will be used for the next buffer
     // that gets queued. It is set by calling setCrop.
     Rect mCrop;
@@ -208,23 +256,29 @@
     // buffer that gets queued. It is set by calling setTransform.
     uint32_t mTransform;
 
-     // mDefaultWidth is default width of the buffers, regardless of the
-     // native_window_set_buffers_dimensions call.
-     uint32_t mDefaultWidth;
+    // mStickyTransform is a transform that is applied on top of mTransform
+    // in each buffer that is queued.  This is typically used to force the
+    // compositor to apply a transform, and will prevent the transform hint
+    // from being set by the compositor.
+    uint32_t mStickyTransform;
 
-     // mDefaultHeight is default height of the buffers, regardless of the
-     // native_window_set_buffers_dimensions call.
-     uint32_t mDefaultHeight;
+    // mDefaultWidth is default width of the buffers, regardless of the
+    // native_window_set_buffers_dimensions call.
+    uint32_t mDefaultWidth;
 
-     // mUserWidth, if non-zero, is an application-specified override
-     // of mDefaultWidth.  This is lower priority than the width set by
-     // native_window_set_buffers_dimensions.
-     uint32_t mUserWidth;
+    // mDefaultHeight is default height of the buffers, regardless of the
+    // native_window_set_buffers_dimensions call.
+    uint32_t mDefaultHeight;
 
-     // mUserHeight, if non-zero, is an application-specified override
-     // of mDefaultHeight.  This is lower priority than the height set
-     // by native_window_set_buffers_dimensions.
-     uint32_t mUserHeight;
+    // mUserWidth, if non-zero, is an application-specified override
+    // of mDefaultWidth.  This is lower priority than the width set by
+    // native_window_set_buffers_dimensions.
+    uint32_t mUserWidth;
+
+    // mUserHeight, if non-zero, is an application-specified override
+    // of mDefaultHeight.  This is lower priority than the height set
+    // by native_window_set_buffers_dimensions.
+    uint32_t mUserHeight;
 
     // mTransformHint is the transform probably applied to buffers of this
     // window. this is only a hint, actual transform may differ.
@@ -252,8 +306,17 @@
     sp<GraphicBuffer>           mPostedBuffer;
     bool                        mConnectedToCpu;
 
-    // must be accessed from lock/unlock thread only
+    // When a CPU producer is attached, this reflects the region that the
+    // producer wished to update as well as whether the Surface was able to copy
+    // the previous buffer back to allow a partial update.
+    //
+    // When a non-CPU producer is attached, this reflects the surface damage
+    // (the change since the previous frame) passed in by the producer.
     Region mDirtyRegion;
+
+    // Stores the current generation number. See setGenerationNumber and
+    // IGraphicBufferProducer::setGenerationNumber for more information.
+    uint32_t mGenerationNumber;
 };
 
 }; // namespace android
diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h
index e982bcd..37d953e 100644
--- a/include/gui/SurfaceComposerClient.h
+++ b/include/gui/SurfaceComposerClient.h
@@ -28,6 +28,7 @@
 #include <utils/SortedVector.h>
 #include <utils/threads.h>
 
+#include <ui/FrameStats.h>
 #include <ui/PixelFormat.h>
 
 #include <gui/CpuConsumer.h>
@@ -65,14 +66,24 @@
     status_t linkToComposerDeath(const sp<IBinder::DeathRecipient>& recipient,
             void* cookie = NULL, uint32_t flags = 0);
 
-    // Get information about a display
-    static status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info);
+    // Get a list of supported configurations for a given display
+    static status_t getDisplayConfigs(const sp<IBinder>& display,
+            Vector<DisplayInfo>* configs);
 
-    /* triggers screen off and waits for it to complete */
-    static void blankDisplay(const sp<IBinder>& display);
+    // Get the DisplayInfo for the currently-active configuration
+    static status_t getDisplayInfo(const sp<IBinder>& display,
+            DisplayInfo* info);
 
-    /* triggers screen on and waits for it to complete */
-    static void unblankDisplay(const sp<IBinder>& display);
+    // Get the index of the current active configuration (relative to the list
+    // returned by getDisplayInfo)
+    static int getActiveConfig(const sp<IBinder>& display);
+
+    // Set a new active configuration using an index relative to the list
+    // returned by getDisplayInfo
+    static status_t setActiveConfig(const sp<IBinder>& display, int id);
+
+    /* Triggers screen on/off or low power mode and waits for it to complete */
+    static void setDisplayPowerMode(const sp<IBinder>& display, int mode);
 
     // ------------------------------------------------------------------------
     // surface creation / destruction
@@ -116,7 +127,7 @@
     status_t    show(const sp<IBinder>& id);
     status_t    setFlags(const sp<IBinder>& id, uint32_t flags, uint32_t mask);
     status_t    setTransparentRegionHint(const sp<IBinder>& id, const Region& transparent);
-    status_t    setLayer(const sp<IBinder>& id, int32_t layer);
+    status_t    setLayer(const sp<IBinder>& id, uint32_t layer);
     status_t    setAlpha(const sp<IBinder>& id, float alpha=1.0f);
     status_t    setMatrix(const sp<IBinder>& id, float dsdx, float dtdx, float dsdy, float dtdy);
     status_t    setPosition(const sp<IBinder>& id, float x, float y);
@@ -125,10 +136,17 @@
     status_t    setLayerStack(const sp<IBinder>& id, uint32_t layerStack);
     status_t    destroySurface(const sp<IBinder>& id);
 
+    status_t clearLayerFrameStats(const sp<IBinder>& token) const;
+    status_t getLayerFrameStats(const sp<IBinder>& token, FrameStats* outStats) const;
+
+    static status_t clearAnimationFrameStats();
+    static status_t getAnimationFrameStats(FrameStats* outStats);
+
     static void setDisplaySurface(const sp<IBinder>& token,
             const sp<IGraphicBufferProducer>& bufferProducer);
     static void setDisplayLayerStack(const sp<IBinder>& token,
             uint32_t layerStack);
+    static void setDisplaySize(const sp<IBinder>& token, uint32_t width, uint32_t height);
 
     /* setDisplayProjection() defines the projection of layer stacks
      * to a given display.
@@ -160,15 +178,18 @@
 class ScreenshotClient
 {
 public:
+    // if cropping isn't required, callers may pass in a default Rect, e.g.:
+    //   capture(display, producer, Rect(), reqWidth, ...);
     static status_t capture(
             const sp<IBinder>& display,
             const sp<IGraphicBufferProducer>& producer,
-            uint32_t reqWidth, uint32_t reqHeight,
-            uint32_t minLayerZ, uint32_t maxLayerZ);
+            Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
+            uint32_t minLayerZ, uint32_t maxLayerZ,
+            bool useIdentityTransform);
 
 private:
     mutable sp<CpuConsumer> mCpuConsumer;
-    mutable sp<BufferQueue> mBufferQueue;
+    mutable sp<IGraphicBufferProducer> mProducer;
     CpuConsumer::LockedBuffer mBuffer;
     bool mHaveBuffer;
 
@@ -176,13 +197,22 @@
     ScreenshotClient();
     ~ScreenshotClient();
 
-    // frees the previous screenshot and capture a new one
-    status_t update(const sp<IBinder>& display);
+    // frees the previous screenshot and captures a new one
+    // if cropping isn't required, callers may pass in a default Rect, e.g.:
+    //   update(display, Rect(), useIdentityTransform);
     status_t update(const sp<IBinder>& display,
-            uint32_t reqWidth, uint32_t reqHeight);
+            Rect sourceCrop, bool useIdentityTransform);
     status_t update(const sp<IBinder>& display,
-            uint32_t reqWidth, uint32_t reqHeight,
-            uint32_t minLayerZ, uint32_t maxLayerZ);
+            Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
+            bool useIdentityTransform);
+    status_t update(const sp<IBinder>& display,
+            Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
+            uint32_t minLayerZ, uint32_t maxLayerZ,
+            bool useIdentityTransform);
+    status_t update(const sp<IBinder>& display,
+            Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
+            uint32_t minLayerZ, uint32_t maxLayerZ,
+            bool useIdentityTransform, uint32_t rotation);
 
     sp<CpuConsumer> getCpuConsumer() const;
 
diff --git a/include/gui/SurfaceControl.h b/include/gui/SurfaceControl.h
index f27754c..9f62f7c 100644
--- a/include/gui/SurfaceControl.h
+++ b/include/gui/SurfaceControl.h
@@ -24,6 +24,7 @@
 #include <utils/RefBase.h>
 #include <utils/threads.h>
 
+#include <ui/FrameStats.h>
 #include <ui/PixelFormat.h>
 #include <ui/Region.h>
 
@@ -52,12 +53,12 @@
 
     static bool isSameSurface(
             const sp<SurfaceControl>& lhs, const sp<SurfaceControl>& rhs);
-        
+
     // release surface data from java
     void        clear();
-    
-    status_t    setLayerStack(int32_t layerStack);
-    status_t    setLayer(int32_t layer);
+
+    status_t    setLayerStack(uint32_t layerStack);
+    status_t    setLayer(uint32_t layer);
     status_t    setPosition(float x, float y);
     status_t    setSize(uint32_t w, uint32_t h);
     status_t    hide();
@@ -73,6 +74,9 @@
 
     sp<Surface> getSurface() const;
 
+    status_t clearLayerFrameStats() const;
+    status_t getLayerFrameStats(FrameStats* outStats) const;
+
 private:
     // can't be copied
     SurfaceControl& operator = (SurfaceControl& rhs);
@@ -90,7 +94,7 @@
 
     status_t validate() const;
     void destroy();
-    
+
     sp<SurfaceComposerClient>   mClient;
     sp<IBinder>                 mHandle;
     sp<IGraphicBufferProducer>  mGraphicBufferProducer;
diff --git a/include/input/IInputFlinger.h b/include/input/IInputFlinger.h
new file mode 100644
index 0000000..629310f
--- /dev/null
+++ b/include/input/IInputFlinger.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _LIBINPUT_IINPUT_FLINGER_H
+#define _LIBINPUT_IINPUT_FLINGER_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <binder/IInterface.h>
+
+namespace android {
+
+/*
+ * This class defines the Binder IPC interface for accessing various
+ * InputFlinger features.
+ */
+class IInputFlinger : public IInterface {
+public:
+    DECLARE_META_INTERFACE(InputFlinger);
+};
+
+
+/**
+ * Binder implementation.
+ */
+class BnInputFlinger : public BnInterface<IInputFlinger> {
+public:
+    enum {
+        DO_SOMETHING_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
+    };
+
+    virtual status_t onTransact(uint32_t code, const Parcel& data,
+            Parcel* reply, uint32_t flags = 0);
+};
+
+} // namespace android
+
+#endif // _LIBINPUT_IINPUT_FLINGER_H
diff --git a/include/input/Input.h b/include/input/Input.h
index e778076..3b1c86b 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -22,11 +22,13 @@
  */
 
 #include <android/input.h>
-#include <utils/Vector.h>
+#include <utils/BitSet.h>
 #include <utils/KeyedVector.h>
-#include <utils/Timers.h>
 #include <utils/RefBase.h>
 #include <utils/String8.h>
+#include <utils/Timers.h>
+#include <utils/Vector.h>
+#include <stdint.h>
 
 /*
  * Additional private constants not defined in ndk/ui/input.h.
@@ -65,6 +67,34 @@
     AINPUT_SOURCE_SWITCH = 0x80000000,
 };
 
+enum {
+    /**
+     * Constants for LEDs. Hidden from the API since we don't actually expose a way to interact
+     * with LEDs to developers
+     *
+     * NOTE: If you add LEDs here, you must also add them to InputEventLabels.h
+     */
+
+    ALED_NUM_LOCK = 0x00,
+    ALED_CAPS_LOCK = 0x01,
+    ALED_SCROLL_LOCK = 0x02,
+    ALED_COMPOSE = 0x03,
+    ALED_KANA = 0x04,
+    ALED_SLEEP = 0x05,
+    ALED_SUSPEND = 0x06,
+    ALED_MUTE = 0x07,
+    ALED_MISC = 0x08,
+    ALED_MAIL = 0x09,
+    ALED_CHARGING = 0x0a,
+    ALED_CONTROLLER_1 = 0x10,
+    ALED_CONTROLLER_2 = 0x11,
+    ALED_CONTROLLER_3 = 0x12,
+    ALED_CONTROLLER_4 = 0x13,
+};
+
+/* Maximum number of controller LEDs we support */
+#define MAX_CONTROLLER_LEDS 4
+
 /*
  * SystemUiVisibility constants from View.
  */
@@ -82,6 +112,11 @@
 #define MAX_POINTERS 16
 
 /*
+ * Maximum number of samples supported per motion event.
+ */
+#define MAX_SAMPLES UINT16_MAX
+
+/*
  * Maximum pointer id value supported in a motion event.
  * Smallest pointer id is 0.
  * (This is limited by our use of BitSet32 to track pointer assignments.)
@@ -105,7 +140,7 @@
 
 namespace android {
 
-#ifdef HAVE_ANDROID_OS
+#ifdef __ANDROID__
 class Parcel;
 #endif
 
@@ -117,18 +152,24 @@
  */
 enum {
     /* These flags originate in RawEvents and are generally set in the key map.
-     * NOTE: If you edit these flags, also edit labels in KeycodeLabels.h. */
+     * NOTE: If you want a flag to be able to set in a keylayout file, then you must add it to
+     * InputEventLabels.h as well. */
 
+    // Indicates that the event should wake the device.
     POLICY_FLAG_WAKE = 0x00000001,
-    POLICY_FLAG_WAKE_DROPPED = 0x00000002,
-    POLICY_FLAG_SHIFT = 0x00000004,
-    POLICY_FLAG_CAPS_LOCK = 0x00000008,
-    POLICY_FLAG_ALT = 0x00000010,
-    POLICY_FLAG_ALT_GR = 0x00000020,
-    POLICY_FLAG_MENU = 0x00000040,
-    POLICY_FLAG_LAUNCHER = 0x00000080,
-    POLICY_FLAG_VIRTUAL = 0x00000100,
-    POLICY_FLAG_FUNCTION = 0x00000200,
+
+    // Indicates that the key is virtual, such as a capacitive button, and should
+    // generate haptic feedback.  Virtual keys may be suppressed for some time
+    // after a recent touch to prevent accidental activation of virtual keys adjacent
+    // to the touch screen during an edge swipe.
+    POLICY_FLAG_VIRTUAL = 0x00000002,
+
+    // Indicates that the key is the special function modifier.
+    POLICY_FLAG_FUNCTION = 0x00000004,
+
+    // Indicates that the key represents a special gesture that has been detected by
+    // the touch firmware or driver.  Causes touch events from the same device to be canceled.
+    POLICY_FLAG_GESTURE = 0x00000008,
 
     POLICY_FLAG_RAW_MASK = 0x0000ffff,
 
@@ -149,13 +190,9 @@
 
     /* These flags are set by the input reader policy as it intercepts each event. */
 
-    // Indicates that the screen was off when the event was received and the event
-    // should wake the device.
-    POLICY_FLAG_WOKE_HERE = 0x10000000,
-
-    // Indicates that the screen was dim when the event was received and the event
-    // should brighten the device.
-    POLICY_FLAG_BRIGHT_HERE = 0x20000000,
+    // Indicates that the device was in an interactive state when the
+    // event was intercepted.
+    POLICY_FLAG_INTERACTIVE = 0x20000000,
 
     // Indicates that the event should be dispatched to applications.
     // The input event should still be sent to the InputDispatcher so that it can see all
@@ -167,23 +204,28 @@
  * Pointer coordinate data.
  */
 struct PointerCoords {
-    enum { MAX_AXES = 14 }; // 14 so that sizeof(PointerCoords) == 64
+    enum { MAX_AXES = 30 }; // 30 so that sizeof(PointerCoords) == 128
 
     // Bitfield of axes that are present in this structure.
-    uint64_t bits;
+    uint64_t bits __attribute__((aligned(8)));
 
     // Values of axes that are stored in this structure packed in order by axis id
     // for each axis that is present in the structure according to 'bits'.
     float values[MAX_AXES];
 
     inline void clear() {
-        bits = 0;
+        BitSet64::clear(bits);
+    }
+
+    bool isEmpty() const {
+        return BitSet64::isEmpty(bits);
     }
 
     float getAxisValue(int32_t axis) const;
     status_t setAxisValue(int32_t axis, float value);
 
     void scale(float scale);
+    void applyOffset(float xOffset, float yOffset);
 
     inline float getX() const {
         return getAxisValue(AMOTION_EVENT_AXIS_X);
@@ -193,7 +235,7 @@
         return getAxisValue(AMOTION_EVENT_AXIS_Y);
     }
 
-#ifdef HAVE_ANDROID_OS
+#ifdef __ANDROID__
     status_t readFromParcel(Parcel* parcel);
     status_t writeToParcel(Parcel* parcel) const;
 #endif
@@ -282,13 +324,8 @@
 
     inline nsecs_t getEventTime() const { return mEventTime; }
 
-    // Return true if this event may have a default action implementation.
-    static bool hasDefaultAction(int32_t keyCode);
-    bool hasDefaultAction() const;
-
-    // Return true if this event represents a system key.
-    static bool isSystemKey(int32_t keyCode);
-    bool isSystemKey() const;
+    static const char* getLabel(int32_t keyCode);
+    static int32_t getKeyCodeFromLabel(const char* label);
     
     void initialize(
             int32_t deviceId,
@@ -348,6 +385,12 @@
 
     inline int32_t getButtonState() const { return mButtonState; }
 
+    inline int32_t setButtonState(int32_t buttonState) { mButtonState = buttonState; }
+
+    inline int32_t getActionButton() const { return mActionButton; }
+
+    inline void setActionButton(int32_t button) { mActionButton = button; }
+
     inline float getXOffset() const { return mXOffset; }
 
     inline float getYOffset() const { return mYOffset; }
@@ -501,6 +544,7 @@
             int32_t deviceId,
             int32_t source,
             int32_t action,
+            int32_t actionButton,
             int32_t flags,
             int32_t edgeFlags,
             int32_t metaState,
@@ -529,7 +573,7 @@
     // Matrix is in row-major form and compatible with SkMatrix.
     void transform(const float matrix[9]);
 
-#ifdef HAVE_ANDROID_OS
+#ifdef __ANDROID__
     status_t readFromParcel(Parcel* parcel);
     status_t writeToParcel(Parcel* parcel) const;
 #endif
@@ -548,8 +592,12 @@
             return mSamplePointerCoords.array();
     }
 
+    static const char* getLabel(int32_t axis);
+    static int32_t getAxisFromLabel(const char* label);
+
 protected:
     int32_t mAction;
+    int32_t mActionButton;
     int32_t mFlags;
     int32_t mEdgeFlags;
     int32_t mMetaState;
diff --git a/include/input/InputDevice.h b/include/input/InputDevice.h
index 1419b45..1ea69d3 100644
--- a/include/input/InputDevice.h
+++ b/include/input/InputDevice.h
@@ -46,6 +46,11 @@
     // Ideally, the way this value is computed should not change between Android releases
     // because that would invalidate persistent settings that rely on it.
     String8 descriptor;
+
+    // A value added to uniquely identify a device in the absence of a unique id. This
+    // is intended to be a minimum way to distinguish from other active devices and may
+    // reuse values that are not associated with an input anymore.
+    uint16_t nonce;
 };
 
 /*
@@ -68,7 +73,8 @@
     };
 
     void initialize(int32_t id, int32_t generation, int32_t controllerNumber,
-            const InputDeviceIdentifier& identifier, const String8& alias, bool isExternal);
+            const InputDeviceIdentifier& identifier, const String8& alias, bool isExternal,
+            bool hasMic);
 
     inline int32_t getId() const { return mId; }
     inline int32_t getControllerNumber() const { return mControllerNumber; }
@@ -79,6 +85,7 @@
         return mAlias.isEmpty() ? mIdentifier.name : mAlias;
     }
     inline bool isExternal() const { return mIsExternal; }
+    inline bool hasMic() const { return mHasMic; }
     inline uint32_t getSources() const { return mSources; }
 
     const MotionRange* getMotionRange(int32_t axis, uint32_t source) const;
@@ -116,6 +123,7 @@
     InputDeviceIdentifier mIdentifier;
     String8 mAlias;
     bool mIsExternal;
+    bool mHasMic;
     uint32_t mSources;
     int32_t mKeyboardType;
     sp<KeyCharacterMap> mKeyCharacterMap;
diff --git a/include/input/InputEventLabels.h b/include/input/InputEventLabels.h
new file mode 100644
index 0000000..f0a6238
--- /dev/null
+++ b/include/input/InputEventLabels.h
@@ -0,0 +1,446 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _LIBINPUT_INPUT_EVENT_LABELS_H
+#define _LIBINPUT_INPUT_EVENT_LABELS_H
+
+#include <input/Input.h>
+#include <android/keycodes.h>
+
+#define DEFINE_KEYCODE(key) { #key, AKEYCODE_##key }
+#define DEFINE_AXIS(axis) { #axis, AMOTION_EVENT_AXIS_##axis }
+#define DEFINE_LED(led) { #led, ALED_##led }
+#define DEFINE_FLAG(flag) { #flag, POLICY_FLAG_##flag }
+
+namespace android {
+
+template<typename T, size_t N>
+size_t size(T (&)[N]) { return N; }
+
+struct InputEventLabel {
+    const char *literal;
+    int value;
+};
+
+
+static const InputEventLabel KEYCODES[] = {
+    // NOTE: If you add a new keycode here you must also add it to several other files.
+    //       Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
+    DEFINE_KEYCODE(UNKNOWN),
+    DEFINE_KEYCODE(SOFT_LEFT),
+    DEFINE_KEYCODE(SOFT_RIGHT),
+    DEFINE_KEYCODE(HOME),
+    DEFINE_KEYCODE(BACK),
+    DEFINE_KEYCODE(CALL),
+    DEFINE_KEYCODE(ENDCALL),
+    DEFINE_KEYCODE(0),
+    DEFINE_KEYCODE(1),
+    DEFINE_KEYCODE(2),
+    DEFINE_KEYCODE(3),
+    DEFINE_KEYCODE(4),
+    DEFINE_KEYCODE(5),
+    DEFINE_KEYCODE(6),
+    DEFINE_KEYCODE(7),
+    DEFINE_KEYCODE(8),
+    DEFINE_KEYCODE(9),
+    DEFINE_KEYCODE(STAR),
+    DEFINE_KEYCODE(POUND),
+    DEFINE_KEYCODE(DPAD_UP),
+    DEFINE_KEYCODE(DPAD_DOWN),
+    DEFINE_KEYCODE(DPAD_LEFT),
+    DEFINE_KEYCODE(DPAD_RIGHT),
+    DEFINE_KEYCODE(DPAD_CENTER),
+    DEFINE_KEYCODE(VOLUME_UP),
+    DEFINE_KEYCODE(VOLUME_DOWN),
+    DEFINE_KEYCODE(POWER),
+    DEFINE_KEYCODE(CAMERA),
+    DEFINE_KEYCODE(CLEAR),
+    DEFINE_KEYCODE(A),
+    DEFINE_KEYCODE(B),
+    DEFINE_KEYCODE(C),
+    DEFINE_KEYCODE(D),
+    DEFINE_KEYCODE(E),
+    DEFINE_KEYCODE(F),
+    DEFINE_KEYCODE(G),
+    DEFINE_KEYCODE(H),
+    DEFINE_KEYCODE(I),
+    DEFINE_KEYCODE(J),
+    DEFINE_KEYCODE(K),
+    DEFINE_KEYCODE(L),
+    DEFINE_KEYCODE(M),
+    DEFINE_KEYCODE(N),
+    DEFINE_KEYCODE(O),
+    DEFINE_KEYCODE(P),
+    DEFINE_KEYCODE(Q),
+    DEFINE_KEYCODE(R),
+    DEFINE_KEYCODE(S),
+    DEFINE_KEYCODE(T),
+    DEFINE_KEYCODE(U),
+    DEFINE_KEYCODE(V),
+    DEFINE_KEYCODE(W),
+    DEFINE_KEYCODE(X),
+    DEFINE_KEYCODE(Y),
+    DEFINE_KEYCODE(Z),
+    DEFINE_KEYCODE(COMMA),
+    DEFINE_KEYCODE(PERIOD),
+    DEFINE_KEYCODE(ALT_LEFT),
+    DEFINE_KEYCODE(ALT_RIGHT),
+    DEFINE_KEYCODE(SHIFT_LEFT),
+    DEFINE_KEYCODE(SHIFT_RIGHT),
+    DEFINE_KEYCODE(TAB),
+    DEFINE_KEYCODE(SPACE),
+    DEFINE_KEYCODE(SYM),
+    DEFINE_KEYCODE(EXPLORER),
+    DEFINE_KEYCODE(ENVELOPE),
+    DEFINE_KEYCODE(ENTER),
+    DEFINE_KEYCODE(DEL),
+    DEFINE_KEYCODE(GRAVE),
+    DEFINE_KEYCODE(MINUS),
+    DEFINE_KEYCODE(EQUALS),
+    DEFINE_KEYCODE(LEFT_BRACKET),
+    DEFINE_KEYCODE(RIGHT_BRACKET),
+    DEFINE_KEYCODE(BACKSLASH),
+    DEFINE_KEYCODE(SEMICOLON),
+    DEFINE_KEYCODE(APOSTROPHE),
+    DEFINE_KEYCODE(SLASH),
+    DEFINE_KEYCODE(AT),
+    DEFINE_KEYCODE(NUM),
+    DEFINE_KEYCODE(HEADSETHOOK),
+    DEFINE_KEYCODE(FOCUS),   // *Camera* focus
+    DEFINE_KEYCODE(PLUS),
+    DEFINE_KEYCODE(MENU),
+    DEFINE_KEYCODE(NOTIFICATION),
+    DEFINE_KEYCODE(SEARCH),
+    DEFINE_KEYCODE(MEDIA_PLAY_PAUSE),
+    DEFINE_KEYCODE(MEDIA_STOP),
+    DEFINE_KEYCODE(MEDIA_NEXT),
+    DEFINE_KEYCODE(MEDIA_PREVIOUS),
+    DEFINE_KEYCODE(MEDIA_REWIND),
+    DEFINE_KEYCODE(MEDIA_FAST_FORWARD),
+    DEFINE_KEYCODE(MUTE),
+    DEFINE_KEYCODE(PAGE_UP),
+    DEFINE_KEYCODE(PAGE_DOWN),
+    DEFINE_KEYCODE(PICTSYMBOLS),
+    DEFINE_KEYCODE(SWITCH_CHARSET),
+    DEFINE_KEYCODE(BUTTON_A),
+    DEFINE_KEYCODE(BUTTON_B),
+    DEFINE_KEYCODE(BUTTON_C),
+    DEFINE_KEYCODE(BUTTON_X),
+    DEFINE_KEYCODE(BUTTON_Y),
+    DEFINE_KEYCODE(BUTTON_Z),
+    DEFINE_KEYCODE(BUTTON_L1),
+    DEFINE_KEYCODE(BUTTON_R1),
+    DEFINE_KEYCODE(BUTTON_L2),
+    DEFINE_KEYCODE(BUTTON_R2),
+    DEFINE_KEYCODE(BUTTON_THUMBL),
+    DEFINE_KEYCODE(BUTTON_THUMBR),
+    DEFINE_KEYCODE(BUTTON_START),
+    DEFINE_KEYCODE(BUTTON_SELECT),
+    DEFINE_KEYCODE(BUTTON_MODE),
+    DEFINE_KEYCODE(ESCAPE),
+    DEFINE_KEYCODE(FORWARD_DEL),
+    DEFINE_KEYCODE(CTRL_LEFT),
+    DEFINE_KEYCODE(CTRL_RIGHT),
+    DEFINE_KEYCODE(CAPS_LOCK),
+    DEFINE_KEYCODE(SCROLL_LOCK),
+    DEFINE_KEYCODE(META_LEFT),
+    DEFINE_KEYCODE(META_RIGHT),
+    DEFINE_KEYCODE(FUNCTION),
+    DEFINE_KEYCODE(SYSRQ),
+    DEFINE_KEYCODE(BREAK),
+    DEFINE_KEYCODE(MOVE_HOME),
+    DEFINE_KEYCODE(MOVE_END),
+    DEFINE_KEYCODE(INSERT),
+    DEFINE_KEYCODE(FORWARD),
+    DEFINE_KEYCODE(MEDIA_PLAY),
+    DEFINE_KEYCODE(MEDIA_PAUSE),
+    DEFINE_KEYCODE(MEDIA_CLOSE),
+    DEFINE_KEYCODE(MEDIA_EJECT),
+    DEFINE_KEYCODE(MEDIA_RECORD),
+    DEFINE_KEYCODE(F1),
+    DEFINE_KEYCODE(F2),
+    DEFINE_KEYCODE(F3),
+    DEFINE_KEYCODE(F4),
+    DEFINE_KEYCODE(F5),
+    DEFINE_KEYCODE(F6),
+    DEFINE_KEYCODE(F7),
+    DEFINE_KEYCODE(F8),
+    DEFINE_KEYCODE(F9),
+    DEFINE_KEYCODE(F10),
+    DEFINE_KEYCODE(F11),
+    DEFINE_KEYCODE(F12),
+    DEFINE_KEYCODE(NUM_LOCK),
+    DEFINE_KEYCODE(NUMPAD_0),
+    DEFINE_KEYCODE(NUMPAD_1),
+    DEFINE_KEYCODE(NUMPAD_2),
+    DEFINE_KEYCODE(NUMPAD_3),
+    DEFINE_KEYCODE(NUMPAD_4),
+    DEFINE_KEYCODE(NUMPAD_5),
+    DEFINE_KEYCODE(NUMPAD_6),
+    DEFINE_KEYCODE(NUMPAD_7),
+    DEFINE_KEYCODE(NUMPAD_8),
+    DEFINE_KEYCODE(NUMPAD_9),
+    DEFINE_KEYCODE(NUMPAD_DIVIDE),
+    DEFINE_KEYCODE(NUMPAD_MULTIPLY),
+    DEFINE_KEYCODE(NUMPAD_SUBTRACT),
+    DEFINE_KEYCODE(NUMPAD_ADD),
+    DEFINE_KEYCODE(NUMPAD_DOT),
+    DEFINE_KEYCODE(NUMPAD_COMMA),
+    DEFINE_KEYCODE(NUMPAD_ENTER),
+    DEFINE_KEYCODE(NUMPAD_EQUALS),
+    DEFINE_KEYCODE(NUMPAD_LEFT_PAREN),
+    DEFINE_KEYCODE(NUMPAD_RIGHT_PAREN),
+    DEFINE_KEYCODE(VOLUME_MUTE),
+    DEFINE_KEYCODE(INFO),
+    DEFINE_KEYCODE(CHANNEL_UP),
+    DEFINE_KEYCODE(CHANNEL_DOWN),
+    DEFINE_KEYCODE(ZOOM_IN),
+    DEFINE_KEYCODE(ZOOM_OUT),
+    DEFINE_KEYCODE(TV),
+    DEFINE_KEYCODE(WINDOW),
+    DEFINE_KEYCODE(GUIDE),
+    DEFINE_KEYCODE(DVR),
+    DEFINE_KEYCODE(BOOKMARK),
+    DEFINE_KEYCODE(CAPTIONS),
+    DEFINE_KEYCODE(SETTINGS),
+    DEFINE_KEYCODE(TV_POWER),
+    DEFINE_KEYCODE(TV_INPUT),
+    DEFINE_KEYCODE(STB_POWER),
+    DEFINE_KEYCODE(STB_INPUT),
+    DEFINE_KEYCODE(AVR_POWER),
+    DEFINE_KEYCODE(AVR_INPUT),
+    DEFINE_KEYCODE(PROG_RED),
+    DEFINE_KEYCODE(PROG_GREEN),
+    DEFINE_KEYCODE(PROG_YELLOW),
+    DEFINE_KEYCODE(PROG_BLUE),
+    DEFINE_KEYCODE(APP_SWITCH),
+    DEFINE_KEYCODE(BUTTON_1),
+    DEFINE_KEYCODE(BUTTON_2),
+    DEFINE_KEYCODE(BUTTON_3),
+    DEFINE_KEYCODE(BUTTON_4),
+    DEFINE_KEYCODE(BUTTON_5),
+    DEFINE_KEYCODE(BUTTON_6),
+    DEFINE_KEYCODE(BUTTON_7),
+    DEFINE_KEYCODE(BUTTON_8),
+    DEFINE_KEYCODE(BUTTON_9),
+    DEFINE_KEYCODE(BUTTON_10),
+    DEFINE_KEYCODE(BUTTON_11),
+    DEFINE_KEYCODE(BUTTON_12),
+    DEFINE_KEYCODE(BUTTON_13),
+    DEFINE_KEYCODE(BUTTON_14),
+    DEFINE_KEYCODE(BUTTON_15),
+    DEFINE_KEYCODE(BUTTON_16),
+    DEFINE_KEYCODE(LANGUAGE_SWITCH),
+    DEFINE_KEYCODE(MANNER_MODE),
+    DEFINE_KEYCODE(3D_MODE),
+    DEFINE_KEYCODE(CONTACTS),
+    DEFINE_KEYCODE(CALENDAR),
+    DEFINE_KEYCODE(MUSIC),
+    DEFINE_KEYCODE(CALCULATOR),
+    DEFINE_KEYCODE(ZENKAKU_HANKAKU),
+    DEFINE_KEYCODE(EISU),
+    DEFINE_KEYCODE(MUHENKAN),
+    DEFINE_KEYCODE(HENKAN),
+    DEFINE_KEYCODE(KATAKANA_HIRAGANA),
+    DEFINE_KEYCODE(YEN),
+    DEFINE_KEYCODE(RO),
+    DEFINE_KEYCODE(KANA),
+    DEFINE_KEYCODE(ASSIST),
+    DEFINE_KEYCODE(BRIGHTNESS_DOWN),
+    DEFINE_KEYCODE(BRIGHTNESS_UP),
+    DEFINE_KEYCODE(MEDIA_AUDIO_TRACK),
+    DEFINE_KEYCODE(SLEEP),
+    DEFINE_KEYCODE(WAKEUP),
+    DEFINE_KEYCODE(PAIRING),
+    DEFINE_KEYCODE(MEDIA_TOP_MENU),
+    DEFINE_KEYCODE(11),
+    DEFINE_KEYCODE(12),
+    DEFINE_KEYCODE(LAST_CHANNEL),
+    DEFINE_KEYCODE(TV_DATA_SERVICE),
+    DEFINE_KEYCODE(VOICE_ASSIST),
+    DEFINE_KEYCODE(TV_RADIO_SERVICE),
+    DEFINE_KEYCODE(TV_TELETEXT),
+    DEFINE_KEYCODE(TV_NUMBER_ENTRY),
+    DEFINE_KEYCODE(TV_TERRESTRIAL_ANALOG),
+    DEFINE_KEYCODE(TV_TERRESTRIAL_DIGITAL),
+    DEFINE_KEYCODE(TV_SATELLITE),
+    DEFINE_KEYCODE(TV_SATELLITE_BS),
+    DEFINE_KEYCODE(TV_SATELLITE_CS),
+    DEFINE_KEYCODE(TV_SATELLITE_SERVICE),
+    DEFINE_KEYCODE(TV_NETWORK),
+    DEFINE_KEYCODE(TV_ANTENNA_CABLE),
+    DEFINE_KEYCODE(TV_INPUT_HDMI_1),
+    DEFINE_KEYCODE(TV_INPUT_HDMI_2),
+    DEFINE_KEYCODE(TV_INPUT_HDMI_3),
+    DEFINE_KEYCODE(TV_INPUT_HDMI_4),
+    DEFINE_KEYCODE(TV_INPUT_COMPOSITE_1),
+    DEFINE_KEYCODE(TV_INPUT_COMPOSITE_2),
+    DEFINE_KEYCODE(TV_INPUT_COMPONENT_1),
+    DEFINE_KEYCODE(TV_INPUT_COMPONENT_2),
+    DEFINE_KEYCODE(TV_INPUT_VGA_1),
+    DEFINE_KEYCODE(TV_AUDIO_DESCRIPTION),
+    DEFINE_KEYCODE(TV_AUDIO_DESCRIPTION_MIX_UP),
+    DEFINE_KEYCODE(TV_AUDIO_DESCRIPTION_MIX_DOWN),
+    DEFINE_KEYCODE(TV_ZOOM_MODE),
+    DEFINE_KEYCODE(TV_CONTENTS_MENU),
+    DEFINE_KEYCODE(TV_MEDIA_CONTEXT_MENU),
+    DEFINE_KEYCODE(TV_TIMER_PROGRAMMING),
+    DEFINE_KEYCODE(HELP),
+    DEFINE_KEYCODE(NAVIGATE_PREVIOUS),
+    DEFINE_KEYCODE(NAVIGATE_NEXT),
+    DEFINE_KEYCODE(NAVIGATE_IN),
+    DEFINE_KEYCODE(NAVIGATE_OUT),
+    DEFINE_KEYCODE(STEM_PRIMARY),
+    DEFINE_KEYCODE(STEM_1),
+    DEFINE_KEYCODE(STEM_2),
+    DEFINE_KEYCODE(STEM_3),
+    DEFINE_KEYCODE(MEDIA_SKIP_FORWARD),
+    DEFINE_KEYCODE(MEDIA_SKIP_BACKWARD),
+    DEFINE_KEYCODE(MEDIA_STEP_FORWARD),
+    DEFINE_KEYCODE(MEDIA_STEP_BACKWARD),
+    DEFINE_KEYCODE(SOFT_SLEEP),
+
+    { NULL, 0 }
+};
+
+static const InputEventLabel AXES[] = {
+    DEFINE_AXIS(X),
+    DEFINE_AXIS(Y),
+    DEFINE_AXIS(PRESSURE),
+    DEFINE_AXIS(SIZE),
+    DEFINE_AXIS(TOUCH_MAJOR),
+    DEFINE_AXIS(TOUCH_MINOR),
+    DEFINE_AXIS(TOOL_MAJOR),
+    DEFINE_AXIS(TOOL_MINOR),
+    DEFINE_AXIS(ORIENTATION),
+    DEFINE_AXIS(VSCROLL),
+    DEFINE_AXIS(HSCROLL),
+    DEFINE_AXIS(Z),
+    DEFINE_AXIS(RX),
+    DEFINE_AXIS(RY),
+    DEFINE_AXIS(RZ),
+    DEFINE_AXIS(HAT_X),
+    DEFINE_AXIS(HAT_Y),
+    DEFINE_AXIS(LTRIGGER),
+    DEFINE_AXIS(RTRIGGER),
+    DEFINE_AXIS(THROTTLE),
+    DEFINE_AXIS(RUDDER),
+    DEFINE_AXIS(WHEEL),
+    DEFINE_AXIS(GAS),
+    DEFINE_AXIS(BRAKE),
+    DEFINE_AXIS(DISTANCE),
+    DEFINE_AXIS(TILT),
+    DEFINE_AXIS(GENERIC_1),
+    DEFINE_AXIS(GENERIC_2),
+    DEFINE_AXIS(GENERIC_3),
+    DEFINE_AXIS(GENERIC_4),
+    DEFINE_AXIS(GENERIC_5),
+    DEFINE_AXIS(GENERIC_6),
+    DEFINE_AXIS(GENERIC_7),
+    DEFINE_AXIS(GENERIC_8),
+    DEFINE_AXIS(GENERIC_9),
+    DEFINE_AXIS(GENERIC_10),
+    DEFINE_AXIS(GENERIC_11),
+    DEFINE_AXIS(GENERIC_12),
+    DEFINE_AXIS(GENERIC_13),
+    DEFINE_AXIS(GENERIC_14),
+    DEFINE_AXIS(GENERIC_15),
+    DEFINE_AXIS(GENERIC_16),
+
+    // NOTE: If you add a new axis here you must also add it to several other files.
+    //       Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
+    { NULL, 0 }
+};
+
+static const InputEventLabel LEDS[] = {
+    DEFINE_LED(NUM_LOCK),
+    DEFINE_LED(CAPS_LOCK),
+    DEFINE_LED(SCROLL_LOCK),
+    DEFINE_LED(COMPOSE),
+    DEFINE_LED(KANA),
+    DEFINE_LED(SLEEP),
+    DEFINE_LED(SUSPEND),
+    DEFINE_LED(MUTE),
+    DEFINE_LED(MISC),
+    DEFINE_LED(MAIL),
+    DEFINE_LED(CHARGING),
+    DEFINE_LED(CONTROLLER_1),
+    DEFINE_LED(CONTROLLER_2),
+    DEFINE_LED(CONTROLLER_3),
+    DEFINE_LED(CONTROLLER_4),
+
+    // NOTE: If you add new LEDs here, you must also add them to Input.h
+    { NULL, 0 }
+};
+
+static const InputEventLabel FLAGS[] = {
+    DEFINE_FLAG(VIRTUAL),
+    DEFINE_FLAG(FUNCTION),
+    DEFINE_FLAG(GESTURE),
+
+    { NULL, 0 }
+};
+
+static int lookupValueByLabel(const char* literal, const InputEventLabel *list) {
+    while (list->literal) {
+        if (strcmp(literal, list->literal) == 0) {
+            return list->value;
+        }
+        list++;
+    }
+    return list->value;
+}
+
+static const char* lookupLabelByValue(int value, const InputEventLabel* list) {
+    while (list->literal) {
+        if (list->value == value) {
+            return list->literal;
+        }
+        list++;
+    }
+    return NULL;
+}
+
+static int32_t getKeyCodeByLabel(const char* label) {
+    return int32_t(lookupValueByLabel(label, KEYCODES));
+}
+
+static const char* getLabelByKeyCode(int32_t keyCode) {
+    if (keyCode >= 0 && keyCode < size(KEYCODES)) {
+        return KEYCODES[keyCode].literal;
+    }
+    return NULL;
+}
+
+static uint32_t getKeyFlagByLabel(const char* label) {
+    return uint32_t(lookupValueByLabel(label, FLAGS));
+}
+
+static int32_t getAxisByLabel(const char* label) {
+    return int32_t(lookupValueByLabel(label, AXES));
+}
+
+static const char* getAxisLabel(int32_t axisId) {
+    return lookupLabelByValue(axisId, AXES);
+}
+
+static int32_t getLedByLabel(const char* label) {
+    return int32_t(lookupValueByLabel(label, LEDS));
+}
+
+
+} // namespace android
+#endif // _LIBINPUT_INPUT_EVENT_LABELS_H
diff --git a/include/input/InputTransport.h b/include/input/InputTransport.h
index 609b679..f31bcea 100644
--- a/include/input/InputTransport.h
+++ b/include/input/InputTransport.h
@@ -39,6 +39,9 @@
 
 /*
  * Intermediate representation used to send input events and related signals.
+ *
+ * Note that this structure is used for IPCs so its layout must be identical
+ * on 64 and 32 bit processes. This is tested in StructLayout_test.cpp.
  */
 struct InputMessage {
     enum {
@@ -49,13 +52,17 @@
 
     struct Header {
         uint32_t type;
-        uint32_t padding; // 8 byte alignment for the body that follows
+        // We don't need this field in order to align the body below but we
+        // leave it here because InputMessage::size() and other functions
+        // compute the size of this structure as sizeof(Header) + sizeof(Body).
+        uint32_t padding;
     } header;
 
+    // Body *must* be 8 byte aligned.
     union Body {
         struct Key {
             uint32_t seq;
-            nsecs_t eventTime;
+            nsecs_t eventTime __attribute__((aligned(8)));
             int32_t deviceId;
             int32_t source;
             int32_t action;
@@ -64,7 +71,7 @@
             int32_t scanCode;
             int32_t metaState;
             int32_t repeatCount;
-            nsecs_t downTime;
+            nsecs_t downTime __attribute__((aligned(8)));
 
             inline size_t size() const {
                 return sizeof(Key);
@@ -73,20 +80,22 @@
 
         struct Motion {
             uint32_t seq;
-            nsecs_t eventTime;
+            nsecs_t eventTime __attribute__((aligned(8)));
             int32_t deviceId;
             int32_t source;
             int32_t action;
+            int32_t actionButton;
             int32_t flags;
             int32_t metaState;
             int32_t buttonState;
             int32_t edgeFlags;
-            nsecs_t downTime;
+            nsecs_t downTime __attribute__((aligned(8)));
             float xOffset;
             float yOffset;
             float xPrecision;
             float yPrecision;
-            size_t pointerCount;
+            uint32_t pointerCount;
+            // Note that PointerCoords requires 8 byte alignment.
             struct Pointer {
                 PointerProperties properties;
                 PointerCoords coords;
@@ -112,7 +121,7 @@
                 return sizeof(Finished);
             }
         } finished;
-    } body;
+    } __attribute__((aligned(8))) body;
 
     bool isValid(size_t actualSize) const;
     size_t size() const;
@@ -224,6 +233,7 @@
             int32_t deviceId,
             int32_t source,
             int32_t action,
+            int32_t actionButton,
             int32_t flags,
             int32_t edgeFlags,
             int32_t metaState,
@@ -234,7 +244,7 @@
             float yPrecision,
             nsecs_t downTime,
             nsecs_t eventTime,
-            size_t pointerCount,
+            uint32_t pointerCount,
             const PointerProperties* pointerProperties,
             const PointerCoords* pointerCoords);
 
@@ -360,7 +370,7 @@
         void initializeFrom(const InputMessage* msg) {
             eventTime = msg->body.motion.eventTime;
             idBits.clear();
-            for (size_t i = 0; i < msg->body.motion.pointerCount; i++) {
+            for (uint32_t i = 0; i < msg->body.motion.pointerCount; i++) {
                 uint32_t id = msg->body.motion.pointers[i].properties.id;
                 idBits.markBit(id);
                 idToIndex[id] = i;
diff --git a/include/input/KeyCharacterMap.h b/include/input/KeyCharacterMap.h
index e70666a..eb5840e 100644
--- a/include/input/KeyCharacterMap.h
+++ b/include/input/KeyCharacterMap.h
@@ -19,7 +19,7 @@
 
 #include <stdint.h>
 
-#if HAVE_ANDROID_OS
+#ifdef __ANDROID__
 #include <binder/IBinder.h>
 #endif
 
@@ -124,7 +124,12 @@
      * the mapping in some way. */
     status_t mapKey(int32_t scanCode, int32_t usageCode, int32_t* outKeyCode) const;
 
-#if HAVE_ANDROID_OS
+    /* Tries to find a replacement key code for a given key code and meta state
+     * in character map. */
+    void tryRemapKey(int32_t scanCode, int32_t metaState,
+            int32_t* outKeyCode, int32_t* outMetaState) const;
+
+#ifdef __ANDROID__
     /* Reads a key map from a parcel. */
     static sp<KeyCharacterMap> readFromParcel(Parcel* parcel);
 
@@ -151,6 +156,9 @@
 
         /* The fallback keycode if the key is not handled. */
         int32_t fallbackKeyCode;
+
+        /* The replacement keycode if the key has to be replaced outright. */
+        int32_t replacementKeyCode;
     };
 
     struct Key {
diff --git a/include/input/KeyLayoutMap.h b/include/input/KeyLayoutMap.h
index eec11cf..1e8de71 100644
--- a/include/input/KeyLayoutMap.h
+++ b/include/input/KeyLayoutMap.h
@@ -67,6 +67,8 @@
     status_t mapKey(int32_t scanCode, int32_t usageCode,
             int32_t* outKeyCode, uint32_t* outFlags) const;
     status_t findScanCodesForKey(int32_t keyCode, Vector<int32_t>* outScanCodes) const;
+    status_t findScanCodeForLed(int32_t ledCode, int32_t* outScanCode) const;
+    status_t findUsageCodeForLed(int32_t ledCode, int32_t* outUsageCode) const;
 
     status_t mapAxis(int32_t scanCode, AxisInfo* outAxisInfo) const;
 
@@ -79,9 +81,16 @@
         uint32_t flags;
     };
 
+    struct Led {
+        int32_t ledCode;
+    };
+
+
     KeyedVector<int32_t, Key> mKeysByScanCode;
     KeyedVector<int32_t, Key> mKeysByUsageCode;
     KeyedVector<int32_t, AxisInfo> mAxes;
+    KeyedVector<int32_t, Led> mLedsByScanCode;
+    KeyedVector<int32_t, Led> mLedsByUsageCode;
 
     KeyLayoutMap();
 
@@ -99,6 +108,7 @@
     private:
         status_t parseKey();
         status_t parseAxis();
+        status_t parseLed();
     };
 };
 
diff --git a/include/input/Keyboard.h b/include/input/Keyboard.h
index 846cb0c..d4903e9 100644
--- a/include/input/Keyboard.h
+++ b/include/input/Keyboard.h
@@ -19,6 +19,7 @@
 
 #include <input/Input.h>
 #include <input/InputDevice.h>
+#include <input/InputEventLabels.h>
 #include <utils/Errors.h>
 #include <utils/String8.h>
 #include <utils/PropertyMap.h>
@@ -82,35 +83,18 @@
         const PropertyMap* deviceConfiguration, const KeyMap* keyMap);
 
 /**
- * Gets a key code by its short form label, eg. "HOME".
- * Returns 0 if unknown.
- */
-extern int32_t getKeyCodeByLabel(const char* label);
-
-/**
- * Gets a key flag by its short form label, eg. "WAKE".
- * Returns 0 if unknown.
- */
-extern uint32_t getKeyFlagByLabel(const char* label);
-
-/**
- * Gets a axis by its short form label, eg. "X".
- * Returns -1 if unknown.
- */
-extern int32_t getAxisByLabel(const char* label);
-
-/**
- * Gets a axis label by its id.
- * Returns NULL if unknown.
- */
-extern const char* getAxisLabel(int32_t axisId);
-
-/**
  * Updates a meta state field when a key is pressed or released.
  */
 extern int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState);
 
 /**
+ * Normalizes the meta state such that if either the left or right modifier
+ * meta state bits are set then the result will also include the universal
+ * bit for that modifier.
+ */
+extern int32_t normalizeMetaState(int32_t oldMetaState);
+
+/**
  * Returns true if a key is a meta key like ALT or CAPS_LOCK.
  */
 extern bool isMetaKey(int32_t keyCode);
diff --git a/include/input/KeycodeLabels.h b/include/input/KeycodeLabels.h
deleted file mode 100644
index c64c5d8..0000000
--- a/include/input/KeycodeLabels.h
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _LIBINPUT_KEYCODE_LABELS_H
-#define _LIBINPUT_KEYCODE_LABELS_H
-
-#include <android/keycodes.h>
-
-struct KeycodeLabel {
-    const char *literal;
-    int value;
-};
-
-static const KeycodeLabel KEYCODES[] = {
-    { "SOFT_LEFT", 1 },
-    { "SOFT_RIGHT", 2 },
-    { "HOME", 3 },
-    { "BACK", 4 },
-    { "CALL", 5 },
-    { "ENDCALL", 6 },
-    { "0", 7 },
-    { "1", 8 },
-    { "2", 9 },
-    { "3", 10 },
-    { "4", 11 },
-    { "5", 12 },
-    { "6", 13 },
-    { "7", 14 },
-    { "8", 15 },
-    { "9", 16 },
-    { "STAR", 17 },
-    { "POUND", 18 },
-    { "DPAD_UP", 19 },
-    { "DPAD_DOWN", 20 },
-    { "DPAD_LEFT", 21 },
-    { "DPAD_RIGHT", 22 },
-    { "DPAD_CENTER", 23 },
-    { "VOLUME_UP", 24 },
-    { "VOLUME_DOWN", 25 },
-    { "POWER", 26 },
-    { "CAMERA", 27 },
-    { "CLEAR", 28 },
-    { "A", 29 },
-    { "B", 30 },
-    { "C", 31 },
-    { "D", 32 },
-    { "E", 33 },
-    { "F", 34 },
-    { "G", 35 },
-    { "H", 36 },
-    { "I", 37 },
-    { "J", 38 },
-    { "K", 39 },
-    { "L", 40 },
-    { "M", 41 },
-    { "N", 42 },
-    { "O", 43 },
-    { "P", 44 },
-    { "Q", 45 },
-    { "R", 46 },
-    { "S", 47 },
-    { "T", 48 },
-    { "U", 49 },
-    { "V", 50 },
-    { "W", 51 },
-    { "X", 52 },
-    { "Y", 53 },
-    { "Z", 54 },
-    { "COMMA", 55 },
-    { "PERIOD", 56 },
-    { "ALT_LEFT", 57 },
-    { "ALT_RIGHT", 58 },
-    { "SHIFT_LEFT", 59 },
-    { "SHIFT_RIGHT", 60 },
-    { "TAB", 61 },
-    { "SPACE", 62 },
-    { "SYM", 63 },
-    { "EXPLORER", 64 },
-    { "ENVELOPE", 65 },
-    { "ENTER", 66 },
-    { "DEL", 67 },
-    { "GRAVE", 68 },
-    { "MINUS", 69 },
-    { "EQUALS", 70 },
-    { "LEFT_BRACKET", 71 },
-    { "RIGHT_BRACKET", 72 },
-    { "BACKSLASH", 73 },
-    { "SEMICOLON", 74 },
-    { "APOSTROPHE", 75 },
-    { "SLASH", 76 },
-    { "AT", 77 },
-    { "NUM", 78 },
-    { "HEADSETHOOK", 79 },
-    { "FOCUS", 80 },
-    { "PLUS", 81 },
-    { "MENU", 82 },
-    { "NOTIFICATION", 83 },
-    { "SEARCH", 84 },
-    { "MEDIA_PLAY_PAUSE", 85 },
-    { "MEDIA_STOP", 86 },
-    { "MEDIA_NEXT", 87 },
-    { "MEDIA_PREVIOUS", 88 },
-    { "MEDIA_REWIND", 89 },
-    { "MEDIA_FAST_FORWARD", 90 },
-    { "MUTE", 91 },
-    { "PAGE_UP", 92 },
-    { "PAGE_DOWN", 93 },
-    { "PICTSYMBOLS", 94 },
-    { "SWITCH_CHARSET", 95 },
-    { "BUTTON_A", 96 },
-    { "BUTTON_B", 97 },
-    { "BUTTON_C", 98 },
-    { "BUTTON_X", 99 },
-    { "BUTTON_Y", 100 },
-    { "BUTTON_Z", 101 },
-    { "BUTTON_L1", 102 },
-    { "BUTTON_R1", 103 },
-    { "BUTTON_L2", 104 },
-    { "BUTTON_R2", 105 },
-    { "BUTTON_THUMBL", 106 },
-    { "BUTTON_THUMBR", 107 },
-    { "BUTTON_START", 108 },
-    { "BUTTON_SELECT", 109 },
-    { "BUTTON_MODE", 110 },
-    { "ESCAPE", 111 },
-    { "FORWARD_DEL", 112 },
-    { "CTRL_LEFT", 113 },
-    { "CTRL_RIGHT", 114 },
-    { "CAPS_LOCK", 115 },
-    { "SCROLL_LOCK", 116 },
-    { "META_LEFT", 117 },
-    { "META_RIGHT", 118 },
-    { "FUNCTION", 119 },
-    { "SYSRQ", 120 },
-    { "BREAK", 121 },
-    { "MOVE_HOME", 122 },
-    { "MOVE_END", 123 },
-    { "INSERT", 124 },
-    { "FORWARD", 125 },
-    { "MEDIA_PLAY", 126 },
-    { "MEDIA_PAUSE", 127 },
-    { "MEDIA_CLOSE", 128 },
-    { "MEDIA_EJECT", 129 },
-    { "MEDIA_RECORD", 130 },
-    { "F1", 131 },
-    { "F2", 132 },
-    { "F3", 133 },
-    { "F4", 134 },
-    { "F5", 135 },
-    { "F6", 136 },
-    { "F7", 137 },
-    { "F8", 138 },
-    { "F9", 139 },
-    { "F10", 140 },
-    { "F11", 141 },
-    { "F12", 142 },
-    { "NUM_LOCK", 143 },
-    { "NUMPAD_0", 144 },
-    { "NUMPAD_1", 145 },
-    { "NUMPAD_2", 146 },
-    { "NUMPAD_3", 147 },
-    { "NUMPAD_4", 148 },
-    { "NUMPAD_5", 149 },
-    { "NUMPAD_6", 150 },
-    { "NUMPAD_7", 151 },
-    { "NUMPAD_8", 152 },
-    { "NUMPAD_9", 153 },
-    { "NUMPAD_DIVIDE", 154 },
-    { "NUMPAD_MULTIPLY", 155 },
-    { "NUMPAD_SUBTRACT", 156 },
-    { "NUMPAD_ADD", 157 },
-    { "NUMPAD_DOT", 158 },
-    { "NUMPAD_COMMA", 159 },
-    { "NUMPAD_ENTER", 160 },
-    { "NUMPAD_EQUALS", 161 },
-    { "NUMPAD_LEFT_PAREN", 162 },
-    { "NUMPAD_RIGHT_PAREN", 163 },
-    { "VOLUME_MUTE", 164 },
-    { "INFO", 165 },
-    { "CHANNEL_UP", 166 },
-    { "CHANNEL_DOWN", 167 },
-    { "ZOOM_IN", 168 },
-    { "ZOOM_OUT", 169 },
-    { "TV", 170 },
-    { "WINDOW", 171 },
-    { "GUIDE", 172 },
-    { "DVR", 173 },
-    { "BOOKMARK", 174 },
-    { "CAPTIONS", 175 },
-    { "SETTINGS", 176 },
-    { "TV_POWER", 177 },
-    { "TV_INPUT", 178 },
-    { "STB_POWER", 179 },
-    { "STB_INPUT", 180 },
-    { "AVR_POWER", 181 },
-    { "AVR_INPUT", 182 },
-    { "PROG_RED", 183 },
-    { "PROG_GREEN", 184 },
-    { "PROG_YELLOW", 185 },
-    { "PROG_BLUE", 186 },
-    { "APP_SWITCH", 187 },
-    { "BUTTON_1", 188 },
-    { "BUTTON_2", 189 },
-    { "BUTTON_3", 190 },
-    { "BUTTON_4", 191 },
-    { "BUTTON_5", 192 },
-    { "BUTTON_6", 193 },
-    { "BUTTON_7", 194 },
-    { "BUTTON_8", 195 },
-    { "BUTTON_9", 196 },
-    { "BUTTON_10", 197 },
-    { "BUTTON_11", 198 },
-    { "BUTTON_12", 199 },
-    { "BUTTON_13", 200 },
-    { "BUTTON_14", 201 },
-    { "BUTTON_15", 202 },
-    { "BUTTON_16", 203 },
-    { "LANGUAGE_SWITCH", 204 },
-    { "MANNER_MODE", 205 },
-    { "3D_MODE", 206 },
-    { "CONTACTS", 207 },
-    { "CALENDAR", 208 },
-    { "MUSIC", 209 },
-    { "CALCULATOR", 210 },
-    { "ZENKAKU_HANKAKU", 211 },
-    { "EISU", 212 },
-    { "MUHENKAN", 213 },
-    { "HENKAN", 214 },
-    { "KATAKANA_HIRAGANA", 215 },
-    { "YEN", 216 },
-    { "RO", 217 },
-    { "KANA", 218 },
-    { "ASSIST", 219 },
-    { "BRIGHTNESS_DOWN", 220 },
-    { "BRIGHTNESS_UP", 221 },
-    { "MEDIA_AUDIO_TRACK", 222 },
-
-    // NOTE: If you add a new keycode here you must also add it to several other files.
-    //       Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
-
-    { NULL, 0 }
-};
-
-// NOTE: If you edit these flags, also edit policy flags in Input.h.
-static const KeycodeLabel FLAGS[] = {
-    { "WAKE", 0x00000001 },
-    { "WAKE_DROPPED", 0x00000002 },
-    { "SHIFT", 0x00000004 },
-    { "CAPS_LOCK", 0x00000008 },
-    { "ALT", 0x00000010 },
-    { "ALT_GR", 0x00000020 },
-    { "MENU", 0x00000040 },
-    { "LAUNCHER", 0x00000080 },
-    { "VIRTUAL", 0x00000100 },
-    { "FUNCTION", 0x00000200 },
-    { NULL, 0 }
-};
-
-static const KeycodeLabel AXES[] = {
-    { "X", 0 },
-    { "Y", 1 },
-    { "PRESSURE", 2 },
-    { "SIZE", 3 },
-    { "TOUCH_MAJOR", 4 },
-    { "TOUCH_MINOR", 5 },
-    { "TOOL_MAJOR", 6 },
-    { "TOOL_MINOR", 7 },
-    { "ORIENTATION", 8 },
-    { "VSCROLL", 9 },
-    { "HSCROLL", 10 },
-    { "Z", 11 },
-    { "RX", 12 },
-    { "RY", 13 },
-    { "RZ", 14 },
-    { "HAT_X", 15 },
-    { "HAT_Y", 16 },
-    { "LTRIGGER", 17 },
-    { "RTRIGGER", 18 },
-    { "THROTTLE", 19 },
-    { "RUDDER", 20 },
-    { "WHEEL", 21 },
-    { "GAS", 22 },
-    { "BRAKE", 23 },
-    { "DISTANCE", 24 },
-    { "TILT", 25 },
-    { "GENERIC_1", 32 },
-    { "GENERIC_2", 33 },
-    { "GENERIC_3", 34 },
-    { "GENERIC_4", 35 },
-    { "GENERIC_5", 36 },
-    { "GENERIC_6", 37 },
-    { "GENERIC_7", 38 },
-    { "GENERIC_8", 39 },
-    { "GENERIC_9", 40 },
-    { "GENERIC_10", 41 },
-    { "GENERIC_11", 42 },
-    { "GENERIC_12", 43 },
-    { "GENERIC_13", 44 },
-    { "GENERIC_14", 45 },
-    { "GENERIC_15", 46 },
-    { "GENERIC_16", 47 },
-
-    // NOTE: If you add a new axis here you must also add it to several other files.
-    //       Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
-
-    { NULL, -1 }
-};
-
-#endif // _LIBINPUT_KEYCODE_LABELS_H
diff --git a/include/media/drm/DrmAPI.h b/include/media/drm/DrmAPI.h
index 95bdf77..272881b 100644
--- a/include/media/drm/DrmAPI.h
+++ b/include/media/drm/DrmAPI.h
@@ -80,7 +80,10 @@
             kDrmPluginEventProvisionRequired = 1,
             kDrmPluginEventKeyNeeded,
             kDrmPluginEventKeyExpired,
-            kDrmPluginEventVendorDefined
+            kDrmPluginEventVendorDefined,
+            kDrmPluginEventSessionReclaimed,
+            kDrmPluginEventExpirationUpdate,
+            kDrmPluginEventKeysChange,
         };
 
         // Drm keys can be for offline content or for online streaming.
@@ -93,6 +96,33 @@
             kKeyType_Release
         };
 
+        // Enumerate KeyRequestTypes to allow an app to determine the
+        // type of a key request returned from getKeyRequest.
+        enum KeyRequestType {
+            kKeyRequestType_Unknown,
+            kKeyRequestType_Initial,
+            kKeyRequestType_Renewal,
+            kKeyRequestType_Release
+        };
+
+        // Enumerate KeyStatusTypes which indicate the state of a key
+        enum KeyStatusType
+        {
+            kKeyStatusType_Usable,
+            kKeyStatusType_Expired,
+            kKeyStatusType_OutputNotAllowed,
+            kKeyStatusType_StatusPending,
+            kKeyStatusType_InternalError
+        };
+
+        // Used by sendKeysChange to report the usability status of each
+        // key to the app.
+        struct KeyStatus
+        {
+            Vector<uint8_t> mKeyId;
+            KeyStatusType mType;
+        };
+
         DrmPlugin() {}
         virtual ~DrmPlugin() {}
 
@@ -135,7 +165,8 @@
                           Vector<uint8_t> const &initData,
                           String8 const &mimeType, KeyType keyType,
                           KeyedVector<String8, String8> const &optionalParameters,
-                          Vector<uint8_t> &request, String8 &defaultUrl) = 0;
+                          Vector<uint8_t> &request, String8 &defaultUrl,
+                          KeyRequestType *keyRequestType) = 0;
 
         //
         // After a key response is received by the app, it is provided to the
@@ -178,12 +209,19 @@
         // provisioning server.
         //
         // If successful, the opaque provision request blob is returned to the caller.
-        virtual status_t getProvisionRequest(Vector<uint8_t> &request,
+        virtual status_t getProvisionRequest(String8 const &cert_type,
+                                             String8 const &cert_authority,
+                                             Vector<uint8_t> &request,
                                              String8 &defaultUrl) = 0;
 
         // After a provision response is received by the app, it is provided to the
         // Drm plugin using provideProvisionResponse.
-        virtual status_t provideProvisionResponse(Vector<uint8_t> const &response) = 0;
+        virtual status_t provideProvisionResponse(Vector<uint8_t> const &response,
+                                                  Vector<uint8_t> &certificate,
+                                                  Vector<uint8_t> &wrapped_key) = 0;
+
+        // Remove device provisioning.
+        virtual status_t unprovisionDevice() = 0;
 
         // A means of enforcing the contractual requirement for a concurrent stream
         // limit per subscriber across devices is provided via SecureStop.  SecureStop
@@ -202,7 +240,9 @@
         // confirmed. The persisted record on the client is only removed after positive
         // confirmation that the server received the message using releaseSecureStops().
         virtual status_t getSecureStops(List<Vector<uint8_t> > &secureStops) = 0;
+        virtual status_t getSecureStop(Vector<uint8_t> const &ssid, Vector<uint8_t> &secureStop) = 0;
         virtual status_t releaseSecureStops(Vector<uint8_t> const &ssRelease) = 0;
+        virtual status_t releaseAllSecureStops() = 0;
 
         // Read a property value given the device property string.  There are a few forms
         // of property access methods, depending on the data type returned.
@@ -290,6 +330,15 @@
                                 bool &match) = 0;
 
 
+        // Compute an RSA signature on the provided message using the algorithm
+        // specified by algorithm.
+        virtual status_t signRSA(Vector<uint8_t> const &sessionId,
+                                 String8 const &algorithm,
+                                 Vector<uint8_t> const &message,
+                                 Vector<uint8_t> const &wrapped_key,
+                                 Vector<uint8_t> &signature) = 0;
+
+
         status_t setListener(const sp<DrmPluginListener>& listener) {
             Mutex::Autolock lock(mEventLock);
             mListener = listener;
@@ -297,11 +346,18 @@
         }
 
     protected:
-        // Plugins call sendEvent to deliver events to the java app
+        // Plugins call these methods to deliver events to the java app
         void sendEvent(EventType eventType, int extra,
                        Vector<uint8_t> const *sessionId,
                        Vector<uint8_t> const *data);
 
+        void sendExpirationUpdate(Vector<uint8_t> const *sessionId,
+                                  int64_t expiryTimeInMS);
+
+        void sendKeysChange(Vector<uint8_t> const *sessionId,
+                            Vector<DrmPlugin::KeyStatus> const *keyStatusList,
+                            bool hasNewUsableKey);
+
     private:
         Mutex mEventLock;
         sp<DrmPluginListener> mListener;
@@ -313,14 +369,20 @@
     {
     public:
         virtual void sendEvent(DrmPlugin::EventType eventType, int extra,
-                               Vector<uint8_t> const *sesionId,
+                               Vector<uint8_t> const *sessionId,
                                Vector<uint8_t> const *data) = 0;
+
+        virtual void sendExpirationUpdate(Vector<uint8_t> const *sessionId,
+                                          int64_t expiryTimeInMS) = 0;
+
+        virtual void sendKeysChange(Vector<uint8_t> const *sessionId,
+                                    Vector<DrmPlugin::KeyStatus> const *keyStatusList,
+                                    bool hasNewUsableKey) = 0;
     };
 
     inline void DrmPlugin::sendEvent(EventType eventType, int extra,
                                      Vector<uint8_t> const *sessionId,
                                      Vector<uint8_t> const *data) {
-
         mEventLock.lock();
         sp<DrmPluginListener> listener = mListener;
         mEventLock.unlock();
@@ -330,6 +392,28 @@
         }
     }
 
+    inline void DrmPlugin::sendExpirationUpdate(Vector<uint8_t> const *sessionId,
+                                                int64_t expiryTimeInMS) {
+        mEventLock.lock();
+        sp<DrmPluginListener> listener = mListener;
+        mEventLock.unlock();
+
+        if (listener != NULL) {
+            listener->sendExpirationUpdate(sessionId, expiryTimeInMS);
+        }
+    }
+
+    inline void DrmPlugin::sendKeysChange(Vector<uint8_t> const *sessionId,
+                                          Vector<DrmPlugin::KeyStatus> const *keyStatusList,
+                                          bool hasNewUsableKey) {
+        mEventLock.lock();
+        sp<DrmPluginListener> listener = mListener;
+        mEventLock.unlock();
+
+        if (listener != NULL) {
+            listener->sendKeysChange(sessionId, keyStatusList, hasNewUsableKey);
+        }
+    }
 }  // namespace android
 
 #endif // DRM_API_H_
diff --git a/include/media/hardware/CryptoAPI.h b/include/media/hardware/CryptoAPI.h
index 44a0040..3e3257f 100644
--- a/include/media/hardware/CryptoAPI.h
+++ b/include/media/hardware/CryptoAPI.h
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
+#include <media/stagefright/MediaErrors.h>
 #include <utils/Errors.h>
+#include <utils/Vector.h>
 
 #ifndef CRYPTO_API_H_
 
@@ -51,8 +53,8 @@
     };
 
     struct SubSample {
-        size_t mNumBytesOfClearData;
-        size_t mNumBytesOfEncryptedData;
+        uint32_t mNumBytesOfClearData;
+        uint32_t mNumBytesOfEncryptedData;
     };
 
     CryptoPlugin() {}
@@ -64,6 +66,23 @@
     // media data of the given mime type.
     virtual bool requiresSecureDecoderComponent(const char *mime) const = 0;
 
+    // To implement resolution constraints, the crypto plugin needs to know
+    // the resolution of the video being decrypted.  The media player should
+    // call this method when the resolution is determined and any time it
+    // is subsequently changed.
+
+    virtual void notifyResolution(uint32_t /* width */, uint32_t /* height */) {}
+
+    // A MediaDrm session may be associated with a MediaCrypto session.  The
+    // associated MediaDrm session is used to load decryption keys
+    // into the crypto/drm plugin.  The keys are then referenced by key-id
+    // in the 'key' parameter to the decrypt() method.
+    // Should return NO_ERROR on success, ERROR_DRM_SESSION_NOT_OPENED if
+    // the session is not opened and a code from MediaErrors.h otherwise.
+    virtual status_t setMediaDrmSession(const Vector<uint8_t> & /*sessionId */) {
+        return ERROR_UNSUPPORTED;
+    }
+
     // If the error returned falls into the range
     // ERROR_DRM_VENDOR_MIN..ERROR_DRM_VENDOR_MAX, errorDetailMsg should be
     // filled in with an appropriate string.
diff --git a/include/media/hardware/HDCPAPI.h b/include/media/hardware/HDCPAPI.h
index d4abb3f..3a53e9f 100644
--- a/include/media/hardware/HDCPAPI.h
+++ b/include/media/hardware/HDCPAPI.h
@@ -88,6 +88,11 @@
     // Request to shutdown the active HDCP session.
     virtual status_t shutdownAsync() = 0;
 
+    // Returns the capability bitmask of this HDCP session.
+    virtual uint32_t getCaps() {
+        return HDCP_CAPS_ENCRYPT;
+    }
+
     // ENCRYPTION only:
     // Encrypt data according to the HDCP spec. "size" bytes of data are
     // available at "inData" (virtual address), "size" may not be a multiple
diff --git a/include/media/hardware/HardwareAPI.h b/include/media/hardware/HardwareAPI.h
index de3aeb1..1008c22 100644
--- a/include/media/hardware/HardwareAPI.h
+++ b/include/media/hardware/HardwareAPI.h
@@ -52,9 +52,9 @@
     OMX_BOOL enable;
 };
 
-// A pointer to this struct is passed to OMX_SetParameter() when the extension
-// index "OMX.google.android.index.storeMetaDataInBuffers"
-// is given.
+// A pointer to this struct is passed to OMX_SetParameter() when the extension index
+// "OMX.google.android.index.storeMetaDataInBuffers" or
+// "OMX.google.android.index.storeANWBufferInMetadata" is given.
 //
 // When meta data is stored in the video buffers passed between OMX clients
 // and OMX components, interpretation of the buffer data is up to the
@@ -62,19 +62,33 @@
 // some information helpful for the receiver to locate the actual data.
 // The buffer receiver thus needs to know how to interpret what is stored
 // in these buffers, with mechanisms pre-determined externally. How to
-// interpret the meta data is outside of the scope of this method.
+// interpret the meta data is outside of the scope of this parameter.
 //
-// Currently, this is specifically used to pass meta data from video source
-// (camera component, for instance) to video encoder to avoid memcpying of
-// input video frame data. To do this, bStoreMetaData is set to OMX_TRUE.
-// If bStoreMetaData is set to false, real YUV frame data will be stored
-// in the buffers. In addition, if no OMX_SetParameter() call is made
-// with the corresponding extension index, real YUV data is stored
-// in the buffers.
+// Currently, this is used to pass meta data from video source (camera component, for instance) to
+// video encoder to avoid memcpying of input video frame data, as well as to pass dynamic output
+// buffer to video decoder. To do this, bStoreMetaData is set to OMX_TRUE.
 //
-// For video decoder output port, the metadata buffer layout is defined below.
+// If bStoreMetaData is set to false, real YUV frame data will be stored in input buffers, and
+// the output buffers contain either real YUV frame data, or are themselves native handles as
+// directed by enable/use-android-native-buffer parameter settings.
+// In addition, if no OMX_SetParameter() call is made on a port with the corresponding extension
+// index, the component should not assume that the client is not using metadata mode for the port.
 //
-// Metadata buffers are registered with the component using UseBuffer calls.
+// If the component supports this using the "OMX.google.android.index.storeANWBufferInMetadata"
+// extension and bStoreMetaData is set to OMX_TRUE, data is passed using the VideoNativeMetadata
+// layout as defined below. Each buffer will be accompanied by a fence. The fence must signal
+// before the buffer can be used (e.g. read from or written into). When returning such buffer to
+// the client, component must provide a new fence that must signal before the returned buffer can
+// be used (e.g. read from or written into). The component owns the incoming fenceFd, and must close
+// it when fence has signaled. The client will own and close the returned fence file descriptor.
+//
+// If the component supports this using the "OMX.google.android.index.storeMetaDataInBuffers"
+// extension and bStoreMetaData is set to OMX_TRUE, data is passed using VideoGrallocMetadata
+// (the layout of which is the VideoGrallocMetadata defined below). Camera input can be also passed
+// as "CameraSource", the layout of which is vendor dependent.
+//
+// Metadata buffers are registered with the component using UseBuffer calls, or can be allocated
+// by the component for encoder-metadata-output buffers.
 struct StoreMetaDataInBuffersParams {
     OMX_U32 nSize;
     OMX_VERSIONTYPE nVersion;
@@ -84,9 +98,26 @@
 
 // Meta data buffer layout used to transport output frames to the decoder for
 // dynamic buffer handling.
-struct VideoDecoderOutputMetaData {
-  MetadataBufferType eType;
-  buffer_handle_t pHandle;
+struct VideoGrallocMetadata {
+    MetadataBufferType eType;               // must be kMetadataBufferTypeGrallocSource
+#ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
+    OMX_PTR pHandle;
+#else
+    buffer_handle_t pHandle;
+#endif
+};
+
+// Legacy name for VideoGrallocMetadata struct.
+struct VideoDecoderOutputMetaData : public VideoGrallocMetadata {};
+
+struct VideoNativeMetadata {
+    MetadataBufferType eType;               // must be kMetadataBufferTypeANWBuffer
+#ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
+    OMX_PTR pBuffer;
+#else
+    struct ANativeWindowBuffer* pBuffer;
+#endif
+    int nFenceFd;                           // -1 if unused
 };
 
 // A pointer to this struct is passed to OMX_SetParameter() when the extension
@@ -157,6 +188,99 @@
     OMX_BOOL bEnable;
 };
 
+// Structure describing a media image (frame)
+// Currently only supporting YUV
+struct MediaImage {
+    enum Type {
+        MEDIA_IMAGE_TYPE_UNKNOWN = 0,
+        MEDIA_IMAGE_TYPE_YUV,
+    };
+
+    enum PlaneIndex {
+        Y = 0,
+        U,
+        V,
+        MAX_NUM_PLANES
+    };
+
+    Type mType;
+    uint32_t mNumPlanes;              // number of planes
+    uint32_t mWidth;                  // width of largest plane (unpadded, as in nFrameWidth)
+    uint32_t mHeight;                 // height of largest plane (unpadded, as in nFrameHeight)
+    uint32_t mBitDepth;               // useable bit depth
+    struct PlaneInfo {
+        uint32_t mOffset;             // offset of first pixel of the plane in bytes
+                                      // from buffer offset
+        uint32_t mColInc;             // column increment in bytes
+        uint32_t mRowInc;             // row increment in bytes
+        uint32_t mHorizSubsampling;   // subsampling compared to the largest plane
+        uint32_t mVertSubsampling;    // subsampling compared to the largest plane
+    };
+    PlaneInfo mPlane[MAX_NUM_PLANES];
+};
+
+// A pointer to this struct is passed to OMX_GetParameter when the extension
+// index for the 'OMX.google.android.index.describeColorFormat'
+// extension is given.  This method can be called from any component state
+// other than invalid.  The color-format, frame width/height, and stride/
+// slice-height parameters are ones that are associated with a raw video
+// port (input or output), but the stride/slice height parameters may be
+// incorrect. bUsingNativeBuffers is OMX_TRUE if native android buffers will
+// be used (while specifying this color format).
+//
+// The component shall fill out the MediaImage structure that
+// corresponds to the described raw video format, and the potentially corrected
+// stride and slice-height info.
+//
+// The behavior is slightly different if bUsingNativeBuffers is OMX_TRUE,
+// though most implementations can ignore this difference. When using native buffers,
+// the component may change the configured color format to an optimized format.
+// Additionally, when allocating these buffers for flexible usecase, the framework
+// will set the SW_READ/WRITE_OFTEN usage flags. In this case (if bUsingNativeBuffers
+// is OMX_TRUE), the component shall fill out the MediaImage information for the
+// scenario when these SW-readable/writable buffers are locked using gralloc_lock.
+// Note, that these buffers may also be locked using gralloc_lock_ycbcr, which must
+// be supported for vendor-specific formats.
+//
+// For non-YUV packed planar/semiplanar image formats, or if bUsingNativeBuffers
+// is OMX_TRUE and the component does not support this color format with native
+// buffers, the component shall set mNumPlanes to 0, and mType to MEDIA_IMAGE_TYPE_UNKNOWN.
+struct DescribeColorFormatParams {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    // input: parameters from OMX_VIDEO_PORTDEFINITIONTYPE
+    OMX_COLOR_FORMATTYPE eColorFormat;
+    OMX_U32 nFrameWidth;
+    OMX_U32 nFrameHeight;
+    OMX_U32 nStride;
+    OMX_U32 nSliceHeight;
+    OMX_BOOL bUsingNativeBuffers;
+
+    // output: fill out the MediaImage fields
+    MediaImage sMediaImage;
+};
+
+// A pointer to this struct is passed to OMX_SetParameter or OMX_GetParameter
+// when the extension index for the
+// 'OMX.google.android.index.configureVideoTunnelMode' extension is  given.
+// If the extension is supported then tunneled playback mode should be supported
+// by the codec. If bTunneled is set to OMX_TRUE then the video decoder should
+// operate in "tunneled" mode and output its decoded frames directly to the
+// sink. In this case nAudioHwSync is the HW SYNC ID of the audio HAL Output
+// stream to sync the video with. If bTunneled is set to OMX_FALSE, "tunneled"
+// mode should be disabled and nAudioHwSync should be ignored.
+// OMX_GetParameter is used to query tunneling configuration. bTunneled should
+// return whether decoder is operating in tunneled mode, and if it is,
+// pSidebandWindow should contain the codec allocated sideband window handle.
+struct ConfigureVideoTunnelModeParams {
+    OMX_U32 nSize;              // IN
+    OMX_VERSIONTYPE nVersion;   // IN
+    OMX_U32 nPortIndex;         // IN
+    OMX_BOOL bTunneled;         // IN/OUT
+    OMX_U32 nAudioHwSync;       // IN
+    OMX_PTR pSidebandWindow;    // OUT
+};
+
 }  // namespace android
 
 extern android::OMXPluginBase *createOMXPlugin();
diff --git a/include/media/hardware/MetadataBufferType.h b/include/media/hardware/MetadataBufferType.h
index 4eaf8ac..b765203 100644
--- a/include/media/hardware/MetadataBufferType.h
+++ b/include/media/hardware/MetadataBufferType.h
@@ -77,11 +77,44 @@
      * GRalloc buffer. The encoder needs to interpret this GRalloc handle
      * and encode the frames.
      * --------------------------------------------------------------
-     * |  kMetadataBufferTypeGrallocSource | sizeof(buffer_handle_t) |
+     * |  kMetadataBufferTypeGrallocSource | buffer_handle_t buffer |
      * --------------------------------------------------------------
+     *
+     * See the VideoGrallocMetadata structure.
      */
     kMetadataBufferTypeGrallocSource = 1,
 
+    /*
+     * kMetadataBufferTypeGraphicBuffer is used to indicate that
+     * the payload of the metadata buffers can be interpreted as
+     * an ANativeWindowBuffer, and that a fence is provided.
+     *
+     * In this case, the metadata will have a byte stream that consists of three parts:
+     * 1. First, there is an integer indicating that the metadata
+     * contains an ANativeWindowBuffer (kMetadataBufferTypeANWBuffer)
+     * 2. This is followed by the pointer to the ANativeWindowBuffer.
+     * Codec must not free this buffer as it does not actually own this buffer.
+     * 3. Finally, there is an integer containing a fence file descriptor.
+     * The codec must wait on the fence before encoding or decoding into this
+     * buffer. When the buffer is returned, codec must replace this file descriptor
+     * with a new fence, that will be waited on before the buffer is replaced
+     * (encoder) or read (decoder).
+     * ---------------------------------
+     * |  kMetadataBufferTypeANWBuffer |
+     * ---------------------------------
+     * |  ANativeWindowBuffer *buffer  |
+     * ---------------------------------
+     * |  int fenceFd                  |
+     * ---------------------------------
+     *
+     * See the VideoNativeMetadata structure.
+     */
+    kMetadataBufferTypeANWBuffer = 2,
+
+    /* This value is used by framework, but is never used inside a metadata buffer  */
+    kMetadataBufferTypeInvalid = -1,
+
+
     // Add more here...
 
 } MetadataBufferType;
diff --git a/include/media/openmax/OMX_AsString.h b/include/media/openmax/OMX_AsString.h
new file mode 100644
index 0000000..ae8430d
--- /dev/null
+++ b/include/media/openmax/OMX_AsString.h
@@ -0,0 +1,947 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* NOTE: This file contains several sections for individual OMX include files.
+   Each section has its own include guard.  This file should be included AFTER
+   the OMX include files. */
+
+#ifdef OMX_Audio_h
+/* asString definitions if media/openmax/OMX_Audio.h was included */
+
+#ifndef AS_STRING_FOR_OMX_AUDIO_H
+#define AS_STRING_FOR_OMX_AUDIO_H
+
+inline static const char *asString(OMX_AUDIO_CODINGTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_AUDIO_CodingUnused:     return "Unused";      // unused
+        case OMX_AUDIO_CodingAutoDetect: return "AutoDetect";  // unused
+        case OMX_AUDIO_CodingPCM:        return "PCM";
+        case OMX_AUDIO_CodingADPCM:      return "ADPCM";       // unused
+        case OMX_AUDIO_CodingAMR:        return "AMR";
+        case OMX_AUDIO_CodingGSMFR:      return "GSMFR";
+        case OMX_AUDIO_CodingGSMEFR:     return "GSMEFR";      // unused
+        case OMX_AUDIO_CodingGSMHR:      return "GSMHR";       // unused
+        case OMX_AUDIO_CodingPDCFR:      return "PDCFR";       // unused
+        case OMX_AUDIO_CodingPDCEFR:     return "PDCEFR";      // unused
+        case OMX_AUDIO_CodingPDCHR:      return "PDCHR";       // unused
+        case OMX_AUDIO_CodingTDMAFR:     return "TDMAFR";      // unused
+        case OMX_AUDIO_CodingTDMAEFR:    return "TDMAEFR";     // unused
+        case OMX_AUDIO_CodingQCELP8:     return "QCELP8";      // unused
+        case OMX_AUDIO_CodingQCELP13:    return "QCELP13";     // unused
+        case OMX_AUDIO_CodingEVRC:       return "EVRC";        // unused
+        case OMX_AUDIO_CodingSMV:        return "SMV";         // unused
+        case OMX_AUDIO_CodingG711:       return "G711";
+        case OMX_AUDIO_CodingG723:       return "G723";        // unused
+        case OMX_AUDIO_CodingG726:       return "G726";        // unused
+        case OMX_AUDIO_CodingG729:       return "G729";        // unused
+        case OMX_AUDIO_CodingAAC:        return "AAC";
+        case OMX_AUDIO_CodingMP3:        return "MP3";
+        case OMX_AUDIO_CodingSBC:        return "SBC";         // unused
+        case OMX_AUDIO_CodingVORBIS:     return "VORBIS";
+        case OMX_AUDIO_CodingWMA:        return "WMA";         // unused
+        case OMX_AUDIO_CodingRA:         return "RA";          // unused
+        case OMX_AUDIO_CodingMIDI:       return "MIDI";        // unused
+        case OMX_AUDIO_CodingFLAC:       return "FLAC";
+        default:                         return def;
+    }
+}
+
+inline static const char *asString(OMX_AUDIO_PCMMODETYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_AUDIO_PCMModeLinear: return "Linear";
+        case OMX_AUDIO_PCMModeALaw:   return "ALaw";
+        case OMX_AUDIO_PCMModeMULaw:  return "MULaw";
+        default:                      return def;
+    }
+}
+
+inline static const char *asString(OMX_AUDIO_CHANNELTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_AUDIO_ChannelNone: return "None";  // unused
+        case OMX_AUDIO_ChannelLF:   return "LF";
+        case OMX_AUDIO_ChannelRF:   return "RF";
+        case OMX_AUDIO_ChannelCF:   return "CF";
+        case OMX_AUDIO_ChannelLS:   return "LS";
+        case OMX_AUDIO_ChannelRS:   return "RS";
+        case OMX_AUDIO_ChannelLFE:  return "LFE";
+        case OMX_AUDIO_ChannelCS:   return "CS";
+        case OMX_AUDIO_ChannelLR:   return "LR";
+        case OMX_AUDIO_ChannelRR:   return "RR";
+        default:                    return def;
+    }
+}
+
+inline static const char *asString(OMX_AUDIO_CHANNELMODETYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_AUDIO_ChannelModeStereo:      return "Stereo";
+//      case OMX_AUDIO_ChannelModeJointStereo: return "JointStereo";
+//      case OMX_AUDIO_ChannelModeDual:        return "Dual";
+        case OMX_AUDIO_ChannelModeMono:        return "Mono";
+        default:                               return def;
+    }
+}
+
+inline static const char *asString(OMX_AUDIO_AACSTREAMFORMATTYPE i, const char *def = "??") {
+    switch (i) {
+//      case OMX_AUDIO_AACStreamFormatMP2ADTS: return "MP2ADTS";
+        case OMX_AUDIO_AACStreamFormatMP4ADTS: return "MP4ADTS";
+//      case OMX_AUDIO_AACStreamFormatMP4LOAS: return "MP4LOAS";
+//      case OMX_AUDIO_AACStreamFormatMP4LATM: return "MP4LATM";
+//      case OMX_AUDIO_AACStreamFormatADIF:    return "ADIF";
+        case OMX_AUDIO_AACStreamFormatMP4FF:   return "MP4FF";
+//      case OMX_AUDIO_AACStreamFormatRAW:     return "RAW";
+        default:                               return def;
+    }
+}
+
+inline static const char *asString(OMX_AUDIO_AMRFRAMEFORMATTYPE i, const char *def = "??") {
+    switch (i) {
+//      case OMX_AUDIO_AMRFrameFormatConformance: return "Conformance";
+//      case OMX_AUDIO_AMRFrameFormatIF1:         return "IF1";
+//      case OMX_AUDIO_AMRFrameFormatIF2:         return "IF2";
+        case OMX_AUDIO_AMRFrameFormatFSF:         return "FSF";
+//      case OMX_AUDIO_AMRFrameFormatRTPPayload:  return "RTPPayload";
+//      case OMX_AUDIO_AMRFrameFormatITU:         return "ITU";
+        default:                                  return def;
+    }
+}
+
+inline static const char *asString(OMX_AUDIO_AMRBANDMODETYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_AUDIO_AMRBandModeUnused: return "Unused";
+        case OMX_AUDIO_AMRBandModeNB0:    return "NB0";
+        case OMX_AUDIO_AMRBandModeNB1:    return "NB1";
+        case OMX_AUDIO_AMRBandModeNB2:    return "NB2";
+        case OMX_AUDIO_AMRBandModeNB3:    return "NB3";
+        case OMX_AUDIO_AMRBandModeNB4:    return "NB4";
+        case OMX_AUDIO_AMRBandModeNB5:    return "NB5";
+        case OMX_AUDIO_AMRBandModeNB6:    return "NB6";
+        case OMX_AUDIO_AMRBandModeNB7:    return "NB7";
+        case OMX_AUDIO_AMRBandModeWB0:    return "WB0";
+        case OMX_AUDIO_AMRBandModeWB1:    return "WB1";
+        case OMX_AUDIO_AMRBandModeWB2:    return "WB2";
+        case OMX_AUDIO_AMRBandModeWB3:    return "WB3";
+        case OMX_AUDIO_AMRBandModeWB4:    return "WB4";
+        case OMX_AUDIO_AMRBandModeWB5:    return "WB5";
+        case OMX_AUDIO_AMRBandModeWB6:    return "WB6";
+        case OMX_AUDIO_AMRBandModeWB7:    return "WB7";
+        case OMX_AUDIO_AMRBandModeWB8:    return "WB8";
+        default:                          return def;
+    }
+}
+
+inline static const char *asString(OMX_AUDIO_AMRDTXMODETYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_AUDIO_AMRDTXModeOff:    return "ModeOff";
+//      case OMX_AUDIO_AMRDTXModeOnVAD1: return "ModeOnVAD1";
+//      case OMX_AUDIO_AMRDTXModeOnVAD2: return "ModeOnVAD2";
+//      case OMX_AUDIO_AMRDTXModeOnAuto: return "ModeOnAuto";
+//      case OMX_AUDIO_AMRDTXasEFR:      return "asEFR";
+        default:                         return def;
+    }
+}
+
+#endif // AS_STRING_FOR_OMX_AUDIO_H
+
+#endif // OMX_Audio_h
+
+#ifdef OMX_AudioExt_h
+/* asString definitions if media/openmax/OMX_AudioExt.h was included */
+
+#ifndef AS_STRING_FOR_OMX_AUDIOEXT_H
+#define AS_STRING_FOR_OMX_AUDIOEXT_H
+
+inline static const char *asString(OMX_AUDIO_CODINGEXTTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_AUDIO_CodingAndroidAC3:  return "AndroidAC3";
+        case OMX_AUDIO_CodingAndroidOPUS: return "AndroidOPUS";
+        default:                          return asString((OMX_AUDIO_CODINGTYPE)i, def);
+    }
+}
+
+#endif // AS_STRING_FOR_OMX_AUDIOEXT_H
+
+#endif // OMX_AudioExt_h
+
+#ifdef OMX_Component_h
+/* asString definitions if media/openmax/OMX_Component.h was included */
+
+#ifndef AS_STRING_FOR_OMX_COMPONENT_H
+#define AS_STRING_FOR_OMX_COMPONENT_H
+
+inline static const char *asString(OMX_PORTDOMAINTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_PortDomainAudio: return "Audio";
+        case OMX_PortDomainVideo: return "Video";
+        case OMX_PortDomainImage: return "Image";
+//      case OMX_PortDomainOther: return "Other";
+        default:                  return def;
+    }
+}
+
+#endif // AS_STRING_FOR_OMX_COMPONENT_H
+
+#endif // OMX_Component_h
+
+#ifdef OMX_Core_h
+/* asString definitions if media/openmax/OMX_Core.h was included */
+
+#ifndef AS_STRING_FOR_OMX_CORE_H
+#define AS_STRING_FOR_OMX_CORE_H
+
+inline static const char *asString(OMX_COMMANDTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_CommandStateSet:    return "StateSet";
+        case OMX_CommandFlush:       return "Flush";
+        case OMX_CommandPortDisable: return "PortDisable";
+        case OMX_CommandPortEnable:  return "PortEnable";
+//      case OMX_CommandMarkBuffer:  return "MarkBuffer";
+        default:                     return def;
+    }
+}
+
+inline static const char *asString(OMX_STATETYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_StateInvalid:          return "Invalid";
+        case OMX_StateLoaded:           return "Loaded";
+        case OMX_StateIdle:             return "Idle";
+        case OMX_StateExecuting:        return "Executing";
+//      case OMX_StatePause:            return "Pause";
+//      case OMX_StateWaitForResources: return "WaitForResources";
+        default:                        return def;
+    }
+}
+
+inline static const char *asString(OMX_ERRORTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_ErrorNone:                               return "None";
+        case OMX_ErrorInsufficientResources:              return "InsufficientResources";
+        case OMX_ErrorUndefined:                          return "Undefined";
+        case OMX_ErrorInvalidComponentName:               return "InvalidComponentName";
+        case OMX_ErrorComponentNotFound:                  return "ComponentNotFound";
+        case OMX_ErrorInvalidComponent:                   return "InvalidComponent";       // unused
+        case OMX_ErrorBadParameter:                       return "BadParameter";
+        case OMX_ErrorNotImplemented:                     return "NotImplemented";
+        case OMX_ErrorUnderflow:                          return "Underflow";              // unused
+        case OMX_ErrorOverflow:                           return "Overflow";               // unused
+        case OMX_ErrorHardware:                           return "Hardware";               // unused
+        case OMX_ErrorInvalidState:                       return "InvalidState";
+        case OMX_ErrorStreamCorrupt:                      return "StreamCorrupt";
+        case OMX_ErrorPortsNotCompatible:                 return "PortsNotCompatible";     // unused
+        case OMX_ErrorResourcesLost:                      return "ResourcesLost";
+        case OMX_ErrorNoMore:                             return "NoMore";
+        case OMX_ErrorVersionMismatch:                    return "VersionMismatch";        // unused
+        case OMX_ErrorNotReady:                           return "NotReady";               // unused
+        case OMX_ErrorTimeout:                            return "Timeout";                // unused
+        case OMX_ErrorSameState:                          return "SameState";              // unused
+        case OMX_ErrorResourcesPreempted:                 return "ResourcesPreempted";     // unused
+        case OMX_ErrorPortUnresponsiveDuringAllocation:
+            return "PortUnresponsiveDuringAllocation";    // unused
+        case OMX_ErrorPortUnresponsiveDuringDeallocation:
+            return "PortUnresponsiveDuringDeallocation";  // unused
+        case OMX_ErrorPortUnresponsiveDuringStop:
+            return "PortUnresponsiveDuringStop";          // unused
+        case OMX_ErrorIncorrectStateTransition:
+            return "IncorrectStateTransition";            // unused
+        case OMX_ErrorIncorrectStateOperation:
+            return "IncorrectStateOperation";             // unused
+        case OMX_ErrorUnsupportedSetting:                 return "UnsupportedSetting";
+        case OMX_ErrorUnsupportedIndex:                   return "UnsupportedIndex";
+        case OMX_ErrorBadPortIndex:                       return "BadPortIndex";
+        case OMX_ErrorPortUnpopulated:                    return "PortUnpopulated";        // unused
+        case OMX_ErrorComponentSuspended:                 return "ComponentSuspended";     // unused
+        case OMX_ErrorDynamicResourcesUnavailable:
+            return "DynamicResourcesUnavailable";         // unused
+        case OMX_ErrorMbErrorsInFrame:                    return "MbErrorsInFrame";        // unused
+        case OMX_ErrorFormatNotDetected:                  return "FormatNotDetected";      // unused
+        case OMX_ErrorContentPipeOpenFailed:              return "ContentPipeOpenFailed";  // unused
+        case OMX_ErrorContentPipeCreationFailed:
+            return "ContentPipeCreationFailed";           // unused
+        case OMX_ErrorSeperateTablesUsed:                 return "SeperateTablesUsed";     // unused
+        case OMX_ErrorTunnelingUnsupported:               return "TunnelingUnsupported";   // unused
+        default:                                          return def;
+    }
+}
+
+inline static const char *asString(OMX_EVENTTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_EventCmdComplete:               return "CmdComplete";
+        case OMX_EventError:                     return "Error";
+//      case OMX_EventMark:                      return "Mark";
+        case OMX_EventPortSettingsChanged:       return "PortSettingsChanged";
+        case OMX_EventBufferFlag:                return "BufferFlag";
+//      case OMX_EventResourcesAcquired:         return "ResourcesAcquired";
+//      case OMX_EventComponentResumed:          return "ComponentResumed";
+//      case OMX_EventDynamicResourcesAvailable: return "DynamicResourcesAvailable";
+//      case OMX_EventPortFormatDetected:        return "PortFormatDetected";
+        case OMX_EventOutputRendered:            return "OutputRendered";
+        default:                                 return def;
+    }
+}
+
+#endif // AS_STRING_FOR_OMX_CORE_H
+
+#endif // OMX_Core_h
+
+#ifdef OMX_Image_h
+/* asString definitions if media/openmax/OMX_Image.h was included */
+
+#ifndef AS_STRING_FOR_OMX_IMAGE_H
+#define AS_STRING_FOR_OMX_IMAGE_H
+
+inline static const char *asString(OMX_IMAGE_CODINGTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_IMAGE_CodingUnused:     return "Unused";
+        case OMX_IMAGE_CodingAutoDetect: return "AutoDetect";  // unused
+        case OMX_IMAGE_CodingJPEG:       return "JPEG";
+        case OMX_IMAGE_CodingJPEG2K:     return "JPEG2K";      // unused
+        case OMX_IMAGE_CodingEXIF:       return "EXIF";        // unused
+        case OMX_IMAGE_CodingTIFF:       return "TIFF";        // unused
+        case OMX_IMAGE_CodingGIF:        return "GIF";         // unused
+        case OMX_IMAGE_CodingPNG:        return "PNG";         // unused
+        case OMX_IMAGE_CodingLZW:        return "LZW";         // unused
+        case OMX_IMAGE_CodingBMP:        return "BMP";         // unused
+        default:                         return def;
+    }
+}
+
+#endif // AS_STRING_FOR_OMX_IMAGE_H
+
+#endif // OMX_Image_h
+
+#ifdef OMX_Index_h
+/* asString definitions if media/openmax/OMX_Index.h was included */
+
+#ifndef AS_STRING_FOR_OMX_INDEX_H
+#define AS_STRING_FOR_OMX_INDEX_H
+
+inline static const char *asString(OMX_INDEXTYPE i, const char *def = "??") {
+    switch (i) {
+//      case OMX_IndexParamPriorityMgmt:                    return "ParamPriorityMgmt";
+//      case OMX_IndexParamAudioInit:                       return "ParamAudioInit";
+//      case OMX_IndexParamImageInit:                       return "ParamImageInit";
+//      case OMX_IndexParamVideoInit:                       return "ParamVideoInit";
+//      case OMX_IndexParamOtherInit:                       return "ParamOtherInit";
+//      case OMX_IndexParamNumAvailableStreams:             return "ParamNumAvailableStreams";
+//      case OMX_IndexParamActiveStream:                    return "ParamActiveStream";
+//      case OMX_IndexParamSuspensionPolicy:                return "ParamSuspensionPolicy";
+//      case OMX_IndexParamComponentSuspended:              return "ParamComponentSuspended";
+//      case OMX_IndexConfigCapturing:                      return "ConfigCapturing";
+//      case OMX_IndexConfigCaptureMode:                    return "ConfigCaptureMode";
+//      case OMX_IndexAutoPauseAfterCapture:                return "AutoPauseAfterCapture";
+//      case OMX_IndexParamContentURI:                      return "ParamContentURI";
+//      case OMX_IndexParamCustomContentPipe:               return "ParamCustomContentPipe";
+//      case OMX_IndexParamDisableResourceConcealment:
+//          return "ParamDisableResourceConcealment";
+//      case OMX_IndexConfigMetadataItemCount:              return "ConfigMetadataItemCount";
+//      case OMX_IndexConfigContainerNodeCount:             return "ConfigContainerNodeCount";
+//      case OMX_IndexConfigMetadataItem:                   return "ConfigMetadataItem";
+//      case OMX_IndexConfigCounterNodeID:                  return "ConfigCounterNodeID";
+//      case OMX_IndexParamMetadataFilterType:              return "ParamMetadataFilterType";
+//      case OMX_IndexParamMetadataKeyFilter:               return "ParamMetadataKeyFilter";
+//      case OMX_IndexConfigPriorityMgmt:                   return "ConfigPriorityMgmt";
+        case OMX_IndexParamStandardComponentRole:           return "ParamStandardComponentRole";
+        case OMX_IndexParamPortDefinition:                  return "ParamPortDefinition";
+//      case OMX_IndexParamCompBufferSupplier:              return "ParamCompBufferSupplier";
+        case OMX_IndexParamAudioPortFormat:                 return "ParamAudioPortFormat";
+        case OMX_IndexParamAudioPcm:                        return "ParamAudioPcm";
+        case OMX_IndexParamAudioAac:                        return "ParamAudioAac";
+//      case OMX_IndexParamAudioRa:                         return "ParamAudioRa";
+        case OMX_IndexParamAudioMp3:                        return "ParamAudioMp3";
+//      case OMX_IndexParamAudioAdpcm:                      return "ParamAudioAdpcm";
+//      case OMX_IndexParamAudioG723:                       return "ParamAudioG723";
+//      case OMX_IndexParamAudioG729:                       return "ParamAudioG729";
+        case OMX_IndexParamAudioAmr:                        return "ParamAudioAmr";
+//      case OMX_IndexParamAudioWma:                        return "ParamAudioWma";
+//      case OMX_IndexParamAudioSbc:                        return "ParamAudioSbc";
+//      case OMX_IndexParamAudioMidi:                       return "ParamAudioMidi";
+//      case OMX_IndexParamAudioGsm_FR:                     return "ParamAudioGsm_FR";
+//      case OMX_IndexParamAudioMidiLoadUserSound:          return "ParamAudioMidiLoadUserSound";
+//      case OMX_IndexParamAudioG726:                       return "ParamAudioG726";
+//      case OMX_IndexParamAudioGsm_EFR:                    return "ParamAudioGsm_EFR";
+//      case OMX_IndexParamAudioGsm_HR:                     return "ParamAudioGsm_HR";
+//      case OMX_IndexParamAudioPdc_FR:                     return "ParamAudioPdc_FR";
+//      case OMX_IndexParamAudioPdc_EFR:                    return "ParamAudioPdc_EFR";
+//      case OMX_IndexParamAudioPdc_HR:                     return "ParamAudioPdc_HR";
+//      case OMX_IndexParamAudioTdma_FR:                    return "ParamAudioTdma_FR";
+//      case OMX_IndexParamAudioTdma_EFR:                   return "ParamAudioTdma_EFR";
+//      case OMX_IndexParamAudioQcelp8:                     return "ParamAudioQcelp8";
+//      case OMX_IndexParamAudioQcelp13:                    return "ParamAudioQcelp13";
+//      case OMX_IndexParamAudioEvrc:                       return "ParamAudioEvrc";
+//      case OMX_IndexParamAudioSmv:                        return "ParamAudioSmv";
+        case OMX_IndexParamAudioVorbis:                     return "ParamAudioVorbis";
+        case OMX_IndexParamAudioFlac:                       return "ParamAudioFlac";
+//      case OMX_IndexConfigAudioMidiImmediateEvent:        return "ConfigAudioMidiImmediateEvent";
+//      case OMX_IndexConfigAudioMidiControl:               return "ConfigAudioMidiControl";
+//      case OMX_IndexConfigAudioMidiSoundBankProgram:
+//          return "ConfigAudioMidiSoundBankProgram";
+//      case OMX_IndexConfigAudioMidiStatus:                return "ConfigAudioMidiStatus";
+//      case OMX_IndexConfigAudioMidiMetaEvent:             return "ConfigAudioMidiMetaEvent";
+//      case OMX_IndexConfigAudioMidiMetaEventData:         return "ConfigAudioMidiMetaEventData";
+//      case OMX_IndexConfigAudioVolume:                    return "ConfigAudioVolume";
+//      case OMX_IndexConfigAudioBalance:                   return "ConfigAudioBalance";
+//      case OMX_IndexConfigAudioChannelMute:               return "ConfigAudioChannelMute";
+//      case OMX_IndexConfigAudioMute:                      return "ConfigAudioMute";
+//      case OMX_IndexConfigAudioLoudness:                  return "ConfigAudioLoudness";
+//      case OMX_IndexConfigAudioEchoCancelation:           return "ConfigAudioEchoCancelation";
+//      case OMX_IndexConfigAudioNoiseReduction:            return "ConfigAudioNoiseReduction";
+//      case OMX_IndexConfigAudioBass:                      return "ConfigAudioBass";
+//      case OMX_IndexConfigAudioTreble:                    return "ConfigAudioTreble";
+//      case OMX_IndexConfigAudioStereoWidening:            return "ConfigAudioStereoWidening";
+//      case OMX_IndexConfigAudioChorus:                    return "ConfigAudioChorus";
+//      case OMX_IndexConfigAudioEqualizer:                 return "ConfigAudioEqualizer";
+//      case OMX_IndexConfigAudioReverberation:             return "ConfigAudioReverberation";
+//      case OMX_IndexConfigAudioChannelVolume:             return "ConfigAudioChannelVolume";
+//      case OMX_IndexParamImagePortFormat:                 return "ParamImagePortFormat";
+//      case OMX_IndexParamFlashControl:                    return "ParamFlashControl";
+//      case OMX_IndexConfigFocusControl:                   return "ConfigFocusControl";
+//      case OMX_IndexParamQFactor:                         return "ParamQFactor";
+//      case OMX_IndexParamQuantizationTable:               return "ParamQuantizationTable";
+//      case OMX_IndexParamHuffmanTable:                    return "ParamHuffmanTable";
+//      case OMX_IndexConfigFlashControl:                   return "ConfigFlashControl";
+        case OMX_IndexParamVideoPortFormat:                 return "ParamVideoPortFormat";
+//      case OMX_IndexParamVideoQuantization:               return "ParamVideoQuantization";
+//      case OMX_IndexParamVideoFastUpdate:                 return "ParamVideoFastUpdate";
+        case OMX_IndexParamVideoBitrate:                    return "ParamVideoBitrate";
+//      case OMX_IndexParamVideoMotionVector:               return "ParamVideoMotionVector";
+        case OMX_IndexParamVideoIntraRefresh:               return "ParamVideoIntraRefresh";
+        case OMX_IndexParamVideoErrorCorrection:            return "ParamVideoErrorCorrection";
+//      case OMX_IndexParamVideoVBSMC:                      return "ParamVideoVBSMC";
+//      case OMX_IndexParamVideoMpeg2:                      return "ParamVideoMpeg2";
+        case OMX_IndexParamVideoMpeg4:                      return "ParamVideoMpeg4";
+//      case OMX_IndexParamVideoWmv:                        return "ParamVideoWmv";
+//      case OMX_IndexParamVideoRv:                         return "ParamVideoRv";
+        case OMX_IndexParamVideoAvc:                        return "ParamVideoAvc";
+        case OMX_IndexParamVideoH263:                       return "ParamVideoH263";
+        case OMX_IndexParamVideoProfileLevelQuerySupported:
+            return "ParamVideoProfileLevelQuerySupported";
+        case OMX_IndexParamVideoProfileLevelCurrent:        return "ParamVideoProfileLevelCurrent";
+        case OMX_IndexConfigVideoBitrate:                   return "ConfigVideoBitrate";
+//      case OMX_IndexConfigVideoFramerate:                 return "ConfigVideoFramerate";
+        case OMX_IndexConfigVideoIntraVOPRefresh:           return "ConfigVideoIntraVOPRefresh";
+//      case OMX_IndexConfigVideoIntraMBRefresh:            return "ConfigVideoIntraMBRefresh";
+//      case OMX_IndexConfigVideoMBErrorReporting:          return "ConfigVideoMBErrorReporting";
+//      case OMX_IndexParamVideoMacroblocksPerFrame:        return "ParamVideoMacroblocksPerFrame";
+//      case OMX_IndexConfigVideoMacroBlockErrorMap:        return "ConfigVideoMacroBlockErrorMap";
+//      case OMX_IndexParamVideoSliceFMO:                   return "ParamVideoSliceFMO";
+//      case OMX_IndexConfigVideoAVCIntraPeriod:            return "ConfigVideoAVCIntraPeriod";
+//      case OMX_IndexConfigVideoNalSize:                   return "ConfigVideoNalSize";
+//      case OMX_IndexParamCommonDeblocking:                return "ParamCommonDeblocking";
+//      case OMX_IndexParamCommonSensorMode:                return "ParamCommonSensorMode";
+//      case OMX_IndexParamCommonInterleave:                return "ParamCommonInterleave";
+//      case OMX_IndexConfigCommonColorFormatConversion:
+//          return "ConfigCommonColorFormatConversion";
+        case OMX_IndexConfigCommonScale:                    return "ConfigCommonScale";
+//      case OMX_IndexConfigCommonImageFilter:              return "ConfigCommonImageFilter";
+//      case OMX_IndexConfigCommonColorEnhancement:         return "ConfigCommonColorEnhancement";
+//      case OMX_IndexConfigCommonColorKey:                 return "ConfigCommonColorKey";
+//      case OMX_IndexConfigCommonColorBlend:               return "ConfigCommonColorBlend";
+//      case OMX_IndexConfigCommonFrameStabilisation:       return "ConfigCommonFrameStabilisation";
+//      case OMX_IndexConfigCommonRotate:                   return "ConfigCommonRotate";
+//      case OMX_IndexConfigCommonMirror:                   return "ConfigCommonMirror";
+//      case OMX_IndexConfigCommonOutputPosition:           return "ConfigCommonOutputPosition";
+        case OMX_IndexConfigCommonInputCrop:                return "ConfigCommonInputCrop";
+        case OMX_IndexConfigCommonOutputCrop:               return "ConfigCommonOutputCrop";
+//      case OMX_IndexConfigCommonDigitalZoom:              return "ConfigCommonDigitalZoom";
+//      case OMX_IndexConfigCommonOpticalZoom:              return "ConfigCommonOpticalZoom";
+//      case OMX_IndexConfigCommonWhiteBalance:             return "ConfigCommonWhiteBalance";
+//      case OMX_IndexConfigCommonExposure:                 return "ConfigCommonExposure";
+//      case OMX_IndexConfigCommonContrast:                 return "ConfigCommonContrast";
+//      case OMX_IndexConfigCommonBrightness:               return "ConfigCommonBrightness";
+//      case OMX_IndexConfigCommonBacklight:                return "ConfigCommonBacklight";
+//      case OMX_IndexConfigCommonGamma:                    return "ConfigCommonGamma";
+//      case OMX_IndexConfigCommonSaturation:               return "ConfigCommonSaturation";
+//      case OMX_IndexConfigCommonLightness:                return "ConfigCommonLightness";
+//      case OMX_IndexConfigCommonExclusionRect:            return "ConfigCommonExclusionRect";
+//      case OMX_IndexConfigCommonDithering:                return "ConfigCommonDithering";
+//      case OMX_IndexConfigCommonPlaneBlend:               return "ConfigCommonPlaneBlend";
+//      case OMX_IndexConfigCommonExposureValue:            return "ConfigCommonExposureValue";
+//      case OMX_IndexConfigCommonOutputSize:               return "ConfigCommonOutputSize";
+//      case OMX_IndexParamCommonExtraQuantData:            return "ParamCommonExtraQuantData";
+//      case OMX_IndexConfigCommonFocusRegion:              return "ConfigCommonFocusRegion";
+//      case OMX_IndexConfigCommonFocusStatus:              return "ConfigCommonFocusStatus";
+//      case OMX_IndexConfigCommonTransitionEffect:         return "ConfigCommonTransitionEffect";
+//      case OMX_IndexParamOtherPortFormat:                 return "ParamOtherPortFormat";
+//      case OMX_IndexConfigOtherPower:                     return "ConfigOtherPower";
+//      case OMX_IndexConfigOtherStats:                     return "ConfigOtherStats";
+//      case OMX_IndexConfigTimeScale:                      return "ConfigTimeScale";
+//      case OMX_IndexConfigTimeClockState:                 return "ConfigTimeClockState";
+//      case OMX_IndexConfigTimeActiveRefClock:             return "ConfigTimeActiveRefClock";
+//      case OMX_IndexConfigTimeCurrentMediaTime:           return "ConfigTimeCurrentMediaTime";
+//      case OMX_IndexConfigTimeCurrentWallTime:            return "ConfigTimeCurrentWallTime";
+//      case OMX_IndexConfigTimeCurrentAudioReference:
+//          return "ConfigTimeCurrentAudioReference";
+//      case OMX_IndexConfigTimeCurrentVideoReference:
+//          return "ConfigTimeCurrentVideoReference";
+//      case OMX_IndexConfigTimeMediaTimeRequest:           return "ConfigTimeMediaTimeRequest";
+//      case OMX_IndexConfigTimeClientStartTime:            return "ConfigTimeClientStartTime";
+//      case OMX_IndexConfigTimePosition:                   return "ConfigTimePosition";
+//      case OMX_IndexConfigTimeSeekMode:                   return "ConfigTimeSeekMode";
+        default:                                            return def;
+    }
+}
+
+#endif // AS_STRING_FOR_OMX_INDEX_H
+
+#endif // OMX_Index_h
+
+#ifdef OMX_IndexExt_h
+/* asString definitions if media/openmax/OMX_IndexExt.h was included */
+
+#ifndef AS_STRING_FOR_OMX_INDEXEXT_H
+#define AS_STRING_FOR_OMX_INDEXEXT_H
+
+inline static const char *asString(OMX_INDEXEXTTYPE i, const char *def = "??") {
+    switch (i) {
+//      case OMX_IndexConfigCallbackRequest:            return "ConfigCallbackRequest";
+//      case OMX_IndexConfigCommitMode:                 return "ConfigCommitMode";
+//      case OMX_IndexConfigCommit:                     return "ConfigCommit";
+        case OMX_IndexParamAudioAndroidAc3:             return "ParamAudioAndroidAc3";
+        case OMX_IndexParamAudioAndroidOpus:            return "ParamAudioAndroidOpus";
+        case OMX_IndexParamAudioAndroidAacPresentation: return "ParamAudioAndroidAacPresentation";
+//      case OMX_IndexParamNalStreamFormatSupported:    return "ParamNalStreamFormatSupported";
+//      case OMX_IndexParamNalStreamFormat:             return "ParamNalStreamFormat";
+//      case OMX_IndexParamNalStreamFormatSelect:       return "ParamNalStreamFormatSelect";
+        case OMX_IndexParamVideoVp8:                    return "ParamVideoVp8";
+//      case OMX_IndexConfigVideoVp8ReferenceFrame:     return "ConfigVideoVp8ReferenceFrame";
+//      case OMX_IndexConfigVideoVp8ReferenceFrameType: return "ConfigVideoVp8ReferenceFrameType";
+        case OMX_IndexParamVideoAndroidVp8Encoder:      return "ParamVideoAndroidVp8Encoder";
+        case OMX_IndexParamVideoHevc:                   return "ParamVideoHevc";
+//      case OMX_IndexParamSliceSegments:               return "ParamSliceSegments";
+        case OMX_IndexConfigAutoFramerateConversion:    return "ConfigAutoFramerateConversion";
+        case OMX_IndexConfigPriority:                   return "ConfigPriority";
+        case OMX_IndexConfigOperatingRate:              return "ConfigOperatingRate";
+        case OMX_IndexParamConsumerUsageBits:           return "ParamConsumerUsageBits";
+        default:                                        return asString((OMX_INDEXTYPE)i, def);
+    }
+}
+
+#endif // AS_STRING_FOR_OMX_INDEXEXT_H
+
+#endif // OMX_IndexExt_h
+
+#ifdef OMX_IVCommon_h
+/* asString definitions if media/openmax/OMX_IVCommon.h was included */
+
+#ifndef AS_STRING_FOR_OMX_IVCOMMON_H
+#define AS_STRING_FOR_OMX_IVCOMMON_H
+
+inline static const char *asString(OMX_COLOR_FORMATTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_COLOR_FormatUnused:
+            return "COLOR_FormatUnused";
+        case OMX_COLOR_FormatMonochrome:
+            return "COLOR_FormatMonochrome";
+        case OMX_COLOR_Format8bitRGB332:
+            return "COLOR_Format8bitRGB332";
+        case OMX_COLOR_Format12bitRGB444:
+            return "COLOR_Format12bitRGB444";
+        case OMX_COLOR_Format16bitARGB4444:
+            return "COLOR_Format16bitARGB4444";
+        case OMX_COLOR_Format16bitARGB1555:
+            return "COLOR_Format16bitARGB1555";
+        case OMX_COLOR_Format16bitRGB565:
+            return "COLOR_Format16bitRGB565";
+        case OMX_COLOR_Format16bitBGR565:
+            return "COLOR_Format16bitBGR565";
+        case OMX_COLOR_Format18bitRGB666:
+            return "COLOR_Format18bitRGB666";
+        case OMX_COLOR_Format18bitARGB1665:
+            return "COLOR_Format18bitARGB1665";
+        case OMX_COLOR_Format19bitARGB1666:
+            return "COLOR_Format19bitARGB1666";
+        case OMX_COLOR_Format24bitRGB888:
+            return "COLOR_Format24bitRGB888";
+        case OMX_COLOR_Format24bitBGR888:
+            return "COLOR_Format24bitBGR888";
+        case OMX_COLOR_Format24bitARGB1887:
+            return "COLOR_Format24bitARGB1887";
+        case OMX_COLOR_Format25bitARGB1888:
+            return "COLOR_Format25bitARGB1888";
+        case OMX_COLOR_Format32bitBGRA8888:
+            return "COLOR_Format32bitBGRA8888";
+        case OMX_COLOR_Format32bitARGB8888:
+            return "COLOR_Format32bitARGB8888";
+        case OMX_COLOR_FormatYUV411Planar:
+            return "COLOR_FormatYUV411Planar";
+        case OMX_COLOR_FormatYUV411PackedPlanar:
+            return "COLOR_FormatYUV411PackedPlanar";
+        case OMX_COLOR_FormatYUV420Planar:
+            return "COLOR_FormatYUV420Planar";
+        case OMX_COLOR_FormatYUV420PackedPlanar:
+            return "COLOR_FormatYUV420PackedPlanar";
+        case OMX_COLOR_FormatYUV420SemiPlanar:
+            return "COLOR_FormatYUV420SemiPlanar";
+        case OMX_COLOR_FormatYUV422Planar:
+            return "COLOR_FormatYUV422Planar";
+        case OMX_COLOR_FormatYUV422PackedPlanar:
+            return "COLOR_FormatYUV422PackedPlanar";
+        case OMX_COLOR_FormatYUV422SemiPlanar:
+            return "COLOR_FormatYUV422SemiPlanar";
+        case OMX_COLOR_FormatYCbYCr:
+            return "COLOR_FormatYCbYCr";
+        case OMX_COLOR_FormatYCrYCb:
+            return "COLOR_FormatYCrYCb";
+        case OMX_COLOR_FormatCbYCrY:
+            return "COLOR_FormatCbYCrY";
+        case OMX_COLOR_FormatCrYCbY:
+            return "COLOR_FormatCrYCbY";
+        case OMX_COLOR_FormatYUV444Interleaved:
+            return "COLOR_FormatYUV444Interleaved";
+        case OMX_COLOR_FormatRawBayer8bit:
+            return "COLOR_FormatRawBayer8bit";
+        case OMX_COLOR_FormatRawBayer10bit:
+            return "COLOR_FormatRawBayer10bit";
+        case OMX_COLOR_FormatRawBayer8bitcompressed:
+            return "COLOR_FormatRawBayer8bitcompressed";
+        case OMX_COLOR_FormatL2:
+            return "COLOR_FormatL2";
+        case OMX_COLOR_FormatL4:
+            return "COLOR_FormatL4";
+        case OMX_COLOR_FormatL8:
+            return "COLOR_FormatL8";
+        case OMX_COLOR_FormatL16:
+            return "COLOR_FormatL16";
+        case OMX_COLOR_FormatL24:
+            return "COLOR_FormatL24";
+        case OMX_COLOR_FormatL32:
+            return "COLOR_FormatL32";
+        case OMX_COLOR_FormatYUV420PackedSemiPlanar:
+            return "COLOR_FormatYUV420PackedSemiPlanar";
+        case OMX_COLOR_FormatYUV422PackedSemiPlanar:
+            return "COLOR_FormatYUV422PackedSemiPlanar";
+        case OMX_COLOR_Format18BitBGR666:
+            return "COLOR_Format18BitBGR666";
+        case OMX_COLOR_Format24BitARGB6666:
+            return "COLOR_Format24BitARGB6666";
+        case OMX_COLOR_Format24BitABGR6666:
+            return "COLOR_Format24BitABGR6666";
+        case OMX_COLOR_FormatAndroidOpaque:
+            return "COLOR_FormatAndroidOpaque";
+        case OMX_COLOR_FormatYUV420Flexible:
+            return "COLOR_FormatYUV420Flexible";
+        case OMX_TI_COLOR_FormatYUV420PackedSemiPlanar:
+            return "TI_COLOR_FormatYUV420PackedSemiPlanar";
+        case OMX_QCOM_COLOR_FormatYVU420SemiPlanar:
+            return "QCOM_COLOR_FormatYVU420SemiPlanar";
+//      case OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka:
+//          return "QCOM_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka";
+//      case OMX_SEC_COLOR_FormatNV12Tiled:
+//          return "SEC_COLOR_FormatNV12Tiled";
+//      case OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar32m:
+//          return "QCOM_COLOR_FormatYUV420PackedSemiPlanar32m";
+        default:
+            return def;
+    }
+}
+
+#endif // AS_STRING_FOR_OMX_IVCOMMON_H
+
+#endif // OMX_IVCommon_h
+
+#ifdef OMX_Types_h
+/* asString definitions if media/openmax/OMX_Types.h was included */
+
+#ifndef AS_STRING_FOR_OMX_TYPES_H
+#define AS_STRING_FOR_OMX_TYPES_H
+
+inline static const char *asString(OMX_BOOL i, const char *def = "??") {
+    switch (i) {
+        case OMX_FALSE: return "FALSE";
+        case OMX_TRUE:  return "TRUE";
+        default:        return def;
+    }
+}
+
+inline static const char *asString(OMX_DIRTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_DirInput:  return "Input";
+        case OMX_DirOutput: return "Output";
+        default:            return def;
+    }
+}
+
+inline static const char *asString(OMX_ENDIANTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_EndianBig:    return "Big";
+//      case OMX_EndianLittle: return "Little";
+        default:               return def;
+    }
+}
+
+inline static const char *asString(OMX_NUMERICALDATATYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_NumericalDataSigned:   return "Signed";
+//      case OMX_NumericalDataUnsigned: return "Unsigned";
+        default:                        return def;
+    }
+}
+
+#endif // AS_STRING_FOR_OMX_TYPES_H
+
+#endif // OMX_Types_h
+
+#ifdef OMX_Video_h
+/* asString definitions if media/openmax/OMX_Video.h was included */
+
+#ifndef AS_STRING_FOR_OMX_VIDEO_H
+#define AS_STRING_FOR_OMX_VIDEO_H
+
+inline static const char *asString(OMX_VIDEO_CODINGTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_VIDEO_CodingUnused:     return "Unused";
+        case OMX_VIDEO_CodingAutoDetect: return "AutoDetect";  // unused
+        case OMX_VIDEO_CodingMPEG2:      return "MPEG2";
+        case OMX_VIDEO_CodingH263:       return "H263";
+        case OMX_VIDEO_CodingMPEG4:      return "MPEG4";
+        case OMX_VIDEO_CodingWMV:        return "WMV";         // unused
+        case OMX_VIDEO_CodingRV:         return "RV";          // unused
+        case OMX_VIDEO_CodingAVC:        return "AVC";
+        case OMX_VIDEO_CodingMJPEG:      return "MJPEG";       // unused
+        case OMX_VIDEO_CodingVP8:        return "VP8";
+        case OMX_VIDEO_CodingVP9:        return "VP9";
+        case OMX_VIDEO_CodingHEVC:       return "HEVC";
+        default:                         return def;
+    }
+}
+
+inline static const char *asString(OMX_VIDEO_CONTROLRATETYPE i, const char *def = "??") {
+    switch (i) {
+//      case OMX_Video_ControlRateDisable:            return "Disable";
+        case OMX_Video_ControlRateVariable:           return "Variable";
+        case OMX_Video_ControlRateConstant:           return "Constant";
+//      case OMX_Video_ControlRateVariableSkipFrames: return "VariableSkipFrames";
+//      case OMX_Video_ControlRateConstantSkipFrames: return "ConstantSkipFrames";
+        default:                                      return def;
+    }
+}
+
+inline static const char *asString(OMX_VIDEO_INTRAREFRESHTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_VIDEO_IntraRefreshCyclic:   return "Cyclic";
+        case OMX_VIDEO_IntraRefreshAdaptive: return "Adaptive";
+        case OMX_VIDEO_IntraRefreshBoth:     return "Both";
+        default:                             return def;
+    }
+}
+
+inline static const char *asString(OMX_VIDEO_H263PROFILETYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_VIDEO_H263ProfileBaseline:           return "Baseline";
+        case OMX_VIDEO_H263ProfileH320Coding:         return "H320Coding";
+        case OMX_VIDEO_H263ProfileBackwardCompatible: return "BackwardCompatible";
+        case OMX_VIDEO_H263ProfileISWV2:              return "ISWV2";
+        case OMX_VIDEO_H263ProfileISWV3:              return "ISWV3";
+        case OMX_VIDEO_H263ProfileHighCompression:    return "HighCompression";
+        case OMX_VIDEO_H263ProfileInternet:           return "Internet";
+        case OMX_VIDEO_H263ProfileInterlace:          return "Interlace";
+        case OMX_VIDEO_H263ProfileHighLatency:        return "HighLatency";
+        default:                                      return def;
+    }
+}
+
+inline static const char *asString(OMX_VIDEO_H263LEVELTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_VIDEO_H263Level10: return "Level10";
+        case OMX_VIDEO_H263Level20: return "Level20";
+        case OMX_VIDEO_H263Level30: return "Level30";
+        case OMX_VIDEO_H263Level40: return "Level40";
+        case OMX_VIDEO_H263Level45: return "Level45";
+        case OMX_VIDEO_H263Level50: return "Level50";
+        case OMX_VIDEO_H263Level60: return "Level60";
+        case OMX_VIDEO_H263Level70: return "Level70";
+        default:                    return def;
+    }
+}
+
+inline static const char *asString(OMX_VIDEO_PICTURETYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_VIDEO_PictureTypeI:  return "I";
+        case OMX_VIDEO_PictureTypeP:  return "P";
+        case OMX_VIDEO_PictureTypeB:  return "B";
+//      case OMX_VIDEO_PictureTypeSI: return "SI";
+//      case OMX_VIDEO_PictureTypeSP: return "SP";
+//      case OMX_VIDEO_PictureTypeEI: return "EI";
+//      case OMX_VIDEO_PictureTypeEP: return "EP";
+//      case OMX_VIDEO_PictureTypeS:  return "S";
+        default:                      return def;
+    }
+}
+
+inline static const char *asString(OMX_VIDEO_MPEG4PROFILETYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_VIDEO_MPEG4ProfileSimple:           return "Simple";
+        case OMX_VIDEO_MPEG4ProfileSimpleScalable:   return "SimpleScalable";
+        case OMX_VIDEO_MPEG4ProfileCore:             return "Core";
+        case OMX_VIDEO_MPEG4ProfileMain:             return "Main";
+        case OMX_VIDEO_MPEG4ProfileNbit:             return "Nbit";
+        case OMX_VIDEO_MPEG4ProfileScalableTexture:  return "ScalableTexture";
+        case OMX_VIDEO_MPEG4ProfileSimpleFace:       return "SimpleFace";
+        case OMX_VIDEO_MPEG4ProfileSimpleFBA:        return "SimpleFBA";
+        case OMX_VIDEO_MPEG4ProfileBasicAnimated:    return "BasicAnimated";
+        case OMX_VIDEO_MPEG4ProfileHybrid:           return "Hybrid";
+        case OMX_VIDEO_MPEG4ProfileAdvancedRealTime: return "AdvancedRealTime";
+        case OMX_VIDEO_MPEG4ProfileCoreScalable:     return "CoreScalable";
+        case OMX_VIDEO_MPEG4ProfileAdvancedCoding:   return "AdvancedCoding";
+        case OMX_VIDEO_MPEG4ProfileAdvancedCore:     return "AdvancedCore";
+        case OMX_VIDEO_MPEG4ProfileAdvancedScalable: return "AdvancedScalable";
+        case OMX_VIDEO_MPEG4ProfileAdvancedSimple:   return "AdvancedSimple";
+        default:                                     return def;
+    }
+}
+
+inline static const char *asString(OMX_VIDEO_MPEG4LEVELTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_VIDEO_MPEG4Level0:  return "Level0";
+        case OMX_VIDEO_MPEG4Level0b: return "Level0b";
+        case OMX_VIDEO_MPEG4Level1:  return "Level1";
+        case OMX_VIDEO_MPEG4Level2:  return "Level2";
+        case OMX_VIDEO_MPEG4Level3:  return "Level3";
+        case OMX_VIDEO_MPEG4Level4:  return "Level4";
+        case OMX_VIDEO_MPEG4Level4a: return "Level4a";
+        case OMX_VIDEO_MPEG4Level5:  return "Level5";
+        default:                     return def;
+    }
+}
+
+inline static const char *asString(OMX_VIDEO_AVCPROFILETYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_VIDEO_AVCProfileBaseline: return "Baseline";
+        case OMX_VIDEO_AVCProfileMain:     return "Main";
+        case OMX_VIDEO_AVCProfileExtended: return "Extended";
+        case OMX_VIDEO_AVCProfileHigh:     return "High";
+        case OMX_VIDEO_AVCProfileHigh10:   return "High10";
+        case OMX_VIDEO_AVCProfileHigh422:  return "High422";
+        case OMX_VIDEO_AVCProfileHigh444:  return "High444";
+        default:                           return def;
+    }
+}
+
+inline static const char *asString(OMX_VIDEO_AVCLEVELTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_VIDEO_AVCLevel1:  return "Level1";
+        case OMX_VIDEO_AVCLevel1b: return "Level1b";
+        case OMX_VIDEO_AVCLevel11: return "Level11";
+        case OMX_VIDEO_AVCLevel12: return "Level12";
+        case OMX_VIDEO_AVCLevel13: return "Level13";
+        case OMX_VIDEO_AVCLevel2:  return "Level2";
+        case OMX_VIDEO_AVCLevel21: return "Level21";
+        case OMX_VIDEO_AVCLevel22: return "Level22";
+        case OMX_VIDEO_AVCLevel3:  return "Level3";
+        case OMX_VIDEO_AVCLevel31: return "Level31";
+        case OMX_VIDEO_AVCLevel32: return "Level32";
+        case OMX_VIDEO_AVCLevel4:  return "Level4";
+        case OMX_VIDEO_AVCLevel41: return "Level41";
+        case OMX_VIDEO_AVCLevel42: return "Level42";
+        case OMX_VIDEO_AVCLevel5:  return "Level5";
+        case OMX_VIDEO_AVCLevel51: return "Level51";
+        case OMX_VIDEO_AVCLevel52: return "Level52";
+        default:                   return def;
+    }
+}
+
+inline static const char *asString(OMX_VIDEO_AVCLOOPFILTERTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_VIDEO_AVCLoopFilterEnable:               return "Enable";
+//      case OMX_VIDEO_AVCLoopFilterDisable:              return "Disable";
+//      case OMX_VIDEO_AVCLoopFilterDisableSliceBoundary: return "DisableSliceBoundary";
+        default:                                          return def;
+    }
+}
+
+#endif // AS_STRING_FOR_OMX_VIDEO_H
+
+#endif // OMX_Video_h
+
+#ifdef OMX_VideoExt_h
+/* asString definitions if media/openmax/OMX_VideoExt.h was included */
+
+#ifndef AS_STRING_FOR_OMX_VIDEOEXT_H
+#define AS_STRING_FOR_OMX_VIDEOEXT_H
+
+inline static const char *asString(OMX_VIDEO_VP8PROFILETYPE i, const char *def = "!!") {
+    switch (i) {
+        case OMX_VIDEO_VP8ProfileMain:    return "Main";
+        case OMX_VIDEO_VP8ProfileUnknown: return "Unknown";  // unused
+        default:                          return def;
+    }
+}
+
+inline static const char *asString(OMX_VIDEO_VP8LEVELTYPE i, const char *def = "!!") {
+    switch (i) {
+        case OMX_VIDEO_VP8Level_Version0: return "_Version0";
+        case OMX_VIDEO_VP8Level_Version1: return "_Version1";
+        case OMX_VIDEO_VP8Level_Version2: return "_Version2";
+        case OMX_VIDEO_VP8Level_Version3: return "_Version3";
+        case OMX_VIDEO_VP8LevelUnknown:   return "Unknown";    // unused
+        default:                          return def;
+    }
+}
+
+inline static const char *asString(
+        OMX_VIDEO_ANDROID_VPXTEMPORALLAYERPATTERNTYPE i, const char *def = "??") {
+    switch (i) {
+        case OMX_VIDEO_VPXTemporalLayerPatternNone:   return "VPXTemporalLayerPatternNone";
+        case OMX_VIDEO_VPXTemporalLayerPatternWebRTC: return "VPXTemporalLayerPatternWebRTC";
+        default:                                      return def;
+    }
+}
+
+inline static const char *asString(OMX_VIDEO_HEVCPROFILETYPE i, const char *def = "!!") {
+    switch (i) {
+        case OMX_VIDEO_HEVCProfileUnknown: return "Unknown";  // unused
+        case OMX_VIDEO_HEVCProfileMain:    return "Main";
+        case OMX_VIDEO_HEVCProfileMain10:  return "Main10";
+        default:                           return def;
+    }
+}
+
+inline static const char *asString(OMX_VIDEO_HEVCLEVELTYPE i, const char *def = "!!") {
+    switch (i) {
+        case OMX_VIDEO_HEVCLevelUnknown:    return "LevelUnknown";     // unused
+        case OMX_VIDEO_HEVCMainTierLevel1:  return "MainTierLevel1";
+        case OMX_VIDEO_HEVCHighTierLevel1:  return "HighTierLevel1";
+        case OMX_VIDEO_HEVCMainTierLevel2:  return "MainTierLevel2";
+        case OMX_VIDEO_HEVCHighTierLevel2:  return "HighTierLevel2";
+        case OMX_VIDEO_HEVCMainTierLevel21: return "MainTierLevel21";
+        case OMX_VIDEO_HEVCHighTierLevel21: return "HighTierLevel21";
+        case OMX_VIDEO_HEVCMainTierLevel3:  return "MainTierLevel3";
+        case OMX_VIDEO_HEVCHighTierLevel3:  return "HighTierLevel3";
+        case OMX_VIDEO_HEVCMainTierLevel31: return "MainTierLevel31";
+        case OMX_VIDEO_HEVCHighTierLevel31: return "HighTierLevel31";
+        case OMX_VIDEO_HEVCMainTierLevel4:  return "MainTierLevel4";
+        case OMX_VIDEO_HEVCHighTierLevel4:  return "HighTierLevel4";
+        case OMX_VIDEO_HEVCMainTierLevel41: return "MainTierLevel41";
+        case OMX_VIDEO_HEVCHighTierLevel41: return "HighTierLevel41";
+        case OMX_VIDEO_HEVCMainTierLevel5:  return "MainTierLevel5";
+        case OMX_VIDEO_HEVCHighTierLevel5:  return "HighTierLevel5";
+        case OMX_VIDEO_HEVCMainTierLevel51: return "MainTierLevel51";
+        case OMX_VIDEO_HEVCHighTierLevel51: return "HighTierLevel51";
+        case OMX_VIDEO_HEVCMainTierLevel52: return "MainTierLevel52";
+        case OMX_VIDEO_HEVCHighTierLevel52: return "HighTierLevel52";
+        case OMX_VIDEO_HEVCMainTierLevel6:  return "MainTierLevel6";
+        case OMX_VIDEO_HEVCHighTierLevel6:  return "HighTierLevel6";
+        case OMX_VIDEO_HEVCMainTierLevel61: return "MainTierLevel61";
+        case OMX_VIDEO_HEVCHighTierLevel61: return "HighTierLevel61";
+        case OMX_VIDEO_HEVCMainTierLevel62: return "MainTierLevel62";
+        case OMX_VIDEO_HEVCHighTierLevel62: return "HighTierLevel62";
+        default:                            return def;
+    }
+}
+
+#endif // AS_STRING_FOR_OMX_VIDEOEXT_H
+
+#endif // OMX_VideoExt_h
diff --git a/include/media/openmax/OMX_Audio.h b/include/media/openmax/OMX_Audio.h
index 89ce0fc..a0cbd3b 100644
--- a/include/media/openmax/OMX_Audio.h
+++ b/include/media/openmax/OMX_Audio.h
@@ -16,25 +16,25 @@
  * -------------------------------------------------------------------
  */
 /*
- * Copyright (c) 2008 The Khronos Group Inc. 
- * 
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
  * "Software"), to deal in the Software without restriction, including
  * without limitation the rights to use, copy, modify, merge, publish,
  * distribute, sublicense, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject
- * to the following conditions: 
+ * to the following conditions:
  * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software. 
- * 
+ * in all copies or substantial portions of the Software.
+ *
  * THE SOFTWARE IS 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
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
@@ -50,10 +50,9 @@
 extern "C" {
 #endif /* __cplusplus */
 
-
 /* Each OMX header must include all required header files to allow the
  *  header to compile without errors.  The includes below are required
- *  for this header file to compile successfully 
+ *  for this header file to compile successfully
  */
 
 #include <OMX_Core.h>
@@ -61,7 +60,7 @@
 /** @defgroup midi MIDI
  * @ingroup audio
  */
- 
+
 /** @defgroup effects Audio effects
  * @ingroup audio
  */
@@ -71,10 +70,10 @@
  * @{
  */
 
-/** Enumeration used to define the possible audio codings.  
- *  If "OMX_AUDIO_CodingUnused" is selected, the coding selection must 
- *  be done in a vendor specific way.  Since this is for an audio 
- *  processing element this enum is relevant.  However, for another 
+/** Enumeration used to define the possible audio codings.
+ *  If "OMX_AUDIO_CodingUnused" is selected, the coding selection must
+ *  be done in a vendor specific way.  Since this is for an audio
+ *  processing element this enum is relevant.  However, for another
  *  type of component other enums would be in this area.
  */
 typedef enum OMX_AUDIO_CODINGTYPE {
@@ -107,14 +106,14 @@
     OMX_AUDIO_CodingRA,          /**< Any variant of RA encoded data */
     OMX_AUDIO_CodingMIDI,        /**< Any variant of MIDI encoded data */
     OMX_AUDIO_CodingFLAC,        /**< Any variant of FLAC encoded data */
-    OMX_AUDIO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_CodingMax = 0x7FFFFFFF
 } OMX_AUDIO_CODINGTYPE;
 
 
-/** The PortDefinition structure is used to define all of the parameters 
- *  necessary for the compliant component to setup an input or an output audio 
+/** The PortDefinition structure is used to define all of the parameters
+ *  necessary for the compliant component to setup an input or an output audio
  *  path.  If additional information is needed to define the parameters of the
  *  port (such as frequency), additional structures must be sent such as the
  *  OMX_AUDIO_PARAM_PCMMODETYPE structure to supply the extra parameters for the port.
@@ -122,11 +121,11 @@
 typedef struct OMX_AUDIO_PORTDEFINITIONTYPE {
     OMX_STRING cMIMEType;            /**< MIME type of data for the port */
     OMX_NATIVE_DEVICETYPE pNativeRender; /** < platform specific reference
-                                               for an output device, 
+                                               for an output device,
                                                otherwise this field is 0 */
-    OMX_BOOL bFlagErrorConcealment;  /**< Turns on error concealment if it is 
+    OMX_BOOL bFlagErrorConcealment;  /**< Turns on error concealment if it is
                                           supported by the OMX component */
-    OMX_AUDIO_CODINGTYPE eEncoding;  /**< Type of data expected for this 
+    OMX_AUDIO_CODINGTYPE eEncoding;  /**< Type of data expected for this
                                           port (e.g. PCM, AMR, MP3, etc) */
 } OMX_AUDIO_PORTDEFINITIONTYPE;
 
@@ -143,15 +142,15 @@
 } OMX_AUDIO_PARAM_PORTFORMATTYPE;
 
 
-/** PCM mode type  */ 
-typedef enum OMX_AUDIO_PCMMODETYPE { 
-    OMX_AUDIO_PCMModeLinear = 0,  /**< Linear PCM encoded data */ 
-    OMX_AUDIO_PCMModeALaw,        /**< A law PCM encoded data (G.711) */ 
-    OMX_AUDIO_PCMModeMULaw,       /**< Mu law PCM encoded data (G.711)  */ 
-    OMX_AUDIO_PCMModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+/** PCM mode type  */
+typedef enum OMX_AUDIO_PCMMODETYPE {
+    OMX_AUDIO_PCMModeLinear = 0,  /**< Linear PCM encoded data */
+    OMX_AUDIO_PCMModeALaw,        /**< A law PCM encoded data (G.711) */
+    OMX_AUDIO_PCMModeMULaw,       /**< Mu law PCM encoded data (G.711)  */
+    OMX_AUDIO_PCMModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_PCMModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
-    OMX_AUDIO_PCMModeMax = 0x7FFFFFFF 
-} OMX_AUDIO_PCMMODETYPE; 
+    OMX_AUDIO_PCMModeMax = 0x7FFFFFFF
+} OMX_AUDIO_PCMMODETYPE;
 
 
 typedef enum OMX_AUDIO_CHANNELTYPE {
@@ -165,45 +164,45 @@
     OMX_AUDIO_ChannelCS   = 0x7,    /**< Back surround */
     OMX_AUDIO_ChannelLR   = 0x8,    /**< Left rear. */
     OMX_AUDIO_ChannelRR   = 0x9,    /**< Right rear. */
-    OMX_AUDIO_ChannelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_ChannelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_ChannelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
-    OMX_AUDIO_ChannelMax  = 0x7FFFFFFF 
+    OMX_AUDIO_ChannelMax  = 0x7FFFFFFF
 } OMX_AUDIO_CHANNELTYPE;
 
 #define OMX_AUDIO_MAXCHANNELS 16  /**< maximum number distinct audio channels that a buffer may contain */
 #define OMX_MIN_PCMPAYLOAD_MSEC 5 /**< Minimum audio buffer payload size for uncompressed (PCM) audio */
 
-/** PCM format description */ 
-typedef struct OMX_AUDIO_PARAM_PCMMODETYPE { 
-    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */ 
-    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */ 
-    OMX_U32 nPortIndex;               /**< port that this structure applies to */ 
-    OMX_U32 nChannels;                /**< Number of channels (e.g. 2 for stereo) */ 
-    OMX_NUMERICALDATATYPE eNumData;   /**< indicates PCM data as signed or unsigned */ 
-    OMX_ENDIANTYPE eEndian;           /**< indicates PCM data as little or big endian */ 
-    OMX_BOOL bInterleaved;            /**< True for normal interleaved data; false for 
-                                           non-interleaved data (e.g. block data) */ 
-    OMX_U32 nBitPerSample;            /**< Bit per sample */ 
-    OMX_U32 nSamplingRate;            /**< Sampling rate of the source data.  Use 0 for 
-                                           variable or unknown sampling rate. */ 
-    OMX_AUDIO_PCMMODETYPE ePCMMode;   /**< PCM mode enumeration */ 
+/** PCM format description */
+typedef struct OMX_AUDIO_PARAM_PCMMODETYPE {
+    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */
+    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */
+    OMX_U32 nPortIndex;               /**< port that this structure applies to */
+    OMX_U32 nChannels;                /**< Number of channels (e.g. 2 for stereo) */
+    OMX_NUMERICALDATATYPE eNumData;   /**< indicates PCM data as signed or unsigned */
+    OMX_ENDIANTYPE eEndian;           /**< indicates PCM data as little or big endian */
+    OMX_BOOL bInterleaved;            /**< True for normal interleaved data; false for
+                                           non-interleaved data (e.g. block data) */
+    OMX_U32 nBitPerSample;            /**< Bit per sample */
+    OMX_U32 nSamplingRate;            /**< Sampling rate of the source data.  Use 0 for
+                                           variable or unknown sampling rate. */
+    OMX_AUDIO_PCMMODETYPE ePCMMode;   /**< PCM mode enumeration */
     OMX_AUDIO_CHANNELTYPE eChannelMapping[OMX_AUDIO_MAXCHANNELS]; /**< Slot i contains channel defined by eChannelMap[i] */
 
-} OMX_AUDIO_PARAM_PCMMODETYPE; 
+} OMX_AUDIO_PARAM_PCMMODETYPE;
 
 
 /** Audio channel mode.  This is used by both AAC and MP3, although the names are more appropriate
- * for the MP3.  For example, JointStereo for MP3 is CouplingChannels for AAC. 
+ * for the MP3.  For example, JointStereo for MP3 is CouplingChannels for AAC.
  */
 typedef enum OMX_AUDIO_CHANNELMODETYPE {
-    OMX_AUDIO_ChannelModeStereo = 0,  /**< 2 channels, the bitrate allocation between those 
+    OMX_AUDIO_ChannelModeStereo = 0,  /**< 2 channels, the bitrate allocation between those
                                           two channels changes accordingly to each channel information */
-    OMX_AUDIO_ChannelModeJointStereo, /**< mode that takes advantage of what is common between 
+    OMX_AUDIO_ChannelModeJointStereo, /**< mode that takes advantage of what is common between
                                            2 channels for higher compression gain */
-    OMX_AUDIO_ChannelModeDual,        /**< 2 mono-channels, each channel is encoded with half 
+    OMX_AUDIO_ChannelModeDual,        /**< 2 mono-channels, each channel is encoded with half
                                            the bitrate of the overall bitrate */
     OMX_AUDIO_ChannelModeMono,        /**< Mono channel mode */
-    OMX_AUDIO_ChannelModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_ChannelModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_ChannelModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_ChannelModeMax = 0x7FFFFFFF
 } OMX_AUDIO_CHANNELMODETYPE;
@@ -213,7 +212,7 @@
     OMX_AUDIO_MP3StreamFormatMP1Layer3 = 0, /**< MP3 Audio MPEG 1 Layer 3 Stream format */
     OMX_AUDIO_MP3StreamFormatMP2Layer3,     /**< MP3 Audio MPEG 2 Layer 3 Stream format */
     OMX_AUDIO_MP3StreamFormatMP2_5Layer3,   /**< MP3 Audio MPEG2.5 Layer 3 Stream format */
-    OMX_AUDIO_MP3StreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_MP3StreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_MP3StreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_MP3StreamFormatMax = 0x7FFFFFFF
 } OMX_AUDIO_MP3STREAMFORMATTYPE;
@@ -243,7 +242,7 @@
     OMX_AUDIO_AACStreamFormatADIF,        /**< AAC Audio Data Interchange Format */
     OMX_AUDIO_AACStreamFormatMP4FF,       /**< AAC inside MPEG-4/ISO File Format */
     OMX_AUDIO_AACStreamFormatRAW,         /**< AAC Raw Format */
-    OMX_AUDIO_AACStreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_AACStreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_AACStreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_AACStreamFormatMax = 0x7FFFFFFF
 } OMX_AUDIO_AACSTREAMFORMATTYPE;
@@ -278,6 +277,7 @@
 #define OMX_AUDIO_AACToolTNS  0x00000004 /**< TNS: Temporal Noise Shaping tool allowed or active */
 #define OMX_AUDIO_AACToolPNS  0x00000008 /**< PNS: MPEG-4 Perceptual Noise substitution tool allowed or active */
 #define OMX_AUDIO_AACToolLTP  0x00000010 /**< LTP: MPEG-4 Long Term Prediction tool allowed or active */
+#define OMX_AUDIO_AACToolVendor 0x00010000 /**< NOT A KHRONOS VALUE, offset for vendor-specific additions */
 #define OMX_AUDIO_AACToolAll  0x7FFFFFFF /**< all AAC tools allowed or active (*/
 
 /** MPEG-4 AAC error resilience (ER) tool usage (for nAACERtools in OMX_AUDIO_PARAM_AACPROFILETYPE).
@@ -328,16 +328,16 @@
                                    variable or unknown sampling rate. */
     OMX_U32 nAudioBandWidth;  /**< Audio band width (in Hz) to which an encoder should
                                    limit the audio signal. Use 0 to let encoder decide */
-    OMX_S32 nQuality;		  /**< Sets encoding quality to n, between -1 (low) and 10 (high).
+    OMX_S32 nQuality;         /**< Sets encoding quality to n, between -1 (low) and 10 (high).
                                    In the default mode of operation, teh quality level is 3.
                                    Normal quality range is 0 - 10. */
-    OMX_BOOL bManaged;		  /**< Set  bitrate  management  mode. This turns off the
+    OMX_BOOL bManaged;        /**< Set  bitrate  management  mode. This turns off the
                                    normal VBR encoding, but allows hard or soft bitrate
                                    constraints to be enforced by the encoder. This mode can
                                    be slower, and may also be lower quality. It is
                                    primarily useful for streaming. */
-    OMX_BOOL bDownmix;		  /**< Downmix input from stereo to mono (has no effect on 
-                                   non-stereo streams). Useful for lower-bitrate encoding. */     
+    OMX_BOOL bDownmix;        /**< Downmix input from stereo to mono (has no effect on
+                                   non-stereo streams). Useful for lower-bitrate encoding. */
 } OMX_AUDIO_PARAM_VORBISTYPE;
 
 
@@ -360,7 +360,7 @@
   OMX_AUDIO_WMAFormat7,          /**< Windows Media Audio format 7 */
   OMX_AUDIO_WMAFormat8,          /**< Windows Media Audio format 8 */
   OMX_AUDIO_WMAFormat9,          /**< Windows Media Audio format 9 */
-  OMX_AUDIO_WMAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+  OMX_AUDIO_WMAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
   OMX_AUDIO_WMAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
   OMX_AUDIO_WMAFormatMax = 0x7FFFFFFF
 } OMX_AUDIO_WMAFORMATTYPE;
@@ -372,7 +372,7 @@
   OMX_AUDIO_WMAProfileL1,          /**< Windows Media audio version 9 profile L1 */
   OMX_AUDIO_WMAProfileL2,          /**< Windows Media audio version 9 profile L2 */
   OMX_AUDIO_WMAProfileL3,          /**< Windows Media audio version 9 profile L3 */
-  OMX_AUDIO_WMAProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+  OMX_AUDIO_WMAProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
   OMX_AUDIO_WMAProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
   OMX_AUDIO_WMAProfileMax = 0x7FFFFFFF
 } OMX_AUDIO_WMAPROFILETYPE;
@@ -387,14 +387,14 @@
     OMX_U32 nBitRate;         /**< Bit rate of the input data.  Use 0 for variable
                                    rate or unknown bit rates */
     OMX_AUDIO_WMAFORMATTYPE eFormat; /**< Version of WMA stream / data */
-	OMX_AUDIO_WMAPROFILETYPE eProfile;  /**< Profile of WMA stream / data */
+    OMX_AUDIO_WMAPROFILETYPE eProfile;  /**< Profile of WMA stream / data */
     OMX_U32 nSamplingRate;    /**< Sampling rate of the source data */
     OMX_U16 nBlockAlign;      /**< is the block alignment, or block size, in bytes of the audio codec */
     OMX_U16 nEncodeOptions;   /**< WMA Type-specific data */
     OMX_U32 nSuperBlockAlign; /**< WMA Type-specific data */
 } OMX_AUDIO_PARAM_WMATYPE;
 
-/** 
+/**
  * RealAudio format
  */
 typedef enum OMX_AUDIO_RAFORMATTYPE {
@@ -406,32 +406,32 @@
     OMX_AUDIO_RA10_LOSSLESS,      /**< RealAudio Lossless */
     OMX_AUDIO_RA10_MULTICHANNEL,  /**< RealAudio Multichannel */
     OMX_AUDIO_RA10_VOICE,         /**< RealAudio Voice for bitrates below 15 kbps */
-    OMX_AUDIO_RAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_RAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_RAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_RAFormatMax = 0x7FFFFFFF
 } OMX_AUDIO_RAFORMATTYPE;
 
-/** RA (Real Audio) params */ 
-typedef struct OMX_AUDIO_PARAM_RATYPE { 
-    OMX_U32 nSize;              /**< Size of this structure, in Bytes */ 
-    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */ 
-    OMX_U32 nPortIndex;         /**< Port that this structure applies to */ 
-    OMX_U32 nChannels;          /**< Number of channels */ 
-    OMX_U32 nSamplingRate;      /**< is the sampling rate of the source data */ 
-    OMX_U32 nBitsPerFrame;      /**< is the value for bits per frame  */ 
-    OMX_U32 nSamplePerFrame;    /**< is the value for samples per frame */ 
-    OMX_U32 nCouplingQuantBits; /**< is the number of coupling quantization bits in the stream */ 
-    OMX_U32 nCouplingStartRegion;   /**< is the coupling start region in the stream  */ 
-    OMX_U32 nNumRegions;        /**< is the number of regions value */ 
+/** RA (Real Audio) params */
+typedef struct OMX_AUDIO_PARAM_RATYPE {
+    OMX_U32 nSize;              /**< Size of this structure, in Bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U32 nPortIndex;         /**< Port that this structure applies to */
+    OMX_U32 nChannels;          /**< Number of channels */
+    OMX_U32 nSamplingRate;      /**< is the sampling rate of the source data */
+    OMX_U32 nBitsPerFrame;      /**< is the value for bits per frame  */
+    OMX_U32 nSamplePerFrame;    /**< is the value for samples per frame */
+    OMX_U32 nCouplingQuantBits; /**< is the number of coupling quantization bits in the stream */
+    OMX_U32 nCouplingStartRegion;   /**< is the coupling start region in the stream  */
+    OMX_U32 nNumRegions;        /**< is the number of regions value */
     OMX_AUDIO_RAFORMATTYPE eFormat; /**< is the RealAudio audio format */
-} OMX_AUDIO_PARAM_RATYPE; 
+} OMX_AUDIO_PARAM_RATYPE;
 
 
 /** SBC Allocation Method Type */
 typedef enum OMX_AUDIO_SBCALLOCMETHODTYPE {
   OMX_AUDIO_SBCAllocMethodLoudness, /**< Loudness allocation method */
   OMX_AUDIO_SBCAllocMethodSNR,      /**< SNR allocation method */
-  OMX_AUDIO_SBCAllocMethodKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+  OMX_AUDIO_SBCAllocMethodKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
   OMX_AUDIO_SBCAllocMethodVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
   OMX_AUDIO_SBCAllocMethodMax = 0x7FFFFFFF
 } OMX_AUDIO_SBCALLOCMETHODTYPE;
@@ -456,18 +456,18 @@
 } OMX_AUDIO_PARAM_SBCTYPE;
 
 
-/** ADPCM stream format parameters */ 
-typedef struct OMX_AUDIO_PARAM_ADPCMTYPE { 
-    OMX_U32 nSize;              /**< size of the structure in bytes */ 
-    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */ 
-    OMX_U32 nPortIndex;         /**< port that this structure applies to */ 
-    OMX_U32 nChannels;          /**< Number of channels in the data stream (not 
-                                     necessarily the same as the number of channels 
-                                     to be rendered. */ 
-    OMX_U32 nBitsPerSample;     /**< Number of bits in each sample */ 
-    OMX_U32 nSampleRate;        /**< Sampling rate of the source data.  Use 0 for 
-                                    variable or unknown sampling rate. */ 
-} OMX_AUDIO_PARAM_ADPCMTYPE; 
+/** ADPCM stream format parameters */
+typedef struct OMX_AUDIO_PARAM_ADPCMTYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U32 nPortIndex;         /**< port that this structure applies to */
+    OMX_U32 nChannels;          /**< Number of channels in the data stream (not
+                                     necessarily the same as the number of channels
+                                     to be rendered. */
+    OMX_U32 nBitsPerSample;     /**< Number of bits in each sample */
+    OMX_U32 nSampleRate;        /**< Sampling rate of the source data.  Use 0 for
+                                    variable or unknown sampling rate. */
+} OMX_AUDIO_PARAM_ADPCMTYPE;
 
 
 /** G723 rate */
@@ -475,25 +475,25 @@
     OMX_AUDIO_G723ModeUnused = 0,  /**< AMRNB Mode unused / unknown */
     OMX_AUDIO_G723ModeLow,         /**< 5300 bps */
     OMX_AUDIO_G723ModeHigh,        /**< 6300 bps */
-    OMX_AUDIO_G723ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_G723ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_G723ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_G723ModeMax = 0x7FFFFFFF
 } OMX_AUDIO_G723RATE;
 
 
 /** G723 - Sample rate must be 8 KHz */
-typedef struct OMX_AUDIO_PARAM_G723TYPE { 
-    OMX_U32 nSize;                /**< size of the structure in bytes */ 
-    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */ 
-    OMX_U32 nPortIndex;           /**< port that this structure applies to */ 
-    OMX_U32 nChannels;            /**< Number of channels in the data stream (not 
-                                       necessarily the same as the number of channels 
-                                       to be rendered. */ 
-    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */ 
+typedef struct OMX_AUDIO_PARAM_G723TYPE {
+    OMX_U32 nSize;                /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */
+    OMX_U32 nPortIndex;           /**< port that this structure applies to */
+    OMX_U32 nChannels;            /**< Number of channels in the data stream (not
+                                       necessarily the same as the number of channels
+                                       to be rendered. */
+    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */
     OMX_AUDIO_G723RATE eBitRate;  /**< todo: Should this be moved to a config? */
-    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */ 
-    OMX_BOOL bPostFilter;         /**< Enable Post Filter */ 
-} OMX_AUDIO_PARAM_G723TYPE; 
+    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */
+    OMX_BOOL bPostFilter;         /**< Enable Post Filter */
+} OMX_AUDIO_PARAM_G723TYPE;
 
 
 /** ITU G726 (ADPCM) rate */
@@ -503,22 +503,22 @@
     OMX_AUDIO_G726Mode24,          /**< 24 kbps */
     OMX_AUDIO_G726Mode32,          /**< 32 kbps, most common rate, also G721 */
     OMX_AUDIO_G726Mode40,          /**< 40 kbps */
-    OMX_AUDIO_G726ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_G726ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_G726ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_G726ModeMax = 0x7FFFFFFF
 } OMX_AUDIO_G726MODE;
 
 
-/** G.726 stream format parameters - must be at 8KHz */ 
-typedef struct OMX_AUDIO_PARAM_G726TYPE { 
-    OMX_U32 nSize;              /**< size of the structure in bytes */ 
-    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */ 
-    OMX_U32 nPortIndex;         /**< port that this structure applies to */ 
-    OMX_U32 nChannels;          /**< Number of channels in the data stream (not 
-                                     necessarily the same as the number of channels 
-                                     to be rendered. */ 
+/** G.726 stream format parameters - must be at 8KHz */
+typedef struct OMX_AUDIO_PARAM_G726TYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U32 nPortIndex;         /**< port that this structure applies to */
+    OMX_U32 nChannels;          /**< Number of channels in the data stream (not
+                                     necessarily the same as the number of channels
+                                     to be rendered. */
      OMX_AUDIO_G726MODE eG726Mode;
-} OMX_AUDIO_PARAM_G726TYPE; 
+} OMX_AUDIO_PARAM_G726TYPE;
 
 
 /** G729 coder type */
@@ -527,7 +527,7 @@
     OMX_AUDIO_G729A,              /**< ITU G.729 annex A  encoded data */
     OMX_AUDIO_G729B,              /**< ITU G.729 with annex B encoded data */
     OMX_AUDIO_G729AB,             /**< ITU G.729 annexes A and B encoded data */
-    OMX_AUDIO_G729KhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_G729KhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_G729VendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_G729Max = 0x7FFFFFFF
 } OMX_AUDIO_G729TYPE;
@@ -546,23 +546,23 @@
 } OMX_AUDIO_PARAM_G729TYPE;
 
 
-/** AMR Frame format */ 
-typedef enum OMX_AUDIO_AMRFRAMEFORMATTYPE { 
-    OMX_AUDIO_AMRFrameFormatConformance = 0,  /**< Frame Format is AMR Conformance 
-                                                   (Standard) Format */ 
-    OMX_AUDIO_AMRFrameFormatIF1,              /**< Frame Format is AMR Interface 
-                                                   Format 1 */ 
-    OMX_AUDIO_AMRFrameFormatIF2,              /**< Frame Format is AMR Interface 
-                                                   Format 2*/ 
-    OMX_AUDIO_AMRFrameFormatFSF,              /**< Frame Format is AMR File Storage 
-                                                   Format */ 
-    OMX_AUDIO_AMRFrameFormatRTPPayload,       /**< Frame Format is AMR Real-Time 
-                                                   Transport Protocol Payload Format */ 
-    OMX_AUDIO_AMRFrameFormatITU,              /**< Frame Format is ITU Format (added at Motorola request) */ 
-    OMX_AUDIO_AMRFrameFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+/** AMR Frame format */
+typedef enum OMX_AUDIO_AMRFRAMEFORMATTYPE {
+    OMX_AUDIO_AMRFrameFormatConformance = 0,  /**< Frame Format is AMR Conformance
+                                                   (Standard) Format */
+    OMX_AUDIO_AMRFrameFormatIF1,              /**< Frame Format is AMR Interface
+                                                   Format 1 */
+    OMX_AUDIO_AMRFrameFormatIF2,              /**< Frame Format is AMR Interface
+                                                   Format 2*/
+    OMX_AUDIO_AMRFrameFormatFSF,              /**< Frame Format is AMR File Storage
+                                                   Format */
+    OMX_AUDIO_AMRFrameFormatRTPPayload,       /**< Frame Format is AMR Real-Time
+                                                   Transport Protocol Payload Format */
+    OMX_AUDIO_AMRFrameFormatITU,              /**< Frame Format is ITU Format (added at Motorola request) */
+    OMX_AUDIO_AMRFrameFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_AMRFrameFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
-    OMX_AUDIO_AMRFrameFormatMax = 0x7FFFFFFF 
-} OMX_AUDIO_AMRFRAMEFORMATTYPE; 
+    OMX_AUDIO_AMRFrameFormatMax = 0x7FFFFFFF
+} OMX_AUDIO_AMRFRAMEFORMATTYPE;
 
 
 /** AMR band mode */
@@ -570,7 +570,7 @@
     OMX_AUDIO_AMRBandModeUnused = 0,          /**< AMRNB Mode unused / unknown */
     OMX_AUDIO_AMRBandModeNB0,                 /**< AMRNB Mode 0 =  4750 bps */
     OMX_AUDIO_AMRBandModeNB1,                 /**< AMRNB Mode 1 =  5150 bps */
-    OMX_AUDIO_AMRBandModeNB2,                 /**< AMRNB Mode 2 =  5900 bps */ 
+    OMX_AUDIO_AMRBandModeNB2,                 /**< AMRNB Mode 2 =  5900 bps */
     OMX_AUDIO_AMRBandModeNB3,                 /**< AMRNB Mode 3 =  6700 bps */
     OMX_AUDIO_AMRBandModeNB4,                 /**< AMRNB Mode 4 =  7400 bps */
     OMX_AUDIO_AMRBandModeNB5,                 /**< AMRNB Mode 5 =  7950 bps */
@@ -578,36 +578,36 @@
     OMX_AUDIO_AMRBandModeNB7,                 /**< AMRNB Mode 7 = 12200 bps */
     OMX_AUDIO_AMRBandModeWB0,                 /**< AMRWB Mode 0 =  6600 bps */
     OMX_AUDIO_AMRBandModeWB1,                 /**< AMRWB Mode 1 =  8850 bps */
-    OMX_AUDIO_AMRBandModeWB2,                 /**< AMRWB Mode 2 = 12650 bps */ 
-    OMX_AUDIO_AMRBandModeWB3,                 /**< AMRWB Mode 3 = 14250 bps */ 
+    OMX_AUDIO_AMRBandModeWB2,                 /**< AMRWB Mode 2 = 12650 bps */
+    OMX_AUDIO_AMRBandModeWB3,                 /**< AMRWB Mode 3 = 14250 bps */
     OMX_AUDIO_AMRBandModeWB4,                 /**< AMRWB Mode 4 = 15850 bps */
     OMX_AUDIO_AMRBandModeWB5,                 /**< AMRWB Mode 5 = 18250 bps */
     OMX_AUDIO_AMRBandModeWB6,                 /**< AMRWB Mode 6 = 19850 bps */
     OMX_AUDIO_AMRBandModeWB7,                 /**< AMRWB Mode 7 = 23050 bps */
-    OMX_AUDIO_AMRBandModeWB8,                 /**< AMRWB Mode 8 = 23850 bps */      
-    OMX_AUDIO_AMRBandModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_AMRBandModeWB8,                 /**< AMRWB Mode 8 = 23850 bps */
+    OMX_AUDIO_AMRBandModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_AMRBandModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_AMRBandModeMax = 0x7FFFFFFF
 } OMX_AUDIO_AMRBANDMODETYPE;
-     
 
-/** AMR Discontinuous Transmission mode */ 
-typedef enum OMX_AUDIO_AMRDTXMODETYPE { 
-    OMX_AUDIO_AMRDTXModeOff = 0,        /**< AMR Discontinuous Transmission Mode is disabled */ 
-    OMX_AUDIO_AMRDTXModeOnVAD1,         /**< AMR Discontinuous Transmission Mode using 
-                                             Voice Activity Detector 1 (VAD1) is enabled */ 
-    OMX_AUDIO_AMRDTXModeOnVAD2,         /**< AMR Discontinuous Transmission Mode using 
-                                             Voice Activity Detector 2 (VAD2) is enabled */       
-    OMX_AUDIO_AMRDTXModeOnAuto,         /**< The codec will automatically select between 
-                                             Off, VAD1 or VAD2 modes */ 
+
+/** AMR Discontinuous Transmission mode */
+typedef enum OMX_AUDIO_AMRDTXMODETYPE {
+    OMX_AUDIO_AMRDTXModeOff = 0,        /**< AMR Discontinuous Transmission Mode is disabled */
+    OMX_AUDIO_AMRDTXModeOnVAD1,         /**< AMR Discontinuous Transmission Mode using
+                                             Voice Activity Detector 1 (VAD1) is enabled */
+    OMX_AUDIO_AMRDTXModeOnVAD2,         /**< AMR Discontinuous Transmission Mode using
+                                             Voice Activity Detector 2 (VAD2) is enabled */
+    OMX_AUDIO_AMRDTXModeOnAuto,         /**< The codec will automatically select between
+                                             Off, VAD1 or VAD2 modes */
 
     OMX_AUDIO_AMRDTXasEFR,             /**< DTX as EFR instead of AMR standard (3GPP 26.101, frame type =8,9,10) */
 
-    OMX_AUDIO_AMRDTXModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_AMRDTXModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_AMRDTXModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
-    OMX_AUDIO_AMRDTXModeMax = 0x7FFFFFFF 
-} OMX_AUDIO_AMRDTXMODETYPE; 
- 
+    OMX_AUDIO_AMRDTXModeMax = 0x7FFFFFFF
+} OMX_AUDIO_AMRDTXMODETYPE;
+
 
 /** AMR params */
 typedef struct OMX_AUDIO_PARAM_AMRTYPE {
@@ -616,7 +616,7 @@
     OMX_U32 nPortIndex;                     /**< port that this structure applies to */
     OMX_U32 nChannels;                      /**< Number of channels */
     OMX_U32 nBitRate;                       /**< Bit rate read only field */
-    OMX_AUDIO_AMRBANDMODETYPE eAMRBandMode; /**< AMR Band Mode enumeration */ 
+    OMX_AUDIO_AMRBANDMODETYPE eAMRBandMode; /**< AMR Band Mode enumeration */
     OMX_AUDIO_AMRDTXMODETYPE  eAMRDTXMode;  /**< AMR DTX Mode enumeration */
     OMX_AUDIO_AMRFRAMEFORMATTYPE eAMRFrameFormat; /**< AMR frame format enumeration */
 } OMX_AUDIO_PARAM_AMRTYPE;
@@ -724,7 +724,7 @@
     OMX_AUDIO_CDMARateQuarter,            /**< CDMA encoded frame in quarter rate */
     OMX_AUDIO_CDMARateEighth,             /**< CDMA encoded frame in eighth rate (DTX)*/
     OMX_AUDIO_CDMARateErasure,            /**< CDMA erasure frame */
-    OMX_AUDIO_CDMARateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_CDMARateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_CDMARateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_CDMARateMax = 0x7FFFFFFF
 } OMX_AUDIO_CDMARATETYPE;
@@ -796,7 +796,7 @@
 } OMX_AUDIO_PARAM_SMVTYPE;
 
 
-/** MIDI Format 
+/** MIDI Format
  * @ingroup midi
  */
 typedef enum OMX_AUDIO_MIDIFORMATTYPE
@@ -809,33 +809,33 @@
     OMX_AUDIO_MIDIFormatXMF0,        /**< eXtensible Music Format type 0 */
     OMX_AUDIO_MIDIFormatXMF1,        /**< eXtensible Music Format type 1 */
     OMX_AUDIO_MIDIFormatMobileXMF,   /**< Mobile XMF (eXtensible Music Format type 2) */
-    OMX_AUDIO_MIDIFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_MIDIFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_MIDIFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_MIDIFormatMax = 0x7FFFFFFF
 } OMX_AUDIO_MIDIFORMATTYPE;
 
 
-/** MIDI params 
+/** MIDI params
  * @ingroup midi
  */
 typedef struct OMX_AUDIO_PARAM_MIDITYPE {
     OMX_U32 nSize;                 /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */
     OMX_U32 nPortIndex;            /**< port that this structure applies to */
-    OMX_U32 nFileSize;             /**< size of the MIDI file in bytes, where the entire 
-                                        MIDI file passed in, otherwise if 0x0, the MIDI data 
-                                        is merged and streamed (instead of passed as an 
+    OMX_U32 nFileSize;             /**< size of the MIDI file in bytes, where the entire
+                                        MIDI file passed in, otherwise if 0x0, the MIDI data
+                                        is merged and streamed (instead of passed as an
                                         entire MIDI file) */
-    OMX_BU32 sMaxPolyphony;        /**< Specifies the maximum simultaneous polyphonic 
-                                        voices. A value of zero indicates that the default 
-                                        polyphony of the device is used  */                                    
-    OMX_BOOL bLoadDefaultSound;    /**< Whether to load default sound 
+    OMX_BU32 sMaxPolyphony;        /**< Specifies the maximum simultaneous polyphonic
+                                        voices. A value of zero indicates that the default
+                                        polyphony of the device is used  */
+    OMX_BOOL bLoadDefaultSound;    /**< Whether to load default sound
                                         bank at initialization */
-    OMX_AUDIO_MIDIFORMATTYPE eMidiFormat; /**< Version of the MIDI file */                                                                           
+    OMX_AUDIO_MIDIFORMATTYPE eMidiFormat; /**< Version of the MIDI file */
 } OMX_AUDIO_PARAM_MIDITYPE;
 
 
-/** Type of the MIDI sound bank 
+/** Type of the MIDI sound bank
  * @ingroup midi
  */
 typedef enum OMX_AUDIO_MIDISOUNDBANKTYPE {
@@ -844,13 +844,13 @@
     OMX_AUDIO_MIDISoundBankDLS2,                 /**< DLS version 2 */
     OMX_AUDIO_MIDISoundBankMobileDLSBase,        /**< Mobile DLS, using the base functionality */
     OMX_AUDIO_MIDISoundBankMobileDLSPlusOptions, /**< Mobile DLS, using the specification-defined optional feature set */
-    OMX_AUDIO_MIDISoundBankKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_MIDISoundBankKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_MIDISoundBankVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_MIDISoundBankMax = 0x7FFFFFFF
 } OMX_AUDIO_MIDISOUNDBANKTYPE;
 
 
-/** Bank Layout describes how bank MSB & LSB are used in the DLS instrument definitions sound bank 
+/** Bank Layout describes how bank MSB & LSB are used in the DLS instrument definitions sound bank
  * @ingroup midi
  */
 typedef enum OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE {
@@ -858,13 +858,13 @@
    OMX_AUDIO_MIDISoundBankLayoutGM,           /**< GS layout (based on bank MSB 0x00) */
    OMX_AUDIO_MIDISoundBankLayoutGM2,          /**< General MIDI 2 layout (using MSB 0x78/0x79, LSB 0x00) */
    OMX_AUDIO_MIDISoundBankLayoutUser,         /**< Does not conform to any bank numbering standards */
-   OMX_AUDIO_MIDISoundBankLayoutKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+   OMX_AUDIO_MIDISoundBankLayoutKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
    OMX_AUDIO_MIDISoundBankLayoutVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
    OMX_AUDIO_MIDISoundBankLayoutMax = 0x7FFFFFFF
 } OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE;
 
 
-/** MIDI params to load/unload user soundbank 
+/** MIDI params to load/unload user soundbank
  * @ingroup midi
  */
 typedef struct OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE {
@@ -879,8 +879,8 @@
 } OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE;
 
 
-/** Structure for Live MIDI events and MIP messages. 
- * (MIP = Maximum Instantaneous Polyphony; part of the SP-MIDI standard.) 
+/** Structure for Live MIDI events and MIP messages.
+ * (MIP = Maximum Instantaneous Polyphony; part of the SP-MIDI standard.)
  * @ingroup midi
  */
 typedef struct OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE {
@@ -889,12 +889,12 @@
     OMX_U32 nPortIndex;       /**< Port that this structure applies to */
     OMX_U32 nMidiEventSize;   /**< Size of immediate MIDI events or MIP message in bytes  */
     OMX_U8 nMidiEvents[1];    /**< MIDI event array to be rendered immediately, or an
-                                   array for the MIP message buffer, where the size is 
+                                   array for the MIP message buffer, where the size is
                                    indicated by nMidiEventSize */
 } OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE;
 
 
-/** MIDI sound bank/ program pair in a given channel 
+/** MIDI sound bank/ program pair in a given channel
  * @ingroup midi
  */
 typedef struct OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE {
@@ -904,29 +904,29 @@
     OMX_U32 nChannel;           /**< Valid channel values range from 1 to 16 */
     OMX_U16 nIDProgram;         /**< Valid program ID range is 1 to 128 */
     OMX_U16 nIDSoundBank;       /**< Sound bank ID */
-    OMX_U32 nUserSoundBankIndex;/**< User soundbank index, easier to access soundbanks 
+    OMX_U32 nUserSoundBankIndex;/**< User soundbank index, easier to access soundbanks
                                      by index if multiple banks are present */
 } OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE;
 
 
-/** MIDI control 
+/** MIDI control
  * @ingroup midi
  */
 typedef struct OMX_AUDIO_CONFIG_MIDICONTROLTYPE {
     OMX_U32 nSize;                /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */
     OMX_U32 nPortIndex;           /**< port that this structure applies to */
-    OMX_BS32 sPitchTransposition; /**< Pitch transposition in semitones, stored as Q22.10 
+    OMX_BS32 sPitchTransposition; /**< Pitch transposition in semitones, stored as Q22.10
                                        format based on JAVA MMAPI (JSR-135) requirement */
     OMX_BU32 sPlayBackRate;       /**< Relative playback rate, stored as Q14.17 fixed-point
                                        number based on JSR-135 requirement */
-    OMX_BU32 sTempo ;             /**< Tempo in beats per minute (BPM), stored as Q22.10 
+    OMX_BU32 sTempo ;             /**< Tempo in beats per minute (BPM), stored as Q22.10
                                        fixed-point number based on JSR-135 requirement */
-    OMX_U32 nMaxPolyphony;        /**< Specifies the maximum simultaneous polyphonic 
-                                       voices. A value of zero indicates that the default 
+    OMX_U32 nMaxPolyphony;        /**< Specifies the maximum simultaneous polyphonic
+                                       voices. A value of zero indicates that the default
                                        polyphony of the device is used  */
     OMX_U32 nNumRepeat;           /**< Number of times to repeat playback */
-    OMX_U32 nStopTime;            /**< Time in milliseconds to indicate when playback 
+    OMX_U32 nStopTime;            /**< Time in milliseconds to indicate when playback
                                        will stop automatically.  Set to zero if not used */
     OMX_U16 nChannelMuteMask;     /**< 16 bit mask for channel mute status */
     OMX_U16 nChannelSoloMask;     /**< 16 bit mask for channel solo status */
@@ -938,22 +938,22 @@
 } OMX_AUDIO_CONFIG_MIDICONTROLTYPE;
 
 
-/** MIDI Playback States 
+/** MIDI Playback States
  * @ingroup midi
  */
 typedef enum OMX_AUDIO_MIDIPLAYBACKSTATETYPE {
-  OMX_AUDIO_MIDIPlayBackStateUnknown = 0,      /**< Unknown state or state does not map to 
-  													other defined states */
-  OMX_AUDIO_MIDIPlayBackStateClosedEngaged,    /**< No MIDI resource is currently open. 
-                                                    The MIDI engine is currently processing 
+  OMX_AUDIO_MIDIPlayBackStateUnknown = 0,      /**< Unknown state or state does not map to
+                                                    other defined states */
+  OMX_AUDIO_MIDIPlayBackStateClosedEngaged,    /**< No MIDI resource is currently open.
+                                                    The MIDI engine is currently processing
                                                     MIDI events. */
-  OMX_AUDIO_MIDIPlayBackStateParsing,          /**< A MIDI resource is open and is being 
-                                                    primed. The MIDI engine is currently 
+  OMX_AUDIO_MIDIPlayBackStateParsing,          /**< A MIDI resource is open and is being
+                                                    primed. The MIDI engine is currently
                                                     processing MIDI events. */
-  OMX_AUDIO_MIDIPlayBackStateOpenEngaged,      /**< A MIDI resource is open and primed but 
+  OMX_AUDIO_MIDIPlayBackStateOpenEngaged,      /**< A MIDI resource is open and primed but
                                                     not playing. The MIDI engine is currently
                                                     processing MIDI events. The transition to
-                                                    this state is only possible from the 
+                                                    this state is only possible from the
                                                     OMX_AUDIO_MIDIPlayBackStatePlaying state,
                                                     when the 'playback head' reaches the end
                                                     of media data or the playback stops due
@@ -968,95 +968,95 @@
                                                     no audible MIDI content during playback
                                                     currently. The situation may change if
                                                     resources are freed later.*/
-  OMX_AUDIO_MIDIPlayBackStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+  OMX_AUDIO_MIDIPlayBackStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
   OMX_AUDIO_MIDIPlayBackStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
   OMX_AUDIO_MIDIPlayBackStateMax = 0x7FFFFFFF
 } OMX_AUDIO_MIDIPLAYBACKSTATETYPE;
 
 
-/** MIDI status 
+/** MIDI status
  * @ingroup midi
  */
 typedef struct OMX_AUDIO_CONFIG_MIDISTATUSTYPE {
     OMX_U32 nSize;              /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
     OMX_U32 nPortIndex;         /**< port that this structure applies to */
-    OMX_U16 nNumTracks;         /**< Number of MIDI tracks in the file, read only field. 
-                                     NOTE: May not return a meaningful value until the entire 
+    OMX_U16 nNumTracks;         /**< Number of MIDI tracks in the file, read only field.
+                                     NOTE: May not return a meaningful value until the entire
                                      file is parsed and buffered.  */
-    OMX_U32 nDuration;          /**< The length of the currently open MIDI resource 
-                                     in milliseconds. NOTE: May not return a meaningful value 
-                                     until the entire file is parsed and buffered.  */  
-    OMX_U32 nPosition;          /**< Current Position of the MIDI resource being played 
-                                     in milliseconds */
-    OMX_BOOL bVibra;            /**< Does Vibra track exist? NOTE: May not return a meaningful 
-                                     value until the entire file is parsed and buffered. */
-    OMX_U32 nNumMetaEvents;     /**< Total number of MIDI Meta Events in the currently 
-                                     open MIDI resource. NOTE: May not return a meaningful value 
+    OMX_U32 nDuration;          /**< The length of the currently open MIDI resource
+                                     in milliseconds. NOTE: May not return a meaningful value
                                      until the entire file is parsed and buffered.  */
-    OMX_U32 nNumActiveVoices;   /**< Number of active voices in the currently playing 
-                                     MIDI resource. NOTE: May not return a meaningful value until 
+    OMX_U32 nPosition;          /**< Current Position of the MIDI resource being played
+                                     in milliseconds */
+    OMX_BOOL bVibra;            /**< Does Vibra track exist? NOTE: May not return a meaningful
+                                     value until the entire file is parsed and buffered. */
+    OMX_U32 nNumMetaEvents;     /**< Total number of MIDI Meta Events in the currently
+                                     open MIDI resource. NOTE: May not return a meaningful value
+                                     until the entire file is parsed and buffered.  */
+    OMX_U32 nNumActiveVoices;   /**< Number of active voices in the currently playing
+                                     MIDI resource. NOTE: May not return a meaningful value until
                                      the entire file is parsed and buffered. */
     OMX_AUDIO_MIDIPLAYBACKSTATETYPE eMIDIPlayBackState;  /**< MIDI playback state enumeration, read only field */
 } OMX_AUDIO_CONFIG_MIDISTATUSTYPE;
 
 
 /** MIDI Meta Event structure one per Meta Event.
- *  MIDI Meta Events are like audio metadata, except that they are interspersed 
- *  with the MIDI content throughout the file and are not localized in the header. 
- *  As such, it is necessary to retrieve information about these Meta Events from 
- *  the engine, as it encounters these Meta Events within the MIDI content. 
- *  For example, SMF files can have up to 14 types of MIDI Meta Events (copyright, 
- *  author, default tempo, etc.) scattered throughout the file. 
+ *  MIDI Meta Events are like audio metadata, except that they are interspersed
+ *  with the MIDI content throughout the file and are not localized in the header.
+ *  As such, it is necessary to retrieve information about these Meta Events from
+ *  the engine, as it encounters these Meta Events within the MIDI content.
+ *  For example, SMF files can have up to 14 types of MIDI Meta Events (copyright,
+ *  author, default tempo, etc.) scattered throughout the file.
  *  @ingroup midi
  */
-typedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE{ 
-    OMX_U32 nSize;            /**< size of the structure in bytes */ 
-    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ 
-    OMX_U32 nPortIndex;       /**< port that this structure applies to */ 
-    OMX_U32 nIndex;           /**< Index of Meta Event */ 
-    OMX_U8 nMetaEventType;    /**< Meta Event Type, 7bits (i.e. 0 - 127) */ 
-    OMX_U32 nMetaEventSize;   /**< size of the Meta Event in bytes */ 
+typedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE{
+    OMX_U32 nSize;            /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex;       /**< port that this structure applies to */
+    OMX_U32 nIndex;           /**< Index of Meta Event */
+    OMX_U8 nMetaEventType;    /**< Meta Event Type, 7bits (i.e. 0 - 127) */
+    OMX_U32 nMetaEventSize;   /**< size of the Meta Event in bytes */
     OMX_U32 nTrack;           /**< track number for the meta event */
     OMX_U32 nPosition;        /**< Position of the meta-event in milliseconds */
-} OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE; 
+} OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE;
 
 
-/** MIDI Meta Event Data structure - one per Meta Event. 
+/** MIDI Meta Event Data structure - one per Meta Event.
  * @ingroup midi
- */ 
-typedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE{ 
-    OMX_U32 nSize;            /**< size of the structure in bytes */ 
-    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ 
-    OMX_U32 nPortIndex;       /**< port that this structure applies to */ 
-    OMX_U32 nIndex;           /**< Index of Meta Event */ 
-    OMX_U32 nMetaEventSize;   /**< size of the Meta Event in bytes */ 
-    OMX_U8 nData[1];          /**< array of one or more bytes of meta data 
-                                   as indicated by the nMetaEventSize field */ 
-} OMX_AUDIO_CONFIG__MIDIMETAEVENTDATATYPE; 
+ */
+typedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE{
+    OMX_U32 nSize;            /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex;       /**< port that this structure applies to */
+    OMX_U32 nIndex;           /**< Index of Meta Event */
+    OMX_U32 nMetaEventSize;   /**< size of the Meta Event in bytes */
+    OMX_U8 nData[1];          /**< array of one or more bytes of meta data
+                                   as indicated by the nMetaEventSize field */
+} OMX_AUDIO_CONFIG__MIDIMETAEVENTDATATYPE;
 
 
 /** Audio Volume adjustment for a port */
 typedef struct OMX_AUDIO_CONFIG_VOLUMETYPE {
     OMX_U32 nSize;              /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
-    OMX_U32 nPortIndex;         /**< Port index indicating which port to 
-                                     set.  Select the input port to set 
-                                     just that port's volume.  Select the 
-                                     output port to adjust the master 
+    OMX_U32 nPortIndex;         /**< Port index indicating which port to
+                                     set.  Select the input port to set
+                                     just that port's volume.  Select the
+                                     output port to adjust the master
                                      volume. */
-    OMX_BOOL bLinear;           /**< Is the volume to be set in linear (0.100) 
+    OMX_BOOL bLinear;           /**< Is the volume to be set in linear (0.100)
                                      or logarithmic scale (mB) */
     OMX_BS32 sVolume;           /**< Volume linear setting in the 0..100 range, OR
                                      Volume logarithmic setting for this port.  The values
                                      for volume are in mB (millibels = 1/100 dB) relative
-                                     to a gain of 1 (e.g. the output is the same as the 
-                                     input level).  Values are in mB from nMax 
+                                     to a gain of 1 (e.g. the output is the same as the
+                                     input level).  Values are in mB from nMax
                                      (maximum volume) to nMin mB (typically negative).
                                      Since the volume is "voltage"
                                      and not a "power", it takes a setting of
                                      -600 mB to decrease the volume by 1/2.  If
-                                     a component cannot accurately set the 
+                                     a component cannot accurately set the
                                      volume to the requested value, it must
                                      set the volume to the closest value BELOW
                                      the requested value.  When getting the
@@ -1069,27 +1069,27 @@
 typedef struct OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE {
     OMX_U32 nSize;              /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
-    OMX_U32 nPortIndex;         /**< Port index indicating which port to 
-                                     set.  Select the input port to set 
-                                     just that port's volume.  Select the 
-                                     output port to adjust the master 
+    OMX_U32 nPortIndex;         /**< Port index indicating which port to
+                                     set.  Select the input port to set
+                                     just that port's volume.  Select the
+                                     output port to adjust the master
                                      volume. */
-    OMX_U32 nChannel;           /**< channel to select from 0 to N-1, 
+    OMX_U32 nChannel;           /**< channel to select from 0 to N-1,
                                      using OMX_ALL to apply volume settings
                                      to all channels */
-    OMX_BOOL bLinear;           /**< Is the volume to be set in linear (0.100) or 
+    OMX_BOOL bLinear;           /**< Is the volume to be set in linear (0.100) or
                                      logarithmic scale (mB) */
     OMX_BS32 sVolume;           /**< Volume linear setting in the 0..100 range, OR
-                                     Volume logarithmic setting for this port.  
-                                     The values for volume are in mB 
+                                     Volume logarithmic setting for this port.
+                                     The values for volume are in mB
                                      (millibels = 1/100 dB) relative to a gain
-                                     of 1 (e.g. the output is the same as the 
-                                     input level).  Values are in mB from nMax 
-                                     (maximum volume) to nMin mB (typically negative).  
+                                     of 1 (e.g. the output is the same as the
+                                     input level).  Values are in mB from nMax
+                                     (maximum volume) to nMin mB (typically negative).
                                      Since the volume is "voltage"
                                      and not a "power", it takes a setting of
                                      -600 mB to decrease the volume by 1/2.  If
-                                     a component cannot accurately set the 
+                                     a component cannot accurately set the
                                      volume to the requested value, it must
                                      set the volume to the closest value BELOW
                                      the requested value.  When getting the
@@ -1104,12 +1104,12 @@
 typedef struct OMX_AUDIO_CONFIG_BALANCETYPE {
     OMX_U32 nSize;              /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
-    OMX_U32 nPortIndex;         /**< Port index indicating which port to 
-                                     set.  Select the input port to set 
-                                     just that port's balance.  Select the 
-                                     output port to adjust the master 
+    OMX_U32 nPortIndex;         /**< Port index indicating which port to
+                                     set.  Select the input port to set
+                                     just that port's balance.  Select the
+                                     output port to adjust the master
                                      balance. */
-    OMX_S32 nBalance;           /**< balance setting for this port 
+    OMX_S32 nBalance;           /**< balance setting for this port
                                      (-100 to 100, where -100 indicates
                                      all left, and no right */
 } OMX_AUDIO_CONFIG_BALANCETYPE;
@@ -1119,10 +1119,10 @@
 typedef struct OMX_AUDIO_CONFIG_MUTETYPE {
     OMX_U32 nSize;              /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
-    OMX_U32 nPortIndex;         /**< Port index indicating which port to 
-                                     set.  Select the input port to set 
-                                     just that port's mute.  Select the 
-                                     output port to adjust the master 
+    OMX_U32 nPortIndex;         /**< Port index indicating which port to
+                                     set.  Select the input port to set
+                                     just that port's mute.  Select the
+                                     output port to adjust the master
                                      mute. */
     OMX_BOOL bMute;             /**< Mute setting for this port */
 } OMX_AUDIO_CONFIG_MUTETYPE;
@@ -1133,20 +1133,20 @@
     OMX_U32 nSize;              /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
     OMX_U32 nPortIndex;         /**< port that this structure applies to */
-    OMX_U32 nChannel;           /**< channel to select from 0 to N-1, 
+    OMX_U32 nChannel;           /**< channel to select from 0 to N-1,
                                      using OMX_ALL to apply mute settings
                                      to all channels */
     OMX_BOOL bMute;             /**< Mute setting for this channel */
     OMX_BOOL bIsMIDI;           /**< TRUE if nChannel refers to a MIDI channel,
-                                     FALSE otherwise */ 
+                                     FALSE otherwise */
 } OMX_AUDIO_CONFIG_CHANNELMUTETYPE;
 
 
 
-/** Enable / Disable for loudness control, which boosts bass and to a 
+/** Enable / Disable for loudness control, which boosts bass and to a
  *  smaller extent high end frequencies to compensate for hearing
  *  ability at the extreme ends of the audio spectrum
- */ 
+ */
 typedef struct OMX_AUDIO_CONFIG_LOUDNESSTYPE {
     OMX_U32 nSize;             /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
@@ -1156,33 +1156,33 @@
 
 
 /** Enable / Disable for bass, which controls low frequencies
- */ 
+ */
 typedef struct OMX_AUDIO_CONFIG_BASSTYPE {
     OMX_U32 nSize;             /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
     OMX_U32 nPortIndex;        /**< port that this structure applies to */
     OMX_BOOL bEnable;          /**< Enable/disable for bass control */
-    OMX_S32 nBass;             /**< bass setting for the port, as a 
-                                    continuous value from -100 to 100  
+    OMX_S32 nBass;             /**< bass setting for the port, as a
+                                    continuous value from -100 to 100
                                     (0 means no change in bass level)*/
 } OMX_AUDIO_CONFIG_BASSTYPE;
 
 
 /** Enable / Disable for treble, which controls high frequencies tones
- */ 
+ */
 typedef struct OMX_AUDIO_CONFIG_TREBLETYPE {
     OMX_U32 nSize;             /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
     OMX_U32 nPortIndex;        /**< port that this structure applies to */
     OMX_BOOL bEnable;          /**< Enable/disable for treble control */
     OMX_S32  nTreble;          /**< treble setting for the port, as a
-                                    continuous value from -100 to 100  
+                                    continuous value from -100 to 100
                                     (0 means no change in treble level) */
 } OMX_AUDIO_CONFIG_TREBLETYPE;
 
 
-/** An equalizer is typically used for two reasons: to compensate for an 
- *  sub-optimal frequency response of a system to make it sound more natural 
+/** An equalizer is typically used for two reasons: to compensate for an
+ *  sub-optimal frequency response of a system to make it sound more natural
  *  or to create intentionally some unnatural coloring to the sound to create
  *  an effect.
  *  @ingroup effects
@@ -1192,33 +1192,33 @@
     OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
     OMX_U32 nPortIndex;        /**< port that this structure applies to */
     OMX_BOOL bEnable;          /**< Enable/disable for equalizer */
-    OMX_BU32 sBandIndex;       /**< Band number to be set.  Upper Limit is 
+    OMX_BU32 sBandIndex;       /**< Band number to be set.  Upper Limit is
                                     N-1, where N is the number of bands, lower limit is 0 */
     OMX_BU32 sCenterFreq;      /**< Center frequecies in Hz.  This is a
-                                    read only element and is used to determine 
-                                    the lower, center and upper frequency of 
+                                    read only element and is used to determine
+                                    the lower, center and upper frequency of
                                     this band.  */
     OMX_BS32 sBandLevel;       /**< band level in millibels */
 } OMX_AUDIO_CONFIG_EQUALIZERTYPE;
 
 
-/** Stereo widening mode type 
+/** Stereo widening mode type
  * @ingroup effects
- */ 
+ */
 typedef enum OMX_AUDIO_STEREOWIDENINGTYPE {
     OMX_AUDIO_StereoWideningHeadphones,    /**< Stereo widening for loudspeakers */
     OMX_AUDIO_StereoWideningLoudspeakers,  /**< Stereo widening for closely spaced loudspeakers */
-    OMX_AUDIO_StereoWideningKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_StereoWideningKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_AUDIO_StereoWideningVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_StereoWideningMax = 0x7FFFFFFF
 } OMX_AUDIO_STEREOWIDENINGTYPE;
 
 
 /** Control for stereo widening, which is a special 2-channel
- *  case of the audio virtualizer effect. For example, for 5.1-channel 
- *  output, it translates to virtual surround sound. 
+ *  case of the audio virtualizer effect. For example, for 5.1-channel
+ *  output, it translates to virtual surround sound.
  * @ingroup effects
- */ 
+ */
 typedef struct OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE {
     OMX_U32 nSize;             /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
@@ -1231,10 +1231,10 @@
 
 
 /** The chorus effect (or ``choralizer'') is any signal processor which makes
- *  one sound source (such as a voice) sound like many such sources singing 
- *  (or playing) in unison. Since performance in unison is never exact, chorus 
- *  effects simulate this by making independently modified copies of the input 
- *  signal. Modifications may include (1) delay, (2) frequency shift, and 
+ *  one sound source (such as a voice) sound like many such sources singing
+ *  (or playing) in unison. Since performance in unison is never exact, chorus
+ *  effects simulate this by making independently modified copies of the input
+ *  signal. Modifications may include (1) delay, (2) frequency shift, and
  *  (3) amplitude modulation.
  * @ingroup effects
  */
@@ -1245,16 +1245,16 @@
     OMX_BOOL bEnable;          /**< Enable/disable for chorus */
     OMX_BU32 sDelay;           /**< average delay in milliseconds */
     OMX_BU32 sModulationRate;  /**< rate of modulation in millihertz */
-    OMX_U32 nModulationDepth;  /**< depth of modulation as a percentage of 
+    OMX_U32 nModulationDepth;  /**< depth of modulation as a percentage of
                                     delay (i.e. 0 to 100) */
     OMX_BU32 nFeedback;        /**< Feedback from chorus output to input in percentage */
 } OMX_AUDIO_CONFIG_CHORUSTYPE;
 
 
-/** Reverberation is part of the reflected sound that follows the early 
- *  reflections. In a typical room, this consists of a dense succession of 
- *  echoes whose energy decays exponentially. The reverberation effect structure 
- *  as defined here includes both (early) reflections as well as (late) reverberations. 
+/** Reverberation is part of the reflected sound that follows the early
+ *  reflections. In a typical room, this consists of a dense succession of
+ *  echoes whose energy decays exponentially. The reverberation effect structure
+ *  as defined here includes both (early) reflections as well as (late) reverberations.
  * @ingroup effects
  */
 typedef struct OMX_AUDIO_CONFIG_REVERBERATIONTYPE {
@@ -1262,48 +1262,48 @@
     OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */
     OMX_U32 nPortIndex;           /**< port that this structure applies to */
     OMX_BOOL bEnable;             /**< Enable/disable for reverberation control */
-    OMX_BS32 sRoomLevel;          /**< Intensity level for the whole room effect 
-                                       (i.e. both early reflections and late 
+    OMX_BS32 sRoomLevel;          /**< Intensity level for the whole room effect
+                                       (i.e. both early reflections and late
                                        reverberation) in millibels */
     OMX_BS32 sRoomHighFreqLevel;  /**< Attenuation at high frequencies
                                        relative to the intensity at low
                                        frequencies in millibels */
     OMX_BS32 sReflectionsLevel;   /**< Intensity level of early reflections
                                        (relative to room value), in millibels */
-    OMX_BU32 sReflectionsDelay;   /**< Delay time of the first reflection relative 
+    OMX_BU32 sReflectionsDelay;   /**< Delay time of the first reflection relative
                                        to the direct path, in milliseconds */
     OMX_BS32 sReverbLevel;        /**< Intensity level of late reverberation
                                        relative to room level, in millibels */
-    OMX_BU32 sReverbDelay;        /**< Time delay from the first early reflection 
-                                       to the beginning of the late reverberation 
+    OMX_BU32 sReverbDelay;        /**< Time delay from the first early reflection
+                                       to the beginning of the late reverberation
                                        section, in milliseconds */
     OMX_BU32 sDecayTime;          /**< Late reverberation decay time at low
                                        frequencies, in milliseconds */
-    OMX_BU32 nDecayHighFreqRatio; /**< Ratio of high frequency decay time relative 
+    OMX_BU32 nDecayHighFreqRatio; /**< Ratio of high frequency decay time relative
                                        to low frequency decay time in percent  */
     OMX_U32 nDensity;             /**< Modal density in the late reverberation decay,
                                        in percent (i.e. 0 - 100) */
     OMX_U32 nDiffusion;           /**< Echo density in the late reverberation decay,
                                        in percent (i.e. 0 - 100) */
-    OMX_BU32 sReferenceHighFreq;  /**< Reference high frequency in Hertz. This is 
-                                       the frequency used as the reference for all 
+    OMX_BU32 sReferenceHighFreq;  /**< Reference high frequency in Hertz. This is
+                                       the frequency used as the reference for all
                                        the high-frequency settings above */
 
 } OMX_AUDIO_CONFIG_REVERBERATIONTYPE;
 
 
-/** Possible settings for the Echo Cancelation structure to use 
+/** Possible settings for the Echo Cancelation structure to use
  * @ingroup effects
  */
 typedef enum OMX_AUDIO_ECHOCANTYPE {
    OMX_AUDIO_EchoCanOff = 0,    /**< Echo Cancellation is disabled */
-   OMX_AUDIO_EchoCanNormal,     /**< Echo Cancellation normal operation - 
+   OMX_AUDIO_EchoCanNormal,     /**< Echo Cancellation normal operation -
                                      echo from plastics and face */
-   OMX_AUDIO_EchoCanHFree,      /**< Echo Cancellation optimized for 
+   OMX_AUDIO_EchoCanHFree,      /**< Echo Cancellation optimized for
                                      Hands Free operation */
-   OMX_AUDIO_EchoCanCarKit,    /**< Echo Cancellation optimized for 
+   OMX_AUDIO_EchoCanCarKit,    /**< Echo Cancellation optimized for
                                      Car Kit (longer echo) */
-   OMX_AUDIO_EchoCanKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+   OMX_AUDIO_EchoCanKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
    OMX_AUDIO_EchoCanVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
    OMX_AUDIO_EchoCanMax = 0x7FFFFFFF
 } OMX_AUDIO_ECHOCANTYPE;
@@ -1312,7 +1312,7 @@
 /** Enable / Disable for echo cancelation, which removes undesired echo's
  *  from the audio
  * @ingroup effects
- */ 
+ */
 typedef struct OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE {
     OMX_U32 nSize;             /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
@@ -1324,7 +1324,7 @@
 /** Enable / Disable for noise reduction, which undesired noise from
  * the audio
  * @ingroup effects
- */ 
+ */
 typedef struct OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE {
     OMX_U32 nSize;             /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
diff --git a/include/media/openmax/OMX_AudioExt.h b/include/media/openmax/OMX_AudioExt.h
new file mode 100644
index 0000000..2a1c3f2
--- /dev/null
+++ b/include/media/openmax/OMX_AudioExt.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2010 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is 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 Software.
+ *
+ * THE SOFTWARE IS 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
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** OMX_AudioExt.h - OpenMax IL version 1.1.2
+ * The OMX_AudioExt header file contains extensions to the
+ * definitions used by both the application and the component to
+ * access video items.
+ */
+
+#ifndef OMX_AudioExt_h
+#define OMX_AudioExt_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Each OMX header shall include all required header files to allow the
+ * header to compile without errors.  The includes below are required
+ * for this header file to compile successfully
+ */
+#include <OMX_Core.h>
+
+#define OMX_AUDIO_AACToolAndroidSSBR (OMX_AUDIO_AACToolVendor << 0) /**< SSBR: MPEG-4 Single-rate (downsampled) Spectral Band Replication tool allowed or active */
+#define OMX_AUDIO_AACToolAndroidDSBR (OMX_AUDIO_AACToolVendor << 1) /**< DSBR: MPEG-4 Dual-rate Spectral Band Replication tool allowed or active */
+
+typedef enum OMX_AUDIO_CODINGEXTTYPE {
+    OMX_AUDIO_CodingAndroidUnused = OMX_AUDIO_CodingKhronosExtensions + 0x00100000,
+    OMX_AUDIO_CodingAndroidAC3,         /**< AC3 encoded data */
+    OMX_AUDIO_CodingAndroidOPUS,        /**< OPUS encoded data */
+    OMX_AUDIO_CodingAndroidEAC3,        /**< EAC3 encoded data */
+} OMX_AUDIO_CODINGEXTTYPE;
+
+typedef struct OMX_AUDIO_PARAM_ANDROID_AC3TYPE {
+    OMX_U32 nSize;                 /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */
+    OMX_U32 nPortIndex;            /**< port that this structure applies to */
+    OMX_U32 nChannels;             /**< Number of channels */
+    OMX_U32 nSampleRate;           /**< Sampling rate of the source data.  Use 0 for
+                                        variable or unknown sampling rate. */
+} OMX_AUDIO_PARAM_ANDROID_AC3TYPE;
+
+typedef struct OMX_AUDIO_PARAM_ANDROID_EAC3TYPE {
+    OMX_U32 nSize;                 /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */
+    OMX_U32 nPortIndex;            /**< port that this structure applies to */
+    OMX_U32 nChannels;             /**< Number of channels */
+    OMX_U32 nSampleRate;           /**< Sampling rate of the source data.  Use 0 for
+                                        variable or unknown sampling rate. */
+} OMX_AUDIO_PARAM_ANDROID_EAC3TYPE;
+
+typedef struct OMX_AUDIO_PARAM_ANDROID_OPUSTYPE {
+    OMX_U32 nSize;            /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_U32 nPortIndex;       /**< port that this structure applies to */
+    OMX_U32 nChannels;        /**< Number of channels */
+    OMX_U32 nBitRate;         /**< Bit rate of the encoded data data.  Use 0 for variable
+                                   rate or unknown bit rates. Encoding is set to the
+                                   bitrate closest to specified  value (in bps) */
+    OMX_U32 nSampleRate;      /**< Sampling rate of the source data.  Use 0 for
+                                   variable or unknown sampling rate. */
+    OMX_U32 nAudioBandWidth;  /**< Audio band width (in Hz) to which an encoder should
+                                   limit the audio signal. Use 0 to let encoder decide */
+} OMX_AUDIO_PARAM_ANDROID_OPUSTYPE;
+
+typedef struct OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE {
+    OMX_U32 nSize;            /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+    OMX_S32 nMaxOutputChannels;    /**< Maximum channel count to be output, -1 if unspecified, 0 if downmixing disabled */
+    OMX_S32 nDrcCut;               /**< The DRC attenuation factor, between 0 and 127, -1 if unspecified */
+    OMX_S32 nDrcBoost;             /**< The DRC amplification factor, between 0 and 127, -1 if unspecified */
+    OMX_S32 nHeavyCompression;     /**< 0 for light compression, 1 for heavy compression, -1 if unspecified */
+    OMX_S32 nTargetReferenceLevel; /**< Target reference level, between 0 and 127, -1 if unspecified */
+    OMX_S32 nEncodedTargetLevel;   /**< Target reference level assumed at the encoder, between 0 and 127, -1 if unspecified */
+    OMX_S32 nPCMLimiterEnable;     /**< Signal level limiting, 0 for disable, 1 for enable, -1 if unspecified */
+} OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* OMX_AudioExt_h */
+/* File EOF */
diff --git a/include/media/openmax/OMX_Component.h b/include/media/openmax/OMX_Component.h
index b5b784e..0dc2c76 100644
--- a/include/media/openmax/OMX_Component.h
+++ b/include/media/openmax/OMX_Component.h
@@ -16,25 +16,25 @@
  * -------------------------------------------------------------------
  */
 /*
- * Copyright (c) 2008 The Khronos Group Inc. 
- * 
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
  * "Software"), to deal in the Software without restriction, including
  * without limitation the rights to use, copy, modify, merge, publish,
  * distribute, sublicense, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject
- * to the following conditions: 
+ * to the following conditions:
  * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software. 
- * 
+ * in all copies or substantial portions of the Software.
+ *
  * THE SOFTWARE IS 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
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
@@ -55,7 +55,7 @@
 
 /* Each OMX header must include all required header files to allow the
  *  header to compile without errors.  The includes below are required
- *  for this header file to compile successfully 
+ *  for this header file to compile successfully
  */
 
 #include <OMX_Audio.h>
@@ -64,12 +64,12 @@
 #include <OMX_Other.h>
 
 /** @ingroup comp */
-typedef enum OMX_PORTDOMAINTYPE { 
-    OMX_PortDomainAudio, 
-    OMX_PortDomainVideo, 
-    OMX_PortDomainImage, 
+typedef enum OMX_PORTDOMAINTYPE {
+    OMX_PortDomainAudio,
+    OMX_PortDomainVideo,
+    OMX_PortDomainImage,
     OMX_PortDomainOther,
-    OMX_PortDomainKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_PortDomainKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_PortDomainVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_PortDomainMax = 0x7ffffff
 } OMX_PORTDOMAINTYPE;
@@ -88,7 +88,7 @@
                                         When disabled a port is unpopulated. A disabled port
                                         is not populated with buffers on a transition to IDLE. */
     OMX_BOOL bPopulated;           /**< Port is populated with all of its buffers as indicated by
-                                        nBufferCountActual. A disabled port is always unpopulated. 
+                                        nBufferCountActual. A disabled port is always unpopulated.
                                         An enabled port is populated on a transition to OMX_StateIdle
                                         and unpopulated on a transition to loaded. */
     OMX_PORTDOMAINTYPE eDomain;    /**< Domain of the port. Determines the contents of metadata below. */
@@ -103,26 +103,26 @@
 } OMX_PARAM_PORTDEFINITIONTYPE;
 
 /** @ingroup comp */
-typedef struct OMX_PARAM_U32TYPE { 
-    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */ 
-    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */ 
-    OMX_U32 nPortIndex;               /**< port that this structure applies to */ 
+typedef struct OMX_PARAM_U32TYPE {
+    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */
+    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */
+    OMX_U32 nPortIndex;               /**< port that this structure applies to */
     OMX_U32 nU32;                     /**< U32 value */
 } OMX_PARAM_U32TYPE;
 
 /** @ingroup rpm */
 typedef enum OMX_SUSPENSIONPOLICYTYPE {
     OMX_SuspensionDisabled, /**< No suspension; v1.0 behavior */
-    OMX_SuspensionEnabled,  /**< Suspension allowed */   
-    OMX_SuspensionPolicyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_SuspensionEnabled,  /**< Suspension allowed */
+    OMX_SuspensionPolicyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_SuspensionPolicyStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_SuspensionPolicyMax = 0x7fffffff
 } OMX_SUSPENSIONPOLICYTYPE;
 
 /** @ingroup rpm */
 typedef struct OMX_PARAM_SUSPENSIONPOLICYTYPE {
-    OMX_U32 nSize;                  
-    OMX_VERSIONTYPE nVersion;        
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
     OMX_SUSPENSIONPOLICYTYPE ePolicy;
 } OMX_PARAM_SUSPENSIONPOLICYTYPE;
 
@@ -130,22 +130,22 @@
 typedef enum OMX_SUSPENSIONTYPE {
     OMX_NotSuspended, /**< component is not suspended */
     OMX_Suspended,    /**< component is suspended */
-    OMX_SuspensionKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_SuspensionKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_SuspensionVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_SuspendMax = 0x7FFFFFFF
 } OMX_SUSPENSIONTYPE;
 
 /** @ingroup rpm */
 typedef struct OMX_PARAM_SUSPENSIONTYPE {
-    OMX_U32 nSize;                  
-    OMX_VERSIONTYPE nVersion;       
-    OMX_SUSPENSIONTYPE eType;             
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_SUSPENSIONTYPE eType;
 } OMX_PARAM_SUSPENSIONTYPE ;
 
 typedef struct OMX_CONFIG_BOOLEANTYPE {
     OMX_U32 nSize;
     OMX_VERSIONTYPE nVersion;
-    OMX_BOOL bEnabled;    
+    OMX_BOOL bEnabled;
 } OMX_CONFIG_BOOLEANTYPE;
 
 /* Parameter specifying the content uri to use. */
@@ -171,9 +171,9 @@
 typedef struct OMX_RESOURCECONCEALMENTTYPE {
     OMX_U32 nSize;             /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */
-    OMX_BOOL bResourceConcealmentForbidden; /**< disallow the use of resource concealment 
-                                            methods (like degrading algorithm quality to 
-                                            lower resource consumption or functional bypass) 
+    OMX_BOOL bResourceConcealmentForbidden; /**< disallow the use of resource concealment
+                                            methods (like degrading algorithm quality to
+                                            lower resource consumption or functional bypass)
                                             on a component as a resolution to resource conflicts. */
 } OMX_RESOURCECONCEALMENTTYPE;
 
@@ -188,7 +188,7 @@
     OMX_MetadataCharsetJavaConformantUTF8,
     OMX_MetadataCharsetUTF7,
     OMX_MetadataCharsetImapUTF7,
-    OMX_MetadataCharsetUTF16LE, 
+    OMX_MetadataCharsetUTF16LE,
     OMX_MetadataCharsetUTF16BE,
     OMX_MetadataCharsetGB12345,
     OMX_MetadataCharsetHZGB2312,
@@ -214,7 +214,7 @@
     OMX_MetadataCharsetISO2022JP1,
     OMX_MetadataCharsetISOEUCJP,
     OMX_MetadataCharsetSMS7Bit,
-    OMX_MetadataCharsetKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_MetadataCharsetKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_MetadataCharsetVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_MetadataCharsetTypeMax= 0x7FFFFFFF
 } OMX_METADATACHARSETTYPE;
@@ -226,7 +226,7 @@
     OMX_MetadataScopeTopLevel,
     OMX_MetadataScopePortLevel,
     OMX_MetadataScopeNodeLevel,
-    OMX_MetadataScopeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_MetadataScopeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_MetadataScopeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_MetadataScopeTypeMax = 0x7fffffff
 } OMX_METADATASCOPETYPE;
@@ -237,7 +237,7 @@
     OMX_MetadataSearchValueSizeByIndex,
     OMX_MetadataSearchItemByIndex,
     OMX_MetadataSearchNextItemByKey,
-    OMX_MetadataSearchKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_MetadataSearchKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_MetadataSearchVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_MetadataSearchTypeMax = 0x7fffffff
 } OMX_METADATASEARCHMODETYPE;
@@ -258,7 +258,7 @@
     OMX_VERSIONTYPE nVersion;
     OMX_METADATASCOPETYPE eScopeMode;
     OMX_U32 nScopeSpecifier;
-    OMX_U32 nMetadataItemIndex;  
+    OMX_U32 nMetadataItemIndex;
     OMX_METADATASEARCHMODETYPE eSearchMode;
     OMX_METADATACHARSETTYPE eKeyCharset;
     OMX_U8 nKeySizeUsed;
@@ -287,30 +287,30 @@
     OMX_VERSIONTYPE nVersion;
     OMX_BOOL bAllKeys;
     OMX_U32 nParentNodeID;
-    OMX_U32 nNodeIndex; 
-    OMX_U32 nNodeID; 
+    OMX_U32 nNodeIndex;
+    OMX_U32 nNodeID;
     OMX_STRING cNodeName;
     OMX_BOOL bIsLeafType;
 } OMX_CONFIG_CONTAINERNODEIDTYPE;
 
 /** @ingroup metadata */
-typedef struct OMX_PARAM_METADATAFILTERTYPE 
-{ 
-    OMX_U32 nSize; 
-    OMX_VERSIONTYPE nVersion; 
-    OMX_BOOL bAllKeys;	/* if true then this structure refers to all keys and 
+typedef struct OMX_PARAM_METADATAFILTERTYPE
+{
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_BOOL bAllKeys;  /* if true then this structure refers to all keys and
                          * the three key fields below are ignored */
     OMX_METADATACHARSETTYPE eKeyCharset;
-    OMX_U32 nKeySizeUsed; 
-    OMX_U8   nKey [128]; 
+    OMX_U32 nKeySizeUsed;
+    OMX_U8   nKey [128];
     OMX_U32 nLanguageCountrySizeUsed;
     OMX_U8 nLanguageCountry[128];
-    OMX_BOOL bEnabled;	/* if true then key is part of filter (e.g. 
+    OMX_BOOL bEnabled;  /* if true then key is part of filter (e.g.
                          * retained for query later). If false then
                          * key is not part of filter */
-} OMX_PARAM_METADATAFILTERTYPE; 
+} OMX_PARAM_METADATAFILTERTYPE;
 
-/** The OMX_HANDLETYPE structure defines the component handle.  The component 
+/** The OMX_HANDLETYPE structure defines the component handle.  The component
  *  handle is used to access all of the component's public methods and also
  *  contains pointers to the component's private data area.  The component
  *  handle is initialized by the OMX core (with help from the component)
@@ -318,7 +318,7 @@
  *  successfully loaded, the application can safely access any of the
  *  component's public functions (although some may return an error because
  *  the state is inappropriate for the access).
- * 
+ *
  *  @ingroup comp
  */
 typedef struct OMX_COMPONENTTYPE
@@ -329,26 +329,26 @@
         function will fill in this value. */
     OMX_U32 nSize;
 
-    /** nVersion is the version of the OMX specification that the structure 
-        is built against.  It is the responsibility of the creator of this 
-        structure to initialize this value and every user of this structure 
-        should verify that it knows how to use the exact version of 
+    /** nVersion is the version of the OMX specification that the structure
+        is built against.  It is the responsibility of the creator of this
+        structure to initialize this value and every user of this structure
+        should verify that it knows how to use the exact version of
         this structure found herein. */
     OMX_VERSIONTYPE nVersion;
 
-    /** pComponentPrivate is a pointer to the component private data area.  
-        This member is allocated and initialized by the component when the 
-        component is first loaded.  The application should not access this 
+    /** pComponentPrivate is a pointer to the component private data area.
+        This member is allocated and initialized by the component when the
+        component is first loaded.  The application should not access this
         data area. */
     OMX_PTR pComponentPrivate;
 
-    /** pApplicationPrivate is a pointer that is a parameter to the 
-        OMX_GetHandle method, and contains an application private value 
-        provided by the IL client.  This application private data is 
+    /** pApplicationPrivate is a pointer that is a parameter to the
+        OMX_GetHandle method, and contains an application private value
+        provided by the IL client.  This application private data is
         returned to the IL Client by OMX in all callbacks */
     OMX_PTR pApplicationPrivate;
 
-    /** refer to OMX_GetComponentVersion in OMX_core.h or the OMX IL 
+    /** refer to OMX_GetComponentVersion in OMX_core.h or the OMX IL
         specification for details on the GetComponentVersion method.
      */
     OMX_ERRORTYPE (*GetComponentVersion)(
@@ -358,7 +358,7 @@
             OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
             OMX_OUT OMX_UUIDTYPE* pComponentUUID);
 
-    /** refer to OMX_SendCommand in OMX_core.h or the OMX IL 
+    /** refer to OMX_SendCommand in OMX_core.h or the OMX IL
         specification for details on the SendCommand method.
      */
     OMX_ERRORTYPE (*SendCommand)(
@@ -367,43 +367,43 @@
             OMX_IN  OMX_U32 nParam1,
             OMX_IN  OMX_PTR pCmdData);
 
-    /** refer to OMX_GetParameter in OMX_core.h or the OMX IL 
+    /** refer to OMX_GetParameter in OMX_core.h or the OMX IL
         specification for details on the GetParameter method.
      */
     OMX_ERRORTYPE (*GetParameter)(
-            OMX_IN  OMX_HANDLETYPE hComponent, 
-            OMX_IN  OMX_INDEXTYPE nParamIndex,  
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nParamIndex,
             OMX_INOUT OMX_PTR pComponentParameterStructure);
 
 
-    /** refer to OMX_SetParameter in OMX_core.h or the OMX IL 
+    /** refer to OMX_SetParameter in OMX_core.h or the OMX IL
         specification for details on the SetParameter method.
      */
     OMX_ERRORTYPE (*SetParameter)(
-            OMX_IN  OMX_HANDLETYPE hComponent, 
+            OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_INDEXTYPE nIndex,
             OMX_IN  OMX_PTR pComponentParameterStructure);
 
 
-    /** refer to OMX_GetConfig in OMX_core.h or the OMX IL 
+    /** refer to OMX_GetConfig in OMX_core.h or the OMX IL
         specification for details on the GetConfig method.
      */
     OMX_ERRORTYPE (*GetConfig)(
             OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex, 
+            OMX_IN  OMX_INDEXTYPE nIndex,
             OMX_INOUT OMX_PTR pComponentConfigStructure);
 
 
-    /** refer to OMX_SetConfig in OMX_core.h or the OMX IL 
+    /** refer to OMX_SetConfig in OMX_core.h or the OMX IL
         specification for details on the SetConfig method.
      */
     OMX_ERRORTYPE (*SetConfig)(
             OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex, 
+            OMX_IN  OMX_INDEXTYPE nIndex,
             OMX_IN  OMX_PTR pComponentConfigStructure);
 
 
-    /** refer to OMX_GetExtensionIndex in OMX_core.h or the OMX IL 
+    /** refer to OMX_GetExtensionIndex in OMX_core.h or the OMX IL
         specification for details on the GetExtensionIndex method.
      */
     OMX_ERRORTYPE (*GetExtensionIndex)(
@@ -412,50 +412,50 @@
             OMX_OUT OMX_INDEXTYPE* pIndexType);
 
 
-    /** refer to OMX_GetState in OMX_core.h or the OMX IL 
+    /** refer to OMX_GetState in OMX_core.h or the OMX IL
         specification for details on the GetState method.
      */
     OMX_ERRORTYPE (*GetState)(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_OUT OMX_STATETYPE* pState);
 
-    
+
     /** The ComponentTunnelRequest method will interact with another OMX
         component to determine if tunneling is possible and to setup the
-        tunneling.  The return codes for this method can be used to 
+        tunneling.  The return codes for this method can be used to
         determine if tunneling is not possible, or if tunneling is not
-        supported.  
-        
-        Base profile components (i.e. non-interop) do not support this
-        method and should return OMX_ErrorNotImplemented 
+        supported.
 
-        The interop profile component MUST support tunneling to another 
-        interop profile component with a compatible port parameters.  
+        Base profile components (i.e. non-interop) do not support this
+        method and should return OMX_ErrorNotImplemented
+
+        The interop profile component MUST support tunneling to another
+        interop profile component with a compatible port parameters.
         A component may also support proprietary communication.
-        
-        If proprietary communication is supported the negotiation of 
-        proprietary communication is done outside of OMX in a vendor 
-        specific way. It is only required that the proper result be 
-        returned and the details of how the setup is done is left 
-        to the component implementation.  
-    
+
+        If proprietary communication is supported the negotiation of
+        proprietary communication is done outside of OMX in a vendor
+        specific way. It is only required that the proper result be
+        returned and the details of how the setup is done is left
+        to the component implementation.
+
         When this method is invoked when nPort in an output port, the
         component will:
-        1.  Populate the pTunnelSetup structure with the output port's 
+        1.  Populate the pTunnelSetup structure with the output port's
             requirements and constraints for the tunnel.
 
         When this method is invoked when nPort in an input port, the
         component will:
-        1.  Query the necessary parameters from the output port to 
+        1.  Query the necessary parameters from the output port to
             determine if the ports are compatible for tunneling
         2.  If the ports are compatible, the component should store
             the tunnel step provided by the output port
         3.  Determine which port (either input or output) is the buffer
             supplier, and call OMX_SetParameter on the output port to
             indicate this selection.
-        
+
         The component will return from this call within 5 msec.
-    
+
         @param [in] hComp
             Handle of the component to be accessed.  This is the component
             handle returned by the call to the OMX_GetHandle method.
@@ -463,7 +463,7 @@
             nPort is used to select the port on the component to be used
             for tunneling.
         @param [in] hTunneledComp
-            Handle of the component to tunnel with.  This is the component 
+            Handle of the component to tunnel with.  This is the component
             handle returned by the call to the OMX_GetHandle method.  When
             this parameter is 0x0 the component should setup the port for
             communication with the application / IL Client.
@@ -486,9 +486,9 @@
         OMX_IN  OMX_U32 nPort,
         OMX_IN  OMX_HANDLETYPE hTunneledComp,
         OMX_IN  OMX_U32 nTunneledPort,
-        OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup); 
+        OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup);
 
-    /** refer to OMX_UseBuffer in OMX_core.h or the OMX IL 
+    /** refer to OMX_UseBuffer in OMX_core.h or the OMX IL
         specification for details on the UseBuffer method.
         @ingroup buf
      */
@@ -500,7 +500,7 @@
             OMX_IN OMX_U32 nSizeBytes,
             OMX_IN OMX_U8* pBuffer);
 
-    /** refer to OMX_AllocateBuffer in OMX_core.h or the OMX IL 
+    /** refer to OMX_AllocateBuffer in OMX_core.h or the OMX IL
         specification for details on the AllocateBuffer method.
         @ingroup buf
      */
@@ -511,7 +511,7 @@
             OMX_IN OMX_PTR pAppPrivate,
             OMX_IN OMX_U32 nSizeBytes);
 
-    /** refer to OMX_FreeBuffer in OMX_core.h or the OMX IL 
+    /** refer to OMX_FreeBuffer in OMX_core.h or the OMX IL
         specification for details on the FreeBuffer method.
         @ingroup buf
      */
@@ -520,7 +520,7 @@
             OMX_IN  OMX_U32 nPortIndex,
             OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
 
-    /** refer to OMX_EmptyThisBuffer in OMX_core.h or the OMX IL 
+    /** refer to OMX_EmptyThisBuffer in OMX_core.h or the OMX IL
         specification for details on the EmptyThisBuffer method.
         @ingroup buf
      */
@@ -528,7 +528,7 @@
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
 
-    /** refer to OMX_FillThisBuffer in OMX_core.h or the OMX IL 
+    /** refer to OMX_FillThisBuffer in OMX_core.h or the OMX IL
         specification for details on the FillThisBuffer method.
         @ingroup buf
      */
@@ -543,10 +543,10 @@
             Handle of the component to be accessed.  This is the component
             handle returned by the call to the GetHandle function.
         @param [in] pCallbacks
-            pointer to an OMX_CALLBACKTYPE structure used to provide the 
+            pointer to an OMX_CALLBACKTYPE structure used to provide the
             callback information to the component
         @param [in] pAppData
-            pointer to an application defined value.  It is anticipated that 
+            pointer to an application defined value.  It is anticipated that
             the application will pass a pointer to a data structure or a "this
             pointer" in this area to allow the callback (in the application)
             to determine the context of the call
@@ -556,7 +556,7 @@
      */
     OMX_ERRORTYPE (*SetCallbacks)(
             OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_CALLBACKTYPE* pCallbacks, 
+            OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
             OMX_IN  OMX_PTR pAppData);
 
     /** ComponentDeInit method is used to deinitialize the component
@@ -583,8 +583,8 @@
 
     OMX_ERRORTYPE (*ComponentRoleEnum)(
         OMX_IN OMX_HANDLETYPE hComponent,
-		OMX_OUT OMX_U8 *cRole,
-		OMX_IN OMX_U32 nIndex);
+        OMX_OUT OMX_U8 *cRole,
+        OMX_IN OMX_U32 nIndex);
 
 } OMX_COMPONENTTYPE;
 
diff --git a/include/media/openmax/OMX_ContentPipe.h b/include/media/openmax/OMX_ContentPipe.h
index ee9e4db..0224c8a 100644
--- a/include/media/openmax/OMX_ContentPipe.h
+++ b/include/media/openmax/OMX_ContentPipe.h
@@ -16,25 +16,25 @@
  * -------------------------------------------------------------------
  */
 /*
- * Copyright (c) 2008 The Khronos Group Inc. 
- * 
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
  * "Software"), to deal in the Software without restriction, including
  * without limitation the rights to use, copy, modify, merge, publish,
  * distribute, sublicense, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject
- * to the following conditions: 
+ * to the following conditions:
  * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software. 
- * 
+ * in all copies or substantial portions of the Software.
+ *
  * THE SOFTWARE IS 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
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
@@ -81,83 +81,83 @@
 
 /** Map types from OMX standard types only here so interface is as generic as possible. */
 typedef OMX_U32    CPresult;
-typedef char *     CPstring;  
+typedef char *     CPstring;
 typedef void *     CPhandle;
 typedef OMX_U32    CPuint;
-typedef OMX_S32    CPint;  
-typedef char       CPbyte;  
+typedef OMX_S32    CPint;
+typedef char       CPbyte;
 typedef OMX_BOOL   CPbool;
 
-/** enumeration of origin types used in the CP_PIPETYPE's Seek function 
+/** enumeration of origin types used in the CP_PIPETYPE's Seek function
  * @ingroup cp
  */
 typedef enum CP_ORIGINTYPE {
-    CP_OriginBegin,      
-    CP_OriginCur,      
-    CP_OriginEnd,      
-    CP_OriginKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    CP_OriginBegin,
+    CP_OriginCur,
+    CP_OriginEnd,
+    CP_OriginKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     CP_OriginVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     CP_OriginMax = 0X7FFFFFFF
 } CP_ORIGINTYPE;
 
-/** enumeration of contact access types used in the CP_PIPETYPE's Open function 
+/** enumeration of contact access types used in the CP_PIPETYPE's Open function
  * @ingroup cp
  */
 typedef enum CP_ACCESSTYPE {
-    CP_AccessRead,      
-    CP_AccessWrite,  
-    CP_AccessReadWrite ,  
-    CP_AccessKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    CP_AccessRead,
+    CP_AccessWrite,
+    CP_AccessReadWrite,
+    CP_AccessKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     CP_AccessVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     CP_AccessMax = 0X7FFFFFFF
 } CP_ACCESSTYPE;
 
-/** enumeration of results returned by the CP_PIPETYPE's CheckAvailableBytes function 
+/** enumeration of results returned by the CP_PIPETYPE's CheckAvailableBytes function
  * @ingroup cp
  */
 typedef enum CP_CHECKBYTESRESULTTYPE
 {
-    CP_CheckBytesOk,                    /**< There are at least the request number 
+    CP_CheckBytesOk,                    /**< There are at least the request number
                                               of bytes available */
-    CP_CheckBytesNotReady,              /**< The pipe is still retrieving bytes 
-                                              and presently lacks sufficient bytes. 
-                                              Client will be called when they are 
+    CP_CheckBytesNotReady,              /**< The pipe is still retrieving bytes
+                                              and presently lacks sufficient bytes.
+                                              Client will be called when they are
                                               sufficient bytes are available. */
-    CP_CheckBytesInsufficientBytes  ,     /**< The pipe has retrieved all bytes 
-                                              but those available are less than those 
+    CP_CheckBytesInsufficientBytes,     /**< The pipe has retrieved all bytes
+                                              but those available are less than those
                                               requested */
     CP_CheckBytesAtEndOfStream,         /**< The pipe has reached the end of stream
                                               and no more bytes are available. */
     CP_CheckBytesOutOfBuffers,          /**< All read/write buffers are currently in use. */
-    CP_CheckBytesKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    CP_CheckBytesKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     CP_CheckBytesVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     CP_CheckBytesMax = 0X7FFFFFFF
 } CP_CHECKBYTESRESULTTYPE;
 
-/** enumeration of content pipe events sent to the client callback. 
+/** enumeration of content pipe events sent to the client callback.
  * @ingroup cp
  */
 typedef enum CP_EVENTTYPE{
-    CP_BytesAvailable,      	    /** bytes requested in a CheckAvailableBytes call are now available*/
-    CP_Overflow,  		           /** enumeration of content pipe events sent to the client callback*/
-    CP_PipeDisconnected  ,  		    /** enumeration of content pipe events sent to the client callback*/
-    CP_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    CP_BytesAvailable,                      /** bytes requested in a CheckAvailableBytes call are now available*/
+    CP_Overflow,                            /** enumeration of content pipe events sent to the client callback*/
+    CP_PipeDisconnected,                    /** enumeration of content pipe events sent to the client callback*/
+    CP_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     CP_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     CP_EventMax = 0X7FFFFFFF
 } CP_EVENTTYPE;
 
-/** content pipe definition 
+/** content pipe definition
  * @ingroup cp
  */
 typedef struct CP_PIPETYPE
 {
-    /** Open a content stream for reading or writing. */ 
+    /** Open a content stream for reading or writing. */
     CPresult (*Open)( CPhandle* hContent, CPstring szURI, CP_ACCESSTYPE eAccess );
 
-    /** Close a content stream. */ 
+    /** Close a content stream. */
     CPresult (*Close)( CPhandle hContent );
 
-    /** Create a content source and open it for writing. */ 
+    /** Create a content source and open it for writing. */
     CPresult (*Create)( CPhandle *hContent, CPstring szURI );
 
     /** Check the that specified number of bytes are available for reading or writing (depending on access type).*/
@@ -171,19 +171,19 @@
 
     /** Retrieve data of the specified size from the content stream (advance content pointer by size of data).
        Note: pipe client provides pointer. This function is appropriate for small high frequency reads. */
-    CPresult (*Read)( CPhandle hContent, CPbyte *pData, CPuint nSize); 
+    CPresult (*Read)( CPhandle hContent, CPbyte *pData, CPuint nSize);
 
-    /** Retrieve a buffer allocated by the pipe that contains the requested number of bytes. 
+    /** Retrieve a buffer allocated by the pipe that contains the requested number of bytes.
        Buffer contains the next block of bytes, as specified by nSize, of the content. nSize also
-       returns the size of the block actually read. Content pointer advances the by the returned size. 
-       Note: pipe provides pointer. This function is appropriate for large reads. The client must call 
-       ReleaseReadBuffer when done with buffer. 
+       returns the size of the block actually read. Content pointer advances the by the returned size.
+       Note: pipe provides pointer. This function is appropriate for large reads. The client must call
+       ReleaseReadBuffer when done with buffer.
 
        In some cases the requested block may not reside in contiguous memory within the
-       pipe implementation. For instance if the pipe leverages a circular buffer then the requested 
-       block may straddle the boundary of the circular buffer. By default a pipe implementation 
+       pipe implementation. For instance if the pipe leverages a circular buffer then the requested
+       block may straddle the boundary of the circular buffer. By default a pipe implementation
        performs a copy in this case to provide the block to the pipe client in one contiguous buffer.
-       If, however, the client sets bForbidCopy, then the pipe returns only those bytes preceding the memory 
+       If, however, the client sets bForbidCopy, then the pipe returns only those bytes preceding the memory
        boundary. Here the client may retrieve the data in segments over successive calls. */
     CPresult (*ReadBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint *nSize, CPbool bForbidCopy);
 
@@ -192,14 +192,14 @@
 
     /** Write data of the specified size to the content (advance content pointer by size of data).
        Note: pipe client provides pointer. This function is appropriate for small high frequency writes. */
-    CPresult (*Write)( CPhandle hContent, CPbyte *data, CPuint nSize); 
+    CPresult (*Write)( CPhandle hContent, CPbyte *data, CPuint nSize);
 
-    /** Retrieve a buffer allocated by the pipe used to write data to the content. 
+    /** Retrieve a buffer allocated by the pipe used to write data to the content.
        Client will fill buffer with output data. Note: pipe provides pointer. This function is appropriate
        for large writes. The client must call WriteBuffer when done it has filled the buffer with data.*/
     CPresult (*GetWriteBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint nSize);
 
-    /** Deliver a buffer obtained via GetWriteBuffer to the pipe. Pipe will write the 
+    /** Deliver a buffer obtained via GetWriteBuffer to the pipe. Pipe will write the
        the contents of the buffer to content and advance content pointer by the size of the buffer */
     CPresult (*WriteBuffer)( CPhandle hContent, CPbyte *pBuffer, CPuint nFilledSize);
 
diff --git a/include/media/openmax/OMX_Core.h b/include/media/openmax/OMX_Core.h
index 9fb0f6f..0859966 100644
--- a/include/media/openmax/OMX_Core.h
+++ b/include/media/openmax/OMX_Core.h
@@ -16,25 +16,25 @@
  * -------------------------------------------------------------------
  */
 /*
- * Copyright (c) 2008 The Khronos Group Inc. 
- * 
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
  * "Software"), to deal in the Software without restriction, including
  * without limitation the rights to use, copy, modify, merge, publish,
  * distribute, sublicense, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject
- * to the following conditions: 
+ * to the following conditions:
  * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software. 
- * 
+ * in all copies or substantial portions of the Software.
+ *
  * THE SOFTWARE IS 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
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
@@ -53,14 +53,14 @@
 
 /* Each OMX header shall include all required header files to allow the
  *  header to compile without errors.  The includes below are required
- *  for this header file to compile successfully 
+ *  for this header file to compile successfully
  */
 
 #include <OMX_Index.h>
 
 
 /** The OMX_COMMANDTYPE enumeration is used to specify the action in the
- *  OMX_SendCommand macro.  
+ *  OMX_SendCommand macro.
  *  @ingroup core
  */
 typedef enum OMX_COMMANDTYPE
@@ -70,7 +70,7 @@
     OMX_CommandPortDisable, /**< Disable a port on a component. */
     OMX_CommandPortEnable,  /**< Enable a port on a component. */
     OMX_CommandMarkBuffer,  /**< Mark a component/buffer for observation */
-    OMX_CommandKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_CommandKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_CommandVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_CommandMax = 0X7FFFFFFF
 } OMX_COMMANDTYPE;
@@ -93,28 +93,28 @@
  *  specified configuration and will transition to the idle state if the
  *  allocation is successful.  If the component cannot successfully
  *  transition to the idle state for any reason, the state of the component
- *  shall be fully rolled back to the Loaded state (e.g. all allocated 
+ *  shall be fully rolled back to the Loaded state (e.g. all allocated
  *  resources shall be released).  When the component receives the command
  *  to go to the Executing state, it shall begin processing buffers by
  *  sending all input buffers it holds to the application.  While
  *  the component is in the Idle state, the application may also send the
  *  Pause command.  If the component receives the pause command while in the
- *  Idle state, the component shall send all input buffers it holds to the 
+ *  Idle state, the component shall send all input buffers it holds to the
  *  application, but shall not begin processing buffers.  This will allow the
  *  application to prefill buffers.
- * 
+ *
  *  @ingroup comp
  */
 
 typedef enum OMX_STATETYPE
 {
-    OMX_StateInvalid,      /**< component has detected that it's internal data 
+    OMX_StateInvalid,      /**< component has detected that it's internal data
                                 structures are corrupted to the point that
                                 it cannot determine it's state properly */
     OMX_StateLoaded,      /**< component has been loaded but has not completed
                                 initialization.  The OMX_SetParameter macro
-                                and the OMX_GetParameter macro are the only 
-                                valid macros allowed to be sent to the 
+                                and the OMX_GetParameter macro are the only
+                                valid macros allowed to be sent to the
                                 component in this state. */
     OMX_StateIdle,        /**< component initialization has been completed
                                 successfully and the component is ready to
@@ -122,17 +122,17 @@
     OMX_StateExecuting,   /**< component has accepted the start command and
                                 is processing data (if data is available) */
     OMX_StatePause,       /**< component has received pause command */
-    OMX_StateWaitForResources, /**< component is waiting for resources, either after 
+    OMX_StateWaitForResources, /**< component is waiting for resources, either after
                                 preemption or before it gets the resources requested.
                                 See specification for complete details. */
-    OMX_StateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_StateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_StateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_StateMax = 0X7FFFFFFF
 } OMX_STATETYPE;
 
-/** The OMX_ERRORTYPE enumeration defines the standard OMX Errors.  These 
- *  errors should cover most of the common failure cases.  However, 
- *  vendors are free to add additional error messages of their own as 
+/** The OMX_ERRORTYPE enumeration defines the standard OMX Errors.  These
+ *  errors should cover most of the common failure cases.  However,
+ *  vendors are free to add additional error messages of their own as
  *  long as they follow these rules:
  *  1.  Vendor error messages shall be in the range of 0x90000000 to
  *      0x9000FFFF.
@@ -203,25 +203,25 @@
   /** This error occurs when trying to transition into the state you are already in */
   OMX_ErrorSameState = (OMX_S32) 0x80001012,
 
-  /** Resources allocated to an executing or paused component have been 
+  /** Resources allocated to an executing or paused component have been
       preempted, causing the component to return to the idle state */
-  OMX_ErrorResourcesPreempted = (OMX_S32) 0x80001013, 
+  OMX_ErrorResourcesPreempted = (OMX_S32) 0x80001013,
 
-  /** A non-supplier port sends this error to the IL client (via the EventHandler callback) 
+  /** A non-supplier port sends this error to the IL client (via the EventHandler callback)
       during the allocation of buffers (on a transition from the LOADED to the IDLE state or
-      on a port restart) when it deems that it has waited an unusually long time for the supplier 
+      on a port restart) when it deems that it has waited an unusually long time for the supplier
       to send it an allocated buffer via a UseBuffer call. */
   OMX_ErrorPortUnresponsiveDuringAllocation = (OMX_S32) 0x80001014,
 
-  /** A non-supplier port sends this error to the IL client (via the EventHandler callback) 
-      during the deallocation of buffers (on a transition from the IDLE to LOADED state or 
-      on a port stop) when it deems that it has waited an unusually long time for the supplier 
+  /** A non-supplier port sends this error to the IL client (via the EventHandler callback)
+      during the deallocation of buffers (on a transition from the IDLE to LOADED state or
+      on a port stop) when it deems that it has waited an unusually long time for the supplier
       to request the deallocation of a buffer header via a FreeBuffer call. */
   OMX_ErrorPortUnresponsiveDuringDeallocation = (OMX_S32) 0x80001015,
 
-  /** A supplier port sends this error to the IL client (via the EventHandler callback) 
-      during the stopping of a port (either on a transition from the IDLE to LOADED 
-      state or a port stop) when it deems that it has waited an unusually long time for 
+  /** A supplier port sends this error to the IL client (via the EventHandler callback)
+      during the stopping of a port (either on a transition from the IDLE to LOADED
+      state or a port stop) when it deems that it has waited an unusually long time for
       the non-supplier to return a buffer via an EmptyThisBuffer or FillThisBuffer call. */
   OMX_ErrorPortUnresponsiveDuringStop = (OMX_S32) 0x80001016,
 
@@ -229,7 +229,7 @@
   OMX_ErrorIncorrectStateTransition = (OMX_S32) 0x80001017,
 
   /* Attempting a command that is not allowed during the present state. */
-  OMX_ErrorIncorrectStateOperation = (OMX_S32) 0x80001018, 
+  OMX_ErrorIncorrectStateOperation = (OMX_S32) 0x80001018,
 
   /** The values encapsulated in the parameter or config structure are not supported. */
   OMX_ErrorUnsupportedSetting = (OMX_S32) 0x80001019,
@@ -249,12 +249,12 @@
   /** Component suspended due to an inability to acquire dynamic resources */
   OMX_ErrorDynamicResourcesUnavailable = (OMX_S32) 0x8000101E,
 
-  /** When the macroblock error reporting is enabled the component returns new error 
+  /** When the macroblock error reporting is enabled the component returns new error
   for every frame that has errors */
   OMX_ErrorMbErrorsInFrame = (OMX_S32) 0x8000101F,
 
   /** A component reports this error when it cannot parse or determine the format of an input stream. */
-  OMX_ErrorFormatNotDetected = (OMX_S32) 0x80001020, 
+  OMX_ErrorFormatNotDetected = (OMX_S32) 0x80001020,
 
   /** The content open operation failed. */
   OMX_ErrorContentPipeOpenFailed = (OMX_S32) 0x80001021,
@@ -268,7 +268,7 @@
   /** Tunneling is unsupported by the component*/
   OMX_ErrorTunnelingUnsupported = (OMX_S32) 0x80001024,
 
-  OMX_ErrorKhronosExtensions = (OMX_S32)0x8F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+  OMX_ErrorKhronosExtensions = (OMX_S32)0x8F000000, /**< Reserved region for introducing Khronos Standard Extensions */
   OMX_ErrorVendorStartUnused = (OMX_S32)0x90000000, /**< Reserved region for introducing Vendor Extensions */
   OMX_ErrorMax = 0x7FFFFFFF
 } OMX_ERRORTYPE;
@@ -304,69 +304,69 @@
     OMX_U8 cRole[OMX_MAX_STRINGNAME_SIZE];  /**< name of standard component which defines component role */
 } OMX_PARAM_COMPONENTROLETYPE;
 
-/** End of Stream Buffer Flag: 
+/** End of Stream Buffer Flag:
   *
-  * A component sets EOS when it has no more data to emit on a particular 
-  * output port. Thus an output port shall set EOS on the last buffer it 
-  * emits. A component's determination of when an output port should 
+  * A component sets EOS when it has no more data to emit on a particular
+  * output port. Thus an output port shall set EOS on the last buffer it
+  * emits. A component's determination of when an output port should
   * cease sending data is implemenation specific.
   * @ingroup buf
   */
 
-#define OMX_BUFFERFLAG_EOS 0x00000001 
+#define OMX_BUFFERFLAG_EOS 0x00000001
 
-/** Start Time Buffer Flag: 
+/** Start Time Buffer Flag:
  *
  * The source of a stream (e.g. a demux component) sets the STARTTIME
  * flag on the buffer that contains the starting timestamp for the
  * stream. The starting timestamp corresponds to the first data that
  * should be displayed at startup or after a seek.
  * The first timestamp of the stream is not necessarily the start time.
- * For instance, in the case of a seek to a particular video frame, 
- * the target frame may be an interframe. Thus the first buffer of 
+ * For instance, in the case of a seek to a particular video frame,
+ * the target frame may be an interframe. Thus the first buffer of
  * the stream will be the intra-frame preceding the target frame and
  * the starttime will occur with the target frame (with any other
  * required frames required to reconstruct the target intervening).
  *
- * The STARTTIME flag is directly associated with the buffer's 
- * timestamp ' thus its association to buffer data and its 
+ * The STARTTIME flag is directly associated with the buffer's
+ * timestamp ' thus its association to buffer data and its
  * propagation is identical to the timestamp's.
  *
- * When a Sync Component client receives a buffer with the 
- * STARTTIME flag it shall perform a SetConfig on its sync port 
+ * When a Sync Component client receives a buffer with the
+ * STARTTIME flag it shall perform a SetConfig on its sync port
  * using OMX_ConfigTimeClientStartTime and passing the buffer's
  * timestamp.
- * 
+ *
  * @ingroup buf
  */
 
 #define OMX_BUFFERFLAG_STARTTIME 0x00000002
 
- 
 
-/** Decode Only Buffer Flag: 
+
+/** Decode Only Buffer Flag:
  *
  * The source of a stream (e.g. a demux component) sets the DECODEONLY
  * flag on any buffer that should shall be decoded but should not be
- * displayed. This flag is used, for instance, when a source seeks to 
- * a target interframe that requires the decode of frames preceding the 
- * target to facilitate the target's reconstruction. In this case the 
- * source would emit the frames preceding the target downstream 
+ * displayed. This flag is used, for instance, when a source seeks to
+ * a target interframe that requires the decode of frames preceding the
+ * target to facilitate the target's reconstruction. In this case the
+ * source would emit the frames preceding the target downstream
  * but mark them as decode only.
  *
- * The DECODEONLY is associated with buffer data and propagated in a 
+ * The DECODEONLY is associated with buffer data and propagated in a
  * manner identical to the buffer timestamp.
  *
- * A component that renders data should ignore all buffers with 
+ * A component that renders data should ignore all buffers with
  * the DECODEONLY flag set.
- * 
+ *
  * @ingroup buf
  */
 
 #define OMX_BUFFERFLAG_DECODEONLY 0x00000004
 
 
-/* Data Corrupt Flag: This flag is set when the IL client believes the data in the associated buffer is corrupt 
+/* Data Corrupt Flag: This flag is set when the IL client believes the data in the associated buffer is corrupt
  * @ingroup buf
  */
 
@@ -374,29 +374,29 @@
 
 /* End of Frame: The buffer contains exactly one end of frame and no data
  *  occurs after the end of frame. This flag is an optional hint. The absence
- *  of this flag does not imply the absence of an end of frame within the buffer. 
+ *  of this flag does not imply the absence of an end of frame within the buffer.
  * @ingroup buf
 */
 #define OMX_BUFFERFLAG_ENDOFFRAME 0x00000010
 
-/* Sync Frame Flag: This flag is set when the buffer content contains a coded sync frame ' 
- *  a frame that has no dependency on any other frame information 
+/* Sync Frame Flag: This flag is set when the buffer content contains a coded sync frame '
+ *  a frame that has no dependency on any other frame information
  *  @ingroup buf
  */
 #define OMX_BUFFERFLAG_SYNCFRAME 0x00000020
 
 /* Extra data present flag: there is extra data appended to the data stream
- * residing in the buffer 
- * @ingroup buf  
+ * residing in the buffer
+ * @ingroup buf
  */
 #define OMX_BUFFERFLAG_EXTRADATA 0x00000040
 
-/** Codec Config Buffer Flag: 
+/** Codec Config Buffer Flag:
 * OMX_BUFFERFLAG_CODECCONFIG is an optional flag that is set by an
 * output port when all bytes in the buffer form part or all of a set of
 * codec specific configuration data.  Examples include SPS/PPS nal units
 * for OMX_VIDEO_CodingAVC or AudioSpecificConfig data for
-* OMX_AUDIO_CodingAAC.  Any component that for a given stream sets 
+* OMX_AUDIO_CodingAAC.  Any component that for a given stream sets
 * OMX_BUFFERFLAG_CODECCONFIG shall not mix codec configuration bytes
 * with frame data in the same buffer, and shall send all buffers
 * containing codec configuration bytes before any buffers containing
@@ -416,50 +416,50 @@
 {
     OMX_U32 nSize;              /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
-    OMX_U8* pBuffer;            /**< Pointer to actual block of memory 
+    OMX_U8* pBuffer;            /**< Pointer to actual block of memory
                                      that is acting as the buffer */
     OMX_U32 nAllocLen;          /**< size of the buffer allocated, in bytes */
-    OMX_U32 nFilledLen;         /**< number of bytes currently in the 
+    OMX_U32 nFilledLen;         /**< number of bytes currently in the
                                      buffer */
     OMX_U32 nOffset;            /**< start offset of valid data in bytes from
                                      the start of the buffer */
     OMX_PTR pAppPrivate;        /**< pointer to any data the application
                                      wants to associate with this buffer */
     OMX_PTR pPlatformPrivate;   /**< pointer to any data the platform
-                                     wants to associate with this buffer */ 
+                                     wants to associate with this buffer */
     OMX_PTR pInputPortPrivate;  /**< pointer to any data the input port
                                      wants to associate with this buffer */
     OMX_PTR pOutputPortPrivate; /**< pointer to any data the output port
                                      wants to associate with this buffer */
-    OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will generate a 
+    OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will generate a
                                               mark event upon processing this buffer. */
-    OMX_PTR pMarkData;          /**< Application specific data associated with 
-                                     the mark sent on a mark event to disambiguate 
+    OMX_PTR pMarkData;          /**< Application specific data associated with
+                                     the mark sent on a mark event to disambiguate
                                      this mark from others. */
     OMX_U32 nTickCount;         /**< Optional entry that the component and
                                      application can update with a tick count
                                      when they access the component.  This
                                      value should be in microseconds.  Since
                                      this is a value relative to an arbitrary
-                                     starting point, this value cannot be used 
+                                     starting point, this value cannot be used
                                      to determine absolute time.  This is an
                                      optional entry and not all components
                                      will update it.*/
- OMX_TICKS nTimeStamp;          /**< Timestamp corresponding to the sample 
-                                     starting at the first logical sample 
-                                     boundary in the buffer. Timestamps of 
+ OMX_TICKS nTimeStamp;          /**< Timestamp corresponding to the sample
+                                     starting at the first logical sample
+                                     boundary in the buffer. Timestamps of
                                      successive samples within the buffer may
-                                     be inferred by adding the duration of the 
+                                     be inferred by adding the duration of the
                                      of the preceding buffer to the timestamp
                                      of the preceding buffer.*/
   OMX_U32     nFlags;           /**< buffer specific flags */
-  OMX_U32 nOutputPortIndex;     /**< The index of the output port (if any) using 
+  OMX_U32 nOutputPortIndex;     /**< The index of the output port (if any) using
                                      this buffer */
   OMX_U32 nInputPortIndex;      /**< The index of the input port (if any) using
                                      this buffer */
 } OMX_BUFFERHEADERTYPE;
 
-/** The OMX_EXTRADATATYPE enumeration is used to define the 
+/** The OMX_EXTRADATATYPE enumeration is used to define the
  * possible extra data payload types.
  * NB: this enum is binary backwards compatible with the previous
  * OMX_EXTRADATA_QUANT define.  This should be replaced with
@@ -467,9 +467,9 @@
  */
 typedef enum OMX_EXTRADATATYPE
 {
-   OMX_ExtraDataNone = 0,                       /**< Indicates that no more extra data sections follow */        
+   OMX_ExtraDataNone = 0,                       /**< Indicates that no more extra data sections follow */
    OMX_ExtraDataQuantization,                   /**< The data payload contains quantization data */
-   OMX_ExtraDataKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+   OMX_ExtraDataKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
    OMX_ExtraDataVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
    OMX_ExtraDataMax = 0x7FFFFFFF
 } OMX_EXTRADATATYPE;
@@ -477,7 +477,7 @@
 
 typedef struct OMX_OTHER_EXTRADATATYPE  {
     OMX_U32 nSize;
-    OMX_VERSIONTYPE nVersion;               
+    OMX_VERSIONTYPE nVersion;
     OMX_U32 nPortIndex;
     OMX_EXTRADATATYPE eType;       /* Extra Data type */
     OMX_U32 nDataSize;   /* Size of the supporting data to follow */
@@ -490,7 +490,7 @@
     OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
     OMX_U32 nPorts;             /**< The number of ports for this component */
     OMX_U32 nStartPortNumber;   /** first port number for this type of port */
-} OMX_PORT_PARAM_TYPE; 
+} OMX_PORT_PARAM_TYPE;
 
 /** @ingroup comp */
 typedef enum OMX_EVENTTYPE
@@ -499,16 +499,32 @@
     OMX_EventError,               /**< component has detected an error condition */
     OMX_EventMark,                /**< component has detected a buffer mark */
     OMX_EventPortSettingsChanged, /**< component is reported a port settings change */
-    OMX_EventBufferFlag,          /**< component has detected an EOS */ 
+    OMX_EventBufferFlag,          /**< component has detected an EOS */
     OMX_EventResourcesAcquired,   /**< component has been granted resources and is
                                        automatically starting the state change from
                                        OMX_StateWaitForResources to OMX_StateIdle. */
-   OMX_EventComponentResumed,     /**< Component resumed due to reacquisition of resources */
-   OMX_EventDynamicResourcesAvailable, /**< Component has acquired previously unavailable dynamic resources */
-   OMX_EventPortFormatDetected,      /**< Component has detected a supported format. */
-   OMX_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
-   OMX_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
-   OMX_EventMax = 0x7FFFFFFF
+    OMX_EventComponentResumed,     /**< Component resumed due to reacquisition of resources */
+    OMX_EventDynamicResourcesAvailable, /**< Component has acquired previously unavailable dynamic resources */
+    OMX_EventPortFormatDetected,      /**< Component has detected a supported format. */
+    OMX_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+    OMX_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+
+    /** Event when tunneled decoder has rendered an output or reached EOS
+     *  nData1 must contain the number of timestamps returned
+     *  pEventData must point to an array of the OMX_VIDEO_RENDEREVENTTYPE structs containing the
+     *  render-timestamps of each frame. Component may batch rendered timestamps using this event,
+     *  but must signal the event no more than 40ms after the first frame in the batch. The frames
+     *  must be ordered by system timestamp inside and across batches.
+     *
+     *  If component is doing frame-rate conversion, it must signal the render time of each
+     *  converted frame, and must interpolate media timestamps for in-between frames.
+     *
+     *  When the component reached EOS, it must signal an EOS timestamp using the same mechanism.
+     *  This is in addition to the timestamp of the last rendered frame, and should follow that
+     *  frame.
+     */
+    OMX_EventOutputRendered = 0x7F000001,
+    OMX_EventMax = 0x7FFFFFFF
 } OMX_EVENTTYPE;
 
 typedef struct OMX_CALLBACKTYPE
@@ -517,7 +533,7 @@
         event of interest occurs.  Events are defined in the OMX_EVENTTYPE
         enumeration.  Please see that enumeration for details of what will
         be returned for each type of event. Callbacks should not return
-        an error to the component, so if an error occurs, the application 
+        an error to the component, so if an error occurs, the application
         shall handle it internally.  This is a blocking call.
 
         The application should return from this call within 5 msec to avoid
@@ -527,14 +543,14 @@
             handle of the component to access.  This is the component
             handle returned by the call to the GetHandle function.
         @param pAppData
-            pointer to an application defined value that was provided in the 
+            pointer to an application defined value that was provided in the
             pAppData parameter to the OMX_GetHandle method for the component.
-            This application defined value is provided so that the application 
+            This application defined value is provided so that the application
             can have a component specific context when receiving the callback.
         @param eEvent
             Event that the component wants to notify the application about.
         @param nData1
-            nData will be the OMX_ERRORTYPE for an error event and will be 
+            nData will be the OMX_ERRORTYPE for an error event and will be
             an OMX_COMMANDTYPE for a command complete event and OMX_INDEXTYPE for a OMX_PortSettingsChanged event.
          @param nData2
             nData2 will hold further information related to the event. Can be OMX_STATETYPE for
@@ -553,21 +569,21 @@
         OMX_IN OMX_PTR pEventData);
 
     /** The EmptyBufferDone method is used to return emptied buffers from an
-        input port back to the application for reuse.  This is a blocking call 
+        input port back to the application for reuse.  This is a blocking call
         so the application should not attempt to refill the buffers during this
         call, but should queue them and refill them in another thread.  There
         is no error return, so the application shall handle any errors generated
-        internally.  
-        
+        internally.
+
         The application should return from this call within 5 msec.
-        
+
         @param hComponent
             handle of the component to access.  This is the component
             handle returned by the call to the GetHandle function.
         @param pAppData
-            pointer to an application defined value that was provided in the 
+            pointer to an application defined value that was provided in the
             pAppData parameter to the OMX_GetHandle method for the component.
-            This application defined value is provided so that the application 
+            This application defined value is provided so that the application
             can have a component specific context when receiving the callback.
         @param pBuffer
             pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer
@@ -580,23 +596,23 @@
         OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
 
     /** The FillBufferDone method is used to return filled buffers from an
-        output port back to the application for emptying and then reuse.  
-        This is a blocking call so the application should not attempt to 
-        empty the buffers during this call, but should queue the buffers 
-        and empty them in another thread.  There is no error return, so 
-        the application shall handle any errors generated internally.  The 
+        output port back to the application for emptying and then reuse.
+        This is a blocking call so the application should not attempt to
+        empty the buffers during this call, but should queue the buffers
+        and empty them in another thread.  There is no error return, so
+        the application shall handle any errors generated internally.  The
         application shall also update the buffer header to indicate the
-        number of bytes placed into the buffer.  
+        number of bytes placed into the buffer.
 
         The application should return from this call within 5 msec.
-        
+
         @param hComponent
             handle of the component to access.  This is the component
             handle returned by the call to the GetHandle function.
         @param pAppData
-            pointer to an application defined value that was provided in the 
+            pointer to an application defined value that was provided in the
             pAppData parameter to the OMX_GetHandle method for the component.
-            This application defined value is provided so that the application 
+            This application defined value is provided so that the application
             can have a component specific context when receiving the callback.
         @param pBuffer
             pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer
@@ -620,13 +636,13 @@
                                               or don't care */
     OMX_BufferSupplyInput,             /**< input port supplies the buffers */
     OMX_BufferSupplyOutput,            /**< output port supplies the buffers */
-    OMX_BufferSupplyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_BufferSupplyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_BufferSupplyVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_BufferSupplyMax = 0x7FFFFFFF
 } OMX_BUFFERSUPPLIERTYPE;
 
 
-/** buffer supplier parameter 
+/** buffer supplier parameter
  * @ingroup tun
  */
 typedef struct OMX_PARAM_BUFFERSUPPLIERTYPE {
@@ -637,61 +653,61 @@
 } OMX_PARAM_BUFFERSUPPLIERTYPE;
 
 
-/**< indicates that buffers received by an input port of a tunnel 
-     may not modify the data in the buffers 
+/**< indicates that buffers received by an input port of a tunnel
+     may not modify the data in the buffers
      @ingroup tun
  */
-#define OMX_PORTTUNNELFLAG_READONLY 0x00000001 
+#define OMX_PORTTUNNELFLAG_READONLY 0x00000001
 
 
 /** The OMX_TUNNELSETUPTYPE structure is used to pass data from an output
     port to an input port as part the two ComponentTunnelRequest calls
-    resulting from a OMX_SetupTunnel call from the IL Client. 
+    resulting from a OMX_SetupTunnel call from the IL Client.
     @ingroup tun
- */   
+ */
 typedef struct OMX_TUNNELSETUPTYPE
 {
     OMX_U32 nTunnelFlags;             /**< bit flags for tunneling */
     OMX_BUFFERSUPPLIERTYPE eSupplier; /**< supplier preference */
-} OMX_TUNNELSETUPTYPE; 
+} OMX_TUNNELSETUPTYPE;
 
 /* OMX Component headers is included to enable the core to use
-   macros for functions into the component for OMX release 1.0.  
+   macros for functions into the component for OMX release 1.0.
    Developers should not access any structures or data from within
    the component header directly */
 /* TO BE REMOVED - #include <OMX_Component.h> */
 
-/** GetComponentVersion will return information about the component.  
+/** GetComponentVersion will return information about the component.
     This is a blocking call.  This macro will go directly from the
     application to the component (via a core macro).  The
     component will return from this call within 5 msec.
     @param [in] hComponent
         handle of component to execute the command
     @param [out] pComponentName
-        pointer to an empty string of length 128 bytes.  The component 
-        will write its name into this string.  The name will be 
-        terminated by a single zero byte.  The name of a component will 
-        be 127 bytes or less to leave room for the trailing zero byte.  
+        pointer to an empty string of length 128 bytes.  The component
+        will write its name into this string.  The name will be
+        terminated by a single zero byte.  The name of a component will
+        be 127 bytes or less to leave room for the trailing zero byte.
         An example of a valid component name is "OMX.ABC.ChannelMixer\0".
     @param [out] pComponentVersion
-        pointer to an OMX Version structure that the component will fill 
-        in.  The component will fill in a value that indicates the 
-        component version.  NOTE: the component version is NOT the same 
-        as the OMX Specification version (found in all structures).  The 
-        component version is defined by the vendor of the component and 
+        pointer to an OMX Version structure that the component will fill
+        in.  The component will fill in a value that indicates the
+        component version.  NOTE: the component version is NOT the same
+        as the OMX Specification version (found in all structures).  The
+        component version is defined by the vendor of the component and
         its value is entirely up to the component vendor.
     @param [out] pSpecVersion
-        pointer to an OMX Version structure that the component will fill 
-        in.  The SpecVersion is the version of the specification that the 
-        component was built against.  Please note that this value may or 
-        may not match the structure's version.  For example, if the 
-        component was built against the 2.0 specification, but the 
-        application (which creates the structure is built against the 
+        pointer to an OMX Version structure that the component will fill
+        in.  The SpecVersion is the version of the specification that the
+        component was built against.  Please note that this value may or
+        may not match the structure's version.  For example, if the
+        component was built against the 2.0 specification, but the
+        application (which creates the structure is built against the
         1.0 specification the versions would be different.
     @param [out] pComponentUUID
-        pointer to the UUID of the component which will be filled in by 
-        the component.  The UUID is a unique identifier that is set at 
-        RUN time for the component and is unique to each instantion of 
+        pointer to the UUID of the component which will be filled in by
+        the component.  The UUID is a unique identifier that is set at
+        RUN time for the component and is unique to each instantion of
         the component.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
@@ -704,7 +720,7 @@
         pComponentVersion,                                  \
         pSpecVersion,                                       \
         pComponentUUID)                                     \
-    ((OMX_COMPONENTTYPE*)hComponent)->GetComponentVersion(  \
+    ((OMX_COMPONENTTYPE*)(hComponent))->GetComponentVersion(\
         hComponent,                                         \
         pComponentName,                                     \
         pComponentVersion,                                  \
@@ -714,46 +730,46 @@
 
 /** Send a command to the component.  This call is a non-blocking call.
     The component should check the parameters and then queue the command
-    to the component thread to be executed.  The component thread shall 
-    send the EventHandler() callback at the conclusion of the command. 
+    to the component thread to be executed.  The component thread shall
+    send the EventHandler() callback at the conclusion of the command.
     This macro will go directly from the application to the component (via
     a core macro).  The component will return from this call within 5 msec.
-    
+
     When the command is "OMX_CommandStateSet" the component will queue a
     state transition to the new state idenfied in nParam.
-    
+
     When the command is "OMX_CommandFlush", to flush a port's buffer queues,
-    the command will force the component to return all buffers NOT CURRENTLY 
-    BEING PROCESSED to the application, in the order in which the buffers 
+    the command will force the component to return all buffers NOT CURRENTLY
+    BEING PROCESSED to the application, in the order in which the buffers
     were received.
-    
-    When the command is "OMX_CommandPortDisable" or 
+
+    When the command is "OMX_CommandPortDisable" or
     "OMX_CommandPortEnable", the component's port (given by the value of
-    nParam) will be stopped or restarted. 
-    
+    nParam) will be stopped or restarted.
+
     When the command "OMX_CommandMarkBuffer" is used to mark a buffer, the
     pCmdData will point to a OMX_MARKTYPE structure containing the component
     handle of the component to examine the buffer chain for the mark.  nParam1
     contains the index of the port on which the buffer mark is applied.
 
-    Specification text for more details. 
-    
+    Specification text for more details.
+
     @param [in] hComponent
         handle of component to execute the command
     @param [in] Cmd
         Command for the component to execute
     @param [in] nParam
-        Parameter for the command to be executed.  When Cmd has the value 
-        OMX_CommandStateSet, value is a member of OMX_STATETYPE.  When Cmd has 
-        the value OMX_CommandFlush, value of nParam indicates which port(s) 
-        to flush. -1 is used to flush all ports a single port index will 
+        Parameter for the command to be executed.  When Cmd has the value
+        OMX_CommandStateSet, value is a member of OMX_STATETYPE.  When Cmd has
+        the value OMX_CommandFlush, value of nParam indicates which port(s)
+        to flush. -1 is used to flush all ports a single port index will
         only flush that port.  When Cmd has the value "OMX_CommandPortDisable"
-        or "OMX_CommandPortEnable", the component's port is given by 
+        or "OMX_CommandPortEnable", the component's port is given by
         the value of nParam.  When Cmd has the value "OMX_CommandMarkBuffer"
         the components pot is given by the value of nParam.
     @param [in] pCmdData
         Parameter pointing to the OMX_MARKTYPE structure when Cmd has the value
-        "OMX_CommandMarkBuffer".     
+        "OMX_CommandMarkBuffer".
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
         OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
@@ -764,28 +780,28 @@
          Cmd,                                               \
          nParam,                                            \
          pCmdData)                                          \
-     ((OMX_COMPONENTTYPE*)hComponent)->SendCommand(         \
+     ((OMX_COMPONENTTYPE*)(hComponent))->SendCommand(       \
          hComponent,                                        \
          Cmd,                                               \
          nParam,                                            \
          pCmdData)                          /* Macro End */
 
 
-/** The OMX_GetParameter macro will get one of the current parameter 
-    settings from the component.  This macro cannot only be invoked when 
+/** The OMX_GetParameter macro will get one of the current parameter
+    settings from the component.  This macro cannot only be invoked when
     the component is in the OMX_StateInvalid state.  The nParamIndex
     parameter is used to indicate which structure is being requested from
-    the component.  The application shall allocate the correct structure 
-    and shall fill in the structure size and version information before 
+    the component.  The application shall allocate the correct structure
+    and shall fill in the structure size and version information before
     invoking this macro.  When the parameter applies to a port, the
     caller shall fill in the appropriate nPortIndex value indicating the
-    port on which the parameter applies. If the component has not had 
-    any settings changed, then the component should return a set of 
-    valid DEFAULT  parameters for the component.  This is a blocking 
-    call.  
-    
+    port on which the parameter applies. If the component has not had
+    any settings changed, then the component should return a set of
+    valid DEFAULT  parameters for the component.  This is a blocking
+    call.
+
     The component should return from this call within 20 msec.
-    
+
     @param [in] hComponent
         Handle of the component to be accessed.  This is the component
         handle returned by the call to the OMX_GetHandle function.
@@ -793,7 +809,7 @@
         Index of the structure to be filled.  This value is from the
         OMX_INDEXTYPE enumeration.
     @param [in,out] pComponentParameterStructure
-        Pointer to application allocated structure to be filled by the 
+        Pointer to application allocated structure to be filled by the
         component.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
@@ -803,8 +819,8 @@
 #define OMX_GetParameter(                                   \
         hComponent,                                         \
         nParamIndex,                                        \
-        pComponentParameterStructure)                        \
-    ((OMX_COMPONENTTYPE*)hComponent)->GetParameter(         \
+        pComponentParameterStructure)                       \
+    ((OMX_COMPONENTTYPE*)(hComponent))->GetParameter(       \
         hComponent,                                         \
         nParamIndex,                                        \
         pComponentParameterStructure)    /* Macro End */
@@ -814,17 +830,17 @@
     structure to a component.  Each structure shall be sent one at a time,
     in a separate invocation of the macro.  This macro can only be
     invoked when the component is in the OMX_StateLoaded state, or the
-    port is disabled (when the parameter applies to a port). The 
+    port is disabled (when the parameter applies to a port). The
     nParamIndex parameter is used to indicate which structure is being
-    passed to the component.  The application shall allocate the 
-    correct structure and shall fill in the structure size and version 
+    passed to the component.  The application shall allocate the
+    correct structure and shall fill in the structure size and version
     information (as well as the actual data) before invoking this macro.
     The application is free to dispose of this structure after the call
-    as the component is required to copy any data it shall retain.  This 
-    is a blocking call.  
-    
+    as the component is required to copy any data it shall retain.  This
+    is a blocking call.
+
     The component should return from this call within 20 msec.
-    
+
     @param [in] hComponent
         Handle of the component to be accessed.  This is the component
         handle returned by the call to the OMX_GetHandle function.
@@ -842,25 +858,25 @@
 #define OMX_SetParameter(                                   \
         hComponent,                                         \
         nParamIndex,                                        \
-        pComponentParameterStructure)                        \
-    ((OMX_COMPONENTTYPE*)hComponent)->SetParameter(         \
+        pComponentParameterStructure)                       \
+    ((OMX_COMPONENTTYPE*)(hComponent))->SetParameter(       \
         hComponent,                                         \
         nParamIndex,                                        \
         pComponentParameterStructure)    /* Macro End */
 
 
-/** The OMX_GetConfig macro will get one of the configuration structures 
-    from a component.  This macro can be invoked anytime after the 
-    component has been loaded.  The nParamIndex call parameter is used to 
-    indicate which structure is being requested from the component.  The 
-    application shall allocate the correct structure and shall fill in the 
-    structure size and version information before invoking this macro.  
-    If the component has not had this configuration parameter sent before, 
-    then the component should return a set of valid DEFAULT values for the 
-    component.  This is a blocking call.  
-    
+/** The OMX_GetConfig macro will get one of the configuration structures
+    from a component.  This macro can be invoked anytime after the
+    component has been loaded.  The nParamIndex call parameter is used to
+    indicate which structure is being requested from the component.  The
+    application shall allocate the correct structure and shall fill in the
+    structure size and version information before invoking this macro.
+    If the component has not had this configuration parameter sent before,
+    then the component should return a set of valid DEFAULT values for the
+    component.  This is a blocking call.
+
     The component should return from this call within 5 msec.
-    
+
     @param [in] hComponent
         Handle of the component to be accessed.  This is the component
         handle returned by the call to the OMX_GetHandle function.
@@ -868,35 +884,35 @@
         Index of the structure to be filled.  This value is from the
         OMX_INDEXTYPE enumeration.
     @param [in,out] pComponentConfigStructure
-        pointer to application allocated structure to be filled by the 
+        pointer to application allocated structure to be filled by the
         component.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
         OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup comp
-*/        
+*/
 #define OMX_GetConfig(                                      \
         hComponent,                                         \
         nConfigIndex,                                       \
-        pComponentConfigStructure)                           \
-    ((OMX_COMPONENTTYPE*)hComponent)->GetConfig(            \
+        pComponentConfigStructure)                          \
+    ((OMX_COMPONENTTYPE*)(hComponent))->GetConfig(          \
         hComponent,                                         \
         nConfigIndex,                                       \
         pComponentConfigStructure)       /* Macro End */
 
 
-/** The OMX_SetConfig macro will send one of the configuration 
+/** The OMX_SetConfig macro will send one of the configuration
     structures to a component.  Each structure shall be sent one at a time,
-    each in a separate invocation of the macro.  This macro can be invoked 
-    anytime after the component has been loaded.  The application shall 
-    allocate the correct structure and shall fill in the structure size 
-    and version information (as well as the actual data) before invoking 
-    this macro.  The application is free to dispose of this structure after 
-    the call as the component is required to copy any data it shall retain.  
-    This is a blocking call.  
-    
+    each in a separate invocation of the macro.  This macro can be invoked
+    anytime after the component has been loaded.  The application shall
+    allocate the correct structure and shall fill in the structure size
+    and version information (as well as the actual data) before invoking
+    this macro.  The application is free to dispose of this structure after
+    the call as the component is required to copy any data it shall retain.
+    This is a blocking call.
+
     The component should return from this call within 5 msec.
-    
+
     @param [in] hComponent
         Handle of the component to be accessed.  This is the component
         handle returned by the call to the OMX_GetHandle function.
@@ -914,29 +930,29 @@
 #define OMX_SetConfig(                                      \
         hComponent,                                         \
         nConfigIndex,                                       \
-        pComponentConfigStructure)                           \
-    ((OMX_COMPONENTTYPE*)hComponent)->SetConfig(            \
+        pComponentConfigStructure)                          \
+    ((OMX_COMPONENTTYPE*)(hComponent))->SetConfig(          \
         hComponent,                                         \
         nConfigIndex,                                       \
         pComponentConfigStructure)       /* Macro End */
 
 
-/** The OMX_GetExtensionIndex macro will invoke a component to translate 
-    a vendor specific configuration or parameter string into an OMX 
-    structure index.  There is no requirement for the vendor to support 
-    this command for the indexes already found in the OMX_INDEXTYPE 
-    enumeration (this is done to save space in small components).  The 
+/** The OMX_GetExtensionIndex macro will invoke a component to translate
+    a vendor specific configuration or parameter string into an OMX
+    structure index.  There is no requirement for the vendor to support
+    this command for the indexes already found in the OMX_INDEXTYPE
+    enumeration (this is done to save space in small components).  The
     component shall support all vendor supplied extension indexes not found
-    in the master OMX_INDEXTYPE enumeration.  This is a blocking call.  
-    
+    in the master OMX_INDEXTYPE enumeration.  This is a blocking call.
+
     The component should return from this call within 5 msec.
-    
+
     @param [in] hComponent
         Handle of the component to be accessed.  This is the component
         handle returned by the call to the GetHandle function.
     @param [in] cParameterName
         OMX_STRING that shall be less than 128 characters long including
-        the trailing null byte.  This is the string that will get 
+        the trailing null byte.  This is the string that will get
         translated by the component into a configuration index.
     @param [out] pIndexType
         a pointer to a OMX_INDEXTYPE to receive the index value.
@@ -949,24 +965,24 @@
         hComponent,                                         \
         cParameterName,                                     \
         pIndexType)                                         \
-    ((OMX_COMPONENTTYPE*)hComponent)->GetExtensionIndex(    \
+    ((OMX_COMPONENTTYPE*)(hComponent))->GetExtensionIndex(  \
         hComponent,                                         \
         cParameterName,                                     \
         pIndexType)                     /* Macro End */
 
 
-/** The OMX_GetState macro will invoke the component to get the current 
+/** The OMX_GetState macro will invoke the component to get the current
     state of the component and place the state value into the location
-    pointed to by pState.  
-    
+    pointed to by pState.
+
     The component should return from this call within 5 msec.
-    
+
     @param [in] hComponent
         Handle of the component to be accessed.  This is the component
         handle returned by the call to the OMX_GetHandle function.
     @param [out] pState
         pointer to the location to receive the state.  The value returned
-        is one of the OMX_STATETYPE members 
+        is one of the OMX_STATETYPE members
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
         OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
@@ -975,23 +991,23 @@
 #define OMX_GetState(                                       \
         hComponent,                                         \
         pState)                                             \
-    ((OMX_COMPONENTTYPE*)hComponent)->GetState(             \
+    ((OMX_COMPONENTTYPE*)(hComponent))->GetState(           \
         hComponent,                                         \
         pState)                         /* Macro End */
 
 
 /** The OMX_UseBuffer macro will request that the component use
-    a buffer (and allocate its own buffer header) already allocated 
-    by another component, or by the IL Client. This is a blocking 
+    a buffer (and allocate its own buffer header) already allocated
+    by another component, or by the IL Client. This is a blocking
     call.
-    
+
     The component should return from this call within 20 msec.
-    
+
     @param [in] hComponent
         Handle of the component to be accessed.  This is the component
         handle returned by the call to the OMX_GetHandle function.
     @param [out] ppBuffer
-        pointer to an OMX_BUFFERHEADERTYPE structure used to receive the 
+        pointer to an OMX_BUFFERHEADERTYPE structure used to receive the
         pointer to the buffer header
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
@@ -1006,7 +1022,7 @@
            pAppPrivate,                                     \
            nSizeBytes,                                      \
            pBuffer)                                         \
-    ((OMX_COMPONENTTYPE*)hComponent)->UseBuffer(            \
+    ((OMX_COMPONENTTYPE*)(hComponent))->UseBuffer(          \
            hComponent,                                      \
            ppBufferHdr,                                     \
            nPortIndex,                                      \
@@ -1015,25 +1031,25 @@
            pBuffer)
 
 
-/** The OMX_AllocateBuffer macro will request that the component allocate 
-    a new buffer and buffer header.  The component will allocate the 
-    buffer and the buffer header and return a pointer to the buffer 
+/** The OMX_AllocateBuffer macro will request that the component allocate
+    a new buffer and buffer header.  The component will allocate the
+    buffer and the buffer header and return a pointer to the buffer
     header.  This is a blocking call.
-    
+
     The component should return from this call within 5 msec.
-    
+
     @param [in] hComponent
         Handle of the component to be accessed.  This is the component
         handle returned by the call to the OMX_GetHandle function.
     @param [out] ppBuffer
-        pointer to an OMX_BUFFERHEADERTYPE structure used to receive 
+        pointer to an OMX_BUFFERHEADERTYPE structure used to receive
         the pointer to the buffer header
     @param [in] nPortIndex
         nPortIndex is used to select the port on the component the buffer will
         be used with.  The port can be found by using the nPortIndex
         value as an index into the Port Definition array of the component.
     @param [in] pAppPrivate
-        pAppPrivate is used to initialize the pAppPrivate member of the 
+        pAppPrivate is used to initialize the pAppPrivate member of the
         buffer header structure.
     @param [in] nSizeBytes
         size of the buffer to allocate.  Used when bAllocateNew is true.
@@ -1041,14 +1057,14 @@
         If the command successfully executes, the return code will be
         OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup comp buf
- */    
+ */
 #define OMX_AllocateBuffer(                                 \
         hComponent,                                         \
         ppBuffer,                                           \
         nPortIndex,                                         \
         pAppPrivate,                                        \
         nSizeBytes)                                         \
-    ((OMX_COMPONENTTYPE*)hComponent)->AllocateBuffer(       \
+    ((OMX_COMPONENTTYPE*)(hComponent))->AllocateBuffer(     \
         hComponent,                                         \
         ppBuffer,                                           \
         nPortIndex,                                         \
@@ -1057,13 +1073,13 @@
 
 
 /** The OMX_FreeBuffer macro will release a buffer header from the component
-    which was allocated using either OMX_AllocateBuffer or OMX_UseBuffer. If  
-    the component allocated the buffer (see the OMX_UseBuffer macro) then 
-    the component shall free the buffer and buffer header. This is a 
-    blocking call. 
-    
+    which was allocated using either OMX_AllocateBuffer or OMX_UseBuffer. If
+    the component allocated the buffer (see the OMX_UseBuffer macro) then
+    the component shall free the buffer and buffer header. This is a
+    blocking call.
+
     The component should return from this call within 20 msec.
-    
+
     @param [in] hComponent
         Handle of the component to be accessed.  This is the component
         handle returned by the call to the OMX_GetHandle function.
@@ -1082,23 +1098,23 @@
         hComponent,                                         \
         nPortIndex,                                         \
         pBuffer)                                            \
-    ((OMX_COMPONENTTYPE*)hComponent)->FreeBuffer(           \
+    ((OMX_COMPONENTTYPE*)(hComponent))->FreeBuffer(         \
         hComponent,                                         \
         nPortIndex,                                         \
         pBuffer)                        /* Macro End */
 
 
-/** The OMX_EmptyThisBuffer macro will send a buffer full of data to an 
+/** The OMX_EmptyThisBuffer macro will send a buffer full of data to an
     input port of a component.  The buffer will be emptied by the component
     and returned to the application via the EmptyBufferDone call back.
     This is a non-blocking call in that the component will record the buffer
-    and return immediately and then empty the buffer, later, at the proper 
-    time.  As expected, this macro may be invoked only while the component 
+    and return immediately and then empty the buffer, later, at the proper
+    time.  As expected, this macro may be invoked only while the component
     is in the OMX_StateExecuting.  If nPortIndex does not specify an input
-    port, the component shall return an error.  
-    
+    port, the component shall return an error.
+
     The component should return from this call within 5 msec.
-    
+
     @param [in] hComponent
         Handle of the component to be accessed.  This is the component
         handle returned by the call to the OMX_GetHandle function.
@@ -1113,22 +1129,22 @@
 #define OMX_EmptyThisBuffer(                                \
         hComponent,                                         \
         pBuffer)                                            \
-    ((OMX_COMPONENTTYPE*)hComponent)->EmptyThisBuffer(      \
+    ((OMX_COMPONENTTYPE*)(hComponent))->EmptyThisBuffer(    \
         hComponent,                                         \
         pBuffer)                        /* Macro End */
 
 
-/** The OMX_FillThisBuffer macro will send an empty buffer to an 
+/** The OMX_FillThisBuffer macro will send an empty buffer to an
     output port of a component.  The buffer will be filled by the component
     and returned to the application via the FillBufferDone call back.
     This is a non-blocking call in that the component will record the buffer
-    and return immediately and then fill the buffer, later, at the proper 
-    time.  As expected, this macro may be invoked only while the component 
+    and return immediately and then fill the buffer, later, at the proper
+    time.  As expected, this macro may be invoked only while the component
     is in the OMX_ExecutingState.  If nPortIndex does not specify an output
-    port, the component shall return an error.  
-    
+    port, the component shall return an error.
+
     The component should return from this call within 5 msec.
-    
+
     @param [in] hComponent
         Handle of the component to be accessed.  This is the component
         handle returned by the call to the OMX_GetHandle function.
@@ -1143,7 +1159,7 @@
 #define OMX_FillThisBuffer(                                 \
         hComponent,                                         \
         pBuffer)                                            \
-    ((OMX_COMPONENTTYPE*)hComponent)->FillThisBuffer(       \
+    ((OMX_COMPONENTTYPE*)(hComponent))->FillThisBuffer(     \
         hComponent,                                         \
         pBuffer)                        /* Macro End */
 
@@ -1152,14 +1168,14 @@
 /** The OMX_UseEGLImage macro will request that the component use
     a EGLImage provided by EGL (and allocate its own buffer header)
     This is a blocking call.
-    
+
     The component should return from this call within 20 msec.
-    
+
     @param [in] hComponent
         Handle of the component to be accessed.  This is the component
         handle returned by the call to the OMX_GetHandle function.
     @param [out] ppBuffer
-        pointer to an OMX_BUFFERHEADERTYPE structure used to receive the 
+        pointer to an OMX_BUFFERHEADERTYPE structure used to receive the
         pointer to the buffer header.  Note that the memory location used
         for this buffer is NOT visible to the IL Client.
     @param [in] nPortIndex
@@ -1167,13 +1183,13 @@
         be used with.  The port can be found by using the nPortIndex
         value as an index into the Port Definition array of the component.
     @param [in] pAppPrivate
-        pAppPrivate is used to initialize the pAppPrivate member of the 
+        pAppPrivate is used to initialize the pAppPrivate member of the
         buffer header structure.
     @param [in] eglImage
         eglImage contains the handle of the EGLImage to use as a buffer on the
-        specified port.  The component is expected to validate properties of 
+        specified port.  The component is expected to validate properties of
         the EGLImage against the configuration of the port to ensure the component
-        can use the EGLImage as a buffer.          
+        can use the EGLImage as a buffer.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
         OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
@@ -1185,7 +1201,7 @@
            nPortIndex,                                      \
            pAppPrivate,                                     \
            eglImage)                                        \
-    ((OMX_COMPONENTTYPE*)hComponent)->UseEGLImage(          \
+    ((OMX_COMPONENTTYPE*)(hComponent))->UseEGLImage(        \
            hComponent,                                      \
            ppBufferHdr,                                     \
            nPortIndex,                                      \
@@ -1194,8 +1210,8 @@
 
 /** The OMX_Init method is used to initialize the OMX core.  It shall be the
     first call made into OMX and it should only be executed one time without
-    an interviening OMX_Deinit call.  
-    
+    an interviening OMX_Deinit call.
+
     The core should return from this call within 20 msec.
 
     @return OMX_ERRORTYPE
@@ -1206,13 +1222,13 @@
 OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Init(void);
 
 
-/** The OMX_Deinit method is used to deinitialize the OMX core.  It shall be 
-    the last call made into OMX. In the event that the core determines that 
-    thare are components loaded when this call is made, the core may return 
+/** The OMX_Deinit method is used to deinitialize the OMX core.  It shall be
+    the last call made into OMX. In the event that the core determines that
+    thare are components loaded when this call is made, the core may return
     with an error rather than try to unload the components.
-        
+
     The core should return from this call within 20 msec.
-    
+
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
         OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
@@ -1229,23 +1245,23 @@
     installation of new components, it is only requried to detect newly
     installed components when the first call to enumerate component names
     is made (i.e. when nIndex is 0x0).
-    
+
     The core should return from this call in 20 msec.
-    
+
     @param [out] cComponentName
         pointer to a null terminated string with the component name.  The
         names of the components are strings less than 127 bytes in length
-        plus the trailing null for a maximum size of 128 bytes.  An example 
-        of a valid component name is "OMX.TI.AUDIO.DSP.MIXER\0".  Names are 
-        assigned by the vendor, but shall start with "OMX." and then have 
+        plus the trailing null for a maximum size of 128 bytes.  An example
+        of a valid component name is "OMX.TI.AUDIO.DSP.MIXER\0".  Names are
+        assigned by the vendor, but shall start with "OMX." and then have
         the Vendor designation next.
     @param [in] nNameLength
-        number of characters in the cComponentName string.  With all 
-        component name strings restricted to less than 128 characters 
+        number of characters in the cComponentName string.  With all
+        component name strings restricted to less than 128 characters
         (including the trailing null) it is recomended that the caller
         provide a input string for the cComponentName of 128 characters.
     @param [in] nIndex
-        number containing the enumeration index for the component. 
+        number containing the enumeration index for the component.
         Multiple calls to OMX_ComponentNameEnum with increasing values
         of nIndex will enumerate through the component names in the
         system until OMX_ErrorNoMore is returned.  The value of nIndex
@@ -1253,7 +1269,7 @@
         in the system.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_ErrorNone.  When the value of nIndex exceeds the number of 
+        OMX_ErrorNone.  When the value of nIndex exceeds the number of
         components in the system minus 1, OMX_ErrorNoMore will be
         returned. Otherwise the appropriate OMX error will be returned.
     @ingroup core
@@ -1266,18 +1282,18 @@
 
 /** The OMX_GetHandle method will locate the component specified by the
     component name given, load that component into memory and then invoke
-    the component's methods to create an instance of the component.  
-    
+    the component's methods to create an instance of the component.
+
     The core should return from this call within 20 msec.
-    
+
     @param [out] pHandle
         pointer to an OMX_HANDLETYPE pointer to be filled in by this method.
     @param [in] cComponentName
         pointer to a null terminated string with the component name.  The
         names of the components are strings less than 127 bytes in length
-        plus the trailing null for a maximum size of 128 bytes.  An example 
-        of a valid component name is "OMX.TI.AUDIO.DSP.MIXER\0".  Names are 
-        assigned by the vendor, but shall start with "OMX." and then have 
+        plus the trailing null for a maximum size of 128 bytes.  An example
+        of a valid component name is "OMX.TI.AUDIO.DSP.MIXER\0".  Names are
+        assigned by the vendor, but shall start with "OMX." and then have
         the Vendor designation next.
     @param [in] pAppData
         pointer to an application defined value that will be returned
@@ -1285,24 +1301,24 @@
         of the callback.
     @param [in] pCallBacks
         pointer to a OMX_CALLBACKTYPE structure that will be passed to the
-        component to initialize it with.  
+        component to initialize it with.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
         OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup core
  */
 OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle(
-    OMX_OUT OMX_HANDLETYPE* pHandle, 
+    OMX_OUT OMX_HANDLETYPE* pHandle,
     OMX_IN  OMX_STRING cComponentName,
     OMX_IN  OMX_PTR pAppData,
     OMX_IN  OMX_CALLBACKTYPE* pCallBacks);
 
 
-/** The OMX_FreeHandle method will free a handle allocated by the OMX_GetHandle 
+/** The OMX_FreeHandle method will free a handle allocated by the OMX_GetHandle
     method.  If the component reference count goes to zero, the component will
-    be unloaded from memory.  
-    
-    The core should return from this call within 20 msec when the component is 
+    be unloaded from memory.
+
+    The core should return from this call within 20 msec when the component is
     in the OMX_StateLoaded state.
 
     @param [in] hComponent
@@ -1321,34 +1337,34 @@
 /** The OMX_SetupTunnel method will handle the necessary calls to the components
     to setup the specified tunnel the two components.  NOTE: This is
     an actual method (not a #define macro).  This method will make calls into
-    the component ComponentTunnelRequest method to do the actual tunnel 
-    connection.  
+    the component ComponentTunnelRequest method to do the actual tunnel
+    connection.
 
-    The ComponentTunnelRequest method on both components will be called. 
-    This method shall not be called unless the component is in the 
+    The ComponentTunnelRequest method on both components will be called.
+    This method shall not be called unless the component is in the
     OMX_StateLoaded state except when the ports used for the tunnel are
     disabled. In this case, the component may be in the OMX_StateExecuting,
-    OMX_StatePause, or OMX_StateIdle states. 
+    OMX_StatePause, or OMX_StateIdle states.
 
     The core should return from this call within 20 msec.
-    
+
     @param [in] hOutput
         Handle of the component to be accessed.  Also this is the handle
         of the component whose port, specified in the nPortOutput parameter
         will be used the source for the tunnel. This is the component handle
-        returned by the call to the OMX_GetHandle function.  There is a 
+        returned by the call to the OMX_GetHandle function.  There is a
         requirement that hOutput be the source for the data when
         tunelling (i.e. nPortOutput is an output port).  If 0x0, the component
         specified in hInput will have it's port specified in nPortInput
         setup for communication with the application / IL client.
     @param [in] nPortOutput
         nPortOutput is used to select the source port on component to be
-        used in the tunnel. 
+        used in the tunnel.
     @param [in] hInput
         This is the component to setup the tunnel with. This is the handle
         of the component whose port, specified in the nPortInput parameter
         will be used the destination for the tunnel. This is the component handle
-        returned by the call to the OMX_GetHandle function.  There is a 
+        returned by the call to the OMX_GetHandle function.  There is a
         requirement that hInput be the destination for the data when
         tunelling (i.e. nPortInut is an input port).   If 0x0, the component
         specified in hOutput will have it's port specified in nPortPOutput
@@ -1359,9 +1375,9 @@
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
         OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
-        When OMX_ErrorNotImplemented is returned, one or both components is 
+        When OMX_ErrorNotImplemented is returned, one or both components is
         a non-interop component and does not support tunneling.
-        
+
         On failure, the ports of both components are setup for communication
         with the application / IL Client.
     @ingroup core tun
@@ -1371,50 +1387,50 @@
     OMX_IN  OMX_U32 nPortOutput,
     OMX_IN  OMX_HANDLETYPE hInput,
     OMX_IN  OMX_U32 nPortInput);
-    
+
 /** @ingroup cp */
 OMX_API OMX_ERRORTYPE   OMX_GetContentPipe(
     OMX_OUT OMX_HANDLETYPE *hPipe,
     OMX_IN OMX_STRING szURI);
 
 /** The OMX_GetComponentsOfRole method will return the number of components that support the given
-    role and (if the compNames field is non-NULL) the names of those components. The call will fail if 
+    role and (if the compNames field is non-NULL) the names of those components. The call will fail if
     an insufficiently sized array of names is supplied. To ensure the array is sufficiently sized the
     client should:
         * first call this function with the compNames field NULL to determine the number of component names
-        * second call this function with the compNames field pointing to an array of names allocated 
+        * second call this function with the compNames field pointing to an array of names allocated
           according to the number returned by the first call.
 
     The core should return from this call within 5 msec.
-    
+
     @param [in] role
-        This is generic standard component name consisting only of component class 
+        This is generic standard component name consisting only of component class
         name and the type within that class (e.g. 'audio_decoder.aac').
     @param [inout] pNumComps
-        This is used both as input and output. 
- 
+        This is used both as input and output.
+
         If compNames is NULL, the input is ignored and the output specifies how many components support
         the given role.
-     
-        If compNames is not NULL, on input it bounds the size of the input structure and 
+
+        If compNames is not NULL, on input it bounds the size of the input structure and
         on output, it specifies the number of components string names listed within the compNames parameter.
     @param [inout] compNames
-        If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings which accepts 
-        a list of the names of all physical components that implement the specified standard component name. 
+        If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings which accepts
+        a list of the names of all physical components that implement the specified standard component name.
         Each name is NULL terminated. numComps indicates the number of names.
     @ingroup core
  */
-OMX_API OMX_ERRORTYPE OMX_GetComponentsOfRole ( 
-	OMX_IN      OMX_STRING role,
+OMX_API OMX_ERRORTYPE OMX_GetComponentsOfRole (
+    OMX_IN      OMX_STRING role,
     OMX_INOUT   OMX_U32 *pNumComps,
     OMX_INOUT   OMX_U8  **compNames);
 
 /** The OMX_GetRolesOfComponent method will return the number of roles supported by the given
-    component and (if the roles field is non-NULL) the names of those roles. The call will fail if 
+    component and (if the roles field is non-NULL) the names of those roles. The call will fail if
     an insufficiently sized array of names is supplied. To ensure the array is sufficiently sized the
     client should:
         * first call this function with the roles field NULL to determine the number of role names
-        * second call this function with the roles field pointing to an array of names allocated 
+        * second call this function with the roles field pointing to an array of names allocated
           according to the number returned by the first call.
 
     The core should return from this call within 5 msec.
@@ -1422,20 +1438,20 @@
     @param [in] compName
         This is the name of the component being queried about.
     @param [inout] pNumRoles
-        This is used both as input and output. 
- 
+        This is used both as input and output.
+
         If roles is NULL, the input is ignored and the output specifies how many roles the component supports.
-     
-        If compNames is not NULL, on input it bounds the size of the input structure and 
+
+        If compNames is not NULL, on input it bounds the size of the input structure and
         on output, it specifies the number of roles string names listed within the roles parameter.
     @param [out] roles
-        If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings 
-        which accepts a list of the names of all standard components roles implemented on the 
+        If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings
+        which accepts a list of the names of all standard components roles implemented on the
         specified component name. numComps indicates the number of names.
     @ingroup core
  */
-OMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent ( 
-	OMX_IN      OMX_STRING compName, 
+OMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent (
+    OMX_IN      OMX_STRING compName,
     OMX_INOUT   OMX_U32 *pNumRoles,
     OMX_OUT     OMX_U8 **roles);
 
diff --git a/include/media/openmax/OMX_IVCommon.h b/include/media/openmax/OMX_IVCommon.h
index 96a4396..f9b6f4b 100644
--- a/include/media/openmax/OMX_IVCommon.h
+++ b/include/media/openmax/OMX_IVCommon.h
@@ -157,6 +157,14 @@
      * an acceptable range once that is done.
      * */
     OMX_COLOR_FormatAndroidOpaque = 0x7F000789,
+    OMX_COLOR_Format32BitRGBA8888 = 0x7F00A000,
+    /** Flexible 8-bit YUV format.  Codec should report this format
+     *  as being supported if it supports any YUV420 packed planar
+     *  or semiplanar formats.  When port is set to use this format,
+     *  codec can substitute any YUV420 packed planar or semiplanar
+     *  format for it. */
+    OMX_COLOR_FormatYUV420Flexible = 0x7F420888,
+
     OMX_TI_COLOR_FormatYUV420PackedSemiPlanar = 0x7F000100,
     OMX_QCOM_COLOR_FormatYVU420SemiPlanar = 0x7FA30C00,
     OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka = 0x7FA30C03,
@@ -838,7 +846,7 @@
 typedef enum OMX_METERINGTYPE {
 
     OMX_MeteringModeAverage,     /**< Center-weighted average metering. */
-    OMX_MeteringModeSpot,  	      /**< Spot (partial) metering. */
+    OMX_MeteringModeSpot,        /**< Spot (partial) metering. */
     OMX_MeteringModeMatrix,      /**< Matrix or evaluative metering. */
 
     OMX_MeteringKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
@@ -853,11 +861,11 @@
     OMX_METERINGTYPE eMetering;
     OMX_S32 xEVCompensation;      /**< Fixed point value stored as Q16 */
     OMX_U32 nApertureFNumber;     /**< e.g. nApertureFNumber = 2 implies "f/2" - Q16 format */
-    OMX_BOOL bAutoAperture;		/**< Whether aperture number is defined automatically */
+    OMX_BOOL bAutoAperture;       /**< Whether aperture number is defined automatically */
     OMX_U32 nShutterSpeedMsec;    /**< Shutterspeed in milliseconds */
-    OMX_BOOL bAutoShutterSpeed;	/**< Whether shutter speed is defined automatically */
+    OMX_BOOL bAutoShutterSpeed;   /**< Whether shutter speed is defined automatically */
     OMX_U32 nSensitivity;         /**< e.g. nSensitivity = 100 implies "ISO 100" */
-    OMX_BOOL bAutoSensitivity;	/**< Whether sensitivity is defined automatically */
+    OMX_BOOL bAutoSensitivity;    /**< Whether sensitivity is defined automatically */
 } OMX_CONFIG_EXPOSUREVALUETYPE;
 
 /**
diff --git a/include/media/openmax/OMX_Image.h b/include/media/openmax/OMX_Image.h
index 42e39ec..23a0209 100644
--- a/include/media/openmax/OMX_Image.h
+++ b/include/media/openmax/OMX_Image.h
@@ -16,30 +16,30 @@
  * -------------------------------------------------------------------
  */
 /**
- * Copyright (c) 2008 The Khronos Group Inc. 
- * 
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
  * "Software"), to deal in the Software without restriction, including
  * without limitation the rights to use, copy, modify, merge, publish,
  * distribute, sublicense, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject
- * to the following conditions: 
+ * to the following conditions:
  * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software. 
- * 
+ * in all copies or substantial portions of the Software.
+ *
  * THE SOFTWARE IS 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
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-/** 
+/**
  * @file OMX_Image.h - OpenMax IL version 1.1.2
- * The structures needed by Image components to exchange parameters and 
+ * The structures needed by Image components to exchange parameters and
  * configuration data with the components.
  */
 #ifndef OMX_Image_h
@@ -51,9 +51,9 @@
 
 
 /**
- * Each OMX header must include all required header files to allow the 
- * header to compile without errors.  The includes below are required  
- * for this header file to compile successfully 
+ * Each OMX header must include all required header files to allow the
+ * header to compile without errors.  The includes below are required
+ * for this header file to compile successfully
  */
 
 #include <OMX_IVCommon.h>
@@ -64,8 +64,8 @@
  * @{
  */
 
-/** 
- * Enumeration used to define the possible image compression coding. 
+/**
+ * Enumeration used to define the possible image compression coding.
  */
 typedef enum OMX_IMAGE_CODINGTYPE {
     OMX_IMAGE_CodingUnused,      /**< Value when format is N/A */
@@ -78,59 +78,59 @@
     OMX_IMAGE_CodingPNG,         /**< PNG image format */
     OMX_IMAGE_CodingLZW,         /**< LZW image format */
     OMX_IMAGE_CodingBMP,         /**< Windows Bitmap format */
-    OMX_IMAGE_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_IMAGE_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_IMAGE_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_IMAGE_CodingMax = 0x7FFFFFFF
 } OMX_IMAGE_CODINGTYPE;
 
 
 /**
- * Data structure used to define an image path. The number of image paths 
- * for input and output will vary by type of the image component.  
- * 
+ * Data structure used to define an image path. The number of image paths
+ * for input and output will vary by type of the image component.
+ *
  *  Input (aka Source) : Zero Inputs, one Output,
  *  Splitter           : One Input, 2 or more Outputs,
  *  Processing Element : One Input, one output,
  *  Mixer              : 2 or more inputs, one output,
  *  Output (aka Sink)  : One Input, zero outputs.
- * 
- * The PortDefinition structure is used to define all of the parameters 
- * necessary for the compliant component to setup an input or an output  
- * image path.  If additional vendor specific data is required, it should  
- * be transmitted to the component using the CustomCommand function.   
- * Compliant components will prepopulate this structure with optimal  
+ *
+ * The PortDefinition structure is used to define all of the parameters
+ * necessary for the compliant component to setup an input or an output
+ * image path.  If additional vendor specific data is required, it should
+ * be transmitted to the component using the CustomCommand function.
+ * Compliant components will prepopulate this structure with optimal
  * values during the OMX_GetParameter() command.
  *
  * STRUCT MEMBERS:
  *  cMIMEType             : MIME type of data for the port
- *  pNativeRender         : Platform specific reference for a display if a 
+ *  pNativeRender         : Platform specific reference for a display if a
  *                          sync, otherwise this field is 0
- *  nFrameWidth           : Width of frame to be used on port if 
- *                          uncompressed format is used.  Use 0 for 
+ *  nFrameWidth           : Width of frame to be used on port if
+ *                          uncompressed format is used.  Use 0 for
  *                          unknown, don't care or variable
- *  nFrameHeight          : Height of frame to be used on port if 
- *                          uncompressed format is used. Use 0 for 
+ *  nFrameHeight          : Height of frame to be used on port if
+ *                          uncompressed format is used. Use 0 for
  *                          unknown, don't care or variable
- *  nStride               : Number of bytes per span of an image (i.e. 
+ *  nStride               : Number of bytes per span of an image (i.e.
  *                          indicates the number of bytes to get from
- *                          span N to span N+1, where negative stride 
+ *                          span N to span N+1, where negative stride
  *                          indicates the image is bottom up
  *  nSliceHeight          : Height used when encoding in slices
- *  bFlagErrorConcealment : Turns on error concealment if it is supported by 
+ *  bFlagErrorConcealment : Turns on error concealment if it is supported by
  *                          the OMX component
- *  eCompressionFormat    : Compression format used in this instance of  
- *                          the component. When OMX_IMAGE_CodingUnused is 
+ *  eCompressionFormat    : Compression format used in this instance of
+ *                          the component. When OMX_IMAGE_CodingUnused is
  *                          specified, eColorFormat is valid
  *  eColorFormat          : Decompressed format used by this component
- *  pNativeWindow         : Platform specific reference for a window object if a 
- *                          display sink , otherwise this field is 0x0. 
+ *  pNativeWindow         : Platform specific reference for a window object if a
+ *                          display sink , otherwise this field is 0x0.
  */
 typedef struct OMX_IMAGE_PORTDEFINITIONTYPE {
     OMX_STRING cMIMEType;
     OMX_NATIVE_DEVICETYPE pNativeRender;
-    OMX_U32 nFrameWidth; 
+    OMX_U32 nFrameWidth;
     OMX_U32 nFrameHeight;
-    OMX_S32 nStride;     
+    OMX_S32 nStride;
     OMX_U32 nSliceHeight;
     OMX_BOOL bFlagErrorConcealment;
     OMX_IMAGE_CODINGTYPE eCompressionFormat;
@@ -139,18 +139,18 @@
 } OMX_IMAGE_PORTDEFINITIONTYPE;
 
 
-/**  
- * Port format parameter.  This structure is used to enumerate the various 
+/**
+ * Port format parameter.  This structure is used to enumerate the various
  * data input/output format supported by the port.
- * 
+ *
  * STRUCT MEMBERS:
  *  nSize              : Size of the structure in bytes
  *  nVersion           : OMX specification version information
  *  nPortIndex         : Indicates which port to set
- *  nIndex             : Indicates the enumeration index for the format from 
+ *  nIndex             : Indicates the enumeration index for the format from
  *                       0x0 to N-1
- *  eCompressionFormat : Compression format used in this instance of the 
- *                       component. When OMX_IMAGE_CodingUnused is specified, 
+ *  eCompressionFormat : Compression format used in this instance of the
+ *                       component. When OMX_IMAGE_CodingUnused is specified,
  *                       eColorFormat is valid
  *  eColorFormat       : Decompressed format used by this component
  */
@@ -164,8 +164,8 @@
 } OMX_IMAGE_PARAM_PORTFORMATTYPE;
 
 
-/** 
- * Flash control type 
+/**
+ * Flash control type
  *
  * ENUMS
  *  Torch : Flash forced constantly on
@@ -177,14 +177,14 @@
     OMX_IMAGE_FlashControlRedEyeReduction,
     OMX_IMAGE_FlashControlFillin,
     OMX_IMAGE_FlashControlTorch,
-    OMX_IMAGE_FlashControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_IMAGE_FlashControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_IMAGE_FlashControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_IMAGE_FlashControlMax = 0x7FFFFFFF
 } OMX_IMAGE_FLASHCONTROLTYPE;
 
 
-/** 
- * Flash control configuration 
+/**
+ * Flash control configuration
  *
  * STRUCT MEMBERS:
  *  nSize         : Size of the structure in bytes
@@ -200,29 +200,29 @@
 } OMX_IMAGE_PARAM_FLASHCONTROLTYPE;
 
 
-/** 
- * Focus control type 
+/**
+ * Focus control type
  */
 typedef enum OMX_IMAGE_FOCUSCONTROLTYPE {
     OMX_IMAGE_FocusControlOn = 0,
     OMX_IMAGE_FocusControlOff,
     OMX_IMAGE_FocusControlAuto,
     OMX_IMAGE_FocusControlAutoLock,
-    OMX_IMAGE_FocusControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_IMAGE_FocusControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_IMAGE_FocusControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_IMAGE_FocusControlMax = 0x7FFFFFFF
 } OMX_IMAGE_FOCUSCONTROLTYPE;
 
- 
-/** 
- * Focus control configuration 
+
+/**
+ * Focus control configuration
  *
  * STRUCT MEMBERS:
  *  nSize           : Size of the structure in bytes
  *  nVersion        : OMX specification version information
  *  nPortIndex      : Port that this structure applies to
  *  eFocusControl   : Focus control
- *  nFocusSteps     : Focus can take on values from 0 mm to infinity. 
+ *  nFocusSteps     : Focus can take on values from 0 mm to infinity.
  *                    Interest is only in number of steps over this range.
  *  nFocusStepIndex : Current focus step index
  */
@@ -236,30 +236,30 @@
 } OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE;
 
 
-/** 
+/**
  * Q Factor for JPEG compression, which controls the tradeoff between image
  * quality and size.  Q Factor provides a more simple means of controlling
  * JPEG compression quality, without directly programming Quantization
- * tables for chroma and luma 
+ * tables for chroma and luma
  *
  * STRUCT MEMBERS:
- *  nSize      : Size of the structure in bytes         
- *  nVersion   : OMX specification version information 
- *  nPortIndex : Port that this structure applies to 
- *  nQFactor   : JPEG Q factor value in the range of 1-100. A factor of 1 
- *               produces the smallest, worst quality images, and a factor 
- *               of 100 produces the largest, best quality images.  A 
- *               typical default is 75 for small good quality images               
+ *  nSize      : Size of the structure in bytes
+ *  nVersion   : OMX specification version information
+ *  nPortIndex : Port that this structure applies to
+ *  nQFactor   : JPEG Q factor value in the range of 1-100. A factor of 1
+ *               produces the smallest, worst quality images, and a factor
+ *               of 100 produces the largest, best quality images.  A
+ *               typical default is 75 for small good quality images
  */
 typedef struct OMX_IMAGE_PARAM_QFACTORTYPE {
-    OMX_U32 nSize;            
-    OMX_VERSIONTYPE nVersion; 
-    OMX_U32 nPortIndex;       
-    OMX_U32 nQFactor;                                        
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nQFactor;
 } OMX_IMAGE_PARAM_QFACTORTYPE;
 
-/** 
- * Quantization table type 
+/**
+ * Quantization table type
  */
 
 typedef enum OMX_IMAGE_QUANTIZATIONTABLETYPE {
@@ -267,27 +267,27 @@
     OMX_IMAGE_QuantizationTableChroma,
     OMX_IMAGE_QuantizationTableChromaCb,
     OMX_IMAGE_QuantizationTableChromaCr,
-    OMX_IMAGE_QuantizationTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_IMAGE_QuantizationTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_IMAGE_QuantizationTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_IMAGE_QuantizationTableMax = 0x7FFFFFFF
 } OMX_IMAGE_QUANTIZATIONTABLETYPE;
 
-/** 
+/**
  * JPEG quantization tables are used to determine DCT compression for
- * YUV data, as an alternative to specifying Q factor, providing exact 
- * control of compression 
+ * YUV data, as an alternative to specifying Q factor, providing exact
+ * control of compression
  *
  * STRUCT MEMBERS:
  *  nSize                   : Size of the structure in bytes
- *  nVersion                : OMX specification version information 
+ *  nVersion                : OMX specification version information
  *  nPortIndex              : Port that this structure applies to
  *  eQuantizationTable      : Quantization table type
- *  nQuantizationMatrix[64] : JPEG quantization table of coefficients stored 
- *                            in increasing columns then by rows of data (i.e. 
- *                            row 1, ... row 8). Quantization values are in 
+ *  nQuantizationMatrix[64] : JPEG quantization table of coefficients stored
+ *                            in increasing columns then by rows of data (i.e.
+ *                            row 1, ... row 8). Quantization values are in
  *                            the range 0-255 and stored in linear order
- *                            (i.e. the component will zig-zag the 
- *                            quantization table data if required internally) 
+ *                            (i.e. the component will zig-zag the
+ *                            quantization table data if required internally)
  */
 typedef struct OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE {
     OMX_U32 nSize;
@@ -298,9 +298,9 @@
 } OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE;
 
 
-/** 
- * Huffman table type, the same Huffman table is applied for chroma and 
- * luma component 
+/**
+ * Huffman table type, the same Huffman table is applied for chroma and
+ * luma component
  */
 typedef enum OMX_IMAGE_HUFFMANTABLETYPE {
     OMX_IMAGE_HuffmanTableAC = 0,
@@ -309,23 +309,23 @@
     OMX_IMAGE_HuffmanTableACChroma,
     OMX_IMAGE_HuffmanTableDCLuma,
     OMX_IMAGE_HuffmanTableDCChroma,
-    OMX_IMAGE_HuffmanTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_IMAGE_HuffmanTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_IMAGE_HuffmanTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_IMAGE_HuffmanTableMax = 0x7FFFFFFF
 } OMX_IMAGE_HUFFMANTABLETYPE;
 
-/** 
- * JPEG Huffman table 
+/**
+ * JPEG Huffman table
  *
  * STRUCT MEMBERS:
  *  nSize                            : Size of the structure in bytes
  *  nVersion                         : OMX specification version information
  *  nPortIndex                       : Port that this structure applies to
  *  eHuffmanTable                    : Huffman table type
- *  nNumberOfHuffmanCodeOfLength[16] : 0-16, number of Huffman codes of each 
+ *  nNumberOfHuffmanCodeOfLength[16] : 0-16, number of Huffman codes of each
  *                                     possible length
- *  nHuffmanTable[256]               : 0-255, the size used for AC and DC 
- *                                     HuffmanTable are 16 and 162 
+ *  nHuffmanTable[256]               : 0-255, the size used for AC and DC
+ *                                     HuffmanTable are 16 and 162
  */
 typedef struct OMX_IMAGE_PARAM_HUFFMANTTABLETYPE {
     OMX_U32 nSize;
diff --git a/include/media/openmax/OMX_Index.h b/include/media/openmax/OMX_Index.h
index be9a1a6..1a2a548 100644
--- a/include/media/openmax/OMX_Index.h
+++ b/include/media/openmax/OMX_Index.h
@@ -16,25 +16,25 @@
  * -------------------------------------------------------------------
  */
 /*
- * Copyright (c) 2008 The Khronos Group Inc. 
- * 
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
  * "Software"), to deal in the Software without restriction, including
  * without limitation the rights to use, copy, modify, merge, publish,
  * distribute, sublicense, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject
- * to the following conditions: 
+ * to the following conditions:
  * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software. 
- * 
+ * in all copies or substantial portions of the Software.
+ *
  * THE SOFTWARE IS 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
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
@@ -51,25 +51,23 @@
 extern "C" {
 #endif /* __cplusplus */
 
-
 /* Each OMX header must include all required header files to allow the
  *  header to compile without errors.  The includes below are required
- *  for this header file to compile successfully 
+ *  for this header file to compile successfully
  */
 #include <OMX_Types.h>
 
-
 /** The OMX_INDEXTYPE enumeration is used to select a structure when either
- *  getting or setting parameters and/or configuration data.  Each entry in 
- *  this enumeration maps to an OMX specified structure.  When the 
+ *  getting or setting parameters and/or configuration data.  Each entry in
+ *  this enumeration maps to an OMX specified structure.  When the
  *  OMX_GetParameter, OMX_SetParameter, OMX_GetConfig or OMX_SetConfig methods
  *  are used, the second parameter will always be an entry from this enumeration
  *  and the third entry will be the structure shown in the comments for the entry.
- *  For example, if the application is initializing a cropping function, the 
- *  OMX_SetConfig command would have OMX_IndexConfigCommonInputCrop as the second parameter 
- *  and would send a pointer to an initialized OMX_RECTTYPE structure as the 
+ *  For example, if the application is initializing a cropping function, the
+ *  OMX_SetConfig command would have OMX_IndexConfigCommonInputCrop as the second parameter
+ *  and would send a pointer to an initialized OMX_RECTTYPE structure as the
  *  third parameter.
- *  
+ *
  *  The enumeration entries named with the OMX_Config prefix are sent using
  *  the OMX_SetConfig command and the enumeration entries named with the
  *  OMX_PARAM_ prefix are sent using the OMX_SetParameter command.
@@ -86,11 +84,11 @@
     OMX_IndexParamActiveStream,             /**< reference: OMX_PARAM_U32TYPE */
     OMX_IndexParamSuspensionPolicy,         /**< reference: OMX_PARAM_SUSPENSIONPOLICYTYPE */
     OMX_IndexParamComponentSuspended,       /**< reference: OMX_PARAM_SUSPENSIONTYPE */
-    OMX_IndexConfigCapturing,               /**< reference: OMX_CONFIG_BOOLEANTYPE */ 
-    OMX_IndexConfigCaptureMode,             /**< reference: OMX_CONFIG_CAPTUREMODETYPE */ 
-    OMX_IndexAutoPauseAfterCapture,         /**< reference: OMX_CONFIG_BOOLEANTYPE */ 
+    OMX_IndexConfigCapturing,               /**< reference: OMX_CONFIG_BOOLEANTYPE */
+    OMX_IndexConfigCaptureMode,             /**< reference: OMX_CONFIG_CAPTUREMODETYPE */
+    OMX_IndexAutoPauseAfterCapture,         /**< reference: OMX_CONFIG_BOOLEANTYPE */
     OMX_IndexParamContentURI,               /**< reference: OMX_PARAM_CONTENTURITYPE */
-    OMX_IndexParamCustomContentPipe,        /**< reference: OMX_PARAM_CONTENTPIPETYPE */ 
+    OMX_IndexParamCustomContentPipe,        /**< reference: OMX_PARAM_CONTENTPIPETYPE */
     OMX_IndexParamDisableResourceConcealment, /**< reference: OMX_RESOURCECONCEALMENTTYPE */
     OMX_IndexConfigMetadataItemCount,       /**< reference: OMX_CONFIG_METADATAITEMCOUNTTYPE */
     OMX_IndexConfigContainerNodeCount,      /**< reference: OMX_CONFIG_CONTAINERNODECOUNTTYPE */
@@ -103,7 +101,7 @@
 
     OMX_IndexPortStartUnused = 0x02000000,
     OMX_IndexParamPortDefinition,           /**< reference: OMX_PARAM_PORTDEFINITIONTYPE */
-    OMX_IndexParamCompBufferSupplier,       /**< reference: OMX_PARAM_BUFFERSUPPLIERTYPE */ 
+    OMX_IndexParamCompBufferSupplier,       /**< reference: OMX_PARAM_BUFFERSUPPLIERTYPE */
     OMX_IndexReservedStartUnused = 0x03000000,
 
     /* Audio parameters and configurations */
@@ -256,10 +254,10 @@
     OMX_IndexConfigTimeSeekMode,            /**< reference: OMX_TIME_CONFIG_SEEKMODETYPE */
 
 
-    OMX_IndexKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_IndexKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     /* Vendor specific area */
     OMX_IndexVendorStartUnused = 0x7F000000,
-    /* Vendor specific structures should be in the range of 0x7F000000 
+    /* Vendor specific structures should be in the range of 0x7F000000
        to 0x7FFFFFFE.  This range is not broken out by vendor, so
        private indexes are not guaranteed unique and therefore should
        only be sent to the appropriate component. */
diff --git a/include/media/openmax/OMX_IndexExt.h b/include/media/openmax/OMX_IndexExt.h
index d22df56..25bea1f 100644
--- a/include/media/openmax/OMX_IndexExt.h
+++ b/include/media/openmax/OMX_IndexExt.h
@@ -57,6 +57,10 @@
 
     /* Audio parameters and configurations */
     OMX_IndexExtAudioStartUnused = OMX_IndexKhronosExtensions + 0x00400000,
+    OMX_IndexParamAudioAndroidAc3,                  /**< reference: OMX_AUDIO_PARAM_ANDROID_AC3TYPE */
+    OMX_IndexParamAudioAndroidOpus,                 /**< reference: OMX_AUDIO_PARAM_ANDROID_OPUSTYPE */
+    OMX_IndexParamAudioAndroidAacPresentation,      /**< reference: OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE */
+    OMX_IndexParamAudioAndroidEac3,                 /**< reference: OMX_AUDIO_PARAM_ANDROID_EAC3TYPE */
 
     /* Image parameters and configurations */
     OMX_IndexExtImageStartUnused = OMX_IndexKhronosExtensions + 0x00500000,
@@ -69,12 +73,19 @@
     OMX_IndexParamVideoVp8,                         /**< reference: OMX_VIDEO_PARAM_VP8TYPE */
     OMX_IndexConfigVideoVp8ReferenceFrame,          /**< reference: OMX_VIDEO_VP8REFERENCEFRAMETYPE */
     OMX_IndexConfigVideoVp8ReferenceFrameType,      /**< reference: OMX_VIDEO_VP8REFERENCEFRAMEINFOTYPE */
+    OMX_IndexParamVideoAndroidVp8Encoder,           /**< reference: OMX_VIDEO_PARAM_ANDROID_VP8ENCODERTYPE */
+    OMX_IndexParamVideoHevc,                        /**< reference: OMX_VIDEO_PARAM_HEVCTYPE */
+    OMX_IndexParamSliceSegments,                    /**< reference: OMX_VIDEO_SLICESEGMENTSTYPE */
 
     /* Image & Video common configurations */
     OMX_IndexExtCommonStartUnused = OMX_IndexKhronosExtensions + 0x00700000,
 
     /* Other configurations */
     OMX_IndexExtOtherStartUnused = OMX_IndexKhronosExtensions + 0x00800000,
+    OMX_IndexConfigAutoFramerateConversion,         /**< reference: OMX_CONFIG_BOOLEANTYPE */
+    OMX_IndexConfigPriority,                        /**< reference: OMX_PARAM_U32TYPE */
+    OMX_IndexConfigOperatingRate,                   /**< reference: OMX_PARAM_U32TYPE in Q16 format for video and in Hz for audio */
+    OMX_IndexParamConsumerUsageBits,                /**< reference: OMX_PARAM_U32TYPE */
 
     /* Time configurations */
     OMX_IndexExtTimeStartUnused = OMX_IndexKhronosExtensions + 0x00900000,
diff --git a/include/media/openmax/OMX_Other.h b/include/media/openmax/OMX_Other.h
index efbce83..6072ef6 100644
--- a/include/media/openmax/OMX_Other.h
+++ b/include/media/openmax/OMX_Other.h
@@ -16,25 +16,25 @@
  * -------------------------------------------------------------------
  */
 /*
- * Copyright (c) 2008 The Khronos Group Inc. 
- * 
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
  * "Software"), to deal in the Software without restriction, including
  * without limitation the rights to use, copy, modify, merge, publish,
  * distribute, sublicense, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject
- * to the following conditions: 
+ * to the following conditions:
  * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software. 
- * 
+ * in all copies or substantial portions of the Software.
+ *
  * THE SOFTWARE IS 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
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
@@ -53,46 +53,46 @@
 
 /* Each OMX header must include all required header files to allow the
  *  header to compile without errors.  The includes below are required
- *  for this header file to compile successfully 
+ *  for this header file to compile successfully
  */
 
 #include <OMX_Core.h>
 
 
-/** 
+/**
  * Enumeration of possible data types which match to multiple domains or no
  * domain at all.  For types which are vendor specific, a value above
  * OMX_OTHER_VENDORTSTART should be used.
  */
 typedef enum OMX_OTHER_FORMATTYPE {
-    OMX_OTHER_FormatTime = 0, /**< Transmission of various timestamps, elapsed time, 
+    OMX_OTHER_FormatTime = 0, /**< Transmission of various timestamps, elapsed time,
                                    time deltas, etc */
-    OMX_OTHER_FormatPower,    /**< Perhaps used for enabling/disabling power 
+    OMX_OTHER_FormatPower,    /**< Perhaps used for enabling/disabling power
                                    management, setting clocks? */
-    OMX_OTHER_FormatStats,    /**< Could be things such as frame rate, frames 
+    OMX_OTHER_FormatStats,    /**< Could be things such as frame rate, frames
                                    dropped, etc */
     OMX_OTHER_FormatBinary,   /**< Arbitrary binary data */
-    OMX_OTHER_FormatVendorReserved = 1000, /**< Starting value for vendor specific 
+    OMX_OTHER_FormatVendorReserved = 1000, /**< Starting value for vendor specific
                                                 formats */
 
-    OMX_OTHER_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_OTHER_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_OTHER_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_OTHER_FormatMax = 0x7FFFFFFF
 } OMX_OTHER_FORMATTYPE;
 
-/** 
+/**
  * Enumeration of seek modes.
  */
 typedef enum OMX_TIME_SEEKMODETYPE {
     OMX_TIME_SeekModeFast = 0, /**< Prefer seeking to an approximation
-                                * of the requested seek position over   
+                                * of the requested seek position over
                                 * the actual seek position if it
                                 * results in a faster seek. */
-    OMX_TIME_SeekModeAccurate, /**< Prefer seeking to the actual seek 
+    OMX_TIME_SeekModeAccurate, /**< Prefer seeking to the actual seek
                                 * position over an approximation
                                 * of the requested seek position even
                                 * if it results in a slower seek. */
-    OMX_TIME_SeekModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_TIME_SeekModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_TIME_SeekModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_TIME_SeekModeMax = 0x7FFFFFFF
 } OMX_TIME_SEEKMODETYPE;
@@ -104,42 +104,42 @@
     OMX_TIME_SEEKMODETYPE eType;    /**< The seek mode */
 } OMX_TIME_CONFIG_SEEKMODETYPE;
 
-/** Structure representing a time stamp used with the following configs 
+/** Structure representing a time stamp used with the following configs
  * on the Clock Component (CC):
- * 
- * OMX_IndexConfigTimeCurrentWallTime: query of the CCÂ’s current wall  
+ *
+ * OMX_IndexConfigTimeCurrentWallTime: query of the CC's current wall
  *     time
- * OMX_IndexConfigTimeCurrentMediaTime: query of the CCÂ’s current media
+ * OMX_IndexConfigTimeCurrentMediaTime: query of the CC's current media
  *     time
- * OMX_IndexConfigTimeCurrentAudioReference and  
- * OMX_IndexConfigTimeCurrentVideoReference: audio/video reference 
+ * OMX_IndexConfigTimeCurrentAudioReference and
+ * OMX_IndexConfigTimeCurrentVideoReference: audio/video reference
  *     clock sending SC its reference time
- * OMX_IndexConfigTimeClientStartTime: a Clock Component client sends 
- *     this structure to the Clock Component via a SetConfig on its 
+ * OMX_IndexConfigTimeClientStartTime: a Clock Component client sends
+ *     this structure to the Clock Component via a SetConfig on its
  *     client port when it receives a buffer with
  *     OMX_BUFFERFLAG_STARTTIME set. It must use the timestamp
- *     specified by that buffer for nStartTimestamp. 
+ *     specified by that buffer for nStartTimestamp.
  *
- * ItÂ’s also used with the following config on components in general:
+ * It's also used with the following config on components in general:
  *
- * OMX_IndexConfigTimePosition: IL client querying component position 
+ * OMX_IndexConfigTimePosition: IL client querying component position
  * (GetConfig) or commanding a component to seek to the given location
  * (SetConfig)
- */	
+ */
 typedef struct OMX_TIME_CONFIG_TIMESTAMPTYPE {
     OMX_U32 nSize;               /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;    /**< OMX specification version
                                   *   information */
-    OMX_U32 nPortIndex;     /**< port that this structure applies to */
-    OMX_TICKS nTimestamp;  	     /**< timestamp .*/ 
-} OMX_TIME_CONFIG_TIMESTAMPTYPE;  
+    OMX_U32 nPortIndex;          /**< port that this structure applies to */
+    OMX_TICKS nTimestamp;        /**< timestamp .*/
+} OMX_TIME_CONFIG_TIMESTAMPTYPE;
 
 /** Enumeration of possible reference clocks to the media time. */
 typedef enum OMX_TIME_UPDATETYPE {
       OMX_TIME_UpdateRequestFulfillment,    /**< Update is the fulfillment of a media time request. */
-      OMX_TIME_UpdateScaleChanged,	        /**< Update was generated because the scale chagned. */
+      OMX_TIME_UpdateScaleChanged,          /**< Update was generated because the scale chagned. */
       OMX_TIME_UpdateClockStateChanged,     /**< Update was generated because the clock state changed. */
-      OMX_TIME_UpdateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+      OMX_TIME_UpdateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
       OMX_TIME_UpdateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
       OMX_TIME_UpdateMax = 0x7FFFFFFF
 } OMX_TIME_UPDATETYPE;
@@ -147,9 +147,9 @@
 /** Enumeration of possible reference clocks to the media time. */
 typedef enum OMX_TIME_REFCLOCKTYPE {
       OMX_TIME_RefClockNone,    /**< Use no references. */
-      OMX_TIME_RefClockAudio,	/**< Use references sent through OMX_IndexConfigTimeCurrentAudioReference */
+      OMX_TIME_RefClockAudio,   /**< Use references sent through OMX_IndexConfigTimeCurrentAudioReference */
       OMX_TIME_RefClockVideo,   /**< Use references sent through OMX_IndexConfigTimeCurrentVideoReference */
-      OMX_TIME_RefClockKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+      OMX_TIME_RefClockKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
       OMX_TIME_RefClockVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
       OMX_TIME_RefClockMax = 0x7FFFFFFF
 } OMX_TIME_REFCLOCKTYPE;
@@ -157,11 +157,11 @@
 /** Enumeration of clock states. */
 typedef enum OMX_TIME_CLOCKSTATE {
       OMX_TIME_ClockStateRunning,             /**< Clock running. */
-      OMX_TIME_ClockStateWaitingForStartTime, /**< Clock waiting until the 
+      OMX_TIME_ClockStateWaitingForStartTime, /**< Clock waiting until the
                                                *   prescribed clients emit their
                                                *   start time. */
       OMX_TIME_ClockStateStopped,             /**< Clock stopped. */
-      OMX_TIME_ClockStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+      OMX_TIME_ClockStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
       OMX_TIME_ClockStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
       OMX_TIME_ClockStateMax = 0x7FFFFFFF
 } OMX_TIME_CLOCKSTATE;
@@ -171,18 +171,18 @@
  *  A client component sends this structure to the Clock Component via a SetConfig
  *  on its client port to specify a media timestamp the Clock Component
  *  should emit.  The Clock Component should fulfill the request by sending a
- *  OMX_TIME_MEDIATIMETYPE when its media clock matches the requested 
+ *  OMX_TIME_MEDIATIMETYPE when its media clock matches the requested
  *  timestamp.
  *
  *  The client may require a media time request be fulfilled slightly
- *  earlier than the media time specified. In this case the client specifies 
- *  an offset which is equal to the difference between wall time corresponding 
- *  to the requested media time and the wall time when it will be 
- *  fulfilled. 
+ *  earlier than the media time specified. In this case the client specifies
+ *  an offset which is equal to the difference between wall time corresponding
+ *  to the requested media time and the wall time when it will be
+ *  fulfilled.
  *
  *  A client component may uses these requests and the OMX_TIME_MEDIATIMETYPE to
  *  time events according to timestamps. If a client must perform an operation O at
- *  a time T (e.g. deliver a video frame at its corresponding timestamp), it makes a 
+ *  a time T (e.g. deliver a video frame at its corresponding timestamp), it makes a
  *  media time request at T (perhaps specifying an offset to ensure the request fulfillment
  *  is a little early). When the clock component passes the resulting OMX_TIME_MEDIATIMETYPE
  *  structure back to the client component, the client may perform operation O (perhaps having
@@ -193,52 +193,52 @@
     OMX_U32 nSize;              /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
     OMX_U32 nPortIndex;         /**< port that this structure applies to */
-    OMX_PTR pClientPrivate;     /**< Client private data to disabiguate this media time 
-                                 *   from others (e.g. the number of the frame to deliver). 
-                                 *   Duplicated in the media time structure that fulfills 
-                                 *   this request. A value of zero is reserved for time scale 
+    OMX_PTR pClientPrivate;     /**< Client private data to disabiguate this media time
+                                 *   from others (e.g. the number of the frame to deliver).
+                                 *   Duplicated in the media time structure that fulfills
+                                 *   this request. A value of zero is reserved for time scale
                                  *   updates. */
-    OMX_TICKS nMediaTimestamp;  /**< Media timestamp requested.*/ 
+    OMX_TICKS nMediaTimestamp;  /**< Media timestamp requested.*/
     OMX_TICKS nOffset;          /**< Amount of wall clock time by which this
                                  *   request should be fulfilled early */
 } OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE;
 
-/**< Structure sent from the clock component client either when fulfilling 
- *   a media time request or when the time scale has changed. 
+/**< Structure sent from the clock component client either when fulfilling
+ *   a media time request or when the time scale has changed.
  *
- *   In the former case the Clock Component fills this structure and times its emission 
- *   to a client component (via the client port) according to the corresponding media 
+ *   In the former case the Clock Component fills this structure and times its emission
+ *   to a client component (via the client port) according to the corresponding media
  *   time request sent by the client. The Clock Component should time the emission to occur
- *   when the requested timestamp matches the Clock Component's media time but also the 
- *   prescribed offset early. 
+ *   when the requested timestamp matches the Clock Component's media time but also the
+ *   prescribed offset early.
  *
  *   Upon scale changes the clock component clears the nClientPrivate data, sends the current
- *   media time and sets the nScale to the new scale via the client port. It emits a 
- *   OMX_TIME_MEDIATIMETYPE to all clients independent of any requests. This allows clients to 
- *   alter processing to accomodate scaling. For instance a video component might skip inter-frames 
- *   in the case of extreme fastforward. Likewise an audio component might add or remove samples 
- *   from an audio frame to scale audio data. 
+ *   media time and sets the nScale to the new scale via the client port. It emits a
+ *   OMX_TIME_MEDIATIMETYPE to all clients independent of any requests. This allows clients to
+ *   alter processing to accomodate scaling. For instance a video component might skip inter-frames
+ *   in the case of extreme fastforward. Likewise an audio component might add or remove samples
+ *   from an audio frame to scale audio data.
  *
  *   It is expected that some clock components may not be able to fulfill requests
- *   at exactly the prescribed time. This is acceptable so long as the request is 
- *   fulfilled at least as early as described and not later. This structure provides 
+ *   at exactly the prescribed time. This is acceptable so long as the request is
+ *   fulfilled at least as early as described and not later. This structure provides
  *   fields the client may use to wait for the remaining time.
  *
- *   The client may use either the nOffset or nWallTimeAtMedia fields to determine the 
+ *   The client may use either the nOffset or nWallTimeAtMedia fields to determine the
  *   wall time until the nMediaTimestamp actually occurs. In the latter case the
  *   client can get a more accurate value for offset by getting the current wall
- *   from the cloc component and subtracting it from nWallTimeAtMedia. 
+ *   from the cloc component and subtracting it from nWallTimeAtMedia.
  */
 
 typedef struct OMX_TIME_MEDIATIMETYPE {
     OMX_U32 nSize;                  /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */
-    OMX_U32 nClientPrivate;         /**< Client private data to disabiguate this media time 
-                                     *   from others. Copied from the media time request. 
+    OMX_U32 nClientPrivate;         /**< Client private data to disabiguate this media time
+                                     *   from others. Copied from the media time request.
                                      *   A value of zero is reserved for time scale updates. */
     OMX_TIME_UPDATETYPE eUpdateType; /**< Reason for the update */
-    OMX_TICKS nMediaTimestamp;      /**< Media time requested. If no media time was 
-                                     *   requested then this is the current media time. */ 
+    OMX_TICKS nMediaTimestamp;      /**< Media time requested. If no media time was
+                                     *   requested then this is the current media time. */
     OMX_TICKS nOffset;              /**< Amount of wall clock time by which this
                                      *   request was actually fulfilled early */
 
@@ -250,21 +250,21 @@
     OMX_S32 xScale;                 /**< Current media time scale in Q16 format. */
     OMX_TIME_CLOCKSTATE eState;     /* Seeking Change. Added 7/12.*/
                                     /**< State of the media time. */
-} OMX_TIME_MEDIATIMETYPE;  
+} OMX_TIME_MEDIATIMETYPE;
 
-/** Structure representing the current media time scale factor. Applicable only to clock 
+/** Structure representing the current media time scale factor. Applicable only to clock
  *  component, other components see scale changes via OMX_TIME_MEDIATIMETYPE buffers sent via
- *  the clock component client ports. Upon recieving this config the clock component changes 
- *  the rate by which the media time increases or decreases effectively implementing trick modes. 
- */ 
+ *  the clock component client ports. Upon recieving this config the clock component changes
+ *  the rate by which the media time increases or decreases effectively implementing trick modes.
+ */
 typedef struct OMX_TIME_CONFIG_SCALETYPE {
     OMX_U32 nSize;                  /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */
     OMX_S32 xScale;                 /**< This is a value in Q16 format which is used for
                                      * scaling the media time */
 } OMX_TIME_CONFIG_SCALETYPE;
- 
-/** Bits used to identify a clock port. Used in OMX_TIME_CONFIG_CLOCKSTATETYPEÂ’s nWaitMask field */
+
+/** Bits used to identify a clock port. Used in OMX_TIME_CONFIG_CLOCKSTATETYPE's nWaitMask field */
 #define OMX_CLOCKPORT0 0x00000001
 #define OMX_CLOCKPORT1 0x00000002
 #define OMX_CLOCKPORT2 0x00000004
@@ -274,38 +274,38 @@
 #define OMX_CLOCKPORT6 0x00000040
 #define OMX_CLOCKPORT7 0x00000080
 
-/** Structure representing the current mode of the media clock. 
- *  IL Client uses this config to change or query the mode of the 
+/** Structure representing the current mode of the media clock.
+ *  IL Client uses this config to change or query the mode of the
  *  media clock of the clock component. Applicable only to clock
- *  component. 
- *  
+ *  component.
+ *
  *  On a SetConfig if eState is OMX_TIME_ClockStateRunning media time
  *  starts immediately at the prescribed start time. If
  *  OMX_TIME_ClockStateWaitingForStartTime the Clock Component ignores
- *  the given nStartTime and waits for all clients specified in the 
- *  nWaitMask to send starttimes (via 
- *  OMX_IndexConfigTimeClientStartTime). The Clock Component then starts 
- *  the media clock using the earliest start time supplied. */    
+ *  the given nStartTime and waits for all clients specified in the
+ *  nWaitMask to send starttimes (via
+ *  OMX_IndexConfigTimeClientStartTime). The Clock Component then starts
+ *  the media clock using the earliest start time supplied. */
 typedef struct OMX_TIME_CONFIG_CLOCKSTATETYPE {
     OMX_U32 nSize;              /**< size of the structure in bytes */
-    OMX_VERSIONTYPE nVersion;   /**< OMX specification version 
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version
                                  *   information */
     OMX_TIME_CLOCKSTATE eState; /**< State of the media time. */
     OMX_TICKS nStartTime;       /**< Start time of the media time. */
-    OMX_TICKS nOffset;          /**< Time to offset the media time by 
+    OMX_TICKS nOffset;          /**< Time to offset the media time by
                                  * (e.g. preroll). Media time will be
-                                 * reported to be nOffset ticks earlier.     
+                                 * reported to be nOffset ticks earlier.
                                  */
     OMX_U32 nWaitMask;          /**< Mask of OMX_CLOCKPORT values. */
 } OMX_TIME_CONFIG_CLOCKSTATETYPE;
 
 /** Structure representing the reference clock currently being used to
- *  compute media time. IL client uses this config to change or query the 
+ *  compute media time. IL client uses this config to change or query the
  *  clock component's active reference clock */
 typedef struct OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE {
     OMX_U32 nSize;                  /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */
-    OMX_TIME_REFCLOCKTYPE eClock;   /**< Reference clock used to compute media time */                        
+    OMX_TIME_REFCLOCKTYPE eClock;   /**< Reference clock used to compute media time */
 } OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE;
 
 /** Descriptor for setting specifics of power type.
@@ -327,8 +327,8 @@
 
 
 /**
- * The PortDefinition structure is used to define all of the parameters 
- * necessary for the compliant component to setup an input or an output other 
+ * The PortDefinition structure is used to define all of the parameters
+ * necessary for the compliant component to setup an input or an output other
  * path.
  */
 typedef struct OMX_OTHER_PORTDEFINITIONTYPE {
@@ -344,7 +344,7 @@
     OMX_U32 nPortIndex; /**< Indicates which port to set */
     OMX_U32 nIndex; /**< Indicates the enumeration index for the format from 0x0 to N-1 */
     OMX_OTHER_FORMATTYPE eFormat; /**< Type of data expected for this channel */
-} OMX_OTHER_PARAM_PORTFORMATTYPE; 
+} OMX_OTHER_PARAM_PORTFORMATTYPE;
 
 #ifdef __cplusplus
 }
diff --git a/include/media/openmax/OMX_Types.h b/include/media/openmax/OMX_Types.h
index 9dec372..5afaba0 100644
--- a/include/media/openmax/OMX_Types.h
+++ b/include/media/openmax/OMX_Types.h
@@ -16,32 +16,32 @@
  * -------------------------------------------------------------------
  */
 /*
- * Copyright (c) 2008 The Khronos Group Inc. 
- * 
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
  * "Software"), to deal in the Software without restriction, including
  * without limitation the rights to use, copy, modify, merge, publish,
  * distribute, sublicense, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject
- * to the following conditions: 
+ * to the following conditions:
  * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software. 
- * 
+ * in all copies or substantial portions of the Software.
+ *
  * THE SOFTWARE IS 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
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
 /** OMX_Types.h - OpenMax IL version 1.1.2
- *  The OMX_Types header file contains the primitive type definitions used by 
+ *  The OMX_Types header file contains the primitive type definitions used by
  *  the core, the application and the component.  This file may need to be
- *  modified to be used on systems that do not have "char" set to 8 bits, 
+ *  modified to be used on systems that do not have "char" set to 8 bits,
  *  "short" set to 16 bits and "long" set to 32 bits.
  */
 
@@ -57,12 +57,12 @@
 /** The OMX_API and OMX_APIENTRY are platform specific definitions used
  *  to declare OMX function prototypes.  They are modified to meet the
  *  requirements for a particular platform */
-#ifdef __SYMBIAN32__   
+#ifdef __SYMBIAN32__
 #   ifdef __OMX_EXPORTS
 #       define OMX_API __declspec(dllexport)
 #   else
 #       ifdef _WIN32
-#           define OMX_API __declspec(dllexport) 
+#           define OMX_API __declspec(dllexport)
 #       else
 #           define OMX_API __declspec(dllimport)
 #       endif
@@ -85,18 +85,18 @@
 #endif
 
 #ifndef OMX_APIENTRY
-#define OMX_APIENTRY 
-#endif 
+#define OMX_APIENTRY
+#endif
 
-/** OMX_IN is used to identify inputs to an OMX function.  This designation 
-    will also be used in the case of a pointer that points to a parameter 
+/** OMX_IN is used to identify inputs to an OMX function.  This designation
+    will also be used in the case of a pointer that points to a parameter
     that is used as an output. */
 #ifndef OMX_IN
 #define OMX_IN
 #endif
 
-/** OMX_OUT is used to identify outputs from an OMX function.  This 
-    designation will also be used in the case of a pointer that points 
+/** OMX_OUT is used to identify outputs from an OMX function.  This
+    designation will also be used in the case of a pointer that points
     to a parameter that is used as an input. */
 #ifndef OMX_OUT
 #define OMX_OUT
@@ -104,8 +104,8 @@
 
 
 /** OMX_INOUT is used to identify parameters that may be either inputs or
-    outputs from an OMX function at the same time.  This designation will 
-    also be used in the case of a pointer that  points to a parameter that 
+    outputs from an OMX function at the same time.  This designation will
+    also be used in the case of a pointer that  points to a parameter that
     is used both as an input and an output. */
 #ifndef OMX_INOUT
 #define OMX_INOUT
@@ -123,31 +123,31 @@
 /** @defgroup core OpenMAX IL core
  * Functions and structure related to the OMX IL core
  */
- 
+
  /** @defgroup comp OpenMAX IL component
  * Functions and structure related to the OMX IL component
  */
- 
-/** @defgroup rpm Resource and Policy Management 
+
+/** @defgroup rpm Resource and Policy Management
  * Structures for resource and policy management of components
  */
 
 /** @defgroup buf Buffer Management
  * Buffer handling functions and structures
  */
-  
+
 /** @defgroup tun Tunneling
  * @ingroup core comp
  * Structures and functions to manage tunnels among component ports
  */
- 
+
 /** @defgroup cp Content Pipes
  *  @ingroup core
  */
- 
+
  /** @defgroup metadata Metadata handling
-  * 
-  */ 
+  *
+  */
 
 /** OMX_U8 is an 8 bit unsigned quantity that is byte aligned */
 typedef unsigned char OMX_U8;
@@ -169,7 +169,7 @@
 
 
 /* Users with compilers that cannot accept the "long long" designation should
-   define the OMX_SKIP64BIT macro.  It should be noted that this may cause 
+   define the OMX_SKIP64BIT macro.  It should be noted that this may cause
    some components to fail to compile if the component was written to require
    64 bit integral types.  However, these components would NOT compile anyway
    since the compiler does not support the way the component was written.
@@ -184,7 +184,7 @@
 
 #elif defined(WIN32)
 
-/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */   
+/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */
 typedef unsigned __int64  OMX_U64;
 
 /** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */
@@ -202,7 +202,7 @@
 #endif
 
 
-/** The OMX_BOOL type is intended to be used to represent a true or a false 
+/** The OMX_BOOL type is intended to be used to represent a true or a false
     value when passing parameters to and from the OMX core and components.  The
     OMX_BOOL is a 32 bit quantity and is aligned on a 32 bit word boundary.
  */
@@ -210,8 +210,26 @@
     OMX_FALSE = 0,
     OMX_TRUE = !OMX_FALSE,
     OMX_BOOL_MAX = 0x7FFFFFFF
-} OMX_BOOL; 
- 
+} OMX_BOOL;
+
+/*
+ * Temporary Android 64 bit modification
+ *
+ * #define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
+ * overrides all OMX pointer types to be uint32_t.
+ *
+ * After this change, OMX codecs will work in 32 bit only, so 64 bit processes
+ * must communicate to a remote 32 bit process for OMX to work.
+ */
+
+#ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
+
+typedef uint32_t OMX_PTR;
+typedef OMX_PTR OMX_STRING;
+typedef OMX_PTR OMX_BYTE;
+
+#else /* OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS */
+
 /** The OMX_PTR type is intended to be used to pass pointers between the OMX
     applications and the OMX Core and components.  This is a 32 bit pointer and
     is aligned on a 32 bit boundary.
@@ -219,19 +237,21 @@
 typedef void* OMX_PTR;
 
 /** The OMX_STRING type is intended to be used to pass "C" type strings between
-    the application and the core and component.  The OMX_STRING type is a 32 
-    bit pointer to a zero terminated string.  The  pointer is word aligned and 
-    the string is byte aligned.  
+    the application and the core and component.  The OMX_STRING type is a 32
+    bit pointer to a zero terminated string.  The  pointer is word aligned and
+    the string is byte aligned.
  */
 typedef char* OMX_STRING;
 
 /** The OMX_BYTE type is intended to be used to pass arrays of bytes such as
-    buffers between the application and the component and core.  The OMX_BYTE 
+    buffers between the application and the component and core.  The OMX_BYTE
     type is a 32 bit pointer to a zero terminated string.  The  pointer is word
     aligned and the string is byte aligned.
  */
 typedef unsigned char* OMX_BYTE;
 
+#endif /* OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS */
+
 /** OMX_UUIDTYPE is a very long unique identifier to uniquely identify
     at runtime.  This identifier should be generated by a component in a way
     that guarantees that every instance of the identifier running on the system
@@ -239,7 +259,7 @@
 typedef unsigned char OMX_UUIDTYPE[128];
 
 /** The OMX_DIRTYPE enumeration is used to indicate if a port is an input or
-    an output port.  This enumeration is common across all component types.    
+    an output port.  This enumeration is common across all component types.
  */
 typedef enum OMX_DIRTYPE
 {
@@ -248,8 +268,8 @@
     OMX_DirMax = 0x7FFFFFFF
 } OMX_DIRTYPE;
 
-/** The OMX_ENDIANTYPE enumeration is used to indicate the bit ordering 
-    for numerical data (i.e. big endian, or little endian).    
+/** The OMX_ENDIANTYPE enumeration is used to indicate the bit ordering
+    for numerical data (i.e. big endian, or little endian).
  */
 typedef enum OMX_ENDIANTYPE
 {
@@ -259,7 +279,7 @@
 } OMX_ENDIANTYPE;
 
 
-/** The OMX_NUMERICALDATATYPE enumeration is used to indicate if data 
+/** The OMX_NUMERICALDATATYPE enumeration is used to indicate if data
     is signed or unsigned
  */
 typedef enum OMX_NUMERICALDATATYPE
@@ -287,16 +307,16 @@
 
 
 /** Structure representing some time or duration in microseconds. This structure
-  *  must be interpreted as a signed 64 bit value. The quantity is signed to accommodate 
-  *  negative deltas and preroll scenarios. The quantity is represented in microseconds 
+  *  must be interpreted as a signed 64 bit value. The quantity is signed to accommodate
+  *  negative deltas and preroll scenarios. The quantity is represented in microseconds
   *  to accomodate high resolution timestamps (e.g. DVD presentation timestamps based
-  *  on a 90kHz clock) and to allow more accurate and synchronized delivery (e.g. 
-  *  individual audio samples delivered at 192 kHz). The quantity is 64 bit to 
+  *  on a 90kHz clock) and to allow more accurate and synchronized delivery (e.g.
+  *  individual audio samples delivered at 192 kHz). The quantity is 64 bit to
   *  accommodate a large dynamic range (signed 32 bit values would allow only for plus
   *  or minus 35 minutes).
   *
-  *  Implementations with limited precision may convert the signed 64 bit value to 
-  *  a signed 32 bit value internally but risk loss of precision.  
+  *  Implementations with limited precision may convert the signed 64 bit value to
+  *  a signed 32 bit value internally but risk loss of precision.
   */
 #ifndef OMX_SKIP64BIT
 typedef OMX_S64 OMX_TICKS;
@@ -312,32 +332,32 @@
 /** Define the public interface for the OMX Handle.  The core will not use
     this value internally, but the application should only use this value.
  */
-typedef void* OMX_HANDLETYPE;
+typedef OMX_PTR OMX_HANDLETYPE;
 
 typedef struct OMX_MARKTYPE
 {
-    OMX_HANDLETYPE hMarkTargetComponent;   /**< The component that will 
-                                                generate a mark event upon 
+    OMX_HANDLETYPE hMarkTargetComponent;   /**< The component that will
+                                                generate a mark event upon
                                                 processing the mark. */
-    OMX_PTR pMarkData;   /**< Application specific data associated with 
-                              the mark sent on a mark event to disambiguate 
+    OMX_PTR pMarkData;   /**< Application specific data associated with
+                              the mark sent on a mark event to disambiguate
                               this mark from others. */
 } OMX_MARKTYPE;
 
 
 /** OMX_NATIVE_DEVICETYPE is used to map a OMX video port to the
- *  platform & operating specific object used to reference the display 
+ *  platform & operating specific object used to reference the display
  *  or can be used by a audio port for native audio rendering */
-typedef void* OMX_NATIVE_DEVICETYPE;
+typedef OMX_PTR OMX_NATIVE_DEVICETYPE;
 
 /** OMX_NATIVE_WINDOWTYPE is used to map a OMX video port to the
  *  platform & operating specific object used to reference the window */
-typedef void* OMX_NATIVE_WINDOWTYPE;
+typedef OMX_PTR OMX_NATIVE_WINDOWTYPE;
 
 /** The OMX_VERSIONTYPE union is used to specify the version for
     a structure or component.  For a component, the version is entirely
     specified by the component vendor.  Components doing the same function
-    from different vendors may or may not have the same version.  For 
+    from different vendors may or may not have the same version.  For
     structures, the version shall be set by the entity that allocates the
     structure.  For structures specified in the OMX 1.1 specification, the
     value of the version shall be set to 1.1.0.0 in all cases.  Access to the
diff --git a/include/media/openmax/OMX_Video.h b/include/media/openmax/OMX_Video.h
index 4441a7a..decc410 100644
--- a/include/media/openmax/OMX_Video.h
+++ b/include/media/openmax/OMX_Video.h
@@ -16,31 +16,31 @@
  * -------------------------------------------------------------------
  */
 /**
- * Copyright (c) 2008 The Khronos Group Inc. 
- * 
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
  * "Software"), to deal in the Software without restriction, including
  * without limitation the rights to use, copy, modify, merge, publish,
  * distribute, sublicense, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject
- * to the following conditions: 
+ * to the following conditions:
  * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software. 
- * 
+ * in all copies or substantial portions of the Software.
+ *
  * THE SOFTWARE IS 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
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
-/** 
+/**
  *  @file OMX_Video.h - OpenMax IL version 1.1.2
- *  The structures is needed by Video components to exchange parameters 
+ *  The structures is needed by Video components to exchange parameters
  *  and configuration data with OMX components.
  */
 #ifndef OMX_Video_h
@@ -60,19 +60,19 @@
 /**
  * Each OMX header must include all required header files to allow the
  * header to compile without errors.  The includes below are required
- * for this header file to compile successfully 
+ * for this header file to compile successfully
  */
 
 #include <OMX_IVCommon.h>
 
 
 /**
- * Enumeration used to define the possible video compression codings.  
- * NOTE:  This essentially refers to file extensions. If the coding is 
- *        being used to specify the ENCODE type, then additional work 
- *        must be done to configure the exact flavor of the compression 
- *        to be used.  For decode cases where the user application can 
- *        not differentiate between MPEG-4 and H.264 bit streams, it is 
+ * Enumeration used to define the possible video compression codings.
+ * NOTE:  This essentially refers to file extensions. If the coding is
+ *        being used to specify the ENCODE type, then additional work
+ *        must be done to configure the exact flavor of the compression
+ *        to be used.  For decode cases where the user application can
+ *        not differentiate between MPEG-4 and H.264 bit streams, it is
  *        up to the codec to handle this.
  */
 typedef enum OMX_VIDEO_CODINGTYPE {
@@ -87,58 +87,59 @@
     OMX_VIDEO_CodingMJPEG,      /**< Motion JPEG */
     OMX_VIDEO_CodingVP8,        /**< Google VP8, formerly known as On2 VP8 */
     OMX_VIDEO_CodingVP9,        /**< Google VP9 */
-    OMX_VIDEO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_CodingHEVC,       /**< ITU H.265/HEVC */
+    OMX_VIDEO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_VIDEO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_CodingMax = 0x7FFFFFFF
 } OMX_VIDEO_CODINGTYPE;
 
 
 /**
- * Data structure used to define a video path.  The number of Video paths for 
- * input and output will vary by type of the Video component.  
- * 
+ * Data structure used to define a video path.  The number of Video paths for
+ * input and output will vary by type of the Video component.
+ *
  *    Input (aka Source) : zero Inputs, one Output,
  *    Splitter           : one Input, 2 or more Outputs,
  *    Processing Element : one Input, one output,
  *    Mixer              : 2 or more inputs, one output,
  *    Output (aka Sink)  : one Input, zero outputs.
- * 
- * The PortDefinition structure is used to define all of the parameters 
- * necessary for the compliant component to setup an input or an output video 
- * path.  If additional vendor specific data is required, it should be 
- * transmitted to the component using the CustomCommand function.  Compliant 
- * components will prepopulate this structure with optimal values during the 
+ *
+ * The PortDefinition structure is used to define all of the parameters
+ * necessary for the compliant component to setup an input or an output video
+ * path.  If additional vendor specific data is required, it should be
+ * transmitted to the component using the CustomCommand function.  Compliant
+ * components will prepopulate this structure with optimal values during the
  * GetDefaultInitParams command.
  *
  * STRUCT MEMBERS:
  *  cMIMEType             : MIME type of data for the port
- *  pNativeRender         : Platform specific reference for a display if a 
+ *  pNativeRender         : Platform specific reference for a display if a
  *                          sync, otherwise this field is 0
- *  nFrameWidth           : Width of frame to be used on channel if 
+ *  nFrameWidth           : Width of frame to be used on channel if
  *                          uncompressed format is used.  Use 0 for unknown,
  *                          don't care or variable
- *  nFrameHeight          : Height of frame to be used on channel if 
+ *  nFrameHeight          : Height of frame to be used on channel if
  *                          uncompressed format is used. Use 0 for unknown,
  *                          don't care or variable
- *  nStride               : Number of bytes per span of an image 
+ *  nStride               : Number of bytes per span of an image
  *                          (i.e. indicates the number of bytes to get
  *                          from span N to span N+1, where negative stride
  *                          indicates the image is bottom up
  *  nSliceHeight          : Height used when encoding in slices
- *  nBitrate              : Bit rate of frame to be used on channel if 
- *                          compressed format is used. Use 0 for unknown, 
+ *  nBitrate              : Bit rate of frame to be used on channel if
+ *                          compressed format is used. Use 0 for unknown,
  *                          don't care or variable
- *  xFramerate            : Frame rate to be used on channel if uncompressed 
- *                          format is used. Use 0 for unknown, don't care or 
+ *  xFramerate            : Frame rate to be used on channel if uncompressed
+ *                          format is used. Use 0 for unknown, don't care or
  *                          variable.  Units are Q16 frames per second.
- *  bFlagErrorConcealment : Turns on error concealment if it is supported by 
+ *  bFlagErrorConcealment : Turns on error concealment if it is supported by
  *                          the OMX component
- *  eCompressionFormat    : Compression format used in this instance of the 
- *                          component. When OMX_VIDEO_CodingUnused is 
+ *  eCompressionFormat    : Compression format used in this instance of the
+ *                          component. When OMX_VIDEO_CodingUnused is
  *                          specified, eColorFormat is used
  *  eColorFormat : Decompressed format used by this component
- *  pNativeWindow : Platform specific reference for a window object if a 
- *                          display sink , otherwise this field is 0x0. 
+ *  pNativeWindow : Platform specific reference for a window object if a
+ *                          display sink , otherwise this field is 0x0.
  */
 typedef struct OMX_VIDEO_PORTDEFINITIONTYPE {
     OMX_STRING cMIMEType;
@@ -155,19 +156,19 @@
     OMX_NATIVE_WINDOWTYPE pNativeWindow;
 } OMX_VIDEO_PORTDEFINITIONTYPE;
 
-/**  
- * Port format parameter.  This structure is used to enumerate the various 
+/**
+ * Port format parameter.  This structure is used to enumerate the various
  * data input/output format supported by the port.
- * 
+ *
  * STRUCT MEMBERS:
  *  nSize              : Size of the structure in bytes
  *  nVersion           : OMX specification version information
  *  nPortIndex         : Indicates which port to set
- *  nIndex             : Indicates the enumeration index for the format from 
+ *  nIndex             : Indicates the enumeration index for the format from
  *                       0x0 to N-1
- *  eCompressionFormat : Compression format used in this instance of the 
- *                       component. When OMX_VIDEO_CodingUnused is specified, 
- *                       eColorFormat is used 
+ *  eCompressionFormat : Compression format used in this instance of the
+ *                       component. When OMX_VIDEO_CodingUnused is specified,
+ *                       eColorFormat is used
  *  eColorFormat       : Decompressed format used by this component
  *  xFrameRate         : Indicates the video frame rate in Q16 format
  */
@@ -176,14 +177,14 @@
     OMX_VERSIONTYPE nVersion;
     OMX_U32 nPortIndex;
     OMX_U32 nIndex;
-    OMX_VIDEO_CODINGTYPE eCompressionFormat; 
+    OMX_VIDEO_CODINGTYPE eCompressionFormat;
     OMX_COLOR_FORMATTYPE eColorFormat;
     OMX_U32 xFramerate;
 } OMX_VIDEO_PARAM_PORTFORMATTYPE;
 
 
 /**
- * This is a structure for configuring video compression quantization 
+ * This is a structure for configuring video compression quantization
  * parameter values.  Codecs may support different QP values for different
  * frame types.
  *
@@ -193,10 +194,10 @@
  *  nPortIndex : Port that this structure applies to
  *  nQpI       : QP value to use for index frames
  *  nQpP       : QP value to use for P frames
- *  nQpB       : QP values to use for bidirectional frames 
+ *  nQpB       : QP values to use for bidirectional frames
  */
 typedef struct OMX_VIDEO_PARAM_QUANTIZATIONTYPE {
-    OMX_U32 nSize;            
+    OMX_U32 nSize;
     OMX_VERSIONTYPE nVersion;
     OMX_U32 nPortIndex;
     OMX_U32 nQpI;
@@ -205,32 +206,32 @@
 } OMX_VIDEO_PARAM_QUANTIZATIONTYPE;
 
 
-/** 
- * Structure for configuration of video fast update parameters. 
- *  
+/**
+ * Structure for configuration of video fast update parameters.
+ *
  * STRUCT MEMBERS:
  *  nSize      : Size of the structure in bytes
- *  nVersion   : OMX specification version info 
+ *  nVersion   : OMX specification version info
  *  nPortIndex : Port that this structure applies to
  *  bEnableVFU : Enable/Disable video fast update
  *  nFirstGOB  : Specifies the number of the first macroblock row
  *  nFirstMB   : specifies the first MB relative to the specified first GOB
- *  nNumMBs    : Specifies the number of MBs to be refreshed from nFirstGOB 
+ *  nNumMBs    : Specifies the number of MBs to be refreshed from nFirstGOB
  *               and nFirstMB
  */
 typedef struct OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE {
-    OMX_U32 nSize;            
-    OMX_VERSIONTYPE nVersion; 
-    OMX_U32 nPortIndex;       
-    OMX_BOOL bEnableVFU;      
-    OMX_U32 nFirstGOB;                            
-    OMX_U32 nFirstMB;                            
-    OMX_U32 nNumMBs;                                  
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL bEnableVFU;
+    OMX_U32 nFirstGOB;
+    OMX_U32 nFirstMB;
+    OMX_U32 nNumMBs;
 } OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE;
 
 
-/** 
- * Enumeration of possible bitrate control types 
+/**
+ * Enumeration of possible bitrate control types
  */
 typedef enum OMX_VIDEO_CONTROLRATETYPE {
     OMX_Video_ControlRateDisable,
@@ -238,14 +239,14 @@
     OMX_Video_ControlRateConstant,
     OMX_Video_ControlRateVariableSkipFrames,
     OMX_Video_ControlRateConstantSkipFrames,
-    OMX_Video_ControlRateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_Video_ControlRateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_Video_ControlRateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_Video_ControlRateMax = 0x7FFFFFFF
 } OMX_VIDEO_CONTROLRATETYPE;
 
 
-/** 
- * Structure for configuring bitrate mode of a codec. 
+/**
+ * Structure for configuring bitrate mode of a codec.
  *
  * STRUCT MEMBERS:
  *  nSize          : Size of the struct in bytes
@@ -255,23 +256,23 @@
  *  nTargetBitrate : Target bitrate to encode with
  */
 typedef struct OMX_VIDEO_PARAM_BITRATETYPE {
-    OMX_U32 nSize;                          
-    OMX_VERSIONTYPE nVersion;               
-    OMX_U32 nPortIndex;                     
-    OMX_VIDEO_CONTROLRATETYPE eControlRate; 
-    OMX_U32 nTargetBitrate;                 
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_VIDEO_CONTROLRATETYPE eControlRate;
+    OMX_U32 nTargetBitrate;
 } OMX_VIDEO_PARAM_BITRATETYPE;
 
 
-/** 
- * Enumeration of possible motion vector (MV) types 
+/**
+ * Enumeration of possible motion vector (MV) types
  */
 typedef enum OMX_VIDEO_MOTIONVECTORTYPE {
     OMX_Video_MotionVectorPixel,
     OMX_Video_MotionVectorHalfPel,
     OMX_Video_MotionVectorQuarterPel,
     OMX_Video_MotionVectorEighthPel,
-    OMX_Video_MotionVectorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_Video_MotionVectorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_Video_MotionVectorVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_Video_MotionVectorMax = 0x7FFFFFFF
 } OMX_VIDEO_MOTIONVECTORTYPE;
@@ -280,7 +281,7 @@
 /**
  * Structure for configuring the number of motion vectors used as well
  * as their accuracy.
- * 
+ *
  * STRUCT MEMBERS:
  *  nSize            : Size of the struct in bytes
  *  nVersion         : OMX spec version info
@@ -303,32 +304,32 @@
 } OMX_VIDEO_PARAM_MOTIONVECTORTYPE;
 
 
-/** 
- * Enumeration of possible methods to use for Intra Refresh 
+/**
+ * Enumeration of possible methods to use for Intra Refresh
  */
 typedef enum OMX_VIDEO_INTRAREFRESHTYPE {
     OMX_VIDEO_IntraRefreshCyclic,
     OMX_VIDEO_IntraRefreshAdaptive,
     OMX_VIDEO_IntraRefreshBoth,
-    OMX_VIDEO_IntraRefreshKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_IntraRefreshKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_VIDEO_IntraRefreshVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_IntraRefreshMax = 0x7FFFFFFF
 } OMX_VIDEO_INTRAREFRESHTYPE;
 
 
 /**
- * Structure for configuring intra refresh mode 
- * 
+ * Structure for configuring intra refresh mode
+ *
  * STRUCT MEMBERS:
  *  nSize        : Size of the structure in bytes
  *  nVersion     : OMX specification version information
  *  nPortIndex   : Port that this structure applies to
  *  eRefreshMode : Cyclic, Adaptive, or Both
- *  nAirMBs      : Number of intra macroblocks to refresh in a frame when 
+ *  nAirMBs      : Number of intra macroblocks to refresh in a frame when
  *                 AIR is enabled
- *  nAirRef      : Number of times a motion marked macroblock has to be  
+ *  nAirRef      : Number of times a motion marked macroblock has to be
  *                 intra coded
- *  nCirMBs      : Number of consecutive macroblocks to be coded as "intra"  
+ *  nCirMBs      : Number of consecutive macroblocks to be coded as "intra"
  *                 when CIR is enabled
  */
 typedef struct OMX_VIDEO_PARAM_INTRAREFRESHTYPE {
@@ -343,19 +344,19 @@
 
 
 /**
- * Structure for enabling various error correction methods for video 
+ * Structure for enabling various error correction methods for video
  * compression.
  *
  * STRUCT MEMBERS:
  *  nSize                   : Size of the structure in bytes
- *  nVersion                : OMX specification version information 
- *  nPortIndex              : Port that this structure applies to 
+ *  nVersion                : OMX specification version information
+ *  nPortIndex              : Port that this structure applies to
  *  bEnableHEC              : Enable/disable header extension codes (HEC)
  *  bEnableResync           : Enable/disable resynchronization markers
- *  nResynchMarkerSpacing   : Resynch markers interval (in bits) to be 
- *                            applied in the stream 
- *  bEnableDataPartitioning : Enable/disable data partitioning 
- *  bEnableRVLC             : Enable/disable reversible variable length 
+ *  nResynchMarkerSpacing   : Resynch markers interval (in bits) to be
+ *                            applied in the stream
+ *  bEnableDataPartitioning : Enable/disable data partitioning
+ *  bEnableRVLC             : Enable/disable reversible variable length
  *                            coding
  */
 typedef struct OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE {
@@ -370,12 +371,12 @@
 } OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE;
 
 
-/** 
- * Configuration of variable block-size motion compensation (VBSMC) 
- * 
+/**
+ * Configuration of variable block-size motion compensation (VBSMC)
+ *
  * STRUCT MEMBERS:
  *  nSize      : Size of the structure in bytes
- *  nVersion   : OMX specification version information 
+ *  nVersion   : OMX specification version information
  *  nPortIndex : Port that this structure applies to
  *  b16x16     : Enable inter block search 16x16
  *  b16x8      : Enable inter block search 16x8
@@ -386,11 +387,11 @@
  *  b4x4       : Enable inter block search 4x4
  */
 typedef struct OMX_VIDEO_PARAM_VBSMCTYPE {
-    OMX_U32 nSize; 
-    OMX_VERSIONTYPE nVersion; 
-    OMX_U32 nPortIndex;       
-    OMX_BOOL b16x16; 
-    OMX_BOOL b16x8; 
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL b16x16;
+    OMX_BOOL b16x8;
     OMX_BOOL b8x16;
     OMX_BOOL b8x8;
     OMX_BOOL b8x4;
@@ -399,67 +400,67 @@
 } OMX_VIDEO_PARAM_VBSMCTYPE;
 
 
-/** 
- * H.263 profile types, each profile indicates support for various 
+/**
+ * H.263 profile types, each profile indicates support for various
  * performance bounds and different annexes.
  *
  * ENUMS:
- *  Baseline           : Baseline Profile: H.263 (V1), no optional modes                                                    
- *  H320 Coding        : H.320 Coding Efficiency Backward Compatibility 
+ *  Baseline           : Baseline Profile: H.263 (V1), no optional modes
+ *  H320 Coding        : H.320 Coding Efficiency Backward Compatibility
  *                       Profile: H.263+ (V2), includes annexes I, J, L.4
  *                       and T
- *  BackwardCompatible : Backward Compatibility Profile: H.263 (V1), 
- *                       includes annex F                                    
- *  ISWV2              : Interactive Streaming Wireless Profile: H.263+ 
- *                       (V2), includes annexes I, J, K and T                 
- *  ISWV3              : Interactive Streaming Wireless Profile: H.263++  
- *                       (V3), includes profile 3 and annexes V and W.6.3.8   
- *  HighCompression    : Conversational High Compression Profile: H.263++  
- *                       (V3), includes profiles 1 & 2 and annexes D and U   
- *  Internet           : Conversational Internet Profile: H.263++ (V3),  
- *                       includes profile 5 and annex K                       
- *  Interlace          : Conversational Interlace Profile: H.263++ (V3),  
- *                       includes profile 5 and annex W.6.3.11               
- *  HighLatency        : High Latency Profile: H.263++ (V3), includes  
- *                       profile 6 and annexes O.1 and P.5                       
+ *  BackwardCompatible : Backward Compatibility Profile: H.263 (V1),
+ *                       includes annex F
+ *  ISWV2              : Interactive Streaming Wireless Profile: H.263+
+ *                       (V2), includes annexes I, J, K and T
+ *  ISWV3              : Interactive Streaming Wireless Profile: H.263++
+ *                       (V3), includes profile 3 and annexes V and W.6.3.8
+ *  HighCompression    : Conversational High Compression Profile: H.263++
+ *                       (V3), includes profiles 1 & 2 and annexes D and U
+ *  Internet           : Conversational Internet Profile: H.263++ (V3),
+ *                       includes profile 5 and annex K
+ *  Interlace          : Conversational Interlace Profile: H.263++ (V3),
+ *                       includes profile 5 and annex W.6.3.11
+ *  HighLatency        : High Latency Profile: H.263++ (V3), includes
+ *                       profile 6 and annexes O.1 and P.5
  */
 typedef enum OMX_VIDEO_H263PROFILETYPE {
-    OMX_VIDEO_H263ProfileBaseline            = 0x01,        
-    OMX_VIDEO_H263ProfileH320Coding          = 0x02,          
-    OMX_VIDEO_H263ProfileBackwardCompatible  = 0x04,  
-    OMX_VIDEO_H263ProfileISWV2               = 0x08,               
-    OMX_VIDEO_H263ProfileISWV3               = 0x10,               
-    OMX_VIDEO_H263ProfileHighCompression     = 0x20,     
-    OMX_VIDEO_H263ProfileInternet            = 0x40,            
-    OMX_VIDEO_H263ProfileInterlace           = 0x80,           
-    OMX_VIDEO_H263ProfileHighLatency         = 0x100,         
-    OMX_VIDEO_H263ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_H263ProfileBaseline            = 0x01,
+    OMX_VIDEO_H263ProfileH320Coding          = 0x02,
+    OMX_VIDEO_H263ProfileBackwardCompatible  = 0x04,
+    OMX_VIDEO_H263ProfileISWV2               = 0x08,
+    OMX_VIDEO_H263ProfileISWV3               = 0x10,
+    OMX_VIDEO_H263ProfileHighCompression     = 0x20,
+    OMX_VIDEO_H263ProfileInternet            = 0x40,
+    OMX_VIDEO_H263ProfileInterlace           = 0x80,
+    OMX_VIDEO_H263ProfileHighLatency         = 0x100,
+    OMX_VIDEO_H263ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_VIDEO_H263ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
-    OMX_VIDEO_H263ProfileMax                 = 0x7FFFFFFF  
+    OMX_VIDEO_H263ProfileMax                 = 0x7FFFFFFF
 } OMX_VIDEO_H263PROFILETYPE;
 
 
-/** 
- * H.263 level types, each level indicates support for various frame sizes, 
+/**
+ * H.263 level types, each level indicates support for various frame sizes,
  * bit rates, decoder frame rates.
  */
 typedef enum OMX_VIDEO_H263LEVELTYPE {
-    OMX_VIDEO_H263Level10  = 0x01,  
-    OMX_VIDEO_H263Level20  = 0x02,      
-    OMX_VIDEO_H263Level30  = 0x04,      
-    OMX_VIDEO_H263Level40  = 0x08,      
-    OMX_VIDEO_H263Level45  = 0x10,      
-    OMX_VIDEO_H263Level50  = 0x20,      
-    OMX_VIDEO_H263Level60  = 0x40,      
-    OMX_VIDEO_H263Level70  = 0x80, 
-    OMX_VIDEO_H263LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_H263Level10  = 0x01,
+    OMX_VIDEO_H263Level20  = 0x02,
+    OMX_VIDEO_H263Level30  = 0x04,
+    OMX_VIDEO_H263Level40  = 0x08,
+    OMX_VIDEO_H263Level45  = 0x10,
+    OMX_VIDEO_H263Level50  = 0x20,
+    OMX_VIDEO_H263Level60  = 0x40,
+    OMX_VIDEO_H263Level70  = 0x80,
+    OMX_VIDEO_H263LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_VIDEO_H263LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
-    OMX_VIDEO_H263LevelMax = 0x7FFFFFFF  
+    OMX_VIDEO_H263LevelMax = 0x7FFFFFFF
 } OMX_VIDEO_H263LEVELTYPE;
 
 
-/** 
- * Specifies the picture type. These values should be OR'd to signal all 
+/**
+ * Specifies the picture type. These values should be OR'd to signal all
  * pictures types which are allowed.
  *
  * ENUMS:
@@ -477,36 +478,36 @@
     OMX_VIDEO_PictureTypeEI  = 0x11,
     OMX_VIDEO_PictureTypeEP  = 0x12,
     OMX_VIDEO_PictureTypeS   = 0x14,
-    OMX_VIDEO_PictureTypeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_PictureTypeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_VIDEO_PictureTypeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_PictureTypeMax = 0x7FFFFFFF
 } OMX_VIDEO_PICTURETYPE;
 
 
-/** 
- * H.263 Params 
+/**
+ * H.263 Params
  *
  * STRUCT MEMBERS:
  *  nSize                    : Size of the structure in bytes
- *  nVersion                 : OMX specification version information 
+ *  nVersion                 : OMX specification version information
  *  nPortIndex               : Port that this structure applies to
  *  nPFrames                 : Number of P frames between each I frame
  *  nBFrames                 : Number of B frames between each I frame
  *  eProfile                 : H.263 profile(s) to use
  *  eLevel                   : H.263 level(s) to use
- *  bPLUSPTYPEAllowed        : Indicating that it is allowed to use PLUSPTYPE 
- *                             (specified in the 1998 version of H.263) to 
- *                             indicate custom picture sizes or clock 
- *                             frequencies 
- *  nAllowedPictureTypes     : Specifies the picture types allowed in the 
+ *  bPLUSPTYPEAllowed        : Indicating that it is allowed to use PLUSPTYPE
+ *                             (specified in the 1998 version of H.263) to
+ *                             indicate custom picture sizes or clock
+ *                             frequencies
+ *  nAllowedPictureTypes     : Specifies the picture types allowed in the
  *                             bitstream
- *  bForceRoundingTypeToZero : value of the RTYPE bit (bit 6 of MPPTYPE) is 
- *                             not constrained. It is recommended to change 
- *                             the value of the RTYPE bit for each reference 
+ *  bForceRoundingTypeToZero : value of the RTYPE bit (bit 6 of MPPTYPE) is
+ *                             not constrained. It is recommended to change
+ *                             the value of the RTYPE bit for each reference
  *                             picture in error-free communication
- *  nPictureHeaderRepetition : Specifies the frequency of picture header 
+ *  nPictureHeaderRepetition : Specifies the frequency of picture header
  *                             repetition
- *  nGOBHeaderInterval       : Specifies the interval of non-empty GOB  
+ *  nGOBHeaderInterval       : Specifies the interval of non-empty GOB
  *                             headers in units of GOBs
  */
 typedef struct OMX_VIDEO_PARAM_H263TYPE {
@@ -516,7 +517,7 @@
     OMX_U32 nPFrames;
     OMX_U32 nBFrames;
     OMX_VIDEO_H263PROFILETYPE eProfile;
-	OMX_VIDEO_H263LEVELTYPE eLevel;
+    OMX_VIDEO_H263LEVELTYPE eLevel;
     OMX_BOOL bPLUSPTYPEAllowed;
     OMX_U32 nAllowedPictureTypes;
     OMX_BOOL bForceRoundingTypeToZero;
@@ -525,8 +526,8 @@
 } OMX_VIDEO_PARAM_H263TYPE;
 
 
-/** 
- * MPEG-2 profile types, each profile indicates support for various 
+/**
+ * MPEG-2 profile types, each profile indicates support for various
  * performance bounds and different annexes.
  */
 typedef enum OMX_VIDEO_MPEG2PROFILETYPE {
@@ -536,29 +537,29 @@
     OMX_VIDEO_MPEG2ProfileSNR,         /**< SNR Profile */
     OMX_VIDEO_MPEG2ProfileSpatial,     /**< Spatial Profile */
     OMX_VIDEO_MPEG2ProfileHigh,        /**< High Profile */
-    OMX_VIDEO_MPEG2ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_MPEG2ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_VIDEO_MPEG2ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
-    OMX_VIDEO_MPEG2ProfileMax = 0x7FFFFFFF  
+    OMX_VIDEO_MPEG2ProfileMax = 0x7FFFFFFF
 } OMX_VIDEO_MPEG2PROFILETYPE;
 
 
-/** 
- * MPEG-2 level types, each level indicates support for various frame 
- * sizes, bit rates, decoder frame rates.  No need 
+/**
+ * MPEG-2 level types, each level indicates support for various frame
+ * sizes, bit rates, decoder frame rates.  No need
  */
 typedef enum OMX_VIDEO_MPEG2LEVELTYPE {
-    OMX_VIDEO_MPEG2LevelLL = 0,  /**< Low Level */ 
-    OMX_VIDEO_MPEG2LevelML,      /**< Main Level */ 
-    OMX_VIDEO_MPEG2LevelH14,     /**< High 1440 */ 
-    OMX_VIDEO_MPEG2LevelHL,      /**< High Level */   
-    OMX_VIDEO_MPEG2LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_MPEG2LevelLL = 0,  /**< Low Level */
+    OMX_VIDEO_MPEG2LevelML,      /**< Main Level */
+    OMX_VIDEO_MPEG2LevelH14,     /**< High 1440 */
+    OMX_VIDEO_MPEG2LevelHL,      /**< High Level */
+    OMX_VIDEO_MPEG2LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_VIDEO_MPEG2LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
-    OMX_VIDEO_MPEG2LevelMax = 0x7FFFFFFF  
+    OMX_VIDEO_MPEG2LevelMax = 0x7FFFFFFF
 } OMX_VIDEO_MPEG2LEVELTYPE;
 
 
-/** 
- * MPEG-2 params 
+/**
+ * MPEG-2 params
  *
  * STRUCT MEMBERS:
  *  nSize      : Size of the structure in bytes
@@ -570,20 +571,20 @@
  *  eLevel     : MPEG-2 levels(s) to use
  */
 typedef struct OMX_VIDEO_PARAM_MPEG2TYPE {
-    OMX_U32 nSize;           
+    OMX_U32 nSize;
     OMX_VERSIONTYPE nVersion;
-    OMX_U32 nPortIndex;      
-    OMX_U32 nPFrames;        
-    OMX_U32 nBFrames;        
+    OMX_U32 nPortIndex;
+    OMX_U32 nPFrames;
+    OMX_U32 nBFrames;
     OMX_VIDEO_MPEG2PROFILETYPE eProfile;
-	OMX_VIDEO_MPEG2LEVELTYPE eLevel;   
+    OMX_VIDEO_MPEG2LEVELTYPE eLevel;
 } OMX_VIDEO_PARAM_MPEG2TYPE;
 
 
-/** 
- * MPEG-4 profile types, each profile indicates support for various 
+/**
+ * MPEG-4 profile types, each profile indicates support for various
  * performance bounds and different annexes.
- * 
+ *
  * ENUMS:
  *  - Simple Profile, Levels 1-3
  *  - Simple Scalable Profile, Levels 1-2
@@ -602,48 +603,48 @@
  *  - Advanced Scalable Texture, Levels 2-3
  */
 typedef enum OMX_VIDEO_MPEG4PROFILETYPE {
-    OMX_VIDEO_MPEG4ProfileSimple           = 0x01,        
-    OMX_VIDEO_MPEG4ProfileSimpleScalable   = 0x02,    
-    OMX_VIDEO_MPEG4ProfileCore             = 0x04,              
-    OMX_VIDEO_MPEG4ProfileMain             = 0x08,             
-    OMX_VIDEO_MPEG4ProfileNbit             = 0x10,              
-    OMX_VIDEO_MPEG4ProfileScalableTexture  = 0x20,   
-    OMX_VIDEO_MPEG4ProfileSimpleFace       = 0x40,        
-    OMX_VIDEO_MPEG4ProfileSimpleFBA        = 0x80,         
-    OMX_VIDEO_MPEG4ProfileBasicAnimated    = 0x100,     
-    OMX_VIDEO_MPEG4ProfileHybrid           = 0x200,            
-    OMX_VIDEO_MPEG4ProfileAdvancedRealTime = 0x400,  
-    OMX_VIDEO_MPEG4ProfileCoreScalable     = 0x800,      
-    OMX_VIDEO_MPEG4ProfileAdvancedCoding   = 0x1000,    
-    OMX_VIDEO_MPEG4ProfileAdvancedCore     = 0x2000,      
+    OMX_VIDEO_MPEG4ProfileSimple           = 0x01,
+    OMX_VIDEO_MPEG4ProfileSimpleScalable   = 0x02,
+    OMX_VIDEO_MPEG4ProfileCore             = 0x04,
+    OMX_VIDEO_MPEG4ProfileMain             = 0x08,
+    OMX_VIDEO_MPEG4ProfileNbit             = 0x10,
+    OMX_VIDEO_MPEG4ProfileScalableTexture  = 0x20,
+    OMX_VIDEO_MPEG4ProfileSimpleFace       = 0x40,
+    OMX_VIDEO_MPEG4ProfileSimpleFBA        = 0x80,
+    OMX_VIDEO_MPEG4ProfileBasicAnimated    = 0x100,
+    OMX_VIDEO_MPEG4ProfileHybrid           = 0x200,
+    OMX_VIDEO_MPEG4ProfileAdvancedRealTime = 0x400,
+    OMX_VIDEO_MPEG4ProfileCoreScalable     = 0x800,
+    OMX_VIDEO_MPEG4ProfileAdvancedCoding   = 0x1000,
+    OMX_VIDEO_MPEG4ProfileAdvancedCore     = 0x2000,
     OMX_VIDEO_MPEG4ProfileAdvancedScalable = 0x4000,
     OMX_VIDEO_MPEG4ProfileAdvancedSimple   = 0x8000,
-    OMX_VIDEO_MPEG4ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_MPEG4ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_VIDEO_MPEG4ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
-    OMX_VIDEO_MPEG4ProfileMax              = 0x7FFFFFFF  
+    OMX_VIDEO_MPEG4ProfileMax              = 0x7FFFFFFF
 } OMX_VIDEO_MPEG4PROFILETYPE;
 
 
-/** 
- * MPEG-4 level types, each level indicates support for various frame 
- * sizes, bit rates, decoder frame rates.  No need 
+/**
+ * MPEG-4 level types, each level indicates support for various frame
+ * sizes, bit rates, decoder frame rates.  No need
  */
 typedef enum OMX_VIDEO_MPEG4LEVELTYPE {
-    OMX_VIDEO_MPEG4Level0  = 0x01,   /**< Level 0 */   
-    OMX_VIDEO_MPEG4Level0b = 0x02,   /**< Level 0b */   
-    OMX_VIDEO_MPEG4Level1  = 0x04,   /**< Level 1 */ 
-    OMX_VIDEO_MPEG4Level2  = 0x08,   /**< Level 2 */ 
-    OMX_VIDEO_MPEG4Level3  = 0x10,   /**< Level 3 */ 
-    OMX_VIDEO_MPEG4Level4  = 0x20,   /**< Level 4 */  
-    OMX_VIDEO_MPEG4Level4a = 0x40,   /**< Level 4a */  
-    OMX_VIDEO_MPEG4Level5  = 0x80,   /**< Level 5 */  
-    OMX_VIDEO_MPEG4LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_MPEG4Level0  = 0x01,   /**< Level 0 */
+    OMX_VIDEO_MPEG4Level0b = 0x02,   /**< Level 0b */
+    OMX_VIDEO_MPEG4Level1  = 0x04,   /**< Level 1 */
+    OMX_VIDEO_MPEG4Level2  = 0x08,   /**< Level 2 */
+    OMX_VIDEO_MPEG4Level3  = 0x10,   /**< Level 3 */
+    OMX_VIDEO_MPEG4Level4  = 0x20,   /**< Level 4 */
+    OMX_VIDEO_MPEG4Level4a = 0x40,   /**< Level 4a */
+    OMX_VIDEO_MPEG4Level5  = 0x80,   /**< Level 5 */
+    OMX_VIDEO_MPEG4LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_VIDEO_MPEG4LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
-    OMX_VIDEO_MPEG4LevelMax = 0x7FFFFFFF  
+    OMX_VIDEO_MPEG4LevelMax = 0x7FFFFFFF
 } OMX_VIDEO_MPEG4LEVELTYPE;
 
 
-/** 
+/**
  * MPEG-4 configuration.  This structure handles configuration options
  * which are specific to MPEG4 algorithms
  *
@@ -651,24 +652,24 @@
  *  nSize                : Size of the structure in bytes
  *  nVersion             : OMX specification version information
  *  nPortIndex           : Port that this structure applies to
- *  nSliceHeaderSpacing  : Number of macroblocks between slice header (H263+ 
+ *  nSliceHeaderSpacing  : Number of macroblocks between slice header (H263+
  *                         Annex K). Put zero if not used
  *  bSVH                 : Enable Short Video Header mode
  *  bGov                 : Flag to enable GOV
- *  nPFrames             : Number of P frames between each I frame (also called 
+ *  nPFrames             : Number of P frames between each I frame (also called
  *                         GOV period)
  *  nBFrames             : Number of B frames between each I frame
  *  nIDCVLCThreshold     : Value of intra DC VLC threshold
  *  bACPred              : Flag to use ac prediction
  *  nMaxPacketSize       : Maximum size of packet in bytes.
- *  nTimeIncRes          : Used to pass VOP time increment resolution for MPEG4. 
+ *  nTimeIncRes          : Used to pass VOP time increment resolution for MPEG4.
  *                         Interpreted as described in MPEG4 standard.
  *  eProfile             : MPEG-4 profile(s) to use.
  *  eLevel               : MPEG-4 level(s) to use.
  *  nAllowedPictureTypes : Specifies the picture types allowed in the bitstream
  *  nHeaderExtension     : Specifies the number of consecutive video packet
  *                         headers within a VOP
- *  bReversibleVLC       : Specifies whether reversible variable length coding 
+ *  bReversibleVLC       : Specifies whether reversible variable length coding
  *                         is in use
  */
 typedef struct OMX_VIDEO_PARAM_MPEG4TYPE {
@@ -692,22 +693,22 @@
 } OMX_VIDEO_PARAM_MPEG4TYPE;
 
 
-/** 
- * WMV Versions 
+/**
+ * WMV Versions
  */
 typedef enum OMX_VIDEO_WMVFORMATTYPE {
     OMX_VIDEO_WMVFormatUnused = 0x01,   /**< Format unused or unknown */
     OMX_VIDEO_WMVFormat7      = 0x02,   /**< Windows Media Video format 7 */
     OMX_VIDEO_WMVFormat8      = 0x04,   /**< Windows Media Video format 8 */
     OMX_VIDEO_WMVFormat9      = 0x08,   /**< Windows Media Video format 9 */
-    OMX_VIDEO_WMFFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_WMFFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_VIDEO_WMFFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_WMVFormatMax    = 0x7FFFFFFF
 } OMX_VIDEO_WMVFORMATTYPE;
 
 
-/** 
- * WMV Params 
+/**
+ * WMV Params
  *
  * STRUCT MEMBERS:
  *  nSize      : Size of the structure in bytes
@@ -716,33 +717,33 @@
  *  eFormat    : Version of WMV stream / data
  */
 typedef struct OMX_VIDEO_PARAM_WMVTYPE {
-    OMX_U32 nSize; 
+    OMX_U32 nSize;
     OMX_VERSIONTYPE nVersion;
     OMX_U32 nPortIndex;
     OMX_VIDEO_WMVFORMATTYPE eFormat;
 } OMX_VIDEO_PARAM_WMVTYPE;
 
 
-/** 
- * Real Video Version 
+/**
+ * Real Video Version
  */
 typedef enum OMX_VIDEO_RVFORMATTYPE {
     OMX_VIDEO_RVFormatUnused = 0, /**< Format unused or unknown */
     OMX_VIDEO_RVFormat8,          /**< Real Video format 8 */
     OMX_VIDEO_RVFormat9,          /**< Real Video format 9 */
     OMX_VIDEO_RVFormatG2,         /**< Real Video Format G2 */
-    OMX_VIDEO_RVFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_RVFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_VIDEO_RVFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_RVFormatMax = 0x7FFFFFFF
 } OMX_VIDEO_RVFORMATTYPE;
 
 
-/** 
- * Real Video Params 
+/**
+ * Real Video Params
  *
  * STUCT MEMBERS:
  *  nSize              : Size of the structure in bytes
- *  nVersion           : OMX specification version information 
+ *  nVersion           : OMX specification version information
  *  nPortIndex         : Port that this structure applies to
  *  eFormat            : Version of RV stream / data
  *  nBitsPerPixel      : Bits per pixel coded in the frame
@@ -754,11 +755,11 @@
  *  nMaxEncodeFrameSize: Max encoded frame size
  *  bEnablePostFilter  : Turn on/off post filter
  *  bEnableTemporalInterpolation : Turn on/off temporal interpolation
- *  bEnableLatencyMode : When enabled, the decoder does not display a decoded 
- *                       frame until it has detected that no enhancement layer 
- *  					 frames or dependent B frames will be coming. This 
- *  					 detection usually occurs when a subsequent non-B 
- *  					 frame is encountered 
+ *  bEnableLatencyMode : When enabled, the decoder does not display a decoded
+ *                       frame until it has detected that no enhancement layer
+ *                       frames or dependent B frames will be coming. This
+ *                       detection usually occurs when a subsequent non-B
+ *                       frame is encountered
  */
 typedef struct OMX_VIDEO_PARAM_RVTYPE {
     OMX_U32 nSize;
@@ -778,8 +779,8 @@
 } OMX_VIDEO_PARAM_RVTYPE;
 
 
-/** 
- * AVC profile types, each profile indicates support for various 
+/**
+ * AVC profile types, each profile indicates support for various
  * performance bounds and different annexes.
  */
 typedef enum OMX_VIDEO_AVCPROFILETYPE {
@@ -790,15 +791,15 @@
     OMX_VIDEO_AVCProfileHigh10   = 0x10,   /**< High 10 profile */
     OMX_VIDEO_AVCProfileHigh422  = 0x20,   /**< High 4:2:2 profile */
     OMX_VIDEO_AVCProfileHigh444  = 0x40,   /**< High 4:4:4 profile */
-    OMX_VIDEO_AVCProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_AVCProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_VIDEO_AVCProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
-    OMX_VIDEO_AVCProfileMax      = 0x7FFFFFFF  
+    OMX_VIDEO_AVCProfileMax      = 0x7FFFFFFF
 } OMX_VIDEO_AVCPROFILETYPE;
 
 
-/** 
- * AVC level types, each level indicates support for various frame sizes, 
- * bit rates, decoder frame rates.  No need 
+/**
+ * AVC level types, each level indicates support for various frame sizes,
+ * bit rates, decoder frame rates.  No need
  */
 typedef enum OMX_VIDEO_AVCLEVELTYPE {
     OMX_VIDEO_AVCLevel1   = 0x01,     /**< Level 1 */
@@ -817,14 +818,15 @@
     OMX_VIDEO_AVCLevel42  = 0x2000,   /**< Level 4.2 */
     OMX_VIDEO_AVCLevel5   = 0x4000,   /**< Level 5 */
     OMX_VIDEO_AVCLevel51  = 0x8000,   /**< Level 5.1 */
-    OMX_VIDEO_AVCLevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_AVCLevel52  = 0x10000,  /**< Level 5.2 */
+    OMX_VIDEO_AVCLevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_VIDEO_AVCLevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
-    OMX_VIDEO_AVCLevelMax = 0x7FFFFFFF  
+    OMX_VIDEO_AVCLevelMax = 0x7FFFFFFF
 } OMX_VIDEO_AVCLEVELTYPE;
 
 
-/** 
- * AVC loop filter modes 
+/**
+ * AVC loop filter modes
  *
  * OMX_VIDEO_AVCLoopFilterEnable               : Enable
  * OMX_VIDEO_AVCLoopFilterDisable              : Disable
@@ -834,20 +836,20 @@
     OMX_VIDEO_AVCLoopFilterEnable = 0,
     OMX_VIDEO_AVCLoopFilterDisable,
     OMX_VIDEO_AVCLoopFilterDisableSliceBoundary,
-    OMX_VIDEO_AVCLoopFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_AVCLoopFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_VIDEO_AVCLoopFilterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_AVCLoopFilterMax = 0x7FFFFFFF
 } OMX_VIDEO_AVCLOOPFILTERTYPE;
 
 
-/** 
- * AVC params 
+/**
+ * AVC params
  *
  * STRUCT MEMBERS:
  *  nSize                     : Size of the structure in bytes
  *  nVersion                  : OMX specification version information
  *  nPortIndex                : Port that this structure applies to
- *  nSliceHeaderSpacing       : Number of macroblocks between slice header, put  
+ *  nSliceHeaderSpacing       : Number of macroblocks between slice header, put
  *                              zero if not used
  *  nPFrames                  : Number of P frames between each I frame
  *  nBFrames                  : Number of B frames between each I frame
@@ -860,85 +862,85 @@
  *  nRefIdxForward            : Pic param set ref frame index (index into ref
  *                              frame buffer of forward frames list), B frame
  *                              support
- *  bEnableUEP                : Enable/disable unequal error protection. This 
+ *  bEnableUEP                : Enable/disable unequal error protection. This
  *                              is only valid of data partitioning is enabled.
  *  bEnableFMO                : Enable/disable flexible macroblock ordering
  *  bEnableASO                : Enable/disable arbitrary slice ordering
  *  bEnableRS                 : Enable/disable sending of redundant slices
  *  eProfile                  : AVC profile(s) to use
  *  eLevel                    : AVC level(s) to use
- *  nAllowedPictureTypes      : Specifies the picture types allowed in the 
+ *  nAllowedPictureTypes      : Specifies the picture types allowed in the
  *                              bitstream
- *  bFrameMBsOnly             : specifies that every coded picture of the 
- *                              coded video sequence is a coded frame 
+ *  bFrameMBsOnly             : specifies that every coded picture of the
+ *                              coded video sequence is a coded frame
  *                              containing only frame macroblocks
- *  bMBAFF                    : Enable/disable switching between frame and 
+ *  bMBAFF                    : Enable/disable switching between frame and
  *                              field macroblocks within a picture
- *  bEntropyCodingCABAC       : Entropy decoding method to be applied for the 
- *                              syntax elements for which two descriptors appear 
+ *  bEntropyCodingCABAC       : Entropy decoding method to be applied for the
+ *                              syntax elements for which two descriptors appear
  *                              in the syntax tables
- *  bWeightedPPrediction      : Enable/disable weighted prediction shall not 
+ *  bWeightedPPrediction      : Enable/disable weighted prediction shall not
  *                              be applied to P and SP slices
- *  nWeightedBipredicitonMode : Default weighted prediction is applied to B 
- *                              slices 
+ *  nWeightedBipredicitonMode : Default weighted prediction is applied to B
+ *                              slices
  *  bconstIpred               : Enable/disable intra prediction
- *  bDirect8x8Inference       : Specifies the method used in the derivation 
- *                              process for luma motion vectors for B_Skip, 
- *                              B_Direct_16x16 and B_Direct_8x8 as specified 
- *                              in subclause 8.4.1.2 of the AVC spec 
+ *  bDirect8x8Inference       : Specifies the method used in the derivation
+ *                              process for luma motion vectors for B_Skip,
+ *                              B_Direct_16x16 and B_Direct_8x8 as specified
+ *                              in subclause 8.4.1.2 of the AVC spec
  *  bDirectSpatialTemporal    : Flag indicating spatial or temporal direct
- *                              mode used in B slice coding (related to 
- *                              bDirect8x8Inference) . Spatial direct mode is 
+ *                              mode used in B slice coding (related to
+ *                              bDirect8x8Inference) . Spatial direct mode is
  *                              more common and should be the default.
  *  nCabacInitIdx             : Index used to init CABAC contexts
  *  eLoopFilterMode           : Enable/disable loop filter
  */
 typedef struct OMX_VIDEO_PARAM_AVCTYPE {
-    OMX_U32 nSize;                 
-    OMX_VERSIONTYPE nVersion;      
-    OMX_U32 nPortIndex;            
-    OMX_U32 nSliceHeaderSpacing;  
-    OMX_U32 nPFrames;     
-    OMX_U32 nBFrames;     
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nSliceHeaderSpacing;
+    OMX_U32 nPFrames;
+    OMX_U32 nBFrames;
     OMX_BOOL bUseHadamard;
-    OMX_U32 nRefFrames;  
-	OMX_U32 nRefIdx10ActiveMinus1;
-	OMX_U32 nRefIdx11ActiveMinus1;
-    OMX_BOOL bEnableUEP;  
-    OMX_BOOL bEnableFMO;  
-    OMX_BOOL bEnableASO;  
-    OMX_BOOL bEnableRS;   
+    OMX_U32 nRefFrames;
+    OMX_U32 nRefIdx10ActiveMinus1;
+    OMX_U32 nRefIdx11ActiveMinus1;
+    OMX_BOOL bEnableUEP;
+    OMX_BOOL bEnableFMO;
+    OMX_BOOL bEnableASO;
+    OMX_BOOL bEnableRS;
     OMX_VIDEO_AVCPROFILETYPE eProfile;
-	OMX_VIDEO_AVCLEVELTYPE eLevel; 
-    OMX_U32 nAllowedPictureTypes;  
-	OMX_BOOL bFrameMBsOnly;        									
-    OMX_BOOL bMBAFF;               
-    OMX_BOOL bEntropyCodingCABAC;  
-    OMX_BOOL bWeightedPPrediction; 
-    OMX_U32 nWeightedBipredicitonMode; 
+    OMX_VIDEO_AVCLEVELTYPE eLevel;
+    OMX_U32 nAllowedPictureTypes;
+    OMX_BOOL bFrameMBsOnly;
+    OMX_BOOL bMBAFF;
+    OMX_BOOL bEntropyCodingCABAC;
+    OMX_BOOL bWeightedPPrediction;
+    OMX_U32 nWeightedBipredicitonMode;
     OMX_BOOL bconstIpred ;
-    OMX_BOOL bDirect8x8Inference;  
-	OMX_BOOL bDirectSpatialTemporal;
-	OMX_U32 nCabacInitIdc;
-	OMX_VIDEO_AVCLOOPFILTERTYPE eLoopFilterMode;
+    OMX_BOOL bDirect8x8Inference;
+    OMX_BOOL bDirectSpatialTemporal;
+    OMX_U32 nCabacInitIdc;
+    OMX_VIDEO_AVCLOOPFILTERTYPE eLoopFilterMode;
 } OMX_VIDEO_PARAM_AVCTYPE;
 
 typedef struct OMX_VIDEO_PARAM_PROFILELEVELTYPE {
-   OMX_U32 nSize;                 
-   OMX_VERSIONTYPE nVersion;      
-   OMX_U32 nPortIndex;            
-   OMX_U32 eProfile;      /**< type is OMX_VIDEO_AVCPROFILETYPE, OMX_VIDEO_H263PROFILETYPE, 
+   OMX_U32 nSize;
+   OMX_VERSIONTYPE nVersion;
+   OMX_U32 nPortIndex;
+   OMX_U32 eProfile;      /**< type is OMX_VIDEO_AVCPROFILETYPE, OMX_VIDEO_H263PROFILETYPE,
                                  or OMX_VIDEO_MPEG4PROFILETYPE depending on context */
-   OMX_U32 eLevel;        /**< type is OMX_VIDEO_AVCLEVELTYPE, OMX_VIDEO_H263LEVELTYPE, 
+   OMX_U32 eLevel;        /**< type is OMX_VIDEO_AVCLEVELTYPE, OMX_VIDEO_H263LEVELTYPE,
                                  or OMX_VIDEO_MPEG4PROFILETYPE depending on context */
    OMX_U32 nProfileIndex; /**< Used to query for individual profile support information,
-                               This parameter is valid only for 
+                               This parameter is valid only for
                                OMX_IndexParamVideoProfileLevelQuerySupported index,
                                For all other indices this parameter is to be ignored. */
 } OMX_VIDEO_PARAM_PROFILELEVELTYPE;
 
-/** 
- * Structure for dynamically configuring bitrate mode of a codec. 
+/**
+ * Structure for dynamically configuring bitrate mode of a codec.
  *
  * STRUCT MEMBERS:
  *  nSize          : Size of the struct in bytes
@@ -947,18 +949,18 @@
  *  nEncodeBitrate : Target average bitrate to be generated in bps
  */
 typedef struct OMX_VIDEO_CONFIG_BITRATETYPE {
-    OMX_U32 nSize;                          
-    OMX_VERSIONTYPE nVersion;               
-    OMX_U32 nPortIndex;                     
-    OMX_U32 nEncodeBitrate;                 
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nEncodeBitrate;
 } OMX_VIDEO_CONFIG_BITRATETYPE;
 
-/** 
+/**
  * Defines Encoder Frame Rate setting
  *
  * STRUCT MEMBERS:
  *  nSize            : Size of the structure in bytes
- *  nVersion         : OMX specification version information 
+ *  nVersion         : OMX specification version information
  *  nPortIndex       : Port that this structure applies to
  *  xEncodeFramerate : Encoding framerate represented in Q16 format
  */
@@ -998,8 +1000,8 @@
     OMX_U32 nMacroblocks;
 } OMX_PARAM_MACROBLOCKSTYPE;
 
-/** 
- * AVC Slice Mode modes 
+/**
+ * AVC Slice Mode modes
  *
  * OMX_VIDEO_SLICEMODE_AVCDefault   : Normal frame encoding, one slice per frame
  * OMX_VIDEO_SLICEMODE_AVCMBSlice   : NAL mode, number of MBs per frame
@@ -1009,13 +1011,13 @@
     OMX_VIDEO_SLICEMODE_AVCDefault = 0,
     OMX_VIDEO_SLICEMODE_AVCMBSlice,
     OMX_VIDEO_SLICEMODE_AVCByteSlice,
-    OMX_VIDEO_SLICEMODE_AVCKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_SLICEMODE_AVCKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
     OMX_VIDEO_SLICEMODE_AVCVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_SLICEMODE_AVCLevelMax = 0x7FFFFFFF
 } OMX_VIDEO_AVCSLICEMODETYPE;
 
-/** 
- * AVC FMO Slice Mode Params 
+/**
+ * AVC FMO Slice Mode Params
  *
  * STRUCT MEMBERS:
  *  nSize      : Size of the structure in bytes
@@ -1026,7 +1028,7 @@
  *  eSliceMode : Specifies the type of slice
  */
 typedef struct OMX_VIDEO_PARAM_AVCSLICEFMO {
-    OMX_U32 nSize; 
+    OMX_U32 nSize;
     OMX_VERSIONTYPE nVersion;
     OMX_U32 nPortIndex;
     OMX_U8 nNumSliceGroups;
@@ -1034,7 +1036,7 @@
     OMX_VIDEO_AVCSLICEMODETYPE eSliceMode;
 } OMX_VIDEO_PARAM_AVCSLICEFMO;
 
-/** 
+/**
  * AVC IDR Period Configs
  *
  * STRUCT MEMBERS:
@@ -1045,14 +1047,14 @@
  *  nPFrames : Specifies internal of coding Intra frames
  */
 typedef struct OMX_VIDEO_CONFIG_AVCINTRAPERIOD {
-    OMX_U32 nSize; 
+    OMX_U32 nSize;
     OMX_VERSIONTYPE nVersion;
     OMX_U32 nPortIndex;
     OMX_U32 nIDRPeriod;
     OMX_U32 nPFrames;
 } OMX_VIDEO_CONFIG_AVCINTRAPERIOD;
 
-/** 
+/**
  * AVC NAL Size Configs
  *
  * STRUCT MEMBERS:
@@ -1062,7 +1064,7 @@
  *  nNaluBytes : Specifies the NAL unit size
  */
 typedef struct OMX_VIDEO_CONFIG_NALSIZE {
-    OMX_U32 nSize; 
+    OMX_U32 nSize;
     OMX_VERSIONTYPE nVersion;
     OMX_U32 nPortIndex;
     OMX_U32 nNaluBytes;
diff --git a/include/media/openmax/OMX_VideoExt.h b/include/media/openmax/OMX_VideoExt.h
index fa24168..3971bc5 100644
--- a/include/media/openmax/OMX_VideoExt.h
+++ b/include/media/openmax/OMX_VideoExt.h
@@ -108,6 +108,113 @@
     OMX_BOOL bIsGoldenOrAlternateFrame;
 } OMX_VIDEO_VP8REFERENCEFRAMEINFOTYPE;
 
+/** Maximum number of VP8 temporal layers */
+#define OMX_VIDEO_ANDROID_MAXVP8TEMPORALLAYERS 3
+
+/** VP8 temporal layer patterns */
+typedef enum OMX_VIDEO_ANDROID_VPXTEMPORALLAYERPATTERNTYPE {
+    OMX_VIDEO_VPXTemporalLayerPatternNone = 0,
+    OMX_VIDEO_VPXTemporalLayerPatternWebRTC = 1,
+    OMX_VIDEO_VPXTemporalLayerPatternMax = 0x7FFFFFFF
+} OMX_VIDEO_ANDROID_VPXTEMPORALLAYERPATTERNTYPE;
+
+/**
+ * Android specific VP8 encoder params
+ *
+ * STRUCT MEMBERS:
+ *  nSize                      : Size of the structure in bytes
+ *  nVersion                   : OMX specification version information
+ *  nPortIndex                 : Port that this structure applies to
+ *  nKeyFrameInterval          : Key frame interval in frames
+ *  eTemporalPattern           : Type of temporal layer pattern
+ *  nTemporalLayerCount        : Number of temporal coding layers
+ *  nTemporalLayerBitrateRatio : Bitrate ratio allocation between temporal
+ *                               streams in percentage
+ *  nMinQuantizer              : Minimum (best quality) quantizer
+ *  nMaxQuantizer              : Maximum (worst quality) quantizer
+ */
+typedef struct OMX_VIDEO_PARAM_ANDROID_VP8ENCODERTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_U32 nKeyFrameInterval;
+    OMX_VIDEO_ANDROID_VPXTEMPORALLAYERPATTERNTYPE eTemporalPattern;
+    OMX_U32 nTemporalLayerCount;
+    OMX_U32 nTemporalLayerBitrateRatio[OMX_VIDEO_ANDROID_MAXVP8TEMPORALLAYERS];
+    OMX_U32 nMinQuantizer;
+    OMX_U32 nMaxQuantizer;
+} OMX_VIDEO_PARAM_ANDROID_VP8ENCODERTYPE;
+
+/** HEVC Profile enum type */
+typedef enum OMX_VIDEO_HEVCPROFILETYPE {
+    OMX_VIDEO_HEVCProfileUnknown = 0x0,
+    OMX_VIDEO_HEVCProfileMain    = 0x1,
+    OMX_VIDEO_HEVCProfileMain10  = 0x2,
+    OMX_VIDEO_HEVCProfileMax     = 0x7FFFFFFF
+} OMX_VIDEO_HEVCPROFILETYPE;
+
+/** HEVC Level enum type */
+typedef enum OMX_VIDEO_HEVCLEVELTYPE {
+    OMX_VIDEO_HEVCLevelUnknown    = 0x0,
+    OMX_VIDEO_HEVCMainTierLevel1  = 0x1,
+    OMX_VIDEO_HEVCHighTierLevel1  = 0x2,
+    OMX_VIDEO_HEVCMainTierLevel2  = 0x4,
+    OMX_VIDEO_HEVCHighTierLevel2  = 0x8,
+    OMX_VIDEO_HEVCMainTierLevel21 = 0x10,
+    OMX_VIDEO_HEVCHighTierLevel21 = 0x20,
+    OMX_VIDEO_HEVCMainTierLevel3  = 0x40,
+    OMX_VIDEO_HEVCHighTierLevel3  = 0x80,
+    OMX_VIDEO_HEVCMainTierLevel31 = 0x100,
+    OMX_VIDEO_HEVCHighTierLevel31 = 0x200,
+    OMX_VIDEO_HEVCMainTierLevel4  = 0x400,
+    OMX_VIDEO_HEVCHighTierLevel4  = 0x800,
+    OMX_VIDEO_HEVCMainTierLevel41 = 0x1000,
+    OMX_VIDEO_HEVCHighTierLevel41 = 0x2000,
+    OMX_VIDEO_HEVCMainTierLevel5  = 0x4000,
+    OMX_VIDEO_HEVCHighTierLevel5  = 0x8000,
+    OMX_VIDEO_HEVCMainTierLevel51 = 0x10000,
+    OMX_VIDEO_HEVCHighTierLevel51 = 0x20000,
+    OMX_VIDEO_HEVCMainTierLevel52 = 0x40000,
+    OMX_VIDEO_HEVCHighTierLevel52 = 0x80000,
+    OMX_VIDEO_HEVCMainTierLevel6  = 0x100000,
+    OMX_VIDEO_HEVCHighTierLevel6  = 0x200000,
+    OMX_VIDEO_HEVCMainTierLevel61 = 0x400000,
+    OMX_VIDEO_HEVCHighTierLevel61 = 0x800000,
+    OMX_VIDEO_HEVCMainTierLevel62 = 0x1000000,
+    OMX_VIDEO_HEVCHighTierLevel62 = 0x2000000,
+    OMX_VIDEO_HEVCHighTiermax     = 0x7FFFFFFF
+} OMX_VIDEO_HEVCLEVELTYPE;
+
+/** Structure for controlling HEVC video encoding and decoding */
+typedef struct OMX_VIDEO_PARAM_HEVCTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_VIDEO_HEVCPROFILETYPE eProfile;
+    OMX_VIDEO_HEVCLEVELTYPE eLevel;
+} OMX_VIDEO_PARAM_HEVCTYPE;
+
+/** Structure to define if dependent slice segments should be used */
+typedef struct OMX_VIDEO_SLICESEGMENTSTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL bDepedentSegments;
+    OMX_BOOL bEnableLoopFilterAcrossSlices;
+} OMX_VIDEO_SLICESEGMENTSTYPE;
+
+/** Structure to return timestamps of rendered output frames as well as EOS
+ *  for tunneled components.
+ */
+typedef struct OMX_VIDEO_RENDEREVENTTYPE {
+    OMX_S64 nMediaTimeUs;  // timestamp of rendered video frame
+    OMX_S64 nSystemTimeNs; // system monotonic time at the time frame was rendered
+                           // Use INT64_MAX for nMediaTimeUs to signal that the EOS
+                           // has been reached. In this case, nSystemTimeNs MUST be
+                           // the system time when the last frame was rendered.
+                           // This MUST be done in addition to returning (and
+                           // following) the render information for the last frame.
+} OMX_VIDEO_RENDEREVENTTYPE;
 
 #ifdef __cplusplus
 }
diff --git a/include/powermanager/IPowerManager.h b/include/powermanager/IPowerManager.h
index d85003f..461fad7 100644
--- a/include/powermanager/IPowerManager.h
+++ b/include/powermanager/IPowerManager.h
@@ -19,23 +19,54 @@
 
 #include <utils/Errors.h>
 #include <binder/IInterface.h>
+#include <hardware/power.h>
 
 namespace android {
 
 // ----------------------------------------------------------------------------
 
-// must be kept in sync with interface defined in IPowerManager.aidl
 class IPowerManager : public IInterface
 {
 public:
+    // These transaction IDs must be kept in sync with the method order from
+    // IPowerManager.aidl.
+    enum {
+        ACQUIRE_WAKE_LOCK            = IBinder::FIRST_CALL_TRANSACTION,
+        ACQUIRE_WAKE_LOCK_UID        = IBinder::FIRST_CALL_TRANSACTION + 1,
+        RELEASE_WAKE_LOCK            = IBinder::FIRST_CALL_TRANSACTION + 2,
+        UPDATE_WAKE_LOCK_UIDS        = IBinder::FIRST_CALL_TRANSACTION + 3,
+        POWER_HINT                   = IBinder::FIRST_CALL_TRANSACTION + 4,
+        UPDATE_WAKE_LOCK_SOURCE      = IBinder::FIRST_CALL_TRANSACTION + 5,
+        IS_WAKE_LOCK_LEVEL_SUPPORTED = IBinder::FIRST_CALL_TRANSACTION + 6,
+        USER_ACTIVITY                = IBinder::FIRST_CALL_TRANSACTION + 7,
+        WAKE_UP                      = IBinder::FIRST_CALL_TRANSACTION + 8,
+        GO_TO_SLEEP                  = IBinder::FIRST_CALL_TRANSACTION + 9,
+        NAP                          = IBinder::FIRST_CALL_TRANSACTION + 10,
+        IS_INTERACTIVE               = IBinder::FIRST_CALL_TRANSACTION + 11,
+        IS_POWER_SAVE_MODE           = IBinder::FIRST_CALL_TRANSACTION + 12,
+        SET_POWER_SAVE_MODE          = IBinder::FIRST_CALL_TRANSACTION + 13,
+        REBOOT                       = IBinder::FIRST_CALL_TRANSACTION + 14,
+        SHUTDOWN                     = IBinder::FIRST_CALL_TRANSACTION + 15,
+        CRASH                        = IBinder::FIRST_CALL_TRANSACTION + 16,
+    };
+
     DECLARE_META_INTERFACE(PowerManager);
 
+    // The parcels created by these methods must be kept in sync with the
+    // corresponding methods from IPowerManager.aidl.
+    // FIXME remove the bool isOneWay parameters as they are not oneway in the .aidl
     virtual status_t acquireWakeLock(int flags, const sp<IBinder>& lock, const String16& tag,
-            const String16& packageName) = 0;
+            const String16& packageName, bool isOneWay = false) = 0;
     virtual status_t acquireWakeLockWithUid(int flags, const sp<IBinder>& lock, const String16& tag,
-            const String16& packageName, int uid) = 0;
-    virtual status_t releaseWakeLock(const sp<IBinder>& lock, int flags) = 0;
-    virtual status_t updateWakeLockUids(const sp<IBinder>& lock, int len, const int *uids) = 0;
+            const String16& packageName, int uid, bool isOneWay = false) = 0;
+    virtual status_t releaseWakeLock(const sp<IBinder>& lock, int flags, bool isOneWay = false) = 0;
+    virtual status_t updateWakeLockUids(const sp<IBinder>& lock, int len, const int *uids,
+            bool isOneWay = false) = 0;
+    virtual status_t powerHint(int hintId, int data) = 0;
+    virtual status_t goToSleep(int64_t event_time_ms, int reason, int flags) = 0;
+    virtual status_t reboot(bool confirm, const String16& reason, bool wait) = 0;
+    virtual status_t shutdown(bool confirm, const String16& reason, bool wait) = 0;
+    virtual status_t crash(const String16& message) = 0;
 };
 
 // ----------------------------------------------------------------------------
diff --git a/include/powermanager/PowerManager.h b/include/powermanager/PowerManager.h
index 4590174..cbddc11 100644
--- a/include/powermanager/PowerManager.h
+++ b/include/powermanager/PowerManager.h
@@ -24,6 +24,14 @@
     POWERMANAGER_PARTIAL_WAKE_LOCK = 1, // equals PowerManager.PARTIAL_WAKE_LOCK constant
 };
 
+enum {
+    USER_ACTIVITY_EVENT_OTHER = 0,
+    USER_ACTIVITY_EVENT_BUTTON = 1,
+    USER_ACTIVITY_EVENT_TOUCH = 2,
+
+    USER_ACTIVITY_EVENT_LAST = USER_ACTIVITY_EVENT_TOUCH, // Last valid event code.
+};
+
 }; // namespace android
 
 #endif // ANDROID_POWERMANAGER_H
diff --git a/include/private/binder/Static.h b/include/private/binder/Static.h
index 6a03594..d104646 100644
--- a/include/private/binder/Static.h
+++ b/include/private/binder/Static.h
@@ -34,7 +34,7 @@
 extern Mutex gProcessMutex;
 extern sp<ProcessState> gProcess;
 
-// For ServiceManager.cpp
+// For IServiceManager.cpp
 extern Mutex gDefaultServiceManagerLock;
 extern sp<IServiceManager> gDefaultServiceManager;
 extern sp<IPermissionController> gPermissionController;
diff --git a/include/private/binder/binder_module.h b/include/private/binder/binder_module.h
index a8dd64f..2f11622 100644
--- a/include/private/binder/binder_module.h
+++ b/include/private/binder/binder_module.h
@@ -24,7 +24,7 @@
 /* obtain structures and constants from the kernel header */
 
 #include <sys/ioctl.h>
-#include <linux/binder.h>
+#include <linux/android/binder.h>
 
 #ifdef __cplusplus
 }   // namespace android
diff --git a/include/private/gui/LayerState.h b/include/private/gui/LayerState.h
index bf4bf03..cbe8733 100644
--- a/include/private/gui/LayerState.h
+++ b/include/private/gui/LayerState.h
@@ -30,11 +30,16 @@
 class Parcel;
 class ISurfaceComposerClient;
 
+/*
+ * Used to communicate layer information between SurfaceFlinger and its clients.
+ */
 struct layer_state_t {
 
 
     enum {
-        eLayerHidden        = 0x01,
+        eLayerHidden        = 0x01,     // SURFACE_HIDDEN in SurfaceControl.java
+        eLayerOpaque        = 0x02,     // SURFACE_OPAQUE
+        eLayerSecure        = 0x80,     // SECURE
     };
 
     enum {
@@ -44,7 +49,7 @@
         eAlphaChanged               = 0x00000008,
         eMatrixChanged              = 0x00000010,
         eTransparentRegionChanged   = 0x00000020,
-        eVisibilityChanged          = 0x00000040,
+        eFlagsChanged               = 0x00000040,
         eLayerStackChanged          = 0x00000080,
         eCropChanged                = 0x00000100,
     };
@@ -108,7 +113,8 @@
     enum {
         eSurfaceChanged             = 0x01,
         eLayerStackChanged          = 0x02,
-        eDisplayProjectionChanged   = 0x04
+        eDisplayProjectionChanged   = 0x04,
+        eDisplaySizeChanged         = 0x08
     };
 
     uint32_t what;
@@ -118,6 +124,7 @@
     uint32_t orientation;
     Rect viewport;
     Rect frame;
+    uint32_t width, height;
     status_t write(Parcel& output) const;
     status_t read(const Parcel& input);
 };
diff --git a/include/ui/DisplayInfo.h b/include/ui/DisplayInfo.h
index 2853e06..ad73ee7 100644
--- a/include/ui/DisplayInfo.h
+++ b/include/ui/DisplayInfo.h
@@ -19,6 +19,7 @@
 
 #include <stdint.h>
 #include <sys/types.h>
+#include <utils/Timers.h>
 
 #include <ui/PixelFormat.h>
 
@@ -33,7 +34,9 @@
     float density;
     uint8_t orientation;
     bool secure;
-    uint8_t reserved[2];
+    nsecs_t appVsyncOffset;
+    nsecs_t presentationDeadline;
+    int colorTransform;
 };
 
 /* Display orientations as defined in Surface.java and ISurfaceComposer.h. */
diff --git a/cmds/dumpstate/libdumpstate_default.c b/include/ui/DisplayStatInfo.h
similarity index 63%
copy from cmds/dumpstate/libdumpstate_default.c
copy to include/ui/DisplayStatInfo.h
index fd840df..0549a83 100644
--- a/cmds/dumpstate/libdumpstate_default.c
+++ b/include/ui/DisplayStatInfo.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 The Android Open Source Project
+ * Copyright 2014 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,9 +14,18 @@
  * limitations under the License.
  */
 
-#include "dumpstate.h"
+#ifndef ANDROID_UI_DISPLAY_STAT_INFO_H
+#define ANDROID_UI_DISPLAY_STAT_INFO_H
 
-void dumpstate_board(void)
-{
-}
+#include <utils/Timers.h>
 
+namespace android {
+
+struct DisplayStatInfo {
+    nsecs_t vsyncTime;
+    nsecs_t vsyncPeriod;
+};
+
+}; // namespace android
+
+#endif // ANDROID_COMPOSER_DISPLAY_STAT_INFO_H
diff --git a/include/ui/Fence.h b/include/ui/Fence.h
index 20466b6..b431bd5 100644
--- a/include/ui/Fence.h
+++ b/include/ui/Fence.h
@@ -65,7 +65,7 @@
     // before the fence signals then -ETIME is returned.  A timeout of
     // TIMEOUT_NEVER may be used to indicate that the call should wait
     // indefinitely for the fence to signal.
-    status_t wait(unsigned int timeout);
+    status_t wait(int timeout);
 
     // waitForever is a convenience function for waiting forever for a fence to
     // signal (just like wait(TIMEOUT_NEVER)), but issuing an error to the
diff --git a/include/ui/FrameStats.h b/include/ui/FrameStats.h
new file mode 100644
index 0000000..5fdf94d
--- /dev/null
+++ b/include/ui/FrameStats.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_UI_FRAME_STATS_H
+#define ANDROID_UI_FRAME_STATS_H
+
+#include <utils/Flattenable.h>
+#include <utils/Timers.h>
+#include <utils/Vector.h>
+
+namespace android {
+
+class FrameStats : public LightFlattenable<FrameStats> {
+public:
+
+    /*
+     * Approximate refresh time, in nanoseconds.
+     */
+    nsecs_t refreshPeriodNano;
+
+   /*
+    * The times in nanoseconds for when the frame contents were posted by the producer (e.g.
+    * the application). They are either explicitly set or defaulted to the time when
+    * Surface::queueBuffer() was called.
+    */
+    Vector<nsecs_t> desiredPresentTimesNano;
+
+   /*
+    * The times in milliseconds for when the frame contents were presented on the screen.
+    */
+    Vector<nsecs_t> actualPresentTimesNano;
+
+   /*
+    * The times in nanoseconds for when the frame contents were ready to be presented. Note that
+    * a frame can be posted and still it contents being rendered asynchronously in GL. In such a
+    * case these are the times when the frame contents were completely rendered (i.e. their fences
+    * signaled).
+    */
+    Vector<nsecs_t> frameReadyTimesNano;
+
+    // LightFlattenable
+    bool isFixedSize() const;
+    size_t getFlattenedSize() const;
+    status_t flatten(void* buffer, size_t size) const;
+    status_t unflatten(void const* buffer, size_t size);
+};
+
+}; // namespace android
+
+#endif // ANDROID_UI_FRAME_STATS_H
diff --git a/include/ui/FramebufferNativeWindow.h b/include/ui/FramebufferNativeWindow.h
index 5ec738f..6b66d5f 100644
--- a/include/ui/FramebufferNativeWindow.h
+++ b/include/ui/FramebufferNativeWindow.h
@@ -14,6 +14,10 @@
  * limitations under the License.
  */
 
+#ifndef INCLUDED_FROM_FRAMEBUFFER_NATIVE_WINDOW_CPP
+#warning "FramebufferNativeWindow is deprecated"
+#endif
+
 #ifndef ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
 #define ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
 
diff --git a/include/ui/GraphicBuffer.h b/include/ui/GraphicBuffer.h
index 3cf628c..3da720f 100644
--- a/include/ui/GraphicBuffer.h
+++ b/include/ui/GraphicBuffer.h
@@ -49,7 +49,7 @@
         USAGE_SW_READ_RARELY    = GRALLOC_USAGE_SW_READ_RARELY,
         USAGE_SW_READ_OFTEN     = GRALLOC_USAGE_SW_READ_OFTEN,
         USAGE_SW_READ_MASK      = GRALLOC_USAGE_SW_READ_MASK,
-        
+
         USAGE_SW_WRITE_NEVER    = GRALLOC_USAGE_SW_WRITE_NEVER,
         USAGE_SW_WRITE_RARELY   = GRALLOC_USAGE_SW_WRITE_RARELY,
         USAGE_SW_WRITE_OFTEN    = GRALLOC_USAGE_SW_WRITE_OFTEN,
@@ -64,17 +64,21 @@
         USAGE_HW_2D             = GRALLOC_USAGE_HW_2D,
         USAGE_HW_COMPOSER       = GRALLOC_USAGE_HW_COMPOSER,
         USAGE_HW_VIDEO_ENCODER  = GRALLOC_USAGE_HW_VIDEO_ENCODER,
-        USAGE_HW_MASK           = GRALLOC_USAGE_HW_MASK
+        USAGE_HW_MASK           = GRALLOC_USAGE_HW_MASK,
+
+        USAGE_CURSOR            = GRALLOC_USAGE_CURSOR,
     };
 
     GraphicBuffer();
 
     // creates w * h buffer
-    GraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage);
+    GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,
+            uint32_t inUsage);
 
     // create a buffer from an existing handle
-    GraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage,
-            uint32_t stride, native_handle_t* handle, bool keepOwnership);
+    GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,
+            uint32_t inUsage, uint32_t inStride, native_handle_t* inHandle,
+            bool keepOwnership);
 
     // create a buffer from an existing ANativeWindowBuffer
     GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership);
@@ -82,21 +86,40 @@
     // return status
     status_t initCheck() const;
 
-    uint32_t getWidth() const           { return width; }
-    uint32_t getHeight() const          { return height; }
-    uint32_t getStride() const          { return stride; }
-    uint32_t getUsage() const           { return usage; }
+    uint32_t getWidth() const           { return static_cast<uint32_t>(width); }
+    uint32_t getHeight() const          { return static_cast<uint32_t>(height); }
+    uint32_t getStride() const          { return static_cast<uint32_t>(stride); }
+    uint32_t getUsage() const           { return static_cast<uint32_t>(usage); }
     PixelFormat getPixelFormat() const  { return format; }
     Rect getBounds() const              { return Rect(width, height); }
-    
-    status_t reallocate(uint32_t w, uint32_t h, PixelFormat f, uint32_t usage);
+    uint64_t getId() const              { return mId; }
 
-    status_t lock(uint32_t usage, void** vaddr);
-    status_t lock(uint32_t usage, const Rect& rect, void** vaddr);
+    uint32_t getGenerationNumber() const { return mGenerationNumber; }
+    void setGenerationNumber(uint32_t generation) {
+        mGenerationNumber = generation;
+    }
+
+    status_t reallocate(uint32_t inWidth, uint32_t inHeight,
+            PixelFormat inFormat, uint32_t inUsage);
+
+    bool needsReallocation(uint32_t inWidth, uint32_t inHeight,
+            PixelFormat inFormat, uint32_t inUsage);
+
+    status_t lock(uint32_t inUsage, void** vaddr);
+    status_t lock(uint32_t inUsage, const Rect& rect, void** vaddr);
     // For HAL_PIXEL_FORMAT_YCbCr_420_888
-    status_t lockYCbCr(uint32_t usage, android_ycbcr *ycbcr);
-    status_t lockYCbCr(uint32_t usage, const Rect& rect, android_ycbcr *ycbcr);
+    status_t lockYCbCr(uint32_t inUsage, android_ycbcr *ycbcr);
+    status_t lockYCbCr(uint32_t inUsage, const Rect& rect,
+            android_ycbcr *ycbcr);
     status_t unlock();
+    status_t lockAsync(uint32_t inUsage, void** vaddr, int fenceFd);
+    status_t lockAsync(uint32_t inUsage, const Rect& rect, void** vaddr,
+            int fenceFd);
+    status_t lockAsyncYCbCr(uint32_t inUsage, android_ycbcr *ycbcr,
+            int fenceFd);
+    status_t lockAsyncYCbCr(uint32_t inUsage, const Rect& rect,
+            android_ycbcr *ycbcr, int fenceFd);
+    status_t unlockAsync(int *fenceFd);
 
     ANativeWindowBuffer* getNativeBuffer() const;
 
@@ -135,8 +158,8 @@
     GraphicBuffer& operator = (const GraphicBuffer& rhs);
     const GraphicBuffer& operator = (const GraphicBuffer& rhs) const;
 
-    status_t initSize(uint32_t w, uint32_t h, PixelFormat format, 
-            uint32_t usage);
+    status_t initSize(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,
+            uint32_t inUsage);
 
     void free_handle();
 
@@ -146,6 +169,13 @@
     // If we're wrapping another buffer then this reference will make sure it
     // doesn't get freed.
     sp<ANativeWindowBuffer> mWrappedBuffer;
+
+    uint64_t mId;
+
+    // Stores the generation number of this buffer. If this number does not
+    // match the BufferQueue's internal generation number (set through
+    // IGBP::setGenerationNumber), attempts to attach the buffer will fail.
+    uint32_t mGenerationNumber;
 };
 
 }; // namespace android
diff --git a/include/ui/GraphicBufferAllocator.h b/include/ui/GraphicBufferAllocator.h
index dffa788..5443f09 100644
--- a/include/ui/GraphicBufferAllocator.h
+++ b/include/ui/GraphicBufferAllocator.h
@@ -1,17 +1,17 @@
-/* 
+/*
 **
 ** Copyright 2009, The Android Open Source Project
 **
-** Licensed under the Apache License, Version 2.0 (the "License"); 
-** you may not use this file except in compliance with the License. 
-** You may obtain a copy of the License at 
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
 **
-**     http://www.apache.org/licenses/LICENSE-2.0 
+**     http://www.apache.org/licenses/LICENSE-2.0
 **
-** Unless required by applicable law or agreed to in writing, software 
-** distributed under the License is distributed on an "AS IS" BASIS, 
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-** See the License for the specific language governing permissions and 
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
 ** limitations under the License.
 */
 
@@ -45,14 +45,14 @@
         USAGE_SW_READ_RARELY    = GRALLOC_USAGE_SW_READ_RARELY,
         USAGE_SW_READ_OFTEN     = GRALLOC_USAGE_SW_READ_OFTEN,
         USAGE_SW_READ_MASK      = GRALLOC_USAGE_SW_READ_MASK,
-        
+
         USAGE_SW_WRITE_NEVER    = GRALLOC_USAGE_SW_WRITE_NEVER,
         USAGE_SW_WRITE_RARELY   = GRALLOC_USAGE_SW_WRITE_RARELY,
         USAGE_SW_WRITE_OFTEN    = GRALLOC_USAGE_SW_WRITE_OFTEN,
         USAGE_SW_WRITE_MASK     = GRALLOC_USAGE_SW_WRITE_MASK,
-        
+
         USAGE_SOFTWARE_MASK     = USAGE_SW_READ_MASK|USAGE_SW_WRITE_MASK,
-        
+
         USAGE_HW_TEXTURE        = GRALLOC_USAGE_HW_TEXTURE,
         USAGE_HW_RENDER         = GRALLOC_USAGE_HW_RENDER,
         USAGE_HW_2D             = GRALLOC_USAGE_HW_2D,
@@ -60,10 +60,9 @@
     };
 
     static inline GraphicBufferAllocator& get() { return getInstance(); }
-    
 
-    status_t alloc(uint32_t w, uint32_t h, PixelFormat format, int usage,
-            buffer_handle_t* handle, int32_t* stride);
+    status_t alloc(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage,
+            buffer_handle_t* handle, uint32_t* stride);
 
     status_t free(buffer_handle_t handle);
 
@@ -72,21 +71,21 @@
 
 private:
     struct alloc_rec_t {
-        uint32_t w;
-        uint32_t h;
-        uint32_t s;
+        uint32_t width;
+        uint32_t height;
+        uint32_t stride;
         PixelFormat format;
         uint32_t usage;
         size_t size;
     };
-    
+
     static Mutex sLock;
     static KeyedVector<buffer_handle_t, alloc_rec_t> sAllocList;
-    
+
     friend class Singleton<GraphicBufferAllocator>;
     GraphicBufferAllocator();
     ~GraphicBufferAllocator();
-    
+
     alloc_device_t  *mAllocDev;
 };
 
diff --git a/include/ui/GraphicBufferMapper.h b/include/ui/GraphicBufferMapper.h
index 99d8723..6099548 100644
--- a/include/ui/GraphicBufferMapper.h
+++ b/include/ui/GraphicBufferMapper.h
@@ -41,15 +41,24 @@
     status_t registerBuffer(buffer_handle_t handle);
 
     status_t unregisterBuffer(buffer_handle_t handle);
-    
+
     status_t lock(buffer_handle_t handle,
-            int usage, const Rect& bounds, void** vaddr);
+            uint32_t usage, const Rect& bounds, void** vaddr);
 
     status_t lockYCbCr(buffer_handle_t handle,
-            int usage, const Rect& bounds, android_ycbcr *ycbcr);
+            uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr);
 
     status_t unlock(buffer_handle_t handle);
-    
+
+    status_t lockAsync(buffer_handle_t handle,
+            uint32_t usage, const Rect& bounds, void** vaddr, int fenceFd);
+
+    status_t lockAsyncYCbCr(buffer_handle_t handle,
+            uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr,
+            int fenceFd);
+
+    status_t unlockAsync(buffer_handle_t handle, int *fenceFd);
+
     // dumps information about the mapping of this handle
     void dump(buffer_handle_t handle);
 
diff --git a/include/ui/PixelFormat.h b/include/ui/PixelFormat.h
index 627cfb6..f26fecb 100644
--- a/include/ui/PixelFormat.h
+++ b/include/ui/PixelFormat.h
@@ -25,9 +25,6 @@
 #ifndef UI_PIXELFORMAT_H
 #define UI_PIXELFORMAT_H
 
-#include <stdint.h>
-#include <sys/types.h>
-#include <utils/Errors.h>
 #include <hardware/hardware.h>
 
 namespace android {
@@ -56,19 +53,19 @@
 
     // real pixel formats supported for rendering -----------------------------
 
-    PIXEL_FORMAT_RGBA_8888   = HAL_PIXEL_FORMAT_RGBA_8888,  // 4x8-bit RGBA
-    PIXEL_FORMAT_RGBX_8888   = HAL_PIXEL_FORMAT_RGBX_8888,  // 4x8-bit RGB0
-    PIXEL_FORMAT_RGB_888     = HAL_PIXEL_FORMAT_RGB_888,    // 3x8-bit RGB
-    PIXEL_FORMAT_RGB_565     = HAL_PIXEL_FORMAT_RGB_565,    // 16-bit RGB
-    PIXEL_FORMAT_BGRA_8888   = HAL_PIXEL_FORMAT_BGRA_8888,  // 4x8-bit BGRA
-    PIXEL_FORMAT_RGBA_5551   = 6,                           // 16-bit ARGB
-    PIXEL_FORMAT_RGBA_4444   = 7,                           // 16-bit ARGB
+    PIXEL_FORMAT_RGBA_8888   = HAL_PIXEL_FORMAT_RGBA_8888,   // 4x8-bit RGBA
+    PIXEL_FORMAT_RGBX_8888   = HAL_PIXEL_FORMAT_RGBX_8888,   // 4x8-bit RGB0
+    PIXEL_FORMAT_RGB_888     = HAL_PIXEL_FORMAT_RGB_888,     // 3x8-bit RGB
+    PIXEL_FORMAT_RGB_565     = HAL_PIXEL_FORMAT_RGB_565,     // 16-bit RGB
+    PIXEL_FORMAT_BGRA_8888   = HAL_PIXEL_FORMAT_BGRA_8888,   // 4x8-bit BGRA
+    PIXEL_FORMAT_RGBA_5551   = 6,                            // 16-bit ARGB
+    PIXEL_FORMAT_RGBA_4444   = 7,                            // 16-bit ARGB
 };
 
 typedef int32_t PixelFormat;
 
-ssize_t bytesPerPixel(PixelFormat format);
-ssize_t bitsPerPixel(PixelFormat format);
+uint32_t bytesPerPixel(PixelFormat format);
+uint32_t bitsPerPixel(PixelFormat format);
 
 }; // namespace android
 
diff --git a/include/ui/Rect.h b/include/ui/Rect.h
index 6cf64eb..3886f93 100644
--- a/include/ui/Rect.h
+++ b/include/ui/Rect.h
@@ -18,6 +18,7 @@
 #define ANDROID_UI_RECT
 
 #include <utils/Flattenable.h>
+#include <utils/Log.h>
 #include <utils/TypeHelpers.h>
 #include <ui/Point.h>
 
@@ -30,10 +31,13 @@
 public:
     typedef ARect::value_type value_type;
 
+    static const Rect INVALID_RECT;
+
     // we don't provide copy-ctor and operator= on purpose
     // because we want the compiler generated versions
 
     inline Rect() {
+      left = right = top = bottom = 0;
     }
 
     inline Rect(int32_t w, int32_t h) {
@@ -42,6 +46,22 @@
         bottom = h;
     }
 
+    inline Rect(uint32_t w, uint32_t h) {
+        if (w > INT32_MAX) {
+            ALOG(LOG_WARN, "Rect",
+                    "Width %u too large for Rect class, clamping", w);
+            w = INT32_MAX;
+        }
+        if (h > INT32_MAX) {
+            ALOG(LOG_WARN, "Rect",
+                    "Height %u too large for Rect class, clamping", h);
+            h = INT32_MAX;
+        }
+        left = top = 0;
+        right = w;
+        bottom = h;
+    }
+
     inline Rect(int32_t l, int32_t t, int32_t r, int32_t b) {
         left = l;
         top = t;
diff --git a/include/ui/Region.h b/include/ui/Region.h
index d906dbb..810f098 100644
--- a/include/ui/Region.h
+++ b/include/ui/Region.h
@@ -28,13 +28,14 @@
 namespace android {
 // ---------------------------------------------------------------------------
 
-class SharedBuffer;
 class String8;
 
 // ---------------------------------------------------------------------------
 class Region : public LightFlattenable<Region>
 {
 public:
+    static const Region INVALID_REGION;
+
                         Region();
                         Region(const Region& rhs);
     explicit            Region(const Rect& rhs);
@@ -50,13 +51,17 @@
     inline  Rect        getBounds() const   { return mStorage[mStorage.size() - 1]; }
     inline  Rect        bounds() const      { return getBounds(); }
 
+            bool        contains(const Point& point) const;
+            bool        contains(int x, int y) const;
+
             // the region becomes its bounds
             Region&     makeBoundsSelf();
-    
+
             void        clear();
             void        set(const Rect& r);
+            void        set(int32_t w, int32_t h);
             void        set(uint32_t w, uint32_t h);
-        
+
             Region&     orSelf(const Rect& rhs);
             Region&     xorSelf(const Rect& rhs);
             Region&     andSelf(const Rect& rhs);
@@ -107,14 +112,14 @@
     inline  Region&     operator -= (const Region& rhs);
     inline  Region&     operator += (const Point& pt);
 
-    
+
     // returns true if the regions share the same underlying storage
     bool isTriviallyEqual(const Region& region) const;
 
 
     /* various ways to access the rectangle list */
 
-    
+
     // STL-like iterators
     typedef Rect const* const_iterator;
     const_iterator begin() const;
@@ -124,13 +129,8 @@
     // Region object.
     Rect const* getArray(size_t* count) const;
 
-    // returns a SharedBuffer as well as the number of rects.
-    // ownership is transfered to the caller.
-    // the caller must call SharedBuffer::release() to free the memory.
-    SharedBuffer const* getSharedBuffer(size_t* count) const;
-
     /* no user serviceable parts here... */
-            
+
             // add a rectangle to the internal list. This rectangle must
             // be sorted in Y and X and must not make the region invalid.
             void        addRectUnchecked(int l, int t, int r, int b);
@@ -146,7 +146,7 @@
 private:
     class rasterizer;
     friend class rasterizer;
-    
+
     Region& operationSelf(const Rect& r, int op);
     Region& operationSelf(const Region& r, int op);
     Region& operationSelf(const Region& r, int dx, int dy, int op);
@@ -169,7 +169,7 @@
 
     static bool validate(const Region& reg,
             const char* name, bool silent = false);
-    
+
     // mStorage is a (manually) sorted array of Rects describing the region
     // with an extra Rect as the last element which is set to the
     // bounds of the region. However, if the region is
diff --git a/include/ui/mat4.h b/include/ui/mat4.h
index d9647cc..4fd1eff 100644
--- a/include/ui/mat4.h
+++ b/include/ui/mat4.h
@@ -322,6 +322,7 @@
         r[ 1] =  xy*nc + zs;    r[ 5] = y*y*nc +  c;    r[ 9] =  yz*nc - xs;
         r[ 2] =  zx*nc - ys;    r[ 6] =  yz*nc + xs;    r[10] = z*z*nc +  c;
     }
+    return rotation;
 }
 
 // ----------------------------------------------------------------------------------------
diff --git a/libs/binder/Android.mk b/libs/binder/Android.mk
index 673fc82..f0368a0 100644
--- a/libs/binder/Android.mk
+++ b/libs/binder/Android.mk
@@ -21,42 +21,48 @@
     Debug.cpp \
     IAppOpsCallback.cpp \
     IAppOpsService.cpp \
+    IBatteryStats.cpp \
     IInterface.cpp \
     IMemory.cpp \
     IPCThreadState.cpp \
     IPermissionController.cpp \
+    IProcessInfoService.cpp \
     IServiceManager.cpp \
-    MemoryDealer.cpp \
     MemoryBase.cpp \
+    MemoryDealer.cpp \
     MemoryHeapBase.cpp \
     Parcel.cpp \
     PermissionCache.cpp \
+    PersistableBundle.cpp \
+    ProcessInfoService.cpp \
     ProcessState.cpp \
     Static.cpp \
+    Status.cpp \
     TextOutput.cpp \
 
 LOCAL_PATH:= $(call my-dir)
 
-include $(CLEAR_VARS)
-LOCAL_LDLIBS += -lpthread
-LOCAL_MODULE := libbinder
-LOCAL_SHARED_LIBRARIES := liblog libcutils libutils
-LOCAL_SRC_FILES := $(sources)
+binder_cflags := -Wall -Wextra -Werror
 ifneq ($(TARGET_USES_64_BIT_BINDER),true)
 ifneq ($(TARGET_IS_64_BIT),true)
-LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1
+binder_cflags += -DBINDER_IPC_32BIT=1
 endif
 endif
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libbinder
+LOCAL_SHARED_LIBRARIES := libbase liblog libcutils libutils
+LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libbase libutils
+
+LOCAL_SANITIZE := integer
+LOCAL_SRC_FILES := $(sources)
+LOCAL_CFLAGS := $(binder_cflags)
 include $(BUILD_SHARED_LIBRARY)
 
 include $(CLEAR_VARS)
-LOCAL_LDLIBS += -lpthread
 LOCAL_MODULE := libbinder
-LOCAL_STATIC_LIBRARIES += libutils
+LOCAL_STATIC_LIBRARIES := libbase libutils
+LOCAL_EXPORT_STATIC_LIBRARY_HEADERS := libbase libutils
 LOCAL_SRC_FILES := $(sources)
-ifneq ($(TARGET_USES_64_BIT_BINDER),true)
-ifneq ($(TARGET_IS_64_BIT),true)
-LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1
-endif
-endif
+LOCAL_CFLAGS := $(binder_cflags)
 include $(BUILD_STATIC_LIBRARY)
diff --git a/libs/binder/AppOpsManager.cpp b/libs/binder/AppOpsManager.cpp
index 61b4f7d..e97bde5 100644
--- a/libs/binder/AppOpsManager.cpp
+++ b/libs/binder/AppOpsManager.cpp
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <mutex>
 #include <binder/AppOpsManager.h>
 #include <binder/Binder.h>
 #include <binder/IServiceManager.h>
@@ -22,6 +23,19 @@
 
 namespace android {
 
+namespace {
+
+#if defined(__BRILLO__)
+// Because Brillo has no application model, security policy is managed
+// statically (at build time) with SELinux controls.
+// As a consequence, it also never runs the AppOpsManager service.
+const int APP_OPS_MANAGER_UNAVAILABLE_MODE = AppOpsManager::MODE_ALLOWED;
+#else
+const int APP_OPS_MANAGER_UNAVAILABLE_MODE = AppOpsManager::MODE_IGNORED;
+#endif  // defined(__BRILLO__)
+
+}  // namespace
+
 static String16 _appops("appops");
 static pthread_mutex_t gTokenMutex = PTHREAD_MUTEX_INITIALIZER;
 static sp<IBinder> gToken;
@@ -39,12 +53,17 @@
 {
 }
 
+#if defined(__BRILLO__)
+// There is no AppOpsService on Brillo
+sp<IAppOpsService> AppOpsManager::getService() { return NULL; }
+#else
 sp<IAppOpsService> AppOpsManager::getService()
 {
+
+    std::lock_guard<Mutex> scoped_lock(mLock);
     int64_t startTime = 0;
-    mLock.lock();
     sp<IAppOpsService> service = mService;
-    while (service == NULL || !service->asBinder()->isBinderAlive()) {
+    while (service == NULL || !IInterface::asBinder(service)->isBinderAlive()) {
         sp<IBinder> binder = defaultServiceManager()->checkService(_appops);
         if (binder == NULL) {
             // Wait for the app ops service to come back...
@@ -53,7 +72,8 @@
                 ALOGI("Waiting for app ops service");
             } else if ((uptimeMillis()-startTime) > 10000) {
                 ALOGW("Waiting too long for app ops service, giving up");
-                return NULL;
+                service = NULL;
+                break;
             }
             sleep(1);
         } else {
@@ -61,25 +81,30 @@
             mService = service;
         }
     }
-    mLock.unlock();
     return service;
 }
+#endif  // defined(__BRILLO__)
 
 int32_t AppOpsManager::checkOp(int32_t op, int32_t uid, const String16& callingPackage)
 {
     sp<IAppOpsService> service = getService();
-    return service != NULL ? service->checkOperation(op, uid, callingPackage) : MODE_IGNORED;
+    return service != NULL
+            ? service->checkOperation(op, uid, callingPackage)
+            : APP_OPS_MANAGER_UNAVAILABLE_MODE;
 }
 
 int32_t AppOpsManager::noteOp(int32_t op, int32_t uid, const String16& callingPackage) {
     sp<IAppOpsService> service = getService();
-    return service != NULL ? service->noteOperation(op, uid, callingPackage) : MODE_IGNORED;
+    return service != NULL
+            ? service->noteOperation(op, uid, callingPackage)
+            : APP_OPS_MANAGER_UNAVAILABLE_MODE;
 }
 
 int32_t AppOpsManager::startOp(int32_t op, int32_t uid, const String16& callingPackage) {
     sp<IAppOpsService> service = getService();
-    return service != NULL ? service->startOperation(getToken(service), op, uid, callingPackage)
-            : MODE_IGNORED;
+    return service != NULL
+            ? service->startOperation(getToken(service), op, uid, callingPackage)
+            : APP_OPS_MANAGER_UNAVAILABLE_MODE;
 }
 
 void AppOpsManager::finishOp(int32_t op, int32_t uid, const String16& callingPackage) {
@@ -104,4 +129,13 @@
     }
 }
 
+int32_t AppOpsManager::permissionToOpCode(const String16& permission) {
+    sp<IAppOpsService> service = getService();
+    if (service != NULL) {
+        return service->permissionToOpCode(permission);
+    }
+    return -1;
+}
+
+
 }; // namespace android
diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp
index 71e62ab..e39093d 100644
--- a/libs/binder/Binder.cpp
+++ b/libs/binder/Binder.cpp
@@ -16,7 +16,7 @@
 
 #include <binder/Binder.h>
 
-#include <utils/Atomic.h>
+#include <atomic>
 #include <utils/misc.h>
 #include <binder/BpBinder.h>
 #include <binder/IInterface.h>
@@ -70,8 +70,7 @@
 
 // ---------------------------------------------------------------------------
 
-BBinder::BBinder()
-    : mExtras(NULL)
+BBinder::BBinder() : mExtras(nullptr)
 {
 }
 
@@ -139,19 +138,16 @@
     const void* objectID, void* object, void* cleanupCookie,
     object_cleanup_func func)
 {
-    Extras* e = mExtras;
+    Extras* e = mExtras.load(std::memory_order_acquire);
 
     if (!e) {
         e = new Extras;
-#ifdef __LP64__
-        if (android_atomic_release_cas64(0, reinterpret_cast<int64_t>(e),
-                reinterpret_cast<volatile int64_t*>(&mExtras)) != 0) {
-#else
-        if (android_atomic_cmpxchg(0, reinterpret_cast<int32_t>(e),
-                reinterpret_cast<volatile int32_t*>(&mExtras)) != 0) {
-#endif
+        Extras* expected = nullptr;
+        if (!mExtras.compare_exchange_strong(expected, e,
+                                             std::memory_order_release,
+                                             std::memory_order_acquire)) {
             delete e;
-            e = mExtras;
+            e = expected;  // Filled in by CAS
         }
         if (e == 0) return; // out of memory
     }
@@ -162,7 +158,7 @@
 
 void* BBinder::findObject(const void* objectID) const
 {
-    Extras* e = mExtras;
+    Extras* e = mExtras.load(std::memory_order_acquire);
     if (!e) return NULL;
 
     AutoMutex _l(e->mLock);
@@ -171,7 +167,7 @@
 
 void BBinder::detachObject(const void* objectID)
 {
-    Extras* e = mExtras;
+    Extras* e = mExtras.load(std::memory_order_acquire);
     if (!e) return;
 
     AutoMutex _l(e->mLock);
@@ -185,7 +181,8 @@
 
 BBinder::~BBinder()
 {
-    if (mExtras) delete mExtras;
+    Extras* e = mExtras.load(std::memory_order_relaxed);
+    if (e) delete e;
 }
 
 
@@ -240,7 +237,7 @@
 BpRefBase::~BpRefBase()
 {
     if (mRemote) {
-        if (!(mState&kRemoteAcquired)) {
+        if (!(mState.load(std::memory_order_relaxed)&kRemoteAcquired)) {
             mRemote->decStrong(this);
         }
         mRefs->decWeak(this);
@@ -249,7 +246,7 @@
 
 void BpRefBase::onFirstRef()
 {
-    android_atomic_or(kRemoteAcquired, &mState);
+    mState.fetch_or(kRemoteAcquired, std::memory_order_relaxed);
 }
 
 void BpRefBase::onLastStrongRef(const void* /*id*/)
diff --git a/libs/binder/BpBinder.cpp b/libs/binder/BpBinder.cpp
index 1bad67a..345ba20 100644
--- a/libs/binder/BpBinder.cpp
+++ b/libs/binder/BpBinder.cpp
@@ -73,7 +73,7 @@
 void BpBinder::ObjectManager::kill()
 {
     const size_t N = mObjects.size();
-    ALOGV("Killing %d objects in manager %p", N, this);
+    ALOGV("Killing %zu objects in manager %p", N, this);
     for (size_t i=0; i<N; i++) {
         const entry_t& e = mObjects.valueAt(i);
         if (e.func != NULL) {
@@ -119,11 +119,11 @@
                 mDescriptorCache = res;
         }
     }
-    
+
     // we're returning a reference to a non-static object here. Usually this
-    // is not something smart to do, however, with binder objects it is 
+    // is not something smart to do, however, with binder objects it is
     // (usually) safe because they are reference-counted.
-    
+
     return mDescriptorCache;
 }
 
@@ -220,7 +220,6 @@
         if ((obit.recipient == recipient
                     || (recipient == NULL && obit.cookie == cookie))
                 && obit.flags == flags) {
-            const uint32_t allFlags = obit.flags|flags;
             if (outRecipient != NULL) {
                 *outRecipient = mObituaries->itemAt(i).recipient;
             }
@@ -260,8 +259,8 @@
     mObitsSent = 1;
     mLock.unlock();
 
-    ALOGV("Reporting death of proxy %p for %d recipients\n",
-        this, obits ? obits->size() : 0);
+    ALOGV("Reporting death of proxy %p for %zu recipients\n",
+        this, obits ? obits->size() : 0U);
 
     if (obits != NULL) {
         const size_t N = obits->size();
diff --git a/libs/binder/BufferedTextOutput.cpp b/libs/binder/BufferedTextOutput.cpp
index 2d493c1..a2443c0 100644
--- a/libs/binder/BufferedTextOutput.cpp
+++ b/libs/binder/BufferedTextOutput.cpp
@@ -34,7 +34,7 @@
 
 struct BufferedTextOutput::BufferState : public RefBase
 {
-    BufferState(int32_t _seq)
+    explicit BufferState(int32_t _seq)
         : seq(_seq)
         , buffer(NULL)
         , bufferPos(0)
@@ -49,9 +49,12 @@
     
     status_t append(const char* txt, size_t len) {
         if ((len+bufferPos) > bufferSize) {
-            void* b = realloc(buffer, ((len+bufferPos)*3)/2);
+            size_t newSize = ((len+bufferPos)*3)/2;
+            if (newSize < (len+bufferPos)) return NO_MEMORY;    // overflow
+            void* b = realloc(buffer, newSize);
             if (!b) return NO_MEMORY;
             buffer = (char*)b;
+            bufferSize = newSize;
         }
         memcpy(buffer+bufferPos, txt, len);
         bufferPos += len;
diff --git a/libs/binder/Debug.cpp b/libs/binder/Debug.cpp
index 0ffafbb..a8f2da5 100644
--- a/libs/binder/Debug.cpp
+++ b/libs/binder/Debug.cpp
@@ -138,7 +138,7 @@
         *pos = 0;
         return pos;
     }
-    
+
     if( fullContext ) {
         *pos++ = '0';
         *pos++ = 'x';
@@ -167,21 +167,21 @@
     if (func == NULL) func = defaultPrintFunc;
 
     size_t offset;
-    
+
     unsigned char *pos = (unsigned char *)buf;
-    
+
     if (pos == NULL) {
         if (singleLineBytesCutoff < 0) func(cookie, "\n");
         func(cookie, "(NULL)");
         return;
     }
-    
+
     if (length == 0) {
         if (singleLineBytesCutoff < 0) func(cookie, "\n");
         func(cookie, "(empty)");
         return;
     }
-    
+
     if ((int32_t)length < 0) {
         if (singleLineBytesCutoff < 0) func(cookie, "\n");
         char buf[64];
@@ -189,12 +189,12 @@
         func(cookie, buf);
         return;
     }
-    
+
     char buffer[256];
     static const size_t maxBytesPerLine = (sizeof(buffer)-1-11-4)/(3+1);
-    
+
     if (bytesPerLine > maxBytesPerLine) bytesPerLine = maxBytesPerLine;
-    
+
     const bool oneLine = (int32_t)length <= singleLineBytesCutoff;
     bool newLine = false;
     if (cStyle) {
@@ -205,7 +205,7 @@
         func(cookie, "\n");
         newLine = true;
     }
-    
+
     for (offset = 0; ; offset += bytesPerLine, pos += bytesPerLine) {
         long remain = length;
 
@@ -217,26 +217,20 @@
 
         size_t index;
         size_t word;
-        
+
         for (word = 0; word < bytesPerLine; ) {
 
-#ifdef HAVE_LITTLE_ENDIAN
             const size_t startIndex = word+(alignment-(alignment?1:0));
-            const ssize_t dir = -1;
-#else
-            const size_t startIndex = word;
-            const ssize_t dir = 1;
-#endif
 
             for (index = 0; index < alignment || (alignment == 0 && index < bytesPerLine); index++) {
-            
+
                 if (!cStyle) {
                     if (index == 0 && word > 0 && alignment > 0) {
                         *c++ = ' ';
                     }
-                
+
                     if (remain-- > 0) {
-                        const unsigned char val = *(pos+startIndex+(index*dir));
+                        const unsigned char val = *(pos+startIndex-index);
                         *c++ = makehexdigit(val>>4);
                         *c++ = makehexdigit(val);
                     } else if (!oneLine) {
@@ -253,14 +247,14 @@
                             *c++ = '0';
                             *c++ = 'x';
                         }
-                        const unsigned char val = *(pos+startIndex+(index*dir));
+                        const unsigned char val = *(pos+startIndex-index);
                         *c++ = makehexdigit(val>>4);
                         *c++ = makehexdigit(val);
                         remain--;
                     }
                 }
             }
-            
+
             word += index;
         }
 
@@ -277,7 +271,7 @@
                     *c++ = ' ';
                 }
             }
-            
+
             *c++ = '\'';
             if (length > bytesPerLine) *c++ = '\n';
         } else {
@@ -289,7 +283,7 @@
         *c = 0;
         func(cookie, buffer);
         newLine = true;
-        
+
         if (length <= bytesPerLine) break;
         length -= bytesPerLine;
     }
diff --git a/libs/binder/IAppOpsCallback.cpp b/libs/binder/IAppOpsCallback.cpp
index e0aad23..f9ec593 100644
--- a/libs/binder/IAppOpsCallback.cpp
+++ b/libs/binder/IAppOpsCallback.cpp
@@ -18,7 +18,6 @@
 
 #include <binder/IAppOpsCallback.h>
 
-#include <utils/Debug.h>
 #include <utils/Log.h>
 #include <binder/Parcel.h>
 #include <utils/String8.h>
@@ -32,7 +31,7 @@
 class BpAppOpsCallback : public BpInterface<IAppOpsCallback>
 {
 public:
-    BpAppOpsCallback(const sp<IBinder>& impl)
+    explicit BpAppOpsCallback(const sp<IBinder>& impl)
         : BpInterface<IAppOpsCallback>(impl)
     {
     }
diff --git a/libs/binder/IAppOpsService.cpp b/libs/binder/IAppOpsService.cpp
index 471e3e9..638ae5c 100644
--- a/libs/binder/IAppOpsService.cpp
+++ b/libs/binder/IAppOpsService.cpp
@@ -18,7 +18,6 @@
 
 #include <binder/IAppOpsService.h>
 
-#include <utils/Debug.h>
 #include <utils/Log.h>
 #include <binder/Parcel.h>
 #include <utils/String8.h>
@@ -32,7 +31,7 @@
 class BpAppOpsService : public BpInterface<IAppOpsService>
 {
 public:
-    BpAppOpsService(const sp<IBinder>& impl)
+    explicit BpAppOpsService(const sp<IBinder>& impl)
         : BpInterface<IAppOpsService>(impl)
     {
     }
@@ -92,14 +91,14 @@
         data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
         data.writeInt32(op);
         data.writeString16(packageName);
-        data.writeStrongBinder(callback->asBinder());
+        data.writeStrongBinder(IInterface::asBinder(callback));
         remote()->transact(START_WATCHING_MODE_TRANSACTION, data, &reply);
     }
 
     virtual void stopWatchingMode(const sp<IAppOpsCallback>& callback) {
         Parcel data, reply;
         data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
-        data.writeStrongBinder(callback->asBinder());
+        data.writeStrongBinder(IInterface::asBinder(callback));
         remote()->transact(STOP_WATCHING_MODE_TRANSACTION, data, &reply);
     }
 
@@ -112,6 +111,17 @@
         if (reply.readExceptionCode() != 0) return NULL;
         return reply.readStrongBinder();
     }
+
+
+    virtual int32_t permissionToOpCode(const String16& permission) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
+        data.writeString16(permission);
+        remote()->transact(PERMISSION_TO_OP_CODE_TRANSACTION, data, &reply);
+        // fail on exception
+        if (reply.readExceptionCode() != 0) return -1;
+        return reply.readInt32();
+    }
 };
 
 IMPLEMENT_META_INTERFACE(AppOpsService, "com.android.internal.app.IAppOpsService");
@@ -188,6 +198,14 @@
             reply->writeStrongBinder(token);
             return NO_ERROR;
         } break;
+        case PERMISSION_TO_OP_CODE_TRANSACTION: {
+            CHECK_INTERFACE(IAppOpsService, data, reply);
+            String16 permission = data.readString16();
+            const int32_t opCode = permissionToOpCode(permission);
+            reply->writeNoException();
+            reply->writeInt32(opCode);
+            return NO_ERROR;
+        } break;
         default:
             return BBinder::onTransact(code, data, reply, flags);
     }
diff --git a/libs/binder/IBatteryStats.cpp b/libs/binder/IBatteryStats.cpp
new file mode 100644
index 0000000..ad1e69f
--- /dev/null
+++ b/libs/binder/IBatteryStats.cpp
@@ -0,0 +1,244 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <binder/IBatteryStats.h>
+
+#include <utils/Log.h>
+#include <binder/Parcel.h>
+#include <utils/String8.h>
+
+#include <private/binder/Static.h>
+
+namespace android {
+
+// ----------------------------------------------------------------------
+
+class BpBatteryStats : public BpInterface<IBatteryStats>
+{
+public:
+    explicit BpBatteryStats(const sp<IBinder>& impl)
+        : BpInterface<IBatteryStats>(impl)
+    {
+    }
+
+    virtual void noteStartSensor(int uid, int sensor) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
+        data.writeInt32(uid);
+        data.writeInt32(sensor);
+        remote()->transact(NOTE_START_SENSOR_TRANSACTION, data, &reply);
+    }
+
+    virtual void noteStopSensor(int uid, int sensor) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
+        data.writeInt32(uid);
+        data.writeInt32(sensor);
+        remote()->transact(NOTE_STOP_SENSOR_TRANSACTION, data, &reply);
+    }
+
+    virtual void noteStartVideo(int uid) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
+        data.writeInt32(uid);
+        remote()->transact(NOTE_START_VIDEO_TRANSACTION, data, &reply);
+    }
+
+    virtual void noteStopVideo(int uid) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
+        data.writeInt32(uid);
+        remote()->transact(NOTE_STOP_VIDEO_TRANSACTION, data, &reply);
+    }
+
+    virtual void noteStartAudio(int uid) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
+        data.writeInt32(uid);
+        remote()->transact(NOTE_START_AUDIO_TRANSACTION, data, &reply);
+    }
+
+    virtual void noteStopAudio(int uid) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
+        data.writeInt32(uid);
+        remote()->transact(NOTE_STOP_AUDIO_TRANSACTION, data, &reply);
+    }
+
+    virtual void noteResetVideo() {
+        Parcel data, reply;
+        data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
+        remote()->transact(NOTE_RESET_VIDEO_TRANSACTION, data, &reply);
+    }
+
+    virtual void noteResetAudio() {
+        Parcel data, reply;
+        data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
+        remote()->transact(NOTE_RESET_AUDIO_TRANSACTION, data, &reply);
+    }
+
+    virtual void noteFlashlightOn(int uid) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
+        data.writeInt32(uid);
+        remote()->transact(NOTE_FLASHLIGHT_ON_TRANSACTION, data, &reply);
+    }
+
+    virtual void noteFlashlightOff(int uid) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
+        data.writeInt32(uid);
+        remote()->transact(NOTE_FLASHLIGHT_OFF_TRANSACTION, data, &reply);
+    }
+
+    virtual void noteStartCamera(int uid) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
+        data.writeInt32(uid);
+        remote()->transact(NOTE_START_CAMERA_TRANSACTION, data, &reply);
+    }
+
+    virtual void noteStopCamera(int uid) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
+        data.writeInt32(uid);
+        remote()->transact(NOTE_STOP_CAMERA_TRANSACTION, data, &reply);
+    }
+
+    virtual void noteResetCamera() {
+        Parcel data, reply;
+        data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
+        remote()->transact(NOTE_RESET_CAMERA_TRANSACTION, data, &reply);
+    }
+
+    virtual void noteResetFlashlight() {
+        Parcel data, reply;
+        data.writeInterfaceToken(IBatteryStats::getInterfaceDescriptor());
+        remote()->transact(NOTE_RESET_FLASHLIGHT_TRANSACTION, data, &reply);
+    }
+
+};
+
+IMPLEMENT_META_INTERFACE(BatteryStats, "com.android.internal.app.IBatteryStats");
+
+// ----------------------------------------------------------------------
+
+status_t BnBatteryStats::onTransact(
+    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
+{
+    switch(code) {
+        case NOTE_START_SENSOR_TRANSACTION: {
+            CHECK_INTERFACE(IBatteryStats, data, reply);
+            int uid = data.readInt32();
+            int sensor = data.readInt32();
+            noteStartSensor(uid, sensor);
+            reply->writeNoException();
+            return NO_ERROR;
+        } break;
+        case NOTE_STOP_SENSOR_TRANSACTION: {
+            CHECK_INTERFACE(IBatteryStats, data, reply);
+            int uid = data.readInt32();
+            int sensor = data.readInt32();
+            noteStopSensor(uid, sensor);
+            reply->writeNoException();
+            return NO_ERROR;
+        } break;
+        case NOTE_START_VIDEO_TRANSACTION: {
+            CHECK_INTERFACE(IBatteryStats, data, reply);
+            int uid = data.readInt32();
+            noteStartVideo(uid);
+            reply->writeNoException();
+            return NO_ERROR;
+        } break;
+        case NOTE_STOP_VIDEO_TRANSACTION: {
+            CHECK_INTERFACE(IBatteryStats, data, reply);
+            int uid = data.readInt32();
+            noteStopVideo(uid);
+            reply->writeNoException();
+            return NO_ERROR;
+        } break;
+        case NOTE_START_AUDIO_TRANSACTION: {
+            CHECK_INTERFACE(IBatteryStats, data, reply);
+            int uid = data.readInt32();
+            noteStartAudio(uid);
+            reply->writeNoException();
+            return NO_ERROR;
+        } break;
+        case NOTE_STOP_AUDIO_TRANSACTION: {
+            CHECK_INTERFACE(IBatteryStats, data, reply);
+            int uid = data.readInt32();
+            noteStopAudio(uid);
+            reply->writeNoException();
+            return NO_ERROR;
+        } break;
+        case NOTE_RESET_VIDEO_TRANSACTION: {
+            CHECK_INTERFACE(IBatteryStats, data, reply);
+            noteResetVideo();
+            reply->writeNoException();
+            return NO_ERROR;
+        } break;
+        case NOTE_RESET_AUDIO_TRANSACTION: {
+            CHECK_INTERFACE(IBatteryStats, data, reply);
+            noteResetAudio();
+            reply->writeNoException();
+            return NO_ERROR;
+        } break;
+        case NOTE_FLASHLIGHT_ON_TRANSACTION: {
+            CHECK_INTERFACE(IBatteryStats, data, reply);
+            int uid = data.readInt32();
+            noteFlashlightOn(uid);
+            reply->writeNoException();
+            return NO_ERROR;
+        } break;
+        case NOTE_FLASHLIGHT_OFF_TRANSACTION: {
+            CHECK_INTERFACE(IBatteryStats, data, reply);
+            int uid = data.readInt32();
+            noteFlashlightOff(uid);
+            reply->writeNoException();
+            return NO_ERROR;
+        } break;
+        case NOTE_START_CAMERA_TRANSACTION: {
+            CHECK_INTERFACE(IBatteryStats, data, reply);
+            int uid = data.readInt32();
+            noteStartCamera(uid);
+            reply->writeNoException();
+            return NO_ERROR;
+        } break;
+        case NOTE_STOP_CAMERA_TRANSACTION: {
+            CHECK_INTERFACE(IBatteryStats, data, reply);
+            int uid = data.readInt32();
+            noteStopCamera(uid);
+            reply->writeNoException();
+            return NO_ERROR;
+        } break;
+        case NOTE_RESET_CAMERA_TRANSACTION: {
+            CHECK_INTERFACE(IBatteryStats, data, reply);
+            noteResetCamera();
+            reply->writeNoException();
+            return NO_ERROR;
+        } break;
+        case NOTE_RESET_FLASHLIGHT_TRANSACTION: {
+            CHECK_INTERFACE(IBatteryStats, data, reply);
+            noteResetFlashlight();
+            reply->writeNoException();
+            return NO_ERROR;
+        } break;
+        default:
+            return BBinder::onTransact(code, data, reply, flags);
+    }
+}
+
+}; // namespace android
diff --git a/libs/binder/IInterface.cpp b/libs/binder/IInterface.cpp
index 29acf5d..2fcd3d9 100644
--- a/libs/binder/IInterface.cpp
+++ b/libs/binder/IInterface.cpp
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#define LOG_TAG "IInterface"
+#include <utils/Log.h>
 #include <binder/IInterface.h>
 
 namespace android {
@@ -27,16 +29,39 @@
 IInterface::~IInterface() {
 }
 
-sp<IBinder> IInterface::asBinder()
+// static
+sp<IBinder> IInterface::asBinder(const IInterface* iface)
 {
-    return this ? onAsBinder() : NULL;
+    if (iface == NULL) return NULL;
+    return const_cast<IInterface*>(iface)->onAsBinder();
 }
 
-sp<const IBinder> IInterface::asBinder() const
+// static
+sp<IBinder> IInterface::asBinder(const sp<IInterface>& iface)
 {
-    return this ? const_cast<IInterface*>(this)->onAsBinder() : NULL;
+    if (iface == NULL) return NULL;
+    return iface->onAsBinder();
 }
 
+
 // ---------------------------------------------------------------------------
 
 }; // namespace android
+
+extern "C" {
+
+void _ZN7android10IInterface8asBinderEv(void *retval, void* self) {
+    ALOGW("deprecated asBinder call, please update your code");
+    //ALOGI("self: %p, retval: %p", self, retval);
+    android::sp<android::IBinder> *ret = new(retval) android::sp<android::IBinder>;
+    *ret = android::IInterface::asBinder((android::IInterface*)self);
+}
+
+void _ZNK7android10IInterface8asBinderEv(void *retval, void *self) {
+    ALOGW("deprecated asBinder call, please update your code");
+    //ALOGI("self: %p, retval: %p", self, retval);
+    android::sp<android::IBinder> *ret = new(retval) android::sp<android::IBinder>;
+    *ret = android::IInterface::asBinder((android::IInterface*)self);
+}
+
+} // extern "C"
diff --git a/libs/binder/IMemory.cpp b/libs/binder/IMemory.cpp
index d8ed995..f27b882 100644
--- a/libs/binder/IMemory.cpp
+++ b/libs/binder/IMemory.cpp
@@ -74,7 +74,7 @@
 class BpMemoryHeap : public BpInterface<IMemoryHeap>
 {
 public:
-    BpMemoryHeap(const sp<IBinder>& impl);
+    explicit BpMemoryHeap(const sp<IBinder>& impl);
     virtual ~BpMemoryHeap();
 
     virtual int getHeapID() const;
@@ -122,7 +122,7 @@
 class BpMemory : public BpInterface<IMemory>
 {
 public:
-    BpMemory(const sp<IBinder>& impl);
+    explicit BpMemory(const sp<IBinder>& impl);
     virtual ~BpMemory();
     virtual sp<IMemoryHeap> getMemory(ssize_t* offset=0, size_t* size=0) const;
 
@@ -216,7 +216,7 @@
             CHECK_INTERFACE(IMemory, data, reply);
             ssize_t offset;
             size_t size;
-            reply->writeStrongBinder( getMemory(&offset, &size)->asBinder() );
+            reply->writeStrongBinder( IInterface::asBinder(getMemory(&offset, &size)) );
             reply->writeInt32(offset);
             reply->writeInt32(size);
             return NO_ERROR;
@@ -241,7 +241,7 @@
         if (mRealHeap) {
             // by construction we're the last one
             if (mBase != MAP_FAILED) {
-                sp<IBinder> binder = const_cast<BpMemoryHeap*>(this)->asBinder();
+                sp<IBinder> binder = IInterface::asBinder(this);
 
                 if (VERBOSE) {
                     ALOGD("UNMAPPING binder=%p, heap=%p, size=%zu, fd=%d",
@@ -253,7 +253,7 @@
             }
         } else {
             // remove from list only if it was mapped before
-            sp<IBinder> binder = const_cast<BpMemoryHeap*>(this)->asBinder();
+            sp<IBinder> binder = IInterface::asBinder(this);
             free_heap(binder);
         }
     }
@@ -262,7 +262,7 @@
 void BpMemoryHeap::assertMapped() const
 {
     if (mHeapId == -1) {
-        sp<IBinder> binder(const_cast<BpMemoryHeap*>(this)->asBinder());
+        sp<IBinder> binder(IInterface::asBinder(const_cast<BpMemoryHeap*>(this)));
         sp<BpMemoryHeap> heap(static_cast<BpMemoryHeap*>(find_heap(binder).get()));
         heap->assertReallyMapped();
         if (heap->mBase != MAP_FAILED) {
@@ -297,7 +297,8 @@
         uint32_t offset = reply.readInt32();
 
         ALOGE_IF(err, "binder=%p transaction failed fd=%d, size=%zd, err=%d (%s)",
-                asBinder().get(), parcel_fd, size, err, strerror(-err));
+                IInterface::asBinder(this).get(),
+                parcel_fd, size, err, strerror(-err));
 
         int fd = dup( parcel_fd );
         ALOGE_IF(fd==-1, "cannot dup fd=%d, size=%zd, err=%d (%s)",
@@ -314,7 +315,7 @@
             mBase = mmap(0, size, access, MAP_SHARED, fd, offset);
             if (mBase == MAP_FAILED) {
                 ALOGE("cannot map BpMemoryHeap (binder=%p), size=%zd, fd=%d (%s)",
-                        asBinder().get(), size, fd, strerror(errno));
+                        IInterface::asBinder(this).get(), size, fd, strerror(errno));
                 close(fd);
             } else {
                 mSize = size;
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
index 35dba12..6d4071e 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -23,28 +23,20 @@
 #include <binder/TextOutput.h>
 
 #include <cutils/sched_policy.h>
-#include <utils/Debug.h>
 #include <utils/Log.h>
 #include <utils/threads.h>
 
 #include <private/binder/binder_module.h>
 #include <private/binder/Static.h>
 
-#include <sys/ioctl.h>
-#include <signal.h>
 #include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#ifdef HAVE_PTHREADS
 #include <pthread.h>
 #include <sched.h>
+#include <signal.h>
+#include <stdio.h>
+#include <sys/ioctl.h>
 #include <sys/resource.h>
-#endif
-#ifdef HAVE_WIN32_THREADS
-#include <windows.h>
-#endif
-
+#include <unistd.h>
 
 #if LOG_NDEBUG
 
@@ -71,13 +63,11 @@
 namespace android {
 
 static const char* getReturnString(size_t idx);
-static const char* getCommandString(size_t idx);
 static const void* printReturnCommand(TextOutput& out, const void* _cmd);
 static const void* printCommand(TextOutput& out, const void* _cmd);
 
-// This will result in a missing symbol failure if the IF_LOG_COMMANDS()
-// conditionals don't get stripped...  but that is probably what we want.
-#if !LOG_NDEBUG
+// Static const and functions will be optimized out if not used,
+// when LOG_NDEBUG and references in IF_LOG_COMMANDS() are optimized out.
 static const char *kReturnStrings[] = {
     "BR_ERROR",
     "BR_OK",
@@ -127,14 +117,6 @@
         return "unknown";
 }
 
-static const char* getCommandString(size_t idx)
-{
-    if (idx < sizeof(kCommandStrings) / sizeof(kCommandStrings[0]))
-        return kCommandStrings[idx];
-    else
-        return "unknown";
-}
-
 static const void* printBinderTransactionData(TextOutput& out, const void* data)
 {
     const binder_transaction_data* btd =
@@ -146,7 +128,7 @@
         out << "target.ptr=" << btd->target.ptr;
     }
     out << " (cookie " << btd->cookie << ")" << endl
-        << "code=" << TypeCode(btd->code) << ", flags=" << (void*)btd->flags << endl
+        << "code=" << TypeCode(btd->code) << ", flags=" << (void*)(long)btd->flags << endl
         << "data=" << btd->data.ptr.buffer << " (" << (void*)btd->data_size
         << " bytes)" << endl
         << "offsets=" << btd->data.ptr.offsets << " (" << (void*)btd->offsets_size
@@ -158,10 +140,10 @@
 {
     static const size_t N = sizeof(kReturnStrings)/sizeof(kReturnStrings[0]);
     const int32_t* cmd = (const int32_t*)_cmd;
-    int32_t code = *cmd++;
+    uint32_t code = (uint32_t)*cmd++;
     size_t cmdIndex = code & 0xff;
-    if (code == (int32_t) BR_ERROR) {
-        out << "BR_ERROR: " << (void*)(*cmd++) << endl;
+    if (code == BR_ERROR) {
+        out << "BR_ERROR: " << (void*)(long)(*cmd++) << endl;
         return cmd;
     } else if (cmdIndex >= N) {
         out << "Unknown reply: " << code << endl;
@@ -188,21 +170,21 @@
         case BR_DECREFS: {
             const int32_t b = *cmd++;
             const int32_t c = *cmd++;
-            out << ": target=" << (void*)b << " (cookie " << (void*)c << ")";
+            out << ": target=" << (void*)(long)b << " (cookie " << (void*)(long)c << ")";
         } break;
     
         case BR_ATTEMPT_ACQUIRE: {
             const int32_t p = *cmd++;
             const int32_t b = *cmd++;
             const int32_t c = *cmd++;
-            out << ": target=" << (void*)b << " (cookie " << (void*)c
+            out << ": target=" << (void*)(long)b << " (cookie " << (void*)(long)c
                 << "), pri=" << p;
         } break;
 
         case BR_DEAD_BINDER:
         case BR_CLEAR_DEATH_NOTIFICATION_DONE: {
             const int32_t c = *cmd++;
-            out << ": death cookie " << (void*)c;
+            out << ": death cookie " << (void*)(long)c;
         } break;
 
         default:
@@ -219,7 +201,7 @@
 {
     static const size_t N = sizeof(kCommandStrings)/sizeof(kCommandStrings[0]);
     const int32_t* cmd = (const int32_t*)_cmd;
-    int32_t code = *cmd++;
+    uint32_t code = (uint32_t)*cmd++;
     size_t cmdIndex = code & 0xff;
 
     if (cmdIndex >= N) {
@@ -243,7 +225,7 @@
         
         case BC_FREE_BUFFER: {
             const int32_t buf = *cmd++;
-            out << ": buffer=" << (void*)buf;
+            out << ": buffer=" << (void*)(long)buf;
         } break;
         
         case BC_INCREFS:
@@ -258,7 +240,7 @@
         case BC_ACQUIRE_DONE: {
             const int32_t b = *cmd++;
             const int32_t c = *cmd++;
-            out << ": target=" << (void*)b << " (cookie " << (void*)c << ")";
+            out << ": target=" << (void*)(long)b << " (cookie " << (void*)(long)c << ")";
         } break;
         
         case BC_ATTEMPT_ACQUIRE: {
@@ -271,12 +253,12 @@
         case BC_CLEAR_DEATH_NOTIFICATION: {
             const int32_t h = *cmd++;
             const int32_t c = *cmd++;
-            out << ": handle=" << h << " (death cookie " << (void*)c << ")";
+            out << ": handle=" << h << " (death cookie " << (void*)(long)c << ")";
         } break;
 
         case BC_DEAD_BINDER_DONE: {
             const int32_t c = *cmd++;
-            out << ": death cookie " << (void*)c;
+            out << ": death cookie " << (void*)(long)c;
         } break;
 
         default:
@@ -288,7 +270,6 @@
     out << endl;
     return cmd;
 }
-#endif
 
 static pthread_mutex_t gTLSMutex = PTHREAD_MUTEX_INITIALIZER;
 static bool gHaveTLS = false;
@@ -306,12 +287,18 @@
         return new IPCThreadState;
     }
     
-    if (gShutdown) return NULL;
+    if (gShutdown) {
+        ALOGW("Calling IPCThreadState::self() during shutdown is dangerous, expect a crash.\n");
+        return NULL;
+    }
     
     pthread_mutex_lock(&gTLSMutex);
     if (!gHaveTLS) {
-        if (pthread_key_create(&gTLS, threadDestructor) != 0) {
+        int key_create_value = pthread_key_create(&gTLS, threadDestructor);
+        if (key_create_value != 0) {
             pthread_mutex_unlock(&gTLSMutex);
+            ALOGW("IPCThreadState::self() unable to create TLS key, expect a crash: %s\n",
+                    strerror(key_create_value));
             return NULL;
         }
         gHaveTLS = true;
@@ -341,6 +328,7 @@
             delete st;
             pthread_setspecific(gTLS, NULL);
         }
+        pthread_key_delete(gTLS);
         gHaveTLS = false;
     }
 }
@@ -362,12 +350,12 @@
     return err;
 }
 
-int IPCThreadState::getCallingPid() const
+pid_t IPCThreadState::getCallingPid() const
 {
     return mCallingPid;
 }
 
-int IPCThreadState::getCallingUid() const
+uid_t IPCThreadState::getCallingUid() const
 {
     return mCallingUid;
 }
@@ -418,6 +406,18 @@
     talkWithDriver(false);
 }
 
+void IPCThreadState::blockUntilThreadAvailable()
+{
+    pthread_mutex_lock(&mProcess->mThreadCountLock);
+    while (mProcess->mExecutingThreadsCount >= mProcess->mMaxThreads) {
+        ALOGW("Waiting for thread to be free. mExecutingThreadsCount=%lu mMaxThreads=%lu\n",
+                static_cast<unsigned long>(mProcess->mExecutingThreadsCount),
+                static_cast<unsigned long>(mProcess->mMaxThreads));
+        pthread_cond_wait(&mProcess->mThreadCountDecrement, &mProcess->mThreadCountLock);
+    }
+    pthread_mutex_unlock(&mProcess->mThreadCountLock);
+}
+
 status_t IPCThreadState::getAndExecuteCommand()
 {
     status_t result;
@@ -433,8 +433,17 @@
                  << getReturnString(cmd) << endl;
         }
 
+        pthread_mutex_lock(&mProcess->mThreadCountLock);
+        mProcess->mExecutingThreadsCount++;
+        pthread_mutex_unlock(&mProcess->mThreadCountLock);
+
         result = executeCommand(cmd);
 
+        pthread_mutex_lock(&mProcess->mThreadCountLock);
+        mProcess->mExecutingThreadsCount--;
+        pthread_cond_broadcast(&mProcess->mThreadCountDecrement);
+        pthread_mutex_unlock(&mProcess->mThreadCountLock);
+
         // After executing the command, ensure that the thread is returned to the
         // foreground cgroup before rejoining the pool.  The driver takes care of
         // restoring the priority, but doesn't do anything with cgroups so we
@@ -683,7 +692,7 @@
 
 IPCThreadState::IPCThreadState()
     : mProcess(ProcessState::self()),
-      mMyThreadId(androidGetTid()),
+      mMyThreadId(gettid()),
       mStrictModePolicy(0),
       mLastTransactionBinderFlags(0)
 {
@@ -709,7 +718,7 @@
 
 status_t IPCThreadState::waitForResponse(Parcel *reply, status_t *acquireResult)
 {
-    int32_t cmd;
+    uint32_t cmd;
     int32_t err;
 
     while (1) {
@@ -718,7 +727,7 @@
         if (err < NO_ERROR) break;
         if (mIn.dataAvail() == 0) continue;
         
-        cmd = mIn.readInt32();
+        cmd = (uint32_t)mIn.readInt32();
         
         IF_LOG_COMMANDS() {
             alog << "Processing waitForResponse Command: "
@@ -850,7 +859,7 @@
         IF_LOG_COMMANDS() {
             alog << "About to read/write, write size = " << mOut.dataSize() << endl;
         }
-#if defined(HAVE_ANDROID_OS)
+#if defined(__ANDROID__)
         if (ioctl(mProcess->mDriverFD, BINDER_WRITE_READ, &bwr) >= 0)
             err = NO_ERROR;
         else
@@ -948,7 +957,7 @@
     RefBase::weakref_type* refs;
     status_t result = NO_ERROR;
     
-    switch (cmd) {
+    switch ((uint32_t)cmd) {
     case BR_ERROR:
         result = mIn.readInt32();
         break;
@@ -1038,10 +1047,13 @@
             
             const pid_t origPid = mCallingPid;
             const uid_t origUid = mCallingUid;
-            
+            const int32_t origStrictModePolicy = mStrictModePolicy;
+            const int32_t origTransactionBinderFlags = mLastTransactionBinderFlags;
+
             mCallingPid = tr.sender_pid;
             mCallingUid = tr.sender_euid;
-            
+            mLastTransactionBinderFlags = tr.flags;
+
             int curPrio = getpriority(PRIO_PROCESS, mMyThreadId);
             if (gDisableBackgroundScheduling) {
                 if (curPrio > ANDROID_PRIORITY_NORMAL) {
@@ -1063,8 +1075,9 @@
             }
 
             //ALOGI(">>>> TRANSACT from pid %d uid %d\n", mCallingPid, mCallingUid);
-            
+
             Parcel reply;
+            status_t error;
             IF_LOG_TRANSACTIONS() {
                 TextOutput::Bundle _b(alog);
                 alog << "BR_TRANSACTION thr " << (void*)pthread_self()
@@ -1078,19 +1091,18 @@
             }
             if (tr.target.ptr) {
                 sp<BBinder> b((BBinder*)tr.cookie);
-                const status_t error = b->transact(tr.code, buffer, &reply, tr.flags);
-                if (error < NO_ERROR) reply.setError(error);
+                error = b->transact(tr.code, buffer, &reply, tr.flags);
 
             } else {
-                const status_t error = the_context_object->transact(tr.code, buffer, &reply, tr.flags);
-                if (error < NO_ERROR) reply.setError(error);
+                error = the_context_object->transact(tr.code, buffer, &reply, tr.flags);
             }
-            
+
             //ALOGI("<<<< TRANSACT from pid %d restore pid %d uid %d\n",
             //     mCallingPid, origPid, origUid);
             
             if ((tr.flags & TF_ONE_WAY) == 0) {
                 LOG_ONEWAY("Sending reply to %d!", mCallingPid);
+                if (error < NO_ERROR) reply.setError(error);
                 sendReply(reply, 0);
             } else {
                 LOG_ONEWAY("NOT sending reply to %d!", mCallingPid);
@@ -1098,6 +1110,8 @@
             
             mCallingPid = origPid;
             mCallingUid = origUid;
+            mStrictModePolicy = origStrictModePolicy;
+            mLastTransactionBinderFlags = origTransactionBinderFlags;
 
             IF_LOG_TRANSACTIONS() {
                 TextOutput::Bundle _b(alog);
@@ -1151,7 +1165,7 @@
         IPCThreadState* const self = static_cast<IPCThreadState*>(st);
         if (self) {
                 self->flushCommands();
-#if defined(HAVE_ANDROID_OS)
+#if defined(__ANDROID__)
         if (self->mProcess->mDriverFD > 0) {
             ioctl(self->mProcess->mDriverFD, BINDER_THREAD_EXIT, 0);
         }
diff --git a/libs/binder/IPermissionController.cpp b/libs/binder/IPermissionController.cpp
index e13036f..674bddf 100644
--- a/libs/binder/IPermissionController.cpp
+++ b/libs/binder/IPermissionController.cpp
@@ -18,7 +18,6 @@
 
 #include <binder/IPermissionController.h>
 
-#include <utils/Debug.h>
 #include <utils/Log.h>
 #include <binder/Parcel.h>
 #include <utils/String8.h>
@@ -32,7 +31,7 @@
 class BpPermissionController : public BpInterface<IPermissionController>
 {
 public:
-    BpPermissionController(const sp<IBinder>& impl)
+    explicit BpPermissionController(const sp<IBinder>& impl)
         : BpInterface<IPermissionController>(impl)
     {
     }
@@ -49,6 +48,36 @@
         if (reply.readExceptionCode() != 0) return 0;
         return reply.readInt32() != 0;
     }
+
+    virtual void getPackagesForUid(const uid_t uid, Vector<String16>& packages)
+    {
+        Parcel data, reply;
+        data.writeInterfaceToken(IPermissionController::getInterfaceDescriptor());
+        data.writeInt32(uid);
+        remote()->transact(GET_PACKAGES_FOR_UID_TRANSACTION, data, &reply);
+        // fail on exception
+        if (reply.readExceptionCode() != 0) {
+            return;
+        }
+        const int32_t size = reply.readInt32();
+        if (size <= 0) {
+            return;
+        }
+        for (int i = 0; i < size; i++) {
+            packages.push(reply.readString16());
+        }
+    }
+
+    virtual bool isRuntimePermission(const String16& permission)
+    {
+        Parcel data, reply;
+        data.writeInterfaceToken(IPermissionController::getInterfaceDescriptor());
+        data.writeString16(permission);
+        remote()->transact(IS_RUNTIME_PERMISSION_TRANSACTION, data, &reply);
+        // fail on exception
+        if (reply.readExceptionCode() != 0) return false;
+        return reply.readInt32() != 0;
+    }
 };
 
 IMPLEMENT_META_INTERFACE(PermissionController, "android.os.IPermissionController");
@@ -58,7 +87,6 @@
 status_t BnPermissionController::onTransact(
     uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
 {
-    //printf("PermissionController received: "); data.print();
     switch(code) {
         case CHECK_PERMISSION_TRANSACTION: {
             CHECK_INTERFACE(IPermissionController, data, reply);
@@ -70,6 +98,30 @@
             reply->writeInt32(res ? 1 : 0);
             return NO_ERROR;
         } break;
+
+        case GET_PACKAGES_FOR_UID_TRANSACTION: {
+            CHECK_INTERFACE(IPermissionController, data, reply);
+            int32_t uid = data.readInt32();
+            Vector<String16> packages;
+            getPackagesForUid(uid, packages);
+            reply->writeNoException();
+            size_t size = packages.size();
+            reply->writeInt32(size);
+            for (size_t i = 0; i < size; i++) {
+                reply->writeString16(packages[i]);
+            }
+            return NO_ERROR;
+        } break;
+
+        case IS_RUNTIME_PERMISSION_TRANSACTION: {
+            CHECK_INTERFACE(IPermissionController, data, reply);
+            String16 permission = data.readString16();
+            const bool res = isRuntimePermission(permission);
+            reply->writeNoException();
+            reply->writeInt32(res ? 1 : 0);
+            return NO_ERROR;
+        } break;
+
         default:
             return BBinder::onTransact(code, data, reply, flags);
     }
diff --git a/libs/binder/IProcessInfoService.cpp b/libs/binder/IProcessInfoService.cpp
new file mode 100644
index 0000000..794588b
--- /dev/null
+++ b/libs/binder/IProcessInfoService.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <binder/IProcessInfoService.h>
+#include <binder/Parcel.h>
+#include <utils/Errors.h>
+#include <sys/types.h>
+
+namespace android {
+
+// ----------------------------------------------------------------------
+
+class BpProcessInfoService : public BpInterface<IProcessInfoService> {
+public:
+    explicit BpProcessInfoService(const sp<IBinder>& impl)
+        : BpInterface<IProcessInfoService>(impl) {}
+
+    virtual status_t getProcessStatesFromPids(size_t length, /*in*/ int32_t* pids,
+            /*out*/ int32_t* states)
+    {
+        Parcel data, reply;
+        data.writeInterfaceToken(IProcessInfoService::getInterfaceDescriptor());
+        data.writeInt32Array(length, pids);
+        data.writeInt32(length); // write length of output array, used by java AIDL stubs
+        status_t err = remote()->transact(GET_PROCESS_STATES_FROM_PIDS, data, &reply);
+        if (err != NO_ERROR || ((err = reply.readExceptionCode()) != NO_ERROR)) {
+            return err;
+        }
+        int32_t replyLen = reply.readInt32();
+        if (static_cast<size_t>(replyLen) != length) {
+            return NOT_ENOUGH_DATA;
+        }
+        if (replyLen > 0 && (err = reply.read(states, length * sizeof(*states))) != NO_ERROR) {
+            return err;
+        }
+        return reply.readInt32();
+    }
+
+};
+
+IMPLEMENT_META_INTERFACE(ProcessInfoService, "android.os.IProcessInfoService");
+
+// ----------------------------------------------------------------------
+
+status_t BnProcessInfoService::onTransact( uint32_t code, const Parcel& data, Parcel* reply,
+        uint32_t flags) {
+    switch(code) {
+        case GET_PROCESS_STATES_FROM_PIDS: {
+            CHECK_INTERFACE(IProcessInfoService, data, reply);
+            int32_t arrayLen = data.readInt32();
+            if (arrayLen <= 0) {
+                reply->writeNoException();
+                reply->writeInt32(0);
+                reply->writeInt32(NOT_ENOUGH_DATA);
+                return NO_ERROR;
+            }
+
+            size_t len = static_cast<size_t>(arrayLen);
+            int32_t pids[len];
+            status_t res = data.read(pids, len * sizeof(*pids));
+
+            // Ignore output array length returned in the parcel here, as the states array must
+            // always be the same length as the input PIDs array.
+            int32_t states[len];
+            for (size_t i = 0; i < len; i++) states[i] = -1;
+            if (res == NO_ERROR) {
+                res = getProcessStatesFromPids(len, /*in*/ pids, /*out*/ states);
+            }
+            reply->writeNoException();
+            reply->writeInt32Array(len, states);
+            reply->writeInt32(res);
+            return NO_ERROR;
+        } break;
+        default:
+            return BBinder::onTransact(code, data, reply, flags);
+    }
+}
+
+// ----------------------------------------------------------------------
+
+}; // namespace android
diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp
index a341ca8..2062b3b 100644
--- a/libs/binder/IServiceManager.cpp
+++ b/libs/binder/IServiceManager.cpp
@@ -18,7 +18,6 @@
 
 #include <binder/IServiceManager.h>
 
-#include <utils/Debug.h>
 #include <utils/Log.h>
 #include <binder/IPCThreadState.h>
 #include <binder/Parcel.h>
@@ -34,7 +33,7 @@
 sp<IServiceManager> defaultServiceManager()
 {
     if (gDefaultServiceManager != NULL) return gDefaultServiceManager;
-    
+
     {
         AutoMutex _l(gDefaultServiceManagerLock);
         while (gDefaultServiceManager == NULL) {
@@ -44,7 +43,7 @@
                 sleep(1);
         }
     }
-    
+
     return gDefaultServiceManager;
 }
 
@@ -72,7 +71,7 @@
     gDefaultServiceManagerLock.lock();
     pc = gPermissionController;
     gDefaultServiceManagerLock.unlock();
-    
+
     int64_t startTime = 0;
 
     while (true) {
@@ -86,14 +85,14 @@
                 }
                 return res;
             }
-            
+
             // Is this a permission failure, or did the controller go away?
-            if (pc->asBinder()->isBinderAlive()) {
+            if (IInterface::asBinder(pc)->isBinderAlive()) {
                 ALOGW("Permission failure: %s from uid=%d pid=%d",
                         String8(permission).string(), uid, pid);
                 return false;
             }
-            
+
             // Object is dead!
             gDefaultServiceManagerLock.lock();
             if (gPermissionController == pc) {
@@ -101,7 +100,7 @@
             }
             gDefaultServiceManagerLock.unlock();
         }
-    
+
         // Need to retrieve the permission controller.
         sp<IBinder> binder = defaultServiceManager()->checkService(_permission);
         if (binder == NULL) {
@@ -114,7 +113,7 @@
             sleep(1);
         } else {
             pc = interface_cast<IPermissionController>(binder);
-            // Install the new permission controller, and try again.        
+            // Install the new permission controller, and try again.
             gDefaultServiceManagerLock.lock();
             gPermissionController = pc;
             gDefaultServiceManagerLock.unlock();
@@ -127,7 +126,7 @@
 class BpServiceManager : public BpInterface<IServiceManager>
 {
 public:
-    BpServiceManager(const sp<IBinder>& impl)
+    explicit BpServiceManager(const sp<IBinder>& impl)
         : BpInterface<IServiceManager>(impl)
     {
     }
@@ -185,48 +184,4 @@
 
 IMPLEMENT_META_INTERFACE(ServiceManager, "android.os.IServiceManager");
 
-// ----------------------------------------------------------------------
-
-status_t BnServiceManager::onTransact(
-    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
-{
-    //printf("ServiceManager received: "); data.print();
-    switch(code) {
-        case GET_SERVICE_TRANSACTION: {
-            CHECK_INTERFACE(IServiceManager, data, reply);
-            String16 which = data.readString16();
-            sp<IBinder> b = const_cast<BnServiceManager*>(this)->getService(which);
-            reply->writeStrongBinder(b);
-            return NO_ERROR;
-        } break;
-        case CHECK_SERVICE_TRANSACTION: {
-            CHECK_INTERFACE(IServiceManager, data, reply);
-            String16 which = data.readString16();
-            sp<IBinder> b = const_cast<BnServiceManager*>(this)->checkService(which);
-            reply->writeStrongBinder(b);
-            return NO_ERROR;
-        } break;
-        case ADD_SERVICE_TRANSACTION: {
-            CHECK_INTERFACE(IServiceManager, data, reply);
-            String16 which = data.readString16();
-            sp<IBinder> b = data.readStrongBinder();
-            status_t err = addService(which, b);
-            reply->writeInt32(err);
-            return NO_ERROR;
-        } break;
-        case LIST_SERVICES_TRANSACTION: {
-            CHECK_INTERFACE(IServiceManager, data, reply);
-            Vector<String16> list = listServices();
-            const size_t N = list.size();
-            reply->writeInt32(N);
-            for (size_t i=0; i<N; i++) {
-                reply->writeString16(list[i]);
-            }
-            return NO_ERROR;
-        } break;
-        default:
-            return BBinder::onTransact(code, data, reply, flags);
-    }
-}
-
 }; // namespace android
diff --git a/libs/binder/MemoryDealer.cpp b/libs/binder/MemoryDealer.cpp
index a14c100..a5ba4ac 100644
--- a/libs/binder/MemoryDealer.cpp
+++ b/libs/binder/MemoryDealer.cpp
@@ -126,7 +126,7 @@
         PAGE_ALIGNED = 0x00000001
     };
 public:
-    SimpleBestFitAllocator(size_t size);
+    explicit SimpleBestFitAllocator(size_t size);
     ~SimpleBestFitAllocator();
 
     size_t      allocate(size_t size, uint32_t flags = 0);
@@ -225,8 +225,8 @@
 
 // ----------------------------------------------------------------------------
 
-MemoryDealer::MemoryDealer(size_t size, const char* name)
-    : mHeap(new MemoryHeapBase(size, 0, name)),
+MemoryDealer::MemoryDealer(size_t size, const char* name, uint32_t flags)
+    : mHeap(new MemoryHeapBase(size, flags, name)),
     mAllocator(new SimpleBestFitAllocator(size))
 {    
 }
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 159003d..1c28000 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -17,49 +17,62 @@
 #define LOG_TAG "Parcel"
 //#define LOG_NDEBUG 0
 
-#include <binder/Parcel.h>
-
-#include <binder/IPCThreadState.h>
-#include <binder/Binder.h>
-#include <binder/BpBinder.h>
-#include <binder/ProcessState.h>
-#include <binder/TextOutput.h>
-
-#include <utils/Debug.h>
-#include <utils/Log.h>
-#include <utils/String8.h>
-#include <utils/String16.h>
-#include <utils/misc.h>
-#include <utils/Flattenable.h>
-#include <cutils/ashmem.h>
-
-#include <private/binder/binder_module.h>
-
+#include <errno.h>
+#include <fcntl.h>
 #include <inttypes.h>
+#include <pthread.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdint.h>
 #include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <binder/Binder.h>
+#include <binder/BpBinder.h>
+#include <binder/IPCThreadState.h>
+#include <binder/Parcel.h>
+#include <binder/ProcessState.h>
+#include <binder/Status.h>
+#include <binder/TextOutput.h>
+
+#include <cutils/ashmem.h>
+#include <utils/Debug.h>
+#include <utils/Flattenable.h>
+#include <utils/Log.h>
+#include <utils/misc.h>
+#include <utils/String8.h>
+#include <utils/String16.h>
+
+#include <private/binder/binder_module.h>
+#include <private/binder/Static.h>
 
 #ifndef INT32_MAX
 #define INT32_MAX ((int32_t)(2147483647))
 #endif
 
 #define LOG_REFS(...)
-//#define LOG_REFS(...) ALOG(LOG_DEBUG, "Parcel", __VA_ARGS__)
+//#define LOG_REFS(...) ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)
+#define LOG_ALLOC(...)
+//#define LOG_ALLOC(...) ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)
 
 // ---------------------------------------------------------------------------
 
-#define PAD_SIZE(s) (((s)+3)&~3)
+// This macro should never be used at runtime, as a too large value
+// of s could cause an integer overflow. Instead, you should always
+// use the wrapper function pad_size()
+#define PAD_SIZE_UNSAFE(s) (((s)+3)&~3)
+
+static size_t pad_size(size_t s) {
+    if (s > (SIZE_T_MAX - 3)) {
+        abort();
+    }
+    return PAD_SIZE_UNSAFE(s);
+}
 
 // Note: must be kept in sync with android/os/StrictMode.java's PENALTY_GATHER
-#define STRICT_MODE_PENALTY_GATHER 0x100
-
-// Note: must be kept in sync with android/os/Parcel.java's EX_HAS_REPLY_HEADER
-#define EX_HAS_REPLY_HEADER -128
-
-// Maximum size of a blob to transfer in-place.
-static const size_t IN_PLACE_BLOB_LIMIT = 40 * 1024;
+#define STRICT_MODE_PENALTY_GATHER (0x40 << 16)
 
 // XXX This can be made public if we want to provide
 // support for typed data.
@@ -71,8 +84,47 @@
 
 namespace android {
 
+static pthread_mutex_t gParcelGlobalAllocSizeLock = PTHREAD_MUTEX_INITIALIZER;
+static size_t gParcelGlobalAllocSize = 0;
+static size_t gParcelGlobalAllocCount = 0;
+
+// Maximum size of a blob to transfer in-place.
+static const size_t BLOB_INPLACE_LIMIT = 16 * 1024;
+
+enum {
+    BLOB_INPLACE = 0,
+    BLOB_ASHMEM_IMMUTABLE = 1,
+    BLOB_ASHMEM_MUTABLE = 2,
+};
+
+static dev_t ashmem_rdev()
+{
+    static dev_t __ashmem_rdev;
+    static pthread_mutex_t __ashmem_rdev_lock = PTHREAD_MUTEX_INITIALIZER;
+
+    pthread_mutex_lock(&__ashmem_rdev_lock);
+
+    dev_t rdev = __ashmem_rdev;
+    if (!rdev) {
+        int fd = TEMP_FAILURE_RETRY(open("/dev/ashmem", O_RDONLY));
+        if (fd >= 0) {
+            struct stat st;
+
+            int ret = TEMP_FAILURE_RETRY(fstat(fd, &st));
+            close(fd);
+            if ((ret >= 0) && S_ISCHR(st.st_mode)) {
+                rdev = __ashmem_rdev = st.st_rdev;
+            }
+        }
+    }
+
+    pthread_mutex_unlock(&__ashmem_rdev_lock);
+
+    return rdev;
+}
+
 void acquire_object(const sp<ProcessState>& proc,
-    const flat_binder_object& obj, const void* who)
+    const flat_binder_object& obj, const void* who, size_t* outAshmemSize)
 {
     switch (obj.type) {
         case BINDER_TYPE_BINDER:
@@ -99,8 +151,17 @@
             return;
         }
         case BINDER_TYPE_FD: {
-            // intentionally blank -- nothing to do to acquire this, but we do
-            // recognize it as a legitimate object type.
+            if ((obj.cookie != 0) && (outAshmemSize != NULL)) {
+                struct stat st;
+                int ret = fstat(obj.handle, &st);
+                if (!ret && S_ISCHR(st.st_mode) && (st.st_rdev == ashmem_rdev())) {
+                    // If we own an ashmem fd, keep track of how much memory it refers to.
+                    int size = ashmem_get_size_region(obj.handle);
+                    if (size > 0) {
+                        *outAshmemSize += size;
+                    }
+                }
+            }
             return;
         }
     }
@@ -108,9 +169,15 @@
     ALOGD("Invalid object type 0x%08x", obj.type);
 }
 
-void release_object(const sp<ProcessState>& proc,
+void acquire_object(const sp<ProcessState>& proc,
     const flat_binder_object& obj, const void* who)
 {
+    acquire_object(proc, obj, who, NULL);
+}
+
+static void release_object(const sp<ProcessState>& proc,
+    const flat_binder_object& obj, const void* who, size_t* outAshmemSize)
+{
     switch (obj.type) {
         case BINDER_TYPE_BINDER:
             if (obj.binder) {
@@ -136,7 +203,20 @@
             return;
         }
         case BINDER_TYPE_FD: {
-            if (obj.cookie != 0) close(obj.handle);
+            if (obj.cookie != 0) { // owned
+                if (outAshmemSize != NULL) {
+                    struct stat st;
+                    int ret = fstat(obj.handle, &st);
+                    if (!ret && S_ISCHR(st.st_mode) && (st.st_rdev == ashmem_rdev())) {
+                        int size = ashmem_get_size_region(obj.handle);
+                        if (size > 0) {
+                            *outAshmemSize -= size;
+                        }
+                    }
+                }
+
+                close(obj.handle);
+            }
             return;
         }
     }
@@ -144,6 +224,12 @@
     ALOGE("Invalid object type 0x%08x", obj.type);
 }
 
+void release_object(const sp<ProcessState>& proc,
+    const flat_binder_object& obj, const void* who)
+{
+    release_object(proc, obj, who, NULL);
+}
+
 inline static status_t finish_flatten_binder(
     const sp<IBinder>& /*binder*/, const flat_binder_object& flat, Parcel* out)
 {
@@ -154,7 +240,7 @@
     const sp<IBinder>& binder, Parcel* out)
 {
     flat_binder_object obj;
-    
+
     obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
     if (binder != NULL) {
         IBinder *local = binder->localBinder();
@@ -178,7 +264,7 @@
         obj.binder = 0;
         obj.cookie = 0;
     }
-    
+
     return finish_flatten_binder(binder, obj, out);
 }
 
@@ -186,7 +272,7 @@
     const wp<IBinder>& binder, Parcel* out)
 {
     flat_binder_object obj;
-    
+
     obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
     if (binder != NULL) {
         sp<IBinder> real = binder.promote();
@@ -209,7 +295,7 @@
             }
             return finish_flatten_binder(real, obj, out);
         }
-        
+
         // XXX How to deal?  In order to flatten the given binder,
         // we need to probe it for information, which requires a primary
         // reference...  but we don't have one.
@@ -222,7 +308,7 @@
         obj.binder = 0;
         obj.cookie = 0;
         return finish_flatten_binder(NULL, obj, out);
-    
+
     } else {
         obj.type = BINDER_TYPE_BINDER;
         obj.binder = 0;
@@ -237,12 +323,12 @@
 {
     return NO_ERROR;
 }
-    
+
 status_t unflatten_binder(const sp<ProcessState>& proc,
     const Parcel& in, sp<IBinder>* out)
 {
     const flat_binder_object* flat = in.readObject(false);
-    
+
     if (flat) {
         switch (flat->type) {
             case BINDER_TYPE_BINDER:
@@ -252,7 +338,7 @@
                 *out = proc->getStrongProxyForHandle(flat->handle);
                 return finish_unflatten_binder(
                     static_cast<BpBinder*>(out->get()), *flat, in);
-        }        
+        }
     }
     return BAD_TYPE;
 }
@@ -261,7 +347,7 @@
     const Parcel& in, wp<IBinder>* out)
 {
     const flat_binder_object* flat = in.readObject(false);
-    
+
     if (flat) {
         switch (flat->type) {
             case BINDER_TYPE_BINDER:
@@ -290,12 +376,28 @@
 
 Parcel::Parcel()
 {
+    LOG_ALLOC("Parcel %p: constructing", this);
     initState();
 }
 
 Parcel::~Parcel()
 {
     freeDataNoInit();
+    LOG_ALLOC("Parcel %p: destroyed", this);
+}
+
+size_t Parcel::getGlobalAllocSize() {
+    pthread_mutex_lock(&gParcelGlobalAllocSizeLock);
+    size_t size = gParcelGlobalAllocSize;
+    pthread_mutex_unlock(&gParcelGlobalAllocSizeLock);
+    return size;
+}
+
+size_t Parcel::getGlobalAllocCount() {
+    pthread_mutex_lock(&gParcelGlobalAllocSizeLock);
+    size_t count = gParcelGlobalAllocCount;
+    pthread_mutex_unlock(&gParcelGlobalAllocSizeLock);
+    return count;
 }
 
 const uint8_t* Parcel::data() const
@@ -310,13 +412,11 @@
 
 size_t Parcel::dataAvail() const
 {
-    // TODO: decide what to do about the possibility that this can
-    // report an available-data size that exceeds a Java int's max
-    // positive value, causing havoc.  Fortunately this will only
-    // happen if someone constructs a Parcel containing more than two
-    // gigabytes of data, which on typical phone hardware is simply
-    // not possible.
-    return dataSize() - dataPosition();
+    size_t result = dataSize() - dataPosition();
+    if (result > INT32_MAX) {
+        abort();
+    }
+    return result;
 }
 
 size_t Parcel::dataPosition() const
@@ -331,29 +431,53 @@
 
 status_t Parcel::setDataSize(size_t size)
 {
+    if (size > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return BAD_VALUE;
+    }
+
     status_t err;
     err = continueWrite(size);
     if (err == NO_ERROR) {
         mDataSize = size;
-        ALOGV("setDataSize Setting data size of %p to %d\n", this, mDataSize);
+        ALOGV("setDataSize Setting data size of %p to %zu", this, mDataSize);
     }
     return err;
 }
 
 void Parcel::setDataPosition(size_t pos) const
 {
+    if (pos > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        abort();
+    }
+
     mDataPos = pos;
     mNextObjectHint = 0;
 }
 
 status_t Parcel::setDataCapacity(size_t size)
 {
+    if (size > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return BAD_VALUE;
+    }
+
     if (size > mDataCapacity) return continueWrite(size);
     return NO_ERROR;
 }
 
 status_t Parcel::setData(const uint8_t* buffer, size_t len)
 {
+    if (len > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return BAD_VALUE;
+    }
+
     status_t err = restartWrite(len);
     if (err == NO_ERROR) {
         memcpy(const_cast<uint8_t*>(data()), buffer, len);
@@ -377,6 +501,12 @@
         return NO_ERROR;
     }
 
+    if (len > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return BAD_VALUE;
+    }
+
     // range checks against the source parcel size
     if ((offset > parcel->mDataSize)
             || (len > parcel->mDataSize)
@@ -387,7 +517,7 @@
     // Count objects in range
     for (int i = 0; i < (int) size; i++) {
         size_t off = objects[i];
-        if ((off >= offset) && (off < offset + len)) {
+        if ((off >= offset) && (off + sizeof(flat_binder_object) <= offset + len)) {
             if (firstIndex == -1) {
                 firstIndex = i;
             }
@@ -414,7 +544,8 @@
     if (numObjects > 0) {
         // grow objects
         if (mObjectsCapacity < mObjectsSize + numObjects) {
-            int newSize = ((mObjectsSize + numObjects)*3)/2;
+            size_t newSize = ((mObjectsSize + numObjects)*3)/2;
+            if (newSize < mObjectsSize) return NO_MEMORY;   // overflow
             binder_size_t *objects =
                 (binder_size_t*)realloc(mObjects, newSize*sizeof(binder_size_t));
             if (objects == (binder_size_t*)0) {
@@ -423,7 +554,7 @@
             mObjects = objects;
             mObjectsCapacity = newSize;
         }
-        
+
         // append and acquire objects
         int idx = mObjectsSize;
         for (int i = firstIndex; i <= lastIndex; i++) {
@@ -433,7 +564,7 @@
 
             flat_binder_object* flat
                 = reinterpret_cast<flat_binder_object*>(mData + off);
-            acquire_object(proc, *flat, this);
+            acquire_object(proc, *flat, this, &mOpenAshmemSize);
 
             if (flat->type == BINDER_TYPE_FD) {
                 // If this is a file descriptor, we need to dup it so the
@@ -452,6 +583,11 @@
     return err;
 }
 
+bool Parcel::allowFds() const
+{
+    return mAllowFds;
+}
+
 bool Parcel::pushAllowFds(bool allowFds)
 {
     const bool origValue = mAllowFds;
@@ -509,7 +645,7 @@
     if (str == interface) {
         return true;
     } else {
-        ALOGW("**** enforceInterface() expected '%s' but read '%s'\n",
+        ALOGW("**** enforceInterface() expected '%s' but read '%s'",
                 String8(interface).string(), String8(str).string());
         return false;
     }
@@ -537,12 +673,18 @@
 
 status_t Parcel::finishWrite(size_t len)
 {
+    if (len > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return BAD_VALUE;
+    }
+
     //printf("Finish write of %d\n", len);
     mDataPos += len;
-    ALOGV("finishWrite Setting data pos of %p to %d\n", this, mDataPos);
+    ALOGV("finishWrite Setting data pos of %p to %zu", this, mDataPos);
     if (mDataPos > mDataSize) {
         mDataSize = mDataPos;
-        ALOGV("finishWrite Setting data size of %p to %d\n", this, mDataSize);
+        ALOGV("finishWrite Setting data size of %p to %zu", this, mDataSize);
     }
     //printf("New pos=%d, size=%d\n", mDataPos, mDataSize);
     return NO_ERROR;
@@ -550,6 +692,12 @@
 
 status_t Parcel::writeUnpadded(const void* data, size_t len)
 {
+    if (len > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return BAD_VALUE;
+    }
+
     size_t end = mDataPos + len;
     if (end < mDataPos) {
         // integer overflow
@@ -569,6 +717,12 @@
 
 status_t Parcel::write(const void* data, size_t len)
 {
+    if (len > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return BAD_VALUE;
+    }
+
     void* const d = writeInplace(len);
     if (d) {
         memcpy(d, data, len);
@@ -579,7 +733,13 @@
 
 void* Parcel::writeInplace(size_t len)
 {
-    const size_t padded = PAD_SIZE(len);
+    if (len > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return NULL;
+    }
+
+    const size_t padded = pad_size(len);
 
     // sanity check for integer overflow
     if (mDataPos+padded < mDataPos) {
@@ -617,26 +777,242 @@
     return NULL;
 }
 
+status_t Parcel::writeUtf8AsUtf16(const std::string& str) {
+    const uint8_t* strData = (uint8_t*)str.data();
+    const size_t strLen= str.length();
+    const ssize_t utf16Len = utf8_to_utf16_length(strData, strLen);
+    if (utf16Len < 0 || utf16Len> std::numeric_limits<int32_t>::max()) {
+        return BAD_VALUE;
+    }
+
+    status_t err = writeInt32(utf16Len);
+    if (err) {
+        return err;
+    }
+
+    // Allocate enough bytes to hold our converted string and its terminating NULL.
+    void* dst = writeInplace((utf16Len + 1) * sizeof(char16_t));
+    if (!dst) {
+        return NO_MEMORY;
+    }
+
+    utf8_to_utf16(strData, strLen, (char16_t*)dst);
+
+    return NO_ERROR;
+}
+
+status_t Parcel::writeUtf8AsUtf16(const std::unique_ptr<std::string>& str) {
+  if (!str) {
+    return writeInt32(-1);
+  }
+  return writeUtf8AsUtf16(*str);
+}
+
+namespace {
+
+template<typename T>
+status_t writeByteVectorInternal(Parcel* parcel, const std::vector<T>& val)
+{
+    status_t status;
+    if (val.size() > std::numeric_limits<int32_t>::max()) {
+        status = BAD_VALUE;
+        return status;
+    }
+
+    status = parcel->writeInt32(val.size());
+    if (status != OK) {
+        return status;
+    }
+
+    void* data = parcel->writeInplace(val.size());
+    if (!data) {
+        status = BAD_VALUE;
+        return status;
+    }
+
+    memcpy(data, val.data(), val.size());
+    return status;
+}
+
+template<typename T>
+status_t writeByteVectorInternalPtr(Parcel* parcel,
+                                    const std::unique_ptr<std::vector<T>>& val)
+{
+    if (!val) {
+        return parcel->writeInt32(-1);
+    }
+
+    return writeByteVectorInternal(parcel, *val);
+}
+
+}  // namespace
+
+status_t Parcel::writeByteVector(const std::vector<int8_t>& val) {
+    return writeByteVectorInternal(this, val);
+}
+
+status_t Parcel::writeByteVector(const std::unique_ptr<std::vector<int8_t>>& val)
+{
+    return writeByteVectorInternalPtr(this, val);
+}
+
+status_t Parcel::writeByteVector(const std::vector<uint8_t>& val) {
+    return writeByteVectorInternal(this, val);
+}
+
+status_t Parcel::writeByteVector(const std::unique_ptr<std::vector<uint8_t>>& val)
+{
+    return writeByteVectorInternalPtr(this, val);
+}
+
+status_t Parcel::writeInt32Vector(const std::vector<int32_t>& val)
+{
+    return writeTypedVector(val, &Parcel::writeInt32);
+}
+
+status_t Parcel::writeInt32Vector(const std::unique_ptr<std::vector<int32_t>>& val)
+{
+    return writeNullableTypedVector(val, &Parcel::writeInt32);
+}
+
+status_t Parcel::writeInt64Vector(const std::vector<int64_t>& val)
+{
+    return writeTypedVector(val, &Parcel::writeInt64);
+}
+
+status_t Parcel::writeInt64Vector(const std::unique_ptr<std::vector<int64_t>>& val)
+{
+    return writeNullableTypedVector(val, &Parcel::writeInt64);
+}
+
+status_t Parcel::writeFloatVector(const std::vector<float>& val)
+{
+    return writeTypedVector(val, &Parcel::writeFloat);
+}
+
+status_t Parcel::writeFloatVector(const std::unique_ptr<std::vector<float>>& val)
+{
+    return writeNullableTypedVector(val, &Parcel::writeFloat);
+}
+
+status_t Parcel::writeDoubleVector(const std::vector<double>& val)
+{
+    return writeTypedVector(val, &Parcel::writeDouble);
+}
+
+status_t Parcel::writeDoubleVector(const std::unique_ptr<std::vector<double>>& val)
+{
+    return writeNullableTypedVector(val, &Parcel::writeDouble);
+}
+
+status_t Parcel::writeBoolVector(const std::vector<bool>& val)
+{
+    return writeTypedVector(val, &Parcel::writeBool);
+}
+
+status_t Parcel::writeBoolVector(const std::unique_ptr<std::vector<bool>>& val)
+{
+    return writeNullableTypedVector(val, &Parcel::writeBool);
+}
+
+status_t Parcel::writeCharVector(const std::vector<char16_t>& val)
+{
+    return writeTypedVector(val, &Parcel::writeChar);
+}
+
+status_t Parcel::writeCharVector(const std::unique_ptr<std::vector<char16_t>>& val)
+{
+    return writeNullableTypedVector(val, &Parcel::writeChar);
+}
+
+status_t Parcel::writeString16Vector(const std::vector<String16>& val)
+{
+    return writeTypedVector(val, &Parcel::writeString16);
+}
+
+status_t Parcel::writeString16Vector(
+        const std::unique_ptr<std::vector<std::unique_ptr<String16>>>& val)
+{
+    return writeNullableTypedVector(val, &Parcel::writeString16);
+}
+
+status_t Parcel::writeUtf8VectorAsUtf16Vector(
+                        const std::unique_ptr<std::vector<std::unique_ptr<std::string>>>& val) {
+    return writeNullableTypedVector(val, &Parcel::writeUtf8AsUtf16);
+}
+
+status_t Parcel::writeUtf8VectorAsUtf16Vector(const std::vector<std::string>& val) {
+    return writeTypedVector(val, &Parcel::writeUtf8AsUtf16);
+}
+
 status_t Parcel::writeInt32(int32_t val)
 {
     return writeAligned(val);
 }
+
+status_t Parcel::writeUint32(uint32_t val)
+{
+    return writeAligned(val);
+}
+
 status_t Parcel::writeInt32Array(size_t len, const int32_t *val) {
-    if (!val) {
-        return writeAligned(-1);
+    if (len > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return BAD_VALUE;
     }
-    status_t ret = writeAligned(len);
+
+    if (!val) {
+        return writeInt32(-1);
+    }
+    status_t ret = writeInt32(static_cast<uint32_t>(len));
+    if (ret == NO_ERROR) {
+        ret = write(val, len * sizeof(*val));
+    }
+    return ret;
+}
+status_t Parcel::writeByteArray(size_t len, const uint8_t *val) {
+    if (len > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return BAD_VALUE;
+    }
+
+    if (!val) {
+        return writeInt32(-1);
+    }
+    status_t ret = writeInt32(static_cast<uint32_t>(len));
     if (ret == NO_ERROR) {
         ret = write(val, len * sizeof(*val));
     }
     return ret;
 }
 
+status_t Parcel::writeBool(bool val)
+{
+    return writeInt32(int32_t(val));
+}
+
+status_t Parcel::writeChar(char16_t val)
+{
+    return writeInt32(int32_t(val));
+}
+
+status_t Parcel::writeByte(int8_t val)
+{
+    return writeInt32(int32_t(val));
+}
+
 status_t Parcel::writeInt64(int64_t val)
 {
     return writeAligned(val);
 }
 
+status_t Parcel::writeUint64(uint64_t val)
+{
+    return writeAligned(val);
+}
+
 status_t Parcel::writePointer(uintptr_t val)
 {
     return writeAligned<binder_uintptr_t>(val);
@@ -668,11 +1044,6 @@
 
 #endif
 
-status_t Parcel::writeIntPtr(intptr_t val)
-{
-    return writeAligned(val);
-}
-
 status_t Parcel::writeCString(const char* str)
 {
     return write(str, strlen(str)+1);
@@ -690,6 +1061,15 @@
     return err;
 }
 
+status_t Parcel::writeString16(const std::unique_ptr<String16>& str)
+{
+    if (!str) {
+        return writeInt32(-1);
+    }
+
+    return writeString16(*str);
+}
+
 status_t Parcel::writeString16(const String16& str)
 {
     return writeString16(str.string(), str.size());
@@ -698,7 +1078,7 @@
 status_t Parcel::writeString16(const char16_t* str, size_t len)
 {
     if (str == NULL) return writeInt32(-1);
-    
+
     status_t err = writeInt32(len);
     if (err == NO_ERROR) {
         len *= sizeof(char16_t);
@@ -718,11 +1098,45 @@
     return flatten_binder(ProcessState::self(), val, this);
 }
 
+status_t Parcel::writeStrongBinderVector(const std::vector<sp<IBinder>>& val)
+{
+    return writeTypedVector(val, &Parcel::writeStrongBinder);
+}
+
+status_t Parcel::writeStrongBinderVector(const std::unique_ptr<std::vector<sp<IBinder>>>& val)
+{
+    return writeNullableTypedVector(val, &Parcel::writeStrongBinder);
+}
+
+status_t Parcel::readStrongBinderVector(std::unique_ptr<std::vector<sp<IBinder>>>* val) const {
+    return readNullableTypedVector(val, &Parcel::readNullableStrongBinder);
+}
+
+status_t Parcel::readStrongBinderVector(std::vector<sp<IBinder>>* val) const {
+    return readTypedVector(val, &Parcel::readStrongBinder);
+}
+
 status_t Parcel::writeWeakBinder(const wp<IBinder>& val)
 {
     return flatten_binder(ProcessState::self(), val, this);
 }
 
+status_t Parcel::writeRawNullableParcelable(const Parcelable* parcelable) {
+    if (!parcelable) {
+        return writeInt32(0);
+    }
+
+    return writeParcelable(*parcelable);
+}
+
+status_t Parcel::writeParcelable(const Parcelable& parcelable) {
+    status_t status = writeInt32(1);  // parcelable is not null.
+    if (status != OK) {
+        return status;
+    }
+    return parcelable.writeToParcel(this);
+}
+
 status_t Parcel::writeNativeHandle(const native_handle* handle)
 {
     if (!handle || handle->version != sizeof(native_handle))
@@ -764,25 +1178,42 @@
         return -errno;
     }
     status_t err = writeFileDescriptor(dupFd, true /*takeOwnership*/);
-    if (err) {
+    if (err != OK) {
         close(dupFd);
     }
     return err;
 }
 
-status_t Parcel::writeBlob(size_t len, WritableBlob* outBlob)
-{
-    status_t status;
+status_t Parcel::writeUniqueFileDescriptor(const base::unique_fd& fd) {
+    return writeDupFileDescriptor(fd.get());
+}
 
-    if (!mAllowFds || len <= IN_PLACE_BLOB_LIMIT) {
+status_t Parcel::writeUniqueFileDescriptorVector(const std::vector<base::unique_fd>& val) {
+    return writeTypedVector(val, &Parcel::writeUniqueFileDescriptor);
+}
+
+status_t Parcel::writeUniqueFileDescriptorVector(const std::unique_ptr<std::vector<base::unique_fd>>& val) {
+    return writeNullableTypedVector(val, &Parcel::writeUniqueFileDescriptor);
+}
+
+status_t Parcel::writeBlob(size_t len, bool mutableCopy, WritableBlob* outBlob)
+{
+    if (len > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return BAD_VALUE;
+    }
+
+    status_t status;
+    if (!mAllowFds || len <= BLOB_INPLACE_LIMIT) {
         ALOGV("writeBlob: write in place");
-        status = writeInt32(0);
+        status = writeInt32(BLOB_INPLACE);
         if (status) return status;
 
         void* ptr = writeInplace(len);
         if (!ptr) return NO_MEMORY;
 
-        outBlob->init(false /*mapped*/, ptr, len);
+        outBlob->init(-1, ptr, len, false);
         return NO_ERROR;
     }
 
@@ -798,15 +1229,17 @@
         if (ptr == MAP_FAILED) {
             status = -errno;
         } else {
-            result = ashmem_set_prot_region(fd, PROT_READ);
+            if (!mutableCopy) {
+                result = ashmem_set_prot_region(fd, PROT_READ);
+            }
             if (result < 0) {
                 status = result;
             } else {
-                status = writeInt32(1);
+                status = writeInt32(mutableCopy ? BLOB_ASHMEM_MUTABLE : BLOB_ASHMEM_IMMUTABLE);
                 if (!status) {
                     status = writeFileDescriptor(fd, true /*takeOwnership*/);
                     if (!status) {
-                        outBlob->init(true /*mapped*/, ptr, len);
+                        outBlob->init(fd, ptr, len, mutableCopy);
                         return NO_ERROR;
                     }
                 }
@@ -818,6 +1251,15 @@
     return status;
 }
 
+status_t Parcel::writeDupImmutableBlobFileDescriptor(int fd)
+{
+    // Must match up with what's done in writeBlob.
+    if (!mAllowFds) return FDS_NOT_ALLOWED;
+    status_t status = writeInt32(BLOB_ASHMEM_IMMUTABLE);
+    if (status) return status;
+    return writeDupFileDescriptor(fd);
+}
+
 status_t Parcel::write(const FlattenableHelperInterface& val)
 {
     status_t err;
@@ -826,6 +1268,12 @@
     const size_t len = val.getFlattenedSize();
     const size_t fd_count = val.getFdCount();
 
+    if ((len > INT32_MAX) || (fd_count > INT32_MAX)) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return BAD_VALUE;
+    }
+
     err = this->writeInt32(len);
     if (err) return err;
 
@@ -833,7 +1281,7 @@
     if (err) return err;
 
     // payload
-    void* const buf = this->writeInplace(PAD_SIZE(len));
+    void* const buf = this->writeInplace(pad_size(len));
     if (buf == NULL)
         return BAD_VALUE;
 
@@ -861,22 +1309,23 @@
     if (enoughData && enoughObjects) {
 restart_write:
         *reinterpret_cast<flat_binder_object*>(mData+mDataPos) = val;
-        
-        // Need to write meta-data?
-        if (nullMetaData || val.binder != 0) {
-            mObjects[mObjectsSize] = mDataPos;
-            acquire_object(ProcessState::self(), val, this);
-            mObjectsSize++;
-        }
-        
+
         // remember if it's a file descriptor
         if (val.type == BINDER_TYPE_FD) {
             if (!mAllowFds) {
+                // fail before modifying our object index
                 return FDS_NOT_ALLOWED;
             }
             mHasFds = mFdsKnown = true;
         }
 
+        // Need to write meta-data?
+        if (nullMetaData || val.binder != 0) {
+            mObjects[mObjectsSize] = mDataPos;
+            acquire_object(ProcessState::self(), val, this, &mOpenAshmemSize);
+            mObjectsSize++;
+        }
+
         return finishWrite(sizeof(flat_binder_object));
     }
 
@@ -886,18 +1335,20 @@
     }
     if (!enoughObjects) {
         size_t newSize = ((mObjectsSize+2)*3)/2;
+        if (newSize < mObjectsSize) return NO_MEMORY;   // overflow
         binder_size_t* objects = (binder_size_t*)realloc(mObjects, newSize*sizeof(binder_size_t));
         if (objects == NULL) return NO_MEMORY;
         mObjects = objects;
         mObjectsCapacity = newSize;
     }
-    
+
     goto restart_write;
 }
 
 status_t Parcel::writeNoException()
 {
-    return writeInt32(0);
+    binder::Status status;
+    return status.writeToParcel(this);
 }
 
 void Parcel::remove(size_t /*start*/, size_t /*amt*/)
@@ -907,10 +1358,17 @@
 
 status_t Parcel::read(void* outData, size_t len) const
 {
-    if ((mDataPos+PAD_SIZE(len)) >= mDataPos && (mDataPos+PAD_SIZE(len)) <= mDataSize) {
+    if (len > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return BAD_VALUE;
+    }
+
+    if ((mDataPos+pad_size(len)) >= mDataPos && (mDataPos+pad_size(len)) <= mDataSize
+            && len <= pad_size(len)) {
         memcpy(outData, mData+mDataPos, len);
-        mDataPos += PAD_SIZE(len);
-        ALOGV("read Setting data pos of %p to %d\n", this, mDataPos);
+        mDataPos += pad_size(len);
+        ALOGV("read Setting data pos of %p to %zu", this, mDataPos);
         return NO_ERROR;
     }
     return NOT_ENOUGH_DATA;
@@ -918,10 +1376,17 @@
 
 const void* Parcel::readInplace(size_t len) const
 {
-    if ((mDataPos+PAD_SIZE(len)) >= mDataPos && (mDataPos+PAD_SIZE(len)) <= mDataSize) {
+    if (len > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return NULL;
+    }
+
+    if ((mDataPos+pad_size(len)) >= mDataPos && (mDataPos+pad_size(len)) <= mDataSize
+            && len <= pad_size(len)) {
         const void* data = mData+mDataPos;
-        mDataPos += PAD_SIZE(len);
-        ALOGV("readInplace Setting data pos of %p to %d\n", this, mDataPos);
+        mDataPos += pad_size(len);
+        ALOGV("readInplace Setting data pos of %p to %zu", this, mDataPos);
         return data;
     }
     return NULL;
@@ -929,7 +1394,7 @@
 
 template<class T>
 status_t Parcel::readAligned(T *pArg) const {
-    COMPILE_TIME_ASSERT_FUNCTION_SCOPE(PAD_SIZE(sizeof(T)) == sizeof(T));
+    COMPILE_TIME_ASSERT_FUNCTION_SCOPE(PAD_SIZE_UNSAFE(sizeof(T)) == sizeof(T));
 
     if ((mDataPos+sizeof(T)) <= mDataSize) {
         const void* data = mData+mDataPos;
@@ -953,7 +1418,7 @@
 
 template<class T>
 status_t Parcel::writeAligned(T val) {
-    COMPILE_TIME_ASSERT_FUNCTION_SCOPE(PAD_SIZE(sizeof(T)) == sizeof(T));
+    COMPILE_TIME_ASSERT_FUNCTION_SCOPE(PAD_SIZE_UNSAFE(sizeof(T)) == sizeof(T));
 
     if ((mDataPos+sizeof(val)) <= mDataCapacity) {
 restart_write:
@@ -966,6 +1431,193 @@
     return err;
 }
 
+namespace {
+
+template<typename T>
+status_t readByteVectorInternal(const Parcel* parcel,
+                                std::vector<T>* val) {
+    val->clear();
+
+    int32_t size;
+    status_t status = parcel->readInt32(&size);
+
+    if (status != OK) {
+        return status;
+    }
+
+    if (size < 0) {
+        status = UNEXPECTED_NULL;
+        return status;
+    }
+    if (size_t(size) > parcel->dataAvail()) {
+        status = BAD_VALUE;
+        return status;
+    }
+
+    const void* data = parcel->readInplace(size);
+    if (!data) {
+        status = BAD_VALUE;
+        return status;
+    }
+    val->resize(size);
+    memcpy(val->data(), data, size);
+
+    return status;
+}
+
+template<typename T>
+status_t readByteVectorInternalPtr(
+        const Parcel* parcel,
+        std::unique_ptr<std::vector<T>>* val) {
+    const int32_t start = parcel->dataPosition();
+    int32_t size;
+    status_t status = parcel->readInt32(&size);
+    val->reset();
+
+    if (status != OK || size < 0) {
+        return status;
+    }
+
+    parcel->setDataPosition(start);
+    val->reset(new std::vector<T>());
+
+    status = readByteVectorInternal(parcel, val->get());
+
+    if (status != OK) {
+        val->reset();
+    }
+
+    return status;
+}
+
+}  // namespace
+
+status_t Parcel::readByteVector(std::vector<int8_t>* val) const {
+    return readByteVectorInternal(this, val);
+}
+
+status_t Parcel::readByteVector(std::vector<uint8_t>* val) const {
+    return readByteVectorInternal(this, val);
+}
+
+status_t Parcel::readByteVector(std::unique_ptr<std::vector<int8_t>>* val) const {
+    return readByteVectorInternalPtr(this, val);
+}
+
+status_t Parcel::readByteVector(std::unique_ptr<std::vector<uint8_t>>* val) const {
+    return readByteVectorInternalPtr(this, val);
+}
+
+status_t Parcel::readInt32Vector(std::unique_ptr<std::vector<int32_t>>* val) const {
+    return readNullableTypedVector(val, &Parcel::readInt32);
+}
+
+status_t Parcel::readInt32Vector(std::vector<int32_t>* val) const {
+    return readTypedVector(val, &Parcel::readInt32);
+}
+
+status_t Parcel::readInt64Vector(std::unique_ptr<std::vector<int64_t>>* val) const {
+    return readNullableTypedVector(val, &Parcel::readInt64);
+}
+
+status_t Parcel::readInt64Vector(std::vector<int64_t>* val) const {
+    return readTypedVector(val, &Parcel::readInt64);
+}
+
+status_t Parcel::readFloatVector(std::unique_ptr<std::vector<float>>* val) const {
+    return readNullableTypedVector(val, &Parcel::readFloat);
+}
+
+status_t Parcel::readFloatVector(std::vector<float>* val) const {
+    return readTypedVector(val, &Parcel::readFloat);
+}
+
+status_t Parcel::readDoubleVector(std::unique_ptr<std::vector<double>>* val) const {
+    return readNullableTypedVector(val, &Parcel::readDouble);
+}
+
+status_t Parcel::readDoubleVector(std::vector<double>* val) const {
+    return readTypedVector(val, &Parcel::readDouble);
+}
+
+status_t Parcel::readBoolVector(std::unique_ptr<std::vector<bool>>* val) const {
+    const int32_t start = dataPosition();
+    int32_t size;
+    status_t status = readInt32(&size);
+    val->reset();
+
+    if (status != OK || size < 0) {
+        return status;
+    }
+
+    setDataPosition(start);
+    val->reset(new std::vector<bool>());
+
+    status = readBoolVector(val->get());
+
+    if (status != OK) {
+        val->reset();
+    }
+
+    return status;
+}
+
+status_t Parcel::readBoolVector(std::vector<bool>* val) const {
+    int32_t size;
+    status_t status = readInt32(&size);
+
+    if (status != OK) {
+        return status;
+    }
+
+    if (size < 0) {
+        return UNEXPECTED_NULL;
+    }
+
+    val->resize(size);
+
+    /* C++ bool handling means a vector of bools isn't necessarily addressable
+     * (we might use individual bits)
+     */
+    bool data;
+    for (int32_t i = 0; i < size; ++i) {
+        status = readBool(&data);
+        (*val)[i] = data;
+
+        if (status != OK) {
+            return status;
+        }
+    }
+
+    return OK;
+}
+
+status_t Parcel::readCharVector(std::unique_ptr<std::vector<char16_t>>* val) const {
+    return readNullableTypedVector(val, &Parcel::readChar);
+}
+
+status_t Parcel::readCharVector(std::vector<char16_t>* val) const {
+    return readTypedVector(val, &Parcel::readChar);
+}
+
+status_t Parcel::readString16Vector(
+        std::unique_ptr<std::vector<std::unique_ptr<String16>>>* val) const {
+    return readNullableTypedVector(val, &Parcel::readString16);
+}
+
+status_t Parcel::readString16Vector(std::vector<String16>* val) const {
+    return readTypedVector(val, &Parcel::readString16);
+}
+
+status_t Parcel::readUtf8VectorFromUtf16Vector(
+        std::unique_ptr<std::vector<std::unique_ptr<std::string>>>* val) const {
+    return readNullableTypedVector(val, &Parcel::readUtf8FromUtf16);
+}
+
+status_t Parcel::readUtf8VectorFromUtf16Vector(std::vector<std::string>* val) const {
+    return readTypedVector(val, &Parcel::readUtf8FromUtf16);
+}
+
 status_t Parcel::readInt32(int32_t *pArg) const
 {
     return readAligned(pArg);
@@ -976,6 +1628,15 @@
     return readAligned<int32_t>();
 }
 
+status_t Parcel::readUint32(uint32_t *pArg) const
+{
+    return readAligned(pArg);
+}
+
+uint32_t Parcel::readUint32() const
+{
+    return readAligned<uint32_t>();
+}
 
 status_t Parcel::readInt64(int64_t *pArg) const
 {
@@ -988,6 +1649,16 @@
     return readAligned<int64_t>();
 }
 
+status_t Parcel::readUint64(uint64_t *pArg) const
+{
+    return readAligned(pArg);
+}
+
+uint64_t Parcel::readUint64() const
+{
+    return readAligned<uint64_t>();
+}
+
 status_t Parcel::readPointer(uintptr_t *pArg) const
 {
     status_t ret;
@@ -1023,6 +1694,7 @@
       double d;
       unsigned long long ll;
     } u;
+    u.d = 0;
     status_t status;
     status = readAligned(&u.ll);
     *pArg = u.d;
@@ -1064,6 +1736,84 @@
     return readAligned<intptr_t>();
 }
 
+status_t Parcel::readBool(bool *pArg) const
+{
+    int32_t tmp;
+    status_t ret = readInt32(&tmp);
+    *pArg = (tmp != 0);
+    return ret;
+}
+
+bool Parcel::readBool() const
+{
+    return readInt32() != 0;
+}
+
+status_t Parcel::readChar(char16_t *pArg) const
+{
+    int32_t tmp;
+    status_t ret = readInt32(&tmp);
+    *pArg = char16_t(tmp);
+    return ret;
+}
+
+char16_t Parcel::readChar() const
+{
+    return char16_t(readInt32());
+}
+
+status_t Parcel::readByte(int8_t *pArg) const
+{
+    int32_t tmp;
+    status_t ret = readInt32(&tmp);
+    *pArg = int8_t(tmp);
+    return ret;
+}
+
+int8_t Parcel::readByte() const
+{
+    return int8_t(readInt32());
+}
+
+status_t Parcel::readUtf8FromUtf16(std::string* str) const {
+    size_t utf16Size = 0;
+    const char16_t* src = readString16Inplace(&utf16Size);
+    if (!src) {
+        return UNEXPECTED_NULL;
+    }
+
+    // Save ourselves the trouble, we're done.
+    if (utf16Size == 0u) {
+        str->clear();
+       return NO_ERROR;
+    }
+
+    ssize_t utf8Size = utf16_to_utf8_length(src, utf16Size);
+    if (utf8Size < 0) {
+        return BAD_VALUE;
+    }
+    // Note that while it is probably safe to assume string::resize keeps a
+    // spare byte around for the trailing null, we're going to be explicit.
+    str->resize(utf8Size + 1);
+    utf16_to_utf8(src, utf16Size, &((*str)[0]));
+    str->resize(utf8Size);
+    return NO_ERROR;
+}
+
+status_t Parcel::readUtf8FromUtf16(std::unique_ptr<std::string>* str) const {
+    const int32_t start = dataPosition();
+    int32_t size;
+    status_t status = readInt32(&size);
+    str->reset();
+
+    if (status != OK || size < 0) {
+        return status;
+    }
+
+    setDataPosition(start);
+    str->reset(new std::string());
+    return readUtf8FromUtf16(str->get());
+}
 
 const char* Parcel::readCString() const
 {
@@ -1074,8 +1824,8 @@
         const char* eos = reinterpret_cast<const char*>(memchr(str, 0, avail));
         if (eos) {
             const size_t len = eos - str;
-            mDataPos += PAD_SIZE(len+1);
-            ALOGV("readCString Setting data pos of %p to %d\n", this, mDataPos);
+            mDataPos += pad_size(len+1);
+            ALOGV("readCString Setting data pos of %p to %zu", this, mDataPos);
             return str;
         }
     }
@@ -1084,13 +1834,37 @@
 
 String8 Parcel::readString8() const
 {
-    int32_t size = readInt32();
-    // watch for potential int overflow adding 1 for trailing NUL
-    if (size > 0 && size < INT32_MAX) {
-        const char* str = (const char*)readInplace(size+1);
-        if (str) return String8(str, size);
+    String8 retString;
+    status_t status = readString8(&retString);
+    if (status != OK) {
+        // We don't care about errors here, so just return an empty string.
+        return String8();
     }
-    return String8();
+    return retString;
+}
+
+status_t Parcel::readString8(String8* pArg) const
+{
+    int32_t size;
+    status_t status = readInt32(&size);
+    if (status != OK) {
+        return status;
+    }
+    // watch for potential int overflow from size+1
+    if (size < 0 || size >= INT32_MAX) {
+        return BAD_VALUE;
+    }
+    // |writeString8| writes nothing for empty string.
+    if (size == 0) {
+        *pArg = String8();
+        return OK;
+    }
+    const char* str = (const char*)readInplace(size + 1);
+    if (str == NULL) {
+        return BAD_VALUE;
+    }
+    pArg->setTo(str, size);
+    return OK;
 }
 
 String16 Parcel::readString16() const
@@ -1102,6 +1876,42 @@
     return String16();
 }
 
+status_t Parcel::readString16(std::unique_ptr<String16>* pArg) const
+{
+    const int32_t start = dataPosition();
+    int32_t size;
+    status_t status = readInt32(&size);
+    pArg->reset();
+
+    if (status != OK || size < 0) {
+        return status;
+    }
+
+    setDataPosition(start);
+    pArg->reset(new String16());
+
+    status = readString16(pArg->get());
+
+    if (status != OK) {
+        pArg->reset();
+    }
+
+    return status;
+}
+
+status_t Parcel::readString16(String16* pArg) const
+{
+    size_t len;
+    const char16_t* str = readString16Inplace(&len);
+    if (str) {
+        pArg->setTo(str, len);
+        return 0;
+    } else {
+        *pArg = String16();
+        return UNEXPECTED_NULL;
+    }
+}
+
 const char16_t* Parcel::readString16Inplace(size_t* outLen) const
 {
     int32_t size = readInt32();
@@ -1117,10 +1927,27 @@
     return NULL;
 }
 
+status_t Parcel::readStrongBinder(sp<IBinder>* val) const
+{
+    status_t status = readNullableStrongBinder(val);
+    if (status == OK && !val->get()) {
+        status = UNEXPECTED_NULL;
+    }
+    return status;
+}
+
+status_t Parcel::readNullableStrongBinder(sp<IBinder>* val) const
+{
+    return unflatten_binder(ProcessState::self(), *this, val);
+}
+
 sp<IBinder> Parcel::readStrongBinder() const
 {
     sp<IBinder> val;
-    unflatten_binder(ProcessState::self(), *this, &val);
+    // Note that a lot of code in Android reads binders by hand with this
+    // method, and that code has historically been ok with getting nullptr
+    // back (while ignoring error codes).
+    readNullableStrongBinder(&val);
     return val;
 }
 
@@ -1131,20 +1958,23 @@
     return val;
 }
 
+status_t Parcel::readParcelable(Parcelable* parcelable) const {
+    int32_t have_parcelable = 0;
+    status_t status = readInt32(&have_parcelable);
+    if (status != OK) {
+        return status;
+    }
+    if (!have_parcelable) {
+        return UNEXPECTED_NULL;
+    }
+    return parcelable->readFromParcel(this);
+}
+
 int32_t Parcel::readExceptionCode() const
 {
-  int32_t exception_code = readAligned<int32_t>();
-  if (exception_code == EX_HAS_REPLY_HEADER) {
-    int32_t header_start = dataPosition();
-    int32_t header_size = readAligned<int32_t>();
-    // Skip over fat responses headers.  Not used (or propagated) in
-    // native code
-    setDataPosition(header_start + header_size);
-    // And fat response headers are currently only used when there are no
-    // exceptions, so return no error:
-    return 0;
-  }
-  return exception_code;
+    binder::Status status;
+    status.readFromParcel(*this);
+    return status.exceptionCode();
 }
 
 native_handle* Parcel::readNativeHandle() const
@@ -1157,6 +1987,10 @@
     if (err != NO_ERROR) return 0;
 
     native_handle* h = native_handle_create(numFds, numInts);
+    if (!h) {
+        return 0;
+    }
+
     for (int i=0 ; err==NO_ERROR && i<numFds ; i++) {
         h->data[i] = dup(readFileDescriptor());
         if (h->data[i] < 0) err = BAD_VALUE;
@@ -1174,39 +2008,65 @@
 int Parcel::readFileDescriptor() const
 {
     const flat_binder_object* flat = readObject(true);
-    if (flat) {
-        switch (flat->type) {
-            case BINDER_TYPE_FD:
-                //ALOGI("Returning file descriptor %ld from parcel %p\n", flat->handle, this);
-                return flat->handle;
-        }        
+
+    if (flat && flat->type == BINDER_TYPE_FD) {
+        return flat->handle;
     }
+
     return BAD_TYPE;
 }
 
+status_t Parcel::readUniqueFileDescriptor(base::unique_fd* val) const
+{
+    int got = readFileDescriptor();
+
+    if (got == BAD_TYPE) {
+        return BAD_TYPE;
+    }
+
+    val->reset(dup(got));
+
+    if (val->get() < 0) {
+        return BAD_VALUE;
+    }
+
+    return OK;
+}
+
+
+status_t Parcel::readUniqueFileDescriptorVector(std::unique_ptr<std::vector<base::unique_fd>>* val) const {
+    return readNullableTypedVector(val, &Parcel::readUniqueFileDescriptor);
+}
+
+status_t Parcel::readUniqueFileDescriptorVector(std::vector<base::unique_fd>* val) const {
+    return readTypedVector(val, &Parcel::readUniqueFileDescriptor);
+}
+
 status_t Parcel::readBlob(size_t len, ReadableBlob* outBlob) const
 {
-    int32_t useAshmem;
-    status_t status = readInt32(&useAshmem);
+    int32_t blobType;
+    status_t status = readInt32(&blobType);
     if (status) return status;
 
-    if (!useAshmem) {
+    if (blobType == BLOB_INPLACE) {
         ALOGV("readBlob: read in place");
         const void* ptr = readInplace(len);
         if (!ptr) return BAD_VALUE;
 
-        outBlob->init(false /*mapped*/, const_cast<void*>(ptr), len);
+        outBlob->init(-1, const_cast<void*>(ptr), len, false);
         return NO_ERROR;
     }
 
     ALOGV("readBlob: read from ashmem");
+    bool isMutable = (blobType == BLOB_ASHMEM_MUTABLE);
     int fd = readFileDescriptor();
     if (fd == int(BAD_TYPE)) return BAD_VALUE;
 
-    void* ptr = ::mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
-    if (!ptr) return NO_MEMORY;
+    void* ptr = ::mmap(NULL, len, isMutable ? PROT_READ | PROT_WRITE : PROT_READ,
+            MAP_SHARED, fd, 0);
+    if (ptr == MAP_FAILED) return NO_MEMORY;
 
-    outBlob->init(true /*mapped*/, ptr, len);
+    outBlob->init(fd, ptr, len, isMutable);
     return NO_ERROR;
 }
 
@@ -1216,8 +2076,14 @@
     const size_t len = this->readInt32();
     const size_t fd_count = this->readInt32();
 
+    if (len > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return BAD_VALUE;
+    }
+
     // payload
-    void const* const buf = this->readInplace(PAD_SIZE(len));
+    void const* const buf = this->readInplace(pad_size(len));
     if (buf == NULL)
         return BAD_VALUE;
 
@@ -1229,7 +2095,11 @@
     status_t err = NO_ERROR;
     for (size_t i=0 ; i<fd_count && err==NO_ERROR ; i++) {
         fds[i] = dup(this->readFileDescriptor());
-        if (fds[i] < 0) err = BAD_VALUE;
+        if (fds[i] < 0) {
+            err = BAD_VALUE;
+            ALOGE("dup() failed in Parcel::read, i is %zu, fds[i] is %d, fd_count is %zu, error: %s",
+                i, fds[i], fd_count, strerror(errno));
+        }
     }
 
     if (err == NO_ERROR) {
@@ -1253,19 +2123,19 @@
             // When transferring a NULL object, we don't write it into
             // the object list, so we don't want to check for it when
             // reading.
-            ALOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
+            ALOGV("readObject Setting data pos of %p to %zu", this, mDataPos);
             return obj;
         }
-        
+
         // Ensure that this object is valid...
         binder_size_t* const OBJS = mObjects;
         const size_t N = mObjectsSize;
         size_t opos = mNextObjectHint;
-        
+
         if (N > 0) {
-            ALOGV("Parcel %p looking for obj at %d, hint=%d\n",
+            ALOGV("Parcel %p looking for obj at %zu, hint=%zu",
                  this, DPOS, opos);
-            
+
             // Start at the current hint position, looking for an object at
             // the current data position.
             if (opos < N) {
@@ -1277,23 +2147,23 @@
             }
             if (OBJS[opos] == DPOS) {
                 // Found it!
-                ALOGV("Parcel found obj %d at index %d with forward search",
+                ALOGV("Parcel %p found obj %zu at index %zu with forward search",
                      this, DPOS, opos);
                 mNextObjectHint = opos+1;
-                ALOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
+                ALOGV("readObject Setting data pos of %p to %zu", this, mDataPos);
                 return obj;
             }
-        
+
             // Look backwards for it...
             while (opos > 0 && OBJS[opos] > DPOS) {
                 opos--;
             }
             if (OBJS[opos] == DPOS) {
                 // Found it!
-                ALOGV("Parcel found obj %d at index %d with backward search",
+                ALOGV("Parcel %p found obj %zu at index %zu with backward search",
                      this, DPOS, opos);
                 mNextObjectHint = opos+1;
-                ALOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
+                ALOGV("readObject Setting data pos of %p to %zu", this, mDataPos);
                 return obj;
             }
         }
@@ -1307,14 +2177,14 @@
 {
     size_t i = mObjectsSize;
     if (i > 0) {
-        //ALOGI("Closing file descriptors for %d objects...", mObjectsSize);
+        //ALOGI("Closing file descriptors for %zu objects...", i);
     }
     while (i > 0) {
         i--;
         const flat_binder_object* flat
             = reinterpret_cast<flat_binder_object*>(mData+mObjects[i]);
         if (flat->type == BINDER_TYPE_FD) {
-            //ALOGI("Closing fd: %ld\n", flat->handle);
+            //ALOGI("Closing fd: %ld", flat->handle);
             close(flat->handle);
         }
     }
@@ -1348,9 +2218,9 @@
     mError = NO_ERROR;
     mData = const_cast<uint8_t*>(data);
     mDataSize = mDataCapacity = dataSize;
-    //ALOGI("setDataReference Setting data size of %p to %lu (pid=%d)\n", this, mDataSize, getpid());
+    //ALOGI("setDataReference Setting data size of %p to %lu (pid=%d)", this, mDataSize, getpid());
     mDataPos = 0;
-    ALOGV("setDataReference Setting data pos of %p to %d\n", this, mDataPos);
+    ALOGV("setDataReference Setting data pos of %p to %zu", this, mDataPos);
     mObjects = const_cast<binder_size_t*>(objects);
     mObjectsSize = mObjectsCapacity = objectsCount;
     mNextObjectHint = 0;
@@ -1359,7 +2229,7 @@
     for (size_t i = 0; i < mObjectsSize; i++) {
         binder_size_t offset = mObjects[i];
         if (offset < minOffset) {
-            ALOGE("%s: bad object offset %"PRIu64" < %"PRIu64"\n",
+            ALOGE("%s: bad object offset %" PRIu64 " < %" PRIu64 "\n",
                   __func__, (uint64_t)offset, (uint64_t)minOffset);
             mObjectsSize = 0;
             break;
@@ -1372,7 +2242,7 @@
 void Parcel::print(TextOutput& to, uint32_t /*flags*/) const
 {
     to << "Parcel(";
-    
+
     if (errorCheck() != NO_ERROR) {
         const status_t err = errorCheck();
         to << "Error: " << (void*)(intptr_t)err << " \"" << strerror(-err) << "\"";
@@ -1391,7 +2261,7 @@
     } else {
         to << "NULL";
     }
-    
+
     to << ")";
 }
 
@@ -1405,7 +2275,7 @@
         i--;
         const flat_binder_object* flat
             = reinterpret_cast<flat_binder_object*>(data+objects[i]);
-        release_object(proc, *flat, this);
+        release_object(proc, *flat, this, &mOpenAshmemSize);
     }
 }
 
@@ -1419,7 +2289,7 @@
         i--;
         const flat_binder_object* flat
             = reinterpret_cast<flat_binder_object*>(data+objects[i]);
-        acquire_object(proc, *flat, this);
+        acquire_object(proc, *flat, this, &mOpenAshmemSize);
     }
 }
 
@@ -1432,17 +2302,38 @@
 void Parcel::freeDataNoInit()
 {
     if (mOwner) {
-        //ALOGI("Freeing data ref of %p (pid=%d)\n", this, getpid());
+        LOG_ALLOC("Parcel %p: freeing other owner data", this);
+        //ALOGI("Freeing data ref of %p (pid=%d)", this, getpid());
         mOwner(this, mData, mDataSize, mObjects, mObjectsSize, mOwnerCookie);
     } else {
+        LOG_ALLOC("Parcel %p: freeing allocated data", this);
         releaseObjects();
-        if (mData) free(mData);
+        if (mData) {
+            LOG_ALLOC("Parcel %p: freeing with %zu capacity", this, mDataCapacity);
+            pthread_mutex_lock(&gParcelGlobalAllocSizeLock);
+            if (mDataCapacity <= gParcelGlobalAllocSize) {
+              gParcelGlobalAllocSize = gParcelGlobalAllocSize - mDataCapacity;
+            } else {
+              gParcelGlobalAllocSize = 0;
+            }
+            if (gParcelGlobalAllocCount > 0) {
+              gParcelGlobalAllocCount--;
+            }
+            pthread_mutex_unlock(&gParcelGlobalAllocSizeLock);
+            free(mData);
+        }
         if (mObjects) free(mObjects);
     }
 }
 
 status_t Parcel::growData(size_t len)
 {
+    if (len > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return BAD_VALUE;
+    }
+
     size_t newSize = ((mDataSize+len)*3)/2;
     return (newSize <= mDataSize)
             ? (status_t) NO_MEMORY
@@ -1451,28 +2342,42 @@
 
 status_t Parcel::restartWrite(size_t desired)
 {
+    if (desired > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return BAD_VALUE;
+    }
+
     if (mOwner) {
         freeData();
         return continueWrite(desired);
     }
-    
+
     uint8_t* data = (uint8_t*)realloc(mData, desired);
     if (!data && desired > mDataCapacity) {
         mError = NO_MEMORY;
         return NO_MEMORY;
     }
-    
+
     releaseObjects();
-    
+
     if (data) {
+        LOG_ALLOC("Parcel %p: restart from %zu to %zu capacity", this, mDataCapacity, desired);
+        pthread_mutex_lock(&gParcelGlobalAllocSizeLock);
+        gParcelGlobalAllocSize += desired;
+        gParcelGlobalAllocSize -= mDataCapacity;
+        if (!mData) {
+            gParcelGlobalAllocCount++;
+        }
+        pthread_mutex_unlock(&gParcelGlobalAllocSizeLock);
         mData = data;
         mDataCapacity = desired;
     }
-    
+
     mDataSize = mDataPos = 0;
-    ALOGV("restartWrite Setting data size of %p to %d\n", this, mDataSize);
-    ALOGV("restartWrite Setting data pos of %p to %d\n", this, mDataPos);
-        
+    ALOGV("restartWrite Setting data size of %p to %zu", this, mDataSize);
+    ALOGV("restartWrite Setting data pos of %p to %zu", this, mDataPos);
+
     free(mObjects);
     mObjects = NULL;
     mObjectsSize = mObjectsCapacity = 0;
@@ -1480,12 +2385,18 @@
     mHasFds = false;
     mFdsKnown = true;
     mAllowFds = true;
-    
+
     return NO_ERROR;
 }
 
 status_t Parcel::continueWrite(size_t desired)
 {
+    if (desired > INT32_MAX) {
+        // don't accept size_t values which may have come from an
+        // inadvertent conversion from a negative int.
+        return BAD_VALUE;
+    }
+
     // If shrinking, first adjust for any objects that appear
     // after the new data size.
     size_t objectsSize = mObjectsSize;
@@ -1500,7 +2411,7 @@
             }
         }
     }
-    
+
     if (mOwner) {
         // If the size is going to zero, just release the owner's data.
         if (desired == 0) {
@@ -1516,9 +2427,9 @@
             return NO_MEMORY;
         }
         binder_size_t* objects = NULL;
-        
+
         if (objectsSize) {
-            objects = (binder_size_t*)malloc(objectsSize*sizeof(binder_size_t));
+            objects = (binder_size_t*)calloc(objectsSize, sizeof(binder_size_t));
             if (!objects) {
                 free(data);
 
@@ -1533,21 +2444,27 @@
             acquireObjects();
             mObjectsSize = oldObjectsSize;
         }
-        
+
         if (mData) {
             memcpy(data, mData, mDataSize < desired ? mDataSize : desired);
         }
         if (objects && mObjects) {
             memcpy(objects, mObjects, objectsSize*sizeof(binder_size_t));
         }
-        //ALOGI("Freeing data ref of %p (pid=%d)\n", this, getpid());
+        //ALOGI("Freeing data ref of %p (pid=%d)", this, getpid());
         mOwner(this, mData, mDataSize, mObjects, mObjectsSize, mOwnerCookie);
         mOwner = NULL;
 
+        LOG_ALLOC("Parcel %p: taking ownership of %zu capacity", this, desired);
+        pthread_mutex_lock(&gParcelGlobalAllocSizeLock);
+        gParcelGlobalAllocSize += desired;
+        gParcelGlobalAllocCount++;
+        pthread_mutex_unlock(&gParcelGlobalAllocSizeLock);
+
         mData = data;
         mObjects = objects;
         mDataSize = (mDataSize < desired) ? mDataSize : desired;
-        ALOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
+        ALOGV("continueWrite Setting data size of %p to %zu", this, mDataSize);
         mDataCapacity = desired;
         mObjectsSize = mObjectsCapacity = objectsSize;
         mNextObjectHint = 0;
@@ -1563,7 +2480,7 @@
                     // will need to rescan because we may have lopped off the only FDs
                     mFdsKnown = false;
                 }
-                release_object(proc, *flat, this);
+                release_object(proc, *flat, this, &mOpenAshmemSize);
             }
             binder_size_t* objects =
                 (binder_size_t*)realloc(mObjects, objectsSize*sizeof(binder_size_t));
@@ -1578,6 +2495,12 @@
         if (desired > mDataCapacity) {
             uint8_t* data = (uint8_t*)realloc(mData, desired);
             if (data) {
+                LOG_ALLOC("Parcel %p: continue from %zu to %zu capacity", this, mDataCapacity,
+                        desired);
+                pthread_mutex_lock(&gParcelGlobalAllocSizeLock);
+                gParcelGlobalAllocSize += desired;
+                gParcelGlobalAllocSize -= mDataCapacity;
+                pthread_mutex_unlock(&gParcelGlobalAllocSizeLock);
                 mData = data;
                 mDataCapacity = desired;
             } else if (desired > mDataCapacity) {
@@ -1587,14 +2510,14 @@
         } else {
             if (mDataSize > desired) {
                 mDataSize = desired;
-                ALOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
+                ALOGV("continueWrite Setting data size of %p to %zu", this, mDataSize);
             }
             if (mDataPos > desired) {
                 mDataPos = desired;
-                ALOGV("continueWrite Setting data pos of %p to %d\n", this, mDataPos);
+                ALOGV("continueWrite Setting data pos of %p to %zu", this, mDataPos);
             }
         }
-        
+
     } else {
         // This is the first data.  Easy!
         uint8_t* data = (uint8_t*)malloc(desired);
@@ -1607,11 +2530,17 @@
              && mObjectsCapacity == 0)) {
             ALOGE("continueWrite: %zu/%p/%zu/%zu", mDataCapacity, mObjects, mObjectsCapacity, desired);
         }
-        
+
+        LOG_ALLOC("Parcel %p: allocating with %zu capacity", this, desired);
+        pthread_mutex_lock(&gParcelGlobalAllocSizeLock);
+        gParcelGlobalAllocSize += desired;
+        gParcelGlobalAllocCount++;
+        pthread_mutex_unlock(&gParcelGlobalAllocSizeLock);
+
         mData = data;
         mDataSize = mDataPos = 0;
-        ALOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
-        ALOGV("continueWrite Setting data pos of %p to %d\n", this, mDataPos);
+        ALOGV("continueWrite Setting data size of %p to %zu", this, mDataSize);
+        ALOGV("continueWrite Setting data pos of %p to %zu", this, mDataPos);
         mDataCapacity = desired;
     }
 
@@ -1620,13 +2549,14 @@
 
 void Parcel::initState()
 {
+    LOG_ALLOC("Parcel %p: initState", this);
     mError = NO_ERROR;
     mData = 0;
     mDataSize = 0;
     mDataCapacity = 0;
     mDataPos = 0;
-    ALOGV("initState Setting data size of %p to %d\n", this, mDataSize);
-    ALOGV("initState Setting data pos of %p to %d\n", this, mDataPos);
+    ALOGV("initState Setting data size of %p to %zu", this, mDataSize);
+    ALOGV("initState Setting data pos of %p to %zu", this, mDataPos);
     mObjects = NULL;
     mObjectsSize = 0;
     mObjectsCapacity = 0;
@@ -1635,6 +2565,7 @@
     mFdsKnown = true;
     mAllowFds = true;
     mOwner = NULL;
+    mOpenAshmemSize = 0;
 }
 
 void Parcel::scanForFds() const
@@ -1652,10 +2583,23 @@
     mFdsKnown = true;
 }
 
+size_t Parcel::getBlobAshmemSize() const
+{
+    // This used to return the size of all blobs that were written to ashmem, now we're returning
+    // the ashmem currently referenced by this Parcel, which should be equivalent.
+    // TODO: Remove method once ABI can be changed.
+    return mOpenAshmemSize;
+}
+
+size_t Parcel::getOpenAshmemSize() const
+{
+    return mOpenAshmemSize;
+}
+
 // --- Parcel::Blob ---
 
 Parcel::Blob::Blob() :
-        mMapped(false), mData(NULL), mSize(0) {
+        mFd(-1), mData(NULL), mSize(0), mMutable(false) {
 }
 
 Parcel::Blob::~Blob() {
@@ -1663,22 +2607,24 @@
 }
 
 void Parcel::Blob::release() {
-    if (mMapped && mData) {
+    if (mFd != -1 && mData) {
         ::munmap(mData, mSize);
     }
     clear();
 }
 
-void Parcel::Blob::init(bool mapped, void* data, size_t size) {
-    mMapped = mapped;
+void Parcel::Blob::init(int fd, void* data, size_t size, bool isMutable) {
+    mFd = fd;
     mData = data;
     mSize = size;
+    mMutable = isMutable;
 }
 
 void Parcel::Blob::clear() {
-    mMapped = false;
+    mFd = -1;
     mData = NULL;
     mSize = 0;
+    mMutable = false;
 }
 
 }; // namespace android
diff --git a/libs/binder/PersistableBundle.cpp b/libs/binder/PersistableBundle.cpp
new file mode 100644
index 0000000..e7078ba
--- /dev/null
+++ b/libs/binder/PersistableBundle.cpp
@@ -0,0 +1,490 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "PersistableBundle"
+
+#include <binder/PersistableBundle.h>
+
+#include <limits>
+
+#include <binder/IBinder.h>
+#include <binder/Parcel.h>
+#include <log/log.h>
+#include <utils/Errors.h>
+
+using android::BAD_TYPE;
+using android::BAD_VALUE;
+using android::NO_ERROR;
+using android::Parcel;
+using android::sp;
+using android::status_t;
+using android::UNEXPECTED_NULL;
+using std::map;
+using std::set;
+using std::vector;
+
+enum {
+    // Keep in sync with BUNDLE_MAGIC in frameworks/base/core/java/android/os/BaseBundle.java.
+    BUNDLE_MAGIC = 0x4C444E42,
+};
+
+enum {
+    // Keep in sync with frameworks/base/core/java/android/os/Parcel.java.
+    VAL_STRING = 0,
+    VAL_INTEGER = 1,
+    VAL_LONG = 6,
+    VAL_DOUBLE = 8,
+    VAL_BOOLEAN = 9,
+    VAL_STRINGARRAY = 14,
+    VAL_INTARRAY = 18,
+    VAL_LONGARRAY = 19,
+    VAL_BOOLEANARRAY = 23,
+    VAL_PERSISTABLEBUNDLE = 25,
+    VAL_DOUBLEARRAY = 28,
+};
+
+namespace {
+template <typename T>
+bool getValue(const android::String16& key, T* out, const map<android::String16, T>& map) {
+    const auto& it = map.find(key);
+    if (it == map.end()) return false;
+    *out = it->second;
+    return true;
+}
+
+template <typename T>
+set<android::String16> getKeys(const map<android::String16, T>& map) {
+    if (map.empty()) return set<android::String16>();
+    set<android::String16> keys;
+    for (const auto& key_value_pair : map) {
+        keys.emplace(key_value_pair.first);
+    }
+    return keys;
+}
+}  // namespace
+
+namespace android {
+
+namespace os {
+
+#define RETURN_IF_FAILED(calledOnce)                                     \
+    {                                                                    \
+        status_t returnStatus = calledOnce;                              \
+        if (returnStatus) {                                              \
+            ALOGE("Failed at %s:%d (%s)", __FILE__, __LINE__, __func__); \
+            return returnStatus;                                         \
+         }                                                               \
+    }
+
+#define RETURN_IF_ENTRY_ERASED(map, key)                                 \
+    {                                                                    \
+        size_t num_erased = (map).erase(key);                            \
+        if (num_erased) {                                                \
+            ALOGE("Failed at %s:%d (%s)", __FILE__, __LINE__, __func__); \
+            return num_erased;                                           \
+         }                                                               \
+    }
+
+status_t PersistableBundle::writeToParcel(Parcel* parcel) const {
+    /*
+     * Keep implementation in sync with writeToParcelInner() in
+     * frameworks/base/core/java/android/os/BaseBundle.java.
+     */
+
+    // Special case for empty bundles.
+    if (empty()) {
+        RETURN_IF_FAILED(parcel->writeInt32(0));
+        return NO_ERROR;
+    }
+
+    size_t length_pos = parcel->dataPosition();
+    RETURN_IF_FAILED(parcel->writeInt32(1));  // dummy, will hold length
+    RETURN_IF_FAILED(parcel->writeInt32(BUNDLE_MAGIC));
+
+    size_t start_pos = parcel->dataPosition();
+    RETURN_IF_FAILED(writeToParcelInner(parcel));
+    size_t end_pos = parcel->dataPosition();
+
+    // Backpatch length. This length value includes the length header.
+    parcel->setDataPosition(length_pos);
+    size_t length = end_pos - start_pos;
+    if (length > std::numeric_limits<int32_t>::max()) {
+        ALOGE("Parcel length (%zu) too large to store in 32-bit signed int", length);
+        return BAD_VALUE;
+    }
+    RETURN_IF_FAILED(parcel->writeInt32(static_cast<int32_t>(length)));
+    parcel->setDataPosition(end_pos);
+    return NO_ERROR;
+}
+
+status_t PersistableBundle::readFromParcel(const Parcel* parcel) {
+    /*
+     * Keep implementation in sync with readFromParcelInner() in
+     * frameworks/base/core/java/android/os/BaseBundle.java.
+     */
+    int32_t length = parcel->readInt32();
+    if (length < 0) {
+        ALOGE("Bad length in parcel: %d", length);
+        return UNEXPECTED_NULL;
+    }
+
+    return readFromParcelInner(parcel, static_cast<size_t>(length));
+}
+
+bool PersistableBundle::empty() const {
+    return size() == 0u;
+}
+
+size_t PersistableBundle::size() const {
+    return (mBoolMap.size() +
+            mIntMap.size() +
+            mLongMap.size() +
+            mDoubleMap.size() +
+            mStringMap.size() +
+            mBoolVectorMap.size() +
+            mIntVectorMap.size() +
+            mLongVectorMap.size() +
+            mDoubleVectorMap.size() +
+            mStringVectorMap.size() +
+            mPersistableBundleMap.size());
+}
+
+size_t PersistableBundle::erase(const String16& key) {
+    RETURN_IF_ENTRY_ERASED(mBoolMap, key);
+    RETURN_IF_ENTRY_ERASED(mIntMap, key);
+    RETURN_IF_ENTRY_ERASED(mLongMap, key);
+    RETURN_IF_ENTRY_ERASED(mDoubleMap, key);
+    RETURN_IF_ENTRY_ERASED(mStringMap, key);
+    RETURN_IF_ENTRY_ERASED(mBoolVectorMap, key);
+    RETURN_IF_ENTRY_ERASED(mIntVectorMap, key);
+    RETURN_IF_ENTRY_ERASED(mLongVectorMap, key);
+    RETURN_IF_ENTRY_ERASED(mDoubleVectorMap, key);
+    RETURN_IF_ENTRY_ERASED(mStringVectorMap, key);
+    return mPersistableBundleMap.erase(key);
+}
+
+void PersistableBundle::putBoolean(const String16& key, bool value) {
+    erase(key);
+    mBoolMap[key] = value;
+}
+
+void PersistableBundle::putInt(const String16& key, int32_t value) {
+    erase(key);
+    mIntMap[key] = value;
+}
+
+void PersistableBundle::putLong(const String16& key, int64_t value) {
+    erase(key);
+    mLongMap[key] = value;
+}
+
+void PersistableBundle::putDouble(const String16& key, double value) {
+    erase(key);
+    mDoubleMap[key] = value;
+}
+
+void PersistableBundle::putString(const String16& key, const String16& value) {
+    erase(key);
+    mStringMap[key] = value;
+}
+
+void PersistableBundle::putBooleanVector(const String16& key, const vector<bool>& value) {
+    erase(key);
+    mBoolVectorMap[key] = value;
+}
+
+void PersistableBundle::putIntVector(const String16& key, const vector<int32_t>& value) {
+    erase(key);
+    mIntVectorMap[key] = value;
+}
+
+void PersistableBundle::putLongVector(const String16& key, const vector<int64_t>& value) {
+    erase(key);
+    mLongVectorMap[key] = value;
+}
+
+void PersistableBundle::putDoubleVector(const String16& key, const vector<double>& value) {
+    erase(key);
+    mDoubleVectorMap[key] = value;
+}
+
+void PersistableBundle::putStringVector(const String16& key, const vector<String16>& value) {
+    erase(key);
+    mStringVectorMap[key] = value;
+}
+
+void PersistableBundle::putPersistableBundle(const String16& key, const PersistableBundle& value) {
+    erase(key);
+    mPersistableBundleMap[key] = value;
+}
+
+bool PersistableBundle::getBoolean(const String16& key, bool* out) const {
+    return getValue(key, out, mBoolMap);
+}
+
+bool PersistableBundle::getInt(const String16& key, int32_t* out) const {
+    return getValue(key, out, mIntMap);
+}
+
+bool PersistableBundle::getLong(const String16& key, int64_t* out) const {
+    return getValue(key, out, mLongMap);
+}
+
+bool PersistableBundle::getDouble(const String16& key, double* out) const {
+    return getValue(key, out, mDoubleMap);
+}
+
+bool PersistableBundle::getString(const String16& key, String16* out) const {
+    return getValue(key, out, mStringMap);
+}
+
+bool PersistableBundle::getBooleanVector(const String16& key, vector<bool>* out) const {
+    return getValue(key, out, mBoolVectorMap);
+}
+
+bool PersistableBundle::getIntVector(const String16& key, vector<int32_t>* out) const {
+    return getValue(key, out, mIntVectorMap);
+}
+
+bool PersistableBundle::getLongVector(const String16& key, vector<int64_t>* out) const {
+    return getValue(key, out, mLongVectorMap);
+}
+
+bool PersistableBundle::getDoubleVector(const String16& key, vector<double>* out) const {
+    return getValue(key, out, mDoubleVectorMap);
+}
+
+bool PersistableBundle::getStringVector(const String16& key, vector<String16>* out) const {
+    return getValue(key, out, mStringVectorMap);
+}
+
+bool PersistableBundle::getPersistableBundle(const String16& key, PersistableBundle* out) const {
+    return getValue(key, out, mPersistableBundleMap);
+}
+
+set<String16> PersistableBundle::getBooleanKeys() const {
+    return getKeys(mBoolMap);
+}
+
+set<String16> PersistableBundle::getIntKeys() const {
+    return getKeys(mIntMap);
+}
+
+set<String16> PersistableBundle::getLongKeys() const {
+    return getKeys(mLongMap);
+}
+
+set<String16> PersistableBundle::getDoubleKeys() const {
+    return getKeys(mDoubleMap);
+}
+
+set<String16> PersistableBundle::getStringKeys() const {
+    return getKeys(mStringMap);
+}
+
+set<String16> PersistableBundle::getBooleanVectorKeys() const {
+    return getKeys(mBoolVectorMap);
+}
+
+set<String16> PersistableBundle::getIntVectorKeys() const {
+    return getKeys(mIntVectorMap);
+}
+
+set<String16> PersistableBundle::getLongVectorKeys() const {
+    return getKeys(mLongVectorMap);
+}
+
+set<String16> PersistableBundle::getDoubleVectorKeys() const {
+    return getKeys(mDoubleVectorMap);
+}
+
+set<String16> PersistableBundle::getStringVectorKeys() const {
+    return getKeys(mStringVectorMap);
+}
+
+set<String16> PersistableBundle::getPersistableBundleKeys() const {
+    return getKeys(mPersistableBundleMap);
+}
+
+status_t PersistableBundle::writeToParcelInner(Parcel* parcel) const {
+    /*
+     * To keep this implementation in sync with writeArrayMapInternal() in
+     * frameworks/base/core/java/android/os/Parcel.java, the number of key
+     * value pairs must be written into the parcel before writing the key-value
+     * pairs themselves.
+     */
+    size_t num_entries = size();
+    if (num_entries > std::numeric_limits<int32_t>::max()) {
+        ALOGE("The size of this PersistableBundle (%zu) too large to store in 32-bit signed int",
+              num_entries);
+        return BAD_VALUE;
+    }
+    RETURN_IF_FAILED(parcel->writeInt32(static_cast<int32_t>(num_entries)));
+
+    for (const auto& key_val_pair : mBoolMap) {
+        RETURN_IF_FAILED(parcel->writeString16(key_val_pair.first));
+        RETURN_IF_FAILED(parcel->writeInt32(VAL_BOOLEAN));
+        RETURN_IF_FAILED(parcel->writeBool(key_val_pair.second));
+    }
+    for (const auto& key_val_pair : mIntMap) {
+        RETURN_IF_FAILED(parcel->writeString16(key_val_pair.first));
+        RETURN_IF_FAILED(parcel->writeInt32(VAL_INTEGER));
+        RETURN_IF_FAILED(parcel->writeInt32(key_val_pair.second));
+    }
+    for (const auto& key_val_pair : mLongMap) {
+        RETURN_IF_FAILED(parcel->writeString16(key_val_pair.first));
+        RETURN_IF_FAILED(parcel->writeInt32(VAL_LONG));
+        RETURN_IF_FAILED(parcel->writeInt64(key_val_pair.second));
+    }
+    for (const auto& key_val_pair : mDoubleMap) {
+        RETURN_IF_FAILED(parcel->writeString16(key_val_pair.first));
+        RETURN_IF_FAILED(parcel->writeInt32(VAL_DOUBLE));
+        RETURN_IF_FAILED(parcel->writeDouble(key_val_pair.second));
+    }
+    for (const auto& key_val_pair : mStringMap) {
+        RETURN_IF_FAILED(parcel->writeString16(key_val_pair.first));
+        RETURN_IF_FAILED(parcel->writeInt32(VAL_STRING));
+        RETURN_IF_FAILED(parcel->writeString16(key_val_pair.second));
+    }
+    for (const auto& key_val_pair : mBoolVectorMap) {
+        RETURN_IF_FAILED(parcel->writeString16(key_val_pair.first));
+        RETURN_IF_FAILED(parcel->writeInt32(VAL_BOOLEANARRAY));
+        RETURN_IF_FAILED(parcel->writeBoolVector(key_val_pair.second));
+    }
+    for (const auto& key_val_pair : mIntVectorMap) {
+        RETURN_IF_FAILED(parcel->writeString16(key_val_pair.first));
+        RETURN_IF_FAILED(parcel->writeInt32(VAL_INTARRAY));
+        RETURN_IF_FAILED(parcel->writeInt32Vector(key_val_pair.second));
+    }
+    for (const auto& key_val_pair : mLongVectorMap) {
+        RETURN_IF_FAILED(parcel->writeString16(key_val_pair.first));
+        RETURN_IF_FAILED(parcel->writeInt32(VAL_LONGARRAY));
+        RETURN_IF_FAILED(parcel->writeInt64Vector(key_val_pair.second));
+    }
+    for (const auto& key_val_pair : mDoubleVectorMap) {
+        RETURN_IF_FAILED(parcel->writeString16(key_val_pair.first));
+        RETURN_IF_FAILED(parcel->writeInt32(VAL_DOUBLEARRAY));
+        RETURN_IF_FAILED(parcel->writeDoubleVector(key_val_pair.second));
+    }
+    for (const auto& key_val_pair : mStringVectorMap) {
+        RETURN_IF_FAILED(parcel->writeString16(key_val_pair.first));
+        RETURN_IF_FAILED(parcel->writeInt32(VAL_STRINGARRAY));
+        RETURN_IF_FAILED(parcel->writeString16Vector(key_val_pair.second));
+    }
+    for (const auto& key_val_pair : mPersistableBundleMap) {
+        RETURN_IF_FAILED(parcel->writeString16(key_val_pair.first));
+        RETURN_IF_FAILED(parcel->writeInt32(VAL_PERSISTABLEBUNDLE));
+        RETURN_IF_FAILED(key_val_pair.second.writeToParcel(parcel));
+    }
+    return NO_ERROR;
+}
+
+status_t PersistableBundle::readFromParcelInner(const Parcel* parcel, size_t length) {
+    /*
+     * Note: we don't actually use length for anything other than an empty PersistableBundle
+     * check, since we do not actually need to copy in an entire Parcel, unlike in the Java
+     * implementation.
+     */
+    if (length == 0) {
+        // Empty PersistableBundle or end of data.
+        return NO_ERROR;
+    }
+
+    int32_t magic;
+    RETURN_IF_FAILED(parcel->readInt32(&magic));
+    if (magic != BUNDLE_MAGIC) {
+        ALOGE("Bad magic number for PersistableBundle: 0x%08x", magic);
+        return BAD_VALUE;
+    }
+
+    /*
+     * To keep this implementation in sync with unparcel() in
+     * frameworks/base/core/java/android/os/BaseBundle.java, the number of
+     * key-value pairs must be read from the parcel before reading the key-value
+     * pairs themselves.
+     */
+    int32_t num_entries;
+    RETURN_IF_FAILED(parcel->readInt32(&num_entries));
+
+    for (; num_entries > 0; --num_entries) {
+        String16 key;
+        int32_t value_type;
+        RETURN_IF_FAILED(parcel->readString16(&key));
+        RETURN_IF_FAILED(parcel->readInt32(&value_type));
+
+        /*
+         * We assume that both the C++ and Java APIs ensure that all keys in a PersistableBundle
+         * are unique.
+         */
+        switch (value_type) {
+            case VAL_STRING: {
+                RETURN_IF_FAILED(parcel->readString16(&mStringMap[key]));
+                break;
+            }
+            case VAL_INTEGER: {
+                RETURN_IF_FAILED(parcel->readInt32(&mIntMap[key]));
+                break;
+            }
+            case VAL_LONG: {
+                RETURN_IF_FAILED(parcel->readInt64(&mLongMap[key]));
+                break;
+            }
+            case VAL_DOUBLE: {
+                RETURN_IF_FAILED(parcel->readDouble(&mDoubleMap[key]));
+                break;
+            }
+            case VAL_BOOLEAN: {
+                RETURN_IF_FAILED(parcel->readBool(&mBoolMap[key]));
+                break;
+            }
+            case VAL_STRINGARRAY: {
+                RETURN_IF_FAILED(parcel->readString16Vector(&mStringVectorMap[key]));
+                break;
+            }
+            case VAL_INTARRAY: {
+                RETURN_IF_FAILED(parcel->readInt32Vector(&mIntVectorMap[key]));
+                break;
+            }
+            case VAL_LONGARRAY: {
+                RETURN_IF_FAILED(parcel->readInt64Vector(&mLongVectorMap[key]));
+                break;
+            }
+            case VAL_BOOLEANARRAY: {
+                RETURN_IF_FAILED(parcel->readBoolVector(&mBoolVectorMap[key]));
+                break;
+            }
+            case VAL_PERSISTABLEBUNDLE: {
+                RETURN_IF_FAILED(mPersistableBundleMap[key].readFromParcel(parcel));
+                break;
+            }
+            case VAL_DOUBLEARRAY: {
+                RETURN_IF_FAILED(parcel->readDoubleVector(&mDoubleVectorMap[key]));
+                break;
+            }
+            default: {
+                ALOGE("Unrecognized type: %d", value_type);
+                return BAD_TYPE;
+                break;
+            }
+        }
+    }
+
+    return NO_ERROR;
+}
+
+}  // namespace os
+
+}  // namespace android
diff --git a/libs/binder/ProcessInfoService.cpp b/libs/binder/ProcessInfoService.cpp
new file mode 100644
index 0000000..fb28643
--- /dev/null
+++ b/libs/binder/ProcessInfoService.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <binder/ProcessInfoService.h>
+#include <binder/IServiceManager.h>
+
+#include <utils/Log.h>
+#include <utils/String16.h>
+
+namespace android {
+
+ProcessInfoService::ProcessInfoService() {
+    updateBinderLocked();
+}
+
+status_t ProcessInfoService::getProcessStatesImpl(size_t length, /*in*/ int32_t* pids,
+        /*out*/ int32_t* states) {
+    status_t err = NO_ERROR;
+    sp<IProcessInfoService> pis;
+    mProcessInfoLock.lock();
+    pis = mProcessInfoService;
+    mProcessInfoLock.unlock();
+
+    for (int i = 0; i < BINDER_ATTEMPT_LIMIT; i++) {
+
+        if (pis != NULL) {
+            err = pis->getProcessStatesFromPids(length, /*in*/ pids, /*out*/ states);
+            if (err == NO_ERROR) return NO_ERROR; // success
+            if (IInterface::asBinder(pis)->isBinderAlive()) return err;
+        }
+        sleep(1);
+
+        mProcessInfoLock.lock();
+        if (pis == mProcessInfoService) {
+            updateBinderLocked();
+        }
+        pis = mProcessInfoService;
+        mProcessInfoLock.unlock();
+    }
+
+    ALOGW("%s: Could not retrieve process states from ProcessInfoService after %d retries.",
+            __FUNCTION__, BINDER_ATTEMPT_LIMIT);
+
+    return TIMED_OUT;
+}
+
+void ProcessInfoService::updateBinderLocked() {
+    const sp<IServiceManager> sm(defaultServiceManager());
+    if (sm != NULL) {
+        const String16 name("processinfo");
+        mProcessInfoService = interface_cast<IProcessInfoService>(sm->checkService(name));
+    }
+}
+
+ANDROID_SINGLETON_STATIC_INSTANCE(ProcessInfoService);
+
+}; // namespace android
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp
index 303d6cf..4748979 100644
--- a/libs/binder/ProcessState.cpp
+++ b/libs/binder/ProcessState.cpp
@@ -42,16 +42,17 @@
 #include <sys/stat.h>
 
 #define BINDER_VM_SIZE ((1*1024*1024) - (4096 *2))
+#define DEFAULT_MAX_BINDER_THREADS 15
 
 
 // ---------------------------------------------------------------------------
 
 namespace android {
- 
+
 class PoolThread : public Thread
 {
 public:
-    PoolThread(bool isMain)
+    explicit PoolThread(bool isMain)
         : mIsMain(isMain)
     {
     }
@@ -294,7 +295,9 @@
 
 status_t ProcessState::setThreadPoolMaxThreadCount(size_t maxThreads) {
     status_t result = NO_ERROR;
-    if (ioctl(mDriverFD, BINDER_SET_MAX_THREADS, &maxThreads) == -1) {
+    if (ioctl(mDriverFD, BINDER_SET_MAX_THREADS, &maxThreads) != -1) {
+        mMaxThreads = maxThreads;
+    } else {
         result = -errno;
         ALOGE("Binder ioctl to set max threads failed: %s", strerror(-result));
     }
@@ -307,9 +310,8 @@
 
 static int open_driver()
 {
-    int fd = open("/dev/binder", O_RDWR);
+    int fd = open("/dev/binder", O_RDWR | O_CLOEXEC);
     if (fd >= 0) {
-        fcntl(fd, F_SETFD, FD_CLOEXEC);
         int vers = 0;
         status_t result = ioctl(fd, BINDER_VERSION, &vers);
         if (result == -1) {
@@ -322,7 +324,7 @@
             close(fd);
             fd = -1;
         }
-        size_t maxThreads = 15;
+        size_t maxThreads = DEFAULT_MAX_BINDER_THREADS;
         result = ioctl(fd, BINDER_SET_MAX_THREADS, &maxThreads);
         if (result == -1) {
             ALOGE("Binder ioctl to set max threads failed: %s", strerror(errno));
@@ -336,6 +338,10 @@
 ProcessState::ProcessState()
     : mDriverFD(open_driver())
     , mVMStart(MAP_FAILED)
+    , mThreadCountLock(PTHREAD_MUTEX_INITIALIZER)
+    , mThreadCountDecrement(PTHREAD_COND_INITIALIZER)
+    , mExecutingThreadsCount(0)
+    , mMaxThreads(DEFAULT_MAX_BINDER_THREADS)
     , mManagesContexts(false)
     , mBinderContextCheckFunc(NULL)
     , mBinderContextUserData(NULL)
@@ -343,10 +349,6 @@
     , mThreadPoolSeq(1)
 {
     if (mDriverFD >= 0) {
-        // XXX Ideally, there should be a specific define for whether we
-        // have mmap (or whether we could possibly have the kernel module
-        // availabla).
-#if !defined(HAVE_WIN32_IPC)
         // mmap the binder, providing a chunk of virtual address space to receive transactions.
         mVMStart = mmap(0, BINDER_VM_SIZE, PROT_READ, MAP_PRIVATE | MAP_NORESERVE, mDriverFD, 0);
         if (mVMStart == MAP_FAILED) {
@@ -355,9 +357,6 @@
             close(mDriverFD);
             mDriverFD = -1;
         }
-#else
-        mDriverFD = -1;
-#endif
     }
 
     LOG_ALWAYS_FATAL_IF(mDriverFD < 0, "Binder driver could not be opened.  Terminating.");
@@ -365,6 +364,13 @@
 
 ProcessState::~ProcessState()
 {
+    if (mDriverFD >= 0) {
+        if (mVMStart != MAP_FAILED) {
+            munmap(mVMStart, BINDER_VM_SIZE);
+        }
+        close(mDriverFD);
+    }
+    mDriverFD = -1;
 }
         
 }; // namespace android
diff --git a/libs/binder/Static.cpp b/libs/binder/Static.cpp
index 2062692..f0613d1 100644
--- a/libs/binder/Static.cpp
+++ b/libs/binder/Static.cpp
@@ -48,7 +48,7 @@
 class FdTextOutput : public BufferedTextOutput
 {
 public:
-    FdTextOutput(int fd) : BufferedTextOutput(MULTITHREADED), mFD(fd) { }
+    explicit FdTextOutput(int fd) : BufferedTextOutput(MULTITHREADED), mFD(fd) { }
     virtual ~FdTextOutput() { };
 
 protected:
@@ -90,7 +90,7 @@
 
 static LibBinderIPCtStatics gIPCStatics;
 
-// ------------ ServiceManager.cpp
+// ------------ IServiceManager.cpp
 
 Mutex gDefaultServiceManagerLock;
 sp<IServiceManager> gDefaultServiceManager;
diff --git a/libs/binder/Status.cpp b/libs/binder/Status.cpp
new file mode 100644
index 0000000..8466863
--- /dev/null
+++ b/libs/binder/Status.cpp
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <binder/Status.h>
+
+namespace android {
+namespace binder {
+
+Status Status::ok() {
+    return Status();
+}
+
+Status Status::fromExceptionCode(int32_t exceptionCode) {
+    return Status(exceptionCode, OK);
+}
+
+Status Status::fromExceptionCode(int32_t exceptionCode,
+                                 const String8& message) {
+    return Status(exceptionCode, OK, message);
+}
+
+Status Status::fromExceptionCode(int32_t exceptionCode,
+                                 const char* message) {
+    return fromExceptionCode(exceptionCode, String8(message));
+}
+
+Status Status::fromServiceSpecificError(int32_t serviceSpecificErrorCode) {
+    return Status(EX_SERVICE_SPECIFIC, serviceSpecificErrorCode);
+}
+
+Status Status::fromServiceSpecificError(int32_t serviceSpecificErrorCode,
+                                        const String8& message) {
+    return Status(EX_SERVICE_SPECIFIC, serviceSpecificErrorCode, message);
+}
+
+Status Status::fromServiceSpecificError(int32_t serviceSpecificErrorCode,
+                                        const char* message) {
+    return fromServiceSpecificError(serviceSpecificErrorCode, String8(message));
+}
+
+Status Status::fromStatusT(status_t status) {
+    Status ret;
+    ret.setFromStatusT(status);
+    return ret;
+}
+
+Status::Status(int32_t exceptionCode, int32_t errorCode)
+    : mException(exceptionCode),
+      mErrorCode(errorCode) {}
+
+Status::Status(int32_t exceptionCode, int32_t errorCode, const String8& message)
+    : mException(exceptionCode),
+      mErrorCode(errorCode),
+      mMessage(message) {}
+
+status_t Status::readFromParcel(const Parcel& parcel) {
+    status_t status = parcel.readInt32(&mException);
+    if (status != OK) {
+        setFromStatusT(status);
+        return status;
+    }
+
+    // Skip over fat response headers.  Not used (or propagated) in native code.
+    if (mException == EX_HAS_REPLY_HEADER) {
+        // Note that the header size includes the 4 byte size field.
+        const int32_t header_start = parcel.dataPosition();
+        int32_t header_size;
+        status = parcel.readInt32(&header_size);
+        if (status != OK) {
+            setFromStatusT(status);
+            return status;
+        }
+        parcel.setDataPosition(header_start + header_size);
+        // And fat response headers are currently only used when there are no
+        // exceptions, so act like there was no error.
+        mException = EX_NONE;
+    }
+
+    if (mException == EX_NONE) {
+        return status;
+    }
+
+    // The remote threw an exception.  Get the message back.
+    String16 message;
+    status = parcel.readString16(&message);
+    if (status != OK) {
+        setFromStatusT(status);
+        return status;
+    }
+    mMessage = String8(message);
+
+    if (mException == EX_SERVICE_SPECIFIC) {
+        status = parcel.readInt32(&mErrorCode);
+    }
+    if (status != OK) {
+        setFromStatusT(status);
+        return status;
+    }
+
+    return status;
+}
+
+status_t Status::writeToParcel(Parcel* parcel) const {
+    // Something really bad has happened, and we're not going to even
+    // try returning rich error data.
+    if (mException == EX_TRANSACTION_FAILED) {
+        return mErrorCode;
+    }
+
+    status_t status = parcel->writeInt32(mException);
+    if (status != OK) { return status; }
+    if (mException == EX_NONE) {
+        // We have no more information to write.
+        return status;
+    }
+    status = parcel->writeString16(String16(mMessage));
+    if (mException != EX_SERVICE_SPECIFIC) {
+        // We have no more information to write.
+        return status;
+    }
+    status = parcel->writeInt32(mErrorCode);
+    return status;
+}
+
+void Status::setException(int32_t ex, const String8& message) {
+    mException = ex;
+    mErrorCode = NO_ERROR;  // an exception, not a transaction failure.
+    mMessage.setTo(message);
+}
+
+void Status::setServiceSpecificError(int32_t errorCode, const String8& message) {
+    setException(EX_SERVICE_SPECIFIC, message);
+    mErrorCode = errorCode;
+}
+
+void Status::setFromStatusT(status_t status) {
+    mException = (status == NO_ERROR) ? EX_NONE : EX_TRANSACTION_FAILED;
+    mErrorCode = status;
+    mMessage.clear();
+}
+
+String8 Status::toString8() const {
+    String8 ret;
+    if (mException == EX_NONE) {
+        ret.append("No error");
+    } else {
+        ret.appendFormat("Status(%d): '", mException);
+        if (mException == EX_SERVICE_SPECIFIC ||
+            mException == EX_TRANSACTION_FAILED) {
+            ret.appendFormat("%d: ", mErrorCode);
+        }
+        ret.append(String8(mMessage));
+        ret.append("'");
+    }
+    return ret;
+}
+
+std::stringstream& operator<< (std::stringstream& stream, const Status& s) {
+    stream << s.toString8().string();
+    return stream;
+}
+
+}  // namespace binder
+}  // namespace android
diff --git a/libs/binder/TextOutput.cpp b/libs/binder/TextOutput.cpp
index db3e858..2ed5188 100644
--- a/libs/binder/TextOutput.cpp
+++ b/libs/binder/TextOutput.cpp
@@ -116,8 +116,8 @@
 
 TextOutput& operator<<(TextOutput& to, const void* val)
 {
-    char buf[16];
-    sprintf(buf, "%p", val);
+    char buf[32];
+    snprintf(buf, sizeof(buf), "%p", val);
     to.print(buf, strlen(buf));
     return to;
 }
diff --git a/libs/binder/tests/Android.mk b/libs/binder/tests/Android.mk
new file mode 100644
index 0000000..a40523d
--- /dev/null
+++ b/libs/binder/tests/Android.mk
@@ -0,0 +1,42 @@
+#
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+ifneq ($(TARGET_USES_64_BIT_BINDER),true)
+ifneq ($(TARGET_IS_64_BIT),true)
+LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1
+endif
+endif
+
+LOCAL_MODULE := binderDriverInterfaceTest
+LOCAL_SRC_FILES := binderDriverInterfaceTest.cpp
+include $(BUILD_NATIVE_TEST)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := binderLibTest
+LOCAL_SRC_FILES := binderLibTest.cpp
+LOCAL_SHARED_LIBRARIES := libbinder libutils
+include $(BUILD_NATIVE_TEST)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := binderThroughputTest
+LOCAL_SRC_FILES := binderThroughputTest.cpp
+LOCAL_SHARED_LIBRARIES := libbinder libutils
+LOCAL_CLANG := true
+LOCAL_CFLAGS += -g -Wall -Werror -std=c++11 -Wno-missing-field-initializers -Wno-sign-compare -O3
+include $(BUILD_NATIVE_TEST)
diff --git a/libs/binder/tests/binderDriverInterfaceTest.cpp b/libs/binder/tests/binderDriverInterfaceTest.cpp
new file mode 100644
index 0000000..0277550
--- /dev/null
+++ b/libs/binder/tests/binderDriverInterfaceTest.cpp
@@ -0,0 +1,353 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <gtest/gtest.h>
+#include <linux/binder.h>
+#include <binder/IBinder.h>
+#include <sys/mman.h>
+#include <poll.h>
+
+#define BINDER_DEV_NAME "/dev/binder"
+
+testing::Environment* binder_env;
+
+class BinderDriverInterfaceTestEnv : public ::testing::Environment {
+        virtual void SetUp() {
+            int ret;
+            uint32_t max_threads = 0;
+
+            m_binderFd = open(BINDER_DEV_NAME, O_RDWR | O_NONBLOCK | O_CLOEXEC);
+            ASSERT_GE(m_binderFd, 0);
+            m_buffer = mmap(NULL, 64*1024, PROT_READ, MAP_SHARED, m_binderFd, 0);
+            ASSERT_NE(m_buffer, (void *)NULL);
+            ret = ioctl(m_binderFd, BINDER_SET_MAX_THREADS, &max_threads);
+            EXPECT_EQ(0, ret);
+            EnterLooper();
+        }
+        virtual void TearDown() {
+            close(m_binderFd);
+        }
+    private:
+        int m_binderFd;
+        void *m_buffer;
+    public:
+        int getBinderFd(void) {
+            return m_binderFd;
+        }
+        void EnterLooper(void) {
+            int ret;
+            const uint32_t bc[] = {
+                BC_ENTER_LOOPER,
+            };
+            struct binder_write_read bwr = binder_write_read();
+            bwr.write_buffer = (uintptr_t)bc;
+            bwr.write_size = sizeof(bc);
+            ret = ioctl(m_binderFd, BINDER_WRITE_READ, &bwr);
+            EXPECT_EQ(0, ret);
+            if (ret < 0) {
+                    EXPECT_EQ(0, errno);
+            }
+            EXPECT_EQ(sizeof(bc), bwr.write_consumed);
+        }
+};
+
+class BinderDriverInterfaceTest : public ::testing::Test {
+    public:
+        virtual void SetUp() {
+            m_binderFd = static_cast<BinderDriverInterfaceTestEnv *>(binder_env)->getBinderFd();
+        }
+        virtual void TearDown() {
+        }
+    protected:
+        void binderTestIoctlRetErr2(int cmd, void *arg, int expect_ret, int expect_errno, int accept_errno) {
+            int ret;
+
+            ret = ioctl(m_binderFd, cmd, arg);
+            EXPECT_EQ(expect_ret, ret);
+            if (ret < 0) {
+                if (errno != accept_errno)
+                    EXPECT_EQ(expect_errno, errno);
+            }
+        }
+        void binderTestIoctlErr2(int cmd, void *arg, int expect_errno, int accept_errno) {
+            binderTestIoctlRetErr2(cmd, arg, -1, expect_errno, accept_errno);
+        }
+        void binderTestIoctlErr1(int cmd, void *arg, int expect_errno) {
+            binderTestIoctlErr2(cmd, arg, expect_errno, expect_errno);
+        }
+        void binderTestIoctl(int cmd, void *arg) {
+            binderTestIoctlRetErr2(cmd, arg, 0, 0, 0);
+        }
+        void binderTestIoctlUnimplemented(int cmd, void *arg) {
+            int ret;
+
+            ret = ioctl(m_binderFd, cmd, arg);
+            if (ret < 0) {
+                /* Not currently implmented. Allow ret == -1, errno == EINVAL */
+                EXPECT_EQ(-1, ret);
+                EXPECT_EQ(EINVAL, errno);
+            }
+        }
+        void binderTestReadEmpty(void) {
+            size_t i;
+            uint32_t br[32];
+            struct binder_write_read bwr = binder_write_read();
+            SCOPED_TRACE("TestReadEmpty");
+            bwr.read_buffer = (uintptr_t)br;
+            bwr.read_size = sizeof(br);
+            binderTestIoctlErr1(BINDER_WRITE_READ, &bwr, EAGAIN);
+            EXPECT_EQ(0u, bwr.read_consumed);
+            for (i = 0; i * sizeof(uint32_t) < bwr.read_consumed; i++) {
+                SCOPED_TRACE(testing::Message() << "i = " << i);
+                EXPECT_EQ(BR_NOOP, br[i]);
+            }
+        }
+        void binderWaitForReadData(int timeout_ms) {
+            int ret;
+            pollfd pfd = pollfd();
+
+            pfd.fd = m_binderFd;
+            pfd.events = POLLIN;
+            ret = poll(&pfd, 1, timeout_ms);
+            EXPECT_EQ(1, ret);
+        }
+    private:
+        int m_binderFd;
+};
+
+TEST_F(BinderDriverInterfaceTest, Version) {
+    struct binder_version version;
+    binderTestIoctl(BINDER_VERSION, &version);
+    ASSERT_EQ(BINDER_CURRENT_PROTOCOL_VERSION, version.protocol_version);
+}
+
+TEST_F(BinderDriverInterfaceTest, WriteReadNull) {
+    binderTestIoctlErr1(BINDER_WRITE_READ, NULL, EFAULT);
+}
+
+TEST_F(BinderDriverInterfaceTest, SetIdleTimeoutNull) {
+    binderTestIoctlErr2(BINDER_SET_IDLE_TIMEOUT, NULL, EFAULT, EINVAL);
+}
+
+TEST_F(BinderDriverInterfaceTest, SetMaxThreadsNull) {
+    binderTestIoctlErr2(BINDER_SET_MAX_THREADS, NULL, EFAULT, EINVAL); /* TODO: don't accept EINVAL */
+}
+
+TEST_F(BinderDriverInterfaceTest, SetIdlePriorityNull) {
+    binderTestIoctlErr2(BINDER_SET_IDLE_PRIORITY, NULL, EFAULT, EINVAL);
+}
+
+TEST_F(BinderDriverInterfaceTest, VersionNull) {
+    binderTestIoctlErr2(BINDER_VERSION, NULL, EFAULT, EINVAL); /* TODO: don't accept EINVAL */
+}
+
+TEST_F(BinderDriverInterfaceTest, SetIdleTimeoutNoTest) {
+    int64_t idle_timeout = 100000;
+    binderTestIoctlUnimplemented(BINDER_SET_IDLE_TIMEOUT, &idle_timeout);
+}
+
+TEST_F(BinderDriverInterfaceTest, SetMaxThreads) {
+    uint32_t max_threads = 0;
+    binderTestIoctl(BINDER_SET_MAX_THREADS, &max_threads);
+}
+
+TEST_F(BinderDriverInterfaceTest, SetIdlePriorityNoTest) {
+    int idle_priority = 0;
+    binderTestIoctlUnimplemented(BINDER_SET_IDLE_PRIORITY, &idle_priority);
+}
+
+TEST_F(BinderDriverInterfaceTest, SetContextMgrBusy) {
+    int32_t dummy = 0;
+    binderTestIoctlErr1(BINDER_SET_CONTEXT_MGR, &dummy, EBUSY);
+}
+
+TEST_F(BinderDriverInterfaceTest, ThreadExit) {
+    int32_t dummy = 0;
+    binderTestIoctl(BINDER_THREAD_EXIT, &dummy);
+    static_cast<BinderDriverInterfaceTestEnv *>(binder_env)->EnterLooper();
+}
+
+TEST_F(BinderDriverInterfaceTest, WriteReadEmpty) {
+    struct binder_write_read bwr = binder_write_read();
+    binderTestIoctl(BINDER_WRITE_READ, &bwr);
+}
+
+TEST_F(BinderDriverInterfaceTest, Read) {
+    binderTestReadEmpty();
+}
+
+TEST_F(BinderDriverInterfaceTest, IncRefsAcquireReleaseDecRefs) {
+    const uint32_t bc[] = {
+        BC_INCREFS,
+        0,
+        BC_ACQUIRE,
+        0,
+        BC_RELEASE,
+        0,
+        BC_DECREFS,
+        0,
+    };
+    struct binder_write_read bwr = binder_write_read();
+    bwr.write_buffer = (uintptr_t)bc;
+    bwr.write_size = sizeof(bc);
+    binderTestIoctl(BINDER_WRITE_READ, &bwr);
+    EXPECT_EQ(sizeof(bc), bwr.write_consumed);
+    binderTestReadEmpty();
+}
+
+TEST_F(BinderDriverInterfaceTest, Transaction) {
+    binder_uintptr_t cookie = 1234;
+    struct {
+        uint32_t cmd1;
+        struct binder_transaction_data arg1;
+    } __attribute__((packed)) bc1 = {
+        .cmd1 = BC_TRANSACTION,
+        .arg1 = {
+            .target = { 0 },
+            .cookie = 0,
+            .code = android::IBinder::PING_TRANSACTION,
+            .flags = 0,
+            .sender_pid = 0,
+            .sender_euid = 0,
+            .data_size = 0,
+            .offsets_size = 0,
+            .data = {0, 0},
+        },
+    };
+    struct {
+        uint32_t cmd0;
+        uint32_t cmd1;
+        uint32_t cmd2;
+        binder_transaction_data arg2;
+        uint32_t pad[16];
+    } __attribute__((packed)) br;
+    struct binder_write_read bwr = binder_write_read();
+
+    bwr.write_buffer = (uintptr_t)&bc1;
+    bwr.write_size = sizeof(bc1);
+    bwr.read_buffer = (uintptr_t)&br;
+    bwr.read_size = sizeof(br);
+
+    {
+        SCOPED_TRACE("1st WriteRead");
+        binderTestIoctl(BINDER_WRITE_READ, &bwr);
+    }
+    EXPECT_EQ(sizeof(bc1), bwr.write_consumed);
+    if (bwr.read_consumed < offsetof(typeof(br), pad)) {
+        SCOPED_TRACE("2nd WriteRead");
+        binderWaitForReadData(10000);
+        binderTestIoctl(BINDER_WRITE_READ, &bwr);
+    }
+    EXPECT_EQ(offsetof(typeof(br), pad), bwr.read_consumed);
+    if (bwr.read_consumed > offsetof(typeof(br), cmd0))
+        EXPECT_EQ(BR_NOOP, br.cmd0);
+    if (bwr.read_consumed > offsetof(typeof(br), cmd1))
+        EXPECT_EQ(BR_TRANSACTION_COMPLETE, br.cmd1);
+    if (bwr.read_consumed > offsetof(typeof(br), cmd2))
+        EXPECT_EQ(BR_REPLY, br.cmd2);
+    if (bwr.read_consumed >= offsetof(typeof(br), pad)) {
+        EXPECT_EQ(0u, br.arg2.target.ptr);
+        EXPECT_EQ(0u, br.arg2.cookie);
+        EXPECT_EQ(0u, br.arg2.code);
+        EXPECT_EQ(0u, br.arg2.flags);
+        EXPECT_EQ(0u, br.arg2.data_size);
+        EXPECT_EQ(0u, br.arg2.offsets_size);
+
+        SCOPED_TRACE("3rd WriteRead");
+
+        binderTestReadEmpty();
+
+        struct {
+            uint32_t cmd1;
+            binder_uintptr_t arg1;
+        } __attribute__((packed)) bc2 = {
+            .cmd1 = BC_FREE_BUFFER,
+            .arg1 = br.arg2.data.ptr.buffer,
+        };
+
+        bwr.write_buffer = (uintptr_t)&bc2;
+        bwr.write_size = sizeof(bc2);
+        bwr.write_consumed = 0;
+        bwr.read_size = 0;
+
+        binderTestIoctl(BINDER_WRITE_READ, &bwr);
+        EXPECT_EQ(sizeof(bc2), bwr.write_consumed);
+    }
+    binderTestReadEmpty();
+}
+
+TEST_F(BinderDriverInterfaceTest, RequestDeathNotification) {
+    binder_uintptr_t cookie = 1234;
+    struct {
+        uint32_t cmd0;
+        uint32_t arg0;
+        uint32_t cmd1;
+        struct binder_handle_cookie arg1;
+        uint32_t cmd2;
+        struct binder_handle_cookie arg2;
+        uint32_t cmd3;
+        uint32_t arg3;
+    } __attribute__((packed)) bc = {
+        .cmd0 = BC_INCREFS,
+        .arg0 = 0,
+        .cmd1 = BC_REQUEST_DEATH_NOTIFICATION,
+        .arg1 = {
+            .handle = 0,
+            .cookie = cookie,
+        },
+        .cmd2 = BC_CLEAR_DEATH_NOTIFICATION,
+        .arg2 = {
+            .handle = 0,
+            .cookie = cookie,
+        },
+        .cmd3 = BC_DECREFS,
+        .arg3 = 0,
+    };
+    struct {
+        uint32_t cmd0;
+        uint32_t cmd1;
+        binder_uintptr_t arg1;
+        uint32_t pad[16];
+    } __attribute__((packed)) br;
+    struct binder_write_read bwr = binder_write_read();
+
+    bwr.write_buffer = (uintptr_t)&bc;
+    bwr.write_size = sizeof(bc);
+    bwr.read_buffer = (uintptr_t)&br;
+    bwr.read_size = sizeof(br);
+
+    binderTestIoctl(BINDER_WRITE_READ, &bwr);
+    EXPECT_EQ(sizeof(bc), bwr.write_consumed);
+    EXPECT_EQ(sizeof(br) - sizeof(br.pad), bwr.read_consumed);
+    EXPECT_EQ(BR_NOOP, br.cmd0);
+    EXPECT_EQ(BR_CLEAR_DEATH_NOTIFICATION_DONE, br.cmd1);
+    EXPECT_EQ(cookie, br.arg1);
+    binderTestReadEmpty();
+}
+
+int main(int argc, char **argv) {
+    ::testing::InitGoogleTest(&argc, argv);
+
+    binder_env = AddGlobalTestEnvironment(new BinderDriverInterfaceTestEnv());
+
+    return RUN_ALL_TESTS();
+}
+
diff --git a/libs/binder/tests/binderLibTest.cpp b/libs/binder/tests/binderLibTest.cpp
new file mode 100644
index 0000000..17479ca
--- /dev/null
+++ b/libs/binder/tests/binderLibTest.cpp
@@ -0,0 +1,946 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <poll.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <gtest/gtest.h>
+
+#include <binder/Binder.h>
+#include <binder/IBinder.h>
+#include <binder/IPCThreadState.h>
+#include <binder/IServiceManager.h>
+
+#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
+
+using namespace android;
+
+static testing::Environment* binder_env;
+static char *binderservername;
+static char binderserverarg[] = "--binderserver";
+
+static String16 binderLibTestServiceName = String16("test.binderLib");
+
+enum BinderLibTestTranscationCode {
+    BINDER_LIB_TEST_NOP_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
+    BINDER_LIB_TEST_REGISTER_SERVER,
+    BINDER_LIB_TEST_ADD_SERVER,
+    BINDER_LIB_TEST_CALL_BACK,
+    BINDER_LIB_TEST_NOP_CALL_BACK,
+    BINDER_LIB_TEST_GET_ID_TRANSACTION,
+    BINDER_LIB_TEST_INDIRECT_TRANSACTION,
+    BINDER_LIB_TEST_SET_ERROR_TRANSACTION,
+    BINDER_LIB_TEST_GET_STATUS_TRANSACTION,
+    BINDER_LIB_TEST_ADD_STRONG_REF_TRANSACTION,
+    BINDER_LIB_TEST_LINK_DEATH_TRANSACTION,
+    BINDER_LIB_TEST_WRITE_FILE_TRANSACTION,
+    BINDER_LIB_TEST_PROMOTE_WEAK_REF_TRANSACTION,
+    BINDER_LIB_TEST_EXIT_TRANSACTION,
+    BINDER_LIB_TEST_DELAYED_EXIT_TRANSACTION,
+    BINDER_LIB_TEST_GET_PTR_SIZE_TRANSACTION,
+};
+
+pid_t start_server_process(int arg2)
+{
+    int ret;
+    pid_t pid;
+    status_t status;
+    int pipefd[2];
+    char stri[16];
+    char strpipefd1[16];
+    char *childargv[] = {
+        binderservername,
+        binderserverarg,
+        stri,
+        strpipefd1,
+        NULL
+    };
+
+    ret = pipe(pipefd);
+    if (ret < 0)
+        return ret;
+
+    snprintf(stri, sizeof(stri), "%d", arg2);
+    snprintf(strpipefd1, sizeof(strpipefd1), "%d", pipefd[1]);
+
+    pid = fork();
+    if (pid == -1)
+        return pid;
+    if (pid == 0) {
+        close(pipefd[0]);
+        execv(binderservername, childargv);
+        status = -errno;
+        write(pipefd[1], &status, sizeof(status));
+        fprintf(stderr, "execv failed, %s\n", strerror(errno));
+        _exit(EXIT_FAILURE);
+    }
+    close(pipefd[1]);
+    ret = read(pipefd[0], &status, sizeof(status));
+    //printf("pipe read returned %d, status %d\n", ret, status);
+    close(pipefd[0]);
+    if (ret == sizeof(status)) {
+        ret = status;
+    } else {
+        kill(pid, SIGKILL);
+        if (ret >= 0) {
+            ret = NO_INIT;
+        }
+    }
+    if (ret < 0) {
+        wait(NULL);
+        return ret;
+    }
+    return pid;
+}
+
+class BinderLibTestEnv : public ::testing::Environment {
+    public:
+        BinderLibTestEnv() {}
+        sp<IBinder> getServer(void) {
+            return m_server;
+        }
+
+    private:
+        virtual void SetUp() {
+            m_serverpid = start_server_process(0);
+            //printf("m_serverpid %d\n", m_serverpid);
+            ASSERT_GT(m_serverpid, 0);
+
+            sp<IServiceManager> sm = defaultServiceManager();
+            //printf("%s: pid %d, get service\n", __func__, m_pid);
+            m_server = sm->getService(binderLibTestServiceName);
+            ASSERT_TRUE(m_server != NULL);
+            //printf("%s: pid %d, get service done\n", __func__, m_pid);
+        }
+        virtual void TearDown() {
+            status_t ret;
+            Parcel data, reply;
+            int exitStatus;
+            pid_t pid;
+
+            //printf("%s: pid %d\n", __func__, m_pid);
+            if (m_server != NULL) {
+                ret = m_server->transact(BINDER_LIB_TEST_GET_STATUS_TRANSACTION, data, &reply);
+                EXPECT_EQ(0, ret);
+                ret = m_server->transact(BINDER_LIB_TEST_EXIT_TRANSACTION, data, &reply, TF_ONE_WAY);
+                EXPECT_EQ(0, ret);
+            }
+            if (m_serverpid > 0) {
+                //printf("wait for %d\n", m_pids[i]);
+                pid = wait(&exitStatus);
+                EXPECT_EQ(m_serverpid, pid);
+                EXPECT_TRUE(WIFEXITED(exitStatus));
+                EXPECT_EQ(0, WEXITSTATUS(exitStatus));
+            }
+        }
+
+        pid_t m_serverpid;
+        sp<IBinder> m_server;
+};
+
+class BinderLibTest : public ::testing::Test {
+    public:
+        virtual void SetUp() {
+            m_server = static_cast<BinderLibTestEnv *>(binder_env)->getServer();
+        }
+        virtual void TearDown() {
+        }
+    protected:
+        sp<IBinder> addServer(int32_t *idPtr = NULL)
+        {
+            int ret;
+            int32_t id;
+            Parcel data, reply;
+            sp<IBinder> binder;
+
+            ret = m_server->transact(BINDER_LIB_TEST_ADD_SERVER, data, &reply);
+            EXPECT_EQ(NO_ERROR, ret);
+
+            EXPECT_FALSE(binder != NULL);
+            binder = reply.readStrongBinder();
+            EXPECT_TRUE(binder != NULL);
+            ret = reply.readInt32(&id);
+            EXPECT_EQ(NO_ERROR, ret);
+            if (idPtr)
+                *idPtr = id;
+            return binder;
+        }
+        void waitForReadData(int fd, int timeout_ms) {
+            int ret;
+            pollfd pfd = pollfd();
+
+            pfd.fd = fd;
+            pfd.events = POLLIN;
+            ret = poll(&pfd, 1, timeout_ms);
+            EXPECT_EQ(1, ret);
+        }
+
+        sp<IBinder> m_server;
+};
+
+class BinderLibTestBundle : public Parcel
+{
+    public:
+        BinderLibTestBundle(void) {}
+        BinderLibTestBundle(const Parcel *source) : m_isValid(false) {
+            int32_t mark;
+            int32_t bundleLen;
+            size_t pos;
+
+            if (source->readInt32(&mark))
+                return;
+            if (mark != MARK_START)
+                return;
+            if (source->readInt32(&bundleLen))
+                return;
+            pos = source->dataPosition();
+            if (Parcel::appendFrom(source, pos, bundleLen))
+                return;
+            source->setDataPosition(pos + bundleLen);
+            if (source->readInt32(&mark))
+                return;
+            if (mark != MARK_END)
+                return;
+            m_isValid = true;
+            setDataPosition(0);
+        }
+        void appendTo(Parcel *dest) {
+            dest->writeInt32(MARK_START);
+            dest->writeInt32(dataSize());
+            dest->appendFrom(this, 0, dataSize());
+            dest->writeInt32(MARK_END);
+        };
+        bool isValid(void) {
+            return m_isValid;
+        }
+    private:
+        enum {
+            MARK_START  = B_PACK_CHARS('B','T','B','S'),
+            MARK_END    = B_PACK_CHARS('B','T','B','E'),
+        };
+        bool m_isValid;
+};
+
+class BinderLibTestEvent
+{
+    public:
+        BinderLibTestEvent(void)
+            : m_eventTriggered(false)
+        {
+            pthread_mutex_init(&m_waitMutex, NULL);
+            pthread_cond_init(&m_waitCond, NULL);
+        }
+        int waitEvent(int timeout_s)
+        {
+            int ret;
+            pthread_mutex_lock(&m_waitMutex);
+            if (!m_eventTriggered) {
+                struct timespec ts;
+                clock_gettime(CLOCK_REALTIME, &ts);
+                ts.tv_sec += timeout_s;
+                pthread_cond_timedwait(&m_waitCond, &m_waitMutex, &ts);
+            }
+            ret = m_eventTriggered ? NO_ERROR : TIMED_OUT;
+            pthread_mutex_unlock(&m_waitMutex);
+            return ret;
+        }
+    protected:
+        void triggerEvent(void) {
+            pthread_mutex_lock(&m_waitMutex);
+            pthread_cond_signal(&m_waitCond);
+            m_eventTriggered = true;
+            pthread_mutex_unlock(&m_waitMutex);
+        };
+    private:
+        pthread_mutex_t m_waitMutex;
+        pthread_cond_t m_waitCond;
+        bool m_eventTriggered;
+};
+
+class BinderLibTestCallBack : public BBinder, public BinderLibTestEvent
+{
+    public:
+        BinderLibTestCallBack()
+            : m_result(NOT_ENOUGH_DATA)
+        {
+        }
+        status_t getResult(void)
+        {
+            return m_result;
+        }
+
+    private:
+        virtual status_t onTransact(uint32_t code,
+                                    const Parcel& data, Parcel* reply,
+                                    uint32_t flags = 0)
+        {
+            (void)reply;
+            (void)flags;
+            switch(code) {
+            case BINDER_LIB_TEST_CALL_BACK:
+                m_result = data.readInt32();
+                triggerEvent();
+                return NO_ERROR;
+            default:
+                return UNKNOWN_TRANSACTION;
+            }
+        }
+
+        status_t m_result;
+};
+
+class TestDeathRecipient : public IBinder::DeathRecipient, public BinderLibTestEvent
+{
+    private:
+        virtual void binderDied(const wp<IBinder>& who) {
+            (void)who;
+            triggerEvent();
+        };
+};
+
+TEST_F(BinderLibTest, NopTransaction) {
+    status_t ret;
+    Parcel data, reply;
+    ret = m_server->transact(BINDER_LIB_TEST_NOP_TRANSACTION, data, &reply);
+    EXPECT_EQ(NO_ERROR, ret);
+}
+
+TEST_F(BinderLibTest, SetError) {
+    int32_t testValue[] = { 0, -123, 123 };
+    for (size_t i = 0; i < ARRAY_SIZE(testValue); i++) {
+        status_t ret;
+        Parcel data, reply;
+        data.writeInt32(testValue[i]);
+        ret = m_server->transact(BINDER_LIB_TEST_SET_ERROR_TRANSACTION, data, &reply);
+        EXPECT_EQ(testValue[i], ret);
+    }
+}
+
+TEST_F(BinderLibTest, GetId) {
+    status_t ret;
+    int32_t id;
+    Parcel data, reply;
+    ret = m_server->transact(BINDER_LIB_TEST_GET_ID_TRANSACTION, data, &reply);
+    EXPECT_EQ(NO_ERROR, ret);
+    ret = reply.readInt32(&id);
+    EXPECT_EQ(NO_ERROR, ret);
+    EXPECT_EQ(0, id);
+}
+
+TEST_F(BinderLibTest, PtrSize) {
+    status_t ret;
+    int32_t ptrsize;
+    Parcel data, reply;
+    sp<IBinder> server = addServer();
+    ASSERT_TRUE(server != NULL);
+    ret = server->transact(BINDER_LIB_TEST_GET_PTR_SIZE_TRANSACTION, data, &reply);
+    EXPECT_EQ(NO_ERROR, ret);
+    ret = reply.readInt32(&ptrsize);
+    EXPECT_EQ(NO_ERROR, ret);
+    RecordProperty("TestPtrSize", sizeof(void *));
+    RecordProperty("ServerPtrSize", sizeof(void *));
+}
+
+TEST_F(BinderLibTest, IndirectGetId2)
+{
+    status_t ret;
+    int32_t id;
+    int32_t count;
+    Parcel data, reply;
+    int32_t serverId[3];
+
+    data.writeInt32(ARRAY_SIZE(serverId));
+    for (size_t i = 0; i < ARRAY_SIZE(serverId); i++) {
+        sp<IBinder> server;
+        BinderLibTestBundle datai;
+
+        server = addServer(&serverId[i]);
+        ASSERT_TRUE(server != NULL);
+        data.writeStrongBinder(server);
+        data.writeInt32(BINDER_LIB_TEST_GET_ID_TRANSACTION);
+        datai.appendTo(&data);
+    }
+
+    ret = m_server->transact(BINDER_LIB_TEST_INDIRECT_TRANSACTION, data, &reply);
+    ASSERT_EQ(NO_ERROR, ret);
+
+    ret = reply.readInt32(&id);
+    ASSERT_EQ(NO_ERROR, ret);
+    EXPECT_EQ(0, id);
+
+    ret = reply.readInt32(&count);
+    ASSERT_EQ(NO_ERROR, ret);
+    EXPECT_EQ(ARRAY_SIZE(serverId), count);
+
+    for (size_t i = 0; i < (size_t)count; i++) {
+        BinderLibTestBundle replyi(&reply);
+        EXPECT_TRUE(replyi.isValid());
+        ret = replyi.readInt32(&id);
+        EXPECT_EQ(NO_ERROR, ret);
+        EXPECT_EQ(serverId[i], id);
+        EXPECT_EQ(replyi.dataSize(), replyi.dataPosition());
+    }
+
+    EXPECT_EQ(reply.dataSize(), reply.dataPosition());
+}
+
+TEST_F(BinderLibTest, IndirectGetId3)
+{
+    status_t ret;
+    int32_t id;
+    int32_t count;
+    Parcel data, reply;
+    int32_t serverId[3];
+
+    data.writeInt32(ARRAY_SIZE(serverId));
+    for (size_t i = 0; i < ARRAY_SIZE(serverId); i++) {
+        sp<IBinder> server;
+        BinderLibTestBundle datai;
+        BinderLibTestBundle datai2;
+
+        server = addServer(&serverId[i]);
+        ASSERT_TRUE(server != NULL);
+        data.writeStrongBinder(server);
+        data.writeInt32(BINDER_LIB_TEST_INDIRECT_TRANSACTION);
+
+        datai.writeInt32(1);
+        datai.writeStrongBinder(m_server);
+        datai.writeInt32(BINDER_LIB_TEST_GET_ID_TRANSACTION);
+        datai2.appendTo(&datai);
+
+        datai.appendTo(&data);
+    }
+
+    ret = m_server->transact(BINDER_LIB_TEST_INDIRECT_TRANSACTION, data, &reply);
+    ASSERT_EQ(NO_ERROR, ret);
+
+    ret = reply.readInt32(&id);
+    ASSERT_EQ(NO_ERROR, ret);
+    EXPECT_EQ(0, id);
+
+    ret = reply.readInt32(&count);
+    ASSERT_EQ(NO_ERROR, ret);
+    EXPECT_EQ(ARRAY_SIZE(serverId), count);
+
+    for (size_t i = 0; i < (size_t)count; i++) {
+        int32_t counti;
+
+        BinderLibTestBundle replyi(&reply);
+        EXPECT_TRUE(replyi.isValid());
+        ret = replyi.readInt32(&id);
+        EXPECT_EQ(NO_ERROR, ret);
+        EXPECT_EQ(serverId[i], id);
+
+        ret = replyi.readInt32(&counti);
+        ASSERT_EQ(NO_ERROR, ret);
+        EXPECT_EQ(1, counti);
+
+        BinderLibTestBundle replyi2(&replyi);
+        EXPECT_TRUE(replyi2.isValid());
+        ret = replyi2.readInt32(&id);
+        EXPECT_EQ(NO_ERROR, ret);
+        EXPECT_EQ(0, id);
+        EXPECT_EQ(replyi2.dataSize(), replyi2.dataPosition());
+
+        EXPECT_EQ(replyi.dataSize(), replyi.dataPosition());
+    }
+
+    EXPECT_EQ(reply.dataSize(), reply.dataPosition());
+}
+
+TEST_F(BinderLibTest, CallBack)
+{
+    status_t ret;
+    Parcel data, reply;
+    sp<BinderLibTestCallBack> callBack = new BinderLibTestCallBack();
+    data.writeStrongBinder(callBack);
+    ret = m_server->transact(BINDER_LIB_TEST_NOP_CALL_BACK, data, &reply, TF_ONE_WAY);
+    EXPECT_EQ(NO_ERROR, ret);
+    ret = callBack->waitEvent(5);
+    EXPECT_EQ(NO_ERROR, ret);
+    ret = callBack->getResult();
+    EXPECT_EQ(NO_ERROR, ret);
+}
+
+TEST_F(BinderLibTest, AddServer)
+{
+    sp<IBinder> server = addServer();
+    ASSERT_TRUE(server != NULL);
+}
+
+TEST_F(BinderLibTest, DeathNotificationNoRefs)
+{
+    status_t ret;
+
+    sp<TestDeathRecipient> testDeathRecipient = new TestDeathRecipient();
+
+    {
+        sp<IBinder> binder = addServer();
+        ASSERT_TRUE(binder != NULL);
+        ret = binder->linkToDeath(testDeathRecipient);
+        EXPECT_EQ(NO_ERROR, ret);
+    }
+    IPCThreadState::self()->flushCommands();
+    ret = testDeathRecipient->waitEvent(5);
+    EXPECT_EQ(NO_ERROR, ret);
+#if 0 /* Is there an unlink api that does not require a strong reference? */
+    ret = binder->unlinkToDeath(testDeathRecipient);
+    EXPECT_EQ(NO_ERROR, ret);
+#endif
+}
+
+TEST_F(BinderLibTest, DeathNotificationWeakRef)
+{
+    status_t ret;
+    wp<IBinder> wbinder;
+
+    sp<TestDeathRecipient> testDeathRecipient = new TestDeathRecipient();
+
+    {
+        sp<IBinder> binder = addServer();
+        ASSERT_TRUE(binder != NULL);
+        ret = binder->linkToDeath(testDeathRecipient);
+        EXPECT_EQ(NO_ERROR, ret);
+        wbinder = binder;
+    }
+    IPCThreadState::self()->flushCommands();
+    ret = testDeathRecipient->waitEvent(5);
+    EXPECT_EQ(NO_ERROR, ret);
+#if 0 /* Is there an unlink api that does not require a strong reference? */
+    ret = binder->unlinkToDeath(testDeathRecipient);
+    EXPECT_EQ(NO_ERROR, ret);
+#endif
+}
+
+TEST_F(BinderLibTest, DeathNotificationStrongRef)
+{
+    status_t ret;
+    sp<IBinder> sbinder;
+
+    sp<TestDeathRecipient> testDeathRecipient = new TestDeathRecipient();
+
+    {
+        sp<IBinder> binder = addServer();
+        ASSERT_TRUE(binder != NULL);
+        ret = binder->linkToDeath(testDeathRecipient);
+        EXPECT_EQ(NO_ERROR, ret);
+        sbinder = binder;
+    }
+    {
+        Parcel data, reply;
+        ret = sbinder->transact(BINDER_LIB_TEST_EXIT_TRANSACTION, data, &reply, TF_ONE_WAY);
+        EXPECT_EQ(0, ret);
+    }
+    IPCThreadState::self()->flushCommands();
+    ret = testDeathRecipient->waitEvent(5);
+    EXPECT_EQ(NO_ERROR, ret);
+    ret = sbinder->unlinkToDeath(testDeathRecipient);
+    EXPECT_EQ(DEAD_OBJECT, ret);
+}
+
+TEST_F(BinderLibTest, DeathNotificationMultiple)
+{
+    status_t ret;
+    const int clientcount = 2;
+    sp<IBinder> target;
+    sp<IBinder> linkedclient[clientcount];
+    sp<BinderLibTestCallBack> callBack[clientcount];
+    sp<IBinder> passiveclient[clientcount];
+
+    target = addServer();
+    ASSERT_TRUE(target != NULL);
+    for (int i = 0; i < clientcount; i++) {
+        {
+            Parcel data, reply;
+
+            linkedclient[i] = addServer();
+            ASSERT_TRUE(linkedclient[i] != NULL);
+            callBack[i] = new BinderLibTestCallBack();
+            data.writeStrongBinder(target);
+            data.writeStrongBinder(callBack[i]);
+            ret = linkedclient[i]->transact(BINDER_LIB_TEST_LINK_DEATH_TRANSACTION, data, &reply, TF_ONE_WAY);
+            EXPECT_EQ(NO_ERROR, ret);
+        }
+        {
+            Parcel data, reply;
+
+            passiveclient[i] = addServer();
+            ASSERT_TRUE(passiveclient[i] != NULL);
+            data.writeStrongBinder(target);
+            ret = passiveclient[i]->transact(BINDER_LIB_TEST_ADD_STRONG_REF_TRANSACTION, data, &reply, TF_ONE_WAY);
+            EXPECT_EQ(NO_ERROR, ret);
+        }
+    }
+    {
+        Parcel data, reply;
+        ret = target->transact(BINDER_LIB_TEST_EXIT_TRANSACTION, data, &reply, TF_ONE_WAY);
+        EXPECT_EQ(0, ret);
+    }
+
+    for (int i = 0; i < clientcount; i++) {
+        ret = callBack[i]->waitEvent(5);
+        EXPECT_EQ(NO_ERROR, ret);
+        ret = callBack[i]->getResult();
+        EXPECT_EQ(NO_ERROR, ret);
+    }
+}
+
+TEST_F(BinderLibTest, PassFile) {
+    int ret;
+    int pipefd[2];
+    uint8_t buf[1] = { 0 };
+    uint8_t write_value = 123;
+
+    ret = pipe2(pipefd, O_NONBLOCK);
+    ASSERT_EQ(0, ret);
+
+    {
+        Parcel data, reply;
+        uint8_t writebuf[1] = { write_value };
+
+        ret = data.writeFileDescriptor(pipefd[1], true);
+        EXPECT_EQ(NO_ERROR, ret);
+
+        ret = data.writeInt32(sizeof(writebuf));
+        EXPECT_EQ(NO_ERROR, ret);
+
+        ret = data.write(writebuf, sizeof(writebuf));
+        EXPECT_EQ(NO_ERROR, ret);
+
+        ret = m_server->transact(BINDER_LIB_TEST_WRITE_FILE_TRANSACTION, data, &reply);
+        EXPECT_EQ(NO_ERROR, ret);
+    }
+
+    ret = read(pipefd[0], buf, sizeof(buf));
+    EXPECT_EQ(sizeof(buf), ret);
+    EXPECT_EQ(write_value, buf[0]);
+
+    waitForReadData(pipefd[0], 5000); /* wait for other proccess to close pipe */
+
+    ret = read(pipefd[0], buf, sizeof(buf));
+    EXPECT_EQ(0, ret);
+
+    close(pipefd[0]);
+}
+
+TEST_F(BinderLibTest, PromoteLocal) {
+    sp<IBinder> strong = new BBinder();
+    wp<IBinder> weak = strong;
+    sp<IBinder> strong_from_weak = weak.promote();
+    EXPECT_TRUE(strong != NULL);
+    EXPECT_EQ(strong, strong_from_weak);
+    strong = NULL;
+    strong_from_weak = NULL;
+    strong_from_weak = weak.promote();
+    EXPECT_TRUE(strong_from_weak == NULL);
+}
+
+TEST_F(BinderLibTest, PromoteRemote) {
+    int ret;
+    Parcel data, reply;
+    sp<IBinder> strong = new BBinder();
+    sp<IBinder> server = addServer();
+
+    ASSERT_TRUE(server != NULL);
+    ASSERT_TRUE(strong != NULL);
+
+    ret = data.writeWeakBinder(strong);
+    EXPECT_EQ(NO_ERROR, ret);
+
+    ret = server->transact(BINDER_LIB_TEST_PROMOTE_WEAK_REF_TRANSACTION, data, &reply);
+    EXPECT_GE(ret, 0);
+}
+
+class BinderLibTestService : public BBinder
+{
+    public:
+        BinderLibTestService(int32_t id)
+            : m_id(id)
+            , m_nextServerId(id + 1)
+            , m_serverStartRequested(false)
+        {
+            pthread_mutex_init(&m_serverWaitMutex, NULL);
+            pthread_cond_init(&m_serverWaitCond, NULL);
+        }
+        ~BinderLibTestService()
+        {
+            exit(EXIT_SUCCESS);
+        }
+        virtual status_t onTransact(uint32_t code,
+                                    const Parcel& data, Parcel* reply,
+                                    uint32_t flags = 0) {
+            //printf("%s: code %d\n", __func__, code);
+            (void)flags;
+
+            if (getuid() != (uid_t)IPCThreadState::self()->getCallingUid()) {
+                return PERMISSION_DENIED;
+            }
+            switch (code) {
+            case BINDER_LIB_TEST_REGISTER_SERVER: {
+                int32_t id;
+                sp<IBinder> binder;
+                id = data.readInt32();
+                binder = data.readStrongBinder();
+                if (binder == NULL) {
+                    return BAD_VALUE;
+                }
+
+                if (m_id != 0)
+                    return INVALID_OPERATION;
+
+                pthread_mutex_lock(&m_serverWaitMutex);
+                if (m_serverStartRequested) {
+                    m_serverStartRequested = false;
+                    m_serverStarted = binder;
+                    pthread_cond_signal(&m_serverWaitCond);
+                }
+                pthread_mutex_unlock(&m_serverWaitMutex);
+                return NO_ERROR;
+            }
+            case BINDER_LIB_TEST_ADD_SERVER: {
+                int ret;
+                uint8_t buf[1] = { 0 };
+                int serverid;
+
+                if (m_id != 0) {
+                    return INVALID_OPERATION;
+                }
+                pthread_mutex_lock(&m_serverWaitMutex);
+                if (m_serverStartRequested) {
+                    ret = -EBUSY;
+                } else {
+                    serverid = m_nextServerId++;
+                    m_serverStartRequested = true;
+
+                    pthread_mutex_unlock(&m_serverWaitMutex);
+                    ret = start_server_process(serverid);
+                    pthread_mutex_lock(&m_serverWaitMutex);
+                }
+                if (ret > 0) {
+                    if (m_serverStartRequested) {
+                        struct timespec ts;
+                        clock_gettime(CLOCK_REALTIME, &ts);
+                        ts.tv_sec += 5;
+                        ret = pthread_cond_timedwait(&m_serverWaitCond, &m_serverWaitMutex, &ts);
+                    }
+                    if (m_serverStartRequested) {
+                        m_serverStartRequested = false;
+                        ret = -ETIMEDOUT;
+                    } else {
+                        reply->writeStrongBinder(m_serverStarted);
+                        reply->writeInt32(serverid);
+                        m_serverStarted = NULL;
+                        ret = NO_ERROR;
+                    }
+                } else if (ret >= 0) {
+                    m_serverStartRequested = false;
+                    ret = UNKNOWN_ERROR;
+                }
+                pthread_mutex_unlock(&m_serverWaitMutex);
+                return ret;
+            }
+            case BINDER_LIB_TEST_NOP_TRANSACTION:
+                return NO_ERROR;
+            case BINDER_LIB_TEST_NOP_CALL_BACK: {
+                Parcel data2, reply2;
+                sp<IBinder> binder;
+                binder = data.readStrongBinder();
+                if (binder == NULL) {
+                    return BAD_VALUE;
+                }
+                reply2.writeInt32(NO_ERROR);
+                binder->transact(BINDER_LIB_TEST_CALL_BACK, data2, &reply2);
+                return NO_ERROR;
+            }
+            case BINDER_LIB_TEST_GET_ID_TRANSACTION:
+                reply->writeInt32(m_id);
+                return NO_ERROR;
+            case BINDER_LIB_TEST_INDIRECT_TRANSACTION: {
+                int32_t count;
+                uint32_t indirect_code;
+                sp<IBinder> binder;
+
+                count = data.readInt32();
+                reply->writeInt32(m_id);
+                reply->writeInt32(count);
+                for (int i = 0; i < count; i++) {
+                    binder = data.readStrongBinder();
+                    if (binder == NULL) {
+                        return BAD_VALUE;
+                    }
+                    indirect_code = data.readInt32();
+                    BinderLibTestBundle data2(&data);
+                    if (!data2.isValid()) {
+                        return BAD_VALUE;
+                    }
+                    BinderLibTestBundle reply2;
+                    binder->transact(indirect_code, data2, &reply2);
+                    reply2.appendTo(reply);
+                }
+                return NO_ERROR;
+            }
+            case BINDER_LIB_TEST_SET_ERROR_TRANSACTION:
+                reply->setError(data.readInt32());
+                return NO_ERROR;
+            case BINDER_LIB_TEST_GET_PTR_SIZE_TRANSACTION:
+                reply->writeInt32(sizeof(void *));
+                return NO_ERROR;
+            case BINDER_LIB_TEST_GET_STATUS_TRANSACTION:
+                return NO_ERROR;
+            case BINDER_LIB_TEST_ADD_STRONG_REF_TRANSACTION:
+                m_strongRef = data.readStrongBinder();
+                return NO_ERROR;
+            case BINDER_LIB_TEST_LINK_DEATH_TRANSACTION: {
+                int ret;
+                Parcel data2, reply2;
+                sp<TestDeathRecipient> testDeathRecipient = new TestDeathRecipient();
+                sp<IBinder> target;
+                sp<IBinder> callback;
+
+                target = data.readStrongBinder();
+                if (target == NULL) {
+                    return BAD_VALUE;
+                }
+                callback = data.readStrongBinder();
+                if (callback == NULL) {
+                    return BAD_VALUE;
+                }
+                ret = target->linkToDeath(testDeathRecipient);
+                if (ret == NO_ERROR)
+                    ret = testDeathRecipient->waitEvent(5);
+                data2.writeInt32(ret);
+                callback->transact(BINDER_LIB_TEST_CALL_BACK, data2, &reply2);
+                return NO_ERROR;
+            }
+            case BINDER_LIB_TEST_WRITE_FILE_TRANSACTION: {
+                int ret;
+                int32_t size;
+                const void *buf;
+                int fd;
+
+                fd = data.readFileDescriptor();
+                if (fd < 0) {
+                    return BAD_VALUE;
+                }
+                ret = data.readInt32(&size);
+                if (ret != NO_ERROR) {
+                    return ret;
+                }
+                buf = data.readInplace(size);
+                if (buf == NULL) {
+                    return BAD_VALUE;
+                }
+                ret = write(fd, buf, size);
+                if (ret != size)
+                    return UNKNOWN_ERROR;
+                return NO_ERROR;
+            }
+            case BINDER_LIB_TEST_PROMOTE_WEAK_REF_TRANSACTION: {
+                int ret;
+                wp<IBinder> weak;
+                sp<IBinder> strong;
+                Parcel data2, reply2;
+                sp<IServiceManager> sm = defaultServiceManager();
+                sp<IBinder> server = sm->getService(binderLibTestServiceName);
+
+                weak = data.readWeakBinder();
+                if (weak == NULL) {
+                    return BAD_VALUE;
+                }
+                strong = weak.promote();
+
+                ret = server->transact(BINDER_LIB_TEST_NOP_TRANSACTION, data2, &reply2);
+                if (ret != NO_ERROR)
+                    exit(EXIT_FAILURE);
+
+                if (strong == NULL) {
+                    reply->setError(1);
+                }
+                return NO_ERROR;
+            }
+            case BINDER_LIB_TEST_DELAYED_EXIT_TRANSACTION:
+                alarm(10);
+                return NO_ERROR;
+            case BINDER_LIB_TEST_EXIT_TRANSACTION:
+                while (wait(NULL) != -1 || errno != ECHILD)
+                    ;
+                exit(EXIT_SUCCESS);
+            default:
+                return UNKNOWN_TRANSACTION;
+            };
+        }
+    private:
+        int32_t m_id;
+        int32_t m_nextServerId;
+        pthread_mutex_t m_serverWaitMutex;
+        pthread_cond_t m_serverWaitCond;
+        bool m_serverStartRequested;
+        sp<IBinder> m_serverStarted;
+        sp<IBinder> m_strongRef;
+};
+
+int run_server(int index, int readypipefd)
+{
+    status_t ret;
+    sp<IServiceManager> sm = defaultServiceManager();
+    {
+        sp<BinderLibTestService> testService = new BinderLibTestService(index);
+        if (index == 0) {
+            ret = sm->addService(binderLibTestServiceName, testService);
+        } else {
+            sp<IBinder> server = sm->getService(binderLibTestServiceName);
+            Parcel data, reply;
+            data.writeInt32(index);
+            data.writeStrongBinder(testService);
+
+            ret = server->transact(BINDER_LIB_TEST_REGISTER_SERVER, data, &reply);
+        }
+    }
+    write(readypipefd, &ret, sizeof(ret));
+    close(readypipefd);
+    //printf("%s: ret %d\n", __func__, ret);
+    if (ret)
+        return 1;
+    //printf("%s: joinThreadPool\n", __func__);
+    ProcessState::self()->startThreadPool();
+    IPCThreadState::self()->joinThreadPool();
+    //printf("%s: joinThreadPool returned\n", __func__);
+    return 1; /* joinThreadPool should not return */
+}
+
+int main(int argc, char **argv) {
+    int ret;
+
+    if (argc == 3 && !strcmp(argv[1], "--servername")) {
+        binderservername = argv[2];
+    } else {
+        binderservername = argv[0];
+    }
+
+    if (argc == 4 && !strcmp(argv[1], binderserverarg)) {
+        return run_server(atoi(argv[2]), atoi(argv[3]));
+    }
+
+    ::testing::InitGoogleTest(&argc, argv);
+    binder_env = AddGlobalTestEnvironment(new BinderLibTestEnv());
+    ProcessState::self()->startThreadPool();
+    return RUN_ALL_TESTS();
+}
+
diff --git a/libs/binder/tests/binderThroughputTest.cpp b/libs/binder/tests/binderThroughputTest.cpp
new file mode 100644
index 0000000..71b96d4
--- /dev/null
+++ b/libs/binder/tests/binderThroughputTest.cpp
@@ -0,0 +1,317 @@
+#include <binder/Binder.h>
+#include <binder/IBinder.h>
+#include <binder/IPCThreadState.h>
+#include <binder/IServiceManager.h>
+#include <string>
+#include <cstring>
+#include <cstdlib>
+#include <cstdio>
+
+#include <iostream>
+#include <vector>
+#include <tuple>
+
+#include <unistd.h>
+#include <sys/wait.h>
+
+using namespace std;
+using namespace android;
+
+enum BinderWorkerServiceCode {
+    BINDER_NOP = IBinder::FIRST_CALL_TRANSACTION,
+};
+
+#define ASSERT_TRUE(cond) \
+do { \
+    if (!(cond)) {\
+       cerr << __func__ << ":" << __LINE__ << " condition:" << #cond << " failed\n" << endl; \
+       exit(EXIT_FAILURE); \
+    } \
+} while (0)
+
+class BinderWorkerService : public BBinder
+{
+public:
+    BinderWorkerService() {}
+    ~BinderWorkerService() {}
+    virtual status_t onTransact(uint32_t code,
+                                const Parcel& data, Parcel* reply,
+                                uint32_t flags = 0) {
+        (void)flags;
+        (void)data;
+        (void)reply;
+        switch (code) {
+        case BINDER_NOP:
+            return NO_ERROR;
+        default:
+            return UNKNOWN_TRANSACTION;
+        };
+    }
+};
+
+class Pipe {
+    int m_readFd;
+    int m_writeFd;
+    Pipe(int readFd, int writeFd) : m_readFd{readFd}, m_writeFd{writeFd} {}
+    Pipe(const Pipe &) = delete;
+    Pipe& operator=(const Pipe &) = delete;
+    Pipe& operator=(const Pipe &&) = delete;
+public:
+    Pipe(Pipe&& rval) noexcept {
+        m_readFd = rval.m_readFd;
+        m_writeFd = rval.m_writeFd;
+        rval.m_readFd = 0;
+        rval.m_writeFd = 0;
+    }
+    ~Pipe() {
+        if (m_readFd)
+            close(m_readFd);
+        if (m_writeFd)
+            close(m_writeFd);
+    }
+    void signal() {
+        bool val = true;
+        int error = write(m_writeFd, &val, sizeof(val));
+        ASSERT_TRUE(error >= 0);
+    };
+    void wait() {
+        bool val = false;
+        int error = read(m_readFd, &val, sizeof(val));
+        ASSERT_TRUE(error >= 0);
+    }
+    template <typename T> void send(const T& v) {
+        int error = write(m_writeFd, &v, sizeof(T));
+        ASSERT_TRUE(error >= 0);
+    }
+    template <typename T> void recv(T& v) {
+        int error = read(m_readFd, &v, sizeof(T));
+        ASSERT_TRUE(error >= 0);
+    }
+    static tuple<Pipe, Pipe> createPipePair() {
+        int a[2];
+        int b[2];
+
+        int error1 = pipe(a);
+        int error2 = pipe(b);
+        ASSERT_TRUE(error1 >= 0);
+        ASSERT_TRUE(error2 >= 0);
+
+        return make_tuple(Pipe(a[0], b[1]), Pipe(b[0], a[1]));
+    }
+};
+
+static const uint32_t num_buckets = 128;
+static const uint64_t max_time_bucket = 50ull * 1000000;
+static const uint64_t time_per_bucket = max_time_bucket / num_buckets;
+static constexpr float time_per_bucket_ms = time_per_bucket / 1.0E6;
+
+struct ProcResults {
+    uint64_t m_best = max_time_bucket;
+    uint64_t m_worst = 0;
+    uint32_t m_buckets[num_buckets] = {0};
+    uint64_t m_transactions = 0;
+    uint64_t m_total_time = 0;
+
+    void add_time(uint64_t time) {
+        m_buckets[min(time, max_time_bucket-1) / time_per_bucket] += 1;
+        m_best = min(time, m_best);
+        m_worst = max(time, m_worst);
+        m_transactions += 1;
+        m_total_time += time;
+    }
+    static ProcResults combine(const ProcResults& a, const ProcResults& b) {
+        ProcResults ret;
+        for (int i = 0; i < num_buckets; i++) {
+            ret.m_buckets[i] = a.m_buckets[i] + b.m_buckets[i];
+        }
+        ret.m_worst = max(a.m_worst, b.m_worst);
+        ret.m_best = min(a.m_best, b.m_best);
+        ret.m_transactions = a.m_transactions + b.m_transactions;
+        ret.m_total_time = a.m_total_time + b.m_total_time;
+        return ret;
+    }
+    void dump() {
+        double best = (double)m_best / 1.0E6;
+        double worst = (double)m_worst / 1.0E6;
+        double average = (double)m_total_time / m_transactions / 1.0E6;
+        cout << "average:" << average << "ms worst:" << worst << "ms best:" << best << "ms" << endl;
+
+        uint64_t cur_total = 0;
+        for (int i = 0; i < num_buckets; i++) {
+            float cur_time = time_per_bucket_ms * i + 0.5f * time_per_bucket_ms;
+            if ((cur_total < 0.5f * m_transactions) && (cur_total + m_buckets[i] >= 0.5f * m_transactions)) {
+                cout << "50%: " << cur_time << " ";
+            }
+            if ((cur_total < 0.9f * m_transactions) && (cur_total + m_buckets[i] >= 0.9f * m_transactions)) {
+                cout << "90%: " << cur_time << " ";
+            }
+            if ((cur_total < 0.95f * m_transactions) && (cur_total + m_buckets[i] >= 0.95f * m_transactions)) {
+                cout << "95%: " << cur_time << " ";
+            }
+            if ((cur_total < 0.99f * m_transactions) && (cur_total + m_buckets[i] >= 0.99f * m_transactions)) {
+                cout << "99%: " << cur_time << " ";
+            }
+            cur_total += m_buckets[i];
+        }
+        cout << endl;
+
+    }
+};
+
+String16 generateServiceName(int num)
+{
+    char num_str[32];
+    snprintf(num_str, sizeof(num_str), "%d", num);
+    String16 serviceName = String16("binderWorker") + String16(num_str);
+    return serviceName;
+}
+
+void worker_fx(
+    int num,
+    int worker_count,
+    int iterations,
+    Pipe p)
+{
+    // Create BinderWorkerService and for go.
+    ProcessState::self()->startThreadPool();
+    sp<IServiceManager> serviceMgr = defaultServiceManager();
+    sp<BinderWorkerService> service = new BinderWorkerService;
+    serviceMgr->addService(generateServiceName(num), service);
+
+    srand(num);
+    p.signal();
+    p.wait();
+
+    // Get references to other binder services.
+    cout << "Created BinderWorker" << num << endl;
+    (void)worker_count;
+    vector<sp<IBinder> > workers;
+    for (int i = 0; i < worker_count; i++) {
+        if (num == i)
+            continue;
+        workers.push_back(serviceMgr->getService(generateServiceName(i)));
+    }
+
+    // Run the benchmark.
+    ProcResults results;
+    chrono::time_point<chrono::high_resolution_clock> start, end;
+    for (int i = 0; i < iterations; i++) {
+        int target = rand() % workers.size();
+        Parcel data, reply;
+        start = chrono::high_resolution_clock::now();
+        status_t ret = workers[target]->transact(BINDER_NOP, data, &reply);
+        end = chrono::high_resolution_clock::now();
+
+        uint64_t cur_time = uint64_t(chrono::duration_cast<chrono::nanoseconds>(end - start).count());
+        results.add_time(cur_time);
+
+        if (ret != NO_ERROR) {
+           cout << "thread " << num << " failed " << ret << "i : " << i << endl;
+           exit(EXIT_FAILURE);
+        }
+    }
+    // Signal completion to master and wait.
+    p.signal();
+    p.wait();
+
+    // Send results to master and wait for go to exit.
+    p.send(results);
+    p.wait();
+
+    exit(EXIT_SUCCESS);
+}
+
+Pipe make_worker(int num, int iterations, int worker_count)
+{
+    auto pipe_pair = Pipe::createPipePair();
+    pid_t pid = fork();
+    if (pid) {
+        /* parent */
+        return move(get<0>(pipe_pair));
+    } else {
+        /* child */
+        worker_fx(num, worker_count, iterations, move(get<1>(pipe_pair)));
+        /* never get here */
+        return move(get<0>(pipe_pair));
+    }
+
+}
+
+void wait_all(vector<Pipe>& v)
+{
+    for (int i = 0; i < v.size(); i++) {
+        v[i].wait();
+    }
+}
+
+void signal_all(vector<Pipe>& v)
+{
+    for (int i = 0; i < v.size(); i++) {
+        v[i].signal();
+    }
+}
+
+int main(int argc, char *argv[])
+{
+    int workers = 2;
+    int iterations = 10000;
+    (void)argc;
+    (void)argv;
+    vector<Pipe> pipes;
+
+    // Parse arguments.
+    for (int i = 1; i < argc; i++) {
+        if (string(argv[i]) == "-w") {
+            workers = atoi(argv[i+1]);
+            i++;
+            continue;
+        }
+        if (string(argv[i]) == "-i") {
+            iterations = atoi(argv[i+1]);
+            i++;
+            continue;
+        }
+    }
+
+    // Create all the workers and wait for them to spawn.
+    for (int i = 0; i < workers; i++) {
+        pipes.push_back(make_worker(i, iterations, workers));
+    }
+    wait_all(pipes);
+
+
+    // Run the workers and wait for completion.
+    chrono::time_point<chrono::high_resolution_clock> start, end;
+    cout << "waiting for workers to complete" << endl;
+    start = chrono::high_resolution_clock::now();
+    signal_all(pipes);
+    wait_all(pipes);
+    end = chrono::high_resolution_clock::now();
+
+    // Calculate overall throughput.
+    double iterations_per_sec = double(iterations * workers) / (chrono::duration_cast<chrono::nanoseconds>(end - start).count() / 1.0E9);
+    cout << "iterations per sec: " << iterations_per_sec << endl;
+
+    // Collect all results from the workers.
+    cout << "collecting results" << endl;
+    signal_all(pipes);
+    ProcResults tot_results;
+    for (int i = 0; i < workers; i++) {
+        ProcResults tmp_results;
+        pipes[i].recv(tmp_results);
+        tot_results = ProcResults::combine(tot_results, tmp_results);
+    }
+    tot_results.dump();
+
+    // Kill all the workers.
+    cout << "killing workers" << endl;
+    signal_all(pipes);
+    for (int i = 0; i < workers; i++) {
+        int status;
+        wait(&status);
+        if (status != 0) {
+            cout << "nonzero child status" << status << endl;
+        }
+    }
+    return 0;
+}
diff --git a/libs/diskusage/dirsize.c b/libs/diskusage/dirsize.c
index 24e5af0..7576994 100644
--- a/libs/diskusage/dirsize.c
+++ b/libs/diskusage/dirsize.c
@@ -18,6 +18,7 @@
 #include <dirent.h>
 #include <fcntl.h>
 #include <sys/stat.h>
+#include <unistd.h>
 
 #include <diskusage/dirsize.h>
 
diff --git a/libs/gui/Android.mk b/libs/gui/Android.mk
index c14c950..ffa0922 100644
--- a/libs/gui/Android.mk
+++ b/libs/gui/Android.mk
@@ -1,12 +1,52 @@
-LOCAL_PATH:= $(call my-dir)
+# Copyright 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES:= \
+LOCAL_CLANG := true
+LOCAL_CPPFLAGS := -std=c++1y -Weverything -Werror
+
+# The static constructors and destructors in this library have not been noted to
+# introduce significant overheads
+LOCAL_CPPFLAGS += -Wno-exit-time-destructors
+LOCAL_CPPFLAGS += -Wno-global-constructors
+
+# We only care about compiling as C++14
+LOCAL_CPPFLAGS += -Wno-c++98-compat-pedantic
+
+# We don't need to enumerate every case in a switch as long as a default case
+# is present
+LOCAL_CPPFLAGS += -Wno-switch-enum
+
+# Allow calling variadic macros without a __VA_ARGS__ list
+LOCAL_CPPFLAGS += -Wno-gnu-zero-variadic-macro-arguments
+
+# Don't warn about struct padding
+LOCAL_CPPFLAGS += -Wno-padded
+
+LOCAL_SRC_FILES := \
 	IGraphicBufferConsumer.cpp \
 	IConsumerListener.cpp \
 	BitTube.cpp \
+	BufferItem.cpp \
 	BufferItemConsumer.cpp \
 	BufferQueue.cpp \
+	BufferQueueConsumer.cpp \
+	BufferQueueCore.cpp \
+	BufferQueueProducer.cpp \
+	BufferSlot.cpp \
 	ConsumerBase.cpp \
 	CpuConsumer.cpp \
 	DisplayEventReceiver.cpp \
@@ -16,6 +56,7 @@
 	IDisplayEventConnection.cpp \
 	IGraphicBufferAlloc.cpp \
 	IGraphicBufferProducer.cpp \
+	IProducerListener.cpp \
 	ISensorEventConnection.cpp \
 	ISensorServer.cpp \
 	ISurfaceComposer.cpp \
@@ -24,6 +65,7 @@
 	Sensor.cpp \
 	SensorEventQueue.cpp \
 	SensorManager.cpp \
+	StreamSplitter.cpp \
 	Surface.cpp \
 	SurfaceControl.cpp \
 	SurfaceComposerClient.cpp \
@@ -39,8 +81,9 @@
 	libutils \
 	liblog
 
+LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libbinder
 
-LOCAL_MODULE:= libgui
+LOCAL_MODULE := libgui
 
 ifeq ($(TARGET_BOARD_PLATFORM), tegra)
 	LOCAL_CFLAGS += -DDONT_USE_FENCE_SYNC
@@ -49,6 +92,10 @@
 	LOCAL_CFLAGS += -DDONT_USE_FENCE_SYNC
 endif
 
+ifeq ($(TARGET_BOARD_HAS_NO_SURFACE_FLINGER), true)
+	LOCAL_CFLAGS += -DHAVE_NO_SURFACE_FLINGER
+endif
+
 include $(BUILD_SHARED_LIBRARY)
 
 ifeq (,$(ONE_SHOT_MAKEFILE))
diff --git a/libs/gui/BitTube.cpp b/libs/gui/BitTube.cpp
index 85a7de7..b653c5b 100644
--- a/libs/gui/BitTube.cpp
+++ b/libs/gui/BitTube.cpp
@@ -99,6 +99,11 @@
     return mReceiveFd;
 }
 
+int BitTube::getSendFd() const
+{
+    return mSendFd;
+}
+
 ssize_t BitTube::write(void const* vaddr, size_t size)
 {
     ssize_t err, len;
@@ -144,12 +149,12 @@
     ssize_t size = tube->write(vaddr, count*objSize);
 
     // should never happen because of SOCK_SEQPACKET
-    LOG_ALWAYS_FATAL_IF((size >= 0) && (size % objSize),
-            "BitTube::sendObjects(count=%d, size=%d), res=%d (partial events were sent!)",
+    LOG_ALWAYS_FATAL_IF((size >= 0) && (size % static_cast<ssize_t>(objSize)),
+            "BitTube::sendObjects(count=%zu, size=%zu), res=%zd (partial events were sent!)",
             count, objSize, size);
 
     //ALOGE_IF(size<0, "error %d sending %d events", size, count);
-    return size < 0 ? size : size / objSize;
+    return size < 0 ? size : size / static_cast<ssize_t>(objSize);
 }
 
 ssize_t BitTube::recvObjects(const sp<BitTube>& tube,
@@ -159,12 +164,12 @@
     ssize_t size = tube->read(vaddr, count*objSize);
 
     // should never happen because of SOCK_SEQPACKET
-    LOG_ALWAYS_FATAL_IF((size >= 0) && (size % objSize),
-            "BitTube::recvObjects(count=%d, size=%d), res=%d (partial events were received!)",
+    LOG_ALWAYS_FATAL_IF((size >= 0) && (size % static_cast<ssize_t>(objSize)),
+            "BitTube::recvObjects(count=%zu, size=%zu), res=%zd (partial events were received!)",
             count, objSize, size);
 
     //ALOGE_IF(size<0, "error %d receiving %d events", size, count);
-    return size < 0 ? size : size / objSize;
+    return size < 0 ? size : size / static_cast<ssize_t>(objSize);
 }
 
 // ----------------------------------------------------------------------------
diff --git a/libs/gui/BufferItem.cpp b/libs/gui/BufferItem.cpp
new file mode 100644
index 0000000..8f64ae0
--- /dev/null
+++ b/libs/gui/BufferItem.cpp
@@ -0,0 +1,217 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gui/BufferItem.h>
+
+#include <ui/Fence.h>
+#include <ui/GraphicBuffer.h>
+
+#include <system/window.h>
+
+namespace android {
+
+BufferItem::BufferItem() :
+    mTransform(0),
+    mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
+    mTimestamp(0),
+    mIsAutoTimestamp(false),
+    mDataSpace(HAL_DATASPACE_UNKNOWN),
+    mFrameNumber(0),
+    mSlot(INVALID_BUFFER_SLOT),
+    mIsDroppable(false),
+    mAcquireCalled(false),
+    mTransformToDisplayInverse(false) {
+    mCrop.makeInvalid();
+}
+
+BufferItem::~BufferItem() {}
+
+template <typename T>
+static void addAligned(size_t& size, T /* value */) {
+    size = FlattenableUtils::align<sizeof(T)>(size);
+    size += sizeof(T);
+}
+
+size_t BufferItem::getPodSize() const {
+    size_t size = 0;
+    addAligned(size, mCrop);
+    addAligned(size, mTransform);
+    addAligned(size, mScalingMode);
+    addAligned(size, mTimestampLo);
+    addAligned(size, mTimestampHi);
+    addAligned(size, mIsAutoTimestamp);
+    addAligned(size, mDataSpace);
+    addAligned(size, mFrameNumberLo);
+    addAligned(size, mFrameNumberHi);
+    addAligned(size, mSlot);
+    addAligned(size, mIsDroppable);
+    addAligned(size, mAcquireCalled);
+    addAligned(size, mTransformToDisplayInverse);
+    return size;
+}
+
+size_t BufferItem::getFlattenedSize() const {
+    size_t size = sizeof(uint32_t); // Flags
+    if (mGraphicBuffer != 0) {
+        size += mGraphicBuffer->getFlattenedSize();
+        FlattenableUtils::align<4>(size);
+    }
+    if (mFence != 0) {
+        size += mFence->getFlattenedSize();
+        FlattenableUtils::align<4>(size);
+    }
+    size += mSurfaceDamage.getFlattenedSize();
+    size = FlattenableUtils::align<8>(size);
+    return size + getPodSize();
+}
+
+size_t BufferItem::getFdCount() const {
+    size_t count = 0;
+    if (mGraphicBuffer != 0) {
+        count += mGraphicBuffer->getFdCount();
+    }
+    if (mFence != 0) {
+        count += mFence->getFdCount();
+    }
+    return count;
+}
+
+template <typename T>
+static void writeAligned(void*& buffer, size_t& size, T value) {
+    size -= FlattenableUtils::align<alignof(T)>(buffer);
+    FlattenableUtils::write(buffer, size, value);
+}
+
+status_t BufferItem::flatten(
+        void*& buffer, size_t& size, int*& fds, size_t& count) const {
+
+    // make sure we have enough space
+    if (size < BufferItem::getFlattenedSize()) {
+        return NO_MEMORY;
+    }
+
+    // content flags are stored first
+    uint32_t& flags = *static_cast<uint32_t*>(buffer);
+
+    // advance the pointer
+    FlattenableUtils::advance(buffer, size, sizeof(uint32_t));
+
+    flags = 0;
+    if (mGraphicBuffer != 0) {
+        status_t err = mGraphicBuffer->flatten(buffer, size, fds, count);
+        if (err) return err;
+        size -= FlattenableUtils::align<4>(buffer);
+        flags |= 1;
+    }
+    if (mFence != 0) {
+        status_t err = mFence->flatten(buffer, size, fds, count);
+        if (err) return err;
+        size -= FlattenableUtils::align<4>(buffer);
+        flags |= 2;
+    }
+
+    status_t err = mSurfaceDamage.flatten(buffer, size);
+    if (err) return err;
+    FlattenableUtils::advance(buffer, size, mSurfaceDamage.getFlattenedSize());
+
+    // Check we still have enough space
+    if (size < getPodSize()) {
+        return NO_MEMORY;
+    }
+
+    writeAligned(buffer, size, mCrop);
+    writeAligned(buffer, size, mTransform);
+    writeAligned(buffer, size, mScalingMode);
+    writeAligned(buffer, size, mTimestampLo);
+    writeAligned(buffer, size, mTimestampHi);
+    writeAligned(buffer, size, mIsAutoTimestamp);
+    writeAligned(buffer, size, mDataSpace);
+    writeAligned(buffer, size, mFrameNumberLo);
+    writeAligned(buffer, size, mFrameNumberHi);
+    writeAligned(buffer, size, mSlot);
+    writeAligned(buffer, size, mIsDroppable);
+    writeAligned(buffer, size, mAcquireCalled);
+    writeAligned(buffer, size, mTransformToDisplayInverse);
+
+    return NO_ERROR;
+}
+
+template <typename T>
+static void readAligned(const void*& buffer, size_t& size, T& value) {
+    size -= FlattenableUtils::align<alignof(T)>(buffer);
+    FlattenableUtils::read(buffer, size, value);
+}
+
+status_t BufferItem::unflatten(
+        void const*& buffer, size_t& size, int const*& fds, size_t& count) {
+
+    if (size < sizeof(uint32_t)) {
+        return NO_MEMORY;
+    }
+
+    uint32_t flags = 0;
+    FlattenableUtils::read(buffer, size, flags);
+
+    if (flags & 1) {
+        mGraphicBuffer = new GraphicBuffer();
+        status_t err = mGraphicBuffer->unflatten(buffer, size, fds, count);
+        if (err) return err;
+        size -= FlattenableUtils::align<4>(buffer);
+    }
+
+    if (flags & 2) {
+        mFence = new Fence();
+        status_t err = mFence->unflatten(buffer, size, fds, count);
+        if (err) return err;
+        size -= FlattenableUtils::align<4>(buffer);
+    }
+
+    status_t err = mSurfaceDamage.unflatten(buffer, size);
+    if (err) return err;
+    FlattenableUtils::advance(buffer, size, mSurfaceDamage.getFlattenedSize());
+
+    // Check we still have enough space
+    if (size < getPodSize()) {
+        return NO_MEMORY;
+    }
+
+    readAligned(buffer, size, mCrop);
+    readAligned(buffer, size, mTransform);
+    readAligned(buffer, size, mScalingMode);
+    readAligned(buffer, size, mTimestampLo);
+    readAligned(buffer, size, mTimestampHi);
+    readAligned(buffer, size, mIsAutoTimestamp);
+    readAligned(buffer, size, mDataSpace);
+    readAligned(buffer, size, mFrameNumberLo);
+    readAligned(buffer, size, mFrameNumberHi);
+    readAligned(buffer, size, mSlot);
+    readAligned(buffer, size, mIsDroppable);
+    readAligned(buffer, size, mAcquireCalled);
+    readAligned(buffer, size, mTransformToDisplayInverse);
+
+    return NO_ERROR;
+}
+
+const char* BufferItem::scalingModeName(uint32_t scalingMode) {
+    switch (scalingMode) {
+        case NATIVE_WINDOW_SCALING_MODE_FREEZE: return "FREEZE";
+        case NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW: return "SCALE_TO_WINDOW";
+        case NATIVE_WINDOW_SCALING_MODE_SCALE_CROP: return "SCALE_CROP";
+        default: return "Unknown";
+    }
+}
+
+} // namespace android
diff --git a/libs/gui/BufferItemConsumer.cpp b/libs/gui/BufferItemConsumer.cpp
index 350887a..578b8d9 100644
--- a/libs/gui/BufferItemConsumer.cpp
+++ b/libs/gui/BufferItemConsumer.cpp
@@ -16,29 +16,36 @@
 
 //#define LOG_NDEBUG 0
 #define LOG_TAG "BufferItemConsumer"
-#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+//#define ATRACE_TAG ATRACE_TAG_GRAPHICS
 #include <utils/Log.h>
 
+#include <gui/BufferItem.h>
 #include <gui/BufferItemConsumer.h>
 
-#define BI_LOGV(x, ...) ALOGV("[%s] "x, mName.string(), ##__VA_ARGS__)
-#define BI_LOGD(x, ...) ALOGD("[%s] "x, mName.string(), ##__VA_ARGS__)
-#define BI_LOGI(x, ...) ALOGI("[%s] "x, mName.string(), ##__VA_ARGS__)
-#define BI_LOGW(x, ...) ALOGW("[%s] "x, mName.string(), ##__VA_ARGS__)
-#define BI_LOGE(x, ...) ALOGE("[%s] "x, mName.string(), ##__VA_ARGS__)
+//#define BI_LOGV(x, ...) ALOGV("[%s] " x, mName.string(), ##__VA_ARGS__)
+//#define BI_LOGD(x, ...) ALOGD("[%s] " x, mName.string(), ##__VA_ARGS__)
+//#define BI_LOGI(x, ...) ALOGI("[%s] " x, mName.string(), ##__VA_ARGS__)
+//#define BI_LOGW(x, ...) ALOGW("[%s] " x, mName.string(), ##__VA_ARGS__)
+#define BI_LOGE(x, ...) ALOGE("[%s] " x, mName.string(), ##__VA_ARGS__)
 
 namespace android {
 
-BufferItemConsumer::BufferItemConsumer(const sp<BufferQueue>& bq,
-        uint32_t consumerUsage, int bufferCount, bool controlledByApp) :
-    ConsumerBase(bq, controlledByApp)
+BufferItemConsumer::BufferItemConsumer(
+        const sp<IGraphicBufferConsumer>& consumer, uint32_t consumerUsage,
+        int bufferCount, bool controlledByApp) :
+    ConsumerBase(consumer, controlledByApp)
 {
-    mConsumer->setConsumerUsageBits(consumerUsage);
-    mConsumer->setMaxAcquiredBufferCount(bufferCount);
+    status_t err = mConsumer->setConsumerUsageBits(consumerUsage);
+    LOG_ALWAYS_FATAL_IF(err != OK,
+            "Failed to set consumer usage bits to %#x", consumerUsage);
+    if (bufferCount != DEFAULT_MAX_BUFFERS) {
+        err = mConsumer->setMaxAcquiredBufferCount(bufferCount);
+        LOG_ALWAYS_FATAL_IF(err != OK,
+                "Failed to set max acquired buffer count to %d", bufferCount);
+    }
 }
 
-BufferItemConsumer::~BufferItemConsumer() {
-}
+BufferItemConsumer::~BufferItemConsumer() {}
 
 void BufferItemConsumer::setName(const String8& name) {
     Mutex::Autolock _l(mMutex);
@@ -93,14 +100,4 @@
     return err;
 }
 
-status_t BufferItemConsumer::setDefaultBufferSize(uint32_t w, uint32_t h) {
-    Mutex::Autolock _l(mMutex);
-    return mConsumer->setDefaultBufferSize(w, h);
-}
-
-status_t BufferItemConsumer::setDefaultBufferFormat(uint32_t defaultFormat) {
-    Mutex::Autolock _l(mMutex);
-    return mConsumer->setDefaultBufferFormat(defaultFormat);
-}
-
 } // namespace android
diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp
index 2aecb67..ccbb5a2 100644
--- a/libs/gui/BufferQueue.cpp
+++ b/libs/gui/BufferQueue.cpp
@@ -18,1218 +18,32 @@
 #define ATRACE_TAG ATRACE_TAG_GRAPHICS
 //#define LOG_NDEBUG 0
 
-#define GL_GLEXT_PROTOTYPES
-#define EGL_EGLEXT_PROTOTYPES
-
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-
 #include <gui/BufferQueue.h>
-#include <gui/IConsumerListener.h>
-#include <gui/ISurfaceComposer.h>
-#include <private/gui/ComposerService.h>
-
-#include <utils/Log.h>
-#include <utils/Trace.h>
-#include <utils/CallStack.h>
-
-// Macros for including the BufferQueue name in log messages
-#define ST_LOGV(x, ...) ALOGV("[%s] "x, mConsumerName.string(), ##__VA_ARGS__)
-#define ST_LOGD(x, ...) ALOGD("[%s] "x, mConsumerName.string(), ##__VA_ARGS__)
-#define ST_LOGI(x, ...) ALOGI("[%s] "x, mConsumerName.string(), ##__VA_ARGS__)
-#define ST_LOGW(x, ...) ALOGW("[%s] "x, mConsumerName.string(), ##__VA_ARGS__)
-#define ST_LOGE(x, ...) ALOGE("[%s] "x, mConsumerName.string(), ##__VA_ARGS__)
-
-#define ATRACE_BUFFER_INDEX(index)                                            \
-    if (ATRACE_ENABLED()) {                                                   \
-        char ___traceBuf[1024];                                               \
-        snprintf(___traceBuf, 1024, "%s: %d", mConsumerName.string(),         \
-                (index));                                                     \
-        android::ScopedTrace ___bufTracer(ATRACE_TAG, ___traceBuf);           \
-    }
+#include <gui/BufferQueueConsumer.h>
+#include <gui/BufferQueueCore.h>
+#include <gui/BufferQueueProducer.h>
 
 namespace android {
 
-// Get an ID that's unique within this process.
-static int32_t createProcessUniqueId() {
-    static volatile int32_t globalCounter = 0;
-    return android_atomic_inc(&globalCounter);
-}
-
-static const char* scalingModeName(int scalingMode) {
-    switch (scalingMode) {
-        case NATIVE_WINDOW_SCALING_MODE_FREEZE: return "FREEZE";
-        case NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW: return "SCALE_TO_WINDOW";
-        case NATIVE_WINDOW_SCALING_MODE_SCALE_CROP: return "SCALE_CROP";
-        default: return "Unknown";
-    }
-}
-
-BufferQueue::BufferQueue(const sp<IGraphicBufferAlloc>& allocator) :
-    mDefaultWidth(1),
-    mDefaultHeight(1),
-    mMaxAcquiredBufferCount(1),
-    mDefaultMaxBufferCount(2),
-    mOverrideMaxBufferCount(0),
-    mConsumerControlledByApp(false),
-    mDequeueBufferCannotBlock(false),
-    mUseAsyncBuffer(true),
-    mConnectedApi(NO_CONNECTED_API),
-    mAbandoned(false),
-    mFrameCounter(0),
-    mBufferHasBeenQueued(false),
-    mDefaultBufferFormat(PIXEL_FORMAT_RGBA_8888),
-    mConsumerUsageBits(0),
-    mTransformHint(0)
-{
-    // Choose a name using the PID and a process-unique ID.
-    mConsumerName = String8::format("unnamed-%d-%d", getpid(), createProcessUniqueId());
-
-    ST_LOGV("BufferQueue");
-    if (allocator == NULL) {
-        sp<ISurfaceComposer> composer(ComposerService::getComposerService());
-        mGraphicBufferAlloc = composer->createGraphicBufferAlloc();
-        if (mGraphicBufferAlloc == 0) {
-            ST_LOGE("createGraphicBufferAlloc() failed in BufferQueue()");
-        }
-    } else {
-        mGraphicBufferAlloc = allocator;
-    }
-}
-
-BufferQueue::~BufferQueue() {
-    ST_LOGV("~BufferQueue");
-}
-
-status_t BufferQueue::setDefaultMaxBufferCountLocked(int count) {
-    const int minBufferCount = mUseAsyncBuffer ? 2 : 1;
-    if (count < minBufferCount || count > NUM_BUFFER_SLOTS)
-        return BAD_VALUE;
-
-    mDefaultMaxBufferCount = count;
-    mDequeueCondition.broadcast();
-
-    return NO_ERROR;
-}
-
-void BufferQueue::setConsumerName(const String8& name) {
-    Mutex::Autolock lock(mMutex);
-    mConsumerName = name;
-}
-
-status_t BufferQueue::setDefaultBufferFormat(uint32_t defaultFormat) {
-    Mutex::Autolock lock(mMutex);
-    mDefaultBufferFormat = defaultFormat;
-    return NO_ERROR;
-}
-
-status_t BufferQueue::setConsumerUsageBits(uint32_t usage) {
-    Mutex::Autolock lock(mMutex);
-    mConsumerUsageBits = usage;
-    return NO_ERROR;
-}
-
-status_t BufferQueue::setTransformHint(uint32_t hint) {
-    ST_LOGV("setTransformHint: %02x", hint);
-    Mutex::Autolock lock(mMutex);
-    mTransformHint = hint;
-    return NO_ERROR;
-}
-
-status_t BufferQueue::setBufferCount(int bufferCount) {
-    ST_LOGV("setBufferCount: count=%d", bufferCount);
-
-    sp<IConsumerListener> listener;
-    {
-        Mutex::Autolock lock(mMutex);
-
-        if (mAbandoned) {
-            ST_LOGE("setBufferCount: BufferQueue has been abandoned!");
-            return NO_INIT;
-        }
-        if (bufferCount > NUM_BUFFER_SLOTS) {
-            ST_LOGE("setBufferCount: bufferCount too large (max %d)",
-                    NUM_BUFFER_SLOTS);
-            return BAD_VALUE;
-        }
-
-        // Error out if the user has dequeued buffers
-        for (int i=0 ; i<NUM_BUFFER_SLOTS; i++) {
-            if (mSlots[i].mBufferState == BufferSlot::DEQUEUED) {
-                ST_LOGE("setBufferCount: client owns some buffers");
-                return -EINVAL;
-            }
-        }
-
-        if (bufferCount == 0) {
-            mOverrideMaxBufferCount = 0;
-            mDequeueCondition.broadcast();
-            return NO_ERROR;
-        }
-
-        // fine to assume async to false before we're setting the buffer count
-        const int minBufferSlots = getMinMaxBufferCountLocked(false);
-        if (bufferCount < minBufferSlots) {
-            ST_LOGE("setBufferCount: requested buffer count (%d) is less than "
-                    "minimum (%d)", bufferCount, minBufferSlots);
-            return BAD_VALUE;
-        }
-
-        // here we're guaranteed that the client doesn't have dequeued buffers
-        // and will release all of its buffer references.  We don't clear the
-        // queue, however, so currently queued buffers still get displayed.
-        freeAllBuffersLocked();
-        mOverrideMaxBufferCount = bufferCount;
-        mDequeueCondition.broadcast();
-        listener = mConsumerListener;
-    } // scope for lock
-
-    if (listener != NULL) {
-        listener->onBuffersReleased();
-    }
-
-    return NO_ERROR;
-}
-
-int BufferQueue::query(int what, int* outValue)
-{
-    ATRACE_CALL();
-    Mutex::Autolock lock(mMutex);
-
-    if (mAbandoned) {
-        ST_LOGE("query: BufferQueue has been abandoned!");
-        return NO_INIT;
-    }
-
-    int value;
-    switch (what) {
-    case NATIVE_WINDOW_WIDTH:
-        value = mDefaultWidth;
-        break;
-    case NATIVE_WINDOW_HEIGHT:
-        value = mDefaultHeight;
-        break;
-    case NATIVE_WINDOW_FORMAT:
-        value = mDefaultBufferFormat;
-        break;
-    case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
-        value = getMinUndequeuedBufferCount(false);
-        break;
-    case NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND:
-        value = (mQueue.size() >= 2);
-        break;
-    case NATIVE_WINDOW_CONSUMER_USAGE_BITS:
-        value = mConsumerUsageBits;
-        break;
-    default:
-        return BAD_VALUE;
-    }
-    outValue[0] = value;
-    return NO_ERROR;
-}
-
-status_t BufferQueue::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
-    ATRACE_CALL();
-    ST_LOGV("requestBuffer: slot=%d", slot);
-    Mutex::Autolock lock(mMutex);
-    if (mAbandoned) {
-        ST_LOGE("requestBuffer: BufferQueue has been abandoned!");
-        return NO_INIT;
-    }
-    if (slot < 0 || slot >= NUM_BUFFER_SLOTS) {
-        ST_LOGE("requestBuffer: slot index out of range [0, %d]: %d",
-                NUM_BUFFER_SLOTS, slot);
-        return BAD_VALUE;
-    } else if (mSlots[slot].mBufferState != BufferSlot::DEQUEUED) {
-        ST_LOGE("requestBuffer: slot %d is not owned by the client (state=%d)",
-                slot, mSlots[slot].mBufferState);
-        return BAD_VALUE;
-    }
-    mSlots[slot].mRequestBufferCalled = true;
-    *buf = mSlots[slot].mGraphicBuffer;
-    return NO_ERROR;
-}
-
-status_t BufferQueue::dequeueBuffer(int *outBuf, sp<Fence>* outFence, bool async,
-        uint32_t w, uint32_t h, uint32_t format, uint32_t usage) {
-    ATRACE_CALL();
-    ST_LOGV("dequeueBuffer: w=%d h=%d fmt=%#x usage=%#x", w, h, format, usage);
-
-    if ((w && !h) || (!w && h)) {
-        ST_LOGE("dequeueBuffer: invalid size: w=%u, h=%u", w, h);
-        return BAD_VALUE;
-    }
-
-    status_t returnFlags(OK);
-    EGLDisplay dpy = EGL_NO_DISPLAY;
-    EGLSyncKHR eglFence = EGL_NO_SYNC_KHR;
-
-    { // Scope for the lock
-        Mutex::Autolock lock(mMutex);
-
-        if (format == 0) {
-            format = mDefaultBufferFormat;
-        }
-        // turn on usage bits the consumer requested
-        usage |= mConsumerUsageBits;
-
-        int found = -1;
-        bool tryAgain = true;
-        while (tryAgain) {
-            if (mAbandoned) {
-                ST_LOGE("dequeueBuffer: BufferQueue has been abandoned!");
-                return NO_INIT;
-            }
-
-            const int maxBufferCount = getMaxBufferCountLocked(async);
-            if (async && mOverrideMaxBufferCount) {
-                // FIXME: some drivers are manually setting the buffer-count (which they
-                // shouldn't), so we do this extra test here to handle that case.
-                // This is TEMPORARY, until we get this fixed.
-                if (mOverrideMaxBufferCount < maxBufferCount) {
-                    ST_LOGE("dequeueBuffer: async mode is invalid with buffercount override");
-                    return BAD_VALUE;
-                }
-            }
-
-            // Free up any buffers that are in slots beyond the max buffer
-            // count.
-            for (int i = maxBufferCount; i < NUM_BUFFER_SLOTS; i++) {
-                assert(mSlots[i].mBufferState == BufferSlot::FREE);
-                if (mSlots[i].mGraphicBuffer != NULL) {
-                    freeBufferLocked(i);
-                    returnFlags |= IGraphicBufferProducer::RELEASE_ALL_BUFFERS;
-                }
-            }
-
-            // look for a free buffer to give to the client
-            found = INVALID_BUFFER_SLOT;
-            int dequeuedCount = 0;
-            int acquiredCount = 0;
-            for (int i = 0; i < maxBufferCount; i++) {
-                const int state = mSlots[i].mBufferState;
-                switch (state) {
-                    case BufferSlot::DEQUEUED:
-                        dequeuedCount++;
-                        break;
-                    case BufferSlot::ACQUIRED:
-                        acquiredCount++;
-                        break;
-                    case BufferSlot::FREE:
-                        /* We return the oldest of the free buffers to avoid
-                         * stalling the producer if possible.  This is because
-                         * the consumer may still have pending reads of the
-                         * buffers in flight.
-                         */
-                        if ((found < 0) ||
-                                mSlots[i].mFrameNumber < mSlots[found].mFrameNumber) {
-                            found = i;
-                        }
-                        break;
-                }
-            }
-
-            // clients are not allowed to dequeue more than one buffer
-            // if they didn't set a buffer count.
-            if (!mOverrideMaxBufferCount && dequeuedCount) {
-                ST_LOGE("dequeueBuffer: can't dequeue multiple buffers without "
-                        "setting the buffer count");
-                return -EINVAL;
-            }
-
-            // See whether a buffer has been queued since the last
-            // setBufferCount so we know whether to perform the min undequeued
-            // buffers check below.
-            if (mBufferHasBeenQueued) {
-                // make sure the client is not trying to dequeue more buffers
-                // than allowed.
-                const int newUndequeuedCount = maxBufferCount - (dequeuedCount+1);
-                const int minUndequeuedCount = getMinUndequeuedBufferCount(async);
-                if (newUndequeuedCount < minUndequeuedCount) {
-                    ST_LOGE("dequeueBuffer: min undequeued buffer count (%d) "
-                            "exceeded (dequeued=%d undequeudCount=%d)",
-                            minUndequeuedCount, dequeuedCount,
-                            newUndequeuedCount);
-                    return -EBUSY;
-                }
-            }
-
-            // If no buffer is found, wait for a buffer to be released or for
-            // the max buffer count to change.
-            tryAgain = found == INVALID_BUFFER_SLOT;
-            if (tryAgain) {
-                // return an error if we're in "cannot block" mode (producer and consumer
-                // are controlled by the application) -- however, the consumer is allowed
-                // to acquire briefly an extra buffer (which could cause us to have to wait here)
-                // and that's okay because we know the wait will be brief (it happens
-                // if we dequeue a buffer while the consumer has acquired one but not released
-                // the old one yet -- for e.g.: see GLConsumer::updateTexImage()).
-                if (mDequeueBufferCannotBlock && (acquiredCount <= mMaxAcquiredBufferCount)) {
-                    ST_LOGE("dequeueBuffer: would block! returning an error instead.");
-                    return WOULD_BLOCK;
-                }
-                mDequeueCondition.wait(mMutex);
-            }
-        }
-
-
-        if (found == INVALID_BUFFER_SLOT) {
-            // This should not happen.
-            ST_LOGE("dequeueBuffer: no available buffer slots");
-            return -EBUSY;
-        }
-
-        const int buf = found;
-        *outBuf = found;
-
-        ATRACE_BUFFER_INDEX(buf);
-
-        const bool useDefaultSize = !w && !h;
-        if (useDefaultSize) {
-            // use the default size
-            w = mDefaultWidth;
-            h = mDefaultHeight;
-        }
-
-        mSlots[buf].mBufferState = BufferSlot::DEQUEUED;
-
-        const sp<GraphicBuffer>& buffer(mSlots[buf].mGraphicBuffer);
-        if ((buffer == NULL) ||
-            (uint32_t(buffer->width)  != w) ||
-            (uint32_t(buffer->height) != h) ||
-            (uint32_t(buffer->format) != format) ||
-            ((uint32_t(buffer->usage) & usage) != usage))
-        {
-            mSlots[buf].mAcquireCalled = false;
-            mSlots[buf].mGraphicBuffer = NULL;
-            mSlots[buf].mRequestBufferCalled = false;
-            mSlots[buf].mEglFence = EGL_NO_SYNC_KHR;
-            mSlots[buf].mFence = Fence::NO_FENCE;
-            mSlots[buf].mEglDisplay = EGL_NO_DISPLAY;
-
-            returnFlags |= IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION;
-        }
-
-
-        if (CC_UNLIKELY(mSlots[buf].mFence == NULL)) {
-            ST_LOGE("dequeueBuffer: about to return a NULL fence from mSlot. "
-                    "buf=%d, w=%d, h=%d, format=%d",
-                    buf, buffer->width, buffer->height, buffer->format);
-        }
-
-        dpy = mSlots[buf].mEglDisplay;
-        eglFence = mSlots[buf].mEglFence;
-        *outFence = mSlots[buf].mFence;
-        mSlots[buf].mEglFence = EGL_NO_SYNC_KHR;
-        mSlots[buf].mFence = Fence::NO_FENCE;
-    }  // end lock scope
-
-    if (returnFlags & IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION) {
-        status_t error;
-        sp<GraphicBuffer> graphicBuffer(
-                mGraphicBufferAlloc->createGraphicBuffer(w, h, format, usage, &error));
-        if (graphicBuffer == 0) {
-            ST_LOGE("dequeueBuffer: SurfaceComposer::createGraphicBuffer failed");
-            return error;
-        }
-
-        { // Scope for the lock
-            Mutex::Autolock lock(mMutex);
-
-            if (mAbandoned) {
-                ST_LOGE("dequeueBuffer: BufferQueue has been abandoned!");
-                return NO_INIT;
-            }
-
-            mSlots[*outBuf].mFrameNumber = ~0;
-            mSlots[*outBuf].mGraphicBuffer = graphicBuffer;
-        }
-    }
-
-    if (eglFence != EGL_NO_SYNC_KHR) {
-        EGLint result = eglClientWaitSyncKHR(dpy, eglFence, 0, 1000000000);
-        // If something goes wrong, log the error, but return the buffer without
-        // synchronizing access to it.  It's too late at this point to abort the
-        // dequeue operation.
-        if (result == EGL_FALSE) {
-            ST_LOGE("dequeueBuffer: error waiting for fence: %#x", eglGetError());
-        } else if (result == EGL_TIMEOUT_EXPIRED_KHR) {
-            ST_LOGE("dequeueBuffer: timeout waiting for fence");
-        }
-        eglDestroySyncKHR(dpy, eglFence);
-    }
-
-    ST_LOGV("dequeueBuffer: returning slot=%d/%llu buf=%p flags=%#x", *outBuf,
-            mSlots[*outBuf].mFrameNumber,
-            mSlots[*outBuf].mGraphicBuffer->handle, returnFlags);
-
-    return returnFlags;
-}
-
-status_t BufferQueue::queueBuffer(int buf,
-        const QueueBufferInput& input, QueueBufferOutput* output) {
-    ATRACE_CALL();
-    ATRACE_BUFFER_INDEX(buf);
-
-    Rect crop;
-    uint32_t transform;
-    int scalingMode;
-    int64_t timestamp;
-    bool isAutoTimestamp;
-    bool async;
-    sp<Fence> fence;
-
-    input.deflate(&timestamp, &isAutoTimestamp, &crop, &scalingMode, &transform,
-            &async, &fence);
-
-    if (fence == NULL) {
-        ST_LOGE("queueBuffer: fence is NULL");
-        return BAD_VALUE;
-    }
-
-    switch (scalingMode) {
-        case NATIVE_WINDOW_SCALING_MODE_FREEZE:
-        case NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW:
-        case NATIVE_WINDOW_SCALING_MODE_SCALE_CROP:
-        case NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP:
-            break;
-        default:
-            ST_LOGE("unknown scaling mode: %d", scalingMode);
-            return -EINVAL;
-    }
-
-    sp<IConsumerListener> listener;
-
-    { // scope for the lock
-        Mutex::Autolock lock(mMutex);
-
-        if (mAbandoned) {
-            ST_LOGE("queueBuffer: BufferQueue has been abandoned!");
-            return NO_INIT;
-        }
-
-        const int maxBufferCount = getMaxBufferCountLocked(async);
-        if (async && mOverrideMaxBufferCount) {
-            // FIXME: some drivers are manually setting the buffer-count (which they
-            // shouldn't), so we do this extra test here to handle that case.
-            // This is TEMPORARY, until we get this fixed.
-            if (mOverrideMaxBufferCount < maxBufferCount) {
-                ST_LOGE("queueBuffer: async mode is invalid with buffercount override");
-                return BAD_VALUE;
-            }
-        }
-        if (buf < 0 || buf >= maxBufferCount) {
-            ST_LOGE("queueBuffer: slot index out of range [0, %d]: %d",
-                    maxBufferCount, buf);
-            return -EINVAL;
-        } else if (mSlots[buf].mBufferState != BufferSlot::DEQUEUED) {
-            ST_LOGE("queueBuffer: slot %d is not owned by the client "
-                    "(state=%d)", buf, mSlots[buf].mBufferState);
-            return -EINVAL;
-        } else if (!mSlots[buf].mRequestBufferCalled) {
-            ST_LOGE("queueBuffer: slot %d was enqueued without requesting a "
-                    "buffer", buf);
-            return -EINVAL;
-        }
-
-        ST_LOGV("queueBuffer: slot=%d/%llu time=%#llx crop=[%d,%d,%d,%d] "
-                "tr=%#x scale=%s",
-                buf, mFrameCounter + 1, timestamp,
-                crop.left, crop.top, crop.right, crop.bottom,
-                transform, scalingModeName(scalingMode));
-
-        const sp<GraphicBuffer>& graphicBuffer(mSlots[buf].mGraphicBuffer);
-        Rect bufferRect(graphicBuffer->getWidth(), graphicBuffer->getHeight());
-        Rect croppedCrop;
-        crop.intersect(bufferRect, &croppedCrop);
-        if (croppedCrop != crop) {
-            ST_LOGE("queueBuffer: crop rect is not contained within the "
-                    "buffer in slot %d", buf);
-            return -EINVAL;
-        }
-
-        mSlots[buf].mFence = fence;
-        mSlots[buf].mBufferState = BufferSlot::QUEUED;
-        mFrameCounter++;
-        mSlots[buf].mFrameNumber = mFrameCounter;
-
-        BufferItem item;
-        item.mAcquireCalled = mSlots[buf].mAcquireCalled;
-        item.mGraphicBuffer = mSlots[buf].mGraphicBuffer;
-        item.mCrop = crop;
-        item.mTransform = transform & ~NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY;
-        item.mTransformToDisplayInverse = bool(transform & NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY);
-        item.mScalingMode = scalingMode;
-        item.mTimestamp = timestamp;
-        item.mIsAutoTimestamp = isAutoTimestamp;
-        item.mFrameNumber = mFrameCounter;
-        item.mBuf = buf;
-        item.mFence = fence;
-        item.mIsDroppable = mDequeueBufferCannotBlock || async;
-
-        if (mQueue.empty()) {
-            // when the queue is empty, we can ignore "mDequeueBufferCannotBlock", and
-            // simply queue this buffer.
-            mQueue.push_back(item);
-            listener = mConsumerListener;
-        } else {
-            // when the queue is not empty, we need to look at the front buffer
-            // state and see if we need to replace it.
-            Fifo::iterator front(mQueue.begin());
-            if (front->mIsDroppable) {
-                // buffer slot currently queued is marked free if still tracked
-                if (stillTracking(front)) {
-                    mSlots[front->mBuf].mBufferState = BufferSlot::FREE;
-                    // reset the frame number of the freed buffer so that it is the first in
-                    // line to be dequeued again.
-                    mSlots[front->mBuf].mFrameNumber = 0;
-                }
-                // and we record the new buffer in the queued list
-                *front = item;
-            } else {
-                mQueue.push_back(item);
-                listener = mConsumerListener;
-            }
-        }
-
-        mBufferHasBeenQueued = true;
-        mDequeueCondition.broadcast();
-
-        output->inflate(mDefaultWidth, mDefaultHeight, mTransformHint,
-                mQueue.size());
-
-        ATRACE_INT(mConsumerName.string(), mQueue.size());
-    } // scope for the lock
-
-    // call back without lock held
-    if (listener != 0) {
-        listener->onFrameAvailable();
-    }
-    return NO_ERROR;
-}
-
-void BufferQueue::cancelBuffer(int buf, const sp<Fence>& fence) {
-    ATRACE_CALL();
-    ST_LOGV("cancelBuffer: slot=%d", buf);
-    Mutex::Autolock lock(mMutex);
-
-    if (mAbandoned) {
-        ST_LOGW("cancelBuffer: BufferQueue has been abandoned!");
-        return;
-    }
-
-    if (buf < 0 || buf >= NUM_BUFFER_SLOTS) {
-        ST_LOGE("cancelBuffer: slot index out of range [0, %d]: %d",
-                NUM_BUFFER_SLOTS, buf);
-        return;
-    } else if (mSlots[buf].mBufferState != BufferSlot::DEQUEUED) {
-        ST_LOGE("cancelBuffer: slot %d is not owned by the client (state=%d)",
-                buf, mSlots[buf].mBufferState);
-        return;
-    } else if (fence == NULL) {
-        ST_LOGE("cancelBuffer: fence is NULL");
-        return;
-    }
-    mSlots[buf].mBufferState = BufferSlot::FREE;
-    mSlots[buf].mFrameNumber = 0;
-    mSlots[buf].mFence = fence;
-    mDequeueCondition.broadcast();
-}
-
-
-status_t BufferQueue::connect(const sp<IBinder>& token,
-        int api, bool producerControlledByApp, QueueBufferOutput* output) {
-    ATRACE_CALL();
-    ST_LOGV("connect: api=%d producerControlledByApp=%s", api,
-            producerControlledByApp ? "true" : "false");
-    Mutex::Autolock lock(mMutex);
-
-retry:
-    if (mAbandoned) {
-        ST_LOGE("connect: BufferQueue has been abandoned!");
-        return NO_INIT;
-    }
-
-    if (mConsumerListener == NULL) {
-        ST_LOGE("connect: BufferQueue has no consumer!");
-        return NO_INIT;
-    }
-
-    if (mConnectedApi != NO_CONNECTED_API) {
-        ST_LOGE("connect: already connected (cur=%d, req=%d)",
-                mConnectedApi, api);
-        return -EINVAL;
-    }
-
-    // If we disconnect and reconnect quickly, we can be in a state where our slots are
-    // empty but we have many buffers in the queue.  This can cause us to run out of
-    // memory if we outrun the consumer.  Wait here if it looks like we have too many
-    // buffers queued up.
-    int maxBufferCount = getMaxBufferCountLocked(false);    // worst-case, i.e. largest value
-    if (mQueue.size() > (size_t) maxBufferCount) {
-        // TODO: make this bound tighter?
-        ST_LOGV("queue size is %d, waiting", mQueue.size());
-        mDequeueCondition.wait(mMutex);
-        goto retry;
-    }
-
-    int err = NO_ERROR;
-    switch (api) {
-        case NATIVE_WINDOW_API_EGL:
-        case NATIVE_WINDOW_API_CPU:
-        case NATIVE_WINDOW_API_MEDIA:
-        case NATIVE_WINDOW_API_CAMERA:
-            mConnectedApi = api;
-            output->inflate(mDefaultWidth, mDefaultHeight, mTransformHint, mQueue.size());
-
-            // set-up a death notification so that we can disconnect
-            // automatically when/if the remote producer dies.
-            if (token != NULL && token->remoteBinder() != NULL) {
-                status_t err = token->linkToDeath(static_cast<IBinder::DeathRecipient*>(this));
-                if (err == NO_ERROR) {
-                    mConnectedProducerToken = token;
-                } else {
-                    ALOGE("linkToDeath failed: %s (%d)", strerror(-err), err);
-                }
-            }
-            break;
-        default:
-            err = -EINVAL;
-            break;
-    }
-
-    mBufferHasBeenQueued = false;
-    mDequeueBufferCannotBlock = mConsumerControlledByApp && producerControlledByApp;
-
-    return err;
-}
-
-void BufferQueue::binderDied(const wp<IBinder>& who) {
-    // If we're here, it means that a producer we were connected to died.
-    // We're GUARANTEED that we still are connected to it because it has no other way
-    // to get disconnected -- or -- we wouldn't be here because we're removing this
-    // callback upon disconnect. Therefore, it's okay to read mConnectedApi without
-    // synchronization here.
-    int api = mConnectedApi;
-    this->disconnect(api);
-}
-
-status_t BufferQueue::disconnect(int api) {
-    ATRACE_CALL();
-    ST_LOGV("disconnect: api=%d", api);
-
-    int err = NO_ERROR;
-    sp<IConsumerListener> listener;
-
-    { // Scope for the lock
-        Mutex::Autolock lock(mMutex);
-
-        if (mAbandoned) {
-            // it is not really an error to disconnect after the surface
-            // has been abandoned, it should just be a no-op.
-            return NO_ERROR;
-        }
-
-        switch (api) {
-            case NATIVE_WINDOW_API_EGL:
-            case NATIVE_WINDOW_API_CPU:
-            case NATIVE_WINDOW_API_MEDIA:
-            case NATIVE_WINDOW_API_CAMERA:
-                if (mConnectedApi == api) {
-                    freeAllBuffersLocked();
-                    // remove our death notification callback if we have one
-                    sp<IBinder> token = mConnectedProducerToken;
-                    if (token != NULL) {
-                        // this can fail if we're here because of the death notification
-                        // either way, we just ignore.
-                        token->unlinkToDeath(static_cast<IBinder::DeathRecipient*>(this));
-                    }
-                    mConnectedProducerToken = NULL;
-                    mConnectedApi = NO_CONNECTED_API;
-                    mDequeueCondition.broadcast();
-                    listener = mConsumerListener;
-                } else {
-                    ST_LOGE("disconnect: connected to another api (cur=%d, req=%d)",
-                            mConnectedApi, api);
-                    err = -EINVAL;
-                }
-                break;
-            default:
-                ST_LOGE("disconnect: unknown API %d", api);
-                err = -EINVAL;
-                break;
-        }
-    }
-
-    if (listener != NULL) {
-        listener->onBuffersReleased();
-    }
-
-    return err;
-}
-
-void BufferQueue::dump(String8& result, const char* prefix) const {
-    Mutex::Autolock _l(mMutex);
-
-    String8 fifo;
-    int fifoSize = 0;
-    Fifo::const_iterator i(mQueue.begin());
-    while (i != mQueue.end()) {
-        fifo.appendFormat("%02d:%p crop=[%d,%d,%d,%d], "
-                "xform=0x%02x, time=%#llx, scale=%s\n",
-                i->mBuf, i->mGraphicBuffer.get(),
-                i->mCrop.left, i->mCrop.top, i->mCrop.right,
-                i->mCrop.bottom, i->mTransform, i->mTimestamp,
-                scalingModeName(i->mScalingMode)
-                );
-        i++;
-        fifoSize++;
-    }
-
-
-    result.appendFormat(
-            "%s-BufferQueue mMaxAcquiredBufferCount=%d, mDequeueBufferCannotBlock=%d, default-size=[%dx%d], "
-            "default-format=%d, transform-hint=%02x, FIFO(%d)={%s}\n",
-            prefix, mMaxAcquiredBufferCount, mDequeueBufferCannotBlock, mDefaultWidth,
-            mDefaultHeight, mDefaultBufferFormat, mTransformHint,
-            fifoSize, fifo.string());
-
-    struct {
-        const char * operator()(int state) const {
-            switch (state) {
-                case BufferSlot::DEQUEUED: return "DEQUEUED";
-                case BufferSlot::QUEUED: return "QUEUED";
-                case BufferSlot::FREE: return "FREE";
-                case BufferSlot::ACQUIRED: return "ACQUIRED";
-                default: return "Unknown";
-            }
-        }
-    } stateName;
-
-    // just trim the free buffers to not spam the dump
-    int maxBufferCount = 0;
-    for (int i=NUM_BUFFER_SLOTS-1 ; i>=0 ; i--) {
-        const BufferSlot& slot(mSlots[i]);
-        if ((slot.mBufferState != BufferSlot::FREE) || (slot.mGraphicBuffer != NULL)) {
-            maxBufferCount = i+1;
-            break;
-        }
-    }
-
-    for (int i=0 ; i<maxBufferCount ; i++) {
-        const BufferSlot& slot(mSlots[i]);
-        const sp<GraphicBuffer>& buf(slot.mGraphicBuffer);
-        result.appendFormat(
-            "%s%s[%02d:%p] state=%-8s",
-                prefix, (slot.mBufferState == BufferSlot::ACQUIRED)?">":" ", i, buf.get(),
-                stateName(slot.mBufferState)
-        );
-
-        if (buf != NULL) {
-            result.appendFormat(
-                    ", %p [%4ux%4u:%4u,%3X]",
-                    buf->handle, buf->width, buf->height, buf->stride,
-                    buf->format);
-        }
-        result.append("\n");
-    }
-}
-
-void BufferQueue::freeBufferLocked(int slot) {
-    ST_LOGV("freeBufferLocked: slot=%d", slot);
-    mSlots[slot].mGraphicBuffer = 0;
-    if (mSlots[slot].mBufferState == BufferSlot::ACQUIRED) {
-        mSlots[slot].mNeedsCleanupOnRelease = true;
-    }
-    mSlots[slot].mBufferState = BufferSlot::FREE;
-    mSlots[slot].mFrameNumber = 0;
-    mSlots[slot].mAcquireCalled = false;
-
-    // destroy fence as BufferQueue now takes ownership
-    if (mSlots[slot].mEglFence != EGL_NO_SYNC_KHR) {
-        eglDestroySyncKHR(mSlots[slot].mEglDisplay, mSlots[slot].mEglFence);
-        mSlots[slot].mEglFence = EGL_NO_SYNC_KHR;
-    }
-    mSlots[slot].mFence = Fence::NO_FENCE;
-}
-
-void BufferQueue::freeAllBuffersLocked() {
-    mBufferHasBeenQueued = false;
-    for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
-        freeBufferLocked(i);
-    }
-}
-
-status_t BufferQueue::acquireBuffer(BufferItem *buffer, nsecs_t expectedPresent) {
-    ATRACE_CALL();
-    Mutex::Autolock _l(mMutex);
-
-    // Check that the consumer doesn't currently have the maximum number of
-    // buffers acquired.  We allow the max buffer count to be exceeded by one
-    // buffer, so that the consumer can successfully set up the newly acquired
-    // buffer before releasing the old one.
-    int numAcquiredBuffers = 0;
-    for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
-        if (mSlots[i].mBufferState == BufferSlot::ACQUIRED) {
-            numAcquiredBuffers++;
-        }
-    }
-    if (numAcquiredBuffers >= mMaxAcquiredBufferCount+1) {
-        ST_LOGE("acquireBuffer: max acquired buffer count reached: %d (max=%d)",
-                numAcquiredBuffers, mMaxAcquiredBufferCount);
-        return INVALID_OPERATION;
-    }
-
-    // check if queue is empty
-    // In asynchronous mode the list is guaranteed to be one buffer
-    // deep, while in synchronous mode we use the oldest buffer.
-    if (mQueue.empty()) {
-        return NO_BUFFER_AVAILABLE;
-    }
-
-    Fifo::iterator front(mQueue.begin());
-
-    // If expectedPresent is specified, we may not want to return a buffer yet.
-    // If it's specified and there's more than one buffer queued, we may
-    // want to drop a buffer.
-    if (expectedPresent != 0) {
-        const int MAX_REASONABLE_NSEC = 1000000000ULL;  // 1 second
-
-        // The "expectedPresent" argument indicates when the buffer is expected
-        // to be presented on-screen.  If the buffer's desired-present time
-        // is earlier (less) than expectedPresent, meaning it'll be displayed
-        // on time or possibly late if we show it ASAP, we acquire and return
-        // it.  If we don't want to display it until after the expectedPresent
-        // time, we return PRESENT_LATER without acquiring it.
-        //
-        // To be safe, we don't defer acquisition if expectedPresent is
-        // more than one second in the future beyond the desired present time
-        // (i.e. we'd be holding the buffer for a long time).
-        //
-        // NOTE: code assumes monotonic time values from the system clock are
-        // positive.
-
-        // Start by checking to see if we can drop frames.  We skip this check
-        // if the timestamps are being auto-generated by Surface -- if the
-        // app isn't generating timestamps explicitly, they probably don't
-        // want frames to be discarded based on them.
-        while (mQueue.size() > 1 && !mQueue[0].mIsAutoTimestamp) {
-            // If entry[1] is timely, drop entry[0] (and repeat).  We apply
-            // an additional criteria here: we only drop the earlier buffer if
-            // our desiredPresent falls within +/- 1 second of the expected
-            // present.  Otherwise, bogus desiredPresent times (e.g. 0 or
-            // a small relative timestamp), which normally mean "ignore the
-            // timestamp and acquire immediately", would cause us to drop
-            // frames.
-            //
-            // We may want to add an additional criteria: don't drop the
-            // earlier buffer if entry[1]'s fence hasn't signaled yet.
-            //
-            // (Vector front is [0], back is [size()-1])
-            const BufferItem& bi(mQueue[1]);
-            nsecs_t desiredPresent = bi.mTimestamp;
-            if (desiredPresent < expectedPresent - MAX_REASONABLE_NSEC ||
-                    desiredPresent > expectedPresent) {
-                // This buffer is set to display in the near future, or
-                // desiredPresent is garbage.  Either way we don't want to
-                // drop the previous buffer just to get this on screen sooner.
-                ST_LOGV("pts nodrop: des=%lld expect=%lld (%lld) now=%lld",
-                        desiredPresent, expectedPresent, desiredPresent - expectedPresent,
-                        systemTime(CLOCK_MONOTONIC));
-                break;
-            }
-            ST_LOGV("pts drop: queue1des=%lld expect=%lld size=%d",
-                    desiredPresent, expectedPresent, mQueue.size());
-            if (stillTracking(front)) {
-                // front buffer is still in mSlots, so mark the slot as free
-                mSlots[front->mBuf].mBufferState = BufferSlot::FREE;
-            }
-            mQueue.erase(front);
-            front = mQueue.begin();
-        }
-
-        // See if the front buffer is due.
-        nsecs_t desiredPresent = front->mTimestamp;
-        if (desiredPresent > expectedPresent &&
-                desiredPresent < expectedPresent + MAX_REASONABLE_NSEC) {
-            ST_LOGV("pts defer: des=%lld expect=%lld (%lld) now=%lld",
-                    desiredPresent, expectedPresent, desiredPresent - expectedPresent,
-                    systemTime(CLOCK_MONOTONIC));
-            return PRESENT_LATER;
-        }
-
-        ST_LOGV("pts accept: des=%lld expect=%lld (%lld) now=%lld",
-                desiredPresent, expectedPresent, desiredPresent - expectedPresent,
-                systemTime(CLOCK_MONOTONIC));
-    }
-
-    int buf = front->mBuf;
-    *buffer = *front;
-    ATRACE_BUFFER_INDEX(buf);
-
-    ST_LOGV("acquireBuffer: acquiring { slot=%d/%llu, buffer=%p }",
-            front->mBuf, front->mFrameNumber,
-            front->mGraphicBuffer->handle);
-    // if front buffer still being tracked update slot state
-    if (stillTracking(front)) {
-        mSlots[buf].mAcquireCalled = true;
-        mSlots[buf].mNeedsCleanupOnRelease = false;
-        mSlots[buf].mBufferState = BufferSlot::ACQUIRED;
-        mSlots[buf].mFence = Fence::NO_FENCE;
-    }
-
-    // If the buffer has previously been acquired by the consumer, set
-    // mGraphicBuffer to NULL to avoid unnecessarily remapping this
-    // buffer on the consumer side.
-    if (buffer->mAcquireCalled) {
-        buffer->mGraphicBuffer = NULL;
-    }
-
-    mQueue.erase(front);
-    mDequeueCondition.broadcast();
-
-    ATRACE_INT(mConsumerName.string(), mQueue.size());
-
-    return NO_ERROR;
-}
-
-status_t BufferQueue::releaseBuffer(
-        int buf, uint64_t frameNumber, EGLDisplay display,
-        EGLSyncKHR eglFence, const sp<Fence>& fence) {
-    ATRACE_CALL();
-    ATRACE_BUFFER_INDEX(buf);
-
-    if (buf == INVALID_BUFFER_SLOT || fence == NULL) {
-        return BAD_VALUE;
-    }
-
-    Mutex::Autolock _l(mMutex);
-
-    // If the frame number has changed because buffer has been reallocated,
-    // we can ignore this releaseBuffer for the old buffer.
-    if (frameNumber != mSlots[buf].mFrameNumber) {
-        return STALE_BUFFER_SLOT;
-    }
-
-
-    // Internal state consistency checks:
-    // Make sure this buffers hasn't been queued while we were owning it (acquired)
-    Fifo::iterator front(mQueue.begin());
-    Fifo::const_iterator const end(mQueue.end());
-    while (front != end) {
-        if (front->mBuf == buf) {
-            LOG_ALWAYS_FATAL("[%s] received new buffer(#%lld) on slot #%d that has not yet been "
-                    "acquired", mConsumerName.string(), frameNumber, buf);
-            break; // never reached
-        }
-        front++;
-    }
-
-    // The buffer can now only be released if its in the acquired state
-    if (mSlots[buf].mBufferState == BufferSlot::ACQUIRED) {
-        mSlots[buf].mEglDisplay = display;
-        mSlots[buf].mEglFence = eglFence;
-        mSlots[buf].mFence = fence;
-        mSlots[buf].mBufferState = BufferSlot::FREE;
-    } else if (mSlots[buf].mNeedsCleanupOnRelease) {
-        ST_LOGV("releasing a stale buf %d its state was %d", buf, mSlots[buf].mBufferState);
-        mSlots[buf].mNeedsCleanupOnRelease = false;
-        return STALE_BUFFER_SLOT;
-    } else {
-        ST_LOGE("attempted to release buf %d but its state was %d", buf, mSlots[buf].mBufferState);
-        return -EINVAL;
-    }
-
-    mDequeueCondition.broadcast();
-    return NO_ERROR;
-}
-
-status_t BufferQueue::consumerConnect(const sp<IConsumerListener>& consumerListener,
-        bool controlledByApp) {
-    ST_LOGV("consumerConnect controlledByApp=%s",
-            controlledByApp ? "true" : "false");
-    Mutex::Autolock lock(mMutex);
-
-    if (mAbandoned) {
-        ST_LOGE("consumerConnect: BufferQueue has been abandoned!");
-        return NO_INIT;
-    }
-    if (consumerListener == NULL) {
-        ST_LOGE("consumerConnect: consumerListener may not be NULL");
-        return BAD_VALUE;
-    }
-
-    mConsumerListener = consumerListener;
-    mConsumerControlledByApp = controlledByApp;
-
-    return NO_ERROR;
-}
-
-status_t BufferQueue::consumerDisconnect() {
-    ST_LOGV("consumerDisconnect");
-    Mutex::Autolock lock(mMutex);
-
-    if (mConsumerListener == NULL) {
-        ST_LOGE("consumerDisconnect: No consumer is connected!");
-        return -EINVAL;
-    }
-
-    mAbandoned = true;
-    mConsumerListener = NULL;
-    mQueue.clear();
-    freeAllBuffersLocked();
-    mDequeueCondition.broadcast();
-    return NO_ERROR;
-}
-
-status_t BufferQueue::getReleasedBuffers(uint32_t* slotMask) {
-    ST_LOGV("getReleasedBuffers");
-    Mutex::Autolock lock(mMutex);
-
-    if (mAbandoned) {
-        ST_LOGE("getReleasedBuffers: BufferQueue has been abandoned!");
-        return NO_INIT;
-    }
-
-    uint32_t mask = 0;
-    for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
-        if (!mSlots[i].mAcquireCalled) {
-            mask |= 1 << i;
-        }
-    }
-
-    // Remove buffers in flight (on the queue) from the mask where acquire has
-    // been called, as the consumer will not receive the buffer address, so
-    // it should not free these slots.
-    Fifo::iterator front(mQueue.begin());
-    while (front != mQueue.end()) {
-        if (front->mAcquireCalled)
-            mask &= ~(1 << front->mBuf);
-        front++;
-    }
-
-    *slotMask = mask;
-
-    ST_LOGV("getReleasedBuffers: returning mask %#x", mask);
-    return NO_ERROR;
-}
-
-status_t BufferQueue::setDefaultBufferSize(uint32_t w, uint32_t h) {
-    ST_LOGV("setDefaultBufferSize: w=%d, h=%d", w, h);
-    if (!w || !h) {
-        ST_LOGE("setDefaultBufferSize: dimensions cannot be 0 (w=%d, h=%d)",
-                w, h);
-        return BAD_VALUE;
-    }
-
-    Mutex::Autolock lock(mMutex);
-    mDefaultWidth = w;
-    mDefaultHeight = h;
-    return NO_ERROR;
-}
-
-status_t BufferQueue::setDefaultMaxBufferCount(int bufferCount) {
-    ATRACE_CALL();
-    Mutex::Autolock lock(mMutex);
-    return setDefaultMaxBufferCountLocked(bufferCount);
-}
-
-status_t BufferQueue::disableAsyncBuffer() {
-    ATRACE_CALL();
-    Mutex::Autolock lock(mMutex);
-    if (mConsumerListener != NULL) {
-        ST_LOGE("disableAsyncBuffer: consumer already connected!");
-        return INVALID_OPERATION;
-    }
-    mUseAsyncBuffer = false;
-    return NO_ERROR;
-}
-
-status_t BufferQueue::setMaxAcquiredBufferCount(int maxAcquiredBuffers) {
-    ATRACE_CALL();
-    Mutex::Autolock lock(mMutex);
-    if (maxAcquiredBuffers < 1 || maxAcquiredBuffers > MAX_MAX_ACQUIRED_BUFFERS) {
-        ST_LOGE("setMaxAcquiredBufferCount: invalid count specified: %d",
-                maxAcquiredBuffers);
-        return BAD_VALUE;
-    }
-    if (mConnectedApi != NO_CONNECTED_API) {
-        return INVALID_OPERATION;
-    }
-    mMaxAcquiredBufferCount = maxAcquiredBuffers;
-    return NO_ERROR;
-}
-
-int BufferQueue::getMinUndequeuedBufferCount(bool async) const {
-    // if dequeueBuffer is allowed to error out, we don't have to
-    // add an extra buffer.
-    if (!mUseAsyncBuffer)
-        return mMaxAcquiredBufferCount;
-
-    // we're in async mode, or we want to prevent the app to
-    // deadlock itself, we throw-in an extra buffer to guarantee it.
-    if (mDequeueBufferCannotBlock || async)
-        return mMaxAcquiredBufferCount+1;
-
-    return mMaxAcquiredBufferCount;
-}
-
-int BufferQueue::getMinMaxBufferCountLocked(bool async) const {
-    return getMinUndequeuedBufferCount(async) + 1;
-}
-
-int BufferQueue::getMaxBufferCountLocked(bool async) const {
-    int minMaxBufferCount = getMinMaxBufferCountLocked(async);
-
-    int maxBufferCount = mDefaultMaxBufferCount;
-    if (maxBufferCount < minMaxBufferCount) {
-        maxBufferCount = minMaxBufferCount;
-    }
-    if (mOverrideMaxBufferCount != 0) {
-        assert(mOverrideMaxBufferCount >= minMaxBufferCount);
-        maxBufferCount = mOverrideMaxBufferCount;
-    }
-
-    // Any buffers that are dequeued by the producer or sitting in the queue
-    // waiting to be consumed need to have their slots preserved.  Such
-    // buffers will temporarily keep the max buffer count up until the slots
-    // no longer need to be preserved.
-    for (int i = maxBufferCount; i < NUM_BUFFER_SLOTS; i++) {
-        BufferSlot::BufferState state = mSlots[i].mBufferState;
-        if (state == BufferSlot::QUEUED || state == BufferSlot::DEQUEUED) {
-            maxBufferCount = i + 1;
-        }
-    }
-
-    return maxBufferCount;
-}
-
-bool BufferQueue::stillTracking(const BufferItem *item) const {
-    const BufferSlot &slot = mSlots[item->mBuf];
-
-    ST_LOGV("stillTracking?: item: { slot=%d/%llu, buffer=%p }, "
-            "slot: { slot=%d/%llu, buffer=%p }",
-            item->mBuf, item->mFrameNumber,
-            (item->mGraphicBuffer.get() ? item->mGraphicBuffer->handle : 0),
-            item->mBuf, slot.mFrameNumber,
-            (slot.mGraphicBuffer.get() ? slot.mGraphicBuffer->handle : 0));
-
-    // Compare item with its original buffer slot.  We can check the slot
-    // as the buffer would not be moved to a different slot by the producer.
-    return (slot.mGraphicBuffer != NULL &&
-            item->mGraphicBuffer->handle == slot.mGraphicBuffer->handle);
-}
-
 BufferQueue::ProxyConsumerListener::ProxyConsumerListener(
         const wp<ConsumerListener>& consumerListener):
         mConsumerListener(consumerListener) {}
 
 BufferQueue::ProxyConsumerListener::~ProxyConsumerListener() {}
 
-void BufferQueue::ProxyConsumerListener::onFrameAvailable() {
+void BufferQueue::ProxyConsumerListener::onFrameAvailable(
+        const BufferItem& item) {
     sp<ConsumerListener> listener(mConsumerListener.promote());
     if (listener != NULL) {
-        listener->onFrameAvailable();
+        listener->onFrameAvailable(item);
+    }
+}
+
+void BufferQueue::ProxyConsumerListener::onFrameReplaced(
+        const BufferItem& item) {
+    sp<ConsumerListener> listener(mConsumerListener.promote());
+    if (listener != NULL) {
+        listener->onFrameReplaced(item);
     }
 }
 
@@ -1240,4 +54,35 @@
     }
 }
 
+void BufferQueue::ProxyConsumerListener::onSidebandStreamChanged() {
+    sp<ConsumerListener> listener(mConsumerListener.promote());
+    if (listener != NULL) {
+        listener->onSidebandStreamChanged();
+    }
+}
+
+void BufferQueue::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
+        sp<IGraphicBufferConsumer>* outConsumer,
+        const sp<IGraphicBufferAlloc>& allocator) {
+    LOG_ALWAYS_FATAL_IF(outProducer == NULL,
+            "BufferQueue: outProducer must not be NULL");
+    LOG_ALWAYS_FATAL_IF(outConsumer == NULL,
+            "BufferQueue: outConsumer must not be NULL");
+
+    sp<BufferQueueCore> core(new BufferQueueCore(allocator));
+    LOG_ALWAYS_FATAL_IF(core == NULL,
+            "BufferQueue: failed to create BufferQueueCore");
+
+    sp<IGraphicBufferProducer> producer(new BufferQueueProducer(core));
+    LOG_ALWAYS_FATAL_IF(producer == NULL,
+            "BufferQueue: failed to create BufferQueueProducer");
+
+    sp<IGraphicBufferConsumer> consumer(new BufferQueueConsumer(core));
+    LOG_ALWAYS_FATAL_IF(consumer == NULL,
+            "BufferQueue: failed to create BufferQueueConsumer");
+
+    *outProducer = producer;
+    *outConsumer = consumer;
+}
+
 }; // namespace android
diff --git a/libs/gui/BufferQueueConsumer.cpp b/libs/gui/BufferQueueConsumer.cpp
new file mode 100644
index 0000000..bb3e1b0
--- /dev/null
+++ b/libs/gui/BufferQueueConsumer.cpp
@@ -0,0 +1,578 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <inttypes.h>
+
+#define LOG_TAG "BufferQueueConsumer"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+//#define LOG_NDEBUG 0
+
+#include <gui/BufferItem.h>
+#include <gui/BufferQueueConsumer.h>
+#include <gui/BufferQueueCore.h>
+#include <gui/IConsumerListener.h>
+#include <gui/IProducerListener.h>
+
+namespace android {
+
+BufferQueueConsumer::BufferQueueConsumer(const sp<BufferQueueCore>& core) :
+    mCore(core),
+    mSlots(core->mSlots),
+    mConsumerName() {}
+
+BufferQueueConsumer::~BufferQueueConsumer() {}
+
+status_t BufferQueueConsumer::acquireBuffer(BufferItem* outBuffer,
+        nsecs_t expectedPresent, uint64_t maxFrameNumber) {
+    ATRACE_CALL();
+
+    int numDroppedBuffers = 0;
+    sp<IProducerListener> listener;
+    {
+        Mutex::Autolock lock(mCore->mMutex);
+
+        // Check that the consumer doesn't currently have the maximum number of
+        // buffers acquired. We allow the max buffer count to be exceeded by one
+        // buffer so that the consumer can successfully set up the newly acquired
+        // buffer before releasing the old one.
+        int numAcquiredBuffers = 0;
+        for (int s = 0; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
+            if (mSlots[s].mBufferState == BufferSlot::ACQUIRED) {
+                ++numAcquiredBuffers;
+            }
+        }
+        if (numAcquiredBuffers >= mCore->mMaxAcquiredBufferCount + 1) {
+            BQ_LOGE("acquireBuffer: max acquired buffer count reached: %d (max %d)",
+                    numAcquiredBuffers, mCore->mMaxAcquiredBufferCount);
+            return INVALID_OPERATION;
+        }
+
+        // Check if the queue is empty.
+        // In asynchronous mode the list is guaranteed to be one buffer deep,
+        // while in synchronous mode we use the oldest buffer.
+        if (mCore->mQueue.empty()) {
+            return NO_BUFFER_AVAILABLE;
+        }
+
+        BufferQueueCore::Fifo::iterator front(mCore->mQueue.begin());
+
+        // If expectedPresent is specified, we may not want to return a buffer yet.
+        // If it's specified and there's more than one buffer queued, we may want
+        // to drop a buffer.
+        if (expectedPresent != 0) {
+            const int MAX_REASONABLE_NSEC = 1000000000ULL; // 1 second
+
+            // The 'expectedPresent' argument indicates when the buffer is expected
+            // to be presented on-screen. If the buffer's desired present time is
+            // earlier (less) than expectedPresent -- meaning it will be displayed
+            // on time or possibly late if we show it as soon as possible -- we
+            // acquire and return it. If we don't want to display it until after the
+            // expectedPresent time, we return PRESENT_LATER without acquiring it.
+            //
+            // To be safe, we don't defer acquisition if expectedPresent is more
+            // than one second in the future beyond the desired present time
+            // (i.e., we'd be holding the buffer for a long time).
+            //
+            // NOTE: Code assumes monotonic time values from the system clock
+            // are positive.
+
+            // Start by checking to see if we can drop frames. We skip this check if
+            // the timestamps are being auto-generated by Surface. If the app isn't
+            // generating timestamps explicitly, it probably doesn't want frames to
+            // be discarded based on them.
+            while (mCore->mQueue.size() > 1 && !mCore->mQueue[0].mIsAutoTimestamp) {
+                const BufferItem& bufferItem(mCore->mQueue[1]);
+
+                // If dropping entry[0] would leave us with a buffer that the
+                // consumer is not yet ready for, don't drop it.
+                if (maxFrameNumber && bufferItem.mFrameNumber > maxFrameNumber) {
+                    break;
+                }
+
+                // If entry[1] is timely, drop entry[0] (and repeat). We apply an
+                // additional criterion here: we only drop the earlier buffer if our
+                // desiredPresent falls within +/- 1 second of the expected present.
+                // Otherwise, bogus desiredPresent times (e.g., 0 or a small
+                // relative timestamp), which normally mean "ignore the timestamp
+                // and acquire immediately", would cause us to drop frames.
+                //
+                // We may want to add an additional criterion: don't drop the
+                // earlier buffer if entry[1]'s fence hasn't signaled yet.
+                nsecs_t desiredPresent = bufferItem.mTimestamp;
+                if (desiredPresent < expectedPresent - MAX_REASONABLE_NSEC ||
+                        desiredPresent > expectedPresent) {
+                    // This buffer is set to display in the near future, or
+                    // desiredPresent is garbage. Either way we don't want to drop
+                    // the previous buffer just to get this on the screen sooner.
+                    BQ_LOGV("acquireBuffer: nodrop desire=%" PRId64 " expect=%"
+                            PRId64 " (%" PRId64 ") now=%" PRId64,
+                            desiredPresent, expectedPresent,
+                            desiredPresent - expectedPresent,
+                            systemTime(CLOCK_MONOTONIC));
+                    break;
+                }
+
+                BQ_LOGV("acquireBuffer: drop desire=%" PRId64 " expect=%" PRId64
+                        " size=%zu",
+                        desiredPresent, expectedPresent, mCore->mQueue.size());
+                if (mCore->stillTracking(front)) {
+                    // Front buffer is still in mSlots, so mark the slot as free
+                    mSlots[front->mSlot].mBufferState = BufferSlot::FREE;
+                    mCore->mFreeBuffers.push_back(front->mSlot);
+                    listener = mCore->mConnectedProducerListener;
+                    ++numDroppedBuffers;
+                }
+                mCore->mQueue.erase(front);
+                front = mCore->mQueue.begin();
+            }
+
+            // See if the front buffer is ready to be acquired
+            nsecs_t desiredPresent = front->mTimestamp;
+            bool bufferIsDue = desiredPresent <= expectedPresent ||
+                    desiredPresent > expectedPresent + MAX_REASONABLE_NSEC;
+            bool consumerIsReady = maxFrameNumber > 0 ?
+                    front->mFrameNumber <= maxFrameNumber : true;
+            if (!bufferIsDue || !consumerIsReady) {
+                BQ_LOGV("acquireBuffer: defer desire=%" PRId64 " expect=%" PRId64
+                        " (%" PRId64 ") now=%" PRId64 " frame=%" PRIu64
+                        " consumer=%" PRIu64,
+                        desiredPresent, expectedPresent,
+                        desiredPresent - expectedPresent,
+                        systemTime(CLOCK_MONOTONIC),
+                        front->mFrameNumber, maxFrameNumber);
+                return PRESENT_LATER;
+            }
+
+            BQ_LOGV("acquireBuffer: accept desire=%" PRId64 " expect=%" PRId64 " "
+                    "(%" PRId64 ") now=%" PRId64, desiredPresent, expectedPresent,
+                    desiredPresent - expectedPresent,
+                    systemTime(CLOCK_MONOTONIC));
+        }
+
+        int slot = front->mSlot;
+        *outBuffer = *front;
+        ATRACE_BUFFER_INDEX(slot);
+
+        BQ_LOGV("acquireBuffer: acquiring { slot=%d/%" PRIu64 " buffer=%p }",
+                slot, front->mFrameNumber, front->mGraphicBuffer->handle);
+        // If the front buffer is still being tracked, update its slot state
+        if (mCore->stillTracking(front)) {
+            mSlots[slot].mAcquireCalled = true;
+            mSlots[slot].mNeedsCleanupOnRelease = false;
+            mSlots[slot].mBufferState = BufferSlot::ACQUIRED;
+            mSlots[slot].mFence = Fence::NO_FENCE;
+        }
+
+        // If the buffer has previously been acquired by the consumer, set
+        // mGraphicBuffer to NULL to avoid unnecessarily remapping this buffer
+        // on the consumer side
+        if (outBuffer->mAcquireCalled) {
+            outBuffer->mGraphicBuffer = NULL;
+        }
+
+        mCore->mQueue.erase(front);
+
+        // We might have freed a slot while dropping old buffers, or the producer
+        // may be blocked waiting for the number of buffers in the queue to
+        // decrease.
+        mCore->mDequeueCondition.broadcast();
+
+        ATRACE_INT(mCore->mConsumerName.string(), mCore->mQueue.size());
+
+        mCore->validateConsistencyLocked();
+    }
+
+    if (listener != NULL) {
+        for (int i = 0; i < numDroppedBuffers; ++i) {
+            listener->onBufferReleased();
+        }
+    }
+
+    return NO_ERROR;
+}
+
+status_t BufferQueueConsumer::detachBuffer(int slot) {
+    ATRACE_CALL();
+    ATRACE_BUFFER_INDEX(slot);
+    BQ_LOGV("detachBuffer(C): slot %d", slot);
+    Mutex::Autolock lock(mCore->mMutex);
+
+    if (mCore->mIsAbandoned) {
+        BQ_LOGE("detachBuffer(C): BufferQueue has been abandoned");
+        return NO_INIT;
+    }
+
+    if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) {
+        BQ_LOGE("detachBuffer(C): slot index %d out of range [0, %d)",
+                slot, BufferQueueDefs::NUM_BUFFER_SLOTS);
+        return BAD_VALUE;
+    } else if (mSlots[slot].mBufferState != BufferSlot::ACQUIRED) {
+        BQ_LOGE("detachBuffer(C): slot %d is not owned by the consumer "
+                "(state = %d)", slot, mSlots[slot].mBufferState);
+        return BAD_VALUE;
+    }
+
+    mCore->freeBufferLocked(slot);
+    mCore->mDequeueCondition.broadcast();
+    mCore->validateConsistencyLocked();
+
+    return NO_ERROR;
+}
+
+status_t BufferQueueConsumer::attachBuffer(int* outSlot,
+        const sp<android::GraphicBuffer>& buffer) {
+    ATRACE_CALL();
+
+    if (outSlot == NULL) {
+        BQ_LOGE("attachBuffer(P): outSlot must not be NULL");
+        return BAD_VALUE;
+    } else if (buffer == NULL) {
+        BQ_LOGE("attachBuffer(P): cannot attach NULL buffer");
+        return BAD_VALUE;
+    }
+
+    Mutex::Autolock lock(mCore->mMutex);
+
+    // Make sure we don't have too many acquired buffers
+    int numAcquiredBuffers = 0;
+    for (int s = 0; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
+        if (mSlots[s].mBufferState == BufferSlot::ACQUIRED) {
+            ++numAcquiredBuffers;
+        }
+    }
+
+    if (numAcquiredBuffers >= mCore->mMaxAcquiredBufferCount + 1) {
+        BQ_LOGE("attachBuffer(P): max acquired buffer count reached: %d "
+                "(max %d)", numAcquiredBuffers,
+                mCore->mMaxAcquiredBufferCount);
+        return INVALID_OPERATION;
+    }
+
+    if (buffer->getGenerationNumber() != mCore->mGenerationNumber) {
+        BQ_LOGE("attachBuffer: generation number mismatch [buffer %u] "
+                "[queue %u]", buffer->getGenerationNumber(),
+                mCore->mGenerationNumber);
+        return BAD_VALUE;
+    }
+
+    // Find a free slot to put the buffer into
+    int found = BufferQueueCore::INVALID_BUFFER_SLOT;
+    if (!mCore->mFreeSlots.empty()) {
+        auto slot = mCore->mFreeSlots.begin();
+        found = *slot;
+        mCore->mFreeSlots.erase(slot);
+    } else if (!mCore->mFreeBuffers.empty()) {
+        found = mCore->mFreeBuffers.front();
+        mCore->mFreeBuffers.remove(found);
+    }
+    if (found == BufferQueueCore::INVALID_BUFFER_SLOT) {
+        BQ_LOGE("attachBuffer(P): could not find free buffer slot");
+        return NO_MEMORY;
+    }
+
+    *outSlot = found;
+    ATRACE_BUFFER_INDEX(*outSlot);
+    BQ_LOGV("attachBuffer(C): returning slot %d", *outSlot);
+
+    mSlots[*outSlot].mGraphicBuffer = buffer;
+    mSlots[*outSlot].mBufferState = BufferSlot::ACQUIRED;
+    mSlots[*outSlot].mAttachedByConsumer = true;
+    mSlots[*outSlot].mNeedsCleanupOnRelease = false;
+    mSlots[*outSlot].mFence = Fence::NO_FENCE;
+    mSlots[*outSlot].mFrameNumber = 0;
+
+    // mAcquireCalled tells BufferQueue that it doesn't need to send a valid
+    // GraphicBuffer pointer on the next acquireBuffer call, which decreases
+    // Binder traffic by not un/flattening the GraphicBuffer. However, it
+    // requires that the consumer maintain a cached copy of the slot <--> buffer
+    // mappings, which is why the consumer doesn't need the valid pointer on
+    // acquire.
+    //
+    // The StreamSplitter is one of the primary users of the attach/detach
+    // logic, and while it is running, all buffers it acquires are immediately
+    // detached, and all buffers it eventually releases are ones that were
+    // attached (as opposed to having been obtained from acquireBuffer), so it
+    // doesn't make sense to maintain the slot/buffer mappings, which would
+    // become invalid for every buffer during detach/attach. By setting this to
+    // false, the valid GraphicBuffer pointer will always be sent with acquire
+    // for attached buffers.
+    mSlots[*outSlot].mAcquireCalled = false;
+
+    mCore->validateConsistencyLocked();
+
+    return NO_ERROR;
+}
+
+status_t BufferQueueConsumer::releaseBuffer(int slot, uint64_t frameNumber,
+        const sp<Fence>& releaseFence, EGLDisplay eglDisplay,
+        EGLSyncKHR eglFence) {
+    ATRACE_CALL();
+    ATRACE_BUFFER_INDEX(slot);
+
+    if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS ||
+            releaseFence == NULL) {
+        BQ_LOGE("releaseBuffer: slot %d out of range or fence %p NULL", slot,
+                releaseFence.get());
+        return BAD_VALUE;
+    }
+
+    sp<IProducerListener> listener;
+    { // Autolock scope
+        Mutex::Autolock lock(mCore->mMutex);
+
+        // If the frame number has changed because the buffer has been reallocated,
+        // we can ignore this releaseBuffer for the old buffer
+        if (frameNumber != mSlots[slot].mFrameNumber) {
+            return STALE_BUFFER_SLOT;
+        }
+
+        // Make sure this buffer hasn't been queued while acquired by the consumer
+        BufferQueueCore::Fifo::iterator current(mCore->mQueue.begin());
+        while (current != mCore->mQueue.end()) {
+            if (current->mSlot == slot) {
+                BQ_LOGE("releaseBuffer: buffer slot %d pending release is "
+                        "currently queued", slot);
+                return BAD_VALUE;
+            }
+            ++current;
+        }
+
+        if (mSlots[slot].mBufferState == BufferSlot::ACQUIRED) {
+            mSlots[slot].mEglDisplay = eglDisplay;
+            mSlots[slot].mEglFence = eglFence;
+            mSlots[slot].mFence = releaseFence;
+            mSlots[slot].mBufferState = BufferSlot::FREE;
+            mCore->mFreeBuffers.push_back(slot);
+            listener = mCore->mConnectedProducerListener;
+            BQ_LOGV("releaseBuffer: releasing slot %d", slot);
+        } else if (mSlots[slot].mNeedsCleanupOnRelease) {
+            BQ_LOGV("releaseBuffer: releasing a stale buffer slot %d "
+                    "(state = %d)", slot, mSlots[slot].mBufferState);
+            mSlots[slot].mNeedsCleanupOnRelease = false;
+            return STALE_BUFFER_SLOT;
+        } else {
+            BQ_LOGE("releaseBuffer: attempted to release buffer slot %d "
+                    "but its state was %d", slot, mSlots[slot].mBufferState);
+            return BAD_VALUE;
+        }
+
+        mCore->mDequeueCondition.broadcast();
+        mCore->validateConsistencyLocked();
+    } // Autolock scope
+
+    // Call back without lock held
+    if (listener != NULL) {
+        listener->onBufferReleased();
+    }
+
+    return NO_ERROR;
+}
+
+status_t BufferQueueConsumer::connect(
+        const sp<IConsumerListener>& consumerListener, bool controlledByApp) {
+    ATRACE_CALL();
+
+    if (consumerListener == NULL) {
+        BQ_LOGE("connect(C): consumerListener may not be NULL");
+        return BAD_VALUE;
+    }
+
+    BQ_LOGV("connect(C): controlledByApp=%s",
+            controlledByApp ? "true" : "false");
+
+    Mutex::Autolock lock(mCore->mMutex);
+
+    if (mCore->mIsAbandoned) {
+        BQ_LOGE("connect(C): BufferQueue has been abandoned");
+        return NO_INIT;
+    }
+
+    mCore->mConsumerListener = consumerListener;
+    mCore->mConsumerControlledByApp = controlledByApp;
+
+    return NO_ERROR;
+}
+
+status_t BufferQueueConsumer::disconnect() {
+    ATRACE_CALL();
+
+    BQ_LOGV("disconnect(C)");
+
+    Mutex::Autolock lock(mCore->mMutex);
+
+    if (mCore->mConsumerListener == NULL) {
+        BQ_LOGE("disconnect(C): no consumer is connected");
+        return BAD_VALUE;
+    }
+
+    mCore->mIsAbandoned = true;
+    mCore->mConsumerListener = NULL;
+    mCore->mQueue.clear();
+    mCore->freeAllBuffersLocked();
+    mCore->mDequeueCondition.broadcast();
+    return NO_ERROR;
+}
+
+status_t BufferQueueConsumer::getReleasedBuffers(uint64_t *outSlotMask) {
+    ATRACE_CALL();
+
+    if (outSlotMask == NULL) {
+        BQ_LOGE("getReleasedBuffers: outSlotMask may not be NULL");
+        return BAD_VALUE;
+    }
+
+    Mutex::Autolock lock(mCore->mMutex);
+
+    if (mCore->mIsAbandoned) {
+        BQ_LOGE("getReleasedBuffers: BufferQueue has been abandoned");
+        return NO_INIT;
+    }
+
+    uint64_t mask = 0;
+    for (int s = 0; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
+        if (!mSlots[s].mAcquireCalled) {
+            mask |= (1ULL << s);
+        }
+    }
+
+    // Remove from the mask queued buffers for which acquire has been called,
+    // since the consumer will not receive their buffer addresses and so must
+    // retain their cached information
+    BufferQueueCore::Fifo::iterator current(mCore->mQueue.begin());
+    while (current != mCore->mQueue.end()) {
+        if (current->mAcquireCalled) {
+            mask &= ~(1ULL << current->mSlot);
+        }
+        ++current;
+    }
+
+    BQ_LOGV("getReleasedBuffers: returning mask %#" PRIx64, mask);
+    *outSlotMask = mask;
+    return NO_ERROR;
+}
+
+status_t BufferQueueConsumer::setDefaultBufferSize(uint32_t width,
+        uint32_t height) {
+    ATRACE_CALL();
+
+    if (width == 0 || height == 0) {
+        BQ_LOGV("setDefaultBufferSize: dimensions cannot be 0 (width=%u "
+                "height=%u)", width, height);
+        return BAD_VALUE;
+    }
+
+    BQ_LOGV("setDefaultBufferSize: width=%u height=%u", width, height);
+
+    Mutex::Autolock lock(mCore->mMutex);
+    mCore->mDefaultWidth = width;
+    mCore->mDefaultHeight = height;
+    return NO_ERROR;
+}
+
+status_t BufferQueueConsumer::setDefaultMaxBufferCount(int bufferCount) {
+    ATRACE_CALL();
+    Mutex::Autolock lock(mCore->mMutex);
+    return mCore->setDefaultMaxBufferCountLocked(bufferCount);
+}
+
+status_t BufferQueueConsumer::disableAsyncBuffer() {
+    ATRACE_CALL();
+
+    Mutex::Autolock lock(mCore->mMutex);
+
+    if (mCore->mConsumerListener != NULL) {
+        BQ_LOGE("disableAsyncBuffer: consumer already connected");
+        return INVALID_OPERATION;
+    }
+
+    BQ_LOGV("disableAsyncBuffer");
+    mCore->mUseAsyncBuffer = false;
+    return NO_ERROR;
+}
+
+status_t BufferQueueConsumer::setMaxAcquiredBufferCount(
+        int maxAcquiredBuffers) {
+    ATRACE_CALL();
+
+    if (maxAcquiredBuffers < 1 ||
+            maxAcquiredBuffers > BufferQueueCore::MAX_MAX_ACQUIRED_BUFFERS) {
+        BQ_LOGE("setMaxAcquiredBufferCount: invalid count %d",
+                maxAcquiredBuffers);
+        return BAD_VALUE;
+    }
+
+    Mutex::Autolock lock(mCore->mMutex);
+
+    if (mCore->mConnectedApi != BufferQueueCore::NO_CONNECTED_API) {
+        BQ_LOGE("setMaxAcquiredBufferCount: producer is already connected");
+        return INVALID_OPERATION;
+    }
+
+    BQ_LOGV("setMaxAcquiredBufferCount: %d", maxAcquiredBuffers);
+    mCore->mMaxAcquiredBufferCount = maxAcquiredBuffers;
+    return NO_ERROR;
+}
+
+void BufferQueueConsumer::setConsumerName(const String8& name) {
+    ATRACE_CALL();
+    BQ_LOGV("setConsumerName: '%s'", name.string());
+    Mutex::Autolock lock(mCore->mMutex);
+    mCore->mConsumerName = name;
+    mConsumerName = name;
+}
+
+status_t BufferQueueConsumer::setDefaultBufferFormat(PixelFormat defaultFormat) {
+    ATRACE_CALL();
+    BQ_LOGV("setDefaultBufferFormat: %u", defaultFormat);
+    Mutex::Autolock lock(mCore->mMutex);
+    mCore->mDefaultBufferFormat = defaultFormat;
+    return NO_ERROR;
+}
+
+status_t BufferQueueConsumer::setDefaultBufferDataSpace(
+        android_dataspace defaultDataSpace) {
+    ATRACE_CALL();
+    BQ_LOGV("setDefaultBufferDataSpace: %u", defaultDataSpace);
+    Mutex::Autolock lock(mCore->mMutex);
+    mCore->mDefaultBufferDataSpace = defaultDataSpace;
+    return NO_ERROR;
+}
+
+status_t BufferQueueConsumer::setConsumerUsageBits(uint32_t usage) {
+    ATRACE_CALL();
+    BQ_LOGV("setConsumerUsageBits: %#x", usage);
+    Mutex::Autolock lock(mCore->mMutex);
+    mCore->mConsumerUsageBits = usage;
+    return NO_ERROR;
+}
+
+status_t BufferQueueConsumer::setTransformHint(uint32_t hint) {
+    ATRACE_CALL();
+    BQ_LOGV("setTransformHint: %#x", hint);
+    Mutex::Autolock lock(mCore->mMutex);
+    mCore->mTransformHint = hint;
+    return NO_ERROR;
+}
+
+sp<NativeHandle> BufferQueueConsumer::getSidebandStream() const {
+    return mCore->mSidebandStream;
+}
+
+void BufferQueueConsumer::dump(String8& result, const char* prefix) const {
+    mCore->dump(result, prefix);
+}
+
+} // namespace android
diff --git a/libs/gui/BufferQueueCore.cpp b/libs/gui/BufferQueueCore.cpp
new file mode 100644
index 0000000..0f8ec7f
--- /dev/null
+++ b/libs/gui/BufferQueueCore.cpp
@@ -0,0 +1,320 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "BufferQueueCore"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+//#define LOG_NDEBUG 0
+
+#define EGL_EGLEXT_PROTOTYPES
+
+#include <inttypes.h>
+
+#include <cutils/properties.h>
+
+#include <gui/BufferItem.h>
+#include <gui/BufferQueueCore.h>
+#include <gui/GraphicBufferAlloc.h>
+#include <gui/IConsumerListener.h>
+#include <gui/IGraphicBufferAlloc.h>
+#include <gui/IProducerListener.h>
+#include <gui/ISurfaceComposer.h>
+#include <private/gui/ComposerService.h>
+
+template <typename T>
+static inline T max(T a, T b) { return a > b ? a : b; }
+
+namespace android {
+
+static String8 getUniqueName() {
+    static volatile int32_t counter = 0;
+    return String8::format("unnamed-%d-%d", getpid(),
+            android_atomic_inc(&counter));
+}
+
+BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) :
+    mAllocator(allocator),
+    mMutex(),
+    mIsAbandoned(false),
+    mConsumerControlledByApp(false),
+    mConsumerName(getUniqueName()),
+    mConsumerListener(),
+    mConsumerUsageBits(0),
+    mConnectedApi(NO_CONNECTED_API),
+    mConnectedProducerListener(),
+    mSlots(),
+    mQueue(),
+    mFreeSlots(),
+    mFreeBuffers(),
+    mOverrideMaxBufferCount(0),
+    mDequeueCondition(),
+    mUseAsyncBuffer(true),
+    mDequeueBufferCannotBlock(false),
+    mDefaultBufferFormat(PIXEL_FORMAT_RGBA_8888),
+    mDefaultWidth(1),
+    mDefaultHeight(1),
+    mDefaultBufferDataSpace(HAL_DATASPACE_UNKNOWN),
+    mDefaultMaxBufferCount(2),
+    mMaxAcquiredBufferCount(1),
+    mBufferHasBeenQueued(false),
+    mFrameCounter(0),
+    mTransformHint(0),
+    mIsAllocating(false),
+    mIsAllocatingCondition(),
+    mAllowAllocation(true),
+    mBufferAge(0),
+    mGenerationNumber(0)
+{
+    if (allocator == NULL) {
+
+#ifdef HAVE_NO_SURFACE_FLINGER
+        // Without a SurfaceFlinger, allocate in-process.  This only makes
+        // sense in systems with static SELinux configurations and no
+        // applications (since applications need dynamic SELinux policy).
+        mAllocator = new GraphicBufferAlloc();
+#else
+        // Run time check for headless, where we also allocate in-process.
+        char value[PROPERTY_VALUE_MAX];
+        property_get("config.headless", value, "0");
+        if (atoi(value) == 1) {
+            mAllocator = new GraphicBufferAlloc();
+        } else {
+            sp<ISurfaceComposer> composer(ComposerService::getComposerService());
+            mAllocator = composer->createGraphicBufferAlloc();
+        }
+#endif  // HAVE_NO_SURFACE_FLINGER
+
+        if (mAllocator == NULL) {
+            BQ_LOGE("createGraphicBufferAlloc failed");
+        }
+    }
+    for (int slot = 0; slot < BufferQueueDefs::NUM_BUFFER_SLOTS; ++slot) {
+        mFreeSlots.insert(slot);
+    }
+}
+
+BufferQueueCore::~BufferQueueCore() {}
+
+void BufferQueueCore::dump(String8& result, const char* prefix) const {
+    Mutex::Autolock lock(mMutex);
+
+    String8 fifo;
+    Fifo::const_iterator current(mQueue.begin());
+    while (current != mQueue.end()) {
+        fifo.appendFormat("%02d:%p crop=[%d,%d,%d,%d], "
+                "xform=0x%02x, time=%#" PRIx64 ", scale=%s\n",
+                current->mSlot, current->mGraphicBuffer.get(),
+                current->mCrop.left, current->mCrop.top, current->mCrop.right,
+                current->mCrop.bottom, current->mTransform, current->mTimestamp,
+                BufferItem::scalingModeName(current->mScalingMode));
+        ++current;
+    }
+
+    result.appendFormat("%s-BufferQueue mMaxAcquiredBufferCount=%d, "
+            "mDequeueBufferCannotBlock=%d, default-size=[%dx%d], "
+            "default-format=%d, transform-hint=%02x, FIFO(%zu)={%s}\n",
+            prefix, mMaxAcquiredBufferCount, mDequeueBufferCannotBlock,
+            mDefaultWidth, mDefaultHeight, mDefaultBufferFormat, mTransformHint,
+            mQueue.size(), fifo.string());
+
+    // Trim the free buffers so as to not spam the dump
+    int maxBufferCount = 0;
+    for (int s = BufferQueueDefs::NUM_BUFFER_SLOTS - 1; s >= 0; --s) {
+        const BufferSlot& slot(mSlots[s]);
+        if (slot.mBufferState != BufferSlot::FREE ||
+                slot.mGraphicBuffer != NULL) {
+            maxBufferCount = s + 1;
+            break;
+        }
+    }
+
+    for (int s = 0; s < maxBufferCount; ++s) {
+        const BufferSlot& slot(mSlots[s]);
+        const sp<GraphicBuffer>& buffer(slot.mGraphicBuffer);
+        result.appendFormat("%s%s[%02d:%p] state=%-8s", prefix,
+                (slot.mBufferState == BufferSlot::ACQUIRED) ? ">" : " ",
+                s, buffer.get(),
+                BufferSlot::bufferStateName(slot.mBufferState));
+
+        if (buffer != NULL) {
+            result.appendFormat(", %p [%4ux%4u:%4u,%3X]", buffer->handle,
+                    buffer->width, buffer->height, buffer->stride,
+                    buffer->format);
+        }
+
+        result.append("\n");
+    }
+}
+
+int BufferQueueCore::getMinUndequeuedBufferCountLocked(bool async) const {
+    // If dequeueBuffer is allowed to error out, we don't have to add an
+    // extra buffer.
+    if (!mUseAsyncBuffer) {
+        return mMaxAcquiredBufferCount;
+    }
+
+    if (mDequeueBufferCannotBlock || async) {
+        return mMaxAcquiredBufferCount + 1;
+    }
+
+    return mMaxAcquiredBufferCount;
+}
+
+int BufferQueueCore::getMinMaxBufferCountLocked(bool async) const {
+    return getMinUndequeuedBufferCountLocked(async) + 1;
+}
+
+int BufferQueueCore::getMaxBufferCountLocked(bool async) const {
+    int minMaxBufferCount = getMinMaxBufferCountLocked(async);
+
+    int maxBufferCount = max(mDefaultMaxBufferCount, minMaxBufferCount);
+    if (mOverrideMaxBufferCount != 0) {
+        assert(mOverrideMaxBufferCount >= minMaxBufferCount);
+        maxBufferCount = mOverrideMaxBufferCount;
+    }
+
+    // Any buffers that are dequeued by the producer or sitting in the queue
+    // waiting to be consumed need to have their slots preserved. Such buffers
+    // will temporarily keep the max buffer count up until the slots no longer
+    // need to be preserved.
+    for (int s = maxBufferCount; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
+        BufferSlot::BufferState state = mSlots[s].mBufferState;
+        if (state == BufferSlot::QUEUED || state == BufferSlot::DEQUEUED) {
+            maxBufferCount = s + 1;
+        }
+    }
+
+    return maxBufferCount;
+}
+
+status_t BufferQueueCore::setDefaultMaxBufferCountLocked(int count) {
+    const int minBufferCount = mUseAsyncBuffer ? 2 : 1;
+    if (count < minBufferCount || count > BufferQueueDefs::NUM_BUFFER_SLOTS) {
+        BQ_LOGV("setDefaultMaxBufferCount: invalid count %d, should be in "
+                "[%d, %d]",
+                count, minBufferCount, BufferQueueDefs::NUM_BUFFER_SLOTS);
+        return BAD_VALUE;
+    }
+
+    BQ_LOGV("setDefaultMaxBufferCount: setting count to %d", count);
+    mDefaultMaxBufferCount = count;
+    mDequeueCondition.broadcast();
+
+    return NO_ERROR;
+}
+
+void BufferQueueCore::freeBufferLocked(int slot) {
+    BQ_LOGV("freeBufferLocked: slot %d", slot);
+    bool hadBuffer = mSlots[slot].mGraphicBuffer != NULL;
+    mSlots[slot].mGraphicBuffer.clear();
+    if (mSlots[slot].mBufferState == BufferSlot::ACQUIRED) {
+        mSlots[slot].mNeedsCleanupOnRelease = true;
+    }
+    if (mSlots[slot].mBufferState != BufferSlot::FREE) {
+        mFreeSlots.insert(slot);
+    } else if (hadBuffer) {
+        // If the slot was FREE, but we had a buffer, we need to move this slot
+        // from the free buffers list to the the free slots list
+        mFreeBuffers.remove(slot);
+        mFreeSlots.insert(slot);
+    }
+    mSlots[slot].mBufferState = BufferSlot::FREE;
+    mSlots[slot].mAcquireCalled = false;
+    mSlots[slot].mFrameNumber = 0;
+
+    // Destroy fence as BufferQueue now takes ownership
+    if (mSlots[slot].mEglFence != EGL_NO_SYNC_KHR) {
+        eglDestroySyncKHR(mSlots[slot].mEglDisplay, mSlots[slot].mEglFence);
+        mSlots[slot].mEglFence = EGL_NO_SYNC_KHR;
+    }
+    mSlots[slot].mFence = Fence::NO_FENCE;
+    validateConsistencyLocked();
+}
+
+void BufferQueueCore::freeAllBuffersLocked() {
+    mBufferHasBeenQueued = false;
+    for (int s = 0; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
+        freeBufferLocked(s);
+    }
+}
+
+bool BufferQueueCore::stillTracking(const BufferItem* item) const {
+    const BufferSlot& slot = mSlots[item->mSlot];
+
+    BQ_LOGV("stillTracking: item { slot=%d/%" PRIu64 " buffer=%p } "
+            "slot { slot=%d/%" PRIu64 " buffer=%p }",
+            item->mSlot, item->mFrameNumber,
+            (item->mGraphicBuffer.get() ? item->mGraphicBuffer->handle : 0),
+            item->mSlot, slot.mFrameNumber,
+            (slot.mGraphicBuffer.get() ? slot.mGraphicBuffer->handle : 0));
+
+    // Compare item with its original buffer slot. We can check the slot as
+    // the buffer would not be moved to a different slot by the producer.
+    return (slot.mGraphicBuffer != NULL) &&
+           (item->mGraphicBuffer->handle == slot.mGraphicBuffer->handle);
+}
+
+void BufferQueueCore::waitWhileAllocatingLocked() const {
+    ATRACE_CALL();
+    while (mIsAllocating) {
+        mIsAllocatingCondition.wait(mMutex);
+    }
+}
+
+void BufferQueueCore::validateConsistencyLocked() const {
+    static const useconds_t PAUSE_TIME = 0;
+    for (int slot = 0; slot < BufferQueueDefs::NUM_BUFFER_SLOTS; ++slot) {
+        bool isInFreeSlots = mFreeSlots.count(slot) != 0;
+        bool isInFreeBuffers =
+                std::find(mFreeBuffers.cbegin(), mFreeBuffers.cend(), slot) !=
+                mFreeBuffers.cend();
+        if (mSlots[slot].mBufferState == BufferSlot::FREE) {
+            if (mSlots[slot].mGraphicBuffer == NULL) {
+                if (!isInFreeSlots) {
+                    BQ_LOGE("Slot %d is FREE but is not in mFreeSlots", slot);
+                    usleep(PAUSE_TIME);
+                }
+                if (isInFreeBuffers) {
+                    BQ_LOGE("Slot %d is in mFreeSlots "
+                            "but is also in mFreeBuffers", slot);
+                    usleep(PAUSE_TIME);
+                }
+            } else {
+                if (!isInFreeBuffers) {
+                    BQ_LOGE("Slot %d is FREE but is not in mFreeBuffers", slot);
+                    usleep(PAUSE_TIME);
+                }
+                if (isInFreeSlots) {
+                    BQ_LOGE("Slot %d is in mFreeBuffers "
+                            "but is also in mFreeSlots", slot);
+                    usleep(PAUSE_TIME);
+                }
+            }
+        } else {
+            if (isInFreeSlots) {
+                BQ_LOGE("Slot %d is in mFreeSlots but is not FREE (%d)",
+                        slot, mSlots[slot].mBufferState);
+                usleep(PAUSE_TIME);
+            }
+            if (isInFreeBuffers) {
+                BQ_LOGE("Slot %d is in mFreeBuffers but is not FREE (%d)",
+                        slot, mSlots[slot].mBufferState);
+                usleep(PAUSE_TIME);
+            }
+        }
+    }
+}
+
+} // namespace android
diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp
new file mode 100644
index 0000000..a941e2d
--- /dev/null
+++ b/libs/gui/BufferQueueProducer.cpp
@@ -0,0 +1,1107 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <inttypes.h>
+
+#define LOG_TAG "BufferQueueProducer"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+//#define LOG_NDEBUG 0
+
+#define EGL_EGLEXT_PROTOTYPES
+
+#include <gui/BufferItem.h>
+#include <gui/BufferQueueCore.h>
+#include <gui/BufferQueueProducer.h>
+#include <gui/IConsumerListener.h>
+#include <gui/IGraphicBufferAlloc.h>
+#include <gui/IProducerListener.h>
+
+#include <utils/Log.h>
+#include <utils/Trace.h>
+
+namespace android {
+
+BufferQueueProducer::BufferQueueProducer(const sp<BufferQueueCore>& core) :
+    mCore(core),
+    mSlots(core->mSlots),
+    mConsumerName(),
+    mStickyTransform(0),
+    mLastQueueBufferFence(Fence::NO_FENCE),
+    mCallbackMutex(),
+    mNextCallbackTicket(0),
+    mCurrentCallbackTicket(0),
+    mCallbackCondition() {}
+
+BufferQueueProducer::~BufferQueueProducer() {}
+
+status_t BufferQueueProducer::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
+    ATRACE_CALL();
+    BQ_LOGV("requestBuffer: slot %d", slot);
+    Mutex::Autolock lock(mCore->mMutex);
+
+    if (mCore->mIsAbandoned) {
+        BQ_LOGE("requestBuffer: BufferQueue has been abandoned");
+        return NO_INIT;
+    }
+
+    if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) {
+        BQ_LOGE("requestBuffer: slot index %d out of range [0, %d)",
+                slot, BufferQueueDefs::NUM_BUFFER_SLOTS);
+        return BAD_VALUE;
+    } else if (mSlots[slot].mBufferState != BufferSlot::DEQUEUED) {
+        BQ_LOGE("requestBuffer: slot %d is not owned by the producer "
+                "(state = %d)", slot, mSlots[slot].mBufferState);
+        return BAD_VALUE;
+    }
+
+    mSlots[slot].mRequestBufferCalled = true;
+    *buf = mSlots[slot].mGraphicBuffer;
+    return NO_ERROR;
+}
+
+status_t BufferQueueProducer::setBufferCount(int bufferCount) {
+    ATRACE_CALL();
+    BQ_LOGV("setBufferCount: count = %d", bufferCount);
+
+    sp<IConsumerListener> listener;
+    { // Autolock scope
+        Mutex::Autolock lock(mCore->mMutex);
+        mCore->waitWhileAllocatingLocked();
+
+        if (mCore->mIsAbandoned) {
+            BQ_LOGE("setBufferCount: BufferQueue has been abandoned");
+            return NO_INIT;
+        }
+
+        if (bufferCount > BufferQueueDefs::NUM_BUFFER_SLOTS) {
+            BQ_LOGE("setBufferCount: bufferCount %d too large (max %d)",
+                    bufferCount, BufferQueueDefs::NUM_BUFFER_SLOTS);
+            return BAD_VALUE;
+        }
+
+        // There must be no dequeued buffers when changing the buffer count.
+        for (int s = 0; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
+            if (mSlots[s].mBufferState == BufferSlot::DEQUEUED) {
+                BQ_LOGE("setBufferCount: buffer owned by producer");
+                return BAD_VALUE;
+            }
+        }
+
+        if (bufferCount == 0) {
+            mCore->mOverrideMaxBufferCount = 0;
+            mCore->mDequeueCondition.broadcast();
+            return NO_ERROR;
+        }
+
+        const int minBufferSlots = mCore->getMinMaxBufferCountLocked(false);
+        if (bufferCount < minBufferSlots) {
+            BQ_LOGE("setBufferCount: requested buffer count %d is less than "
+                    "minimum %d", bufferCount, minBufferSlots);
+            return BAD_VALUE;
+        }
+
+        // Here we are guaranteed that the producer doesn't have any dequeued
+        // buffers and will release all of its buffer references. We don't
+        // clear the queue, however, so that currently queued buffers still
+        // get displayed.
+        mCore->freeAllBuffersLocked();
+        mCore->mOverrideMaxBufferCount = bufferCount;
+        mCore->mDequeueCondition.broadcast();
+        listener = mCore->mConsumerListener;
+    } // Autolock scope
+
+    // Call back without lock held
+    if (listener != NULL) {
+        listener->onBuffersReleased();
+    }
+
+    return NO_ERROR;
+}
+
+status_t BufferQueueProducer::waitForFreeSlotThenRelock(const char* caller,
+        bool async, int* found, status_t* returnFlags) const {
+    bool tryAgain = true;
+    while (tryAgain) {
+        if (mCore->mIsAbandoned) {
+            BQ_LOGE("%s: BufferQueue has been abandoned", caller);
+            return NO_INIT;
+        }
+
+        const int maxBufferCount = mCore->getMaxBufferCountLocked(async);
+        if (async && mCore->mOverrideMaxBufferCount) {
+            // FIXME: Some drivers are manually setting the buffer count
+            // (which they shouldn't), so we do this extra test here to
+            // handle that case. This is TEMPORARY until we get this fixed.
+            if (mCore->mOverrideMaxBufferCount < maxBufferCount) {
+                BQ_LOGE("%s: async mode is invalid with buffer count override",
+                        caller);
+                return BAD_VALUE;
+            }
+        }
+
+        // Free up any buffers that are in slots beyond the max buffer count
+        for (int s = maxBufferCount; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
+            assert(mSlots[s].mBufferState == BufferSlot::FREE);
+            if (mSlots[s].mGraphicBuffer != NULL) {
+                mCore->freeBufferLocked(s);
+                *returnFlags |= RELEASE_ALL_BUFFERS;
+            }
+        }
+
+        int dequeuedCount = 0;
+        int acquiredCount = 0;
+        for (int s = 0; s < maxBufferCount; ++s) {
+            switch (mSlots[s].mBufferState) {
+                case BufferSlot::DEQUEUED:
+                    ++dequeuedCount;
+                    break;
+                case BufferSlot::ACQUIRED:
+                    ++acquiredCount;
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        // Producers are not allowed to dequeue more than one buffer if they
+        // did not set a buffer count
+        if (!mCore->mOverrideMaxBufferCount && dequeuedCount) {
+            BQ_LOGE("%s: can't dequeue multiple buffers without setting the "
+                    "buffer count", caller);
+            return INVALID_OPERATION;
+        }
+
+        // See whether a buffer has been queued since the last
+        // setBufferCount so we know whether to perform the min undequeued
+        // buffers check below
+        if (mCore->mBufferHasBeenQueued) {
+            // Make sure the producer is not trying to dequeue more buffers
+            // than allowed
+            const int newUndequeuedCount =
+                maxBufferCount - (dequeuedCount + 1);
+            const int minUndequeuedCount =
+                mCore->getMinUndequeuedBufferCountLocked(async);
+            if (newUndequeuedCount < minUndequeuedCount) {
+                BQ_LOGE("%s: min undequeued buffer count (%d) exceeded "
+                        "(dequeued=%d undequeued=%d)",
+                        caller, minUndequeuedCount,
+                        dequeuedCount, newUndequeuedCount);
+                return INVALID_OPERATION;
+            }
+        }
+
+        *found = BufferQueueCore::INVALID_BUFFER_SLOT;
+
+        // If we disconnect and reconnect quickly, we can be in a state where
+        // our slots are empty but we have many buffers in the queue. This can
+        // cause us to run out of memory if we outrun the consumer. Wait here if
+        // it looks like we have too many buffers queued up.
+        bool tooManyBuffers = mCore->mQueue.size()
+                            > static_cast<size_t>(maxBufferCount);
+        if (tooManyBuffers) {
+            BQ_LOGV("%s: queue size is %zu, waiting", caller,
+                    mCore->mQueue.size());
+        } else {
+            if (!mCore->mFreeBuffers.empty()) {
+                auto slot = mCore->mFreeBuffers.begin();
+                *found = *slot;
+                mCore->mFreeBuffers.erase(slot);
+            } else if (mCore->mAllowAllocation && !mCore->mFreeSlots.empty()) {
+                auto slot = mCore->mFreeSlots.begin();
+                // Only return free slots up to the max buffer count
+                if (*slot < maxBufferCount) {
+                    *found = *slot;
+                    mCore->mFreeSlots.erase(slot);
+                }
+            }
+        }
+
+        // If no buffer is found, or if the queue has too many buffers
+        // outstanding, wait for a buffer to be acquired or released, or for the
+        // max buffer count to change.
+        tryAgain = (*found == BufferQueueCore::INVALID_BUFFER_SLOT) ||
+                   tooManyBuffers;
+        if (tryAgain) {
+            // Return an error if we're in non-blocking mode (producer and
+            // consumer are controlled by the application).
+            // However, the consumer is allowed to briefly acquire an extra
+            // buffer (which could cause us to have to wait here), which is
+            // okay, since it is only used to implement an atomic acquire +
+            // release (e.g., in GLConsumer::updateTexImage())
+            if (mCore->mDequeueBufferCannotBlock &&
+                    (acquiredCount <= mCore->mMaxAcquiredBufferCount)) {
+                return WOULD_BLOCK;
+            }
+            mCore->mDequeueCondition.wait(mCore->mMutex);
+        }
+    } // while (tryAgain)
+
+    return NO_ERROR;
+}
+
+status_t BufferQueueProducer::dequeueBuffer(int *outSlot,
+        sp<android::Fence> *outFence, bool async,
+        uint32_t width, uint32_t height, PixelFormat format, uint32_t usage) {
+    ATRACE_CALL();
+    { // Autolock scope
+        Mutex::Autolock lock(mCore->mMutex);
+        mConsumerName = mCore->mConsumerName;
+    } // Autolock scope
+
+    BQ_LOGV("dequeueBuffer: async=%s w=%u h=%u format=%#x, usage=%#x",
+            async ? "true" : "false", width, height, format, usage);
+
+    if ((width && !height) || (!width && height)) {
+        BQ_LOGE("dequeueBuffer: invalid size: w=%u h=%u", width, height);
+        return BAD_VALUE;
+    }
+
+    status_t returnFlags = NO_ERROR;
+    EGLDisplay eglDisplay = EGL_NO_DISPLAY;
+    EGLSyncKHR eglFence = EGL_NO_SYNC_KHR;
+    bool attachedByConsumer = false;
+
+    { // Autolock scope
+        Mutex::Autolock lock(mCore->mMutex);
+        mCore->waitWhileAllocatingLocked();
+
+        if (format == 0) {
+            format = mCore->mDefaultBufferFormat;
+        }
+
+        // Enable the usage bits the consumer requested
+        usage |= mCore->mConsumerUsageBits;
+
+        const bool useDefaultSize = !width && !height;
+        if (useDefaultSize) {
+            width = mCore->mDefaultWidth;
+            height = mCore->mDefaultHeight;
+        }
+
+        int found = BufferItem::INVALID_BUFFER_SLOT;
+        while (found == BufferItem::INVALID_BUFFER_SLOT) {
+            status_t status = waitForFreeSlotThenRelock("dequeueBuffer", async,
+                    &found, &returnFlags);
+            if (status != NO_ERROR) {
+                return status;
+            }
+
+            // This should not happen
+            if (found == BufferQueueCore::INVALID_BUFFER_SLOT) {
+                BQ_LOGE("dequeueBuffer: no available buffer slots");
+                return -EBUSY;
+            }
+
+            const sp<GraphicBuffer>& buffer(mSlots[found].mGraphicBuffer);
+
+            // If we are not allowed to allocate new buffers,
+            // waitForFreeSlotThenRelock must have returned a slot containing a
+            // buffer. If this buffer would require reallocation to meet the
+            // requested attributes, we free it and attempt to get another one.
+            if (!mCore->mAllowAllocation) {
+                if (buffer->needsReallocation(width, height, format, usage)) {
+                    mCore->freeBufferLocked(found);
+                    found = BufferItem::INVALID_BUFFER_SLOT;
+                    continue;
+                }
+            }
+        }
+
+        *outSlot = found;
+        ATRACE_BUFFER_INDEX(found);
+
+        attachedByConsumer = mSlots[found].mAttachedByConsumer;
+
+        mSlots[found].mBufferState = BufferSlot::DEQUEUED;
+
+        const sp<GraphicBuffer>& buffer(mSlots[found].mGraphicBuffer);
+        if ((buffer == NULL) ||
+                buffer->needsReallocation(width, height, format, usage))
+        {
+            mSlots[found].mAcquireCalled = false;
+            mSlots[found].mGraphicBuffer = NULL;
+            mSlots[found].mRequestBufferCalled = false;
+            mSlots[found].mEglDisplay = EGL_NO_DISPLAY;
+            mSlots[found].mEglFence = EGL_NO_SYNC_KHR;
+            mSlots[found].mFence = Fence::NO_FENCE;
+            mCore->mBufferAge = 0;
+
+            returnFlags |= BUFFER_NEEDS_REALLOCATION;
+        } else {
+            // We add 1 because that will be the frame number when this buffer
+            // is queued
+            mCore->mBufferAge =
+                    mCore->mFrameCounter + 1 - mSlots[found].mFrameNumber;
+        }
+
+        BQ_LOGV("dequeueBuffer: setting buffer age to %" PRIu64,
+                mCore->mBufferAge);
+
+        if (CC_UNLIKELY(mSlots[found].mFence == NULL)) {
+            BQ_LOGE("dequeueBuffer: about to return a NULL fence - "
+                    "slot=%d w=%d h=%d format=%u",
+                    found, buffer->width, buffer->height, buffer->format);
+        }
+
+        eglDisplay = mSlots[found].mEglDisplay;
+        eglFence = mSlots[found].mEglFence;
+        *outFence = mSlots[found].mFence;
+        mSlots[found].mEglFence = EGL_NO_SYNC_KHR;
+        mSlots[found].mFence = Fence::NO_FENCE;
+
+        mCore->validateConsistencyLocked();
+    } // Autolock scope
+
+    if (returnFlags & BUFFER_NEEDS_REALLOCATION) {
+        status_t error;
+        BQ_LOGV("dequeueBuffer: allocating a new buffer for slot %d", *outSlot);
+        sp<GraphicBuffer> graphicBuffer(mCore->mAllocator->createGraphicBuffer(
+                width, height, format, usage, &error));
+        if (graphicBuffer == NULL) {
+            BQ_LOGE("dequeueBuffer: createGraphicBuffer failed");
+            return error;
+        }
+
+        { // Autolock scope
+            Mutex::Autolock lock(mCore->mMutex);
+
+            if (mCore->mIsAbandoned) {
+                BQ_LOGE("dequeueBuffer: BufferQueue has been abandoned");
+                return NO_INIT;
+            }
+
+            graphicBuffer->setGenerationNumber(mCore->mGenerationNumber);
+            mSlots[*outSlot].mGraphicBuffer = graphicBuffer;
+        } // Autolock scope
+    }
+
+    if (attachedByConsumer) {
+        returnFlags |= BUFFER_NEEDS_REALLOCATION;
+    }
+
+    if (eglFence != EGL_NO_SYNC_KHR) {
+        EGLint result = eglClientWaitSyncKHR(eglDisplay, eglFence, 0,
+                1000000000);
+        // If something goes wrong, log the error, but return the buffer without
+        // synchronizing access to it. It's too late at this point to abort the
+        // dequeue operation.
+        if (result == EGL_FALSE) {
+            BQ_LOGE("dequeueBuffer: error %#x waiting for fence",
+                    eglGetError());
+        } else if (result == EGL_TIMEOUT_EXPIRED_KHR) {
+            BQ_LOGE("dequeueBuffer: timeout waiting for fence");
+        }
+        eglDestroySyncKHR(eglDisplay, eglFence);
+    }
+
+    BQ_LOGV("dequeueBuffer: returning slot=%d/%" PRIu64 " buf=%p flags=%#x",
+            *outSlot,
+            mSlots[*outSlot].mFrameNumber,
+            mSlots[*outSlot].mGraphicBuffer->handle, returnFlags);
+
+    return returnFlags;
+}
+
+status_t BufferQueueProducer::detachBuffer(int slot) {
+    ATRACE_CALL();
+    ATRACE_BUFFER_INDEX(slot);
+    BQ_LOGV("detachBuffer(P): slot %d", slot);
+    Mutex::Autolock lock(mCore->mMutex);
+
+    if (mCore->mIsAbandoned) {
+        BQ_LOGE("detachBuffer(P): BufferQueue has been abandoned");
+        return NO_INIT;
+    }
+
+    if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) {
+        BQ_LOGE("detachBuffer(P): slot index %d out of range [0, %d)",
+                slot, BufferQueueDefs::NUM_BUFFER_SLOTS);
+        return BAD_VALUE;
+    } else if (mSlots[slot].mBufferState != BufferSlot::DEQUEUED) {
+        BQ_LOGE("detachBuffer(P): slot %d is not owned by the producer "
+                "(state = %d)", slot, mSlots[slot].mBufferState);
+        return BAD_VALUE;
+    } else if (!mSlots[slot].mRequestBufferCalled) {
+        BQ_LOGE("detachBuffer(P): buffer in slot %d has not been requested",
+                slot);
+        return BAD_VALUE;
+    }
+
+    mCore->freeBufferLocked(slot);
+    mCore->mDequeueCondition.broadcast();
+    mCore->validateConsistencyLocked();
+
+    return NO_ERROR;
+}
+
+status_t BufferQueueProducer::detachNextBuffer(sp<GraphicBuffer>* outBuffer,
+        sp<Fence>* outFence) {
+    ATRACE_CALL();
+
+    if (outBuffer == NULL) {
+        BQ_LOGE("detachNextBuffer: outBuffer must not be NULL");
+        return BAD_VALUE;
+    } else if (outFence == NULL) {
+        BQ_LOGE("detachNextBuffer: outFence must not be NULL");
+        return BAD_VALUE;
+    }
+
+    Mutex::Autolock lock(mCore->mMutex);
+    mCore->waitWhileAllocatingLocked();
+
+    if (mCore->mIsAbandoned) {
+        BQ_LOGE("detachNextBuffer: BufferQueue has been abandoned");
+        return NO_INIT;
+    }
+
+    if (mCore->mFreeBuffers.empty()) {
+        return NO_MEMORY;
+    }
+
+    int found = mCore->mFreeBuffers.front();
+    mCore->mFreeBuffers.remove(found);
+
+    BQ_LOGV("detachNextBuffer detached slot %d", found);
+
+    *outBuffer = mSlots[found].mGraphicBuffer;
+    *outFence = mSlots[found].mFence;
+    mCore->freeBufferLocked(found);
+    mCore->validateConsistencyLocked();
+
+    return NO_ERROR;
+}
+
+status_t BufferQueueProducer::attachBuffer(int* outSlot,
+        const sp<android::GraphicBuffer>& buffer) {
+    ATRACE_CALL();
+
+    if (outSlot == NULL) {
+        BQ_LOGE("attachBuffer(P): outSlot must not be NULL");
+        return BAD_VALUE;
+    } else if (buffer == NULL) {
+        BQ_LOGE("attachBuffer(P): cannot attach NULL buffer");
+        return BAD_VALUE;
+    }
+
+    Mutex::Autolock lock(mCore->mMutex);
+    mCore->waitWhileAllocatingLocked();
+
+    if (buffer->getGenerationNumber() != mCore->mGenerationNumber) {
+        BQ_LOGE("attachBuffer: generation number mismatch [buffer %u] "
+                "[queue %u]", buffer->getGenerationNumber(),
+                mCore->mGenerationNumber);
+        return BAD_VALUE;
+    }
+
+    status_t returnFlags = NO_ERROR;
+    int found;
+    // TODO: Should we provide an async flag to attachBuffer? It seems
+    // unlikely that buffers which we are attaching to a BufferQueue will
+    // be asynchronous (droppable), but it may not be impossible.
+    status_t status = waitForFreeSlotThenRelock("attachBuffer(P)", false,
+            &found, &returnFlags);
+    if (status != NO_ERROR) {
+        return status;
+    }
+
+    // This should not happen
+    if (found == BufferQueueCore::INVALID_BUFFER_SLOT) {
+        BQ_LOGE("attachBuffer(P): no available buffer slots");
+        return -EBUSY;
+    }
+
+    *outSlot = found;
+    ATRACE_BUFFER_INDEX(*outSlot);
+    BQ_LOGV("attachBuffer(P): returning slot %d flags=%#x",
+            *outSlot, returnFlags);
+
+    mSlots[*outSlot].mGraphicBuffer = buffer;
+    mSlots[*outSlot].mBufferState = BufferSlot::DEQUEUED;
+    mSlots[*outSlot].mEglFence = EGL_NO_SYNC_KHR;
+    mSlots[*outSlot].mFence = Fence::NO_FENCE;
+    mSlots[*outSlot].mRequestBufferCalled = true;
+
+    mCore->validateConsistencyLocked();
+
+    return returnFlags;
+}
+
+status_t BufferQueueProducer::queueBuffer(int slot,
+        const QueueBufferInput &input, QueueBufferOutput *output) {
+    ATRACE_CALL();
+    ATRACE_BUFFER_INDEX(slot);
+
+    int64_t timestamp;
+    bool isAutoTimestamp;
+    android_dataspace dataSpace;
+    Rect crop;
+    int scalingMode;
+    uint32_t transform;
+    uint32_t stickyTransform;
+    bool async;
+    sp<Fence> fence;
+    input.deflate(&timestamp, &isAutoTimestamp, &dataSpace, &crop, &scalingMode,
+            &transform, &async, &fence, &stickyTransform);
+    Region surfaceDamage = input.getSurfaceDamage();
+
+    if (fence == NULL) {
+        BQ_LOGE("queueBuffer: fence is NULL");
+        return BAD_VALUE;
+    }
+
+    switch (scalingMode) {
+        case NATIVE_WINDOW_SCALING_MODE_FREEZE:
+        case NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW:
+        case NATIVE_WINDOW_SCALING_MODE_SCALE_CROP:
+        case NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP:
+            break;
+        default:
+            BQ_LOGE("queueBuffer: unknown scaling mode %d", scalingMode);
+            return BAD_VALUE;
+    }
+
+    sp<IConsumerListener> frameAvailableListener;
+    sp<IConsumerListener> frameReplacedListener;
+    int callbackTicket = 0;
+    BufferItem item;
+    { // Autolock scope
+        Mutex::Autolock lock(mCore->mMutex);
+
+        if (mCore->mIsAbandoned) {
+            BQ_LOGE("queueBuffer: BufferQueue has been abandoned");
+            return NO_INIT;
+        }
+
+        const int maxBufferCount = mCore->getMaxBufferCountLocked(async);
+        if (async && mCore->mOverrideMaxBufferCount) {
+            // FIXME: Some drivers are manually setting the buffer count
+            // (which they shouldn't), so we do this extra test here to
+            // handle that case. This is TEMPORARY until we get this fixed.
+            if (mCore->mOverrideMaxBufferCount < maxBufferCount) {
+                BQ_LOGE("queueBuffer: async mode is invalid with "
+                        "buffer count override");
+                return BAD_VALUE;
+            }
+        }
+
+        if (slot < 0 || slot >= maxBufferCount) {
+            BQ_LOGE("queueBuffer: slot index %d out of range [0, %d)",
+                    slot, maxBufferCount);
+            return BAD_VALUE;
+        } else if (mSlots[slot].mBufferState != BufferSlot::DEQUEUED) {
+            BQ_LOGE("queueBuffer: slot %d is not owned by the producer "
+                    "(state = %d)", slot, mSlots[slot].mBufferState);
+            return BAD_VALUE;
+        } else if (!mSlots[slot].mRequestBufferCalled) {
+            BQ_LOGE("queueBuffer: slot %d was queued without requesting "
+                    "a buffer", slot);
+            return BAD_VALUE;
+        }
+
+        BQ_LOGV("queueBuffer: slot=%d/%" PRIu64 " time=%" PRIu64 " dataSpace=%d"
+                " crop=[%d,%d,%d,%d] transform=%#x scale=%s",
+                slot, mCore->mFrameCounter + 1, timestamp, dataSpace,
+                crop.left, crop.top, crop.right, crop.bottom, transform,
+                BufferItem::scalingModeName(static_cast<uint32_t>(scalingMode)));
+
+        const sp<GraphicBuffer>& graphicBuffer(mSlots[slot].mGraphicBuffer);
+        Rect bufferRect(graphicBuffer->getWidth(), graphicBuffer->getHeight());
+        Rect croppedRect;
+        crop.intersect(bufferRect, &croppedRect);
+        if (croppedRect != crop) {
+            BQ_LOGE("queueBuffer: crop rect is not contained within the "
+                    "buffer in slot %d", slot);
+            return BAD_VALUE;
+        }
+
+        // Override UNKNOWN dataspace with consumer default
+        if (dataSpace == HAL_DATASPACE_UNKNOWN) {
+            dataSpace = mCore->mDefaultBufferDataSpace;
+        }
+
+        mSlots[slot].mFence = fence;
+        mSlots[slot].mBufferState = BufferSlot::QUEUED;
+        ++mCore->mFrameCounter;
+        mSlots[slot].mFrameNumber = mCore->mFrameCounter;
+
+        item.mAcquireCalled = mSlots[slot].mAcquireCalled;
+        item.mGraphicBuffer = mSlots[slot].mGraphicBuffer;
+        item.mCrop = crop;
+        item.mTransform = transform &
+                ~static_cast<uint32_t>(NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY);
+        item.mTransformToDisplayInverse =
+                (transform & NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY) != 0;
+        item.mScalingMode = static_cast<uint32_t>(scalingMode);
+        item.mTimestamp = timestamp;
+        item.mIsAutoTimestamp = isAutoTimestamp;
+        item.mDataSpace = dataSpace;
+        item.mFrameNumber = mCore->mFrameCounter;
+        item.mSlot = slot;
+        item.mFence = fence;
+        item.mIsDroppable = mCore->mDequeueBufferCannotBlock || async;
+        item.mSurfaceDamage = surfaceDamage;
+
+        mStickyTransform = stickyTransform;
+
+        if (mCore->mQueue.empty()) {
+            // When the queue is empty, we can ignore mDequeueBufferCannotBlock
+            // and simply queue this buffer
+            mCore->mQueue.push_back(item);
+            frameAvailableListener = mCore->mConsumerListener;
+        } else {
+            // When the queue is not empty, we need to look at the front buffer
+            // state to see if we need to replace it
+            BufferQueueCore::Fifo::iterator front(mCore->mQueue.begin());
+            if (front->mIsDroppable) {
+                // If the front queued buffer is still being tracked, we first
+                // mark it as freed
+                if (mCore->stillTracking(front)) {
+                    mSlots[front->mSlot].mBufferState = BufferSlot::FREE;
+                    mCore->mFreeBuffers.push_front(front->mSlot);
+                }
+                // Overwrite the droppable buffer with the incoming one
+                *front = item;
+                frameReplacedListener = mCore->mConsumerListener;
+            } else {
+                mCore->mQueue.push_back(item);
+                frameAvailableListener = mCore->mConsumerListener;
+            }
+        }
+
+        mCore->mBufferHasBeenQueued = true;
+        mCore->mDequeueCondition.broadcast();
+
+        output->inflate(mCore->mDefaultWidth, mCore->mDefaultHeight,
+                mCore->mTransformHint,
+                static_cast<uint32_t>(mCore->mQueue.size()));
+
+        ATRACE_INT(mCore->mConsumerName.string(), mCore->mQueue.size());
+
+        // Take a ticket for the callback functions
+        callbackTicket = mNextCallbackTicket++;
+
+        mCore->validateConsistencyLocked();
+    } // Autolock scope
+
+    // Don't send the GraphicBuffer through the callback, and don't send
+    // the slot number, since the consumer shouldn't need it
+    item.mGraphicBuffer.clear();
+    item.mSlot = BufferItem::INVALID_BUFFER_SLOT;
+
+    // Call back without the main BufferQueue lock held, but with the callback
+    // lock held so we can ensure that callbacks occur in order
+    {
+        Mutex::Autolock lock(mCallbackMutex);
+        while (callbackTicket != mCurrentCallbackTicket) {
+            mCallbackCondition.wait(mCallbackMutex);
+        }
+
+        if (frameAvailableListener != NULL) {
+            frameAvailableListener->onFrameAvailable(item);
+        } else if (frameReplacedListener != NULL) {
+            frameReplacedListener->onFrameReplaced(item);
+        }
+
+        ++mCurrentCallbackTicket;
+        mCallbackCondition.broadcast();
+    }
+
+    // Wait without lock held
+    if (mCore->mConnectedApi == NATIVE_WINDOW_API_EGL) {
+        // Waiting here allows for two full buffers to be queued but not a
+        // third. In the event that frames take varying time, this makes a
+        // small trade-off in favor of latency rather than throughput.
+        mLastQueueBufferFence->waitForever("Throttling EGL Production");
+        mLastQueueBufferFence = fence;
+    }
+
+    return NO_ERROR;
+}
+
+void BufferQueueProducer::cancelBuffer(int slot, const sp<Fence>& fence) {
+    ATRACE_CALL();
+    BQ_LOGV("cancelBuffer: slot %d", slot);
+    Mutex::Autolock lock(mCore->mMutex);
+
+    if (mCore->mIsAbandoned) {
+        BQ_LOGE("cancelBuffer: BufferQueue has been abandoned");
+        return;
+    }
+
+    if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) {
+        BQ_LOGE("cancelBuffer: slot index %d out of range [0, %d)",
+                slot, BufferQueueDefs::NUM_BUFFER_SLOTS);
+        return;
+    } else if (mSlots[slot].mBufferState != BufferSlot::DEQUEUED) {
+        BQ_LOGE("cancelBuffer: slot %d is not owned by the producer "
+                "(state = %d)", slot, mSlots[slot].mBufferState);
+        return;
+    } else if (fence == NULL) {
+        BQ_LOGE("cancelBuffer: fence is NULL");
+        return;
+    }
+
+    mCore->mFreeBuffers.push_front(slot);
+    mSlots[slot].mBufferState = BufferSlot::FREE;
+    mSlots[slot].mFence = fence;
+    mCore->mDequeueCondition.broadcast();
+    mCore->validateConsistencyLocked();
+}
+
+int BufferQueueProducer::query(int what, int *outValue) {
+    ATRACE_CALL();
+    Mutex::Autolock lock(mCore->mMutex);
+
+    if (outValue == NULL) {
+        BQ_LOGE("query: outValue was NULL");
+        return BAD_VALUE;
+    }
+
+    if (mCore->mIsAbandoned) {
+        BQ_LOGE("query: BufferQueue has been abandoned");
+        return NO_INIT;
+    }
+
+    int value;
+    switch (what) {
+        case NATIVE_WINDOW_WIDTH:
+            value = static_cast<int32_t>(mCore->mDefaultWidth);
+            break;
+        case NATIVE_WINDOW_HEIGHT:
+            value = static_cast<int32_t>(mCore->mDefaultHeight);
+            break;
+        case NATIVE_WINDOW_FORMAT:
+            value = static_cast<int32_t>(mCore->mDefaultBufferFormat);
+            break;
+        case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
+            value = mCore->getMinUndequeuedBufferCountLocked(false);
+            break;
+        case NATIVE_WINDOW_STICKY_TRANSFORM:
+            value = static_cast<int32_t>(mStickyTransform);
+            break;
+        case NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND:
+            value = (mCore->mQueue.size() > 1);
+            break;
+        case NATIVE_WINDOW_CONSUMER_USAGE_BITS:
+            value = static_cast<int32_t>(mCore->mConsumerUsageBits);
+            break;
+        case NATIVE_WINDOW_DEFAULT_DATASPACE:
+            value = static_cast<int32_t>(mCore->mDefaultBufferDataSpace);
+            break;
+        case NATIVE_WINDOW_BUFFER_AGE:
+            if (mCore->mBufferAge > INT32_MAX) {
+                value = 0;
+            } else {
+                value = static_cast<int32_t>(mCore->mBufferAge);
+            }
+            break;
+        default:
+            return BAD_VALUE;
+    }
+
+    BQ_LOGV("query: %d? %d", what, value);
+    *outValue = value;
+    return NO_ERROR;
+}
+
+status_t BufferQueueProducer::connect(const sp<IProducerListener>& listener,
+        int api, bool producerControlledByApp, QueueBufferOutput *output) {
+    ATRACE_CALL();
+    Mutex::Autolock lock(mCore->mMutex);
+    mConsumerName = mCore->mConsumerName;
+    BQ_LOGV("connect(P): api=%d producerControlledByApp=%s", api,
+            producerControlledByApp ? "true" : "false");
+
+    if (mCore->mIsAbandoned) {
+        BQ_LOGE("connect(P): BufferQueue has been abandoned");
+        return NO_INIT;
+    }
+
+    if (mCore->mConsumerListener == NULL) {
+        BQ_LOGE("connect(P): BufferQueue has no consumer");
+        return NO_INIT;
+    }
+
+    if (output == NULL) {
+        BQ_LOGE("connect(P): output was NULL");
+        return BAD_VALUE;
+    }
+
+    if (mCore->mConnectedApi != BufferQueueCore::NO_CONNECTED_API) {
+        BQ_LOGE("connect(P): already connected (cur=%d req=%d)",
+                mCore->mConnectedApi, api);
+        return BAD_VALUE;
+    }
+
+    int status = NO_ERROR;
+    switch (api) {
+        case NATIVE_WINDOW_API_EGL:
+        case NATIVE_WINDOW_API_CPU:
+        case NATIVE_WINDOW_API_MEDIA:
+        case NATIVE_WINDOW_API_CAMERA:
+            mCore->mConnectedApi = api;
+            output->inflate(mCore->mDefaultWidth, mCore->mDefaultHeight,
+                    mCore->mTransformHint,
+                    static_cast<uint32_t>(mCore->mQueue.size()));
+
+            // Set up a death notification so that we can disconnect
+            // automatically if the remote producer dies
+            if (listener != NULL &&
+                    IInterface::asBinder(listener)->remoteBinder() != NULL) {
+                status = IInterface::asBinder(listener)->linkToDeath(
+                        static_cast<IBinder::DeathRecipient*>(this));
+                if (status != NO_ERROR) {
+                    BQ_LOGE("connect(P): linkToDeath failed: %s (%d)",
+                            strerror(-status), status);
+                }
+            }
+            mCore->mConnectedProducerListener = listener;
+            break;
+        default:
+            BQ_LOGE("connect(P): unknown API %d", api);
+            status = BAD_VALUE;
+            break;
+    }
+
+    mCore->mBufferHasBeenQueued = false;
+    mCore->mDequeueBufferCannotBlock =
+            mCore->mConsumerControlledByApp && producerControlledByApp;
+    mCore->mAllowAllocation = true;
+
+    return status;
+}
+
+status_t BufferQueueProducer::disconnect(int api) {
+    ATRACE_CALL();
+    BQ_LOGV("disconnect(P): api %d", api);
+
+    int status = NO_ERROR;
+    sp<IConsumerListener> listener;
+    { // Autolock scope
+        Mutex::Autolock lock(mCore->mMutex);
+        mCore->waitWhileAllocatingLocked();
+
+        if (mCore->mIsAbandoned) {
+            // It's not really an error to disconnect after the surface has
+            // been abandoned; it should just be a no-op.
+            return NO_ERROR;
+        }
+
+        switch (api) {
+            case NATIVE_WINDOW_API_EGL:
+            case NATIVE_WINDOW_API_CPU:
+            case NATIVE_WINDOW_API_MEDIA:
+            case NATIVE_WINDOW_API_CAMERA:
+                if (mCore->mConnectedApi == api) {
+                    mCore->freeAllBuffersLocked();
+
+                    // Remove our death notification callback if we have one
+                    if (mCore->mConnectedProducerListener != NULL) {
+                        sp<IBinder> token =
+                                IInterface::asBinder(mCore->mConnectedProducerListener);
+                        // This can fail if we're here because of the death
+                        // notification, but we just ignore it
+                        token->unlinkToDeath(
+                                static_cast<IBinder::DeathRecipient*>(this));
+                    }
+                    mCore->mConnectedProducerListener = NULL;
+                    mCore->mConnectedApi = BufferQueueCore::NO_CONNECTED_API;
+                    mCore->mSidebandStream.clear();
+                    mCore->mDequeueCondition.broadcast();
+                    listener = mCore->mConsumerListener;
+                } else if (mCore->mConnectedApi != BufferQueueCore::NO_CONNECTED_API) {
+                    BQ_LOGE("disconnect(P): still connected to another API "
+                            "(cur=%d req=%d)", mCore->mConnectedApi, api);
+                    status = BAD_VALUE;
+                }
+                break;
+            default:
+                BQ_LOGE("disconnect(P): unknown API %d", api);
+                status = BAD_VALUE;
+                break;
+        }
+    } // Autolock scope
+
+    // Call back without lock held
+    if (listener != NULL) {
+        listener->onBuffersReleased();
+    }
+
+    return status;
+}
+
+status_t BufferQueueProducer::setSidebandStream(const sp<NativeHandle>& stream) {
+    sp<IConsumerListener> listener;
+    { // Autolock scope
+        Mutex::Autolock _l(mCore->mMutex);
+        mCore->mSidebandStream = stream;
+        listener = mCore->mConsumerListener;
+    } // Autolock scope
+
+    if (listener != NULL) {
+        listener->onSidebandStreamChanged();
+    }
+    return NO_ERROR;
+}
+
+void BufferQueueProducer::allocateBuffers(bool async, uint32_t width,
+        uint32_t height, PixelFormat format, uint32_t usage) {
+    ATRACE_CALL();
+    while (true) {
+        Vector<int> freeSlots;
+        size_t newBufferCount = 0;
+        uint32_t allocWidth = 0;
+        uint32_t allocHeight = 0;
+        PixelFormat allocFormat = PIXEL_FORMAT_UNKNOWN;
+        uint32_t allocUsage = 0;
+        { // Autolock scope
+            Mutex::Autolock lock(mCore->mMutex);
+            mCore->waitWhileAllocatingLocked();
+
+            if (!mCore->mAllowAllocation) {
+                BQ_LOGE("allocateBuffers: allocation is not allowed for this "
+                        "BufferQueue");
+                return;
+            }
+
+            int currentBufferCount = 0;
+            for (int slot = 0; slot < BufferQueueDefs::NUM_BUFFER_SLOTS; ++slot) {
+                if (mSlots[slot].mGraphicBuffer != NULL) {
+                    ++currentBufferCount;
+                } else {
+                    if (mSlots[slot].mBufferState != BufferSlot::FREE) {
+                        BQ_LOGE("allocateBuffers: slot %d without buffer is not FREE",
+                                slot);
+                        continue;
+                    }
+
+                    freeSlots.push_back(slot);
+                }
+            }
+
+            int maxBufferCount = mCore->getMaxBufferCountLocked(async);
+            BQ_LOGV("allocateBuffers: allocating from %d buffers up to %d buffers",
+                    currentBufferCount, maxBufferCount);
+            if (maxBufferCount <= currentBufferCount)
+                return;
+            newBufferCount =
+                    static_cast<size_t>(maxBufferCount - currentBufferCount);
+            if (freeSlots.size() < newBufferCount) {
+                BQ_LOGE("allocateBuffers: ran out of free slots");
+                return;
+            }
+            allocWidth = width > 0 ? width : mCore->mDefaultWidth;
+            allocHeight = height > 0 ? height : mCore->mDefaultHeight;
+            allocFormat = format != 0 ? format : mCore->mDefaultBufferFormat;
+            allocUsage = usage | mCore->mConsumerUsageBits;
+
+            mCore->mIsAllocating = true;
+        } // Autolock scope
+
+        Vector<sp<GraphicBuffer>> buffers;
+        for (size_t i = 0; i <  newBufferCount; ++i) {
+            status_t result = NO_ERROR;
+            sp<GraphicBuffer> graphicBuffer(mCore->mAllocator->createGraphicBuffer(
+                    allocWidth, allocHeight, allocFormat, allocUsage, &result));
+            if (result != NO_ERROR) {
+                BQ_LOGE("allocateBuffers: failed to allocate buffer (%u x %u, format"
+                        " %u, usage %u)", width, height, format, usage);
+                Mutex::Autolock lock(mCore->mMutex);
+                mCore->mIsAllocating = false;
+                mCore->mIsAllocatingCondition.broadcast();
+                return;
+            }
+            buffers.push_back(graphicBuffer);
+        }
+
+        { // Autolock scope
+            Mutex::Autolock lock(mCore->mMutex);
+            uint32_t checkWidth = width > 0 ? width : mCore->mDefaultWidth;
+            uint32_t checkHeight = height > 0 ? height : mCore->mDefaultHeight;
+            PixelFormat checkFormat = format != 0 ?
+                    format : mCore->mDefaultBufferFormat;
+            uint32_t checkUsage = usage | mCore->mConsumerUsageBits;
+            if (checkWidth != allocWidth || checkHeight != allocHeight ||
+                checkFormat != allocFormat || checkUsage != allocUsage) {
+                // Something changed while we released the lock. Retry.
+                BQ_LOGV("allocateBuffers: size/format/usage changed while allocating. Retrying.");
+                mCore->mIsAllocating = false;
+                mCore->mIsAllocatingCondition.broadcast();
+                continue;
+            }
+
+            for (size_t i = 0; i < newBufferCount; ++i) {
+                int slot = freeSlots[i];
+                if (mSlots[slot].mBufferState != BufferSlot::FREE) {
+                    // A consumer allocated the FREE slot with attachBuffer. Discard the buffer we
+                    // allocated.
+                    BQ_LOGV("allocateBuffers: slot %d was acquired while allocating. "
+                            "Dropping allocated buffer.", slot);
+                    continue;
+                }
+                mCore->freeBufferLocked(slot); // Clean up the slot first
+                mSlots[slot].mGraphicBuffer = buffers[i];
+                mSlots[slot].mFence = Fence::NO_FENCE;
+
+                // freeBufferLocked puts this slot on the free slots list. Since
+                // we then attached a buffer, move the slot to free buffer list.
+                mCore->mFreeSlots.erase(slot);
+                mCore->mFreeBuffers.push_front(slot);
+
+                BQ_LOGV("allocateBuffers: allocated a new buffer in slot %d", slot);
+            }
+
+            mCore->mIsAllocating = false;
+            mCore->mIsAllocatingCondition.broadcast();
+            mCore->validateConsistencyLocked();
+        } // Autolock scope
+    }
+}
+
+status_t BufferQueueProducer::allowAllocation(bool allow) {
+    ATRACE_CALL();
+    BQ_LOGV("allowAllocation: %s", allow ? "true" : "false");
+
+    Mutex::Autolock lock(mCore->mMutex);
+    mCore->mAllowAllocation = allow;
+    return NO_ERROR;
+}
+
+status_t BufferQueueProducer::setGenerationNumber(uint32_t generationNumber) {
+    ATRACE_CALL();
+    BQ_LOGV("setGenerationNumber: %u", generationNumber);
+
+    Mutex::Autolock lock(mCore->mMutex);
+    mCore->mGenerationNumber = generationNumber;
+    return NO_ERROR;
+}
+
+String8 BufferQueueProducer::getConsumerName() const {
+    ATRACE_CALL();
+    BQ_LOGV("getConsumerName: %s", mConsumerName.string());
+    return mConsumerName;
+}
+
+void BufferQueueProducer::binderDied(const wp<android::IBinder>& /* who */) {
+    // If we're here, it means that a producer we were connected to died.
+    // We're guaranteed that we are still connected to it because we remove
+    // this callback upon disconnect. It's therefore safe to read mConnectedApi
+    // without synchronization here.
+    int api = mCore->mConnectedApi;
+    disconnect(api);
+}
+
+} // namespace android
diff --git a/libs/gui/BufferSlot.cpp b/libs/gui/BufferSlot.cpp
new file mode 100644
index 0000000..01595de
--- /dev/null
+++ b/libs/gui/BufferSlot.cpp
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gui/BufferSlot.h>
+
+namespace android {
+
+const char* BufferSlot::bufferStateName(BufferState state) {
+    switch (state) {
+        case BufferSlot::DEQUEUED: return "DEQUEUED";
+        case BufferSlot::QUEUED: return "QUEUED";
+        case BufferSlot::FREE: return "FREE";
+        case BufferSlot::ACQUIRED: return "ACQUIRED";
+    }
+    return "Unknown";
+}
+
+} // namespace android
diff --git a/libs/gui/ConsumerBase.cpp b/libs/gui/ConsumerBase.cpp
index c4ec857..04ab06b 100644
--- a/libs/gui/ConsumerBase.cpp
+++ b/libs/gui/ConsumerBase.cpp
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#include <inttypes.h>
+
 #define LOG_TAG "ConsumerBase"
 #define ATRACE_TAG ATRACE_TAG_GRAPHICS
 //#define LOG_NDEBUG 0
@@ -25,6 +27,7 @@
 
 #include <hardware/hardware.h>
 
+#include <gui/BufferItem.h>
 #include <gui/IGraphicBufferAlloc.h>
 #include <gui/ISurfaceComposer.h>
 #include <gui/SurfaceComposerClient.h>
@@ -37,11 +40,11 @@
 #include <utils/Trace.h>
 
 // Macros for including the ConsumerBase name in log messages
-#define CB_LOGV(x, ...) ALOGV("[%s] "x, mName.string(), ##__VA_ARGS__)
-#define CB_LOGD(x, ...) ALOGD("[%s] "x, mName.string(), ##__VA_ARGS__)
-#define CB_LOGI(x, ...) ALOGI("[%s] "x, mName.string(), ##__VA_ARGS__)
-#define CB_LOGW(x, ...) ALOGW("[%s] "x, mName.string(), ##__VA_ARGS__)
-#define CB_LOGE(x, ...) ALOGE("[%s] "x, mName.string(), ##__VA_ARGS__)
+#define CB_LOGV(x, ...) ALOGV("[%s] " x, mName.string(), ##__VA_ARGS__)
+//#define CB_LOGD(x, ...) ALOGD("[%s] " x, mName.string(), ##__VA_ARGS__)
+//#define CB_LOGI(x, ...) ALOGI("[%s] " x, mName.string(), ##__VA_ARGS__)
+//#define CB_LOGW(x, ...) ALOGW("[%s] " x, mName.string(), ##__VA_ARGS__)
+#define CB_LOGE(x, ...) ALOGE("[%s] " x, mName.string(), ##__VA_ARGS__)
 
 namespace android {
 
@@ -85,7 +88,7 @@
         "consumer is not abandoned!", mName.string());
 }
 
-void ConsumerBase::onLastStrongRef(const void* id) {
+void ConsumerBase::onLastStrongRef(const void* id __attribute__((unused))) {
     abandon();
 }
 
@@ -96,7 +99,7 @@
     mSlots[slotIndex].mFrameNumber = 0;
 }
 
-void ConsumerBase::onFrameAvailable() {
+void ConsumerBase::onFrameAvailable(const BufferItem& item) {
     CB_LOGV("onFrameAvailable");
 
     sp<FrameAvailableListener> listener;
@@ -107,7 +110,22 @@
 
     if (listener != NULL) {
         CB_LOGV("actually calling onFrameAvailable");
-        listener->onFrameAvailable();
+        listener->onFrameAvailable(item);
+    }
+}
+
+void ConsumerBase::onFrameReplaced(const BufferItem &item) {
+    CB_LOGV("onFrameReplaced");
+
+    sp<FrameAvailableListener> listener;
+    {
+        Mutex::Autolock lock(mMutex);
+        listener = mFrameAvailableListener.promote();
+    }
+
+    if (listener != NULL) {
+        CB_LOGV("actually calling onFrameReplaced");
+        listener->onFrameReplaced(item);
     }
 }
 
@@ -121,15 +139,18 @@
         return;
     }
 
-    uint32_t mask = 0;
+    uint64_t mask = 0;
     mConsumer->getReleasedBuffers(&mask);
     for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
-        if (mask & (1 << i)) {
+        if (mask & (1ULL << i)) {
             freeBufferLocked(i);
         }
     }
 }
 
+void ConsumerBase::onSidebandStreamChanged() {
+}
+
 void ConsumerBase::abandon() {
     CB_LOGV("abandon");
     Mutex::Autolock lock(mMutex);
@@ -150,6 +171,11 @@
     mConsumer.clear();
 }
 
+bool ConsumerBase::isAbandoned() {
+    Mutex::Autolock _l(mMutex);
+    return mAbandoned;
+}
+
 void ConsumerBase::setFrameAvailableListener(
         const wp<FrameAvailableListener>& listener) {
     CB_LOGV("setFrameAvailableListener");
@@ -157,6 +183,37 @@
     mFrameAvailableListener = listener;
 }
 
+status_t ConsumerBase::detachBuffer(int slot) {
+    CB_LOGV("detachBuffer");
+    Mutex::Autolock lock(mMutex);
+
+    status_t result = mConsumer->detachBuffer(slot);
+    if (result != NO_ERROR) {
+        CB_LOGE("Failed to detach buffer: %d", result);
+        return result;
+    }
+
+    freeBufferLocked(slot);
+
+    return result;
+}
+
+status_t ConsumerBase::setDefaultBufferSize(uint32_t width, uint32_t height) {
+    Mutex::Autolock _l(mMutex);
+    return mConsumer->setDefaultBufferSize(width, height);
+}
+
+status_t ConsumerBase::setDefaultBufferFormat(PixelFormat defaultFormat) {
+    Mutex::Autolock _l(mMutex);
+    return mConsumer->setDefaultBufferFormat(defaultFormat);
+}
+
+status_t ConsumerBase::setDefaultBufferDataSpace(
+        android_dataspace defaultDataSpace) {
+    Mutex::Autolock _l(mMutex);
+    return mConsumer->setDefaultBufferDataSpace(defaultDataSpace);
+}
+
 void ConsumerBase::dump(String8& result) const {
     dump(result, "");
 }
@@ -174,9 +231,9 @@
     }
 }
 
-status_t ConsumerBase::acquireBufferLocked(BufferQueue::BufferItem *item,
-        nsecs_t presentWhen) {
-    status_t err = mConsumer->acquireBuffer(item, presentWhen);
+status_t ConsumerBase::acquireBufferLocked(BufferItem *item,
+        nsecs_t presentWhen, uint64_t maxFrameNumber) {
+    status_t err = mConsumer->acquireBuffer(item, presentWhen, maxFrameNumber);
     if (err != NO_ERROR) {
         return err;
     }
@@ -188,7 +245,7 @@
     mSlots[item->mBuf].mFrameNumber = item->mFrameNumber;
     mSlots[item->mBuf].mFence = item->mFence;
 
-    CB_LOGV("acquireBufferLocked: -> slot=%d/%llu",
+    CB_LOGV("acquireBufferLocked: -> slot=%d/%" PRIu64,
             item->mBuf, item->mFrameNumber);
 
     return OK;
@@ -239,11 +296,11 @@
         return OK;
     }
 
-    CB_LOGV("releaseBufferLocked: slot=%d/%llu",
+    CB_LOGV("releaseBufferLocked: slot=%d/%" PRIu64,
             slot, mSlots[slot].mFrameNumber);
     status_t err = mConsumer->releaseBuffer(slot, mSlots[slot].mFrameNumber,
             display, eglFence, mSlots[slot].mFence);
-    if (err == BufferQueue::STALE_BUFFER_SLOT) {
+    if (err == IGraphicBufferConsumer::STALE_BUFFER_SLOT) {
         freeBufferLocked(slot);
     }
 
diff --git a/libs/gui/CpuConsumer.cpp b/libs/gui/CpuConsumer.cpp
index bff55d1..e29b740 100644
--- a/libs/gui/CpuConsumer.cpp
+++ b/libs/gui/CpuConsumer.cpp
@@ -16,22 +16,23 @@
 
 //#define LOG_NDEBUG 0
 #define LOG_TAG "CpuConsumer"
-#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+//#define ATRACE_TAG ATRACE_TAG_GRAPHICS
 
 #include <cutils/compiler.h>
 #include <utils/Log.h>
+#include <gui/BufferItem.h>
 #include <gui/CpuConsumer.h>
 
-#define CC_LOGV(x, ...) ALOGV("[%s] "x, mName.string(), ##__VA_ARGS__)
-#define CC_LOGD(x, ...) ALOGD("[%s] "x, mName.string(), ##__VA_ARGS__)
-#define CC_LOGI(x, ...) ALOGI("[%s] "x, mName.string(), ##__VA_ARGS__)
-#define CC_LOGW(x, ...) ALOGW("[%s] "x, mName.string(), ##__VA_ARGS__)
-#define CC_LOGE(x, ...) ALOGE("[%s] "x, mName.string(), ##__VA_ARGS__)
+#define CC_LOGV(x, ...) ALOGV("[%s] " x, mName.string(), ##__VA_ARGS__)
+//#define CC_LOGD(x, ...) ALOGD("[%s] " x, mName.string(), ##__VA_ARGS__)
+//#define CC_LOGI(x, ...) ALOGI("[%s] " x, mName.string(), ##__VA_ARGS__)
+#define CC_LOGW(x, ...) ALOGW("[%s] " x, mName.string(), ##__VA_ARGS__)
+#define CC_LOGE(x, ...) ALOGE("[%s] " x, mName.string(), ##__VA_ARGS__)
 
 namespace android {
 
 CpuConsumer::CpuConsumer(const sp<IGraphicBufferConsumer>& bq,
-        uint32_t maxLockedBuffers, bool controlledByApp) :
+        size_t maxLockedBuffers, bool controlledByApp) :
     ConsumerBase(bq, controlledByApp),
     mMaxLockedBuffers(maxLockedBuffers),
     mCurrentLockedBuffers(0)
@@ -40,7 +41,7 @@
     mAcquiredBuffers.insertAt(0, maxLockedBuffers);
 
     mConsumer->setConsumerUsageBits(GRALLOC_USAGE_SW_READ_OFTEN);
-    mConsumer->setMaxAcquiredBufferCount(maxLockedBuffers);
+    mConsumer->setMaxAcquiredBufferCount(static_cast<int32_t>(maxLockedBuffers));
 }
 
 CpuConsumer::~CpuConsumer() {
@@ -55,16 +56,30 @@
     mConsumer->setConsumerName(name);
 }
 
-status_t CpuConsumer::setDefaultBufferSize(uint32_t width, uint32_t height)
-{
-    Mutex::Autolock _l(mMutex);
-    return mConsumer->setDefaultBufferSize(width, height);
-}
+static bool isPossiblyYUV(PixelFormat format) {
+    switch (static_cast<int>(format)) {
+        case HAL_PIXEL_FORMAT_RGBA_8888:
+        case HAL_PIXEL_FORMAT_RGBX_8888:
+        case HAL_PIXEL_FORMAT_RGB_888:
+        case HAL_PIXEL_FORMAT_RGB_565:
+        case HAL_PIXEL_FORMAT_BGRA_8888:
+        case HAL_PIXEL_FORMAT_Y8:
+        case HAL_PIXEL_FORMAT_Y16:
+        case HAL_PIXEL_FORMAT_RAW16:
+        case HAL_PIXEL_FORMAT_RAW10:
+        case HAL_PIXEL_FORMAT_RAW_OPAQUE:
+        case HAL_PIXEL_FORMAT_BLOB:
+        case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
+            return false;
 
-status_t CpuConsumer::setDefaultBufferFormat(uint32_t defaultFormat)
-{
-    Mutex::Autolock _l(mMutex);
-    return mConsumer->setDefaultBufferFormat(defaultFormat);
+        case HAL_PIXEL_FORMAT_YV12:
+        case HAL_PIXEL_FORMAT_YCbCr_420_888:
+        case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+        case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+        case HAL_PIXEL_FORMAT_YCbCr_422_I:
+        default:
+            return true;
+    }
 }
 
 status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) {
@@ -72,12 +87,12 @@
 
     if (!nativeBuffer) return BAD_VALUE;
     if (mCurrentLockedBuffers == mMaxLockedBuffers) {
-        CC_LOGW("Max buffers have been locked (%d), cannot lock anymore.",
+        CC_LOGW("Max buffers have been locked (%zd), cannot lock anymore.",
                 mMaxLockedBuffers);
         return NOT_ENOUGH_DATA;
     }
 
-    BufferQueue::BufferItem b;
+    BufferItem b;
 
     Mutex::Autolock _l(mMutex);
 
@@ -93,37 +108,50 @@
 
     int buf = b.mBuf;
 
-    if (b.mFence.get()) {
-        err = b.mFence->waitForever("CpuConsumer::lockNextBuffer");
-        if (err != OK) {
-            CC_LOGE("Failed to wait for fence of acquired buffer: %s (%d)",
+    void *bufferPointer = NULL;
+    android_ycbcr ycbcr = android_ycbcr();
+
+    PixelFormat format = mSlots[buf].mGraphicBuffer->getPixelFormat();
+    PixelFormat flexFormat = format;
+    if (isPossiblyYUV(format)) {
+        if (b.mFence.get()) {
+            err = mSlots[buf].mGraphicBuffer->lockAsyncYCbCr(
+                GraphicBuffer::USAGE_SW_READ_OFTEN,
+                b.mCrop,
+                &ycbcr,
+                b.mFence->dup());
+        } else {
+            err = mSlots[buf].mGraphicBuffer->lockYCbCr(
+                GraphicBuffer::USAGE_SW_READ_OFTEN,
+                b.mCrop,
+                &ycbcr);
+        }
+        if (err == OK) {
+            bufferPointer = ycbcr.y;
+            flexFormat = HAL_PIXEL_FORMAT_YCbCr_420_888;
+            if (format != HAL_PIXEL_FORMAT_YCbCr_420_888) {
+                CC_LOGV("locking buffer of format %#x as flex YUV", format);
+            }
+        } else if (format == HAL_PIXEL_FORMAT_YCbCr_420_888) {
+            CC_LOGE("Unable to lock YCbCr buffer for CPU reading: %s (%d)",
                     strerror(-err), err);
             return err;
         }
     }
 
-    void *bufferPointer = NULL;
-    android_ycbcr ycbcr = android_ycbcr();
-
-    if (mSlots[buf].mGraphicBuffer->getPixelFormat() ==
-            HAL_PIXEL_FORMAT_YCbCr_420_888) {
-        err = mSlots[buf].mGraphicBuffer->lockYCbCr(
-            GraphicBuffer::USAGE_SW_READ_OFTEN,
-            b.mCrop,
-            &ycbcr);
-
-        if (err != OK) {
-            CC_LOGE("Unable to lock YCbCr buffer for CPU reading: %s (%d)",
-                    strerror(-err), err);
-            return err;
+    if (bufferPointer == NULL) { // not flexible YUV
+        if (b.mFence.get()) {
+            err = mSlots[buf].mGraphicBuffer->lockAsync(
+                GraphicBuffer::USAGE_SW_READ_OFTEN,
+                b.mCrop,
+                &bufferPointer,
+                b.mFence->dup());
+        } else {
+            err = mSlots[buf].mGraphicBuffer->lock(
+                GraphicBuffer::USAGE_SW_READ_OFTEN,
+                b.mCrop,
+                &bufferPointer);
         }
-        bufferPointer = ycbcr.y;
-    } else {
-        err = mSlots[buf].mGraphicBuffer->lock(
-            GraphicBuffer::USAGE_SW_READ_OFTEN,
-            b.mCrop,
-            &bufferPointer);
-
         if (err != OK) {
             CC_LOGE("Unable to lock buffer for CPU reading: %s (%d)",
                     strerror(-err), err);
@@ -132,7 +160,7 @@
     }
 
     size_t lockedIdx = 0;
-    for (; lockedIdx < mMaxLockedBuffers; lockedIdx++) {
+    for (; lockedIdx < static_cast<size_t>(mMaxLockedBuffers); lockedIdx++) {
         if (mAcquiredBuffers[lockedIdx].mSlot ==
                 BufferQueue::INVALID_BUFFER_SLOT) {
             break;
@@ -149,21 +177,23 @@
             reinterpret_cast<uint8_t*>(bufferPointer);
     nativeBuffer->width  = mSlots[buf].mGraphicBuffer->getWidth();
     nativeBuffer->height = mSlots[buf].mGraphicBuffer->getHeight();
-    nativeBuffer->format = mSlots[buf].mGraphicBuffer->getPixelFormat();
+    nativeBuffer->format = format;
+    nativeBuffer->flexFormat = flexFormat;
     nativeBuffer->stride = (ycbcr.y != NULL) ?
-            ycbcr.ystride :
+            static_cast<uint32_t>(ycbcr.ystride) :
             mSlots[buf].mGraphicBuffer->getStride();
 
     nativeBuffer->crop        = b.mCrop;
     nativeBuffer->transform   = b.mTransform;
     nativeBuffer->scalingMode = b.mScalingMode;
     nativeBuffer->timestamp   = b.mTimestamp;
+    nativeBuffer->dataSpace   = b.mDataSpace;
     nativeBuffer->frameNumber = b.mFrameNumber;
 
     nativeBuffer->dataCb       = reinterpret_cast<uint8_t*>(ycbcr.cb);
     nativeBuffer->dataCr       = reinterpret_cast<uint8_t*>(ycbcr.cr);
-    nativeBuffer->chromaStride = ycbcr.cstride;
-    nativeBuffer->chromaStep   = ycbcr.chroma_step;
+    nativeBuffer->chromaStride = static_cast<uint32_t>(ycbcr.cstride);
+    nativeBuffer->chromaStep   = static_cast<uint32_t>(ycbcr.chroma_step);
 
     mCurrentLockedBuffers++;
 
@@ -173,10 +203,9 @@
 status_t CpuConsumer::unlockBuffer(const LockedBuffer &nativeBuffer) {
     Mutex::Autolock _l(mMutex);
     size_t lockedIdx = 0;
-    status_t err;
 
     void *bufPtr = reinterpret_cast<void *>(nativeBuffer.data);
-    for (; lockedIdx < mMaxLockedBuffers; lockedIdx++) {
+    for (; lockedIdx < static_cast<size_t>(mMaxLockedBuffers); lockedIdx++) {
         if (bufPtr == mAcquiredBuffers[lockedIdx].mBufferPointer) break;
     }
     if (lockedIdx == mMaxLockedBuffers) {
@@ -187,16 +216,24 @@
     return releaseAcquiredBufferLocked(lockedIdx);
 }
 
-status_t CpuConsumer::releaseAcquiredBufferLocked(int lockedIdx) {
+status_t CpuConsumer::releaseAcquiredBufferLocked(size_t lockedIdx) {
     status_t err;
+    int fd = -1;
 
-    err = mAcquiredBuffers[lockedIdx].mGraphicBuffer->unlock();
+    err = mAcquiredBuffers[lockedIdx].mGraphicBuffer->unlockAsync(&fd);
     if (err != OK) {
-        CC_LOGE("%s: Unable to unlock graphic buffer %d", __FUNCTION__,
+        CC_LOGE("%s: Unable to unlock graphic buffer %zd", __FUNCTION__,
                 lockedIdx);
         return err;
     }
     int buf = mAcquiredBuffers[lockedIdx].mSlot;
+    if (CC_LIKELY(fd != -1)) {
+        sp<Fence> fence(new Fence(fd));
+        addReleaseFenceLocked(
+            mAcquiredBuffers[lockedIdx].mSlot,
+            mSlots[buf].mGraphicBuffer,
+            fence);
+    }
 
     // release the buffer if it hasn't already been freed by the BufferQueue.
     // This can happen, for example, when the producer of this buffer
diff --git a/libs/gui/GLConsumer.cpp b/libs/gui/GLConsumer.cpp
index 7ee3081..757e08a 100644
--- a/libs/gui/GLConsumer.cpp
+++ b/libs/gui/GLConsumer.cpp
@@ -29,6 +29,7 @@
 
 #include <hardware/hardware.h>
 
+#include <gui/BufferItem.h>
 #include <gui/GLConsumer.h>
 #include <gui/IGraphicBufferAlloc.h>
 #include <gui/ISurfaceComposer.h>
@@ -47,18 +48,28 @@
 namespace android {
 
 // Macros for including the GLConsumer name in log messages
-#define ST_LOGV(x, ...) ALOGV("[%s] "x, mName.string(), ##__VA_ARGS__)
-#define ST_LOGD(x, ...) ALOGD("[%s] "x, mName.string(), ##__VA_ARGS__)
-#define ST_LOGI(x, ...) ALOGI("[%s] "x, mName.string(), ##__VA_ARGS__)
-#define ST_LOGW(x, ...) ALOGW("[%s] "x, mName.string(), ##__VA_ARGS__)
-#define ST_LOGE(x, ...) ALOGE("[%s] "x, mName.string(), ##__VA_ARGS__)
+#define GLC_LOGV(x, ...) ALOGV("[%s] " x, mName.string(), ##__VA_ARGS__)
+#define GLC_LOGD(x, ...) ALOGD("[%s] " x, mName.string(), ##__VA_ARGS__)
+//#define GLC_LOGI(x, ...) ALOGI("[%s] " x, mName.string(), ##__VA_ARGS__)
+#define GLC_LOGW(x, ...) ALOGW("[%s] " x, mName.string(), ##__VA_ARGS__)
+#define GLC_LOGE(x, ...) ALOGE("[%s] " x, mName.string(), ##__VA_ARGS__)
 
 static const struct {
-    size_t width, height;
+    uint32_t width, height;
     char const* bits;
 } kDebugData = { 15, 12,
-    "___________________________________XX_XX_______X_X_____X_X____X_XXXXXXX_X____XXXXXXXXXXX__"
-    "___XX_XXX_XX_______XXXXXXX_________X___X_________X_____X__________________________________"
+    "_______________"
+    "_______________"
+    "_____XX_XX_____"
+    "__X_X_____X_X__"
+    "__X_XXXXXXX_X__"
+    "__XXXXXXXXXXX__"
+    "___XX_XXX_XX___"
+    "____XXXXXXX____"
+    "_____X___X_____"
+    "____X_____X____"
+    "_______________"
+    "_______________"
 };
 
 // Transform matrices
@@ -135,7 +146,34 @@
     mCurrentTexture(BufferQueue::INVALID_BUFFER_SLOT),
     mAttached(true)
 {
-    ST_LOGV("GLConsumer");
+    GLC_LOGV("GLConsumer");
+
+    memcpy(mCurrentTransformMatrix, mtxIdentity,
+            sizeof(mCurrentTransformMatrix));
+
+    mConsumer->setConsumerUsageBits(DEFAULT_USAGE_FLAGS);
+}
+
+GLConsumer::GLConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t texTarget,
+        bool useFenceSync, bool isControlledByApp) :
+    ConsumerBase(bq, isControlledByApp),
+    mCurrentTransform(0),
+    mCurrentScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
+    mCurrentFence(Fence::NO_FENCE),
+    mCurrentTimestamp(0),
+    mCurrentFrameNumber(0),
+    mDefaultWidth(1),
+    mDefaultHeight(1),
+    mFilteringEnabled(true),
+    mTexName(0),
+    mUseFenceSync(useFenceSync),
+    mTexTarget(texTarget),
+    mEglDisplay(EGL_NO_DISPLAY),
+    mEglContext(EGL_NO_CONTEXT),
+    mCurrentTexture(BufferQueue::INVALID_BUFFER_SLOT),
+    mAttached(false)
+{
+    GLC_LOGV("GLConsumer");
 
     memcpy(mCurrentTransformMatrix, mtxIdentity,
             sizeof(mCurrentTransformMatrix));
@@ -159,11 +197,11 @@
 
 status_t GLConsumer::updateTexImage() {
     ATRACE_CALL();
-    ST_LOGV("updateTexImage");
+    GLC_LOGV("updateTexImage");
     Mutex::Autolock lock(mMutex);
 
     if (mAbandoned) {
-        ST_LOGE("updateTexImage: GLConsumer is abandoned!");
+        GLC_LOGE("updateTexImage: GLConsumer is abandoned!");
         return NO_INIT;
     }
 
@@ -173,7 +211,7 @@
         return err;
     }
 
-    BufferQueue::BufferItem item;
+    BufferItem item;
 
     // Acquire the next buffer.
     // In asynchronous mode the list is guaranteed to be one buffer
@@ -182,11 +220,11 @@
     if (err != NO_ERROR) {
         if (err == BufferQueue::NO_BUFFER_AVAILABLE) {
             // We always bind the texture even if we don't update its contents.
-            ST_LOGV("updateTexImage: no buffers were available");
+            GLC_LOGV("updateTexImage: no buffers were available");
             glBindTexture(mTexTarget, mTexName);
             err = NO_ERROR;
         } else {
-            ST_LOGE("updateTexImage: acquire failed: %s (%d)",
+            GLC_LOGE("updateTexImage: acquire failed: %s (%d)",
                 strerror(-err), err);
         }
         return err;
@@ -207,11 +245,11 @@
 
 status_t GLConsumer::releaseTexImage() {
     ATRACE_CALL();
-    ST_LOGV("releaseTexImage");
+    GLC_LOGV("releaseTexImage");
     Mutex::Autolock lock(mMutex);
 
     if (mAbandoned) {
-        ST_LOGE("releaseTexImage: GLConsumer is abandoned!");
+        GLC_LOGE("releaseTexImage: GLConsumer is abandoned!");
         return NO_INIT;
     }
 
@@ -231,13 +269,13 @@
     int buf = mCurrentTexture;
     if (buf != BufferQueue::INVALID_BUFFER_SLOT) {
 
-        ST_LOGV("releaseTexImage: (slot=%d, mAttached=%d)", buf, mAttached);
+        GLC_LOGV("releaseTexImage: (slot=%d, mAttached=%d)", buf, mAttached);
 
         if (mAttached) {
             // Do whatever sync ops we need to do before releasing the slot.
             err = syncForReleaseLocked(mEglDisplay);
             if (err != NO_ERROR) {
-                ST_LOGE("syncForReleaseLocked failed (slot=%d), err=%d", buf, err);
+                GLC_LOGE("syncForReleaseLocked failed (slot=%d), err=%d", buf, err);
                 return err;
             }
         } else {
@@ -247,13 +285,17 @@
 
         err = releaseBufferLocked(buf, mSlots[buf].mGraphicBuffer, mEglDisplay, EGL_NO_SYNC_KHR);
         if (err < NO_ERROR) {
-            ST_LOGE("releaseTexImage: failed to release buffer: %s (%d)",
+            GLC_LOGE("releaseTexImage: failed to release buffer: %s (%d)",
                     strerror(-err), err);
             return err;
         }
 
+        if (mReleasedTexImage == NULL) {
+            mReleasedTexImage = new EglImage(getDebugTexImageBuffer());
+        }
+
         mCurrentTexture = BufferQueue::INVALID_BUFFER_SLOT;
-        mCurrentTextureBuf = getDebugTexImageBuffer();
+        mCurrentTextureImage = mReleasedTexImage;
         mCurrentCrop.makeInvalid();
         mCurrentTransform = 0;
         mCurrentScalingMode = NATIVE_WINDOW_SCALING_MODE_FREEZE;
@@ -261,9 +303,11 @@
         mCurrentFence = Fence::NO_FENCE;
 
         if (mAttached) {
-            // bind a dummy texture
-            glBindTexture(mTexTarget, mTexName);
-            bindUnslottedBufferLocked(mEglDisplay);
+            // This binds a dummy buffer (mReleasedTexImage).
+            status_t result = bindTextureImageLocked();
+            if (result != NO_ERROR) {
+                return result;
+            }
         } else {
             // detached, don't touch the texture (and we may not even have an
             // EGLDisplay here.
@@ -283,14 +327,15 @@
                 GraphicBuffer::USAGE_SW_WRITE_RARELY);
         uint32_t* bits;
         buffer->lock(GraphicBuffer::USAGE_SW_WRITE_RARELY, reinterpret_cast<void**>(&bits));
-        size_t w = buffer->getStride();
-        size_t h = buffer->getHeight();
-        memset(bits, 0, w*h*4);
-        for (size_t y=0 ; y<kDebugData.height ; y++) {
-            for (size_t x=0 ; x<kDebugData.width ; x++) {
-                bits[x] = (kDebugData.bits[y*kDebugData.width+x] == 'X') ? 0xFF000000 : 0xFFFFFFFF;
+        uint32_t stride = buffer->getStride();
+        uint32_t height = buffer->getHeight();
+        memset(bits, 0, stride * height * 4);
+        for (uint32_t y = 0; y < kDebugData.height; y++) {
+            for (uint32_t x = 0; x < kDebugData.width; x++) {
+                bits[x] = (kDebugData.bits[y + kDebugData.width + x] == 'X') ?
+                    0xFF000000 : 0xFFFFFFFF;
             }
-            bits += w;
+            bits += stride;
         }
         buffer->unlock();
         sReleasedTexImageBuffer = buffer;
@@ -298,36 +343,20 @@
     return sReleasedTexImageBuffer;
 }
 
-status_t GLConsumer::acquireBufferLocked(BufferQueue::BufferItem *item,
-        nsecs_t presentWhen) {
-    status_t err = ConsumerBase::acquireBufferLocked(item, presentWhen);
+status_t GLConsumer::acquireBufferLocked(BufferItem *item,
+        nsecs_t presentWhen, uint64_t maxFrameNumber) {
+    status_t err = ConsumerBase::acquireBufferLocked(item, presentWhen,
+            maxFrameNumber);
     if (err != NO_ERROR) {
         return err;
     }
 
-    int slot = item->mBuf;
-    bool destroyEglImage = false;
-
-    if (mEglSlots[slot].mEglImage != EGL_NO_IMAGE_KHR) {
-        if (item->mGraphicBuffer != NULL) {
-            // This buffer has not been acquired before, so we must assume
-            // that any EGLImage in mEglSlots is stale.
-            destroyEglImage = true;
-        } else if (mEglSlots[slot].mCropRect != item->mCrop) {
-            // We've already seen this buffer before, but it now has a
-            // different crop rect, so we'll need to recreate the EGLImage if
-            // we're using the EGL_ANDROID_image_crop extension.
-            destroyEglImage = hasEglAndroidImageCrop();
-        }
-    }
-
-    if (destroyEglImage) {
-        if (!eglDestroyImageKHR(mEglDisplay, mEglSlots[slot].mEglImage)) {
-            ST_LOGW("acquireBufferLocked: eglDestroyImageKHR failed for slot=%d",
-                  slot);
-            // keep going
-        }
-        mEglSlots[slot].mEglImage = EGL_NO_IMAGE_KHR;
+    // If item->mGraphicBuffer is not null, this buffer has not been acquired
+    // before, so any prior EglImage created is using a stale buffer. This
+    // replaces any old EglImage with a new one (using the new buffer).
+    if (item->mGraphicBuffer != NULL) {
+        int slot = item->mBuf;
+        mEglSlots[slot].mEglImage = new EglImage(item->mGraphicBuffer);
     }
 
     return NO_ERROR;
@@ -346,41 +375,40 @@
     return err;
 }
 
-status_t GLConsumer::updateAndReleaseLocked(const BufferQueue::BufferItem& item)
+status_t GLConsumer::updateAndReleaseLocked(const BufferItem& item)
 {
     status_t err = NO_ERROR;
 
+    int buf = item.mBuf;
+
     if (!mAttached) {
-        ST_LOGE("updateAndRelease: GLConsumer is not attached to an OpenGL "
+        GLC_LOGE("updateAndRelease: GLConsumer is not attached to an OpenGL "
                 "ES context");
+        releaseBufferLocked(buf, mSlots[buf].mGraphicBuffer,
+                mEglDisplay, EGL_NO_SYNC_KHR);
         return INVALID_OPERATION;
     }
 
     // Confirm state.
     err = checkAndUpdateEglStateLocked();
     if (err != NO_ERROR) {
+        releaseBufferLocked(buf, mSlots[buf].mGraphicBuffer,
+                mEglDisplay, EGL_NO_SYNC_KHR);
         return err;
     }
 
-    int buf = item.mBuf;
-
-    // If the mEglSlot entry is empty, create an EGLImage for the gralloc
-    // buffer currently in the slot in ConsumerBase.
-    //
+    // Ensure we have a valid EglImageKHR for the slot, creating an EglImage
+    // if nessessary, for the gralloc buffer currently in the slot in
+    // ConsumerBase.
     // We may have to do this even when item.mGraphicBuffer == NULL (which
-    // means the buffer was previously acquired), if we destroyed the
-    // EGLImage when detaching from a context but the buffer has not been
-    // re-allocated.
-    if (mEglSlots[buf].mEglImage == EGL_NO_IMAGE_KHR) {
-        EGLImageKHR image = createImage(mEglDisplay,
-                mSlots[buf].mGraphicBuffer, item.mCrop);
-        if (image == EGL_NO_IMAGE_KHR) {
-            ST_LOGW("updateAndRelease: unable to createImage on display=%p slot=%d",
-                  mEglDisplay, buf);
-            return UNKNOWN_ERROR;
-        }
-        mEglSlots[buf].mEglImage = image;
-        mEglSlots[buf].mCropRect = item.mCrop;
+    // means the buffer was previously acquired).
+    err = mEglSlots[buf].mEglImage->createIfNeeded(mEglDisplay, item.mCrop);
+    if (err != NO_ERROR) {
+        GLC_LOGW("updateAndRelease: unable to createImage on display=%p slot=%d",
+                mEglDisplay, buf);
+        releaseBufferLocked(buf, mSlots[buf].mGraphicBuffer,
+                mEglDisplay, EGL_NO_SYNC_KHR);
+        return UNKNOWN_ERROR;
     }
 
     // Do whatever sync ops we need to do before releasing the old slot.
@@ -395,18 +423,18 @@
         return err;
     }
 
-    ST_LOGV("updateAndRelease: (slot=%d buf=%p) -> (slot=%d buf=%p)",
-            mCurrentTexture,
-            mCurrentTextureBuf != NULL ? mCurrentTextureBuf->handle : 0,
+    GLC_LOGV("updateAndRelease: (slot=%d buf=%p) -> (slot=%d buf=%p)",
+            mCurrentTexture, mCurrentTextureImage != NULL ?
+                    mCurrentTextureImage->graphicBufferHandle() : 0,
             buf, mSlots[buf].mGraphicBuffer->handle);
 
     // release old buffer
     if (mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) {
         status_t status = releaseBufferLocked(
-                mCurrentTexture, mCurrentTextureBuf, mEglDisplay,
-                mEglSlots[mCurrentTexture].mEglFence);
+                mCurrentTexture, mCurrentTextureImage->graphicBuffer(),
+                mEglDisplay, mEglSlots[mCurrentTexture].mEglFence);
         if (status < NO_ERROR) {
-            ST_LOGE("updateAndRelease: failed to release buffer: %s (%d)",
+            GLC_LOGE("updateAndRelease: failed to release buffer: %s (%d)",
                    strerror(-status), status);
             err = status;
             // keep going, with error raised [?]
@@ -415,7 +443,7 @@
 
     // Update the GLConsumer state.
     mCurrentTexture = buf;
-    mCurrentTextureBuf = mSlots[buf].mGraphicBuffer;
+    mCurrentTextureImage = mEglSlots[buf].mEglImage;
     mCurrentCrop = item.mCrop;
     mCurrentTransform = item.mTransform;
     mCurrentScalingMode = item.mScalingMode;
@@ -434,36 +462,50 @@
         return INVALID_OPERATION;
     }
 
-    GLint error;
+    GLenum error;
     while ((error = glGetError()) != GL_NO_ERROR) {
-        ST_LOGW("bindTextureImage: clearing GL error: %#04x", error);
+        GLC_LOGW("bindTextureImage: clearing GL error: %#04x", error);
     }
 
     glBindTexture(mTexTarget, mTexName);
-    if (mCurrentTexture == BufferQueue::INVALID_BUFFER_SLOT) {
-        if (mCurrentTextureBuf == NULL) {
-            ST_LOGE("bindTextureImage: no currently-bound texture");
-            return NO_INIT;
-        }
-        status_t err = bindUnslottedBufferLocked(mEglDisplay);
-        if (err != NO_ERROR) {
-            return err;
-        }
-    } else {
-        EGLImageKHR image = mEglSlots[mCurrentTexture].mEglImage;
+    if (mCurrentTexture == BufferQueue::INVALID_BUFFER_SLOT &&
+            mCurrentTextureImage == NULL) {
+        GLC_LOGE("bindTextureImage: no currently-bound texture");
+        return NO_INIT;
+    }
 
-        glEGLImageTargetTexture2DOES(mTexTarget, (GLeglImageOES)image);
+    status_t err = mCurrentTextureImage->createIfNeeded(mEglDisplay,
+                                                        mCurrentCrop);
+    if (err != NO_ERROR) {
+        GLC_LOGW("bindTextureImage: can't create image on display=%p slot=%d",
+                mEglDisplay, mCurrentTexture);
+        return UNKNOWN_ERROR;
+    }
+    mCurrentTextureImage->bindToTextureTarget(mTexTarget);
 
-        while ((error = glGetError()) != GL_NO_ERROR) {
-            ST_LOGE("bindTextureImage: error binding external texture image %p"
-                    ": %#04x", image, error);
+    // In the rare case that the display is terminated and then initialized
+    // again, we can't detect that the display changed (it didn't), but the
+    // image is invalid. In this case, repeat the exact same steps while
+    // forcing the creation of a new image.
+    if ((error = glGetError()) != GL_NO_ERROR) {
+        glBindTexture(mTexTarget, mTexName);
+        status_t result = mCurrentTextureImage->createIfNeeded(mEglDisplay,
+                                                               mCurrentCrop,
+                                                               true);
+        if (result != NO_ERROR) {
+            GLC_LOGW("bindTextureImage: can't create image on display=%p slot=%d",
+                    mEglDisplay, mCurrentTexture);
+            return UNKNOWN_ERROR;
+        }
+        mCurrentTextureImage->bindToTextureTarget(mTexTarget);
+        if ((error = glGetError()) != GL_NO_ERROR) {
+            GLC_LOGE("bindTextureImage: error binding external image: %#04x", error);
             return UNKNOWN_ERROR;
         }
     }
 
     // Wait for the new buffer to be ready.
     return doGLFenceWaitLocked();
-
 }
 
 status_t GLConsumer::checkAndUpdateEglStateLocked(bool contextCheck) {
@@ -476,18 +518,18 @@
         if (mEglDisplay == EGL_NO_DISPLAY) {
             mEglDisplay = dpy;
         }
-        if (mEglContext == EGL_NO_DISPLAY) {
+        if (mEglContext == EGL_NO_CONTEXT) {
             mEglContext = ctx;
         }
     }
 
     if (mEglDisplay != dpy || dpy == EGL_NO_DISPLAY) {
-        ST_LOGE("checkAndUpdateEglState: invalid current EGLDisplay");
+        GLC_LOGE("checkAndUpdateEglState: invalid current EGLDisplay");
         return INVALID_OPERATION;
     }
 
     if (mEglContext != ctx || ctx == EGL_NO_CONTEXT) {
-        ST_LOGE("checkAndUpdateEglState: invalid current EGLContext");
+        GLC_LOGE("checkAndUpdateEglState: invalid current EGLContext");
         return INVALID_OPERATION;
     }
 
@@ -500,9 +542,9 @@
     if (fence->isValid() &&
             mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) {
         status_t err = addReleaseFence(mCurrentTexture,
-                mCurrentTextureBuf, fence);
+                mCurrentTextureImage->graphicBuffer(), fence);
         if (err != OK) {
-            ST_LOGE("setReleaseFence: failed to add the fence: %s (%d)",
+            GLC_LOGE("setReleaseFence: failed to add the fence: %s (%d)",
                     strerror(-err), err);
         }
     }
@@ -510,16 +552,16 @@
 
 status_t GLConsumer::detachFromContext() {
     ATRACE_CALL();
-    ST_LOGV("detachFromContext");
+    GLC_LOGV("detachFromContext");
     Mutex::Autolock lock(mMutex);
 
     if (mAbandoned) {
-        ST_LOGE("detachFromContext: abandoned GLConsumer");
+        GLC_LOGE("detachFromContext: abandoned GLConsumer");
         return NO_INIT;
     }
 
     if (!mAttached) {
-        ST_LOGE("detachFromContext: GLConsumer is not attached to a "
+        GLC_LOGE("detachFromContext: GLConsumer is not attached to a "
                 "context");
         return INVALID_OPERATION;
     }
@@ -528,12 +570,12 @@
     EGLContext ctx = eglGetCurrentContext();
 
     if (mEglDisplay != dpy && mEglDisplay != EGL_NO_DISPLAY) {
-        ST_LOGE("detachFromContext: invalid current EGLDisplay");
+        GLC_LOGE("detachFromContext: invalid current EGLDisplay");
         return INVALID_OPERATION;
     }
 
     if (mEglContext != ctx && mEglContext != EGL_NO_CONTEXT) {
-        ST_LOGE("detachFromContext: invalid current EGLContext");
+        GLC_LOGE("detachFromContext: invalid current EGLContext");
         return INVALID_OPERATION;
     }
 
@@ -546,18 +588,6 @@
         glDeleteTextures(1, &mTexName);
     }
 
-    // Because we're giving up the EGLDisplay we need to free all the EGLImages
-    // that are associated with it.  They'll be recreated when the
-    // GLConsumer gets attached to a new OpenGL ES context (and thus gets a
-    // new EGLDisplay).
-    for (int i =0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
-        EGLImageKHR img = mEglSlots[i].mEglImage;
-        if (img != EGL_NO_IMAGE_KHR) {
-            eglDestroyImageKHR(mEglDisplay, img);
-            mEglSlots[i].mEglImage = EGL_NO_IMAGE_KHR;
-        }
-    }
-
     mEglDisplay = EGL_NO_DISPLAY;
     mEglContext = EGL_NO_CONTEXT;
     mAttached = false;
@@ -567,16 +597,16 @@
 
 status_t GLConsumer::attachToContext(uint32_t tex) {
     ATRACE_CALL();
-    ST_LOGV("attachToContext");
+    GLC_LOGV("attachToContext");
     Mutex::Autolock lock(mMutex);
 
     if (mAbandoned) {
-        ST_LOGE("attachToContext: abandoned GLConsumer");
+        GLC_LOGE("attachToContext: abandoned GLConsumer");
         return NO_INIT;
     }
 
     if (mAttached) {
-        ST_LOGE("attachToContext: GLConsumer is already attached to a "
+        GLC_LOGE("attachToContext: GLConsumer is already attached to a "
                 "context");
         return INVALID_OPERATION;
     }
@@ -585,12 +615,12 @@
     EGLContext ctx = eglGetCurrentContext();
 
     if (dpy == EGL_NO_DISPLAY) {
-        ST_LOGE("attachToContext: invalid current EGLDisplay");
+        GLC_LOGE("attachToContext: invalid current EGLDisplay");
         return INVALID_OPERATION;
     }
 
     if (ctx == EGL_NO_CONTEXT) {
-        ST_LOGE("attachToContext: invalid current EGLContext");
+        GLC_LOGE("attachToContext: invalid current EGLContext");
         return INVALID_OPERATION;
     }
 
@@ -598,66 +628,35 @@
     // buffer.
     glBindTexture(mTexTarget, GLuint(tex));
 
-    if (mCurrentTextureBuf != NULL) {
-        // The EGLImageKHR that was associated with the slot was destroyed when
-        // the GLConsumer was detached from the old context, so we need to
-        // recreate it here.
-        status_t err = bindUnslottedBufferLocked(dpy);
-        if (err != NO_ERROR) {
-            return err;
-        }
-    }
-
     mEglDisplay = dpy;
     mEglContext = ctx;
     mTexName = tex;
     mAttached = true;
 
+    if (mCurrentTextureImage != NULL) {
+        // This may wait for a buffer a second time. This is likely required if
+        // this is a different context, since otherwise the wait could be skipped
+        // by bouncing through another context. For the same context the extra
+        // wait is redundant.
+        status_t err =  bindTextureImageLocked();
+        if (err != NO_ERROR) {
+            return err;
+        }
+    }
+
     return OK;
 }
 
-status_t GLConsumer::bindUnslottedBufferLocked(EGLDisplay dpy) {
-    ST_LOGV("bindUnslottedBuffer ct=%d ctb=%p",
-            mCurrentTexture, mCurrentTextureBuf.get());
-
-    // Create a temporary EGLImageKHR.
-    Rect crop;
-    EGLImageKHR image = createImage(dpy, mCurrentTextureBuf, mCurrentCrop);
-    if (image == EGL_NO_IMAGE_KHR) {
-        return UNKNOWN_ERROR;
-    }
-
-    // Attach the current buffer to the GL texture.
-    glEGLImageTargetTexture2DOES(mTexTarget, (GLeglImageOES)image);
-
-    GLint error;
-    status_t err = OK;
-    while ((error = glGetError()) != GL_NO_ERROR) {
-        ST_LOGE("bindUnslottedBuffer: error binding external texture image %p "
-                "(slot %d): %#04x", image, mCurrentTexture, error);
-        err = UNKNOWN_ERROR;
-    }
-
-    // We destroy the EGLImageKHR here because the current buffer may no
-    // longer be associated with one of the buffer slots, so we have
-    // nowhere to to store it.  If the buffer is still associated with a
-    // slot then another EGLImageKHR will be created next time that buffer
-    // gets acquired in updateTexImage.
-    eglDestroyImageKHR(dpy, image);
-
-    return err;
-}
-
 
 status_t GLConsumer::syncForReleaseLocked(EGLDisplay dpy) {
-    ST_LOGV("syncForReleaseLocked");
+    GLC_LOGV("syncForReleaseLocked");
 
     if (mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) {
         if (SyncFeatures::getInstance().useNativeFenceSync()) {
             EGLSyncKHR sync = eglCreateSyncKHR(dpy,
                     EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
             if (sync == EGL_NO_SYNC_KHR) {
-                ST_LOGE("syncForReleaseLocked: error creating EGL fence: %#x",
+                GLC_LOGE("syncForReleaseLocked: error creating EGL fence: %#x",
                         eglGetError());
                 return UNKNOWN_ERROR;
             }
@@ -665,15 +664,15 @@
             int fenceFd = eglDupNativeFenceFDANDROID(dpy, sync);
             eglDestroySyncKHR(dpy, sync);
             if (fenceFd == EGL_NO_NATIVE_FENCE_FD_ANDROID) {
-                ST_LOGE("syncForReleaseLocked: error dup'ing native fence "
+                GLC_LOGE("syncForReleaseLocked: error dup'ing native fence "
                         "fd: %#x", eglGetError());
                 return UNKNOWN_ERROR;
             }
             sp<Fence> fence(new Fence(fenceFd));
             status_t err = addReleaseFenceLocked(mCurrentTexture,
-                    mCurrentTextureBuf, fence);
+                    mCurrentTextureImage->graphicBuffer(), fence);
             if (err != OK) {
-                ST_LOGE("syncForReleaseLocked: error adding release fence: "
+                GLC_LOGE("syncForReleaseLocked: error adding release fence: "
                         "%s (%d)", strerror(-err), err);
                 return err;
             }
@@ -686,11 +685,11 @@
                 // before the producer accesses it.
                 EGLint result = eglClientWaitSyncKHR(dpy, fence, 0, 1000000000);
                 if (result == EGL_FALSE) {
-                    ST_LOGE("syncForReleaseLocked: error waiting for previous "
+                    GLC_LOGE("syncForReleaseLocked: error waiting for previous "
                             "fence: %#x", eglGetError());
                     return UNKNOWN_ERROR;
                 } else if (result == EGL_TIMEOUT_EXPIRED_KHR) {
-                    ST_LOGE("syncForReleaseLocked: timeout waiting for previous "
+                    GLC_LOGE("syncForReleaseLocked: timeout waiting for previous "
                             "fence");
                     return TIMED_OUT;
                 }
@@ -701,7 +700,7 @@
             // OpenGL ES context.
             fence = eglCreateSyncKHR(dpy, EGL_SYNC_FENCE_KHR, NULL);
             if (fence == EGL_NO_SYNC_KHR) {
-                ST_LOGE("syncForReleaseLocked: error creating fence: %#x",
+                GLC_LOGE("syncForReleaseLocked: error creating fence: %#x",
                         eglGetError());
                 return UNKNOWN_ERROR;
             }
@@ -713,7 +712,7 @@
     return OK;
 }
 
-bool GLConsumer::isExternalFormat(uint32_t format)
+bool GLConsumer::isExternalFormat(PixelFormat format)
 {
     switch (format) {
     // supported YUV formats
@@ -744,23 +743,23 @@
 void GLConsumer::setFilteringEnabled(bool enabled) {
     Mutex::Autolock lock(mMutex);
     if (mAbandoned) {
-        ST_LOGE("setFilteringEnabled: GLConsumer is abandoned!");
+        GLC_LOGE("setFilteringEnabled: GLConsumer is abandoned!");
         return;
     }
     bool needsRecompute = mFilteringEnabled != enabled;
     mFilteringEnabled = enabled;
 
-    if (needsRecompute && mCurrentTextureBuf==NULL) {
-        ST_LOGD("setFilteringEnabled called with mCurrentTextureBuf == NULL");
+    if (needsRecompute && mCurrentTextureImage==NULL) {
+        GLC_LOGD("setFilteringEnabled called with mCurrentTextureImage == NULL");
     }
 
-    if (needsRecompute && mCurrentTextureBuf != NULL) {
+    if (needsRecompute && mCurrentTextureImage != NULL) {
         computeCurrentTransformMatrixLocked();
     }
 }
 
 void GLConsumer::computeCurrentTransformMatrixLocked() {
-    ST_LOGV("computeCurrentTransformMatrixLocked");
+    GLC_LOGV("computeCurrentTransformMatrixLocked");
 
     float xform[16];
     for (int i = 0; i < 16; i++) {
@@ -788,10 +787,11 @@
         }
     }
 
-    sp<GraphicBuffer>& buf(mCurrentTextureBuf);
+    sp<GraphicBuffer> buf = (mCurrentTextureImage == NULL) ?
+            NULL : mCurrentTextureImage->graphicBuffer();
 
     if (buf == NULL) {
-        ST_LOGD("computeCurrentTransformMatrixLocked: mCurrentTextureBuf is NULL");
+        GLC_LOGD("computeCurrentTransformMatrixLocked: mCurrentTextureImage is NULL");
     }
 
     float mtxBeforeFlipV[16];
@@ -863,50 +863,21 @@
 }
 
 nsecs_t GLConsumer::getTimestamp() {
-    ST_LOGV("getTimestamp");
+    GLC_LOGV("getTimestamp");
     Mutex::Autolock lock(mMutex);
     return mCurrentTimestamp;
 }
 
-nsecs_t GLConsumer::getFrameNumber() {
-    ST_LOGV("getFrameNumber");
+uint64_t GLConsumer::getFrameNumber() {
+    GLC_LOGV("getFrameNumber");
     Mutex::Autolock lock(mMutex);
     return mCurrentFrameNumber;
 }
 
-EGLImageKHR GLConsumer::createImage(EGLDisplay dpy,
-        const sp<GraphicBuffer>& graphicBuffer, const Rect& crop) {
-    EGLClientBuffer cbuf = (EGLClientBuffer)graphicBuffer->getNativeBuffer();
-    EGLint attrs[] = {
-        EGL_IMAGE_PRESERVED_KHR,        EGL_TRUE,
-        EGL_IMAGE_CROP_LEFT_ANDROID,    crop.left,
-        EGL_IMAGE_CROP_TOP_ANDROID,     crop.top,
-        EGL_IMAGE_CROP_RIGHT_ANDROID,   crop.right,
-        EGL_IMAGE_CROP_BOTTOM_ANDROID,  crop.bottom,
-        EGL_NONE,
-    };
-    if (!crop.isValid()) {
-        // No crop rect to set, so terminate the attrib array before the crop.
-        attrs[2] = EGL_NONE;
-    } else if (!isEglImageCroppable(crop)) {
-        // The crop rect is not at the origin, so we can't set the crop on the
-        // EGLImage because that's not allowed by the EGL_ANDROID_image_crop
-        // extension.  In the future we can add a layered extension that
-        // removes this restriction if there is hardware that can support it.
-        attrs[2] = EGL_NONE;
-    }
-    EGLImageKHR image = eglCreateImageKHR(dpy, EGL_NO_CONTEXT,
-            EGL_NATIVE_BUFFER_ANDROID, cbuf, attrs);
-    if (image == EGL_NO_IMAGE_KHR) {
-        EGLint error = eglGetError();
-        ST_LOGE("error creating EGLImage: %#x", error);
-    }
-    return image;
-}
-
 sp<GraphicBuffer> GLConsumer::getCurrentBuffer() const {
     Mutex::Autolock lock(mMutex);
-    return mCurrentTextureBuf;
+    return (mCurrentTextureImage == NULL) ?
+            NULL : mCurrentTextureImage->graphicBuffer();
 }
 
 Rect GLConsumer::getCurrentCrop() const {
@@ -914,30 +885,37 @@
 
     Rect outCrop = mCurrentCrop;
     if (mCurrentScalingMode == NATIVE_WINDOW_SCALING_MODE_SCALE_CROP) {
-        int32_t newWidth = mCurrentCrop.width();
-        int32_t newHeight = mCurrentCrop.height();
+        uint32_t newWidth = static_cast<uint32_t>(mCurrentCrop.width());
+        uint32_t newHeight = static_cast<uint32_t>(mCurrentCrop.height());
 
         if (newWidth * mDefaultHeight > newHeight * mDefaultWidth) {
             newWidth = newHeight * mDefaultWidth / mDefaultHeight;
-            ST_LOGV("too wide: newWidth = %d", newWidth);
+            GLC_LOGV("too wide: newWidth = %d", newWidth);
         } else if (newWidth * mDefaultHeight < newHeight * mDefaultWidth) {
             newHeight = newWidth * mDefaultHeight / mDefaultWidth;
-            ST_LOGV("too tall: newHeight = %d", newHeight);
+            GLC_LOGV("too tall: newHeight = %d", newHeight);
         }
 
+        uint32_t currentWidth = static_cast<uint32_t>(mCurrentCrop.width());
+        uint32_t currentHeight = static_cast<uint32_t>(mCurrentCrop.height());
+
         // The crop is too wide
-        if (newWidth < mCurrentCrop.width()) {
-            int32_t dw = (newWidth - mCurrentCrop.width())/2;
-            outCrop.left -=dw;
-            outCrop.right += dw;
+        if (newWidth < currentWidth) {
+            uint32_t dw = currentWidth - newWidth;
+            auto halfdw = dw / 2;
+            outCrop.left += halfdw;
+            // Not halfdw because it would subtract 1 too few when dw is odd
+            outCrop.right -= (dw - halfdw);
         // The crop is too tall
-        } else if (newHeight < mCurrentCrop.height()) {
-            int32_t dh = (newHeight - mCurrentCrop.height())/2;
-            outCrop.top -= dh;
-            outCrop.bottom += dh;
+        } else if (newHeight < currentHeight) {
+            uint32_t dh = currentHeight - newHeight;
+            auto halfdh = dh / 2;
+            outCrop.top += halfdh;
+            // Not halfdh because it would subtract 1 too few when dh is odd
+            outCrop.bottom -= (dh - halfdh);
         }
 
-        ST_LOGV("getCurrentCrop final crop [%d,%d,%d,%d]",
+        GLC_LOGV("getCurrentCrop final crop [%d,%d,%d,%d]",
             outCrop.left, outCrop.top,
             outCrop.right,outCrop.bottom);
     }
@@ -971,12 +949,12 @@
     EGLContext ctx = eglGetCurrentContext();
 
     if (mEglDisplay != dpy || mEglDisplay == EGL_NO_DISPLAY) {
-        ST_LOGE("doGLFenceWait: invalid current EGLDisplay");
+        GLC_LOGE("doGLFenceWait: invalid current EGLDisplay");
         return INVALID_OPERATION;
     }
 
     if (mEglContext != ctx || mEglContext == EGL_NO_CONTEXT) {
-        ST_LOGE("doGLFenceWait: invalid current EGLContext");
+        GLC_LOGE("doGLFenceWait: invalid current EGLContext");
         return INVALID_OPERATION;
     }
 
@@ -985,7 +963,7 @@
             // Create an EGLSyncKHR from the current fence.
             int fenceFd = mCurrentFence->dup();
             if (fenceFd == -1) {
-                ST_LOGE("doGLFenceWait: error dup'ing fence fd: %d", errno);
+                GLC_LOGE("doGLFenceWait: error dup'ing fence fd: %d", errno);
                 return -errno;
             }
             EGLint attribs[] = {
@@ -996,7 +974,7 @@
                     EGL_SYNC_NATIVE_FENCE_ANDROID, attribs);
             if (sync == EGL_NO_SYNC_KHR) {
                 close(fenceFd);
-                ST_LOGE("doGLFenceWait: error creating EGL fence: %#x",
+                GLC_LOGE("doGLFenceWait: error creating EGL fence: %#x",
                         eglGetError());
                 return UNKNOWN_ERROR;
             }
@@ -1008,7 +986,7 @@
             EGLint eglErr = eglGetError();
             eglDestroySyncKHR(dpy, sync);
             if (eglErr != EGL_SUCCESS) {
-                ST_LOGE("doGLFenceWait: error waiting for EGL fence: %#x",
+                GLC_LOGE("doGLFenceWait: error waiting for EGL fence: %#x",
                         eglErr);
                 return UNKNOWN_ERROR;
             }
@@ -1016,7 +994,7 @@
             status_t err = mCurrentFence->waitForever(
                     "GLConsumer::doGLFenceWaitLocked");
             if (err != NO_ERROR) {
-                ST_LOGE("doGLFenceWait: error waiting for fence: %d", err);
+                GLC_LOGE("doGLFenceWait: error waiting for fence: %d", err);
                 return err;
             }
         }
@@ -1026,22 +1004,17 @@
 }
 
 void GLConsumer::freeBufferLocked(int slotIndex) {
-    ST_LOGV("freeBufferLocked: slotIndex=%d", slotIndex);
+    GLC_LOGV("freeBufferLocked: slotIndex=%d", slotIndex);
     if (slotIndex == mCurrentTexture) {
         mCurrentTexture = BufferQueue::INVALID_BUFFER_SLOT;
     }
-    EGLImageKHR img = mEglSlots[slotIndex].mEglImage;
-    if (img != EGL_NO_IMAGE_KHR) {
-        ST_LOGV("destroying EGLImage dpy=%p img=%p", mEglDisplay, img);
-        eglDestroyImageKHR(mEglDisplay, img);
-    }
-    mEglSlots[slotIndex].mEglImage = EGL_NO_IMAGE_KHR;
+    mEglSlots[slotIndex].mEglImage.clear();
     ConsumerBase::freeBufferLocked(slotIndex);
 }
 
 void GLConsumer::abandonLocked() {
-    ST_LOGV("abandonLocked");
-    mCurrentTextureBuf.clear();
+    GLC_LOGV("abandonLocked");
+    mCurrentTextureImage.clear();
     ConsumerBase::abandonLocked();
 }
 
@@ -1051,11 +1024,17 @@
     mConsumer->setConsumerName(name);
 }
 
-status_t GLConsumer::setDefaultBufferFormat(uint32_t defaultFormat) {
+status_t GLConsumer::setDefaultBufferFormat(PixelFormat defaultFormat) {
     Mutex::Autolock lock(mMutex);
     return mConsumer->setDefaultBufferFormat(defaultFormat);
 }
 
+status_t GLConsumer::setDefaultBufferDataSpace(
+        android_dataspace defaultDataSpace) {
+    Mutex::Autolock lock(mMutex);
+    return mConsumer->setDefaultBufferDataSpace(defaultDataSpace);
+}
+
 status_t GLConsumer::setConsumerUsageBits(uint32_t usage) {
     Mutex::Autolock lock(mMutex);
     usage |= DEFAULT_USAGE_FLAGS;
@@ -1101,4 +1080,94 @@
     out[15] = a[3]*b[12] + a[7]*b[13] + a[11]*b[14] + a[15]*b[15];
 }
 
+GLConsumer::EglImage::EglImage(sp<GraphicBuffer> graphicBuffer) :
+    mGraphicBuffer(graphicBuffer),
+    mEglImage(EGL_NO_IMAGE_KHR),
+    mEglDisplay(EGL_NO_DISPLAY) {
+}
+
+GLConsumer::EglImage::~EglImage() {
+    if (mEglImage != EGL_NO_IMAGE_KHR) {
+        if (!eglDestroyImageKHR(mEglDisplay, mEglImage)) {
+           ALOGE("~EglImage: eglDestroyImageKHR failed");
+        }
+        eglTerminate(mEglDisplay);
+    }
+}
+
+status_t GLConsumer::EglImage::createIfNeeded(EGLDisplay eglDisplay,
+                                              const Rect& cropRect,
+                                              bool forceCreation) {
+    // If there's an image and it's no longer valid, destroy it.
+    bool haveImage = mEglImage != EGL_NO_IMAGE_KHR;
+    bool displayInvalid = mEglDisplay != eglDisplay;
+    bool cropInvalid = hasEglAndroidImageCrop() && mCropRect != cropRect;
+    if (haveImage && (displayInvalid || cropInvalid || forceCreation)) {
+        if (!eglDestroyImageKHR(mEglDisplay, mEglImage)) {
+           ALOGE("createIfNeeded: eglDestroyImageKHR failed");
+        }
+        eglTerminate(mEglDisplay);
+        mEglImage = EGL_NO_IMAGE_KHR;
+        mEglDisplay = EGL_NO_DISPLAY;
+    }
+
+    // If there's no image, create one.
+    if (mEglImage == EGL_NO_IMAGE_KHR) {
+        mEglDisplay = eglDisplay;
+        mCropRect = cropRect;
+        mEglImage = createImage(mEglDisplay, mGraphicBuffer, mCropRect);
+    }
+
+    // Fail if we can't create a valid image.
+    if (mEglImage == EGL_NO_IMAGE_KHR) {
+        mEglDisplay = EGL_NO_DISPLAY;
+        mCropRect.makeInvalid();
+        const sp<GraphicBuffer>& buffer = mGraphicBuffer;
+        ALOGE("Failed to create image. size=%ux%u st=%u usage=0x%x fmt=%d",
+            buffer->getWidth(), buffer->getHeight(), buffer->getStride(),
+            buffer->getUsage(), buffer->getPixelFormat());
+        return UNKNOWN_ERROR;
+    }
+
+    return OK;
+}
+
+void GLConsumer::EglImage::bindToTextureTarget(uint32_t texTarget) {
+    glEGLImageTargetTexture2DOES(texTarget,
+            static_cast<GLeglImageOES>(mEglImage));
+}
+
+EGLImageKHR GLConsumer::EglImage::createImage(EGLDisplay dpy,
+        const sp<GraphicBuffer>& graphicBuffer, const Rect& crop) {
+    EGLClientBuffer cbuf =
+            static_cast<EGLClientBuffer>(graphicBuffer->getNativeBuffer());
+    EGLint attrs[] = {
+        EGL_IMAGE_PRESERVED_KHR,        EGL_TRUE,
+        EGL_IMAGE_CROP_LEFT_ANDROID,    crop.left,
+        EGL_IMAGE_CROP_TOP_ANDROID,     crop.top,
+        EGL_IMAGE_CROP_RIGHT_ANDROID,   crop.right,
+        EGL_IMAGE_CROP_BOTTOM_ANDROID,  crop.bottom,
+        EGL_NONE,
+    };
+    if (!crop.isValid()) {
+        // No crop rect to set, so terminate the attrib array before the crop.
+        attrs[2] = EGL_NONE;
+    } else if (!isEglImageCroppable(crop)) {
+        // The crop rect is not at the origin, so we can't set the crop on the
+        // EGLImage because that's not allowed by the EGL_ANDROID_image_crop
+        // extension.  In the future we can add a layered extension that
+        // removes this restriction if there is hardware that can support it.
+        attrs[2] = EGL_NONE;
+    }
+    eglInitialize(dpy, 0, 0);
+    EGLImageKHR image = eglCreateImageKHR(dpy, EGL_NO_CONTEXT,
+            EGL_NATIVE_BUFFER_ANDROID, cbuf, attrs);
+    if (image == EGL_NO_IMAGE_KHR) {
+        EGLint error = eglGetError();
+        ALOGE("error creating EGLImage: %#x", error);
+        eglTerminate(dpy);
+    }
+    return image;
+}
+
 }; // namespace android
diff --git a/libs/gui/GraphicBufferAlloc.cpp b/libs/gui/GraphicBufferAlloc.cpp
index b360e81..9643402 100644
--- a/libs/gui/GraphicBufferAlloc.cpp
+++ b/libs/gui/GraphicBufferAlloc.cpp
@@ -31,9 +31,10 @@
 GraphicBufferAlloc::~GraphicBufferAlloc() {
 }
 
-sp<GraphicBuffer> GraphicBufferAlloc::createGraphicBuffer(uint32_t w, uint32_t h,
-        PixelFormat format, uint32_t usage, status_t* error) {
-    sp<GraphicBuffer> graphicBuffer(new GraphicBuffer(w, h, format, usage));
+sp<GraphicBuffer> GraphicBufferAlloc::createGraphicBuffer(uint32_t width,
+        uint32_t height, PixelFormat format, uint32_t usage, status_t* error) {
+    sp<GraphicBuffer> graphicBuffer(
+            new GraphicBuffer(width, height, format, usage));
     status_t err = graphicBuffer->initCheck();
     *error = err;
     if (err != 0 || graphicBuffer->handle == 0) {
@@ -42,7 +43,7 @@
         }
         ALOGE("GraphicBufferAlloc::createGraphicBuffer(w=%d, h=%d) "
              "failed (%s), handle=%p",
-                w, h, strerror(-err), graphicBuffer->handle);
+                width, height, strerror(-err), graphicBuffer->handle);
         return 0;
     }
     return graphicBuffer;
diff --git a/libs/gui/IConsumerListener.cpp b/libs/gui/IConsumerListener.cpp
index 5304462..9a0b7a4 100644
--- a/libs/gui/IConsumerListener.cpp
+++ b/libs/gui/IConsumerListener.cpp
@@ -21,6 +21,7 @@
 #include <binder/Parcel.h>
 
 #include <gui/IConsumerListener.h>
+#include <gui/BufferItem.h>
 
 // ---------------------------------------------------------------------------
 namespace android {
@@ -28,19 +29,23 @@
 
 enum {
     ON_FRAME_AVAILABLE = IBinder::FIRST_CALL_TRANSACTION,
-    ON_BUFFER_RELEASED
+    ON_BUFFER_RELEASED,
+    ON_SIDEBAND_STREAM_CHANGED,
 };
 
 class BpConsumerListener : public BpInterface<IConsumerListener>
 {
 public:
-    BpConsumerListener(const sp<IBinder>& impl)
+    explicit BpConsumerListener(const sp<IBinder>& impl)
         : BpInterface<IConsumerListener>(impl) {
     }
 
-    virtual void onFrameAvailable() {
+    virtual ~BpConsumerListener();
+
+    virtual void onFrameAvailable(const BufferItem& item) {
         Parcel data, reply;
         data.writeInterfaceToken(IConsumerListener::getInterfaceDescriptor());
+        data.write(item);
         remote()->transact(ON_FRAME_AVAILABLE, data, &reply, IBinder::FLAG_ONEWAY);
     }
 
@@ -49,8 +54,18 @@
         data.writeInterfaceToken(IConsumerListener::getInterfaceDescriptor());
         remote()->transact(ON_BUFFER_RELEASED, data, &reply, IBinder::FLAG_ONEWAY);
     }
+
+    virtual void onSidebandStreamChanged() {
+        Parcel data, reply;
+        data.writeInterfaceToken(IConsumerListener::getInterfaceDescriptor());
+        remote()->transact(ON_SIDEBAND_STREAM_CHANGED, data, &reply, IBinder::FLAG_ONEWAY);
+    }
 };
 
+// Out-of-line virtual method definition to trigger vtable emission in this
+// translation unit (see clang warning -Wweak-vtables)
+BpConsumerListener::~BpConsumerListener() {}
+
 IMPLEMENT_META_INTERFACE(ConsumerListener, "android.gui.IConsumerListener");
 
 // ----------------------------------------------------------------------
@@ -59,14 +74,20 @@
     uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
 {
     switch(code) {
-        case ON_FRAME_AVAILABLE:
+        case ON_FRAME_AVAILABLE: {
             CHECK_INTERFACE(IConsumerListener, data, reply);
-            onFrameAvailable();
-            return NO_ERROR;
-        case ON_BUFFER_RELEASED:
+            BufferItem item;
+            data.read(item);
+            onFrameAvailable(item);
+            return NO_ERROR; }
+        case ON_BUFFER_RELEASED: {
             CHECK_INTERFACE(IConsumerListener, data, reply);
             onBuffersReleased();
-            return NO_ERROR;
+            return NO_ERROR; }
+        case ON_SIDEBAND_STREAM_CHANGED: {
+            CHECK_INTERFACE(IConsumerListener, data, reply);
+            onSidebandStreamChanged();
+            return NO_ERROR; }
     }
     return BBinder::onTransact(code, data, reply, flags);
 }
diff --git a/libs/gui/IDisplayEventConnection.cpp b/libs/gui/IDisplayEventConnection.cpp
index 887d176..b1d3b00 100644
--- a/libs/gui/IDisplayEventConnection.cpp
+++ b/libs/gui/IDisplayEventConnection.cpp
@@ -39,11 +39,13 @@
 class BpDisplayEventConnection : public BpInterface<IDisplayEventConnection>
 {
 public:
-    BpDisplayEventConnection(const sp<IBinder>& impl)
+    explicit BpDisplayEventConnection(const sp<IBinder>& impl)
         : BpInterface<IDisplayEventConnection>(impl)
     {
     }
 
+    virtual ~BpDisplayEventConnection();
+
     virtual sp<BitTube> getDataChannel() const
     {
         Parcel data, reply;
@@ -55,7 +57,7 @@
     virtual void setVsyncRate(uint32_t count) {
         Parcel data, reply;
         data.writeInterfaceToken(IDisplayEventConnection::getInterfaceDescriptor());
-        data.writeInt32(count);
+        data.writeUint32(count);
         remote()->transact(SET_VSYNC_RATE, data, &reply);
     }
 
@@ -66,6 +68,10 @@
     }
 };
 
+// Out-of-line virtual method definition to trigger vtable emission in this
+// translation unit (see clang warning -Wweak-vtables)
+BpDisplayEventConnection::~BpDisplayEventConnection() {}
+
 IMPLEMENT_META_INTERFACE(DisplayEventConnection, "android.gui.DisplayEventConnection");
 
 // ----------------------------------------------------------------------------
@@ -79,17 +85,17 @@
             sp<BitTube> channel(getDataChannel());
             channel->writeToParcel(reply);
             return NO_ERROR;
-        } break;
+        }
         case SET_VSYNC_RATE: {
             CHECK_INTERFACE(IDisplayEventConnection, data, reply);
-            setVsyncRate(data.readInt32());
+            setVsyncRate(data.readUint32());
             return NO_ERROR;
-        } break;
+        }
         case REQUEST_NEXT_VSYNC: {
             CHECK_INTERFACE(IDisplayEventConnection, data, reply);
             requestNextVsync();
             return NO_ERROR;
-        } break;
+        }
     }
     return BBinder::onTransact(code, data, reply, flags);
 }
diff --git a/libs/gui/IGraphicBufferAlloc.cpp b/libs/gui/IGraphicBufferAlloc.cpp
index 139f219..d4d4702 100644
--- a/libs/gui/IGraphicBufferAlloc.cpp
+++ b/libs/gui/IGraphicBufferAlloc.cpp
@@ -37,25 +37,31 @@
 class BpGraphicBufferAlloc : public BpInterface<IGraphicBufferAlloc>
 {
 public:
-    BpGraphicBufferAlloc(const sp<IBinder>& impl)
+    explicit BpGraphicBufferAlloc(const sp<IBinder>& impl)
         : BpInterface<IGraphicBufferAlloc>(impl)
     {
     }
 
-    virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
-            PixelFormat format, uint32_t usage, status_t* error) {
+    virtual ~BpGraphicBufferAlloc();
+
+    virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width,
+            uint32_t height, PixelFormat format, uint32_t usage,
+            status_t* error) {
         Parcel data, reply;
         data.writeInterfaceToken(IGraphicBufferAlloc::getInterfaceDescriptor());
-        data.writeInt32(w);
-        data.writeInt32(h);
-        data.writeInt32(format);
-        data.writeInt32(usage);
+        data.writeUint32(width);
+        data.writeUint32(height);
+        data.writeInt32(static_cast<int32_t>(format));
+        data.writeUint32(usage);
         remote()->transact(CREATE_GRAPHIC_BUFFER, data, &reply);
         sp<GraphicBuffer> graphicBuffer;
         status_t result = reply.readInt32();
         if (result == NO_ERROR) {
             graphicBuffer = new GraphicBuffer();
             result = reply.read(*graphicBuffer);
+            if (result != NO_ERROR) {
+                graphicBuffer.clear();
+            }
             // reply.readStrongBinder();
             // here we don't even have to read the BufferReference from
             // the parcel, it'll die with the parcel.
@@ -65,6 +71,10 @@
     }
 };
 
+// Out-of-line virtual method definition to trigger vtable emission in this
+// translation unit (see clang warning -Wweak-vtables)
+BpGraphicBufferAlloc::~BpGraphicBufferAlloc() {}
+
 IMPLEMENT_META_INTERFACE(GraphicBufferAlloc, "android.ui.IGraphicBufferAlloc");
 
 // ----------------------------------------------------------------------
@@ -74,27 +84,26 @@
 {
     // codes that don't require permission check
 
-    /* BufferReference just keeps a strong reference to a
-     * GraphicBuffer until it is destroyed (that is, until
-     * no local or remote process have a reference to it).
-     */
+    // BufferReference just keeps a strong reference to a GraphicBuffer until it
+    // is destroyed (that is, until no local or remote process have a reference
+    // to it).
     class BufferReference : public BBinder {
-        sp<GraphicBuffer> buffer;
+        sp<GraphicBuffer> mBuffer;
     public:
-        BufferReference(const sp<GraphicBuffer>& buffer) : buffer(buffer) { }
+        explicit BufferReference(const sp<GraphicBuffer>& buffer) : mBuffer(buffer) {}
     };
 
 
-    switch(code) {
+    switch (code) {
         case CREATE_GRAPHIC_BUFFER: {
             CHECK_INTERFACE(IGraphicBufferAlloc, data, reply);
-            uint32_t w = data.readInt32();
-            uint32_t h = data.readInt32();
-            PixelFormat format = data.readInt32();
-            uint32_t usage = data.readInt32();
+            uint32_t width = data.readUint32();
+            uint32_t height = data.readUint32();
+            PixelFormat format = static_cast<PixelFormat>(data.readInt32());
+            uint32_t usage = data.readUint32();
             status_t error;
             sp<GraphicBuffer> result =
-                    createGraphicBuffer(w, h, format, usage, &error);
+                    createGraphicBuffer(width, height, format, usage, &error);
             reply->writeInt32(error);
             if (result != 0) {
                 reply->write(*result);
@@ -107,7 +116,7 @@
                 reply->writeStrongBinder( new BufferReference(result) );
             }
             return NO_ERROR;
-        } break;
+        }
         default:
             return BBinder::onTransact(code, data, reply, flags);
     }
diff --git a/libs/gui/IGraphicBufferConsumer.cpp b/libs/gui/IGraphicBufferConsumer.cpp
index 9574b61..334611d 100644
--- a/libs/gui/IGraphicBufferConsumer.cpp
+++ b/libs/gui/IGraphicBufferConsumer.cpp
@@ -14,20 +14,16 @@
  * limitations under the License.
  */
 
-#define EGL_EGLEXT_PROTOTYPES
-
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-
-
 #include <stdint.h>
 #include <sys/types.h>
 
 #include <utils/Errors.h>
+#include <utils/NativeHandle.h>
 
 #include <binder/Parcel.h>
 #include <binder/IInterface.h>
 
+#include <gui/BufferItem.h>
 #include <gui/IConsumerListener.h>
 #include <gui/IGraphicBufferConsumer.h>
 
@@ -37,152 +33,11 @@
 #include <system/window.h>
 
 namespace android {
-// ---------------------------------------------------------------------------
-
-IGraphicBufferConsumer::BufferItem::BufferItem() :
-    mTransform(0),
-    mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
-    mTimestamp(0),
-    mIsAutoTimestamp(false),
-    mFrameNumber(0),
-    mBuf(INVALID_BUFFER_SLOT),
-    mIsDroppable(false),
-    mAcquireCalled(false),
-    mTransformToDisplayInverse(false) {
-    mCrop.makeInvalid();
-}
-
-size_t IGraphicBufferConsumer::BufferItem::getPodSize() const {
-    size_t c =  sizeof(mCrop) +
-            sizeof(mTransform) +
-            sizeof(mScalingMode) +
-            sizeof(mTimestamp) +
-            sizeof(mIsAutoTimestamp) +
-            sizeof(mFrameNumber) +
-            sizeof(mBuf) +
-            sizeof(mIsDroppable) +
-            sizeof(mAcquireCalled) +
-            sizeof(mTransformToDisplayInverse);
-    return c;
-}
-
-size_t IGraphicBufferConsumer::BufferItem::getFlattenedSize() const {
-    size_t c = 0;
-    if (mGraphicBuffer != 0) {
-        c += mGraphicBuffer->getFlattenedSize();
-        FlattenableUtils::align<4>(c);
-    }
-    if (mFence != 0) {
-        c += mFence->getFlattenedSize();
-        FlattenableUtils::align<4>(c);
-    }
-    return sizeof(int32_t) + c + getPodSize();
-}
-
-size_t IGraphicBufferConsumer::BufferItem::getFdCount() const {
-    size_t c = 0;
-    if (mGraphicBuffer != 0) {
-        c += mGraphicBuffer->getFdCount();
-    }
-    if (mFence != 0) {
-        c += mFence->getFdCount();
-    }
-    return c;
-}
-
-status_t IGraphicBufferConsumer::BufferItem::flatten(
-        void*& buffer, size_t& size, int*& fds, size_t& count) const {
-
-    // make sure we have enough space
-    if (count < BufferItem::getFlattenedSize()) {
-        return NO_MEMORY;
-    }
-
-    // content flags are stored first
-    uint32_t& flags = *static_cast<uint32_t*>(buffer);
-
-    // advance the pointer
-    FlattenableUtils::advance(buffer, size, sizeof(uint32_t));
-
-    flags = 0;
-    if (mGraphicBuffer != 0) {
-        status_t err = mGraphicBuffer->flatten(buffer, size, fds, count);
-        if (err) return err;
-        size -= FlattenableUtils::align<4>(buffer);
-        flags |= 1;
-    }
-    if (mFence != 0) {
-        status_t err = mFence->flatten(buffer, size, fds, count);
-        if (err) return err;
-        size -= FlattenableUtils::align<4>(buffer);
-        flags |= 2;
-    }
-
-    // check we have enough space (in case flattening the fence/graphicbuffer lied to us)
-    if (size < getPodSize()) {
-        return NO_MEMORY;
-    }
-
-    FlattenableUtils::write(buffer, size, mCrop);
-    FlattenableUtils::write(buffer, size, mTransform);
-    FlattenableUtils::write(buffer, size, mScalingMode);
-    FlattenableUtils::write(buffer, size, mTimestamp);
-    FlattenableUtils::write(buffer, size, mIsAutoTimestamp);
-    FlattenableUtils::write(buffer, size, mFrameNumber);
-    FlattenableUtils::write(buffer, size, mBuf);
-    FlattenableUtils::write(buffer, size, mIsDroppable);
-    FlattenableUtils::write(buffer, size, mAcquireCalled);
-    FlattenableUtils::write(buffer, size, mTransformToDisplayInverse);
-
-    return NO_ERROR;
-}
-
-status_t IGraphicBufferConsumer::BufferItem::unflatten(
-        void const*& buffer, size_t& size, int const*& fds, size_t& count) {
-
-    if (size < sizeof(uint32_t))
-        return NO_MEMORY;
-
-    uint32_t flags = 0;
-    FlattenableUtils::read(buffer, size, flags);
-
-    if (flags & 1) {
-        mGraphicBuffer = new GraphicBuffer();
-        status_t err = mGraphicBuffer->unflatten(buffer, size, fds, count);
-        if (err) return err;
-        size -= FlattenableUtils::align<4>(buffer);
-    }
-
-    if (flags & 2) {
-        mFence = new Fence();
-        status_t err = mFence->unflatten(buffer, size, fds, count);
-        if (err) return err;
-        size -= FlattenableUtils::align<4>(buffer);
-    }
-
-    // check we have enough space
-    if (size < getPodSize()) {
-        return NO_MEMORY;
-    }
-
-    FlattenableUtils::read(buffer, size, mCrop);
-    FlattenableUtils::read(buffer, size, mTransform);
-    FlattenableUtils::read(buffer, size, mScalingMode);
-    FlattenableUtils::read(buffer, size, mTimestamp);
-    FlattenableUtils::read(buffer, size, mIsAutoTimestamp);
-    FlattenableUtils::read(buffer, size, mFrameNumber);
-    FlattenableUtils::read(buffer, size, mBuf);
-    FlattenableUtils::read(buffer, size, mIsDroppable);
-    FlattenableUtils::read(buffer, size, mAcquireCalled);
-    FlattenableUtils::read(buffer, size, mTransformToDisplayInverse);
-
-    return NO_ERROR;
-}
-
-// ---------------------------------------------------------------------------
 
 enum {
     ACQUIRE_BUFFER = IBinder::FIRST_CALL_TRANSACTION,
+    DETACH_BUFFER,
+    ATTACH_BUFFER,
     RELEASE_BUFFER,
     CONSUMER_CONNECT,
     CONSUMER_DISCONNECT,
@@ -193,8 +48,10 @@
     SET_MAX_ACQUIRED_BUFFER_COUNT,
     SET_CONSUMER_NAME,
     SET_DEFAULT_BUFFER_FORMAT,
+    SET_DEFAULT_BUFFER_DATA_SPACE,
     SET_CONSUMER_USAGE_BITS,
     SET_TRANSFORM_HINT,
+    GET_SIDEBAND_STREAM,
     DUMP,
 };
 
@@ -202,15 +59,19 @@
 class BpGraphicBufferConsumer : public BpInterface<IGraphicBufferConsumer>
 {
 public:
-    BpGraphicBufferConsumer(const sp<IBinder>& impl)
+    explicit BpGraphicBufferConsumer(const sp<IBinder>& impl)
         : BpInterface<IGraphicBufferConsumer>(impl)
     {
     }
 
-    virtual status_t acquireBuffer(BufferItem *buffer, nsecs_t presentWhen) {
+    virtual ~BpGraphicBufferConsumer();
+
+    virtual status_t acquireBuffer(BufferItem *buffer, nsecs_t presentWhen,
+            uint64_t maxFrameNumber) {
         Parcel data, reply;
         data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
         data.writeInt64(presentWhen);
+        data.writeUint64(maxFrameNumber);
         status_t result = remote()->transact(ACQUIRE_BUFFER, data, &reply);
         if (result != NO_ERROR) {
             return result;
@@ -222,13 +83,38 @@
         return reply.readInt32();
     }
 
+    virtual status_t detachBuffer(int slot) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
+        data.writeInt32(slot);
+        status_t result = remote()->transact(DETACH_BUFFER, data, &reply);
+        if (result != NO_ERROR) {
+            return result;
+        }
+        result = reply.readInt32();
+        return result;
+    }
+
+    virtual status_t attachBuffer(int* slot, const sp<GraphicBuffer>& buffer) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
+        data.write(*buffer.get());
+        status_t result = remote()->transact(ATTACH_BUFFER, data, &reply);
+        if (result != NO_ERROR) {
+            return result;
+        }
+        *slot = reply.readInt32();
+        result = reply.readInt32();
+        return result;
+    }
+
     virtual status_t releaseBuffer(int buf, uint64_t frameNumber,
-            EGLDisplay display, EGLSyncKHR fence,
+            EGLDisplay display __attribute__((unused)), EGLSyncKHR fence __attribute__((unused)),
             const sp<Fence>& releaseFence) {
         Parcel data, reply;
         data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
         data.writeInt32(buf);
-        data.writeInt64(frameNumber);
+        data.writeInt64(static_cast<int64_t>(frameNumber));
         data.write(*releaseFence);
         status_t result = remote()->transact(RELEASE_BUFFER, data, &reply);
         if (result != NO_ERROR) {
@@ -240,7 +126,7 @@
     virtual status_t consumerConnect(const sp<IConsumerListener>& consumer, bool controlledByApp) {
         Parcel data, reply;
         data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
-        data.writeStrongBinder(consumer->asBinder());
+        data.writeStrongBinder(IInterface::asBinder(consumer));
         data.writeInt32(controlledByApp);
         status_t result = remote()->transact(CONSUMER_CONNECT, data, &reply);
         if (result != NO_ERROR) {
@@ -259,22 +145,26 @@
         return reply.readInt32();
     }
 
-    virtual status_t getReleasedBuffers(uint32_t* slotMask) {
+    virtual status_t getReleasedBuffers(uint64_t* slotMask) {
         Parcel data, reply;
+        if (slotMask == NULL) {
+            ALOGE("getReleasedBuffers: slotMask must not be NULL");
+            return BAD_VALUE;
+        }
         data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
         status_t result = remote()->transact(GET_RELEASED_BUFFERS, data, &reply);
         if (result != NO_ERROR) {
             return result;
         }
-        *slotMask = reply.readInt32();
+        *slotMask = static_cast<uint64_t>(reply.readInt64());
         return reply.readInt32();
     }
 
-    virtual status_t setDefaultBufferSize(uint32_t w, uint32_t h) {
+    virtual status_t setDefaultBufferSize(uint32_t width, uint32_t height) {
         Parcel data, reply;
         data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
-        data.writeInt32(w);
-        data.writeInt32(h);
+        data.writeUint32(width);
+        data.writeUint32(height);
         status_t result = remote()->transact(SET_DEFAULT_BUFFER_SIZE, data, &reply);
         if (result != NO_ERROR) {
             return result;
@@ -321,10 +211,10 @@
         remote()->transact(SET_CONSUMER_NAME, data, &reply);
     }
 
-    virtual status_t setDefaultBufferFormat(uint32_t defaultFormat) {
+    virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat) {
         Parcel data, reply;
         data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
-        data.writeInt32(defaultFormat);
+        data.writeInt32(static_cast<int32_t>(defaultFormat));
         status_t result = remote()->transact(SET_DEFAULT_BUFFER_FORMAT, data, &reply);
         if (result != NO_ERROR) {
             return result;
@@ -332,10 +222,23 @@
         return reply.readInt32();
     }
 
+    virtual status_t setDefaultBufferDataSpace(
+            android_dataspace defaultDataSpace) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
+        data.writeInt32(static_cast<int32_t>(defaultDataSpace));
+        status_t result = remote()->transact(SET_DEFAULT_BUFFER_DATA_SPACE,
+                data, &reply);
+        if (result != NO_ERROR) {
+            return result;
+        }
+        return reply.readInt32();
+    }
+
     virtual status_t setConsumerUsageBits(uint32_t usage) {
         Parcel data, reply;
         data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
-        data.writeInt32(usage);
+        data.writeUint32(usage);
         status_t result = remote()->transact(SET_CONSUMER_USAGE_BITS, data, &reply);
         if (result != NO_ERROR) {
             return result;
@@ -346,7 +249,7 @@
     virtual status_t setTransformHint(uint32_t hint) {
         Parcel data, reply;
         data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
-        data.writeInt32(hint);
+        data.writeUint32(hint);
         status_t result = remote()->transact(SET_TRANSFORM_HINT, data, &reply);
         if (result != NO_ERROR) {
             return result;
@@ -354,6 +257,20 @@
         return reply.readInt32();
     }
 
+    virtual sp<NativeHandle> getSidebandStream() const {
+        Parcel data, reply;
+        status_t err;
+        data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
+        if ((err = remote()->transact(GET_SIDEBAND_STREAM, data, &reply)) != NO_ERROR) {
+            return NULL;
+        }
+        sp<NativeHandle> stream;
+        if (reply.readInt32()) {
+            stream = NativeHandle::create(reply.readNativeHandle(), true);
+        }
+        return stream;
+    }
+
     virtual void dump(String8& result, const char* prefix) const {
         Parcel data, reply;
         data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
@@ -364,6 +281,10 @@
     }
 };
 
+// Out-of-line virtual method definition to trigger vtable emission in this
+// translation unit (see clang warning -Wweak-vtables)
+BpGraphicBufferConsumer::~BpGraphicBufferConsumer() {}
+
 IMPLEMENT_META_INTERFACE(GraphicBufferConsumer, "android.gui.IGraphicBufferConsumer");
 
 // ----------------------------------------------------------------------
@@ -376,16 +297,34 @@
             CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
             BufferItem item;
             int64_t presentWhen = data.readInt64();
-            status_t result = acquireBuffer(&item, presentWhen);
+            uint64_t maxFrameNumber = data.readUint64();
+            status_t result = acquireBuffer(&item, presentWhen, maxFrameNumber);
             status_t err = reply->write(item);
             if (err) return err;
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
+        case DETACH_BUFFER: {
+            CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
+            int slot = data.readInt32();
+            int result = detachBuffer(slot);
+            reply->writeInt32(result);
+            return NO_ERROR;
+        }
+        case ATTACH_BUFFER: {
+            CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
+            sp<GraphicBuffer> buffer = new GraphicBuffer();
+            data.read(*buffer.get());
+            int slot = -1;
+            int result = attachBuffer(&slot, buffer);
+            reply->writeInt32(slot);
+            reply->writeInt32(result);
+            return NO_ERROR;
+        }
         case RELEASE_BUFFER: {
             CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
             int buf = data.readInt32();
-            uint64_t frameNumber = data.readInt64();
+            uint64_t frameNumber = static_cast<uint64_t>(data.readInt64());
             sp<Fence> releaseFence = new Fence();
             status_t err = data.read(*releaseFence);
             if (err) return err;
@@ -393,7 +332,7 @@
                     EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, releaseFence);
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
         case CONSUMER_CONNECT: {
             CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
             sp<IConsumerListener> consumer = IConsumerListener::asInterface( data.readStrongBinder() );
@@ -401,75 +340,92 @@
             status_t result = consumerConnect(consumer, controlledByApp);
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
         case CONSUMER_DISCONNECT: {
             CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
             status_t result = consumerDisconnect();
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
         case GET_RELEASED_BUFFERS: {
             CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
-            uint32_t slotMask;
+            uint64_t slotMask;
             status_t result = getReleasedBuffers(&slotMask);
-            reply->writeInt32(slotMask);
+            reply->writeInt64(static_cast<int64_t>(slotMask));
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
         case SET_DEFAULT_BUFFER_SIZE: {
             CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
-            uint32_t w = data.readInt32();
-            uint32_t h = data.readInt32();
-            status_t result = setDefaultBufferSize(w, h);
+            uint32_t width = data.readUint32();
+            uint32_t height = data.readUint32();
+            status_t result = setDefaultBufferSize(width, height);
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
         case SET_DEFAULT_MAX_BUFFER_COUNT: {
             CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
-            uint32_t bufferCount = data.readInt32();
+            int bufferCount = data.readInt32();
             status_t result = setDefaultMaxBufferCount(bufferCount);
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
         case DISABLE_ASYNC_BUFFER: {
             CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
             status_t result = disableAsyncBuffer();
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
         case SET_MAX_ACQUIRED_BUFFER_COUNT: {
             CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
-            uint32_t maxAcquiredBuffers = data.readInt32();
+            int maxAcquiredBuffers = data.readInt32();
             status_t result = setMaxAcquiredBufferCount(maxAcquiredBuffers);
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
         case SET_CONSUMER_NAME: {
             CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
             setConsumerName( data.readString8() );
             return NO_ERROR;
-        } break;
+        }
         case SET_DEFAULT_BUFFER_FORMAT: {
             CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
-            uint32_t defaultFormat = data.readInt32();
+            PixelFormat defaultFormat = static_cast<PixelFormat>(data.readInt32());
             status_t result = setDefaultBufferFormat(defaultFormat);
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
+        case SET_DEFAULT_BUFFER_DATA_SPACE: {
+            CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
+            android_dataspace defaultDataSpace =
+                    static_cast<android_dataspace>(data.readInt32());
+            status_t result = setDefaultBufferDataSpace(defaultDataSpace);
+            reply->writeInt32(result);
+            return NO_ERROR;
+        }
         case SET_CONSUMER_USAGE_BITS: {
             CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
-            uint32_t usage = data.readInt32();
+            uint32_t usage = data.readUint32();
             status_t result = setConsumerUsageBits(usage);
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
         case SET_TRANSFORM_HINT: {
             CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
-            uint32_t hint = data.readInt32();
+            uint32_t hint = data.readUint32();
             status_t result = setTransformHint(hint);
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
+        case GET_SIDEBAND_STREAM: {
+            CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
+            sp<NativeHandle> stream = getSidebandStream();
+            reply->writeInt32(static_cast<int32_t>(stream != NULL));
+            if (stream != NULL) {
+                reply->writeNativeHandle(stream->handle());
+            }
+            return NO_ERROR;
+        }
         case DUMP: {
             CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
             String8 result = data.readString8();
diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp
index 0f461e5..e91a8e1 100644
--- a/libs/gui/IGraphicBufferProducer.cpp
+++ b/libs/gui/IGraphicBufferProducer.cpp
@@ -18,14 +18,16 @@
 #include <sys/types.h>
 
 #include <utils/Errors.h>
+#include <utils/NativeHandle.h>
 #include <utils/RefBase.h>
-#include <utils/Vector.h>
 #include <utils/Timers.h>
+#include <utils/Vector.h>
 
 #include <binder/Parcel.h>
 #include <binder/IInterface.h>
 
 #include <gui/IGraphicBufferProducer.h>
+#include <gui/IProducerListener.h>
 
 namespace android {
 // ----------------------------------------------------------------------------
@@ -34,21 +36,31 @@
     REQUEST_BUFFER = IBinder::FIRST_CALL_TRANSACTION,
     SET_BUFFER_COUNT,
     DEQUEUE_BUFFER,
+    DETACH_BUFFER,
+    DETACH_NEXT_BUFFER,
+    ATTACH_BUFFER,
     QUEUE_BUFFER,
     CANCEL_BUFFER,
     QUERY,
     CONNECT,
     DISCONNECT,
+    SET_SIDEBAND_STREAM,
+    ALLOCATE_BUFFERS,
+    ALLOW_ALLOCATION,
+    SET_GENERATION_NUMBER,
+    GET_CONSUMER_NAME,
 };
 
 class BpGraphicBufferProducer : public BpInterface<IGraphicBufferProducer>
 {
 public:
-    BpGraphicBufferProducer(const sp<IBinder>& impl)
+    explicit BpGraphicBufferProducer(const sp<IBinder>& impl)
         : BpInterface<IGraphicBufferProducer>(impl)
     {
     }
 
+    virtual ~BpGraphicBufferProducer();
+
     virtual status_t requestBuffer(int bufferIdx, sp<GraphicBuffer>* buf) {
         Parcel data, reply;
         data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
@@ -84,14 +96,15 @@
     }
 
     virtual status_t dequeueBuffer(int *buf, sp<Fence>* fence, bool async,
-            uint32_t w, uint32_t h, uint32_t format, uint32_t usage) {
+            uint32_t width, uint32_t height, PixelFormat format,
+            uint32_t usage) {
         Parcel data, reply;
         data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
-        data.writeInt32(async);
-        data.writeInt32(w);
-        data.writeInt32(h);
-        data.writeInt32(format);
-        data.writeInt32(usage);
+        data.writeInt32(static_cast<int32_t>(async));
+        data.writeUint32(width);
+        data.writeUint32(height);
+        data.writeInt32(static_cast<int32_t>(format));
+        data.writeUint32(usage);
         status_t result = remote()->transact(DEQUEUE_BUFFER, data, &reply);
         if (result != NO_ERROR) {
             return result;
@@ -106,6 +119,62 @@
         return result;
     }
 
+    virtual status_t detachBuffer(int slot) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
+        data.writeInt32(slot);
+        status_t result = remote()->transact(DETACH_BUFFER, data, &reply);
+        if (result != NO_ERROR) {
+            return result;
+        }
+        result = reply.readInt32();
+        return result;
+    }
+
+    virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
+            sp<Fence>* outFence) {
+        if (outBuffer == NULL) {
+            ALOGE("detachNextBuffer: outBuffer must not be NULL");
+            return BAD_VALUE;
+        } else if (outFence == NULL) {
+            ALOGE("detachNextBuffer: outFence must not be NULL");
+            return BAD_VALUE;
+        }
+        Parcel data, reply;
+        data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
+        status_t result = remote()->transact(DETACH_NEXT_BUFFER, data, &reply);
+        if (result != NO_ERROR) {
+            return result;
+        }
+        result = reply.readInt32();
+        if (result == NO_ERROR) {
+            bool nonNull = reply.readInt32();
+            if (nonNull) {
+                *outBuffer = new GraphicBuffer;
+                reply.read(**outBuffer);
+            }
+            nonNull = reply.readInt32();
+            if (nonNull) {
+                *outFence = new Fence;
+                reply.read(**outFence);
+            }
+        }
+        return result;
+    }
+
+    virtual status_t attachBuffer(int* slot, const sp<GraphicBuffer>& buffer) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
+        data.write(*buffer.get());
+        status_t result = remote()->transact(ATTACH_BUFFER, data, &reply);
+        if (result != NO_ERROR) {
+            return result;
+        }
+        *slot = reply.readInt32();
+        result = reply.readInt32();
+        return result;
+    }
+
     virtual status_t queueBuffer(int buf,
             const QueueBufferInput& input, QueueBufferOutput* output) {
         Parcel data, reply;
@@ -142,11 +211,16 @@
         return result;
     }
 
-    virtual status_t connect(const sp<IBinder>& token,
+    virtual status_t connect(const sp<IProducerListener>& listener,
             int api, bool producerControlledByApp, QueueBufferOutput* output) {
         Parcel data, reply;
         data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
-        data.writeStrongBinder(token);
+        if (listener != NULL) {
+            data.writeInt32(1);
+            data.writeStrongBinder(IInterface::asBinder(listener));
+        } else {
+            data.writeInt32(0);
+        }
         data.writeInt32(api);
         data.writeInt32(producerControlledByApp);
         status_t result = remote()->transact(CONNECT, data, &reply);
@@ -169,8 +243,77 @@
         result = reply.readInt32();
         return result;
     }
+
+    virtual status_t setSidebandStream(const sp<NativeHandle>& stream) {
+        Parcel data, reply;
+        status_t result;
+        data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
+        if (stream.get()) {
+            data.writeInt32(true);
+            data.writeNativeHandle(stream->handle());
+        } else {
+            data.writeInt32(false);
+        }
+        if ((result = remote()->transact(SET_SIDEBAND_STREAM, data, &reply)) == NO_ERROR) {
+            result = reply.readInt32();
+        }
+        return result;
+    }
+
+    virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
+            PixelFormat format, uint32_t usage) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
+        data.writeInt32(static_cast<int32_t>(async));
+        data.writeUint32(width);
+        data.writeUint32(height);
+        data.writeInt32(static_cast<int32_t>(format));
+        data.writeUint32(usage);
+        status_t result = remote()->transact(ALLOCATE_BUFFERS, data, &reply);
+        if (result != NO_ERROR) {
+            ALOGE("allocateBuffers failed to transact: %d", result);
+        }
+    }
+
+    virtual status_t allowAllocation(bool allow) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
+        data.writeInt32(static_cast<int32_t>(allow));
+        status_t result = remote()->transact(ALLOW_ALLOCATION, data, &reply);
+        if (result != NO_ERROR) {
+            return result;
+        }
+        result = reply.readInt32();
+        return result;
+    }
+
+    virtual status_t setGenerationNumber(uint32_t generationNumber) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
+        data.writeUint32(generationNumber);
+        status_t result = remote()->transact(SET_GENERATION_NUMBER, data, &reply);
+        if (result == NO_ERROR) {
+            result = reply.readInt32();
+        }
+        return result;
+    }
+
+    virtual String8 getConsumerName() const {
+        Parcel data, reply;
+        data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
+        status_t result = remote()->transact(GET_CONSUMER_NAME, data, &reply);
+        if (result != NO_ERROR) {
+            ALOGE("getConsumerName failed to transact: %d", result);
+            return String8("TransactFailed");
+        }
+        return reply.readString8();
+    }
 };
 
+// Out-of-line virtual method definition to trigger vtable emission in this
+// translation unit (see clang warning -Wweak-vtables)
+BpGraphicBufferProducer::~BpGraphicBufferProducer() {}
+
 IMPLEMENT_META_INTERFACE(GraphicBufferProducer, "android.gui.IGraphicBufferProducer");
 
 // ----------------------------------------------------------------------
@@ -190,24 +333,25 @@
             }
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
         case SET_BUFFER_COUNT: {
             CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
             int bufferCount = data.readInt32();
             int result = setBufferCount(bufferCount);
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
         case DEQUEUE_BUFFER: {
             CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
-            bool async      = data.readInt32();
-            uint32_t w      = data.readInt32();
-            uint32_t h      = data.readInt32();
-            uint32_t format = data.readInt32();
-            uint32_t usage  = data.readInt32();
-            int buf;
+            bool async = static_cast<bool>(data.readInt32());
+            uint32_t width = data.readUint32();
+            uint32_t height = data.readUint32();
+            PixelFormat format = static_cast<PixelFormat>(data.readInt32());
+            uint32_t usage = data.readUint32();
+            int buf = 0;
             sp<Fence> fence;
-            int result = dequeueBuffer(&buf, &fence, async, w, h, format, usage);
+            int result = dequeueBuffer(&buf, &fence, async, width, height,
+                    format, usage);
             reply->writeInt32(buf);
             reply->writeInt32(fence != NULL);
             if (fence != NULL) {
@@ -215,7 +359,42 @@
             }
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
+        case DETACH_BUFFER: {
+            CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
+            int slot = data.readInt32();
+            int result = detachBuffer(slot);
+            reply->writeInt32(result);
+            return NO_ERROR;
+        }
+        case DETACH_NEXT_BUFFER: {
+            CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
+            sp<GraphicBuffer> buffer;
+            sp<Fence> fence;
+            int32_t result = detachNextBuffer(&buffer, &fence);
+            reply->writeInt32(result);
+            if (result == NO_ERROR) {
+                reply->writeInt32(buffer != NULL);
+                if (buffer != NULL) {
+                    reply->write(*buffer);
+                }
+                reply->writeInt32(fence != NULL);
+                if (fence != NULL) {
+                    reply->write(*fence);
+                }
+            }
+            return NO_ERROR;
+        }
+        case ATTACH_BUFFER: {
+            CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
+            sp<GraphicBuffer> buffer = new GraphicBuffer();
+            data.read(*buffer.get());
+            int slot = 0;
+            int result = attachBuffer(&slot, buffer);
+            reply->writeInt32(slot);
+            reply->writeInt32(result);
+            return NO_ERROR;
+        }
         case QUEUE_BUFFER: {
             CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
             int buf = data.readInt32();
@@ -223,10 +402,11 @@
             QueueBufferOutput* const output =
                     reinterpret_cast<QueueBufferOutput *>(
                             reply->writeInplace(sizeof(QueueBufferOutput)));
+            memset(output, 0, sizeof(QueueBufferOutput));
             status_t result = queueBuffer(buf, input, output);
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
         case CANCEL_BUFFER: {
             CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
             int buf = data.readInt32();
@@ -234,35 +414,77 @@
             data.read(*fence.get());
             cancelBuffer(buf, fence);
             return NO_ERROR;
-        } break;
+        }
         case QUERY: {
             CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
-            int value;
+            int value = 0;
             int what = data.readInt32();
             int res = query(what, &value);
             reply->writeInt32(value);
             reply->writeInt32(res);
             return NO_ERROR;
-        } break;
+        }
         case CONNECT: {
             CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
-            sp<IBinder> token = data.readStrongBinder();
+            sp<IProducerListener> listener;
+            if (data.readInt32() == 1) {
+                listener = IProducerListener::asInterface(data.readStrongBinder());
+            }
             int api = data.readInt32();
             bool producerControlledByApp = data.readInt32();
             QueueBufferOutput* const output =
                     reinterpret_cast<QueueBufferOutput *>(
                             reply->writeInplace(sizeof(QueueBufferOutput)));
-            status_t res = connect(token, api, producerControlledByApp, output);
+            status_t res = connect(listener, api, producerControlledByApp, output);
             reply->writeInt32(res);
             return NO_ERROR;
-        } break;
+        }
         case DISCONNECT: {
             CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
             int api = data.readInt32();
             status_t res = disconnect(api);
             reply->writeInt32(res);
             return NO_ERROR;
-        } break;
+        }
+        case SET_SIDEBAND_STREAM: {
+            CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
+            sp<NativeHandle> stream;
+            if (data.readInt32()) {
+                stream = NativeHandle::create(data.readNativeHandle(), true);
+            }
+            status_t result = setSidebandStream(stream);
+            reply->writeInt32(result);
+            return NO_ERROR;
+        }
+        case ALLOCATE_BUFFERS: {
+            CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
+            bool async = static_cast<bool>(data.readInt32());
+            uint32_t width = data.readUint32();
+            uint32_t height = data.readUint32();
+            PixelFormat format = static_cast<PixelFormat>(data.readInt32());
+            uint32_t usage = data.readUint32();
+            allocateBuffers(async, width, height, format, usage);
+            return NO_ERROR;
+        }
+        case ALLOW_ALLOCATION: {
+            CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
+            bool allow = static_cast<bool>(data.readInt32());
+            status_t result = allowAllocation(allow);
+            reply->writeInt32(result);
+            return NO_ERROR;
+        }
+        case SET_GENERATION_NUMBER: {
+            CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
+            uint32_t generationNumber = data.readUint32();
+            status_t result = setGenerationNumber(generationNumber);
+            reply->writeInt32(result);
+            return NO_ERROR;
+        }
+        case GET_CONSUMER_NAME: {
+            CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
+            reply->writeString8(getConsumerName());
+            return NO_ERROR;
+        }
     }
     return BBinder::onTransact(code, data, reply, flags);
 }
@@ -276,11 +498,14 @@
 size_t IGraphicBufferProducer::QueueBufferInput::getFlattenedSize() const {
     return sizeof(timestamp)
          + sizeof(isAutoTimestamp)
+         + sizeof(dataSpace)
          + sizeof(crop)
          + sizeof(scalingMode)
          + sizeof(transform)
+         + sizeof(stickyTransform)
          + sizeof(async)
-         + fence->getFlattenedSize();
+         + fence->getFlattenedSize()
+         + surfaceDamage.getFlattenedSize();
 }
 
 size_t IGraphicBufferProducer::QueueBufferInput::getFdCount() const {
@@ -295,11 +520,17 @@
     }
     FlattenableUtils::write(buffer, size, timestamp);
     FlattenableUtils::write(buffer, size, isAutoTimestamp);
+    FlattenableUtils::write(buffer, size, dataSpace);
     FlattenableUtils::write(buffer, size, crop);
     FlattenableUtils::write(buffer, size, scalingMode);
     FlattenableUtils::write(buffer, size, transform);
+    FlattenableUtils::write(buffer, size, stickyTransform);
     FlattenableUtils::write(buffer, size, async);
-    return fence->flatten(buffer, size, fds, count);
+    status_t result = fence->flatten(buffer, size, fds, count);
+    if (result != NO_ERROR) {
+        return result;
+    }
+    return surfaceDamage.flatten(buffer, size);
 }
 
 status_t IGraphicBufferProducer::QueueBufferInput::unflatten(
@@ -308,9 +539,11 @@
     size_t minNeeded =
               sizeof(timestamp)
             + sizeof(isAutoTimestamp)
+            + sizeof(dataSpace)
             + sizeof(crop)
             + sizeof(scalingMode)
             + sizeof(transform)
+            + sizeof(stickyTransform)
             + sizeof(async);
 
     if (size < minNeeded) {
@@ -319,13 +552,19 @@
 
     FlattenableUtils::read(buffer, size, timestamp);
     FlattenableUtils::read(buffer, size, isAutoTimestamp);
+    FlattenableUtils::read(buffer, size, dataSpace);
     FlattenableUtils::read(buffer, size, crop);
     FlattenableUtils::read(buffer, size, scalingMode);
     FlattenableUtils::read(buffer, size, transform);
+    FlattenableUtils::read(buffer, size, stickyTransform);
     FlattenableUtils::read(buffer, size, async);
 
     fence = new Fence();
-    return fence->unflatten(buffer, size, fds, count);
+    status_t result = fence->unflatten(buffer, size, fds, count);
+    if (result != NO_ERROR) {
+        return result;
+    }
+    return surfaceDamage.unflatten(buffer, size);
 }
 
 }; // namespace android
diff --git a/libs/gui/IProducerListener.cpp b/libs/gui/IProducerListener.cpp
new file mode 100644
index 0000000..9d18ea2
--- /dev/null
+++ b/libs/gui/IProducerListener.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <binder/Parcel.h>
+
+#include <gui/IProducerListener.h>
+
+namespace android {
+
+enum {
+    ON_BUFFER_RELEASED = IBinder::FIRST_CALL_TRANSACTION,
+};
+
+class BpProducerListener : public BpInterface<IProducerListener>
+{
+public:
+    explicit BpProducerListener(const sp<IBinder>& impl)
+        : BpInterface<IProducerListener>(impl) {}
+
+    virtual ~BpProducerListener();
+
+    virtual void onBufferReleased() {
+        Parcel data, reply;
+        data.writeInterfaceToken(IProducerListener::getInterfaceDescriptor());
+        remote()->transact(ON_BUFFER_RELEASED, data, &reply, IBinder::FLAG_ONEWAY);
+    }
+};
+
+// Out-of-line virtual method definition to trigger vtable emission in this
+// translation unit (see clang warning -Wweak-vtables)
+BpProducerListener::~BpProducerListener() {}
+
+IMPLEMENT_META_INTERFACE(ProducerListener, "android.gui.IProducerListener")
+
+status_t BnProducerListener::onTransact(uint32_t code, const Parcel& data,
+        Parcel* reply, uint32_t flags) {
+    switch (code) {
+        case ON_BUFFER_RELEASED:
+            CHECK_INTERFACE(IProducerListener, data, reply);
+            onBufferReleased();
+            return NO_ERROR;
+    }
+    return BBinder::onTransact(code, data, reply, flags);
+}
+
+} // namespace android
diff --git a/libs/gui/ISensorEventConnection.cpp b/libs/gui/ISensorEventConnection.cpp
index 28fcb53..59ecee7 100644
--- a/libs/gui/ISensorEventConnection.cpp
+++ b/libs/gui/ISensorEventConnection.cpp
@@ -40,11 +40,13 @@
 class BpSensorEventConnection : public BpInterface<ISensorEventConnection>
 {
 public:
-    BpSensorEventConnection(const sp<IBinder>& impl)
+    explicit BpSensorEventConnection(const sp<IBinder>& impl)
         : BpInterface<ISensorEventConnection>(impl)
     {
     }
 
+    virtual ~BpSensorEventConnection();
+
     virtual sp<BitTube> getSensorChannel() const
     {
         Parcel data, reply;
@@ -85,6 +87,10 @@
     }
 };
 
+// Out-of-line virtual method definition to trigger vtable emission in this
+// translation unit (see clang warning -Wweak-vtables)
+BpSensorEventConnection::~BpSensorEventConnection() {}
+
 IMPLEMENT_META_INTERFACE(SensorEventConnection, "android.gui.SensorEventConnection");
 
 // ----------------------------------------------------------------------------
@@ -98,7 +104,7 @@
             sp<BitTube> channel(getSensorChannel());
             channel->writeToParcel(reply);
             return NO_ERROR;
-        } break;
+        }
         case ENABLE_DISABLE: {
             CHECK_INTERFACE(ISensorEventConnection, data, reply);
             int handle = data.readInt32();
@@ -110,21 +116,21 @@
                                             maxBatchReportLatencyNs, reservedFlags);
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
         case SET_EVENT_RATE: {
             CHECK_INTERFACE(ISensorEventConnection, data, reply);
             int handle = data.readInt32();
-            int ns = data.readInt64();
+            nsecs_t ns = data.readInt64();
             status_t result = setEventRate(handle, ns);
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
         case FLUSH_SENSOR: {
             CHECK_INTERFACE(ISensorEventConnection, data, reply);
             status_t result = flush();
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
     }
     return BBinder::onTransact(code, data, reply, flags);
 }
diff --git a/libs/gui/ISensorServer.cpp b/libs/gui/ISensorServer.cpp
index 0b76f37..b0ba134 100644
--- a/libs/gui/ISensorServer.cpp
+++ b/libs/gui/ISensorServer.cpp
@@ -35,24 +35,28 @@
 enum {
     GET_SENSOR_LIST = IBinder::FIRST_CALL_TRANSACTION,
     CREATE_SENSOR_EVENT_CONNECTION,
+    ENABLE_DATA_INJECTION
 };
 
 class BpSensorServer : public BpInterface<ISensorServer>
 {
 public:
-    BpSensorServer(const sp<IBinder>& impl)
+    explicit BpSensorServer(const sp<IBinder>& impl)
         : BpInterface<ISensorServer>(impl)
     {
     }
 
-    virtual Vector<Sensor> getSensorList()
+    virtual ~BpSensorServer();
+
+    virtual Vector<Sensor> getSensorList(const String16& opPackageName)
     {
         Parcel data, reply;
         data.writeInterfaceToken(ISensorServer::getInterfaceDescriptor());
+        data.writeString16(opPackageName);
         remote()->transact(GET_SENSOR_LIST, data, &reply);
         Sensor s;
         Vector<Sensor> v;
-        int32_t n = reply.readInt32();
+        uint32_t n = reply.readUint32();
         v.setCapacity(n);
         while (n--) {
             reply.read(s);
@@ -61,15 +65,30 @@
         return v;
     }
 
-    virtual sp<ISensorEventConnection> createSensorEventConnection()
+    virtual sp<ISensorEventConnection> createSensorEventConnection(const String8& packageName,
+             int mode, const String16& opPackageName)
     {
         Parcel data, reply;
         data.writeInterfaceToken(ISensorServer::getInterfaceDescriptor());
+        data.writeString8(packageName);
+        data.writeInt32(mode);
+        data.writeString16(opPackageName);
         remote()->transact(CREATE_SENSOR_EVENT_CONNECTION, data, &reply);
         return interface_cast<ISensorEventConnection>(reply.readStrongBinder());
     }
+
+    virtual int isDataInjectionEnabled() {
+        Parcel data, reply;
+        data.writeInterfaceToken(ISensorServer::getInterfaceDescriptor());
+        remote()->transact(ENABLE_DATA_INJECTION, data, &reply);
+        return reply.readInt32();
+    }
 };
 
+// Out-of-line virtual method definition to trigger vtable emission in this
+// translation unit (see clang warning -Wweak-vtables)
+BpSensorServer::~BpSensorServer() {}
+
 IMPLEMENT_META_INTERFACE(SensorServer, "android.gui.SensorServer");
 
 // ----------------------------------------------------------------------
@@ -80,20 +99,31 @@
     switch(code) {
         case GET_SENSOR_LIST: {
             CHECK_INTERFACE(ISensorServer, data, reply);
-            Vector<Sensor> v(getSensorList());
+            const String16& opPackageName = data.readString16();
+            Vector<Sensor> v(getSensorList(opPackageName));
             size_t n = v.size();
-            reply->writeInt32(n);
-            for (size_t i=0 ; i<n ; i++) {
+            reply->writeUint32(static_cast<uint32_t>(n));
+            for (size_t i = 0; i < n; i++) {
                 reply->write(v[i]);
             }
             return NO_ERROR;
-        } break;
+        }
         case CREATE_SENSOR_EVENT_CONNECTION: {
             CHECK_INTERFACE(ISensorServer, data, reply);
-            sp<ISensorEventConnection> connection(createSensorEventConnection());
-            reply->writeStrongBinder(connection->asBinder());
+            String8 packageName = data.readString8();
+            int32_t mode = data.readInt32();
+            const String16& opPackageName = data.readString16();
+            sp<ISensorEventConnection> connection(createSensorEventConnection(packageName, mode,
+                    opPackageName));
+            reply->writeStrongBinder(IInterface::asBinder(connection));
             return NO_ERROR;
-        } break;
+        }
+        case ENABLE_DATA_INJECTION: {
+            CHECK_INTERFACE(ISensorServer, data, reply);
+            int32_t ret = isDataInjectionEnabled();
+            reply->writeInt32(static_cast<int32_t>(ret));
+            return NO_ERROR;
+        }
     }
     return BBinder::onTransact(code, data, reply, flags);
 }
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index aab0604..9bfc906 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -33,6 +33,7 @@
 #include <private/gui/LayerState.h>
 
 #include <ui/DisplayInfo.h>
+#include <ui/DisplayStatInfo.h>
 
 #include <utils/Log.h>
 
@@ -45,14 +46,15 @@
 class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
 {
 public:
-    BpSurfaceComposer(const sp<IBinder>& impl)
+    explicit BpSurfaceComposer(const sp<IBinder>& impl)
         : BpInterface<ISurfaceComposer>(impl)
     {
     }
 
+    virtual ~BpSurfaceComposer();
+
     virtual sp<ISurfaceComposerClient> createConnection()
     {
-        uint32_t n;
         Parcel data, reply;
         data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
         remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply);
@@ -61,7 +63,6 @@
 
     virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc()
     {
-        uint32_t n;
         Parcel data, reply;
         data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
         remote()->transact(BnSurfaceComposer::CREATE_GRAPHIC_BUFFER_ALLOC, data, &reply);
@@ -75,23 +76,18 @@
     {
         Parcel data, reply;
         data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
-        {
-            Vector<ComposerState>::const_iterator b(state.begin());
-            Vector<ComposerState>::const_iterator e(state.end());
-            data.writeInt32(state.size());
-            for ( ; b != e ; ++b ) {
-                b->write(data);
-            }
+
+        data.writeUint32(static_cast<uint32_t>(state.size()));
+        for (const auto& s : state) {
+            s.write(data);
         }
-        {
-            Vector<DisplayState>::const_iterator b(displays.begin());
-            Vector<DisplayState>::const_iterator e(displays.end());
-            data.writeInt32(displays.size());
-            for ( ; b != e ; ++b ) {
-                b->write(data);
-            }
+
+        data.writeUint32(static_cast<uint32_t>(displays.size()));
+        for (const auto& d : displays) {
+            d.write(data);
         }
-        data.writeInt32(flags);
+
+        data.writeUint32(flags);
         remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
     }
 
@@ -104,17 +100,22 @@
 
     virtual status_t captureScreen(const sp<IBinder>& display,
             const sp<IGraphicBufferProducer>& producer,
-            uint32_t reqWidth, uint32_t reqHeight,
-            uint32_t minLayerZ, uint32_t maxLayerZ)
+            Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
+            uint32_t minLayerZ, uint32_t maxLayerZ,
+            bool useIdentityTransform,
+            ISurfaceComposer::Rotation rotation)
     {
         Parcel data, reply;
         data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
         data.writeStrongBinder(display);
-        data.writeStrongBinder(producer->asBinder());
-        data.writeInt32(reqWidth);
-        data.writeInt32(reqHeight);
-        data.writeInt32(minLayerZ);
-        data.writeInt32(maxLayerZ);
+        data.writeStrongBinder(IInterface::asBinder(producer));
+        data.write(sourceCrop);
+        data.writeUint32(reqWidth);
+        data.writeUint32(reqHeight);
+        data.writeUint32(minLayerZ);
+        data.writeUint32(maxLayerZ);
+        data.writeInt32(static_cast<int32_t>(useIdentityTransform));
+        data.writeInt32(static_cast<int32_t>(rotation));
         remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
         return reply.readInt32();
     }
@@ -131,7 +132,7 @@
                     "interface descriptor: %s (%d)", strerror(-err), -err);
             return false;
         }
-        err = data.writeStrongBinder(bufferProducer->asBinder());
+        err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
         if (err != NO_ERROR) {
             ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
                     "strong binder to parcel: %s (%d)", strerror(-err), -err);
@@ -202,33 +203,91 @@
         return reply.readStrongBinder();
     }
 
-    virtual void blank(const sp<IBinder>& display)
+    virtual void setPowerMode(const sp<IBinder>& display, int mode)
     {
         Parcel data, reply;
         data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
         data.writeStrongBinder(display);
-        remote()->transact(BnSurfaceComposer::BLANK, data, &reply);
+        data.writeInt32(mode);
+        remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
     }
 
-    virtual void unblank(const sp<IBinder>& display)
+    virtual status_t getDisplayConfigs(const sp<IBinder>& display,
+            Vector<DisplayInfo>* configs)
     {
         Parcel data, reply;
         data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
         data.writeStrongBinder(display);
-        remote()->transact(BnSurfaceComposer::UNBLANK, data, &reply);
+        remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
+        status_t result = reply.readInt32();
+        if (result == NO_ERROR) {
+            size_t numConfigs = reply.readUint32();
+            configs->clear();
+            configs->resize(numConfigs);
+            for (size_t c = 0; c < numConfigs; ++c) {
+                memcpy(&(configs->editItemAt(c)),
+                        reply.readInplace(sizeof(DisplayInfo)),
+                        sizeof(DisplayInfo));
+            }
+        }
+        return result;
     }
 
-    virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info)
+    virtual status_t getDisplayStats(const sp<IBinder>& display,
+            DisplayStatInfo* stats)
     {
         Parcel data, reply;
         data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
         data.writeStrongBinder(display);
-        remote()->transact(BnSurfaceComposer::GET_DISPLAY_INFO, data, &reply);
-        memcpy(info, reply.readInplace(sizeof(DisplayInfo)), sizeof(DisplayInfo));
+        remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
+        status_t result = reply.readInt32();
+        if (result == NO_ERROR) {
+            memcpy(stats,
+                    reply.readInplace(sizeof(DisplayStatInfo)),
+                    sizeof(DisplayStatInfo));
+        }
+        return result;
+    }
+
+    virtual int getActiveConfig(const sp<IBinder>& display)
+    {
+        Parcel data, reply;
+        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
+        data.writeStrongBinder(display);
+        remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
+        return reply.readInt32();
+    }
+
+    virtual status_t setActiveConfig(const sp<IBinder>& display, int id)
+    {
+        Parcel data, reply;
+        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
+        data.writeStrongBinder(display);
+        data.writeInt32(id);
+        remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply);
+        return reply.readInt32();
+    }
+
+    virtual status_t clearAnimationFrameStats() {
+        Parcel data, reply;
+        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
+        remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
+        return reply.readInt32();
+    }
+
+    virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
+        Parcel data, reply;
+        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
+        remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
+        reply.read(*outStats);
         return reply.readInt32();
     }
 };
 
+// Out-of-line virtual method definition to trigger vtable emission in this
+// translation unit (see clang warning -Wweak-vtables)
+BpSurfaceComposer::~BpSurfaceComposer() {}
+
 IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
 
 // ----------------------------------------------------------------------
@@ -239,36 +298,49 @@
     switch(code) {
         case CREATE_CONNECTION: {
             CHECK_INTERFACE(ISurfaceComposer, data, reply);
-            sp<IBinder> b = createConnection()->asBinder();
+            sp<IBinder> b = IInterface::asBinder(createConnection());
             reply->writeStrongBinder(b);
             return NO_ERROR;
         }
         case CREATE_GRAPHIC_BUFFER_ALLOC: {
             CHECK_INTERFACE(ISurfaceComposer, data, reply);
-            sp<IBinder> b = createGraphicBufferAlloc()->asBinder();
+            sp<IBinder> b = IInterface::asBinder(createGraphicBufferAlloc());
             reply->writeStrongBinder(b);
             return NO_ERROR;
         }
         case SET_TRANSACTION_STATE: {
             CHECK_INTERFACE(ISurfaceComposer, data, reply);
-            size_t count = data.readInt32();
+
+            size_t count = data.readUint32();
+            if (count > data.dataSize()) {
+                return BAD_VALUE;
+            }
             ComposerState s;
             Vector<ComposerState> state;
             state.setCapacity(count);
-            for (size_t i=0 ; i<count ; i++) {
-                s.read(data);
+            for (size_t i = 0; i < count; i++) {
+                if (s.read(data) == BAD_VALUE) {
+                    return BAD_VALUE;
+                }
                 state.add(s);
             }
-            count = data.readInt32();
+
+            count = data.readUint32();
+            if (count > data.dataSize()) {
+                return BAD_VALUE;
+            }
             DisplayState d;
             Vector<DisplayState> displays;
             displays.setCapacity(count);
-            for (size_t i=0 ; i<count ; i++) {
-                d.read(data);
+            for (size_t i = 0; i < count; i++) {
+                if (d.read(data) == BAD_VALUE) {
+                    return BAD_VALUE;
+                }
                 displays.add(d);
             }
-            uint32_t flags = data.readInt32();
-            setTransactionState(state, displays, flags);
+
+            uint32_t stateFlags = data.readUint32();
+            setTransactionState(state, displays, stateFlags);
             return NO_ERROR;
         }
         case BOOT_FINISHED: {
@@ -281,12 +353,19 @@
             sp<IBinder> display = data.readStrongBinder();
             sp<IGraphicBufferProducer> producer =
                     interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
-            uint32_t reqWidth = data.readInt32();
-            uint32_t reqHeight = data.readInt32();
-            uint32_t minLayerZ = data.readInt32();
-            uint32_t maxLayerZ = data.readInt32();
+            Rect sourceCrop;
+            data.read(sourceCrop);
+            uint32_t reqWidth = data.readUint32();
+            uint32_t reqHeight = data.readUint32();
+            uint32_t minLayerZ = data.readUint32();
+            uint32_t maxLayerZ = data.readUint32();
+            bool useIdentityTransform = static_cast<bool>(data.readInt32());
+            int32_t rotation = data.readInt32();
+
             status_t res = captureScreen(display, producer,
-                    reqWidth, reqHeight, minLayerZ, maxLayerZ);
+                    sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
+                    useIdentityTransform,
+                    static_cast<ISurfaceComposer::Rotation>(rotation));
             reply->writeInt32(res);
             return NO_ERROR;
         }
@@ -301,7 +380,7 @@
         case CREATE_DISPLAY_EVENT_CONNECTION: {
             CHECK_INTERFACE(ISurfaceComposer, data, reply);
             sp<IDisplayEventConnection> connection(createDisplayEventConnection());
-            reply->writeStrongBinder(connection->asBinder());
+            reply->writeStrongBinder(IInterface::asBinder(connection));
             return NO_ERROR;
         }
         case CREATE_DISPLAY: {
@@ -325,33 +404,73 @@
             reply->writeStrongBinder(display);
             return NO_ERROR;
         }
-        case BLANK: {
+        case GET_DISPLAY_CONFIGS: {
             CHECK_INTERFACE(ISurfaceComposer, data, reply);
+            Vector<DisplayInfo> configs;
             sp<IBinder> display = data.readStrongBinder();
-            blank(display);
-            return NO_ERROR;
-        }
-        case UNBLANK: {
-            CHECK_INTERFACE(ISurfaceComposer, data, reply);
-            sp<IBinder> display = data.readStrongBinder();
-            unblank(display);
-            return NO_ERROR;
-        }
-        case GET_DISPLAY_INFO: {
-            CHECK_INTERFACE(ISurfaceComposer, data, reply);
-            DisplayInfo info;
-            sp<IBinder> display = data.readStrongBinder();
-            status_t result = getDisplayInfo(display, &info);
-            memcpy(reply->writeInplace(sizeof(DisplayInfo)), &info, sizeof(DisplayInfo));
+            status_t result = getDisplayConfigs(display, &configs);
             reply->writeInt32(result);
+            if (result == NO_ERROR) {
+                reply->writeUint32(static_cast<uint32_t>(configs.size()));
+                for (size_t c = 0; c < configs.size(); ++c) {
+                    memcpy(reply->writeInplace(sizeof(DisplayInfo)),
+                            &configs[c], sizeof(DisplayInfo));
+                }
+            }
+            return NO_ERROR;
+        }
+        case GET_DISPLAY_STATS: {
+            CHECK_INTERFACE(ISurfaceComposer, data, reply);
+            DisplayStatInfo stats;
+            sp<IBinder> display = data.readStrongBinder();
+            status_t result = getDisplayStats(display, &stats);
+            reply->writeInt32(result);
+            if (result == NO_ERROR) {
+                memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
+                        &stats, sizeof(DisplayStatInfo));
+            }
+            return NO_ERROR;
+        }
+        case GET_ACTIVE_CONFIG: {
+            CHECK_INTERFACE(ISurfaceComposer, data, reply);
+            sp<IBinder> display = data.readStrongBinder();
+            int id = getActiveConfig(display);
+            reply->writeInt32(id);
+            return NO_ERROR;
+        }
+        case SET_ACTIVE_CONFIG: {
+            CHECK_INTERFACE(ISurfaceComposer, data, reply);
+            sp<IBinder> display = data.readStrongBinder();
+            int id = data.readInt32();
+            status_t result = setActiveConfig(display, id);
+            reply->writeInt32(result);
+            return NO_ERROR;
+        }
+        case CLEAR_ANIMATION_FRAME_STATS: {
+            CHECK_INTERFACE(ISurfaceComposer, data, reply);
+            status_t result = clearAnimationFrameStats();
+            reply->writeInt32(result);
+            return NO_ERROR;
+        }
+        case GET_ANIMATION_FRAME_STATS: {
+            CHECK_INTERFACE(ISurfaceComposer, data, reply);
+            FrameStats stats;
+            status_t result = getAnimationFrameStats(&stats);
+            reply->write(stats);
+            reply->writeInt32(result);
+            return NO_ERROR;
+        }
+        case SET_POWER_MODE: {
+            CHECK_INTERFACE(ISurfaceComposer, data, reply);
+            sp<IBinder> display = data.readStrongBinder();
+            int32_t mode = data.readInt32();
+            setPowerMode(display, mode);
             return NO_ERROR;
         }
         default: {
             return BBinder::onTransact(code, data, reply, flags);
         }
     }
-    // should be unreachable
-    return NO_ERROR;
 }
 
 // ----------------------------------------------------------------------------
diff --git a/libs/gui/ISurfaceComposerClient.cpp b/libs/gui/ISurfaceComposerClient.cpp
index 1adc134..decffbf 100644
--- a/libs/gui/ISurfaceComposerClient.cpp
+++ b/libs/gui/ISurfaceComposerClient.cpp
@@ -39,27 +39,31 @@
 
 enum {
     CREATE_SURFACE = IBinder::FIRST_CALL_TRANSACTION,
-    DESTROY_SURFACE
+    DESTROY_SURFACE,
+    CLEAR_LAYER_FRAME_STATS,
+    GET_LAYER_FRAME_STATS
 };
 
 class BpSurfaceComposerClient : public BpInterface<ISurfaceComposerClient>
 {
 public:
-    BpSurfaceComposerClient(const sp<IBinder>& impl)
+    explicit BpSurfaceComposerClient(const sp<IBinder>& impl)
         : BpInterface<ISurfaceComposerClient>(impl) {
     }
 
-    virtual status_t createSurface(const String8& name, uint32_t w,
-            uint32_t h, PixelFormat format, uint32_t flags,
+    virtual ~BpSurfaceComposerClient();
+
+    virtual status_t createSurface(const String8& name, uint32_t width,
+            uint32_t height, PixelFormat format, uint32_t flags,
             sp<IBinder>* handle,
             sp<IGraphicBufferProducer>* gbp) {
         Parcel data, reply;
         data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor());
         data.writeString8(name);
-        data.writeInt32(w);
-        data.writeInt32(h);
-        data.writeInt32(format);
-        data.writeInt32(flags);
+        data.writeUint32(width);
+        data.writeUint32(height);
+        data.writeInt32(static_cast<int32_t>(format));
+        data.writeUint32(flags);
         remote()->transact(CREATE_SURFACE, data, &reply);
         *handle = reply.readStrongBinder();
         *gbp = interface_cast<IGraphicBufferProducer>(reply.readStrongBinder());
@@ -73,8 +77,29 @@
         remote()->transact(DESTROY_SURFACE, data, &reply);
         return reply.readInt32();
     }
+
+    virtual status_t clearLayerFrameStats(const sp<IBinder>& handle) const {
+        Parcel data, reply;
+        data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor());
+        data.writeStrongBinder(handle);
+        remote()->transact(CLEAR_LAYER_FRAME_STATS, data, &reply);
+        return reply.readInt32();
+    }
+
+    virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const {
+        Parcel data, reply;
+        data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor());
+        data.writeStrongBinder(handle);
+        remote()->transact(GET_LAYER_FRAME_STATS, data, &reply);
+        reply.read(*outStats);
+        return reply.readInt32();
+    }
 };
 
+// Out-of-line virtual method definition to trigger vtable emission in this
+// translation unit (see clang warning -Wweak-vtables)
+BpSurfaceComposerClient::~BpSurfaceComposerClient() {}
+
 IMPLEMENT_META_INTERFACE(SurfaceComposerClient, "android.ui.ISurfaceComposerClient");
 
 // ----------------------------------------------------------------------
@@ -86,24 +111,40 @@
         case CREATE_SURFACE: {
             CHECK_INTERFACE(ISurfaceComposerClient, data, reply);
             String8 name = data.readString8();
-            uint32_t w = data.readInt32();
-            uint32_t h = data.readInt32();
-            PixelFormat format = data.readInt32();
-            uint32_t flags = data.readInt32();
+            uint32_t width = data.readUint32();
+            uint32_t height = data.readUint32();
+            PixelFormat format = static_cast<PixelFormat>(data.readInt32());
+            uint32_t createFlags = data.readUint32();
             sp<IBinder> handle;
             sp<IGraphicBufferProducer> gbp;
-            status_t result = createSurface(name, w, h, format, flags,
-                    &handle, &gbp);
+            status_t result = createSurface(name, width, height, format,
+                    createFlags, &handle, &gbp);
             reply->writeStrongBinder(handle);
-            reply->writeStrongBinder(gbp->asBinder());
+            reply->writeStrongBinder(IInterface::asBinder(gbp));
             reply->writeInt32(result);
             return NO_ERROR;
-        } break;
+        }
         case DESTROY_SURFACE: {
             CHECK_INTERFACE(ISurfaceComposerClient, data, reply);
-            reply->writeInt32( destroySurface( data.readStrongBinder() ) );
+            reply->writeInt32(destroySurface( data.readStrongBinder() ) );
             return NO_ERROR;
-        } break;
+        }
+       case CLEAR_LAYER_FRAME_STATS: {
+            CHECK_INTERFACE(ISurfaceComposerClient, data, reply);
+            sp<IBinder> handle = data.readStrongBinder();
+            status_t result = clearLayerFrameStats(handle);
+            reply->writeInt32(result);
+            return NO_ERROR;
+        }
+        case GET_LAYER_FRAME_STATS: {
+            CHECK_INTERFACE(ISurfaceComposerClient, data, reply);
+            sp<IBinder> handle = data.readStrongBinder();
+            FrameStats stats;
+            status_t result = getLayerFrameStats(handle, &stats);
+            reply->write(stats);
+            reply->writeInt32(result);
+            return NO_ERROR;
+        }
         default:
             return BBinder::onTransact(code, data, reply, flags);
     }
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index acdbd77..00323dc 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -25,16 +25,16 @@
 status_t layer_state_t::write(Parcel& output) const
 {
     output.writeStrongBinder(surface);
-    output.writeInt32(what);
+    output.writeUint32(what);
     output.writeFloat(x);
     output.writeFloat(y);
-    output.writeInt32(z);
-    output.writeInt32(w);
-    output.writeInt32(h);
-    output.writeInt32(layerStack);
+    output.writeUint32(z);
+    output.writeUint32(w);
+    output.writeUint32(h);
+    output.writeUint32(layerStack);
     output.writeFloat(alpha);
-    output.writeInt32(flags);
-    output.writeInt32(mask);
+    output.writeUint32(flags);
+    output.writeUint32(mask);
     *reinterpret_cast<layer_state_t::matrix22_t *>(
             output.writeInplace(sizeof(layer_state_t::matrix22_t))) = matrix;
     output.write(crop);
@@ -45,25 +45,29 @@
 status_t layer_state_t::read(const Parcel& input)
 {
     surface = input.readStrongBinder();
-    what = input.readInt32();
+    what = input.readUint32();
     x = input.readFloat();
     y = input.readFloat();
-    z = input.readInt32();
-    w = input.readInt32();
-    h = input.readInt32();
-    layerStack = input.readInt32();
+    z = input.readUint32();
+    w = input.readUint32();
+    h = input.readUint32();
+    layerStack = input.readUint32();
     alpha = input.readFloat();
-    flags = input.readInt32();
-    mask = input.readInt32();
-    matrix = *reinterpret_cast<layer_state_t::matrix22_t const *>(
-            input.readInplace(sizeof(layer_state_t::matrix22_t)));
+    flags = static_cast<uint8_t>(input.readUint32());
+    mask = static_cast<uint8_t>(input.readUint32());
+    const void* matrix_data = input.readInplace(sizeof(layer_state_t::matrix22_t));
+    if (matrix_data) {
+        matrix = *reinterpret_cast<layer_state_t::matrix22_t const *>(matrix_data);
+    } else {
+        return BAD_VALUE;
+    }
     input.read(crop);
     input.read(transparentRegion);
     return NO_ERROR;
 }
 
 status_t ComposerState::write(Parcel& output) const {
-    output.writeStrongBinder(client->asBinder());
+    output.writeStrongBinder(IInterface::asBinder(client));
     return state.write(output);
 }
 
@@ -75,23 +79,27 @@
 
 status_t DisplayState::write(Parcel& output) const {
     output.writeStrongBinder(token);
-    output.writeStrongBinder(surface->asBinder());
-    output.writeInt32(what);
-    output.writeInt32(layerStack);
-    output.writeInt32(orientation);
+    output.writeStrongBinder(IInterface::asBinder(surface));
+    output.writeUint32(what);
+    output.writeUint32(layerStack);
+    output.writeUint32(orientation);
     output.write(viewport);
     output.write(frame);
+    output.writeUint32(width);
+    output.writeUint32(height);
     return NO_ERROR;
 }
 
 status_t DisplayState::read(const Parcel& input) {
     token = input.readStrongBinder();
     surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder());
-    what = input.readInt32();
-    layerStack = input.readInt32();
-    orientation = input.readInt32();
+    what = input.readUint32();
+    layerStack = input.readUint32();
+    orientation = input.readUint32();
     input.read(viewport);
     input.read(frame);
+    width = input.readUint32();
+    height = input.readUint32();
     return NO_ERROR;
 }
 
diff --git a/libs/gui/Sensor.cpp b/libs/gui/Sensor.cpp
index da6b0f9..235cbbd 100644
--- a/libs/gui/Sensor.cpp
+++ b/libs/gui/Sensor.cpp
@@ -14,8 +14,10 @@
  * limitations under the License.
  */
 
+#include <inttypes.h>
 #include <stdint.h>
 #include <sys/types.h>
+#include <sys/limits.h>
 
 #include <utils/Errors.h>
 #include <utils/String8.h>
@@ -23,7 +25,11 @@
 
 #include <hardware/sensors.h>
 
+#include <binder/AppOpsManager.h>
+#include <binder/IServiceManager.h>
+
 #include <gui/Sensor.h>
+#include <log/log.h>
 
 // ----------------------------------------------------------------------------
 namespace android {
@@ -32,7 +38,8 @@
 Sensor::Sensor()
     : mHandle(0), mType(0),
       mMinValue(0), mMaxValue(0), mResolution(0),
-      mPower(0), mMinDelay(0), mFifoReservedEventCount(0), mFifoMaxEventCount(0)
+      mPower(0), mMinDelay(0), mFifoReservedEventCount(0), mFifoMaxEventCount(0),
+      mMaxDelay(0), mFlags(0)
 {
 }
 
@@ -48,15 +55,228 @@
     mResolution = hwSensor->resolution;
     mPower = hwSensor->power;
     mMinDelay = hwSensor->minDelay;
+    mFlags = 0;
+
     // Set fifo event count zero for older devices which do not support batching. Fused
     // sensors also have their fifo counts set to zero.
-    if (halVersion >= SENSORS_DEVICE_API_VERSION_1_1) {
+    if (halVersion > SENSORS_DEVICE_API_VERSION_1_0) {
         mFifoReservedEventCount = hwSensor->fifoReservedEventCount;
         mFifoMaxEventCount = hwSensor->fifoMaxEventCount;
     } else {
         mFifoReservedEventCount = 0;
         mFifoMaxEventCount = 0;
     }
+
+    if (halVersion >= SENSORS_DEVICE_API_VERSION_1_3) {
+        if (hwSensor->maxDelay > INT_MAX) {
+            // Max delay is declared as a 64 bit integer for 64 bit architectures. But it should
+            // always fit in a 32 bit integer, log error and cap it to INT_MAX.
+            ALOGE("Sensor maxDelay overflow error %s %" PRId64, mName.string(),
+                  static_cast<int64_t>(hwSensor->maxDelay));
+            mMaxDelay = INT_MAX;
+        } else {
+            mMaxDelay = static_cast<int32_t>(hwSensor->maxDelay);
+        }
+    } else {
+        // For older hals set maxDelay to 0.
+        mMaxDelay = 0;
+    }
+
+    // Ensure existing sensors have correct string type, required permissions and reporting mode.
+    // Set reportingMode for all android defined sensor types, set wake-up flag only for proximity
+    // sensor, significant motion, tilt, pick_up gesture, wake gesture and glance gesture on older
+    // HALs. Newer HALs can define both wake-up and non wake-up proximity sensors.
+    // All the OEM defined defined sensors have flags set to whatever is provided by the HAL.
+    switch (mType) {
+    case SENSOR_TYPE_ACCELEROMETER:
+        mStringType = SENSOR_STRING_TYPE_ACCELEROMETER;
+        mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
+        break;
+    case SENSOR_TYPE_AMBIENT_TEMPERATURE:
+        mStringType = SENSOR_STRING_TYPE_AMBIENT_TEMPERATURE;
+        mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
+        break;
+    case SENSOR_TYPE_GAME_ROTATION_VECTOR:
+        mStringType = SENSOR_STRING_TYPE_GAME_ROTATION_VECTOR;
+        mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
+        break;
+    case SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR:
+        mStringType = SENSOR_STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR;
+        mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
+        break;
+    case SENSOR_TYPE_GRAVITY:
+        mStringType = SENSOR_STRING_TYPE_GRAVITY;
+        mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
+        break;
+    case SENSOR_TYPE_GYROSCOPE:
+        mStringType = SENSOR_STRING_TYPE_GYROSCOPE;
+        mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
+        break;
+    case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED:
+        mStringType = SENSOR_STRING_TYPE_GYROSCOPE_UNCALIBRATED;
+        mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
+        break;
+    case SENSOR_TYPE_HEART_RATE: {
+        mStringType = SENSOR_STRING_TYPE_HEART_RATE;
+        mRequiredPermission = SENSOR_PERMISSION_BODY_SENSORS;
+        AppOpsManager appOps;
+        mRequiredAppOp = appOps.permissionToOpCode(String16(SENSOR_PERMISSION_BODY_SENSORS));
+        mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
+        } break;
+    case SENSOR_TYPE_LIGHT:
+        mStringType = SENSOR_STRING_TYPE_LIGHT;
+        mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
+        break;
+    case SENSOR_TYPE_LINEAR_ACCELERATION:
+        mStringType = SENSOR_STRING_TYPE_LINEAR_ACCELERATION;
+        mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
+        break;
+    case SENSOR_TYPE_MAGNETIC_FIELD:
+        mStringType = SENSOR_STRING_TYPE_MAGNETIC_FIELD;
+        mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
+        break;
+    case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED:
+        mStringType = SENSOR_STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED;
+        mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
+        break;
+    case SENSOR_TYPE_ORIENTATION:
+        mStringType = SENSOR_STRING_TYPE_ORIENTATION;
+        mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
+        break;
+    case SENSOR_TYPE_PRESSURE:
+        mStringType = SENSOR_STRING_TYPE_PRESSURE;
+        mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
+        break;
+    case SENSOR_TYPE_PROXIMITY:
+        mStringType = SENSOR_STRING_TYPE_PROXIMITY;
+        mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
+        if (halVersion < SENSORS_DEVICE_API_VERSION_1_3) {
+            mFlags |= SENSOR_FLAG_WAKE_UP;
+        }
+        break;
+    case SENSOR_TYPE_RELATIVE_HUMIDITY:
+        mStringType = SENSOR_STRING_TYPE_RELATIVE_HUMIDITY;
+        mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
+        break;
+    case SENSOR_TYPE_ROTATION_VECTOR:
+        mStringType = SENSOR_STRING_TYPE_ROTATION_VECTOR;
+        mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
+        break;
+    case SENSOR_TYPE_SIGNIFICANT_MOTION:
+        mStringType = SENSOR_STRING_TYPE_SIGNIFICANT_MOTION;
+        mFlags |= SENSOR_FLAG_ONE_SHOT_MODE;
+        if (halVersion < SENSORS_DEVICE_API_VERSION_1_3) {
+            mFlags |= SENSOR_FLAG_WAKE_UP;
+        }
+        break;
+    case SENSOR_TYPE_STEP_COUNTER:
+        mStringType = SENSOR_STRING_TYPE_STEP_COUNTER;
+        mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
+        break;
+    case SENSOR_TYPE_STEP_DETECTOR:
+        mStringType = SENSOR_STRING_TYPE_STEP_DETECTOR;
+        mFlags |= SENSOR_FLAG_SPECIAL_REPORTING_MODE;
+        break;
+    case SENSOR_TYPE_TEMPERATURE:
+        mStringType = SENSOR_STRING_TYPE_TEMPERATURE;
+        mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
+        break;
+    case SENSOR_TYPE_TILT_DETECTOR:
+        mStringType = SENSOR_STRING_TYPE_TILT_DETECTOR;
+        mFlags |= SENSOR_FLAG_SPECIAL_REPORTING_MODE;
+        if (halVersion < SENSORS_DEVICE_API_VERSION_1_3) {
+            mFlags |= SENSOR_FLAG_WAKE_UP;
+        }
+         break;
+    case SENSOR_TYPE_WAKE_GESTURE:
+        mStringType = SENSOR_STRING_TYPE_WAKE_GESTURE;
+        mFlags |= SENSOR_FLAG_ONE_SHOT_MODE;
+        if (halVersion < SENSORS_DEVICE_API_VERSION_1_3) {
+            mFlags |= SENSOR_FLAG_WAKE_UP;
+        }
+        break;
+    case SENSOR_TYPE_GLANCE_GESTURE:
+        mStringType = SENSOR_STRING_TYPE_GLANCE_GESTURE;
+        mFlags |= SENSOR_FLAG_ONE_SHOT_MODE;
+        if (halVersion < SENSORS_DEVICE_API_VERSION_1_3) {
+            mFlags |= SENSOR_FLAG_WAKE_UP;
+        }
+        break;
+    case SENSOR_TYPE_PICK_UP_GESTURE:
+        mStringType = SENSOR_STRING_TYPE_PICK_UP_GESTURE;
+        mFlags |= SENSOR_FLAG_ONE_SHOT_MODE;
+        if (halVersion < SENSORS_DEVICE_API_VERSION_1_3) {
+            mFlags |= SENSOR_FLAG_WAKE_UP;
+        }
+        break;
+    case SENSOR_TYPE_WRIST_TILT_GESTURE:
+        mStringType = SENSOR_STRING_TYPE_WRIST_TILT_GESTURE;
+        mFlags |= SENSOR_FLAG_SPECIAL_REPORTING_MODE;
+        if (halVersion < SENSORS_DEVICE_API_VERSION_1_3) {
+            mFlags |= SENSOR_FLAG_WAKE_UP;
+        }
+        break;
+    default:
+        // Only pipe the stringType, requiredPermission and flags for custom sensors.
+        if (halVersion > SENSORS_DEVICE_API_VERSION_1_0 && hwSensor->stringType) {
+            mStringType = hwSensor->stringType;
+        }
+        if (halVersion > SENSORS_DEVICE_API_VERSION_1_0 && hwSensor->requiredPermission) {
+            mRequiredPermission = hwSensor->requiredPermission;
+            if (!strcmp(mRequiredPermission, SENSOR_PERMISSION_BODY_SENSORS)) {
+                AppOpsManager appOps;
+                mRequiredAppOp = appOps.permissionToOpCode(String16(SENSOR_PERMISSION_BODY_SENSORS));
+            }
+        }
+
+        if (halVersion >= SENSORS_DEVICE_API_VERSION_1_3) {
+            mFlags = static_cast<uint32_t>(hwSensor->flags);
+        } else {
+            // This is an OEM defined sensor on an older HAL. Use minDelay to determine the
+            // reporting mode of the sensor.
+            if (mMinDelay > 0) {
+                mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
+            } else if (mMinDelay == 0) {
+                mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
+            } else if (mMinDelay < 0) {
+                mFlags |= SENSOR_FLAG_ONE_SHOT_MODE;
+            }
+        }
+        break;
+    }
+
+    // Set DATA_INJECTION flag here. Defined in HAL 1_4.
+    if (halVersion >= SENSORS_DEVICE_API_VERSION_1_4) {
+        mFlags |= (hwSensor->flags & DATA_INJECTION_MASK);
+    }
+
+    // For the newer HALs log errors if reporting mask flags are set incorrectly.
+    if (halVersion >= SENSORS_DEVICE_API_VERSION_1_3) {
+        // Wake-up flag is set here.
+        mFlags |= (hwSensor->flags & SENSOR_FLAG_WAKE_UP);
+        if (mFlags != hwSensor->flags) {
+            int actualReportingMode =
+                 (hwSensor->flags & REPORTING_MODE_MASK) >> REPORTING_MODE_SHIFT;
+            int expectedReportingMode = (mFlags & REPORTING_MODE_MASK) >> REPORTING_MODE_SHIFT;
+            if (actualReportingMode != expectedReportingMode) {
+                ALOGE("Reporting Mode incorrect: sensor %s handle=%d type=%d "
+                       "actual=%d expected=%d",
+                       mName.string(), mHandle, mType, actualReportingMode, expectedReportingMode);
+            }
+
+        }
+    }
+
+    if (mRequiredPermission.length() > 0) {
+        // If the sensor is protected by a permission we need to know if it is
+        // a runtime one to determine whether we can use the permission cache.
+        sp<IBinder> binder = defaultServiceManager()->getService(String16("permission"));
+        if (binder != 0) {
+            sp<IPermissionController> permCtrl = interface_cast<IPermissionController>(binder);
+            mRequiredPermissionRuntime = permCtrl->isRuntimePermission(
+                    String16(mRequiredPermission));
+        }
+    }
 }
 
 Sensor::~Sensor()
@@ -107,24 +327,59 @@
     return mVersion;
 }
 
-int32_t Sensor::getFifoReservedEventCount() const {
+uint32_t Sensor::getFifoReservedEventCount() const {
     return mFifoReservedEventCount;
 }
 
-int32_t Sensor::getFifoMaxEventCount() const {
+uint32_t Sensor::getFifoMaxEventCount() const {
     return mFifoMaxEventCount;
 }
 
+const String8& Sensor::getStringType() const {
+    return mStringType;
+}
+
+const String8& Sensor::getRequiredPermission() const {
+    return mRequiredPermission;
+}
+
+bool Sensor::isRequiredPermissionRuntime() const {
+    return mRequiredPermissionRuntime;
+}
+
+int32_t Sensor::getRequiredAppOp() const {
+    return mRequiredAppOp;
+}
+
+int32_t Sensor::getMaxDelay() const {
+    return mMaxDelay;
+}
+
+uint32_t Sensor::getFlags() const {
+    return mFlags;
+}
+
+bool Sensor::isWakeUpSensor() const {
+    return mFlags & SENSOR_FLAG_WAKE_UP;
+}
+
+int32_t Sensor::getReportingMode() const {
+    return ((mFlags & REPORTING_MODE_MASK) >> REPORTING_MODE_SHIFT);
+}
+
 size_t Sensor::getFlattenedSize() const
 {
     size_t fixedSize =
             sizeof(int32_t) * 3 +
             sizeof(float) * 4 +
-            sizeof(int32_t) * 3;
+            sizeof(int32_t) * 6 +
+            sizeof(bool);
 
     size_t variableSize =
-            sizeof(int32_t) + FlattenableUtils::align<4>(mName.length()) +
-            sizeof(int32_t) + FlattenableUtils::align<4>(mVendor.length());
+            sizeof(uint32_t) + FlattenableUtils::align<4>(mName.length()) +
+            sizeof(uint32_t) + FlattenableUtils::align<4>(mVendor.length()) +
+            sizeof(uint32_t) + FlattenableUtils::align<4>(mStringType.length()) +
+            sizeof(uint32_t) + FlattenableUtils::align<4>(mRequiredPermission.length());
 
     return fixedSize + variableSize;
 }
@@ -134,14 +389,8 @@
         return NO_MEMORY;
     }
 
-    FlattenableUtils::write(buffer, size, mName.length());
-    memcpy(static_cast<char*>(buffer), mName.string(), mName.length());
-    FlattenableUtils::advance(buffer, size, FlattenableUtils::align<4>(mName.length()));
-
-    FlattenableUtils::write(buffer, size, mVendor.length());
-    memcpy(static_cast<char*>(buffer), mVendor.string(), mVendor.length());
-    FlattenableUtils::advance(buffer, size, FlattenableUtils::align<4>(mVendor.length()));
-
+    flattenString8(buffer, size, mName);
+    flattenString8(buffer, size, mVendor);
     FlattenableUtils::write(buffer, size, mVersion);
     FlattenableUtils::write(buffer, size, mHandle);
     FlattenableUtils::write(buffer, size, mType);
@@ -152,38 +401,27 @@
     FlattenableUtils::write(buffer, size, mMinDelay);
     FlattenableUtils::write(buffer, size, mFifoReservedEventCount);
     FlattenableUtils::write(buffer, size, mFifoMaxEventCount);
+    flattenString8(buffer, size, mStringType);
+    flattenString8(buffer, size, mRequiredPermission);
+    FlattenableUtils::write(buffer, size, mRequiredPermissionRuntime);
+    FlattenableUtils::write(buffer, size, mRequiredAppOp);
+    FlattenableUtils::write(buffer, size, mMaxDelay);
+    FlattenableUtils::write(buffer, size, mFlags);
     return NO_ERROR;
 }
 
 status_t Sensor::unflatten(void const* buffer, size_t size) {
-    size_t len;
-
-    if (size < sizeof(size_t)) {
+    if (!unflattenString8(buffer, size, mName)) {
         return NO_MEMORY;
     }
-    FlattenableUtils::read(buffer, size, len);
-    if (size < len) {
+    if (!unflattenString8(buffer, size, mVendor)) {
         return NO_MEMORY;
     }
-    mName.setTo(static_cast<char const*>(buffer), len);
-    FlattenableUtils::advance(buffer, size, FlattenableUtils::align<4>(len));
-
-
-    if (size < sizeof(size_t)) {
-        return NO_MEMORY;
-    }
-    FlattenableUtils::read(buffer, size, len);
-    if (size < len) {
-        return NO_MEMORY;
-    }
-    mVendor.setTo(static_cast<char const*>(buffer), len);
-    FlattenableUtils::advance(buffer, size, FlattenableUtils::align<4>(len));
 
     size_t fixedSize =
             sizeof(int32_t) * 3 +
             sizeof(float) * 4 +
-            sizeof(int32_t) * 3;
-
+            sizeof(int32_t) * 5;
     if (size < fixedSize) {
         return NO_MEMORY;
     }
@@ -198,8 +436,41 @@
     FlattenableUtils::read(buffer, size, mMinDelay);
     FlattenableUtils::read(buffer, size, mFifoReservedEventCount);
     FlattenableUtils::read(buffer, size, mFifoMaxEventCount);
+
+    if (!unflattenString8(buffer, size, mStringType)) {
+        return NO_MEMORY;
+    }
+    if (!unflattenString8(buffer, size, mRequiredPermission)) {
+        return NO_MEMORY;
+    }
+    FlattenableUtils::read(buffer, size, mRequiredPermissionRuntime);
+    FlattenableUtils::read(buffer, size, mRequiredAppOp);
+    FlattenableUtils::read(buffer, size, mMaxDelay);
+    FlattenableUtils::read(buffer, size, mFlags);
     return NO_ERROR;
 }
 
+void Sensor::flattenString8(void*& buffer, size_t& size,
+        const String8& string8) {
+    uint32_t len = static_cast<uint32_t>(string8.length());
+    FlattenableUtils::write(buffer, size, len);
+    memcpy(static_cast<char*>(buffer), string8.string(), len);
+    FlattenableUtils::advance(buffer, size, FlattenableUtils::align<4>(len));
+}
+
+bool Sensor::unflattenString8(void const*& buffer, size_t& size, String8& outputString8) {
+    uint32_t len;
+    if (size < sizeof(len)) {
+        return false;
+    }
+    FlattenableUtils::read(buffer, size, len);
+    if (size < len) {
+        return false;
+    }
+    outputString8.setTo(static_cast<char const*>(buffer), len);
+    FlattenableUtils::advance(buffer, size, FlattenableUtils::align<4>(len));
+    return true;
+}
+
 // ----------------------------------------------------------------------------
 }; // namespace android
diff --git a/libs/gui/SensorEventQueue.cpp b/libs/gui/SensorEventQueue.cpp
index c365671..4b7986e 100644
--- a/libs/gui/SensorEventQueue.cpp
+++ b/libs/gui/SensorEventQueue.cpp
@@ -16,8 +16,11 @@
 
 #define LOG_TAG "Sensors"
 
+#include <algorithm>
 #include <stdint.h>
 #include <sys/types.h>
+#include <sys/socket.h>
+#include <linux/errno.h>
 
 #include <utils/Errors.h>
 #include <utils/RefBase.h>
@@ -30,12 +33,15 @@
 
 #include <android/sensor.h>
 
+using std::min;
+
 // ----------------------------------------------------------------------------
 namespace android {
 // ----------------------------------------------------------------------------
 
 SensorEventQueue::SensorEventQueue(const sp<ISensorEventConnection>& connection)
-    : mSensorEventConnection(connection), mRecBuffer(NULL), mAvailable(0), mConsumed(0) {
+    : mSensorEventConnection(connection), mRecBuffer(NULL), mAvailable(0), mConsumed(0),
+      mNumAcksToSend(0) {
     mRecBuffer = new ASensorEvent[MAX_RECEIVE_BUFFER_EVENT_COUNT];
 }
 
@@ -66,14 +72,14 @@
         if (err < 0) {
             return err;
         }
-        mAvailable = err;
+        mAvailable = static_cast<size_t>(err);
         mConsumed = 0;
     }
-    size_t count = numEvents < mAvailable ? numEvents : mAvailable;
-    memcpy(events, mRecBuffer + mConsumed, count*sizeof(ASensorEvent));
+    size_t count = min(numEvents, mAvailable);
+    memcpy(events, mRecBuffer + mConsumed, count * sizeof(ASensorEvent));
     mAvailable -= count;
     mConsumed += count;
-    return count;
+    return static_cast<ssize_t>(count);
 }
 
 sp<Looper> SensorEventQueue::getLooper() const
@@ -144,6 +150,42 @@
     return mSensorEventConnection->setEventRate(sensor->getHandle(), ns);
 }
 
+status_t SensorEventQueue::injectSensorEvent(const ASensorEvent& event) {
+    do {
+        // Blocking call.
+        ssize_t size = ::send(mSensorChannel->getFd(), &event, sizeof(event), MSG_NOSIGNAL);
+        if (size >= 0) {
+            return NO_ERROR;
+        } else if (size < 0 && errno == EAGAIN) {
+            // If send is returning a "Try again" error, sleep for 100ms and try again. In all
+            // other cases log a failure and exit.
+            usleep(100000);
+        } else {
+            ALOGE("injectSensorEvent failure %s %zd", strerror(errno), size);
+            return INVALID_OPERATION;
+        }
+    } while (true);
+}
+
+void SensorEventQueue::sendAck(const ASensorEvent* events, int count) {
+    for (int i = 0; i < count; ++i) {
+        if (events[i].flags & WAKE_UP_SENSOR_EVENT_NEEDS_ACK) {
+            ++mNumAcksToSend;
+        }
+    }
+    // Send mNumAcksToSend to acknowledge for the wake up sensor events received.
+    if (mNumAcksToSend > 0) {
+        ssize_t size = ::send(mSensorChannel->getFd(), &mNumAcksToSend, sizeof(mNumAcksToSend),
+                MSG_DONTWAIT | MSG_NOSIGNAL);
+        if (size < 0) {
+            ALOGE("sendAck failure %zd %d", size, mNumAcksToSend);
+        } else {
+            mNumAcksToSend = 0;
+        }
+    }
+    return;
+}
+
 // ----------------------------------------------------------------------------
 }; // namespace android
 
diff --git a/libs/gui/SensorManager.cpp b/libs/gui/SensorManager.cpp
index b80da56..9b9e78f 100644
--- a/libs/gui/SensorManager.cpp
+++ b/libs/gui/SensorManager.cpp
@@ -36,10 +36,60 @@
 namespace android {
 // ----------------------------------------------------------------------------
 
-ANDROID_SINGLETON_STATIC_INSTANCE(SensorManager)
+android::Mutex android::SensorManager::sLock;
+std::map<String16, SensorManager*> android::SensorManager::sPackageInstances;
 
-SensorManager::SensorManager()
-    : mSensorList(0)
+SensorManager& SensorManager::getInstanceForPackage(const String16& packageName) {
+    Mutex::Autolock _l(sLock);
+    SensorManager* sensorManager;
+    std::map<String16, SensorManager*>::iterator iterator =
+        sPackageInstances.find(packageName);
+
+    if (iterator != sPackageInstances.end()) {
+        sensorManager = iterator->second;
+    } else {
+        String16 opPackageName = packageName;
+
+        // It is possible that the calling code has no access to the package name.
+        // In this case we will get the packages for the calling UID and pick the
+        // first one for attributing the app op. This will work correctly for
+        // runtime permissions as for legacy apps we will toggle the app op for
+        // all packages in the UID. The caveat is that the operation may be attributed
+        // to the wrong package and stats based on app ops may be slightly off.
+        if (opPackageName.size() <= 0) {
+            sp<IBinder> binder = defaultServiceManager()->getService(String16("permission"));
+            if (binder != 0) {
+                const uid_t uid = IPCThreadState::self()->getCallingUid();
+                Vector<String16> packages;
+                interface_cast<IPermissionController>(binder)->getPackagesForUid(uid, packages);
+                if (!packages.isEmpty()) {
+                    opPackageName = packages[0];
+                } else {
+                    ALOGE("No packages for calling UID");
+                }
+            } else {
+                ALOGE("Cannot get permission service");
+            }
+        }
+
+        sensorManager = new SensorManager(opPackageName);
+
+        // If we had no package name, we looked it up from the UID and the sensor
+        // manager instance we created should also be mapped to the empty package
+        // name, to avoid looking up the packages for a UID and get the same result.
+        if (packageName.size() <= 0) {
+            sPackageInstances.insert(std::make_pair(String16(), sensorManager));
+        }
+
+        // Stash the per package sensor manager.
+        sPackageInstances.insert(std::make_pair(opPackageName, sensorManager));
+    }
+
+    return *sensorManager;
+}
+
+SensorManager::SensorManager(const String16& opPackageName)
+    : mSensorList(0), mOpPackageName(opPackageName)
 {
     // okay we're not locked here, but it's not needed during construction
     assertStateLocked();
@@ -60,13 +110,23 @@
 }
 
 status_t SensorManager::assertStateLocked() const {
+    bool initSensorManager = false;
     if (mSensorServer == NULL) {
-        // try for one second
+        initSensorManager = true;
+    } else {
+        // Ping binder to check if sensorservice is alive.
+        status_t err = IInterface::asBinder(mSensorServer)->pingBinder();
+        if (err != NO_ERROR) {
+            initSensorManager = true;
+        }
+    }
+    if (initSensorManager) {
+        // try for 300 seconds (60*5(getService() tries for 5 seconds)) before giving up ...
         const String16 name("sensorservice");
-        for (int i=0 ; i<4 ; i++) {
+        for (int i = 0; i < 60; i++) {
             status_t err = getService(name, &mSensorServer);
             if (err == NAME_NOT_FOUND) {
-                usleep(250000);
+                sleep(1);
                 continue;
             }
             if (err != NO_ERROR) {
@@ -82,15 +142,20 @@
                 mSensorManger.sensorManagerDied();
             }
         public:
-            DeathObserver(SensorManager& mgr) : mSensorManger(mgr) { }
+            explicit DeathObserver(SensorManager& mgr) : mSensorManger(mgr) { }
         };
 
-        mDeathObserver = new DeathObserver(*const_cast<SensorManager *>(this));
-        mSensorServer->asBinder()->linkToDeath(mDeathObserver);
+        LOG_ALWAYS_FATAL_IF(mSensorServer.get() == NULL, "getService(SensorService) NULL");
 
-        mSensors = mSensorServer->getSensorList();
+        mDeathObserver = new DeathObserver(*const_cast<SensorManager *>(this));
+        IInterface::asBinder(mSensorServer)->linkToDeath(mDeathObserver);
+
+        mSensors = mSensorServer->getSensorList(mOpPackageName);
         size_t count = mSensors.size();
-        mSensorList = (Sensor const**)malloc(count * sizeof(Sensor*));
+        mSensorList =
+                static_cast<Sensor const**>(malloc(count * sizeof(Sensor*)));
+        LOG_ALWAYS_FATAL_IF(mSensorList == NULL, "mSensorList NULL");
+
         for (size_t i=0 ; i<count ; i++) {
             mSensorList[i] = mSensors.array() + i;
         }
@@ -99,46 +164,54 @@
     return NO_ERROR;
 }
 
-
-
 ssize_t SensorManager::getSensorList(Sensor const* const** list) const
 {
     Mutex::Autolock _l(mLock);
     status_t err = assertStateLocked();
     if (err < 0) {
-        return ssize_t(err);
+        return static_cast<ssize_t>(err);
     }
     *list = mSensorList;
-    return mSensors.size();
+    return static_cast<ssize_t>(mSensors.size());
 }
 
 Sensor const* SensorManager::getDefaultSensor(int type)
 {
     Mutex::Autolock _l(mLock);
     if (assertStateLocked() == NO_ERROR) {
+        bool wakeUpSensor = false;
+        // For the following sensor types, return a wake-up sensor. These types are by default
+        // defined as wake-up sensors. For the rest of the sensor types defined in sensors.h return
+        // a non_wake-up version.
+        if (type == SENSOR_TYPE_PROXIMITY || type == SENSOR_TYPE_SIGNIFICANT_MOTION ||
+            type == SENSOR_TYPE_TILT_DETECTOR || type == SENSOR_TYPE_WAKE_GESTURE ||
+            type == SENSOR_TYPE_GLANCE_GESTURE || type == SENSOR_TYPE_PICK_UP_GESTURE) {
+            wakeUpSensor = true;
+        }
         // For now we just return the first sensor of that type we find.
         // in the future it will make sense to let the SensorService make
         // that decision.
         for (size_t i=0 ; i<mSensors.size() ; i++) {
-            if (mSensorList[i]->getType() == type)
+            if (mSensorList[i]->getType() == type &&
+                mSensorList[i]->isWakeUpSensor() == wakeUpSensor) {
                 return mSensorList[i];
+            }
         }
     }
     return NULL;
 }
 
-sp<SensorEventQueue> SensorManager::createEventQueue()
-{
+sp<SensorEventQueue> SensorManager::createEventQueue(String8 packageName, int mode) {
     sp<SensorEventQueue> queue;
 
     Mutex::Autolock _l(mLock);
     while (assertStateLocked() == NO_ERROR) {
         sp<ISensorEventConnection> connection =
-                mSensorServer->createSensorEventConnection();
+                mSensorServer->createSensorEventConnection(packageName, mode, mOpPackageName);
         if (connection == NULL) {
-            // SensorService just died.
-            ALOGE("createEventQueue: connection is NULL. SensorService died.");
-            continue;
+            // SensorService just died or the app doesn't have required permissions.
+            ALOGE("createEventQueue: connection is NULL.");
+            return NULL;
         }
         queue = new SensorEventQueue(connection);
         break;
@@ -146,5 +219,13 @@
     return queue;
 }
 
+bool SensorManager::isDataInjectionEnabled() {
+    Mutex::Autolock _l(mLock);
+    if (assertStateLocked() == NO_ERROR) {
+        return mSensorServer->isDataInjectionEnabled();
+    }
+    return false;
+}
+
 // ----------------------------------------------------------------------------
 }; // namespace android
diff --git a/libs/gui/StreamSplitter.cpp b/libs/gui/StreamSplitter.cpp
new file mode 100644
index 0000000..43f9214
--- /dev/null
+++ b/libs/gui/StreamSplitter.cpp
@@ -0,0 +1,286 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <inttypes.h>
+
+#define LOG_TAG "StreamSplitter"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+//#define LOG_NDEBUG 0
+
+#include <gui/BufferItem.h>
+#include <gui/IGraphicBufferConsumer.h>
+#include <gui/IGraphicBufferProducer.h>
+#include <gui/StreamSplitter.h>
+
+#include <ui/GraphicBuffer.h>
+
+#include <binder/ProcessState.h>
+
+#include <utils/Trace.h>
+
+namespace android {
+
+status_t StreamSplitter::createSplitter(
+        const sp<IGraphicBufferConsumer>& inputQueue,
+        sp<StreamSplitter>* outSplitter) {
+    if (inputQueue == NULL) {
+        ALOGE("createSplitter: inputQueue must not be NULL");
+        return BAD_VALUE;
+    }
+    if (outSplitter == NULL) {
+        ALOGE("createSplitter: outSplitter must not be NULL");
+        return BAD_VALUE;
+    }
+
+    sp<StreamSplitter> splitter(new StreamSplitter(inputQueue));
+    status_t status = splitter->mInput->consumerConnect(splitter, false);
+    if (status == NO_ERROR) {
+        splitter->mInput->setConsumerName(String8("StreamSplitter"));
+        *outSplitter = splitter;
+    }
+    return status;
+}
+
+StreamSplitter::StreamSplitter(const sp<IGraphicBufferConsumer>& inputQueue)
+      : mIsAbandoned(false), mMutex(), mReleaseCondition(),
+        mOutstandingBuffers(0), mInput(inputQueue), mOutputs(), mBuffers() {}
+
+StreamSplitter::~StreamSplitter() {
+    mInput->consumerDisconnect();
+    Vector<sp<IGraphicBufferProducer> >::iterator output = mOutputs.begin();
+    for (; output != mOutputs.end(); ++output) {
+        (*output)->disconnect(NATIVE_WINDOW_API_CPU);
+    }
+
+    if (mBuffers.size() > 0) {
+        ALOGE("%zu buffers still being tracked", mBuffers.size());
+    }
+}
+
+status_t StreamSplitter::addOutput(
+        const sp<IGraphicBufferProducer>& outputQueue) {
+    if (outputQueue == NULL) {
+        ALOGE("addOutput: outputQueue must not be NULL");
+        return BAD_VALUE;
+    }
+
+    Mutex::Autolock lock(mMutex);
+
+    IGraphicBufferProducer::QueueBufferOutput queueBufferOutput;
+    sp<OutputListener> listener(new OutputListener(this, outputQueue));
+    IInterface::asBinder(outputQueue)->linkToDeath(listener);
+    status_t status = outputQueue->connect(listener, NATIVE_WINDOW_API_CPU,
+            /* producerControlledByApp */ false, &queueBufferOutput);
+    if (status != NO_ERROR) {
+        ALOGE("addOutput: failed to connect (%d)", status);
+        return status;
+    }
+
+    mOutputs.push_back(outputQueue);
+
+    return NO_ERROR;
+}
+
+void StreamSplitter::setName(const String8 &name) {
+    Mutex::Autolock lock(mMutex);
+    mInput->setConsumerName(name);
+}
+
+void StreamSplitter::onFrameAvailable(const BufferItem& /* item */) {
+    ATRACE_CALL();
+    Mutex::Autolock lock(mMutex);
+
+    // The current policy is that if any one consumer is consuming buffers too
+    // slowly, the splitter will stall the rest of the outputs by not acquiring
+    // any more buffers from the input. This will cause back pressure on the
+    // input queue, slowing down its producer.
+
+    // If there are too many outstanding buffers, we block until a buffer is
+    // released back to the input in onBufferReleased
+    while (mOutstandingBuffers >= MAX_OUTSTANDING_BUFFERS) {
+        mReleaseCondition.wait(mMutex);
+
+        // If the splitter is abandoned while we are waiting, the release
+        // condition variable will be broadcast, and we should just return
+        // without attempting to do anything more (since the input queue will
+        // also be abandoned).
+        if (mIsAbandoned) {
+            return;
+        }
+    }
+    ++mOutstandingBuffers;
+
+    // Acquire and detach the buffer from the input
+    BufferItem bufferItem;
+    status_t status = mInput->acquireBuffer(&bufferItem, /* presentWhen */ 0);
+    LOG_ALWAYS_FATAL_IF(status != NO_ERROR,
+            "acquiring buffer from input failed (%d)", status);
+
+    ALOGV("acquired buffer %#" PRIx64 " from input",
+            bufferItem.mGraphicBuffer->getId());
+
+    status = mInput->detachBuffer(bufferItem.mBuf);
+    LOG_ALWAYS_FATAL_IF(status != NO_ERROR,
+            "detaching buffer from input failed (%d)", status);
+
+    // Initialize our reference count for this buffer
+    mBuffers.add(bufferItem.mGraphicBuffer->getId(),
+            new BufferTracker(bufferItem.mGraphicBuffer));
+
+    IGraphicBufferProducer::QueueBufferInput queueInput(
+            bufferItem.mTimestamp, bufferItem.mIsAutoTimestamp,
+            bufferItem.mDataSpace, bufferItem.mCrop,
+            static_cast<int32_t>(bufferItem.mScalingMode),
+            bufferItem.mTransform, bufferItem.mIsDroppable,
+            bufferItem.mFence);
+
+    // Attach and queue the buffer to each of the outputs
+    Vector<sp<IGraphicBufferProducer> >::iterator output = mOutputs.begin();
+    for (; output != mOutputs.end(); ++output) {
+        int slot;
+        status = (*output)->attachBuffer(&slot, bufferItem.mGraphicBuffer);
+        if (status == NO_INIT) {
+            // If we just discovered that this output has been abandoned, note
+            // that, increment the release count so that we still release this
+            // buffer eventually, and move on to the next output
+            onAbandonedLocked();
+            mBuffers.editValueFor(bufferItem.mGraphicBuffer->getId())->
+                    incrementReleaseCountLocked();
+            continue;
+        } else {
+            LOG_ALWAYS_FATAL_IF(status != NO_ERROR,
+                    "attaching buffer to output failed (%d)", status);
+        }
+
+        IGraphicBufferProducer::QueueBufferOutput queueOutput;
+        status = (*output)->queueBuffer(slot, queueInput, &queueOutput);
+        if (status == NO_INIT) {
+            // If we just discovered that this output has been abandoned, note
+            // that, increment the release count so that we still release this
+            // buffer eventually, and move on to the next output
+            onAbandonedLocked();
+            mBuffers.editValueFor(bufferItem.mGraphicBuffer->getId())->
+                    incrementReleaseCountLocked();
+            continue;
+        } else {
+            LOG_ALWAYS_FATAL_IF(status != NO_ERROR,
+                    "queueing buffer to output failed (%d)", status);
+        }
+
+        ALOGV("queued buffer %#" PRIx64 " to output %p",
+                bufferItem.mGraphicBuffer->getId(), output->get());
+    }
+}
+
+void StreamSplitter::onBufferReleasedByOutput(
+        const sp<IGraphicBufferProducer>& from) {
+    ATRACE_CALL();
+    Mutex::Autolock lock(mMutex);
+
+    sp<GraphicBuffer> buffer;
+    sp<Fence> fence;
+    status_t status = from->detachNextBuffer(&buffer, &fence);
+    if (status == NO_INIT) {
+        // If we just discovered that this output has been abandoned, note that,
+        // but we can't do anything else, since buffer is invalid
+        onAbandonedLocked();
+        return;
+    } else {
+        LOG_ALWAYS_FATAL_IF(status != NO_ERROR,
+                "detaching buffer from output failed (%d)", status);
+    }
+
+    ALOGV("detached buffer %#" PRIx64 " from output %p",
+          buffer->getId(), from.get());
+
+    const sp<BufferTracker>& tracker = mBuffers.editValueFor(buffer->getId());
+
+    // Merge the release fence of the incoming buffer so that the fence we send
+    // back to the input includes all of the outputs' fences
+    tracker->mergeFence(fence);
+
+    // Check to see if this is the last outstanding reference to this buffer
+    size_t releaseCount = tracker->incrementReleaseCountLocked();
+    ALOGV("buffer %#" PRIx64 " reference count %zu (of %zu)", buffer->getId(),
+            releaseCount, mOutputs.size());
+    if (releaseCount < mOutputs.size()) {
+        return;
+    }
+
+    // If we've been abandoned, we can't return the buffer to the input, so just
+    // stop tracking it and move on
+    if (mIsAbandoned) {
+        mBuffers.removeItem(buffer->getId());
+        return;
+    }
+
+    // Attach and release the buffer back to the input
+    int consumerSlot;
+    status = mInput->attachBuffer(&consumerSlot, tracker->getBuffer());
+    LOG_ALWAYS_FATAL_IF(status != NO_ERROR,
+            "attaching buffer to input failed (%d)", status);
+
+    status = mInput->releaseBuffer(consumerSlot, /* frameNumber */ 0,
+            EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, tracker->getMergedFence());
+    LOG_ALWAYS_FATAL_IF(status != NO_ERROR,
+            "releasing buffer to input failed (%d)", status);
+
+    ALOGV("released buffer %#" PRIx64 " to input", buffer->getId());
+
+    // We no longer need to track the buffer once it has been returned to the
+    // input
+    mBuffers.removeItem(buffer->getId());
+
+    // Notify any waiting onFrameAvailable calls
+    --mOutstandingBuffers;
+    mReleaseCondition.signal();
+}
+
+void StreamSplitter::onAbandonedLocked() {
+    ALOGE("one of my outputs has abandoned me");
+    if (!mIsAbandoned) {
+        mInput->consumerDisconnect();
+    }
+    mIsAbandoned = true;
+    mReleaseCondition.broadcast();
+}
+
+StreamSplitter::OutputListener::OutputListener(
+        const sp<StreamSplitter>& splitter,
+        const sp<IGraphicBufferProducer>& output)
+      : mSplitter(splitter), mOutput(output) {}
+
+StreamSplitter::OutputListener::~OutputListener() {}
+
+void StreamSplitter::OutputListener::onBufferReleased() {
+    mSplitter->onBufferReleasedByOutput(mOutput);
+}
+
+void StreamSplitter::OutputListener::binderDied(const wp<IBinder>& /* who */) {
+    Mutex::Autolock lock(mSplitter->mMutex);
+    mSplitter->onAbandonedLocked();
+}
+
+StreamSplitter::BufferTracker::BufferTracker(const sp<GraphicBuffer>& buffer)
+      : mBuffer(buffer), mMergedFence(Fence::NO_FENCE), mReleaseCount(0) {}
+
+StreamSplitter::BufferTracker::~BufferTracker() {}
+
+void StreamSplitter::BufferTracker::mergeFence(const sp<Fence>& with) {
+    mMergedFence = Fence::merge(String8("StreamSplitter"), mMergedFence, with);
+}
+
+} // namespace android
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 27dbc4e..4b76f98 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -24,9 +24,12 @@
 
 #include <utils/Log.h>
 #include <utils/Trace.h>
+#include <utils/NativeHandle.h>
 
 #include <ui/Fence.h>
+#include <ui/Region.h>
 
+#include <gui/IProducerListener.h>
 #include <gui/ISurfaceComposer.h>
 #include <gui/SurfaceComposerClient.h>
 #include <gui/GLConsumer.h>
@@ -39,7 +42,8 @@
 Surface::Surface(
         const sp<IGraphicBufferProducer>& bufferProducer,
         bool controlledByApp)
-    : mGraphicBufferProducer(bufferProducer)
+    : mGraphicBufferProducer(bufferProducer),
+      mGenerationNumber(0)
 {
     // Initialize the ANativeWindow function pointers.
     ANativeWindow::setSwapInterval  = hook_setSwapInterval;
@@ -62,9 +66,11 @@
     mReqFormat = 0;
     mReqUsage = 0;
     mTimestamp = NATIVE_WINDOW_TIMESTAMP_AUTO;
+    mDataSpace = HAL_DATASPACE_UNKNOWN;
     mCrop.clear();
     mScalingMode = NATIVE_WINDOW_SCALING_MODE_FREEZE;
     mTransform = 0;
+    mStickyTransform = 0;
     mDefaultWidth = 0;
     mDefaultHeight = 0;
     mUserWidth = 0;
@@ -86,6 +92,29 @@
     return mGraphicBufferProducer;
 }
 
+void Surface::setSidebandStream(const sp<NativeHandle>& stream) {
+    mGraphicBufferProducer->setSidebandStream(stream);
+}
+
+void Surface::allocateBuffers() {
+    uint32_t reqWidth = mReqWidth ? mReqWidth : mUserWidth;
+    uint32_t reqHeight = mReqHeight ? mReqHeight : mUserHeight;
+    mGraphicBufferProducer->allocateBuffers(mSwapIntervalZero, reqWidth,
+            reqHeight, mReqFormat, mReqUsage);
+}
+
+status_t Surface::setGenerationNumber(uint32_t generation) {
+    status_t result = mGraphicBufferProducer->setGenerationNumber(generation);
+    if (result == NO_ERROR) {
+        mGenerationNumber = generation;
+    }
+    return result;
+}
+
+String8 Surface::getConsumerName() const {
+    return mGraphicBufferProducer->getConsumerName();
+}
+
 int Surface::hook_setSwapInterval(ANativeWindow* window, int interval) {
     Surface* c = getSelf(window);
     return c->setSwapInterval(interval);
@@ -178,19 +207,38 @@
 int Surface::dequeueBuffer(android_native_buffer_t** buffer, int* fenceFd) {
     ATRACE_CALL();
     ALOGV("Surface::dequeueBuffer");
-    Mutex::Autolock lock(mMutex);
+
+    uint32_t reqWidth;
+    uint32_t reqHeight;
+    bool swapIntervalZero;
+    PixelFormat reqFormat;
+    uint32_t reqUsage;
+
+    {
+        Mutex::Autolock lock(mMutex);
+
+        reqWidth = mReqWidth ? mReqWidth : mUserWidth;
+        reqHeight = mReqHeight ? mReqHeight : mUserHeight;
+
+        swapIntervalZero = mSwapIntervalZero;
+        reqFormat = mReqFormat;
+        reqUsage = mReqUsage;
+    } // Drop the lock so that we can still touch the Surface while blocking in IGBP::dequeueBuffer
+
     int buf = -1;
-    int reqW = mReqWidth ? mReqWidth : mUserWidth;
-    int reqH = mReqHeight ? mReqHeight : mUserHeight;
     sp<Fence> fence;
-    status_t result = mGraphicBufferProducer->dequeueBuffer(&buf, &fence, mSwapIntervalZero,
-            reqW, reqH, mReqFormat, mReqUsage);
+    status_t result = mGraphicBufferProducer->dequeueBuffer(&buf, &fence, swapIntervalZero,
+            reqWidth, reqHeight, reqFormat, reqUsage);
+
     if (result < 0) {
-        ALOGV("dequeueBuffer: IGraphicBufferProducer::dequeueBuffer(%d, %d, %d, %d)"
-             "failed: %d", mReqWidth, mReqHeight, mReqFormat, mReqUsage,
-             result);
+        ALOGV("dequeueBuffer: IGraphicBufferProducer::dequeueBuffer(%d, %d, %d, %d, %d)"
+             "failed: %d", swapIntervalZero, reqWidth, reqHeight, reqFormat,
+             reqUsage, result);
         return result;
     }
+
+    Mutex::Autolock lock(mMutex);
+
     sp<GraphicBuffer>& gbuf(mSlots[buf].buffer);
 
     // this should never happen
@@ -204,6 +252,7 @@
         result = mGraphicBufferProducer->requestBuffer(buf, &gbuf);
         if (result != NO_ERROR) {
             ALOGE("dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: %d", result);
+            mGraphicBufferProducer->cancelBuffer(buf, fence);
             return result;
         }
     }
@@ -231,6 +280,9 @@
     Mutex::Autolock lock(mMutex);
     int i = getSlotFromBufferLocked(buffer);
     if (i < 0) {
+        if (fenceFd >= 0) {
+            close(fenceFd);
+        }
         return i;
     }
     sp<Fence> fence(fenceFd >= 0 ? new Fence(fenceFd) : Fence::NO_FENCE);
@@ -240,7 +292,6 @@
 
 int Surface::getSlotFromBufferLocked(
         android_native_buffer_t* buffer) const {
-    bool dumpedState = false;
     for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
         if (mSlots[i].buffer != NULL &&
                 mSlots[i].buffer->handle == buffer->handle) {
@@ -251,7 +302,7 @@
     return BAD_VALUE;
 }
 
-int Surface::lockBuffer_DEPRECATED(android_native_buffer_t* buffer) {
+int Surface::lockBuffer_DEPRECATED(android_native_buffer_t* buffer __attribute__((unused))) {
     ALOGV("Surface::lockBuffer");
     Mutex::Autolock lock(mMutex);
     return OK;
@@ -273,6 +324,9 @@
     }
     int i = getSlotFromBufferLocked(buffer);
     if (i < 0) {
+        if (fenceFd >= 0) {
+            close(fenceFd);
+        }
         return i;
     }
 
@@ -284,17 +338,93 @@
     sp<Fence> fence(fenceFd >= 0 ? new Fence(fenceFd) : Fence::NO_FENCE);
     IGraphicBufferProducer::QueueBufferOutput output;
     IGraphicBufferProducer::QueueBufferInput input(timestamp, isAutoTimestamp,
-            crop, mScalingMode, mTransform, mSwapIntervalZero, fence);
+            mDataSpace, crop, mScalingMode, mTransform ^ mStickyTransform,
+            mSwapIntervalZero, fence, mStickyTransform);
+
+    if (mConnectedToCpu || mDirtyRegion.bounds() == Rect::INVALID_RECT) {
+        input.setSurfaceDamage(Region::INVALID_REGION);
+    } else {
+        // Here we do two things:
+        // 1) The surface damage was specified using the OpenGL ES convention of
+        //    the origin being in the bottom-left corner. Here we flip to the
+        //    convention that the rest of the system uses (top-left corner) by
+        //    subtracting all top/bottom coordinates from the buffer height.
+        // 2) If the buffer is coming in rotated (for example, because the EGL
+        //    implementation is reacting to the transform hint coming back from
+        //    SurfaceFlinger), the surface damage needs to be rotated the
+        //    opposite direction, since it was generated assuming an unrotated
+        //    buffer (the app doesn't know that the EGL implementation is
+        //    reacting to the transform hint behind its back). The
+        //    transformations in the switch statement below apply those
+        //    complementary rotations (e.g., if 90 degrees, rotate 270 degrees).
+
+        int width = buffer->width;
+        int height = buffer->height;
+        bool rotated90 = (mTransform ^ mStickyTransform) &
+                NATIVE_WINDOW_TRANSFORM_ROT_90;
+        if (rotated90) {
+            std::swap(width, height);
+        }
+
+        Region flippedRegion;
+        for (auto rect : mDirtyRegion) {
+            int left = rect.left;
+            int right = rect.right;
+            int top = height - rect.bottom; // Flip from OpenGL convention
+            int bottom = height - rect.top; // Flip from OpenGL convention
+            switch (mTransform ^ mStickyTransform) {
+                case NATIVE_WINDOW_TRANSFORM_ROT_90: {
+                    // Rotate 270 degrees
+                    Rect flippedRect{top, width - right, bottom, width - left};
+                    flippedRegion.orSelf(flippedRect);
+                    break;
+                }
+                case NATIVE_WINDOW_TRANSFORM_ROT_180: {
+                    // Rotate 180 degrees
+                    Rect flippedRect{width - right, height - bottom,
+                            width - left, height - top};
+                    flippedRegion.orSelf(flippedRect);
+                    break;
+                }
+                case NATIVE_WINDOW_TRANSFORM_ROT_270: {
+                    // Rotate 90 degrees
+                    Rect flippedRect{height - bottom, left,
+                            height - top, right};
+                    flippedRegion.orSelf(flippedRect);
+                    break;
+                }
+                default: {
+                    Rect flippedRect{left, top, right, bottom};
+                    flippedRegion.orSelf(flippedRect);
+                    break;
+                }
+            }
+        }
+
+        input.setSurfaceDamage(flippedRegion);
+    }
+
     status_t err = mGraphicBufferProducer->queueBuffer(i, input, &output);
     if (err != OK)  {
         ALOGE("queueBuffer: error queuing buffer to SurfaceTexture, %d", err);
     }
     uint32_t numPendingBuffers = 0;
-    output.deflate(&mDefaultWidth, &mDefaultHeight, &mTransformHint,
+    uint32_t hint = 0;
+    output.deflate(&mDefaultWidth, &mDefaultHeight, &hint,
             &numPendingBuffers);
 
+    // Disable transform hint if sticky transform is set.
+    if (mStickyTransform == 0) {
+        mTransformHint = hint;
+    }
+
     mConsumerRunningBehind = (numPendingBuffers >= 2);
 
+    if (!mConnectedToCpu) {
+        // Clear surface damage back to full-buffer
+        mDirtyRegion = Region::INVALID_REGION;
+    }
+
     return err;
 }
 
@@ -306,7 +436,7 @@
         switch (what) {
             case NATIVE_WINDOW_FORMAT:
                 if (mReqFormat) {
-                    *value = mReqFormat;
+                    *value = static_cast<int>(mReqFormat);
                     return NO_ERROR;
                 }
                 break;
@@ -324,13 +454,15 @@
                 *value = NATIVE_WINDOW_SURFACE;
                 return NO_ERROR;
             case NATIVE_WINDOW_DEFAULT_WIDTH:
-                *value = mUserWidth ? mUserWidth : mDefaultWidth;
+                *value = static_cast<int>(
+                        mUserWidth ? mUserWidth : mDefaultWidth);
                 return NO_ERROR;
             case NATIVE_WINDOW_DEFAULT_HEIGHT:
-                *value = mUserHeight ? mUserHeight : mDefaultHeight;
+                *value = static_cast<int>(
+                        mUserHeight ? mUserHeight : mDefaultHeight);
                 return NO_ERROR;
             case NATIVE_WINDOW_TRANSFORM_HINT:
-                *value = mTransformHint;
+                *value = static_cast<int>(mTransformHint);
                 return NO_ERROR;
             case NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND: {
                 status_t err = NO_ERROR;
@@ -374,6 +506,9 @@
     case NATIVE_WINDOW_SET_BUFFERS_TRANSFORM:
         res = dispatchSetBuffersTransform(args);
         break;
+    case NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM:
+        res = dispatchSetBuffersStickyTransform(args);
+        break;
     case NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP:
         res = dispatchSetBuffersTimestamp(args);
         break;
@@ -401,6 +536,15 @@
     case NATIVE_WINDOW_API_DISCONNECT:
         res = dispatchDisconnect(args);
         break;
+    case NATIVE_WINDOW_SET_SIDEBAND_STREAM:
+        res = dispatchSetSidebandStream(args);
+        break;
+    case NATIVE_WINDOW_SET_BUFFERS_DATASPACE:
+        res = dispatchSetBuffersDataSpace(args);
+        break;
+    case NATIVE_WINDOW_SET_SURFACE_DAMAGE:
+        res = dispatchSetSurfaceDamage(args);
+        break;
     default:
         res = NAME_NOT_FOUND;
         break;
@@ -420,7 +564,7 @@
 
 int Surface::dispatchSetUsage(va_list args) {
     int usage = va_arg(args, int);
-    return setUsage(usage);
+    return setUsage(static_cast<uint32_t>(usage));
 }
 
 int Surface::dispatchSetCrop(va_list args) {
@@ -430,47 +574,52 @@
 
 int Surface::dispatchSetBufferCount(va_list args) {
     size_t bufferCount = va_arg(args, size_t);
-    return setBufferCount(bufferCount);
+    return setBufferCount(static_cast<int32_t>(bufferCount));
 }
 
 int Surface::dispatchSetBuffersGeometry(va_list args) {
-    int w = va_arg(args, int);
-    int h = va_arg(args, int);
-    int f = va_arg(args, int);
-    int err = setBuffersDimensions(w, h);
+    uint32_t width = va_arg(args, uint32_t);
+    uint32_t height = va_arg(args, uint32_t);
+    PixelFormat format = va_arg(args, PixelFormat);
+    int err = setBuffersDimensions(width, height);
     if (err != 0) {
         return err;
     }
-    return setBuffersFormat(f);
+    return setBuffersFormat(format);
 }
 
 int Surface::dispatchSetBuffersDimensions(va_list args) {
-    int w = va_arg(args, int);
-    int h = va_arg(args, int);
-    return setBuffersDimensions(w, h);
+    uint32_t width = va_arg(args, uint32_t);
+    uint32_t height = va_arg(args, uint32_t);
+    return setBuffersDimensions(width, height);
 }
 
 int Surface::dispatchSetBuffersUserDimensions(va_list args) {
-    int w = va_arg(args, int);
-    int h = va_arg(args, int);
-    return setBuffersUserDimensions(w, h);
+    uint32_t width = va_arg(args, uint32_t);
+    uint32_t height = va_arg(args, uint32_t);
+    return setBuffersUserDimensions(width, height);
 }
 
 int Surface::dispatchSetBuffersFormat(va_list args) {
-    int f = va_arg(args, int);
-    return setBuffersFormat(f);
+    PixelFormat format = va_arg(args, PixelFormat);
+    return setBuffersFormat(format);
 }
 
 int Surface::dispatchSetScalingMode(va_list args) {
-    int m = va_arg(args, int);
-    return setScalingMode(m);
+    int mode = va_arg(args, int);
+    return setScalingMode(mode);
 }
 
 int Surface::dispatchSetBuffersTransform(va_list args) {
-    int transform = va_arg(args, int);
+    uint32_t transform = va_arg(args, uint32_t);
     return setBuffersTransform(transform);
 }
 
+int Surface::dispatchSetBuffersStickyTransform(va_list args) {
+    uint32_t transform = va_arg(args, uint32_t);
+    return setBuffersStickyTransform(transform);
+}
+
 int Surface::dispatchSetBuffersTimestamp(va_list args) {
     int64_t timestamp = va_arg(args, int64_t);
     return setBuffersTimestamp(timestamp);
@@ -482,27 +631,63 @@
     return lock(outBuffer, inOutDirtyBounds);
 }
 
-int Surface::dispatchUnlockAndPost(va_list args) {
+int Surface::dispatchUnlockAndPost(va_list args __attribute__((unused))) {
     return unlockAndPost();
 }
 
+int Surface::dispatchSetSidebandStream(va_list args) {
+    native_handle_t* sH = va_arg(args, native_handle_t*);
+    sp<NativeHandle> sidebandHandle = NativeHandle::create(sH, false);
+    setSidebandStream(sidebandHandle);
+    return OK;
+}
+
+int Surface::dispatchSetBuffersDataSpace(va_list args) {
+    android_dataspace dataspace =
+            static_cast<android_dataspace>(va_arg(args, int));
+    return setBuffersDataSpace(dataspace);
+}
+
+int Surface::dispatchSetSurfaceDamage(va_list args) {
+    android_native_rect_t* rects = va_arg(args, android_native_rect_t*);
+    size_t numRects = va_arg(args, size_t);
+    setSurfaceDamage(rects, numRects);
+    return NO_ERROR;
+}
 
 int Surface::connect(int api) {
+    static sp<IProducerListener> listener = new DummyProducerListener();
+    return connect(api, listener);
+}
+
+int Surface::connect(int api, const sp<IProducerListener>& listener) {
     ATRACE_CALL();
     ALOGV("Surface::connect");
-    static sp<BBinder> sLife = new BBinder();
     Mutex::Autolock lock(mMutex);
     IGraphicBufferProducer::QueueBufferOutput output;
-    int err = mGraphicBufferProducer->connect(sLife, api, mProducerControlledByApp, &output);
+    int err = mGraphicBufferProducer->connect(listener, api, mProducerControlledByApp, &output);
     if (err == NO_ERROR) {
         uint32_t numPendingBuffers = 0;
-        output.deflate(&mDefaultWidth, &mDefaultHeight, &mTransformHint,
+        uint32_t hint = 0;
+        output.deflate(&mDefaultWidth, &mDefaultHeight, &hint,
                 &numPendingBuffers);
+
+        // Disable transform hint if sticky transform is set.
+        if (mStickyTransform == 0) {
+            mTransformHint = hint;
+        }
+
         mConsumerRunningBehind = (numPendingBuffers >= 2);
     }
     if (!err && api == NATIVE_WINDOW_API_CPU) {
         mConnectedToCpu = true;
+        // Clear the dirty region in case we're switching from a non-CPU API
+        mDirtyRegion.clear();
+    } else if (!err) {
+        // Initialize the dirty region for tracking surface damage
+        mDirtyRegion = Region::INVALID_REGION;
     }
+
     return err;
 }
 
@@ -521,6 +706,8 @@
         mCrop.clear();
         mScalingMode = NATIVE_WINDOW_SCALING_MODE_FREEZE;
         mTransform = 0;
+        mStickyTransform = 0;
+
         if (api == NATIVE_WINDOW_API_CPU) {
             mConnectedToCpu = false;
         }
@@ -528,6 +715,58 @@
     return err;
 }
 
+int Surface::detachNextBuffer(sp<GraphicBuffer>* outBuffer,
+        sp<Fence>* outFence) {
+    ATRACE_CALL();
+    ALOGV("Surface::detachNextBuffer");
+
+    if (outBuffer == NULL || outFence == NULL) {
+        return BAD_VALUE;
+    }
+
+    Mutex::Autolock lock(mMutex);
+
+    sp<GraphicBuffer> buffer(NULL);
+    sp<Fence> fence(NULL);
+    status_t result = mGraphicBufferProducer->detachNextBuffer(
+            &buffer, &fence);
+    if (result != NO_ERROR) {
+        return result;
+    }
+
+    *outBuffer = buffer;
+    if (fence != NULL && fence->isValid()) {
+        *outFence = fence;
+    } else {
+        *outFence = Fence::NO_FENCE;
+    }
+
+    return NO_ERROR;
+}
+
+int Surface::attachBuffer(ANativeWindowBuffer* buffer)
+{
+    ATRACE_CALL();
+    ALOGV("Surface::attachBuffer");
+
+    Mutex::Autolock lock(mMutex);
+
+    sp<GraphicBuffer> graphicBuffer(static_cast<GraphicBuffer*>(buffer));
+    uint32_t priorGeneration = graphicBuffer->mGenerationNumber;
+    graphicBuffer->mGenerationNumber = mGenerationNumber;
+    int32_t attachedSlot = -1;
+    status_t result = mGraphicBufferProducer->attachBuffer(
+            &attachedSlot, graphicBuffer);
+    if (result != NO_ERROR) {
+        ALOGE("attachBuffer: IGraphicBufferProducer call failed (%d)", result);
+        graphicBuffer->mGenerationNumber = priorGeneration;
+        return result;
+    }
+    mSlots[attachedSlot].buffer = graphicBuffer;
+
+    return NO_ERROR;
+}
+
 int Surface::setUsage(uint32_t reqUsage)
 {
     ALOGV("Surface::setUsage");
@@ -572,47 +811,38 @@
     return err;
 }
 
-int Surface::setBuffersDimensions(int w, int h)
+int Surface::setBuffersDimensions(uint32_t width, uint32_t height)
 {
     ATRACE_CALL();
     ALOGV("Surface::setBuffersDimensions");
 
-    if (w<0 || h<0)
-        return BAD_VALUE;
-
-    if ((w && !h) || (!w && h))
+    if ((width && !height) || (!width && height))
         return BAD_VALUE;
 
     Mutex::Autolock lock(mMutex);
-    mReqWidth = w;
-    mReqHeight = h;
+    mReqWidth = width;
+    mReqHeight = height;
     return NO_ERROR;
 }
 
-int Surface::setBuffersUserDimensions(int w, int h)
+int Surface::setBuffersUserDimensions(uint32_t width, uint32_t height)
 {
     ATRACE_CALL();
     ALOGV("Surface::setBuffersUserDimensions");
 
-    if (w<0 || h<0)
-        return BAD_VALUE;
-
-    if ((w && !h) || (!w && h))
+    if ((width && !height) || (!width && height))
         return BAD_VALUE;
 
     Mutex::Autolock lock(mMutex);
-    mUserWidth = w;
-    mUserHeight = h;
+    mUserWidth = width;
+    mUserHeight = height;
     return NO_ERROR;
 }
 
-int Surface::setBuffersFormat(int format)
+int Surface::setBuffersFormat(PixelFormat format)
 {
     ALOGV("Surface::setBuffersFormat");
 
-    if (format<0)
-        return BAD_VALUE;
-
     Mutex::Autolock lock(mMutex);
     mReqFormat = format;
     return NO_ERROR;
@@ -638,7 +868,7 @@
     return NO_ERROR;
 }
 
-int Surface::setBuffersTransform(int transform)
+int Surface::setBuffersTransform(uint32_t transform)
 {
     ATRACE_CALL();
     ALOGV("Surface::setBuffersTransform");
@@ -647,6 +877,15 @@
     return NO_ERROR;
 }
 
+int Surface::setBuffersStickyTransform(uint32_t transform)
+{
+    ATRACE_CALL();
+    ALOGV("Surface::setBuffersStickyTransform");
+    Mutex::Autolock lock(mMutex);
+    mStickyTransform = transform;
+    return NO_ERROR;
+}
+
 int Surface::setBuffersTimestamp(int64_t timestamp)
 {
     ALOGV("Surface::setBuffersTimestamp");
@@ -655,12 +894,41 @@
     return NO_ERROR;
 }
 
+int Surface::setBuffersDataSpace(android_dataspace dataSpace)
+{
+    ALOGV("Surface::setBuffersDataSpace");
+    Mutex::Autolock lock(mMutex);
+    mDataSpace = dataSpace;
+    return NO_ERROR;
+}
+
 void Surface::freeAllBuffers() {
     for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
         mSlots[i].buffer = 0;
     }
 }
 
+void Surface::setSurfaceDamage(android_native_rect_t* rects, size_t numRects) {
+    ATRACE_CALL();
+    ALOGV("Surface::setSurfaceDamage");
+    Mutex::Autolock lock(mMutex);
+
+    if (mConnectedToCpu || numRects == 0) {
+        mDirtyRegion = Region::INVALID_REGION;
+        return;
+    }
+
+    mDirtyRegion.clear();
+    for (size_t r = 0; r < numRects; ++r) {
+        // We intentionally flip top and bottom here, since because they're
+        // specified with a bottom-left origin, top > bottom, which fails
+        // validation in the Region class. We will fix this up when we flip to a
+        // top-left origin in queueBuffer.
+        Rect rect(rects[r].left, rects[r].bottom, rects[r].right, rects[r].top);
+        mDirtyRegion.orSelf(rect);
+    }
+}
+
 // ----------------------------------------------------------------------
 // the lock/unlock APIs must be used from the same thread
 
@@ -672,30 +940,34 @@
     // src and dst with, height and format must be identical. no verification
     // is done here.
     status_t err;
-    uint8_t const * src_bits = NULL;
-    err = src->lock(GRALLOC_USAGE_SW_READ_OFTEN, reg.bounds(), (void**)&src_bits);
+    uint8_t* src_bits = NULL;
+    err = src->lock(GRALLOC_USAGE_SW_READ_OFTEN, reg.bounds(),
+            reinterpret_cast<void**>(&src_bits));
     ALOGE_IF(err, "error locking src buffer %s", strerror(-err));
 
     uint8_t* dst_bits = NULL;
-    err = dst->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, reg.bounds(), (void**)&dst_bits);
+    err = dst->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, reg.bounds(),
+            reinterpret_cast<void**>(&dst_bits));
     ALOGE_IF(err, "error locking dst buffer %s", strerror(-err));
 
     Region::const_iterator head(reg.begin());
     Region::const_iterator tail(reg.end());
     if (head != tail && src_bits && dst_bits) {
         const size_t bpp = bytesPerPixel(src->format);
-        const size_t dbpr = dst->stride * bpp;
-        const size_t sbpr = src->stride * bpp;
+        const size_t dbpr = static_cast<uint32_t>(dst->stride) * bpp;
+        const size_t sbpr = static_cast<uint32_t>(src->stride) * bpp;
 
         while (head != tail) {
             const Rect& r(*head++);
-            ssize_t h = r.height();
+            int32_t h = r.height();
             if (h <= 0) continue;
-            size_t size = r.width() * bpp;
-            uint8_t const * s = src_bits + (r.left + src->stride * r.top) * bpp;
-            uint8_t       * d = dst_bits + (r.left + dst->stride * r.top) * bpp;
+            size_t size = static_cast<uint32_t>(r.width()) * bpp;
+            uint8_t const * s = src_bits +
+                    static_cast<uint32_t>(r.left + src->stride * r.top) * bpp;
+            uint8_t       * d = dst_bits +
+                    static_cast<uint32_t>(r.left + dst->stride * r.top) * bpp;
             if (dbpr==sbpr && size==sbpr) {
-                size *= h;
+                size *= static_cast<size_t>(h);
                 h = 1;
             }
             do {
@@ -740,15 +1012,6 @@
     ALOGE_IF(err, "dequeueBuffer failed (%s)", strerror(-err));
     if (err == NO_ERROR) {
         sp<GraphicBuffer> backBuffer(GraphicBuffer::getSelf(out));
-        sp<Fence> fence(new Fence(fenceFd));
-
-        err = fence->waitForever("Surface::lock");
-        if (err != OK) {
-            ALOGE("Fence::wait failed (%s)", strerror(-err));
-            cancelBuffer(out, fenceFd);
-            return err;
-        }
-
         const Rect bounds(backBuffer->width, backBuffer->height);
 
         Region newDirtyRegion;
@@ -799,9 +1062,9 @@
         }
 
         void* vaddr;
-        status_t res = backBuffer->lock(
+        status_t res = backBuffer->lockAsync(
                 GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN,
-                newDirtyRegion.bounds(), &vaddr);
+                newDirtyRegion.bounds(), &vaddr, fenceFd);
 
         ALOGW_IF(res, "failed locking buffer (handle = %p)",
                 backBuffer->handle);
@@ -827,10 +1090,11 @@
         return INVALID_OPERATION;
     }
 
-    status_t err = mLockedBuffer->unlock();
+    int fd = -1;
+    status_t err = mLockedBuffer->unlockAsync(&fd);
     ALOGE_IF(err, "failed unlocking buffer (%p)", mLockedBuffer->handle);
 
-    err = queueBuffer(mLockedBuffer.get(), -1);
+    err = queueBuffer(mLockedBuffer.get(), fd);
     ALOGE_IF(err, "queueBuffer (handle=%p) failed (%s)",
             mLockedBuffer->handle, strerror(-err));
 
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index aafc4d2..5863798 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -67,11 +67,11 @@
             mComposerService.composerServiceDied();
         }
      public:
-        DeathObserver(ComposerService& mgr) : mComposerService(mgr) { }
+        explicit DeathObserver(ComposerService& mgr) : mComposerService(mgr) { }
     };
 
     mDeathObserver = new DeathObserver(*const_cast<ComposerService*>(this));
-    mComposerService->asBinder()->linkToDeath(mDeathObserver);
+    IInterface::asBinder(mComposerService)->linkToDeath(mDeathObserver);
 }
 
 /*static*/ sp<ISurfaceComposer> ComposerService::getComposerService() {
@@ -143,7 +143,7 @@
     status_t setSize(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
             uint32_t w, uint32_t h);
     status_t setLayer(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
-            int32_t z);
+            uint32_t z);
     status_t setFlags(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
             uint32_t flags, uint32_t mask);
     status_t setTransparentRegionHint(
@@ -166,6 +166,7 @@
             uint32_t orientation,
             const Rect& layerStackRect,
             const Rect& displayRect);
+    void setDisplaySize(const sp<IBinder>& token, uint32_t width, uint32_t height);
 
     static void setAnimationTransaction() {
         Composer::getInstance().setAnimationTransactionImpl();
@@ -292,7 +293,7 @@
 }
 
 status_t Composer::setLayer(const sp<SurfaceComposerClient>& client,
-        const sp<IBinder>& id, int32_t z) {
+        const sp<IBinder>& id, uint32_t z) {
     Mutex::Autolock _l(mLock);
     layer_state_t* s = getLayerStateLocked(client, id);
     if (!s)
@@ -309,7 +310,11 @@
     layer_state_t* s = getLayerStateLocked(client, id);
     if (!s)
         return BAD_INDEX;
-    s->what |= layer_state_t::eVisibilityChanged;
+    if (mask & layer_state_t::eLayerOpaque ||
+            mask & layer_state_t::eLayerHidden ||
+            mask & layer_state_t::eLayerSecure) {
+        s->what |= layer_state_t::eFlagsChanged;
+    }
     s->flags &= ~mask;
     s->flags |= (flags & mask);
     s->mask |= mask;
@@ -389,7 +394,7 @@
         s.what = 0;
         index = mDisplayStates.add(s);
     }
-    return mDisplayStates.editItemAt(index);
+    return mDisplayStates.editItemAt(static_cast<size_t>(index));
 }
 
 void Composer::setDisplaySurface(const sp<IBinder>& token,
@@ -421,6 +426,14 @@
     mForceSynchronous = true; // TODO: do we actually still need this?
 }
 
+void Composer::setDisplaySize(const sp<IBinder>& token, uint32_t width, uint32_t height) {
+    Mutex::Autolock _l(mLock);
+    DisplayState& s(getDisplayStateLocked(token));
+    s.width = width;
+    s.height = height;
+    s.what |= DisplayState::eDisplaySizeChanged;
+}
+
 // ---------------------------------------------------------------------------
 
 SurfaceComposerClient::SurfaceComposerClient()
@@ -448,14 +461,14 @@
 }
 
 sp<IBinder> SurfaceComposerClient::connection() const {
-    return (mClient != 0) ? mClient->asBinder() : 0;
+    return IInterface::asBinder(mClient);
 }
 
 status_t SurfaceComposerClient::linkToComposerDeath(
         const sp<IBinder::DeathRecipient>& recipient,
         void* cookie, uint32_t flags) {
     sp<ISurfaceComposer> sm(ComposerService::getComposerService());
-    return sm->asBinder()->linkToDeath(recipient, cookie, flags);
+    return IInterface::asBinder(sm)->linkToDeath(recipient, cookie, flags);
 }
 
 void SurfaceComposerClient::dispose() {
@@ -510,6 +523,21 @@
     return err;
 }
 
+status_t SurfaceComposerClient::clearLayerFrameStats(const sp<IBinder>& token) const {
+    if (mStatus != NO_ERROR) {
+        return mStatus;
+    }
+    return mClient->clearLayerFrameStats(token);
+}
+
+status_t SurfaceComposerClient::getLayerFrameStats(const sp<IBinder>& token,
+        FrameStats* outStats) const {
+    if (mStatus != NO_ERROR) {
+        return mStatus;
+    }
+    return mClient->getLayerFrameStats(token, outStats);
+}
+
 inline Composer& SurfaceComposerClient::getComposer() {
     return mComposer;
 }
@@ -542,7 +570,7 @@
     return getComposer().setSize(this, id, w, h);
 }
 
-status_t SurfaceComposerClient::setLayer(const sp<IBinder>& id, int32_t z) {
+status_t SurfaceComposerClient::setLayer(const sp<IBinder>& id, uint32_t z) {
     return getComposer().setLayer(this, id, z);
 }
 
@@ -601,20 +629,56 @@
             layerStackRect, displayRect);
 }
 
+void SurfaceComposerClient::setDisplaySize(const sp<IBinder>& token,
+        uint32_t width, uint32_t height) {
+    Composer::getInstance().setDisplaySize(token, width, height);
+}
+
 // ----------------------------------------------------------------------------
 
-status_t SurfaceComposerClient::getDisplayInfo(
-        const sp<IBinder>& display, DisplayInfo* info)
+status_t SurfaceComposerClient::getDisplayConfigs(
+        const sp<IBinder>& display, Vector<DisplayInfo>* configs)
 {
-    return ComposerService::getComposerService()->getDisplayInfo(display, info);
+    return ComposerService::getComposerService()->getDisplayConfigs(display, configs);
 }
 
-void SurfaceComposerClient::blankDisplay(const sp<IBinder>& token) {
-    ComposerService::getComposerService()->blank(token);
+status_t SurfaceComposerClient::getDisplayInfo(const sp<IBinder>& display,
+        DisplayInfo* info) {
+    Vector<DisplayInfo> configs;
+    status_t result = getDisplayConfigs(display, &configs);
+    if (result != NO_ERROR) {
+        return result;
+    }
+
+    int activeId = getActiveConfig(display);
+    if (activeId < 0) {
+        ALOGE("No active configuration found");
+        return NAME_NOT_FOUND;
+    }
+
+    *info = configs[static_cast<size_t>(activeId)];
+    return NO_ERROR;
 }
 
-void SurfaceComposerClient::unblankDisplay(const sp<IBinder>& token) {
-    ComposerService::getComposerService()->unblank(token);
+int SurfaceComposerClient::getActiveConfig(const sp<IBinder>& display) {
+    return ComposerService::getComposerService()->getActiveConfig(display);
+}
+
+status_t SurfaceComposerClient::setActiveConfig(const sp<IBinder>& display, int id) {
+    return ComposerService::getComposerService()->setActiveConfig(display, id);
+}
+
+void SurfaceComposerClient::setDisplayPowerMode(const sp<IBinder>& token,
+        int mode) {
+    ComposerService::getComposerService()->setPowerMode(token, mode);
+}
+
+status_t SurfaceComposerClient::clearAnimationFrameStats() {
+    return ComposerService::getComposerService()->clearAnimationFrameStats();
+}
+
+status_t SurfaceComposerClient::getAnimationFrameStats(FrameStats* outStats) {
+    return ComposerService::getComposerService()->getAnimationFrameStats(outStats);
 }
 
 // ----------------------------------------------------------------------------
@@ -622,12 +686,12 @@
 status_t ScreenshotClient::capture(
         const sp<IBinder>& display,
         const sp<IGraphicBufferProducer>& producer,
-        uint32_t reqWidth, uint32_t reqHeight,
-        uint32_t minLayerZ, uint32_t maxLayerZ) {
+        Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
+        uint32_t minLayerZ, uint32_t maxLayerZ, bool useIdentityTransform) {
     sp<ISurfaceComposer> s(ComposerService::getComposerService());
     if (s == NULL) return NO_INIT;
-    return s->captureScreen(display, producer,
-            reqWidth, reqHeight, minLayerZ, maxLayerZ);
+    return s->captureScreen(display, producer, sourceCrop,
+            reqWidth, reqHeight, minLayerZ, maxLayerZ, useIdentityTransform);
 }
 
 ScreenshotClient::ScreenshotClient()
@@ -641,16 +705,18 @@
 
 sp<CpuConsumer> ScreenshotClient::getCpuConsumer() const {
     if (mCpuConsumer == NULL) {
-        mBufferQueue = new BufferQueue();
-        mCpuConsumer = new CpuConsumer(mBufferQueue, 1);
+        sp<IGraphicBufferConsumer> consumer;
+        BufferQueue::createBufferQueue(&mProducer, &consumer);
+        mCpuConsumer = new CpuConsumer(consumer, 1);
         mCpuConsumer->setName(String8("ScreenshotClient"));
     }
     return mCpuConsumer;
 }
 
 status_t ScreenshotClient::update(const sp<IBinder>& display,
-        uint32_t reqWidth, uint32_t reqHeight,
-        uint32_t minLayerZ, uint32_t maxLayerZ) {
+        Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
+        uint32_t minLayerZ, uint32_t maxLayerZ,
+        bool useIdentityTransform, uint32_t rotation) {
     sp<ISurfaceComposer> s(ComposerService::getComposerService());
     if (s == NULL) return NO_INIT;
     sp<CpuConsumer> cpuConsumer = getCpuConsumer();
@@ -661,8 +727,9 @@
         mHaveBuffer = false;
     }
 
-    status_t err = s->captureScreen(display, mBufferQueue,
-            reqWidth, reqHeight, minLayerZ, maxLayerZ);
+    status_t err = s->captureScreen(display, mProducer, sourceCrop,
+            reqWidth, reqHeight, minLayerZ, maxLayerZ, useIdentityTransform,
+            static_cast<ISurfaceComposer::Rotation>(rotation));
 
     if (err == NO_ERROR) {
         err = mCpuConsumer->lockNextBuffer(&mBuffer);
@@ -673,13 +740,25 @@
     return err;
 }
 
-status_t ScreenshotClient::update(const sp<IBinder>& display) {
-    return ScreenshotClient::update(display, 0, 0, 0, -1UL);
+status_t ScreenshotClient::update(const sp<IBinder>& display,
+        Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
+        uint32_t minLayerZ, uint32_t maxLayerZ,
+        bool useIdentityTransform) {
+
+    return ScreenshotClient::update(display, sourceCrop, reqWidth, reqHeight,
+            minLayerZ, maxLayerZ, useIdentityTransform, ISurfaceComposer::eRotateNone);
 }
 
-status_t ScreenshotClient::update(const sp<IBinder>& display,
-        uint32_t reqWidth, uint32_t reqHeight) {
-    return ScreenshotClient::update(display, reqWidth, reqHeight, 0, -1UL);
+status_t ScreenshotClient::update(const sp<IBinder>& display, Rect sourceCrop,
+        bool useIdentityTransform) {
+    return ScreenshotClient::update(display, sourceCrop, 0, 0, 0, -1U,
+            useIdentityTransform, ISurfaceComposer::eRotateNone);
+}
+
+status_t ScreenshotClient::update(const sp<IBinder>& display, Rect sourceCrop,
+        uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform) {
+    return ScreenshotClient::update(display, sourceCrop, reqWidth, reqHeight,
+            0, -1U, useIdentityTransform, ISurfaceComposer::eRotateNone);
 }
 
 void ScreenshotClient::release() {
diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp
index 16e533c..1983027 100644
--- a/libs/gui/SurfaceControl.cpp
+++ b/libs/gui/SurfaceControl.cpp
@@ -23,7 +23,6 @@
 
 #include <android/native_window.h>
 
-#include <utils/CallStack.h>
 #include <utils/Errors.h>
 #include <utils/Log.h>
 #include <utils/threads.h>
@@ -90,71 +89,74 @@
     return lhs->mHandle == rhs->mHandle;
 }
 
-status_t SurfaceControl::setLayerStack(int32_t layerStack) {
+status_t SurfaceControl::setLayerStack(uint32_t layerStack) {
     status_t err = validate();
     if (err < 0) return err;
-    const sp<SurfaceComposerClient>& client(mClient);
-    return client->setLayerStack(mHandle, layerStack);
+    return mClient->setLayerStack(mHandle, layerStack);
 }
-status_t SurfaceControl::setLayer(int32_t layer) {
+status_t SurfaceControl::setLayer(uint32_t layer) {
     status_t err = validate();
     if (err < 0) return err;
-    const sp<SurfaceComposerClient>& client(mClient);
-    return client->setLayer(mHandle, layer);
+    return mClient->setLayer(mHandle, layer);
 }
 status_t SurfaceControl::setPosition(float x, float y) {
     status_t err = validate();
     if (err < 0) return err;
-    const sp<SurfaceComposerClient>& client(mClient);
-    return client->setPosition(mHandle, x, y);
+    return mClient->setPosition(mHandle, x, y);
 }
 status_t SurfaceControl::setSize(uint32_t w, uint32_t h) {
     status_t err = validate();
     if (err < 0) return err;
-    const sp<SurfaceComposerClient>& client(mClient);
-    return client->setSize(mHandle, w, h);
+    return mClient->setSize(mHandle, w, h);
 }
 status_t SurfaceControl::hide() {
     status_t err = validate();
     if (err < 0) return err;
-    const sp<SurfaceComposerClient>& client(mClient);
-    return client->hide(mHandle);
+    return mClient->hide(mHandle);
 }
 status_t SurfaceControl::show() {
     status_t err = validate();
     if (err < 0) return err;
-    const sp<SurfaceComposerClient>& client(mClient);
-    return client->show(mHandle);
+    return mClient->show(mHandle);
 }
 status_t SurfaceControl::setFlags(uint32_t flags, uint32_t mask) {
     status_t err = validate();
     if (err < 0) return err;
-    const sp<SurfaceComposerClient>& client(mClient);
-    return client->setFlags(mHandle, flags, mask);
+    return mClient->setFlags(mHandle, flags, mask);
 }
 status_t SurfaceControl::setTransparentRegionHint(const Region& transparent) {
     status_t err = validate();
     if (err < 0) return err;
-    const sp<SurfaceComposerClient>& client(mClient);
-    return client->setTransparentRegionHint(mHandle, transparent);
+    return mClient->setTransparentRegionHint(mHandle, transparent);
 }
 status_t SurfaceControl::setAlpha(float alpha) {
     status_t err = validate();
     if (err < 0) return err;
-    const sp<SurfaceComposerClient>& client(mClient);
-    return client->setAlpha(mHandle, alpha);
+    return mClient->setAlpha(mHandle, alpha);
 }
 status_t SurfaceControl::setMatrix(float dsdx, float dtdx, float dsdy, float dtdy) {
     status_t err = validate();
     if (err < 0) return err;
-    const sp<SurfaceComposerClient>& client(mClient);
-    return client->setMatrix(mHandle, dsdx, dtdx, dsdy, dtdy);
+    return mClient->setMatrix(mHandle, dsdx, dtdx, dsdy, dtdy);
 }
 status_t SurfaceControl::setCrop(const Rect& crop) {
     status_t err = validate();
     if (err < 0) return err;
+    return mClient->setCrop(mHandle, crop);
+}
+
+status_t SurfaceControl::clearLayerFrameStats() const {
+    status_t err = validate();
+    if (err < 0) return err;
     const sp<SurfaceComposerClient>& client(mClient);
-    return client->setCrop(mHandle, crop);
+    return client->clearLayerFrameStats(mHandle);
+}
+
+status_t SurfaceControl::getLayerFrameStats(FrameStats* outStats) const {
+    status_t err = validate();
+    if (err < 0) return err;
+    const sp<SurfaceComposerClient>& client(mClient);
+    return client->getLayerFrameStats(mHandle, outStats);
 }
 
 status_t SurfaceControl::validate() const
@@ -174,7 +176,7 @@
     if (control != NULL) {
         bp = control->mGraphicBufferProducer;
     }
-    return parcel->writeStrongBinder(bp->asBinder());
+    return parcel->writeStrongBinder(IInterface::asBinder(bp));
 }
 
 sp<Surface> SurfaceControl::getSurface() const
diff --git a/libs/gui/SyncFeatures.cpp b/libs/gui/SyncFeatures.cpp
index e5804a7..187b211 100644
--- a/libs/gui/SyncFeatures.cpp
+++ b/libs/gui/SyncFeatures.cpp
@@ -16,7 +16,6 @@
 
 #define LOG_TAG "GLConsumer"
 
-#define GL_GLEXT_PROTOTYPES
 #define EGL_EGLEXT_PROTOTYPES
 
 #include <EGL/egl.h>
@@ -78,10 +77,11 @@
     // on some devices it's better to not use EGL_KHR_fence_sync
     // even if they have it
     return false;
-#endif
+#else
     // currently we shall only attempt to use EGL_KHR_fence_sync if
     // USE_FENCE_SYNC is set in our makefile
     return !mHasNativeFenceSync && mHasFenceSync;
+#endif
 }
 bool SyncFeatures::useWaitSync() const {
     return (useNativeFenceSync() || useFenceSync()) && mHasWaitSync;
diff --git a/libs/gui/tests/Android.mk b/libs/gui/tests/Android.mk
index 21bd875..7d984a4 100644
--- a/libs/gui/tests/Android.mk
+++ b/libs/gui/tests/Android.mk
@@ -1,6 +1,9 @@
 # Build the unit tests,
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+
+LOCAL_CLANG := true
 
 LOCAL_MODULE := libgui_test
 
@@ -9,28 +12,33 @@
 LOCAL_SRC_FILES := \
     BufferQueue_test.cpp \
     CpuConsumer_test.cpp \
+    FillBuffer.cpp \
+    GLTest.cpp \
+    IGraphicBufferProducer_test.cpp \
+    MultiTextureConsumer_test.cpp \
+    SRGB_test.cpp \
+    StreamSplitter_test.cpp \
     SurfaceTextureClient_test.cpp \
-    SurfaceTexture_test.cpp \
+    SurfaceTextureFBO_test.cpp \
+    SurfaceTextureGLThreadToGL_test.cpp \
+    SurfaceTextureGLToGL_test.cpp \
+    SurfaceTextureGL_test.cpp \
+    SurfaceTextureMultiContextGL_test.cpp \
     Surface_test.cpp \
+    TextureRenderer.cpp \
 
 LOCAL_SHARED_LIBRARIES := \
+	liblog \
 	libEGL \
 	libGLESv1_CM \
 	libGLESv2 \
 	libbinder \
 	libcutils \
 	libgui \
-	libstlport \
 	libsync \
 	libui \
 	libutils \
 
-LOCAL_C_INCLUDES := \
-    bionic \
-    bionic/libstdc++/include \
-    external/gtest/include \
-    external/stlport/stlport \
-
 # Build the binary to $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
 # to integrate with auto-test framework.
 include $(BUILD_NATIVE_TEST)
diff --git a/libs/gui/tests/BufferQueue_test.cpp b/libs/gui/tests/BufferQueue_test.cpp
index 03c1a29..1a54875 100644
--- a/libs/gui/tests/BufferQueue_test.cpp
+++ b/libs/gui/tests/BufferQueue_test.cpp
@@ -17,101 +17,427 @@
 #define LOG_TAG "BufferQueue_test"
 //#define LOG_NDEBUG 0
 
-#include <gtest/gtest.h>
+#include "DummyConsumer.h"
+
+#include <gui/BufferItem.h>
+#include <gui/BufferQueue.h>
+#include <gui/IProducerListener.h>
+
+#include <ui/GraphicBuffer.h>
+
+#include <binder/IPCThreadState.h>
+#include <binder/IServiceManager.h>
+#include <binder/ProcessState.h>
 
 #include <utils/String8.h>
 #include <utils/threads.h>
 
-#include <ui/GraphicBuffer.h>
-#include <ui/FramebufferNativeWindow.h>
-
-#include <gui/BufferQueue.h>
+#include <gtest/gtest.h>
 
 namespace android {
 
 class BufferQueueTest : public ::testing::Test {
+
+public:
 protected:
-
-    BufferQueueTest() {}
-
-    virtual void SetUp() {
+    BufferQueueTest() {
         const ::testing::TestInfo* const testInfo =
             ::testing::UnitTest::GetInstance()->current_test_info();
         ALOGV("Begin test: %s.%s", testInfo->test_case_name(),
                 testInfo->name());
-
-        mBQ = new BufferQueue();
     }
 
-    virtual void TearDown() {
-        mBQ.clear();
-
+    ~BufferQueueTest() {
         const ::testing::TestInfo* const testInfo =
             ::testing::UnitTest::GetInstance()->current_test_info();
         ALOGV("End test:   %s.%s", testInfo->test_case_name(),
                 testInfo->name());
     }
 
-    sp<BufferQueue> mBQ;
+    void GetMinUndequeuedBufferCount(int* bufferCount) {
+        ASSERT_TRUE(bufferCount != NULL);
+        ASSERT_EQ(OK, mProducer->query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
+                    bufferCount));
+        ASSERT_GE(*bufferCount, 0);
+    }
+
+    void createBufferQueue() {
+        BufferQueue::createBufferQueue(&mProducer, &mConsumer);
+    }
+
+    sp<IGraphicBufferProducer> mProducer;
+    sp<IGraphicBufferConsumer> mConsumer;
 };
 
-struct DummyConsumer : public BnConsumerListener {
-    virtual void onFrameAvailable() {}
-    virtual void onBuffersReleased() {}
-};
+static const uint32_t TEST_DATA = 0x12345678u;
+
+// XXX: Tests that fork a process to hold the BufferQueue must run before tests
+// that use a local BufferQueue, or else Binder will get unhappy
+TEST_F(BufferQueueTest, BufferQueueInAnotherProcess) {
+    const String16 PRODUCER_NAME = String16("BQTestProducer");
+    const String16 CONSUMER_NAME = String16("BQTestConsumer");
+
+    pid_t forkPid = fork();
+    ASSERT_NE(forkPid, -1);
+
+    if (forkPid == 0) {
+        // Child process
+        sp<IGraphicBufferProducer> producer;
+        sp<IGraphicBufferConsumer> consumer;
+        BufferQueue::createBufferQueue(&producer, &consumer);
+        sp<IServiceManager> serviceManager = defaultServiceManager();
+        serviceManager->addService(PRODUCER_NAME, IInterface::asBinder(producer));
+        serviceManager->addService(CONSUMER_NAME, IInterface::asBinder(consumer));
+        ProcessState::self()->startThreadPool();
+        IPCThreadState::self()->joinThreadPool();
+        LOG_ALWAYS_FATAL("Shouldn't be here");
+    }
+
+    sp<IServiceManager> serviceManager = defaultServiceManager();
+    sp<IBinder> binderProducer =
+        serviceManager->getService(PRODUCER_NAME);
+    mProducer = interface_cast<IGraphicBufferProducer>(binderProducer);
+    EXPECT_TRUE(mProducer != NULL);
+    sp<IBinder> binderConsumer =
+        serviceManager->getService(CONSUMER_NAME);
+    mConsumer = interface_cast<IGraphicBufferConsumer>(binderConsumer);
+    EXPECT_TRUE(mConsumer != NULL);
+
+    sp<DummyConsumer> dc(new DummyConsumer);
+    ASSERT_EQ(OK, mConsumer->consumerConnect(dc, false));
+    IGraphicBufferProducer::QueueBufferOutput output;
+    ASSERT_EQ(OK,
+            mProducer->connect(NULL, NATIVE_WINDOW_API_CPU, false, &output));
+
+    int slot;
+    sp<Fence> fence;
+    sp<GraphicBuffer> buffer;
+    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
+            mProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+                    GRALLOC_USAGE_SW_WRITE_OFTEN));
+    ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
+
+    uint32_t* dataIn;
+    ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN,
+            reinterpret_cast<void**>(&dataIn)));
+    *dataIn = TEST_DATA;
+    ASSERT_EQ(OK, buffer->unlock());
+
+    IGraphicBufferProducer::QueueBufferInput input(0, false,
+            HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
+            NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
+    ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
+
+    BufferItem item;
+    ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0));
+
+    uint32_t* dataOut;
+    ASSERT_EQ(OK, item.mGraphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN,
+            reinterpret_cast<void**>(&dataOut)));
+    ASSERT_EQ(*dataOut, TEST_DATA);
+    ASSERT_EQ(OK, item.mGraphicBuffer->unlock());
+}
 
 TEST_F(BufferQueueTest, AcquireBuffer_ExceedsMaxAcquireCount_Fails) {
+    createBufferQueue();
     sp<DummyConsumer> dc(new DummyConsumer);
-    mBQ->consumerConnect(dc, false);
+    mConsumer->consumerConnect(dc, false);
     IGraphicBufferProducer::QueueBufferOutput qbo;
-    mBQ->connect(NULL, NATIVE_WINDOW_API_CPU, false, &qbo);
-    mBQ->setBufferCount(4);
+    mProducer->connect(new DummyProducerListener, NATIVE_WINDOW_API_CPU, false,
+            &qbo);
+    mProducer->setBufferCount(4);
 
     int slot;
     sp<Fence> fence;
     sp<GraphicBuffer> buf;
-    IGraphicBufferProducer::QueueBufferInput qbi(0, false, Rect(0, 0, 1, 1),
+    IGraphicBufferProducer::QueueBufferInput qbi(0, false,
+            HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
             NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
-    BufferQueue::BufferItem item;
+    BufferItem item;
 
     for (int i = 0; i < 2; i++) {
         ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
-                mBQ->dequeueBuffer(&slot, &fence, false, 1, 1, 0,
+                mProducer->dequeueBuffer(&slot, &fence, false, 1, 1, 0,
                     GRALLOC_USAGE_SW_READ_OFTEN));
-        ASSERT_EQ(OK, mBQ->requestBuffer(slot, &buf));
-        ASSERT_EQ(OK, mBQ->queueBuffer(slot, qbi, &qbo));
-        ASSERT_EQ(OK, mBQ->acquireBuffer(&item, 0));
+        ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buf));
+        ASSERT_EQ(OK, mProducer->queueBuffer(slot, qbi, &qbo));
+        ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0));
     }
 
     ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
-            mBQ->dequeueBuffer(&slot, &fence, false, 1, 1, 0,
+            mProducer->dequeueBuffer(&slot, &fence, false, 1, 1, 0,
                 GRALLOC_USAGE_SW_READ_OFTEN));
-    ASSERT_EQ(OK, mBQ->requestBuffer(slot, &buf));
-    ASSERT_EQ(OK, mBQ->queueBuffer(slot, qbi, &qbo));
+    ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buf));
+    ASSERT_EQ(OK, mProducer->queueBuffer(slot, qbi, &qbo));
 
     // Acquire the third buffer, which should fail.
-    ASSERT_EQ(INVALID_OPERATION, mBQ->acquireBuffer(&item, 0));
+    ASSERT_EQ(INVALID_OPERATION, mConsumer->acquireBuffer(&item, 0));
 }
 
 TEST_F(BufferQueueTest, SetMaxAcquiredBufferCountWithIllegalValues_ReturnsError) {
+    createBufferQueue();
     sp<DummyConsumer> dc(new DummyConsumer);
-    mBQ->consumerConnect(dc, false);
+    mConsumer->consumerConnect(dc, false);
 
-    ASSERT_EQ(BAD_VALUE, mBQ->setMaxAcquiredBufferCount(0));
-    ASSERT_EQ(BAD_VALUE, mBQ->setMaxAcquiredBufferCount(-3));
-    ASSERT_EQ(BAD_VALUE, mBQ->setMaxAcquiredBufferCount(
+    int minBufferCount;
+    ASSERT_NO_FATAL_FAILURE(GetMinUndequeuedBufferCount(&minBufferCount));
+    EXPECT_EQ(BAD_VALUE, mConsumer->setMaxAcquiredBufferCount(
+                minBufferCount - 1));
+
+    EXPECT_EQ(BAD_VALUE, mConsumer->setMaxAcquiredBufferCount(0));
+    EXPECT_EQ(BAD_VALUE, mConsumer->setMaxAcquiredBufferCount(-3));
+    EXPECT_EQ(BAD_VALUE, mConsumer->setMaxAcquiredBufferCount(
             BufferQueue::MAX_MAX_ACQUIRED_BUFFERS+1));
-    ASSERT_EQ(BAD_VALUE, mBQ->setMaxAcquiredBufferCount(100));
+    EXPECT_EQ(BAD_VALUE, mConsumer->setMaxAcquiredBufferCount(100));
 }
 
 TEST_F(BufferQueueTest, SetMaxAcquiredBufferCountWithLegalValues_Succeeds) {
+    createBufferQueue();
     sp<DummyConsumer> dc(new DummyConsumer);
-    mBQ->consumerConnect(dc, false);
+    mConsumer->consumerConnect(dc, false);
 
-    ASSERT_EQ(OK, mBQ->setMaxAcquiredBufferCount(1));
-    ASSERT_EQ(OK, mBQ->setMaxAcquiredBufferCount(2));
-    ASSERT_EQ(OK, mBQ->setMaxAcquiredBufferCount(
+    int minBufferCount;
+    ASSERT_NO_FATAL_FAILURE(GetMinUndequeuedBufferCount(&minBufferCount));
+
+    EXPECT_EQ(OK, mConsumer->setMaxAcquiredBufferCount(1));
+    EXPECT_EQ(OK, mConsumer->setMaxAcquiredBufferCount(2));
+    EXPECT_EQ(OK, mConsumer->setMaxAcquiredBufferCount(minBufferCount));
+    EXPECT_EQ(OK, mConsumer->setMaxAcquiredBufferCount(
             BufferQueue::MAX_MAX_ACQUIRED_BUFFERS));
 }
 
+TEST_F(BufferQueueTest, DetachAndReattachOnProducerSide) {
+    createBufferQueue();
+    sp<DummyConsumer> dc(new DummyConsumer);
+    ASSERT_EQ(OK, mConsumer->consumerConnect(dc, false));
+    IGraphicBufferProducer::QueueBufferOutput output;
+    ASSERT_EQ(OK, mProducer->connect(new DummyProducerListener,
+            NATIVE_WINDOW_API_CPU, false, &output));
+
+    ASSERT_EQ(BAD_VALUE, mProducer->detachBuffer(-1)); // Index too low
+    ASSERT_EQ(BAD_VALUE, mProducer->detachBuffer(
+                BufferQueueDefs::NUM_BUFFER_SLOTS)); // Index too high
+    ASSERT_EQ(BAD_VALUE, mProducer->detachBuffer(0)); // Not dequeued
+
+    int slot;
+    sp<Fence> fence;
+    sp<GraphicBuffer> buffer;
+    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
+            mProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+                    GRALLOC_USAGE_SW_WRITE_OFTEN));
+    ASSERT_EQ(BAD_VALUE, mProducer->detachBuffer(slot)); // Not requested
+    ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
+    ASSERT_EQ(OK, mProducer->detachBuffer(slot));
+    ASSERT_EQ(BAD_VALUE, mProducer->detachBuffer(slot)); // Not dequeued
+
+    sp<GraphicBuffer> safeToClobberBuffer;
+    // Can no longer request buffer from this slot
+    ASSERT_EQ(BAD_VALUE, mProducer->requestBuffer(slot, &safeToClobberBuffer));
+
+    uint32_t* dataIn;
+    ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN,
+            reinterpret_cast<void**>(&dataIn)));
+    *dataIn = TEST_DATA;
+    ASSERT_EQ(OK, buffer->unlock());
+
+    int newSlot;
+    ASSERT_EQ(BAD_VALUE, mProducer->attachBuffer(NULL, safeToClobberBuffer));
+    ASSERT_EQ(BAD_VALUE, mProducer->attachBuffer(&newSlot, NULL));
+
+    ASSERT_EQ(OK, mProducer->attachBuffer(&newSlot, buffer));
+    IGraphicBufferProducer::QueueBufferInput input(0, false,
+            HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
+            NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
+    ASSERT_EQ(OK, mProducer->queueBuffer(newSlot, input, &output));
+
+    BufferItem item;
+    ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, static_cast<nsecs_t>(0)));
+
+    uint32_t* dataOut;
+    ASSERT_EQ(OK, item.mGraphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN,
+            reinterpret_cast<void**>(&dataOut)));
+    ASSERT_EQ(*dataOut, TEST_DATA);
+    ASSERT_EQ(OK, item.mGraphicBuffer->unlock());
+}
+
+TEST_F(BufferQueueTest, DetachAndReattachOnConsumerSide) {
+    createBufferQueue();
+    sp<DummyConsumer> dc(new DummyConsumer);
+    ASSERT_EQ(OK, mConsumer->consumerConnect(dc, false));
+    IGraphicBufferProducer::QueueBufferOutput output;
+    ASSERT_EQ(OK, mProducer->connect(new DummyProducerListener,
+            NATIVE_WINDOW_API_CPU, false, &output));
+
+    int slot;
+    sp<Fence> fence;
+    sp<GraphicBuffer> buffer;
+    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
+            mProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+                    GRALLOC_USAGE_SW_WRITE_OFTEN));
+    ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
+    IGraphicBufferProducer::QueueBufferInput input(0, false,
+            HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
+            NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
+    ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
+
+    ASSERT_EQ(BAD_VALUE, mConsumer->detachBuffer(-1)); // Index too low
+    ASSERT_EQ(BAD_VALUE, mConsumer->detachBuffer(
+            BufferQueueDefs::NUM_BUFFER_SLOTS)); // Index too high
+    ASSERT_EQ(BAD_VALUE, mConsumer->detachBuffer(0)); // Not acquired
+
+    BufferItem item;
+    ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, static_cast<nsecs_t>(0)));
+
+    ASSERT_EQ(OK, mConsumer->detachBuffer(item.mBuf));
+    ASSERT_EQ(BAD_VALUE, mConsumer->detachBuffer(item.mBuf)); // Not acquired
+
+    uint32_t* dataIn;
+    ASSERT_EQ(OK, item.mGraphicBuffer->lock(
+            GraphicBuffer::USAGE_SW_WRITE_OFTEN,
+            reinterpret_cast<void**>(&dataIn)));
+    *dataIn = TEST_DATA;
+    ASSERT_EQ(OK, item.mGraphicBuffer->unlock());
+
+    int newSlot;
+    sp<GraphicBuffer> safeToClobberBuffer;
+    ASSERT_EQ(BAD_VALUE, mConsumer->attachBuffer(NULL, safeToClobberBuffer));
+    ASSERT_EQ(BAD_VALUE, mConsumer->attachBuffer(&newSlot, NULL));
+    ASSERT_EQ(OK, mConsumer->attachBuffer(&newSlot, item.mGraphicBuffer));
+
+    ASSERT_EQ(OK, mConsumer->releaseBuffer(newSlot, 0, EGL_NO_DISPLAY,
+            EGL_NO_SYNC_KHR, Fence::NO_FENCE));
+
+    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
+            mProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+                    GRALLOC_USAGE_SW_WRITE_OFTEN));
+    ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
+
+    uint32_t* dataOut;
+    ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN,
+            reinterpret_cast<void**>(&dataOut)));
+    ASSERT_EQ(*dataOut, TEST_DATA);
+    ASSERT_EQ(OK, buffer->unlock());
+}
+
+TEST_F(BufferQueueTest, MoveFromConsumerToProducer) {
+    createBufferQueue();
+    sp<DummyConsumer> dc(new DummyConsumer);
+    ASSERT_EQ(OK, mConsumer->consumerConnect(dc, false));
+    IGraphicBufferProducer::QueueBufferOutput output;
+    ASSERT_EQ(OK, mProducer->connect(new DummyProducerListener,
+            NATIVE_WINDOW_API_CPU, false, &output));
+
+    int slot;
+    sp<Fence> fence;
+    sp<GraphicBuffer> buffer;
+    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
+            mProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+                    GRALLOC_USAGE_SW_WRITE_OFTEN));
+    ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
+
+    uint32_t* dataIn;
+    ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN,
+            reinterpret_cast<void**>(&dataIn)));
+    *dataIn = TEST_DATA;
+    ASSERT_EQ(OK, buffer->unlock());
+
+    IGraphicBufferProducer::QueueBufferInput input(0, false,
+            HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
+            NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
+    ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
+
+    BufferItem item;
+    ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, static_cast<nsecs_t>(0)));
+    ASSERT_EQ(OK, mConsumer->detachBuffer(item.mBuf));
+
+    int newSlot;
+    ASSERT_EQ(OK, mProducer->attachBuffer(&newSlot, item.mGraphicBuffer));
+    ASSERT_EQ(OK, mProducer->queueBuffer(newSlot, input, &output));
+    ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, static_cast<nsecs_t>(0)));
+
+    uint32_t* dataOut;
+    ASSERT_EQ(OK, item.mGraphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN,
+            reinterpret_cast<void**>(&dataOut)));
+    ASSERT_EQ(*dataOut, TEST_DATA);
+    ASSERT_EQ(OK, item.mGraphicBuffer->unlock());
+}
+
+TEST_F(BufferQueueTest, TestDisallowingAllocation) {
+    createBufferQueue();
+    sp<DummyConsumer> dc(new DummyConsumer);
+    ASSERT_EQ(OK, mConsumer->consumerConnect(dc, true));
+    IGraphicBufferProducer::QueueBufferOutput output;
+    ASSERT_EQ(OK, mProducer->connect(new DummyProducerListener,
+            NATIVE_WINDOW_API_CPU, true, &output));
+
+    static const uint32_t WIDTH = 320;
+    static const uint32_t HEIGHT = 240;
+
+    ASSERT_EQ(OK, mConsumer->setDefaultBufferSize(WIDTH, HEIGHT));
+
+    int slot;
+    sp<Fence> fence;
+    sp<GraphicBuffer> buffer;
+    // This should return an error since it would require an allocation
+    ASSERT_EQ(OK, mProducer->allowAllocation(false));
+    ASSERT_EQ(WOULD_BLOCK, mProducer->dequeueBuffer(&slot, &fence, false, 0, 0,
+            0, GRALLOC_USAGE_SW_WRITE_OFTEN));
+
+    // This should succeed, now that we've lifted the prohibition
+    ASSERT_EQ(OK, mProducer->allowAllocation(true));
+    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
+            mProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+            GRALLOC_USAGE_SW_WRITE_OFTEN));
+
+    // Release the previous buffer back to the BufferQueue
+    mProducer->cancelBuffer(slot, fence);
+
+    // This should fail since we're requesting a different size
+    ASSERT_EQ(OK, mProducer->allowAllocation(false));
+    ASSERT_EQ(WOULD_BLOCK, mProducer->dequeueBuffer(&slot, &fence, false,
+            WIDTH * 2, HEIGHT * 2, 0, GRALLOC_USAGE_SW_WRITE_OFTEN));
+}
+
+TEST_F(BufferQueueTest, TestGenerationNumbers) {
+    createBufferQueue();
+    sp<DummyConsumer> dc(new DummyConsumer);
+    ASSERT_EQ(OK, mConsumer->consumerConnect(dc, true));
+    IGraphicBufferProducer::QueueBufferOutput output;
+    ASSERT_EQ(OK, mProducer->connect(new DummyProducerListener,
+            NATIVE_WINDOW_API_CPU, true, &output));
+
+    ASSERT_EQ(OK, mProducer->setGenerationNumber(1));
+
+    // Get one buffer to play with
+    int slot;
+    sp<Fence> fence;
+    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
+            mProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0, 0));
+
+    sp<GraphicBuffer> buffer;
+    ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
+
+    // Ensure that the generation number we set propagates to allocated buffers
+    ASSERT_EQ(1U, buffer->getGenerationNumber());
+
+    ASSERT_EQ(OK, mProducer->detachBuffer(slot));
+
+    ASSERT_EQ(OK, mProducer->setGenerationNumber(2));
+
+    // These should fail, since we've changed the generation number on the queue
+    int outSlot;
+    ASSERT_EQ(BAD_VALUE, mProducer->attachBuffer(&outSlot, buffer));
+    ASSERT_EQ(BAD_VALUE, mConsumer->attachBuffer(&outSlot, buffer));
+
+    buffer->setGenerationNumber(2);
+
+    // This should succeed now that we've changed the buffer's generation number
+    ASSERT_EQ(OK, mProducer->attachBuffer(&outSlot, buffer));
+
+    ASSERT_EQ(OK, mProducer->detachBuffer(outSlot));
+
+    // This should also succeed with the new generation number
+    ASSERT_EQ(OK, mConsumer->attachBuffer(&outSlot, buffer));
+}
+
 } // namespace android
diff --git a/libs/gui/tests/CpuConsumer_test.cpp b/libs/gui/tests/CpuConsumer_test.cpp
index b370a2d..5d53afc 100644
--- a/libs/gui/tests/CpuConsumer_test.cpp
+++ b/libs/gui/tests/CpuConsumer_test.cpp
@@ -33,8 +33,6 @@
 #include <utils/Mutex.h>
 #include <utils/Condition.h>
 
-#include <ui/FramebufferNativeWindow.h>
-
 #define CPU_CONSUMER_TEST_FORMAT_RAW 0
 #define CPU_CONSUMER_TEST_FORMAT_Y8 0
 #define CPU_CONSUMER_TEST_FORMAT_Y16 0
@@ -66,11 +64,13 @@
                 test_info->name(),
                 params.width, params.height,
                 params.maxLockedBuffers, params.format);
-        sp<BufferQueue> bq = new BufferQueue();
-        mCC = new CpuConsumer(bq, params.maxLockedBuffers);
+        sp<IGraphicBufferProducer> producer;
+        sp<IGraphicBufferConsumer> consumer;
+        BufferQueue::createBufferQueue(&producer, &consumer);
+        mCC = new CpuConsumer(consumer, params.maxLockedBuffers);
         String8 name("CpuConsumer_Under_Test");
         mCC->setName(name);
-        mSTC = new Surface(bq);
+        mSTC = new Surface(producer);
         mANW = mSTC;
     }
 
@@ -94,7 +94,7 @@
             mPendingFrames--;
         }
 
-        virtual void onFrameAvailable() {
+        virtual void onFrameAvailable(const BufferItem&) {
             Mutex::Autolock lock(mMutex);
             mPendingFrames++;
             mCondition.signal();
@@ -125,7 +125,7 @@
             mPendingFrames--;
         }
 
-        virtual void onFrameAvailable() {
+        virtual void onFrameAvailable(const BufferItem&) {
             Mutex::Autolock lock(mMutex);
             mPendingFrames++;
             mFrameCondition.signal();
@@ -160,13 +160,13 @@
 };
 
 #define ASSERT_NO_ERROR(err, msg) \
-    ASSERT_EQ(NO_ERROR, err) << msg << strerror(-err)
+    ASSERT_EQ(NO_ERROR, err) << (msg) << strerror(-(err))
 
 void checkPixel(const CpuConsumer::LockedBuffer &buf,
         uint32_t x, uint32_t y, uint32_t r, uint32_t g=0, uint32_t b=0) {
     // Ignores components that don't exist for given pixel
     switch(buf.format) {
-        case HAL_PIXEL_FORMAT_RAW_SENSOR: {
+        case HAL_PIXEL_FORMAT_RAW16: {
             String8 msg;
             uint16_t *bPtr = (uint16_t*)buf.data;
             bPtr += y * buf.stride + x;
@@ -429,7 +429,7 @@
 
 void checkAnyBuffer(const CpuConsumer::LockedBuffer &buf, int format) {
     switch (format) {
-        case HAL_PIXEL_FORMAT_RAW_SENSOR:
+        case HAL_PIXEL_FORMAT_RAW16:
             checkBayerRawBuffer(buf);
             break;
         case HAL_PIXEL_FORMAT_Y8:
@@ -457,9 +457,12 @@
         const CpuConsumerTestParams& params,
         int maxBufferSlack) {
     status_t err;
-    err = native_window_set_buffers_geometry(anw.get(),
-            params.width, params.height, params.format);
-    ASSERT_NO_ERROR(err, "set_buffers_geometry error: ");
+    err = native_window_set_buffers_dimensions(anw.get(),
+            params.width, params.height);
+    ASSERT_NO_ERROR(err, "set_buffers_dimensions error: ");
+
+    err = native_window_set_buffers_format(anw.get(), params.format);
+    ASSERT_NO_ERROR(err, "set_buffers_format error: ");
 
     err = native_window_set_usage(anw.get(),
             GRALLOC_USAGE_SW_WRITE_OFTEN);
@@ -505,7 +508,7 @@
         case HAL_PIXEL_FORMAT_YV12:
             fillYV12Buffer(img, params.width, params.height, *stride);
             break;
-        case HAL_PIXEL_FORMAT_RAW_SENSOR:
+        case HAL_PIXEL_FORMAT_RAW16:
             fillBayerRawBuffer(img, params.width, params.height, buf->getStride());
             break;
         case HAL_PIXEL_FORMAT_Y8:
@@ -537,7 +540,7 @@
     ASSERT_NO_ERROR(err, "queueBuffer error:");
 };
 
-// This test is disabled because the HAL_PIXEL_FORMAT_RAW_SENSOR format is not
+// This test is disabled because the HAL_PIXEL_FORMAT_RAW16 format is not
 // supported on all devices.
 TEST_P(CpuConsumerTest, FromCpuSingle) {
     status_t err;
@@ -571,7 +574,7 @@
     mCC->unlockBuffer(b);
 }
 
-// This test is disabled because the HAL_PIXEL_FORMAT_RAW_SENSOR format is not
+// This test is disabled because the HAL_PIXEL_FORMAT_RAW16 format is not
 // supported on all devices.
 TEST_P(CpuConsumerTest, FromCpuManyInQueue) {
     status_t err;
@@ -614,7 +617,7 @@
     }
 }
 
-// This test is disabled because the HAL_PIXEL_FORMAT_RAW_SENSOR format is not
+// This test is disabled because the HAL_PIXEL_FORMAT_RAW16 format is not
 // supported on all devices.
 TEST_P(CpuConsumerTest, FromCpuLockMax) {
     status_t err;
@@ -710,12 +713,12 @@
 };
 
 CpuConsumerTestParams rawTestSets[] = {
-    { 512,   512, 1, HAL_PIXEL_FORMAT_RAW_SENSOR},
-    { 512,   512, 3, HAL_PIXEL_FORMAT_RAW_SENSOR},
-    { 2608, 1960, 1, HAL_PIXEL_FORMAT_RAW_SENSOR},
-    { 2608, 1960, 3, HAL_PIXEL_FORMAT_RAW_SENSOR},
-    { 100,   100, 1, HAL_PIXEL_FORMAT_RAW_SENSOR},
-    { 100,   100, 3, HAL_PIXEL_FORMAT_RAW_SENSOR},
+    { 512,   512, 1, HAL_PIXEL_FORMAT_RAW16},
+    { 512,   512, 3, HAL_PIXEL_FORMAT_RAW16},
+    { 2608, 1960, 1, HAL_PIXEL_FORMAT_RAW16},
+    { 2608, 1960, 3, HAL_PIXEL_FORMAT_RAW16},
+    { 100,   100, 1, HAL_PIXEL_FORMAT_RAW16},
+    { 100,   100, 3, HAL_PIXEL_FORMAT_RAW16},
 };
 
 CpuConsumerTestParams rgba8888TestSets[] = {
diff --git a/libs/gui/tests/DisconnectWaiter.h b/libs/gui/tests/DisconnectWaiter.h
new file mode 100644
index 0000000..6e6915b
--- /dev/null
+++ b/libs/gui/tests/DisconnectWaiter.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_DISCONNECT_WAITER_H
+#define ANDROID_DISCONNECT_WAITER_H
+
+#include <gui/IConsumerListener.h>
+
+#include <utils/Condition.h>
+#include <utils/Mutex.h>
+
+namespace android {
+
+// Note that GLConsumer will lose the notifications
+// onBuffersReleased and onFrameAvailable as there is currently
+// no way to forward the events.  This DisconnectWaiter will not let the
+// disconnect finish until finishDisconnect() is called.  It will
+// also block until a disconnect is called
+class DisconnectWaiter : public BnConsumerListener {
+public:
+    DisconnectWaiter () :
+        mWaitForDisconnect(false),
+        mPendingFrames(0) {
+    }
+
+    void waitForFrame() {
+        Mutex::Autolock lock(mMutex);
+        while (mPendingFrames == 0) {
+            mFrameCondition.wait(mMutex);
+        }
+        mPendingFrames--;
+    }
+
+    virtual void onFrameAvailable(const BufferItem& /* item */) {
+        Mutex::Autolock lock(mMutex);
+        mPendingFrames++;
+        mFrameCondition.signal();
+    }
+
+    virtual void onBuffersReleased() {
+        Mutex::Autolock lock(mMutex);
+        while (!mWaitForDisconnect) {
+            mDisconnectCondition.wait(mMutex);
+        }
+    }
+
+    virtual void onSidebandStreamChanged() {}
+
+    void finishDisconnect() {
+        Mutex::Autolock lock(mMutex);
+        mWaitForDisconnect = true;
+        mDisconnectCondition.signal();
+    }
+
+private:
+    Mutex mMutex;
+
+    bool mWaitForDisconnect;
+    Condition mDisconnectCondition;
+
+    int mPendingFrames;
+    Condition mFrameCondition;
+};
+
+} // namespace android
+
+#endif
diff --git a/cmds/dumpstate/libdumpstate_default.c b/libs/gui/tests/DummyConsumer.h
similarity index 62%
copy from cmds/dumpstate/libdumpstate_default.c
copy to libs/gui/tests/DummyConsumer.h
index fd840df..0511e16 100644
--- a/cmds/dumpstate/libdumpstate_default.c
+++ b/libs/gui/tests/DummyConsumer.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 The Android Open Source Project
+ * Copyright 2015 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,9 +14,14 @@
  * limitations under the License.
  */
 
-#include "dumpstate.h"
+#include <gui/IConsumerListener.h>
 
-void dumpstate_board(void)
-{
-}
+namespace android {
 
+struct DummyConsumer : public BnConsumerListener {
+    virtual void onFrameAvailable(const BufferItem& /* item */) {}
+    virtual void onBuffersReleased() {}
+    virtual void onSidebandStreamChanged() {}
+};
+
+} // namespace android
diff --git a/libs/gui/tests/FillBuffer.cpp b/libs/gui/tests/FillBuffer.cpp
new file mode 100644
index 0000000..079962c
--- /dev/null
+++ b/libs/gui/tests/FillBuffer.cpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "FillBuffer.h"
+
+#include <ui/GraphicBuffer.h>
+
+#include <gtest/gtest.h>
+
+namespace android {
+
+void fillYV12Buffer(uint8_t* buf, int w, int h, int stride) {
+    const int blockWidth = w > 16 ? w / 16 : 1;
+    const int blockHeight = h > 16 ? h / 16 : 1;
+    const int yuvTexOffsetY = 0;
+    int yuvTexStrideY = stride;
+    int yuvTexOffsetV = yuvTexStrideY * h;
+    int yuvTexStrideV = (yuvTexStrideY/2 + 0xf) & ~0xf;
+    int yuvTexOffsetU = yuvTexOffsetV + yuvTexStrideV * h/2;
+    int yuvTexStrideU = yuvTexStrideV;
+    for (int x = 0; x < w; x++) {
+        for (int y = 0; y < h; y++) {
+            int parityX = (x / blockWidth) & 1;
+            int parityY = (y / blockHeight) & 1;
+            unsigned char intensity = (parityX ^ parityY) ? 63 : 191;
+            buf[yuvTexOffsetY + (y * yuvTexStrideY) + x] = intensity;
+            if (x < w / 2 && y < h / 2) {
+                buf[yuvTexOffsetU + (y * yuvTexStrideU) + x] = intensity;
+                if (x * 2 < w / 2 && y * 2 < h / 2) {
+                    buf[yuvTexOffsetV + (y*2 * yuvTexStrideV) + x*2 + 0] =
+                    buf[yuvTexOffsetV + (y*2 * yuvTexStrideV) + x*2 + 1] =
+                    buf[yuvTexOffsetV + ((y*2+1) * yuvTexStrideV) + x*2 + 0] =
+                    buf[yuvTexOffsetV + ((y*2+1) * yuvTexStrideV) + x*2 + 1] =
+                        intensity;
+                }
+            }
+        }
+    }
+}
+
+void fillYV12BufferRect(uint8_t* buf, int w, int h, int stride,
+        const android_native_rect_t& rect) {
+    const int yuvTexOffsetY = 0;
+    int yuvTexStrideY = stride;
+    int yuvTexOffsetV = yuvTexStrideY * h;
+    int yuvTexStrideV = (yuvTexStrideY/2 + 0xf) & ~0xf;
+    int yuvTexOffsetU = yuvTexOffsetV + yuvTexStrideV * h/2;
+    int yuvTexStrideU = yuvTexStrideV;
+    for (int x = 0; x < w; x++) {
+        for (int y = 0; y < h; y++) {
+            bool inside = rect.left <= x && x < rect.right &&
+                    rect.top <= y && y < rect.bottom;
+            buf[yuvTexOffsetY + (y * yuvTexStrideY) + x] = inside ? 240 : 64;
+            if (x < w / 2 && y < h / 2) {
+                bool inside = rect.left <= 2*x && 2*x < rect.right &&
+                        rect.top <= 2*y && 2*y < rect.bottom;
+                buf[yuvTexOffsetU + (y * yuvTexStrideU) + x] = 16;
+                buf[yuvTexOffsetV + (y * yuvTexStrideV) + x] =
+                        inside ? 16 : 255;
+            }
+        }
+    }
+}
+
+void fillRGBA8Buffer(uint8_t* buf, int w, int h, int stride) {
+    const size_t PIXEL_SIZE = 4;
+    for (int x = 0; x < w; x++) {
+        for (int y = 0; y < h; y++) {
+            off_t offset = (y * stride + x) * PIXEL_SIZE;
+            for (int c = 0; c < 4; c++) {
+                int parityX = (x / (1 << (c+2))) & 1;
+                int parityY = (y / (1 << (c+2))) & 1;
+                buf[offset + c] = (parityX ^ parityY) ? 231 : 35;
+            }
+        }
+    }
+}
+
+void produceOneRGBA8Frame(const sp<ANativeWindow>& anw) {
+    android_native_buffer_t* anb;
+    ASSERT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(anw.get(),
+            &anb));
+    ASSERT_TRUE(anb != NULL);
+
+    sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
+
+    uint8_t* img = NULL;
+    ASSERT_EQ(NO_ERROR, buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN,
+            (void**)(&img)));
+    fillRGBA8Buffer(img, buf->getWidth(), buf->getHeight(), buf->getStride());
+    ASSERT_EQ(NO_ERROR, buf->unlock());
+    ASSERT_EQ(NO_ERROR, anw->queueBuffer(anw.get(), buf->getNativeBuffer(),
+            -1));
+}
+} // namespace android
diff --git a/libs/gui/tests/FillBuffer.h b/libs/gui/tests/FillBuffer.h
new file mode 100644
index 0000000..b584179
--- /dev/null
+++ b/libs/gui/tests/FillBuffer.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_FILL_BUFFER_H
+#define ANDROID_FILL_BUFFER_H
+
+#include <system/window.h>
+#include <utils/StrongPointer.h>
+
+namespace android {
+
+// Fill a YV12 buffer with a multi-colored checkerboard pattern
+void fillYV12Buffer(uint8_t* buf, int w, int h, int stride);
+
+// Fill a YV12 buffer with red outside a given rectangle and green inside it.
+void fillYV12BufferRect(uint8_t* buf, int w, int h, int stride,
+        const android_native_rect_t& rect);
+
+void fillRGBA8Buffer(uint8_t* buf, int w, int h, int stride);
+
+// Produce a single RGBA8 frame by filling a buffer with a checkerboard pattern
+// using the CPU.  This assumes that the ANativeWindow is already configured to
+// allow this to be done (e.g. the format is set to RGBA8).
+//
+// Calls to this function should be wrapped in an ASSERT_NO_FATAL_FAILURE().
+void produceOneRGBA8Frame(const sp<ANativeWindow>& anw);
+
+} // namespace android
+
+#endif
diff --git a/libs/gui/tests/FrameWaiter.h b/libs/gui/tests/FrameWaiter.h
new file mode 100644
index 0000000..f78fa00
--- /dev/null
+++ b/libs/gui/tests/FrameWaiter.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_FRAME_WAITER_H
+#define ANDROID_FRAME_WAITER_H
+
+#include <gui/GLConsumer.h>
+
+namespace android {
+
+class FrameWaiter : public GLConsumer::FrameAvailableListener {
+public:
+    FrameWaiter():
+            mPendingFrames(0) {
+    }
+
+    void waitForFrame() {
+        Mutex::Autolock lock(mMutex);
+        while (mPendingFrames == 0) {
+            mCondition.wait(mMutex);
+        }
+        mPendingFrames--;
+    }
+
+    virtual void onFrameAvailable(const BufferItem& /* item */) {
+        Mutex::Autolock lock(mMutex);
+        mPendingFrames++;
+        mCondition.signal();
+    }
+
+private:
+    int mPendingFrames;
+    Mutex mMutex;
+    Condition mCondition;
+};
+
+} // namespace android
+
+#endif
diff --git a/libs/gui/tests/GLTest.cpp b/libs/gui/tests/GLTest.cpp
new file mode 100644
index 0000000..1739d9c
--- /dev/null
+++ b/libs/gui/tests/GLTest.cpp
@@ -0,0 +1,339 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "GLTest.h"
+
+#include <gui/Surface.h>
+
+#include <GLES2/gl2.h>
+
+namespace android {
+
+static int abs(int value) {
+    return value > 0 ? value : -value;
+}
+
+void GLTest::SetUp() {
+    const ::testing::TestInfo* const testInfo =
+        ::testing::UnitTest::GetInstance()->current_test_info();
+    ALOGV("Begin test: %s.%s", testInfo->test_case_name(), testInfo->name());
+
+    mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+    ASSERT_NE(EGL_NO_DISPLAY, mEglDisplay);
+
+    EGLint majorVersion;
+    EGLint minorVersion;
+    EXPECT_TRUE(eglInitialize(mEglDisplay, &majorVersion, &minorVersion));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+    RecordProperty("EglVersionMajor", majorVersion);
+    RecordProperty("EglVersionMinor", minorVersion);
+
+    EGLint numConfigs = 0;
+    EXPECT_TRUE(eglChooseConfig(mEglDisplay, getConfigAttribs(), &mGlConfig, 1,
+            &numConfigs));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    char* displaySecsEnv = getenv("GLTEST_DISPLAY_SECS");
+    if (displaySecsEnv != NULL) {
+        mDisplaySecs = atoi(displaySecsEnv);
+        if (mDisplaySecs < 0) {
+            mDisplaySecs = 0;
+        }
+    } else {
+        mDisplaySecs = 0;
+    }
+
+    if (mDisplaySecs > 0) {
+        mComposerClient = new SurfaceComposerClient;
+        ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
+
+        mSurfaceControl = mComposerClient->createSurface(
+                String8("Test Surface"), getSurfaceWidth(), getSurfaceHeight(),
+                PIXEL_FORMAT_RGB_888, 0);
+
+        ASSERT_TRUE(mSurfaceControl != NULL);
+        ASSERT_TRUE(mSurfaceControl->isValid());
+
+        SurfaceComposerClient::openGlobalTransaction();
+        ASSERT_EQ(NO_ERROR, mSurfaceControl->setLayer(0x7FFFFFFF));
+        ASSERT_EQ(NO_ERROR, mSurfaceControl->show());
+        SurfaceComposerClient::closeGlobalTransaction();
+
+        sp<ANativeWindow> window = mSurfaceControl->getSurface();
+        mEglSurface = createWindowSurface(mEglDisplay, mGlConfig, window);
+    } else {
+        EGLint pbufferAttribs[] = {
+            EGL_WIDTH, getSurfaceWidth(),
+            EGL_HEIGHT, getSurfaceHeight(),
+            EGL_NONE };
+
+        mEglSurface = eglCreatePbufferSurface(mEglDisplay, mGlConfig,
+                pbufferAttribs);
+    }
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+    ASSERT_NE(EGL_NO_SURFACE, mEglSurface);
+
+    mEglContext = eglCreateContext(mEglDisplay, mGlConfig, EGL_NO_CONTEXT,
+            getContextAttribs());
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+    ASSERT_NE(EGL_NO_CONTEXT, mEglContext);
+
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    EGLint w, h;
+    EXPECT_TRUE(eglQuerySurface(mEglDisplay, mEglSurface, EGL_WIDTH, &w));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+    EXPECT_TRUE(eglQuerySurface(mEglDisplay, mEglSurface, EGL_HEIGHT, &h));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+    RecordProperty("EglSurfaceWidth", w);
+    RecordProperty("EglSurfaceHeight", h);
+
+    glViewport(0, 0, w, h);
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+}
+
+void GLTest::TearDown() {
+    // Display the result
+    if (mDisplaySecs > 0 && mEglSurface != EGL_NO_SURFACE) {
+        eglSwapBuffers(mEglDisplay, mEglSurface);
+        sleep(mDisplaySecs);
+    }
+
+    if (mComposerClient != NULL) {
+        mComposerClient->dispose();
+    }
+    if (mEglContext != EGL_NO_CONTEXT) {
+        eglDestroyContext(mEglDisplay, mEglContext);
+    }
+    if (mEglSurface != EGL_NO_SURFACE) {
+        eglDestroySurface(mEglDisplay, mEglSurface);
+    }
+    if (mEglDisplay != EGL_NO_DISPLAY) {
+        eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
+                EGL_NO_CONTEXT);
+        eglTerminate(mEglDisplay);
+    }
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    const ::testing::TestInfo* const testInfo =
+        ::testing::UnitTest::GetInstance()->current_test_info();
+    ALOGV("End test:   %s.%s", testInfo->test_case_name(), testInfo->name());
+}
+
+EGLint const* GLTest::getConfigAttribs() {
+    static const EGLint sDefaultConfigAttribs[] = {
+        EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
+        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+        EGL_RED_SIZE, 8,
+        EGL_GREEN_SIZE, 8,
+        EGL_BLUE_SIZE, 8,
+        EGL_ALPHA_SIZE, 8,
+        EGL_DEPTH_SIZE, 16,
+        EGL_STENCIL_SIZE, 8,
+        EGL_NONE };
+
+    return sDefaultConfigAttribs;
+}
+
+EGLint const* GLTest::getContextAttribs() {
+    static const EGLint sDefaultContextAttribs[] = {
+        EGL_CONTEXT_CLIENT_VERSION, 2,
+        EGL_NONE };
+
+    return sDefaultContextAttribs;
+}
+
+EGLint GLTest::getSurfaceWidth() {
+    return 512;
+}
+
+EGLint GLTest::getSurfaceHeight() {
+    return 512;
+}
+
+EGLSurface GLTest::createWindowSurface(EGLDisplay display, EGLConfig config,
+                                       sp<ANativeWindow>& window) const {
+    return eglCreateWindowSurface(display, config, window.get(), NULL);
+}
+
+::testing::AssertionResult GLTest::checkPixel(int x, int y,
+        int r, int g, int b, int a, int tolerance) {
+    GLubyte pixel[4];
+    String8 msg;
+    glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
+    GLenum err = glGetError();
+    if (err != GL_NO_ERROR) {
+        msg += String8::format("error reading pixel: %#x", err);
+        while ((err = glGetError()) != GL_NO_ERROR) {
+            msg += String8::format(", %#x", err);
+        }
+        return ::testing::AssertionFailure(::testing::Message(msg.string()));
+    }
+    if (r >= 0 && abs(r - int(pixel[0])) > tolerance) {
+        msg += String8::format("r(%d isn't %d)", pixel[0], r);
+    }
+    if (g >= 0 && abs(g - int(pixel[1])) > tolerance) {
+        if (!msg.isEmpty()) {
+            msg += " ";
+        }
+        msg += String8::format("g(%d isn't %d)", pixel[1], g);
+    }
+    if (b >= 0 && abs(b - int(pixel[2])) > tolerance) {
+        if (!msg.isEmpty()) {
+            msg += " ";
+        }
+        msg += String8::format("b(%d isn't %d)", pixel[2], b);
+    }
+    if (a >= 0 && abs(a - int(pixel[3])) > tolerance) {
+        if (!msg.isEmpty()) {
+            msg += " ";
+        }
+        msg += String8::format("a(%d isn't %d)", pixel[3], a);
+    }
+    if (!msg.isEmpty()) {
+        return ::testing::AssertionFailure(::testing::Message(msg.string()));
+    } else {
+        return ::testing::AssertionSuccess();
+    }
+}
+
+::testing::AssertionResult GLTest::assertRectEq(const Rect &r1, const Rect &r2,
+                                                int tolerance) {
+    String8 msg;
+
+    if (abs(r1.left - r2.left) > tolerance) {
+        msg += String8::format("left(%d isn't %d)", r1.left, r2.left);
+    }
+    if (abs(r1.top - r2.top) > tolerance) {
+        if (!msg.isEmpty()) {
+            msg += " ";
+        }
+        msg += String8::format("top(%d isn't %d)", r1.top, r2.top);
+    }
+    if (abs(r1.right - r2.right) > tolerance) {
+        if (!msg.isEmpty()) {
+            msg += " ";
+        }
+        msg += String8::format("right(%d isn't %d)", r1.right, r2.right);
+    }
+    if (abs(r1.bottom - r2.bottom) > tolerance) {
+        if (!msg.isEmpty()) {
+            msg += " ";
+        }
+        msg += String8::format("bottom(%d isn't %d)", r1.bottom, r2.bottom);
+    }
+    if (!msg.isEmpty()) {
+        msg += String8::format(" R1: [%d %d %d %d] R2: [%d %d %d %d]",
+                               r1.left, r1.top, r1.right, r1.bottom,
+                               r2.left, r2.top, r2.right, r2.bottom);
+        fprintf(stderr, "assertRectEq: %s\n", msg.string());
+        return ::testing::AssertionFailure(::testing::Message(msg.string()));
+    } else {
+        return ::testing::AssertionSuccess();
+    }
+}
+
+void GLTest::loadShader(GLenum shaderType, const char* pSource,
+        GLuint* outShader) {
+    GLuint shader = glCreateShader(shaderType);
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+    if (shader) {
+        glShaderSource(shader, 1, &pSource, NULL);
+        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+        glCompileShader(shader);
+        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+        GLint compiled = 0;
+        glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
+        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+        if (!compiled) {
+            GLint infoLen = 0;
+            glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
+            ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+            if (infoLen) {
+                char* buf = (char*) malloc(infoLen);
+                if (buf) {
+                    glGetShaderInfoLog(shader, infoLen, NULL, buf);
+                    printf("Shader compile log:\n%s\n", buf);
+                    free(buf);
+                    FAIL();
+                }
+            } else {
+                char* buf = (char*) malloc(0x1000);
+                if (buf) {
+                    glGetShaderInfoLog(shader, 0x1000, NULL, buf);
+                    printf("Shader compile log:\n%s\n", buf);
+                    free(buf);
+                    FAIL();
+                }
+            }
+            glDeleteShader(shader);
+            shader = 0;
+        }
+    }
+    ASSERT_TRUE(shader != 0);
+    *outShader = shader;
+}
+
+void GLTest::createProgram(const char* pVertexSource,
+        const char* pFragmentSource, GLuint* outPgm) {
+    GLuint vertexShader, fragmentShader;
+    {
+        SCOPED_TRACE("compiling vertex shader");
+        ASSERT_NO_FATAL_FAILURE(loadShader(GL_VERTEX_SHADER, pVertexSource,
+                &vertexShader));
+    }
+    {
+        SCOPED_TRACE("compiling fragment shader");
+        ASSERT_NO_FATAL_FAILURE(loadShader(GL_FRAGMENT_SHADER, pFragmentSource,
+                &fragmentShader));
+    }
+
+    GLuint program = glCreateProgram();
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+    if (program) {
+        glAttachShader(program, vertexShader);
+        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+        glAttachShader(program, fragmentShader);
+        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+        glLinkProgram(program);
+        GLint linkStatus = GL_FALSE;
+        glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
+        if (linkStatus != GL_TRUE) {
+            GLint bufLength = 0;
+            glGetProgramiv(program, GL_INFO_LOG_LENGTH, &bufLength);
+            if (bufLength) {
+                char* buf = (char*) malloc(bufLength);
+                if (buf) {
+                    glGetProgramInfoLog(program, bufLength, NULL, buf);
+                    printf("Program link log:\n%s\n", buf);
+                    free(buf);
+                    FAIL();
+                }
+            }
+            glDeleteProgram(program);
+            program = 0;
+        }
+    }
+    glDeleteShader(vertexShader);
+    glDeleteShader(fragmentShader);
+    ASSERT_TRUE(program != 0);
+    *outPgm = program;
+}
+
+} // namespace android
diff --git a/libs/gui/tests/GLTest.h b/libs/gui/tests/GLTest.h
new file mode 100644
index 0000000..d3c4a95
--- /dev/null
+++ b/libs/gui/tests/GLTest.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_GL_TEST_H
+#define ANDROID_GL_TEST_H
+
+#include <gtest/gtest.h>
+
+#include <gui/SurfaceComposerClient.h>
+
+#include <EGL/egl.h>
+#include <GLES/gl.h>
+
+namespace android {
+
+class GLTest : public ::testing::Test {
+public:
+    static void loadShader(GLenum shaderType, const char* pSource,
+            GLuint* outShader);
+    static void createProgram(const char* pVertexSource,
+            const char* pFragmentSource, GLuint* outPgm);
+
+protected:
+    GLTest() :
+            mEglDisplay(EGL_NO_DISPLAY),
+            mEglSurface(EGL_NO_SURFACE),
+            mEglContext(EGL_NO_CONTEXT) {
+    }
+
+    virtual void SetUp();
+    virtual void TearDown();
+
+    virtual EGLint const* getConfigAttribs();
+    virtual EGLint const* getContextAttribs();
+    virtual EGLint getSurfaceWidth();
+    virtual EGLint getSurfaceHeight();
+    virtual EGLSurface createWindowSurface(EGLDisplay display, EGLConfig config,
+                                           sp<ANativeWindow>& window) const;
+
+    ::testing::AssertionResult checkPixel(int x, int y,
+            int r, int g, int b, int a, int tolerance = 2);
+    ::testing::AssertionResult assertRectEq(const Rect &r1, const Rect &r2,
+            int tolerance = 1);
+
+    int mDisplaySecs;
+    sp<SurfaceComposerClient> mComposerClient;
+    sp<SurfaceControl> mSurfaceControl;
+
+    EGLDisplay mEglDisplay;
+    EGLSurface mEglSurface;
+    EGLContext mEglContext;
+    EGLConfig  mGlConfig;
+};
+
+} // namespace android
+
+#endif
diff --git a/libs/gui/tests/IGraphicBufferProducer_test.cpp b/libs/gui/tests/IGraphicBufferProducer_test.cpp
new file mode 100644
index 0000000..4ef9a69
--- /dev/null
+++ b/libs/gui/tests/IGraphicBufferProducer_test.cpp
@@ -0,0 +1,572 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "IGraphicBufferProducer_test"
+//#define LOG_NDEBUG 0
+
+#include <gtest/gtest.h>
+
+#include <utils/String8.h>
+#include <utils/threads.h>
+
+#include <ui/GraphicBuffer.h>
+
+#include <gui/BufferQueue.h>
+#include <gui/IProducerListener.h>
+
+#include <vector>
+
+#define ASSERT_OK(x) ASSERT_EQ(OK, (x))
+#define EXPECT_OK(x) EXPECT_EQ(OK, (x))
+
+#define TEST_TOKEN ((IProducerListener*)(NULL))
+#define TEST_API NATIVE_WINDOW_API_CPU
+#define TEST_API_OTHER NATIVE_WINDOW_API_EGL // valid API that's not TEST_API
+#define TEST_CONTROLLED_BY_APP false
+#define TEST_PRODUCER_USAGE_BITS (0)
+
+namespace android {
+
+namespace {
+    // Default dimensions before setDefaultBufferSize is called
+    const uint32_t DEFAULT_WIDTH = 1;
+    const uint32_t DEFAULT_HEIGHT = 1;
+
+    // Default format before setDefaultBufferFormat is called
+    const PixelFormat DEFAULT_FORMAT = HAL_PIXEL_FORMAT_RGBA_8888;
+
+    // Default transform hint before setTransformHint is called
+    const uint32_t DEFAULT_TRANSFORM_HINT = 0;
+
+    // TODO: Make these constants in header
+    const int DEFAULT_CONSUMER_USAGE_BITS = 0;
+
+    // Parameters for a generic "valid" input for queueBuffer.
+    const int64_t QUEUE_BUFFER_INPUT_TIMESTAMP = 1384888611;
+    const bool QUEUE_BUFFER_INPUT_IS_AUTO_TIMESTAMP = false;
+    const android_dataspace QUEUE_BUFFER_INPUT_DATASPACE = HAL_DATASPACE_UNKNOWN;
+    const Rect QUEUE_BUFFER_INPUT_RECT = Rect(DEFAULT_WIDTH, DEFAULT_HEIGHT);
+    const int QUEUE_BUFFER_INPUT_SCALING_MODE = 0;
+    const int QUEUE_BUFFER_INPUT_TRANSFORM = 0;
+    const bool QUEUE_BUFFER_INPUT_ASYNC = false;
+    const sp<Fence> QUEUE_BUFFER_INPUT_FENCE = Fence::NO_FENCE;
+}; // namespace anonymous
+
+struct DummyConsumer : public BnConsumerListener {
+    virtual void onFrameAvailable(const BufferItem& /* item */) {}
+    virtual void onBuffersReleased() {}
+    virtual void onSidebandStreamChanged() {}
+};
+
+class IGraphicBufferProducerTest : public ::testing::Test {
+protected:
+
+    IGraphicBufferProducerTest() {}
+
+    virtual void SetUp() {
+        const ::testing::TestInfo* const testInfo =
+            ::testing::UnitTest::GetInstance()->current_test_info();
+        ALOGV("Begin test: %s.%s", testInfo->test_case_name(),
+                testInfo->name());
+
+        mDC = new DummyConsumer;
+
+        BufferQueue::createBufferQueue(&mProducer, &mConsumer);
+
+        // Test check: Can't connect producer if no consumer yet
+        ASSERT_EQ(NO_INIT, TryConnectProducer());
+
+        // Must connect consumer before producer connects will succeed.
+        ASSERT_OK(mConsumer->consumerConnect(mDC, /*controlledByApp*/false));
+    }
+
+    virtual void TearDown() {
+        const ::testing::TestInfo* const testInfo =
+            ::testing::UnitTest::GetInstance()->current_test_info();
+        ALOGV("End test:   %s.%s", testInfo->test_case_name(),
+                testInfo->name());
+    }
+
+    status_t TryConnectProducer() {
+        IGraphicBufferProducer::QueueBufferOutput output;
+        return mProducer->connect(TEST_TOKEN,
+                                  TEST_API,
+                                  TEST_CONTROLLED_BY_APP,
+                                  &output);
+        // TODO: use params to vary token, api, producercontrolledbyapp, etc
+    }
+
+    // Connect to a producer in a 'correct' fashion.
+    //   Precondition: Consumer is connected.
+    void ConnectProducer() {
+        ASSERT_OK(TryConnectProducer());
+    }
+
+    // Create a generic "valid" input for queueBuffer
+    // -- uses the default buffer format, width, etc.
+    static IGraphicBufferProducer::QueueBufferInput CreateBufferInput() {
+        return QueueBufferInputBuilder().build();
+    }
+
+    // Builder pattern to slightly vary *almost* correct input
+    // -- avoids copying and pasting
+    struct QueueBufferInputBuilder {
+        QueueBufferInputBuilder() {
+           timestamp = QUEUE_BUFFER_INPUT_TIMESTAMP;
+           isAutoTimestamp = QUEUE_BUFFER_INPUT_IS_AUTO_TIMESTAMP;
+           dataSpace = QUEUE_BUFFER_INPUT_DATASPACE;
+           crop = QUEUE_BUFFER_INPUT_RECT;
+           scalingMode = QUEUE_BUFFER_INPUT_SCALING_MODE;
+           transform = QUEUE_BUFFER_INPUT_TRANSFORM;
+           async = QUEUE_BUFFER_INPUT_ASYNC;
+           fence = QUEUE_BUFFER_INPUT_FENCE;
+        }
+
+        IGraphicBufferProducer::QueueBufferInput build() {
+            return IGraphicBufferProducer::QueueBufferInput(
+                    timestamp,
+                    isAutoTimestamp,
+                    dataSpace,
+                    crop,
+                    scalingMode,
+                    transform,
+                    async,
+                    fence);
+        }
+
+        QueueBufferInputBuilder& setTimestamp(int64_t timestamp) {
+            this->timestamp = timestamp;
+            return *this;
+        }
+
+        QueueBufferInputBuilder& setIsAutoTimestamp(bool isAutoTimestamp) {
+            this->isAutoTimestamp = isAutoTimestamp;
+            return *this;
+        }
+
+        QueueBufferInputBuilder& setDataSpace(android_dataspace dataSpace) {
+            this->dataSpace = dataSpace;
+            return *this;
+        }
+
+        QueueBufferInputBuilder& setCrop(Rect crop) {
+            this->crop = crop;
+            return *this;
+        }
+
+        QueueBufferInputBuilder& setScalingMode(int scalingMode) {
+            this->scalingMode = scalingMode;
+            return *this;
+        }
+
+        QueueBufferInputBuilder& setTransform(uint32_t transform) {
+            this->transform = transform;
+            return *this;
+        }
+
+        QueueBufferInputBuilder& setAsync(bool async) {
+            this->async = async;
+            return *this;
+        }
+
+        QueueBufferInputBuilder& setFence(sp<Fence> fence) {
+            this->fence = fence;
+            return *this;
+        }
+
+    private:
+        int64_t timestamp;
+        bool isAutoTimestamp;
+        android_dataspace dataSpace;
+        Rect crop;
+        int scalingMode;
+        uint32_t transform;
+        int async;
+        sp<Fence> fence;
+    }; // struct QueueBufferInputBuilder
+
+    // To easily store dequeueBuffer results into containers
+    struct DequeueBufferResult {
+        int slot;
+        sp<Fence> fence;
+    };
+
+    status_t dequeueBuffer(bool async, uint32_t w, uint32_t h, uint32_t format, uint32_t usage, DequeueBufferResult* result) {
+        return mProducer->dequeueBuffer(&result->slot, &result->fence, async, w, h, format, usage);
+    }
+
+private: // hide from test body
+    sp<DummyConsumer> mDC;
+
+protected: // accessible from test body
+    sp<IGraphicBufferProducer> mProducer;
+    sp<IGraphicBufferConsumer> mConsumer;
+};
+
+TEST_F(IGraphicBufferProducerTest, ConnectFirst_ReturnsError) {
+    IGraphicBufferProducer::QueueBufferOutput output;
+
+    // NULL output returns BAD_VALUE
+    EXPECT_EQ(BAD_VALUE, mProducer->connect(TEST_TOKEN,
+                                            TEST_API,
+                                            TEST_CONTROLLED_BY_APP,
+                                            /*output*/NULL));
+
+    // Invalid API returns bad value
+    EXPECT_EQ(BAD_VALUE, mProducer->connect(TEST_TOKEN,
+                                            /*api*/0xDEADBEEF,
+                                            TEST_CONTROLLED_BY_APP,
+                                            &output));
+
+    // TODO: get a token from a dead process somehow
+}
+
+TEST_F(IGraphicBufferProducerTest, ConnectAgain_ReturnsError) {
+    ASSERT_NO_FATAL_FAILURE(ConnectProducer());
+
+    // Can't connect when there is already a producer connected
+    IGraphicBufferProducer::QueueBufferOutput output;
+    EXPECT_EQ(BAD_VALUE, mProducer->connect(TEST_TOKEN,
+                                            TEST_API,
+                                            TEST_CONTROLLED_BY_APP,
+                                            &output));
+
+    ASSERT_OK(mConsumer->consumerDisconnect());
+    // Can't connect when IGBP is abandoned
+    EXPECT_EQ(NO_INIT, mProducer->connect(TEST_TOKEN,
+                                          TEST_API,
+                                          TEST_CONTROLLED_BY_APP,
+                                          &output));
+}
+
+TEST_F(IGraphicBufferProducerTest, Disconnect_Succeeds) {
+    ASSERT_NO_FATAL_FAILURE(ConnectProducer());
+
+    ASSERT_OK(mProducer->disconnect(TEST_API));
+}
+
+
+TEST_F(IGraphicBufferProducerTest, Disconnect_ReturnsError) {
+    ASSERT_NO_FATAL_FAILURE(ConnectProducer());
+
+    // Must disconnect with same API number
+    ASSERT_EQ(BAD_VALUE, mProducer->disconnect(TEST_API_OTHER));
+    // API must not be out of range
+    ASSERT_EQ(BAD_VALUE, mProducer->disconnect(/*api*/0xDEADBEEF));
+
+    // TODO: somehow kill mProducer so that this returns DEAD_OBJECT
+}
+
+TEST_F(IGraphicBufferProducerTest, Query_Succeeds) {
+    ASSERT_NO_FATAL_FAILURE(ConnectProducer());
+
+    int32_t value = -1;
+    EXPECT_OK(mProducer->query(NATIVE_WINDOW_WIDTH, &value));
+    EXPECT_EQ(DEFAULT_WIDTH, static_cast<uint32_t>(value));
+
+    EXPECT_OK(mProducer->query(NATIVE_WINDOW_HEIGHT, &value));
+    EXPECT_EQ(DEFAULT_HEIGHT, static_cast<uint32_t>(value));
+
+    EXPECT_OK(mProducer->query(NATIVE_WINDOW_FORMAT, &value));
+    EXPECT_EQ(DEFAULT_FORMAT, value);
+
+    EXPECT_OK(mProducer->query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, &value));
+    EXPECT_LE(0, value);
+    EXPECT_GE(BufferQueue::NUM_BUFFER_SLOTS, value);
+
+    EXPECT_OK(mProducer->query(NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND, &value));
+    EXPECT_FALSE(value); // Can't run behind when we haven't touched the queue
+
+    EXPECT_OK(mProducer->query(NATIVE_WINDOW_CONSUMER_USAGE_BITS, &value));
+    EXPECT_EQ(DEFAULT_CONSUMER_USAGE_BITS, value);
+
+}
+
+TEST_F(IGraphicBufferProducerTest, Query_ReturnsError) {
+    ASSERT_NO_FATAL_FAILURE(ConnectProducer());
+
+    // One past the end of the last 'query' enum value. Update this if we add more enums.
+    const int NATIVE_WINDOW_QUERY_LAST_OFF_BY_ONE = NATIVE_WINDOW_BUFFER_AGE + 1;
+
+    int value;
+    // What was out of range
+    EXPECT_EQ(BAD_VALUE, mProducer->query(/*what*/-1, &value));
+    EXPECT_EQ(BAD_VALUE, mProducer->query(/*what*/0xDEADBEEF, &value));
+    EXPECT_EQ(BAD_VALUE, mProducer->query(NATIVE_WINDOW_QUERY_LAST_OFF_BY_ONE, &value));
+
+    // Some enums from window.h are 'invalid'
+    EXPECT_EQ(BAD_VALUE, mProducer->query(NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER, &value));
+    EXPECT_EQ(BAD_VALUE, mProducer->query(NATIVE_WINDOW_CONCRETE_TYPE, &value));
+    EXPECT_EQ(BAD_VALUE, mProducer->query(NATIVE_WINDOW_DEFAULT_WIDTH, &value));
+    EXPECT_EQ(BAD_VALUE, mProducer->query(NATIVE_WINDOW_DEFAULT_HEIGHT, &value));
+    EXPECT_EQ(BAD_VALUE, mProducer->query(NATIVE_WINDOW_TRANSFORM_HINT, &value));
+    // TODO: Consider documented the above enums as unsupported or make a new enum for IGBP
+
+    // Value was NULL
+    EXPECT_EQ(BAD_VALUE, mProducer->query(NATIVE_WINDOW_FORMAT, /*value*/NULL));
+
+    ASSERT_OK(mConsumer->consumerDisconnect());
+
+    // BQ was abandoned
+    EXPECT_EQ(NO_INIT, mProducer->query(NATIVE_WINDOW_FORMAT, &value));
+
+    // TODO: other things in window.h that are supported by Surface::query
+    // but not by BufferQueue::query
+}
+
+// TODO: queue under more complicated situations not involving just a single buffer
+TEST_F(IGraphicBufferProducerTest, Queue_Succeeds) {
+    ASSERT_NO_FATAL_FAILURE(ConnectProducer());
+
+    int dequeuedSlot = -1;
+    sp<Fence> dequeuedFence;
+
+    // XX: OK to assume first call returns this flag or not? Not really documented.
+    ASSERT_EQ(OK | IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
+            mProducer->dequeueBuffer(&dequeuedSlot, &dequeuedFence,
+                                     QUEUE_BUFFER_INPUT_ASYNC,
+                                     DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_FORMAT,
+                                     TEST_PRODUCER_USAGE_BITS));
+
+    EXPECT_LE(0, dequeuedSlot);
+    EXPECT_GT(BufferQueue::NUM_BUFFER_SLOTS, dequeuedSlot);
+
+    // Request the buffer (pre-requisite for queueing)
+    sp<GraphicBuffer> dequeuedBuffer;
+    ASSERT_OK(mProducer->requestBuffer(dequeuedSlot, &dequeuedBuffer));
+
+    // A generic "valid" input
+    IGraphicBufferProducer::QueueBufferInput input = CreateBufferInput();
+    IGraphicBufferProducer::QueueBufferOutput output;
+
+    // Queue the buffer back into the BQ
+    ASSERT_OK(mProducer->queueBuffer(dequeuedSlot, input, &output));
+
+    {
+        uint32_t width;
+        uint32_t height;
+        uint32_t transformHint;
+        uint32_t numPendingBuffers;
+
+        output.deflate(&width, &height, &transformHint, &numPendingBuffers);
+
+        EXPECT_EQ(DEFAULT_WIDTH, width);
+        EXPECT_EQ(DEFAULT_HEIGHT, height);
+        EXPECT_EQ(DEFAULT_TRANSFORM_HINT, transformHint);
+        EXPECT_EQ(1u, numPendingBuffers); // since queueBuffer was called exactly once
+    }
+
+    // Buffer was not in the dequeued state
+    EXPECT_EQ(BAD_VALUE, mProducer->queueBuffer(dequeuedSlot, input, &output));
+}
+
+TEST_F(IGraphicBufferProducerTest, Queue_ReturnsError) {
+    ASSERT_NO_FATAL_FAILURE(ConnectProducer());
+
+    // Invalid slot number
+    {
+        // A generic "valid" input
+        IGraphicBufferProducer::QueueBufferInput input = CreateBufferInput();
+        IGraphicBufferProducer::QueueBufferOutput output;
+
+        EXPECT_EQ(BAD_VALUE, mProducer->queueBuffer(/*slot*/-1, input, &output));
+        EXPECT_EQ(BAD_VALUE, mProducer->queueBuffer(/*slot*/0xDEADBEEF, input, &output));
+        EXPECT_EQ(BAD_VALUE, mProducer->queueBuffer(BufferQueue::NUM_BUFFER_SLOTS,
+                                                    input, &output));
+    }
+
+    // Slot was not in the dequeued state (all slots start out in Free state)
+    {
+        IGraphicBufferProducer::QueueBufferInput input = CreateBufferInput();
+        IGraphicBufferProducer::QueueBufferOutput output;
+
+        EXPECT_EQ(BAD_VALUE, mProducer->queueBuffer(/*slot*/0, input, &output));
+    }
+
+    // Put the slot into the "dequeued" state for the rest of the test
+    int dequeuedSlot = -1;
+    sp<Fence> dequeuedFence;
+
+    ASSERT_EQ(OK | IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
+            mProducer->dequeueBuffer(&dequeuedSlot, &dequeuedFence,
+                                     QUEUE_BUFFER_INPUT_ASYNC,
+                                     DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_FORMAT,
+                                     TEST_PRODUCER_USAGE_BITS));
+
+    // Slot was enqueued without requesting a buffer
+    {
+        IGraphicBufferProducer::QueueBufferInput input = CreateBufferInput();
+        IGraphicBufferProducer::QueueBufferOutput output;
+
+        EXPECT_EQ(BAD_VALUE, mProducer->queueBuffer(dequeuedSlot, input, &output));
+    }
+
+    // Request the buffer so that the rest of the tests don't fail on earlier checks.
+    sp<GraphicBuffer> dequeuedBuffer;
+    ASSERT_OK(mProducer->requestBuffer(dequeuedSlot, &dequeuedBuffer));
+
+    // Fence was NULL
+    {
+        sp<Fence> nullFence = NULL;
+
+        IGraphicBufferProducer::QueueBufferInput input =
+                QueueBufferInputBuilder().setFence(nullFence).build();
+        IGraphicBufferProducer::QueueBufferOutput output;
+
+        EXPECT_EQ(BAD_VALUE, mProducer->queueBuffer(dequeuedSlot, input, &output));
+    }
+
+    // Scaling mode was unknown
+    {
+        IGraphicBufferProducer::QueueBufferInput input =
+                QueueBufferInputBuilder().setScalingMode(-1).build();
+        IGraphicBufferProducer::QueueBufferOutput output;
+
+        EXPECT_EQ(BAD_VALUE, mProducer->queueBuffer(dequeuedSlot, input, &output));
+
+        input = QueueBufferInputBuilder().setScalingMode(0xDEADBEEF).build();
+
+        EXPECT_EQ(BAD_VALUE, mProducer->queueBuffer(dequeuedSlot, input, &output));
+    }
+
+    // Crop rect is out of bounds of the buffer dimensions
+    {
+        IGraphicBufferProducer::QueueBufferInput input =
+                QueueBufferInputBuilder().setCrop(Rect(DEFAULT_WIDTH + 1, DEFAULT_HEIGHT + 1))
+                .build();
+        IGraphicBufferProducer::QueueBufferOutput output;
+
+        EXPECT_EQ(BAD_VALUE, mProducer->queueBuffer(dequeuedSlot, input, &output));
+    }
+
+    // Abandon the buffer queue so that the last test fails
+    ASSERT_OK(mConsumer->consumerDisconnect());
+
+    // The buffer queue has been abandoned.
+    {
+        IGraphicBufferProducer::QueueBufferInput input = CreateBufferInput();
+        IGraphicBufferProducer::QueueBufferOutput output;
+
+        EXPECT_EQ(NO_INIT, mProducer->queueBuffer(dequeuedSlot, input, &output));
+    }
+}
+
+TEST_F(IGraphicBufferProducerTest, CancelBuffer_DoesntCrash) {
+    ASSERT_NO_FATAL_FAILURE(ConnectProducer());
+
+    int dequeuedSlot = -1;
+    sp<Fence> dequeuedFence;
+
+    ASSERT_EQ(OK | IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
+            mProducer->dequeueBuffer(&dequeuedSlot, &dequeuedFence,
+                                     QUEUE_BUFFER_INPUT_ASYNC,
+                                     DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_FORMAT,
+                                     TEST_PRODUCER_USAGE_BITS));
+
+    // No return code, but at least test that it doesn't blow up...
+    // TODO: add a return code
+    mProducer->cancelBuffer(dequeuedSlot, dequeuedFence);
+}
+
+TEST_F(IGraphicBufferProducerTest, SetBufferCount_Succeeds) {
+
+    // The producer does not wish to set a buffer count
+    EXPECT_OK(mProducer->setBufferCount(0)) << "bufferCount: " << 0;
+    // TODO: how to test "0" buffer count?
+
+    int minBuffers;
+    ASSERT_OK(mProducer->query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, &minBuffers));
+
+    // The MIN_UNDEQUEUED_BUFFERS limit is exclusive, so need to increment by at least 1
+    minBuffers++;
+
+    ASSERT_OK(mProducer->setBufferCount(minBuffers)) << "bufferCount: " << minBuffers;
+
+    std::vector<DequeueBufferResult> dequeueList;
+
+    // Should now be able to dequeue up to minBuffers times
+    for (int i = 0; i < minBuffers; ++i) {
+        DequeueBufferResult result;
+
+        EXPECT_LE(OK,
+                dequeueBuffer(QUEUE_BUFFER_INPUT_ASYNC,
+                              DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_FORMAT,
+                              TEST_PRODUCER_USAGE_BITS, &result))
+                << "iteration: " << i << ", slot: " << result.slot;
+
+        dequeueList.push_back(result);
+    }
+
+    // Cancel every buffer, so we can set buffer count again
+    for (int i = 0; i < minBuffers; ++i) {
+        DequeueBufferResult& result = dequeueList[i];
+        mProducer->cancelBuffer(result.slot, result.fence);
+    }
+
+    ASSERT_OK(mProducer->setBufferCount(BufferQueue::NUM_BUFFER_SLOTS));
+
+    // Should now be able to dequeue up to NUM_BUFFER_SLOTS times
+    for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; ++i) {
+        int dequeuedSlot = -1;
+        sp<Fence> dequeuedFence;
+
+        EXPECT_LE(OK,
+                mProducer->dequeueBuffer(&dequeuedSlot, &dequeuedFence,
+                                         QUEUE_BUFFER_INPUT_ASYNC,
+                                         DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_FORMAT,
+                                         TEST_PRODUCER_USAGE_BITS))
+                << "iteration: " << i << ", slot: " << dequeuedSlot;
+    }
+}
+
+TEST_F(IGraphicBufferProducerTest, SetBufferCount_Fails) {
+    int minBuffers;
+    ASSERT_OK(mProducer->query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, &minBuffers));
+
+    // The MIN_UNDEQUEUED_BUFFERS limit is exclusive, so need to increment by at least 1
+    minBuffers++;
+
+    // Buffer count was out of range
+    EXPECT_EQ(BAD_VALUE, mProducer->setBufferCount(-1)) << "bufferCount: " << -1;
+    EXPECT_EQ(BAD_VALUE, mProducer->setBufferCount(minBuffers - 1)) << "bufferCount: " << minBuffers - 1;
+    EXPECT_EQ(BAD_VALUE, mProducer->setBufferCount(BufferQueue::NUM_BUFFER_SLOTS + 1))
+            << "bufferCount: " << BufferQueue::NUM_BUFFER_SLOTS + 1;
+
+    // Pre-requisite to fail out a valid setBufferCount call
+    {
+        int dequeuedSlot = -1;
+        sp<Fence> dequeuedFence;
+
+        ASSERT_LE(OK,
+                mProducer->dequeueBuffer(&dequeuedSlot, &dequeuedFence,
+                                         QUEUE_BUFFER_INPUT_ASYNC,
+                                         DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_FORMAT,
+                                         TEST_PRODUCER_USAGE_BITS))
+                << "slot: " << dequeuedSlot;
+    }
+
+    // Client has one or more buffers dequeued
+    EXPECT_EQ(BAD_VALUE, mProducer->setBufferCount(minBuffers)) << "bufferCount: " << minBuffers;
+
+    // Abandon buffer queue
+    ASSERT_OK(mConsumer->consumerDisconnect());
+
+    // Fail because the buffer queue was abandoned
+    EXPECT_EQ(NO_INIT, mProducer->setBufferCount(minBuffers)) << "bufferCount: " << minBuffers;
+
+}
+
+} // namespace android
diff --git a/libs/gui/tests/MultiTextureConsumer_test.cpp b/libs/gui/tests/MultiTextureConsumer_test.cpp
new file mode 100644
index 0000000..3a25ac5
--- /dev/null
+++ b/libs/gui/tests/MultiTextureConsumer_test.cpp
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "MultiTextureConsumer_test"
+//#define LOG_NDEBUG 0
+
+#include "GLTest.h"
+
+#include <gui/GLConsumer.h>
+#include <gui/Surface.h>
+
+#include <android/native_window.h>
+
+#include <GLES/glext.h>
+
+namespace android {
+
+class MultiTextureConsumerTest : public GLTest {
+protected:
+    enum { TEX_ID = 123 };
+
+    virtual void SetUp() {
+        GLTest::SetUp();
+        sp<IGraphicBufferProducer> producer;
+        sp<IGraphicBufferConsumer> consumer;
+        BufferQueue::createBufferQueue(&producer, &consumer);
+        mGlConsumer = new GLConsumer(consumer, TEX_ID,
+                GLConsumer::TEXTURE_EXTERNAL, true, false);
+        mSurface = new Surface(producer);
+        mANW = mSurface.get();
+
+    }
+    virtual void TearDown() {
+        GLTest::TearDown();
+    }
+    virtual EGLint const* getContextAttribs() {
+        return NULL;
+    }
+    virtual EGLint const* getConfigAttribs() {
+        static EGLint sDefaultConfigAttribs[] = {
+            EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
+            EGL_RED_SIZE, 8,
+            EGL_GREEN_SIZE, 8,
+            EGL_BLUE_SIZE, 8,
+            EGL_ALPHA_SIZE, 8,
+            EGL_NONE };
+
+        return sDefaultConfigAttribs;
+    }
+    sp<GLConsumer> mGlConsumer;
+    sp<Surface> mSurface;
+    ANativeWindow* mANW;
+};
+
+TEST_F(MultiTextureConsumerTest, EGLImageTargetWorks) {
+    ANativeWindow_Buffer buffer;
+
+    ASSERT_EQ(native_window_set_usage(mANW, GRALLOC_USAGE_SW_WRITE_OFTEN), NO_ERROR);
+    ASSERT_EQ(native_window_set_buffers_format(mANW, HAL_PIXEL_FORMAT_RGBA_8888), NO_ERROR);
+
+    glShadeModel(GL_FLAT);
+    glDisable(GL_DITHER);
+    glDisable(GL_CULL_FACE);
+    glViewport(0, 0, getSurfaceWidth(), getSurfaceHeight());
+    glOrthof(0, getSurfaceWidth(), 0, getSurfaceHeight(), 0, 1);
+    glEnableClientState(GL_VERTEX_ARRAY);
+    glColor4f(1, 1, 1, 1);
+
+    glBindTexture(GL_TEXTURE_EXTERNAL_OES, TEX_ID);
+    glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+    glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+    glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+    uint32_t texel = 0x80808080;
+    glBindTexture(GL_TEXTURE_2D, TEX_ID+1);
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &texel);
+    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+    glActiveTexture(GL_TEXTURE1);
+    glBindTexture(GL_TEXTURE_2D, TEX_ID+1);
+    glEnable(GL_TEXTURE_2D);
+    glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+    glActiveTexture(GL_TEXTURE0);
+    glBindTexture(GL_TEXTURE_EXTERNAL_OES, TEX_ID);
+    glEnable(GL_TEXTURE_EXTERNAL_OES);
+    glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+    glClear(GL_COLOR_BUFFER_BIT);
+    for (int i=0 ; i<8 ; i++) {
+        mSurface->lock(&buffer, NULL);
+        memset(buffer.bits, (i&7) * 0x20, buffer.stride * buffer.height * 4);
+        mSurface->unlockAndPost();
+
+        mGlConsumer->updateTexImage();
+
+        GLfloat vertices[][2] = { {i*16.0f, 0}, {(i+1)*16.0f, 0}, {(i+1)*16.0f, 16.0f}, {i*16.0f, 16.0f} };
+        glVertexPointer(2, GL_FLOAT, 0, vertices);
+        glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+    }
+
+    for (int i=0 ; i<8 ; i++) {
+        EXPECT_TRUE(checkPixel(i*16 + 8,  8, i*16, i*16, i*16, i*16, 0));
+    }
+}
+
+} // namespace android
diff --git a/libs/gui/tests/SRGB_test.cpp b/libs/gui/tests/SRGB_test.cpp
new file mode 100644
index 0000000..3b11b97
--- /dev/null
+++ b/libs/gui/tests/SRGB_test.cpp
@@ -0,0 +1,489 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "SRGB_test"
+//#define LOG_NDEBUG 0
+
+// Ignore for this file because it flags every instance of
+// ASSERT_EQ(GL_NO_ERROR, glGetError());
+#pragma clang diagnostic ignored "-Wsign-compare"
+
+#include "GLTest.h"
+
+#include <math.h>
+
+#include <gui/CpuConsumer.h>
+#include <gui/Surface.h>
+#include <gui/SurfaceComposerClient.h>
+
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <GLES3/gl3.h>
+
+#include <android/native_window.h>
+
+#include <gtest/gtest.h>
+
+namespace android {
+
+class SRGBTest : public ::testing::Test {
+protected:
+    // Class constants
+    enum {
+        DISPLAY_WIDTH = 512,
+        DISPLAY_HEIGHT = 512,
+        PIXEL_SIZE = 4, // bytes or components
+        DISPLAY_SIZE = DISPLAY_WIDTH * DISPLAY_HEIGHT * PIXEL_SIZE,
+        ALPHA_VALUE = 223, // should be in [0, 255]
+        TOLERANCE = 1,
+    };
+    static const char SHOW_DEBUG_STRING[];
+
+    SRGBTest() :
+            mInputSurface(), mCpuConsumer(), mLockedBuffer(),
+            mEglDisplay(EGL_NO_DISPLAY), mEglConfig(),
+            mEglContext(EGL_NO_CONTEXT), mEglSurface(EGL_NO_SURFACE),
+            mComposerClient(), mSurfaceControl(), mOutputSurface() {
+    }
+
+    virtual ~SRGBTest() {
+        if (mEglDisplay != EGL_NO_DISPLAY) {
+            if (mEglSurface != EGL_NO_SURFACE) {
+                eglDestroySurface(mEglDisplay, mEglSurface);
+            }
+            if (mEglContext != EGL_NO_CONTEXT) {
+                eglDestroyContext(mEglDisplay, mEglContext);
+            }
+            eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
+                    EGL_NO_CONTEXT);
+            eglTerminate(mEglDisplay);
+        }
+    }
+
+    virtual void SetUp() {
+        sp<IGraphicBufferProducer> producer;
+        sp<IGraphicBufferConsumer> consumer;
+        BufferQueue::createBufferQueue(&producer, &consumer);
+        ASSERT_EQ(NO_ERROR, consumer->setDefaultBufferSize(
+                DISPLAY_WIDTH, DISPLAY_HEIGHT));
+        mCpuConsumer = new CpuConsumer(consumer, 1);
+        String8 name("CpuConsumer_for_SRGBTest");
+        mCpuConsumer->setName(name);
+        mInputSurface = new Surface(producer);
+
+        ASSERT_NO_FATAL_FAILURE(createEGLSurface(mInputSurface.get()));
+        ASSERT_NO_FATAL_FAILURE(createDebugSurface());
+    }
+
+    virtual void TearDown() {
+        ASSERT_NO_FATAL_FAILURE(copyToDebugSurface());
+        ASSERT_TRUE(mLockedBuffer.data != NULL);
+        ASSERT_EQ(NO_ERROR, mCpuConsumer->unlockBuffer(mLockedBuffer));
+    }
+
+    static float linearToSRGB(float l) {
+        if (l <= 0.0031308f) {
+            return l * 12.92f;
+        } else {
+            return 1.055f * pow(l, (1 / 2.4f)) - 0.055f;
+        }
+    }
+
+    static float srgbToLinear(float s) {
+        if (s <= 0.04045) {
+            return s / 12.92f;
+        } else {
+            return pow(((s + 0.055f) / 1.055f), 2.4f);
+        }
+    }
+
+    static uint8_t srgbToLinear(uint8_t u) {
+        float f = u / 255.0f;
+        return static_cast<uint8_t>(srgbToLinear(f) * 255.0f + 0.5f);
+    }
+
+    void fillTexture(bool writeAsSRGB) {
+        uint8_t* textureData = new uint8_t[DISPLAY_SIZE];
+
+        for (int y = 0; y < DISPLAY_HEIGHT; ++y) {
+            for (int x = 0; x < DISPLAY_WIDTH; ++x) {
+                float realValue = static_cast<float>(x) / (DISPLAY_WIDTH - 1);
+                realValue *= ALPHA_VALUE / 255.0f; // Premultiply by alpha
+                if (writeAsSRGB) {
+                    realValue = linearToSRGB(realValue);
+                }
+
+                int offset = (y * DISPLAY_WIDTH + x) * PIXEL_SIZE;
+                for (int c = 0; c < 3; ++c) {
+                    uint8_t intValue = static_cast<uint8_t>(
+                            realValue * 255.0f + 0.5f);
+                    textureData[offset + c] = intValue;
+                }
+                textureData[offset + 3] = ALPHA_VALUE;
+            }
+        }
+
+        glTexImage2D(GL_TEXTURE_2D, 0, writeAsSRGB ? GL_SRGB8_ALPHA8 : GL_RGBA8,
+                DISPLAY_WIDTH, DISPLAY_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+                textureData);
+        ASSERT_EQ(GL_NO_ERROR, glGetError());
+
+        delete[] textureData;
+    }
+
+    void initShaders() {
+        static const char vertexSource[] =
+            "attribute vec4 vPosition;\n"
+            "varying vec2 texCoords;\n"
+            "void main() {\n"
+            "  texCoords = 0.5 * (vPosition.xy + vec2(1.0, 1.0));\n"
+            "  gl_Position = vPosition;\n"
+            "}\n";
+
+        static const char fragmentSource[] =
+            "precision mediump float;\n"
+            "uniform sampler2D texSampler;\n"
+            "varying vec2 texCoords;\n"
+            "void main() {\n"
+            "  gl_FragColor = texture2D(texSampler, texCoords);\n"
+            "}\n";
+
+        GLuint program;
+        {
+            SCOPED_TRACE("Creating shader program");
+            ASSERT_NO_FATAL_FAILURE(GLTest::createProgram(
+                    vertexSource, fragmentSource, &program));
+        }
+
+        GLint positionHandle = glGetAttribLocation(program, "vPosition");
+        ASSERT_EQ(GL_NO_ERROR, glGetError());
+        ASSERT_NE(-1, positionHandle);
+
+        GLint samplerHandle = glGetUniformLocation(program, "texSampler");
+        ASSERT_EQ(GL_NO_ERROR, glGetError());
+        ASSERT_NE(-1, samplerHandle);
+
+        static const GLfloat vertices[] = {
+            -1.0f, 1.0f,
+            -1.0f, -1.0f,
+            1.0f, -1.0f,
+            1.0f, 1.0f,
+        };
+
+        glVertexAttribPointer(positionHandle, 2, GL_FLOAT, GL_FALSE, 0, vertices);
+        ASSERT_EQ(GL_NO_ERROR, glGetError());
+        glEnableVertexAttribArray(positionHandle);
+        ASSERT_EQ(GL_NO_ERROR, glGetError());
+
+        glUseProgram(program);
+        ASSERT_EQ(GL_NO_ERROR, glGetError());
+        glUniform1i(samplerHandle, 0);
+        ASSERT_EQ(GL_NO_ERROR, glGetError());
+
+        GLuint textureHandle;
+        glGenTextures(1, &textureHandle);
+        ASSERT_EQ(GL_NO_ERROR, glGetError());
+        glBindTexture(GL_TEXTURE_2D, textureHandle);
+        ASSERT_EQ(GL_NO_ERROR, glGetError());
+
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+        ASSERT_EQ(GL_NO_ERROR, glGetError());
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+        ASSERT_EQ(GL_NO_ERROR, glGetError());
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        ASSERT_EQ(GL_NO_ERROR, glGetError());
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+        ASSERT_EQ(GL_NO_ERROR, glGetError());
+    }
+
+    void drawTexture(bool asSRGB, GLint x, GLint y, GLsizei width,
+            GLsizei height) {
+        ASSERT_NO_FATAL_FAILURE(fillTexture(asSRGB));
+        glViewport(x, y, width, height);
+        ASSERT_EQ(GL_NO_ERROR, glGetError());
+        glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+        ASSERT_EQ(GL_NO_ERROR, glGetError());
+    }
+
+    void checkLockedBuffer(PixelFormat format, android_dataspace dataSpace) {
+        ASSERT_EQ(mLockedBuffer.format, format);
+        ASSERT_EQ(mLockedBuffer.width, DISPLAY_WIDTH);
+        ASSERT_EQ(mLockedBuffer.height, DISPLAY_HEIGHT);
+        ASSERT_EQ(mLockedBuffer.dataSpace, dataSpace);
+    }
+
+    static bool withinTolerance(int a, int b) {
+        int diff = a - b;
+        return diff >= 0 ? diff <= TOLERANCE : -diff <= TOLERANCE;
+    }
+
+    // Primary producer and consumer
+    sp<Surface> mInputSurface;
+    sp<CpuConsumer> mCpuConsumer;
+    CpuConsumer::LockedBuffer mLockedBuffer;
+
+    EGLDisplay mEglDisplay;
+    EGLConfig mEglConfig;
+    EGLContext mEglContext;
+    EGLSurface mEglSurface;
+
+    // Auxiliary display output
+    sp<SurfaceComposerClient> mComposerClient;
+    sp<SurfaceControl> mSurfaceControl;
+    sp<Surface> mOutputSurface;
+
+private:
+    void createEGLSurface(Surface* inputSurface) {
+        mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+        ASSERT_NE(EGL_NO_DISPLAY, mEglDisplay);
+
+        EXPECT_TRUE(eglInitialize(mEglDisplay, NULL, NULL));
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+        static const EGLint configAttribs[] = {
+            EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
+            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR,
+            EGL_RED_SIZE, 8,
+            EGL_GREEN_SIZE, 8,
+            EGL_BLUE_SIZE, 8,
+            EGL_ALPHA_SIZE, 8,
+            EGL_NONE };
+
+        EGLint numConfigs = 0;
+        EXPECT_TRUE(eglChooseConfig(mEglDisplay, configAttribs, &mEglConfig, 1,
+                &numConfigs));
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+        ASSERT_GT(numConfigs, 0);
+
+        static const EGLint contextAttribs[] = {
+            EGL_CONTEXT_CLIENT_VERSION, 3,
+            EGL_NONE } ;
+
+        mEglContext = eglCreateContext(mEglDisplay, mEglConfig, EGL_NO_CONTEXT,
+                contextAttribs);
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+        ASSERT_NE(EGL_NO_CONTEXT, mEglContext);
+
+        mEglSurface = eglCreateWindowSurface(mEglDisplay, mEglConfig,
+                inputSurface, NULL);
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+        ASSERT_NE(EGL_NO_SURFACE, mEglSurface);
+
+        EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+                mEglContext));
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+    }
+
+    void createDebugSurface() {
+        if (getenv(SHOW_DEBUG_STRING) == NULL) return;
+
+        mComposerClient = new SurfaceComposerClient;
+        ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
+
+        mSurfaceControl = mComposerClient->createSurface(
+                String8("SRGBTest Surface"), DISPLAY_WIDTH, DISPLAY_HEIGHT,
+                PIXEL_FORMAT_RGBA_8888);
+
+        ASSERT_TRUE(mSurfaceControl != NULL);
+        ASSERT_TRUE(mSurfaceControl->isValid());
+
+        SurfaceComposerClient::openGlobalTransaction();
+        ASSERT_EQ(NO_ERROR, mSurfaceControl->setLayer(0x7FFFFFFF));
+        ASSERT_EQ(NO_ERROR, mSurfaceControl->show());
+        SurfaceComposerClient::closeGlobalTransaction();
+
+        ANativeWindow_Buffer outBuffer;
+        ARect inOutDirtyBounds;
+        mOutputSurface = mSurfaceControl->getSurface();
+        mOutputSurface->lock(&outBuffer, &inOutDirtyBounds);
+        uint8_t* bytePointer = reinterpret_cast<uint8_t*>(outBuffer.bits);
+        for (int y = 0; y < outBuffer.height; ++y) {
+            int rowOffset = y * outBuffer.stride; // pixels
+            for (int x = 0; x < outBuffer.width; ++x) {
+                int colOffset = (rowOffset + x) * PIXEL_SIZE; // bytes
+                for (int c = 0; c < PIXEL_SIZE; ++c) {
+                    int offset = colOffset + c;
+                    bytePointer[offset] = ((c + 1) * 56) - 1;
+                }
+            }
+        }
+        mOutputSurface->unlockAndPost();
+    }
+
+    void copyToDebugSurface() {
+        if (!mOutputSurface.get()) return;
+
+        size_t bufferSize = mLockedBuffer.height * mLockedBuffer.stride *
+                PIXEL_SIZE;
+
+        ANativeWindow_Buffer outBuffer;
+        ARect outBufferBounds;
+        mOutputSurface->lock(&outBuffer, &outBufferBounds);
+        ASSERT_EQ(mLockedBuffer.width, static_cast<uint32_t>(outBuffer.width));
+        ASSERT_EQ(mLockedBuffer.height, static_cast<uint32_t>(outBuffer.height));
+        ASSERT_EQ(mLockedBuffer.stride, static_cast<uint32_t>(outBuffer.stride));
+
+        if (mLockedBuffer.format == outBuffer.format) {
+            memcpy(outBuffer.bits, mLockedBuffer.data, bufferSize);
+        } else {
+            ASSERT_EQ(mLockedBuffer.format, PIXEL_FORMAT_RGBA_8888);
+            ASSERT_EQ(mLockedBuffer.dataSpace, HAL_DATASPACE_SRGB);
+            ASSERT_EQ(outBuffer.format, PIXEL_FORMAT_RGBA_8888);
+            uint8_t* outPointer = reinterpret_cast<uint8_t*>(outBuffer.bits);
+            for (int y = 0; y < outBuffer.height; ++y) {
+                int rowOffset = y * outBuffer.stride; // pixels
+                for (int x = 0; x < outBuffer.width; ++x) {
+                    int colOffset = (rowOffset + x) * PIXEL_SIZE; // bytes
+
+                    // RGB are converted
+                    for (int c = 0; c < (PIXEL_SIZE - 1); ++c) {
+                        outPointer[colOffset + c] = srgbToLinear(
+                                mLockedBuffer.data[colOffset + c]);
+                    }
+
+                    // Alpha isn't converted
+                    outPointer[colOffset + 3] =
+                            mLockedBuffer.data[colOffset + 3];
+                }
+            }
+        }
+        mOutputSurface->unlockAndPost();
+
+        int sleepSeconds = atoi(getenv(SHOW_DEBUG_STRING));
+        sleep(sleepSeconds);
+    }
+};
+
+const char SRGBTest::SHOW_DEBUG_STRING[] = "DEBUG_OUTPUT_SECONDS";
+
+TEST_F(SRGBTest, GLRenderFromSRGBTexture) {
+    ASSERT_NO_FATAL_FAILURE(initShaders());
+
+    // The RGB texture is displayed in the top half
+    ASSERT_NO_FATAL_FAILURE(drawTexture(false, 0, DISPLAY_HEIGHT / 2,
+            DISPLAY_WIDTH, DISPLAY_HEIGHT / 2));
+
+    // The SRGB texture is displayed in the bottom half
+    ASSERT_NO_FATAL_FAILURE(drawTexture(true, 0, 0,
+            DISPLAY_WIDTH, DISPLAY_HEIGHT / 2));
+
+    eglSwapBuffers(mEglDisplay, mEglSurface);
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    // Lock
+    ASSERT_EQ(NO_ERROR, mCpuConsumer->lockNextBuffer(&mLockedBuffer));
+    ASSERT_NO_FATAL_FAILURE(
+        checkLockedBuffer(PIXEL_FORMAT_RGBA_8888, HAL_DATASPACE_UNKNOWN));
+
+    // Compare a pixel in the middle of each texture
+    int midSRGBOffset = (DISPLAY_HEIGHT / 4) * mLockedBuffer.stride *
+            PIXEL_SIZE;
+    int midRGBOffset = midSRGBOffset * 3;
+    midRGBOffset += (DISPLAY_WIDTH / 2) * PIXEL_SIZE;
+    midSRGBOffset += (DISPLAY_WIDTH / 2) * PIXEL_SIZE;
+    for (int c = 0; c < PIXEL_SIZE; ++c) {
+        int expectedValue = mLockedBuffer.data[midRGBOffset + c];
+        int actualValue = mLockedBuffer.data[midSRGBOffset + c];
+        ASSERT_PRED2(withinTolerance, expectedValue, actualValue);
+    }
+
+    // mLockedBuffer is unlocked in TearDown so we can copy data from it to
+    // the debug surface if necessary
+}
+
+// XXX: Disabled since we don't currently expect this to work
+TEST_F(SRGBTest, DISABLED_RenderToSRGBSurface) {
+    ASSERT_NO_FATAL_FAILURE(initShaders());
+
+    // By default, the first buffer we write into will be RGB
+
+    // Render an RGB texture across the whole surface
+    ASSERT_NO_FATAL_FAILURE(drawTexture(false, 0, 0,
+            DISPLAY_WIDTH, DISPLAY_HEIGHT));
+    eglSwapBuffers(mEglDisplay, mEglSurface);
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    // Lock
+    ASSERT_EQ(NO_ERROR, mCpuConsumer->lockNextBuffer(&mLockedBuffer));
+    ASSERT_NO_FATAL_FAILURE(
+        checkLockedBuffer(PIXEL_FORMAT_RGBA_8888, HAL_DATASPACE_UNKNOWN));
+
+    // Save the values of the middle pixel for later comparison against SRGB
+    uint8_t values[PIXEL_SIZE] = {};
+    int middleOffset = (DISPLAY_HEIGHT / 2) * mLockedBuffer.stride *
+            PIXEL_SIZE;
+    middleOffset += (DISPLAY_WIDTH / 2) * PIXEL_SIZE;
+    for (int c = 0; c < PIXEL_SIZE; ++c) {
+        values[c] = mLockedBuffer.data[middleOffset + c];
+    }
+
+    // Unlock
+    ASSERT_EQ(NO_ERROR, mCpuConsumer->unlockBuffer(mLockedBuffer));
+
+    // Switch to SRGB window surface
+#define EGL_GL_COLORSPACE_KHR      EGL_VG_COLORSPACE
+#define EGL_GL_COLORSPACE_SRGB_KHR EGL_VG_COLORSPACE_sRGB
+
+    static const int srgbAttribs[] = {
+        EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR,
+        EGL_NONE,
+    };
+
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
+            mEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    EXPECT_TRUE(eglDestroySurface(mEglDisplay, mEglSurface));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    mEglSurface = eglCreateWindowSurface(mEglDisplay, mEglConfig,
+            mInputSurface.get(), srgbAttribs);
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+    ASSERT_NE(EGL_NO_SURFACE, mEglSurface);
+
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    // Render the texture again
+    ASSERT_NO_FATAL_FAILURE(drawTexture(false, 0, 0,
+            DISPLAY_WIDTH, DISPLAY_HEIGHT));
+    eglSwapBuffers(mEglDisplay, mEglSurface);
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    // Lock
+    ASSERT_EQ(NO_ERROR, mCpuConsumer->lockNextBuffer(&mLockedBuffer));
+
+    // Make sure we actually got the SRGB buffer on the consumer side
+    ASSERT_NO_FATAL_FAILURE(
+        checkLockedBuffer(PIXEL_FORMAT_RGBA_8888, HAL_DATASPACE_SRGB));
+
+    // Verify that the stored value is the same, accounting for RGB/SRGB
+    for (int c = 0; c < PIXEL_SIZE; ++c) {
+        // The alpha value should be equivalent before linear->SRGB
+        float rgbAsSRGB = (c == 3) ? values[c] / 255.0f :
+                linearToSRGB(values[c] / 255.0f);
+        int expectedValue = rgbAsSRGB * 255.0f + 0.5f;
+        int actualValue = mLockedBuffer.data[middleOffset + c];
+        ASSERT_PRED2(withinTolerance, expectedValue, actualValue);
+    }
+
+    // mLockedBuffer is unlocked in TearDown so we can copy data from it to
+    // the debug surface if necessary
+}
+
+} // namespace android
diff --git a/libs/gui/tests/StreamSplitter_test.cpp b/libs/gui/tests/StreamSplitter_test.cpp
new file mode 100644
index 0000000..00cc39d
--- /dev/null
+++ b/libs/gui/tests/StreamSplitter_test.cpp
@@ -0,0 +1,252 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "StreamSplitter_test"
+//#define LOG_NDEBUG 0
+
+#include <gui/BufferItem.h>
+#include <gui/BufferQueue.h>
+#include <gui/IConsumerListener.h>
+#include <gui/ISurfaceComposer.h>
+#include <gui/StreamSplitter.h>
+#include <private/gui/ComposerService.h>
+
+#include <gtest/gtest.h>
+
+namespace android {
+
+class StreamSplitterTest : public ::testing::Test {
+
+protected:
+    StreamSplitterTest() {
+        const ::testing::TestInfo* const testInfo =
+            ::testing::UnitTest::GetInstance()->current_test_info();
+        ALOGV("Begin test: %s.%s", testInfo->test_case_name(),
+                testInfo->name());
+    }
+
+    ~StreamSplitterTest() {
+        const ::testing::TestInfo* const testInfo =
+            ::testing::UnitTest::GetInstance()->current_test_info();
+        ALOGV("End test:   %s.%s", testInfo->test_case_name(),
+                testInfo->name());
+    }
+};
+
+struct DummyListener : public BnConsumerListener {
+    virtual void onFrameAvailable(const BufferItem& /* item */) {}
+    virtual void onBuffersReleased() {}
+    virtual void onSidebandStreamChanged() {}
+};
+
+class CountedAllocator : public BnGraphicBufferAlloc {
+public:
+    CountedAllocator() : mAllocCount(0) {
+        sp<ISurfaceComposer> composer(ComposerService::getComposerService());
+        mAllocator = composer->createGraphicBufferAlloc();
+    }
+
+    virtual ~CountedAllocator() {}
+
+    virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
+            PixelFormat format, uint32_t usage, status_t* error) {
+        ++mAllocCount;
+        sp<GraphicBuffer> buffer = mAllocator->createGraphicBuffer(w, h, format,
+                usage, error);
+        return buffer;
+    }
+
+    int getAllocCount() const { return mAllocCount; }
+
+private:
+    sp<IGraphicBufferAlloc> mAllocator;
+    int mAllocCount;
+};
+
+static const uint32_t TEST_DATA = 0x12345678u;
+
+TEST_F(StreamSplitterTest, OneInputOneOutput) {
+    sp<CountedAllocator> allocator(new CountedAllocator);
+
+    sp<IGraphicBufferProducer> inputProducer;
+    sp<IGraphicBufferConsumer> inputConsumer;
+    BufferQueue::createBufferQueue(&inputProducer, &inputConsumer, allocator);
+
+    sp<IGraphicBufferProducer> outputProducer;
+    sp<IGraphicBufferConsumer> outputConsumer;
+    BufferQueue::createBufferQueue(&outputProducer, &outputConsumer, allocator);
+    ASSERT_EQ(OK, outputConsumer->consumerConnect(new DummyListener, false));
+
+    sp<StreamSplitter> splitter;
+    status_t status = StreamSplitter::createSplitter(inputConsumer, &splitter);
+    ASSERT_EQ(OK, status);
+    ASSERT_EQ(OK, splitter->addOutput(outputProducer));
+
+    IGraphicBufferProducer::QueueBufferOutput qbOutput;
+    ASSERT_EQ(OK, inputProducer->connect(new DummyProducerListener,
+            NATIVE_WINDOW_API_CPU, false, &qbOutput));
+
+    int slot;
+    sp<Fence> fence;
+    sp<GraphicBuffer> buffer;
+    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
+            inputProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+                    GRALLOC_USAGE_SW_WRITE_OFTEN));
+    ASSERT_EQ(OK, inputProducer->requestBuffer(slot, &buffer));
+
+    uint32_t* dataIn;
+    ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN,
+            reinterpret_cast<void**>(&dataIn)));
+    *dataIn = TEST_DATA;
+    ASSERT_EQ(OK, buffer->unlock());
+
+    IGraphicBufferProducer::QueueBufferInput qbInput(0, false,
+            HAL_DATASPACE_UNKNOWN,
+            Rect(0, 0, 1, 1), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false,
+            Fence::NO_FENCE);
+    ASSERT_EQ(OK, inputProducer->queueBuffer(slot, qbInput, &qbOutput));
+
+    BufferItem item;
+    ASSERT_EQ(OK, outputConsumer->acquireBuffer(&item, 0));
+
+    uint32_t* dataOut;
+    ASSERT_EQ(OK, item.mGraphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN,
+            reinterpret_cast<void**>(&dataOut)));
+    ASSERT_EQ(*dataOut, TEST_DATA);
+    ASSERT_EQ(OK, item.mGraphicBuffer->unlock());
+
+    ASSERT_EQ(OK, outputConsumer->releaseBuffer(item.mBuf, item.mFrameNumber,
+            EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE));
+
+    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
+            inputProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+                    GRALLOC_USAGE_SW_WRITE_OFTEN));
+
+    ASSERT_EQ(1, allocator->getAllocCount());
+}
+
+TEST_F(StreamSplitterTest, OneInputMultipleOutputs) {
+    const int NUM_OUTPUTS = 4;
+    sp<CountedAllocator> allocator(new CountedAllocator);
+
+    sp<IGraphicBufferProducer> inputProducer;
+    sp<IGraphicBufferConsumer> inputConsumer;
+    BufferQueue::createBufferQueue(&inputProducer, &inputConsumer, allocator);
+
+    sp<IGraphicBufferProducer> outputProducers[NUM_OUTPUTS] = {};
+    sp<IGraphicBufferConsumer> outputConsumers[NUM_OUTPUTS] = {};
+    for (int output = 0; output < NUM_OUTPUTS; ++output) {
+        BufferQueue::createBufferQueue(&outputProducers[output],
+                &outputConsumers[output], allocator);
+        ASSERT_EQ(OK, outputConsumers[output]->consumerConnect(
+                    new DummyListener, false));
+    }
+
+    sp<StreamSplitter> splitter;
+    status_t status = StreamSplitter::createSplitter(inputConsumer, &splitter);
+    ASSERT_EQ(OK, status);
+    for (int output = 0; output < NUM_OUTPUTS; ++output) {
+        ASSERT_EQ(OK, splitter->addOutput(outputProducers[output]));
+    }
+
+    IGraphicBufferProducer::QueueBufferOutput qbOutput;
+    ASSERT_EQ(OK, inputProducer->connect(new DummyProducerListener,
+            NATIVE_WINDOW_API_CPU, false, &qbOutput));
+
+    int slot;
+    sp<Fence> fence;
+    sp<GraphicBuffer> buffer;
+    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
+            inputProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+                    GRALLOC_USAGE_SW_WRITE_OFTEN));
+    ASSERT_EQ(OK, inputProducer->requestBuffer(slot, &buffer));
+
+    uint32_t* dataIn;
+    ASSERT_EQ(OK, buffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN,
+            reinterpret_cast<void**>(&dataIn)));
+    *dataIn = TEST_DATA;
+    ASSERT_EQ(OK, buffer->unlock());
+
+    IGraphicBufferProducer::QueueBufferInput qbInput(0, false,
+            HAL_DATASPACE_UNKNOWN,
+            Rect(0, 0, 1, 1), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false,
+            Fence::NO_FENCE);
+    ASSERT_EQ(OK, inputProducer->queueBuffer(slot, qbInput, &qbOutput));
+
+    for (int output = 0; output < NUM_OUTPUTS; ++output) {
+        BufferItem item;
+        ASSERT_EQ(OK, outputConsumers[output]->acquireBuffer(&item, 0));
+
+        uint32_t* dataOut;
+        ASSERT_EQ(OK, item.mGraphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN,
+                    reinterpret_cast<void**>(&dataOut)));
+        ASSERT_EQ(*dataOut, TEST_DATA);
+        ASSERT_EQ(OK, item.mGraphicBuffer->unlock());
+
+        ASSERT_EQ(OK, outputConsumers[output]->releaseBuffer(item.mBuf,
+                    item.mFrameNumber, EGL_NO_DISPLAY, EGL_NO_SYNC_KHR,
+                    Fence::NO_FENCE));
+    }
+
+    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
+            inputProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+                    GRALLOC_USAGE_SW_WRITE_OFTEN));
+
+    ASSERT_EQ(1, allocator->getAllocCount());
+}
+
+TEST_F(StreamSplitterTest, OutputAbandonment) {
+    sp<IGraphicBufferProducer> inputProducer;
+    sp<IGraphicBufferConsumer> inputConsumer;
+    BufferQueue::createBufferQueue(&inputProducer, &inputConsumer);
+
+    sp<IGraphicBufferProducer> outputProducer;
+    sp<IGraphicBufferConsumer> outputConsumer;
+    BufferQueue::createBufferQueue(&outputProducer, &outputConsumer);
+    ASSERT_EQ(OK, outputConsumer->consumerConnect(new DummyListener, false));
+
+    sp<StreamSplitter> splitter;
+    status_t status = StreamSplitter::createSplitter(inputConsumer, &splitter);
+    ASSERT_EQ(OK, status);
+    ASSERT_EQ(OK, splitter->addOutput(outputProducer));
+
+    IGraphicBufferProducer::QueueBufferOutput qbOutput;
+    ASSERT_EQ(OK, inputProducer->connect(new DummyProducerListener,
+            NATIVE_WINDOW_API_CPU, false, &qbOutput));
+
+    int slot;
+    sp<Fence> fence;
+    sp<GraphicBuffer> buffer;
+    ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
+            inputProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+                    GRALLOC_USAGE_SW_WRITE_OFTEN));
+    ASSERT_EQ(OK, inputProducer->requestBuffer(slot, &buffer));
+
+    // Abandon the output
+    outputConsumer->consumerDisconnect();
+
+    IGraphicBufferProducer::QueueBufferInput qbInput(0, false,
+            HAL_DATASPACE_UNKNOWN,
+            Rect(0, 0, 1, 1), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false,
+            Fence::NO_FENCE);
+    ASSERT_EQ(OK, inputProducer->queueBuffer(slot, qbInput, &qbOutput));
+
+    // Input should be abandoned
+    ASSERT_EQ(NO_INIT, inputProducer->dequeueBuffer(&slot, &fence, false, 0, 0,
+            0, GRALLOC_USAGE_SW_WRITE_OFTEN));
+}
+
+} // namespace android
diff --git a/libs/gui/tests/SurfaceTextureClient_test.cpp b/libs/gui/tests/SurfaceTextureClient_test.cpp
index 989fcef..2e56419 100644
--- a/libs/gui/tests/SurfaceTextureClient_test.cpp
+++ b/libs/gui/tests/SurfaceTextureClient_test.cpp
@@ -27,6 +27,9 @@
 #include <utils/Log.h>
 #include <utils/Thread.h>
 
+EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name);
+#define CROP_EXT_STR "EGL_ANDROID_image_crop"
+
 namespace android {
 
 class SurfaceTextureClientTest : public ::testing::Test {
@@ -43,9 +46,12 @@
         ALOGV("Begin test: %s.%s", testInfo->test_case_name(),
                 testInfo->name());
 
-        sp<BufferQueue> bq = new BufferQueue();
-        mST = new GLConsumer(bq, 123);
-        mSTC = new Surface(bq);
+        sp<IGraphicBufferProducer> producer;
+        sp<IGraphicBufferConsumer> consumer;
+        BufferQueue::createBufferQueue(&producer, &consumer);
+        mST = new GLConsumer(consumer, 123, GLConsumer::TEXTURE_EXTERNAL, true,
+                false);
+        mSTC = new Surface(producer);
         mANW = mSTC;
 
         // We need a valid GL context so we can test updateTexImage()
@@ -204,12 +210,8 @@
 }
 
 TEST_F(SurfaceTextureClientTest, BufferGeometryInvalidSizesFail) {
-    EXPECT_GT(OK, native_window_set_buffers_geometry(mANW.get(), -1,  0,  0));
-    EXPECT_GT(OK, native_window_set_buffers_geometry(mANW.get(),  0, -1,  0));
-    EXPECT_GT(OK, native_window_set_buffers_geometry(mANW.get(),  0,  0, -1));
-    EXPECT_GT(OK, native_window_set_buffers_geometry(mANW.get(), -1, -1,  0));
-    EXPECT_GT(OK, native_window_set_buffers_geometry(mANW.get(),  0,  8,  0));
-    EXPECT_GT(OK, native_window_set_buffers_geometry(mANW.get(),  8,  0,  0));
+    EXPECT_GT(OK, native_window_set_buffers_dimensions(mANW.get(),  0,  8));
+    EXPECT_GT(OK, native_window_set_buffers_dimensions(mANW.get(),  8,  0));
 }
 
 TEST_F(SurfaceTextureClientTest, DefaultGeometryValues) {
@@ -223,7 +225,8 @@
 
 TEST_F(SurfaceTextureClientTest, BufferGeometryCanBeSet) {
     ANativeWindowBuffer* buf;
-    EXPECT_EQ(OK, native_window_set_buffers_geometry(mANW.get(), 16, 8, PIXEL_FORMAT_RGB_565));
+    EXPECT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 16, 8));
+    EXPECT_EQ(OK, native_window_set_buffers_format(mANW.get(), PIXEL_FORMAT_RGB_565));
     ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf));
     EXPECT_EQ(16, buf->width);
     EXPECT_EQ(8, buf->height);
@@ -233,7 +236,8 @@
 
 TEST_F(SurfaceTextureClientTest, BufferGeometryDefaultSizeSetFormat) {
     ANativeWindowBuffer* buf;
-    EXPECT_EQ(OK, native_window_set_buffers_geometry(mANW.get(), 0, 0, PIXEL_FORMAT_RGB_565));
+    EXPECT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 0, 0));
+    EXPECT_EQ(OK, native_window_set_buffers_format(mANW.get(), PIXEL_FORMAT_RGB_565));
     ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf));
     EXPECT_EQ(1, buf->width);
     EXPECT_EQ(1, buf->height);
@@ -243,7 +247,8 @@
 
 TEST_F(SurfaceTextureClientTest, BufferGeometrySetSizeDefaultFormat) {
     ANativeWindowBuffer* buf;
-    EXPECT_EQ(OK, native_window_set_buffers_geometry(mANW.get(), 16, 8, 0));
+    EXPECT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 16, 8));
+    EXPECT_EQ(OK, native_window_set_buffers_format(mANW.get(), 0));
     ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf));
     EXPECT_EQ(16, buf->width);
     EXPECT_EQ(8, buf->height);
@@ -253,13 +258,15 @@
 
 TEST_F(SurfaceTextureClientTest, BufferGeometrySizeCanBeUnset) {
     ANativeWindowBuffer* buf;
-    EXPECT_EQ(OK, native_window_set_buffers_geometry(mANW.get(), 16, 8, 0));
+    EXPECT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 16, 8));
+    EXPECT_EQ(OK, native_window_set_buffers_format(mANW.get(), 0));
     ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf));
     EXPECT_EQ(16, buf->width);
     EXPECT_EQ(8, buf->height);
     EXPECT_EQ(PIXEL_FORMAT_RGBA_8888, buf->format);
     ASSERT_EQ(OK, mANW->cancelBuffer(mANW.get(), buf, -1));
-    EXPECT_EQ(OK, native_window_set_buffers_geometry(mANW.get(), 0, 0, 0));
+    EXPECT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 0, 0));
+    EXPECT_EQ(OK, native_window_set_buffers_format(mANW.get(), 0));
     ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf));
     EXPECT_EQ(1, buf->width);
     EXPECT_EQ(1, buf->height);
@@ -269,7 +276,8 @@
 
 TEST_F(SurfaceTextureClientTest, BufferGeometrySizeCanBeChangedWithoutFormat) {
     ANativeWindowBuffer* buf;
-    EXPECT_EQ(OK, native_window_set_buffers_geometry(mANW.get(), 0, 0, PIXEL_FORMAT_RGB_565));
+    EXPECT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 0, 0));
+    EXPECT_EQ(OK, native_window_set_buffers_format(mANW.get(), PIXEL_FORMAT_RGB_565));
     ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf));
     EXPECT_EQ(1, buf->width);
     EXPECT_EQ(1, buf->height);
@@ -327,7 +335,8 @@
     EXPECT_EQ(8, buf[1]->height);
     ASSERT_EQ(OK, mANW->cancelBuffer(mANW.get(), buf[0], -1));
     ASSERT_EQ(OK, mANW->cancelBuffer(mANW.get(), buf[1], -1));
-    EXPECT_EQ(OK, native_window_set_buffers_geometry(mANW.get(), 12, 24, 0));
+    EXPECT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 12, 24));
+    EXPECT_EQ(OK, native_window_set_buffers_format(mANW.get(), 0));
     ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf[0]));
     ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf[1]));
     EXPECT_NE(buf[0], buf[1]);
@@ -465,7 +474,8 @@
 
     // Once we've queued a buffer, however we should not be able to dequeue more
     // than (buffer-count - MIN_UNDEQUEUED_BUFFERS), which is 2 in this case.
-    EXPECT_EQ(-EBUSY, native_window_dequeue_buffer_and_wait(mANW.get(), &buf[1]));
+    EXPECT_EQ(INVALID_OPERATION,
+            native_window_dequeue_buffer_and_wait(mANW.get(), &buf[1]));
 
     ASSERT_EQ(OK, mANW->cancelBuffer(mANW.get(), buf[0], -1));
     ASSERT_EQ(OK, mANW->cancelBuffer(mANW.get(), buf[2], -1));
@@ -509,7 +519,7 @@
             return false;
         }
     public:
-        MyThread(const sp<GLConsumer>& mST)
+        explicit MyThread(const sp<GLConsumer>& mST)
             : mST(mST), mBufferRetired(false) {
             ctx = eglGetCurrentContext();
             sur = eglGetCurrentSurface(EGL_DRAW);
@@ -608,6 +618,18 @@
 }
 
 TEST_F(SurfaceTextureClientTest, GetTransformMatrixSucceedsAfterFreeingBuffersWithCrop) {
+    // Query to see if the image crop extension exists
+    EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+    const char* exts = eglQueryStringImplementationANDROID(dpy, EGL_EXTENSIONS);
+    size_t cropExtLen = strlen(CROP_EXT_STR);
+    size_t extsLen = strlen(exts);
+    bool equal = !strcmp(CROP_EXT_STR, exts);
+    bool atStart = !strncmp(CROP_EXT_STR " ", exts, cropExtLen+1);
+    bool atEnd = (cropExtLen+1) < extsLen &&
+            !strcmp(" " CROP_EXT_STR, exts + extsLen - (cropExtLen+1));
+    bool inMiddle = strstr(exts, " " CROP_EXT_STR " ");
+    bool hasEglAndroidImageCrop = equal || atStart || atEnd || inMiddle;
+
     android_native_buffer_t* buf[3];
     float mtx[16] = {};
     android_native_rect_t crop;
@@ -617,7 +639,8 @@
     crop.bottom = 5;
 
     ASSERT_EQ(OK, native_window_set_buffer_count(mANW.get(), 4));
-    ASSERT_EQ(OK, native_window_set_buffers_geometry(mANW.get(), 8, 8, 0));
+    ASSERT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 8, 8));
+    ASSERT_EQ(OK, native_window_set_buffers_format(mANW.get(), 0));
     ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf[0]));
     ASSERT_EQ(OK, native_window_set_crop(mANW.get(), &crop));
     ASSERT_EQ(OK, mANW->queueBuffer(mANW.get(), buf[0], -1));
@@ -625,15 +648,17 @@
     ASSERT_EQ(OK, native_window_set_buffer_count(mANW.get(), 6)); // frees buffers
     mST->getTransformMatrix(mtx);
 
-    // This accounts for the .5 texel shrink for each edge that's included in the
-    // transform matrix to avoid texturing outside the crop region.
-    EXPECT_EQ(0.5, mtx[0]);
+    // If the egl image crop extension is not present, this accounts for the
+    // .5 texel shrink for each edge that's included in the transform matrix
+    // to avoid texturing outside the crop region. Otherwise the crop is not
+    // included in the transform matrix.
+    EXPECT_EQ(hasEglAndroidImageCrop ? 1 : 0.5, mtx[0]);
     EXPECT_EQ(0.f, mtx[1]);
     EXPECT_EQ(0.f, mtx[2]);
     EXPECT_EQ(0.f, mtx[3]);
 
     EXPECT_EQ(0.f, mtx[4]);
-    EXPECT_EQ(-0.5, mtx[5]);
+    EXPECT_EQ(hasEglAndroidImageCrop ? -1 : -0.5, mtx[5]);
     EXPECT_EQ(0.f, mtx[6]);
     EXPECT_EQ(0.f, mtx[7]);
 
@@ -642,8 +667,8 @@
     EXPECT_EQ(1.f, mtx[10]);
     EXPECT_EQ(0.f, mtx[11]);
 
-    EXPECT_EQ(0.0625f, mtx[12]);
-    EXPECT_EQ(0.5625f, mtx[13]);
+    EXPECT_EQ(hasEglAndroidImageCrop ? 0 : 0.0625f, mtx[12]);
+    EXPECT_EQ(hasEglAndroidImageCrop ? 1 : 0.5625f, mtx[13]);
     EXPECT_EQ(0.f, mtx[14]);
     EXPECT_EQ(1.f, mtx[15]);
 }
@@ -665,7 +690,8 @@
     const int numFmts = (sizeof(fmts) / sizeof(fmts[0]));
     for (int i = 0; i < numFmts; i++) {
       int fmt = -1;
-      ASSERT_EQ(OK, native_window_set_buffers_geometry(anw.get(), 0, 0, fmts[i]));
+      ASSERT_EQ(OK, native_window_set_buffers_dimensions(anw.get(), 0, 0));
+      ASSERT_EQ(OK, native_window_set_buffers_format(anw.get(), fmts[i]));
       ASSERT_EQ(OK, anw->query(anw.get(), NATIVE_WINDOW_FORMAT, &fmt));
       EXPECT_EQ(fmts[i], fmt);
     }
@@ -711,9 +737,12 @@
         ASSERT_NE(EGL_NO_CONTEXT, mEglContext);
 
         for (int i = 0; i < NUM_SURFACE_TEXTURES; i++) {
-            sp<BufferQueue> bq = new BufferQueue();
-            sp<GLConsumer> st(new GLConsumer(bq, i));
-            sp<Surface> stc(new Surface(bq));
+            sp<IGraphicBufferProducer> producer;
+            sp<IGraphicBufferConsumer> consumer;
+            BufferQueue::createBufferQueue(&producer, &consumer);
+            sp<GLConsumer> st(new GLConsumer(consumer, i,
+                    GLConsumer::TEXTURE_EXTERNAL, true, false));
+            sp<Surface> stc(new Surface(producer));
             mEglSurfaces[i] = eglCreateWindowSurface(mEglDisplay, myConfig,
                     static_cast<ANativeWindow*>(stc.get()), NULL);
             ASSERT_EQ(EGL_SUCCESS, eglGetError());
diff --git a/libs/gui/tests/SurfaceTextureFBO.h b/libs/gui/tests/SurfaceTextureFBO.h
new file mode 100644
index 0000000..7f1ae84
--- /dev/null
+++ b/libs/gui/tests/SurfaceTextureFBO.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_SURFACE_TEXTURE_FBO_H
+#define ANDROID_SURFACE_TEXTURE_FBO_H
+
+#include "SurfaceTextureGL.h"
+
+#include <GLES2/gl2.h>
+
+namespace android {
+
+class SurfaceTextureFBOTest : public SurfaceTextureGLTest {
+protected:
+    virtual void SetUp() {
+        SurfaceTextureGLTest::SetUp();
+
+        glGenFramebuffers(1, &mFbo);
+        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+
+        glGenTextures(1, &mFboTex);
+        glBindTexture(GL_TEXTURE_2D, mFboTex);
+        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getSurfaceWidth(),
+                getSurfaceHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+        glBindTexture(GL_TEXTURE_2D, 0);
+        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+
+        glBindFramebuffer(GL_FRAMEBUFFER, mFbo);
+        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+                GL_TEXTURE_2D, mFboTex, 0);
+        glBindFramebuffer(GL_FRAMEBUFFER, 0);
+        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+    }
+
+    virtual void TearDown() {
+        SurfaceTextureGLTest::TearDown();
+
+        glDeleteTextures(1, &mFboTex);
+        glDeleteFramebuffers(1, &mFbo);
+    }
+
+    GLuint mFbo;
+    GLuint mFboTex;
+};
+
+void fillRGBA8BufferSolid(uint8_t* buf, int w, int h, int stride,
+        uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
+    const size_t PIXEL_SIZE = 4;
+    for (int y = 0; y < h; y++) {
+        for (int x = 0; x < w; x++) {
+            off_t offset = (y * stride + x) * PIXEL_SIZE;
+            buf[offset + 0] = r;
+            buf[offset + 1] = g;
+            buf[offset + 2] = b;
+            buf[offset + 3] = a;
+        }
+    }
+}
+
+} // namespace android
+
+#endif
diff --git a/libs/gui/tests/SurfaceTextureFBO_test.cpp b/libs/gui/tests/SurfaceTextureFBO_test.cpp
new file mode 100644
index 0000000..c243fc0
--- /dev/null
+++ b/libs/gui/tests/SurfaceTextureFBO_test.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "SurfaceTextureFBO_test"
+//#define LOG_NDEBUG 0
+
+#include "SurfaceTextureFBO.h"
+
+namespace android {
+
+// This test is intended to verify that proper synchronization is done when
+// rendering into an FBO.
+TEST_F(SurfaceTextureFBOTest, BlitFromCpuFilledBufferToFbo) {
+    const int texWidth = 64;
+    const int texHeight = 64;
+
+    ASSERT_EQ(NO_ERROR, native_window_set_buffers_dimensions(mANW.get(),
+            texWidth, texHeight));
+    ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
+            HAL_PIXEL_FORMAT_RGBA_8888));
+    ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
+            GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
+
+    android_native_buffer_t* anb;
+    ASSERT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(),
+            &anb));
+    ASSERT_TRUE(anb != NULL);
+
+    sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
+
+    // Fill the buffer with green
+    uint8_t* img = NULL;
+    buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
+    fillRGBA8BufferSolid(img, texWidth, texHeight, buf->getStride(), 0, 255,
+            0, 255);
+    buf->unlock();
+    ASSERT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), buf->getNativeBuffer(),
+            -1));
+
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+
+    glBindFramebuffer(GL_FRAMEBUFFER, mFbo);
+    drawTexture();
+    glBindFramebuffer(GL_FRAMEBUFFER, 0);
+
+    for (int i = 0; i < 4; i++) {
+        SCOPED_TRACE(String8::format("frame %d", i).string());
+
+        ASSERT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(),
+                &anb));
+        ASSERT_TRUE(anb != NULL);
+
+        buf = new GraphicBuffer(anb, false);
+
+        // Fill the buffer with red
+        ASSERT_EQ(NO_ERROR, buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN,
+                (void**)(&img)));
+        fillRGBA8BufferSolid(img, texWidth, texHeight, buf->getStride(), 255, 0,
+                0, 255);
+        ASSERT_EQ(NO_ERROR, buf->unlock());
+        ASSERT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(),
+                buf->getNativeBuffer(), -1));
+
+        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+
+        drawTexture();
+
+        EXPECT_TRUE(checkPixel( 24, 39, 255, 0, 0, 255));
+    }
+
+    glBindFramebuffer(GL_FRAMEBUFFER, mFbo);
+
+    EXPECT_TRUE(checkPixel( 24, 39, 0, 255, 0, 255));
+}
+
+} // namespace android
diff --git a/libs/gui/tests/SurfaceTextureGL.h b/libs/gui/tests/SurfaceTextureGL.h
new file mode 100644
index 0000000..53eb68c
--- /dev/null
+++ b/libs/gui/tests/SurfaceTextureGL.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_SURFACE_TEXTURE_GL_H
+#define ANDROID_SURFACE_TEXTURE_GL_H
+
+#include "GLTest.h"
+
+#include "FrameWaiter.h"
+#include "TextureRenderer.h"
+
+#include <gui/GLConsumer.h>
+#include <gui/Surface.h>
+
+namespace android {
+
+class FrameWaiter;
+class GLConsumer;
+class TextureRenderer;
+
+class SurfaceTextureGLTest : public GLTest {
+protected:
+    enum { TEX_ID = 123 };
+
+    void SetUp() {
+        GLTest::SetUp();
+        sp<IGraphicBufferProducer> producer;
+        BufferQueue::createBufferQueue(&producer, &mConsumer);
+        mST = new GLConsumer(mConsumer, TEX_ID, GLConsumer::TEXTURE_EXTERNAL,
+                true, false);
+        mSTC = new Surface(producer);
+        mANW = mSTC;
+        mTextureRenderer = new TextureRenderer(TEX_ID, mST);
+        ASSERT_NO_FATAL_FAILURE(mTextureRenderer->SetUp());
+        mFW = new FrameWaiter;
+        mST->setFrameAvailableListener(mFW);
+    }
+
+    void TearDown() {
+        mTextureRenderer.clear();
+        mANW.clear();
+        mSTC.clear();
+        mST.clear();
+        GLTest::TearDown();
+    }
+
+    void drawTexture() {
+        mTextureRenderer->drawTexture();
+    }
+
+    sp<IGraphicBufferConsumer> mConsumer;
+    sp<GLConsumer> mST;
+    sp<Surface> mSTC;
+    sp<ANativeWindow> mANW;
+    sp<TextureRenderer> mTextureRenderer;
+    sp<FrameWaiter> mFW;
+};
+
+} // namespace android
+
+#endif
diff --git a/libs/gui/tests/SurfaceTextureGLThreadToGL.h b/libs/gui/tests/SurfaceTextureGLThreadToGL.h
new file mode 100644
index 0000000..14e42ac
--- /dev/null
+++ b/libs/gui/tests/SurfaceTextureGLThreadToGL.h
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_SURFACE_TEXTURE_GL_THREAD_TO_GL_H
+#define ANDROID_SURFACE_TEXTURE_GL_THREAD_TO_GL_H
+
+#include "SurfaceTextureGLToGL.h"
+
+namespace android {
+
+/*
+ * This test fixture is for testing GL -> GL texture streaming from one thread
+ * to another.  It contains functionality to create a producer thread that will
+ * perform GL rendering to an ANativeWindow that feeds frames to a
+ * GLConsumer.  Additionally it supports interlocking the producer and
+ * consumer threads so that a specific sequence of calls can be
+ * deterministically created by the test.
+ *
+ * The intended usage is as follows:
+ *
+ * TEST_F(...) {
+ *     class PT : public ProducerThread {
+ *         virtual void render() {
+ *             ...
+ *             swapBuffers();
+ *         }
+ *     };
+ *
+ *     runProducerThread(new PT());
+ *
+ *     // The order of these calls will vary from test to test and may include
+ *     // multiple frames and additional operations (e.g. GL rendering from the
+ *     // texture).
+ *     fc->waitForFrame();
+ *     mST->updateTexImage();
+ *     fc->finishFrame();
+ * }
+ *
+ */
+class SurfaceTextureGLThreadToGLTest : public SurfaceTextureGLToGLTest {
+protected:
+
+    // ProducerThread is an abstract base class to simplify the creation of
+    // OpenGL ES frame producer threads.
+    class ProducerThread : public Thread {
+    public:
+        virtual ~ProducerThread() {
+        }
+
+        void setEglObjects(EGLDisplay producerEglDisplay,
+                EGLSurface producerEglSurface,
+                EGLContext producerEglContext) {
+            mProducerEglDisplay = producerEglDisplay;
+            mProducerEglSurface = producerEglSurface;
+            mProducerEglContext = producerEglContext;
+        }
+
+        virtual bool threadLoop() {
+            eglMakeCurrent(mProducerEglDisplay, mProducerEglSurface,
+                    mProducerEglSurface, mProducerEglContext);
+            render();
+            eglMakeCurrent(mProducerEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
+                    EGL_NO_CONTEXT);
+            return false;
+        }
+
+    protected:
+        virtual void render() = 0;
+
+        void swapBuffers() {
+            eglSwapBuffers(mProducerEglDisplay, mProducerEglSurface);
+        }
+
+        EGLDisplay mProducerEglDisplay;
+        EGLSurface mProducerEglSurface;
+        EGLContext mProducerEglContext;
+    };
+
+    // FrameCondition is a utility class for interlocking between the producer
+    // and consumer threads.  The FrameCondition object should be created and
+    // destroyed in the consumer thread only.  The consumer thread should set
+    // the FrameCondition as the FrameAvailableListener of the GLConsumer,
+    // and should call both waitForFrame and finishFrame once for each expected
+    // frame.
+    //
+    // This interlocking relies on the fact that onFrameAvailable gets called
+    // synchronously from GLConsumer::queueBuffer.
+    class FrameCondition : public GLConsumer::FrameAvailableListener {
+    public:
+        FrameCondition():
+                mFrameAvailable(false),
+                mFrameFinished(false) {
+        }
+
+        // waitForFrame waits for the next frame to arrive.  This should be
+        // called from the consumer thread once for every frame expected by the
+        // test.
+        void waitForFrame() {
+            Mutex::Autolock lock(mMutex);
+            ALOGV("+waitForFrame");
+            while (!mFrameAvailable) {
+                mFrameAvailableCondition.wait(mMutex);
+            }
+            mFrameAvailable = false;
+            ALOGV("-waitForFrame");
+        }
+
+        // Allow the producer to return from its swapBuffers call and continue
+        // on to produce the next frame.  This should be called by the consumer
+        // thread once for every frame expected by the test.
+        void finishFrame() {
+            Mutex::Autolock lock(mMutex);
+            ALOGV("+finishFrame");
+            mFrameFinished = true;
+            mFrameFinishCondition.signal();
+            ALOGV("-finishFrame");
+        }
+
+        // This should be called by GLConsumer on the producer thread.
+        virtual void onFrameAvailable(const BufferItem& /* item */) {
+            Mutex::Autolock lock(mMutex);
+            ALOGV("+onFrameAvailable");
+            mFrameAvailable = true;
+            mFrameAvailableCondition.signal();
+            while (!mFrameFinished) {
+                mFrameFinishCondition.wait(mMutex);
+            }
+            mFrameFinished = false;
+            ALOGV("-onFrameAvailable");
+        }
+
+    protected:
+        bool mFrameAvailable;
+        bool mFrameFinished;
+
+        Mutex mMutex;
+        Condition mFrameAvailableCondition;
+        Condition mFrameFinishCondition;
+    };
+
+    virtual void SetUp() {
+        SurfaceTextureGLToGLTest::SetUp();
+        mFC = new FrameCondition();
+        mST->setFrameAvailableListener(mFC);
+    }
+
+    virtual void TearDown() {
+        if (mProducerThread != NULL) {
+            mProducerThread->requestExitAndWait();
+        }
+        mProducerThread.clear();
+        mFC.clear();
+        SurfaceTextureGLToGLTest::TearDown();
+    }
+
+    void runProducerThread(const sp<ProducerThread> producerThread) {
+        ASSERT_TRUE(mProducerThread == NULL);
+        mProducerThread = producerThread;
+        producerThread->setEglObjects(mEglDisplay, mProducerEglSurface,
+                mProducerEglContext);
+        producerThread->run();
+    }
+
+    sp<ProducerThread> mProducerThread;
+    sp<FrameCondition> mFC;
+};
+
+} // namespace android
+
+#endif
diff --git a/libs/gui/tests/SurfaceTextureGLThreadToGL_test.cpp b/libs/gui/tests/SurfaceTextureGLThreadToGL_test.cpp
new file mode 100644
index 0000000..9776733
--- /dev/null
+++ b/libs/gui/tests/SurfaceTextureGLThreadToGL_test.cpp
@@ -0,0 +1,186 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "SurfaceTextureGLThreadToGL_test"
+//#define LOG_NDEBUG 0
+
+#include "SurfaceTextureGLThreadToGL.h"
+
+namespace android {
+
+TEST_F(SurfaceTextureGLThreadToGLTest,
+        UpdateTexImageBeforeFrameFinishedCompletes) {
+    class PT : public ProducerThread {
+        virtual void render() {
+            glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
+            glClear(GL_COLOR_BUFFER_BIT);
+            swapBuffers();
+        }
+    };
+
+    runProducerThread(new PT());
+
+    mFC->waitForFrame();
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+    mFC->finishFrame();
+
+    // TODO: Add frame verification once RGB TEX_EXTERNAL_OES is supported!
+}
+
+TEST_F(SurfaceTextureGLThreadToGLTest,
+        UpdateTexImageAfterFrameFinishedCompletes) {
+    class PT : public ProducerThread {
+        virtual void render() {
+            glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
+            glClear(GL_COLOR_BUFFER_BIT);
+            swapBuffers();
+        }
+    };
+
+    runProducerThread(new PT());
+
+    mFC->waitForFrame();
+    mFC->finishFrame();
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+
+    // TODO: Add frame verification once RGB TEX_EXTERNAL_OES is supported!
+}
+
+TEST_F(SurfaceTextureGLThreadToGLTest,
+        RepeatedUpdateTexImageBeforeFrameFinishedCompletes) {
+    enum { NUM_ITERATIONS = 1024 };
+
+    class PT : public ProducerThread {
+        virtual void render() {
+            for (int i = 0; i < NUM_ITERATIONS; i++) {
+                glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
+                glClear(GL_COLOR_BUFFER_BIT);
+                ALOGV("+swapBuffers");
+                swapBuffers();
+                ALOGV("-swapBuffers");
+            }
+        }
+    };
+
+    runProducerThread(new PT());
+
+    for (int i = 0; i < NUM_ITERATIONS; i++) {
+        mFC->waitForFrame();
+        ALOGV("+updateTexImage");
+        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+        ALOGV("-updateTexImage");
+        mFC->finishFrame();
+
+        // TODO: Add frame verification once RGB TEX_EXTERNAL_OES is supported!
+    }
+}
+
+TEST_F(SurfaceTextureGLThreadToGLTest,
+        RepeatedUpdateTexImageAfterFrameFinishedCompletes) {
+    enum { NUM_ITERATIONS = 1024 };
+
+    class PT : public ProducerThread {
+        virtual void render() {
+            for (int i = 0; i < NUM_ITERATIONS; i++) {
+                glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
+                glClear(GL_COLOR_BUFFER_BIT);
+                ALOGV("+swapBuffers");
+                swapBuffers();
+                ALOGV("-swapBuffers");
+            }
+        }
+    };
+
+    runProducerThread(new PT());
+
+    for (int i = 0; i < NUM_ITERATIONS; i++) {
+        mFC->waitForFrame();
+        mFC->finishFrame();
+        ALOGV("+updateTexImage");
+        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+        ALOGV("-updateTexImage");
+
+        // TODO: Add frame verification once RGB TEX_EXTERNAL_OES is supported!
+    }
+}
+
+// XXX: This test is disabled because it is currently hanging on some devices.
+TEST_F(SurfaceTextureGLThreadToGLTest,
+        DISABLED_RepeatedSwapBuffersWhileDequeueStalledCompletes) {
+    enum { NUM_ITERATIONS = 64 };
+
+    class PT : public ProducerThread {
+        virtual void render() {
+            for (int i = 0; i < NUM_ITERATIONS; i++) {
+                glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
+                glClear(GL_COLOR_BUFFER_BIT);
+                ALOGV("+swapBuffers");
+                swapBuffers();
+                ALOGV("-swapBuffers");
+            }
+        }
+    };
+
+    ASSERT_EQ(OK, mST->setDefaultMaxBufferCount(2));
+
+    runProducerThread(new PT());
+
+    // Allow three frames to be rendered and queued before starting the
+    // rendering in this thread.  For the latter two frames we don't call
+    // updateTexImage so the next dequeue from the producer thread will block
+    // waiting for a frame to become available.
+    mFC->waitForFrame();
+    mFC->finishFrame();
+
+    // We must call updateTexImage to consume the first frame so that the
+    // SurfaceTexture is able to reduce the buffer count to 2.  This is because
+    // the GL driver may dequeue a buffer when the EGLSurface is created, and
+    // that happens before we call setDefaultMaxBufferCount.  It's possible that the
+    // driver does not dequeue a buffer at EGLSurface creation time, so we
+    // cannot rely on this to cause the second dequeueBuffer call to block.
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+
+    mFC->waitForFrame();
+    mFC->finishFrame();
+    mFC->waitForFrame();
+    mFC->finishFrame();
+
+    // Sleep for 100ms to allow the producer thread's dequeueBuffer call to
+    // block waiting for a buffer to become available.
+    usleep(100000);
+
+    // Render and present a number of images.  This thread should not be blocked
+    // by the fact that the producer thread is blocking in dequeue.
+    for (int i = 0; i < NUM_ITERATIONS; i++) {
+        glClear(GL_COLOR_BUFFER_BIT);
+        eglSwapBuffers(mEglDisplay, mEglSurface);
+    }
+
+    // Consume the two pending buffers to unblock the producer thread.
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+
+    // Consume the remaining buffers from the producer thread.
+    for (int i = 0; i < NUM_ITERATIONS-3; i++) {
+        mFC->waitForFrame();
+        mFC->finishFrame();
+        ALOGV("+updateTexImage");
+        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+        ALOGV("-updateTexImage");
+    }
+}
+
+} // namespace android
diff --git a/libs/gui/tests/SurfaceTextureGLToGL.h b/libs/gui/tests/SurfaceTextureGLToGL.h
new file mode 100644
index 0000000..5a2eff3
--- /dev/null
+++ b/libs/gui/tests/SurfaceTextureGLToGL.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_SURFACE_TEXTURE_GL_TO_GL_H
+#define ANDROID_SURFACE_TEXTURE_GL_TO_GL_H
+
+#include "SurfaceTextureGL.h"
+
+namespace android {
+
+/*
+ * This test fixture is for testing GL -> GL texture streaming.  It creates an
+ * EGLSurface and an EGLContext for the image producer to use.
+ */
+class SurfaceTextureGLToGLTest : public SurfaceTextureGLTest {
+protected:
+    SurfaceTextureGLToGLTest():
+            mProducerEglSurface(EGL_NO_SURFACE),
+            mProducerEglContext(EGL_NO_CONTEXT) {
+    }
+
+    virtual void SetUp() {
+        SurfaceTextureGLTest::SetUp();
+
+        mProducerEglSurface = eglCreateWindowSurface(mEglDisplay, mGlConfig,
+                mANW.get(), NULL);
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+        ASSERT_NE(EGL_NO_SURFACE, mProducerEglSurface);
+
+        mProducerEglContext = eglCreateContext(mEglDisplay, mGlConfig,
+                EGL_NO_CONTEXT, getContextAttribs());
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+        ASSERT_NE(EGL_NO_CONTEXT, mProducerEglContext);
+    }
+
+    virtual void TearDown() {
+        if (mProducerEglContext != EGL_NO_CONTEXT) {
+            eglDestroyContext(mEglDisplay, mProducerEglContext);
+        }
+        if (mProducerEglSurface != EGL_NO_SURFACE) {
+            eglDestroySurface(mEglDisplay, mProducerEglSurface);
+        }
+        SurfaceTextureGLTest::TearDown();
+    }
+
+    EGLSurface mProducerEglSurface;
+    EGLContext mProducerEglContext;
+};
+
+} // namespace android
+
+#endif
diff --git a/libs/gui/tests/SurfaceTextureGLToGL_test.cpp b/libs/gui/tests/SurfaceTextureGLToGL_test.cpp
new file mode 100644
index 0000000..6edbfb8
--- /dev/null
+++ b/libs/gui/tests/SurfaceTextureGLToGL_test.cpp
@@ -0,0 +1,507 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "SurfaceTextureGLToGL_test"
+//#define LOG_NDEBUG 0
+
+#include "SurfaceTextureGLToGL.h"
+
+namespace android {
+
+TEST_F(SurfaceTextureGLToGLTest, TransformHintGetsRespected) {
+    const uint32_t texWidth = 32;
+    const uint32_t texHeight = 64;
+
+    mST->setDefaultBufferSize(texWidth, texHeight);
+    mST->setTransformHint(NATIVE_WINDOW_TRANSFORM_ROT_90);
+
+    // This test requires 3 buffers to avoid deadlock because we're
+    // both producer and consumer, and only using one thread.
+    mST->setDefaultMaxBufferCount(3);
+
+    // Do the producer side of things
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
+            mProducerEglSurface, mProducerEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    // Start a buffer with our chosen size and transform hint moving
+    // through the system.
+    glClear(GL_COLOR_BUFFER_BIT);  // give the driver something to do
+    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+    mST->updateTexImage();  // consume it
+    // Swap again.
+    glClear(GL_COLOR_BUFFER_BIT);
+    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+    mST->updateTexImage();
+
+    // The current buffer should either show the effects of the transform
+    // hint (in the form of an inverse transform), or show that the
+    // transform hint has been ignored.
+    sp<GraphicBuffer> buf = mST->getCurrentBuffer();
+    if (mST->getCurrentTransform() == NATIVE_WINDOW_TRANSFORM_ROT_270) {
+        ASSERT_EQ(texWidth, buf->getHeight());
+        ASSERT_EQ(texHeight, buf->getWidth());
+    } else {
+        ASSERT_EQ(texWidth, buf->getWidth());
+        ASSERT_EQ(texHeight, buf->getHeight());
+    }
+
+    // Reset the transform hint and confirm that it takes.
+    mST->setTransformHint(0);
+    glClear(GL_COLOR_BUFFER_BIT);
+    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+    mST->updateTexImage();
+    glClear(GL_COLOR_BUFFER_BIT);
+    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+    mST->updateTexImage();
+
+    buf = mST->getCurrentBuffer();
+    ASSERT_EQ((uint32_t) 0, mST->getCurrentTransform());
+    ASSERT_EQ(texWidth, buf->getWidth());
+    ASSERT_EQ(texHeight, buf->getHeight());
+}
+
+TEST_F(SurfaceTextureGLToGLTest, TexturingFromGLFilledRGBABufferPow2) {
+    const int texWidth = 64;
+    const int texHeight = 64;
+
+    mST->setDefaultBufferSize(texWidth, texHeight);
+
+    // This test requires 3 buffers to complete run on a single thread.
+    mST->setDefaultMaxBufferCount(3);
+
+    // Do the producer side of things
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
+            mProducerEglSurface, mProducerEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    // This is needed to ensure we pick up a buffer of the correct size.
+    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+
+    glClearColor(0.6, 0.6, 0.6, 0.6);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    glEnable(GL_SCISSOR_TEST);
+    glScissor(4, 4, 4, 4);
+    glClearColor(1.0, 0.0, 0.0, 1.0);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    glScissor(24, 48, 4, 4);
+    glClearColor(0.0, 1.0, 0.0, 1.0);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    glScissor(37, 17, 4, 4);
+    glClearColor(0.0, 0.0, 1.0, 1.0);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+
+    // Do the consumer side of things
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    glDisable(GL_SCISSOR_TEST);
+
+    // Skip the first frame, which was empty
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+
+    glClearColor(0.2, 0.2, 0.2, 0.2);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    glViewport(0, 0, texWidth, texHeight);
+    drawTexture();
+
+    EXPECT_TRUE(checkPixel( 0,  0, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(63,  0, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(63, 63, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel( 0, 63, 153, 153, 153, 153));
+
+    EXPECT_TRUE(checkPixel( 4,  7, 255,   0,   0, 255));
+    EXPECT_TRUE(checkPixel(25, 51,   0, 255,   0, 255));
+    EXPECT_TRUE(checkPixel(40, 19,   0,   0, 255, 255));
+    EXPECT_TRUE(checkPixel(29, 51, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel( 5, 32, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(13,  8, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(46,  3, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(30, 33, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel( 6, 52, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(55, 33, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(16, 29, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel( 1, 30, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(41, 37, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(46, 29, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(15, 25, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel( 3, 52, 153, 153, 153, 153));
+}
+
+TEST_F(SurfaceTextureGLToGLTest, EglDestroySurfaceUnrefsBuffers) {
+    sp<GraphicBuffer> buffers[2];
+
+    // This test requires async mode to run on a single thread.
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
+            mProducerEglSurface, mProducerEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+    EXPECT_TRUE(eglSwapInterval(mEglDisplay, 0));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    for (int i = 0; i < 2; i++) {
+        // Produce a frame
+        EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
+                mProducerEglSurface, mProducerEglContext));
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+        glClear(GL_COLOR_BUFFER_BIT);
+        eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+
+        // Consume a frame
+        EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+                mEglContext));
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+        mFW->waitForFrame();
+        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+        buffers[i] = mST->getCurrentBuffer();
+    }
+
+    // Destroy the GL texture object to release its ref on buffers[2].
+    GLuint texID = TEX_ID;
+    glDeleteTextures(1, &texID);
+
+    // Destroy the EGLSurface
+    EXPECT_TRUE(eglDestroySurface(mEglDisplay, mProducerEglSurface));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+    mProducerEglSurface = EGL_NO_SURFACE;
+
+    // This test should have the only reference to buffer 0.
+    EXPECT_EQ(1, buffers[0]->getStrongCount());
+
+    // The GLConsumer should hold one reference to buffer 1 in its
+    // mCurrentTextureImage member and another reference in mEglSlots. The third
+    // reference is in this test.
+    EXPECT_EQ(3, buffers[1]->getStrongCount());
+}
+
+TEST_F(SurfaceTextureGLToGLTest, EglDestroySurfaceAfterAbandonUnrefsBuffers) {
+    sp<GraphicBuffer> buffers[3];
+
+    // This test requires async mode to run on a single thread.
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
+            mProducerEglSurface, mProducerEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+    EXPECT_TRUE(eglSwapInterval(mEglDisplay, 0));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    for (int i = 0; i < 3; i++) {
+        // Produce a frame
+        EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
+                mProducerEglSurface, mProducerEglContext));
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+        glClear(GL_COLOR_BUFFER_BIT);
+        EXPECT_TRUE(eglSwapBuffers(mEglDisplay, mProducerEglSurface));
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+        // Consume a frame
+        EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+                mEglContext));
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+        mFW->waitForFrame();
+        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+        buffers[i] = mST->getCurrentBuffer();
+    }
+
+    // Abandon the GLConsumer, releasing the ref that the GLConsumer has
+    // on buffers[2].
+    mST->abandon();
+
+    // Destroy the GL texture object to release its ref on buffers[2].
+    GLuint texID = TEX_ID;
+    glDeleteTextures(1, &texID);
+
+    // Destroy the EGLSurface.
+    EXPECT_TRUE(eglDestroySurface(mEglDisplay, mProducerEglSurface));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+    mProducerEglSurface = EGL_NO_SURFACE;
+
+    EXPECT_EQ(1, buffers[1]->getStrongCount());
+
+    // Depending on how lazily the GL driver dequeues buffers, we may end up
+    // with either two or three total buffers.  If there are three, each entry
+    // of the buffers array will be unique and there should only be one
+    // reference (the one in this test). If there are two the first and last
+    // element in the array will be equal meaning that buffer representing both
+    // 0 and 2 will have two references (one for 0 and one for 2).
+    if (buffers[2] != buffers[0]) {
+        EXPECT_EQ(1, buffers[0]->getStrongCount());
+        EXPECT_EQ(1, buffers[2]->getStrongCount());
+    } else {
+        EXPECT_EQ(2, buffers[0]->getStrongCount());
+    }
+}
+
+TEST_F(SurfaceTextureGLToGLTest, EglMakeCurrentBeforeConsumerDeathUnrefsBuffers) {
+    sp<GraphicBuffer> buffer;
+
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
+            mProducerEglSurface, mProducerEglContext));
+
+    // Produce a frame
+    glClear(GL_COLOR_BUFFER_BIT);
+    EXPECT_TRUE(eglSwapBuffers(mEglDisplay, mProducerEglSurface));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    // Destroy the EGLSurface.
+    EXPECT_TRUE(eglDestroySurface(mEglDisplay, mProducerEglSurface));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+    mProducerEglSurface = EGL_NO_SURFACE;
+    mSTC.clear();
+    mANW.clear();
+    mTextureRenderer.clear();
+
+    // Consume a frame
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+    buffer = mST->getCurrentBuffer();
+
+    // Destroy the GL texture object to release its ref
+    GLuint texID = TEX_ID;
+    glDeleteTextures(1, &texID);
+
+    // make un-current, all references to buffer should be gone
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE,
+            EGL_NO_SURFACE, EGL_NO_CONTEXT));
+
+    // Destroy consumer
+    mST.clear();
+
+    EXPECT_EQ(1, buffer->getStrongCount());
+}
+
+TEST_F(SurfaceTextureGLToGLTest, EglMakeCurrentAfterConsumerDeathUnrefsBuffers) {
+    sp<GraphicBuffer> buffer;
+
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
+            mProducerEglSurface, mProducerEglContext));
+
+    // Produce a frame
+    glClear(GL_COLOR_BUFFER_BIT);
+    EXPECT_TRUE(eglSwapBuffers(mEglDisplay, mProducerEglSurface));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    // Destroy the EGLSurface.
+    EXPECT_TRUE(eglDestroySurface(mEglDisplay, mProducerEglSurface));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+    mProducerEglSurface = EGL_NO_SURFACE;
+    mSTC.clear();
+    mANW.clear();
+    mTextureRenderer.clear();
+
+    // Consume a frame
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+    buffer = mST->getCurrentBuffer();
+
+    // Destroy the GL texture object to release its ref
+    GLuint texID = TEX_ID;
+    glDeleteTextures(1, &texID);
+
+    // Destroy consumer
+    mST.clear();
+
+    // make un-current, all references to buffer should be gone
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE,
+            EGL_NO_SURFACE, EGL_NO_CONTEXT));
+
+    EXPECT_EQ(1, buffer->getStrongCount());
+}
+
+TEST_F(SurfaceTextureGLToGLTest, TexturingFromUserSizedGLFilledBuffer) {
+    enum { texWidth = 64 };
+    enum { texHeight = 64 };
+
+    // This test requires 3 buffers to complete run on a single thread.
+    mST->setDefaultMaxBufferCount(3);
+
+    // Set the user buffer size.
+    native_window_set_buffers_user_dimensions(mANW.get(), texWidth, texHeight);
+
+    // Do the producer side of things
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
+            mProducerEglSurface, mProducerEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    // This is needed to ensure we pick up a buffer of the correct size.
+    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+
+    glClearColor(0.6, 0.6, 0.6, 0.6);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    glEnable(GL_SCISSOR_TEST);
+    glScissor(4, 4, 1, 1);
+    glClearColor(1.0, 0.0, 0.0, 1.0);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+
+    // Do the consumer side of things
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    glDisable(GL_SCISSOR_TEST);
+
+    // Skip the first frame, which was empty
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+
+    glClearColor(0.2, 0.2, 0.2, 0.2);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    glViewport(0, 0, texWidth, texHeight);
+    drawTexture();
+
+    EXPECT_TRUE(checkPixel( 0,  0, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(63,  0, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(63, 63, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel( 0, 63, 153, 153, 153, 153));
+
+    EXPECT_TRUE(checkPixel( 4,  4, 255,   0,   0, 255));
+    EXPECT_TRUE(checkPixel( 5,  5, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel( 3,  3, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(45, 52, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(12, 36, 153, 153, 153, 153));
+}
+
+TEST_F(SurfaceTextureGLToGLTest, TexturingFromPreRotatedUserSizedGLFilledBuffer) {
+    enum { texWidth = 64 };
+    enum { texHeight = 16 };
+
+    // This test requires 3 buffers to complete run on a single thread.
+    mST->setDefaultMaxBufferCount(3);
+
+    // Set the transform hint.
+    mST->setTransformHint(NATIVE_WINDOW_TRANSFORM_ROT_90);
+
+    // Set the user buffer size.
+    native_window_set_buffers_user_dimensions(mANW.get(), texWidth, texHeight);
+
+    // Do the producer side of things
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
+            mProducerEglSurface, mProducerEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    // This is needed to ensure we pick up a buffer of the correct size and the
+    // new rotation hint.
+    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+
+    glClearColor(0.6, 0.6, 0.6, 0.6);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    glEnable(GL_SCISSOR_TEST);
+    glScissor(24, 4, 1, 1);
+    glClearColor(1.0, 0.0, 0.0, 1.0);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+
+    // Do the consumer side of things
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    glDisable(GL_SCISSOR_TEST);
+
+    // Skip the first frame, which was empty
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+
+    glClearColor(0.2, 0.2, 0.2, 0.2);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    glViewport(0, 0, texWidth, texHeight);
+    drawTexture();
+
+    EXPECT_TRUE(checkPixel( 0,  0, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(63,  0, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(63, 15, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel( 0, 15, 153, 153, 153, 153));
+
+    EXPECT_TRUE(checkPixel(24,  4, 255,   0,   0, 255));
+    EXPECT_TRUE(checkPixel(25,  5, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(23,  3, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(45, 13, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(12,  8, 153, 153, 153, 153));
+}
+
+TEST_F(SurfaceTextureGLToGLTest, TexturingFromPreRotatedGLFilledBuffer) {
+    enum { texWidth = 64 };
+    enum { texHeight = 16 };
+
+    // This test requires 3 buffers to complete run on a single thread.
+    mST->setDefaultMaxBufferCount(3);
+
+    // Set the transform hint.
+    mST->setTransformHint(NATIVE_WINDOW_TRANSFORM_ROT_90);
+
+    // Set the default buffer size.
+    mST->setDefaultBufferSize(texWidth, texHeight);
+
+    // Do the producer side of things
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
+            mProducerEglSurface, mProducerEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    // This is needed to ensure we pick up a buffer of the correct size and the
+    // new rotation hint.
+    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+
+    glClearColor(0.6, 0.6, 0.6, 0.6);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    glEnable(GL_SCISSOR_TEST);
+    glScissor(24, 4, 1, 1);
+    glClearColor(1.0, 0.0, 0.0, 1.0);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+
+    // Do the consumer side of things
+    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    glDisable(GL_SCISSOR_TEST);
+
+    // Skip the first frame, which was empty
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+
+    glClearColor(0.2, 0.2, 0.2, 0.2);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    glViewport(0, 0, texWidth, texHeight);
+    drawTexture();
+
+    EXPECT_TRUE(checkPixel( 0,  0, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(63,  0, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(63, 15, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel( 0, 15, 153, 153, 153, 153));
+
+    EXPECT_TRUE(checkPixel(24,  4, 255,   0,   0, 255));
+    EXPECT_TRUE(checkPixel(25,  5, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(23,  3, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(45, 13, 153, 153, 153, 153));
+    EXPECT_TRUE(checkPixel(12,  8, 153, 153, 153, 153));
+}
+
+} // namespace android
diff --git a/libs/gui/tests/SurfaceTextureGL_test.cpp b/libs/gui/tests/SurfaceTextureGL_test.cpp
new file mode 100644
index 0000000..bf87061
--- /dev/null
+++ b/libs/gui/tests/SurfaceTextureGL_test.cpp
@@ -0,0 +1,715 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "SurfaceTextureGL_test"
+//#define LOG_NDEBUG 0
+
+#include "SurfaceTextureGL.h"
+
+#include "DisconnectWaiter.h"
+#include "FillBuffer.h"
+
+namespace android {
+
+TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledYV12BufferNpot) {
+    const int texWidth = 64;
+    const int texHeight = 66;
+
+    ASSERT_EQ(NO_ERROR, native_window_set_buffers_dimensions(mANW.get(),
+            texWidth, texHeight));
+    ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
+            HAL_PIXEL_FORMAT_YV12));
+    ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
+            GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
+
+    ANativeWindowBuffer* anb;
+    ASSERT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(),
+            &anb));
+    ASSERT_TRUE(anb != NULL);
+
+    sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
+
+    // Fill the buffer with the a checkerboard pattern
+    uint8_t* img = NULL;
+    buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
+    fillYV12Buffer(img, texWidth, texHeight, buf->getStride());
+    buf->unlock();
+    ASSERT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), buf->getNativeBuffer(),
+            -1));
+
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+
+    glClearColor(0.2, 0.2, 0.2, 0.2);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    glViewport(0, 0, texWidth, texHeight);
+    drawTexture();
+
+    EXPECT_TRUE(checkPixel( 0,  0, 255, 127, 255, 255, 3));
+    EXPECT_TRUE(checkPixel(63,  0,   0, 133,   0, 255, 3));
+    EXPECT_TRUE(checkPixel(63, 65,   0, 133,   0, 255, 3));
+    EXPECT_TRUE(checkPixel( 0, 65, 255, 127, 255, 255, 3));
+
+    EXPECT_TRUE(checkPixel(22, 44, 255, 127, 255, 255, 3));
+    EXPECT_TRUE(checkPixel(45, 52, 255, 127, 255, 255, 3));
+    EXPECT_TRUE(checkPixel(52, 51,  98, 255,  73, 255, 3));
+    EXPECT_TRUE(checkPixel( 7, 31, 155,   0, 118, 255, 3));
+    EXPECT_TRUE(checkPixel(31,  9, 107,  24,  87, 255, 3));
+    EXPECT_TRUE(checkPixel(29, 35, 255, 127, 255, 255, 3));
+    EXPECT_TRUE(checkPixel(36, 22, 155,  29,   0, 255, 3));
+}
+
+TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledYV12BufferPow2) {
+    const int texWidth = 64;
+    const int texHeight = 64;
+
+    ASSERT_EQ(NO_ERROR, native_window_set_buffers_dimensions(mANW.get(),
+            texWidth, texHeight));
+    ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
+            HAL_PIXEL_FORMAT_YV12));
+    ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
+            GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
+
+    ANativeWindowBuffer* anb;
+    ASSERT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(),
+            &anb));
+    ASSERT_TRUE(anb != NULL);
+
+    sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
+
+    // Fill the buffer with the a checkerboard pattern
+    uint8_t* img = NULL;
+    buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
+    fillYV12Buffer(img, texWidth, texHeight, buf->getStride());
+    buf->unlock();
+    ASSERT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), buf->getNativeBuffer(),
+            -1));
+
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+
+    glClearColor(0.2, 0.2, 0.2, 0.2);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    glViewport(0, 0, texWidth, texHeight);
+    drawTexture();
+
+    EXPECT_TRUE(checkPixel( 0,  0,   0, 133,   0, 255));
+    EXPECT_TRUE(checkPixel(63,  0, 255, 127, 255, 255));
+    EXPECT_TRUE(checkPixel(63, 63,   0, 133,   0, 255));
+    EXPECT_TRUE(checkPixel( 0, 63, 255, 127, 255, 255));
+
+    EXPECT_TRUE(checkPixel(22, 19, 100, 255,  74, 255));
+    EXPECT_TRUE(checkPixel(45, 11, 100, 255,  74, 255));
+    EXPECT_TRUE(checkPixel(52, 12, 155,   0, 181, 255));
+    EXPECT_TRUE(checkPixel( 7, 32, 150, 237, 170, 255));
+    EXPECT_TRUE(checkPixel(31, 54,   0,  71, 117, 255));
+    EXPECT_TRUE(checkPixel(29, 28,   0, 133,   0, 255));
+    EXPECT_TRUE(checkPixel(36, 41, 100, 232, 255, 255));
+}
+
+TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledYV12BufferWithCrop) {
+    const int texWidth = 64;
+    const int texHeight = 66;
+
+    ASSERT_EQ(NO_ERROR, native_window_set_buffers_dimensions(mANW.get(),
+            texWidth, texHeight));
+    ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
+            HAL_PIXEL_FORMAT_YV12));
+    ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
+            GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
+
+    android_native_rect_t crops[] = {
+        {4, 6, 22, 36},
+        {0, 6, 22, 36},
+        {4, 0, 22, 36},
+        {4, 6, texWidth, 36},
+        {4, 6, 22, texHeight},
+    };
+
+    for (int i = 0; i < 5; i++) {
+        const android_native_rect_t& crop(crops[i]);
+        SCOPED_TRACE(String8::format("rect{ l: %d t: %d r: %d b: %d }",
+                crop.left, crop.top, crop.right, crop.bottom).string());
+
+        ASSERT_EQ(NO_ERROR, native_window_set_crop(mANW.get(), &crop));
+
+        ANativeWindowBuffer* anb;
+        ASSERT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(),
+                &anb));
+        ASSERT_TRUE(anb != NULL);
+
+        sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
+
+        uint8_t* img = NULL;
+        buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
+        fillYV12BufferRect(img, texWidth, texHeight, buf->getStride(), crop);
+        buf->unlock();
+        ASSERT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(),
+                buf->getNativeBuffer(), -1));
+
+        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+
+        glClearColor(0.2, 0.2, 0.2, 0.2);
+        glClear(GL_COLOR_BUFFER_BIT);
+
+        glViewport(0, 0, 64, 64);
+        drawTexture();
+
+        EXPECT_TRUE(checkPixel( 0,  0,  82, 255,  35, 255));
+        EXPECT_TRUE(checkPixel(63,  0,  82, 255,  35, 255));
+        EXPECT_TRUE(checkPixel(63, 63,  82, 255,  35, 255));
+        EXPECT_TRUE(checkPixel( 0, 63,  82, 255,  35, 255));
+
+        EXPECT_TRUE(checkPixel(25, 14,  82, 255,  35, 255));
+        EXPECT_TRUE(checkPixel(35, 31,  82, 255,  35, 255));
+        EXPECT_TRUE(checkPixel(57,  6,  82, 255,  35, 255));
+        EXPECT_TRUE(checkPixel( 5, 42,  82, 255,  35, 255));
+        EXPECT_TRUE(checkPixel(32, 33,  82, 255,  35, 255));
+        EXPECT_TRUE(checkPixel(16, 26,  82, 255,  35, 255));
+        EXPECT_TRUE(checkPixel(46, 51,  82, 255,  35, 255));
+    }
+}
+
+// This test is intended to catch synchronization bugs between the CPU-written
+// and GPU-read buffers.
+TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledYV12BuffersRepeatedly) {
+    enum { texWidth = 16 };
+    enum { texHeight = 16 };
+    enum { numFrames = 1024 };
+
+    ASSERT_EQ(NO_ERROR, mST->setDefaultMaxBufferCount(2));
+    ASSERT_EQ(NO_ERROR, native_window_set_buffers_dimensions(mANW.get(),
+            texWidth, texHeight));
+    ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
+            HAL_PIXEL_FORMAT_YV12));
+    ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
+            GRALLOC_USAGE_SW_WRITE_OFTEN));
+
+    struct TestPixel {
+        int x;
+        int y;
+    };
+    const TestPixel testPixels[] = {
+        {  4, 11 },
+        { 12, 14 },
+        {  7,  2 },
+    };
+    enum {numTestPixels = sizeof(testPixels) / sizeof(testPixels[0])};
+
+    class ProducerThread : public Thread {
+    public:
+        ProducerThread(const sp<ANativeWindow>& anw,
+                const TestPixel* testPixels):
+                mANW(anw),
+                mTestPixels(testPixels) {
+        }
+
+        virtual ~ProducerThread() {
+        }
+
+        virtual bool threadLoop() {
+            for (int i = 0; i < numFrames; i++) {
+                ANativeWindowBuffer* anb;
+                if (native_window_dequeue_buffer_and_wait(mANW.get(),
+                        &anb) != NO_ERROR) {
+                    return false;
+                }
+                if (anb == NULL) {
+                    return false;
+                }
+
+                sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
+
+                const int yuvTexOffsetY = 0;
+                int stride = buf->getStride();
+                int yuvTexStrideY = stride;
+                int yuvTexOffsetV = yuvTexStrideY * texHeight;
+                int yuvTexStrideV = (yuvTexStrideY/2 + 0xf) & ~0xf;
+                int yuvTexOffsetU = yuvTexOffsetV + yuvTexStrideV * texHeight/2;
+                int yuvTexStrideU = yuvTexStrideV;
+
+                uint8_t* img = NULL;
+                buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
+
+                // Gray out all the test pixels first, so we're more likely to
+                // see a failure if GL is still texturing from the buffer we
+                // just dequeued.
+                for (int j = 0; j < numTestPixels; j++) {
+                    int x = mTestPixels[j].x;
+                    int y = mTestPixels[j].y;
+                    uint8_t value = 128;
+                    img[y*stride + x] = value;
+                }
+
+                // Fill the buffer with gray.
+                for (int y = 0; y < texHeight; y++) {
+                    for (int x = 0; x < texWidth; x++) {
+                        img[yuvTexOffsetY + y*yuvTexStrideY + x] = 128;
+                        img[yuvTexOffsetU + (y/2)*yuvTexStrideU + x/2] = 128;
+                        img[yuvTexOffsetV + (y/2)*yuvTexStrideV + x/2] = 128;
+                    }
+                }
+
+                // Set the test pixels to either white or black.
+                for (int j = 0; j < numTestPixels; j++) {
+                    int x = mTestPixels[j].x;
+                    int y = mTestPixels[j].y;
+                    uint8_t value = 0;
+                    if (j == (i % numTestPixels)) {
+                        value = 255;
+                    }
+                    img[y*stride + x] = value;
+                }
+
+                buf->unlock();
+                if (mANW->queueBuffer(mANW.get(), buf->getNativeBuffer(), -1)
+                        != NO_ERROR) {
+                    return false;
+                }
+            }
+            return false;
+        }
+
+        sp<ANativeWindow> mANW;
+        const TestPixel* mTestPixels;
+    };
+
+    sp<Thread> pt(new ProducerThread(mANW, testPixels));
+    pt->run();
+
+    glViewport(0, 0, texWidth, texHeight);
+
+    glClearColor(0.2, 0.2, 0.2, 0.2);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    // We wait for the first two frames up front so that the producer will be
+    // likely to dequeue the buffer that's currently being textured from.
+    mFW->waitForFrame();
+    mFW->waitForFrame();
+
+    for (int i = 0; i < numFrames; i++) {
+        SCOPED_TRACE(String8::format("frame %d", i).string());
+
+        // We must wait for each frame to come in because if we ever do an
+        // updateTexImage call that doesn't consume a newly available buffer
+        // then the producer and consumer will get out of sync, which will cause
+        // a deadlock.
+        if (i > 1) {
+            mFW->waitForFrame();
+        }
+        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+        drawTexture();
+
+        for (int j = 0; j < numTestPixels; j++) {
+            int x = testPixels[j].x;
+            int y = testPixels[j].y;
+            uint8_t value = 0;
+            if (j == (i % numTestPixels)) {
+                // We must y-invert the texture coords
+                EXPECT_TRUE(checkPixel(x, texHeight-y-1, 255, 255, 255, 255));
+            } else {
+                // We must y-invert the texture coords
+                EXPECT_TRUE(checkPixel(x, texHeight-y-1, 0, 0, 0, 255));
+            }
+        }
+    }
+
+    pt->requestExitAndWait();
+}
+
+TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledRGBABufferNpot) {
+    const int texWidth = 64;
+    const int texHeight = 66;
+
+    ASSERT_EQ(NO_ERROR, native_window_set_buffers_dimensions(mANW.get(),
+            texWidth, texHeight));
+    ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
+            HAL_PIXEL_FORMAT_RGBA_8888));
+    ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
+            GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
+
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+
+    glClearColor(0.2, 0.2, 0.2, 0.2);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    glViewport(0, 0, texWidth, texHeight);
+    drawTexture();
+
+    EXPECT_TRUE(checkPixel( 0,  0,  35,  35,  35,  35));
+    EXPECT_TRUE(checkPixel(63,  0, 231, 231, 231, 231));
+    EXPECT_TRUE(checkPixel(63, 65, 231, 231, 231, 231));
+    EXPECT_TRUE(checkPixel( 0, 65,  35,  35,  35,  35));
+
+    EXPECT_TRUE(checkPixel(15, 10,  35, 231, 231, 231));
+    EXPECT_TRUE(checkPixel(23, 65, 231,  35, 231,  35));
+    EXPECT_TRUE(checkPixel(19, 40,  35, 231,  35,  35));
+    EXPECT_TRUE(checkPixel(38, 30, 231,  35,  35,  35));
+    EXPECT_TRUE(checkPixel(42, 54,  35,  35,  35, 231));
+    EXPECT_TRUE(checkPixel(37, 34,  35, 231, 231, 231));
+    EXPECT_TRUE(checkPixel(31,  8, 231,  35,  35, 231));
+    EXPECT_TRUE(checkPixel(37, 47, 231,  35, 231, 231));
+    EXPECT_TRUE(checkPixel(25, 38,  35,  35,  35,  35));
+    EXPECT_TRUE(checkPixel(49,  6,  35, 231,  35,  35));
+    EXPECT_TRUE(checkPixel(54, 50,  35, 231, 231, 231));
+    EXPECT_TRUE(checkPixel(27, 26, 231, 231, 231, 231));
+    EXPECT_TRUE(checkPixel(10,  6,  35,  35, 231, 231));
+    EXPECT_TRUE(checkPixel(29,  4,  35,  35,  35, 231));
+    EXPECT_TRUE(checkPixel(55, 28,  35,  35, 231,  35));
+    EXPECT_TRUE(checkPixel(58, 55,  35,  35, 231, 231));
+}
+
+TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledRGBABufferPow2) {
+    const int texWidth = 64;
+    const int texHeight = 64;
+
+    ASSERT_EQ(NO_ERROR, native_window_set_buffers_dimensions(mANW.get(),
+            texWidth, texHeight));
+    ASSERT_EQ(NO_ERROR, native_window_set_buffers_format(mANW.get(),
+            HAL_PIXEL_FORMAT_RGBA_8888));
+    ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
+            GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
+
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
+
+    glClearColor(0.2, 0.2, 0.2, 0.2);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    glViewport(0, 0, texWidth, texHeight);
+    drawTexture();
+
+    EXPECT_TRUE(checkPixel( 0,  0, 231, 231, 231, 231));
+    EXPECT_TRUE(checkPixel(63,  0,  35,  35,  35,  35));
+    EXPECT_TRUE(checkPixel(63, 63, 231, 231, 231, 231));
+    EXPECT_TRUE(checkPixel( 0, 63,  35,  35,  35,  35));
+
+    EXPECT_TRUE(checkPixel(12, 46, 231, 231, 231,  35));
+    EXPECT_TRUE(checkPixel(16,  1, 231, 231,  35, 231));
+    EXPECT_TRUE(checkPixel(21, 12, 231,  35,  35, 231));
+    EXPECT_TRUE(checkPixel(26, 51, 231,  35, 231,  35));
+    EXPECT_TRUE(checkPixel( 5, 32,  35, 231, 231,  35));
+    EXPECT_TRUE(checkPixel(13,  8,  35, 231, 231, 231));
+    EXPECT_TRUE(checkPixel(46,  3,  35,  35, 231,  35));
+    EXPECT_TRUE(checkPixel(30, 33,  35,  35,  35,  35));
+    EXPECT_TRUE(checkPixel( 6, 52, 231, 231,  35,  35));
+    EXPECT_TRUE(checkPixel(55, 33,  35, 231,  35, 231));
+    EXPECT_TRUE(checkPixel(16, 29,  35,  35, 231, 231));
+    EXPECT_TRUE(checkPixel( 1, 30,  35,  35,  35, 231));
+    EXPECT_TRUE(checkPixel(41, 37,  35,  35, 231, 231));
+    EXPECT_TRUE(checkPixel(46, 29, 231, 231,  35,  35));
+    EXPECT_TRUE(checkPixel(15, 25,  35, 231,  35, 231));
+    EXPECT_TRUE(checkPixel( 3, 52,  35, 231,  35,  35));
+}
+
+// Tests if GLConsumer and BufferQueue are robust enough
+// to handle a special case where updateTexImage is called
+// in the middle of disconnect.  This ordering is enforced
+// by blocking in the disconnect callback.
+TEST_F(SurfaceTextureGLTest, DisconnectStressTest) {
+
+    class ProducerThread : public Thread {
+    public:
+        explicit ProducerThread(const sp<ANativeWindow>& anw):
+                mANW(anw) {
+        }
+
+        virtual ~ProducerThread() {
+        }
+
+        virtual bool threadLoop() {
+            ANativeWindowBuffer* anb;
+
+            native_window_api_connect(mANW.get(), NATIVE_WINDOW_API_EGL);
+
+            for (int numFrames =0 ; numFrames < 2; numFrames ++) {
+
+                if (native_window_dequeue_buffer_and_wait(mANW.get(),
+                        &anb) != NO_ERROR) {
+                    return false;
+                }
+                if (anb == NULL) {
+                    return false;
+                }
+                if (mANW->queueBuffer(mANW.get(), anb, -1)
+                        != NO_ERROR) {
+                    return false;
+                }
+            }
+
+            native_window_api_disconnect(mANW.get(), NATIVE_WINDOW_API_EGL);
+
+            return false;
+        }
+
+    private:
+        sp<ANativeWindow> mANW;
+    };
+
+    sp<DisconnectWaiter> dw(new DisconnectWaiter());
+    mConsumer->consumerConnect(dw, false);
+
+
+    sp<Thread> pt(new ProducerThread(mANW));
+    pt->run();
+
+    // eat a frame so GLConsumer will own an at least one slot
+    dw->waitForFrame();
+    EXPECT_EQ(OK,mST->updateTexImage());
+
+    dw->waitForFrame();
+    // Could fail here as GLConsumer thinks it still owns the slot
+    // but bufferQueue has released all slots
+    EXPECT_EQ(OK,mST->updateTexImage());
+
+    dw->finishDisconnect();
+}
+
+
+// This test ensures that the GLConsumer clears the mCurrentTexture
+// when it is disconnected and reconnected.  Otherwise it will
+// attempt to release a buffer that it does not owned
+TEST_F(SurfaceTextureGLTest, DisconnectClearsCurrentTexture) {
+    ASSERT_EQ(OK, native_window_api_connect(mANW.get(),
+            NATIVE_WINDOW_API_EGL));
+
+    ANativeWindowBuffer *anb;
+
+    EXPECT_EQ (OK, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
+    EXPECT_EQ(OK, mANW->queueBuffer(mANW.get(), anb, -1));
+
+    EXPECT_EQ (OK, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
+    EXPECT_EQ(OK, mANW->queueBuffer(mANW.get(), anb, -1));
+
+    EXPECT_EQ(OK,mST->updateTexImage());
+    EXPECT_EQ(OK,mST->updateTexImage());
+
+    ASSERT_EQ(OK, native_window_api_disconnect(mANW.get(),
+            NATIVE_WINDOW_API_EGL));
+    ASSERT_EQ(OK, native_window_api_connect(mANW.get(),
+            NATIVE_WINDOW_API_EGL));
+
+    EXPECT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
+    EXPECT_EQ(OK, mANW->queueBuffer(mANW.get(), anb, -1));
+
+    // Will fail here if mCurrentTexture is not cleared properly
+    mFW->waitForFrame();
+    EXPECT_EQ(OK,mST->updateTexImage());
+
+    ASSERT_EQ(OK, native_window_api_disconnect(mANW.get(),
+            NATIVE_WINDOW_API_EGL));
+}
+
+TEST_F(SurfaceTextureGLTest, ScaleToWindowMode) {
+    ASSERT_EQ(OK, native_window_set_scaling_mode(mANW.get(),
+        NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW));
+
+    // The producer image size
+    ASSERT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 512, 512));
+
+    // The consumer image size (16 x 9) ratio
+    mST->setDefaultBufferSize(1280, 720);
+
+    ASSERT_EQ(OK, native_window_api_connect(mANW.get(),
+            NATIVE_WINDOW_API_CPU));
+
+    ANativeWindowBuffer *anb;
+
+    android_native_rect_t odd = {23, 78, 123, 477};
+    ASSERT_EQ(OK, native_window_set_crop(mANW.get(), &odd));
+    EXPECT_EQ (OK, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
+    EXPECT_EQ(OK, mANW->queueBuffer(mANW.get(), anb, -1));
+    mFW->waitForFrame();
+    EXPECT_EQ(OK, mST->updateTexImage());
+    Rect r = mST->getCurrentCrop();
+    assertRectEq(Rect(23, 78, 123, 477), r);
+
+    ASSERT_EQ(OK, native_window_api_disconnect(mANW.get(),
+            NATIVE_WINDOW_API_CPU));
+}
+
+// This test ensures the scaling mode does the right thing
+// ie NATIVE_WINDOW_SCALING_MODE_CROP should crop
+// the image such that it has the same aspect ratio as the
+// default buffer size
+TEST_F(SurfaceTextureGLTest, CroppedScalingMode) {
+    ASSERT_EQ(OK, native_window_set_scaling_mode(mANW.get(),
+        NATIVE_WINDOW_SCALING_MODE_SCALE_CROP));
+
+    // The producer image size
+    ASSERT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 512, 512));
+
+    // The consumer image size (16 x 9) ratio
+    mST->setDefaultBufferSize(1280, 720);
+
+    native_window_api_connect(mANW.get(), NATIVE_WINDOW_API_CPU);
+
+    ANativeWindowBuffer *anb;
+
+    // The crop is in the shape of (320, 180) === 16 x 9
+    android_native_rect_t standard = {10, 20, 330, 200};
+    ASSERT_EQ(OK, native_window_set_crop(mANW.get(), &standard));
+    EXPECT_EQ (OK, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
+    EXPECT_EQ(OK, mANW->queueBuffer(mANW.get(), anb, -1));
+    mFW->waitForFrame();
+    EXPECT_EQ(OK, mST->updateTexImage());
+    Rect r = mST->getCurrentCrop();
+    // crop should be the same as crop (same aspect ratio)
+    assertRectEq(Rect(10, 20, 330, 200), r);
+
+    // make this wider then desired aspect 239 x 100 (2.39:1)
+    android_native_rect_t wide = {20, 30, 259, 130};
+    ASSERT_EQ(OK, native_window_set_crop(mANW.get(), &wide));
+    EXPECT_EQ (OK, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
+    EXPECT_EQ(OK, mANW->queueBuffer(mANW.get(), anb, -1));
+    mFW->waitForFrame();
+    EXPECT_EQ(OK, mST->updateTexImage());
+    r = mST->getCurrentCrop();
+    // crop should be the same height, but have cropped left and right borders
+    // offset is 30.6 px L+, R-
+    assertRectEq(Rect(51, 30, 228, 130), r);
+
+    // This image is taller then desired aspect 400 x 300 (4:3)
+    android_native_rect_t narrow = {0, 0, 400, 300};
+    ASSERT_EQ(OK, native_window_set_crop(mANW.get(), &narrow));
+    EXPECT_EQ (OK, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
+    EXPECT_EQ(OK, mANW->queueBuffer(mANW.get(), anb, -1));
+    mFW->waitForFrame();
+    EXPECT_EQ(OK, mST->updateTexImage());
+    r = mST->getCurrentCrop();
+    // crop should be the same width, but have cropped top and bottom borders
+    // offset is 37.5 px
+    assertRectEq(Rect(0, 37, 400, 262), r);
+
+    native_window_api_disconnect(mANW.get(), NATIVE_WINDOW_API_CPU);
+}
+
+TEST_F(SurfaceTextureGLTest, AbandonUnblocksDequeueBuffer) {
+    class ProducerThread : public Thread {
+    public:
+        explicit ProducerThread(const sp<ANativeWindow>& anw):
+                mANW(anw),
+                mDequeueError(NO_ERROR) {
+        }
+
+        virtual ~ProducerThread() {
+        }
+
+        virtual bool threadLoop() {
+            Mutex::Autolock lock(mMutex);
+            ANativeWindowBuffer* anb;
+
+            // Frame 1
+            if (native_window_dequeue_buffer_and_wait(mANW.get(),
+                    &anb) != NO_ERROR) {
+                return false;
+            }
+            if (anb == NULL) {
+                return false;
+            }
+            if (mANW->queueBuffer(mANW.get(), anb, -1)
+                    != NO_ERROR) {
+                return false;
+            }
+
+            // Frame 2
+            if (native_window_dequeue_buffer_and_wait(mANW.get(),
+                    &anb) != NO_ERROR) {
+                return false;
+            }
+            if (anb == NULL) {
+                return false;
+            }
+            if (mANW->queueBuffer(mANW.get(), anb, -1)
+                    != NO_ERROR) {
+                return false;
+            }
+
+            // Frame 3 - error expected
+            mDequeueError = native_window_dequeue_buffer_and_wait(mANW.get(),
+                &anb);
+            return false;
+        }
+
+        status_t getDequeueError() {
+            Mutex::Autolock lock(mMutex);
+            return mDequeueError;
+        }
+
+    private:
+        sp<ANativeWindow> mANW;
+        status_t mDequeueError;
+        Mutex mMutex;
+    };
+
+    ASSERT_EQ(OK, mST->setDefaultMaxBufferCount(2));
+
+    sp<Thread> pt(new ProducerThread(mANW));
+    pt->run();
+
+    mFW->waitForFrame();
+    mFW->waitForFrame();
+
+    // Sleep for 100ms to allow the producer thread's dequeueBuffer call to
+    // block waiting for a buffer to become available.
+    usleep(100000);
+
+    mST->abandon();
+
+    pt->requestExitAndWait();
+    ASSERT_EQ(NO_INIT,
+            reinterpret_cast<ProducerThread*>(pt.get())->getDequeueError());
+}
+
+TEST_F(SurfaceTextureGLTest, InvalidWidthOrHeightFails) {
+    int texHeight = 16;
+    ANativeWindowBuffer* anb;
+
+    GLint maxTextureSize;
+    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
+
+    // make sure it works with small textures
+    mST->setDefaultBufferSize(16, texHeight);
+    EXPECT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(),
+            &anb));
+    EXPECT_EQ(16, anb->width);
+    EXPECT_EQ(texHeight, anb->height);
+    EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb, -1));
+    EXPECT_EQ(NO_ERROR, mST->updateTexImage());
+
+    // make sure it works with GL_MAX_TEXTURE_SIZE
+    mST->setDefaultBufferSize(maxTextureSize, texHeight);
+    EXPECT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(),
+            &anb));
+    EXPECT_EQ(maxTextureSize, anb->width);
+    EXPECT_EQ(texHeight, anb->height);
+    EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb, -1));
+    EXPECT_EQ(NO_ERROR, mST->updateTexImage());
+
+    // make sure it fails with GL_MAX_TEXTURE_SIZE+1
+    mST->setDefaultBufferSize(maxTextureSize+1, texHeight);
+    EXPECT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(),
+            &anb));
+    EXPECT_EQ(maxTextureSize+1, anb->width);
+    EXPECT_EQ(texHeight, anb->height);
+    EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb, -1));
+    ASSERT_NE(NO_ERROR, mST->updateTexImage());
+}
+
+} // namespace android
diff --git a/libs/gui/tests/SurfaceTextureMultiContextGL.h b/libs/gui/tests/SurfaceTextureMultiContextGL.h
new file mode 100644
index 0000000..7934bbc
--- /dev/null
+++ b/libs/gui/tests/SurfaceTextureMultiContextGL.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_SURFACE_TEXTURE_MULTI_CONTEXT_GL_H
+#define ANDROID_SURFACE_TEXTURE_MULTI_CONTEXT_GL_H
+
+#include "SurfaceTextureGL.h"
+
+namespace android {
+
+class SurfaceTextureMultiContextGLTest : public SurfaceTextureGLTest {
+protected:
+    enum { SECOND_TEX_ID = 123 };
+    enum { THIRD_TEX_ID = 456 };
+
+    SurfaceTextureMultiContextGLTest():
+            mSecondEglContext(EGL_NO_CONTEXT) {
+    }
+
+    virtual void SetUp() {
+        SurfaceTextureGLTest::SetUp();
+
+        // Set up the secondary context and texture renderer.
+        mSecondEglContext = eglCreateContext(mEglDisplay, mGlConfig,
+                EGL_NO_CONTEXT, getContextAttribs());
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+        ASSERT_NE(EGL_NO_CONTEXT, mSecondEglContext);
+
+        ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+                mSecondEglContext));
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+        mSecondTextureRenderer = new TextureRenderer(SECOND_TEX_ID, mST);
+        ASSERT_NO_FATAL_FAILURE(mSecondTextureRenderer->SetUp());
+
+        // Set up the tertiary context and texture renderer.
+        mThirdEglContext = eglCreateContext(mEglDisplay, mGlConfig,
+                EGL_NO_CONTEXT, getContextAttribs());
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+        ASSERT_NE(EGL_NO_CONTEXT, mThirdEglContext);
+
+        ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+                mThirdEglContext));
+        ASSERT_EQ(EGL_SUCCESS, eglGetError());
+        mThirdTextureRenderer = new TextureRenderer(THIRD_TEX_ID, mST);
+        ASSERT_NO_FATAL_FAILURE(mThirdTextureRenderer->SetUp());
+
+        // Switch back to the primary context to start the tests.
+        ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+                mEglContext));
+    }
+
+    virtual void TearDown() {
+        if (mThirdEglContext != EGL_NO_CONTEXT) {
+            eglDestroyContext(mEglDisplay, mThirdEglContext);
+        }
+        if (mSecondEglContext != EGL_NO_CONTEXT) {
+            eglDestroyContext(mEglDisplay, mSecondEglContext);
+        }
+        SurfaceTextureGLTest::TearDown();
+    }
+
+    EGLContext mSecondEglContext;
+    sp<TextureRenderer> mSecondTextureRenderer;
+
+    EGLContext mThirdEglContext;
+    sp<TextureRenderer> mThirdTextureRenderer;
+};
+
+}
+
+#endif
diff --git a/libs/gui/tests/SurfaceTextureMultiContextGL_test.cpp b/libs/gui/tests/SurfaceTextureMultiContextGL_test.cpp
new file mode 100644
index 0000000..1cd101e
--- /dev/null
+++ b/libs/gui/tests/SurfaceTextureMultiContextGL_test.cpp
@@ -0,0 +1,444 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "SurfaceTextureMultiContextGL_test"
+//#define LOG_NDEBUG 0
+
+#include "SurfaceTextureMultiContextGL.h"
+
+#include "FillBuffer.h"
+
+#include <GLES/glext.h>
+
+namespace android {
+
+TEST_F(SurfaceTextureMultiContextGLTest, UpdateFromMultipleContextsFails) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Latch the texture contents on the primary context.
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // Attempt to latch the texture on the secondary context.
+    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mSecondEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+    ASSERT_EQ(INVALID_OPERATION, mST->updateTexImage());
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest, DetachFromContextSucceeds) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Latch the texture contents on the primary context.
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // Detach from the primary context.
+    ASSERT_EQ(OK, mST->detachFromContext());
+
+    // Check that the GL texture was deleted.
+    EXPECT_EQ(GL_FALSE, glIsTexture(TEX_ID));
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest,
+        DetachFromContextSucceedsAfterProducerDisconnect) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Latch the texture contents on the primary context.
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // Detach from the primary context.
+    native_window_api_disconnect(mANW.get(), NATIVE_WINDOW_API_CPU);
+    ASSERT_EQ(OK, mST->detachFromContext());
+
+    // Check that the GL texture was deleted.
+    EXPECT_EQ(GL_FALSE, glIsTexture(TEX_ID));
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest, DetachFromContextFailsWhenAbandoned) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Latch the texture contents on the primary context.
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // Attempt to detach from the primary context.
+    mST->abandon();
+    ASSERT_EQ(NO_INIT, mST->detachFromContext());
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest, DetachFromContextFailsWhenDetached) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Latch the texture contents on the primary context.
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // Detach from the primary context.
+    ASSERT_EQ(OK, mST->detachFromContext());
+
+    // Attempt to detach from the primary context again.
+    ASSERT_EQ(INVALID_OPERATION, mST->detachFromContext());
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest, DetachFromContextFailsWithNoDisplay) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Latch the texture contents on the primary context.
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // Make there be no current display.
+    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
+            EGL_NO_CONTEXT));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    // Attempt to detach from the primary context.
+    ASSERT_EQ(INVALID_OPERATION, mST->detachFromContext());
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest, DetachFromContextFailsWithNoContext) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Latch the texture contents on the primary context.
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // Make current context be incorrect.
+    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mSecondEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    // Attempt to detach from the primary context.
+    ASSERT_EQ(INVALID_OPERATION, mST->detachFromContext());
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest, UpdateTexImageFailsWhenDetached) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Detach from the primary context.
+    ASSERT_EQ(OK, mST->detachFromContext());
+
+    // Attempt to latch the texture contents on the primary context.
+    mFW->waitForFrame();
+    ASSERT_EQ(INVALID_OPERATION, mST->updateTexImage());
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest, AttachToContextSucceeds) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Latch the texture contents on the primary context.
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // Detach from the primary context.
+    ASSERT_EQ(OK, mST->detachFromContext());
+
+    // Attach to the secondary context.
+    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mSecondEglContext));
+    ASSERT_EQ(OK, mST->attachToContext(SECOND_TEX_ID));
+
+    // Verify that the texture object was created and bound.
+    GLint texBinding = -1;
+    glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texBinding);
+    EXPECT_EQ(SECOND_TEX_ID, texBinding);
+
+    // Try to use the texture from the secondary context.
+    glClearColor(0.2, 0.2, 0.2, 0.2);
+    glClear(GL_COLOR_BUFFER_BIT);
+    glViewport(0, 0, 1, 1);
+    mSecondTextureRenderer->drawTexture();
+    ASSERT_TRUE(checkPixel( 0,  0,  35,  35,  35,  35));
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest,
+        AttachToContextSucceedsAfterProducerDisconnect) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Latch the texture contents on the primary context.
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // Detach from the primary context.
+    native_window_api_disconnect(mANW.get(), NATIVE_WINDOW_API_CPU);
+    ASSERT_EQ(OK, mST->detachFromContext());
+
+    // Attach to the secondary context.
+    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mSecondEglContext));
+    ASSERT_EQ(OK, mST->attachToContext(SECOND_TEX_ID));
+
+    // Verify that the texture object was created and bound.
+    GLint texBinding = -1;
+    glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texBinding);
+    EXPECT_EQ(SECOND_TEX_ID, texBinding);
+
+    // Try to use the texture from the secondary context.
+    glClearColor(0.2, 0.2, 0.2, 0.2);
+    glClear(GL_COLOR_BUFFER_BIT);
+    glViewport(0, 0, 1, 1);
+    mSecondTextureRenderer->drawTexture();
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+    ASSERT_TRUE(checkPixel( 0,  0,  35,  35,  35,  35));
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest,
+        AttachToContextSucceedsBeforeUpdateTexImage) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Detach from the primary context.
+    native_window_api_disconnect(mANW.get(), NATIVE_WINDOW_API_CPU);
+    ASSERT_EQ(OK, mST->detachFromContext());
+
+    // Attach to the secondary context.
+    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mSecondEglContext));
+    ASSERT_EQ(OK, mST->attachToContext(SECOND_TEX_ID));
+
+    // Verify that the texture object was created and bound.
+    GLint texBinding = -1;
+    glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texBinding);
+    EXPECT_EQ(SECOND_TEX_ID, texBinding);
+
+    // Latch the texture contents on the primary context.
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // Try to use the texture from the secondary context.
+    glClearColor(0.2, 0.2, 0.2, 0.2);
+    glClear(GL_COLOR_BUFFER_BIT);
+    glViewport(0, 0, 1, 1);
+    mSecondTextureRenderer->drawTexture();
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+    ASSERT_TRUE(checkPixel( 0,  0,  35,  35,  35,  35));
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest, AttachToContextFailsWhenAbandoned) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Latch the texture contents on the primary context.
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // Detach from the primary context.
+    ASSERT_EQ(OK, mST->detachFromContext());
+
+    // Attempt to attach to the secondary context.
+    mST->abandon();
+
+    // Attempt to attach to the primary context.
+    ASSERT_EQ(NO_INIT, mST->attachToContext(SECOND_TEX_ID));
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest, AttachToContextFailsWhenAttached) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Latch the texture contents on the primary context.
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // Attempt to attach to the primary context.
+    ASSERT_EQ(INVALID_OPERATION, mST->attachToContext(SECOND_TEX_ID));
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest,
+        AttachToContextFailsWhenAttachedBeforeUpdateTexImage) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Attempt to attach to the primary context.
+    ASSERT_EQ(INVALID_OPERATION, mST->attachToContext(SECOND_TEX_ID));
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest, AttachToContextFailsWithNoDisplay) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Latch the texture contents on the primary context.
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // Detach from the primary context.
+    ASSERT_EQ(OK, mST->detachFromContext());
+
+    // Make there be no current display.
+    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
+            EGL_NO_CONTEXT));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    // Attempt to attach with no context current.
+    ASSERT_EQ(INVALID_OPERATION, mST->attachToContext(SECOND_TEX_ID));
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest, AttachToContextSucceedsTwice) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Latch the texture contents on the primary context.
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // Detach from the primary context.
+    ASSERT_EQ(OK, mST->detachFromContext());
+
+    // Attach to the secondary context.
+    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mSecondEglContext));
+    ASSERT_EQ(OK, mST->attachToContext(SECOND_TEX_ID));
+
+    // Detach from the secondary context.
+    ASSERT_EQ(OK, mST->detachFromContext());
+
+    // Attach to the tertiary context.
+    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mThirdEglContext));
+    ASSERT_EQ(OK, mST->attachToContext(THIRD_TEX_ID));
+
+    // Verify that the texture object was created and bound.
+    GLint texBinding = -1;
+    glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texBinding);
+    EXPECT_EQ(THIRD_TEX_ID, texBinding);
+
+    // Try to use the texture from the tertiary context.
+    glClearColor(0.2, 0.2, 0.2, 0.2);
+    glClear(GL_COLOR_BUFFER_BIT);
+    glViewport(0, 0, 1, 1);
+    mThirdTextureRenderer->drawTexture();
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+    ASSERT_TRUE(checkPixel( 0,  0,  35,  35,  35,  35));
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest,
+        AttachToContextSucceedsTwiceBeforeUpdateTexImage) {
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Detach from the primary context.
+    ASSERT_EQ(OK, mST->detachFromContext());
+
+    // Attach to the secondary context.
+    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mSecondEglContext));
+    ASSERT_EQ(OK, mST->attachToContext(SECOND_TEX_ID));
+
+    // Detach from the secondary context.
+    ASSERT_EQ(OK, mST->detachFromContext());
+
+    // Attach to the tertiary context.
+    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mThirdEglContext));
+    ASSERT_EQ(OK, mST->attachToContext(THIRD_TEX_ID));
+
+    // Verify that the texture object was created and bound.
+    GLint texBinding = -1;
+    glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texBinding);
+    EXPECT_EQ(THIRD_TEX_ID, texBinding);
+
+    // Latch the texture contents on the tertiary context.
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // Try to use the texture from the tertiary context.
+    glClearColor(0.2, 0.2, 0.2, 0.2);
+    glClear(GL_COLOR_BUFFER_BIT);
+    glViewport(0, 0, 1, 1);
+    mThirdTextureRenderer->drawTexture();
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+    ASSERT_TRUE(checkPixel( 0,  0,  35,  35,  35,  35));
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest,
+        UpdateTexImageSucceedsForBufferConsumedBeforeDetach) {
+    ASSERT_EQ(NO_ERROR, mST->setDefaultMaxBufferCount(2));
+
+    // produce two frames and consume them both on the primary context
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // produce one more frame
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Detach from the primary context and attach to the secondary context
+    ASSERT_EQ(OK, mST->detachFromContext());
+    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mSecondEglContext));
+    ASSERT_EQ(OK, mST->attachToContext(SECOND_TEX_ID));
+
+    // Consume final frame on secondary context
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+}
+
+TEST_F(SurfaceTextureMultiContextGLTest,
+       AttachAfterDisplayTerminatedSucceeds) {
+    ASSERT_EQ(NO_ERROR, mST->setDefaultMaxBufferCount(2));
+
+    // produce two frames and consume them both on the primary context
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+
+    // produce one more frame
+    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
+
+    // Detach from the primary context.
+    ASSERT_EQ(OK, mST->releaseTexImage());
+    ASSERT_EQ(OK, mST->detachFromContext());
+
+    // Terminate and then initialize the display. All contexts, surfaces
+    // and images are invalid at this point.
+    EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+    ASSERT_NE(EGL_NO_DISPLAY, mEglDisplay);
+    EGLint majorVersion = 0;
+    EGLint minorVersion = 0;
+    EXPECT_TRUE(eglTerminate(display));
+    EXPECT_TRUE(eglInitialize(mEglDisplay, &majorVersion, &minorVersion));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    // The surface is invalid so create it again.
+    EGLint pbufferAttribs[] = {
+        EGL_WIDTH, 64,
+        EGL_HEIGHT, 64,
+        EGL_NONE };
+    mEglSurface = eglCreatePbufferSurface(mEglDisplay, mGlConfig,
+            pbufferAttribs);
+
+    // The second context is invalid so create it again.
+    mSecondEglContext = eglCreateContext(mEglDisplay, mGlConfig,
+            EGL_NO_CONTEXT, getContextAttribs());
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+    ASSERT_NE(EGL_NO_CONTEXT, mSecondEglContext);
+
+    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+            mSecondEglContext));
+    ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+    // Now attach to and consume final frame on secondary context.
+    ASSERT_EQ(OK, mST->attachToContext(SECOND_TEX_ID));
+    mFW->waitForFrame();
+    ASSERT_EQ(OK, mST->updateTexImage());
+}
+
+
+} // namespace android
diff --git a/libs/gui/tests/SurfaceTexture_test.cpp b/libs/gui/tests/SurfaceTexture_test.cpp
deleted file mode 100644
index e4fba15..0000000
--- a/libs/gui/tests/SurfaceTexture_test.cpp
+++ /dev/null
@@ -1,2816 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "SurfaceTexture_test"
-//#define LOG_NDEBUG 0
-
-#include <gtest/gtest.h>
-#include <gui/GLConsumer.h>
-#include <ui/GraphicBuffer.h>
-#include <utils/String8.h>
-#include <utils/threads.h>
-
-#include <gui/ISurfaceComposer.h>
-#include <gui/Surface.h>
-#include <gui/SurfaceComposerClient.h>
-
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
-#include <ui/FramebufferNativeWindow.h>
-#include <android/native_window.h>
-
-namespace android {
-
-class GLTest : public ::testing::Test {
-protected:
-
-    GLTest():
-            mEglDisplay(EGL_NO_DISPLAY),
-            mEglSurface(EGL_NO_SURFACE),
-            mEglContext(EGL_NO_CONTEXT) {
-    }
-
-    virtual void SetUp() {
-        const ::testing::TestInfo* const testInfo =
-            ::testing::UnitTest::GetInstance()->current_test_info();
-        ALOGV("Begin test: %s.%s", testInfo->test_case_name(),
-                testInfo->name());
-
-        mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-        ASSERT_NE(EGL_NO_DISPLAY, mEglDisplay);
-
-        EGLint majorVersion;
-        EGLint minorVersion;
-        EXPECT_TRUE(eglInitialize(mEglDisplay, &majorVersion, &minorVersion));
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-        RecordProperty("EglVersionMajor", majorVersion);
-        RecordProperty("EglVersionMajor", minorVersion);
-
-        EGLint numConfigs = 0;
-        EXPECT_TRUE(eglChooseConfig(mEglDisplay, getConfigAttribs(), &mGlConfig,
-                1, &numConfigs));
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-        char* displaySecsEnv = getenv("GLTEST_DISPLAY_SECS");
-        if (displaySecsEnv != NULL) {
-            mDisplaySecs = atoi(displaySecsEnv);
-            if (mDisplaySecs < 0) {
-                mDisplaySecs = 0;
-            }
-        } else {
-            mDisplaySecs = 0;
-        }
-
-        if (mDisplaySecs > 0) {
-            mComposerClient = new SurfaceComposerClient;
-            ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
-
-            mSurfaceControl = mComposerClient->createSurface(
-                    String8("Test Surface"),
-                    getSurfaceWidth(), getSurfaceHeight(),
-                    PIXEL_FORMAT_RGB_888, 0);
-
-            ASSERT_TRUE(mSurfaceControl != NULL);
-            ASSERT_TRUE(mSurfaceControl->isValid());
-
-            SurfaceComposerClient::openGlobalTransaction();
-            ASSERT_EQ(NO_ERROR, mSurfaceControl->setLayer(0x7FFFFFFF));
-            ASSERT_EQ(NO_ERROR, mSurfaceControl->show());
-            SurfaceComposerClient::closeGlobalTransaction();
-
-            sp<ANativeWindow> window = mSurfaceControl->getSurface();
-            mEglSurface = eglCreateWindowSurface(mEglDisplay, mGlConfig,
-                    window.get(), NULL);
-        } else {
-            EGLint pbufferAttribs[] = {
-                EGL_WIDTH, getSurfaceWidth(),
-                EGL_HEIGHT, getSurfaceHeight(),
-                EGL_NONE };
-
-            mEglSurface = eglCreatePbufferSurface(mEglDisplay, mGlConfig,
-                    pbufferAttribs);
-        }
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-        ASSERT_NE(EGL_NO_SURFACE, mEglSurface);
-
-        mEglContext = eglCreateContext(mEglDisplay, mGlConfig, EGL_NO_CONTEXT,
-                getContextAttribs());
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-        ASSERT_NE(EGL_NO_CONTEXT, mEglContext);
-
-        EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-                mEglContext));
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-        EGLint w, h;
-        EXPECT_TRUE(eglQuerySurface(mEglDisplay, mEglSurface, EGL_WIDTH, &w));
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-        EXPECT_TRUE(eglQuerySurface(mEglDisplay, mEglSurface, EGL_HEIGHT, &h));
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-        RecordProperty("EglSurfaceWidth", w);
-        RecordProperty("EglSurfaceHeight", h);
-
-        glViewport(0, 0, w, h);
-        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-    }
-
-    virtual void TearDown() {
-        // Display the result
-        if (mDisplaySecs > 0 && mEglSurface != EGL_NO_SURFACE) {
-            eglSwapBuffers(mEglDisplay, mEglSurface);
-            sleep(mDisplaySecs);
-        }
-
-        if (mComposerClient != NULL) {
-            mComposerClient->dispose();
-        }
-        if (mEglContext != EGL_NO_CONTEXT) {
-            eglDestroyContext(mEglDisplay, mEglContext);
-        }
-        if (mEglSurface != EGL_NO_SURFACE) {
-            eglDestroySurface(mEglDisplay, mEglSurface);
-        }
-        if (mEglDisplay != EGL_NO_DISPLAY) {
-            eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
-                    EGL_NO_CONTEXT);
-            eglTerminate(mEglDisplay);
-        }
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-        const ::testing::TestInfo* const testInfo =
-            ::testing::UnitTest::GetInstance()->current_test_info();
-        ALOGV("End test:   %s.%s", testInfo->test_case_name(),
-                testInfo->name());
-    }
-
-    virtual EGLint const* getConfigAttribs() {
-        static EGLint sDefaultConfigAttribs[] = {
-            EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
-            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
-            EGL_RED_SIZE, 8,
-            EGL_GREEN_SIZE, 8,
-            EGL_BLUE_SIZE, 8,
-            EGL_ALPHA_SIZE, 8,
-            EGL_DEPTH_SIZE, 16,
-            EGL_STENCIL_SIZE, 8,
-            EGL_NONE };
-
-        return sDefaultConfigAttribs;
-    }
-
-    virtual EGLint const* getContextAttribs() {
-        static EGLint sDefaultContextAttribs[] = {
-            EGL_CONTEXT_CLIENT_VERSION, 2,
-            EGL_NONE };
-
-        return sDefaultContextAttribs;
-    }
-
-    virtual EGLint getSurfaceWidth() {
-        return 512;
-    }
-
-    virtual EGLint getSurfaceHeight() {
-        return 512;
-    }
-
-    ::testing::AssertionResult checkPixel(int x, int y, int r,
-            int g, int b, int a, int tolerance=2) {
-        GLubyte pixel[4];
-        String8 msg;
-        glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
-        GLenum err = glGetError();
-        if (err != GL_NO_ERROR) {
-            msg += String8::format("error reading pixel: %#x", err);
-            while ((err = glGetError()) != GL_NO_ERROR) {
-                msg += String8::format(", %#x", err);
-            }
-            return ::testing::AssertionFailure(
-                    ::testing::Message(msg.string()));
-        }
-        if (r >= 0 && abs(r - int(pixel[0])) > tolerance) {
-            msg += String8::format("r(%d isn't %d)", pixel[0], r);
-        }
-        if (g >= 0 && abs(g - int(pixel[1])) > tolerance) {
-            if (!msg.isEmpty()) {
-                msg += " ";
-            }
-            msg += String8::format("g(%d isn't %d)", pixel[1], g);
-        }
-        if (b >= 0 && abs(b - int(pixel[2])) > tolerance) {
-            if (!msg.isEmpty()) {
-                msg += " ";
-            }
-            msg += String8::format("b(%d isn't %d)", pixel[2], b);
-        }
-        if (a >= 0 && abs(a - int(pixel[3])) > tolerance) {
-            if (!msg.isEmpty()) {
-                msg += " ";
-            }
-            msg += String8::format("a(%d isn't %d)", pixel[3], a);
-        }
-        if (!msg.isEmpty()) {
-            return ::testing::AssertionFailure(
-                    ::testing::Message(msg.string()));
-        } else {
-            return ::testing::AssertionSuccess();
-        }
-    }
-
-    ::testing::AssertionResult assertRectEq(const Rect &r1,
-        const Rect &r2, int tolerance=1) {
-
-        String8 msg;
-
-        if (abs(r1.left - r2.left) > tolerance) {
-            msg += String8::format("left(%d isn't %d)", r1.left, r2.left);
-        }
-        if (abs(r1.top - r2.top) > tolerance) {
-            if (!msg.isEmpty()) {
-                msg += " ";
-            }
-            msg += String8::format("top(%d isn't %d)", r1.top, r2.top);
-        }
-        if (abs(r1.right - r2.right) > tolerance) {
-            if (!msg.isEmpty()) {
-                msg += " ";
-            }
-            msg += String8::format("right(%d isn't %d)", r1.right, r2.right);
-        }
-        if (abs(r1.bottom - r2.bottom) > tolerance) {
-            if (!msg.isEmpty()) {
-                msg += " ";
-            }
-            msg += String8::format("bottom(%d isn't %d)", r1.bottom, r2.bottom);
-        }
-        if (!msg.isEmpty()) {
-            msg += String8::format(" R1: [%d %d %d %d] R2: [%d %d %d %d]",
-                r1.left, r1.top, r1.right, r1.bottom,
-                r2.left, r2.top, r2.right, r2.bottom);
-            fprintf(stderr, "assertRectEq: %s\n", msg.string());
-            return ::testing::AssertionFailure(
-                    ::testing::Message(msg.string()));
-        } else {
-            return ::testing::AssertionSuccess();
-        }
-    }
-
-    int mDisplaySecs;
-    sp<SurfaceComposerClient> mComposerClient;
-    sp<SurfaceControl> mSurfaceControl;
-
-    EGLDisplay mEglDisplay;
-    EGLSurface mEglSurface;
-    EGLContext mEglContext;
-    EGLConfig  mGlConfig;
-};
-
-static void loadShader(GLenum shaderType, const char* pSource,
-        GLuint* outShader) {
-    GLuint shader = glCreateShader(shaderType);
-    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-    if (shader) {
-        glShaderSource(shader, 1, &pSource, NULL);
-        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-        glCompileShader(shader);
-        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-        GLint compiled = 0;
-        glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
-        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-        if (!compiled) {
-            GLint infoLen = 0;
-            glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
-            ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-            if (infoLen) {
-                char* buf = (char*) malloc(infoLen);
-                if (buf) {
-                    glGetShaderInfoLog(shader, infoLen, NULL, buf);
-                    printf("Shader compile log:\n%s\n", buf);
-                    free(buf);
-                    FAIL();
-                }
-            } else {
-                char* buf = (char*) malloc(0x1000);
-                if (buf) {
-                    glGetShaderInfoLog(shader, 0x1000, NULL, buf);
-                    printf("Shader compile log:\n%s\n", buf);
-                    free(buf);
-                    FAIL();
-                }
-            }
-            glDeleteShader(shader);
-            shader = 0;
-        }
-    }
-    ASSERT_TRUE(shader != 0);
-    *outShader = shader;
-}
-
-static void createProgram(const char* pVertexSource,
-        const char* pFragmentSource, GLuint* outPgm) {
-    GLuint vertexShader, fragmentShader;
-    {
-        SCOPED_TRACE("compiling vertex shader");
-        ASSERT_NO_FATAL_FAILURE(loadShader(GL_VERTEX_SHADER, pVertexSource,
-                &vertexShader));
-    }
-    {
-        SCOPED_TRACE("compiling fragment shader");
-        ASSERT_NO_FATAL_FAILURE(loadShader(GL_FRAGMENT_SHADER, pFragmentSource,
-                &fragmentShader));
-    }
-
-    GLuint program = glCreateProgram();
-    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-    if (program) {
-        glAttachShader(program, vertexShader);
-        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-        glAttachShader(program, fragmentShader);
-        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-        glLinkProgram(program);
-        GLint linkStatus = GL_FALSE;
-        glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
-        if (linkStatus != GL_TRUE) {
-            GLint bufLength = 0;
-            glGetProgramiv(program, GL_INFO_LOG_LENGTH, &bufLength);
-            if (bufLength) {
-                char* buf = (char*) malloc(bufLength);
-                if (buf) {
-                    glGetProgramInfoLog(program, bufLength, NULL, buf);
-                    printf("Program link log:\n%s\n", buf);
-                    free(buf);
-                    FAIL();
-                }
-            }
-            glDeleteProgram(program);
-            program = 0;
-        }
-    }
-    glDeleteShader(vertexShader);
-    glDeleteShader(fragmentShader);
-    ASSERT_TRUE(program != 0);
-    *outPgm = program;
-}
-
-static int abs(int value) {
-    return value > 0 ? value : -value;
-}
-
-
-// XXX: Code above this point should live elsewhere
-
-class MultiTextureConsumerTest : public GLTest {
-protected:
-    enum { TEX_ID = 123 };
-
-    virtual void SetUp() {
-        GLTest::SetUp();
-        sp<BufferQueue> bq = new BufferQueue();
-        mGlConsumer = new GLConsumer(bq, TEX_ID);
-        mSurface = new Surface(bq);
-        mANW = mSurface.get();
-
-    }
-    virtual void TearDown() {
-        GLTest::TearDown();
-    }
-    virtual EGLint const* getContextAttribs() {
-        return NULL;
-    }
-    virtual EGLint const* getConfigAttribs() {
-        static EGLint sDefaultConfigAttribs[] = {
-            EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
-            EGL_RED_SIZE, 8,
-            EGL_GREEN_SIZE, 8,
-            EGL_BLUE_SIZE, 8,
-            EGL_ALPHA_SIZE, 8,
-            EGL_NONE };
-
-        return sDefaultConfigAttribs;
-    }
-    sp<GLConsumer> mGlConsumer;
-    sp<Surface> mSurface;
-    ANativeWindow* mANW;
-};
-
-
-TEST_F(MultiTextureConsumerTest, EGLImageTargetWorks) {
-    ANativeWindow_Buffer buffer;
-
-    ASSERT_EQ(native_window_set_usage(mANW, GRALLOC_USAGE_SW_WRITE_OFTEN), NO_ERROR);
-    ASSERT_EQ(native_window_set_buffers_format(mANW, HAL_PIXEL_FORMAT_RGBA_8888), NO_ERROR);
-
-    glShadeModel(GL_FLAT);
-    glDisable(GL_DITHER);
-    glDisable(GL_CULL_FACE);
-    glViewport(0, 0, getSurfaceWidth(), getSurfaceHeight());
-    glOrthof(0, getSurfaceWidth(), 0, getSurfaceHeight(), 0, 1);
-    glEnableClientState(GL_VERTEX_ARRAY);
-    glColor4f(1, 1, 1, 1);
-
-    glBindTexture(GL_TEXTURE_EXTERNAL_OES, TEX_ID);
-    glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-    glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-    glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
-    uint32_t texel = 0x80808080;
-    glBindTexture(GL_TEXTURE_2D, TEX_ID+1);
-    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &texel);
-    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
-    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
-    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
-    glActiveTexture(GL_TEXTURE1);
-    glBindTexture(GL_TEXTURE_2D, TEX_ID+1);
-    glEnable(GL_TEXTURE_2D);
-    glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
-    glActiveTexture(GL_TEXTURE0);
-    glBindTexture(GL_TEXTURE_EXTERNAL_OES, TEX_ID);
-    glEnable(GL_TEXTURE_EXTERNAL_OES);
-    glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
-    glClear(GL_COLOR_BUFFER_BIT);
-    for (int i=0 ; i<8 ; i++) {
-        mSurface->lock(&buffer, NULL);
-        memset(buffer.bits, (i&7) * 0x20, buffer.stride * buffer.height * 4);
-        mSurface->unlockAndPost();
-
-        mGlConsumer->updateTexImage();
-
-        GLfloat vertices[][2] = { {i*16.0f, 0}, {(i+1)*16.0f, 0}, {(i+1)*16.0f, 16.0f}, {i*16.0f, 16.0f} };
-        glVertexPointer(2, GL_FLOAT, 0, vertices);
-        glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
-        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-    }
-
-    for (int i=0 ; i<8 ; i++) {
-        EXPECT_TRUE(checkPixel(i*16 + 8,  8, i*16, i*16, i*16, i*16, 0));
-    }
-}
-
-
-
-class SurfaceTextureGLTest : public GLTest {
-protected:
-    enum { TEX_ID = 123 };
-
-    virtual void SetUp() {
-        GLTest::SetUp();
-        sp<BufferQueue> bq = new BufferQueue();
-        mBQ = bq;
-        mST = new GLConsumer(bq, TEX_ID);
-        mSTC = new Surface(bq);
-        mANW = mSTC;
-        mTextureRenderer = new TextureRenderer(TEX_ID, mST);
-        ASSERT_NO_FATAL_FAILURE(mTextureRenderer->SetUp());
-        mFW = new FrameWaiter;
-        mST->setFrameAvailableListener(mFW);
-    }
-
-    virtual void TearDown() {
-        mANW.clear();
-        mSTC.clear();
-        mST.clear();
-        GLTest::TearDown();
-    }
-
-    void drawTexture() {
-        mTextureRenderer->drawTexture();
-    }
-
-    class TextureRenderer: public RefBase {
-    public:
-        TextureRenderer(GLuint texName, const sp<GLConsumer>& st):
-                mTexName(texName),
-                mST(st) {
-        }
-
-        void SetUp() {
-            const char vsrc[] =
-                "attribute vec4 vPosition;\n"
-                "varying vec2 texCoords;\n"
-                "uniform mat4 texMatrix;\n"
-                "void main() {\n"
-                "  vec2 vTexCoords = 0.5 * (vPosition.xy + vec2(1.0, 1.0));\n"
-                "  texCoords = (texMatrix * vec4(vTexCoords, 0.0, 1.0)).xy;\n"
-                "  gl_Position = vPosition;\n"
-                "}\n";
-
-            const char fsrc[] =
-                "#extension GL_OES_EGL_image_external : require\n"
-                "precision mediump float;\n"
-                "uniform samplerExternalOES texSampler;\n"
-                "varying vec2 texCoords;\n"
-                "void main() {\n"
-                "  gl_FragColor = texture2D(texSampler, texCoords);\n"
-                "}\n";
-
-            {
-                SCOPED_TRACE("creating shader program");
-                ASSERT_NO_FATAL_FAILURE(createProgram(vsrc, fsrc, &mPgm));
-            }
-
-            mPositionHandle = glGetAttribLocation(mPgm, "vPosition");
-            ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-            ASSERT_NE(-1, mPositionHandle);
-            mTexSamplerHandle = glGetUniformLocation(mPgm, "texSampler");
-            ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-            ASSERT_NE(-1, mTexSamplerHandle);
-            mTexMatrixHandle = glGetUniformLocation(mPgm, "texMatrix");
-            ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-            ASSERT_NE(-1, mTexMatrixHandle);
-        }
-
-        // drawTexture draws the GLConsumer over the entire GL viewport.
-        void drawTexture() {
-            static const GLfloat triangleVertices[] = {
-                -1.0f, 1.0f,
-                -1.0f, -1.0f,
-                1.0f, -1.0f,
-                1.0f, 1.0f,
-            };
-
-            glVertexAttribPointer(mPositionHandle, 2, GL_FLOAT, GL_FALSE, 0,
-                    triangleVertices);
-            ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-            glEnableVertexAttribArray(mPositionHandle);
-            ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-
-            glUseProgram(mPgm);
-            glUniform1i(mTexSamplerHandle, 0);
-            ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-            glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTexName);
-            ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-
-            // XXX: These calls are not needed for GL_TEXTURE_EXTERNAL_OES as
-            // they're setting the defautls for that target, but when hacking
-            // things to use GL_TEXTURE_2D they are needed to achieve the same
-            // behavior.
-            glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER,
-                    GL_LINEAR);
-            ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-            glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER,
-                    GL_LINEAR);
-            ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-            glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S,
-                    GL_CLAMP_TO_EDGE);
-            ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-            glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T,
-                    GL_CLAMP_TO_EDGE);
-            ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-
-            GLfloat texMatrix[16];
-            mST->getTransformMatrix(texMatrix);
-            glUniformMatrix4fv(mTexMatrixHandle, 1, GL_FALSE, texMatrix);
-
-            glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-            ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-        }
-
-        GLuint mTexName;
-        sp<GLConsumer> mST;
-        GLuint mPgm;
-        GLint mPositionHandle;
-        GLint mTexSamplerHandle;
-        GLint mTexMatrixHandle;
-    };
-
-    class FrameWaiter : public GLConsumer::FrameAvailableListener {
-    public:
-        FrameWaiter():
-                mPendingFrames(0) {
-        }
-
-        void waitForFrame() {
-            Mutex::Autolock lock(mMutex);
-            while (mPendingFrames == 0) {
-                mCondition.wait(mMutex);
-            }
-            mPendingFrames--;
-        }
-
-        virtual void onFrameAvailable() {
-            Mutex::Autolock lock(mMutex);
-            mPendingFrames++;
-            mCondition.signal();
-        }
-
-        int mPendingFrames;
-        Mutex mMutex;
-        Condition mCondition;
-    };
-
-    // Note that GLConsumer will lose the notifications
-    // onBuffersReleased and onFrameAvailable as there is currently
-    // no way to forward the events.  This DisconnectWaiter will not let the
-    // disconnect finish until finishDisconnect() is called.  It will
-    // also block until a disconnect is called
-    class DisconnectWaiter : public BnConsumerListener {
-    public:
-        DisconnectWaiter () :
-            mWaitForDisconnect(false),
-            mPendingFrames(0) {
-        }
-
-        void waitForFrame() {
-            Mutex::Autolock lock(mMutex);
-            while (mPendingFrames == 0) {
-                mFrameCondition.wait(mMutex);
-            }
-            mPendingFrames--;
-        }
-
-        virtual void onFrameAvailable() {
-            Mutex::Autolock lock(mMutex);
-            mPendingFrames++;
-            mFrameCondition.signal();
-        }
-
-        virtual void onBuffersReleased() {
-            Mutex::Autolock lock(mMutex);
-            while (!mWaitForDisconnect) {
-                mDisconnectCondition.wait(mMutex);
-            }
-        }
-
-        void finishDisconnect() {
-            Mutex::Autolock lock(mMutex);
-            mWaitForDisconnect = true;
-            mDisconnectCondition.signal();
-        }
-
-    private:
-        Mutex mMutex;
-
-        bool mWaitForDisconnect;
-        Condition mDisconnectCondition;
-
-        int mPendingFrames;
-        Condition mFrameCondition;
-    };
-
-    sp<BufferQueue> mBQ;
-    sp<GLConsumer> mST;
-    sp<Surface> mSTC;
-    sp<ANativeWindow> mANW;
-    sp<TextureRenderer> mTextureRenderer;
-    sp<FrameWaiter> mFW;
-};
-
-// Fill a YV12 buffer with a multi-colored checkerboard pattern
-void fillYV12Buffer(uint8_t* buf, int w, int h, int stride) {
-    const int blockWidth = w > 16 ? w / 16 : 1;
-    const int blockHeight = h > 16 ? h / 16 : 1;
-    const int yuvTexOffsetY = 0;
-    int yuvTexStrideY = stride;
-    int yuvTexOffsetV = yuvTexStrideY * h;
-    int yuvTexStrideV = (yuvTexStrideY/2 + 0xf) & ~0xf;
-    int yuvTexOffsetU = yuvTexOffsetV + yuvTexStrideV * h/2;
-    int yuvTexStrideU = yuvTexStrideV;
-    for (int x = 0; x < w; x++) {
-        for (int y = 0; y < h; y++) {
-            int parityX = (x / blockWidth) & 1;
-            int parityY = (y / blockHeight) & 1;
-            unsigned char intensity = (parityX ^ parityY) ? 63 : 191;
-            buf[yuvTexOffsetY + (y * yuvTexStrideY) + x] = intensity;
-            if (x < w / 2 && y < h / 2) {
-                buf[yuvTexOffsetU + (y * yuvTexStrideU) + x] = intensity;
-                if (x * 2 < w / 2 && y * 2 < h / 2) {
-                    buf[yuvTexOffsetV + (y*2 * yuvTexStrideV) + x*2 + 0] =
-                    buf[yuvTexOffsetV + (y*2 * yuvTexStrideV) + x*2 + 1] =
-                    buf[yuvTexOffsetV + ((y*2+1) * yuvTexStrideV) + x*2 + 0] =
-                    buf[yuvTexOffsetV + ((y*2+1) * yuvTexStrideV) + x*2 + 1] =
-                        intensity;
-                }
-            }
-        }
-    }
-}
-
-// Fill a YV12 buffer with red outside a given rectangle and green inside it.
-void fillYV12BufferRect(uint8_t* buf, int w, int h, int stride,
-        const android_native_rect_t& rect) {
-    const int yuvTexOffsetY = 0;
-    int yuvTexStrideY = stride;
-    int yuvTexOffsetV = yuvTexStrideY * h;
-    int yuvTexStrideV = (yuvTexStrideY/2 + 0xf) & ~0xf;
-    int yuvTexOffsetU = yuvTexOffsetV + yuvTexStrideV * h/2;
-    int yuvTexStrideU = yuvTexStrideV;
-    for (int x = 0; x < w; x++) {
-        for (int y = 0; y < h; y++) {
-            bool inside = rect.left <= x && x < rect.right &&
-                    rect.top <= y && y < rect.bottom;
-            buf[yuvTexOffsetY + (y * yuvTexStrideY) + x] = inside ? 240 : 64;
-            if (x < w / 2 && y < h / 2) {
-                bool inside = rect.left <= 2*x && 2*x < rect.right &&
-                        rect.top <= 2*y && 2*y < rect.bottom;
-                buf[yuvTexOffsetU + (y * yuvTexStrideU) + x] = 16;
-                buf[yuvTexOffsetV + (y * yuvTexStrideV) + x] =
-                        inside ? 16 : 255;
-            }
-        }
-    }
-}
-
-void fillRGBA8Buffer(uint8_t* buf, int w, int h, int stride) {
-    const size_t PIXEL_SIZE = 4;
-    for (int x = 0; x < w; x++) {
-        for (int y = 0; y < h; y++) {
-            off_t offset = (y * stride + x) * PIXEL_SIZE;
-            for (int c = 0; c < 4; c++) {
-                int parityX = (x / (1 << (c+2))) & 1;
-                int parityY = (y / (1 << (c+2))) & 1;
-                buf[offset + c] = (parityX ^ parityY) ? 231 : 35;
-            }
-        }
-    }
-}
-
-void fillRGBA8BufferSolid(uint8_t* buf, int w, int h, int stride, uint8_t r,
-        uint8_t g, uint8_t b, uint8_t a) {
-    const size_t PIXEL_SIZE = 4;
-    for (int y = 0; y < h; y++) {
-        for (int x = 0; x < h; x++) {
-            off_t offset = (y * stride + x) * PIXEL_SIZE;
-            buf[offset + 0] = r;
-            buf[offset + 1] = g;
-            buf[offset + 2] = b;
-            buf[offset + 3] = a;
-        }
-    }
-}
-
-// Produce a single RGBA8 frame by filling a buffer with a checkerboard pattern
-// using the CPU.  This assumes that the ANativeWindow is already configured to
-// allow this to be done (e.g. the format is set to RGBA8).
-//
-// Calls to this function should be wrapped in an ASSERT_NO_FATAL_FAILURE().
-void produceOneRGBA8Frame(const sp<ANativeWindow>& anw) {
-    android_native_buffer_t* anb;
-    ASSERT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(anw.get(),
-            &anb));
-    ASSERT_TRUE(anb != NULL);
-
-    sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
-
-    uint8_t* img = NULL;
-    ASSERT_EQ(NO_ERROR, buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN,
-            (void**)(&img)));
-    fillRGBA8Buffer(img, buf->getWidth(), buf->getHeight(), buf->getStride());
-    ASSERT_EQ(NO_ERROR, buf->unlock());
-    ASSERT_EQ(NO_ERROR, anw->queueBuffer(anw.get(), buf->getNativeBuffer(),
-            -1));
-}
-
-TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledYV12BufferNpot) {
-    const int texWidth = 64;
-    const int texHeight = 66;
-
-    ASSERT_EQ(NO_ERROR, native_window_set_buffers_geometry(mANW.get(),
-            texWidth, texHeight, HAL_PIXEL_FORMAT_YV12));
-    ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
-            GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
-
-    ANativeWindowBuffer* anb;
-    ASSERT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(),
-            &anb));
-    ASSERT_TRUE(anb != NULL);
-
-    sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
-
-    // Fill the buffer with the a checkerboard pattern
-    uint8_t* img = NULL;
-    buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
-    fillYV12Buffer(img, texWidth, texHeight, buf->getStride());
-    buf->unlock();
-    ASSERT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), buf->getNativeBuffer(),
-            -1));
-
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-
-    glClearColor(0.2, 0.2, 0.2, 0.2);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    glViewport(0, 0, texWidth, texHeight);
-    drawTexture();
-
-    EXPECT_TRUE(checkPixel( 0,  0, 255, 127, 255, 255, 3));
-    EXPECT_TRUE(checkPixel(63,  0,   0, 133,   0, 255, 3));
-    EXPECT_TRUE(checkPixel(63, 65,   0, 133,   0, 255, 3));
-    EXPECT_TRUE(checkPixel( 0, 65, 255, 127, 255, 255, 3));
-
-    EXPECT_TRUE(checkPixel(22, 44, 255, 127, 255, 255, 3));
-    EXPECT_TRUE(checkPixel(45, 52, 255, 127, 255, 255, 3));
-    EXPECT_TRUE(checkPixel(52, 51,  98, 255,  73, 255, 3));
-    EXPECT_TRUE(checkPixel( 7, 31, 155,   0, 118, 255, 3));
-    EXPECT_TRUE(checkPixel(31,  9, 107,  24,  87, 255, 3));
-    EXPECT_TRUE(checkPixel(29, 35, 255, 127, 255, 255, 3));
-    EXPECT_TRUE(checkPixel(36, 22, 155,  29,   0, 255, 3));
-}
-
-TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledYV12BufferPow2) {
-    const int texWidth = 64;
-    const int texHeight = 64;
-
-    ASSERT_EQ(NO_ERROR, native_window_set_buffers_geometry(mANW.get(),
-            texWidth, texHeight, HAL_PIXEL_FORMAT_YV12));
-    ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
-            GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
-
-    ANativeWindowBuffer* anb;
-    ASSERT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(),
-            &anb));
-    ASSERT_TRUE(anb != NULL);
-
-    sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
-
-    // Fill the buffer with the a checkerboard pattern
-    uint8_t* img = NULL;
-    buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
-    fillYV12Buffer(img, texWidth, texHeight, buf->getStride());
-    buf->unlock();
-    ASSERT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), buf->getNativeBuffer(),
-            -1));
-
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-
-    glClearColor(0.2, 0.2, 0.2, 0.2);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    glViewport(0, 0, texWidth, texHeight);
-    drawTexture();
-
-    EXPECT_TRUE(checkPixel( 0,  0,   0, 133,   0, 255));
-    EXPECT_TRUE(checkPixel(63,  0, 255, 127, 255, 255));
-    EXPECT_TRUE(checkPixel(63, 63,   0, 133,   0, 255));
-    EXPECT_TRUE(checkPixel( 0, 63, 255, 127, 255, 255));
-
-    EXPECT_TRUE(checkPixel(22, 19, 100, 255,  74, 255));
-    EXPECT_TRUE(checkPixel(45, 11, 100, 255,  74, 255));
-    EXPECT_TRUE(checkPixel(52, 12, 155,   0, 181, 255));
-    EXPECT_TRUE(checkPixel( 7, 32, 150, 237, 170, 255));
-    EXPECT_TRUE(checkPixel(31, 54,   0,  71, 117, 255));
-    EXPECT_TRUE(checkPixel(29, 28,   0, 133,   0, 255));
-    EXPECT_TRUE(checkPixel(36, 41, 100, 232, 255, 255));
-}
-
-TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledYV12BufferWithCrop) {
-    const int texWidth = 64;
-    const int texHeight = 66;
-
-    ASSERT_EQ(NO_ERROR, native_window_set_buffers_geometry(mANW.get(),
-            texWidth, texHeight, HAL_PIXEL_FORMAT_YV12));
-    ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
-            GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
-
-    android_native_rect_t crops[] = {
-        {4, 6, 22, 36},
-        {0, 6, 22, 36},
-        {4, 0, 22, 36},
-        {4, 6, texWidth, 36},
-        {4, 6, 22, texHeight},
-    };
-
-    for (int i = 0; i < 5; i++) {
-        const android_native_rect_t& crop(crops[i]);
-        SCOPED_TRACE(String8::format("rect{ l: %d t: %d r: %d b: %d }",
-                crop.left, crop.top, crop.right, crop.bottom).string());
-
-        ASSERT_EQ(NO_ERROR, native_window_set_crop(mANW.get(), &crop));
-
-        ANativeWindowBuffer* anb;
-        ASSERT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(),
-                &anb));
-        ASSERT_TRUE(anb != NULL);
-
-        sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
-
-        uint8_t* img = NULL;
-        buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
-        fillYV12BufferRect(img, texWidth, texHeight, buf->getStride(), crop);
-        buf->unlock();
-        ASSERT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(),
-                buf->getNativeBuffer(), -1));
-
-        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-
-        glClearColor(0.2, 0.2, 0.2, 0.2);
-        glClear(GL_COLOR_BUFFER_BIT);
-
-        glViewport(0, 0, 64, 64);
-        drawTexture();
-
-        EXPECT_TRUE(checkPixel( 0,  0,  82, 255,  35, 255));
-        EXPECT_TRUE(checkPixel(63,  0,  82, 255,  35, 255));
-        EXPECT_TRUE(checkPixel(63, 63,  82, 255,  35, 255));
-        EXPECT_TRUE(checkPixel( 0, 63,  82, 255,  35, 255));
-
-        EXPECT_TRUE(checkPixel(25, 14,  82, 255,  35, 255));
-        EXPECT_TRUE(checkPixel(35, 31,  82, 255,  35, 255));
-        EXPECT_TRUE(checkPixel(57,  6,  82, 255,  35, 255));
-        EXPECT_TRUE(checkPixel( 5, 42,  82, 255,  35, 255));
-        EXPECT_TRUE(checkPixel(32, 33,  82, 255,  35, 255));
-        EXPECT_TRUE(checkPixel(16, 26,  82, 255,  35, 255));
-        EXPECT_TRUE(checkPixel(46, 51,  82, 255,  35, 255));
-    }
-}
-
-// This test is intended to catch synchronization bugs between the CPU-written
-// and GPU-read buffers.
-TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledYV12BuffersRepeatedly) {
-    enum { texWidth = 16 };
-    enum { texHeight = 16 };
-    enum { numFrames = 1024 };
-
-    ASSERT_EQ(NO_ERROR, mST->setDefaultMaxBufferCount(2));
-    ASSERT_EQ(NO_ERROR, native_window_set_buffers_geometry(mANW.get(),
-            texWidth, texHeight, HAL_PIXEL_FORMAT_YV12));
-    ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
-            GRALLOC_USAGE_SW_WRITE_OFTEN));
-
-    struct TestPixel {
-        int x;
-        int y;
-    };
-    const TestPixel testPixels[] = {
-        {  4, 11 },
-        { 12, 14 },
-        {  7,  2 },
-    };
-    enum {numTestPixels = sizeof(testPixels) / sizeof(testPixels[0])};
-
-    class ProducerThread : public Thread {
-    public:
-        ProducerThread(const sp<ANativeWindow>& anw,
-                const TestPixel* testPixels):
-                mANW(anw),
-                mTestPixels(testPixels) {
-        }
-
-        virtual ~ProducerThread() {
-        }
-
-        virtual bool threadLoop() {
-            for (int i = 0; i < numFrames; i++) {
-                ANativeWindowBuffer* anb;
-                if (native_window_dequeue_buffer_and_wait(mANW.get(),
-                        &anb) != NO_ERROR) {
-                    return false;
-                }
-                if (anb == NULL) {
-                    return false;
-                }
-
-                sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
-
-                const int yuvTexOffsetY = 0;
-                int stride = buf->getStride();
-                int yuvTexStrideY = stride;
-                int yuvTexOffsetV = yuvTexStrideY * texHeight;
-                int yuvTexStrideV = (yuvTexStrideY/2 + 0xf) & ~0xf;
-                int yuvTexOffsetU = yuvTexOffsetV + yuvTexStrideV * texHeight/2;
-                int yuvTexStrideU = yuvTexStrideV;
-
-                uint8_t* img = NULL;
-                buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
-
-                // Gray out all the test pixels first, so we're more likely to
-                // see a failure if GL is still texturing from the buffer we
-                // just dequeued.
-                for (int j = 0; j < numTestPixels; j++) {
-                    int x = mTestPixels[j].x;
-                    int y = mTestPixels[j].y;
-                    uint8_t value = 128;
-                    img[y*stride + x] = value;
-                }
-
-                // Fill the buffer with gray.
-                for (int y = 0; y < texHeight; y++) {
-                    for (int x = 0; x < texWidth; x++) {
-                        img[yuvTexOffsetY + y*yuvTexStrideY + x] = 128;
-                        img[yuvTexOffsetU + (y/2)*yuvTexStrideU + x/2] = 128;
-                        img[yuvTexOffsetV + (y/2)*yuvTexStrideV + x/2] = 128;
-                    }
-                }
-
-                // Set the test pixels to either white or black.
-                for (int j = 0; j < numTestPixels; j++) {
-                    int x = mTestPixels[j].x;
-                    int y = mTestPixels[j].y;
-                    uint8_t value = 0;
-                    if (j == (i % numTestPixels)) {
-                        value = 255;
-                    }
-                    img[y*stride + x] = value;
-                }
-
-                buf->unlock();
-                if (mANW->queueBuffer(mANW.get(), buf->getNativeBuffer(), -1)
-                        != NO_ERROR) {
-                    return false;
-                }
-            }
-            return false;
-        }
-
-        sp<ANativeWindow> mANW;
-        const TestPixel* mTestPixels;
-    };
-
-    sp<Thread> pt(new ProducerThread(mANW, testPixels));
-    pt->run();
-
-    glViewport(0, 0, texWidth, texHeight);
-
-    glClearColor(0.2, 0.2, 0.2, 0.2);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    // We wait for the first two frames up front so that the producer will be
-    // likely to dequeue the buffer that's currently being textured from.
-    mFW->waitForFrame();
-    mFW->waitForFrame();
-
-    for (int i = 0; i < numFrames; i++) {
-        SCOPED_TRACE(String8::format("frame %d", i).string());
-
-        // We must wait for each frame to come in because if we ever do an
-        // updateTexImage call that doesn't consume a newly available buffer
-        // then the producer and consumer will get out of sync, which will cause
-        // a deadlock.
-        if (i > 1) {
-            mFW->waitForFrame();
-        }
-        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-        drawTexture();
-
-        for (int j = 0; j < numTestPixels; j++) {
-            int x = testPixels[j].x;
-            int y = testPixels[j].y;
-            uint8_t value = 0;
-            if (j == (i % numTestPixels)) {
-                // We must y-invert the texture coords
-                EXPECT_TRUE(checkPixel(x, texHeight-y-1, 255, 255, 255, 255));
-            } else {
-                // We must y-invert the texture coords
-                EXPECT_TRUE(checkPixel(x, texHeight-y-1, 0, 0, 0, 255));
-            }
-        }
-    }
-
-    pt->requestExitAndWait();
-}
-
-TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledRGBABufferNpot) {
-    const int texWidth = 64;
-    const int texHeight = 66;
-
-    ASSERT_EQ(NO_ERROR, native_window_set_buffers_geometry(mANW.get(),
-            texWidth, texHeight, HAL_PIXEL_FORMAT_RGBA_8888));
-    ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
-            GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
-
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-
-    glClearColor(0.2, 0.2, 0.2, 0.2);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    glViewport(0, 0, texWidth, texHeight);
-    drawTexture();
-
-    EXPECT_TRUE(checkPixel( 0,  0,  35,  35,  35,  35));
-    EXPECT_TRUE(checkPixel(63,  0, 231, 231, 231, 231));
-    EXPECT_TRUE(checkPixel(63, 65, 231, 231, 231, 231));
-    EXPECT_TRUE(checkPixel( 0, 65,  35,  35,  35,  35));
-
-    EXPECT_TRUE(checkPixel(15, 10,  35, 231, 231, 231));
-    EXPECT_TRUE(checkPixel(23, 65, 231,  35, 231,  35));
-    EXPECT_TRUE(checkPixel(19, 40,  35, 231,  35,  35));
-    EXPECT_TRUE(checkPixel(38, 30, 231,  35,  35,  35));
-    EXPECT_TRUE(checkPixel(42, 54,  35,  35,  35, 231));
-    EXPECT_TRUE(checkPixel(37, 34,  35, 231, 231, 231));
-    EXPECT_TRUE(checkPixel(31,  8, 231,  35,  35, 231));
-    EXPECT_TRUE(checkPixel(37, 47, 231,  35, 231, 231));
-    EXPECT_TRUE(checkPixel(25, 38,  35,  35,  35,  35));
-    EXPECT_TRUE(checkPixel(49,  6,  35, 231,  35,  35));
-    EXPECT_TRUE(checkPixel(54, 50,  35, 231, 231, 231));
-    EXPECT_TRUE(checkPixel(27, 26, 231, 231, 231, 231));
-    EXPECT_TRUE(checkPixel(10,  6,  35,  35, 231, 231));
-    EXPECT_TRUE(checkPixel(29,  4,  35,  35,  35, 231));
-    EXPECT_TRUE(checkPixel(55, 28,  35,  35, 231,  35));
-    EXPECT_TRUE(checkPixel(58, 55,  35,  35, 231, 231));
-}
-
-TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledRGBABufferPow2) {
-    const int texWidth = 64;
-    const int texHeight = 64;
-
-    ASSERT_EQ(NO_ERROR, native_window_set_buffers_geometry(mANW.get(),
-            texWidth, texHeight, HAL_PIXEL_FORMAT_RGBA_8888));
-    ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
-            GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
-
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-
-    glClearColor(0.2, 0.2, 0.2, 0.2);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    glViewport(0, 0, texWidth, texHeight);
-    drawTexture();
-
-    EXPECT_TRUE(checkPixel( 0,  0, 231, 231, 231, 231));
-    EXPECT_TRUE(checkPixel(63,  0,  35,  35,  35,  35));
-    EXPECT_TRUE(checkPixel(63, 63, 231, 231, 231, 231));
-    EXPECT_TRUE(checkPixel( 0, 63,  35,  35,  35,  35));
-
-    EXPECT_TRUE(checkPixel(12, 46, 231, 231, 231,  35));
-    EXPECT_TRUE(checkPixel(16,  1, 231, 231,  35, 231));
-    EXPECT_TRUE(checkPixel(21, 12, 231,  35,  35, 231));
-    EXPECT_TRUE(checkPixel(26, 51, 231,  35, 231,  35));
-    EXPECT_TRUE(checkPixel( 5, 32,  35, 231, 231,  35));
-    EXPECT_TRUE(checkPixel(13,  8,  35, 231, 231, 231));
-    EXPECT_TRUE(checkPixel(46,  3,  35,  35, 231,  35));
-    EXPECT_TRUE(checkPixel(30, 33,  35,  35,  35,  35));
-    EXPECT_TRUE(checkPixel( 6, 52, 231, 231,  35,  35));
-    EXPECT_TRUE(checkPixel(55, 33,  35, 231,  35, 231));
-    EXPECT_TRUE(checkPixel(16, 29,  35,  35, 231, 231));
-    EXPECT_TRUE(checkPixel( 1, 30,  35,  35,  35, 231));
-    EXPECT_TRUE(checkPixel(41, 37,  35,  35, 231, 231));
-    EXPECT_TRUE(checkPixel(46, 29, 231, 231,  35,  35));
-    EXPECT_TRUE(checkPixel(15, 25,  35, 231,  35, 231));
-    EXPECT_TRUE(checkPixel( 3, 52,  35, 231,  35,  35));
-}
-
-// Tests if GLConsumer and BufferQueue are robust enough
-// to handle a special case where updateTexImage is called
-// in the middle of disconnect.  This ordering is enforced
-// by blocking in the disconnect callback.
-TEST_F(SurfaceTextureGLTest, DisconnectStressTest) {
-
-    class ProducerThread : public Thread {
-    public:
-        ProducerThread(const sp<ANativeWindow>& anw):
-                mANW(anw) {
-        }
-
-        virtual ~ProducerThread() {
-        }
-
-        virtual bool threadLoop() {
-            ANativeWindowBuffer* anb;
-
-            native_window_api_connect(mANW.get(), NATIVE_WINDOW_API_EGL);
-
-            for (int numFrames =0 ; numFrames < 2; numFrames ++) {
-
-                if (native_window_dequeue_buffer_and_wait(mANW.get(),
-                        &anb) != NO_ERROR) {
-                    return false;
-                }
-                if (anb == NULL) {
-                    return false;
-                }
-                if (mANW->queueBuffer(mANW.get(), anb, -1)
-                        != NO_ERROR) {
-                    return false;
-                }
-            }
-
-            native_window_api_disconnect(mANW.get(), NATIVE_WINDOW_API_EGL);
-
-            return false;
-        }
-
-    private:
-        sp<ANativeWindow> mANW;
-    };
-
-    sp<DisconnectWaiter> dw(new DisconnectWaiter());
-    mBQ->consumerConnect(dw, false);
-
-
-    sp<Thread> pt(new ProducerThread(mANW));
-    pt->run();
-
-    // eat a frame so GLConsumer will own an at least one slot
-    dw->waitForFrame();
-    EXPECT_EQ(OK,mST->updateTexImage());
-
-    dw->waitForFrame();
-    // Could fail here as GLConsumer thinks it still owns the slot
-    // but bufferQueue has released all slots
-    EXPECT_EQ(OK,mST->updateTexImage());
-
-    dw->finishDisconnect();
-}
-
-
-// This test ensures that the GLConsumer clears the mCurrentTexture
-// when it is disconnected and reconnected.  Otherwise it will
-// attempt to release a buffer that it does not owned
-TEST_F(SurfaceTextureGLTest, DisconnectClearsCurrentTexture) {
-    ASSERT_EQ(OK, native_window_api_connect(mANW.get(),
-            NATIVE_WINDOW_API_EGL));
-
-    ANativeWindowBuffer *anb;
-
-    EXPECT_EQ (OK, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
-    EXPECT_EQ(OK, mANW->queueBuffer(mANW.get(), anb, -1));
-
-    EXPECT_EQ (OK, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
-    EXPECT_EQ(OK, mANW->queueBuffer(mANW.get(), anb, -1));
-
-    EXPECT_EQ(OK,mST->updateTexImage());
-    EXPECT_EQ(OK,mST->updateTexImage());
-
-    ASSERT_EQ(OK, native_window_api_disconnect(mANW.get(),
-            NATIVE_WINDOW_API_EGL));
-    ASSERT_EQ(OK, native_window_api_connect(mANW.get(),
-            NATIVE_WINDOW_API_EGL));
-
-    EXPECT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
-    EXPECT_EQ(OK, mANW->queueBuffer(mANW.get(), anb, -1));
-
-    // Will fail here if mCurrentTexture is not cleared properly
-    mFW->waitForFrame();
-    EXPECT_EQ(OK,mST->updateTexImage());
-
-    ASSERT_EQ(OK, native_window_api_disconnect(mANW.get(),
-            NATIVE_WINDOW_API_EGL));
-}
-
-TEST_F(SurfaceTextureGLTest, ScaleToWindowMode) {
-    ASSERT_EQ(OK, native_window_set_scaling_mode(mANW.get(),
-        NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW));
-
-    // The producer image size
-    ASSERT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 512, 512));
-
-    // The consumer image size (16 x 9) ratio
-    mST->setDefaultBufferSize(1280, 720);
-
-    ASSERT_EQ(OK, native_window_api_connect(mANW.get(),
-            NATIVE_WINDOW_API_CPU));
-
-    ANativeWindowBuffer *anb;
-
-    android_native_rect_t odd = {23, 78, 123, 477};
-    ASSERT_EQ(OK, native_window_set_crop(mANW.get(), &odd));
-    EXPECT_EQ (OK, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
-    EXPECT_EQ(OK, mANW->queueBuffer(mANW.get(), anb, -1));
-    mFW->waitForFrame();
-    EXPECT_EQ(OK, mST->updateTexImage());
-    Rect r = mST->getCurrentCrop();
-    assertRectEq(Rect(23, 78, 123, 477), r);
-
-    ASSERT_EQ(OK, native_window_api_disconnect(mANW.get(),
-            NATIVE_WINDOW_API_CPU));
-}
-
-// This test ensures the scaling mode does the right thing
-// ie NATIVE_WINDOW_SCALING_MODE_CROP should crop
-// the image such that it has the same aspect ratio as the
-// default buffer size
-TEST_F(SurfaceTextureGLTest, CroppedScalingMode) {
-    ASSERT_EQ(OK, native_window_set_scaling_mode(mANW.get(),
-        NATIVE_WINDOW_SCALING_MODE_SCALE_CROP));
-
-    // The producer image size
-    ASSERT_EQ(OK, native_window_set_buffers_dimensions(mANW.get(), 512, 512));
-
-    // The consumer image size (16 x 9) ratio
-    mST->setDefaultBufferSize(1280, 720);
-
-    native_window_api_connect(mANW.get(), NATIVE_WINDOW_API_CPU);
-
-    ANativeWindowBuffer *anb;
-
-    // The crop is in the shape of (320, 180) === 16 x 9
-    android_native_rect_t standard = {10, 20, 330, 200};
-    ASSERT_EQ(OK, native_window_set_crop(mANW.get(), &standard));
-    EXPECT_EQ (OK, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
-    EXPECT_EQ(OK, mANW->queueBuffer(mANW.get(), anb, -1));
-    mFW->waitForFrame();
-    EXPECT_EQ(OK, mST->updateTexImage());
-    Rect r = mST->getCurrentCrop();
-    // crop should be the same as crop (same aspect ratio)
-    assertRectEq(Rect(10, 20, 330, 200), r);
-
-    // make this wider then desired aspect 239 x 100 (2.39:1)
-    android_native_rect_t wide = {20, 30, 259, 130};
-    ASSERT_EQ(OK, native_window_set_crop(mANW.get(), &wide));
-    EXPECT_EQ (OK, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
-    EXPECT_EQ(OK, mANW->queueBuffer(mANW.get(), anb, -1));
-    mFW->waitForFrame();
-    EXPECT_EQ(OK, mST->updateTexImage());
-    r = mST->getCurrentCrop();
-    // crop should be the same height, but have cropped left and right borders
-    // offset is 30.6 px L+, R-
-    assertRectEq(Rect(51, 30, 228, 130), r);
-
-    // This image is taller then desired aspect 400 x 300 (4:3)
-    android_native_rect_t narrow = {0, 0, 400, 300};
-    ASSERT_EQ(OK, native_window_set_crop(mANW.get(), &narrow));
-    EXPECT_EQ (OK, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
-    EXPECT_EQ(OK, mANW->queueBuffer(mANW.get(), anb, -1));
-    mFW->waitForFrame();
-    EXPECT_EQ(OK, mST->updateTexImage());
-    r = mST->getCurrentCrop();
-    // crop should be the same width, but have cropped top and bottom borders
-    // offset is 37.5 px
-    assertRectEq(Rect(0, 37, 400, 262), r);
-
-    native_window_api_disconnect(mANW.get(), NATIVE_WINDOW_API_CPU);
-}
-
-TEST_F(SurfaceTextureGLTest, AbandonUnblocksDequeueBuffer) {
-    class ProducerThread : public Thread {
-    public:
-        ProducerThread(const sp<ANativeWindow>& anw):
-                mANW(anw),
-                mDequeueError(NO_ERROR) {
-        }
-
-        virtual ~ProducerThread() {
-        }
-
-        virtual bool threadLoop() {
-            Mutex::Autolock lock(mMutex);
-            ANativeWindowBuffer* anb;
-
-            // Frame 1
-            if (native_window_dequeue_buffer_and_wait(mANW.get(),
-                    &anb) != NO_ERROR) {
-                return false;
-            }
-            if (anb == NULL) {
-                return false;
-            }
-            if (mANW->queueBuffer(mANW.get(), anb, -1)
-                    != NO_ERROR) {
-                return false;
-            }
-
-            // Frame 2
-            if (native_window_dequeue_buffer_and_wait(mANW.get(),
-                    &anb) != NO_ERROR) {
-                return false;
-            }
-            if (anb == NULL) {
-                return false;
-            }
-            if (mANW->queueBuffer(mANW.get(), anb, -1)
-                    != NO_ERROR) {
-                return false;
-            }
-
-            // Frame 3 - error expected
-            mDequeueError = native_window_dequeue_buffer_and_wait(mANW.get(),
-                &anb);
-            return false;
-        }
-
-        status_t getDequeueError() {
-            Mutex::Autolock lock(mMutex);
-            return mDequeueError;
-        }
-
-    private:
-        sp<ANativeWindow> mANW;
-        status_t mDequeueError;
-        Mutex mMutex;
-    };
-
-    ASSERT_EQ(OK, mST->setDefaultMaxBufferCount(2));
-
-    sp<Thread> pt(new ProducerThread(mANW));
-    pt->run();
-
-    mFW->waitForFrame();
-    mFW->waitForFrame();
-
-    // Sleep for 100ms to allow the producer thread's dequeueBuffer call to
-    // block waiting for a buffer to become available.
-    usleep(100000);
-
-    mST->abandon();
-
-    pt->requestExitAndWait();
-    ASSERT_EQ(NO_INIT,
-            reinterpret_cast<ProducerThread*>(pt.get())->getDequeueError());
-}
-
-TEST_F(SurfaceTextureGLTest, InvalidWidthOrHeightFails) {
-    int texHeight = 16;
-    ANativeWindowBuffer* anb;
-
-    GLint maxTextureSize;
-    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
-
-    // make sure it works with small textures
-    mST->setDefaultBufferSize(16, texHeight);
-    EXPECT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(),
-            &anb));
-    EXPECT_EQ(16, anb->width);
-    EXPECT_EQ(texHeight, anb->height);
-    EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb, -1));
-    EXPECT_EQ(NO_ERROR, mST->updateTexImage());
-
-    // make sure it works with GL_MAX_TEXTURE_SIZE
-    mST->setDefaultBufferSize(maxTextureSize, texHeight);
-    EXPECT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(),
-            &anb));
-    EXPECT_EQ(maxTextureSize, anb->width);
-    EXPECT_EQ(texHeight, anb->height);
-    EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb, -1));
-    EXPECT_EQ(NO_ERROR, mST->updateTexImage());
-
-    // make sure it fails with GL_MAX_TEXTURE_SIZE+1
-    mST->setDefaultBufferSize(maxTextureSize+1, texHeight);
-    EXPECT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(),
-            &anb));
-    EXPECT_EQ(maxTextureSize+1, anb->width);
-    EXPECT_EQ(texHeight, anb->height);
-    EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb, -1));
-    ASSERT_NE(NO_ERROR, mST->updateTexImage());
-}
-
-/*
- * This test fixture is for testing GL -> GL texture streaming.  It creates an
- * EGLSurface and an EGLContext for the image producer to use.
- */
-class SurfaceTextureGLToGLTest : public SurfaceTextureGLTest {
-protected:
-    SurfaceTextureGLToGLTest():
-            mProducerEglSurface(EGL_NO_SURFACE),
-            mProducerEglContext(EGL_NO_CONTEXT) {
-    }
-
-    virtual void SetUp() {
-        SurfaceTextureGLTest::SetUp();
-
-        mProducerEglSurface = eglCreateWindowSurface(mEglDisplay, mGlConfig,
-                mANW.get(), NULL);
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-        ASSERT_NE(EGL_NO_SURFACE, mProducerEglSurface);
-
-        mProducerEglContext = eglCreateContext(mEglDisplay, mGlConfig,
-                EGL_NO_CONTEXT, getContextAttribs());
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-        ASSERT_NE(EGL_NO_CONTEXT, mProducerEglContext);
-    }
-
-    virtual void TearDown() {
-        if (mProducerEglContext != EGL_NO_CONTEXT) {
-            eglDestroyContext(mEglDisplay, mProducerEglContext);
-        }
-        if (mProducerEglSurface != EGL_NO_SURFACE) {
-            eglDestroySurface(mEglDisplay, mProducerEglSurface);
-        }
-        SurfaceTextureGLTest::TearDown();
-    }
-
-    EGLSurface mProducerEglSurface;
-    EGLContext mProducerEglContext;
-};
-
-TEST_F(SurfaceTextureGLToGLTest, TransformHintGetsRespected) {
-    const uint32_t texWidth = 32;
-    const uint32_t texHeight = 64;
-
-    mST->setDefaultBufferSize(texWidth, texHeight);
-    mST->setTransformHint(NATIVE_WINDOW_TRANSFORM_ROT_90);
-
-    // This test requires 3 buffers to avoid deadlock because we're
-    // both producer and consumer, and only using one thread.
-    mST->setDefaultMaxBufferCount(3);
-
-    // Do the producer side of things
-    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
-            mProducerEglSurface, mProducerEglContext));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-    // Start a buffer with our chosen size and transform hint moving
-    // through the system.
-    glClear(GL_COLOR_BUFFER_BIT);  // give the driver something to do
-    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
-    mST->updateTexImage();  // consume it
-    // Swap again.
-    glClear(GL_COLOR_BUFFER_BIT);
-    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
-    mST->updateTexImage();
-
-    // The current buffer should either show the effects of the transform
-    // hint (in the form of an inverse transform), or show that the
-    // transform hint has been ignored.
-    sp<GraphicBuffer> buf = mST->getCurrentBuffer();
-    if (mST->getCurrentTransform() == NATIVE_WINDOW_TRANSFORM_ROT_270) {
-        ASSERT_EQ(texWidth, buf->getHeight());
-        ASSERT_EQ(texHeight, buf->getWidth());
-    } else {
-        ASSERT_EQ(texWidth, buf->getWidth());
-        ASSERT_EQ(texHeight, buf->getHeight());
-    }
-
-    // Reset the transform hint and confirm that it takes.
-    mST->setTransformHint(0);
-    glClear(GL_COLOR_BUFFER_BIT);
-    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
-    mST->updateTexImage();
-    glClear(GL_COLOR_BUFFER_BIT);
-    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
-    mST->updateTexImage();
-
-    buf = mST->getCurrentBuffer();
-    ASSERT_EQ((uint32_t) 0, mST->getCurrentTransform());
-    ASSERT_EQ(texWidth, buf->getWidth());
-    ASSERT_EQ(texHeight, buf->getHeight());
-}
-
-TEST_F(SurfaceTextureGLToGLTest, TexturingFromGLFilledRGBABufferPow2) {
-    const int texWidth = 64;
-    const int texHeight = 64;
-
-    mST->setDefaultBufferSize(texWidth, texHeight);
-
-    // This test requires 3 buffers to complete run on a single thread.
-    mST->setDefaultMaxBufferCount(3);
-
-    // Do the producer side of things
-    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
-            mProducerEglSurface, mProducerEglContext));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-    // This is needed to ensure we pick up a buffer of the correct size.
-    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
-
-    glClearColor(0.6, 0.6, 0.6, 0.6);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    glEnable(GL_SCISSOR_TEST);
-    glScissor(4, 4, 4, 4);
-    glClearColor(1.0, 0.0, 0.0, 1.0);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    glScissor(24, 48, 4, 4);
-    glClearColor(0.0, 1.0, 0.0, 1.0);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    glScissor(37, 17, 4, 4);
-    glClearColor(0.0, 0.0, 1.0, 1.0);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
-
-    // Do the consumer side of things
-    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-            mEglContext));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-    glDisable(GL_SCISSOR_TEST);
-
-    // Skip the first frame, which was empty
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-
-    glClearColor(0.2, 0.2, 0.2, 0.2);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    glViewport(0, 0, texWidth, texHeight);
-    drawTexture();
-
-    EXPECT_TRUE(checkPixel( 0,  0, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(63,  0, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(63, 63, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel( 0, 63, 153, 153, 153, 153));
-
-    EXPECT_TRUE(checkPixel( 4,  7, 255,   0,   0, 255));
-    EXPECT_TRUE(checkPixel(25, 51,   0, 255,   0, 255));
-    EXPECT_TRUE(checkPixel(40, 19,   0,   0, 255, 255));
-    EXPECT_TRUE(checkPixel(29, 51, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel( 5, 32, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(13,  8, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(46,  3, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(30, 33, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel( 6, 52, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(55, 33, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(16, 29, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel( 1, 30, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(41, 37, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(46, 29, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(15, 25, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel( 3, 52, 153, 153, 153, 153));
-}
-
-TEST_F(SurfaceTextureGLToGLTest, EglDestroySurfaceUnrefsBuffers) {
-    sp<GraphicBuffer> buffers[2];
-
-    // This test requires async mode to run on a single thread.
-    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
-            mProducerEglSurface, mProducerEglContext));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-    EXPECT_TRUE(eglSwapInterval(mEglDisplay, 0));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-    for (int i = 0; i < 2; i++) {
-        // Produce a frame
-        EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
-                mProducerEglSurface, mProducerEglContext));
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-        glClear(GL_COLOR_BUFFER_BIT);
-        eglSwapBuffers(mEglDisplay, mProducerEglSurface);
-
-        // Consume a frame
-        EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-                mEglContext));
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-        mFW->waitForFrame();
-        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-        buffers[i] = mST->getCurrentBuffer();
-    }
-
-    // Destroy the GL texture object to release its ref on buffers[2].
-    GLuint texID = TEX_ID;
-    glDeleteTextures(1, &texID);
-
-    // Destroy the EGLSurface
-    EXPECT_TRUE(eglDestroySurface(mEglDisplay, mProducerEglSurface));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-    mProducerEglSurface = EGL_NO_SURFACE;
-
-    // This test should have the only reference to buffer 0.
-    EXPECT_EQ(1, buffers[0]->getStrongCount());
-
-    // The GLConsumer should hold a single reference to buffer 1 in its
-    // mCurrentBuffer member.  All of the references in the slots should have
-    // been released.
-    EXPECT_EQ(2, buffers[1]->getStrongCount());
-}
-
-TEST_F(SurfaceTextureGLToGLTest, EglDestroySurfaceAfterAbandonUnrefsBuffers) {
-    sp<GraphicBuffer> buffers[3];
-
-    // This test requires async mode to run on a single thread.
-    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
-            mProducerEglSurface, mProducerEglContext));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-    EXPECT_TRUE(eglSwapInterval(mEglDisplay, 0));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-    for (int i = 0; i < 3; i++) {
-        // Produce a frame
-        EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
-                mProducerEglSurface, mProducerEglContext));
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-        glClear(GL_COLOR_BUFFER_BIT);
-        EXPECT_TRUE(eglSwapBuffers(mEglDisplay, mProducerEglSurface));
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-        // Consume a frame
-        EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-                mEglContext));
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-        mFW->waitForFrame();
-        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-        buffers[i] = mST->getCurrentBuffer();
-    }
-
-    // Abandon the GLConsumer, releasing the ref that the GLConsumer has
-    // on buffers[2].
-    mST->abandon();
-
-    // Destroy the GL texture object to release its ref on buffers[2].
-    GLuint texID = TEX_ID;
-    glDeleteTextures(1, &texID);
-
-    // Destroy the EGLSurface.
-    EXPECT_TRUE(eglDestroySurface(mEglDisplay, mProducerEglSurface));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-    mProducerEglSurface = EGL_NO_SURFACE;
-
-    EXPECT_EQ(1, buffers[0]->getStrongCount());
-    EXPECT_EQ(1, buffers[1]->getStrongCount());
-
-    // Depending on how lazily the GL driver dequeues buffers, we may end up
-    // with either two or three total buffers.  If there are three, make sure
-    // the last one was properly down-ref'd.
-    if (buffers[2] != buffers[0]) {
-        EXPECT_EQ(1, buffers[2]->getStrongCount());
-    }
-}
-
-TEST_F(SurfaceTextureGLToGLTest, EglMakeCurrentBeforeConsumerDeathUnrefsBuffers) {
-    sp<GraphicBuffer> buffer;
-
-    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
-            mProducerEglSurface, mProducerEglContext));
-
-    // Produce a frame
-    glClear(GL_COLOR_BUFFER_BIT);
-    EXPECT_TRUE(eglSwapBuffers(mEglDisplay, mProducerEglSurface));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-    // Destroy the EGLSurface.
-    EXPECT_TRUE(eglDestroySurface(mEglDisplay, mProducerEglSurface));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-    mProducerEglSurface = EGL_NO_SURFACE;
-    mSTC.clear();
-    mANW.clear();
-    mTextureRenderer.clear();
-
-    // Consume a frame
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-    buffer = mST->getCurrentBuffer();
-
-    // Destroy the GL texture object to release its ref
-    GLuint texID = TEX_ID;
-    glDeleteTextures(1, &texID);
-
-    // make un-current, all references to buffer should be gone
-    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE,
-            EGL_NO_SURFACE, EGL_NO_CONTEXT));
-
-    // Destroy consumer
-    mST.clear();
-
-    EXPECT_EQ(1, buffer->getStrongCount());
-}
-
-TEST_F(SurfaceTextureGLToGLTest, EglMakeCurrentAfterConsumerDeathUnrefsBuffers) {
-    sp<GraphicBuffer> buffer;
-
-    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
-            mProducerEglSurface, mProducerEglContext));
-
-    // Produce a frame
-    glClear(GL_COLOR_BUFFER_BIT);
-    EXPECT_TRUE(eglSwapBuffers(mEglDisplay, mProducerEglSurface));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-    // Destroy the EGLSurface.
-    EXPECT_TRUE(eglDestroySurface(mEglDisplay, mProducerEglSurface));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-    mProducerEglSurface = EGL_NO_SURFACE;
-    mSTC.clear();
-    mANW.clear();
-    mTextureRenderer.clear();
-
-    // Consume a frame
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-    buffer = mST->getCurrentBuffer();
-
-    // Destroy the GL texture object to release its ref
-    GLuint texID = TEX_ID;
-    glDeleteTextures(1, &texID);
-
-    // Destroy consumer
-    mST.clear();
-
-    // make un-current, all references to buffer should be gone
-    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE,
-            EGL_NO_SURFACE, EGL_NO_CONTEXT));
-
-    EXPECT_EQ(1, buffer->getStrongCount());
-}
-
-TEST_F(SurfaceTextureGLToGLTest, TexturingFromUserSizedGLFilledBuffer) {
-    enum { texWidth = 64 };
-    enum { texHeight = 64 };
-
-    // This test requires 3 buffers to complete run on a single thread.
-    mST->setDefaultMaxBufferCount(3);
-
-    // Set the user buffer size.
-    native_window_set_buffers_user_dimensions(mANW.get(), texWidth, texHeight);
-
-    // Do the producer side of things
-    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
-            mProducerEglSurface, mProducerEglContext));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-    // This is needed to ensure we pick up a buffer of the correct size.
-    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
-
-    glClearColor(0.6, 0.6, 0.6, 0.6);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    glEnable(GL_SCISSOR_TEST);
-    glScissor(4, 4, 1, 1);
-    glClearColor(1.0, 0.0, 0.0, 1.0);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
-
-    // Do the consumer side of things
-    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-            mEglContext));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-    glDisable(GL_SCISSOR_TEST);
-
-    // Skip the first frame, which was empty
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-
-    glClearColor(0.2, 0.2, 0.2, 0.2);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    glViewport(0, 0, texWidth, texHeight);
-    drawTexture();
-
-    EXPECT_TRUE(checkPixel( 0,  0, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(63,  0, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(63, 63, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel( 0, 63, 153, 153, 153, 153));
-
-    EXPECT_TRUE(checkPixel( 4,  4, 255,   0,   0, 255));
-    EXPECT_TRUE(checkPixel( 5,  5, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel( 3,  3, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(45, 52, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(12, 36, 153, 153, 153, 153));
-}
-
-TEST_F(SurfaceTextureGLToGLTest, TexturingFromPreRotatedUserSizedGLFilledBuffer) {
-    enum { texWidth = 64 };
-    enum { texHeight = 16 };
-
-    // This test requires 3 buffers to complete run on a single thread.
-    mST->setDefaultMaxBufferCount(3);
-
-    // Set the transform hint.
-    mST->setTransformHint(NATIVE_WINDOW_TRANSFORM_ROT_90);
-
-    // Set the user buffer size.
-    native_window_set_buffers_user_dimensions(mANW.get(), texWidth, texHeight);
-
-    // Do the producer side of things
-    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
-            mProducerEglSurface, mProducerEglContext));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-    // This is needed to ensure we pick up a buffer of the correct size and the
-    // new rotation hint.
-    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
-
-    glClearColor(0.6, 0.6, 0.6, 0.6);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    glEnable(GL_SCISSOR_TEST);
-    glScissor(24, 4, 1, 1);
-    glClearColor(1.0, 0.0, 0.0, 1.0);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
-
-    // Do the consumer side of things
-    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-            mEglContext));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-    glDisable(GL_SCISSOR_TEST);
-
-    // Skip the first frame, which was empty
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-
-    glClearColor(0.2, 0.2, 0.2, 0.2);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    glViewport(0, 0, texWidth, texHeight);
-    drawTexture();
-
-    EXPECT_TRUE(checkPixel( 0,  0, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(63,  0, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(63, 15, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel( 0, 15, 153, 153, 153, 153));
-
-    EXPECT_TRUE(checkPixel(24,  4, 255,   0,   0, 255));
-    EXPECT_TRUE(checkPixel(25,  5, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(23,  3, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(45, 13, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(12,  8, 153, 153, 153, 153));
-}
-
-TEST_F(SurfaceTextureGLToGLTest, TexturingFromPreRotatedGLFilledBuffer) {
-    enum { texWidth = 64 };
-    enum { texHeight = 16 };
-
-    // This test requires 3 buffers to complete run on a single thread.
-    mST->setDefaultMaxBufferCount(3);
-
-    // Set the transform hint.
-    mST->setTransformHint(NATIVE_WINDOW_TRANSFORM_ROT_90);
-
-    // Set the default buffer size.
-    mST->setDefaultBufferSize(texWidth, texHeight);
-
-    // Do the producer side of things
-    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
-            mProducerEglSurface, mProducerEglContext));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-    // This is needed to ensure we pick up a buffer of the correct size and the
-    // new rotation hint.
-    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
-
-    glClearColor(0.6, 0.6, 0.6, 0.6);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    glEnable(GL_SCISSOR_TEST);
-    glScissor(24, 4, 1, 1);
-    glClearColor(1.0, 0.0, 0.0, 1.0);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    eglSwapBuffers(mEglDisplay, mProducerEglSurface);
-
-    // Do the consumer side of things
-    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-            mEglContext));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-    glDisable(GL_SCISSOR_TEST);
-
-    // Skip the first frame, which was empty
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-
-    glClearColor(0.2, 0.2, 0.2, 0.2);
-    glClear(GL_COLOR_BUFFER_BIT);
-
-    glViewport(0, 0, texWidth, texHeight);
-    drawTexture();
-
-    EXPECT_TRUE(checkPixel( 0,  0, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(63,  0, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(63, 15, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel( 0, 15, 153, 153, 153, 153));
-
-    EXPECT_TRUE(checkPixel(24,  4, 255,   0,   0, 255));
-    EXPECT_TRUE(checkPixel(25,  5, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(23,  3, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(45, 13, 153, 153, 153, 153));
-    EXPECT_TRUE(checkPixel(12,  8, 153, 153, 153, 153));
-}
-
-/*
- * This test fixture is for testing GL -> GL texture streaming from one thread
- * to another.  It contains functionality to create a producer thread that will
- * perform GL rendering to an ANativeWindow that feeds frames to a
- * GLConsumer.  Additionally it supports interlocking the producer and
- * consumer threads so that a specific sequence of calls can be
- * deterministically created by the test.
- *
- * The intended usage is as follows:
- *
- * TEST_F(...) {
- *     class PT : public ProducerThread {
- *         virtual void render() {
- *             ...
- *             swapBuffers();
- *         }
- *     };
- *
- *     runProducerThread(new PT());
- *
- *     // The order of these calls will vary from test to test and may include
- *     // multiple frames and additional operations (e.g. GL rendering from the
- *     // texture).
- *     fc->waitForFrame();
- *     mST->updateTexImage();
- *     fc->finishFrame();
- * }
- *
- */
-class SurfaceTextureGLThreadToGLTest : public SurfaceTextureGLToGLTest {
-protected:
-
-    // ProducerThread is an abstract base class to simplify the creation of
-    // OpenGL ES frame producer threads.
-    class ProducerThread : public Thread {
-    public:
-        virtual ~ProducerThread() {
-        }
-
-        void setEglObjects(EGLDisplay producerEglDisplay,
-                EGLSurface producerEglSurface,
-                EGLContext producerEglContext) {
-            mProducerEglDisplay = producerEglDisplay;
-            mProducerEglSurface = producerEglSurface;
-            mProducerEglContext = producerEglContext;
-        }
-
-        virtual bool threadLoop() {
-            eglMakeCurrent(mProducerEglDisplay, mProducerEglSurface,
-                    mProducerEglSurface, mProducerEglContext);
-            render();
-            eglMakeCurrent(mProducerEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
-                    EGL_NO_CONTEXT);
-            return false;
-        }
-
-    protected:
-        virtual void render() = 0;
-
-        void swapBuffers() {
-            eglSwapBuffers(mProducerEglDisplay, mProducerEglSurface);
-        }
-
-        EGLDisplay mProducerEglDisplay;
-        EGLSurface mProducerEglSurface;
-        EGLContext mProducerEglContext;
-    };
-
-    // FrameCondition is a utility class for interlocking between the producer
-    // and consumer threads.  The FrameCondition object should be created and
-    // destroyed in the consumer thread only.  The consumer thread should set
-    // the FrameCondition as the FrameAvailableListener of the GLConsumer,
-    // and should call both waitForFrame and finishFrame once for each expected
-    // frame.
-    //
-    // This interlocking relies on the fact that onFrameAvailable gets called
-    // synchronously from GLConsumer::queueBuffer.
-    class FrameCondition : public GLConsumer::FrameAvailableListener {
-    public:
-        FrameCondition():
-                mFrameAvailable(false),
-                mFrameFinished(false) {
-        }
-
-        // waitForFrame waits for the next frame to arrive.  This should be
-        // called from the consumer thread once for every frame expected by the
-        // test.
-        void waitForFrame() {
-            Mutex::Autolock lock(mMutex);
-            ALOGV("+waitForFrame");
-            while (!mFrameAvailable) {
-                mFrameAvailableCondition.wait(mMutex);
-            }
-            mFrameAvailable = false;
-            ALOGV("-waitForFrame");
-        }
-
-        // Allow the producer to return from its swapBuffers call and continue
-        // on to produce the next frame.  This should be called by the consumer
-        // thread once for every frame expected by the test.
-        void finishFrame() {
-            Mutex::Autolock lock(mMutex);
-            ALOGV("+finishFrame");
-            mFrameFinished = true;
-            mFrameFinishCondition.signal();
-            ALOGV("-finishFrame");
-        }
-
-        // This should be called by GLConsumer on the producer thread.
-        virtual void onFrameAvailable() {
-            Mutex::Autolock lock(mMutex);
-            ALOGV("+onFrameAvailable");
-            mFrameAvailable = true;
-            mFrameAvailableCondition.signal();
-            while (!mFrameFinished) {
-                mFrameFinishCondition.wait(mMutex);
-            }
-            mFrameFinished = false;
-            ALOGV("-onFrameAvailable");
-        }
-
-    protected:
-        bool mFrameAvailable;
-        bool mFrameFinished;
-
-        Mutex mMutex;
-        Condition mFrameAvailableCondition;
-        Condition mFrameFinishCondition;
-    };
-
-    virtual void SetUp() {
-        SurfaceTextureGLToGLTest::SetUp();
-        mFC = new FrameCondition();
-        mST->setFrameAvailableListener(mFC);
-    }
-
-    virtual void TearDown() {
-        if (mProducerThread != NULL) {
-            mProducerThread->requestExitAndWait();
-        }
-        mProducerThread.clear();
-        mFC.clear();
-        SurfaceTextureGLToGLTest::TearDown();
-    }
-
-    void runProducerThread(const sp<ProducerThread> producerThread) {
-        ASSERT_TRUE(mProducerThread == NULL);
-        mProducerThread = producerThread;
-        producerThread->setEglObjects(mEglDisplay, mProducerEglSurface,
-                mProducerEglContext);
-        producerThread->run();
-    }
-
-    sp<ProducerThread> mProducerThread;
-    sp<FrameCondition> mFC;
-};
-
-TEST_F(SurfaceTextureGLThreadToGLTest,
-        UpdateTexImageBeforeFrameFinishedCompletes) {
-    class PT : public ProducerThread {
-        virtual void render() {
-            glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
-            glClear(GL_COLOR_BUFFER_BIT);
-            swapBuffers();
-        }
-    };
-
-    runProducerThread(new PT());
-
-    mFC->waitForFrame();
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-    mFC->finishFrame();
-
-    // TODO: Add frame verification once RGB TEX_EXTERNAL_OES is supported!
-}
-
-TEST_F(SurfaceTextureGLThreadToGLTest,
-        UpdateTexImageAfterFrameFinishedCompletes) {
-    class PT : public ProducerThread {
-        virtual void render() {
-            glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
-            glClear(GL_COLOR_BUFFER_BIT);
-            swapBuffers();
-        }
-    };
-
-    runProducerThread(new PT());
-
-    mFC->waitForFrame();
-    mFC->finishFrame();
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-
-    // TODO: Add frame verification once RGB TEX_EXTERNAL_OES is supported!
-}
-
-TEST_F(SurfaceTextureGLThreadToGLTest,
-        RepeatedUpdateTexImageBeforeFrameFinishedCompletes) {
-    enum { NUM_ITERATIONS = 1024 };
-
-    class PT : public ProducerThread {
-        virtual void render() {
-            for (int i = 0; i < NUM_ITERATIONS; i++) {
-                glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
-                glClear(GL_COLOR_BUFFER_BIT);
-                ALOGV("+swapBuffers");
-                swapBuffers();
-                ALOGV("-swapBuffers");
-            }
-        }
-    };
-
-    runProducerThread(new PT());
-
-    for (int i = 0; i < NUM_ITERATIONS; i++) {
-        mFC->waitForFrame();
-        ALOGV("+updateTexImage");
-        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-        ALOGV("-updateTexImage");
-        mFC->finishFrame();
-
-        // TODO: Add frame verification once RGB TEX_EXTERNAL_OES is supported!
-    }
-}
-
-TEST_F(SurfaceTextureGLThreadToGLTest,
-        RepeatedUpdateTexImageAfterFrameFinishedCompletes) {
-    enum { NUM_ITERATIONS = 1024 };
-
-    class PT : public ProducerThread {
-        virtual void render() {
-            for (int i = 0; i < NUM_ITERATIONS; i++) {
-                glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
-                glClear(GL_COLOR_BUFFER_BIT);
-                ALOGV("+swapBuffers");
-                swapBuffers();
-                ALOGV("-swapBuffers");
-            }
-        }
-    };
-
-    runProducerThread(new PT());
-
-    for (int i = 0; i < NUM_ITERATIONS; i++) {
-        mFC->waitForFrame();
-        mFC->finishFrame();
-        ALOGV("+updateTexImage");
-        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-        ALOGV("-updateTexImage");
-
-        // TODO: Add frame verification once RGB TEX_EXTERNAL_OES is supported!
-    }
-}
-
-// XXX: This test is disabled because it is currently hanging on some devices.
-TEST_F(SurfaceTextureGLThreadToGLTest,
-        DISABLED_RepeatedSwapBuffersWhileDequeueStalledCompletes) {
-    enum { NUM_ITERATIONS = 64 };
-
-    class PT : public ProducerThread {
-        virtual void render() {
-            for (int i = 0; i < NUM_ITERATIONS; i++) {
-                glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
-                glClear(GL_COLOR_BUFFER_BIT);
-                ALOGV("+swapBuffers");
-                swapBuffers();
-                ALOGV("-swapBuffers");
-            }
-        }
-    };
-
-    ASSERT_EQ(OK, mST->setDefaultMaxBufferCount(2));
-
-    runProducerThread(new PT());
-
-    // Allow three frames to be rendered and queued before starting the
-    // rendering in this thread.  For the latter two frames we don't call
-    // updateTexImage so the next dequeue from the producer thread will block
-    // waiting for a frame to become available.
-    mFC->waitForFrame();
-    mFC->finishFrame();
-
-    // We must call updateTexImage to consume the first frame so that the
-    // SurfaceTexture is able to reduce the buffer count to 2.  This is because
-    // the GL driver may dequeue a buffer when the EGLSurface is created, and
-    // that happens before we call setDefaultMaxBufferCount.  It's possible that the
-    // driver does not dequeue a buffer at EGLSurface creation time, so we
-    // cannot rely on this to cause the second dequeueBuffer call to block.
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-
-    mFC->waitForFrame();
-    mFC->finishFrame();
-    mFC->waitForFrame();
-    mFC->finishFrame();
-
-    // Sleep for 100ms to allow the producer thread's dequeueBuffer call to
-    // block waiting for a buffer to become available.
-    usleep(100000);
-
-    // Render and present a number of images.  This thread should not be blocked
-    // by the fact that the producer thread is blocking in dequeue.
-    for (int i = 0; i < NUM_ITERATIONS; i++) {
-        glClear(GL_COLOR_BUFFER_BIT);
-        eglSwapBuffers(mEglDisplay, mEglSurface);
-    }
-
-    // Consume the two pending buffers to unblock the producer thread.
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-
-    // Consume the remaining buffers from the producer thread.
-    for (int i = 0; i < NUM_ITERATIONS-3; i++) {
-        mFC->waitForFrame();
-        mFC->finishFrame();
-        ALOGV("+updateTexImage");
-        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-        ALOGV("-updateTexImage");
-    }
-}
-
-class SurfaceTextureFBOTest : public SurfaceTextureGLTest {
-protected:
-
-    virtual void SetUp() {
-        SurfaceTextureGLTest::SetUp();
-
-        glGenFramebuffers(1, &mFbo);
-        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-
-        glGenTextures(1, &mFboTex);
-        glBindTexture(GL_TEXTURE_2D, mFboTex);
-        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getSurfaceWidth(),
-                getSurfaceHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-        glBindTexture(GL_TEXTURE_2D, 0);
-        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-
-        glBindFramebuffer(GL_FRAMEBUFFER, mFbo);
-        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
-                GL_TEXTURE_2D, mFboTex, 0);
-        glBindFramebuffer(GL_FRAMEBUFFER, 0);
-        ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-    }
-
-    virtual void TearDown() {
-        SurfaceTextureGLTest::TearDown();
-
-        glDeleteTextures(1, &mFboTex);
-        glDeleteFramebuffers(1, &mFbo);
-    }
-
-    GLuint mFbo;
-    GLuint mFboTex;
-};
-
-// This test is intended to verify that proper synchronization is done when
-// rendering into an FBO.
-TEST_F(SurfaceTextureFBOTest, BlitFromCpuFilledBufferToFbo) {
-    const int texWidth = 64;
-    const int texHeight = 64;
-
-    ASSERT_EQ(NO_ERROR, native_window_set_buffers_geometry(mANW.get(),
-            texWidth, texHeight, HAL_PIXEL_FORMAT_RGBA_8888));
-    ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(),
-            GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN));
-
-    android_native_buffer_t* anb;
-    ASSERT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(),
-            &anb));
-    ASSERT_TRUE(anb != NULL);
-
-    sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
-
-    // Fill the buffer with green
-    uint8_t* img = NULL;
-    buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
-    fillRGBA8BufferSolid(img, texWidth, texHeight, buf->getStride(), 0, 255,
-            0, 255);
-    buf->unlock();
-    ASSERT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), buf->getNativeBuffer(),
-            -1));
-
-    ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-
-    glBindFramebuffer(GL_FRAMEBUFFER, mFbo);
-    drawTexture();
-    glBindFramebuffer(GL_FRAMEBUFFER, 0);
-
-    for (int i = 0; i < 4; i++) {
-        SCOPED_TRACE(String8::format("frame %d", i).string());
-
-        ASSERT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(),
-                &anb));
-        ASSERT_TRUE(anb != NULL);
-
-        buf = new GraphicBuffer(anb, false);
-
-        // Fill the buffer with red
-        ASSERT_EQ(NO_ERROR, buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN,
-                (void**)(&img)));
-        fillRGBA8BufferSolid(img, texWidth, texHeight, buf->getStride(), 255, 0,
-                0, 255);
-        ASSERT_EQ(NO_ERROR, buf->unlock());
-        ASSERT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(),
-                buf->getNativeBuffer(), -1));
-
-        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
-
-        drawTexture();
-
-        EXPECT_TRUE(checkPixel( 24, 39, 255, 0, 0, 255));
-    }
-
-    glBindFramebuffer(GL_FRAMEBUFFER, mFbo);
-
-    EXPECT_TRUE(checkPixel( 24, 39, 0, 255, 0, 255));
-}
-
-class SurfaceTextureMultiContextGLTest : public SurfaceTextureGLTest {
-protected:
-    enum { SECOND_TEX_ID = 123 };
-    enum { THIRD_TEX_ID = 456 };
-
-    SurfaceTextureMultiContextGLTest():
-            mSecondEglContext(EGL_NO_CONTEXT) {
-    }
-
-    virtual void SetUp() {
-        SurfaceTextureGLTest::SetUp();
-
-        // Set up the secondary context and texture renderer.
-        mSecondEglContext = eglCreateContext(mEglDisplay, mGlConfig,
-                EGL_NO_CONTEXT, getContextAttribs());
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-        ASSERT_NE(EGL_NO_CONTEXT, mSecondEglContext);
-
-        ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-                mSecondEglContext));
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-        mSecondTextureRenderer = new TextureRenderer(SECOND_TEX_ID, mST);
-        ASSERT_NO_FATAL_FAILURE(mSecondTextureRenderer->SetUp());
-
-        // Set up the tertiary context and texture renderer.
-        mThirdEglContext = eglCreateContext(mEglDisplay, mGlConfig,
-                EGL_NO_CONTEXT, getContextAttribs());
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-        ASSERT_NE(EGL_NO_CONTEXT, mThirdEglContext);
-
-        ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-                mThirdEglContext));
-        ASSERT_EQ(EGL_SUCCESS, eglGetError());
-        mThirdTextureRenderer = new TextureRenderer(THIRD_TEX_ID, mST);
-        ASSERT_NO_FATAL_FAILURE(mThirdTextureRenderer->SetUp());
-
-        // Switch back to the primary context to start the tests.
-        ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-                mEglContext));
-    }
-
-    virtual void TearDown() {
-        if (mThirdEglContext != EGL_NO_CONTEXT) {
-            eglDestroyContext(mEglDisplay, mThirdEglContext);
-        }
-        if (mSecondEglContext != EGL_NO_CONTEXT) {
-            eglDestroyContext(mEglDisplay, mSecondEglContext);
-        }
-        SurfaceTextureGLTest::TearDown();
-    }
-
-    EGLContext mSecondEglContext;
-    sp<TextureRenderer> mSecondTextureRenderer;
-
-    EGLContext mThirdEglContext;
-    sp<TextureRenderer> mThirdTextureRenderer;
-};
-
-TEST_F(SurfaceTextureMultiContextGLTest, UpdateFromMultipleContextsFails) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Latch the texture contents on the primary context.
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    // Attempt to latch the texture on the secondary context.
-    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-            mSecondEglContext));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-    ASSERT_EQ(INVALID_OPERATION, mST->updateTexImage());
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest, DetachFromContextSucceeds) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Latch the texture contents on the primary context.
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    // Detach from the primary context.
-    ASSERT_EQ(OK, mST->detachFromContext());
-
-    // Check that the GL texture was deleted.
-    EXPECT_EQ(GL_FALSE, glIsTexture(TEX_ID));
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest,
-        DetachFromContextSucceedsAfterProducerDisconnect) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Latch the texture contents on the primary context.
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    // Detach from the primary context.
-    native_window_api_disconnect(mANW.get(), NATIVE_WINDOW_API_CPU);
-    ASSERT_EQ(OK, mST->detachFromContext());
-
-    // Check that the GL texture was deleted.
-    EXPECT_EQ(GL_FALSE, glIsTexture(TEX_ID));
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest, DetachFromContextFailsWhenAbandoned) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Latch the texture contents on the primary context.
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    // Attempt to detach from the primary context.
-    mST->abandon();
-    ASSERT_EQ(NO_INIT, mST->detachFromContext());
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest, DetachFromContextFailsWhenDetached) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Latch the texture contents on the primary context.
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    // Detach from the primary context.
-    ASSERT_EQ(OK, mST->detachFromContext());
-
-    // Attempt to detach from the primary context again.
-    ASSERT_EQ(INVALID_OPERATION, mST->detachFromContext());
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest, DetachFromContextFailsWithNoDisplay) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Latch the texture contents on the primary context.
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    // Make there be no current display.
-    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
-            EGL_NO_CONTEXT));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-    // Attempt to detach from the primary context.
-    ASSERT_EQ(INVALID_OPERATION, mST->detachFromContext());
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest, DetachFromContextFailsWithNoContext) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Latch the texture contents on the primary context.
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    // Make current context be incorrect.
-    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-            mSecondEglContext));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-    // Attempt to detach from the primary context.
-    ASSERT_EQ(INVALID_OPERATION, mST->detachFromContext());
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest, UpdateTexImageFailsWhenDetached) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Detach from the primary context.
-    ASSERT_EQ(OK, mST->detachFromContext());
-
-    // Attempt to latch the texture contents on the primary context.
-    mFW->waitForFrame();
-    ASSERT_EQ(INVALID_OPERATION, mST->updateTexImage());
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest, AttachToContextSucceeds) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Latch the texture contents on the primary context.
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    // Detach from the primary context.
-    ASSERT_EQ(OK, mST->detachFromContext());
-
-    // Attach to the secondary context.
-    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-            mSecondEglContext));
-    ASSERT_EQ(OK, mST->attachToContext(SECOND_TEX_ID));
-
-    // Verify that the texture object was created and bound.
-    GLint texBinding = -1;
-    glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texBinding);
-    EXPECT_EQ(SECOND_TEX_ID, texBinding);
-
-    // Try to use the texture from the secondary context.
-    glClearColor(0.2, 0.2, 0.2, 0.2);
-    glClear(GL_COLOR_BUFFER_BIT);
-    glViewport(0, 0, 1, 1);
-    mSecondTextureRenderer->drawTexture();
-    ASSERT_TRUE(checkPixel( 0,  0,  35,  35,  35,  35));
-    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest,
-        AttachToContextSucceedsAfterProducerDisconnect) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Latch the texture contents on the primary context.
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    // Detach from the primary context.
-    native_window_api_disconnect(mANW.get(), NATIVE_WINDOW_API_CPU);
-    ASSERT_EQ(OK, mST->detachFromContext());
-
-    // Attach to the secondary context.
-    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-            mSecondEglContext));
-    ASSERT_EQ(OK, mST->attachToContext(SECOND_TEX_ID));
-
-    // Verify that the texture object was created and bound.
-    GLint texBinding = -1;
-    glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texBinding);
-    EXPECT_EQ(SECOND_TEX_ID, texBinding);
-
-    // Try to use the texture from the secondary context.
-    glClearColor(0.2, 0.2, 0.2, 0.2);
-    glClear(GL_COLOR_BUFFER_BIT);
-    glViewport(0, 0, 1, 1);
-    mSecondTextureRenderer->drawTexture();
-    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-    ASSERT_TRUE(checkPixel( 0,  0,  35,  35,  35,  35));
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest,
-        AttachToContextSucceedsBeforeUpdateTexImage) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Detach from the primary context.
-    native_window_api_disconnect(mANW.get(), NATIVE_WINDOW_API_CPU);
-    ASSERT_EQ(OK, mST->detachFromContext());
-
-    // Attach to the secondary context.
-    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-            mSecondEglContext));
-    ASSERT_EQ(OK, mST->attachToContext(SECOND_TEX_ID));
-
-    // Verify that the texture object was created and bound.
-    GLint texBinding = -1;
-    glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texBinding);
-    EXPECT_EQ(SECOND_TEX_ID, texBinding);
-
-    // Latch the texture contents on the primary context.
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    // Try to use the texture from the secondary context.
-    glClearColor(0.2, 0.2, 0.2, 0.2);
-    glClear(GL_COLOR_BUFFER_BIT);
-    glViewport(0, 0, 1, 1);
-    mSecondTextureRenderer->drawTexture();
-    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-    ASSERT_TRUE(checkPixel( 0,  0,  35,  35,  35,  35));
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest, AttachToContextFailsWhenAbandoned) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Latch the texture contents on the primary context.
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    // Detach from the primary context.
-    ASSERT_EQ(OK, mST->detachFromContext());
-
-    // Attempt to attach to the secondary context.
-    mST->abandon();
-
-    // Attempt to attach to the primary context.
-    ASSERT_EQ(NO_INIT, mST->attachToContext(SECOND_TEX_ID));
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest, AttachToContextFailsWhenAttached) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Latch the texture contents on the primary context.
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    // Attempt to attach to the primary context.
-    ASSERT_EQ(INVALID_OPERATION, mST->attachToContext(SECOND_TEX_ID));
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest,
-        AttachToContextFailsWhenAttachedBeforeUpdateTexImage) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Attempt to attach to the primary context.
-    ASSERT_EQ(INVALID_OPERATION, mST->attachToContext(SECOND_TEX_ID));
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest, AttachToContextFailsWithNoDisplay) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Latch the texture contents on the primary context.
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    // Detach from the primary context.
-    ASSERT_EQ(OK, mST->detachFromContext());
-
-    // Make there be no current display.
-    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
-            EGL_NO_CONTEXT));
-    ASSERT_EQ(EGL_SUCCESS, eglGetError());
-
-    // Attempt to attach with no context current.
-    ASSERT_EQ(INVALID_OPERATION, mST->attachToContext(SECOND_TEX_ID));
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest, AttachToContextSucceedsTwice) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Latch the texture contents on the primary context.
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    // Detach from the primary context.
-    ASSERT_EQ(OK, mST->detachFromContext());
-
-    // Attach to the secondary context.
-    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-            mSecondEglContext));
-    ASSERT_EQ(OK, mST->attachToContext(SECOND_TEX_ID));
-
-    // Detach from the secondary context.
-    ASSERT_EQ(OK, mST->detachFromContext());
-
-    // Attach to the tertiary context.
-    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-            mThirdEglContext));
-    ASSERT_EQ(OK, mST->attachToContext(THIRD_TEX_ID));
-
-    // Verify that the texture object was created and bound.
-    GLint texBinding = -1;
-    glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texBinding);
-    EXPECT_EQ(THIRD_TEX_ID, texBinding);
-
-    // Try to use the texture from the tertiary context.
-    glClearColor(0.2, 0.2, 0.2, 0.2);
-    glClear(GL_COLOR_BUFFER_BIT);
-    glViewport(0, 0, 1, 1);
-    mThirdTextureRenderer->drawTexture();
-    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-    ASSERT_TRUE(checkPixel( 0,  0,  35,  35,  35,  35));
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest,
-        AttachToContextSucceedsTwiceBeforeUpdateTexImage) {
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Detach from the primary context.
-    ASSERT_EQ(OK, mST->detachFromContext());
-
-    // Attach to the secondary context.
-    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-            mSecondEglContext));
-    ASSERT_EQ(OK, mST->attachToContext(SECOND_TEX_ID));
-
-    // Detach from the secondary context.
-    ASSERT_EQ(OK, mST->detachFromContext());
-
-    // Attach to the tertiary context.
-    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-            mThirdEglContext));
-    ASSERT_EQ(OK, mST->attachToContext(THIRD_TEX_ID));
-
-    // Verify that the texture object was created and bound.
-    GLint texBinding = -1;
-    glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texBinding);
-    EXPECT_EQ(THIRD_TEX_ID, texBinding);
-
-    // Latch the texture contents on the tertiary context.
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    // Try to use the texture from the tertiary context.
-    glClearColor(0.2, 0.2, 0.2, 0.2);
-    glClear(GL_COLOR_BUFFER_BIT);
-    glViewport(0, 0, 1, 1);
-    mThirdTextureRenderer->drawTexture();
-    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
-    ASSERT_TRUE(checkPixel( 0,  0,  35,  35,  35,  35));
-}
-
-TEST_F(SurfaceTextureMultiContextGLTest,
-        UpdateTexImageSucceedsForBufferConsumedBeforeDetach) {
-    ASSERT_EQ(NO_ERROR, mST->setDefaultMaxBufferCount(2));
-
-    // produce two frames and consume them both on the primary context
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-
-    // produce one more frame
-    ASSERT_NO_FATAL_FAILURE(produceOneRGBA8Frame(mANW));
-
-    // Detach from the primary context and attach to the secondary context
-    ASSERT_EQ(OK, mST->detachFromContext());
-    ASSERT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
-            mSecondEglContext));
-    ASSERT_EQ(OK, mST->attachToContext(SECOND_TEX_ID));
-
-    // Consume final frame on secondary context
-    mFW->waitForFrame();
-    ASSERT_EQ(OK, mST->updateTexImage());
-}
-
-} // namespace android
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index e0272ba..3f495f8 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#include "DummyConsumer.h"
+
 #include <gtest/gtest.h>
 
 #include <binder/IMemory.h>
@@ -21,6 +23,7 @@
 #include <gui/Surface.h>
 #include <gui/SurfaceComposerClient.h>
 #include <gui/BufferItemConsumer.h>
+#include <ui/Rect.h>
 #include <utils/String8.h>
 
 #include <private/gui/ComposerService.h>
@@ -88,12 +91,14 @@
     sp<ANativeWindow> anw(mSurface);
 
     // Verify the screenshot works with no protected buffers.
-    sp<BufferQueue> bq = new BufferQueue();
-    sp<CpuConsumer> consumer = new CpuConsumer(bq, 1);
+    sp<IGraphicBufferProducer> producer;
+    sp<IGraphicBufferConsumer> consumer;
+    BufferQueue::createBufferQueue(&producer, &consumer);
+    sp<CpuConsumer> cpuConsumer = new CpuConsumer(consumer, 1);
     sp<ISurfaceComposer> sf(ComposerService::getComposerService());
     sp<IBinder> display(sf->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain));
-    ASSERT_EQ(NO_ERROR, sf->captureScreen(display, bq,
-            64, 64, 0, 0x7fffffff));
+    ASSERT_EQ(NO_ERROR, sf->captureScreen(display, producer, Rect(),
+            64, 64, 0, 0x7fffffff, false));
 
     // Set the PROTECTED usage bit and verify that the screenshot fails.  Note
     // that we need to dequeue a buffer in order for it to actually get
@@ -121,8 +126,8 @@
                 &buf));
         ASSERT_EQ(NO_ERROR, anw->queueBuffer(anw.get(), buf, -1));
     }
-    ASSERT_EQ(NO_ERROR, sf->captureScreen(display, bq,
-            64, 64, 0, 0x7fffffff));
+    ASSERT_EQ(NO_ERROR, sf->captureScreen(display, producer, Rect(),
+            64, 64, 0, 0x7fffffff, false));
 }
 
 TEST_F(SurfaceTest, ConcreteTypeIsSurface) {
@@ -136,10 +141,12 @@
 TEST_F(SurfaceTest, QueryConsumerUsage) {
     const int TEST_USAGE_FLAGS =
             GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_HW_RENDER;
-    sp<BufferQueue> bq = new BufferQueue();
-    sp<BufferItemConsumer> c = new BufferItemConsumer(bq,
+    sp<IGraphicBufferProducer> producer;
+    sp<IGraphicBufferConsumer> consumer;
+    BufferQueue::createBufferQueue(&producer, &consumer);
+    sp<BufferItemConsumer> c = new BufferItemConsumer(consumer,
             TEST_USAGE_FLAGS);
-    sp<Surface> s = new Surface(bq);
+    sp<Surface> s = new Surface(producer);
 
     sp<ANativeWindow> anw(s);
 
@@ -150,4 +157,75 @@
     ASSERT_EQ(TEST_USAGE_FLAGS, flags);
 }
 
+TEST_F(SurfaceTest, QueryDefaultBuffersDataSpace) {
+    const android_dataspace TEST_DATASPACE = HAL_DATASPACE_SRGB;
+    sp<IGraphicBufferProducer> producer;
+    sp<IGraphicBufferConsumer> consumer;
+    BufferQueue::createBufferQueue(&producer, &consumer);
+    sp<CpuConsumer> cpuConsumer = new CpuConsumer(consumer, 1);
+
+    cpuConsumer->setDefaultBufferDataSpace(TEST_DATASPACE);
+
+    sp<Surface> s = new Surface(producer);
+
+    sp<ANativeWindow> anw(s);
+
+    android_dataspace dataSpace;
+
+    int err = anw->query(anw.get(), NATIVE_WINDOW_DEFAULT_DATASPACE,
+            reinterpret_cast<int*>(&dataSpace));
+
+    ASSERT_EQ(NO_ERROR, err);
+    ASSERT_EQ(TEST_DATASPACE, dataSpace);
+}
+
+TEST_F(SurfaceTest, SettingGenerationNumber) {
+    sp<IGraphicBufferProducer> producer;
+    sp<IGraphicBufferConsumer> consumer;
+    BufferQueue::createBufferQueue(&producer, &consumer);
+    sp<CpuConsumer> cpuConsumer = new CpuConsumer(consumer, 1);
+    sp<Surface> surface = new Surface(producer);
+    sp<ANativeWindow> window(surface);
+
+    // Allocate a buffer with a generation number of 0
+    ANativeWindowBuffer* buffer;
+    int fenceFd;
+    ASSERT_EQ(NO_ERROR, window->dequeueBuffer(window.get(), &buffer, &fenceFd));
+    ASSERT_EQ(NO_ERROR, window->cancelBuffer(window.get(), buffer, fenceFd));
+
+    // Detach the buffer and check its generation number
+    sp<GraphicBuffer> graphicBuffer;
+    sp<Fence> fence;
+    ASSERT_EQ(NO_ERROR, surface->detachNextBuffer(&graphicBuffer, &fence));
+    ASSERT_EQ(0U, graphicBuffer->getGenerationNumber());
+
+    ASSERT_EQ(NO_ERROR, surface->setGenerationNumber(1));
+    buffer = static_cast<ANativeWindowBuffer*>(graphicBuffer.get());
+
+    // This should change the generation number of the GraphicBuffer
+    ASSERT_EQ(NO_ERROR, surface->attachBuffer(buffer));
+
+    // Check that the new generation number sticks with the buffer
+    ASSERT_EQ(NO_ERROR, window->cancelBuffer(window.get(), buffer, -1));
+    ASSERT_EQ(NO_ERROR, window->dequeueBuffer(window.get(), &buffer, &fenceFd));
+    graphicBuffer = static_cast<GraphicBuffer*>(buffer);
+    ASSERT_EQ(1U, graphicBuffer->getGenerationNumber());
+}
+
+TEST_F(SurfaceTest, GetConsumerName) {
+    sp<IGraphicBufferProducer> producer;
+    sp<IGraphicBufferConsumer> consumer;
+    BufferQueue::createBufferQueue(&producer, &consumer);
+
+    sp<DummyConsumer> dummyConsumer(new DummyConsumer);
+    consumer->consumerConnect(dummyConsumer, false);
+    consumer->setConsumerName(String8("TestConsumer"));
+
+    sp<Surface> surface = new Surface(producer);
+    sp<ANativeWindow> window(surface);
+    native_window_api_connect(window.get(), NATIVE_WINDOW_API_CPU);
+
+    EXPECT_STREQ("TestConsumer", surface->getConsumerName().string());
+}
+
 }
diff --git a/libs/gui/tests/TextureRenderer.cpp b/libs/gui/tests/TextureRenderer.cpp
new file mode 100644
index 0000000..90951b3
--- /dev/null
+++ b/libs/gui/tests/TextureRenderer.cpp
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "TextureRenderer.h"
+
+#include "GLTest.h"
+
+#include <gui/GLConsumer.h>
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+#include <gtest/gtest.h>
+
+namespace android {
+
+TextureRenderer::TextureRenderer(GLuint texName,
+        const sp<GLConsumer>& st) : mTexName(texName), mST(st) {
+}
+
+void TextureRenderer::SetUp() {
+    const char vsrc[] =
+        "attribute vec4 vPosition;\n"
+        "varying vec2 texCoords;\n"
+        "uniform mat4 texMatrix;\n"
+        "void main() {\n"
+        "  vec2 vTexCoords = 0.5 * (vPosition.xy + vec2(1.0, 1.0));\n"
+        "  texCoords = (texMatrix * vec4(vTexCoords, 0.0, 1.0)).xy;\n"
+        "  gl_Position = vPosition;\n"
+        "}\n";
+
+    const char fsrc[] =
+        "#extension GL_OES_EGL_image_external : require\n"
+        "precision mediump float;\n"
+        "uniform samplerExternalOES texSampler;\n"
+        "varying vec2 texCoords;\n"
+        "void main() {\n"
+        "  gl_FragColor = texture2D(texSampler, texCoords);\n"
+        "}\n";
+
+    {
+        SCOPED_TRACE("creating shader program");
+        ASSERT_NO_FATAL_FAILURE(GLTest::createProgram(vsrc, fsrc, &mPgm));
+    }
+
+    mPositionHandle = glGetAttribLocation(mPgm, "vPosition");
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+    ASSERT_NE(-1, mPositionHandle);
+    mTexSamplerHandle = glGetUniformLocation(mPgm, "texSampler");
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+    ASSERT_NE(-1, mTexSamplerHandle);
+    mTexMatrixHandle = glGetUniformLocation(mPgm, "texMatrix");
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+    ASSERT_NE(-1, mTexMatrixHandle);
+}
+
+// drawTexture draws the GLConsumer over the entire GL viewport.
+void TextureRenderer::drawTexture() {
+    static const GLfloat triangleVertices[] = {
+        -1.0f, 1.0f,
+        -1.0f, -1.0f,
+        1.0f, -1.0f,
+        1.0f, 1.0f,
+    };
+
+    glVertexAttribPointer(mPositionHandle, 2, GL_FLOAT, GL_FALSE, 0,
+            triangleVertices);
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+    glEnableVertexAttribArray(mPositionHandle);
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+
+    glUseProgram(mPgm);
+    glUniform1i(mTexSamplerHandle, 0);
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+    glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTexName);
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+
+    // XXX: These calls are not needed for GL_TEXTURE_EXTERNAL_OES as
+    // they're setting the defautls for that target, but when hacking
+    // things to use GL_TEXTURE_2D they are needed to achieve the same
+    // behavior.
+    glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER,
+            GL_LINEAR);
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+    glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER,
+            GL_LINEAR);
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+    glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S,
+            GL_CLAMP_TO_EDGE);
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+    glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T,
+            GL_CLAMP_TO_EDGE);
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+
+    GLfloat texMatrix[16];
+    mST->getTransformMatrix(texMatrix);
+    glUniformMatrix4fv(mTexMatrixHandle, 1, GL_FALSE, texMatrix);
+
+    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
+}
+
+} // namespace android
diff --git a/libs/gui/tests/TextureRenderer.h b/libs/gui/tests/TextureRenderer.h
new file mode 100644
index 0000000..37b2b47
--- /dev/null
+++ b/libs/gui/tests/TextureRenderer.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_TEXTURE_RENDERER_H
+#define ANDROID_TEXTURE_RENDERER_H
+
+#include <GLES/gl.h>
+
+#include <utils/RefBase.h>
+
+namespace android {
+
+class GLConsumer;
+
+class TextureRenderer : public RefBase {
+public:
+    TextureRenderer(GLuint texName, const sp<GLConsumer>& st);
+
+    void SetUp();
+    void drawTexture();
+
+private:
+    GLuint mTexName;
+    sp<GLConsumer> mST;
+    GLuint mPgm;
+    GLint mPositionHandle;
+    GLint mTexSamplerHandle;
+    GLint mTexMatrixHandle;
+};
+
+} // namespace android
+
+#endif
diff --git a/libs/input/Android.mk b/libs/input/Android.mk
index f1921a4..746de66 100644
--- a/libs/input/Android.mk
+++ b/libs/input/Android.mk
@@ -27,6 +27,7 @@
 
 deviceSources := \
     $(commonSources) \
+    IInputFlinger.cpp \
     InputTransport.cpp \
     VelocityControl.cpp \
     VelocityTracker.cpp
@@ -55,6 +56,9 @@
 
 LOCAL_SRC_FILES:= $(deviceSources)
 
+LOCAL_CLANG := true
+LOCAL_SANITIZE := integer
+
 LOCAL_SHARED_LIBRARIES := \
 	liblog \
 	libcutils \
diff --git a/libs/input/IInputFlinger.cpp b/libs/input/IInputFlinger.cpp
new file mode 100644
index 0000000..003e73d
--- /dev/null
+++ b/libs/input/IInputFlinger.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <binder/Parcel.h>
+#include <binder/IPCThreadState.h>
+#include <binder/IServiceManager.h>
+
+#include <input/IInputFlinger.h>
+
+
+namespace android {
+
+class BpInputFlinger : public BpInterface<IInputFlinger> {
+public:
+    explicit BpInputFlinger(const sp<IBinder>& impl) :
+            BpInterface<IInputFlinger>(impl) { }
+
+    virtual status_t doSomething() {
+        Parcel data, reply;
+        data.writeInterfaceToken(IInputFlinger::getInterfaceDescriptor());
+        remote()->transact(BnInputFlinger::DO_SOMETHING_TRANSACTION, data, &reply);
+        return reply.readInt32();
+    }
+};
+
+IMPLEMENT_META_INTERFACE(InputFlinger, "android.input.IInputFlinger");
+
+
+status_t BnInputFlinger::onTransact(
+        uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) {
+    switch(code) {
+    case DO_SOMETHING_TRANSACTION: {
+        CHECK_INTERFACE(IInputFlinger, data, reply);
+        reply->writeInt32(0);
+        break;
+    }
+    default:
+        return BBinder::onTransact(code, data, reply, flags);
+    }
+    return NO_ERROR;
+}
+
+};
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp
index 6f53996..a624663 100644
--- a/libs/input/Input.cpp
+++ b/libs/input/Input.cpp
@@ -21,8 +21,9 @@
 #include <limits.h>
 
 #include <input/Input.h>
+#include <input/InputEventLabels.h>
 
-#ifdef HAVE_ANDROID_OS
+#ifdef __ANDROID__
 #include <binder/Parcel.h>
 #endif
 
@@ -42,82 +43,12 @@
 
 // --- KeyEvent ---
 
-bool KeyEvent::hasDefaultAction(int32_t keyCode) {
-    switch (keyCode) {
-        case AKEYCODE_HOME:
-        case AKEYCODE_BACK:
-        case AKEYCODE_CALL:
-        case AKEYCODE_ENDCALL:
-        case AKEYCODE_VOLUME_UP:
-        case AKEYCODE_VOLUME_DOWN:
-        case AKEYCODE_VOLUME_MUTE:
-        case AKEYCODE_POWER:
-        case AKEYCODE_CAMERA:
-        case AKEYCODE_HEADSETHOOK:
-        case AKEYCODE_MENU:
-        case AKEYCODE_NOTIFICATION:
-        case AKEYCODE_FOCUS:
-        case AKEYCODE_SEARCH:
-        case AKEYCODE_MEDIA_PLAY:
-        case AKEYCODE_MEDIA_PAUSE:
-        case AKEYCODE_MEDIA_PLAY_PAUSE:
-        case AKEYCODE_MEDIA_STOP:
-        case AKEYCODE_MEDIA_NEXT:
-        case AKEYCODE_MEDIA_PREVIOUS:
-        case AKEYCODE_MEDIA_REWIND:
-        case AKEYCODE_MEDIA_RECORD:
-        case AKEYCODE_MEDIA_FAST_FORWARD:
-        case AKEYCODE_MUTE:
-        case AKEYCODE_BRIGHTNESS_DOWN:
-        case AKEYCODE_BRIGHTNESS_UP:
-        case AKEYCODE_MEDIA_AUDIO_TRACK:
-            return true;
-    }
-    
-    return false;
+const char* KeyEvent::getLabel(int32_t keyCode) {
+    return getLabelByKeyCode(keyCode);
 }
 
-bool KeyEvent::hasDefaultAction() const {
-    return hasDefaultAction(getKeyCode());
-}
-
-bool KeyEvent::isSystemKey(int32_t keyCode) {
-    switch (keyCode) {
-        case AKEYCODE_MENU:
-        case AKEYCODE_SOFT_RIGHT:
-        case AKEYCODE_HOME:
-        case AKEYCODE_BACK:
-        case AKEYCODE_CALL:
-        case AKEYCODE_ENDCALL:
-        case AKEYCODE_VOLUME_UP:
-        case AKEYCODE_VOLUME_DOWN:
-        case AKEYCODE_VOLUME_MUTE:
-        case AKEYCODE_MUTE:
-        case AKEYCODE_POWER:
-        case AKEYCODE_HEADSETHOOK:
-        case AKEYCODE_MEDIA_PLAY:
-        case AKEYCODE_MEDIA_PAUSE:
-        case AKEYCODE_MEDIA_PLAY_PAUSE:
-        case AKEYCODE_MEDIA_STOP:
-        case AKEYCODE_MEDIA_NEXT:
-        case AKEYCODE_MEDIA_PREVIOUS:
-        case AKEYCODE_MEDIA_REWIND:
-        case AKEYCODE_MEDIA_RECORD:
-        case AKEYCODE_MEDIA_FAST_FORWARD:
-        case AKEYCODE_CAMERA:
-        case AKEYCODE_FOCUS:
-        case AKEYCODE_SEARCH:
-        case AKEYCODE_BRIGHTNESS_DOWN:
-        case AKEYCODE_BRIGHTNESS_UP:
-        case AKEYCODE_MEDIA_AUDIO_TRACK:
-            return true;
-    }
-    
-    return false;
-}
-
-bool KeyEvent::isSystemKey() const {
-    return isSystemKey(getKeyCode());
+int32_t KeyEvent::getKeyCodeFromLabel(const char* label) {
+    return getKeyCodeByLabel(label);
 }
 
 void KeyEvent::initialize(
@@ -158,16 +89,10 @@
 // --- PointerCoords ---
 
 float PointerCoords::getAxisValue(int32_t axis) const {
-    if (axis < 0 || axis > 63) {
+    if (axis < 0 || axis > 63 || !BitSet64::hasBit(bits, axis)){
         return 0;
     }
-
-    uint64_t axisBit = 1LL << axis;
-    if (!(bits & axisBit)) {
-        return 0;
-    }
-    uint32_t index = __builtin_popcountll(bits & (axisBit - 1LL));
-    return values[index];
+    return values[BitSet64::getIndexOfBit(bits, axis)];
 }
 
 status_t PointerCoords::setAxisValue(int32_t axis, float value) {
@@ -175,22 +100,23 @@
         return NAME_NOT_FOUND;
     }
 
-    uint64_t axisBit = 1LL << axis;
-    uint32_t index = __builtin_popcountll(bits & (axisBit - 1LL));
-    if (!(bits & axisBit)) {
+    uint32_t index = BitSet64::getIndexOfBit(bits, axis);
+    if (!BitSet64::hasBit(bits, axis)) {
         if (value == 0) {
             return OK; // axes with value 0 do not need to be stored
         }
-        uint32_t count = __builtin_popcountll(bits);
+
+        uint32_t count = BitSet64::count(bits);
         if (count >= MAX_AXES) {
             tooManyAxes(axis);
             return NO_MEMORY;
         }
-        bits |= axisBit;
+        BitSet64::markBit(bits, axis);
         for (uint32_t i = count; i > index; i--) {
             values[i] = values[i - 1];
         }
     }
+
     values[index] = value;
     return OK;
 }
@@ -213,11 +139,16 @@
     scaleAxisValue(*this, AMOTION_EVENT_AXIS_TOOL_MINOR, scaleFactor);
 }
 
-#ifdef HAVE_ANDROID_OS
+void PointerCoords::applyOffset(float xOffset, float yOffset) {
+    setAxisValue(AMOTION_EVENT_AXIS_X, getX() + xOffset);
+    setAxisValue(AMOTION_EVENT_AXIS_Y, getY() + yOffset);
+}
+
+#ifdef __ANDROID__
 status_t PointerCoords::readFromParcel(Parcel* parcel) {
     bits = parcel->readInt64();
 
-    uint32_t count = __builtin_popcountll(bits);
+    uint32_t count = BitSet64::count(bits);
     if (count > MAX_AXES) {
         return BAD_VALUE;
     }
@@ -231,7 +162,7 @@
 status_t PointerCoords::writeToParcel(Parcel* parcel) const {
     parcel->writeInt64(bits);
 
-    uint32_t count = __builtin_popcountll(bits);
+    uint32_t count = BitSet64::count(bits);
     for (uint32_t i = 0; i < count; i++) {
         parcel->writeFloat(values[i]);
     }
@@ -248,7 +179,7 @@
     if (bits != other.bits) {
         return false;
     }
-    uint32_t count = __builtin_popcountll(bits);
+    uint32_t count = BitSet64::count(bits);
     for (uint32_t i = 0; i < count; i++) {
         if (values[i] != other.values[i]) {
             return false;
@@ -259,7 +190,7 @@
 
 void PointerCoords::copyFrom(const PointerCoords& other) {
     bits = other.bits;
-    uint32_t count = __builtin_popcountll(bits);
+    uint32_t count = BitSet64::count(bits);
     for (uint32_t i = 0; i < count; i++) {
         values[i] = other.values[i];
     }
@@ -285,6 +216,7 @@
         int32_t deviceId,
         int32_t source,
         int32_t action,
+        int32_t actionButton,
         int32_t flags,
         int32_t edgeFlags,
         int32_t metaState,
@@ -300,6 +232,7 @@
         const PointerCoords* pointerCoords) {
     InputEvent::initialize(deviceId, source);
     mAction = action;
+    mActionButton = actionButton;
     mFlags = flags;
     mEdgeFlags = edgeFlags;
     mMetaState = metaState;
@@ -319,6 +252,7 @@
 void MotionEvent::copyFrom(const MotionEvent* other, bool keepHistory) {
     InputEvent::initialize(other->mDeviceId, other->mSource);
     mAction = other->mAction;
+    mActionButton = other->mActionButton;
     mFlags = other->mFlags;
     mEdgeFlags = other->mEdgeFlags;
     mMetaState = other->mMetaState;
@@ -486,17 +420,19 @@
     }
 }
 
-#ifdef HAVE_ANDROID_OS
+#ifdef __ANDROID__
 status_t MotionEvent::readFromParcel(Parcel* parcel) {
     size_t pointerCount = parcel->readInt32();
     size_t sampleCount = parcel->readInt32();
-    if (pointerCount == 0 || pointerCount > MAX_POINTERS || sampleCount == 0) {
+    if (pointerCount == 0 || pointerCount > MAX_POINTERS ||
+            sampleCount == 0 || sampleCount > MAX_SAMPLES) {
         return BAD_VALUE;
     }
 
     mDeviceId = parcel->readInt32();
     mSource = parcel->readInt32();
     mAction = parcel->readInt32();
+    mActionButton = parcel->readInt32();
     mFlags = parcel->readInt32();
     mEdgeFlags = parcel->readInt32();
     mMetaState = parcel->readInt32();
@@ -521,7 +457,8 @@
         properties.toolType = parcel->readInt32();
     }
 
-    while (sampleCount-- > 0) {
+    while (sampleCount > 0) {
+        sampleCount--;
         mSampleEventTimes.push(parcel->readInt64());
         for (size_t i = 0; i < pointerCount; i++) {
             mSamplePointerCoords.push();
@@ -544,6 +481,7 @@
     parcel->writeInt32(mDeviceId);
     parcel->writeInt32(mSource);
     parcel->writeInt32(mAction);
+    parcel->writeInt32(mActionButton);
     parcel->writeInt32(mFlags);
     parcel->writeInt32(mEdgeFlags);
     parcel->writeInt32(mMetaState);
@@ -591,6 +529,14 @@
     return false;
 }
 
+const char* MotionEvent::getLabel(int32_t axis) {
+    return getAxisLabel(axis);
+}
+
+int32_t MotionEvent::getAxisFromLabel(const char* label) {
+    return getAxisByLabel(label);
+}
+
 
 // --- PooledInputEventFactory ---
 
diff --git a/libs/input/InputDevice.cpp b/libs/input/InputDevice.cpp
index b11110a..d755ed3 100644
--- a/libs/input/InputDevice.cpp
+++ b/libs/input/InputDevice.cpp
@@ -127,28 +127,31 @@
 // --- InputDeviceInfo ---
 
 InputDeviceInfo::InputDeviceInfo() {
-    initialize(-1, 0, -1, InputDeviceIdentifier(), String8(), false);
+    initialize(-1, 0, -1, InputDeviceIdentifier(), String8(), false, false);
 }
 
 InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) :
         mId(other.mId), mGeneration(other.mGeneration), mControllerNumber(other.mControllerNumber),
         mIdentifier(other.mIdentifier), mAlias(other.mAlias), mIsExternal(other.mIsExternal),
-        mSources(other.mSources), mKeyboardType(other.mKeyboardType),
-        mKeyCharacterMap(other.mKeyCharacterMap), mHasVibrator(other.mHasVibrator),
-        mHasButtonUnderPad(other.mHasButtonUnderPad), mMotionRanges(other.mMotionRanges) {
+        mHasMic(other.mHasMic), mSources(other.mSources),
+        mKeyboardType(other.mKeyboardType), mKeyCharacterMap(other.mKeyCharacterMap),
+        mHasVibrator(other.mHasVibrator), mHasButtonUnderPad(other.mHasButtonUnderPad),
+        mMotionRanges(other.mMotionRanges) {
 }
 
 InputDeviceInfo::~InputDeviceInfo() {
 }
 
 void InputDeviceInfo::initialize(int32_t id, int32_t generation, int32_t controllerNumber,
-        const InputDeviceIdentifier& identifier, const String8& alias, bool isExternal) {
+        const InputDeviceIdentifier& identifier, const String8& alias, bool isExternal,
+        bool hasMic) {
     mId = id;
     mGeneration = generation;
     mControllerNumber = controllerNumber;
     mIdentifier = identifier;
     mAlias = alias;
     mIsExternal = isExternal;
+    mHasMic = hasMic;
     mSources = 0;
     mKeyboardType = AINPUT_KEYBOARD_TYPE_NONE;
     mHasVibrator = false;
diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp
index 09b2e7c..2dff4e0 100644
--- a/libs/input/InputTransport.cpp
+++ b/libs/input/InputTransport.cpp
@@ -22,6 +22,7 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <inttypes.h>
 #include <math.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -50,6 +51,10 @@
 // Minimum time difference between consecutive samples before attempting to resample.
 static const nsecs_t RESAMPLE_MIN_DELTA = 2 * NANOS_PER_MS;
 
+// Maximum time difference between consecutive samples before attempting to resample
+// by extrapolation.
+static const nsecs_t RESAMPLE_MAX_DELTA = 20 * NANOS_PER_MS;
+
 // Maximum time to predict forward from the last known state, to avoid predicting too
 // far into the future.  This time is further bounded by 50% of the last time delta.
 static const nsecs_t RESAMPLE_MAX_PREDICTION = 8 * NANOS_PER_MS;
@@ -282,6 +287,7 @@
         int32_t deviceId,
         int32_t source,
         int32_t action,
+        int32_t actionButton,
         int32_t flags,
         int32_t edgeFlags,
         int32_t metaState,
@@ -292,17 +298,17 @@
         float yPrecision,
         nsecs_t downTime,
         nsecs_t eventTime,
-        size_t pointerCount,
+        uint32_t pointerCount,
         const PointerProperties* pointerProperties,
         const PointerCoords* pointerCoords) {
 #if DEBUG_TRANSPORT_ACTIONS
     ALOGD("channel '%s' publisher ~ publishMotionEvent: seq=%u, deviceId=%d, source=0x%x, "
-            "action=0x%x, flags=0x%x, edgeFlags=0x%x, metaState=0x%x, buttonState=0x%x, "
-            "xOffset=%f, yOffset=%f, "
+            "action=0x%x, actionButton=0x%08x, flags=0x%x, edgeFlags=0x%x, "
+            "metaState=0x%x, buttonState=0x%x, xOffset=%f, yOffset=%f, "
             "xPrecision=%f, yPrecision=%f, downTime=%lld, eventTime=%lld, "
-            "pointerCount=%d",
+            "pointerCount=%" PRIu32,
             mChannel->getName().string(), seq,
-            deviceId, source, action, flags, edgeFlags, metaState, buttonState,
+            deviceId, source, action, actionButton, flags, edgeFlags, metaState, buttonState,
             xOffset, yOffset, xPrecision, yPrecision, downTime, eventTime, pointerCount);
 #endif
 
@@ -312,7 +318,7 @@
     }
 
     if (pointerCount > MAX_POINTERS || pointerCount < 1) {
-        ALOGE("channel '%s' publisher ~ Invalid number of pointers provided: %d.",
+        ALOGE("channel '%s' publisher ~ Invalid number of pointers provided: %" PRIu32 ".",
                 mChannel->getName().string(), pointerCount);
         return BAD_VALUE;
     }
@@ -323,6 +329,7 @@
     msg.body.motion.deviceId = deviceId;
     msg.body.motion.source = source;
     msg.body.motion.action = action;
+    msg.body.motion.actionButton = actionButton;
     msg.body.motion.flags = flags;
     msg.body.motion.edgeFlags = edgeFlags;
     msg.body.motion.metaState = metaState;
@@ -334,7 +341,7 @@
     msg.body.motion.downTime = downTime;
     msg.body.motion.eventTime = eventTime;
     msg.body.motion.pointerCount = pointerCount;
-    for (size_t i = 0; i < pointerCount; i++) {
+    for (uint32_t i = 0; i < pointerCount; i++) {
         msg.body.motion.pointers[i].properties.copyFrom(pointerProperties[i]);
         msg.body.motion.pointers[i].coords.copyFrom(pointerCoords[i]);
     }
@@ -509,7 +516,8 @@
 status_t InputConsumer::consumeBatch(InputEventFactoryInterface* factory,
         nsecs_t frameTime, uint32_t* outSeq, InputEvent** outEvent) {
     status_t result;
-    for (size_t i = mBatches.size(); i-- > 0; ) {
+    for (size_t i = mBatches.size(); i > 0; ) {
+        i--;
         Batch& batch = mBatches.editItemAt(i);
         if (frameTime < 0) {
             result = consumeSamples(factory, batch, batch.samples.size(),
@@ -654,7 +662,7 @@
 }
 
 void InputConsumer::rewriteMessage(const TouchState& state, InputMessage* msg) {
-    for (size_t i = 0; i < msg->body.motion.pointerCount; i++) {
+    for (uint32_t i = 0; i < msg->body.motion.pointerCount; i++) {
         uint32_t id = msg->body.motion.pointers[i].properties.id;
         if (state.lastResample.idBits.hasBit(id)) {
             PointerCoords& msgCoords = msg->body.motion.pointers[i].coords;
@@ -721,7 +729,7 @@
         nsecs_t delta = future.eventTime - current->eventTime;
         if (delta < RESAMPLE_MIN_DELTA) {
 #if DEBUG_RESAMPLING
-            ALOGD("Not resampled, delta time is %lld ns.", delta);
+            ALOGD("Not resampled, delta time is too small: %lld ns.", delta);
 #endif
             return;
         }
@@ -733,7 +741,12 @@
         nsecs_t delta = current->eventTime - other->eventTime;
         if (delta < RESAMPLE_MIN_DELTA) {
 #if DEBUG_RESAMPLING
-            ALOGD("Not resampled, delta time is %lld ns.", delta);
+            ALOGD("Not resampled, delta time is too small: %lld ns.", delta);
+#endif
+            return;
+        } else if (delta > RESAMPLE_MAX_DELTA) {
+#if DEBUG_RESAMPLING
+            ALOGD("Not resampled, delta time is too large: %lld ns.", delta);
 #endif
             return;
         }
@@ -814,7 +827,8 @@
         uint32_t currentSeq = seq;
         uint32_t chainSeqs[seqChainCount];
         size_t chainIndex = 0;
-        for (size_t i = seqChainCount; i-- > 0; ) {
+        for (size_t i = seqChainCount; i > 0; ) {
+             i--;
              const SeqChain& seqChain = mSeqChains.itemAt(i);
              if (seqChain.seq == currentSeq) {
                  currentSeq = seqChain.chain;
@@ -823,7 +837,8 @@
              }
         }
         status_t status = OK;
-        while (!status && chainIndex-- > 0) {
+        while (!status && chainIndex > 0) {
+            chainIndex--;
             status = sendUnchainedFinishedSignal(chainSeqs[chainIndex], handled);
         }
         if (status) {
@@ -833,7 +848,10 @@
                 seqChain.seq = chainIndex != 0 ? chainSeqs[chainIndex - 1] : seq;
                 seqChain.chain = chainSeqs[chainIndex];
                 mSeqChains.push(seqChain);
-            } while (chainIndex-- > 0);
+                if (chainIndex != 0) {
+                    chainIndex--;
+                }
+            } while (chainIndex > 0);
             return status;
         }
     }
@@ -894,10 +912,10 @@
 }
 
 void InputConsumer::initializeMotionEvent(MotionEvent* event, const InputMessage* msg) {
-    size_t pointerCount = msg->body.motion.pointerCount;
+    uint32_t pointerCount = msg->body.motion.pointerCount;
     PointerProperties pointerProperties[pointerCount];
     PointerCoords pointerCoords[pointerCount];
-    for (size_t i = 0; i < pointerCount; i++) {
+    for (uint32_t i = 0; i < pointerCount; i++) {
         pointerProperties[i].copyFrom(msg->body.motion.pointers[i].properties);
         pointerCoords[i].copyFrom(msg->body.motion.pointers[i].coords);
     }
@@ -906,6 +924,7 @@
             msg->body.motion.deviceId,
             msg->body.motion.source,
             msg->body.motion.action,
+            msg->body.motion.actionButton,
             msg->body.motion.flags,
             msg->body.motion.edgeFlags,
             msg->body.motion.metaState,
@@ -922,9 +941,9 @@
 }
 
 void InputConsumer::addSample(MotionEvent* event, const InputMessage* msg) {
-    size_t pointerCount = msg->body.motion.pointerCount;
+    uint32_t pointerCount = msg->body.motion.pointerCount;
     PointerCoords pointerCoords[pointerCount];
-    for (size_t i = 0; i < pointerCount; i++) {
+    for (uint32_t i = 0; i < pointerCount; i++) {
         pointerCoords[i].copyFrom(msg->body.motion.pointers[i].coords);
     }
 
@@ -934,7 +953,7 @@
 
 bool InputConsumer::canAddSample(const Batch& batch, const InputMessage *msg) {
     const InputMessage& head = batch.samples.itemAt(0);
-    size_t pointerCount = msg->body.motion.pointerCount;
+    uint32_t pointerCount = msg->body.motion.pointerCount;
     if (head.body.motion.pointerCount != pointerCount
             || head.body.motion.action != msg->body.motion.action) {
         return false;
diff --git a/libs/input/KeyCharacterMap.cpp b/libs/input/KeyCharacterMap.cpp
index 15a877447..dd01a93 100644
--- a/libs/input/KeyCharacterMap.cpp
+++ b/libs/input/KeyCharacterMap.cpp
@@ -19,11 +19,12 @@
 #include <stdlib.h>
 #include <string.h>
 
-#if HAVE_ANDROID_OS
+#ifdef __ANDROID__
 #include <binder/Parcel.h>
 #endif
 
 #include <android/keycodes.h>
+#include <input/InputEventLabels.h>
 #include <input/Keyboard.h>
 #include <input/KeyCharacterMap.h>
 
@@ -331,33 +332,75 @@
     if (usageCode) {
         ssize_t index = mKeysByUsageCode.indexOfKey(usageCode);
         if (index >= 0) {
-#if DEBUG_MAPPING
-    ALOGD("mapKey: scanCode=%d, usageCode=0x%08x ~ Result keyCode=%d.",
-            scanCode, usageCode, *outKeyCode);
-#endif
             *outKeyCode = mKeysByUsageCode.valueAt(index);
+#if DEBUG_MAPPING
+            ALOGD("mapKey: scanCode=%d, usageCode=0x%08x ~ Result keyCode=%d.",
+                    scanCode, usageCode, *outKeyCode);
+#endif
             return OK;
         }
     }
     if (scanCode) {
         ssize_t index = mKeysByScanCode.indexOfKey(scanCode);
         if (index >= 0) {
-#if DEBUG_MAPPING
-    ALOGD("mapKey: scanCode=%d, usageCode=0x%08x ~ Result keyCode=%d.",
-            scanCode, usageCode, *outKeyCode);
-#endif
             *outKeyCode = mKeysByScanCode.valueAt(index);
+#if DEBUG_MAPPING
+            ALOGD("mapKey: scanCode=%d, usageCode=0x%08x ~ Result keyCode=%d.",
+                    scanCode, usageCode, *outKeyCode);
+#endif
             return OK;
         }
     }
 
 #if DEBUG_MAPPING
-        ALOGD("mapKey: scanCode=%d, usageCode=0x%08x ~ Failed.", scanCode, usageCode);
+    ALOGD("mapKey: scanCode=%d, usageCode=0x%08x ~ Failed.", scanCode, usageCode);
 #endif
     *outKeyCode = AKEYCODE_UNKNOWN;
     return NAME_NOT_FOUND;
 }
 
+void KeyCharacterMap::tryRemapKey(int32_t keyCode, int32_t metaState,
+                                  int32_t *outKeyCode, int32_t *outMetaState) const {
+    *outKeyCode = keyCode;
+    *outMetaState = metaState;
+
+    const Key* key;
+    const Behavior* behavior;
+    if (getKeyBehavior(keyCode, metaState, &key, &behavior)) {
+        if (behavior->replacementKeyCode) {
+            *outKeyCode = behavior->replacementKeyCode;
+            int32_t newMetaState = metaState & ~behavior->metaState;
+            // Reset dependent meta states.
+            if (behavior->metaState & AMETA_ALT_ON) {
+                newMetaState &= ~(AMETA_ALT_LEFT_ON | AMETA_ALT_RIGHT_ON);
+            }
+            if (behavior->metaState & (AMETA_ALT_LEFT_ON | AMETA_ALT_RIGHT_ON)) {
+                newMetaState &= ~AMETA_ALT_ON;
+            }
+            if (behavior->metaState & AMETA_CTRL_ON) {
+                newMetaState &= ~(AMETA_CTRL_LEFT_ON | AMETA_CTRL_RIGHT_ON);
+            }
+            if (behavior->metaState & (AMETA_CTRL_LEFT_ON | AMETA_CTRL_RIGHT_ON)) {
+                newMetaState &= ~AMETA_CTRL_ON;
+            }
+            if (behavior->metaState & AMETA_SHIFT_ON) {
+                newMetaState &= ~(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_RIGHT_ON);
+            }
+            if (behavior->metaState & (AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_RIGHT_ON)) {
+                newMetaState &= ~AMETA_SHIFT_ON;
+            }
+            // ... and put universal bits back if needed
+            *outMetaState = normalizeMetaState(newMetaState);
+        }
+    }
+
+#if DEBUG_MAPPING
+    ALOGD("tryRemapKey: keyCode=%d, metaState=0x%08x ~ "
+            "replacement keyCode=%d, replacement metaState=0x%08x.",
+            keyCode, metaState, *outKeyCode, *outMetaState);
+#endif
+}
+
 bool KeyCharacterMap::getKey(int32_t keyCode, const Key** outKey) const {
     ssize_t index = mKeys.indexOfKey(keyCode);
     if (index >= 0) {
@@ -556,7 +599,7 @@
     }
 }
 
-#if HAVE_ANDROID_OS
+#ifdef __ANDROID__
 sp<KeyCharacterMap> KeyCharacterMap::readFromParcel(Parcel* parcel) {
     sp<KeyCharacterMap> map = new KeyCharacterMap();
     map->mType = parcel->readInt32();
@@ -583,6 +626,7 @@
             int32_t metaState = parcel->readInt32();
             char16_t character = parcel->readInt32();
             int32_t fallbackKeyCode = parcel->readInt32();
+            int32_t replacementKeyCode = parcel->readInt32();
             if (parcel->errorCheck()) {
                 return NULL;
             }
@@ -591,6 +635,7 @@
             behavior->metaState = metaState;
             behavior->character = character;
             behavior->fallbackKeyCode = fallbackKeyCode;
+            behavior->replacementKeyCode = replacementKeyCode;
             if (lastBehavior) {
                 lastBehavior->next = behavior;
             } else {
@@ -623,6 +668,7 @@
             parcel->writeInt32(behavior->metaState);
             parcel->writeInt32(behavior->character);
             parcel->writeInt32(behavior->fallbackKeyCode);
+            parcel->writeInt32(behavior->replacementKeyCode);
         }
         parcel->writeInt32(0);
     }
@@ -654,13 +700,14 @@
 // --- KeyCharacterMap::Behavior ---
 
 KeyCharacterMap::Behavior::Behavior() :
-        next(NULL), metaState(0), character(0), fallbackKeyCode(0) {
+        next(NULL), metaState(0), character(0), fallbackKeyCode(0), replacementKeyCode(0) {
 }
 
 KeyCharacterMap::Behavior::Behavior(const Behavior& other) :
         next(other.next ? new Behavior(*other.next) : NULL),
         metaState(other.metaState), character(other.character),
-        fallbackKeyCode(other.fallbackKeyCode) {
+        fallbackKeyCode(other.fallbackKeyCode),
+        replacementKeyCode(other.replacementKeyCode) {
 }
 
 
@@ -922,6 +969,7 @@
     Behavior behavior;
     bool haveCharacter = false;
     bool haveFallback = false;
+    bool haveReplacement = false;
 
     do {
         char ch = mTokenizer->peekChar();
@@ -938,6 +986,11 @@
                         mTokenizer->getLocation().string());
                 return BAD_VALUE;
             }
+            if (haveReplacement) {
+                ALOGE("%s: Cannot combine character literal with replace action.",
+                        mTokenizer->getLocation().string());
+                return BAD_VALUE;
+            }
             behavior.character = character;
             haveCharacter = true;
         } else {
@@ -948,6 +1001,11 @@
                             mTokenizer->getLocation().string());
                     return BAD_VALUE;
                 }
+                if (haveReplacement) {
+                    ALOGE("%s: Cannot combine 'none' with replace action.",
+                            mTokenizer->getLocation().string());
+                    return BAD_VALUE;
+                }
                 haveCharacter = true;
             } else if (token == "fallback") {
                 mTokenizer->skipDelimiters(WHITESPACE);
@@ -959,13 +1017,36 @@
                             token.string());
                     return BAD_VALUE;
                 }
-                if (haveFallback) {
-                    ALOGE("%s: Cannot combine multiple fallback key codes.",
+                if (haveFallback || haveReplacement) {
+                    ALOGE("%s: Cannot combine multiple fallback/replacement key codes.",
                             mTokenizer->getLocation().string());
                     return BAD_VALUE;
                 }
                 behavior.fallbackKeyCode = keyCode;
                 haveFallback = true;
+            } else if (token == "replace") {
+                mTokenizer->skipDelimiters(WHITESPACE);
+                token = mTokenizer->nextToken(WHITESPACE);
+                int32_t keyCode = getKeyCodeByLabel(token.string());
+                if (!keyCode) {
+                    ALOGE("%s: Invalid key code label for replace, got '%s'.",
+                            mTokenizer->getLocation().string(),
+                            token.string());
+                    return BAD_VALUE;
+                }
+                if (haveCharacter) {
+                    ALOGE("%s: Cannot combine character literal with replace action.",
+                            mTokenizer->getLocation().string());
+                    return BAD_VALUE;
+                }
+                if (haveFallback || haveReplacement) {
+                    ALOGE("%s: Cannot combine multiple fallback/replacement key codes.",
+                            mTokenizer->getLocation().string());
+                    return BAD_VALUE;
+                }
+                behavior.replacementKeyCode = keyCode;
+                haveReplacement = true;
+
             } else {
                 ALOGE("%s: Expected a key behavior after ':'.",
                         mTokenizer->getLocation().string());
@@ -1015,8 +1096,10 @@
             newBehavior->next = key->firstBehavior;
             key->firstBehavior = newBehavior;
 #if DEBUG_PARSER
-            ALOGD("Parsed key meta: keyCode=%d, meta=0x%x, char=%d, fallback=%d.", mKeyCode,
-                    newBehavior->metaState, newBehavior->character, newBehavior->fallbackKeyCode);
+            ALOGD("Parsed key meta: keyCode=%d, meta=0x%x, char=%d, fallback=%d replace=%d.",
+                    mKeyCode,
+                    newBehavior->metaState, newBehavior->character,
+                    newBehavior->fallbackKeyCode, newBehavior->replacementKeyCode);
 #endif
             break;
         }
diff --git a/libs/input/KeyLayoutMap.cpp b/libs/input/KeyLayoutMap.cpp
index 2f5494b..2b2f13e 100644
--- a/libs/input/KeyLayoutMap.cpp
+++ b/libs/input/KeyLayoutMap.cpp
@@ -19,6 +19,7 @@
 #include <stdlib.h>
 
 #include <android/keycodes.h>
+#include <input/InputEventLabels.h>
 #include <input/Keyboard.h>
 #include <input/KeyLayoutMap.h>
 #include <utils/Log.h>
@@ -150,6 +151,40 @@
     return NO_ERROR;
 }
 
+status_t KeyLayoutMap::findScanCodeForLed(int32_t ledCode, int32_t* outScanCode) const {
+    const size_t N = mLedsByScanCode.size();
+    for (size_t i = 0; i < N; i++) {
+        if (mLedsByScanCode.valueAt(i).ledCode == ledCode) {
+            *outScanCode = mLedsByScanCode.keyAt(i);
+#if DEBUG_MAPPING
+            ALOGD("findScanCodeForLed: ledCode=%d, scanCode=%d.", ledCode, *outScanCode);
+#endif
+            return NO_ERROR;
+        }
+    }
+#if DEBUG_MAPPING
+            ALOGD("findScanCodeForLed: ledCode=%d ~ Not found.", ledCode);
+#endif
+    return NAME_NOT_FOUND;
+}
+
+status_t KeyLayoutMap::findUsageCodeForLed(int32_t ledCode, int32_t* outUsageCode) const {
+    const size_t N = mLedsByUsageCode.size();
+    for (size_t i = 0; i < N; i++) {
+        if (mLedsByUsageCode.valueAt(i).ledCode == ledCode) {
+            *outUsageCode = mLedsByUsageCode.keyAt(i);
+#if DEBUG_MAPPING
+            ALOGD("findUsageForLed: ledCode=%d, usage=%x.", ledCode, *outUsageCode);
+#endif
+            return NO_ERROR;
+        }
+    }
+#if DEBUG_MAPPING
+            ALOGD("findUsageForLed: ledCode=%d ~ Not found.", ledCode);
+#endif
+    return NAME_NOT_FOUND;
+}
+
 
 // --- KeyLayoutMap::Parser ---
 
@@ -179,6 +214,10 @@
                 mTokenizer->skipDelimiters(WHITESPACE);
                 status_t status = parseAxis();
                 if (status) return status;
+            } else if (keywordToken == "led") {
+                mTokenizer->skipDelimiters(WHITESPACE);
+                status_t status = parseLed();
+                if (status) return status;
             } else {
                 ALOGE("%s: Expected keyword, got '%s'.", mTokenizer->getLocation().string(),
                         keywordToken.string());
@@ -215,8 +254,7 @@
                 mapUsage ? "usage" : "scan code", codeToken.string());
         return BAD_VALUE;
     }
-    KeyedVector<int32_t, Key>& map =
-            mapUsage ? mMap->mKeysByUsageCode : mMap->mKeysByScanCode;
+    KeyedVector<int32_t, Key>& map = mapUsage ? mMap->mKeysByUsageCode : mMap->mKeysByScanCode;
     if (map.indexOfKey(code) >= 0) {
         ALOGE("%s: Duplicate entry for key %s '%s'.", mTokenizer->getLocation().string(),
                 mapUsage ? "usage" : "scan code", codeToken.string());
@@ -364,4 +402,46 @@
     return NO_ERROR;
 }
 
+status_t KeyLayoutMap::Parser::parseLed() {
+    String8 codeToken = mTokenizer->nextToken(WHITESPACE);
+    bool mapUsage = false;
+    if (codeToken == "usage") {
+        mapUsage = true;
+        mTokenizer->skipDelimiters(WHITESPACE);
+        codeToken = mTokenizer->nextToken(WHITESPACE);
+    }
+    char* end;
+    int32_t code = int32_t(strtol(codeToken.string(), &end, 0));
+    if (*end) {
+        ALOGE("%s: Expected led %s number, got '%s'.", mTokenizer->getLocation().string(),
+                mapUsage ? "usage" : "scan code", codeToken.string());
+        return BAD_VALUE;
+    }
+
+    KeyedVector<int32_t, Led>& map = mapUsage ? mMap->mLedsByUsageCode : mMap->mLedsByScanCode;
+    if (map.indexOfKey(code) >= 0) {
+        ALOGE("%s: Duplicate entry for led %s '%s'.", mTokenizer->getLocation().string(),
+                mapUsage ? "usage" : "scan code", codeToken.string());
+        return BAD_VALUE;
+    }
+
+    mTokenizer->skipDelimiters(WHITESPACE);
+    String8 ledCodeToken = mTokenizer->nextToken(WHITESPACE);
+    int32_t ledCode = getLedByLabel(ledCodeToken.string());
+    if (ledCode < 0) {
+        ALOGE("%s: Expected LED code label, got '%s'.", mTokenizer->getLocation().string(),
+                ledCodeToken.string());
+        return BAD_VALUE;
+    }
+
+#if DEBUG_PARSER
+    ALOGD("Parsed led %s: code=%d, ledCode=%d.",
+            mapUsage ? "usage" : "scan code", code, ledCode);
+#endif
+
+    Led led;
+    led.ledCode = ledCode;
+    map.add(code, led);
+    return NO_ERROR;
+}
 };
diff --git a/libs/input/Keyboard.cpp b/libs/input/Keyboard.cpp
index b6551ee..9a01395 100644
--- a/libs/input/Keyboard.cpp
+++ b/libs/input/Keyboard.cpp
@@ -21,7 +21,7 @@
 #include <limits.h>
 
 #include <input/Keyboard.h>
-#include <input/KeycodeLabels.h>
+#include <input/InputEventLabels.h>
 #include <input/KeyLayoutMap.h>
 #include <input/KeyCharacterMap.h>
 #include <input/InputDevice.h>
@@ -167,42 +167,6 @@
     return strstr(deviceIdentifier.name.string(), "-keypad");
 }
 
-static int lookupValueByLabel(const char* literal, const KeycodeLabel *list) {
-    while (list->literal) {
-        if (strcmp(literal, list->literal) == 0) {
-            return list->value;
-        }
-        list++;
-    }
-    return list->value;
-}
-
-static const char* lookupLabelByValue(int value, const KeycodeLabel *list) {
-    while (list->literal) {
-        if (list->value == value) {
-            return list->literal;
-        }
-        list++;
-    }
-    return NULL;
-}
-
-int32_t getKeyCodeByLabel(const char* label) {
-    return int32_t(lookupValueByLabel(label, KEYCODES));
-}
-
-uint32_t getKeyFlagByLabel(const char* label) {
-    return uint32_t(lookupValueByLabel(label, FLAGS));
-}
-
-int32_t getAxisByLabel(const char* label) {
-    return int32_t(lookupValueByLabel(label, AXES));
-}
-
-const char* getAxisLabel(int32_t axisId) {
-    return lookupLabelByValue(axisId, AXES);
-}
-
 static int32_t setEphemeralMetaState(int32_t mask, bool down, int32_t oldMetaState) {
     int32_t newMetaState;
     if (down) {
@@ -212,6 +176,11 @@
                 ~(mask | AMETA_ALT_ON | AMETA_SHIFT_ON | AMETA_CTRL_ON | AMETA_META_ON);
     }
 
+    return normalizeMetaState(newMetaState);
+}
+
+int32_t normalizeMetaState(int32_t oldMetaState) {
+    int32_t newMetaState = oldMetaState;
     if (newMetaState & (AMETA_ALT_LEFT_ON | AMETA_ALT_RIGHT_ON)) {
         newMetaState |= AMETA_ALT_ON;
     }
diff --git a/libs/input/VelocityTracker.cpp b/libs/input/VelocityTracker.cpp
index 6c70c3c..7f6b157 100644
--- a/libs/input/VelocityTracker.cpp
+++ b/libs/input/VelocityTracker.cpp
@@ -46,7 +46,8 @@
 
 static float vectorDot(const float* a, const float* b, uint32_t m) {
     float r = 0;
-    while (m--) {
+    while (m) {
+        m--;
         r += *(a++) * *(b++);
     }
     return r;
@@ -54,7 +55,8 @@
 
 static float vectorNorm(const float* a, uint32_t m) {
     float r = 0;
-    while (m--) {
+    while (m) {
+        m--;
         float t = *(a++);
         r += t * t;
     }
@@ -511,7 +513,8 @@
     for (uint32_t h = 0; h < m; h++) {
         wy[h] = y[h] * w[h];
     }
-    for (uint32_t i = n; i-- != 0; ) {
+    for (uint32_t i = n; i != 0; ) {
+        i--;
         outB[i] = vectorDot(&q[i][0], wy, m);
         for (uint32_t j = n - 1; j > i; j--) {
             outB[i] -= r[i][j] * outB[j];
diff --git a/libs/input/tests/Android.mk b/libs/input/tests/Android.mk
index c62dff1..5bfa3d4 100644
--- a/libs/input/tests/Android.mk
+++ b/libs/input/tests/Android.mk
@@ -1,6 +1,5 @@
 # Build the unit tests.
 LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
 
 # Build the unit tests.
 test_src_files := \
@@ -14,14 +13,10 @@
     libutils \
     libbinder \
     libui \
-    libstlport
-
-static_libraries := \
-    libgtest \
-    libgtest_main
 
 $(foreach file,$(test_src_files), \
     $(eval include $(CLEAR_VARS)) \
+    $(eval LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk) \
     $(eval LOCAL_SHARED_LIBRARIES := $(shared_libraries)) \
     $(eval LOCAL_STATIC_LIBRARIES := $(static_libraries)) \
     $(eval LOCAL_SRC_FILES := $(file)) \
@@ -29,5 +24,17 @@
     $(eval include $(BUILD_NATIVE_TEST)) \
 )
 
+# NOTE: This is a compile time test, and does not need to be
+# run. All assertions are static_asserts and will fail during
+# buildtime if something's wrong.
+include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+LOCAL_SRC_FILES := StructLayout_test.cpp
+LOCAL_MODULE := StructLayout_test
+LOCAL_CFLAGS := -std=c++11 -O0
+LOCAL_MULTILIB := both
+include $(BUILD_STATIC_LIBRARY)
+
+
 # Build the manual test programs.
 include $(call all-makefiles-under, $(LOCAL_PATH))
diff --git a/libs/input/tests/InputEvent_test.cpp b/libs/input/tests/InputEvent_test.cpp
index 78ea98e..3fb1c6d 100644
--- a/libs/input/tests/InputEvent_test.cpp
+++ b/libs/input/tests/InputEvent_test.cpp
@@ -53,8 +53,8 @@
 
     // Set first axis.
     ASSERT_EQ(OK, coords.setAxisValue(1, 5));
-    ASSERT_EQ(0x00000002ULL, coords.bits);
     ASSERT_EQ(5, coords.values[0]);
+    ASSERT_EQ(0x4000000000000000ULL, coords.bits);
 
     ASSERT_EQ(0, coords.getAxisValue(0))
             << "getAxisValue should return zero because axis is not present";
@@ -63,7 +63,7 @@
 
     // Set an axis with a higher id than all others.  (appending value at the end)
     ASSERT_EQ(OK, coords.setAxisValue(3, 2));
-    ASSERT_EQ(0x0000000aULL, coords.bits);
+    ASSERT_EQ(0x5000000000000000ULL, coords.bits);
     ASSERT_EQ(5, coords.values[0]);
     ASSERT_EQ(2, coords.values[1]);
 
@@ -78,7 +78,7 @@
 
     // Set an axis with an id lower than all others.  (prepending value at beginning)
     ASSERT_EQ(OK, coords.setAxisValue(0, 4));
-    ASSERT_EQ(0x0000000bULL, coords.bits);
+    ASSERT_EQ(0xd000000000000000ULL, coords.bits);
     ASSERT_EQ(4, coords.values[0]);
     ASSERT_EQ(5, coords.values[1]);
     ASSERT_EQ(2, coords.values[2]);
@@ -94,7 +94,7 @@
 
     // Set an axis with an id between the others.  (inserting value in the middle)
     ASSERT_EQ(OK, coords.setAxisValue(2, 1));
-    ASSERT_EQ(0x0000000fULL, coords.bits);
+    ASSERT_EQ(0xf000000000000000ULL, coords.bits);
     ASSERT_EQ(4, coords.values[0]);
     ASSERT_EQ(5, coords.values[1]);
     ASSERT_EQ(1, coords.values[2]);
@@ -111,7 +111,7 @@
 
     // Set an existing axis value in place.
     ASSERT_EQ(OK, coords.setAxisValue(1, 6));
-    ASSERT_EQ(0x0000000fULL, coords.bits);
+    ASSERT_EQ(0xf000000000000000ULL, coords.bits);
     ASSERT_EQ(4, coords.values[0]);
     ASSERT_EQ(6, coords.values[1]);
     ASSERT_EQ(1, coords.values[2]);
@@ -248,7 +248,7 @@
     pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, 26);
     pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, 27);
     pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, 28);
-    event->initialize(2, AINPUT_SOURCE_TOUCHSCREEN, AMOTION_EVENT_ACTION_MOVE,
+    event->initialize(2, AINPUT_SOURCE_TOUCHSCREEN, AMOTION_EVENT_ACTION_MOVE, 0,
             AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED,
             AMOTION_EVENT_EDGE_FLAG_TOP, AMETA_ALT_ON, AMOTION_EVENT_BUTTON_PRIMARY,
             X_OFFSET, Y_OFFSET, 2.0f, 2.1f,
@@ -557,7 +557,7 @@
         pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, angle);
     }
     MotionEvent event;
-    event.initialize(0, 0, AMOTION_EVENT_ACTION_MOVE, 0, 0, 0, 0,
+    event.initialize(0, 0, AMOTION_EVENT_ACTION_MOVE, 0, 0, 0, 0, 0,
             0, 0, 0, 0, 0, 0, pointerCount, pointerProperties, pointerCoords);
     float originalRawX = 0 + 3;
     float originalRawY = -RADIUS + 2;
diff --git a/libs/input/tests/InputPublisherAndConsumer_test.cpp b/libs/input/tests/InputPublisherAndConsumer_test.cpp
index de192f1..8e69c9c 100644
--- a/libs/input/tests/InputPublisherAndConsumer_test.cpp
+++ b/libs/input/tests/InputPublisherAndConsumer_test.cpp
@@ -133,6 +133,7 @@
     const int32_t deviceId = 1;
     const int32_t source = AINPUT_SOURCE_TOUCHSCREEN;
     const int32_t action = AMOTION_EVENT_ACTION_MOVE;
+    const int32_t actionButton = 0;
     const int32_t flags = AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED;
     const int32_t edgeFlags = AMOTION_EVENT_EDGE_FLAG_TOP;
     const int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON;
@@ -163,8 +164,8 @@
         pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, 3.5 * i);
     }
 
-    status = mPublisher->publishMotionEvent(seq, deviceId, source, action, flags, edgeFlags,
-            metaState, buttonState, xOffset, yOffset, xPrecision, yPrecision,
+    status = mPublisher->publishMotionEvent(seq, deviceId, source, action, actionButton,
+            flags, edgeFlags, metaState, buttonState, xOffset, yOffset, xPrecision, yPrecision,
             downTime, eventTime, pointerCount,
             pointerProperties, pointerCoords);
     ASSERT_EQ(OK, status)
@@ -255,7 +256,7 @@
     PointerProperties pointerProperties[pointerCount];
     PointerCoords pointerCoords[pointerCount];
 
-    status = mPublisher->publishMotionEvent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    status = mPublisher->publishMotionEvent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             pointerCount, pointerProperties, pointerCoords);
     ASSERT_EQ(BAD_VALUE, status)
             << "publisher publishMotionEvent should return BAD_VALUE";
@@ -271,7 +272,7 @@
         pointerCoords[i].clear();
     }
 
-    status = mPublisher->publishMotionEvent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    status = mPublisher->publishMotionEvent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             pointerCount, pointerProperties, pointerCoords);
     ASSERT_EQ(BAD_VALUE, status)
             << "publisher publishMotionEvent should return BAD_VALUE";
diff --git a/libs/input/tests/StructLayout_test.cpp b/libs/input/tests/StructLayout_test.cpp
new file mode 100644
index 0000000..81b9953
--- /dev/null
+++ b/libs/input/tests/StructLayout_test.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <input/InputTransport.h>
+#include <input/Input.h>
+
+namespace android {
+
+#define CHECK_OFFSET(type, member, expected_offset) \
+  static_assert((offsetof(type, member) == (expected_offset)), "")
+
+struct Foo {
+  uint32_t dummy;
+  PointerCoords coords;
+};
+
+void TestPointerCoordsAlignment() {
+  CHECK_OFFSET(Foo, coords, 8);
+}
+
+void TestInputMessageAlignment() {
+  CHECK_OFFSET(InputMessage, body, 8);
+
+  CHECK_OFFSET(InputMessage::Body::Key, seq, 0);
+  CHECK_OFFSET(InputMessage::Body::Key, eventTime, 8);
+  CHECK_OFFSET(InputMessage::Body::Key, deviceId, 16);
+  CHECK_OFFSET(InputMessage::Body::Key, source, 20);
+  CHECK_OFFSET(InputMessage::Body::Key, action, 24);
+  CHECK_OFFSET(InputMessage::Body::Key, flags, 28);
+  CHECK_OFFSET(InputMessage::Body::Key, keyCode, 32);
+  CHECK_OFFSET(InputMessage::Body::Key, scanCode, 36);
+  CHECK_OFFSET(InputMessage::Body::Key, metaState, 40);
+  CHECK_OFFSET(InputMessage::Body::Key, repeatCount, 44);
+  CHECK_OFFSET(InputMessage::Body::Key, downTime, 48);
+
+  CHECK_OFFSET(InputMessage::Body::Motion, seq, 0);
+  CHECK_OFFSET(InputMessage::Body::Motion, eventTime, 8);
+  CHECK_OFFSET(InputMessage::Body::Motion, deviceId, 16);
+  CHECK_OFFSET(InputMessage::Body::Motion, source, 20);
+  CHECK_OFFSET(InputMessage::Body::Motion, action, 24);
+  CHECK_OFFSET(InputMessage::Body::Motion, actionButton, 28);
+  CHECK_OFFSET(InputMessage::Body::Motion, flags, 32);
+  CHECK_OFFSET(InputMessage::Body::Motion, metaState, 36);
+  CHECK_OFFSET(InputMessage::Body::Motion, buttonState, 40);
+  CHECK_OFFSET(InputMessage::Body::Motion, edgeFlags, 44);
+  CHECK_OFFSET(InputMessage::Body::Motion, downTime, 48);
+  CHECK_OFFSET(InputMessage::Body::Motion, xOffset, 56);
+  CHECK_OFFSET(InputMessage::Body::Motion, yOffset, 60);
+  CHECK_OFFSET(InputMessage::Body::Motion, xPrecision, 64);
+  CHECK_OFFSET(InputMessage::Body::Motion, yPrecision, 68);
+  CHECK_OFFSET(InputMessage::Body::Motion, pointerCount, 72);
+  CHECK_OFFSET(InputMessage::Body::Motion, pointers, 80);
+}
+
+} // namespace android
diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk
index 008446b..54ff741 100644
--- a/libs/ui/Android.mk
+++ b/libs/ui/Android.mk
@@ -12,12 +12,32 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-LOCAL_PATH:= $(call my-dir)
+LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES:= \
+LOCAL_CLANG := true
+LOCAL_CPPFLAGS := -std=c++1y -Weverything -Werror
+LOCAL_SANITIZE := integer
+
+# The static constructors and destructors in this library have not been noted to
+# introduce significant overheads
+LOCAL_CPPFLAGS += -Wno-exit-time-destructors
+LOCAL_CPPFLAGS += -Wno-global-constructors
+
+# We only care about compiling as C++14
+LOCAL_CPPFLAGS += -Wno-c++98-compat-pedantic
+
+# We use four-character constants for the GraphicBuffer header, and don't care
+# that they're non-portable as long as they're consistent within one execution
+LOCAL_CPPFLAGS += -Wno-four-char-constants
+
+# Don't warn about struct padding
+LOCAL_CPPFLAGS += -Wno-padded
+
+LOCAL_SRC_FILES := \
 	Fence.cpp \
 	FramebufferNativeWindow.cpp \
+	FrameStats.cpp \
 	GraphicBuffer.cpp \
 	GraphicBufferAllocator.cpp \
 	GraphicBufferMapper.cpp \
@@ -37,7 +57,7 @@
 LOCAL_CFLAGS += -DFRAMEBUFFER_FORCE_FORMAT=$(BOARD_FRAMEBUFFER_FORCE_FORMAT)
 endif
 
-LOCAL_MODULE:= libui
+LOCAL_MODULE := libui
 
 include $(BUILD_SHARED_LIBRARY)
 
diff --git a/libs/ui/Fence.cpp b/libs/ui/Fence.cpp
index 3c0306c..bf24ffb 100644
--- a/libs/ui/Fence.cpp
+++ b/libs/ui/Fence.cpp
@@ -18,10 +18,13 @@
 #define ATRACE_TAG ATRACE_TAG_GRAPHICS
 //#define LOG_NDEBUG 0
 
- // This is needed for stdint.h to define INT64_MAX in C++
- #define __STDC_LIMIT_MACROS
-
+// We would eliminate the non-conforming zero-length array, but we can't since
+// this is effectively included from the Linux kernel
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wzero-length-array"
 #include <sync/sync.h>
+#pragma clang diagnostic pop
+
 #include <ui/Fence.h>
 #include <unistd.h>
 #include <utils/Log.h>
@@ -45,7 +48,7 @@
     }
 }
 
-status_t Fence::wait(unsigned int timeout) {
+status_t Fence::wait(int timeout) {
     ATRACE_CALL();
     if (mFenceFd == -1) {
         return NO_ERROR;
@@ -59,7 +62,7 @@
     if (mFenceFd == -1) {
         return NO_ERROR;
     }
-    unsigned int warningTimeout = 3000;
+    int warningTimeout = 3000;
     int err = sync_wait(mFenceFd, warningTimeout);
     if (err < 0 && errno == ETIME) {
         ALOGE("%s: fence %d didn't signal in %u ms", logname, mFenceFd,
@@ -127,7 +130,7 @@
 }
 
 size_t Fence::getFlattenedSize() const {
-    return 1;
+    return 4;
 }
 
 size_t Fence::getFdCount() const {
@@ -138,7 +141,9 @@
     if (size < getFlattenedSize() || count < getFdCount()) {
         return NO_MEMORY;
     }
-    FlattenableUtils::write(buffer, size, (uint32_t)getFdCount());
+    // Cast to uint32_t since the size of a size_t can vary between 32- and
+    // 64-bit processes
+    FlattenableUtils::write(buffer, size, static_cast<uint32_t>(getFdCount()));
     if (isValid()) {
         *fds++ = mFenceFd;
         count--;
diff --git a/libs/ui/FrameStats.cpp b/libs/ui/FrameStats.cpp
new file mode 100644
index 0000000..acbe27e
--- /dev/null
+++ b/libs/ui/FrameStats.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <ui/FrameStats.h>
+
+namespace android {
+
+bool FrameStats::isFixedSize() const {
+    return false;
+}
+
+size_t FrameStats::getFlattenedSize() const {
+    const size_t timestampSize = sizeof(nsecs_t);
+
+    size_t size = timestampSize;
+    size += 3 * desiredPresentTimesNano.size() * timestampSize;
+
+    return size;
+}
+
+status_t FrameStats::flatten(void* buffer, size_t size) const {
+    if (size < getFlattenedSize()) {
+        return NO_MEMORY;
+    }
+
+    nsecs_t* timestamps = reinterpret_cast<nsecs_t*>(buffer);
+    const size_t timestampSize = sizeof(nsecs_t);
+    size_t frameCount = desiredPresentTimesNano.size();
+
+    memcpy(timestamps, &refreshPeriodNano, timestampSize);
+    timestamps += 1;
+
+    memcpy(timestamps, desiredPresentTimesNano.array(), frameCount * timestampSize);
+    timestamps += frameCount;
+
+    memcpy(timestamps, actualPresentTimesNano.array(), frameCount * timestampSize);
+    timestamps += frameCount;
+
+    memcpy(timestamps, frameReadyTimesNano.array(), frameCount * timestampSize);
+
+    return NO_ERROR;
+}
+
+status_t FrameStats::unflatten(void const* buffer, size_t size) {
+    const size_t timestampSize = sizeof(nsecs_t);
+
+    if (size < timestampSize) {
+        return NO_MEMORY;
+    }
+
+    nsecs_t const* timestamps = reinterpret_cast<nsecs_t const*>(buffer);
+    size_t frameCount = (size - timestampSize) / (3 * timestampSize);
+
+    memcpy(&refreshPeriodNano, timestamps, timestampSize);
+    timestamps += 1;
+
+    desiredPresentTimesNano.resize(frameCount);
+    memcpy(desiredPresentTimesNano.editArray(), timestamps, frameCount * timestampSize);
+    timestamps += frameCount;
+
+    actualPresentTimesNano.resize(frameCount);
+    memcpy(actualPresentTimesNano.editArray(), timestamps, frameCount * timestampSize);
+    timestamps += frameCount;
+
+    frameReadyTimesNano.resize(frameCount);
+    memcpy(frameReadyTimesNano.editArray(), timestamps, frameCount * timestampSize);
+
+    return NO_ERROR;
+}
+
+} // namespace android
diff --git a/libs/ui/FramebufferNativeWindow.cpp b/libs/ui/FramebufferNativeWindow.cpp
index 918f2e7..3ead25c 100644
--- a/libs/ui/FramebufferNativeWindow.cpp
+++ b/libs/ui/FramebufferNativeWindow.cpp
@@ -1,17 +1,17 @@
-/* 
+/*
 **
 ** Copyright 2007 The Android Open Source Project
 **
-** Licensed under the Apache License Version 2.0(the "License"); 
-** you may not use this file except in compliance with the License. 
-** You may obtain a copy of the License at 
+** Licensed under the Apache License Version 2.0(the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
 **
-**     http://www.apache.org/licenses/LICENSE-2.0 
+**     http://www.apache.org/licenses/LICENSE-2.0
 **
-** Unless required by applicable law or agreed to in writing software 
-** distributed under the License is distributed on an "AS IS" BASIS 
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied. 
-** See the License for the specific language governing permissions and 
+** Unless required by applicable law or agreed to in writing software
+** distributed under the License is distributed on an "AS IS" BASIS
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
+** See the License for the specific language governing permissions and
 ** limitations under the License.
 */
 
@@ -29,7 +29,9 @@
 
 #include <ui/ANativeObjectBase.h>
 #include <ui/Fence.h>
+#define INCLUDED_FROM_FRAMEBUFFER_NATIVE_WINDOW_CPP
 #include <ui/FramebufferNativeWindow.h>
+#undef INCLUDED_FROM_FRAMEBUFFER_NATIVE_WINDOW_CPP
 #include <ui/Rect.h>
 
 #include <EGL/egl.h>
@@ -41,11 +43,11 @@
 namespace android {
 // ----------------------------------------------------------------------------
 
-class NativeBuffer 
+class NativeBuffer final
     : public ANativeObjectBase<
-        ANativeWindowBuffer, 
-        NativeBuffer, 
-        LightRefBase<NativeBuffer> >
+        ANativeWindowBuffer,
+        NativeBuffer,
+        LightRefBase<NativeBuffer>>
 {
 public:
     NativeBuffer(int w, int h, int f, int u) : BASE() {
@@ -55,43 +57,41 @@
         ANativeWindowBuffer::usage  = u;
     }
 private:
-    friend class LightRefBase<NativeBuffer>;    
-    ~NativeBuffer() { }; // this class cannot be overloaded
+    friend class LightRefBase<NativeBuffer>;
 };
 
 
 /*
  * This implements the (main) framebuffer management. This class is used
  * mostly by SurfaceFlinger, but also by command line GL application.
- * 
+ *
  * In fact this is an implementation of ANativeWindow on top of
  * the framebuffer.
- * 
- * Currently it is pretty simple, it manages only two buffers (the front and 
+ *
+ * Currently it is pretty simple, it manages only two buffers (the front and
  * back buffer).
- * 
+ *
  */
 
-FramebufferNativeWindow::FramebufferNativeWindow() 
+FramebufferNativeWindow::FramebufferNativeWindow()
     : BASE(), fbDev(0), grDev(0), mUpdateOnDemand(false)
 {
     hw_module_t const* module;
     if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) {
-        int stride;
         int err;
         int i;
         err = framebuffer_open(module, &fbDev);
         ALOGE_IF(err, "couldn't open framebuffer HAL (%s)", strerror(-err));
-        
+
         err = gralloc_open(module, &grDev);
         ALOGE_IF(err, "couldn't open gralloc HAL (%s)", strerror(-err));
 
         // bail out if we can't initialize the modules
         if (!fbDev || !grDev)
             return;
-        
+
         mUpdateOnDemand = (fbDev->setUpdateRect != 0);
-        
+
         // initialize the buffer FIFO
         if(fbDev->numFramebuffers >= MIN_NUM_FRAME_BUFFERS &&
            fbDev->numFramebuffers <= MAX_NUM_FRAME_BUFFERS){
@@ -114,36 +114,37 @@
         *((uint32_t *)&fbDev->format) = FRAMEBUFFER_FORCE_FORMAT;
 #endif
 
-        for (i = 0; i < mNumBuffers; i++)
-        {
-                buffers[i] = new NativeBuffer(
-                        fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB);
+        for (i = 0; i < mNumBuffers; i++) {
+            buffers[i] = new NativeBuffer(
+                    static_cast<int>(fbDev->width),
+                    static_cast<int>(fbDev->height),
+                    fbDev->format, GRALLOC_USAGE_HW_FB);
         }
 
-        for (i = 0; i < mNumBuffers; i++)
-        {
-                err = grDev->alloc(grDev,
-                        fbDev->width, fbDev->height, fbDev->format,
-                        GRALLOC_USAGE_HW_FB, &buffers[i]->handle, &buffers[i]->stride);
+        for (i = 0; i < mNumBuffers; i++) {
+            err = grDev->alloc(grDev,
+                    static_cast<int>(fbDev->width),
+                    static_cast<int>(fbDev->height),
+                    fbDev->format, GRALLOC_USAGE_HW_FB,
+                    &buffers[i]->handle, &buffers[i]->stride);
 
-                ALOGE_IF(err, "fb buffer %d allocation failed w=%d, h=%d, err=%s",
-                        i, fbDev->width, fbDev->height, strerror(-err));
+            ALOGE_IF(err, "fb buffer %d allocation failed w=%d, h=%d, err=%s",
+                    i, fbDev->width, fbDev->height, strerror(-err));
 
-                if (err)
-                {
-                        mNumBuffers = i;
-                        mNumFreeBuffers = i;
-                        mBufferHead = mNumBuffers-1;
-                        break;
-                }
+            if (err) {
+                mNumBuffers = i;
+                mNumFreeBuffers = i;
+                mBufferHead = mNumBuffers-1;
+                break;
+            }
         }
 
-        const_cast<uint32_t&>(ANativeWindow::flags) = fbDev->flags; 
+        const_cast<uint32_t&>(ANativeWindow::flags) = fbDev->flags;
         const_cast<float&>(ANativeWindow::xdpi) = fbDev->xdpi;
         const_cast<float&>(ANativeWindow::ydpi) = fbDev->ydpi;
-        const_cast<int&>(ANativeWindow::minSwapInterval) = 
+        const_cast<int&>(ANativeWindow::minSwapInterval) =
             fbDev->minSwapInterval;
-        const_cast<int&>(ANativeWindow::maxSwapInterval) = 
+        const_cast<int&>(ANativeWindow::maxSwapInterval) =
             fbDev->maxSwapInterval;
     } else {
         ALOGE("Couldn't get gralloc module");
@@ -160,7 +161,7 @@
     ANativeWindow::queueBuffer_DEPRECATED = queueBuffer_DEPRECATED;
 }
 
-FramebufferNativeWindow::~FramebufferNativeWindow() 
+FramebufferNativeWindow::~FramebufferNativeWindow()
 {
     if (grDev) {
         for(int i = 0; i < mNumBuffers; i++) {
@@ -176,7 +177,7 @@
     }
 }
 
-status_t FramebufferNativeWindow::setUpdateRectangle(const Rect& r) 
+status_t FramebufferNativeWindow::setUpdateRectangle(const Rect& r)
 {
     if (!mUpdateOnDemand) {
         return INVALID_OPERATION;
@@ -193,7 +194,7 @@
 }
 
 int FramebufferNativeWindow::setSwapInterval(
-        ANativeWindow* window, int interval) 
+        ANativeWindow* window, int interval)
 {
     framebuffer_device_t* fb = getSelf(window)->fbDev;
     return fb->setSwapInterval(fb, interval);
@@ -217,7 +218,7 @@
     return index;
 }
 
-int FramebufferNativeWindow::dequeueBuffer_DEPRECATED(ANativeWindow* window, 
+int FramebufferNativeWindow::dequeueBuffer_DEPRECATED(ANativeWindow* window,
         ANativeWindowBuffer** buffer)
 {
     int fenceFd = -1;
@@ -232,12 +233,11 @@
     return result;
 }
 
-int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window, 
+int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window,
         ANativeWindowBuffer** buffer, int* fenceFd)
 {
     FramebufferNativeWindow* self = getSelf(window);
     Mutex::Autolock _l(self->mutex);
-    framebuffer_device_t* fb = self->fbDev;
 
     int index = self->mBufferHead++;
     if (self->mBufferHead >= self->mNumBuffers)
@@ -247,7 +247,7 @@
     while (self->mNumFreeBuffers < 2) {
         self->mCondition.wait(self->mutex);
     }
-    ALOG_ASSERT(self->buffers[index] != self->front);
+    ALOG_ASSERT(self->buffers[index] != self->front, "");
 
     // get this buffer
     self->mNumFreeBuffers--;
@@ -259,19 +259,19 @@
     return 0;
 }
 
-int FramebufferNativeWindow::lockBuffer_DEPRECATED(ANativeWindow* /*window*/, 
+int FramebufferNativeWindow::lockBuffer_DEPRECATED(ANativeWindow* /*window*/,
         ANativeWindowBuffer* /*buffer*/)
 {
     return NO_ERROR;
 }
 
-int FramebufferNativeWindow::queueBuffer_DEPRECATED(ANativeWindow* window, 
+int FramebufferNativeWindow::queueBuffer_DEPRECATED(ANativeWindow* window,
         ANativeWindowBuffer* buffer)
 {
     return queueBuffer(window, buffer, -1);
 }
 
-int FramebufferNativeWindow::queueBuffer(ANativeWindow* window, 
+int FramebufferNativeWindow::queueBuffer(ANativeWindow* window,
         ANativeWindowBuffer* buffer, int fenceFd)
 {
     FramebufferNativeWindow* self = getSelf(window);
@@ -282,7 +282,6 @@
     sp<Fence> fence(new Fence(fenceFd));
     fence->wait(Fence::TIMEOUT_NEVER);
 
-    const int index = self->mCurrentBufferIndex;
     int res = fb->post(fb, handle);
     self->front = static_cast<NativeBuffer*>(buffer);
     self->mNumFreeBuffers++;
@@ -291,17 +290,17 @@
 }
 
 int FramebufferNativeWindow::query(const ANativeWindow* window,
-        int what, int* value) 
+        int what, int* value)
 {
     const FramebufferNativeWindow* self = getSelf(window);
     Mutex::Autolock _l(self->mutex);
     framebuffer_device_t* fb = self->fbDev;
     switch (what) {
         case NATIVE_WINDOW_WIDTH:
-            *value = fb->width;
+            *value = static_cast<int>(fb->width);
             return NO_ERROR;
         case NATIVE_WINDOW_HEIGHT:
-            *value = fb->height;
+            *value = static_cast<int>(fb->height);
             return NO_ERROR;
         case NATIVE_WINDOW_FORMAT:
             *value = fb->format;
@@ -313,10 +312,10 @@
             *value = 0;
             return NO_ERROR;
         case NATIVE_WINDOW_DEFAULT_WIDTH:
-            *value = fb->width;
+            *value = static_cast<int>(fb->width);
             return NO_ERROR;
         case NATIVE_WINDOW_DEFAULT_HEIGHT:
-            *value = fb->height;
+            *value = static_cast<int>(fb->height);
             return NO_ERROR;
         case NATIVE_WINDOW_TRANSFORM_HINT:
             *value = 0;
@@ -357,7 +356,8 @@
 }; // namespace android
 // ----------------------------------------------------------------------------
 
-using namespace android;
+using android::sp;
+using android::FramebufferNativeWindow;
 
 EGLNativeWindowType android_createDisplaySurface(void)
 {
@@ -368,5 +368,5 @@
         sp<FramebufferNativeWindow> ref(w);
         return NULL;
     }
-    return (EGLNativeWindowType)w;
+    return static_cast<EGLNativeWindowType>(w);
 }
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp
index 96a7188..e55db30 100644
--- a/libs/ui/GraphicBuffer.cpp
+++ b/libs/ui/GraphicBuffer.cpp
@@ -34,50 +34,58 @@
 // Buffer and implementation of ANativeWindowBuffer
 // ===========================================================================
 
+static uint64_t getUniqueId() {
+    static volatile int32_t nextId = 0;
+    uint64_t id = static_cast<uint64_t>(getpid()) << 32;
+    id |= static_cast<uint32_t>(android_atomic_inc(&nextId));
+    return id;
+}
+
 GraphicBuffer::GraphicBuffer()
     : BASE(), mOwner(ownData), mBufferMapper(GraphicBufferMapper::get()),
-      mInitCheck(NO_ERROR) {
-    width  = 
-    height = 
-    stride = 
-    format = 
-    usage  = 0;
-    handle = NULL;
-}
-
-GraphicBuffer::GraphicBuffer(uint32_t w, uint32_t h, 
-        PixelFormat reqFormat, uint32_t reqUsage)
-    : BASE(), mOwner(ownData), mBufferMapper(GraphicBufferMapper::get()),
-      mInitCheck(NO_ERROR)
+      mInitCheck(NO_ERROR), mId(getUniqueId())
 {
-    width  = 
-    height = 
-    stride = 
-    format = 
+    width  =
+    height =
+    stride =
+    format =
     usage  = 0;
     handle = NULL;
-    mInitCheck = initSize(w, h, reqFormat, reqUsage);
 }
 
-GraphicBuffer::GraphicBuffer(uint32_t w, uint32_t h,
-        PixelFormat inFormat, uint32_t inUsage,
-        uint32_t inStride, native_handle_t* inHandle, bool keepOwnership)
+GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight,
+        PixelFormat inFormat, uint32_t inUsage)
+    : BASE(), mOwner(ownData), mBufferMapper(GraphicBufferMapper::get()),
+      mInitCheck(NO_ERROR), mId(getUniqueId())
+{
+    width  =
+    height =
+    stride =
+    format =
+    usage  = 0;
+    handle = NULL;
+    mInitCheck = initSize(inWidth, inHeight, inFormat, inUsage);
+}
+
+GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight,
+        PixelFormat inFormat, uint32_t inUsage, uint32_t inStride,
+        native_handle_t* inHandle, bool keepOwnership)
     : BASE(), mOwner(keepOwnership ? ownHandle : ownNone),
       mBufferMapper(GraphicBufferMapper::get()),
-      mInitCheck(NO_ERROR)
+      mInitCheck(NO_ERROR), mId(getUniqueId())
 {
-    width  = w;
-    height = h;
-    stride = inStride;
+    width  = static_cast<int>(inWidth);
+    height = static_cast<int>(inHeight);
+    stride = static_cast<int>(inStride);
     format = inFormat;
-    usage  = inUsage;
+    usage  = static_cast<int>(inUsage);
     handle = inHandle;
 }
 
 GraphicBuffer::GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership)
     : BASE(), mOwner(keepOwnership ? ownHandle : ownNone),
       mBufferMapper(GraphicBufferMapper::get()),
-      mInitCheck(NO_ERROR), mWrappedBuffer(buffer)
+      mInitCheck(NO_ERROR), mWrappedBuffer(buffer), mId(getUniqueId())
 {
     width  = buffer->width;
     height = buffer->height;
@@ -108,7 +116,7 @@
 }
 
 status_t GraphicBuffer::initCheck() const {
-    return mInitCheck;
+    return static_cast<status_t>(mInitCheck);
 }
 
 void GraphicBuffer::dumpAllocationsToSystemLog()
@@ -118,17 +126,22 @@
 
 ANativeWindowBuffer* GraphicBuffer::getNativeBuffer() const
 {
+    LOG_ALWAYS_FATAL_IF(this == NULL, "getNativeBuffer() called on NULL GraphicBuffer");
     return static_cast<ANativeWindowBuffer*>(
             const_cast<GraphicBuffer*>(this));
 }
 
-status_t GraphicBuffer::reallocate(uint32_t w, uint32_t h, PixelFormat f,
-        uint32_t reqUsage)
+status_t GraphicBuffer::reallocate(uint32_t inWidth, uint32_t inHeight,
+        PixelFormat inFormat, uint32_t inUsage)
 {
     if (mOwner != ownData)
         return INVALID_OPERATION;
 
-    if (handle && w==width && h==height && f==format && reqUsage==usage)
+    if (handle &&
+            static_cast<int>(inWidth) == width &&
+            static_cast<int>(inHeight) == height &&
+            inFormat == format &&
+            static_cast<int>(inUsage) == usage)
         return NO_ERROR;
 
     if (handle) {
@@ -136,61 +149,74 @@
         allocator.free(handle);
         handle = 0;
     }
-    return initSize(w, h, f, reqUsage);
+    return initSize(inWidth, inHeight, inFormat, inUsage);
 }
 
-status_t GraphicBuffer::initSize(uint32_t w, uint32_t h, PixelFormat format,
-        uint32_t reqUsage)
+bool GraphicBuffer::needsReallocation(uint32_t inWidth, uint32_t inHeight,
+        PixelFormat inFormat, uint32_t inUsage)
+{
+    if (static_cast<int>(inWidth) != width) return true;
+    if (static_cast<int>(inHeight) != height) return true;
+    if (inFormat != format) return true;
+    if ((static_cast<uint32_t>(usage) & inUsage) != inUsage) return true;
+    return false;
+}
+
+status_t GraphicBuffer::initSize(uint32_t inWidth, uint32_t inHeight,
+        PixelFormat inFormat, uint32_t inUsage)
 {
     GraphicBufferAllocator& allocator = GraphicBufferAllocator::get();
-    status_t err = allocator.alloc(w, h, format, reqUsage, &handle, &stride);
+    uint32_t outStride = 0;
+    status_t err = allocator.alloc(inWidth, inHeight, inFormat, inUsage,
+            &handle, &outStride);
     if (err == NO_ERROR) {
-        this->width  = w;
-        this->height = h;
-        this->format = format;
-        this->usage  = reqUsage;
+        width = static_cast<int>(inWidth);
+        height = static_cast<int>(inHeight);
+        format = inFormat;
+        usage = static_cast<int>(inUsage);
+        stride = static_cast<int>(outStride);
     }
     return err;
 }
 
-status_t GraphicBuffer::lock(uint32_t usage, void** vaddr)
+status_t GraphicBuffer::lock(uint32_t inUsage, void** vaddr)
 {
     const Rect lockBounds(width, height);
-    status_t res = lock(usage, lockBounds, vaddr);
+    status_t res = lock(inUsage, lockBounds, vaddr);
     return res;
 }
 
-status_t GraphicBuffer::lock(uint32_t usage, const Rect& rect, void** vaddr)
+status_t GraphicBuffer::lock(uint32_t inUsage, const Rect& rect, void** vaddr)
 {
-    if (rect.left < 0 || rect.right  > this->width || 
-        rect.top  < 0 || rect.bottom > this->height) {
-        ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
-                rect.left, rect.top, rect.right, rect.bottom, 
-                this->width, this->height);
-        return BAD_VALUE;
-    }
-    status_t res = getBufferMapper().lock(handle, usage, rect, vaddr);
-    return res;
-}
-
-status_t GraphicBuffer::lockYCbCr(uint32_t usage, android_ycbcr *ycbcr)
-{
-    const Rect lockBounds(width, height);
-    status_t res = lockYCbCr(usage, lockBounds, ycbcr);
-    return res;
-}
-
-status_t GraphicBuffer::lockYCbCr(uint32_t usage, const Rect& rect,
-        android_ycbcr *ycbcr)
-{
-    if (rect.left < 0 || rect.right  > this->width ||
-        rect.top  < 0 || rect.bottom > this->height) {
+    if (rect.left < 0 || rect.right  > width ||
+        rect.top  < 0 || rect.bottom > height) {
         ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
                 rect.left, rect.top, rect.right, rect.bottom,
-                this->width, this->height);
+                width, height);
         return BAD_VALUE;
     }
-    status_t res = getBufferMapper().lockYCbCr(handle, usage, rect, ycbcr);
+    status_t res = getBufferMapper().lock(handle, inUsage, rect, vaddr);
+    return res;
+}
+
+status_t GraphicBuffer::lockYCbCr(uint32_t inUsage, android_ycbcr* ycbcr)
+{
+    const Rect lockBounds(width, height);
+    status_t res = lockYCbCr(inUsage, lockBounds, ycbcr);
+    return res;
+}
+
+status_t GraphicBuffer::lockYCbCr(uint32_t inUsage, const Rect& rect,
+        android_ycbcr* ycbcr)
+{
+    if (rect.left < 0 || rect.right  > width ||
+        rect.top  < 0 || rect.bottom > height) {
+        ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
+                rect.left, rect.top, rect.right, rect.bottom,
+                width, height);
+        return BAD_VALUE;
+    }
+    status_t res = getBufferMapper().lockYCbCr(handle, inUsage, rect, ycbcr);
     return res;
 }
 
@@ -200,12 +226,63 @@
     return res;
 }
 
+status_t GraphicBuffer::lockAsync(uint32_t inUsage, void** vaddr, int fenceFd)
+{
+    const Rect lockBounds(width, height);
+    status_t res = lockAsync(inUsage, lockBounds, vaddr, fenceFd);
+    return res;
+}
+
+status_t GraphicBuffer::lockAsync(uint32_t inUsage, const Rect& rect,
+        void** vaddr, int fenceFd)
+{
+    if (rect.left < 0 || rect.right  > width ||
+        rect.top  < 0 || rect.bottom > height) {
+        ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
+                rect.left, rect.top, rect.right, rect.bottom,
+                width, height);
+        return BAD_VALUE;
+    }
+    status_t res = getBufferMapper().lockAsync(handle, inUsage, rect, vaddr,
+            fenceFd);
+    return res;
+}
+
+status_t GraphicBuffer::lockAsyncYCbCr(uint32_t inUsage, android_ycbcr* ycbcr,
+        int fenceFd)
+{
+    const Rect lockBounds(width, height);
+    status_t res = lockAsyncYCbCr(inUsage, lockBounds, ycbcr, fenceFd);
+    return res;
+}
+
+status_t GraphicBuffer::lockAsyncYCbCr(uint32_t inUsage, const Rect& rect,
+        android_ycbcr* ycbcr, int fenceFd)
+{
+    if (rect.left < 0 || rect.right  > width ||
+        rect.top  < 0 || rect.bottom > height) {
+        ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
+                rect.left, rect.top, rect.right, rect.bottom,
+                width, height);
+        return BAD_VALUE;
+    }
+    status_t res = getBufferMapper().lockAsyncYCbCr(handle, inUsage, rect,
+            ycbcr, fenceFd);
+    return res;
+}
+
+status_t GraphicBuffer::unlockAsync(int *fenceFd)
+{
+    status_t res = getBufferMapper().unlockAsync(handle, fenceFd);
+    return res;
+}
+
 size_t GraphicBuffer::getFlattenedSize() const {
-    return (8 + (handle ? handle->numInts : 0))*sizeof(int);
+    return static_cast<size_t>(11 + (handle ? handle->numInts : 0)) * sizeof(int);
 }
 
 size_t GraphicBuffer::getFdCount() const {
-    return handle ? handle->numFds : 0;
+    return static_cast<size_t>(handle ? handle->numFds : 0);
 }
 
 status_t GraphicBuffer::flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const {
@@ -215,46 +292,65 @@
     size_t fdCountNeeded = GraphicBuffer::getFdCount();
     if (count < fdCountNeeded) return NO_MEMORY;
 
-    int* buf = static_cast<int*>(buffer);
+    int32_t* buf = static_cast<int32_t*>(buffer);
     buf[0] = 'GBFR';
     buf[1] = width;
     buf[2] = height;
     buf[3] = stride;
     buf[4] = format;
     buf[5] = usage;
-    buf[6] = 0;
-    buf[7] = 0;
+    buf[6] = static_cast<int32_t>(mId >> 32);
+    buf[7] = static_cast<int32_t>(mId & 0xFFFFFFFFull);
+    buf[8] = static_cast<int32_t>(mGenerationNumber);
+    buf[9] = 0;
+    buf[10] = 0;
 
     if (handle) {
-        buf[6] = handle->numFds;
-        buf[7] = handle->numInts;
-        native_handle_t const* const h = handle;
-        memcpy(fds,     h->data,             h->numFds*sizeof(int));
-        memcpy(&buf[8], h->data + h->numFds, h->numInts*sizeof(int));
+        buf[9] = handle->numFds;
+        buf[10] = handle->numInts;
+        memcpy(fds, handle->data,
+                static_cast<size_t>(handle->numFds) * sizeof(int));
+        memcpy(&buf[11], handle->data + handle->numFds,
+                static_cast<size_t>(handle->numInts) * sizeof(int));
     }
 
-    buffer = reinterpret_cast<void*>(static_cast<int*>(buffer) + sizeNeeded);
+    buffer = static_cast<void*>(static_cast<uint8_t*>(buffer) + sizeNeeded);
     size -= sizeNeeded;
-    fds += handle->numFds;
-    count -= handle->numFds;
+    if (handle) {
+        fds += handle->numFds;
+        count -= static_cast<size_t>(handle->numFds);
+    }
 
     return NO_ERROR;
 }
 
 status_t GraphicBuffer::unflatten(
         void const*& buffer, size_t& size, int const*& fds, size_t& count) {
-    if (size < 8*sizeof(int)) return NO_MEMORY;
+    if (size < 11 * sizeof(int)) return NO_MEMORY;
 
     int const* buf = static_cast<int const*>(buffer);
     if (buf[0] != 'GBFR') return BAD_TYPE;
 
-    const size_t numFds  = buf[6];
-    const size_t numInts = buf[7];
+    const size_t numFds  = static_cast<size_t>(buf[9]);
+    const size_t numInts = static_cast<size_t>(buf[10]);
 
-    const size_t sizeNeeded = (8 + numInts) * sizeof(int);
+    // Limit the maxNumber to be relatively small. The number of fds or ints
+    // should not come close to this number, and the number itself was simply
+    // chosen to be high enough to not cause issues and low enough to prevent
+    // overflow problems.
+    const size_t maxNumber = 4096;
+    if (numFds >= maxNumber || numInts >= (maxNumber - 11)) {
+        width = height = stride = format = usage = 0;
+        handle = NULL;
+        ALOGE("unflatten: numFds or numInts is too large: %zd, %zd",
+                numFds, numInts);
+        return BAD_VALUE;
+    }
+
+    const size_t sizeNeeded = (11 + numInts) * sizeof(int);
     if (size < sizeNeeded) return NO_MEMORY;
 
-    size_t fdCountNeeded = 0;
+    size_t fdCountNeeded = numFds;
     if (count < fdCountNeeded) return NO_MEMORY;
 
     if (handle) {
@@ -268,15 +364,27 @@
         stride = buf[3];
         format = buf[4];
         usage  = buf[5];
-        native_handle* h = native_handle_create(numFds, numInts);
-        memcpy(h->data,          fds,     numFds*sizeof(int));
-        memcpy(h->data + numFds, &buf[8], numInts*sizeof(int));
+        native_handle* h = native_handle_create(
+                static_cast<int>(numFds), static_cast<int>(numInts));
+        if (!h) {
+            width = height = stride = format = usage = 0;
+            handle = NULL;
+            ALOGE("unflatten: native_handle_create failed");
+            return NO_MEMORY;
+        }
+        memcpy(h->data, fds, numFds * sizeof(int));
+        memcpy(h->data + numFds, &buf[11], numInts * sizeof(int));
         handle = h;
     } else {
         width = height = stride = format = usage = 0;
         handle = NULL;
     }
 
+    mId = static_cast<uint64_t>(buf[6]) << 32;
+    mId |= static_cast<uint32_t>(buf[7]);
+
+    mGenerationNumber = static_cast<uint32_t>(buf[8]);
+
     mOwner = ownHandle;
 
     if (handle != 0) {
@@ -290,7 +398,7 @@
         }
     }
 
-    buffer = reinterpret_cast<void const*>(static_cast<int const*>(buffer) + sizeNeeded);
+    buffer = static_cast<void const*>(static_cast<uint8_t const*>(buffer) + sizeNeeded);
     size -= sizeNeeded;
     fds += numFds;
     count -= numFds;
diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp
index ff550d9..9b265af 100644
--- a/libs/ui/GraphicBufferAllocator.cpp
+++ b/libs/ui/GraphicBufferAllocator.cpp
@@ -1,17 +1,17 @@
-/* 
+/*
 **
 ** Copyright 2009, The Android Open Source Project
 **
-** Licensed under the Apache License, Version 2.0 (the "License"); 
-** you may not use this file except in compliance with the License. 
-** You may obtain a copy of the License at 
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
 **
-**     http://www.apache.org/licenses/LICENSE-2.0 
+**     http://www.apache.org/licenses/LICENSE-2.0
 **
-** Unless required by applicable law or agreed to in writing, software 
-** distributed under the License is distributed on an "AS IS" BASIS, 
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-** See the License for the specific language governing permissions and 
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
 ** limitations under the License.
 */
 
@@ -66,11 +66,11 @@
         if (rec.size) {
             snprintf(buffer, SIZE, "%10p: %7.2f KiB | %4u (%4u) x %4u | %8X | 0x%08x\n",
                     list.keyAt(i), rec.size/1024.0f,
-                    rec.w, rec.s, rec.h, rec.format, rec.usage);
+                    rec.width, rec.stride, rec.height, rec.format, rec.usage);
         } else {
             snprintf(buffer, SIZE, "%10p: unknown     | %4u (%4u) x %4u | %8X | 0x%08x\n",
                     list.keyAt(i),
-                    rec.w, rec.s, rec.h, rec.format, rec.usage);
+                    rec.width, rec.stride, rec.height, rec.format, rec.usage);
         }
         result.append(buffer);
         total += rec.size;
@@ -90,39 +90,43 @@
     ALOGD("%s", s.string());
 }
 
-status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat format,
-        int usage, buffer_handle_t* handle, int32_t* stride)
+status_t GraphicBufferAllocator::alloc(uint32_t width, uint32_t height,
+        PixelFormat format, uint32_t usage, buffer_handle_t* handle,
+        uint32_t* stride)
 {
     ATRACE_CALL();
+
     // make sure to not allocate a N x 0 or 0 x N buffer, since this is
     // allowed from an API stand-point allocate a 1x1 buffer instead.
-    if (!w || !h)
-        w = h = 1;
+    if (!width || !height)
+        width = height = 1;
 
     // we have a h/w allocator and h/w buffer is requested
-    status_t err; 
-    
-    err = mAllocDev->alloc(mAllocDev, w, h, format, usage, handle, stride);
+    status_t err;
+
+    // Filter out any usage bits that should not be passed to the gralloc module
+    usage &= GRALLOC_USAGE_ALLOC_MASK;
+
+    int outStride = 0;
+    err = mAllocDev->alloc(mAllocDev, static_cast<int>(width),
+            static_cast<int>(height), format, static_cast<int>(usage), handle,
+            &outStride);
+    *stride = static_cast<uint32_t>(outStride);
 
     ALOGW_IF(err, "alloc(%u, %u, %d, %08x, ...) failed %d (%s)",
-            w, h, format, usage, err, strerror(-err));
-    
+            width, height, format, usage, err, strerror(-err));
+
     if (err == NO_ERROR) {
         Mutex::Autolock _l(sLock);
         KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList);
-        int bpp = bytesPerPixel(format);
-        if (bpp < 0) {
-            // probably a HAL custom format. in any case, we don't know
-            // what its pixel size is.
-            bpp = 0;
-        }
+        uint32_t bpp = bytesPerPixel(format);
         alloc_rec_t rec;
-        rec.w = w;
-        rec.h = h;
-        rec.s = *stride;
+        rec.width = width;
+        rec.height = height;
+        rec.stride = *stride;
         rec.format = format;
         rec.usage = usage;
-        rec.size = h * stride[0] * bpp;
+        rec.size = static_cast<size_t>(height * (*stride) * bpp);
         list.add(*handle, rec);
     }
 
diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp
index a4cfce2..90a1c11 100644
--- a/libs/ui/GraphicBufferMapper.cpp
+++ b/libs/ui/GraphicBufferMapper.cpp
@@ -20,6 +20,13 @@
 #include <stdint.h>
 #include <errno.h>
 
+// We would eliminate the non-conforming zero-length array, but we can't since
+// this is effectively included from the Linux kernel
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wzero-length-array"
+#include <sync/sync.h>
+#pragma clang diagnostic pop
+
 #include <utils/Errors.h>
 #include <utils/Log.h>
 #include <utils/Trace.h>
@@ -42,7 +49,7 @@
     int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
     ALOGE_IF(err, "FATAL: can't find the %s module", GRALLOC_HARDWARE_MODULE_ID);
     if (err == 0) {
-        mAllocMod = (gralloc_module_t const *)module;
+        mAllocMod = reinterpret_cast<gralloc_module_t const *>(module);
     }
 }
 
@@ -70,13 +77,13 @@
     return err;
 }
 
-status_t GraphicBufferMapper::lock(buffer_handle_t handle, 
-        int usage, const Rect& bounds, void** vaddr)
+status_t GraphicBufferMapper::lock(buffer_handle_t handle,
+        uint32_t usage, const Rect& bounds, void** vaddr)
 {
     ATRACE_CALL();
     status_t err;
 
-    err = mAllocMod->lock(mAllocMod, handle, usage,
+    err = mAllocMod->lock(mAllocMod, handle, static_cast<int>(usage),
             bounds.left, bounds.top, bounds.width(), bounds.height(),
             vaddr);
 
@@ -85,12 +92,16 @@
 }
 
 status_t GraphicBufferMapper::lockYCbCr(buffer_handle_t handle,
-        int usage, const Rect& bounds, android_ycbcr *ycbcr)
+        uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr)
 {
     ATRACE_CALL();
     status_t err;
 
-    err = mAllocMod->lock_ycbcr(mAllocMod, handle, usage,
+    if (mAllocMod->lock_ycbcr == NULL) {
+        return -EINVAL; // do not log failure
+    }
+
+    err = mAllocMod->lock_ycbcr(mAllocMod, handle, static_cast<int>(usage),
             bounds.left, bounds.top, bounds.width(), bounds.height(),
             ycbcr);
 
@@ -109,5 +120,75 @@
     return err;
 }
 
+status_t GraphicBufferMapper::lockAsync(buffer_handle_t handle,
+        uint32_t usage, const Rect& bounds, void** vaddr, int fenceFd)
+{
+    ATRACE_CALL();
+    status_t err;
+
+    if (mAllocMod->common.module_api_version >= GRALLOC_MODULE_API_VERSION_0_3) {
+        err = mAllocMod->lockAsync(mAllocMod, handle, static_cast<int>(usage),
+                bounds.left, bounds.top, bounds.width(), bounds.height(),
+                vaddr, fenceFd);
+    } else {
+        if (fenceFd >= 0) {
+            sync_wait(fenceFd, -1);
+            close(fenceFd);
+        }
+        err = mAllocMod->lock(mAllocMod, handle, static_cast<int>(usage),
+                bounds.left, bounds.top, bounds.width(), bounds.height(),
+                vaddr);
+    }
+
+    ALOGW_IF(err, "lockAsync(...) failed %d (%s)", err, strerror(-err));
+    return err;
+}
+
+status_t GraphicBufferMapper::lockAsyncYCbCr(buffer_handle_t handle,
+        uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr, int fenceFd)
+{
+    ATRACE_CALL();
+    status_t err;
+
+    if (mAllocMod->common.module_api_version >= GRALLOC_MODULE_API_VERSION_0_3
+            && mAllocMod->lockAsync_ycbcr != NULL) {
+        err = mAllocMod->lockAsync_ycbcr(mAllocMod, handle,
+                static_cast<int>(usage), bounds.left, bounds.top,
+                bounds.width(), bounds.height(), ycbcr, fenceFd);
+    } else if (mAllocMod->lock_ycbcr != NULL) {
+        if (fenceFd >= 0) {
+            sync_wait(fenceFd, -1);
+            close(fenceFd);
+        }
+        err = mAllocMod->lock_ycbcr(mAllocMod, handle, static_cast<int>(usage),
+                bounds.left, bounds.top, bounds.width(), bounds.height(),
+                ycbcr);
+    } else {
+        if (fenceFd >= 0) {
+            close(fenceFd);
+        }
+        return -EINVAL; // do not log failure
+    }
+
+    ALOGW_IF(err, "lock(...) failed %d (%s)", err, strerror(-err));
+    return err;
+}
+
+status_t GraphicBufferMapper::unlockAsync(buffer_handle_t handle, int *fenceFd)
+{
+    ATRACE_CALL();
+    status_t err;
+
+    if (mAllocMod->common.module_api_version >= GRALLOC_MODULE_API_VERSION_0_3) {
+        err = mAllocMod->unlockAsync(mAllocMod, handle, fenceFd);
+    } else {
+        *fenceFd = -1;
+        err = mAllocMod->unlock(mAllocMod, handle);
+    }
+
+    ALOGW_IF(err, "unlockAsync(...) failed %d (%s)", err, strerror(-err));
+    return err;
+}
+
 // ---------------------------------------------------------------------------
 }; // namespace android
diff --git a/libs/ui/PixelFormat.cpp b/libs/ui/PixelFormat.cpp
index d2d103a..cab1dde 100644
--- a/libs/ui/PixelFormat.cpp
+++ b/libs/ui/PixelFormat.cpp
@@ -15,13 +15,12 @@
  */
 
 #include <ui/PixelFormat.h>
-#include <hardware/hardware.h>
 
 // ----------------------------------------------------------------------------
 namespace android {
 // ----------------------------------------------------------------------------
 
-ssize_t bytesPerPixel(PixelFormat format) {
+uint32_t bytesPerPixel(PixelFormat format) {
     switch (format) {
         case PIXEL_FORMAT_RGBA_8888:
         case PIXEL_FORMAT_RGBX_8888:
@@ -34,10 +33,10 @@
         case PIXEL_FORMAT_RGBA_4444:
             return 2;
     }
-    return BAD_VALUE;
+    return 0;
 }
 
-ssize_t bitsPerPixel(PixelFormat format) {
+uint32_t bitsPerPixel(PixelFormat format) {
     switch (format) {
         case PIXEL_FORMAT_RGBA_8888:
         case PIXEL_FORMAT_RGBX_8888:
@@ -50,10 +49,9 @@
         case PIXEL_FORMAT_RGBA_4444:
             return 16;
     }
-    return BAD_VALUE;
+    return 0;
 }
 
 // ----------------------------------------------------------------------------
 }; // namespace android
 // ----------------------------------------------------------------------------
-
diff --git a/libs/ui/Rect.cpp b/libs/ui/Rect.cpp
index b480f3a..dcce21f 100644
--- a/libs/ui/Rect.cpp
+++ b/libs/ui/Rect.cpp
@@ -19,6 +19,8 @@
 
 namespace android {
 
+const Rect Rect::INVALID_RECT{0, 0, -1, -1};
+
 static inline int32_t min(int32_t a, int32_t b) {
     return (a < b) ? a : b;
 }
diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp
index 6d58f56..2e56543 100644
--- a/libs/ui/Region.cpp
+++ b/libs/ui/Region.cpp
@@ -53,6 +53,8 @@
     direction_RTL
 };
 
+const Region Region::INVALID_REGION(Rect::INVALID_RECT);
+
 // ----------------------------------------------------------------------------
 
 Region::Region() {
@@ -102,8 +104,8 @@
         current--;
     } while (current->top == lastTop && current >= begin);
 
-    unsigned int beginLastSpan = -1;
-    unsigned int endLastSpan = -1;
+    int beginLastSpan = -1;
+    int endLastSpan = -1;
     int top = -1;
     int bottom = -1;
 
@@ -118,7 +120,7 @@
             } else {
                 beginLastSpan = endLastSpan + 1;
             }
-            endLastSpan = dst.size() - 1;
+            endLastSpan = static_cast<int>(dst.size()) - 1;
 
             top = current->top;
             bottom = current->bottom;
@@ -126,43 +128,46 @@
         int left = current->left;
         int right = current->right;
 
-        for (unsigned int prevIndex = beginLastSpan; prevIndex <= endLastSpan; prevIndex++) {
-            const Rect* prev = &dst[prevIndex];
+        for (int prevIndex = beginLastSpan; prevIndex <= endLastSpan; prevIndex++) {
+            // prevIndex can't be -1 here because if endLastSpan is set to a
+            // value greater than -1 (allowing the loop to execute),
+            // beginLastSpan (and therefore prevIndex) will also be increased
+            const Rect prev = dst[static_cast<size_t>(prevIndex)];
             if (spanDirection == direction_RTL) {
                 // iterating over previous span RTL, quit if it's too far left
-                if (prev->right <= left) break;
+                if (prev.right <= left) break;
 
-                if (prev->right > left && prev->right < right) {
-                    dst.add(Rect(prev->right, top, right, bottom));
-                    right = prev->right;
+                if (prev.right > left && prev.right < right) {
+                    dst.add(Rect(prev.right, top, right, bottom));
+                    right = prev.right;
                 }
 
-                if (prev->left > left && prev->left < right) {
-                    dst.add(Rect(prev->left, top, right, bottom));
-                    right = prev->left;
+                if (prev.left > left && prev.left < right) {
+                    dst.add(Rect(prev.left, top, right, bottom));
+                    right = prev.left;
                 }
 
                 // if an entry in the previous span is too far right, nothing further left in the
                 // current span will need it
-                if (prev->left >= right) {
+                if (prev.left >= right) {
                     beginLastSpan = prevIndex;
                 }
             } else {
                 // iterating over previous span LTR, quit if it's too far right
-                if (prev->left >= right) break;
+                if (prev.left >= right) break;
 
-                if (prev->left > left && prev->left < right) {
-                    dst.add(Rect(left, top, prev->left, bottom));
-                    left = prev->left;
+                if (prev.left > left && prev.left < right) {
+                    dst.add(Rect(left, top, prev.left, bottom));
+                    left = prev.left;
                 }
 
-                if (prev->right > left && prev->right < right) {
-                    dst.add(Rect(left, top, prev->right, bottom));
-                    left = prev->right;
+                if (prev.right > left && prev.right < right) {
+                    dst.add(Rect(left, top, prev.right, bottom));
+                    left = prev.right;
                 }
                 // if an entry in the previous span is too far left, nothing further right in the
                 // current span will need it
-                if (prev->right <= left) {
+                if (prev.right <= left) {
                     beginLastSpan = prevIndex;
                 }
             }
@@ -222,6 +227,22 @@
     return *this;
 }
 
+bool Region::contains(const Point& point) const {
+    return contains(point.x, point.y);
+}
+
+bool Region::contains(int x, int y) const {
+    const_iterator cur = begin();
+    const_iterator const tail = end();
+    while (cur != tail) {
+        if (y >= cur->top && y < cur->bottom && x >= cur->left && x < cur->right) {
+            return true;
+        }
+        cur++;
+    }
+    return false;
+}
+
 void Region::clear()
 {
     mStorage.clear();
@@ -234,10 +255,16 @@
     mStorage.add(r);
 }
 
+void Region::set(int32_t w, int32_t h)
+{
+    mStorage.clear();
+    mStorage.add(Rect(w, h));
+}
+
 void Region::set(uint32_t w, uint32_t h)
 {
     mStorage.clear();
-    mStorage.add(Rect(w,h));
+    mStorage.add(Rect(w, h));
 }
 
 bool Region::isTriviallyEqual(const Region& region) const {
@@ -388,7 +415,7 @@
 
 // This is our region rasterizer, which merges rects and spans together
 // to obtain an optimal region.
-class Region::rasterizer : public region_operator<Rect>::region_rasterizer 
+class Region::rasterizer : public region_operator<Rect>::region_rasterizer
 {
     Rect bounds;
     Vector<Rect>& storage;
@@ -397,81 +424,93 @@
     Vector<Rect> span;
     Rect* cur;
 public:
-    rasterizer(Region& reg) 
+    explicit rasterizer(Region& reg)
         : bounds(INT_MAX, 0, INT_MIN, 0), storage(reg.mStorage), head(), tail(), cur() {
         storage.clear();
     }
 
-    ~rasterizer() {
-        if (span.size()) {
-            flushSpan();
-        }
-        if (storage.size()) {
-            bounds.top = storage.itemAt(0).top;
-            bounds.bottom = storage.top().bottom;
-            if (storage.size() == 1) {
-                storage.clear();
-            }
-        } else {
-            bounds.left  = 0;
-            bounds.right = 0;
-        }
-        storage.add(bounds);
-    }
-    
-    virtual void operator()(const Rect& rect) {
-        //ALOGD(">>> %3d, %3d, %3d, %3d",
-        //        rect.left, rect.top, rect.right, rect.bottom);
-        if (span.size()) {
-            if (cur->top != rect.top) {
-                flushSpan();
-            } else if (cur->right == rect.left) {
-                cur->right = rect.right;
-                return;
-            }
-        }
-        span.add(rect);
-        cur = span.editArray() + (span.size() - 1);
-    }
+    virtual ~rasterizer();
+
+    virtual void operator()(const Rect& rect);
+
 private:
-    template<typename T> 
+    template<typename T>
     static inline T min(T rhs, T lhs) { return rhs < lhs ? rhs : lhs; }
-    template<typename T> 
+    template<typename T>
     static inline T max(T rhs, T lhs) { return rhs > lhs ? rhs : lhs; }
-    void flushSpan() {
-        bool merge = false;
-        if (tail-head == ssize_t(span.size())) {
-            Rect const* p = span.editArray();
-            Rect const* q = head;
-            if (p->top == q->bottom) {
-                merge = true;
-                while (q != tail) {
-                    if ((p->left != q->left) || (p->right != q->right)) {
-                        merge = false;
-                        break;
-                    }
-                    p++, q++;
-                }
-            }
-        }
-        if (merge) {
-            const int bottom = span[0].bottom;
-            Rect* r = head;
-            while (r != tail) {
-                r->bottom = bottom;
-                r++;
-            }
-        } else {
-            bounds.left = min(span.itemAt(0).left, bounds.left);
-            bounds.right = max(span.top().right, bounds.right);
-            storage.appendVector(span);
-            tail = storage.editArray() + storage.size();
-            head = tail - span.size();
-        }
-        span.clear();
-    }
+
+    void flushSpan();
 };
 
+Region::rasterizer::~rasterizer()
+{
+    if (span.size()) {
+        flushSpan();
+    }
+    if (storage.size()) {
+        bounds.top = storage.itemAt(0).top;
+        bounds.bottom = storage.top().bottom;
+        if (storage.size() == 1) {
+            storage.clear();
+        }
+    } else {
+        bounds.left  = 0;
+        bounds.right = 0;
+    }
+    storage.add(bounds);
+}
+
+void Region::rasterizer::operator()(const Rect& rect)
+{
+    //ALOGD(">>> %3d, %3d, %3d, %3d",
+    //        rect.left, rect.top, rect.right, rect.bottom);
+    if (span.size()) {
+        if (cur->top != rect.top) {
+            flushSpan();
+        } else if (cur->right == rect.left) {
+            cur->right = rect.right;
+            return;
+        }
+    }
+    span.add(rect);
+    cur = span.editArray() + (span.size() - 1);
+}
+
+void Region::rasterizer::flushSpan()
+{
+    bool merge = false;
+    if (tail-head == ssize_t(span.size())) {
+        Rect const* p = span.editArray();
+        Rect const* q = head;
+        if (p->top == q->bottom) {
+            merge = true;
+            while (q != tail) {
+                if ((p->left != q->left) || (p->right != q->right)) {
+                    merge = false;
+                    break;
+                }
+                p++;
+                q++;
+            }
+        }
+    }
+    if (merge) {
+        const int bottom = span[0].bottom;
+        Rect* r = head;
+        while (r != tail) {
+            r->bottom = bottom;
+            r++;
+        }
+    } else {
+        bounds.left = min(span.itemAt(0).left, bounds.left);
+        bounds.right = max(span.top().right, bounds.right);
+        storage.appendVector(span);
+        tail = storage.editArray() + storage.size();
+        head = tail - span.size();
+    }
+    span.clear();
+}
+
 bool Region::validate(const Region& reg, const char* name, bool silent)
 {
     bool result = true;
@@ -481,8 +520,12 @@
     Rect b(*prev);
     while (cur != tail) {
         if (cur->isValid() == false) {
-            ALOGE_IF(!silent, "%s: region contains an invalid Rect", name);
-            result = false;
+            // We allow this particular flavor of invalid Rect, since it is used
+            // as a signal value in various parts of the system
+            if (*cur != Rect::INVALID_RECT) {
+                ALOGE_IF(!silent, "%s: region contains an invalid Rect", name);
+                result = false;
+            }
         }
         if (cur->right > region_operator<Rect>::max_value) {
             ALOGE_IF(!silent, "%s: rect->right > max_value", name);
@@ -654,7 +697,9 @@
         const Region& lhs,
         const Rect& rhs, int dx, int dy)
 {
-    if (!rhs.isValid()) {
+    // We allow this particular flavor of invalid Rect, since it is used as a
+    // signal value in various parts of the system
+    if (!rhs.isValid() && rhs != Rect::INVALID_RECT) {
         ALOGE("Region::boolean_operation(op=%d) invalid Rect={%d,%d,%d,%d}",
                 op, rhs.left, rhs.top, rhs.right, rhs.bottom);
         return;
@@ -717,35 +762,52 @@
 // ----------------------------------------------------------------------------
 
 size_t Region::getFlattenedSize() const {
-    return mStorage.size() * sizeof(Rect);
+    return sizeof(uint32_t) + mStorage.size() * sizeof(Rect);
 }
 
 status_t Region::flatten(void* buffer, size_t size) const {
 #if VALIDATE_REGIONS
     validate(*this, "Region::flatten");
 #endif
-    if (size < mStorage.size() * sizeof(Rect)) {
+    if (size < getFlattenedSize()) {
         return NO_MEMORY;
     }
-    Rect* rects = reinterpret_cast<Rect*>(buffer);
-    memcpy(rects, mStorage.array(), mStorage.size() * sizeof(Rect));
+    // Cast to uint32_t since the size of a size_t can vary between 32- and
+    // 64-bit processes
+    FlattenableUtils::write(buffer, size, static_cast<uint32_t>(mStorage.size()));
+    for (auto rect : mStorage) {
+        status_t result = rect.flatten(buffer, size);
+        if (result != NO_ERROR) {
+            return result;
+        }
+        FlattenableUtils::advance(buffer, size, sizeof(rect));
+    }
     return NO_ERROR;
 }
 
 status_t Region::unflatten(void const* buffer, size_t size) {
-    Region result;
-    if (size >= sizeof(Rect)) {
-        Rect const* rects = reinterpret_cast<Rect const*>(buffer);
-        size_t count = size / sizeof(Rect);
-        if (count > 0) {
-            result.mStorage.clear();
-            ssize_t err = result.mStorage.insertAt(0, count);
-            if (err < 0) {
-                return status_t(err);
-            }
-            memcpy(result.mStorage.editArray(), rects, count*sizeof(Rect));
-        }
+    if (size < sizeof(uint32_t)) {
+        return NO_MEMORY;
     }
+
+    uint32_t numRects = 0;
+    FlattenableUtils::read(buffer, size, numRects);
+    if (size < numRects * sizeof(Rect)) {
+        return NO_MEMORY;
+    }
+
+    Region result;
+    result.mStorage.clear();
+    for (size_t r = 0; r < numRects; ++r) {
+        Rect rect;
+        status_t status = rect.unflatten(buffer, size);
+        if (status != NO_ERROR) {
+            return status;
+        }
+        FlattenableUtils::advance(buffer, size, sizeof(rect));
+        result.mStorage.push_back(rect);
+    }
+
 #if VALIDATE_REGIONS
     validate(result, "Region::unflatten");
 #endif
@@ -770,49 +832,28 @@
 }
 
 Rect const* Region::getArray(size_t* count) const {
-    const_iterator const b(begin());
-    const_iterator const e(end());
-    if (count) *count = e-b;
-    return b;
-}
-
-SharedBuffer const* Region::getSharedBuffer(size_t* count) const {
-    // We can get to the SharedBuffer of a Vector<Rect> because Rect has
-    // a trivial destructor.
-    SharedBuffer const* sb = SharedBuffer::bufferFromData(mStorage.array());
-    if (count) {
-        size_t numRects = isRect() ? 1 : mStorage.size() - 1;
-        count[0] = numRects;
-    }
-    sb->acquire();
-    return sb;
+    if (count) *count = static_cast<size_t>(end() - begin());
+    return begin();
 }
 
 // ----------------------------------------------------------------------------
 
-void Region::dump(String8& out, const char* what, uint32_t flags) const
+void Region::dump(String8& out, const char* what, uint32_t /* flags */) const
 {
-    (void)flags;
     const_iterator head = begin();
     const_iterator const tail = end();
 
-    size_t SIZE = 256;
-    char buffer[SIZE];
-
-    snprintf(buffer, SIZE, "  Region %s (this=%p, count=%" PRIdPTR ")\n",
-            what, this, tail-head);
-    out.append(buffer);
+    out.appendFormat("  Region %s (this=%p, count=%" PRIdPTR ")\n",
+            what, this, tail - head);
     while (head != tail) {
-        snprintf(buffer, SIZE, "    [%3d, %3d, %3d, %3d]\n",
-                head->left, head->top, head->right, head->bottom);
-        out.append(buffer);
-        head++;
+        out.appendFormat("    [%3d, %3d, %3d, %3d]\n", head->left, head->top,
+                head->right, head->bottom);
+        ++head;
     }
 }
 
-void Region::dump(const char* what, uint32_t flags) const
+void Region::dump(const char* what, uint32_t /* flags */) const
 {
-    (void)flags;
     const_iterator head = begin();
     const_iterator const tail = end();
     ALOGD("  Region %s (this=%p, count=%" PRIdPTR ")\n", what, this, tail-head);
diff --git a/libs/ui/UiConfig.cpp b/libs/ui/UiConfig.cpp
index 8b2130e..9e7ba8e 100644
--- a/libs/ui/UiConfig.cpp
+++ b/libs/ui/UiConfig.cpp
@@ -18,8 +18,11 @@
 
 namespace android {
 
+#ifdef FRAMEBUFFER_FORCE_FORMAT
+// We need the two-level macro to stringify the contents of a macro argument
 #define STRINGIFY(x) #x
 #define TOSTRING(x) STRINGIFY(x)
+#endif
 
 void appendUiConfigString(String8& configStr)
 {
diff --git a/libs/ui/tests/Android.mk b/libs/ui/tests/Android.mk
index b0c57db..6438b1f 100644
--- a/libs/ui/tests/Android.mk
+++ b/libs/ui/tests/Android.mk
@@ -1,31 +1,36 @@
-# Build the unit tests.
+#
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
 LOCAL_PATH := $(call my-dir)
+
 include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+LOCAL_SHARED_LIBRARIES := libui
+LOCAL_SRC_FILES := Region_test.cpp
+LOCAL_MODULE := Region_test
+include $(BUILD_NATIVE_TEST)
 
-# Build the unit tests.
-test_src_files := \
-    Region_test.cpp \
-    vec_test.cpp \
-    mat_test.cpp
+include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+LOCAL_SRC_FILES := vec_test.cpp
+LOCAL_MODULE := vec_test
+include $(BUILD_NATIVE_TEST)
 
-shared_libraries := \
-    libutils \
-    libui
-
-static_libraries := \
-    libgtest \
-    libgtest_main
-
-$(foreach file,$(test_src_files), \
-    $(eval include $(CLEAR_VARS)) \
-    $(eval LOCAL_SHARED_LIBRARIES := $(shared_libraries)) \
-    $(eval LOCAL_STATIC_LIBRARIES := $(static_libraries)) \
-    $(eval LOCAL_SRC_FILES := $(file)) \
-    $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \
-    $(eval include $(BUILD_NATIVE_TEST)) \
-)
-
-# Build the unit tests.
-
-# Build the manual test programs.
-include $(call all-makefiles-under, $(LOCAL_PATH))
+include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+LOCAL_SRC_FILES := mat_test.cpp
+LOCAL_MODULE := mat_test
+include $(BUILD_NATIVE_TEST)
diff --git a/libs/ui/tests/vec_test.cpp b/libs/ui/tests/vec_test.cpp
index 00f737e..454c999 100644
--- a/libs/ui/tests/vec_test.cpp
+++ b/libs/ui/tests/vec_test.cpp
@@ -16,17 +16,18 @@
 
 #define LOG_TAG "RegionTest"
 
+#include <math.h>
 #include <stdlib.h>
+
 #include <ui/Region.h>
 #include <ui/Rect.h>
-#include <gtest/gtest.h>
-
 #include <ui/vec4.h>
 
+#include <gtest/gtest.h>
+
 namespace android {
 
 class VecTest : public testing::Test {
-protected:
 };
 
 TEST_F(VecTest, Basics) {
diff --git a/opengl/include/EGL/eglext.h b/opengl/include/EGL/eglext.h
index 3b2984a..114079b 100644
--- a/opengl/include/EGL/eglext.h
+++ b/opengl/include/EGL/eglext.h
@@ -115,6 +115,13 @@
 #define EGL_GL_TEXTURE_ZOFFSET_KHR		0x30BD	/* eglCreateImageKHR attribute */
 #endif
 
+#ifndef EGL_KHR_gl_colorspace
+#define EGL_KHR_gl_colorspace 1
+#define EGL_GL_COLORSPACE_KHR             0x309D
+#define EGL_GL_COLORSPACE_SRGB_KHR        0x3089
+#define EGL_GL_COLORSPACE_LINEAR_KHR      0x308A
+#endif
+
 #ifndef EGL_KHR_gl_renderbuffer_image
 #define EGL_KHR_gl_renderbuffer_image 1
 #define EGL_GL_RENDERBUFFER_KHR			0x30B9	/* eglCreateImageKHR target */
@@ -176,6 +183,15 @@
 #define EGL_BITMAP_PIXEL_SIZE_KHR		0x3110
 #endif
 
+#ifndef EGL_KHR_partial_update
+#define EGL_KHR_partial_update 1
+#define EGL_BUFFER_AGE_KHR                0x313D
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETDAMAGEREGIONKHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglSetDamageRegionKHR (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);
+#endif
+#endif /* EGL_KHR_partial_update */
+
 #ifndef EGL_NV_coverage_sample
 #define EGL_NV_coverage_sample 1
 #define EGL_COVERAGE_BUFFERS_NV			0x30E0
@@ -435,11 +451,24 @@
 #define EGL_OPENGL_ES3_BIT_KHR				    0x00000040
 #endif
 
+#ifndef EGL_KHR_create_context_no_error
+#define EGL_KHR_create_context_no_error 1
+#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR   0x31B3
+#endif /* EGL_KHR_create_context_no_error */
+
 #ifndef EGL_KHR_surfaceless_context
 #define EGL_KHR_surfaceless_context 1
 /* No tokens/entry points, just relaxes an error condition */
 #endif
 
+#ifndef EGL_KHR_swap_buffers_with_damage
+#define EGL_KHR_swap_buffers_with_damage 1
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEKHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageKHR (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);
+#endif
+#endif /* EGL_KHR_swap_buffers_with_damage */
+
 #ifdef EGL_KHR_stream /* Requires KHR_stream extension */
 #ifndef EGL_KHR_stream_cross_process_fd
 #define EGL_KHR_stream_cross_process_fd 1
@@ -523,7 +552,7 @@
 #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
+#define EGL_NO_NATIVE_FENCE_FD_ANDROID		(-1)
 #ifdef EGL_EGLEXT_PROTOTYPES
 EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID( EGLDisplay dpy, EGLSyncKHR);
 #endif /* EGL_EGLEXT_PROTOTYPES */
diff --git a/opengl/include/GLES/glext.h b/opengl/include/GLES/glext.h
index 54afaab..5843d5e 100644
--- a/opengl/include/GLES/glext.h
+++ b/opengl/include/GLES/glext.h
@@ -1,7 +1,7 @@
 #ifndef __glext_h_
 #define __glext_h_
 
-/* $Revision: 16481 $ on $Date:: 2012-01-04 10:43:56 -0800 #$ */
+/* $Revision: 20798 $ on $Date:: 2013-03-07 01:19:34 -0800 #$ */
 
 #ifdef __cplusplus
 extern "C" {
@@ -165,6 +165,9 @@
 #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
@@ -240,7 +243,7 @@
  * APPLE extension tokens
  *------------------------------------------------------------------------*/
 
-/* GL_APPLE_texture_2D_limited_npot */
+/* GL_APPLE_copy_texture_levels */
 /* No new tokens introduced by this extension. */
 
 /* GL_APPLE_framebuffer_multisample */
@@ -254,6 +257,41 @@
 #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
@@ -288,12 +326,23 @@
 #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
-#define GL_RENDERBUFFER_SAMPLES_EXT                             0x9133
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT               0x9134
-#define GL_MAX_SAMPLES_EXT                                      0x9135
+/* 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 */
@@ -353,10 +402,10 @@
 /* GL_EXT_texture_storage */
 #ifndef GL_EXT_texture_storage
 #define GL_TEXTURE_IMMUTABLE_FORMAT_EXT                         0x912F
-#define GL_ALPHA8_EXT                                           0x803C  
+#define GL_ALPHA8_EXT                                           0x803C
 #define GL_LUMINANCE8_EXT                                       0x8040
 #define GL_LUMINANCE8_ALPHA8_EXT                                0x8045
-#define GL_RGBA32F_EXT                                          0x8814  
+#define GL_RGBA32F_EXT                                          0x8814
 #define GL_RGB32F_EXT                                           0x8815
 #define GL_ALPHA32F_EXT                                         0x8816
 #define GL_LUMINANCE32F_EXT                                     0x8818
@@ -366,7 +415,7 @@
 #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_A2_EXT                                         0x8059
 #define GL_RGB10_EXT                                            0x8052
 #define GL_BGRA8_EXT                                            0x93A1
 #endif
@@ -771,6 +820,11 @@
 #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
@@ -892,22 +946,52 @@
  * APPLE extension functions
  *------------------------------------------------------------------------*/
 
-/* GL_APPLE_texture_2D_limited_npot */
-#ifndef GL_APPLE_texture_2D_limited_npot
-#define GL_APPLE_texture_2D_limited_npot 1
+/* 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 target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+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
@@ -945,12 +1029,23 @@
 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 target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-GL_API void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+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);
@@ -960,11 +1055,11 @@
 #ifndef GL_EXT_multi_draw_arrays
 #define GL_EXT_multi_draw_arrays 1
 #ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glMultiDrawArraysEXT (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
-GL_API void GL_APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
+GL_API void GL_APIENTRY glMultiDrawArraysEXT (GLenum, const GLint *, const GLsizei *, GLsizei);
+GL_API void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* const*, 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);
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const*indices, GLsizei primcount);
 #endif
 
 /* GL_EXT_read_format_bgra */
@@ -1054,8 +1149,8 @@
 #ifndef GL_IMG_user_clip_plane
 #define GL_IMG_user_clip_plane 1
 #ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glClipPlanefIMG (GLenum p, const GLfloat *eqn);
-GL_API void GL_APIENTRY glClipPlanexIMG (GLenum p, const GLfixed *eqn);
+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);
@@ -1065,11 +1160,11 @@
 #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 target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-GL_API void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+GL_API void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
+GL_API void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
 #endif
-typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+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
 
 /*------------------------------------------------------------------------*
@@ -1080,13 +1175,13 @@
 #ifndef GL_NV_fence
 #define GL_NV_fence 1
 #ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences);
-GL_API void GL_APIENTRY glGenFencesNV (GLsizei n, GLuint *fences);
-GL_API GLboolean GL_APIENTRY glIsFenceNV (GLuint fence);
-GL_API GLboolean GL_APIENTRY glTestFenceNV (GLuint fence);
-GL_API void GL_APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params);
-GL_API void GL_APIENTRY glFinishFenceNV (GLuint fence);
-GL_API void GL_APIENTRY glSetFenceNV (GLuint fence, GLenum condition);
+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);
diff --git a/opengl/include/GLES2/gl2.h b/opengl/include/GLES2/gl2.h
index c2d8357..8a4d43a 100644
--- a/opengl/include/GLES2/gl2.h
+++ b/opengl/include/GLES2/gl2.h
@@ -1,56 +1,83 @@
 #ifndef __gl2_h_
-#define __gl2_h_
-
-/* $Revision: 20555 $ on $Date:: 2013-02-12 14:32:47 -0800 #$ */
-
-#include <GLES2/gl2platform.h>
+#define __gl2_h_ 1
 
 #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/ .
+** Copyright (c) 2013-2014 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.
+*/
+/*
+** This header is generated from the Khronos OpenGL / OpenGL ES XML
+** API Registry. The current version of the Registry, generator scripts
+** used to make the header, and the header can be found at
+**   http://www.opengl.org/registry/
+**
+** Khronos $Revision: 26696 $ on $Date: 2014-05-17 14:48:55 -0700 (Sat, 17 May 2014) $
+*/
+
+#include <GLES2/gl2platform.h>
+
+/* Generated on date 20140517 */
+
+/* Generated C header for:
+ * API: gles2
+ * Profile: common
+ * Versions considered: 2\.[0-9]
+ * Versions emitted: .*
+ * Default extensions included: None
+ * Additional extensions included: _nomatch_^
+ * Extensions removed: _nomatch_^
  */
 
-/*-------------------------------------------------------------------------
- * 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 */
+#ifndef GL_ES_VERSION_2_0
+#define GL_ES_VERSION_2_0 1
+#include <KHR/khrplatform.h>
+typedef khronos_int8_t GLbyte;
+typedef khronos_float_t GLclampf;
+typedef khronos_int32_t GLfixed;
+typedef short GLshort;
+typedef unsigned short GLushort;
+typedef void GLvoid;
+typedef struct __GLsync *GLsync;
+typedef khronos_int64_t GLint64;
+typedef khronos_uint64_t GLuint64;
+typedef unsigned int GLenum;
+typedef unsigned int GLuint;
+typedef char GLchar;
+typedef khronos_float_t GLfloat;
+typedef khronos_ssize_t GLsizeiptr;
 typedef khronos_intptr_t GLintptr;
-typedef khronos_ssize_t  GLsizeiptr;
-
-/* OpenGL ES core versions */
-#define GL_ES_VERSION_2_0                 1
-
-/* ClearBufferMask */
+typedef unsigned int GLbitfield;
+typedef int GLint;
+typedef unsigned char GLboolean;
+typedef int GLsizei;
+typedef khronos_uint8_t GLubyte;
 #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
@@ -58,18 +85,6 @@
 #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
@@ -78,29 +93,15 @@
 #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_RGB             0x8009
 #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
@@ -110,38 +111,19 @@
 #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
@@ -152,19 +134,13 @@
 #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
@@ -191,7 +167,6 @@
 #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
@@ -206,32 +181,18 @@
 #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_GENERATE_MIPMAP_HINT           0x8192
 #define GL_BYTE                           0x1400
 #define GL_UNSIGNED_BYTE                  0x1401
 #define GL_SHORT                          0x1402
@@ -240,44 +201,35 @@
 #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_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_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
 #define GL_NEVER                          0x0200
 #define GL_LESS                           0x0201
 #define GL_EQUAL                          0x0202
@@ -286,9 +238,6 @@
 #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
@@ -296,35 +245,21 @@
 #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
@@ -334,8 +269,6 @@
 #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
@@ -369,13 +302,9 @@
 #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
@@ -391,48 +320,34 @@
 #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_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_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
@@ -442,179 +357,169 @@
 #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_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_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_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 GLint        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 GLint        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);
+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 sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage);
+GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *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 d);
+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 void *data);
+GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *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 void *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 GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar *name);
+GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *data);
+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 *data);
+GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *data);
+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 GLint 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, void **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, void *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 count, const GLuint *shaders, GLenum binaryformat, const void *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 sfail, GLenum dpfail, GLenum dppass);
+GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *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 void *pixels);
+GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat v0);
+GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint v0);
+GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1);
+GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint v0, GLint v1);
+GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2);
+GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value);
+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 index, GLfloat x);
+GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y);
+GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
+GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
+#endif /* GL_ES_VERSION_2_0 */
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* __gl2_h_ */
+#endif
diff --git a/opengl/include/GLES2/gl2ext.h b/opengl/include/GLES2/gl2ext.h
index 8f8d80a..9749f9f 100644
--- a/opengl/include/GLES2/gl2ext.h
+++ b/opengl/include/GLES2/gl2ext.h
@@ -1,1160 +1,1359 @@
 #ifndef __gl2ext_h_
-#define __gl2ext_h_
-
-/* $Revision: 16619 $ on $Date:: 2012-01-18 10:00:14 -0800 #$ */
+#define __gl2ext_h_ 1
 
 #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/ .
- */
+** Copyright (c) 2013-2014 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.
+*/
+/*
+** This header is generated from the Khronos OpenGL / OpenGL ES XML
+** API Registry. The current version of the Registry, generator scripts
+** used to make the header, and the header can be found at
+**   http://www.opengl.org/registry/
+**
+** Khronos $Revision$ on $Date$
+*/
 
 #ifndef GL_APIENTRYP
-#   define GL_APIENTRYP GL_APIENTRY*
+#define GL_APIENTRYP GL_APIENTRY*
 #endif
 
-/*------------------------------------------------------------------------*
- * OES extension tokens
- *------------------------------------------------------------------------*/
+/* Generated on date 20140519 */
 
-/* GL_OES_compressed_ETC1_RGB8_texture */
-#ifndef GL_OES_compressed_ETC1_RGB8_texture
-#define GL_ETC1_RGB8_OES                                        0x8D64
-#endif
+/* Generated C header for:
+ * API: gles2
+ * Profile: common
+ * Versions considered: 2\.[0-9]
+ * Versions emitted: _nomatch_^
+ * Default extensions included: gles2
+ * Additional extensions included: _nomatch_^
+ * Extensions removed: _nomatch_^
+ */
 
-/* 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
+#ifndef GL_KHR_blend_equation_advanced
+#define GL_KHR_blend_equation_advanced 1
+#define GL_BLEND_ADVANCED_COHERENT_KHR    0x9285
+#define GL_MULTIPLY_KHR                   0x9294
+#define GL_SCREEN_KHR                     0x9295
+#define GL_OVERLAY_KHR                    0x9296
+#define GL_DARKEN_KHR                     0x9297
+#define GL_LIGHTEN_KHR                    0x9298
+#define GL_COLORDODGE_KHR                 0x9299
+#define GL_COLORBURN_KHR                  0x929A
+#define GL_HARDLIGHT_KHR                  0x929B
+#define GL_SOFTLIGHT_KHR                  0x929C
+#define GL_DIFFERENCE_KHR                 0x929E
+#define GL_EXCLUSION_KHR                  0x92A0
+#define GL_HSL_HUE_KHR                    0x92AD
+#define GL_HSL_SATURATION_KHR             0x92AE
+#define GL_HSL_COLOR_KHR                  0x92AF
+#define GL_HSL_LUMINOSITY_KHR             0x92B0
+typedef void (GL_APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glBlendBarrierKHR (void);
 #endif
+#endif /* GL_KHR_blend_equation_advanced */
 
-/* GL_OES_depth24 */
-#ifndef GL_OES_depth24
-#define GL_DEPTH_COMPONENT24_OES                                0x81A6
+#ifndef GL_KHR_debug
+#define GL_KHR_debug 1
+typedef void (GL_APIENTRY  *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
+#define GL_SAMPLER                        0x82E6
+#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR   0x8242
+#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243
+#define GL_DEBUG_CALLBACK_FUNCTION_KHR    0x8244
+#define GL_DEBUG_CALLBACK_USER_PARAM_KHR  0x8245
+#define GL_DEBUG_SOURCE_API_KHR           0x8246
+#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247
+#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248
+#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR   0x8249
+#define GL_DEBUG_SOURCE_APPLICATION_KHR   0x824A
+#define GL_DEBUG_SOURCE_OTHER_KHR         0x824B
+#define GL_DEBUG_TYPE_ERROR_KHR           0x824C
+#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D
+#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E
+#define GL_DEBUG_TYPE_PORTABILITY_KHR     0x824F
+#define GL_DEBUG_TYPE_PERFORMANCE_KHR     0x8250
+#define GL_DEBUG_TYPE_OTHER_KHR           0x8251
+#define GL_DEBUG_TYPE_MARKER_KHR          0x8268
+#define GL_DEBUG_TYPE_PUSH_GROUP_KHR      0x8269
+#define GL_DEBUG_TYPE_POP_GROUP_KHR       0x826A
+#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B
+#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C
+#define GL_DEBUG_GROUP_STACK_DEPTH_KHR    0x826D
+#define GL_BUFFER_KHR                     0x82E0
+#define GL_SHADER_KHR                     0x82E1
+#define GL_PROGRAM_KHR                    0x82E2
+#define GL_VERTEX_ARRAY_KHR               0x8074
+#define GL_QUERY_KHR                      0x82E3
+#define GL_SAMPLER_KHR                    0x82E6
+#define GL_MAX_LABEL_LENGTH_KHR           0x82E8
+#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR   0x9143
+#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR  0x9144
+#define GL_DEBUG_LOGGED_MESSAGES_KHR      0x9145
+#define GL_DEBUG_SEVERITY_HIGH_KHR        0x9146
+#define GL_DEBUG_SEVERITY_MEDIUM_KHR      0x9147
+#define GL_DEBUG_SEVERITY_LOW_KHR         0x9148
+#define GL_DEBUG_OUTPUT_KHR               0x92E0
+#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR     0x00000002
+#define GL_STACK_OVERFLOW_KHR             0x0503
+#define GL_STACK_UNDERFLOW_KHR            0x0504
+typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKKHRPROC) (GLDEBUGPROCKHR callback, const void *userParam);
+typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPKHRPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);
+typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPKHRPROC) (void);
+typedef void (GL_APIENTRYP PFNGLOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
+typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei length, const GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETPOINTERVKHRPROC) (GLenum pname, void **params);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDebugMessageControlKHR (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+GL_APICALL void GL_APIENTRY glDebugMessageInsertKHR (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+GL_APICALL void GL_APIENTRY glDebugMessageCallbackKHR (GLDEBUGPROCKHR callback, const void *userParam);
+GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLogKHR (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+GL_APICALL void GL_APIENTRY glPushDebugGroupKHR (GLenum source, GLuint id, GLsizei length, const GLchar *message);
+GL_APICALL void GL_APIENTRY glPopDebugGroupKHR (void);
+GL_APICALL void GL_APIENTRY glObjectLabelKHR (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
+GL_APICALL void GL_APIENTRY glGetObjectLabelKHR (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
+GL_APICALL void GL_APIENTRY glObjectPtrLabelKHR (const void *ptr, GLsizei length, const GLchar *label);
+GL_APICALL void GL_APIENTRY glGetObjectPtrLabelKHR (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
+GL_APICALL void GL_APIENTRY glGetPointervKHR (GLenum pname, void **params);
 #endif
+#endif /* GL_KHR_debug */
 
-/* GL_OES_depth32 */
-#ifndef GL_OES_depth32
-#define GL_DEPTH_COMPONENT32_OES                                0x81A7
-#endif
+#ifndef GL_KHR_texture_compression_astc_hdr
+#define GL_KHR_texture_compression_astc_hdr 1
+#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 /* GL_KHR_texture_compression_astc_hdr */
 
-/* GL_OES_depth_texture */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_EGL_image */
-#ifndef GL_OES_EGL_image
-typedef void* GLeglImageOES;
-#endif
-
-/* GL_OES_EGL_image_external */
-#ifndef GL_OES_EGL_image_external
-/* GLeglImageOES defined in GL_OES_EGL_image already. */
-#define GL_TEXTURE_EXTERNAL_OES                                 0x8D65
-#define GL_SAMPLER_EXTERNAL_OES                                 0x8D66
-#define GL_TEXTURE_BINDING_EXTERNAL_OES                         0x8D67
-#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES                     0x8D68
-#endif
-
-/* GL_OES_element_index_uint */
-#ifndef GL_OES_element_index_uint
-#define GL_UNSIGNED_INT                                         0x1405
-#endif
-
-/* GL_OES_get_program_binary */
-#ifndef GL_OES_get_program_binary
-#define GL_PROGRAM_BINARY_LENGTH_OES                            0x8741
-#define GL_NUM_PROGRAM_BINARY_FORMATS_OES                       0x87FE
-#define GL_PROGRAM_BINARY_FORMATS_OES                           0x87FF
-#endif
-
-/* GL_OES_mapbuffer */
-#ifndef GL_OES_mapbuffer
-#define GL_WRITE_ONLY_OES                                       0x88B9
-#define GL_BUFFER_ACCESS_OES                                    0x88BB
-#define GL_BUFFER_MAPPED_OES                                    0x88BC
-#define GL_BUFFER_MAP_POINTER_OES                               0x88BD
-#endif
-
-/* GL_OES_packed_depth_stencil */
-#ifndef GL_OES_packed_depth_stencil
-#define GL_DEPTH_STENCIL_OES                                    0x84F9
-#define GL_UNSIGNED_INT_24_8_OES                                0x84FA
-#define GL_DEPTH24_STENCIL8_OES                                 0x88F0
-#endif
-
-/* GL_OES_rgb8_rgba8 */
-#ifndef GL_OES_rgb8_rgba8
-#define GL_RGB8_OES                                             0x8051
-#define GL_RGBA8_OES                                            0x8058
-#endif
-
-/* GL_OES_standard_derivatives */
-#ifndef GL_OES_standard_derivatives
-#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES                  0x8B8B
-#endif
-
-/* GL_OES_stencil1 */
-#ifndef GL_OES_stencil1
-#define GL_STENCIL_INDEX1_OES                                   0x8D46
-#endif
-
-/* GL_OES_stencil4 */
-#ifndef GL_OES_stencil4
-#define GL_STENCIL_INDEX4_OES                                   0x8D47
-#endif
-
-/* GL_OES_texture_3D */
-#ifndef GL_OES_texture_3D
-#define GL_TEXTURE_WRAP_R_OES                                   0x8072
-#define GL_TEXTURE_3D_OES                                       0x806F
-#define GL_TEXTURE_BINDING_3D_OES                               0x806A
-#define GL_MAX_3D_TEXTURE_SIZE_OES                              0x8073
-#define GL_SAMPLER_3D_OES                                       0x8B5F
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES        0x8CD4
-#endif
-
-/* GL_OES_texture_float */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_texture_float_linear */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_texture_half_float */
-#ifndef GL_OES_texture_half_float
-#define GL_HALF_FLOAT_OES                                       0x8D61
-#endif
-
-/* GL_OES_texture_half_float_linear */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_texture_npot */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_vertex_array_object */
-#ifndef GL_OES_vertex_array_object
-#define GL_VERTEX_ARRAY_BINDING_OES                             0x85B5
-#endif
-
-/* GL_OES_vertex_half_float */
-/* GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already. */
-
-/* GL_OES_vertex_type_10_10_10_2 */
-#ifndef GL_OES_vertex_type_10_10_10_2
-#define GL_UNSIGNED_INT_10_10_10_2_OES                          0x8DF6
-#define GL_INT_10_10_10_2_OES                                   0x8DF7
-#endif
-
-/*------------------------------------------------------------------------*
- * AMD extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_AMD_compressed_3DC_texture */
-#ifndef GL_AMD_compressed_3DC_texture
-#define GL_3DC_X_AMD                                            0x87F9
-#define GL_3DC_XY_AMD                                           0x87FA
-#endif
-
-/* GL_AMD_compressed_ATC_texture */
-#ifndef GL_AMD_compressed_ATC_texture
-#define GL_ATC_RGB_AMD                                          0x8C92
-#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD                          0x8C93
-#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD                      0x87EE
-#endif
-
-/* GL_AMD_performance_monitor */
-#ifndef GL_AMD_performance_monitor
-#define GL_COUNTER_TYPE_AMD                                     0x8BC0
-#define GL_COUNTER_RANGE_AMD                                    0x8BC1
-#define GL_UNSIGNED_INT64_AMD                                   0x8BC2
-#define GL_PERCENTAGE_AMD                                       0x8BC3
-#define GL_PERFMON_RESULT_AVAILABLE_AMD                         0x8BC4
-#define GL_PERFMON_RESULT_SIZE_AMD                              0x8BC5
-#define GL_PERFMON_RESULT_AMD                                   0x8BC6
-#endif
-
-/* GL_AMD_program_binary_Z400 */
-#ifndef GL_AMD_program_binary_Z400
-#define GL_Z400_BINARY_AMD                                      0x8740
-#endif
-
-/*------------------------------------------------------------------------*
- * ANGLE extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_ANGLE_framebuffer_blit */
-#ifndef GL_ANGLE_framebuffer_blit
-#define GL_READ_FRAMEBUFFER_ANGLE                               0x8CA8
-#define GL_DRAW_FRAMEBUFFER_ANGLE                               0x8CA9
-#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE                       0x8CA6
-#define GL_READ_FRAMEBUFFER_BINDING_ANGLE                       0x8CAA
-#endif
-
-/* GL_ANGLE_framebuffer_multisample */
-#ifndef GL_ANGLE_framebuffer_multisample
-#define GL_RENDERBUFFER_SAMPLES_ANGLE                           0x8CAB
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE             0x8D56
-#define GL_MAX_SAMPLES_ANGLE                                    0x8D57
-#endif
-
-/*------------------------------------------------------------------------*
- * APPLE extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_APPLE_rgb_422 */
-#ifndef GL_APPLE_rgb_422
-#define GL_RGB_422_APPLE                                        0x8A1F
-#define GL_UNSIGNED_SHORT_8_8_APPLE                             0x85BA
-#define GL_UNSIGNED_SHORT_8_8_REV_APPLE                         0x85BB
-#endif
-
-/* GL_APPLE_framebuffer_multisample */
-#ifndef GL_APPLE_framebuffer_multisample
-#define GL_RENDERBUFFER_SAMPLES_APPLE                           0x8CAB
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE             0x8D56
-#define GL_MAX_SAMPLES_APPLE                                    0x8D57
-#define GL_READ_FRAMEBUFFER_APPLE                               0x8CA8
-#define GL_DRAW_FRAMEBUFFER_APPLE                               0x8CA9
-#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE                       0x8CA6
-#define GL_READ_FRAMEBUFFER_BINDING_APPLE                       0x8CAA
-#endif
-
-/* GL_APPLE_texture_format_BGRA8888 */
-#ifndef GL_APPLE_texture_format_BGRA8888
-#define GL_BGRA_EXT                                             0x80E1
-#endif
-
-/* GL_APPLE_texture_max_level */
-#ifndef GL_APPLE_texture_max_level
-#define GL_TEXTURE_MAX_LEVEL_APPLE                              0x813D
-#endif
-
-/*------------------------------------------------------------------------*
- * ARM extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_ARM_mali_shader_binary */
-#ifndef GL_ARM_mali_shader_binary
-#define GL_MALI_SHADER_BINARY_ARM                               0x8F60
-#endif
-
-/* GL_ARM_rgba8 */
-/* No new tokens introduced by this extension. */
-
-/*------------------------------------------------------------------------*
- * EXT extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_EXT_blend_minmax */
-#ifndef GL_EXT_blend_minmax
-#define GL_MIN_EXT                                              0x8007
-#define GL_MAX_EXT                                              0x8008
-#endif
-
-/* GL_EXT_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_multisampled_render_to_texture */
-#ifndef GL_EXT_multisampled_render_to_texture
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT           0x8D6C
-#define GL_RENDERBUFFER_SAMPLES_EXT                             0x9133
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT               0x9134
-#define GL_MAX_SAMPLES_EXT                                      0x9135
-#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_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 */
-#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
-
-/* 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
-
-/*------------------------------------------------------------------------*
- * 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_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
+#ifndef GL_KHR_texture_compression_astc_ldr
+#define GL_KHR_texture_compression_astc_ldr 1
+#endif /* GL_KHR_texture_compression_astc_ldr */
 
-/* GL_OES_EGL_image */
 #ifndef GL_OES_EGL_image
 #define GL_OES_EGL_image 1
+typedef void *GLeglImageOES;
+typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
+typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
 #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
+#endif /* GL_OES_EGL_image */
 
-/* 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
+#define GL_TEXTURE_EXTERNAL_OES           0x8D65
+#define GL_TEXTURE_BINDING_EXTERNAL_OES   0x8D67
+#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68
+#define GL_SAMPLER_EXTERNAL_OES           0x8D66
+#endif /* GL_OES_EGL_image_external */
 
-/* GL_OES_element_index_uint */
+#ifndef GL_OES_compressed_ETC1_RGB8_texture
+#define GL_OES_compressed_ETC1_RGB8_texture 1
+#define GL_ETC1_RGB8_OES                  0x8D64
+#endif /* GL_OES_compressed_ETC1_RGB8_texture */
+
+#ifndef GL_OES_compressed_paletted_texture
+#define GL_OES_compressed_paletted_texture 1
+#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_compressed_paletted_texture */
+
+#ifndef GL_OES_depth24
+#define GL_OES_depth24 1
+#define GL_DEPTH_COMPONENT24_OES          0x81A6
+#endif /* GL_OES_depth24 */
+
+#ifndef GL_OES_depth32
+#define GL_OES_depth32 1
+#define GL_DEPTH_COMPONENT32_OES          0x81A7
+#endif /* GL_OES_depth32 */
+
+#ifndef GL_OES_depth_texture
+#define GL_OES_depth_texture 1
+#endif /* GL_OES_depth_texture */
+
 #ifndef GL_OES_element_index_uint
 #define GL_OES_element_index_uint 1
-#endif
+#endif /* GL_OES_element_index_uint */
 
-/* GL_OES_fbo_render_mipmap */
 #ifndef GL_OES_fbo_render_mipmap
 #define GL_OES_fbo_render_mipmap 1
-#endif
+#endif /* GL_OES_fbo_render_mipmap */
 
-/* GL_OES_fragment_precision_high */
 #ifndef GL_OES_fragment_precision_high
 #define GL_OES_fragment_precision_high 1
-#endif
+#endif /* GL_OES_fragment_precision_high */
 
-/* GL_OES_get_program_binary */
 #ifndef GL_OES_get_program_binary
 #define GL_OES_get_program_binary 1
+#define GL_PROGRAM_BINARY_LENGTH_OES      0x8741
+#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE
+#define GL_PROGRAM_BINARY_FORMATS_OES     0x87FF
+typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);
+typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLint length);
 #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);
+GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);
+GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const void *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
+#endif /* GL_OES_get_program_binary */
 
-/* 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);
+#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
+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);
+typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, void **params);
+#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, void **params);
 #endif
+#endif /* GL_OES_mapbuffer */
 
-/* GL_OES_packed_depth_stencil */
 #ifndef GL_OES_packed_depth_stencil
 #define GL_OES_packed_depth_stencil 1
-#endif
+#define GL_DEPTH_STENCIL_OES              0x84F9
+#define GL_UNSIGNED_INT_24_8_OES          0x84FA
+#define GL_DEPTH24_STENCIL8_OES           0x88F0
+#endif /* GL_OES_packed_depth_stencil */
 
-/* GL_OES_rgb8_rgba8 */
+#ifndef GL_OES_required_internalformat
+#define GL_OES_required_internalformat 1
+#define GL_ALPHA8_OES                     0x803C
+#define GL_DEPTH_COMPONENT16_OES          0x81A5
+#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
+#define GL_RGB8_OES                       0x8051
+#define GL_RGBA8_OES                      0x8058
+#define GL_RGB10_EXT                      0x8052
+#define GL_RGB10_A2_EXT                   0x8059
+#endif /* GL_OES_required_internalformat */
+
 #ifndef GL_OES_rgb8_rgba8
 #define GL_OES_rgb8_rgba8 1
-#endif
+#endif /* GL_OES_rgb8_rgba8 */
 
-/* GL_OES_standard_derivatives */
+#ifndef GL_OES_sample_shading
+#define GL_OES_sample_shading 1
+#define GL_SAMPLE_SHADING_OES             0x8C36
+#define GL_MIN_SAMPLE_SHADING_VALUE_OES   0x8C37
+typedef void (GL_APIENTRYP PFNGLMINSAMPLESHADINGOESPROC) (GLfloat value);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glMinSampleShadingOES (GLfloat value);
+#endif
+#endif /* GL_OES_sample_shading */
+
+#ifndef GL_OES_sample_variables
+#define GL_OES_sample_variables 1
+#endif /* GL_OES_sample_variables */
+
+#ifndef GL_OES_shader_image_atomic
+#define GL_OES_shader_image_atomic 1
+#endif /* GL_OES_shader_image_atomic */
+
+#ifndef GL_OES_shader_multisample_interpolation
+#define GL_OES_shader_multisample_interpolation 1
+#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5B
+#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5C
+#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES 0x8E5D
+#endif /* GL_OES_shader_multisample_interpolation */
+
 #ifndef GL_OES_standard_derivatives
 #define GL_OES_standard_derivatives 1
-#endif
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B
+#endif /* GL_OES_standard_derivatives */
 
-/* GL_OES_stencil1 */
 #ifndef GL_OES_stencil1
 #define GL_OES_stencil1 1
-#endif
+#define GL_STENCIL_INDEX1_OES             0x8D46
+#endif /* GL_OES_stencil1 */
 
-/* GL_OES_stencil4 */
 #ifndef GL_OES_stencil4
 #define GL_OES_stencil4 1
-#endif
+#define GL_STENCIL_INDEX4_OES             0x8D47
+#endif /* GL_OES_stencil4 */
 
-/* GL_OES_texture_3D */
+#ifndef GL_OES_surfaceless_context
+#define GL_OES_surfaceless_context 1
+#define GL_FRAMEBUFFER_UNDEFINED_OES      0x8219
+#endif /* GL_OES_surfaceless_context */
+
 #ifndef GL_OES_texture_3D
 #define GL_OES_texture_3D 1
+#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
+typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *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 void *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 void *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 void *data);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
 #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 glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *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 void *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 glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *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 void *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
+#endif /* GL_OES_texture_3D */
 
-/* GL_OES_texture_float */
+#ifndef GL_OES_texture_compression_astc
+#define GL_OES_texture_compression_astc 1
+#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0
+#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1
+#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2
+#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3
+#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4
+#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5
+#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6
+#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7
+#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8
+#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9
+#endif /* GL_OES_texture_compression_astc */
+
 #ifndef GL_OES_texture_float
 #define GL_OES_texture_float 1
-#endif
+#endif /* GL_OES_texture_float */
 
-/* GL_OES_texture_float_linear */
 #ifndef GL_OES_texture_float_linear
 #define GL_OES_texture_float_linear 1
-#endif
+#endif /* GL_OES_texture_float_linear */
 
-/* GL_OES_texture_half_float */
 #ifndef GL_OES_texture_half_float
 #define GL_OES_texture_half_float 1
-#endif
+#define GL_HALF_FLOAT_OES                 0x8D61
+#endif /* GL_OES_texture_half_float */
 
-/* GL_OES_texture_half_float_linear */
 #ifndef GL_OES_texture_half_float_linear
 #define GL_OES_texture_half_float_linear 1
-#endif
+#endif /* GL_OES_texture_half_float_linear */
 
-/* GL_OES_texture_npot */
 #ifndef GL_OES_texture_npot
 #define GL_OES_texture_npot 1
-#endif
+#endif /* GL_OES_texture_npot */
 
-/* GL_OES_vertex_array_object */
+#ifndef GL_OES_texture_stencil8
+#define GL_OES_texture_stencil8 1
+#define GL_STENCIL_INDEX_OES              0x1901
+#define GL_STENCIL_INDEX8_OES             0x8D48
+#endif /* GL_OES_texture_stencil8 */
+
+#ifndef GL_OES_texture_storage_multisample_2d_array
+#define GL_OES_texture_storage_multisample_2d_array 1
+#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES 0x9102
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES 0x9105
+#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910B
+#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910C
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910D
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTexStorage3DMultisampleOES (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+#endif
+#endif /* GL_OES_texture_storage_multisample_2d_array */
+
 #ifndef GL_OES_vertex_array_object
 #define GL_OES_vertex_array_object 1
+#define GL_VERTEX_ARRAY_BINDING_OES       0x85B5
+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);
 #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
+#endif /* GL_OES_vertex_array_object */
 
-/* GL_OES_vertex_half_float */
 #ifndef GL_OES_vertex_half_float
 #define GL_OES_vertex_half_float 1
-#endif
+#endif /* GL_OES_vertex_half_float */
 
-/* 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
+#define GL_UNSIGNED_INT_10_10_10_2_OES    0x8DF6
+#define GL_INT_10_10_10_2_OES             0x8DF7
+#endif /* GL_OES_vertex_type_10_10_10_2 */
 
-/*------------------------------------------------------------------------*
- * AMD extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_AMD_compressed_3DC_texture */
 #ifndef GL_AMD_compressed_3DC_texture
 #define GL_AMD_compressed_3DC_texture 1
-#endif
+#define GL_3DC_X_AMD                      0x87F9
+#define GL_3DC_XY_AMD                     0x87FA
+#endif /* GL_AMD_compressed_3DC_texture */
 
-/* GL_AMD_compressed_ATC_texture */
 #ifndef GL_AMD_compressed_ATC_texture
 #define GL_AMD_compressed_ATC_texture 1
-#endif
+#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_compressed_ATC_texture */
 
-/* AMD_performance_monitor */
 #ifndef GL_AMD_performance_monitor
 #define GL_AMD_performance_monitor 1
+#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
+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, void *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 *counterList);
+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);
 #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 glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *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 glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList);
 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
+#endif /* GL_AMD_performance_monitor */
 
-/* GL_AMD_program_binary_Z400 */
 #ifndef GL_AMD_program_binary_Z400
 #define GL_AMD_program_binary_Z400 1
-#endif
+#define GL_Z400_BINARY_AMD                0x8740
+#endif /* GL_AMD_program_binary_Z400 */
 
-/*------------------------------------------------------------------------*
- * ANGLE extension functions
- *------------------------------------------------------------------------*/
+#ifndef GL_ANGLE_depth_texture
+#define GL_ANGLE_depth_texture 1
+#endif /* GL_ANGLE_depth_texture */
 
-/* GL_ANGLE_framebuffer_blit */
 #ifndef GL_ANGLE_framebuffer_blit
 #define GL_ANGLE_framebuffer_blit 1
+#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
+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);
 #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
+#endif /* GL_ANGLE_framebuffer_blit */
 
-/* GL_ANGLE_framebuffer_multisample */
 #ifndef GL_ANGLE_framebuffer_multisample
 #define GL_ANGLE_framebuffer_multisample 1
+#define GL_RENDERBUFFER_SAMPLES_ANGLE     0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56
+#define GL_MAX_SAMPLES_ANGLE              0x8D57
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
 #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 /* GL_ANGLE_framebuffer_multisample */
+
+#ifndef GL_ANGLE_instanced_arrays
+#define GL_ANGLE_instanced_arrays 1
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE
+typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor);
+#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
+#endif /* GL_ANGLE_instanced_arrays */
 
-/*------------------------------------------------------------------------*
- * APPLE extension functions
- *------------------------------------------------------------------------*/
+#ifndef GL_ANGLE_pack_reverse_row_order
+#define GL_ANGLE_pack_reverse_row_order 1
+#define GL_PACK_REVERSE_ROW_ORDER_ANGLE   0x93A4
+#endif /* GL_ANGLE_pack_reverse_row_order */
 
-/* GL_APPLE_rgb_422 */
-#ifndef GL_APPLE_rgb_422
-#define GL_APPLE_rgb_422 1
+#ifndef GL_ANGLE_program_binary
+#define GL_ANGLE_program_binary 1
+#define GL_PROGRAM_BINARY_ANGLE           0x93A6
+#endif /* GL_ANGLE_program_binary */
+
+#ifndef GL_ANGLE_texture_compression_dxt3
+#define GL_ANGLE_texture_compression_dxt3 1
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2
+#endif /* GL_ANGLE_texture_compression_dxt3 */
+
+#ifndef GL_ANGLE_texture_compression_dxt5
+#define GL_ANGLE_texture_compression_dxt5 1
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3
+#endif /* GL_ANGLE_texture_compression_dxt5 */
+
+#ifndef GL_ANGLE_texture_usage
+#define GL_ANGLE_texture_usage 1
+#define GL_TEXTURE_USAGE_ANGLE            0x93A2
+#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE   0x93A3
+#endif /* GL_ANGLE_texture_usage */
+
+#ifndef GL_ANGLE_translated_shader_source
+#define GL_ANGLE_translated_shader_source 1
+#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0
+typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
 #endif
+#endif /* GL_ANGLE_translated_shader_source */
 
-/* GL_APPLE_framebuffer_multisample */
+#ifndef GL_APPLE_copy_texture_levels
+#define GL_APPLE_copy_texture_levels 1
+typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
+#endif
+#endif /* GL_APPLE_copy_texture_levels */
+
 #ifndef GL_APPLE_framebuffer_multisample
 #define GL_APPLE_framebuffer_multisample 1
+#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
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void);
 #ifdef GL_GLEXT_PROTOTYPES
 GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
 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
+#endif /* GL_APPLE_framebuffer_multisample */
 
-/* GL_APPLE_texture_format_BGRA8888 */
+#ifndef GL_APPLE_rgb_422
+#define GL_APPLE_rgb_422 1
+#define GL_RGB_422_APPLE                  0x8A1F
+#define GL_UNSIGNED_SHORT_8_8_APPLE       0x85BA
+#define GL_UNSIGNED_SHORT_8_8_REV_APPLE   0x85BB
+#define GL_RGB_RAW_422_APPLE              0x8A51
+#endif /* GL_APPLE_rgb_422 */
+
+#ifndef GL_APPLE_sync
+#define GL_APPLE_sync 1
+#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
+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);
+#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
+#endif /* GL_APPLE_sync */
+
 #ifndef GL_APPLE_texture_format_BGRA8888
 #define GL_APPLE_texture_format_BGRA8888 1
-#endif
+#define GL_BGRA_EXT                       0x80E1
+#define GL_BGRA8_EXT                      0x93A1
+#endif /* GL_APPLE_texture_format_BGRA8888 */
 
-/* GL_APPLE_texture_max_level */
 #ifndef GL_APPLE_texture_max_level
 #define GL_APPLE_texture_max_level 1
-#endif
+#define GL_TEXTURE_MAX_LEVEL_APPLE        0x813D
+#endif /* GL_APPLE_texture_max_level */
 
-/*------------------------------------------------------------------------*
- * ARM extension functions
- *------------------------------------------------------------------------*/
+#ifndef GL_ARM_mali_program_binary
+#define GL_ARM_mali_program_binary 1
+#define GL_MALI_PROGRAM_BINARY_ARM        0x8F61
+#endif /* GL_ARM_mali_program_binary */
 
-/* GL_ARM_mali_shader_binary */
 #ifndef GL_ARM_mali_shader_binary
 #define GL_ARM_mali_shader_binary 1
-#endif
+#define GL_MALI_SHADER_BINARY_ARM         0x8F60
+#endif /* GL_ARM_mali_shader_binary */
 
-/* GL_ARM_rgba8 */
 #ifndef GL_ARM_rgba8
 #define GL_ARM_rgba8 1
-#endif
+#endif /* GL_ARM_rgba8 */
 
-/*------------------------------------------------------------------------*
- * EXT extension functions
- *------------------------------------------------------------------------*/
+#ifndef GL_ARM_shader_framebuffer_fetch
+#define GL_ARM_shader_framebuffer_fetch 1
+#define GL_FETCH_PER_SAMPLE_ARM           0x8F65
+#define GL_FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM 0x8F66
+#endif /* GL_ARM_shader_framebuffer_fetch */
 
-/* GL_EXT_blend_minmax */
+#ifndef GL_ARM_shader_framebuffer_fetch_depth_stencil
+#define GL_ARM_shader_framebuffer_fetch_depth_stencil 1
+#endif /* GL_ARM_shader_framebuffer_fetch_depth_stencil */
+
+#ifndef GL_DMP_shader_binary
+#define GL_DMP_shader_binary 1
+#define GL_SHADER_BINARY_DMP              0x9250
+#endif /* GL_DMP_shader_binary */
+
 #ifndef GL_EXT_blend_minmax
 #define GL_EXT_blend_minmax 1
-#endif
+#define GL_MIN_EXT                        0x8007
+#define GL_MAX_EXT                        0x8008
+#endif /* GL_EXT_blend_minmax */
 
-/* GL_EXT_color_buffer_half_float */
 #ifndef GL_EXT_color_buffer_half_float
 #define GL_EXT_color_buffer_half_float 1
-#endif
+#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_color_buffer_half_float */
 
-/* GL_EXT_debug_label */
+#ifndef GL_EXT_copy_image
+#define GL_EXT_copy_image 1
+typedef void (GL_APIENTRYP PFNGLCOPYIMAGESUBDATAEXTPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glCopyImageSubDataEXT (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
+#endif
+#endif /* GL_EXT_copy_image */
+
 #ifndef GL_EXT_debug_label
 #define GL_EXT_debug_label 1
+#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
+#define GL_TRANSFORM_FEEDBACK             0x8E22
+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);
 #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
+#endif /* GL_EXT_debug_label */
 
-/* GL_EXT_debug_marker */
 #ifndef GL_EXT_debug_marker
 #define GL_EXT_debug_marker 1
+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);
 #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
+#endif /* GL_EXT_debug_marker */
 
-/* GL_EXT_discard_framebuffer */
 #ifndef GL_EXT_discard_framebuffer
 #define GL_EXT_discard_framebuffer 1
+#define GL_COLOR_EXT                      0x1800
+#define GL_DEPTH_EXT                      0x1801
+#define GL_STENCIL_EXT                    0x1802
+typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
 #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
+#endif /* GL_EXT_discard_framebuffer */
 
-/* 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 target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
-#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
-
-#ifndef GL_EXT_multi_draw_arrays
-#define GL_EXT_multi_draw_arrays 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
-GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
-#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
+#ifndef GL_EXT_disjoint_timer_query
+#define GL_EXT_disjoint_timer_query 1
+#define GL_QUERY_COUNTER_BITS_EXT         0x8864
+#define GL_CURRENT_QUERY_EXT              0x8865
+#define GL_QUERY_RESULT_EXT               0x8866
+#define GL_QUERY_RESULT_AVAILABLE_EXT     0x8867
+#define GL_TIME_ELAPSED_EXT               0x88BF
+#define GL_TIMESTAMP_EXT                  0x8E28
+#define GL_GPU_DISJOINT_EXT               0x8FBB
+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 PFNGLQUERYCOUNTEREXTPROC) (GLuint id, GLenum target);
+typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTIVEXTPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params);
+typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params);
+typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params);
 #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 glQueryCounterEXT (GLuint id, GLenum target);
 GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetQueryObjectivEXT (GLuint id, GLenum pname, GLint *params);
 GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params);
+GL_APICALL void GL_APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params);
+GL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *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
+#endif /* GL_EXT_disjoint_timer_query */
 
-/* GL_EXT_read_format_bgra */
+#ifndef GL_EXT_draw_buffers
+#define GL_EXT_draw_buffers 1
+#define GL_MAX_COLOR_ATTACHMENTS_EXT      0x8CDF
+#define GL_MAX_DRAW_BUFFERS_EXT           0x8824
+#define GL_DRAW_BUFFER0_EXT               0x8825
+#define GL_DRAW_BUFFER1_EXT               0x8826
+#define GL_DRAW_BUFFER2_EXT               0x8827
+#define GL_DRAW_BUFFER3_EXT               0x8828
+#define GL_DRAW_BUFFER4_EXT               0x8829
+#define GL_DRAW_BUFFER5_EXT               0x882A
+#define GL_DRAW_BUFFER6_EXT               0x882B
+#define GL_DRAW_BUFFER7_EXT               0x882C
+#define GL_DRAW_BUFFER8_EXT               0x882D
+#define GL_DRAW_BUFFER9_EXT               0x882E
+#define GL_DRAW_BUFFER10_EXT              0x882F
+#define GL_DRAW_BUFFER11_EXT              0x8830
+#define GL_DRAW_BUFFER12_EXT              0x8831
+#define GL_DRAW_BUFFER13_EXT              0x8832
+#define GL_DRAW_BUFFER14_EXT              0x8833
+#define GL_DRAW_BUFFER15_EXT              0x8834
+#define GL_COLOR_ATTACHMENT0_EXT          0x8CE0
+#define GL_COLOR_ATTACHMENT1_EXT          0x8CE1
+#define GL_COLOR_ATTACHMENT2_EXT          0x8CE2
+#define GL_COLOR_ATTACHMENT3_EXT          0x8CE3
+#define GL_COLOR_ATTACHMENT4_EXT          0x8CE4
+#define GL_COLOR_ATTACHMENT5_EXT          0x8CE5
+#define GL_COLOR_ATTACHMENT6_EXT          0x8CE6
+#define GL_COLOR_ATTACHMENT7_EXT          0x8CE7
+#define GL_COLOR_ATTACHMENT8_EXT          0x8CE8
+#define GL_COLOR_ATTACHMENT9_EXT          0x8CE9
+#define GL_COLOR_ATTACHMENT10_EXT         0x8CEA
+#define GL_COLOR_ATTACHMENT11_EXT         0x8CEB
+#define GL_COLOR_ATTACHMENT12_EXT         0x8CEC
+#define GL_COLOR_ATTACHMENT13_EXT         0x8CED
+#define GL_COLOR_ATTACHMENT14_EXT         0x8CEE
+#define GL_COLOR_ATTACHMENT15_EXT         0x8CEF
+typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei n, const GLenum *bufs);
+#endif
+#endif /* GL_EXT_draw_buffers */
+
+#ifndef GL_EXT_draw_buffers_indexed
+#define GL_EXT_draw_buffers_indexed 1
+#define GL_MIN                            0x8007
+#define GL_MAX                            0x8008
+typedef void (GL_APIENTRYP PFNGLENABLEIEXTPROC) (GLenum target, GLuint index);
+typedef void (GL_APIENTRYP PFNGLDISABLEIEXTPROC) (GLenum target, GLuint index);
+typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONIEXTPROC) (GLuint buf, GLenum mode);
+typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIEXTPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+typedef void (GL_APIENTRYP PFNGLBLENDFUNCIEXTPROC) (GLuint buf, GLenum src, GLenum dst);
+typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIEXTPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+typedef void (GL_APIENTRYP PFNGLCOLORMASKIEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDIEXTPROC) (GLenum target, GLuint index);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glEnableiEXT (GLenum target, GLuint index);
+GL_APICALL void GL_APIENTRY glDisableiEXT (GLenum target, GLuint index);
+GL_APICALL void GL_APIENTRY glBlendEquationiEXT (GLuint buf, GLenum mode);
+GL_APICALL void GL_APIENTRY glBlendEquationSeparateiEXT (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+GL_APICALL void GL_APIENTRY glBlendFunciEXT (GLuint buf, GLenum src, GLenum dst);
+GL_APICALL void GL_APIENTRY glBlendFuncSeparateiEXT (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+GL_APICALL void GL_APIENTRY glColorMaskiEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+GL_APICALL GLboolean GL_APIENTRY glIsEnablediEXT (GLenum target, GLuint index);
+#endif
+#endif /* GL_EXT_draw_buffers_indexed */
+
+#ifndef GL_EXT_draw_instanced
+#define GL_EXT_draw_instanced 1
+typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+#endif
+#endif /* GL_EXT_draw_instanced */
+
+#ifndef GL_EXT_geometry_shader
+#define GL_EXT_geometry_shader 1
+#define GL_GEOMETRY_SHADER_EXT            0x8DD9
+#define GL_GEOMETRY_SHADER_BIT_EXT        0x00000004
+#define GL_GEOMETRY_LINKED_VERTICES_OUT_EXT 0x8916
+#define GL_GEOMETRY_LINKED_INPUT_TYPE_EXT 0x8917
+#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT 0x8918
+#define GL_GEOMETRY_SHADER_INVOCATIONS_EXT 0x887F
+#define GL_LAYER_PROVOKING_VERTEX_EXT     0x825E
+#define GL_LINES_ADJACENCY_EXT            0x000A
+#define GL_LINE_STRIP_ADJACENCY_EXT       0x000B
+#define GL_TRIANGLES_ADJACENCY_EXT        0x000C
+#define GL_TRIANGLE_STRIP_ADJACENCY_EXT   0x000D
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF
+#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT 0x8A2C
+#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8A32
+#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT 0x9123
+#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT 0x9124
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1
+#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT 0x8E5A
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT 0x92CF
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT 0x92D5
+#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT 0x90CD
+#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT 0x90D7
+#define GL_FIRST_VERTEX_CONVENTION_EXT    0x8E4D
+#define GL_LAST_VERTEX_CONVENTION_EXT     0x8E4E
+#define GL_UNDEFINED_VERTEX_EXT           0x8260
+#define GL_PRIMITIVES_GENERATED_EXT       0x8C87
+#define GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT 0x9312
+#define GL_MAX_FRAMEBUFFER_LAYERS_EXT     0x9317
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7
+#define GL_REFERENCED_BY_GEOMETRY_SHADER_EXT 0x9309
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level);
+#endif
+#endif /* GL_EXT_geometry_shader */
+
+#ifndef GL_EXT_gpu_shader5
+#define GL_EXT_gpu_shader5 1
+#endif /* GL_EXT_gpu_shader5 */
+
+#ifndef GL_EXT_instanced_arrays
+#define GL_EXT_instanced_arrays 1
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_EXT 0x88FE
+typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISOREXTPROC) (GLuint index, GLuint divisor);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glVertexAttribDivisorEXT (GLuint index, GLuint divisor);
+#endif
+#endif /* GL_EXT_instanced_arrays */
+
+#ifndef GL_EXT_map_buffer_range
+#define GL_EXT_map_buffer_range 1
+#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
+typedef void *(GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length);
+#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
+#endif /* GL_EXT_map_buffer_range */
+
+#ifndef GL_EXT_multi_draw_arrays
+#define GL_EXT_multi_draw_arrays 1
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount);
+#endif
+#endif /* GL_EXT_multi_draw_arrays */
+
+#ifndef GL_EXT_multisampled_render_to_texture
+#define GL_EXT_multisampled_render_to_texture 1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
+#define GL_RENDERBUFFER_SAMPLES_EXT       0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
+#define GL_MAX_SAMPLES_EXT                0x8D57
+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);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#endif
+#endif /* GL_EXT_multisampled_render_to_texture */
+
+#ifndef GL_EXT_multiview_draw_buffers
+#define GL_EXT_multiview_draw_buffers 1
+#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
+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);
+#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
+#endif /* GL_EXT_multiview_draw_buffers */
+
+#ifndef GL_EXT_occlusion_query_boolean
+#define GL_EXT_occlusion_query_boolean 1
+#define GL_ANY_SAMPLES_PASSED_EXT         0x8C2F
+#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A
+#endif /* GL_EXT_occlusion_query_boolean */
+
+#ifndef GL_EXT_primitive_bounding_box
+#define GL_EXT_primitive_bounding_box 1
+#define GL_PRIMITIVE_BOUNDING_BOX_EXT     0x92BE
+typedef void (GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXEXTPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glPrimitiveBoundingBoxEXT (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
+#endif
+#endif /* GL_EXT_primitive_bounding_box */
+
+#ifndef GL_EXT_pvrtc_sRGB
+#define GL_EXT_pvrtc_sRGB 1
+#define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54
+#define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1
+#endif /* GL_EXT_pvrtc_sRGB */
+
 #ifndef GL_EXT_read_format_bgra
 #define GL_EXT_read_format_bgra 1
-#endif
+#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_read_format_bgra */
 
-/* GL_EXT_robustness */
 #ifndef GL_EXT_robustness
 #define GL_EXT_robustness 1
+#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
+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, GLfloat *params);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);
 #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 glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, GLfloat *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
+#endif /* GL_EXT_robustness */
 
-/* GL_EXT_separate_shader_objects */
+#ifndef GL_EXT_sRGB
+#define GL_EXT_sRGB 1
+#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_sRGB */
+
+#ifndef GL_EXT_sRGB_write_control
+#define GL_EXT_sRGB_write_control 1
+#define GL_FRAMEBUFFER_SRGB_EXT           0x8DB9
+#endif /* GL_EXT_sRGB_write_control */
+
 #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);
+#define GL_ACTIVE_PROGRAM_EXT             0x8259
+#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_PROGRAM_PIPELINE_BINDING_EXT   0x825A
 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 GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar **strings);
 typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC) (GLsizei n, const GLuint *pipelines);
 typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC) (GLsizei n, GLuint *pipelines);
+typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC) (GLuint pipeline, GLenum pname, GLint *params);
 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 PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0);
 typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1);
 typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
 typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
 typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *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 PFNGLUSEPROGRAMSTAGESEXTPROC) (GLuint pipeline, GLbitfield stages, GLuint program);
 typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline);
-typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT (GLuint pipeline, GLuint program);
+GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT (GLuint pipeline);
+GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar **strings);
+GL_APICALL void GL_APIENTRY glDeleteProgramPipelinesEXT (GLsizei n, const GLuint *pipelines);
+GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT (GLsizei n, GLuint *pipelines);
+GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT (GLuint pipeline, GLenum pname, GLint *params);
+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 glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0);
+GL_APICALL void GL_APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0);
+GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1);
+GL_APICALL void GL_APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1);
+GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GL_APICALL void GL_APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GL_APICALL void GL_APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *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 glUseProgramStagesEXT (GLuint pipeline, GLbitfield stages, GLuint program);
+GL_APICALL void GL_APIENTRY glValidateProgramPipelineEXT (GLuint pipeline);
+GL_APICALL void GL_APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0);
+GL_APICALL void GL_APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1);
+GL_APICALL void GL_APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+GL_APICALL void GL_APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GL_APICALL void GL_APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
 #endif
+#endif /* GL_EXT_separate_shader_objects */
 
-/* GL_EXT_shader_texture_lod */
+#ifndef GL_EXT_shader_framebuffer_fetch
+#define GL_EXT_shader_framebuffer_fetch 1
+#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52
+#endif /* GL_EXT_shader_framebuffer_fetch */
+
+#ifndef GL_EXT_shader_implicit_conversions
+#define GL_EXT_shader_implicit_conversions 1
+#endif /* GL_EXT_shader_implicit_conversions */
+
+#ifndef GL_EXT_shader_integer_mix
+#define GL_EXT_shader_integer_mix 1
+#endif /* GL_EXT_shader_integer_mix */
+
+#ifndef GL_EXT_shader_io_blocks
+#define GL_EXT_shader_io_blocks 1
+#endif /* GL_EXT_shader_io_blocks */
+
+#ifndef GL_EXT_shader_pixel_local_storage
+#define GL_EXT_shader_pixel_local_storage 1
+#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT 0x8F63
+#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE_EXT 0x8F67
+#define GL_SHADER_PIXEL_LOCAL_STORAGE_EXT 0x8F64
+#endif /* GL_EXT_shader_pixel_local_storage */
+
 #ifndef GL_EXT_shader_texture_lod
 #define GL_EXT_shader_texture_lod 1
-#endif
+#endif /* GL_EXT_shader_texture_lod */
 
-/* GL_EXT_shadow_samplers */
 #ifndef GL_EXT_shadow_samplers
 #define GL_EXT_shadow_samplers 1
-#endif
+#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_shadow_samplers */
 
-/* GL_EXT_sRGB */
-#ifndef GL_EXT_sRGB
-#define GL_EXT_sRGB 1
+#ifndef GL_EXT_tessellation_shader
+#define GL_EXT_tessellation_shader 1
+#define GL_PATCHES_EXT                    0x000E
+#define GL_PATCH_VERTICES_EXT             0x8E72
+#define GL_TESS_CONTROL_OUTPUT_VERTICES_EXT 0x8E75
+#define GL_TESS_GEN_MODE_EXT              0x8E76
+#define GL_TESS_GEN_SPACING_EXT           0x8E77
+#define GL_TESS_GEN_VERTEX_ORDER_EXT      0x8E78
+#define GL_TESS_GEN_POINT_MODE_EXT        0x8E79
+#define GL_ISOLINES_EXT                   0x8E7A
+#define GL_QUADS_EXT                      0x0007
+#define GL_FRACTIONAL_ODD_EXT             0x8E7B
+#define GL_FRACTIONAL_EVEN_EXT            0x8E7C
+#define GL_MAX_PATCH_VERTICES_EXT         0x8E7D
+#define GL_MAX_TESS_GEN_LEVEL_EXT         0x8E7E
+#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E7F
+#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E80
+#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT 0x8E81
+#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT 0x8E82
+#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT 0x8E83
+#define GL_MAX_TESS_PATCH_COMPONENTS_EXT  0x8E84
+#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT 0x8E85
+#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT 0x8E86
+#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT 0x8E89
+#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT 0x8E8A
+#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT 0x886C
+#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT 0x886D
+#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E1E
+#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E1F
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT 0x92CD
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT 0x92CE
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT 0x92D3
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT 0x92D4
+#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT 0x90CB
+#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT 0x90CC
+#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT 0x90D8
+#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT 0x90D9
+#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221
+#define GL_IS_PER_PATCH_EXT               0x92E7
+#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT 0x9307
+#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT 0x9308
+#define GL_TESS_CONTROL_SHADER_EXT        0x8E88
+#define GL_TESS_EVALUATION_SHADER_EXT     0x8E87
+#define GL_TESS_CONTROL_SHADER_BIT_EXT    0x00000008
+#define GL_TESS_EVALUATION_SHADER_BIT_EXT 0x00000010
+typedef void (GL_APIENTRYP PFNGLPATCHPARAMETERIEXTPROC) (GLenum pname, GLint value);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glPatchParameteriEXT (GLenum pname, GLint value);
 #endif
+#endif /* GL_EXT_tessellation_shader */
 
-/* GL_EXT_texture_compression_dxt1 */
+#ifndef GL_EXT_texture_border_clamp
+#define GL_EXT_texture_border_clamp 1
+#define GL_TEXTURE_BORDER_COLOR_EXT       0x1004
+#define GL_CLAMP_TO_BORDER_EXT            0x812D
+typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params);
+typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVEXTPROC) (GLuint sampler, GLenum pname, const GLint *param);
+typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVEXTPROC) (GLuint sampler, GLenum pname, const GLuint *param);
+typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVEXTPROC) (GLuint sampler, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVEXTPROC) (GLuint sampler, GLenum pname, GLuint *params);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params);
+GL_APICALL void GL_APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params);
+GL_APICALL void GL_APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params);
+GL_APICALL void GL_APIENTRY glSamplerParameterIivEXT (GLuint sampler, GLenum pname, const GLint *param);
+GL_APICALL void GL_APIENTRY glSamplerParameterIuivEXT (GLuint sampler, GLenum pname, const GLuint *param);
+GL_APICALL void GL_APIENTRY glGetSamplerParameterIivEXT (GLuint sampler, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetSamplerParameterIuivEXT (GLuint sampler, GLenum pname, GLuint *params);
+#endif
+#endif /* GL_EXT_texture_border_clamp */
+
+#ifndef GL_EXT_texture_buffer
+#define GL_EXT_texture_buffer 1
+#define GL_TEXTURE_BUFFER_EXT             0x8C2A
+#define GL_TEXTURE_BUFFER_BINDING_EXT     0x8C2A
+#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT    0x8C2B
+#define GL_TEXTURE_BINDING_BUFFER_EXT     0x8C2C
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D
+#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT 0x919F
+#define GL_SAMPLER_BUFFER_EXT             0x8DC2
+#define GL_INT_SAMPLER_BUFFER_EXT         0x8DD0
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8
+#define GL_IMAGE_BUFFER_EXT               0x9051
+#define GL_INT_IMAGE_BUFFER_EXT           0x905C
+#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT  0x9067
+#define GL_TEXTURE_BUFFER_OFFSET_EXT      0x919D
+#define GL_TEXTURE_BUFFER_SIZE_EXT        0x919E
+typedef void (GL_APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (GL_APIENTRYP PFNGLTEXBUFFERRANGEEXTPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer);
+GL_APICALL void GL_APIENTRY glTexBufferRangeEXT (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+#endif
+#endif /* GL_EXT_texture_buffer */
+
 #ifndef GL_EXT_texture_compression_dxt1
 #define GL_EXT_texture_compression_dxt1 1
-#endif
+#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT   0x83F0
+#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT  0x83F1
+#endif /* GL_EXT_texture_compression_dxt1 */
 
-/* GL_EXT_texture_filter_anisotropic */
+#ifndef GL_EXT_texture_compression_s3tc
+#define GL_EXT_texture_compression_s3tc 1
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT  0x83F2
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT  0x83F3
+#endif /* GL_EXT_texture_compression_s3tc */
+
+#ifndef GL_EXT_texture_cube_map_array
+#define GL_EXT_texture_cube_map_array 1
+#define GL_TEXTURE_CUBE_MAP_ARRAY_EXT     0x9009
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT 0x900A
+#define GL_SAMPLER_CUBE_MAP_ARRAY_EXT     0x900C
+#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT 0x900D
+#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900E
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900F
+#define GL_IMAGE_CUBE_MAP_ARRAY_EXT       0x9054
+#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT   0x905F
+#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A
+#endif /* GL_EXT_texture_cube_map_array */
+
 #ifndef GL_EXT_texture_filter_anisotropic
 #define GL_EXT_texture_filter_anisotropic 1
-#endif
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT     0x84FE
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
+#endif /* GL_EXT_texture_filter_anisotropic */
 
-/* GL_EXT_texture_format_BGRA8888 */
 #ifndef GL_EXT_texture_format_BGRA8888
 #define GL_EXT_texture_format_BGRA8888 1
-#endif
+#endif /* GL_EXT_texture_format_BGRA8888 */
 
-/* GL_EXT_texture_rg */
 #ifndef GL_EXT_texture_rg
 #define GL_EXT_texture_rg 1
-#endif
+#define GL_RED_EXT                        0x1903
+#define GL_RG_EXT                         0x8227
+#define GL_R8_EXT                         0x8229
+#define GL_RG8_EXT                        0x822B
+#endif /* GL_EXT_texture_rg */
 
-/* GL_EXT_texture_storage */
+#ifndef GL_EXT_texture_sRGB_decode
+#define GL_EXT_texture_sRGB_decode 1
+#define GL_TEXTURE_SRGB_DECODE_EXT        0x8A48
+#define GL_DECODE_EXT                     0x8A49
+#define GL_SKIP_DECODE_EXT                0x8A4A
+#endif /* GL_EXT_texture_sRGB_decode */
+
 #ifndef GL_EXT_texture_storage
 #define GL_EXT_texture_storage 1
+#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
+#define GL_ALPHA16F_EXT                   0x881C
+#define GL_LUMINANCE16F_EXT               0x881E
+#define GL_LUMINANCE_ALPHA16F_EXT         0x881F
+#define GL_R32F_EXT                       0x822E
+#define GL_RG32F_EXT                      0x8230
+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);
 #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);
@@ -1163,105 +1362,298 @@
 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
+#endif /* GL_EXT_texture_storage */
 
-/* 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
+#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368
+#endif /* GL_EXT_texture_type_2_10_10_10_REV */
 
-/* GL_EXT_unpack_subimage */
+#ifndef GL_EXT_texture_view
+#define GL_EXT_texture_view 1
+#define GL_TEXTURE_VIEW_MIN_LEVEL_EXT     0x82DB
+#define GL_TEXTURE_VIEW_NUM_LEVELS_EXT    0x82DC
+#define GL_TEXTURE_VIEW_MIN_LAYER_EXT     0x82DD
+#define GL_TEXTURE_VIEW_NUM_LAYERS_EXT    0x82DE
+#define GL_TEXTURE_IMMUTABLE_LEVELS       0x82DF
+typedef void (GL_APIENTRYP PFNGLTEXTUREVIEWEXTPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTextureViewEXT (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+#endif
+#endif /* GL_EXT_texture_view */
+
 #ifndef GL_EXT_unpack_subimage
 #define GL_EXT_unpack_subimage 1
-#endif
+#define GL_UNPACK_ROW_LENGTH_EXT          0x0CF2
+#define GL_UNPACK_SKIP_ROWS_EXT           0x0CF3
+#define GL_UNPACK_SKIP_PIXELS_EXT         0x0CF4
+#endif /* GL_EXT_unpack_subimage */
 
-/*------------------------------------------------------------------------*
- * DMP extension functions
- *------------------------------------------------------------------------*/
+#ifndef GL_FJ_shader_binary_GCCSO
+#define GL_FJ_shader_binary_GCCSO 1
+#define GL_GCCSO_SHADER_BINARY_FJ         0x9260
+#endif /* GL_FJ_shader_binary_GCCSO */
 
-/* GL_DMP_shader_binary */
-#ifndef GL_DMP_shader_binary
-#define GL_DMP_shader_binary 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
+#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
+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);
 #ifdef GL_GLEXT_PROTOTYPES
 GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
 GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
 #endif
-typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#endif /* GL_IMG_multisampled_render_to_texture */
+
+#ifndef GL_IMG_program_binary
+#define GL_IMG_program_binary 1
+#define GL_SGX_PROGRAM_BINARY_IMG         0x9130
+#endif /* GL_IMG_program_binary */
+
+#ifndef GL_IMG_read_format
+#define GL_IMG_read_format 1
+#define GL_BGRA_IMG                       0x80E1
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365
+#endif /* GL_IMG_read_format */
+
+#ifndef GL_IMG_shader_binary
+#define GL_IMG_shader_binary 1
+#define GL_SGX_BINARY_IMG                 0x8C0A
+#endif /* GL_IMG_shader_binary */
+
+#ifndef GL_IMG_texture_compression_pvrtc
+#define GL_IMG_texture_compression_pvrtc 1
+#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_compression_pvrtc */
+
+#ifndef GL_IMG_texture_compression_pvrtc2
+#define GL_IMG_texture_compression_pvrtc2 1
+#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137
+#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138
+#endif /* GL_IMG_texture_compression_pvrtc2 */
+
+#ifndef GL_INTEL_performance_query
+#define GL_INTEL_performance_query 1
+#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000
+#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001
+#define GL_PERFQUERY_WAIT_INTEL           0x83FB
+#define GL_PERFQUERY_FLUSH_INTEL          0x83FA
+#define GL_PERFQUERY_DONOT_FLUSH_INTEL    0x83F9
+#define GL_PERFQUERY_COUNTER_EVENT_INTEL  0x94F0
+#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1
+#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2
+#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3
+#define GL_PERFQUERY_COUNTER_RAW_INTEL    0x94F4
+#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5
+#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8
+#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9
+#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA
+#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB
+#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC
+#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD
+#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE
+#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF
+#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500
+typedef void (GL_APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle);
+typedef void (GL_APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle);
+typedef void (GL_APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle);
+typedef void (GL_APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle);
+typedef void (GL_APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId);
+typedef void (GL_APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId);
+typedef void (GL_APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue);
+typedef void (GL_APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten);
+typedef void (GL_APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId);
+typedef void (GL_APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle);
+GL_APICALL void GL_APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle);
+GL_APICALL void GL_APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle);
+GL_APICALL void GL_APIENTRY glEndPerfQueryINTEL (GLuint queryHandle);
+GL_APICALL void GL_APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId);
+GL_APICALL void GL_APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId);
+GL_APICALL void GL_APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue);
+GL_APICALL void GL_APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten);
+GL_APICALL void GL_APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId);
+GL_APICALL void GL_APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask);
 #endif
+#endif /* GL_INTEL_performance_query */
 
-/*------------------------------------------------------------------------*
- * NV extension functions
- *------------------------------------------------------------------------*/
+#ifndef GL_NV_blend_equation_advanced
+#define GL_NV_blend_equation_advanced 1
+#define GL_BLEND_OVERLAP_NV               0x9281
+#define GL_BLEND_PREMULTIPLIED_SRC_NV     0x9280
+#define GL_BLUE_NV                        0x1905
+#define GL_COLORBURN_NV                   0x929A
+#define GL_COLORDODGE_NV                  0x9299
+#define GL_CONJOINT_NV                    0x9284
+#define GL_CONTRAST_NV                    0x92A1
+#define GL_DARKEN_NV                      0x9297
+#define GL_DIFFERENCE_NV                  0x929E
+#define GL_DISJOINT_NV                    0x9283
+#define GL_DST_ATOP_NV                    0x928F
+#define GL_DST_IN_NV                      0x928B
+#define GL_DST_NV                         0x9287
+#define GL_DST_OUT_NV                     0x928D
+#define GL_DST_OVER_NV                    0x9289
+#define GL_EXCLUSION_NV                   0x92A0
+#define GL_GREEN_NV                       0x1904
+#define GL_HARDLIGHT_NV                   0x929B
+#define GL_HARDMIX_NV                     0x92A9
+#define GL_HSL_COLOR_NV                   0x92AF
+#define GL_HSL_HUE_NV                     0x92AD
+#define GL_HSL_LUMINOSITY_NV              0x92B0
+#define GL_HSL_SATURATION_NV              0x92AE
+#define GL_INVERT_OVG_NV                  0x92B4
+#define GL_INVERT_RGB_NV                  0x92A3
+#define GL_LIGHTEN_NV                     0x9298
+#define GL_LINEARBURN_NV                  0x92A5
+#define GL_LINEARDODGE_NV                 0x92A4
+#define GL_LINEARLIGHT_NV                 0x92A7
+#define GL_MINUS_CLAMPED_NV               0x92B3
+#define GL_MINUS_NV                       0x929F
+#define GL_MULTIPLY_NV                    0x9294
+#define GL_OVERLAY_NV                     0x9296
+#define GL_PINLIGHT_NV                    0x92A8
+#define GL_PLUS_CLAMPED_ALPHA_NV          0x92B2
+#define GL_PLUS_CLAMPED_NV                0x92B1
+#define GL_PLUS_DARKER_NV                 0x9292
+#define GL_PLUS_NV                        0x9291
+#define GL_RED_NV                         0x1903
+#define GL_SCREEN_NV                      0x9295
+#define GL_SOFTLIGHT_NV                   0x929C
+#define GL_SRC_ATOP_NV                    0x928E
+#define GL_SRC_IN_NV                      0x928A
+#define GL_SRC_NV                         0x9286
+#define GL_SRC_OUT_NV                     0x928C
+#define GL_SRC_OVER_NV                    0x9288
+#define GL_UNCORRELATED_NV                0x9282
+#define GL_VIVIDLIGHT_NV                  0x92A6
+#define GL_XOR_NV                         0x1506
+typedef void (GL_APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value);
+typedef void (GL_APIENTRYP PFNGLBLENDBARRIERNVPROC) (void);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glBlendParameteriNV (GLenum pname, GLint value);
+GL_APICALL void GL_APIENTRY glBlendBarrierNV (void);
+#endif
+#endif /* GL_NV_blend_equation_advanced */
 
-/* GL_NV_coverage_sample */
+#ifndef GL_NV_blend_equation_advanced_coherent
+#define GL_NV_blend_equation_advanced_coherent 1
+#define GL_BLEND_ADVANCED_COHERENT_NV     0x9285
+#endif /* GL_NV_blend_equation_advanced_coherent */
+
+#ifndef GL_NV_copy_buffer
+#define GL_NV_copy_buffer 1
+#define GL_COPY_READ_BUFFER_NV            0x8F36
+#define GL_COPY_WRITE_BUFFER_NV           0x8F37
+typedef void (GL_APIENTRYP PFNGLCOPYBUFFERSUBDATANVPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glCopyBufferSubDataNV (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+#endif
+#endif /* GL_NV_copy_buffer */
+
 #ifndef GL_NV_coverage_sample
 #define GL_NV_coverage_sample 1
+#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         0x00008000
+typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask);
+typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation);
 #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
+#endif /* GL_NV_coverage_sample */
 
-/* GL_NV_depth_nonlinear */
 #ifndef GL_NV_depth_nonlinear
 #define GL_NV_depth_nonlinear 1
-#endif
+#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C
+#endif /* GL_NV_depth_nonlinear */
 
-/* GL_NV_draw_buffers */
 #ifndef GL_NV_draw_buffers
 #define GL_NV_draw_buffers 1
+#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
+typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs);
 #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
+#endif /* GL_NV_draw_buffers */
 
-/* GL_NV_fbo_color_attachments */
+#ifndef GL_NV_draw_instanced
+#define GL_NV_draw_instanced 1
+typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+#endif
+#endif /* GL_NV_draw_instanced */
+
+#ifndef GL_NV_explicit_attrib_location
+#define GL_NV_explicit_attrib_location 1
+#endif /* GL_NV_explicit_attrib_location */
+
 #ifndef GL_NV_fbo_color_attachments
 #define GL_NV_fbo_color_attachments 1
-#endif
+#define GL_MAX_COLOR_ATTACHMENTS_NV       0x8CDF
+#endif /* GL_NV_fbo_color_attachments */
 
-/* GL_NV_fence */
 #ifndef GL_NV_fence
 #define GL_NV_fence 1
+#define GL_ALL_COMPLETED_NV               0x84F2
+#define GL_FENCE_STATUS_NV                0x84F3
+#define GL_FENCE_CONDITION_NV             0x84F4
+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);
 #ifdef GL_GLEXT_PROTOTYPES
 GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences);
 GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei n, GLuint *fences);
@@ -1271,85 +1663,185 @@
 GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint fence);
 GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint fence, GLenum condition);
 #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
+#endif /* GL_NV_fence */
 
-/* GL_NV_read_buffer */
+#ifndef GL_NV_framebuffer_blit
+#define GL_NV_framebuffer_blit 1
+#define GL_READ_FRAMEBUFFER_NV            0x8CA8
+#define GL_DRAW_FRAMEBUFFER_NV            0x8CA9
+#define GL_DRAW_FRAMEBUFFER_BINDING_NV    0x8CA6
+#define GL_READ_FRAMEBUFFER_BINDING_NV    0x8CAA
+typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glBlitFramebufferNV (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#endif
+#endif /* GL_NV_framebuffer_blit */
+
+#ifndef GL_NV_framebuffer_multisample
+#define GL_NV_framebuffer_multisample 1
+#define GL_RENDERBUFFER_SAMPLES_NV        0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56
+#define GL_MAX_SAMPLES_NV                 0x8D57
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLENVPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+#endif
+#endif /* GL_NV_framebuffer_multisample */
+
+#ifndef GL_NV_generate_mipmap_sRGB
+#define GL_NV_generate_mipmap_sRGB 1
+#endif /* GL_NV_generate_mipmap_sRGB */
+
+#ifndef GL_NV_instanced_arrays
+#define GL_NV_instanced_arrays 1
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE
+typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV (GLuint index, GLuint divisor);
+#endif
+#endif /* GL_NV_instanced_arrays */
+
+#ifndef GL_NV_non_square_matrices
+#define GL_NV_non_square_matrices 1
+#define GL_FLOAT_MAT2x3_NV                0x8B65
+#define GL_FLOAT_MAT2x4_NV                0x8B66
+#define GL_FLOAT_MAT3x2_NV                0x8B67
+#define GL_FLOAT_MAT3x4_NV                0x8B68
+#define GL_FLOAT_MAT4x2_NV                0x8B69
+#define GL_FLOAT_MAT4x3_NV                0x8B6A
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glUniformMatrix2x3fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix3x2fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix2x4fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix4x2fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix3x4fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix4x3fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+#endif
+#endif /* GL_NV_non_square_matrices */
+
 #ifndef GL_NV_read_buffer
 #define GL_NV_read_buffer 1
+#define GL_READ_BUFFER_NV                 0x0C02
+typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode);
 #ifdef GL_GLEXT_PROTOTYPES
 GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode);
 #endif
-typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode);
-#endif
+#endif /* GL_NV_read_buffer */
 
-/* GL_NV_read_buffer_front */
 #ifndef GL_NV_read_buffer_front
 #define GL_NV_read_buffer_front 1
-#endif
+#endif /* GL_NV_read_buffer_front */
 
-/* GL_NV_read_depth */
 #ifndef GL_NV_read_depth
 #define GL_NV_read_depth 1
-#endif
+#endif /* GL_NV_read_depth */
 
-/* GL_NV_read_depth_stencil */
 #ifndef GL_NV_read_depth_stencil
 #define GL_NV_read_depth_stencil 1
-#endif
+#endif /* GL_NV_read_depth_stencil */
 
-/* GL_NV_read_stencil */
 #ifndef GL_NV_read_stencil
 #define GL_NV_read_stencil 1
-#endif
+#endif /* GL_NV_read_stencil */
 
-/* GL_NV_texture_compression_s3tc_update */
+#ifndef GL_NV_sRGB_formats
+#define GL_NV_sRGB_formats 1
+#define GL_SLUMINANCE_NV                  0x8C46
+#define GL_SLUMINANCE_ALPHA_NV            0x8C44
+#define GL_SRGB8_NV                       0x8C41
+#define GL_SLUMINANCE8_NV                 0x8C47
+#define GL_SLUMINANCE8_ALPHA8_NV          0x8C45
+#define GL_COMPRESSED_SRGB_S3TC_DXT1_NV   0x8C4C
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F
+#define GL_ETC1_SRGB8_NV                  0x88EE
+#endif /* GL_NV_sRGB_formats */
+
+#ifndef GL_NV_shadow_samplers_array
+#define GL_NV_shadow_samplers_array 1
+#define GL_SAMPLER_2D_ARRAY_SHADOW_NV     0x8DC4
+#endif /* GL_NV_shadow_samplers_array */
+
+#ifndef GL_NV_shadow_samplers_cube
+#define GL_NV_shadow_samplers_cube 1
+#define GL_SAMPLER_CUBE_SHADOW_NV         0x8DC5
+#endif /* GL_NV_shadow_samplers_cube */
+
+#ifndef GL_NV_texture_border_clamp
+#define GL_NV_texture_border_clamp 1
+#define GL_TEXTURE_BORDER_COLOR_NV        0x1004
+#define GL_CLAMP_TO_BORDER_NV             0x812D
+#endif /* GL_NV_texture_border_clamp */
+
 #ifndef GL_NV_texture_compression_s3tc_update
 #define GL_NV_texture_compression_s3tc_update 1
-#endif
+#endif /* GL_NV_texture_compression_s3tc_update */
 
-/* GL_NV_texture_npot_2D_mipmap */
 #ifndef GL_NV_texture_npot_2D_mipmap
 #define GL_NV_texture_npot_2D_mipmap 1
-#endif
+#endif /* GL_NV_texture_npot_2D_mipmap */
 
-/*------------------------------------------------------------------------*
- * QCOM extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_QCOM_alpha_test */
 #ifndef GL_QCOM_alpha_test
 #define GL_QCOM_alpha_test 1
+#define GL_ALPHA_TEST_QCOM                0x0BC0
+#define GL_ALPHA_TEST_FUNC_QCOM           0x0BC1
+#define GL_ALPHA_TEST_REF_QCOM            0x0BC2
+typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref);
 #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
+#endif /* GL_QCOM_alpha_test */
 
-/* GL_QCOM_driver_control */
+#ifndef GL_QCOM_binning_control
+#define GL_QCOM_binning_control 1
+#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_binning_control */
+
 #ifndef GL_QCOM_driver_control
 #define GL_QCOM_driver_control 1
+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);
 #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
+#endif /* GL_QCOM_driver_control */
 
-/* GL_QCOM_extended_get */
 #ifndef GL_QCOM_extended_get
 #define GL_QCOM_extended_get 1
+#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
+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, void *texels);
+typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, void **params);
 #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);
@@ -1357,66 +1849,84 @@
 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);
+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, void *texels);
+GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, void **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
+#endif /* GL_QCOM_extended_get */
 
-/* GL_QCOM_extended_get2 */
 #ifndef GL_QCOM_extended_get2
 #define GL_QCOM_extended_get2 1
+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);
 #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
+#endif /* GL_QCOM_extended_get2 */
 
-/* GL_QCOM_perfmon_global_mode */
 #ifndef GL_QCOM_perfmon_global_mode
 #define GL_QCOM_perfmon_global_mode 1
-#endif
+#define GL_PERFMON_GLOBAL_MODE_QCOM       0x8FA0
+#endif /* GL_QCOM_perfmon_global_mode */
 
-/* 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
+#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
+typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
+typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask);
 #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
+#endif /* GL_QCOM_tiled_rendering */
 
-/*------------------------------------------------------------------------*
- * VIV extension tokens
- *------------------------------------------------------------------------*/
+#ifndef GL_QCOM_writeonly_rendering
+#define GL_QCOM_writeonly_rendering 1
+#define GL_WRITEONLY_RENDERING_QCOM       0x8823
+#endif /* GL_QCOM_writeonly_rendering */
 
-/* GL_VIV_shader_binary */
 #ifndef GL_VIV_shader_binary
 #define GL_VIV_shader_binary 1
-#endif
+#define GL_SHADER_BINARY_VIV              0x8FC4
+#endif /* GL_VIV_shader_binary */
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* __gl2ext_h_ */
+#endif
diff --git a/opengl/include/GLES2/gl2platform.h b/opengl/include/GLES2/gl2platform.h
index c9fa3c4..89d4d44 100644
--- a/opengl/include/GLES2/gl2platform.h
+++ b/opengl/include/GLES2/gl2platform.h
@@ -1,7 +1,7 @@
 #ifndef __gl2platform_h_
 #define __gl2platform_h_
 
-/* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */
+/* $Revision: 23328 $ on $Date:: 2013-10-02 02:28:28 -0700 #$ */
 
 /*
  * This document is licensed under the SGI Free Software B License Version
diff --git a/opengl/include/GLES3/gl3.h b/opengl/include/GLES3/gl3.h
index 9c79862..c9a3175 100644
--- a/opengl/include/GLES3/gl3.h
+++ b/opengl/include/GLES3/gl3.h
@@ -1,18 +1,12 @@
 #ifndef __gl3_h_
-#define __gl3_h_
-
-/* 
- * gl3.h last updated on $Date: 2013-02-12 14:37:24 -0800 (Tue, 12 Feb 2013) $
- */
-
-#include <GLES3/gl3platform.h>
+#define __gl3_h_ 1
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 /*
-** Copyright (c) 2007-2013 The Khronos Group Inc.
+** Copyright (c) 2013-2014 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
@@ -33,1026 +27,910 @@
 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
 */
+/*
+** This header is generated from the Khronos OpenGL / OpenGL ES XML
+** API Registry. The current version of the Registry, generator scripts
+** used to make the header, and the header can be found at
+**   http://www.opengl.org/registry/
+**
+** Khronos $Revision: 26696 $ on $Date: 2014-05-17 14:48:55 -0700 (Sat, 17 May 2014) $
+*/
 
-/*-------------------------------------------------------------------------
- * Data type definitions
- *-----------------------------------------------------------------------*/
+#include <GLES3/gl3platform.h>
 
-/* OpenGL ES 2.0 */
+/* Generated on date 20140517 */
 
-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;
+/* Generated C header for:
+ * API: gles2
+ * Profile: common
+ * Versions considered: 2\.[0-9]|3.0
+ * Versions emitted: .*
+ * Default extensions included: None
+ * Additional extensions included: _nomatch_^
+ * Extensions removed: _nomatch_^
+ */
 
-/* OpenGL ES 3.0 */
-
-typedef unsigned short   GLhalf;
-typedef khronos_int64_t  GLint64;
-typedef khronos_uint64_t GLuint64;
+#ifndef GL_ES_VERSION_2_0
+#define GL_ES_VERSION_2_0 1
+#include <KHR/khrplatform.h>
+typedef khronos_int8_t GLbyte;
+typedef khronos_float_t GLclampf;
+typedef khronos_int32_t GLfixed;
+typedef short GLshort;
+typedef unsigned short GLushort;
+typedef void GLvoid;
 typedef struct __GLsync *GLsync;
+typedef khronos_int64_t GLint64;
+typedef khronos_uint64_t GLuint64;
+typedef unsigned int GLenum;
+typedef unsigned int GLuint;
+typedef char GLchar;
+typedef khronos_float_t GLfloat;
+typedef khronos_ssize_t GLsizeiptr;
+typedef khronos_intptr_t GLintptr;
+typedef unsigned int GLbitfield;
+typedef int GLint;
+typedef unsigned char GLboolean;
+typedef int GLsizei;
+typedef khronos_uint8_t GLubyte;
+#define GL_DEPTH_BUFFER_BIT               0x00000100
+#define GL_STENCIL_BUFFER_BIT             0x00000400
+#define GL_COLOR_BUFFER_BIT               0x00004000
+#define GL_FALSE                          0
+#define GL_TRUE                           1
+#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
+#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
+#define GL_DST_COLOR                      0x0306
+#define GL_ONE_MINUS_DST_COLOR            0x0307
+#define GL_SRC_ALPHA_SATURATE             0x0308
+#define GL_FUNC_ADD                       0x8006
+#define GL_BLEND_EQUATION                 0x8009
+#define GL_BLEND_EQUATION_RGB             0x8009
+#define GL_BLEND_EQUATION_ALPHA           0x883D
+#define GL_FUNC_SUBTRACT                  0x800A
+#define GL_FUNC_REVERSE_SUBTRACT          0x800B
+#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
+#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
+#define GL_FRONT                          0x0404
+#define GL_BACK                           0x0405
+#define GL_FRONT_AND_BACK                 0x0408
+#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
+#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
+#define GL_CW                             0x0900
+#define GL_CCW                            0x0901
+#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
+#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
+#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
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS     0x86A3
+#define GL_DONT_CARE                      0x1100
+#define GL_FASTEST                        0x1101
+#define GL_NICEST                         0x1102
+#define GL_GENERATE_MIPMAP_HINT           0x8192
+#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
+#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
+#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
+#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
+#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
+#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
+#define GL_VENDOR                         0x1F00
+#define GL_RENDERER                       0x1F01
+#define GL_VERSION                        0x1F02
+#define GL_EXTENSIONS                     0x1F03
+#define GL_NEAREST                        0x2600
+#define GL_LINEAR                         0x2601
+#define GL_NEAREST_MIPMAP_NEAREST         0x2700
+#define GL_LINEAR_MIPMAP_NEAREST          0x2701
+#define GL_NEAREST_MIPMAP_LINEAR          0x2702
+#define GL_LINEAR_MIPMAP_LINEAR           0x2703
+#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_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
+#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_REPEAT                         0x2901
+#define GL_CLAMP_TO_EDGE                  0x812F
+#define GL_MIRRORED_REPEAT                0x8370
+#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
+#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
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
+#define GL_COMPILE_STATUS                 0x8B81
+#define GL_INFO_LOG_LENGTH                0x8B84
+#define GL_SHADER_SOURCE_LENGTH           0x8B88
+#define GL_SHADER_COMPILER                0x8DFA
+#define GL_SHADER_BINARY_FORMATS          0x8DF8
+#define GL_NUM_SHADER_BINARY_FORMATS      0x8DF9
+#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
+#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_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 sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage);
+GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *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 d);
+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 void *data);
+GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *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 void *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 GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar *name);
+GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *data);
+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 *data);
+GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *data);
+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 GLint 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, void **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, void *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 count, const GLuint *shaders, GLenum binaryformat, const void *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 sfail, GLenum dpfail, GLenum dppass);
+GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *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 void *pixels);
+GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat v0);
+GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint v0);
+GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1);
+GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint v0, GLint v1);
+GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2);
+GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value);
+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 index, GLfloat x);
+GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y);
+GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
+GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
+#endif /* GL_ES_VERSION_2_0 */
 
-/*-------------------------------------------------------------------------
- * 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
+#ifndef GL_ES_VERSION_3_0
+#define GL_ES_VERSION_3_0 1
+typedef unsigned short GLhalf;
+#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                      0x82DF
-
-/*-------------------------------------------------------------------------
- * 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 GLint          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 GLint          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);
+#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       0x8CA6
+#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       0x8F36
+#define GL_COPY_WRITE_BUFFER_BINDING      0x8F37
+#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       0x82DF
+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 void *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 void *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 void *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 void *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 void *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, void **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 void *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 void *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 void *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 *data);
+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, void *binary);
+GL_APICALL void GL_APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *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);
+#endif /* GL_ES_VERSION_3_0 */
 
 #ifdef __cplusplus
 }
diff --git a/opengl/include/GLES3/gl31.h b/opengl/include/GLES3/gl31.h
new file mode 100644
index 0000000..cfb9069
--- /dev/null
+++ b/opengl/include/GLES3/gl31.h
@@ -0,0 +1,1184 @@
+#ifndef __gl31_h_
+#define __gl31_h_ 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** Copyright (c) 2013-2014 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.
+*/
+/*
+** This header is generated from the Khronos OpenGL / OpenGL ES XML
+** API Registry. The current version of the Registry, generator scripts
+** used to make the header, and the header can be found at
+**   http://www.opengl.org/registry/
+**
+** Khronos $Revision$ on $Date$
+*/
+
+#include <GLES3/gl3platform.h>
+
+/* Generated on date 20140517 */
+
+/* Generated C header for:
+ * API: gles2
+ * Profile: common
+ * Versions considered: 2.[0-9]|3.[01]
+ * Versions emitted: .*
+ * Default extensions included: None
+ * Additional extensions included: _nomatch_^
+ * Extensions removed: _nomatch_^
+ */
+
+#ifndef GL_ES_VERSION_2_0
+#define GL_ES_VERSION_2_0 1
+#include <KHR/khrplatform.h>
+typedef khronos_int8_t GLbyte;
+typedef khronos_float_t GLclampf;
+typedef khronos_int32_t GLfixed;
+typedef short GLshort;
+typedef unsigned short GLushort;
+typedef void GLvoid;
+typedef struct __GLsync *GLsync;
+typedef khronos_int64_t GLint64;
+typedef khronos_uint64_t GLuint64;
+typedef unsigned int GLenum;
+typedef unsigned int GLuint;
+typedef char GLchar;
+typedef khronos_float_t GLfloat;
+typedef khronos_ssize_t GLsizeiptr;
+typedef khronos_intptr_t GLintptr;
+typedef unsigned int GLbitfield;
+typedef int GLint;
+typedef unsigned char GLboolean;
+typedef int GLsizei;
+typedef khronos_uint8_t GLubyte;
+#define GL_DEPTH_BUFFER_BIT               0x00000100
+#define GL_STENCIL_BUFFER_BIT             0x00000400
+#define GL_COLOR_BUFFER_BIT               0x00004000
+#define GL_FALSE                          0
+#define GL_TRUE                           1
+#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
+#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
+#define GL_DST_COLOR                      0x0306
+#define GL_ONE_MINUS_DST_COLOR            0x0307
+#define GL_SRC_ALPHA_SATURATE             0x0308
+#define GL_FUNC_ADD                       0x8006
+#define GL_BLEND_EQUATION                 0x8009
+#define GL_BLEND_EQUATION_RGB             0x8009
+#define GL_BLEND_EQUATION_ALPHA           0x883D
+#define GL_FUNC_SUBTRACT                  0x800A
+#define GL_FUNC_REVERSE_SUBTRACT          0x800B
+#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
+#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
+#define GL_FRONT                          0x0404
+#define GL_BACK                           0x0405
+#define GL_FRONT_AND_BACK                 0x0408
+#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
+#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
+#define GL_CW                             0x0900
+#define GL_CCW                            0x0901
+#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
+#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
+#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
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS     0x86A3
+#define GL_DONT_CARE                      0x1100
+#define GL_FASTEST                        0x1101
+#define GL_NICEST                         0x1102
+#define GL_GENERATE_MIPMAP_HINT           0x8192
+#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
+#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
+#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
+#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
+#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
+#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
+#define GL_VENDOR                         0x1F00
+#define GL_RENDERER                       0x1F01
+#define GL_VERSION                        0x1F02
+#define GL_EXTENSIONS                     0x1F03
+#define GL_NEAREST                        0x2600
+#define GL_LINEAR                         0x2601
+#define GL_NEAREST_MIPMAP_NEAREST         0x2700
+#define GL_LINEAR_MIPMAP_NEAREST          0x2701
+#define GL_NEAREST_MIPMAP_LINEAR          0x2702
+#define GL_LINEAR_MIPMAP_LINEAR           0x2703
+#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_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
+#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_REPEAT                         0x2901
+#define GL_CLAMP_TO_EDGE                  0x812F
+#define GL_MIRRORED_REPEAT                0x8370
+#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
+#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
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
+#define GL_COMPILE_STATUS                 0x8B81
+#define GL_INFO_LOG_LENGTH                0x8B84
+#define GL_SHADER_SOURCE_LENGTH           0x8B88
+#define GL_SHADER_COMPILER                0x8DFA
+#define GL_SHADER_BINARY_FORMATS          0x8DF8
+#define GL_NUM_SHADER_BINARY_FORMATS      0x8DF9
+#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
+#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_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 sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage);
+GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *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 d);
+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 void *data);
+GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *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 void *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 GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar *name);
+GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *data);
+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 *data);
+GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *data);
+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 GLint 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, void **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, void *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 count, const GLuint *shaders, GLenum binaryformat, const void *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 sfail, GLenum dpfail, GLenum dppass);
+GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *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 void *pixels);
+GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat v0);
+GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint v0);
+GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1);
+GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint v0, GLint v1);
+GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2);
+GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value);
+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 index, GLfloat x);
+GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y);
+GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
+GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
+#endif /* GL_ES_VERSION_2_0 */
+
+#ifndef GL_ES_VERSION_3_0
+#define GL_ES_VERSION_3_0 1
+typedef unsigned short GLhalf;
+#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       0x8CA6
+#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       0x8F36
+#define GL_COPY_WRITE_BUFFER_BINDING      0x8F37
+#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       0x82DF
+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 void *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 void *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 void *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 void *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 void *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, void **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 void *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 void *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 void *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 *data);
+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, void *binary);
+GL_APICALL void GL_APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *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);
+#endif /* GL_ES_VERSION_3_0 */
+
+#ifndef GL_ES_VERSION_3_1
+#define GL_ES_VERSION_3_1 1
+#define GL_COMPUTE_SHADER                 0x91B9
+#define GL_MAX_COMPUTE_UNIFORM_BLOCKS     0x91BB
+#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC
+#define GL_MAX_COMPUTE_IMAGE_UNIFORMS     0x91BD
+#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262
+#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263
+#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264
+#define GL_MAX_COMPUTE_ATOMIC_COUNTERS    0x8265
+#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266
+#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB
+#define GL_MAX_COMPUTE_WORK_GROUP_COUNT   0x91BE
+#define GL_MAX_COMPUTE_WORK_GROUP_SIZE    0x91BF
+#define GL_COMPUTE_WORK_GROUP_SIZE        0x8267
+#define GL_DISPATCH_INDIRECT_BUFFER       0x90EE
+#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF
+#define GL_COMPUTE_SHADER_BIT             0x00000020
+#define GL_DRAW_INDIRECT_BUFFER           0x8F3F
+#define GL_DRAW_INDIRECT_BUFFER_BINDING   0x8F43
+#define GL_MAX_UNIFORM_LOCATIONS          0x826E
+#define GL_FRAMEBUFFER_DEFAULT_WIDTH      0x9310
+#define GL_FRAMEBUFFER_DEFAULT_HEIGHT     0x9311
+#define GL_FRAMEBUFFER_DEFAULT_SAMPLES    0x9313
+#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314
+#define GL_MAX_FRAMEBUFFER_WIDTH          0x9315
+#define GL_MAX_FRAMEBUFFER_HEIGHT         0x9316
+#define GL_MAX_FRAMEBUFFER_SAMPLES        0x9318
+#define GL_UNIFORM                        0x92E1
+#define GL_UNIFORM_BLOCK                  0x92E2
+#define GL_PROGRAM_INPUT                  0x92E3
+#define GL_PROGRAM_OUTPUT                 0x92E4
+#define GL_BUFFER_VARIABLE                0x92E5
+#define GL_SHADER_STORAGE_BLOCK           0x92E6
+#define GL_ATOMIC_COUNTER_BUFFER          0x92C0
+#define GL_TRANSFORM_FEEDBACK_VARYING     0x92F4
+#define GL_ACTIVE_RESOURCES               0x92F5
+#define GL_MAX_NAME_LENGTH                0x92F6
+#define GL_MAX_NUM_ACTIVE_VARIABLES       0x92F7
+#define GL_NAME_LENGTH                    0x92F9
+#define GL_TYPE                           0x92FA
+#define GL_ARRAY_SIZE                     0x92FB
+#define GL_OFFSET                         0x92FC
+#define GL_BLOCK_INDEX                    0x92FD
+#define GL_ARRAY_STRIDE                   0x92FE
+#define GL_MATRIX_STRIDE                  0x92FF
+#define GL_IS_ROW_MAJOR                   0x9300
+#define GL_ATOMIC_COUNTER_BUFFER_INDEX    0x9301
+#define GL_BUFFER_BINDING                 0x9302
+#define GL_BUFFER_DATA_SIZE               0x9303
+#define GL_NUM_ACTIVE_VARIABLES           0x9304
+#define GL_ACTIVE_VARIABLES               0x9305
+#define GL_REFERENCED_BY_VERTEX_SHADER    0x9306
+#define GL_REFERENCED_BY_FRAGMENT_SHADER  0x930A
+#define GL_REFERENCED_BY_COMPUTE_SHADER   0x930B
+#define GL_TOP_LEVEL_ARRAY_SIZE           0x930C
+#define GL_TOP_LEVEL_ARRAY_STRIDE         0x930D
+#define GL_LOCATION                       0x930E
+#define GL_VERTEX_SHADER_BIT              0x00000001
+#define GL_FRAGMENT_SHADER_BIT            0x00000002
+#define GL_ALL_SHADER_BITS                0xFFFFFFFF
+#define GL_PROGRAM_SEPARABLE              0x8258
+#define GL_ACTIVE_PROGRAM                 0x8259
+#define GL_PROGRAM_PIPELINE_BINDING       0x825A
+#define GL_ATOMIC_COUNTER_BUFFER_BINDING  0x92C1
+#define GL_ATOMIC_COUNTER_BUFFER_START    0x92C2
+#define GL_ATOMIC_COUNTER_BUFFER_SIZE     0x92C3
+#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC
+#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0
+#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1
+#define GL_MAX_VERTEX_ATOMIC_COUNTERS     0x92D2
+#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS   0x92D6
+#define GL_MAX_COMBINED_ATOMIC_COUNTERS   0x92D7
+#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8
+#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC
+#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS  0x92D9
+#define GL_UNSIGNED_INT_ATOMIC_COUNTER    0x92DB
+#define GL_MAX_IMAGE_UNITS                0x8F38
+#define GL_MAX_VERTEX_IMAGE_UNIFORMS      0x90CA
+#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS    0x90CE
+#define GL_MAX_COMBINED_IMAGE_UNIFORMS    0x90CF
+#define GL_IMAGE_BINDING_NAME             0x8F3A
+#define GL_IMAGE_BINDING_LEVEL            0x8F3B
+#define GL_IMAGE_BINDING_LAYERED          0x8F3C
+#define GL_IMAGE_BINDING_LAYER            0x8F3D
+#define GL_IMAGE_BINDING_ACCESS           0x8F3E
+#define GL_IMAGE_BINDING_FORMAT           0x906E
+#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001
+#define GL_ELEMENT_ARRAY_BARRIER_BIT      0x00000002
+#define GL_UNIFORM_BARRIER_BIT            0x00000004
+#define GL_TEXTURE_FETCH_BARRIER_BIT      0x00000008
+#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020
+#define GL_COMMAND_BARRIER_BIT            0x00000040
+#define GL_PIXEL_BUFFER_BARRIER_BIT       0x00000080
+#define GL_TEXTURE_UPDATE_BARRIER_BIT     0x00000100
+#define GL_BUFFER_UPDATE_BARRIER_BIT      0x00000200
+#define GL_FRAMEBUFFER_BARRIER_BIT        0x00000400
+#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800
+#define GL_ATOMIC_COUNTER_BARRIER_BIT     0x00001000
+#define GL_ALL_BARRIER_BITS               0xFFFFFFFF
+#define GL_IMAGE_2D                       0x904D
+#define GL_IMAGE_3D                       0x904E
+#define GL_IMAGE_CUBE                     0x9050
+#define GL_IMAGE_2D_ARRAY                 0x9053
+#define GL_INT_IMAGE_2D                   0x9058
+#define GL_INT_IMAGE_3D                   0x9059
+#define GL_INT_IMAGE_CUBE                 0x905B
+#define GL_INT_IMAGE_2D_ARRAY             0x905E
+#define GL_UNSIGNED_INT_IMAGE_2D          0x9063
+#define GL_UNSIGNED_INT_IMAGE_3D          0x9064
+#define GL_UNSIGNED_INT_IMAGE_CUBE        0x9066
+#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY    0x9069
+#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7
+#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8
+#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9
+#define GL_READ_ONLY                      0x88B8
+#define GL_WRITE_ONLY                     0x88B9
+#define GL_READ_WRITE                     0x88BA
+#define GL_SHADER_STORAGE_BUFFER          0x90D2
+#define GL_SHADER_STORAGE_BUFFER_BINDING  0x90D3
+#define GL_SHADER_STORAGE_BUFFER_START    0x90D4
+#define GL_SHADER_STORAGE_BUFFER_SIZE     0x90D5
+#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6
+#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA
+#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB
+#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC
+#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD
+#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE  0x90DE
+#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF
+#define GL_SHADER_STORAGE_BARRIER_BIT     0x00002000
+#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39
+#define GL_DEPTH_STENCIL_TEXTURE_MODE     0x90EA
+#define GL_STENCIL_INDEX                  0x1901
+#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E
+#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F
+#define GL_SAMPLE_POSITION                0x8E50
+#define GL_SAMPLE_MASK                    0x8E51
+#define GL_SAMPLE_MASK_VALUE              0x8E52
+#define GL_TEXTURE_2D_MULTISAMPLE         0x9100
+#define GL_MAX_SAMPLE_MASK_WORDS          0x8E59
+#define GL_MAX_COLOR_TEXTURE_SAMPLES      0x910E
+#define GL_MAX_DEPTH_TEXTURE_SAMPLES      0x910F
+#define GL_MAX_INTEGER_SAMPLES            0x9110
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104
+#define GL_TEXTURE_SAMPLES                0x9106
+#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107
+#define GL_TEXTURE_WIDTH                  0x1000
+#define GL_TEXTURE_HEIGHT                 0x1001
+#define GL_TEXTURE_DEPTH                  0x8071
+#define GL_TEXTURE_INTERNAL_FORMAT        0x1003
+#define GL_TEXTURE_RED_SIZE               0x805C
+#define GL_TEXTURE_GREEN_SIZE             0x805D
+#define GL_TEXTURE_BLUE_SIZE              0x805E
+#define GL_TEXTURE_ALPHA_SIZE             0x805F
+#define GL_TEXTURE_DEPTH_SIZE             0x884A
+#define GL_TEXTURE_STENCIL_SIZE           0x88F1
+#define GL_TEXTURE_SHARED_SIZE            0x8C3F
+#define GL_TEXTURE_RED_TYPE               0x8C10
+#define GL_TEXTURE_GREEN_TYPE             0x8C11
+#define GL_TEXTURE_BLUE_TYPE              0x8C12
+#define GL_TEXTURE_ALPHA_TYPE             0x8C13
+#define GL_TEXTURE_DEPTH_TYPE             0x8C16
+#define GL_TEXTURE_COMPRESSED             0x86A1
+#define GL_SAMPLER_2D_MULTISAMPLE         0x9108
+#define GL_INT_SAMPLER_2D_MULTISAMPLE     0x9109
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
+#define GL_VERTEX_ATTRIB_BINDING          0x82D4
+#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET  0x82D5
+#define GL_VERTEX_BINDING_DIVISOR         0x82D6
+#define GL_VERTEX_BINDING_OFFSET          0x82D7
+#define GL_VERTEX_BINDING_STRIDE          0x82D8
+#define GL_VERTEX_BINDING_BUFFER          0x8F4F
+#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9
+#define GL_MAX_VERTEX_ATTRIB_BINDINGS     0x82DA
+#define GL_MAX_VERTEX_ATTRIB_STRIDE       0x82E5
+GL_APICALL void GL_APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);
+GL_APICALL void GL_APIENTRY glDispatchComputeIndirect (GLintptr indirect);
+GL_APICALL void GL_APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect);
+GL_APICALL void GL_APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect);
+GL_APICALL void GL_APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param);
+GL_APICALL void GL_APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params);
+GL_APICALL GLuint GL_APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name);
+GL_APICALL void GL_APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name);
+GL_APICALL void GL_APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params);
+GL_APICALL GLint GL_APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name);
+GL_APICALL void GL_APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program);
+GL_APICALL void GL_APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program);
+GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings);
+GL_APICALL void GL_APIENTRY glBindProgramPipeline (GLuint pipeline);
+GL_APICALL void GL_APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines);
+GL_APICALL void GL_APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines);
+GL_APICALL GLboolean GL_APIENTRY glIsProgramPipeline (GLuint pipeline);
+GL_APICALL void GL_APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0);
+GL_APICALL void GL_APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1);
+GL_APICALL void GL_APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+GL_APICALL void GL_APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GL_APICALL void GL_APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0);
+GL_APICALL void GL_APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1);
+GL_APICALL void GL_APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+GL_APICALL void GL_APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GL_APICALL void GL_APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0);
+GL_APICALL void GL_APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1);
+GL_APICALL void GL_APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GL_APICALL void GL_APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GL_APICALL void GL_APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glValidateProgramPipeline (GLuint pipeline);
+GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+GL_APICALL void GL_APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
+GL_APICALL void GL_APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data);
+GL_APICALL void GL_APIENTRY glMemoryBarrier (GLbitfield barriers);
+GL_APICALL void GL_APIENTRY glMemoryBarrierByRegion (GLbitfield barriers);
+GL_APICALL void GL_APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+GL_APICALL void GL_APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val);
+GL_APICALL void GL_APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask);
+GL_APICALL void GL_APIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params);
+GL_APICALL void GL_APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
+GL_APICALL void GL_APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
+GL_APICALL void GL_APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+GL_APICALL void GL_APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex);
+GL_APICALL void GL_APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor);
+#endif /* GL_ES_VERSION_3_1 */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/opengl/libagl/Android.mk b/opengl/libagl/Android.mk
index 32bc5d9..4b08749 100644
--- a/opengl/libagl/Android.mk
+++ b/opengl/libagl/Android.mk
@@ -27,12 +27,13 @@
 LOCAL_CFLAGS += -fvisibility=hidden
 
 LOCAL_SHARED_LIBRARIES := libcutils libhardware libutils liblog libpixelflinger libETC1 libui
-LOCAL_LDLIBS := -lpthread -ldl
 
 LOCAL_SRC_FILES_arm += fixed_asm.S iterators.S
 LOCAL_CFLAGS_arm += -fstrict-aliasing
 
+ifndef ARCH_MIPS_REV6
 LOCAL_SRC_FILES_mips += arch-mips/fixed_asm.S
+endif
 LOCAL_CFLAGS_mips += -fstrict-aliasing
 # The graphics code can generate division by zero
 LOCAL_CFLAGS_mips += -mno-check-zero-division
diff --git a/opengl/libagl/arch-mips/fixed_asm.S b/opengl/libagl/arch-mips/fixed_asm.S
index e1a53bc..a30ffc5 100644
--- a/opengl/libagl/arch-mips/fixed_asm.S
+++ b/opengl/libagl/arch-mips/fixed_asm.S
@@ -17,7 +17,7 @@
 
 
     .text
-    .align
+    .align 4
 
 /*
  * this version rounds-to-nearest and saturates numbers
diff --git a/opengl/libagl/context.h b/opengl/libagl/context.h
index c599a55..d23f435 100644
--- a/opengl/libagl/context.h
+++ b/opengl/libagl/context.h
@@ -21,7 +21,7 @@
 #include <stddef.h>
 #include <sys/types.h>
 #include <pthread.h>
-#ifdef HAVE_ANDROID_OS
+#ifdef __ANDROID__
 #include <bionic_tls.h>
 #endif
 
@@ -579,7 +579,7 @@
 // state
 // ----------------------------------------------------------------------------
 
-#ifdef HAVE_ANDROID_OS
+#ifdef __ANDROID__
     // We have a dedicated TLS slot in bionic
     inline void setGlThreadSpecific(ogles_context_t *value) {
         __get_tls()[TLS_SLOT_OPENGL] = value;
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index 1feac8b..7560d8f 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -64,7 +64,7 @@
 static pthread_mutex_t gInitMutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_mutex_t gErrorKeyMutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_key_t gEGLErrorKey = -1;
-#ifndef HAVE_ANDROID_OS
+#ifndef __ANDROID__
 namespace gl {
 pthread_key_t gGLKey = -1;
 }; // namespace gl
@@ -394,7 +394,13 @@
         depth.width   = width;
         depth.height  = height;
         depth.stride  = depth.width; // use the width here
-        depth.data    = (GGLubyte*)malloc(depth.stride*depth.height*2);
+        uint64_t allocSize = static_cast<uint64_t>(depth.stride) *
+                static_cast<uint64_t>(depth.height) * 2;
+        if (depth.stride < 0 || depth.height > INT_MAX ||
+                allocSize > UINT32_MAX) {
+            return setError(EGL_BAD_ALLOC, EGL_FALSE);
+        }
+        depth.data    = (GGLubyte*)malloc(allocSize);
         if (depth.data == 0) {
             return setError(EGL_BAD_ALLOC, EGL_FALSE);
         }
@@ -548,7 +554,14 @@
                 depth.width   = width;
                 depth.height  = height;
                 depth.stride  = buffer->stride;
-                depth.data    = (GGLubyte*)malloc(depth.stride*depth.height*2);
+                uint64_t allocSize = static_cast<uint64_t>(depth.stride) *
+                        static_cast<uint64_t>(depth.height) * 2;
+                if (depth.stride < 0 || depth.height > INT_MAX ||
+                        allocSize > UINT32_MAX) {
+                    setError(EGL_BAD_ALLOC, EGL_FALSE);
+                    return EGL_FALSE;
+                }
+                depth.data    = (GGLubyte*)malloc(allocSize);
                 if (depth.data == 0) {
                     setError(EGL_BAD_ALLOC, EGL_FALSE);
                     return EGL_FALSE;
@@ -666,7 +679,14 @@
         depth.width   = pixmap->width;
         depth.height  = pixmap->height;
         depth.stride  = depth.width; // use the width here
-        depth.data    = (GGLubyte*)malloc(depth.stride*depth.height*2);
+        uint64_t allocSize = static_cast<uint64_t>(depth.stride) *
+                static_cast<uint64_t>(depth.height) * 2;
+        if (depth.stride < 0 || depth.height > INT_MAX ||
+                allocSize > UINT32_MAX) {
+            setError(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+            return;
+        }
+        depth.data    = (GGLubyte*)malloc(allocSize);
         if (depth.data == 0) {
             setError(EGL_BAD_ALLOC, EGL_NO_SURFACE);
         }
@@ -746,7 +766,14 @@
         depth.width   = pbuffer.width;
         depth.height  = pbuffer.height;
         depth.stride  = depth.width; // use the width here
-        depth.data    = (GGLubyte*)malloc(depth.stride*depth.height*2);
+        uint64_t allocSize = static_cast<uint64_t>(depth.stride) *
+                static_cast<uint64_t>(depth.height) * 2;
+        if (depth.stride < 0 || depth.height > INT_MAX ||
+                allocSize > UINT32_MAX) {
+            setError(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+            return;
+        }
+        depth.data    = (GGLubyte*)malloc(allocSize);
         if (depth.data == 0) {
             setError(EGL_BAD_ALLOC, EGL_NO_SURFACE);
             return;
@@ -1346,7 +1373,7 @@
 
     int32_t w = 0;
     int32_t h = 0;
-    while (attrib_list[0]) {
+    while (attrib_list[0] != EGL_NONE) {
         if (attrib_list[0] == EGL_WIDTH)  w = attrib_list[1];
         if (attrib_list[0] == EGL_HEIGHT) h = attrib_list[1];
         attrib_list+=2;
@@ -1376,7 +1403,7 @@
 
 EGLDisplay eglGetDisplay(NativeDisplayType display)
 {
-#ifndef HAVE_ANDROID_OS
+#ifndef __ANDROID__
     // this just needs to be done once
     if (gGLKey == -1) {
         pthread_mutex_lock(&gInitMutex);
diff --git a/opengl/libagl/fp.cpp b/opengl/libagl/fp.cpp
index aea4449..a7a4f7b 100644
--- a/opengl/libagl/fp.cpp
+++ b/opengl/libagl/fp.cpp
@@ -19,7 +19,7 @@
 
 // ----------------------------------------------------------------------------
 
-#if !defined(__arm__) && !defined(__mips__)
+#if !(defined(__arm__) || (defined(__mips__) && !defined(__LP64__) && __mips_isa_rev < 6))
 GGLfixed gglFloatToFixed(float v) {   
     return GGLfixed(floorf(v * 65536.0f + 0.5f));
 }
diff --git a/opengl/libagl/matrix.h b/opengl/libagl/matrix.h
index 5bd717a..cafc119 100644
--- a/opengl/libagl/matrix.h
+++ b/opengl/libagl/matrix.h
@@ -74,7 +74,7 @@
         ); 
     return r;
 
-#elif defined(__mips__)
+#elif defined(__mips__) && !defined(__LP64__) && __mips_isa_rev < 6
 
     GLfixed res;
     int32_t t1,t2,t3;
@@ -160,7 +160,7 @@
         ); 
     return r;
     
-#elif defined(__mips__)
+#elif defined(__mips__)  && !defined(__LP64__) && __mips_isa_rev < 6
 
     GLfixed res;
     int32_t t1,t2;
diff --git a/opengl/libs/Android.mk b/opengl/libs/Android.mk
index 528b983..4cbca63 100644
--- a/opengl/libs/Android.mk
+++ b/opengl/libs/Android.mk
@@ -33,7 +33,6 @@
 #
 
 LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libGLES_trace
-LOCAL_LDLIBS := -lpthread -ldl
 LOCAL_MODULE:= libEGL
 LOCAL_LDFLAGS += -Wl,--exclude-libs=ALL
 LOCAL_SHARED_LIBRARIES += libdl
@@ -48,9 +47,6 @@
 ifeq ($(BOARD_ALLOW_EGL_HIBERNATION),true)
   LOCAL_CFLAGS += -DBOARD_ALLOW_EGL_HIBERNATION
 endif
-ifeq ($(TARGET_BOARD_PLATFORM), omap4)
-  LOCAL_CFLAGS += -DWORKAROUND_BUG_10194508=1
-endif
 ifneq ($(MAX_EGL_CACHE_ENTRY_SIZE),)
   LOCAL_CFLAGS += -DMAX_EGL_CACHE_ENTRY_SIZE=$(MAX_EGL_CACHE_ENTRY_SIZE)
 endif
@@ -63,6 +59,11 @@
   LOCAL_CFLAGS += -DMAX_EGL_CACHE_SIZE=$(MAX_EGL_CACHE_SIZE)
 endif
 
+ifneq ($(filter address,$(SANITIZE_TARGET)),)
+  LOCAL_CFLAGS_32 += -DEGL_WRAPPER_DIR=\"/$(TARGET_COPY_OUT_DATA)/lib\"
+  LOCAL_CFLAGS_64 += -DEGL_WRAPPER_DIR=\"/$(TARGET_COPY_OUT_DATA)/lib64\"
+endif
+
 LOCAL_REQUIRED_MODULES := $(egl.cfg_config_module)
 egl.cfg_config_module :=
 
@@ -79,7 +80,6 @@
 #
 
 LOCAL_SHARED_LIBRARIES += libcutils liblog libEGL
-LOCAL_LDLIBS := -lpthread -ldl
 LOCAL_MODULE:= libGLESv1_CM
 
 LOCAL_SHARED_LIBRARIES += libdl
@@ -90,6 +90,9 @@
 LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
 LOCAL_CFLAGS += -fvisibility=hidden
 
+# TODO: This is to work around b/20093774. Remove after root cause is fixed
+LOCAL_LDFLAGS_arm += -Wl,--hash-style,both
+
 include $(BUILD_SHARED_LIBRARY)
 
 
@@ -99,12 +102,12 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES:= 		\
-	GLES2/gl2.cpp.arm 	\
+LOCAL_SRC_FILES:= \
+	GLES2/gl2.cpp   \
 #
 
+LOCAL_ARM_MODE := arm
 LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libEGL
-LOCAL_LDLIBS := -lpthread -ldl
 LOCAL_MODULE:= libGLESv2
 
 LOCAL_SHARED_LIBRARIES += libdl
@@ -115,21 +118,36 @@
 LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
 LOCAL_CFLAGS += -fvisibility=hidden
 
+# TODO: This is to work around b/20093774. Remove after root cause is fixed
+LOCAL_LDFLAGS_arm += -Wl,--hash-style,both
+
 include $(BUILD_SHARED_LIBRARY)
 
-# Symlink libGLESv3.so -> libGLESv2.so
-# Platform modules should link against libGLESv2.so (-lGLESv2), but NDK apps
-# will be linked against libGLESv3.so.
-LIBGLESV2 := $(LOCAL_INSTALLED_MODULE)
-LIBGLESV3 := $(subst libGLESv2,libGLESv3,$(LIBGLESV2))
-$(LIBGLESV3): $(LIBGLESV2)
-	@echo "Symlink: $@ -> $(notdir $<)"
-	@mkdir -p $(dir $@)
-	$(hide) ln -sf $(notdir $<) $@
-ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
-	$(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(LIBGLESV3)
-LIBGLESV2 :=
-LIBGLESV3 :=
+###############################################################################
+# Build the wrapper OpenGL ES 3.x library (this is just different name for v2)
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+	GLES2/gl2.cpp   \
+#
+
+LOCAL_ARM_MODE := arm
+LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libEGL
+LOCAL_MODULE:= libGLESv3
+LOCAL_SHARED_LIBRARIES += libdl
+# we need to access the private Bionic header <bionic_tls.h>
+LOCAL_C_INCLUDES += bionic/libc/private
+
+LOCAL_CFLAGS += -DLOG_TAG=\"libGLESv3\"
+LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
+LOCAL_CFLAGS += -fvisibility=hidden
+
+# TODO: This is to work around b/20093774. Remove after root cause is fixed
+LOCAL_LDFLAGS_arm += -Wl,--hash-style,both
+
+include $(BUILD_SHARED_LIBRARY)
 
 ###############################################################################
 # Build the ETC1 host static library
@@ -141,8 +159,8 @@
 	ETC1/etc1.cpp 	\
 #
 
-LOCAL_LDLIBS := -lpthread -ldl
 LOCAL_MODULE:= libETC1
+LOCAL_MODULE_HOST_OS := darwin linux windows
 
 include $(BUILD_HOST_STATIC_LIBRARY)
 
@@ -156,7 +174,6 @@
 	ETC1/etc1.cpp 	\
 #
 
-LOCAL_LDLIBS := -lpthread -ldl
 LOCAL_MODULE:= libETC1
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index 1fcc048..8df9af3 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -167,6 +167,14 @@
     return so;
 }
 
+#ifndef EGL_WRAPPER_DIR
+#if defined(__LP64__)
+#define EGL_WRAPPER_DIR "/system/lib64"
+#else
+#define EGL_WRAPPER_DIR "/system/lib"
+#endif
+#endif
+
 void* Loader::open(egl_connection_t* cnx)
 {
     void* dso;
@@ -187,15 +195,10 @@
 
     LOG_ALWAYS_FATAL_IF(!hnd, "couldn't find an OpenGL ES implementation");
 
-#if defined(__LP64__)
-    cnx->libEgl   = load_wrapper("/system/lib64/libEGL.so");
-    cnx->libGles2 = load_wrapper("/system/lib64/libGLESv2.so");
-    cnx->libGles1 = load_wrapper("/system/lib64/libGLESv1_CM.so");
-#else
-    cnx->libEgl   = load_wrapper("/system/lib/libEGL.so");
-    cnx->libGles2 = load_wrapper("/system/lib/libGLESv2.so");
-    cnx->libGles1 = load_wrapper("/system/lib/libGLESv1_CM.so");
-#endif
+    cnx->libEgl   = load_wrapper(EGL_WRAPPER_DIR "/libEGL.so");
+    cnx->libGles2 = load_wrapper(EGL_WRAPPER_DIR "/libGLESv2.so");
+    cnx->libGles1 = load_wrapper(EGL_WRAPPER_DIR "/libGLESv1_CM.so");
+
     LOG_ALWAYS_FATAL_IF(!cnx->libEgl,
             "couldn't load system EGL wrapper libraries");
 
diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp
index 67fbae5..4e0e5bc 100644
--- a/opengl/libs/EGL/egl.cpp
+++ b/opengl/libs/EGL/egl.cpp
@@ -292,6 +292,44 @@
     return (const GLubyte *)c->gl_extensions.string();
 }
 
+const GLubyte * egl_get_string_for_current_context(GLenum name, GLuint index) {
+    // NOTE: returning NULL here will fall-back to the default
+    // implementation.
+
+    EGLContext context = egl_tls_t::getContext();
+    if (context == EGL_NO_CONTEXT)
+        return NULL;
+
+    egl_context_t const * const c = get_context(context);
+    if (c == NULL) // this should never happen, by construction
+        return NULL;
+
+    if (name != GL_EXTENSIONS)
+        return NULL;
+
+    // if index is out of bounds, assume it will be in the default
+    // implementation too, so we don't have to generate a GL error here
+    if (index >= c->tokenized_gl_extensions.size())
+        return NULL;
+
+    return (const GLubyte *)c->tokenized_gl_extensions.itemAt(index).string();
+}
+
+GLint egl_get_num_extensions_for_current_context() {
+    // NOTE: returning -1 here will fall-back to the default
+    // implementation.
+
+    EGLContext context = egl_tls_t::getContext();
+    if (context == EGL_NO_CONTEXT)
+        return -1;
+
+    egl_context_t const * const c = get_context(context);
+    if (c == NULL) // this should never happen, by construction
+        return -1;
+
+    return (GLint)c->tokenized_gl_extensions.size();
+}
+
 // ----------------------------------------------------------------------------
 
 // this mutex protects:
@@ -330,12 +368,26 @@
     return res;
 }
 
+static pthread_mutex_t sLogPrintMutex = PTHREAD_MUTEX_INITIALIZER;
+static nsecs_t sLogPrintTime = 0;
+#define NSECS_DURATION 1000000000
+
 void gl_unimplemented() {
-    ALOGE("called unimplemented OpenGL ES API");
-    char value[PROPERTY_VALUE_MAX];
-    property_get("debug.egl.callstack", value, "0");
-    if (atoi(value)) {
-        CallStack stack(LOG_TAG);
+    bool printLog = false;
+    nsecs_t now = systemTime();
+    pthread_mutex_lock(&sLogPrintMutex);
+    if ((now - sLogPrintTime) > NSECS_DURATION) {
+        sLogPrintTime = now;
+        printLog = true;
+    }
+    pthread_mutex_unlock(&sLogPrintMutex);
+    if (printLog) {
+        ALOGE("called unimplemented OpenGL ES API");
+        char value[PROPERTY_VALUE_MAX];
+        property_get("debug.egl.callstack", value, "0");
+        if (atoi(value)) {
+            CallStack stack(LOG_TAG);
+        }
     }
 }
 
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index 09ac3fc..34e840d 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -49,10 +49,6 @@
 
 using namespace android;
 
-// This extension has not been ratified yet, so can't be shipped.
-// Implementation is incomplete and untested.
-#define ENABLE_EGL_KHR_GL_COLORSPACE 0
-
 // ----------------------------------------------------------------------------
 
 namespace android {
@@ -80,26 +76,36 @@
 extern char const * const gBuiltinExtensionString =
         "EGL_KHR_get_all_proc_addresses "
         "EGL_ANDROID_presentation_time "
+        "EGL_KHR_swap_buffers_with_damage "
         ;
 extern char const * const gExtensionString  =
         "EGL_KHR_image "                        // mandatory
         "EGL_KHR_image_base "                   // mandatory
         "EGL_KHR_image_pixmap "
         "EGL_KHR_lock_surface "
-#if (ENABLE_EGL_KHR_GL_COLORSPACE != 0)
         "EGL_KHR_gl_colorspace "
-#endif
         "EGL_KHR_gl_texture_2D_image "
+        "EGL_KHR_gl_texture_3D_image "
         "EGL_KHR_gl_texture_cubemap_image "
         "EGL_KHR_gl_renderbuffer_image "
         "EGL_KHR_reusable_sync "
         "EGL_KHR_fence_sync "
         "EGL_KHR_create_context "
+        "EGL_KHR_config_attribs "
+        "EGL_KHR_surfaceless_context "
+        "EGL_KHR_stream "
+        "EGL_KHR_stream_fifo "
+        "EGL_KHR_stream_producer_eglsurface "
+        "EGL_KHR_stream_consumer_gltexture "
+        "EGL_KHR_stream_cross_process_fd "
         "EGL_EXT_create_context_robustness "
         "EGL_NV_system_time "
         "EGL_ANDROID_image_native_buffer "      // mandatory
         "EGL_KHR_wait_sync "                    // strongly recommended
         "EGL_ANDROID_recordable "               // mandatory
+        "EGL_KHR_partial_update "               // strongly recommended
+        "EGL_EXT_buffer_age "                   // strongly recommended with partial_update
+        "EGL_KHR_create_context_no_error "
         ;
 
 // extensions not exposed to applications but used by the ANDROID system
@@ -152,6 +158,39 @@
     // EGL_ANDROID_presentation_time
     { "eglPresentationTimeANDROID",
             (__eglMustCastToProperFunctionPointerType)&eglPresentationTimeANDROID },
+
+    // EGL_KHR_swap_buffers_with_damage
+    { "eglSwapBuffersWithDamageKHR",
+            (__eglMustCastToProperFunctionPointerType)&eglSwapBuffersWithDamageKHR },
+
+    // EGL_KHR_partial_update
+    { "eglSetDamageRegionKHR",
+            (__eglMustCastToProperFunctionPointerType)&eglSetDamageRegionKHR },
+
+    { "eglCreateStreamKHR",
+            (__eglMustCastToProperFunctionPointerType)&eglCreateStreamKHR },
+    { "eglDestroyStreamKHR",
+            (__eglMustCastToProperFunctionPointerType)&eglDestroyStreamKHR },
+    { "eglStreamAttribKHR",
+            (__eglMustCastToProperFunctionPointerType)&eglStreamAttribKHR },
+    { "eglQueryStreamKHR",
+            (__eglMustCastToProperFunctionPointerType)&eglQueryStreamKHR },
+    { "eglQueryStreamu64KHR",
+            (__eglMustCastToProperFunctionPointerType)&eglQueryStreamu64KHR },
+    { "eglQueryStreamTimeKHR",
+            (__eglMustCastToProperFunctionPointerType)&eglQueryStreamTimeKHR },
+    { "eglCreateStreamProducerSurfaceKHR",
+            (__eglMustCastToProperFunctionPointerType)&eglCreateStreamProducerSurfaceKHR },
+    { "eglStreamConsumerGLTextureExternalKHR",
+            (__eglMustCastToProperFunctionPointerType)&eglStreamConsumerGLTextureExternalKHR },
+    { "eglStreamConsumerAcquireKHR",
+            (__eglMustCastToProperFunctionPointerType)&eglStreamConsumerAcquireKHR },
+    { "eglStreamConsumerReleaseKHR",
+            (__eglMustCastToProperFunctionPointerType)&eglStreamConsumerReleaseKHR },
+    { "eglGetStreamFileDescriptorKHR",
+            (__eglMustCastToProperFunctionPointerType)&eglGetStreamFileDescriptorKHR },
+    { "eglCreateStreamFromFileDescriptorKHR",
+            (__eglMustCastToProperFunctionPointerType)&eglCreateStreamFromFileDescriptorKHR },
 };
 
 /*
@@ -372,29 +411,18 @@
 // surfaces
 // ----------------------------------------------------------------------------
 
-// The EGL_KHR_gl_colorspace spec hasn't been ratified yet, so these haven't
-// been added to the Khronos egl.h.
-#define EGL_GL_COLORSPACE_KHR           EGL_VG_COLORSPACE
-#define EGL_GL_COLORSPACE_SRGB_KHR      EGL_VG_COLORSPACE_sRGB
-#define EGL_GL_COLORSPACE_LINEAR_KHR    EGL_VG_COLORSPACE_LINEAR
-
 // Turn linear formats into corresponding sRGB formats when colorspace is
 // EGL_GL_COLORSPACE_SRGB_KHR, or turn sRGB formats into corresponding linear
 // formats when colorspace is EGL_GL_COLORSPACE_LINEAR_KHR. In any cases where
-// the modification isn't possible, the original format is returned.
-static int modifyFormatColorspace(int fmt, EGLint colorspace) {
+// the modification isn't possible, the original dataSpace is returned.
+static android_dataspace modifyBufferDataspace( android_dataspace dataSpace,
+                                                EGLint colorspace) {
     if (colorspace == EGL_GL_COLORSPACE_LINEAR_KHR) {
-        switch (fmt) {
-            case HAL_PIXEL_FORMAT_sRGB_A_8888: return HAL_PIXEL_FORMAT_RGBA_8888;
-            case HAL_PIXEL_FORMAT_sRGB_X_8888: return HAL_PIXEL_FORMAT_RGBX_8888;
-        }
+        return HAL_DATASPACE_SRGB_LINEAR;
     } else if (colorspace == EGL_GL_COLORSPACE_SRGB_KHR) {
-        switch (fmt) {
-            case HAL_PIXEL_FORMAT_RGBA_8888: return HAL_PIXEL_FORMAT_sRGB_A_8888;
-            case HAL_PIXEL_FORMAT_RGBX_8888: return HAL_PIXEL_FORMAT_sRGB_X_8888;
-        }
+        return HAL_DATASPACE_SRGB;
     }
-    return fmt;
+    return dataSpace;
 }
 
 EGLSurface eglCreateWindowSurface(  EGLDisplay dpy, EGLConfig config,
@@ -408,9 +436,11 @@
     if (dp) {
         EGLDisplay iDpy = dp->disp.dpy;
 
-        if (native_window_api_connect(window, NATIVE_WINDOW_API_EGL) != OK) {
-            ALOGE("EGLNativeWindowType %p already connected to another API",
-                    window);
+        int result = native_window_api_connect(window, NATIVE_WINDOW_API_EGL);
+        if (result != OK) {
+            ALOGE("eglCreateWindowSurface: native_window_api_connect (win=%p) "
+                    "failed (%#x) (already connected to another API?)",
+                    window, result);
             return setError(EGL_BAD_ALLOC, EGL_NO_SURFACE);
         }
 
@@ -419,37 +449,10 @@
         // of our native format. So if sRGB gamma is requested, we have to
         // modify the EGLconfig's format before setting the native window's
         // format.
-#if WORKAROUND_BUG_10194508
-#warning "WORKAROUND_10194508 enabled"
-        EGLint format;
-        if (!cnx->egl.eglGetConfigAttrib(iDpy, config, EGL_NATIVE_VISUAL_ID,
-                &format)) {
-            ALOGE("eglGetConfigAttrib(EGL_NATIVE_VISUAL_ID) failed: %#x",
-                    eglGetError());
-            format = 0;
-        }
-        if (attrib_list) {
-            for (const EGLint* attr = attrib_list; *attr != EGL_NONE;
-                    attr += 2) {
-                if (*attr == EGL_GL_COLORSPACE_KHR &&
-                        dp->haveExtension("EGL_KHR_gl_colorspace")) {
-                    if (ENABLE_EGL_KHR_GL_COLORSPACE) {
-                        format = modifyFormatColorspace(format, *(attr+1));
-                    } else {
-                        // Normally we'd pass through unhandled attributes to
-                        // the driver. But in case the driver implements this
-                        // extension but we're disabling it, we want to prevent
-                        // it getting through -- support will be broken without
-                        // our help.
-                        ALOGE("sRGB window surfaces not supported");
-                        return setError(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
-                    }
-                }
-            }
-        }
-#else
+
         // by default, just pick RGBA_8888
         EGLint format = HAL_PIXEL_FORMAT_RGBA_8888;
+        android_dataspace dataSpace = HAL_DATASPACE_UNKNOWN;
 
         EGLint a = 0;
         cnx->egl.eglGetConfigAttrib(iDpy, config, EGL_ALPHA_SIZE, &a);
@@ -474,21 +477,11 @@
         if (attrib_list && dp->haveExtension("EGL_KHR_gl_colorspace")) {
             for (const EGLint* attr = attrib_list; *attr != EGL_NONE; attr += 2) {
                 if (*attr == EGL_GL_COLORSPACE_KHR) {
-                    if (ENABLE_EGL_KHR_GL_COLORSPACE) {
-                        format = modifyFormatColorspace(format, *(attr+1));
-                    } else {
-                        // Normally we'd pass through unhandled attributes to
-                        // the driver. But in case the driver implements this
-                        // extension but we're disabling it, we want to prevent
-                        // it getting through -- support will be broken without
-                        // our help.
-                        ALOGE("sRGB window surfaces not supported");
-                        return setError(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
-                    }
+                    dataSpace = modifyBufferDataspace(dataSpace, *(attr+1));
                 }
             }
         }
-#endif
+
         if (format != 0) {
             int err = native_window_set_buffers_format(window, format);
             if (err != 0) {
@@ -499,6 +492,16 @@
             }
         }
 
+        if (dataSpace != 0) {
+            int err = native_window_set_buffers_data_space(window, dataSpace);
+            if (err != 0) {
+                ALOGE("error setting native window pixel dataSpace: %s (%d)",
+                        strerror(-err), err);
+                native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL);
+                return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
+            }
+        }
+
         // the EGL spec requires that a new EGLSurface default to swap interval
         // 1, so explicitly set that on the window here.
         ANativeWindow* anw = reinterpret_cast<ANativeWindow*>(window);
@@ -1041,7 +1044,8 @@
     Mutex mMutex;
 };
 
-EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw)
+EGLBoolean eglSwapBuffersWithDamageKHR(EGLDisplay dpy, EGLSurface draw,
+        EGLint *rects, EGLint n_rects)
 {
     ATRACE_CALL();
     clearError();
@@ -1100,7 +1104,38 @@
         }
     }
 
-    return s->cnx->egl.eglSwapBuffers(dp->disp.dpy, s->surface);
+    if (n_rects == 0) {
+        return s->cnx->egl.eglSwapBuffers(dp->disp.dpy, s->surface);
+    }
+
+    Vector<android_native_rect_t> androidRects;
+    for (int r = 0; r < n_rects; ++r) {
+        int offset = r * 4;
+        int x = rects[offset];
+        int y = rects[offset + 1];
+        int width = rects[offset + 2];
+        int height = rects[offset + 3];
+        android_native_rect_t androidRect;
+        androidRect.left = x;
+        androidRect.top = y + height;
+        androidRect.right = x + width;
+        androidRect.bottom = y;
+        androidRects.push_back(androidRect);
+    }
+    native_window_set_surface_damage(s->win.get(), androidRects.array(),
+            androidRects.size());
+
+    if (s->cnx->egl.eglSwapBuffersWithDamageKHR) {
+        return s->cnx->egl.eglSwapBuffersWithDamageKHR(dp->disp.dpy, s->surface,
+                rects, n_rects);
+    } else {
+        return s->cnx->egl.eglSwapBuffers(dp->disp.dpy, s->surface);
+    }
+}
+
+EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
+{
+    return eglSwapBuffersWithDamageKHR(dpy, surface, NULL, 0);
 }
 
 EGLBoolean eglCopyBuffers(  EGLDisplay dpy, EGLSurface surface,
@@ -1495,6 +1530,212 @@
     return result;
 }
 
+EGLStreamKHR eglCreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list)
+{
+    clearError();
+
+    const egl_display_ptr dp = validate_display(dpy);
+    if (!dp) return EGL_NO_STREAM_KHR;
+
+    EGLStreamKHR result = EGL_NO_STREAM_KHR;
+    egl_connection_t* const cnx = &gEGLImpl;
+    if (cnx->dso && cnx->egl.eglCreateStreamKHR) {
+        result = cnx->egl.eglCreateStreamKHR(
+                dp->disp.dpy, attrib_list);
+    }
+    return result;
+}
+
+EGLBoolean eglDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream)
+{
+    clearError();
+
+    const egl_display_ptr dp = validate_display(dpy);
+    if (!dp) return EGL_FALSE;
+
+    EGLBoolean result = EGL_FALSE;
+    egl_connection_t* const cnx = &gEGLImpl;
+    if (cnx->dso && cnx->egl.eglDestroyStreamKHR) {
+        result = cnx->egl.eglDestroyStreamKHR(
+                dp->disp.dpy, stream);
+    }
+    return result;
+}
+
+EGLBoolean eglStreamAttribKHR(EGLDisplay dpy, EGLStreamKHR stream,
+        EGLenum attribute, EGLint value)
+{
+    clearError();
+
+    const egl_display_ptr dp = validate_display(dpy);
+    if (!dp) return EGL_FALSE;
+
+    EGLBoolean result = EGL_FALSE;
+    egl_connection_t* const cnx = &gEGLImpl;
+    if (cnx->dso && cnx->egl.eglStreamAttribKHR) {
+        result = cnx->egl.eglStreamAttribKHR(
+                dp->disp.dpy, stream, attribute, value);
+    }
+    return result;
+}
+
+EGLBoolean eglQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream,
+        EGLenum attribute, EGLint *value)
+{
+    clearError();
+
+    const egl_display_ptr dp = validate_display(dpy);
+    if (!dp) return EGL_FALSE;
+
+    EGLBoolean result = EGL_FALSE;
+    egl_connection_t* const cnx = &gEGLImpl;
+    if (cnx->dso && cnx->egl.eglQueryStreamKHR) {
+        result = cnx->egl.eglQueryStreamKHR(
+                dp->disp.dpy, stream, attribute, value);
+    }
+    return result;
+}
+
+EGLBoolean eglQueryStreamu64KHR(EGLDisplay dpy, EGLStreamKHR stream,
+        EGLenum attribute, EGLuint64KHR *value)
+{
+    clearError();
+
+    const egl_display_ptr dp = validate_display(dpy);
+    if (!dp) return EGL_FALSE;
+
+    EGLBoolean result = EGL_FALSE;
+    egl_connection_t* const cnx = &gEGLImpl;
+    if (cnx->dso && cnx->egl.eglQueryStreamu64KHR) {
+        result = cnx->egl.eglQueryStreamu64KHR(
+                dp->disp.dpy, stream, attribute, value);
+    }
+    return result;
+}
+
+EGLBoolean eglQueryStreamTimeKHR(EGLDisplay dpy, EGLStreamKHR stream,
+        EGLenum attribute, EGLTimeKHR *value)
+{
+    clearError();
+
+    const egl_display_ptr dp = validate_display(dpy);
+    if (!dp) return EGL_FALSE;
+
+    EGLBoolean result = EGL_FALSE;
+    egl_connection_t* const cnx = &gEGLImpl;
+    if (cnx->dso && cnx->egl.eglQueryStreamTimeKHR) {
+        result = cnx->egl.eglQueryStreamTimeKHR(
+                dp->disp.dpy, stream, attribute, value);
+    }
+    return result;
+}
+
+EGLSurface eglCreateStreamProducerSurfaceKHR(EGLDisplay dpy, EGLConfig config,
+        EGLStreamKHR stream, const EGLint *attrib_list)
+{
+    clearError();
+
+    egl_display_ptr dp = validate_display(dpy);
+    if (!dp) return EGL_NO_SURFACE;
+
+    egl_connection_t* const cnx = &gEGLImpl;
+    if (cnx->dso && cnx->egl.eglCreateStreamProducerSurfaceKHR) {
+        EGLSurface surface = cnx->egl.eglCreateStreamProducerSurfaceKHR(
+                dp->disp.dpy, config, stream, attrib_list);
+        if (surface != EGL_NO_SURFACE) {
+            egl_surface_t* s = new egl_surface_t(dp.get(), config, NULL,
+                    surface, cnx);
+            return s;
+        }
+    }
+    return EGL_NO_SURFACE;
+}
+
+EGLBoolean eglStreamConsumerGLTextureExternalKHR(EGLDisplay dpy,
+        EGLStreamKHR stream)
+{
+    clearError();
+
+    const egl_display_ptr dp = validate_display(dpy);
+    if (!dp) return EGL_FALSE;
+
+    EGLBoolean result = EGL_FALSE;
+    egl_connection_t* const cnx = &gEGLImpl;
+    if (cnx->dso && cnx->egl.eglStreamConsumerGLTextureExternalKHR) {
+        result = cnx->egl.eglStreamConsumerGLTextureExternalKHR(
+                dp->disp.dpy, stream);
+    }
+    return result;
+}
+
+EGLBoolean eglStreamConsumerAcquireKHR(EGLDisplay dpy,
+        EGLStreamKHR stream)
+{
+    clearError();
+
+    const egl_display_ptr dp = validate_display(dpy);
+    if (!dp) return EGL_FALSE;
+
+    EGLBoolean result = EGL_FALSE;
+    egl_connection_t* const cnx = &gEGLImpl;
+    if (cnx->dso && cnx->egl.eglStreamConsumerAcquireKHR) {
+        result = cnx->egl.eglStreamConsumerAcquireKHR(
+                dp->disp.dpy, stream);
+    }
+    return result;
+}
+
+EGLBoolean eglStreamConsumerReleaseKHR(EGLDisplay dpy,
+        EGLStreamKHR stream)
+{
+    clearError();
+
+    const egl_display_ptr dp = validate_display(dpy);
+    if (!dp) return EGL_FALSE;
+
+    EGLBoolean result = EGL_FALSE;
+    egl_connection_t* const cnx = &gEGLImpl;
+    if (cnx->dso && cnx->egl.eglStreamConsumerReleaseKHR) {
+        result = cnx->egl.eglStreamConsumerReleaseKHR(
+                dp->disp.dpy, stream);
+    }
+    return result;
+}
+
+EGLNativeFileDescriptorKHR eglGetStreamFileDescriptorKHR(
+        EGLDisplay dpy, EGLStreamKHR stream)
+{
+    clearError();
+
+    const egl_display_ptr dp = validate_display(dpy);
+    if (!dp) return EGL_NO_FILE_DESCRIPTOR_KHR;
+
+    EGLNativeFileDescriptorKHR result = EGL_NO_FILE_DESCRIPTOR_KHR;
+    egl_connection_t* const cnx = &gEGLImpl;
+    if (cnx->dso && cnx->egl.eglGetStreamFileDescriptorKHR) {
+        result = cnx->egl.eglGetStreamFileDescriptorKHR(
+                dp->disp.dpy, stream);
+    }
+    return result;
+}
+
+EGLStreamKHR eglCreateStreamFromFileDescriptorKHR(
+        EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor)
+{
+    clearError();
+
+    const egl_display_ptr dp = validate_display(dpy);
+    if (!dp) return EGL_NO_STREAM_KHR;
+
+    EGLStreamKHR result = EGL_NO_STREAM_KHR;
+    egl_connection_t* const cnx = &gEGLImpl;
+    if (cnx->dso && cnx->egl.eglCreateStreamFromFileDescriptorKHR) {
+        result = cnx->egl.eglCreateStreamFromFileDescriptorKHR(
+                dp->disp.dpy, file_descriptor);
+    }
+    return result;
+}
+
 // ----------------------------------------------------------------------------
 // EGL_EGLEXT_VERSION 15
 // ----------------------------------------------------------------------------
@@ -1590,3 +1831,32 @@
 
     return setErrorQuiet(EGL_BAD_DISPLAY, 0);
 }
+
+// ----------------------------------------------------------------------------
+// Partial update extension
+// ----------------------------------------------------------------------------
+EGLBoolean eglSetDamageRegionKHR(EGLDisplay dpy, EGLSurface surface,
+        EGLint *rects, EGLint n_rects)
+{
+    clearError();
+
+    const egl_display_ptr dp = validate_display(dpy);
+    if (!dp) {
+        setError(EGL_BAD_DISPLAY, EGL_FALSE);
+        return EGL_FALSE;
+    }
+
+    SurfaceRef _s(dp.get(), surface);
+    if (!_s.get()) {
+        setError(EGL_BAD_SURFACE, EGL_FALSE);
+        return EGL_FALSE;
+    }
+
+    egl_surface_t const * const s = get_surface(surface);
+    if (s->cnx->egl.eglSetDamageRegionKHR) {
+        return s->cnx->egl.eglSetDamageRegionKHR(dp->disp.dpy, s->surface,
+                rects, n_rects);
+    }
+
+    return EGL_FALSE;
+}
diff --git a/opengl/libs/EGL/egl_cache.cpp b/opengl/libs/EGL/egl_cache.cpp
index b0798a1..f368d75 100644
--- a/opengl/libs/EGL/egl_cache.cpp
+++ b/opengl/libs/EGL/egl_cache.cpp
@@ -21,6 +21,7 @@
 #include "egldefs.h"
 
 #include <fcntl.h>
+#include <inttypes.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -306,7 +307,8 @@
         // Sanity check the size before trying to mmap it.
         size_t fileSize = statBuf.st_size;
         if (fileSize > maxTotalSize * 2) {
-            ALOGE("cache file is too large: %#llx", statBuf.st_size);
+            ALOGE("cache file is too large: %#" PRIx64,
+                  static_cast<off64_t>(statBuf.st_size));
             close(fd);
             return;
         }
diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp
index 7784ca6..e81621b 100644
--- a/opengl/libs/EGL/egl_display.cpp
+++ b/opengl/libs/EGL/egl_display.cpp
@@ -57,7 +57,7 @@
 egl_display_t egl_display_t::sDisplay[NUM_DISPLAYS];
 
 egl_display_t::egl_display_t() :
-    magic('_dpy'), finishOnSwap(false), traceGpuCompletion(false), refs(0) {
+    magic('_dpy'), finishOnSwap(false), traceGpuCompletion(false), refs(0), eglIsInitialized(false) {
 }
 
 egl_display_t::~egl_display_t() {
@@ -120,163 +120,188 @@
 
 EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {
 
-    Mutex::Autolock _l(lock);
+    {
+        Mutex::Autolock _rf(refLock);
 
-    if (refs > 0) {
+        refs++;
+        if (refs > 1) {
+            if (major != NULL)
+                *major = VERSION_MAJOR;
+            if (minor != NULL)
+                *minor = VERSION_MINOR;
+            while(!eglIsInitialized) refCond.wait(refLock);
+            return EGL_TRUE;
+        }
+
+        while(eglIsInitialized) refCond.wait(refLock);
+    }
+
+    {
+        Mutex::Autolock _l(lock);
+
+#if EGL_TRACE
+
+        // Called both at early_init time and at this time. (Early_init is pre-zygote, so
+        // the information from that call may be stale.)
+        initEglTraceLevel();
+        initEglDebugLevel();
+
+#endif
+
+        setGLHooksThreadSpecific(&gHooksNoContext);
+
+        // initialize each EGL and
+        // build our own extension string first, based on the extension we know
+        // and the extension supported by our client implementation
+
+        egl_connection_t* const cnx = &gEGLImpl;
+        cnx->major = -1;
+        cnx->minor = -1;
+        if (cnx->dso) {
+            EGLDisplay idpy = disp.dpy;
+            if (cnx->egl.eglInitialize(idpy, &cnx->major, &cnx->minor)) {
+                //ALOGD("initialized dpy=%p, ver=%d.%d, cnx=%p",
+                //        idpy, cnx->major, cnx->minor, cnx);
+
+                // display is now initialized
+                disp.state = egl_display_t::INITIALIZED;
+
+                // get the query-strings for this display for each implementation
+                disp.queryString.vendor = cnx->egl.eglQueryString(idpy,
+                        EGL_VENDOR);
+                disp.queryString.version = cnx->egl.eglQueryString(idpy,
+                        EGL_VERSION);
+                disp.queryString.extensions = cnx->egl.eglQueryString(idpy,
+                        EGL_EXTENSIONS);
+                disp.queryString.clientApi = cnx->egl.eglQueryString(idpy,
+                        EGL_CLIENT_APIS);
+
+            } else {
+                ALOGW("eglInitialize(%p) failed (%s)", idpy,
+                        egl_tls_t::egl_strerror(cnx->egl.eglGetError()));
+            }
+        }
+
+        // the query strings are per-display
+        mVendorString.setTo(sVendorString);
+        mVersionString.setTo(sVersionString);
+        mClientApiString.setTo(sClientApiString);
+
+        mExtensionString.setTo(gBuiltinExtensionString);
+        char const* start = gExtensionString;
+        char const* end;
+        do {
+            // find the space separating this extension for the next one
+            end = strchr(start, ' ');
+            if (end) {
+                // length of the extension string
+                const size_t len = end - start;
+                if (len) {
+                    // NOTE: we could avoid the copy if we had strnstr.
+                    const String8 ext(start, len);
+                    if (findExtension(disp.queryString.extensions, ext.string(),
+                            len)) {
+                        mExtensionString.append(start, len+1);
+                    }
+                }
+                // process the next extension string, and skip the space.
+                start = end + 1;
+            }
+        } while (end);
+
+        egl_cache_t::get()->initialize(this);
+
+        char value[PROPERTY_VALUE_MAX];
+        property_get("debug.egl.finish", value, "0");
+        if (atoi(value)) {
+            finishOnSwap = true;
+        }
+
+        property_get("debug.egl.traceGpuCompletion", value, "0");
+        if (atoi(value)) {
+            traceGpuCompletion = true;
+        }
+
         if (major != NULL)
             *major = VERSION_MAJOR;
         if (minor != NULL)
             *minor = VERSION_MINOR;
-        refs++;
-        return EGL_TRUE;
+
+        mHibernation.setDisplayValid(true);
     }
 
-#if EGL_TRACE
-
-    // Called both at early_init time and at this time. (Early_init is pre-zygote, so
-    // the information from that call may be stale.)
-    initEglTraceLevel();
-    initEglDebugLevel();
-
-#endif
-
-    setGLHooksThreadSpecific(&gHooksNoContext);
-
-    // initialize each EGL and
-    // build our own extension string first, based on the extension we know
-    // and the extension supported by our client implementation
-
-    egl_connection_t* const cnx = &gEGLImpl;
-    cnx->major = -1;
-    cnx->minor = -1;
-    if (cnx->dso) {
-        EGLDisplay idpy = disp.dpy;
-        if (cnx->egl.eglInitialize(idpy, &cnx->major, &cnx->minor)) {
-            //ALOGD("initialized dpy=%p, ver=%d.%d, cnx=%p",
-            //        idpy, cnx->major, cnx->minor, cnx);
-
-            // display is now initialized
-            disp.state = egl_display_t::INITIALIZED;
-
-            // get the query-strings for this display for each implementation
-            disp.queryString.vendor = cnx->egl.eglQueryString(idpy,
-                    EGL_VENDOR);
-            disp.queryString.version = cnx->egl.eglQueryString(idpy,
-                    EGL_VERSION);
-            disp.queryString.extensions = cnx->egl.eglQueryString(idpy,
-                    EGL_EXTENSIONS);
-            disp.queryString.clientApi = cnx->egl.eglQueryString(idpy,
-                    EGL_CLIENT_APIS);
-
-        } else {
-            ALOGW("eglInitialize(%p) failed (%s)", idpy,
-                    egl_tls_t::egl_strerror(cnx->egl.eglGetError()));
-        }
+    {
+        Mutex::Autolock _rf(refLock);
+        eglIsInitialized = true;
+        refCond.broadcast();
     }
 
-    // the query strings are per-display
-    mVendorString.setTo(sVendorString);
-    mVersionString.setTo(sVersionString);
-    mClientApiString.setTo(sClientApiString);
-
-    mExtensionString.setTo(gBuiltinExtensionString);
-    char const* start = gExtensionString;
-    char const* end;
-    do {
-        // find the space separating this extension for the next one
-        end = strchr(start, ' ');
-        if (end) {
-            // length of the extension string
-            const size_t len = end - start;
-            if (len) {
-                // NOTE: we could avoid the copy if we had strnstr.
-                const String8 ext(start, len);
-                if (findExtension(disp.queryString.extensions, ext.string(),
-                        len)) {
-                    mExtensionString.append(start, len+1);
-                }
-            }
-            // process the next extension string, and skip the space.
-            start = end + 1;
-        }
-    } while (end);
-
-    egl_cache_t::get()->initialize(this);
-
-    char value[PROPERTY_VALUE_MAX];
-    property_get("debug.egl.finish", value, "0");
-    if (atoi(value)) {
-        finishOnSwap = true;
-    }
-
-    property_get("debug.egl.traceGpuCompletion", value, "0");
-    if (atoi(value)) {
-        traceGpuCompletion = true;
-    }
-
-    refs++;
-    if (major != NULL)
-        *major = VERSION_MAJOR;
-    if (minor != NULL)
-        *minor = VERSION_MINOR;
-
-    mHibernation.setDisplayValid(true);
-
     return EGL_TRUE;
 }
 
 EGLBoolean egl_display_t::terminate() {
 
-    Mutex::Autolock _l(lock);
+    {
+        Mutex::Autolock _rl(refLock);
+        if (refs == 0) {
+            /*
+             * From the EGL spec (3.2):
+             * "Termination of a display that has already been terminated,
+             *  (...), is allowed, but the only effect of such a call is
+             *  to return EGL_TRUE (...)
+             */
+            return EGL_TRUE;
+        }
 
-    if (refs == 0) {
-        /*
-         * From the EGL spec (3.2):
-         * "Termination of a display that has already been terminated,
-         *  (...), is allowed, but the only effect of such a call is
-         *  to return EGL_TRUE (...)
-         */
-        return EGL_TRUE;
-    }
-
-    // this is specific to Android, display termination is ref-counted.
-    if (refs > 1) {
+        // this is specific to Android, display termination is ref-counted.
         refs--;
-        return EGL_TRUE;
+        if (refs > 0) {
+            return EGL_TRUE;
+        }
     }
 
     EGLBoolean res = EGL_FALSE;
-    egl_connection_t* const cnx = &gEGLImpl;
-    if (cnx->dso && disp.state == egl_display_t::INITIALIZED) {
-        if (cnx->egl.eglTerminate(disp.dpy) == EGL_FALSE) {
-            ALOGW("eglTerminate(%p) failed (%s)", disp.dpy,
-                    egl_tls_t::egl_strerror(cnx->egl.eglGetError()));
+
+    {
+        Mutex::Autolock _l(lock);
+
+        egl_connection_t* const cnx = &gEGLImpl;
+        if (cnx->dso && disp.state == egl_display_t::INITIALIZED) {
+            if (cnx->egl.eglTerminate(disp.dpy) == EGL_FALSE) {
+                ALOGW("eglTerminate(%p) failed (%s)", disp.dpy,
+                        egl_tls_t::egl_strerror(cnx->egl.eglGetError()));
+            }
+            // REVISIT: it's unclear what to do if eglTerminate() fails
+            disp.state = egl_display_t::TERMINATED;
+            res = EGL_TRUE;
         }
-        // REVISIT: it's unclear what to do if eglTerminate() fails
-        disp.state = egl_display_t::TERMINATED;
-        res = EGL_TRUE;
+
+        mHibernation.setDisplayValid(false);
+
+        // Reset the extension string since it will be regenerated if we get
+        // reinitialized.
+        mExtensionString.setTo("");
+
+        // Mark all objects remaining in the list as terminated, unless
+        // there are no reference to them, it which case, we're free to
+        // delete them.
+        size_t count = objects.size();
+        ALOGW_IF(count, "eglTerminate() called w/ %zu objects remaining", count);
+        for (size_t i=0 ; i<count ; i++) {
+            egl_object_t* o = objects.itemAt(i);
+            o->destroy();
+        }
+
+        // this marks all object handles are "terminated"
+        objects.clear();
     }
 
-    mHibernation.setDisplayValid(false);
-
-    // Reset the extension string since it will be regenerated if we get
-    // reinitialized.
-    mExtensionString.setTo("");
-
-    // Mark all objects remaining in the list as terminated, unless
-    // there are no reference to them, it which case, we're free to
-    // delete them.
-    size_t count = objects.size();
-    ALOGW_IF(count, "eglTerminate() called w/ %d objects remaining", count);
-    for (size_t i=0 ; i<count ; i++) {
-        egl_object_t* o = objects.itemAt(i);
-        o->destroy();
+    {
+        Mutex::Autolock _rl(refLock);
+        eglIsInitialized = false;
+        refCond.broadcast();
     }
 
-    // this marks all object handles are "terminated"
-    objects.clear();
-
-    refs--;
     return res;
 }
 
diff --git a/opengl/libs/EGL/egl_display.h b/opengl/libs/EGL/egl_display.h
index 87f27f8..2d86295 100644
--- a/opengl/libs/EGL/egl_display.h
+++ b/opengl/libs/EGL/egl_display.h
@@ -39,7 +39,7 @@
 
 class egl_object_t;
 class egl_context_t;
-class egl_connection_t;
+struct egl_connection_t;
 
 // ----------------------------------------------------------------------------
 
@@ -131,7 +131,9 @@
     void leave() { return mHibernation.decWakeCount(HibernationMachine::WEAK); }
 
             uint32_t                    refs;
-    mutable Mutex                       lock;
+            bool                        eglIsInitialized;
+    mutable Mutex                       lock, refLock;
+    mutable Condition                   refCond;
             SortedVector<egl_object_t*> objects;
             String8 mVendorString;
             String8 mVersionString;
diff --git a/opengl/libs/EGL/egl_entries.in b/opengl/libs/EGL/egl_entries.in
index 70d0e52..498b2fc 100644
--- a/opengl/libs/EGL/egl_entries.in
+++ b/opengl/libs/EGL/egl_entries.in
@@ -61,18 +61,18 @@
 
 /* EGL_EGLEXT_VERSION 15 */
 
-//    EGL_ENTRY(EGLStreamKHR, eglCreateStreamKHR,     EGLDisplay, const EGLint *)
-//    EGL_ENTRY(EGLBoolean,   eglDestroyStreamKHR,    EGLDisplay, EGLStreamKHR)
-//    EGL_ENTRY(EGLBoolean,   eglStreamAttribKHR,     EGLDisplay, EGLStreamKHR, EGLenum, EGLint)
-//    EGL_ENTRY(EGLBoolean,   eglQueryStreamKHR,      EGLDisplay, EGLStreamKHR, EGLenum, EGLint *)
-//    EGL_ENTRY(EGLBoolean,   eglQueryStreamu64KHR,   EGLDisplay, EGLStreamKHR, EGLenum, EGLuint64KHR *)
-//    EGL_ENTRY(EGLBoolean,   eglStreamConsumerGLTextureExternalKHR,  EGLDisplay, EGLStreamKHR)
-//    EGL_ENTRY(EGLBoolean,   eglStreamConsumerAcquireKHR,            EGLDisplay, EGLStreamKHR)
-//    EGL_ENTRY(EGLBoolean,   eglStreamConsumerReleaseKHR,            EGLDisplay, EGLStreamKHR)
-//    EGL_ENTRY(EGLSurface,   eglCreateStreamProducerSurfaceKHR,      EGLDisplay, EGLConfig, EGLStreamKHR, const EGLint *)
-//    EGL_ENTRY(EGLBoolean,   eglQueryStreamTimeKHR,  EGLDisplay, EGLStreamKHR, EGLenum, EGLTimeKHR*)
-//    EGL_ENTRY(EGLNativeFileDescriptorKHR,   eglGetStreamFileDescriptorKHR,          EGLDisplay, EGLStreamKHR)
-//    EGL_ENTRY(EGLStreamKHR, eglCreateStreamFromFileDescriptorKHR,   EGLDisplay, EGLNativeFileDescriptorKHR)
+EGL_ENTRY(EGLStreamKHR, eglCreateStreamKHR,     EGLDisplay, const EGLint *)
+EGL_ENTRY(EGLBoolean,   eglDestroyStreamKHR,    EGLDisplay, EGLStreamKHR)
+EGL_ENTRY(EGLBoolean,   eglStreamAttribKHR,     EGLDisplay, EGLStreamKHR, EGLenum, EGLint)
+EGL_ENTRY(EGLBoolean,   eglQueryStreamKHR,      EGLDisplay, EGLStreamKHR, EGLenum, EGLint *)
+EGL_ENTRY(EGLBoolean,   eglQueryStreamu64KHR,   EGLDisplay, EGLStreamKHR, EGLenum, EGLuint64KHR *)
+EGL_ENTRY(EGLBoolean,   eglStreamConsumerGLTextureExternalKHR,  EGLDisplay, EGLStreamKHR)
+EGL_ENTRY(EGLBoolean,   eglStreamConsumerAcquireKHR,            EGLDisplay, EGLStreamKHR)
+EGL_ENTRY(EGLBoolean,   eglStreamConsumerReleaseKHR,            EGLDisplay, EGLStreamKHR)
+EGL_ENTRY(EGLSurface,   eglCreateStreamProducerSurfaceKHR,      EGLDisplay, EGLConfig, EGLStreamKHR, const EGLint *)
+EGL_ENTRY(EGLBoolean,   eglQueryStreamTimeKHR,  EGLDisplay, EGLStreamKHR, EGLenum, EGLTimeKHR*)
+EGL_ENTRY(EGLNativeFileDescriptorKHR,   eglGetStreamFileDescriptorKHR,          EGLDisplay, EGLStreamKHR)
+EGL_ENTRY(EGLStreamKHR, eglCreateStreamFromFileDescriptorKHR,   EGLDisplay, EGLNativeFileDescriptorKHR)
 EGL_ENTRY(EGLint,       eglWaitSyncKHR,         EGLDisplay, EGLSyncKHR, EGLint)
 
 /* ANDROID extensions */
@@ -89,4 +89,9 @@
 /* IMG extensions */
 
 EGL_ENTRY(EGLBoolean, eglHibernateProcessIMG, void)
-EGL_ENTRY(EGLBoolean, eglAwakenProcessIMG, void)
\ No newline at end of file
+EGL_ENTRY(EGLBoolean, eglAwakenProcessIMG, void)
+
+/* Partial update extensions */
+
+EGL_ENTRY(EGLBoolean, eglSwapBuffersWithDamageKHR, EGLDisplay, EGLSurface, EGLint *, EGLint)
+EGL_ENTRY(EGLBoolean, eglSetDamageRegionKHR, EGLDisplay, EGLSurface, EGLint *, EGLint)
diff --git a/opengl/libs/EGL/egl_object.cpp b/opengl/libs/EGL/egl_object.cpp
index d3ee76d..918faa8 100644
--- a/opengl/libs/EGL/egl_object.cpp
+++ b/opengl/libs/EGL/egl_object.cpp
@@ -14,6 +14,9 @@
  ** limitations under the License.
  */
 
+#include <string>
+#include <sstream>
+
 #include <ctype.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -113,6 +116,14 @@
             temp.append(gl_extensions);
             gl_extensions.setTo(temp);
         }
+
+        // tokenize the supported extensions for the glGetStringi() wrapper
+        std::stringstream ss;
+        std::string str;
+        ss << gl_extensions.string();
+        while (ss >> str) {
+            tokenized_gl_extensions.push(String8(str.c_str()));
+        }
     }
 }
 
diff --git a/opengl/libs/EGL/egl_object.h b/opengl/libs/EGL/egl_object.h
index 518fdec..17a8304 100644
--- a/opengl/libs/EGL/egl_object.h
+++ b/opengl/libs/EGL/egl_object.h
@@ -27,6 +27,7 @@
 
 #include <utils/threads.h>
 #include <utils/String8.h>
+#include <utils/Vector.h>
 
 #include <system/window.h>
 
@@ -36,7 +37,7 @@
 namespace android {
 // ----------------------------------------------------------------------------
 
-struct egl_display_t;
+class egl_display_t;
 
 class egl_object_t {
     egl_display_t *display;
@@ -159,6 +160,7 @@
     egl_connection_t const* cnx;
     int version;
     String8 gl_extensions;
+    Vector<String8> tokenized_gl_extensions;
 };
 
 // ----------------------------------------------------------------------------
diff --git a/opengl/libs/EGL/getProcAddress.cpp b/opengl/libs/EGL/getProcAddress.cpp
index add2a79..660af33 100644
--- a/opengl/libs/EGL/getProcAddress.cpp
+++ b/opengl/libs/EGL/getProcAddress.cpp
@@ -53,29 +53,94 @@
             : [tls] "J"(TLS_SLOT_OPENGL_API*4),                 \
               [api] "J"(__builtin_offsetof(gl_hooks_t,          \
                                       ext.extensions[_api]))    \
-            :                                                   \
+            : "r12"                                             \
             );
 
-#elif defined(__mips__)
+#elif defined(__aarch64__)
+
+    #define API_ENTRY(_api) __attribute__((noinline)) _api
+
+    #define CALL_GL_EXTENSION_API(_api)                             \
+        asm volatile(                                               \
+            "mrs x16, tpidr_el0\n"                                  \
+            "ldr x16, [x16, %[tls]]\n"                              \
+            "cbz x16, 1f\n"                                         \
+            "ldr x16, [x16, %[api]]\n"                              \
+            "cbz x16, 1f\n"                                         \
+            "br  x16\n"                                             \
+            "1:\n"                                                  \
+            :                                                       \
+            : [tls] "i" (TLS_SLOT_OPENGL_API * sizeof(void*)),      \
+              [api] "i" (__builtin_offsetof(gl_hooks_t,             \
+                                        ext.extensions[_api]))      \
+            : "x16"                                                 \
+        );
+
+#elif defined(__i386__)
+
+    #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api
+
+    #define CALL_GL_EXTENSION_API(_api)                         \
+         register void** fn;                                    \
+         __asm__ volatile(                                      \
+            "mov %%gs:0, %[fn]\n"                               \
+            "mov %P[tls](%[fn]), %[fn]\n"                       \
+            "test %[fn], %[fn]\n"                               \
+            "cmovne %P[api](%[fn]), %[fn]\n"                    \
+            "test %[fn], %[fn]\n"                               \
+            "je 1f\n"                                           \
+            "jmp *%[fn]\n"                                      \
+            "1:\n"                                              \
+            : [fn] "=r" (fn)                                    \
+            : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)),    \
+              [api] "i" (__builtin_offsetof(gl_hooks_t,         \
+                                      ext.extensions[_api]))    \
+            : "cc"                                              \
+            );
+
+#elif defined(__x86_64__)
+
+    #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api
+
+    #define CALL_GL_EXTENSION_API(_api)                         \
+         register void** fn;                                    \
+         __asm__ volatile(                                      \
+            "mov %%fs:0, %[fn]\n"                               \
+            "mov %P[tls](%[fn]), %[fn]\n"                       \
+            "test %[fn], %[fn]\n"                               \
+            "cmovne %P[api](%[fn]), %[fn]\n"                    \
+            "test %[fn], %[fn]\n"                               \
+            "je 1f\n"                                           \
+            "jmp *%[fn]\n"                                      \
+            "1:\n"                                              \
+            : [fn] "=r" (fn)                                    \
+            : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)),    \
+              [api] "i" (__builtin_offsetof(gl_hooks_t,         \
+                                      ext.extensions[_api]))    \
+            : "cc"                                              \
+            );
+
+#elif defined(__mips64)
 
         #define API_ENTRY(_api) __attribute__((noinline)) _api
 
         #define CALL_GL_EXTENSION_API(_api, ...)                    \
-            register unsigned int _t0 asm("t0");                    \
-            register unsigned int _fn asm("t1");                    \
-            register unsigned int _tls asm("v1");                   \
+            register unsigned int _t0 asm("$12");                   \
+            register unsigned int _fn asm("$25");                   \
+            register unsigned int _tls asm("$3");                   \
             asm volatile(                                           \
                 ".set  push\n\t"                                    \
                 ".set  noreorder\n\t"                               \
-                ".set  mips32r2\n\t"                                \
                 "rdhwr %[tls], $29\n\t"                             \
-                "lw    %[t0], %[OPENGL_API](%[tls])\n\t"            \
+                "ld    %[t0], %[OPENGL_API](%[tls])\n\t"            \
                 "beqz  %[t0], 1f\n\t"                               \
                 " move %[fn], $ra\n\t"                              \
-                "lw    %[fn], %[API](%[t0])\n\t"                    \
-                "movz  %[fn], $ra, %[fn]\n\t"                       \
+                "ld    %[t0], %[API](%[t0])\n\t"                    \
+                "beqz  %[t0], 1f\n\t"                               \
+                " nop\n\t"                                          \
+                "move  %[fn], %[t0]\n\t"                            \
                 "1:\n\t"                                            \
-                "j     %[fn]\n\t"                                   \
+                "jalr  $0, %[fn]\n\t"                               \
                 " nop\n\t"                                          \
                 ".set  pop\n\t"                                     \
                 : [fn] "=c"(_fn),                                   \
@@ -86,6 +151,40 @@
                                           ext.extensions[_api]))    \
                 :                                                   \
             );
+
+#elif defined(__mips__)
+
+        #define API_ENTRY(_api) __attribute__((noinline)) _api
+
+        #define CALL_GL_EXTENSION_API(_api, ...)                    \
+            register unsigned int _t0 asm("$8");                    \
+            register unsigned int _fn asm("$25");                    \
+            register unsigned int _tls asm("$3");                   \
+            asm volatile(                                           \
+                ".set  push\n\t"                                    \
+                ".set  noreorder\n\t"                               \
+                ".set  mips32r2\n\t"                                \
+                "rdhwr %[tls], $29\n\t"                             \
+                "lw    %[t0], %[OPENGL_API](%[tls])\n\t"            \
+                "beqz  %[t0], 1f\n\t"                               \
+                " move %[fn], $ra\n\t"                              \
+                "lw    %[t0], %[API](%[t0])\n\t"                    \
+                "beqz  %[t0], 1f\n\t"                               \
+                " nop\n\t"                                          \
+                "move  %[fn], %[t0]\n\t"                            \
+                "1:\n\t"                                            \
+                "jalr  $0, %[fn]\n\t"                               \
+                " nop\n\t"                                          \
+                ".set  pop\n\t"                                     \
+                : [fn] "=c"(_fn),                                   \
+                  [tls] "=&r"(_tls),                                \
+                  [t0] "=&r"(_t0)                                   \
+                : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4),          \
+                  [API] "I"(__builtin_offsetof(gl_hooks_t,          \
+                                          ext.extensions[_api]))    \
+                :                                                   \
+            );
+
 #endif
 
 #if defined(CALL_GL_EXTENSION_API)
diff --git a/opengl/libs/EGL/trace.cpp b/opengl/libs/EGL/trace.cpp
index 3e228e4..248a1a0 100644
--- a/opengl/libs/EGL/trace.cpp
+++ b/opengl/libs/EGL/trace.cpp
@@ -360,25 +360,6 @@
 #undef TRACE_GL_VOID
 #undef TRACE_GL
 
-// define the ES 1.0 Debug_gl* functions as Tracing_gl functions
-#define TRACE_GL_VOID(_api, _args, _argList, ...)                         \
-static void Debug_ ## _api _args {                                      \
-    TraceGL(#_api, __VA_ARGS__);                                          \
-    gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl;  \
-    _c->_api _argList;                                                    \
-}
-
-#define TRACE_GL(_type, _api, _args, _argList, ...)                       \
-static _type Debug_ ## _api _args {                                     \
-    TraceGL(#_api, __VA_ARGS__);                                        \
-    gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl;  \
-    return _c->_api _argList;                                             \
-}
-
-extern "C" {
-#include "../debug.in"
-}
-
 ///////////////////////////////////////////////////////////////////////////
 // Systrace
 ///////////////////////////////////////////////////////////////////////////
@@ -428,7 +409,7 @@
 #define CHECK_ERROR(_c, _api)                                             \
     GLenum status = GL_NO_ERROR;                                          \
     bool error = false;                                                   \
-    while ((status = _c->glGetError()) != GL_NO_ERROR) {                  \
+    while ((status = (_c)->glGetError()) != GL_NO_ERROR) {                \
         ALOGD("[" #_api "] 0x%x", status);                                \
         error = true;                                                     \
     }                                                                     \
diff --git a/opengl/libs/GLES2/gl2.cpp b/opengl/libs/GLES2/gl2.cpp
index 3134e56..6dd87c2 100644
--- a/opengl/libs/GLES2/gl2.cpp
+++ b/opengl/libs/GLES2/gl2.cpp
@@ -20,10 +20,6 @@
 
 #include <sys/ioctl.h>
 
-#include <GLES3/gl3.h>
-#include <GLES3/gl3ext.h>
-#include <GLES2/gl2ext.h>
-
 #include <cutils/log.h>
 #include <cutils/properties.h>
 
@@ -38,96 +34,339 @@
 
 #undef API_ENTRY
 #undef CALL_GL_API
+#undef CALL_GL_API_INTERNAL_CALL
+#undef CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+#undef CALL_GL_API_INTERNAL_DO_RETURN
 #undef CALL_GL_API_RETURN
 
-#if defined(__arm__) && !USE_SLOW_BINDING
-
-    #define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n"
-
-    #define API_ENTRY(_api) __attribute__((noinline)) _api
-
-    #define CALL_GL_API(_api, ...)                              \
-         asm volatile(                                          \
-            GET_TLS(r12)                                        \
-            "ldr   r12, [r12, %[tls]] \n"                       \
-            "cmp   r12, #0            \n"                       \
-            "ldrne pc,  [r12, %[api]] \n"                       \
-            :                                                   \
-            : [tls] "J"(TLS_SLOT_OPENGL_API*4),                 \
-              [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api))    \
-            :                                                   \
-            );
-
-#elif defined(__mips__) && !USE_SLOW_BINDING
-
-    #define API_ENTRY(_api) __attribute__((noinline)) _api
-
-    #define CALL_GL_API(_api, ...)                               \
-        register unsigned int _t0 asm("t0");                     \
-        register unsigned int _fn asm("t1");                     \
-        register unsigned int _tls asm("v1");                    \
-        register unsigned int _v0 asm("v0");                     \
-        asm volatile(                                            \
-            ".set  push\n\t"                                     \
-            ".set  noreorder\n\t"                                \
-            ".set mips32r2\n\t"                                  \
-            "rdhwr %[tls], $29\n\t"                              \
-            "lw    %[t0], %[OPENGL_API](%[tls])\n\t"             \
-            "beqz  %[t0], 1f\n\t"                                \
-            " move %[fn],$ra\n\t"                                \
-            "lw    %[fn], %[API](%[t0])\n\t"                     \
-            "movz  %[fn], $ra, %[fn]\n\t"                        \
-            "1:\n\t"                                             \
-            "j     %[fn]\n\t"                                    \
-            " move %[v0], $0\n\t"                                \
-            ".set  pop\n\t"                                      \
-            : [fn] "=c"(_fn),                                    \
-              [tls] "=&r"(_tls),                                 \
-              [t0] "=&r"(_t0),                                   \
-              [v0] "=&r"(_v0)                                    \
-            : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4),           \
-              [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \
-            :                                                    \
-            );
-
-#else
+#if USE_SLOW_BINDING
 
     #define API_ENTRY(_api) _api
 
-    #define CALL_GL_API(_api, ...)                                       \
+    #define CALL_GL_API_INTERNAL_CALL(_api, ...)                         \
         gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;  \
         if (_c) return _c->_api(__VA_ARGS__);
 
+    #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE return 0;
+
+    // This stays blank, since void functions will implicitly return, and
+    // all of the other functions will return 0 based on the previous macro.
+    #define CALL_GL_API_INTERNAL_DO_RETURN
+
+#elif defined(__arm__)
+
+    #define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n"
+
+    #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
+
+    #define CALL_GL_API_INTERNAL_CALL(_api, ...)                 \
+        asm volatile(                                            \
+            GET_TLS(r12)                                         \
+            "ldr   r12, [r12, %[tls]] \n"                        \
+            "cmp   r12, #0            \n"                        \
+            "ldrne pc,  [r12, %[api]] \n"                        \
+            :                                                    \
+            : [tls] "J"(TLS_SLOT_OPENGL_API*4),                  \
+              [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api)) \
+            : "r0", "r1", "r2", "r3", "r12"                      \
+        );
+
+    #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+        asm volatile(                             \
+            "mov r0, #0 \n"                       \
+            :                                     \
+            :                                     \
+            : "r0"                                \
+        );
+
+
+    #define CALL_GL_API_INTERNAL_DO_RETURN \
+        asm volatile(                      \
+            "bx lr \n"                     \
+            :                              \
+            :                              \
+            : "r0"                         \
+        );
+
+#elif defined(__aarch64__)
+
+    #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
+
+    #define CALL_GL_API_INTERNAL_CALL(_api, ...)                    \
+        asm volatile(                                               \
+            "mrs x16, tpidr_el0\n"                                  \
+            "ldr x16, [x16, %[tls]]\n"                              \
+            "cbz x16, 1f\n"                                         \
+            "ldr x16, [x16, %[api]]\n"                              \
+            "br  x16\n"                                             \
+            "1:\n"                                                  \
+            :                                                       \
+            : [tls] "i" (TLS_SLOT_OPENGL_API * sizeof(void*)),      \
+              [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api))   \
+            : "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x16" \
+        );
+
+    #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+        asm volatile(                             \
+            "mov w0, wzr \n"                      \
+            :                                     \
+            :                                     \
+            : "w0"                                \
+        );
+
+    #define CALL_GL_API_INTERNAL_DO_RETURN \
+        asm volatile(                      \
+            "ret \n"                       \
+            :                              \
+            :                              \
+            :                              \
+        );
+
+#elif defined(__i386__)
+
+    #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
+
+    #define CALL_GL_API_INTERNAL_CALL(_api, ...)                    \
+        __asm__ volatile(                                           \
+            "mov %%gs:0, %%eax\n"                                   \
+            "mov %P[tls](%%eax), %%eax\n"                           \
+            "test %%eax, %%eax\n"                                   \
+            "je 1f\n"                                               \
+            "jmp *%P[api](%%eax)\n"                                 \
+            "1:\n"                                                  \
+            :                                                       \
+            : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)),        \
+              [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api))   \
+            : "cc", "%eax"                                          \
+            );
+
+    #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+        __asm__ volatile(                         \
+            "xor %%eax, %%eax\n"                  \
+            :                                     \
+            :                                     \
+            : "%eax"                              \
+        );
+
+    #define CALL_GL_API_INTERNAL_DO_RETURN \
+        __asm__ volatile(                  \
+            "ret\n"                        \
+            :                              \
+            :                              \
+            :                              \
+        );
+
+#elif defined(__x86_64__)
+
+    #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
+
+    #define CALL_GL_API_INTERNAL_CALL(_api, ...)                    \
+        __asm__ volatile(                                           \
+            "mov %%fs:0, %%rax\n"                                   \
+            "mov %P[tls](%%rax), %%rax\n"                           \
+            "test %%rax, %%rax\n"                                   \
+            "je 1f\n"                                               \
+            "jmp *%P[api](%%rax)\n"                                 \
+            "1:\n"                                                  \
+            :                                                       \
+            : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)),        \
+              [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api))   \
+            : "cc", "%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9",   \
+              "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", \
+              "%xmm6", "%xmm7"                                      \
+        );
+
+    #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+        __asm__ volatile(                         \
+            "xor %%eax, %%eax\n"                  \
+            :                                     \
+            :                                     \
+            : "%eax"                              \
+        );
+
+    #define CALL_GL_API_INTERNAL_DO_RETURN \
+        __asm__ volatile(                  \
+            "retq\n"                       \
+            :                              \
+            :                              \
+            :                              \
+        );
+
+#elif defined(__mips64)
+
+    #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
+
+    // t0:  $12
+    // fn:  $25
+    // tls: $3
+    // v0:  $2
+    #define CALL_GL_API_INTERNAL_CALL(_api, ...)                  \
+        asm volatile(                                             \
+            ".set  push\n\t"                                      \
+            ".set  noreorder\n\t"                                 \
+            "rdhwr $3, $29\n\t"                                   \
+            "ld    $12, %[OPENGL_API]($3)\n\t"                    \
+            "beqz  $12, 1f\n\t"                                   \
+            " move $25, $ra\n\t"                                  \
+            "ld    $12, %[API]($12)\n\t"                          \
+            "beqz  $12, 1f\n\t"                                   \
+            " nop\n\t"                                            \
+            "move  $25, $12\n\t"                                  \
+            "1:\n\t"                                              \
+            "jalr  $0, $25\n\t"                                   \
+            " move $2, $0\n\t"                                    \
+            ".set  pop\n\t"                                       \
+            :                                                     \
+            : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*sizeof(void*)),\
+              [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api))  \
+            : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",     \
+              "$10", "$11", "$12", "$25"                          \
+        );
+
+    #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+    #define CALL_GL_API_INTERNAL_DO_RETURN
+
+#elif defined(__mips__)
+
+    #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
+
+    // t0:  $8
+    // fn:  $25
+    // tls: $3
+    // v0:  $2
+    #define CALL_GL_API_INTERNAL_CALL(_api, ...)                 \
+        asm volatile(                                            \
+            ".set  push\n\t"                                     \
+            ".set  noreorder\n\t"                                \
+            ".set  mips32r2\n\t"                                 \
+            "rdhwr $3, $29\n\t"                                  \
+            "lw    $3, %[OPENGL_API]($3)\n\t"                    \
+            "beqz  $3, 1f\n\t"                                   \
+            " move $25,$ra\n\t"                                  \
+            "lw    $3, %[API]($3)\n\t"                           \
+            "beqz  $3, 1f\n\t"                                   \
+            " nop\n\t"                                           \
+            "move  $25, $3\n\t"                                  \
+            "1:\n\t"                                             \
+            "jalr  $0, $25\n\t"                                  \
+            " move $2, $0\n\t"                                   \
+            ".set  pop\n\t"                                      \
+            :                                                    \
+            : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4),           \
+              [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \
+            : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$25"    \
+        );
+
+    #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+    #define CALL_GL_API_INTERNAL_DO_RETURN
+
 #endif
 
+#define CALL_GL_API(_api, ...) \
+    CALL_GL_API_INTERNAL_CALL(_api, __VA_ARGS__) \
+    CALL_GL_API_INTERNAL_DO_RETURN
+
 #define CALL_GL_API_RETURN(_api, ...) \
-    CALL_GL_API(_api, __VA_ARGS__) \
-    return 0;
-
-
+    CALL_GL_API_INTERNAL_CALL(_api, __VA_ARGS__) \
+    CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+    CALL_GL_API_INTERNAL_DO_RETURN
 
 extern "C" {
-#include "gl3_api.in"
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#include "gl2_api.in"
 #include "gl2ext_api.in"
-#include "gl3ext_api.in"
+#pragma GCC diagnostic warning "-Wunused-parameter"
 }
 
 #undef API_ENTRY
 #undef CALL_GL_API
+#undef CALL_GL_API_INTERNAL_CALL
+#undef CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+#undef CALL_GL_API_INTERNAL_DO_RETURN
 #undef CALL_GL_API_RETURN
 
 /*
- * glGetString() is special because we expose some extensions in the wrapper
+ * glGetString() and glGetStringi() are special because we expose some
+ * extensions in the wrapper. Also, wrapping glGetXXX() is required because
+ * the value returned for GL_NUM_EXTENSIONS may have been altered by the
+ * injection of the additional extensions.
  */
 
-extern "C" const GLubyte * __glGetString(GLenum name);
+extern "C" {
+    const GLubyte * __glGetString(GLenum name);
+    const GLubyte * __glGetStringi(GLenum name, GLuint index);
+    void __glGetBooleanv(GLenum pname, GLboolean * data);
+    void __glGetFloatv(GLenum pname, GLfloat * data);
+    void __glGetIntegerv(GLenum pname, GLint * data);
+    void __glGetInteger64v(GLenum pname, GLint64 * data);
+}
 
-const GLubyte * glGetString(GLenum name)
-{
+const GLubyte * glGetString(GLenum name) {
     const GLubyte * ret = egl_get_string_for_current_context(name);
     if (ret == NULL) {
         gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;
-        ret = _c->glGetString(name);
+        if(_c) ret = _c->glGetString(name);
     }
     return ret;
 }
+
+const GLubyte * glGetStringi(GLenum name, GLuint index) {
+    const GLubyte * ret = egl_get_string_for_current_context(name, index);
+    if (ret == NULL) {
+        gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;
+        if(_c) ret = _c->glGetStringi(name, index);
+    }
+    return ret;
+}
+
+void glGetBooleanv(GLenum pname, GLboolean * data) {
+    if (pname == GL_NUM_EXTENSIONS) {
+        int num_exts = egl_get_num_extensions_for_current_context();
+        if (num_exts >= 0) {
+            *data = num_exts > 0 ? GL_TRUE : GL_FALSE;
+            return;
+        }
+    }
+
+    gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;
+    if (_c) _c->glGetBooleanv(pname, data);
+}
+
+void glGetFloatv(GLenum pname, GLfloat * data) {
+    if (pname == GL_NUM_EXTENSIONS) {
+        int num_exts = egl_get_num_extensions_for_current_context();
+        if (num_exts >= 0) {
+            *data = (GLfloat)num_exts;
+            return;
+        }
+    }
+
+    gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;
+    if (_c) _c->glGetFloatv(pname, data);
+}
+
+void glGetIntegerv(GLenum pname, GLint * data) {
+    if (pname == GL_NUM_EXTENSIONS) {
+        int num_exts = egl_get_num_extensions_for_current_context();
+        if (num_exts >= 0) {
+            *data = (GLint)num_exts;
+            return;
+        }
+    }
+
+    gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;
+    if (_c) _c->glGetIntegerv(pname, data);
+}
+
+void glGetInteger64v(GLenum pname, GLint64 * data) {
+    if (pname == GL_NUM_EXTENSIONS) {
+        int num_exts = egl_get_num_extensions_for_current_context();
+        if (num_exts >= 0) {
+            *data = (GLint64)num_exts;
+            return;
+        }
+    }
+
+    gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;
+    if (_c) _c->glGetInteger64v(pname, data);
+}
diff --git a/opengl/libs/GLES2/gl2_api.in b/opengl/libs/GLES2/gl2_api.in
index 89c8b8d..09d8b00 100644
--- a/opengl/libs/GLES2/gl2_api.in
+++ b/opengl/libs/GLES2/gl2_api.in
@@ -4,7 +4,7 @@
 void API_ENTRY(glAttachShader)(GLuint program, GLuint shader) {
     CALL_GL_API(glAttachShader, program, shader);
 }
-void API_ENTRY(glBindAttribLocation)(GLuint program, GLuint index, const GLchar* name) {
+void API_ENTRY(glBindAttribLocation)(GLuint program, GLuint index, const GLchar * name) {
     CALL_GL_API(glBindAttribLocation, program, index, name);
 }
 void API_ENTRY(glBindBuffer)(GLenum target, GLuint buffer) {
@@ -19,10 +19,10 @@
 void API_ENTRY(glBindTexture)(GLenum target, GLuint texture) {
     CALL_GL_API(glBindTexture, target, texture);
 }
-void API_ENTRY(glBlendColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
+void API_ENTRY(glBlendColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
     CALL_GL_API(glBlendColor, red, green, blue, alpha);
 }
-void API_ENTRY(glBlendEquation)( GLenum mode ) {
+void API_ENTRY(glBlendEquation)(GLenum mode) {
     CALL_GL_API(glBlendEquation, mode);
 }
 void API_ENTRY(glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha) {
@@ -31,13 +31,13 @@
 void API_ENTRY(glBlendFunc)(GLenum sfactor, GLenum dfactor) {
     CALL_GL_API(glBlendFunc, sfactor, dfactor);
 }
-void API_ENTRY(glBlendFuncSeparate)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) {
-    CALL_GL_API(glBlendFuncSeparate, srcRGB, dstRGB, srcAlpha, dstAlpha);
+void API_ENTRY(glBlendFuncSeparate)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) {
+    CALL_GL_API(glBlendFuncSeparate, sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
 }
-void API_ENTRY(glBufferData)(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) {
+void API_ENTRY(glBufferData)(GLenum target, GLsizeiptr size, const void * data, GLenum usage) {
     CALL_GL_API(glBufferData, target, size, data, usage);
 }
-void API_ENTRY(glBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) {
+void API_ENTRY(glBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data) {
     CALL_GL_API(glBufferSubData, target, offset, size, data);
 }
 GLenum API_ENTRY(glCheckFramebufferStatus)(GLenum target) {
@@ -46,11 +46,11 @@
 void API_ENTRY(glClear)(GLbitfield mask) {
     CALL_GL_API(glClear, mask);
 }
-void API_ENTRY(glClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
+void API_ENTRY(glClearColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
     CALL_GL_API(glClearColor, red, green, blue, alpha);
 }
-void API_ENTRY(glClearDepthf)(GLclampf depth) {
-    CALL_GL_API(glClearDepthf, depth);
+void API_ENTRY(glClearDepthf)(GLfloat d) {
+    CALL_GL_API(glClearDepthf, d);
 }
 void API_ENTRY(glClearStencil)(GLint s) {
     CALL_GL_API(glClearStencil, s);
@@ -61,10 +61,10 @@
 void API_ENTRY(glCompileShader)(GLuint shader) {
     CALL_GL_API(glCompileShader, shader);
 }
-void API_ENTRY(glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data) {
+void API_ENTRY(glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data) {
     CALL_GL_API(glCompressedTexImage2D, target, level, internalformat, width, height, border, imageSize, data);
 }
-void API_ENTRY(glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data) {
+void API_ENTRY(glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data) {
     CALL_GL_API(glCompressedTexSubImage2D, target, level, xoffset, yoffset, width, height, format, imageSize, data);
 }
 void API_ENTRY(glCopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
@@ -82,22 +82,22 @@
 void API_ENTRY(glCullFace)(GLenum mode) {
     CALL_GL_API(glCullFace, mode);
 }
-void API_ENTRY(glDeleteBuffers)(GLsizei n, const GLuint* buffers) {
+void API_ENTRY(glDeleteBuffers)(GLsizei n, const GLuint * buffers) {
     CALL_GL_API(glDeleteBuffers, n, buffers);
 }
-void API_ENTRY(glDeleteFramebuffers)(GLsizei n, const GLuint* framebuffers) {
+void API_ENTRY(glDeleteFramebuffers)(GLsizei n, const GLuint * framebuffers) {
     CALL_GL_API(glDeleteFramebuffers, n, framebuffers);
 }
 void API_ENTRY(glDeleteProgram)(GLuint program) {
     CALL_GL_API(glDeleteProgram, program);
 }
-void API_ENTRY(glDeleteRenderbuffers)(GLsizei n, const GLuint* renderbuffers) {
+void API_ENTRY(glDeleteRenderbuffers)(GLsizei n, const GLuint * renderbuffers) {
     CALL_GL_API(glDeleteRenderbuffers, n, renderbuffers);
 }
 void API_ENTRY(glDeleteShader)(GLuint shader) {
     CALL_GL_API(glDeleteShader, shader);
 }
-void API_ENTRY(glDeleteTextures)(GLsizei n, const GLuint* textures) {
+void API_ENTRY(glDeleteTextures)(GLsizei n, const GLuint * textures) {
     CALL_GL_API(glDeleteTextures, n, textures);
 }
 void API_ENTRY(glDepthFunc)(GLenum func) {
@@ -106,8 +106,8 @@
 void API_ENTRY(glDepthMask)(GLboolean flag) {
     CALL_GL_API(glDepthMask, flag);
 }
-void API_ENTRY(glDepthRangef)(GLclampf zNear, GLclampf zFar) {
-    CALL_GL_API(glDepthRangef, zNear, zFar);
+void API_ENTRY(glDepthRangef)(GLfloat n, GLfloat f) {
+    CALL_GL_API(glDepthRangef, n, f);
 }
 void API_ENTRY(glDetachShader)(GLuint program, GLuint shader) {
     CALL_GL_API(glDetachShader, program, shader);
@@ -121,7 +121,7 @@
 void API_ENTRY(glDrawArrays)(GLenum mode, GLint first, GLsizei count) {
     CALL_GL_API(glDrawArrays, mode, first, count);
 }
-void API_ENTRY(glDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) {
+void API_ENTRY(glDrawElements)(GLenum mode, GLsizei count, GLenum type, const void * indices) {
     CALL_GL_API(glDrawElements, mode, count, type, indices);
 }
 void API_ENTRY(glEnable)(GLenum cap) {
@@ -145,97 +145,97 @@
 void API_ENTRY(glFrontFace)(GLenum mode) {
     CALL_GL_API(glFrontFace, mode);
 }
-void API_ENTRY(glGenBuffers)(GLsizei n, GLuint* buffers) {
+void API_ENTRY(glGenBuffers)(GLsizei n, GLuint * buffers) {
     CALL_GL_API(glGenBuffers, n, buffers);
 }
 void API_ENTRY(glGenerateMipmap)(GLenum target) {
     CALL_GL_API(glGenerateMipmap, target);
 }
-void API_ENTRY(glGenFramebuffers)(GLsizei n, GLuint* framebuffers) {
+void API_ENTRY(glGenFramebuffers)(GLsizei n, GLuint * framebuffers) {
     CALL_GL_API(glGenFramebuffers, n, framebuffers);
 }
-void API_ENTRY(glGenRenderbuffers)(GLsizei n, GLuint* renderbuffers) {
+void API_ENTRY(glGenRenderbuffers)(GLsizei n, GLuint * renderbuffers) {
     CALL_GL_API(glGenRenderbuffers, n, renderbuffers);
 }
-void API_ENTRY(glGenTextures)(GLsizei n, GLuint* textures) {
+void API_ENTRY(glGenTextures)(GLsizei n, GLuint * textures) {
     CALL_GL_API(glGenTextures, n, textures);
 }
-void API_ENTRY(glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) {
-    CALL_GL_API(glGetActiveAttrib, program, index, bufsize, length, size, type, name);
+void API_ENTRY(glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name) {
+    CALL_GL_API(glGetActiveAttrib, program, index, bufSize, length, size, type, name);
 }
-void API_ENTRY(glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) {
-    CALL_GL_API(glGetActiveUniform, program, index, bufsize, length, size, type, name);
+void API_ENTRY(glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name) {
+    CALL_GL_API(glGetActiveUniform, program, index, bufSize, length, size, type, name);
 }
-void API_ENTRY(glGetAttachedShaders)(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) {
-    CALL_GL_API(glGetAttachedShaders, program, maxcount, count, shaders);
+void API_ENTRY(glGetAttachedShaders)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders) {
+    CALL_GL_API(glGetAttachedShaders, program, maxCount, count, shaders);
 }
-GLint API_ENTRY(glGetAttribLocation)(GLuint program, const GLchar* name) {
+GLint API_ENTRY(glGetAttribLocation)(GLuint program, const GLchar * name) {
     CALL_GL_API_RETURN(glGetAttribLocation, program, name);
 }
-void API_ENTRY(glGetBooleanv)(GLenum pname, GLboolean* params) {
-    CALL_GL_API(glGetBooleanv, pname, params);
+void API_ENTRY(__glGetBooleanv)(GLenum pname, GLboolean * data) {
+    CALL_GL_API(glGetBooleanv, pname, data);
 }
-void API_ENTRY(glGetBufferParameteriv)(GLenum target, GLenum pname, GLint* params) {
+void API_ENTRY(glGetBufferParameteriv)(GLenum target, GLenum pname, GLint * params) {
     CALL_GL_API(glGetBufferParameteriv, target, pname, params);
 }
 GLenum API_ENTRY(glGetError)(void) {
     CALL_GL_API_RETURN(glGetError);
 }
-void API_ENTRY(glGetFloatv)(GLenum pname, GLfloat* params) {
-    CALL_GL_API(glGetFloatv, pname, params);
+void API_ENTRY(__glGetFloatv)(GLenum pname, GLfloat * data) {
+    CALL_GL_API(glGetFloatv, pname, data);
 }
-void API_ENTRY(glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint* params) {
+void API_ENTRY(glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint * params) {
     CALL_GL_API(glGetFramebufferAttachmentParameteriv, target, attachment, pname, params);
 }
-void API_ENTRY(glGetIntegerv)(GLenum pname, GLint* params) {
-    CALL_GL_API(glGetIntegerv, pname, params);
+void API_ENTRY(__glGetIntegerv)(GLenum pname, GLint * data) {
+    CALL_GL_API(glGetIntegerv, pname, data);
 }
-void API_ENTRY(glGetProgramiv)(GLuint program, GLenum pname, GLint* params) {
+void API_ENTRY(glGetProgramiv)(GLuint program, GLenum pname, GLint * params) {
     CALL_GL_API(glGetProgramiv, program, pname, params);
 }
-void API_ENTRY(glGetProgramInfoLog)(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) {
-    CALL_GL_API(glGetProgramInfoLog, program, bufsize, length, infolog);
+void API_ENTRY(glGetProgramInfoLog)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog) {
+    CALL_GL_API(glGetProgramInfoLog, program, bufSize, length, infoLog);
 }
-void API_ENTRY(glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint* params) {
+void API_ENTRY(glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint * params) {
     CALL_GL_API(glGetRenderbufferParameteriv, target, pname, params);
 }
-void API_ENTRY(glGetShaderiv)(GLuint shader, GLenum pname, GLint* params) {
+void API_ENTRY(glGetShaderiv)(GLuint shader, GLenum pname, GLint * params) {
     CALL_GL_API(glGetShaderiv, shader, pname, params);
 }
-void API_ENTRY(glGetShaderInfoLog)(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) {
-    CALL_GL_API(glGetShaderInfoLog, shader, bufsize, length, infolog);
+void API_ENTRY(glGetShaderInfoLog)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog) {
+    CALL_GL_API(glGetShaderInfoLog, shader, bufSize, length, infoLog);
 }
-void API_ENTRY(glGetShaderPrecisionFormat)(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
+void API_ENTRY(glGetShaderPrecisionFormat)(GLenum shadertype, GLenum precisiontype, GLint * range, GLint * precision) {
     CALL_GL_API(glGetShaderPrecisionFormat, shadertype, precisiontype, range, precision);
 }
-void API_ENTRY(glGetShaderSource)(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) {
-    CALL_GL_API(glGetShaderSource, shader, bufsize, length, source);
+void API_ENTRY(glGetShaderSource)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source) {
+    CALL_GL_API(glGetShaderSource, shader, bufSize, length, source);
 }
-const GLubyte* API_ENTRY(__glGetString)(GLenum name) {
+const GLubyte * API_ENTRY(__glGetString)(GLenum name) {
     CALL_GL_API_RETURN(glGetString, name);
 }
-void API_ENTRY(glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat* params) {
+void API_ENTRY(glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat * params) {
     CALL_GL_API(glGetTexParameterfv, target, pname, params);
 }
-void API_ENTRY(glGetTexParameteriv)(GLenum target, GLenum pname, GLint* params) {
+void API_ENTRY(glGetTexParameteriv)(GLenum target, GLenum pname, GLint * params) {
     CALL_GL_API(glGetTexParameteriv, target, pname, params);
 }
-void API_ENTRY(glGetUniformfv)(GLuint program, GLint location, GLfloat* params) {
+void API_ENTRY(glGetUniformfv)(GLuint program, GLint location, GLfloat * params) {
     CALL_GL_API(glGetUniformfv, program, location, params);
 }
-void API_ENTRY(glGetUniformiv)(GLuint program, GLint location, GLint* params) {
+void API_ENTRY(glGetUniformiv)(GLuint program, GLint location, GLint * params) {
     CALL_GL_API(glGetUniformiv, program, location, params);
 }
-GLint API_ENTRY(glGetUniformLocation)(GLuint program, const GLchar* name) {
+GLint API_ENTRY(glGetUniformLocation)(GLuint program, const GLchar * name) {
     CALL_GL_API_RETURN(glGetUniformLocation, program, name);
 }
-void API_ENTRY(glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat* params) {
+void API_ENTRY(glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat * params) {
     CALL_GL_API(glGetVertexAttribfv, index, pname, params);
 }
-void API_ENTRY(glGetVertexAttribiv)(GLuint index, GLenum pname, GLint* params) {
+void API_ENTRY(glGetVertexAttribiv)(GLuint index, GLenum pname, GLint * params) {
     CALL_GL_API(glGetVertexAttribiv, index, pname, params);
 }
-void API_ENTRY(glGetVertexAttribPointerv)(GLuint index, GLenum pname, GLvoid** pointer) {
+void API_ENTRY(glGetVertexAttribPointerv)(GLuint index, GLenum pname, void ** pointer) {
     CALL_GL_API(glGetVertexAttribPointerv, index, pname, pointer);
 }
 void API_ENTRY(glHint)(GLenum target, GLenum mode) {
@@ -274,7 +274,7 @@
 void API_ENTRY(glPolygonOffset)(GLfloat factor, GLfloat units) {
     CALL_GL_API(glPolygonOffset, factor, units);
 }
-void API_ENTRY(glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) {
+void API_ENTRY(glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels) {
     CALL_GL_API(glReadPixels, x, y, width, height, format, type, pixels);
 }
 void API_ENTRY(glReleaseShaderCompiler)(void) {
@@ -283,16 +283,16 @@
 void API_ENTRY(glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) {
     CALL_GL_API(glRenderbufferStorage, target, internalformat, width, height);
 }
-void API_ENTRY(glSampleCoverage)(GLclampf value, GLboolean invert) {
+void API_ENTRY(glSampleCoverage)(GLfloat value, GLboolean invert) {
     CALL_GL_API(glSampleCoverage, value, invert);
 }
 void API_ENTRY(glScissor)(GLint x, GLint y, GLsizei width, GLsizei height) {
     CALL_GL_API(glScissor, x, y, width, height);
 }
-void API_ENTRY(glShaderBinary)(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length) {
-    CALL_GL_API(glShaderBinary, n, shaders, binaryformat, binary, length);
+void API_ENTRY(glShaderBinary)(GLsizei count, const GLuint * shaders, GLenum binaryformat, const void * binary, GLsizei length) {
+    CALL_GL_API(glShaderBinary, count, shaders, binaryformat, binary, length);
 }
-void API_ENTRY(glShaderSource)(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) {
+void API_ENTRY(glShaderSource)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length) {
     CALL_GL_API(glShaderSource, shader, count, string, length);
 }
 void API_ENTRY(glStencilFunc)(GLenum func, GLint ref, GLuint mask) {
@@ -310,82 +310,82 @@
 void API_ENTRY(glStencilOp)(GLenum fail, GLenum zfail, GLenum zpass) {
     CALL_GL_API(glStencilOp, fail, zfail, zpass);
 }
-void API_ENTRY(glStencilOpSeparate)(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) {
-    CALL_GL_API(glStencilOpSeparate, face, fail, zfail, zpass);
+void API_ENTRY(glStencilOpSeparate)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) {
+    CALL_GL_API(glStencilOpSeparate, face, sfail, dpfail, dppass);
 }
-void API_ENTRY(glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels) {
+void API_ENTRY(glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels) {
     CALL_GL_API(glTexImage2D, target, level, internalformat, width, height, border, format, type, pixels);
 }
 void API_ENTRY(glTexParameterf)(GLenum target, GLenum pname, GLfloat param) {
     CALL_GL_API(glTexParameterf, target, pname, param);
 }
-void API_ENTRY(glTexParameterfv)(GLenum target, GLenum pname, const GLfloat* params) {
+void API_ENTRY(glTexParameterfv)(GLenum target, GLenum pname, const GLfloat * params) {
     CALL_GL_API(glTexParameterfv, target, pname, params);
 }
 void API_ENTRY(glTexParameteri)(GLenum target, GLenum pname, GLint param) {
     CALL_GL_API(glTexParameteri, target, pname, param);
 }
-void API_ENTRY(glTexParameteriv)(GLenum target, GLenum pname, const GLint* params) {
+void API_ENTRY(glTexParameteriv)(GLenum target, GLenum pname, const GLint * params) {
     CALL_GL_API(glTexParameteriv, target, pname, params);
 }
-void API_ENTRY(glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) {
+void API_ENTRY(glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels) {
     CALL_GL_API(glTexSubImage2D, target, level, xoffset, yoffset, width, height, format, type, pixels);
 }
-void API_ENTRY(glUniform1f)(GLint location, GLfloat x) {
-    CALL_GL_API(glUniform1f, location, x);
+void API_ENTRY(glUniform1f)(GLint location, GLfloat v0) {
+    CALL_GL_API(glUniform1f, location, v0);
 }
-void API_ENTRY(glUniform1fv)(GLint location, GLsizei count, const GLfloat* v) {
-    CALL_GL_API(glUniform1fv, location, count, v);
+void API_ENTRY(glUniform1fv)(GLint location, GLsizei count, const GLfloat * value) {
+    CALL_GL_API(glUniform1fv, location, count, value);
 }
-void API_ENTRY(glUniform1i)(GLint location, GLint x) {
-    CALL_GL_API(glUniform1i, location, x);
+void API_ENTRY(glUniform1i)(GLint location, GLint v0) {
+    CALL_GL_API(glUniform1i, location, v0);
 }
-void API_ENTRY(glUniform1iv)(GLint location, GLsizei count, const GLint* v) {
-    CALL_GL_API(glUniform1iv, location, count, v);
+void API_ENTRY(glUniform1iv)(GLint location, GLsizei count, const GLint * value) {
+    CALL_GL_API(glUniform1iv, location, count, value);
 }
-void API_ENTRY(glUniform2f)(GLint location, GLfloat x, GLfloat y) {
-    CALL_GL_API(glUniform2f, location, x, y);
+void API_ENTRY(glUniform2f)(GLint location, GLfloat v0, GLfloat v1) {
+    CALL_GL_API(glUniform2f, location, v0, v1);
 }
-void API_ENTRY(glUniform2fv)(GLint location, GLsizei count, const GLfloat* v) {
-    CALL_GL_API(glUniform2fv, location, count, v);
+void API_ENTRY(glUniform2fv)(GLint location, GLsizei count, const GLfloat * value) {
+    CALL_GL_API(glUniform2fv, location, count, value);
 }
-void API_ENTRY(glUniform2i)(GLint location, GLint x, GLint y) {
-    CALL_GL_API(glUniform2i, location, x, y);
+void API_ENTRY(glUniform2i)(GLint location, GLint v0, GLint v1) {
+    CALL_GL_API(glUniform2i, location, v0, v1);
 }
-void API_ENTRY(glUniform2iv)(GLint location, GLsizei count, const GLint* v) {
-    CALL_GL_API(glUniform2iv, location, count, v);
+void API_ENTRY(glUniform2iv)(GLint location, GLsizei count, const GLint * value) {
+    CALL_GL_API(glUniform2iv, location, count, value);
 }
-void API_ENTRY(glUniform3f)(GLint location, GLfloat x, GLfloat y, GLfloat z) {
-    CALL_GL_API(glUniform3f, location, x, y, z);
+void API_ENTRY(glUniform3f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
+    CALL_GL_API(glUniform3f, location, v0, v1, v2);
 }
-void API_ENTRY(glUniform3fv)(GLint location, GLsizei count, const GLfloat* v) {
-    CALL_GL_API(glUniform3fv, location, count, v);
+void API_ENTRY(glUniform3fv)(GLint location, GLsizei count, const GLfloat * value) {
+    CALL_GL_API(glUniform3fv, location, count, value);
 }
-void API_ENTRY(glUniform3i)(GLint location, GLint x, GLint y, GLint z) {
-    CALL_GL_API(glUniform3i, location, x, y, z);
+void API_ENTRY(glUniform3i)(GLint location, GLint v0, GLint v1, GLint v2) {
+    CALL_GL_API(glUniform3i, location, v0, v1, v2);
 }
-void API_ENTRY(glUniform3iv)(GLint location, GLsizei count, const GLint* v) {
-    CALL_GL_API(glUniform3iv, location, count, v);
+void API_ENTRY(glUniform3iv)(GLint location, GLsizei count, const GLint * value) {
+    CALL_GL_API(glUniform3iv, location, count, value);
 }
-void API_ENTRY(glUniform4f)(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
-    CALL_GL_API(glUniform4f, location, x, y, z, w);
+void API_ENTRY(glUniform4f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
+    CALL_GL_API(glUniform4f, location, v0, v1, v2, v3);
 }
-void API_ENTRY(glUniform4fv)(GLint location, GLsizei count, const GLfloat* v) {
-    CALL_GL_API(glUniform4fv, location, count, v);
+void API_ENTRY(glUniform4fv)(GLint location, GLsizei count, const GLfloat * value) {
+    CALL_GL_API(glUniform4fv, location, count, value);
 }
-void API_ENTRY(glUniform4i)(GLint location, GLint x, GLint y, GLint z, GLint w) {
-    CALL_GL_API(glUniform4i, location, x, y, z, w);
+void API_ENTRY(glUniform4i)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) {
+    CALL_GL_API(glUniform4i, location, v0, v1, v2, v3);
 }
-void API_ENTRY(glUniform4iv)(GLint location, GLsizei count, const GLint* v) {
-    CALL_GL_API(glUniform4iv, location, count, v);
+void API_ENTRY(glUniform4iv)(GLint location, GLsizei count, const GLint * value) {
+    CALL_GL_API(glUniform4iv, location, count, value);
 }
-void API_ENTRY(glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
+void API_ENTRY(glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     CALL_GL_API(glUniformMatrix2fv, location, count, transpose, value);
 }
-void API_ENTRY(glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
+void API_ENTRY(glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     CALL_GL_API(glUniformMatrix3fv, location, count, transpose, value);
 }
-void API_ENTRY(glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
+void API_ENTRY(glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     CALL_GL_API(glUniformMatrix4fv, location, count, transpose, value);
 }
 void API_ENTRY(glUseProgram)(GLuint program) {
@@ -394,33 +394,549 @@
 void API_ENTRY(glValidateProgram)(GLuint program) {
     CALL_GL_API(glValidateProgram, program);
 }
-void API_ENTRY(glVertexAttrib1f)(GLuint indx, GLfloat x) {
-    CALL_GL_API(glVertexAttrib1f, indx, x);
+void API_ENTRY(glVertexAttrib1f)(GLuint index, GLfloat x) {
+    CALL_GL_API(glVertexAttrib1f, index, x);
 }
-void API_ENTRY(glVertexAttrib1fv)(GLuint indx, const GLfloat* values) {
-    CALL_GL_API(glVertexAttrib1fv, indx, values);
+void API_ENTRY(glVertexAttrib1fv)(GLuint index, const GLfloat * v) {
+    CALL_GL_API(glVertexAttrib1fv, index, v);
 }
-void API_ENTRY(glVertexAttrib2f)(GLuint indx, GLfloat x, GLfloat y) {
-    CALL_GL_API(glVertexAttrib2f, indx, x, y);
+void API_ENTRY(glVertexAttrib2f)(GLuint index, GLfloat x, GLfloat y) {
+    CALL_GL_API(glVertexAttrib2f, index, x, y);
 }
-void API_ENTRY(glVertexAttrib2fv)(GLuint indx, const GLfloat* values) {
-    CALL_GL_API(glVertexAttrib2fv, indx, values);
+void API_ENTRY(glVertexAttrib2fv)(GLuint index, const GLfloat * v) {
+    CALL_GL_API(glVertexAttrib2fv, index, v);
 }
-void API_ENTRY(glVertexAttrib3f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z) {
-    CALL_GL_API(glVertexAttrib3f, indx, x, y, z);
+void API_ENTRY(glVertexAttrib3f)(GLuint index, GLfloat x, GLfloat y, GLfloat z) {
+    CALL_GL_API(glVertexAttrib3f, index, x, y, z);
 }
-void API_ENTRY(glVertexAttrib3fv)(GLuint indx, const GLfloat* values) {
-    CALL_GL_API(glVertexAttrib3fv, indx, values);
+void API_ENTRY(glVertexAttrib3fv)(GLuint index, const GLfloat * v) {
+    CALL_GL_API(glVertexAttrib3fv, index, v);
 }
-void API_ENTRY(glVertexAttrib4f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
-    CALL_GL_API(glVertexAttrib4f, indx, x, y, z, w);
+void API_ENTRY(glVertexAttrib4f)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
+    CALL_GL_API(glVertexAttrib4f, index, x, y, z, w);
 }
-void API_ENTRY(glVertexAttrib4fv)(GLuint indx, const GLfloat* values) {
-    CALL_GL_API(glVertexAttrib4fv, indx, values);
+void API_ENTRY(glVertexAttrib4fv)(GLuint index, const GLfloat * v) {
+    CALL_GL_API(glVertexAttrib4fv, index, v);
 }
-void API_ENTRY(glVertexAttribPointer)(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr) {
-    CALL_GL_API(glVertexAttribPointer, indx, size, type, normalized, stride, ptr);
+void API_ENTRY(glVertexAttribPointer)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer) {
+    CALL_GL_API(glVertexAttribPointer, index, size, type, normalized, stride, pointer);
 }
 void API_ENTRY(glViewport)(GLint x, GLint y, GLsizei width, GLsizei height) {
     CALL_GL_API(glViewport, x, y, width, height);
 }
+void API_ENTRY(glReadBuffer)(GLenum mode) {
+    CALL_GL_API(glReadBuffer, mode);
+}
+void API_ENTRY(glDrawRangeElements)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices) {
+    CALL_GL_API(glDrawRangeElements, mode, start, end, count, type, indices);
+}
+void API_ENTRY(glTexImage3D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels) {
+    CALL_GL_API(glTexImage3D, target, level, internalformat, width, height, depth, border, format, type, pixels);
+}
+void API_ENTRY(glTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels) {
+    CALL_GL_API(glTexSubImage3D, target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
+}
+void API_ENTRY(glCopyTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
+    CALL_GL_API(glCopyTexSubImage3D, target, level, xoffset, yoffset, zoffset, x, y, width, height);
+}
+void API_ENTRY(glCompressedTexImage3D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data) {
+    CALL_GL_API(glCompressedTexImage3D, target, level, internalformat, width, height, depth, border, imageSize, data);
+}
+void API_ENTRY(glCompressedTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data) {
+    CALL_GL_API(glCompressedTexSubImage3D, target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
+}
+void API_ENTRY(glGenQueries)(GLsizei n, GLuint * ids) {
+    CALL_GL_API(glGenQueries, n, ids);
+}
+void API_ENTRY(glDeleteQueries)(GLsizei n, const GLuint * ids) {
+    CALL_GL_API(glDeleteQueries, n, ids);
+}
+GLboolean API_ENTRY(glIsQuery)(GLuint id) {
+    CALL_GL_API_RETURN(glIsQuery, id);
+}
+void API_ENTRY(glBeginQuery)(GLenum target, GLuint id) {
+    CALL_GL_API(glBeginQuery, target, id);
+}
+void API_ENTRY(glEndQuery)(GLenum target) {
+    CALL_GL_API(glEndQuery, target);
+}
+void API_ENTRY(glGetQueryiv)(GLenum target, GLenum pname, GLint * params) {
+    CALL_GL_API(glGetQueryiv, target, pname, params);
+}
+void API_ENTRY(glGetQueryObjectuiv)(GLuint id, GLenum pname, GLuint * params) {
+    CALL_GL_API(glGetQueryObjectuiv, id, pname, params);
+}
+GLboolean API_ENTRY(glUnmapBuffer)(GLenum target) {
+    CALL_GL_API_RETURN(glUnmapBuffer, target);
+}
+void API_ENTRY(glGetBufferPointerv)(GLenum target, GLenum pname, void ** params) {
+    CALL_GL_API(glGetBufferPointerv, target, pname, params);
+}
+void API_ENTRY(glDrawBuffers)(GLsizei n, const GLenum * bufs) {
+    CALL_GL_API(glDrawBuffers, n, bufs);
+}
+void API_ENTRY(glUniformMatrix2x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glUniformMatrix2x3fv, location, count, transpose, value);
+}
+void API_ENTRY(glUniformMatrix3x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glUniformMatrix3x2fv, location, count, transpose, value);
+}
+void API_ENTRY(glUniformMatrix2x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glUniformMatrix2x4fv, location, count, transpose, value);
+}
+void API_ENTRY(glUniformMatrix4x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glUniformMatrix4x2fv, location, count, transpose, value);
+}
+void API_ENTRY(glUniformMatrix3x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glUniformMatrix3x4fv, location, count, transpose, value);
+}
+void API_ENTRY(glUniformMatrix4x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glUniformMatrix4x3fv, location, count, transpose, value);
+}
+void API_ENTRY(glBlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {
+    CALL_GL_API(glBlitFramebuffer, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
+}
+void API_ENTRY(glRenderbufferStorageMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
+    CALL_GL_API(glRenderbufferStorageMultisample, target, samples, internalformat, width, height);
+}
+void API_ENTRY(glFramebufferTextureLayer)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) {
+    CALL_GL_API(glFramebufferTextureLayer, target, attachment, texture, level, layer);
+}
+void * API_ENTRY(glMapBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
+    CALL_GL_API_RETURN(glMapBufferRange, target, offset, length, access);
+}
+void API_ENTRY(glFlushMappedBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length) {
+    CALL_GL_API(glFlushMappedBufferRange, target, offset, length);
+}
+void API_ENTRY(glBindVertexArray)(GLuint array) {
+    CALL_GL_API(glBindVertexArray, array);
+}
+void API_ENTRY(glDeleteVertexArrays)(GLsizei n, const GLuint * arrays) {
+    CALL_GL_API(glDeleteVertexArrays, n, arrays);
+}
+void API_ENTRY(glGenVertexArrays)(GLsizei n, GLuint * arrays) {
+    CALL_GL_API(glGenVertexArrays, n, arrays);
+}
+GLboolean API_ENTRY(glIsVertexArray)(GLuint array) {
+    CALL_GL_API_RETURN(glIsVertexArray, array);
+}
+void API_ENTRY(glGetIntegeri_v)(GLenum target, GLuint index, GLint * data) {
+    CALL_GL_API(glGetIntegeri_v, target, index, data);
+}
+void API_ENTRY(glBeginTransformFeedback)(GLenum primitiveMode) {
+    CALL_GL_API(glBeginTransformFeedback, primitiveMode);
+}
+void API_ENTRY(glEndTransformFeedback)(void) {
+    CALL_GL_API(glEndTransformFeedback);
+}
+void API_ENTRY(glBindBufferRange)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) {
+    CALL_GL_API(glBindBufferRange, target, index, buffer, offset, size);
+}
+void API_ENTRY(glBindBufferBase)(GLenum target, GLuint index, GLuint buffer) {
+    CALL_GL_API(glBindBufferBase, target, index, buffer);
+}
+void API_ENTRY(glTransformFeedbackVaryings)(GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode) {
+    CALL_GL_API(glTransformFeedbackVaryings, program, count, varyings, bufferMode);
+}
+void API_ENTRY(glGetTransformFeedbackVarying)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name) {
+    CALL_GL_API(glGetTransformFeedbackVarying, program, index, bufSize, length, size, type, name);
+}
+void API_ENTRY(glVertexAttribIPointer)(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer) {
+    CALL_GL_API(glVertexAttribIPointer, index, size, type, stride, pointer);
+}
+void API_ENTRY(glGetVertexAttribIiv)(GLuint index, GLenum pname, GLint * params) {
+    CALL_GL_API(glGetVertexAttribIiv, index, pname, params);
+}
+void API_ENTRY(glGetVertexAttribIuiv)(GLuint index, GLenum pname, GLuint * params) {
+    CALL_GL_API(glGetVertexAttribIuiv, index, pname, params);
+}
+void API_ENTRY(glVertexAttribI4i)(GLuint index, GLint x, GLint y, GLint z, GLint w) {
+    CALL_GL_API(glVertexAttribI4i, index, x, y, z, w);
+}
+void API_ENTRY(glVertexAttribI4ui)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) {
+    CALL_GL_API(glVertexAttribI4ui, index, x, y, z, w);
+}
+void API_ENTRY(glVertexAttribI4iv)(GLuint index, const GLint * v) {
+    CALL_GL_API(glVertexAttribI4iv, index, v);
+}
+void API_ENTRY(glVertexAttribI4uiv)(GLuint index, const GLuint * v) {
+    CALL_GL_API(glVertexAttribI4uiv, index, v);
+}
+void API_ENTRY(glGetUniformuiv)(GLuint program, GLint location, GLuint * params) {
+    CALL_GL_API(glGetUniformuiv, program, location, params);
+}
+GLint API_ENTRY(glGetFragDataLocation)(GLuint program, const GLchar * name) {
+    CALL_GL_API_RETURN(glGetFragDataLocation, program, name);
+}
+void API_ENTRY(glUniform1ui)(GLint location, GLuint v0) {
+    CALL_GL_API(glUniform1ui, location, v0);
+}
+void API_ENTRY(glUniform2ui)(GLint location, GLuint v0, GLuint v1) {
+    CALL_GL_API(glUniform2ui, location, v0, v1);
+}
+void API_ENTRY(glUniform3ui)(GLint location, GLuint v0, GLuint v1, GLuint v2) {
+    CALL_GL_API(glUniform3ui, location, v0, v1, v2);
+}
+void API_ENTRY(glUniform4ui)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) {
+    CALL_GL_API(glUniform4ui, location, v0, v1, v2, v3);
+}
+void API_ENTRY(glUniform1uiv)(GLint location, GLsizei count, const GLuint * value) {
+    CALL_GL_API(glUniform1uiv, location, count, value);
+}
+void API_ENTRY(glUniform2uiv)(GLint location, GLsizei count, const GLuint * value) {
+    CALL_GL_API(glUniform2uiv, location, count, value);
+}
+void API_ENTRY(glUniform3uiv)(GLint location, GLsizei count, const GLuint * value) {
+    CALL_GL_API(glUniform3uiv, location, count, value);
+}
+void API_ENTRY(glUniform4uiv)(GLint location, GLsizei count, const GLuint * value) {
+    CALL_GL_API(glUniform4uiv, location, count, value);
+}
+void API_ENTRY(glClearBufferiv)(GLenum buffer, GLint drawbuffer, const GLint * value) {
+    CALL_GL_API(glClearBufferiv, buffer, drawbuffer, value);
+}
+void API_ENTRY(glClearBufferuiv)(GLenum buffer, GLint drawbuffer, const GLuint * value) {
+    CALL_GL_API(glClearBufferuiv, buffer, drawbuffer, value);
+}
+void API_ENTRY(glClearBufferfv)(GLenum buffer, GLint drawbuffer, const GLfloat * value) {
+    CALL_GL_API(glClearBufferfv, buffer, drawbuffer, value);
+}
+void API_ENTRY(glClearBufferfi)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) {
+    CALL_GL_API(glClearBufferfi, buffer, drawbuffer, depth, stencil);
+}
+const GLubyte * API_ENTRY(__glGetStringi)(GLenum name, GLuint index) {
+    CALL_GL_API_RETURN(glGetStringi, name, index);
+}
+void API_ENTRY(glCopyBufferSubData)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) {
+    CALL_GL_API(glCopyBufferSubData, readTarget, writeTarget, readOffset, writeOffset, size);
+}
+void API_ENTRY(glGetUniformIndices)(GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices) {
+    CALL_GL_API(glGetUniformIndices, program, uniformCount, uniformNames, uniformIndices);
+}
+void API_ENTRY(glGetActiveUniformsiv)(GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params) {
+    CALL_GL_API(glGetActiveUniformsiv, program, uniformCount, uniformIndices, pname, params);
+}
+GLuint API_ENTRY(glGetUniformBlockIndex)(GLuint program, const GLchar * uniformBlockName) {
+    CALL_GL_API_RETURN(glGetUniformBlockIndex, program, uniformBlockName);
+}
+void API_ENTRY(glGetActiveUniformBlockiv)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params) {
+    CALL_GL_API(glGetActiveUniformBlockiv, program, uniformBlockIndex, pname, params);
+}
+void API_ENTRY(glGetActiveUniformBlockName)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName) {
+    CALL_GL_API(glGetActiveUniformBlockName, program, uniformBlockIndex, bufSize, length, uniformBlockName);
+}
+void API_ENTRY(glUniformBlockBinding)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) {
+    CALL_GL_API(glUniformBlockBinding, program, uniformBlockIndex, uniformBlockBinding);
+}
+void API_ENTRY(glDrawArraysInstanced)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount) {
+    CALL_GL_API(glDrawArraysInstanced, mode, first, count, instancecount);
+}
+void API_ENTRY(glDrawElementsInstanced)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount) {
+    CALL_GL_API(glDrawElementsInstanced, mode, count, type, indices, instancecount);
+}
+GLsync API_ENTRY(glFenceSync)(GLenum condition, GLbitfield flags) {
+    CALL_GL_API_RETURN(glFenceSync, condition, flags);
+}
+GLboolean API_ENTRY(glIsSync)(GLsync sync) {
+    CALL_GL_API_RETURN(glIsSync, sync);
+}
+void API_ENTRY(glDeleteSync)(GLsync sync) {
+    CALL_GL_API(glDeleteSync, sync);
+}
+GLenum API_ENTRY(glClientWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout) {
+    CALL_GL_API_RETURN(glClientWaitSync, sync, flags, timeout);
+}
+void API_ENTRY(glWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout) {
+    CALL_GL_API(glWaitSync, sync, flags, timeout);
+}
+void API_ENTRY(__glGetInteger64v)(GLenum pname, GLint64 * data) {
+    CALL_GL_API(glGetInteger64v, pname, data);
+}
+void API_ENTRY(glGetSynciv)(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values) {
+    CALL_GL_API(glGetSynciv, sync, pname, bufSize, length, values);
+}
+void API_ENTRY(glGetInteger64i_v)(GLenum target, GLuint index, GLint64 * data) {
+    CALL_GL_API(glGetInteger64i_v, target, index, data);
+}
+void API_ENTRY(glGetBufferParameteri64v)(GLenum target, GLenum pname, GLint64 * params) {
+    CALL_GL_API(glGetBufferParameteri64v, target, pname, params);
+}
+void API_ENTRY(glGenSamplers)(GLsizei count, GLuint * samplers) {
+    CALL_GL_API(glGenSamplers, count, samplers);
+}
+void API_ENTRY(glDeleteSamplers)(GLsizei count, const GLuint * samplers) {
+    CALL_GL_API(glDeleteSamplers, count, samplers);
+}
+GLboolean API_ENTRY(glIsSampler)(GLuint sampler) {
+    CALL_GL_API_RETURN(glIsSampler, sampler);
+}
+void API_ENTRY(glBindSampler)(GLuint unit, GLuint sampler) {
+    CALL_GL_API(glBindSampler, unit, sampler);
+}
+void API_ENTRY(glSamplerParameteri)(GLuint sampler, GLenum pname, GLint param) {
+    CALL_GL_API(glSamplerParameteri, sampler, pname, param);
+}
+void API_ENTRY(glSamplerParameteriv)(GLuint sampler, GLenum pname, const GLint * param) {
+    CALL_GL_API(glSamplerParameteriv, sampler, pname, param);
+}
+void API_ENTRY(glSamplerParameterf)(GLuint sampler, GLenum pname, GLfloat param) {
+    CALL_GL_API(glSamplerParameterf, sampler, pname, param);
+}
+void API_ENTRY(glSamplerParameterfv)(GLuint sampler, GLenum pname, const GLfloat * param) {
+    CALL_GL_API(glSamplerParameterfv, sampler, pname, param);
+}
+void API_ENTRY(glGetSamplerParameteriv)(GLuint sampler, GLenum pname, GLint * params) {
+    CALL_GL_API(glGetSamplerParameteriv, sampler, pname, params);
+}
+void API_ENTRY(glGetSamplerParameterfv)(GLuint sampler, GLenum pname, GLfloat * params) {
+    CALL_GL_API(glGetSamplerParameterfv, sampler, pname, params);
+}
+void API_ENTRY(glVertexAttribDivisor)(GLuint index, GLuint divisor) {
+    CALL_GL_API(glVertexAttribDivisor, index, divisor);
+}
+void API_ENTRY(glBindTransformFeedback)(GLenum target, GLuint id) {
+    CALL_GL_API(glBindTransformFeedback, target, id);
+}
+void API_ENTRY(glDeleteTransformFeedbacks)(GLsizei n, const GLuint * ids) {
+    CALL_GL_API(glDeleteTransformFeedbacks, n, ids);
+}
+void API_ENTRY(glGenTransformFeedbacks)(GLsizei n, GLuint * ids) {
+    CALL_GL_API(glGenTransformFeedbacks, n, ids);
+}
+GLboolean API_ENTRY(glIsTransformFeedback)(GLuint id) {
+    CALL_GL_API_RETURN(glIsTransformFeedback, id);
+}
+void API_ENTRY(glPauseTransformFeedback)(void) {
+    CALL_GL_API(glPauseTransformFeedback);
+}
+void API_ENTRY(glResumeTransformFeedback)(void) {
+    CALL_GL_API(glResumeTransformFeedback);
+}
+void API_ENTRY(glGetProgramBinary)(GLuint program, GLsizei bufSize, GLsizei * length, GLenum * binaryFormat, void * binary) {
+    CALL_GL_API(glGetProgramBinary, program, bufSize, length, binaryFormat, binary);
+}
+void API_ENTRY(glProgramBinary)(GLuint program, GLenum binaryFormat, const void * binary, GLsizei length) {
+    CALL_GL_API(glProgramBinary, program, binaryFormat, binary, length);
+}
+void API_ENTRY(glProgramParameteri)(GLuint program, GLenum pname, GLint value) {
+    CALL_GL_API(glProgramParameteri, program, pname, value);
+}
+void API_ENTRY(glInvalidateFramebuffer)(GLenum target, GLsizei numAttachments, const GLenum * attachments) {
+    CALL_GL_API(glInvalidateFramebuffer, target, numAttachments, attachments);
+}
+void API_ENTRY(glInvalidateSubFramebuffer)(GLenum target, GLsizei numAttachments, const GLenum * attachments, GLint x, GLint y, GLsizei width, GLsizei height) {
+    CALL_GL_API(glInvalidateSubFramebuffer, target, numAttachments, attachments, x, y, width, height);
+}
+void API_ENTRY(glTexStorage2D)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) {
+    CALL_GL_API(glTexStorage2D, target, levels, internalformat, width, height);
+}
+void API_ENTRY(glTexStorage3D)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) {
+    CALL_GL_API(glTexStorage3D, target, levels, internalformat, width, height, depth);
+}
+void API_ENTRY(glGetInternalformativ)(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint * params) {
+    CALL_GL_API(glGetInternalformativ, target, internalformat, pname, bufSize, params);
+}
+void API_ENTRY(glDispatchCompute)(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z) {
+    CALL_GL_API(glDispatchCompute, num_groups_x, num_groups_y, num_groups_z);
+}
+void API_ENTRY(glDispatchComputeIndirect)(GLintptr indirect) {
+    CALL_GL_API(glDispatchComputeIndirect, indirect);
+}
+void API_ENTRY(glDrawArraysIndirect)(GLenum mode, const void * indirect) {
+    CALL_GL_API(glDrawArraysIndirect, mode, indirect);
+}
+void API_ENTRY(glDrawElementsIndirect)(GLenum mode, GLenum type, const void * indirect) {
+    CALL_GL_API(glDrawElementsIndirect, mode, type, indirect);
+}
+void API_ENTRY(glFramebufferParameteri)(GLenum target, GLenum pname, GLint param) {
+    CALL_GL_API(glFramebufferParameteri, target, pname, param);
+}
+void API_ENTRY(glGetFramebufferParameteriv)(GLenum target, GLenum pname, GLint * params) {
+    CALL_GL_API(glGetFramebufferParameteriv, target, pname, params);
+}
+void API_ENTRY(glGetProgramInterfaceiv)(GLuint program, GLenum programInterface, GLenum pname, GLint * params) {
+    CALL_GL_API(glGetProgramInterfaceiv, program, programInterface, pname, params);
+}
+GLuint API_ENTRY(glGetProgramResourceIndex)(GLuint program, GLenum programInterface, const GLchar * name) {
+    CALL_GL_API_RETURN(glGetProgramResourceIndex, program, programInterface, name);
+}
+void API_ENTRY(glGetProgramResourceName)(GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei * length, GLchar * name) {
+    CALL_GL_API(glGetProgramResourceName, program, programInterface, index, bufSize, length, name);
+}
+void API_ENTRY(glGetProgramResourceiv)(GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum * props, GLsizei bufSize, GLsizei * length, GLint * params) {
+    CALL_GL_API(glGetProgramResourceiv, program, programInterface, index, propCount, props, bufSize, length, params);
+}
+GLint API_ENTRY(glGetProgramResourceLocation)(GLuint program, GLenum programInterface, const GLchar * name) {
+    CALL_GL_API_RETURN(glGetProgramResourceLocation, program, programInterface, name);
+}
+void API_ENTRY(glUseProgramStages)(GLuint pipeline, GLbitfield stages, GLuint program) {
+    CALL_GL_API(glUseProgramStages, pipeline, stages, program);
+}
+void API_ENTRY(glActiveShaderProgram)(GLuint pipeline, GLuint program) {
+    CALL_GL_API(glActiveShaderProgram, pipeline, program);
+}
+GLuint API_ENTRY(glCreateShaderProgramv)(GLenum type, GLsizei count, const GLchar *const* strings) {
+    CALL_GL_API_RETURN(glCreateShaderProgramv, type, count, strings);
+}
+void API_ENTRY(glBindProgramPipeline)(GLuint pipeline) {
+    CALL_GL_API(glBindProgramPipeline, pipeline);
+}
+void API_ENTRY(glDeleteProgramPipelines)(GLsizei n, const GLuint * pipelines) {
+    CALL_GL_API(glDeleteProgramPipelines, n, pipelines);
+}
+void API_ENTRY(glGenProgramPipelines)(GLsizei n, GLuint * pipelines) {
+    CALL_GL_API(glGenProgramPipelines, n, pipelines);
+}
+GLboolean API_ENTRY(glIsProgramPipeline)(GLuint pipeline) {
+    CALL_GL_API_RETURN(glIsProgramPipeline, pipeline);
+}
+void API_ENTRY(glGetProgramPipelineiv)(GLuint pipeline, GLenum pname, GLint * params) {
+    CALL_GL_API(glGetProgramPipelineiv, pipeline, pname, params);
+}
+void API_ENTRY(glProgramUniform1i)(GLuint program, GLint location, GLint v0) {
+    CALL_GL_API(glProgramUniform1i, program, location, v0);
+}
+void API_ENTRY(glProgramUniform2i)(GLuint program, GLint location, GLint v0, GLint v1) {
+    CALL_GL_API(glProgramUniform2i, program, location, v0, v1);
+}
+void API_ENTRY(glProgramUniform3i)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2) {
+    CALL_GL_API(glProgramUniform3i, program, location, v0, v1, v2);
+}
+void API_ENTRY(glProgramUniform4i)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3) {
+    CALL_GL_API(glProgramUniform4i, program, location, v0, v1, v2, v3);
+}
+void API_ENTRY(glProgramUniform1ui)(GLuint program, GLint location, GLuint v0) {
+    CALL_GL_API(glProgramUniform1ui, program, location, v0);
+}
+void API_ENTRY(glProgramUniform2ui)(GLuint program, GLint location, GLuint v0, GLuint v1) {
+    CALL_GL_API(glProgramUniform2ui, program, location, v0, v1);
+}
+void API_ENTRY(glProgramUniform3ui)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2) {
+    CALL_GL_API(glProgramUniform3ui, program, location, v0, v1, v2);
+}
+void API_ENTRY(glProgramUniform4ui)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) {
+    CALL_GL_API(glProgramUniform4ui, program, location, v0, v1, v2, v3);
+}
+void API_ENTRY(glProgramUniform1f)(GLuint program, GLint location, GLfloat v0) {
+    CALL_GL_API(glProgramUniform1f, program, location, v0);
+}
+void API_ENTRY(glProgramUniform2f)(GLuint program, GLint location, GLfloat v0, GLfloat v1) {
+    CALL_GL_API(glProgramUniform2f, program, location, v0, v1);
+}
+void API_ENTRY(glProgramUniform3f)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
+    CALL_GL_API(glProgramUniform3f, program, location, v0, v1, v2);
+}
+void API_ENTRY(glProgramUniform4f)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
+    CALL_GL_API(glProgramUniform4f, program, location, v0, v1, v2, v3);
+}
+void API_ENTRY(glProgramUniform1iv)(GLuint program, GLint location, GLsizei count, const GLint * value) {
+    CALL_GL_API(glProgramUniform1iv, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform2iv)(GLuint program, GLint location, GLsizei count, const GLint * value) {
+    CALL_GL_API(glProgramUniform2iv, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform3iv)(GLuint program, GLint location, GLsizei count, const GLint * value) {
+    CALL_GL_API(glProgramUniform3iv, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform4iv)(GLuint program, GLint location, GLsizei count, const GLint * value) {
+    CALL_GL_API(glProgramUniform4iv, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform1uiv)(GLuint program, GLint location, GLsizei count, const GLuint * value) {
+    CALL_GL_API(glProgramUniform1uiv, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform2uiv)(GLuint program, GLint location, GLsizei count, const GLuint * value) {
+    CALL_GL_API(glProgramUniform2uiv, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform3uiv)(GLuint program, GLint location, GLsizei count, const GLuint * value) {
+    CALL_GL_API(glProgramUniform3uiv, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform4uiv)(GLuint program, GLint location, GLsizei count, const GLuint * value) {
+    CALL_GL_API(glProgramUniform4uiv, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform1fv)(GLuint program, GLint location, GLsizei count, const GLfloat * value) {
+    CALL_GL_API(glProgramUniform1fv, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform2fv)(GLuint program, GLint location, GLsizei count, const GLfloat * value) {
+    CALL_GL_API(glProgramUniform2fv, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform3fv)(GLuint program, GLint location, GLsizei count, const GLfloat * value) {
+    CALL_GL_API(glProgramUniform3fv, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform4fv)(GLuint program, GLint location, GLsizei count, const GLfloat * value) {
+    CALL_GL_API(glProgramUniform4fv, program, location, count, value);
+}
+void API_ENTRY(glProgramUniformMatrix2fv)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glProgramUniformMatrix2fv, program, location, count, transpose, value);
+}
+void API_ENTRY(glProgramUniformMatrix3fv)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glProgramUniformMatrix3fv, program, location, count, transpose, value);
+}
+void API_ENTRY(glProgramUniformMatrix4fv)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glProgramUniformMatrix4fv, program, location, count, transpose, value);
+}
+void API_ENTRY(glProgramUniformMatrix2x3fv)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glProgramUniformMatrix2x3fv, program, location, count, transpose, value);
+}
+void API_ENTRY(glProgramUniformMatrix3x2fv)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glProgramUniformMatrix3x2fv, program, location, count, transpose, value);
+}
+void API_ENTRY(glProgramUniformMatrix2x4fv)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glProgramUniformMatrix2x4fv, program, location, count, transpose, value);
+}
+void API_ENTRY(glProgramUniformMatrix4x2fv)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glProgramUniformMatrix4x2fv, program, location, count, transpose, value);
+}
+void API_ENTRY(glProgramUniformMatrix3x4fv)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glProgramUniformMatrix3x4fv, program, location, count, transpose, value);
+}
+void API_ENTRY(glProgramUniformMatrix4x3fv)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glProgramUniformMatrix4x3fv, program, location, count, transpose, value);
+}
+void API_ENTRY(glValidateProgramPipeline)(GLuint pipeline) {
+    CALL_GL_API(glValidateProgramPipeline, pipeline);
+}
+void API_ENTRY(glGetProgramPipelineInfoLog)(GLuint pipeline, GLsizei bufSize, GLsizei * length, GLchar * infoLog) {
+    CALL_GL_API(glGetProgramPipelineInfoLog, pipeline, bufSize, length, infoLog);
+}
+void API_ENTRY(glBindImageTexture)(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format) {
+    CALL_GL_API(glBindImageTexture, unit, texture, level, layered, layer, access, format);
+}
+void API_ENTRY(glGetBooleani_v)(GLenum target, GLuint index, GLboolean * data) {
+    CALL_GL_API(glGetBooleani_v, target, index, data);
+}
+void API_ENTRY(glMemoryBarrier)(GLbitfield barriers) {
+    CALL_GL_API(glMemoryBarrier, barriers);
+}
+void API_ENTRY(glMemoryBarrierByRegion)(GLbitfield barriers) {
+    CALL_GL_API(glMemoryBarrierByRegion, barriers);
+}
+void API_ENTRY(glTexStorage2DMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations) {
+    CALL_GL_API(glTexStorage2DMultisample, target, samples, internalformat, width, height, fixedsamplelocations);
+}
+void API_ENTRY(glGetMultisamplefv)(GLenum pname, GLuint index, GLfloat * val) {
+    CALL_GL_API(glGetMultisamplefv, pname, index, val);
+}
+void API_ENTRY(glSampleMaski)(GLuint maskNumber, GLbitfield mask) {
+    CALL_GL_API(glSampleMaski, maskNumber, mask);
+}
+void API_ENTRY(glGetTexLevelParameteriv)(GLenum target, GLint level, GLenum pname, GLint * params) {
+    CALL_GL_API(glGetTexLevelParameteriv, target, level, pname, params);
+}
+void API_ENTRY(glGetTexLevelParameterfv)(GLenum target, GLint level, GLenum pname, GLfloat * params) {
+    CALL_GL_API(glGetTexLevelParameterfv, target, level, pname, params);
+}
+void API_ENTRY(glBindVertexBuffer)(GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride) {
+    CALL_GL_API(glBindVertexBuffer, bindingindex, buffer, offset, stride);
+}
+void API_ENTRY(glVertexAttribFormat)(GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset) {
+    CALL_GL_API(glVertexAttribFormat, attribindex, size, type, normalized, relativeoffset);
+}
+void API_ENTRY(glVertexAttribIFormat)(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset) {
+    CALL_GL_API(glVertexAttribIFormat, attribindex, size, type, relativeoffset);
+}
+void API_ENTRY(glVertexAttribBinding)(GLuint attribindex, GLuint bindingindex) {
+    CALL_GL_API(glVertexAttribBinding, attribindex, bindingindex);
+}
+void API_ENTRY(glVertexBindingDivisor)(GLuint bindingindex, GLuint divisor) {
+    CALL_GL_API(glVertexBindingDivisor, bindingindex, divisor);
+}
diff --git a/opengl/libs/GLES2/gl2ext_api.in b/opengl/libs/GLES2/gl2ext_api.in
index c381075..745590d 100644
--- a/opengl/libs/GLES2/gl2ext_api.in
+++ b/opengl/libs/GLES2/gl2ext_api.in
@@ -1,77 +1,119 @@
+void API_ENTRY(glBlendBarrierKHR)(void) {
+    CALL_GL_API(glBlendBarrierKHR);
+}
+void API_ENTRY(glDebugMessageControlKHR)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled) {
+    CALL_GL_API(glDebugMessageControlKHR, source, type, severity, count, ids, enabled);
+}
+void API_ENTRY(glDebugMessageInsertKHR)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf) {
+    CALL_GL_API(glDebugMessageInsertKHR, source, type, id, severity, length, buf);
+}
+void API_ENTRY(glDebugMessageCallbackKHR)(GLDEBUGPROCKHR callback, const void * userParam) {
+    CALL_GL_API(glDebugMessageCallbackKHR, callback, userParam);
+}
+GLuint API_ENTRY(glGetDebugMessageLogKHR)(GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog) {
+    CALL_GL_API_RETURN(glGetDebugMessageLogKHR, count, bufSize, sources, types, ids, severities, lengths, messageLog);
+}
+void API_ENTRY(glPushDebugGroupKHR)(GLenum source, GLuint id, GLsizei length, const GLchar * message) {
+    CALL_GL_API(glPushDebugGroupKHR, source, id, length, message);
+}
+void API_ENTRY(glPopDebugGroupKHR)(void) {
+    CALL_GL_API(glPopDebugGroupKHR);
+}
+void API_ENTRY(glObjectLabelKHR)(GLenum identifier, GLuint name, GLsizei length, const GLchar * label) {
+    CALL_GL_API(glObjectLabelKHR, identifier, name, length, label);
+}
+void API_ENTRY(glGetObjectLabelKHR)(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label) {
+    CALL_GL_API(glGetObjectLabelKHR, identifier, name, bufSize, length, label);
+}
+void API_ENTRY(glObjectPtrLabelKHR)(const void * ptr, GLsizei length, const GLchar * label) {
+    CALL_GL_API(glObjectPtrLabelKHR, ptr, length, label);
+}
+void API_ENTRY(glGetObjectPtrLabelKHR)(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label) {
+    CALL_GL_API(glGetObjectPtrLabelKHR, ptr, bufSize, length, label);
+}
+void API_ENTRY(glGetPointervKHR)(GLenum pname, void ** params) {
+    CALL_GL_API(glGetPointervKHR, pname, params);
+}
 void API_ENTRY(glEGLImageTargetTexture2DOES)(GLenum target, GLeglImageOES image) {
     CALL_GL_API(glEGLImageTargetTexture2DOES, target, image);
 }
 void API_ENTRY(glEGLImageTargetRenderbufferStorageOES)(GLenum target, GLeglImageOES image) {
     CALL_GL_API(glEGLImageTargetRenderbufferStorageOES, target, image);
 }
-void API_ENTRY(glGetProgramBinaryOES)(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary) {
+void API_ENTRY(glGetProgramBinaryOES)(GLuint program, GLsizei bufSize, GLsizei * length, GLenum * binaryFormat, void * binary) {
     CALL_GL_API(glGetProgramBinaryOES, program, bufSize, length, binaryFormat, binary);
 }
-void API_ENTRY(glProgramBinaryOES)(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length) {
+void API_ENTRY(glProgramBinaryOES)(GLuint program, GLenum binaryFormat, const void * binary, GLint length) {
     CALL_GL_API(glProgramBinaryOES, program, binaryFormat, binary, length);
 }
-void* API_ENTRY(glMapBufferOES)(GLenum target, GLenum access) {
+void * API_ENTRY(glMapBufferOES)(GLenum target, GLenum access) {
     CALL_GL_API_RETURN(glMapBufferOES, target, access);
 }
 GLboolean API_ENTRY(glUnmapBufferOES)(GLenum target) {
     CALL_GL_API_RETURN(glUnmapBufferOES, target);
 }
-void API_ENTRY(glGetBufferPointervOES)(GLenum target, GLenum pname, GLvoid** params) {
+void API_ENTRY(glGetBufferPointervOES)(GLenum target, GLenum pname, void ** params) {
     CALL_GL_API(glGetBufferPointervOES, target, pname, params);
 }
-void API_ENTRY(glTexImage3DOES)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) {
+void API_ENTRY(glMinSampleShadingOES)(GLfloat value) {
+    CALL_GL_API(glMinSampleShadingOES, value);
+}
+void API_ENTRY(glTexImage3DOES)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels) {
     CALL_GL_API(glTexImage3DOES, target, level, internalformat, width, height, depth, border, format, type, pixels);
 }
-void API_ENTRY(glTexSubImage3DOES)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) {
+void API_ENTRY(glTexSubImage3DOES)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels) {
     CALL_GL_API(glTexSubImage3DOES, target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
 }
 void API_ENTRY(glCopyTexSubImage3DOES)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
     CALL_GL_API(glCopyTexSubImage3DOES, target, level, xoffset, yoffset, zoffset, x, y, width, height);
 }
-void API_ENTRY(glCompressedTexImage3DOES)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) {
+void API_ENTRY(glCompressedTexImage3DOES)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data) {
     CALL_GL_API(glCompressedTexImage3DOES, target, level, internalformat, width, height, depth, border, imageSize, data);
 }
-void API_ENTRY(glCompressedTexSubImage3DOES)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) {
+void API_ENTRY(glCompressedTexSubImage3DOES)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data) {
     CALL_GL_API(glCompressedTexSubImage3DOES, target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
 }
 void API_ENTRY(glFramebufferTexture3DOES)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) {
     CALL_GL_API(glFramebufferTexture3DOES, target, attachment, textarget, texture, level, zoffset);
 }
+void API_ENTRY(glTexStorage3DMultisampleOES)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations) {
+    CALL_GL_API(glTexStorage3DMultisampleOES, target, samples, internalformat, width, height, depth, fixedsamplelocations);
+}
 void API_ENTRY(glBindVertexArrayOES)(GLuint array) {
     CALL_GL_API(glBindVertexArrayOES, array);
 }
-void API_ENTRY(glDeleteVertexArraysOES)(GLsizei n, const GLuint *arrays) {
+void API_ENTRY(glDeleteVertexArraysOES)(GLsizei n, const GLuint * arrays) {
     CALL_GL_API(glDeleteVertexArraysOES, n, arrays);
 }
-void API_ENTRY(glGenVertexArraysOES)(GLsizei n, GLuint *arrays) {
+void API_ENTRY(glGenVertexArraysOES)(GLsizei n, GLuint * arrays) {
     CALL_GL_API(glGenVertexArraysOES, n, arrays);
 }
 GLboolean API_ENTRY(glIsVertexArrayOES)(GLuint array) {
     CALL_GL_API_RETURN(glIsVertexArrayOES, array);
 }
-void API_ENTRY(glGetPerfMonitorGroupsAMD)(GLint *numGroups, GLsizei groupsSize, GLuint *groups) {
+void API_ENTRY(glGetPerfMonitorGroupsAMD)(GLint * numGroups, GLsizei groupsSize, GLuint * groups) {
     CALL_GL_API(glGetPerfMonitorGroupsAMD, numGroups, groupsSize, groups);
 }
-void API_ENTRY(glGetPerfMonitorCountersAMD)(GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters) {
+void API_ENTRY(glGetPerfMonitorCountersAMD)(GLuint group, GLint * numCounters, GLint * maxActiveCounters, GLsizei counterSize, GLuint * counters) {
     CALL_GL_API(glGetPerfMonitorCountersAMD, group, numCounters, maxActiveCounters, counterSize, counters);
 }
-void API_ENTRY(glGetPerfMonitorGroupStringAMD)(GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString) {
+void API_ENTRY(glGetPerfMonitorGroupStringAMD)(GLuint group, GLsizei bufSize, GLsizei * length, GLchar * groupString) {
     CALL_GL_API(glGetPerfMonitorGroupStringAMD, group, bufSize, length, groupString);
 }
-void API_ENTRY(glGetPerfMonitorCounterStringAMD)(GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString) {
+void API_ENTRY(glGetPerfMonitorCounterStringAMD)(GLuint group, GLuint counter, GLsizei bufSize, GLsizei * length, GLchar * counterString) {
     CALL_GL_API(glGetPerfMonitorCounterStringAMD, group, counter, bufSize, length, counterString);
 }
-void API_ENTRY(glGetPerfMonitorCounterInfoAMD)(GLuint group, GLuint counter, GLenum pname, GLvoid *data) {
+void API_ENTRY(glGetPerfMonitorCounterInfoAMD)(GLuint group, GLuint counter, GLenum pname, void * data) {
     CALL_GL_API(glGetPerfMonitorCounterInfoAMD, group, counter, pname, data);
 }
-void API_ENTRY(glGenPerfMonitorsAMD)(GLsizei n, GLuint *monitors) {
+void API_ENTRY(glGenPerfMonitorsAMD)(GLsizei n, GLuint * monitors) {
     CALL_GL_API(glGenPerfMonitorsAMD, n, monitors);
 }
-void API_ENTRY(glDeletePerfMonitorsAMD)(GLsizei n, GLuint *monitors) {
+void API_ENTRY(glDeletePerfMonitorsAMD)(GLsizei n, GLuint * monitors) {
     CALL_GL_API(glDeletePerfMonitorsAMD, n, monitors);
 }
-void API_ENTRY(glSelectPerfMonitorCountersAMD)(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList) {
-    CALL_GL_API(glSelectPerfMonitorCountersAMD, monitor, enable, group, numCounters, countersList);
+void API_ENTRY(glSelectPerfMonitorCountersAMD)(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint * counterList) {
+    CALL_GL_API(glSelectPerfMonitorCountersAMD, monitor, enable, group, numCounters, counterList);
 }
 void API_ENTRY(glBeginPerfMonitorAMD)(GLuint monitor) {
     CALL_GL_API(glBeginPerfMonitorAMD, monitor);
@@ -79,7 +121,7 @@
 void API_ENTRY(glEndPerfMonitorAMD)(GLuint monitor) {
     CALL_GL_API(glEndPerfMonitorAMD, monitor);
 }
-void API_ENTRY(glGetPerfMonitorCounterDataAMD)(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten) {
+void API_ENTRY(glGetPerfMonitorCounterDataAMD)(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint * data, GLint * bytesWritten) {
     CALL_GL_API(glGetPerfMonitorCounterDataAMD, monitor, pname, dataSize, data, bytesWritten);
 }
 void API_ENTRY(glBlitFramebufferANGLE)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {
@@ -88,46 +130,73 @@
 void API_ENTRY(glRenderbufferStorageMultisampleANGLE)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
     CALL_GL_API(glRenderbufferStorageMultisampleANGLE, target, samples, internalformat, width, height);
 }
+void API_ENTRY(glDrawArraysInstancedANGLE)(GLenum mode, GLint first, GLsizei count, GLsizei primcount) {
+    CALL_GL_API(glDrawArraysInstancedANGLE, mode, first, count, primcount);
+}
+void API_ENTRY(glDrawElementsInstancedANGLE)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount) {
+    CALL_GL_API(glDrawElementsInstancedANGLE, mode, count, type, indices, primcount);
+}
+void API_ENTRY(glVertexAttribDivisorANGLE)(GLuint index, GLuint divisor) {
+    CALL_GL_API(glVertexAttribDivisorANGLE, index, divisor);
+}
+void API_ENTRY(glGetTranslatedShaderSourceANGLE)(GLuint shader, GLsizei bufsize, GLsizei * length, GLchar * source) {
+    CALL_GL_API(glGetTranslatedShaderSourceANGLE, shader, bufsize, length, source);
+}
+void API_ENTRY(glCopyTextureLevelsAPPLE)(GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount) {
+    CALL_GL_API(glCopyTextureLevelsAPPLE, destinationTexture, sourceTexture, sourceBaseLevel, sourceLevelCount);
+}
 void API_ENTRY(glRenderbufferStorageMultisampleAPPLE)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
     CALL_GL_API(glRenderbufferStorageMultisampleAPPLE, target, samples, internalformat, width, height);
 }
 void API_ENTRY(glResolveMultisampleFramebufferAPPLE)(void) {
     CALL_GL_API(glResolveMultisampleFramebufferAPPLE);
 }
-void API_ENTRY(glLabelObjectEXT)(GLenum type, GLuint object, GLsizei length, const GLchar *label) {
+GLsync API_ENTRY(glFenceSyncAPPLE)(GLenum condition, GLbitfield flags) {
+    CALL_GL_API_RETURN(glFenceSyncAPPLE, condition, flags);
+}
+GLboolean API_ENTRY(glIsSyncAPPLE)(GLsync sync) {
+    CALL_GL_API_RETURN(glIsSyncAPPLE, sync);
+}
+void API_ENTRY(glDeleteSyncAPPLE)(GLsync sync) {
+    CALL_GL_API(glDeleteSyncAPPLE, sync);
+}
+GLenum API_ENTRY(glClientWaitSyncAPPLE)(GLsync sync, GLbitfield flags, GLuint64 timeout) {
+    CALL_GL_API_RETURN(glClientWaitSyncAPPLE, sync, flags, timeout);
+}
+void API_ENTRY(glWaitSyncAPPLE)(GLsync sync, GLbitfield flags, GLuint64 timeout) {
+    CALL_GL_API(glWaitSyncAPPLE, sync, flags, timeout);
+}
+void API_ENTRY(glGetInteger64vAPPLE)(GLenum pname, GLint64 * params) {
+    CALL_GL_API(glGetInteger64vAPPLE, pname, params);
+}
+void API_ENTRY(glGetSyncivAPPLE)(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values) {
+    CALL_GL_API(glGetSyncivAPPLE, sync, pname, bufSize, length, values);
+}
+void API_ENTRY(glCopyImageSubDataEXT)(GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth) {
+    CALL_GL_API(glCopyImageSubDataEXT, srcName, srcTarget, srcLevel, srcX, srcY, srcZ, dstName, dstTarget, dstLevel, dstX, dstY, dstZ, srcWidth, srcHeight, srcDepth);
+}
+void API_ENTRY(glLabelObjectEXT)(GLenum type, GLuint object, GLsizei length, const GLchar * label) {
     CALL_GL_API(glLabelObjectEXT, type, object, length, label);
 }
-void API_ENTRY(glGetObjectLabelEXT)(GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label) {
+void API_ENTRY(glGetObjectLabelEXT)(GLenum type, GLuint object, GLsizei bufSize, GLsizei * length, GLchar * label) {
     CALL_GL_API(glGetObjectLabelEXT, type, object, bufSize, length, label);
 }
-void API_ENTRY(glInsertEventMarkerEXT)(GLsizei length, const GLchar *marker) {
+void API_ENTRY(glInsertEventMarkerEXT)(GLsizei length, const GLchar * marker) {
     CALL_GL_API(glInsertEventMarkerEXT, length, marker);
 }
-void API_ENTRY(glPushGroupMarkerEXT)(GLsizei length, const GLchar *marker) {
+void API_ENTRY(glPushGroupMarkerEXT)(GLsizei length, const GLchar * marker) {
     CALL_GL_API(glPushGroupMarkerEXT, length, marker);
 }
 void API_ENTRY(glPopGroupMarkerEXT)(void) {
     CALL_GL_API(glPopGroupMarkerEXT);
 }
-void API_ENTRY(glDiscardFramebufferEXT)(GLenum target, GLsizei numAttachments, const GLenum *attachments) {
+void API_ENTRY(glDiscardFramebufferEXT)(GLenum target, GLsizei numAttachments, const GLenum * attachments) {
     CALL_GL_API(glDiscardFramebufferEXT, target, numAttachments, attachments);
 }
-void API_ENTRY(glRenderbufferStorageMultisampleEXT)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
-    CALL_GL_API(glRenderbufferStorageMultisampleEXT, target, samples, internalformat, width, height);
-}
-void API_ENTRY(glFramebufferTexture2DMultisampleEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) {
-    CALL_GL_API(glFramebufferTexture2DMultisampleEXT, target, attachment, textarget, texture, level, samples);
-}
-void API_ENTRY(glMultiDrawArraysEXT)(GLenum mode, GLint *first, GLsizei *count, GLsizei primcount) {
-    CALL_GL_API(glMultiDrawArraysEXT, mode, first, count, primcount);
-}
-void API_ENTRY(glMultiDrawElementsEXT)(GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount) {
-    CALL_GL_API(glMultiDrawElementsEXT, mode, count, type, indices, primcount);
-}
-void API_ENTRY(glGenQueriesEXT)(GLsizei n, GLuint *ids) {
+void API_ENTRY(glGenQueriesEXT)(GLsizei n, GLuint * ids) {
     CALL_GL_API(glGenQueriesEXT, n, ids);
 }
-void API_ENTRY(glDeleteQueriesEXT)(GLsizei n, const GLuint *ids) {
+void API_ENTRY(glDeleteQueriesEXT)(GLsizei n, const GLuint * ids) {
     CALL_GL_API(glDeleteQueriesEXT, n, ids);
 }
 GLboolean API_ENTRY(glIsQueryEXT)(GLuint id) {
@@ -139,113 +208,269 @@
 void API_ENTRY(glEndQueryEXT)(GLenum target) {
     CALL_GL_API(glEndQueryEXT, target);
 }
-void API_ENTRY(glGetQueryivEXT)(GLenum target, GLenum pname, GLint *params) {
+void API_ENTRY(glQueryCounterEXT)(GLuint id, GLenum target) {
+    CALL_GL_API(glQueryCounterEXT, id, target);
+}
+void API_ENTRY(glGetQueryivEXT)(GLenum target, GLenum pname, GLint * params) {
     CALL_GL_API(glGetQueryivEXT, target, pname, params);
 }
-void API_ENTRY(glGetQueryObjectuivEXT)(GLuint id, GLenum pname, GLuint *params) {
+void API_ENTRY(glGetQueryObjectivEXT)(GLuint id, GLenum pname, GLint * params) {
+    CALL_GL_API(glGetQueryObjectivEXT, id, pname, params);
+}
+void API_ENTRY(glGetQueryObjectuivEXT)(GLuint id, GLenum pname, GLuint * params) {
     CALL_GL_API(glGetQueryObjectuivEXT, id, pname, params);
 }
+void API_ENTRY(glGetQueryObjecti64vEXT)(GLuint id, GLenum pname, GLint64 * params) {
+    CALL_GL_API(glGetQueryObjecti64vEXT, id, pname, params);
+}
+void API_ENTRY(glGetQueryObjectui64vEXT)(GLuint id, GLenum pname, GLuint64 * params) {
+    CALL_GL_API(glGetQueryObjectui64vEXT, id, pname, params);
+}
+void API_ENTRY(glDrawBuffersEXT)(GLsizei n, const GLenum * bufs) {
+    CALL_GL_API(glDrawBuffersEXT, n, bufs);
+}
+void API_ENTRY(glEnableiEXT)(GLenum target, GLuint index) {
+    CALL_GL_API(glEnableiEXT, target, index);
+}
+void API_ENTRY(glDisableiEXT)(GLenum target, GLuint index) {
+    CALL_GL_API(glDisableiEXT, target, index);
+}
+void API_ENTRY(glBlendEquationiEXT)(GLuint buf, GLenum mode) {
+    CALL_GL_API(glBlendEquationiEXT, buf, mode);
+}
+void API_ENTRY(glBlendEquationSeparateiEXT)(GLuint buf, GLenum modeRGB, GLenum modeAlpha) {
+    CALL_GL_API(glBlendEquationSeparateiEXT, buf, modeRGB, modeAlpha);
+}
+void API_ENTRY(glBlendFunciEXT)(GLuint buf, GLenum src, GLenum dst) {
+    CALL_GL_API(glBlendFunciEXT, buf, src, dst);
+}
+void API_ENTRY(glBlendFuncSeparateiEXT)(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) {
+    CALL_GL_API(glBlendFuncSeparateiEXT, buf, srcRGB, dstRGB, srcAlpha, dstAlpha);
+}
+void API_ENTRY(glColorMaskiEXT)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a) {
+    CALL_GL_API(glColorMaskiEXT, index, r, g, b, a);
+}
+GLboolean API_ENTRY(glIsEnablediEXT)(GLenum target, GLuint index) {
+    CALL_GL_API_RETURN(glIsEnablediEXT, target, index);
+}
+void API_ENTRY(glDrawArraysInstancedEXT)(GLenum mode, GLint start, GLsizei count, GLsizei primcount) {
+    CALL_GL_API(glDrawArraysInstancedEXT, mode, start, count, primcount);
+}
+void API_ENTRY(glDrawElementsInstancedEXT)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount) {
+    CALL_GL_API(glDrawElementsInstancedEXT, mode, count, type, indices, primcount);
+}
+void API_ENTRY(glFramebufferTextureEXT)(GLenum target, GLenum attachment, GLuint texture, GLint level) {
+    CALL_GL_API(glFramebufferTextureEXT, target, attachment, texture, level);
+}
+void API_ENTRY(glVertexAttribDivisorEXT)(GLuint index, GLuint divisor) {
+    CALL_GL_API(glVertexAttribDivisorEXT, index, divisor);
+}
+void * API_ENTRY(glMapBufferRangeEXT)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
+    CALL_GL_API_RETURN(glMapBufferRangeEXT, target, offset, length, access);
+}
+void API_ENTRY(glFlushMappedBufferRangeEXT)(GLenum target, GLintptr offset, GLsizeiptr length) {
+    CALL_GL_API(glFlushMappedBufferRangeEXT, target, offset, length);
+}
+void API_ENTRY(glMultiDrawArraysEXT)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei primcount) {
+    CALL_GL_API(glMultiDrawArraysEXT, mode, first, count, primcount);
+}
+void API_ENTRY(glMultiDrawElementsEXT)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei primcount) {
+    CALL_GL_API(glMultiDrawElementsEXT, mode, count, type, indices, primcount);
+}
+void API_ENTRY(glRenderbufferStorageMultisampleEXT)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
+    CALL_GL_API(glRenderbufferStorageMultisampleEXT, target, samples, internalformat, width, height);
+}
+void API_ENTRY(glFramebufferTexture2DMultisampleEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) {
+    CALL_GL_API(glFramebufferTexture2DMultisampleEXT, target, attachment, textarget, texture, level, samples);
+}
+void API_ENTRY(glReadBufferIndexedEXT)(GLenum src, GLint index) {
+    CALL_GL_API(glReadBufferIndexedEXT, src, index);
+}
+void API_ENTRY(glDrawBuffersIndexedEXT)(GLint n, const GLenum * location, const GLint * indices) {
+    CALL_GL_API(glDrawBuffersIndexedEXT, n, location, indices);
+}
+void API_ENTRY(glGetIntegeri_vEXT)(GLenum target, GLuint index, GLint * data) {
+    CALL_GL_API(glGetIntegeri_vEXT, target, index, data);
+}
+void API_ENTRY(glPrimitiveBoundingBoxEXT)(GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW) {
+    CALL_GL_API(glPrimitiveBoundingBoxEXT, minX, minY, minZ, minW, maxX, maxY, maxZ, maxW);
+}
 GLenum API_ENTRY(glGetGraphicsResetStatusEXT)(void) {
     CALL_GL_API_RETURN(glGetGraphicsResetStatusEXT);
 }
-void API_ENTRY(glReadnPixelsEXT)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data) {
+void API_ENTRY(glReadnPixelsEXT)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data) {
     CALL_GL_API(glReadnPixelsEXT, x, y, width, height, format, type, bufSize, data);
 }
-void API_ENTRY(glGetnUniformfvEXT)(GLuint program, GLint location, GLsizei bufSize, float *params) {
+void API_ENTRY(glGetnUniformfvEXT)(GLuint program, GLint location, GLsizei bufSize, GLfloat * params) {
     CALL_GL_API(glGetnUniformfvEXT, program, location, bufSize, params);
 }
-void API_ENTRY(glGetnUniformivEXT)(GLuint program, GLint location, GLsizei bufSize, GLint *params) {
+void API_ENTRY(glGetnUniformivEXT)(GLuint program, GLint location, GLsizei bufSize, GLint * params) {
     CALL_GL_API(glGetnUniformivEXT, program, location, bufSize, params);
 }
-void API_ENTRY(glUseProgramStagesEXT)(GLuint pipeline, GLbitfield stages, GLuint program) {
-    CALL_GL_API(glUseProgramStagesEXT, pipeline, stages, program);
-}
 void API_ENTRY(glActiveShaderProgramEXT)(GLuint pipeline, GLuint program) {
     CALL_GL_API(glActiveShaderProgramEXT, pipeline, program);
 }
-GLuint API_ENTRY(glCreateShaderProgramvEXT)(GLenum type, GLsizei count, const GLchar **strings) {
-    CALL_GL_API_RETURN(glCreateShaderProgramvEXT, type, count, strings);
-}
 void API_ENTRY(glBindProgramPipelineEXT)(GLuint pipeline) {
     CALL_GL_API(glBindProgramPipelineEXT, pipeline);
 }
-void API_ENTRY(glDeleteProgramPipelinesEXT)(GLsizei n, const GLuint *pipelines) {
+GLuint API_ENTRY(glCreateShaderProgramvEXT)(GLenum type, GLsizei count, const GLchar ** strings) {
+    CALL_GL_API_RETURN(glCreateShaderProgramvEXT, type, count, strings);
+}
+void API_ENTRY(glDeleteProgramPipelinesEXT)(GLsizei n, const GLuint * pipelines) {
     CALL_GL_API(glDeleteProgramPipelinesEXT, n, pipelines);
 }
-void API_ENTRY(glGenProgramPipelinesEXT)(GLsizei n, GLuint *pipelines) {
+void API_ENTRY(glGenProgramPipelinesEXT)(GLsizei n, GLuint * pipelines) {
     CALL_GL_API(glGenProgramPipelinesEXT, n, pipelines);
 }
+void API_ENTRY(glGetProgramPipelineInfoLogEXT)(GLuint pipeline, GLsizei bufSize, GLsizei * length, GLchar * infoLog) {
+    CALL_GL_API(glGetProgramPipelineInfoLogEXT, pipeline, bufSize, length, infoLog);
+}
+void API_ENTRY(glGetProgramPipelineivEXT)(GLuint pipeline, GLenum pname, GLint * params) {
+    CALL_GL_API(glGetProgramPipelineivEXT, pipeline, pname, params);
+}
 GLboolean API_ENTRY(glIsProgramPipelineEXT)(GLuint pipeline) {
     CALL_GL_API_RETURN(glIsProgramPipelineEXT, pipeline);
 }
 void API_ENTRY(glProgramParameteriEXT)(GLuint program, GLenum pname, GLint value) {
     CALL_GL_API(glProgramParameteriEXT, program, pname, value);
 }
-void API_ENTRY(glGetProgramPipelineivEXT)(GLuint pipeline, GLenum pname, GLint *params) {
-    CALL_GL_API(glGetProgramPipelineivEXT, pipeline, pname, params);
+void API_ENTRY(glProgramUniform1fEXT)(GLuint program, GLint location, GLfloat v0) {
+    CALL_GL_API(glProgramUniform1fEXT, program, location, v0);
 }
-void API_ENTRY(glProgramUniform1iEXT)(GLuint program, GLint location, GLint x) {
-    CALL_GL_API(glProgramUniform1iEXT, program, location, x);
-}
-void API_ENTRY(glProgramUniform2iEXT)(GLuint program, GLint location, GLint x, GLint y) {
-    CALL_GL_API(glProgramUniform2iEXT, program, location, x, y);
-}
-void API_ENTRY(glProgramUniform3iEXT)(GLuint program, GLint location, GLint x, GLint y, GLint z) {
-    CALL_GL_API(glProgramUniform3iEXT, program, location, x, y, z);
-}
-void API_ENTRY(glProgramUniform4iEXT)(GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w) {
-    CALL_GL_API(glProgramUniform4iEXT, program, location, x, y, z, w);
-}
-void API_ENTRY(glProgramUniform1fEXT)(GLuint program, GLint location, GLfloat x) {
-    CALL_GL_API(glProgramUniform1fEXT, program, location, x);
-}
-void API_ENTRY(glProgramUniform2fEXT)(GLuint program, GLint location, GLfloat x, GLfloat y) {
-    CALL_GL_API(glProgramUniform2fEXT, program, location, x, y);
-}
-void API_ENTRY(glProgramUniform3fEXT)(GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z) {
-    CALL_GL_API(glProgramUniform3fEXT, program, location, x, y, z);
-}
-void API_ENTRY(glProgramUniform4fEXT)(GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
-    CALL_GL_API(glProgramUniform4fEXT, program, location, x, y, z, w);
-}
-void API_ENTRY(glProgramUniform1ivEXT)(GLuint program, GLint location, GLsizei count, const GLint *value) {
-    CALL_GL_API(glProgramUniform1ivEXT, program, location, count, value);
-}
-void API_ENTRY(glProgramUniform2ivEXT)(GLuint program, GLint location, GLsizei count, const GLint *value) {
-    CALL_GL_API(glProgramUniform2ivEXT, program, location, count, value);
-}
-void API_ENTRY(glProgramUniform3ivEXT)(GLuint program, GLint location, GLsizei count, const GLint *value) {
-    CALL_GL_API(glProgramUniform3ivEXT, program, location, count, value);
-}
-void API_ENTRY(glProgramUniform4ivEXT)(GLuint program, GLint location, GLsizei count, const GLint *value) {
-    CALL_GL_API(glProgramUniform4ivEXT, program, location, count, value);
-}
-void API_ENTRY(glProgramUniform1fvEXT)(GLuint program, GLint location, GLsizei count, const GLfloat *value) {
+void API_ENTRY(glProgramUniform1fvEXT)(GLuint program, GLint location, GLsizei count, const GLfloat * value) {
     CALL_GL_API(glProgramUniform1fvEXT, program, location, count, value);
 }
-void API_ENTRY(glProgramUniform2fvEXT)(GLuint program, GLint location, GLsizei count, const GLfloat *value) {
+void API_ENTRY(glProgramUniform1iEXT)(GLuint program, GLint location, GLint v0) {
+    CALL_GL_API(glProgramUniform1iEXT, program, location, v0);
+}
+void API_ENTRY(glProgramUniform1ivEXT)(GLuint program, GLint location, GLsizei count, const GLint * value) {
+    CALL_GL_API(glProgramUniform1ivEXT, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform2fEXT)(GLuint program, GLint location, GLfloat v0, GLfloat v1) {
+    CALL_GL_API(glProgramUniform2fEXT, program, location, v0, v1);
+}
+void API_ENTRY(glProgramUniform2fvEXT)(GLuint program, GLint location, GLsizei count, const GLfloat * value) {
     CALL_GL_API(glProgramUniform2fvEXT, program, location, count, value);
 }
-void API_ENTRY(glProgramUniform3fvEXT)(GLuint program, GLint location, GLsizei count, const GLfloat *value) {
+void API_ENTRY(glProgramUniform2iEXT)(GLuint program, GLint location, GLint v0, GLint v1) {
+    CALL_GL_API(glProgramUniform2iEXT, program, location, v0, v1);
+}
+void API_ENTRY(glProgramUniform2ivEXT)(GLuint program, GLint location, GLsizei count, const GLint * value) {
+    CALL_GL_API(glProgramUniform2ivEXT, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform3fEXT)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
+    CALL_GL_API(glProgramUniform3fEXT, program, location, v0, v1, v2);
+}
+void API_ENTRY(glProgramUniform3fvEXT)(GLuint program, GLint location, GLsizei count, const GLfloat * value) {
     CALL_GL_API(glProgramUniform3fvEXT, program, location, count, value);
 }
-void API_ENTRY(glProgramUniform4fvEXT)(GLuint program, GLint location, GLsizei count, const GLfloat *value) {
+void API_ENTRY(glProgramUniform3iEXT)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2) {
+    CALL_GL_API(glProgramUniform3iEXT, program, location, v0, v1, v2);
+}
+void API_ENTRY(glProgramUniform3ivEXT)(GLuint program, GLint location, GLsizei count, const GLint * value) {
+    CALL_GL_API(glProgramUniform3ivEXT, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform4fEXT)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
+    CALL_GL_API(glProgramUniform4fEXT, program, location, v0, v1, v2, v3);
+}
+void API_ENTRY(glProgramUniform4fvEXT)(GLuint program, GLint location, GLsizei count, const GLfloat * value) {
     CALL_GL_API(glProgramUniform4fvEXT, program, location, count, value);
 }
-void API_ENTRY(glProgramUniformMatrix2fvEXT)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {
+void API_ENTRY(glProgramUniform4iEXT)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3) {
+    CALL_GL_API(glProgramUniform4iEXT, program, location, v0, v1, v2, v3);
+}
+void API_ENTRY(glProgramUniform4ivEXT)(GLuint program, GLint location, GLsizei count, const GLint * value) {
+    CALL_GL_API(glProgramUniform4ivEXT, program, location, count, value);
+}
+void API_ENTRY(glProgramUniformMatrix2fvEXT)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     CALL_GL_API(glProgramUniformMatrix2fvEXT, program, location, count, transpose, value);
 }
-void API_ENTRY(glProgramUniformMatrix3fvEXT)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {
+void API_ENTRY(glProgramUniformMatrix3fvEXT)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     CALL_GL_API(glProgramUniformMatrix3fvEXT, program, location, count, transpose, value);
 }
-void API_ENTRY(glProgramUniformMatrix4fvEXT)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {
+void API_ENTRY(glProgramUniformMatrix4fvEXT)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     CALL_GL_API(glProgramUniformMatrix4fvEXT, program, location, count, transpose, value);
 }
+void API_ENTRY(glUseProgramStagesEXT)(GLuint pipeline, GLbitfield stages, GLuint program) {
+    CALL_GL_API(glUseProgramStagesEXT, pipeline, stages, program);
+}
 void API_ENTRY(glValidateProgramPipelineEXT)(GLuint pipeline) {
     CALL_GL_API(glValidateProgramPipelineEXT, pipeline);
 }
-void API_ENTRY(glGetProgramPipelineInfoLogEXT)(GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog) {
-    CALL_GL_API(glGetProgramPipelineInfoLogEXT, pipeline, bufSize, length, infoLog);
+void API_ENTRY(glProgramUniform1uiEXT)(GLuint program, GLint location, GLuint v0) {
+    CALL_GL_API(glProgramUniform1uiEXT, program, location, v0);
+}
+void API_ENTRY(glProgramUniform2uiEXT)(GLuint program, GLint location, GLuint v0, GLuint v1) {
+    CALL_GL_API(glProgramUniform2uiEXT, program, location, v0, v1);
+}
+void API_ENTRY(glProgramUniform3uiEXT)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2) {
+    CALL_GL_API(glProgramUniform3uiEXT, program, location, v0, v1, v2);
+}
+void API_ENTRY(glProgramUniform4uiEXT)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) {
+    CALL_GL_API(glProgramUniform4uiEXT, program, location, v0, v1, v2, v3);
+}
+void API_ENTRY(glProgramUniform1uivEXT)(GLuint program, GLint location, GLsizei count, const GLuint * value) {
+    CALL_GL_API(glProgramUniform1uivEXT, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform2uivEXT)(GLuint program, GLint location, GLsizei count, const GLuint * value) {
+    CALL_GL_API(glProgramUniform2uivEXT, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform3uivEXT)(GLuint program, GLint location, GLsizei count, const GLuint * value) {
+    CALL_GL_API(glProgramUniform3uivEXT, program, location, count, value);
+}
+void API_ENTRY(glProgramUniform4uivEXT)(GLuint program, GLint location, GLsizei count, const GLuint * value) {
+    CALL_GL_API(glProgramUniform4uivEXT, program, location, count, value);
+}
+void API_ENTRY(glProgramUniformMatrix2x3fvEXT)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glProgramUniformMatrix2x3fvEXT, program, location, count, transpose, value);
+}
+void API_ENTRY(glProgramUniformMatrix3x2fvEXT)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glProgramUniformMatrix3x2fvEXT, program, location, count, transpose, value);
+}
+void API_ENTRY(glProgramUniformMatrix2x4fvEXT)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glProgramUniformMatrix2x4fvEXT, program, location, count, transpose, value);
+}
+void API_ENTRY(glProgramUniformMatrix4x2fvEXT)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glProgramUniformMatrix4x2fvEXT, program, location, count, transpose, value);
+}
+void API_ENTRY(glProgramUniformMatrix3x4fvEXT)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glProgramUniformMatrix3x4fvEXT, program, location, count, transpose, value);
+}
+void API_ENTRY(glProgramUniformMatrix4x3fvEXT)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glProgramUniformMatrix4x3fvEXT, program, location, count, transpose, value);
+}
+void API_ENTRY(glPatchParameteriEXT)(GLenum pname, GLint value) {
+    CALL_GL_API(glPatchParameteriEXT, pname, value);
+}
+void API_ENTRY(glTexParameterIivEXT)(GLenum target, GLenum pname, const GLint * params) {
+    CALL_GL_API(glTexParameterIivEXT, target, pname, params);
+}
+void API_ENTRY(glTexParameterIuivEXT)(GLenum target, GLenum pname, const GLuint * params) {
+    CALL_GL_API(glTexParameterIuivEXT, target, pname, params);
+}
+void API_ENTRY(glGetTexParameterIivEXT)(GLenum target, GLenum pname, GLint * params) {
+    CALL_GL_API(glGetTexParameterIivEXT, target, pname, params);
+}
+void API_ENTRY(glGetTexParameterIuivEXT)(GLenum target, GLenum pname, GLuint * params) {
+    CALL_GL_API(glGetTexParameterIuivEXT, target, pname, params);
+}
+void API_ENTRY(glSamplerParameterIivEXT)(GLuint sampler, GLenum pname, const GLint * param) {
+    CALL_GL_API(glSamplerParameterIivEXT, sampler, pname, param);
+}
+void API_ENTRY(glSamplerParameterIuivEXT)(GLuint sampler, GLenum pname, const GLuint * param) {
+    CALL_GL_API(glSamplerParameterIuivEXT, sampler, pname, param);
+}
+void API_ENTRY(glGetSamplerParameterIivEXT)(GLuint sampler, GLenum pname, GLint * params) {
+    CALL_GL_API(glGetSamplerParameterIivEXT, sampler, pname, params);
+}
+void API_ENTRY(glGetSamplerParameterIuivEXT)(GLuint sampler, GLenum pname, GLuint * params) {
+    CALL_GL_API(glGetSamplerParameterIuivEXT, sampler, pname, params);
+}
+void API_ENTRY(glTexBufferEXT)(GLenum target, GLenum internalformat, GLuint buffer) {
+    CALL_GL_API(glTexBufferEXT, target, internalformat, buffer);
+}
+void API_ENTRY(glTexBufferRangeEXT)(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size) {
+    CALL_GL_API(glTexBufferRangeEXT, target, internalformat, buffer, offset, size);
 }
 void API_ENTRY(glTexStorage1DEXT)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width) {
     CALL_GL_API(glTexStorage1DEXT, target, levels, internalformat, width);
@@ -265,25 +490,73 @@
 void API_ENTRY(glTextureStorage3DEXT)(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) {
     CALL_GL_API(glTextureStorage3DEXT, texture, target, levels, internalformat, width, height, depth);
 }
+void API_ENTRY(glTextureViewEXT)(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers) {
+    CALL_GL_API(glTextureViewEXT, texture, target, origtexture, internalformat, minlevel, numlevels, minlayer, numlayers);
+}
 void API_ENTRY(glRenderbufferStorageMultisampleIMG)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
     CALL_GL_API(glRenderbufferStorageMultisampleIMG, target, samples, internalformat, width, height);
 }
 void API_ENTRY(glFramebufferTexture2DMultisampleIMG)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) {
     CALL_GL_API(glFramebufferTexture2DMultisampleIMG, target, attachment, textarget, texture, level, samples);
 }
+void API_ENTRY(glBeginPerfQueryINTEL)(GLuint queryHandle) {
+    CALL_GL_API(glBeginPerfQueryINTEL, queryHandle);
+}
+void API_ENTRY(glCreatePerfQueryINTEL)(GLuint queryId, GLuint * queryHandle) {
+    CALL_GL_API(glCreatePerfQueryINTEL, queryId, queryHandle);
+}
+void API_ENTRY(glDeletePerfQueryINTEL)(GLuint queryHandle) {
+    CALL_GL_API(glDeletePerfQueryINTEL, queryHandle);
+}
+void API_ENTRY(glEndPerfQueryINTEL)(GLuint queryHandle) {
+    CALL_GL_API(glEndPerfQueryINTEL, queryHandle);
+}
+void API_ENTRY(glGetFirstPerfQueryIdINTEL)(GLuint * queryId) {
+    CALL_GL_API(glGetFirstPerfQueryIdINTEL, queryId);
+}
+void API_ENTRY(glGetNextPerfQueryIdINTEL)(GLuint queryId, GLuint * nextQueryId) {
+    CALL_GL_API(glGetNextPerfQueryIdINTEL, queryId, nextQueryId);
+}
+void API_ENTRY(glGetPerfCounterInfoINTEL)(GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar * counterName, GLuint counterDescLength, GLchar * counterDesc, GLuint * counterOffset, GLuint * counterDataSize, GLuint * counterTypeEnum, GLuint * counterDataTypeEnum, GLuint64 * rawCounterMaxValue) {
+    CALL_GL_API(glGetPerfCounterInfoINTEL, queryId, counterId, counterNameLength, counterName, counterDescLength, counterDesc, counterOffset, counterDataSize, counterTypeEnum, counterDataTypeEnum, rawCounterMaxValue);
+}
+void API_ENTRY(glGetPerfQueryDataINTEL)(GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid * data, GLuint * bytesWritten) {
+    CALL_GL_API(glGetPerfQueryDataINTEL, queryHandle, flags, dataSize, data, bytesWritten);
+}
+void API_ENTRY(glGetPerfQueryIdByNameINTEL)(GLchar * queryName, GLuint * queryId) {
+    CALL_GL_API(glGetPerfQueryIdByNameINTEL, queryName, queryId);
+}
+void API_ENTRY(glGetPerfQueryInfoINTEL)(GLuint queryId, GLuint queryNameLength, GLchar * queryName, GLuint * dataSize, GLuint * noCounters, GLuint * noInstances, GLuint * capsMask) {
+    CALL_GL_API(glGetPerfQueryInfoINTEL, queryId, queryNameLength, queryName, dataSize, noCounters, noInstances, capsMask);
+}
+void API_ENTRY(glBlendParameteriNV)(GLenum pname, GLint value) {
+    CALL_GL_API(glBlendParameteriNV, pname, value);
+}
+void API_ENTRY(glBlendBarrierNV)(void) {
+    CALL_GL_API(glBlendBarrierNV);
+}
+void API_ENTRY(glCopyBufferSubDataNV)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) {
+    CALL_GL_API(glCopyBufferSubDataNV, readTarget, writeTarget, readOffset, writeOffset, size);
+}
 void API_ENTRY(glCoverageMaskNV)(GLboolean mask) {
     CALL_GL_API(glCoverageMaskNV, mask);
 }
 void API_ENTRY(glCoverageOperationNV)(GLenum operation) {
     CALL_GL_API(glCoverageOperationNV, operation);
 }
-void API_ENTRY(glDrawBuffersNV)(GLsizei n, const GLenum *bufs) {
+void API_ENTRY(glDrawBuffersNV)(GLsizei n, const GLenum * bufs) {
     CALL_GL_API(glDrawBuffersNV, n, bufs);
 }
-void API_ENTRY(glDeleteFencesNV)(GLsizei n, const GLuint *fences) {
+void API_ENTRY(glDrawArraysInstancedNV)(GLenum mode, GLint first, GLsizei count, GLsizei primcount) {
+    CALL_GL_API(glDrawArraysInstancedNV, mode, first, count, primcount);
+}
+void API_ENTRY(glDrawElementsInstancedNV)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount) {
+    CALL_GL_API(glDrawElementsInstancedNV, mode, count, type, indices, primcount);
+}
+void API_ENTRY(glDeleteFencesNV)(GLsizei n, const GLuint * fences) {
     CALL_GL_API(glDeleteFencesNV, n, fences);
 }
-void API_ENTRY(glGenFencesNV)(GLsizei n, GLuint *fences) {
+void API_ENTRY(glGenFencesNV)(GLsizei n, GLuint * fences) {
     CALL_GL_API(glGenFencesNV, n, fences);
 }
 GLboolean API_ENTRY(glIsFenceNV)(GLuint fence) {
@@ -292,7 +565,7 @@
 GLboolean API_ENTRY(glTestFenceNV)(GLuint fence) {
     CALL_GL_API_RETURN(glTestFenceNV, fence);
 }
-void API_ENTRY(glGetFenceivNV)(GLuint fence, GLenum pname, GLint *params) {
+void API_ENTRY(glGetFenceivNV)(GLuint fence, GLenum pname, GLint * params) {
     CALL_GL_API(glGetFenceivNV, fence, pname, params);
 }
 void API_ENTRY(glFinishFenceNV)(GLuint fence) {
@@ -301,16 +574,43 @@
 void API_ENTRY(glSetFenceNV)(GLuint fence, GLenum condition) {
     CALL_GL_API(glSetFenceNV, fence, condition);
 }
+void API_ENTRY(glBlitFramebufferNV)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {
+    CALL_GL_API(glBlitFramebufferNV, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
+}
+void API_ENTRY(glRenderbufferStorageMultisampleNV)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
+    CALL_GL_API(glRenderbufferStorageMultisampleNV, target, samples, internalformat, width, height);
+}
+void API_ENTRY(glVertexAttribDivisorNV)(GLuint index, GLuint divisor) {
+    CALL_GL_API(glVertexAttribDivisorNV, index, divisor);
+}
+void API_ENTRY(glUniformMatrix2x3fvNV)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glUniformMatrix2x3fvNV, location, count, transpose, value);
+}
+void API_ENTRY(glUniformMatrix3x2fvNV)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glUniformMatrix3x2fvNV, location, count, transpose, value);
+}
+void API_ENTRY(glUniformMatrix2x4fvNV)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glUniformMatrix2x4fvNV, location, count, transpose, value);
+}
+void API_ENTRY(glUniformMatrix4x2fvNV)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glUniformMatrix4x2fvNV, location, count, transpose, value);
+}
+void API_ENTRY(glUniformMatrix3x4fvNV)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glUniformMatrix3x4fvNV, location, count, transpose, value);
+}
+void API_ENTRY(glUniformMatrix4x3fvNV)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    CALL_GL_API(glUniformMatrix4x3fvNV, location, count, transpose, value);
+}
 void API_ENTRY(glReadBufferNV)(GLenum mode) {
     CALL_GL_API(glReadBufferNV, mode);
 }
 void API_ENTRY(glAlphaFuncQCOM)(GLenum func, GLclampf ref) {
     CALL_GL_API(glAlphaFuncQCOM, func, ref);
 }
-void API_ENTRY(glGetDriverControlsQCOM)(GLint *num, GLsizei size, GLuint *driverControls) {
+void API_ENTRY(glGetDriverControlsQCOM)(GLint * num, GLsizei size, GLuint * driverControls) {
     CALL_GL_API(glGetDriverControlsQCOM, num, size, driverControls);
 }
-void API_ENTRY(glGetDriverControlStringQCOM)(GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString) {
+void API_ENTRY(glGetDriverControlStringQCOM)(GLuint driverControl, GLsizei bufSize, GLsizei * length, GLchar * driverControlString) {
     CALL_GL_API(glGetDriverControlStringQCOM, driverControl, bufSize, length, driverControlString);
 }
 void API_ENTRY(glEnableDriverControlQCOM)(GLuint driverControl) {
@@ -319,40 +619,40 @@
 void API_ENTRY(glDisableDriverControlQCOM)(GLuint driverControl) {
     CALL_GL_API(glDisableDriverControlQCOM, driverControl);
 }
-void API_ENTRY(glExtGetTexturesQCOM)(GLuint *textures, GLint maxTextures, GLint *numTextures) {
+void API_ENTRY(glExtGetTexturesQCOM)(GLuint * textures, GLint maxTextures, GLint * numTextures) {
     CALL_GL_API(glExtGetTexturesQCOM, textures, maxTextures, numTextures);
 }
-void API_ENTRY(glExtGetBuffersQCOM)(GLuint *buffers, GLint maxBuffers, GLint *numBuffers) {
+void API_ENTRY(glExtGetBuffersQCOM)(GLuint * buffers, GLint maxBuffers, GLint * numBuffers) {
     CALL_GL_API(glExtGetBuffersQCOM, buffers, maxBuffers, numBuffers);
 }
-void API_ENTRY(glExtGetRenderbuffersQCOM)(GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers) {
+void API_ENTRY(glExtGetRenderbuffersQCOM)(GLuint * renderbuffers, GLint maxRenderbuffers, GLint * numRenderbuffers) {
     CALL_GL_API(glExtGetRenderbuffersQCOM, renderbuffers, maxRenderbuffers, numRenderbuffers);
 }
-void API_ENTRY(glExtGetFramebuffersQCOM)(GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers) {
+void API_ENTRY(glExtGetFramebuffersQCOM)(GLuint * framebuffers, GLint maxFramebuffers, GLint * numFramebuffers) {
     CALL_GL_API(glExtGetFramebuffersQCOM, framebuffers, maxFramebuffers, numFramebuffers);
 }
-void API_ENTRY(glExtGetTexLevelParameterivQCOM)(GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params) {
+void API_ENTRY(glExtGetTexLevelParameterivQCOM)(GLuint texture, GLenum face, GLint level, GLenum pname, GLint * params) {
     CALL_GL_API(glExtGetTexLevelParameterivQCOM, texture, face, level, pname, params);
 }
 void API_ENTRY(glExtTexObjectStateOverrideiQCOM)(GLenum target, GLenum pname, GLint param) {
     CALL_GL_API(glExtTexObjectStateOverrideiQCOM, target, pname, param);
 }
-void API_ENTRY(glExtGetTexSubImageQCOM)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels) {
+void API_ENTRY(glExtGetTexSubImageQCOM)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void * texels) {
     CALL_GL_API(glExtGetTexSubImageQCOM, target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, texels);
 }
-void API_ENTRY(glExtGetBufferPointervQCOM)(GLenum target, GLvoid **params) {
+void API_ENTRY(glExtGetBufferPointervQCOM)(GLenum target, void ** params) {
     CALL_GL_API(glExtGetBufferPointervQCOM, target, params);
 }
-void API_ENTRY(glExtGetShadersQCOM)(GLuint *shaders, GLint maxShaders, GLint *numShaders) {
+void API_ENTRY(glExtGetShadersQCOM)(GLuint * shaders, GLint maxShaders, GLint * numShaders) {
     CALL_GL_API(glExtGetShadersQCOM, shaders, maxShaders, numShaders);
 }
-void API_ENTRY(glExtGetProgramsQCOM)(GLuint *programs, GLint maxPrograms, GLint *numPrograms) {
+void API_ENTRY(glExtGetProgramsQCOM)(GLuint * programs, GLint maxPrograms, GLint * numPrograms) {
     CALL_GL_API(glExtGetProgramsQCOM, programs, maxPrograms, numPrograms);
 }
 GLboolean API_ENTRY(glExtIsProgramBinaryQCOM)(GLuint program) {
     CALL_GL_API_RETURN(glExtIsProgramBinaryQCOM, program);
 }
-void API_ENTRY(glExtGetProgramBinarySourceQCOM)(GLuint program, GLenum shadertype, GLchar *source, GLint *length) {
+void API_ENTRY(glExtGetProgramBinarySourceQCOM)(GLuint program, GLenum shadertype, GLchar * source, GLint * length) {
     CALL_GL_API(glExtGetProgramBinarySourceQCOM, program, shadertype, source, length);
 }
 void API_ENTRY(glStartTilingQCOM)(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask) {
diff --git a/opengl/libs/GLES2/gl3_api.in b/opengl/libs/GLES2/gl3_api.in
deleted file mode 100644
index 76f4e23..0000000
--- a/opengl/libs/GLES2/gl3_api.in
+++ /dev/null
@@ -1,738 +0,0 @@
-void API_ENTRY(glActiveTexture)(GLenum texture) {
-    CALL_GL_API(glActiveTexture, texture);
-}
-void API_ENTRY(glAttachShader)(GLuint program, GLuint shader) {
-    CALL_GL_API(glAttachShader, program, shader);
-}
-void API_ENTRY(glBindAttribLocation)(GLuint program, GLuint index, const GLchar* name) {
-    CALL_GL_API(glBindAttribLocation, program, index, name);
-}
-void API_ENTRY(glBindBuffer)(GLenum target, GLuint buffer) {
-    CALL_GL_API(glBindBuffer, target, buffer);
-}
-void API_ENTRY(glBindFramebuffer)(GLenum target, GLuint framebuffer) {
-    CALL_GL_API(glBindFramebuffer, target, framebuffer);
-}
-void API_ENTRY(glBindRenderbuffer)(GLenum target, GLuint renderbuffer) {
-    CALL_GL_API(glBindRenderbuffer, target, renderbuffer);
-}
-void API_ENTRY(glBindTexture)(GLenum target, GLuint texture) {
-    CALL_GL_API(glBindTexture, target, texture);
-}
-void API_ENTRY(glBlendColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
-    CALL_GL_API(glBlendColor, red, green, blue, alpha);
-}
-void API_ENTRY(glBlendEquation)(GLenum mode) {
-    CALL_GL_API(glBlendEquation, mode);
-}
-void API_ENTRY(glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha) {
-    CALL_GL_API(glBlendEquationSeparate, modeRGB, modeAlpha);
-}
-void API_ENTRY(glBlendFunc)(GLenum sfactor, GLenum dfactor) {
-    CALL_GL_API(glBlendFunc, sfactor, dfactor);
-}
-void API_ENTRY(glBlendFuncSeparate)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) {
-    CALL_GL_API(glBlendFuncSeparate, srcRGB, dstRGB, srcAlpha, dstAlpha);
-}
-void API_ENTRY(glBufferData)(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) {
-    CALL_GL_API(glBufferData, target, size, data, usage);
-}
-void API_ENTRY(glBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) {
-    CALL_GL_API(glBufferSubData, target, offset, size, data);
-}
-GLenum API_ENTRY(glCheckFramebufferStatus)(GLenum target) {
-    CALL_GL_API_RETURN(glCheckFramebufferStatus, target);
-}
-void API_ENTRY(glClear)(GLbitfield mask) {
-    CALL_GL_API(glClear, mask);
-}
-void API_ENTRY(glClearColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
-    CALL_GL_API(glClearColor, red, green, blue, alpha);
-}
-void API_ENTRY(glClearDepthf)(GLfloat depth) {
-    CALL_GL_API(glClearDepthf, depth);
-}
-void API_ENTRY(glClearStencil)(GLint s) {
-    CALL_GL_API(glClearStencil, s);
-}
-void API_ENTRY(glColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {
-    CALL_GL_API(glColorMask, red, green, blue, alpha);
-}
-void API_ENTRY(glCompileShader)(GLuint shader) {
-    CALL_GL_API(glCompileShader, shader);
-}
-void API_ENTRY(glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data) {
-    CALL_GL_API(glCompressedTexImage2D, target, level, internalformat, width, height, border, imageSize, data);
-}
-void API_ENTRY(glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data) {
-    CALL_GL_API(glCompressedTexSubImage2D, target, level, xoffset, yoffset, width, height, format, imageSize, data);
-}
-void API_ENTRY(glCopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
-    CALL_GL_API(glCopyTexImage2D, target, level, internalformat, x, y, width, height, border);
-}
-void API_ENTRY(glCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
-    CALL_GL_API(glCopyTexSubImage2D, target, level, xoffset, yoffset, x, y, width, height);
-}
-GLuint API_ENTRY(glCreateProgram)(void) {
-    CALL_GL_API_RETURN(glCreateProgram);
-}
-GLuint API_ENTRY(glCreateShader)(GLenum type) {
-    CALL_GL_API_RETURN(glCreateShader, type);
-}
-void API_ENTRY(glCullFace)(GLenum mode) {
-    CALL_GL_API(glCullFace, mode);
-}
-void API_ENTRY(glDeleteBuffers)(GLsizei n, const GLuint* buffers) {
-    CALL_GL_API(glDeleteBuffers, n, buffers);
-}
-void API_ENTRY(glDeleteFramebuffers)(GLsizei n, const GLuint* framebuffers) {
-    CALL_GL_API(glDeleteFramebuffers, n, framebuffers);
-}
-void API_ENTRY(glDeleteProgram)(GLuint program) {
-    CALL_GL_API(glDeleteProgram, program);
-}
-void API_ENTRY(glDeleteRenderbuffers)(GLsizei n, const GLuint* renderbuffers) {
-    CALL_GL_API(glDeleteRenderbuffers, n, renderbuffers);
-}
-void API_ENTRY(glDeleteShader)(GLuint shader) {
-    CALL_GL_API(glDeleteShader, shader);
-}
-void API_ENTRY(glDeleteTextures)(GLsizei n, const GLuint* textures) {
-    CALL_GL_API(glDeleteTextures, n, textures);
-}
-void API_ENTRY(glDepthFunc)(GLenum func) {
-    CALL_GL_API(glDepthFunc, func);
-}
-void API_ENTRY(glDepthMask)(GLboolean flag) {
-    CALL_GL_API(glDepthMask, flag);
-}
-void API_ENTRY(glDepthRangef)(GLfloat n, GLfloat f) {
-    CALL_GL_API(glDepthRangef, n, f);
-}
-void API_ENTRY(glDetachShader)(GLuint program, GLuint shader) {
-    CALL_GL_API(glDetachShader, program, shader);
-}
-void API_ENTRY(glDisable)(GLenum cap) {
-    CALL_GL_API(glDisable, cap);
-}
-void API_ENTRY(glDisableVertexAttribArray)(GLuint index) {
-    CALL_GL_API(glDisableVertexAttribArray, index);
-}
-void API_ENTRY(glDrawArrays)(GLenum mode, GLint first, GLsizei count) {
-    CALL_GL_API(glDrawArrays, mode, first, count);
-}
-void API_ENTRY(glDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) {
-    CALL_GL_API(glDrawElements, mode, count, type, indices);
-}
-void API_ENTRY(glEnable)(GLenum cap) {
-    CALL_GL_API(glEnable, cap);
-}
-void API_ENTRY(glEnableVertexAttribArray)(GLuint index) {
-    CALL_GL_API(glEnableVertexAttribArray, index);
-}
-void API_ENTRY(glFinish)(void) {
-    CALL_GL_API(glFinish);
-}
-void API_ENTRY(glFlush)(void) {
-    CALL_GL_API(glFlush);
-}
-void API_ENTRY(glFramebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) {
-    CALL_GL_API(glFramebufferRenderbuffer, target, attachment, renderbuffertarget, renderbuffer);
-}
-void API_ENTRY(glFramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
-    CALL_GL_API(glFramebufferTexture2D, target, attachment, textarget, texture, level);
-}
-void API_ENTRY(glFrontFace)(GLenum mode) {
-    CALL_GL_API(glFrontFace, mode);
-}
-void API_ENTRY(glGenBuffers)(GLsizei n, GLuint* buffers) {
-    CALL_GL_API(glGenBuffers, n, buffers);
-}
-void API_ENTRY(glGenerateMipmap)(GLenum target) {
-    CALL_GL_API(glGenerateMipmap, target);
-}
-void API_ENTRY(glGenFramebuffers)(GLsizei n, GLuint* framebuffers) {
-    CALL_GL_API(glGenFramebuffers, n, framebuffers);
-}
-void API_ENTRY(glGenRenderbuffers)(GLsizei n, GLuint* renderbuffers) {
-    CALL_GL_API(glGenRenderbuffers, n, renderbuffers);
-}
-void API_ENTRY(glGenTextures)(GLsizei n, GLuint* textures) {
-    CALL_GL_API(glGenTextures, n, textures);
-}
-void API_ENTRY(glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) {
-    CALL_GL_API(glGetActiveAttrib, program, index, bufsize, length, size, type, name);
-}
-void API_ENTRY(glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) {
-    CALL_GL_API(glGetActiveUniform, program, index, bufsize, length, size, type, name);
-}
-void API_ENTRY(glGetAttachedShaders)(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) {
-    CALL_GL_API(glGetAttachedShaders, program, maxcount, count, shaders);
-}
-GLint API_ENTRY(glGetAttribLocation)(GLuint program, const GLchar* name) {
-    CALL_GL_API_RETURN(glGetAttribLocation, program, name);
-}
-void API_ENTRY(glGetBooleanv)(GLenum pname, GLboolean* params) {
-    CALL_GL_API(glGetBooleanv, pname, params);
-}
-void API_ENTRY(glGetBufferParameteriv)(GLenum target, GLenum pname, GLint* params) {
-    CALL_GL_API(glGetBufferParameteriv, target, pname, params);
-}
-GLenum API_ENTRY(glGetError)(void) {
-    CALL_GL_API_RETURN(glGetError);
-}
-void API_ENTRY(glGetFloatv)(GLenum pname, GLfloat* params) {
-    CALL_GL_API(glGetFloatv, pname, params);
-}
-void API_ENTRY(glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint* params) {
-    CALL_GL_API(glGetFramebufferAttachmentParameteriv, target, attachment, pname, params);
-}
-void API_ENTRY(glGetIntegerv)(GLenum pname, GLint* params) {
-    CALL_GL_API(glGetIntegerv, pname, params);
-}
-void API_ENTRY(glGetProgramiv)(GLuint program, GLenum pname, GLint* params) {
-    CALL_GL_API(glGetProgramiv, program, pname, params);
-}
-void API_ENTRY(glGetProgramInfoLog)(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) {
-    CALL_GL_API(glGetProgramInfoLog, program, bufsize, length, infolog);
-}
-void API_ENTRY(glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint* params) {
-    CALL_GL_API(glGetRenderbufferParameteriv, target, pname, params);
-}
-void API_ENTRY(glGetShaderiv)(GLuint shader, GLenum pname, GLint* params) {
-    CALL_GL_API(glGetShaderiv, shader, pname, params);
-}
-void API_ENTRY(glGetShaderInfoLog)(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) {
-    CALL_GL_API(glGetShaderInfoLog, shader, bufsize, length, infolog);
-}
-void API_ENTRY(glGetShaderPrecisionFormat)(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
-    CALL_GL_API(glGetShaderPrecisionFormat, shadertype, precisiontype, range, precision);
-}
-void API_ENTRY(glGetShaderSource)(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) {
-    CALL_GL_API(glGetShaderSource, shader, bufsize, length, source);
-}
-const GLubyte* API_ENTRY(__glGetString)(GLenum name) {
-    CALL_GL_API_RETURN(glGetString, name);
-}
-void API_ENTRY(glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat* params) {
-    CALL_GL_API(glGetTexParameterfv, target, pname, params);
-}
-void API_ENTRY(glGetTexParameteriv)(GLenum target, GLenum pname, GLint* params) {
-    CALL_GL_API(glGetTexParameteriv, target, pname, params);
-}
-void API_ENTRY(glGetUniformfv)(GLuint program, GLint location, GLfloat* params) {
-    CALL_GL_API(glGetUniformfv, program, location, params);
-}
-void API_ENTRY(glGetUniformiv)(GLuint program, GLint location, GLint* params) {
-    CALL_GL_API(glGetUniformiv, program, location, params);
-}
-GLint API_ENTRY(glGetUniformLocation)(GLuint program, const GLchar* name) {
-    CALL_GL_API_RETURN(glGetUniformLocation, program, name);
-}
-void API_ENTRY(glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat* params) {
-    CALL_GL_API(glGetVertexAttribfv, index, pname, params);
-}
-void API_ENTRY(glGetVertexAttribiv)(GLuint index, GLenum pname, GLint* params) {
-    CALL_GL_API(glGetVertexAttribiv, index, pname, params);
-}
-void API_ENTRY(glGetVertexAttribPointerv)(GLuint index, GLenum pname, GLvoid** pointer) {
-    CALL_GL_API(glGetVertexAttribPointerv, index, pname, pointer);
-}
-void API_ENTRY(glHint)(GLenum target, GLenum mode) {
-    CALL_GL_API(glHint, target, mode);
-}
-GLboolean API_ENTRY(glIsBuffer)(GLuint buffer) {
-    CALL_GL_API_RETURN(glIsBuffer, buffer);
-}
-GLboolean API_ENTRY(glIsEnabled)(GLenum cap) {
-    CALL_GL_API_RETURN(glIsEnabled, cap);
-}
-GLboolean API_ENTRY(glIsFramebuffer)(GLuint framebuffer) {
-    CALL_GL_API_RETURN(glIsFramebuffer, framebuffer);
-}
-GLboolean API_ENTRY(glIsProgram)(GLuint program) {
-    CALL_GL_API_RETURN(glIsProgram, program);
-}
-GLboolean API_ENTRY(glIsRenderbuffer)(GLuint renderbuffer) {
-    CALL_GL_API_RETURN(glIsRenderbuffer, renderbuffer);
-}
-GLboolean API_ENTRY(glIsShader)(GLuint shader) {
-    CALL_GL_API_RETURN(glIsShader, shader);
-}
-GLboolean API_ENTRY(glIsTexture)(GLuint texture) {
-    CALL_GL_API_RETURN(glIsTexture, texture);
-}
-void API_ENTRY(glLineWidth)(GLfloat width) {
-    CALL_GL_API(glLineWidth, width);
-}
-void API_ENTRY(glLinkProgram)(GLuint program) {
-    CALL_GL_API(glLinkProgram, program);
-}
-void API_ENTRY(glPixelStorei)(GLenum pname, GLint param) {
-    CALL_GL_API(glPixelStorei, pname, param);
-}
-void API_ENTRY(glPolygonOffset)(GLfloat factor, GLfloat units) {
-    CALL_GL_API(glPolygonOffset, factor, units);
-}
-void API_ENTRY(glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) {
-    CALL_GL_API(glReadPixels, x, y, width, height, format, type, pixels);
-}
-void API_ENTRY(glReleaseShaderCompiler)(void) {
-    CALL_GL_API(glReleaseShaderCompiler);
-}
-void API_ENTRY(glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) {
-    CALL_GL_API(glRenderbufferStorage, target, internalformat, width, height);
-}
-void API_ENTRY(glSampleCoverage)(GLfloat value, GLboolean invert) {
-    CALL_GL_API(glSampleCoverage, value, invert);
-}
-void API_ENTRY(glScissor)(GLint x, GLint y, GLsizei width, GLsizei height) {
-    CALL_GL_API(glScissor, x, y, width, height);
-}
-void API_ENTRY(glShaderBinary)(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length) {
-    CALL_GL_API(glShaderBinary, n, shaders, binaryformat, binary, length);
-}
-void API_ENTRY(glShaderSource)(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) {
-    CALL_GL_API(glShaderSource, shader, count, string, length);
-}
-void API_ENTRY(glStencilFunc)(GLenum func, GLint ref, GLuint mask) {
-    CALL_GL_API(glStencilFunc, func, ref, mask);
-}
-void API_ENTRY(glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask) {
-    CALL_GL_API(glStencilFuncSeparate, face, func, ref, mask);
-}
-void API_ENTRY(glStencilMask)(GLuint mask) {
-    CALL_GL_API(glStencilMask, mask);
-}
-void API_ENTRY(glStencilMaskSeparate)(GLenum face, GLuint mask) {
-    CALL_GL_API(glStencilMaskSeparate, face, mask);
-}
-void API_ENTRY(glStencilOp)(GLenum fail, GLenum zfail, GLenum zpass) {
-    CALL_GL_API(glStencilOp, fail, zfail, zpass);
-}
-void API_ENTRY(glStencilOpSeparate)(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) {
-    CALL_GL_API(glStencilOpSeparate, face, fail, zfail, zpass);
-}
-void API_ENTRY(glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels) {
-    CALL_GL_API(glTexImage2D, target, level, internalformat, width, height, border, format, type, pixels);
-}
-void API_ENTRY(glTexParameterf)(GLenum target, GLenum pname, GLfloat param) {
-    CALL_GL_API(glTexParameterf, target, pname, param);
-}
-void API_ENTRY(glTexParameterfv)(GLenum target, GLenum pname, const GLfloat* params) {
-    CALL_GL_API(glTexParameterfv, target, pname, params);
-}
-void API_ENTRY(glTexParameteri)(GLenum target, GLenum pname, GLint param) {
-    CALL_GL_API(glTexParameteri, target, pname, param);
-}
-void API_ENTRY(glTexParameteriv)(GLenum target, GLenum pname, const GLint* params) {
-    CALL_GL_API(glTexParameteriv, target, pname, params);
-}
-void API_ENTRY(glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) {
-    CALL_GL_API(glTexSubImage2D, target, level, xoffset, yoffset, width, height, format, type, pixels);
-}
-void API_ENTRY(glUniform1f)(GLint location, GLfloat x) {
-    CALL_GL_API(glUniform1f, location, x);
-}
-void API_ENTRY(glUniform1fv)(GLint location, GLsizei count, const GLfloat* v) {
-    CALL_GL_API(glUniform1fv, location, count, v);
-}
-void API_ENTRY(glUniform1i)(GLint location, GLint x) {
-    CALL_GL_API(glUniform1i, location, x);
-}
-void API_ENTRY(glUniform1iv)(GLint location, GLsizei count, const GLint* v) {
-    CALL_GL_API(glUniform1iv, location, count, v);
-}
-void API_ENTRY(glUniform2f)(GLint location, GLfloat x, GLfloat y) {
-    CALL_GL_API(glUniform2f, location, x, y);
-}
-void API_ENTRY(glUniform2fv)(GLint location, GLsizei count, const GLfloat* v) {
-    CALL_GL_API(glUniform2fv, location, count, v);
-}
-void API_ENTRY(glUniform2i)(GLint location, GLint x, GLint y) {
-    CALL_GL_API(glUniform2i, location, x, y);
-}
-void API_ENTRY(glUniform2iv)(GLint location, GLsizei count, const GLint* v) {
-    CALL_GL_API(glUniform2iv, location, count, v);
-}
-void API_ENTRY(glUniform3f)(GLint location, GLfloat x, GLfloat y, GLfloat z) {
-    CALL_GL_API(glUniform3f, location, x, y, z);
-}
-void API_ENTRY(glUniform3fv)(GLint location, GLsizei count, const GLfloat* v) {
-    CALL_GL_API(glUniform3fv, location, count, v);
-}
-void API_ENTRY(glUniform3i)(GLint location, GLint x, GLint y, GLint z) {
-    CALL_GL_API(glUniform3i, location, x, y, z);
-}
-void API_ENTRY(glUniform3iv)(GLint location, GLsizei count, const GLint* v) {
-    CALL_GL_API(glUniform3iv, location, count, v);
-}
-void API_ENTRY(glUniform4f)(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
-    CALL_GL_API(glUniform4f, location, x, y, z, w);
-}
-void API_ENTRY(glUniform4fv)(GLint location, GLsizei count, const GLfloat* v) {
-    CALL_GL_API(glUniform4fv, location, count, v);
-}
-void API_ENTRY(glUniform4i)(GLint location, GLint x, GLint y, GLint z, GLint w) {
-    CALL_GL_API(glUniform4i, location, x, y, z, w);
-}
-void API_ENTRY(glUniform4iv)(GLint location, GLsizei count, const GLint* v) {
-    CALL_GL_API(glUniform4iv, location, count, v);
-}
-void API_ENTRY(glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
-    CALL_GL_API(glUniformMatrix2fv, location, count, transpose, value);
-}
-void API_ENTRY(glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
-    CALL_GL_API(glUniformMatrix3fv, location, count, transpose, value);
-}
-void API_ENTRY(glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
-    CALL_GL_API(glUniformMatrix4fv, location, count, transpose, value);
-}
-void API_ENTRY(glUseProgram)(GLuint program) {
-    CALL_GL_API(glUseProgram, program);
-}
-void API_ENTRY(glValidateProgram)(GLuint program) {
-    CALL_GL_API(glValidateProgram, program);
-}
-void API_ENTRY(glVertexAttrib1f)(GLuint indx, GLfloat x) {
-    CALL_GL_API(glVertexAttrib1f, indx, x);
-}
-void API_ENTRY(glVertexAttrib1fv)(GLuint indx, const GLfloat* values) {
-    CALL_GL_API(glVertexAttrib1fv, indx, values);
-}
-void API_ENTRY(glVertexAttrib2f)(GLuint indx, GLfloat x, GLfloat y) {
-    CALL_GL_API(glVertexAttrib2f, indx, x, y);
-}
-void API_ENTRY(glVertexAttrib2fv)(GLuint indx, const GLfloat* values) {
-    CALL_GL_API(glVertexAttrib2fv, indx, values);
-}
-void API_ENTRY(glVertexAttrib3f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z) {
-    CALL_GL_API(glVertexAttrib3f, indx, x, y, z);
-}
-void API_ENTRY(glVertexAttrib3fv)(GLuint indx, const GLfloat* values) {
-    CALL_GL_API(glVertexAttrib3fv, indx, values);
-}
-void API_ENTRY(glVertexAttrib4f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
-    CALL_GL_API(glVertexAttrib4f, indx, x, y, z, w);
-}
-void API_ENTRY(glVertexAttrib4fv)(GLuint indx, const GLfloat* values) {
-    CALL_GL_API(glVertexAttrib4fv, indx, values);
-}
-void API_ENTRY(glVertexAttribPointer)(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr) {
-    CALL_GL_API(glVertexAttribPointer, indx, size, type, normalized, stride, ptr);
-}
-void API_ENTRY(glViewport)(GLint x, GLint y, GLsizei width, GLsizei height) {
-    CALL_GL_API(glViewport, x, y, width, height);
-}
-void API_ENTRY(glReadBuffer)(GLenum mode) {
-    CALL_GL_API(glReadBuffer, mode);
-}
-void API_ENTRY(glDrawRangeElements)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) {
-    CALL_GL_API(glDrawRangeElements, mode, start, end, count, type, indices);
-}
-void API_ENTRY(glTexImage3D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) {
-    CALL_GL_API(glTexImage3D, target, level, internalformat, width, height, depth, border, format, type, pixels);
-}
-void API_ENTRY(glTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) {
-    CALL_GL_API(glTexSubImage3D, target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
-}
-void API_ENTRY(glCopyTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
-    CALL_GL_API(glCopyTexSubImage3D, target, level, xoffset, yoffset, zoffset, x, y, width, height);
-}
-void API_ENTRY(glCompressedTexImage3D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) {
-    CALL_GL_API(glCompressedTexImage3D, target, level, internalformat, width, height, depth, border, imageSize, data);
-}
-void API_ENTRY(glCompressedTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) {
-    CALL_GL_API(glCompressedTexSubImage3D, target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
-}
-void API_ENTRY(glGenQueries)(GLsizei n, GLuint* ids) {
-    CALL_GL_API(glGenQueries, n, ids);
-}
-void API_ENTRY(glDeleteQueries)(GLsizei n, const GLuint* ids) {
-    CALL_GL_API(glDeleteQueries, n, ids);
-}
-GLboolean API_ENTRY(glIsQuery)(GLuint id) {
-    CALL_GL_API_RETURN(glIsQuery, id);
-}
-void API_ENTRY(glBeginQuery)(GLenum target, GLuint id) {
-    CALL_GL_API(glBeginQuery, target, id);
-}
-void API_ENTRY(glEndQuery)(GLenum target) {
-    CALL_GL_API(glEndQuery, target);
-}
-void API_ENTRY(glGetQueryiv)(GLenum target, GLenum pname, GLint* params) {
-    CALL_GL_API(glGetQueryiv, target, pname, params);
-}
-void API_ENTRY(glGetQueryObjectuiv)(GLuint id, GLenum pname, GLuint* params) {
-    CALL_GL_API(glGetQueryObjectuiv, id, pname, params);
-}
-GLboolean API_ENTRY(glUnmapBuffer)(GLenum target) {
-    CALL_GL_API_RETURN(glUnmapBuffer, target);
-}
-void API_ENTRY(glGetBufferPointerv)(GLenum target, GLenum pname, GLvoid** params) {
-    CALL_GL_API(glGetBufferPointerv, target, pname, params);
-}
-void API_ENTRY(glDrawBuffers)(GLsizei n, const GLenum* bufs) {
-    CALL_GL_API(glDrawBuffers, n, bufs);
-}
-void API_ENTRY(glUniformMatrix2x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
-    CALL_GL_API(glUniformMatrix2x3fv, location, count, transpose, value);
-}
-void API_ENTRY(glUniformMatrix3x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
-    CALL_GL_API(glUniformMatrix3x2fv, location, count, transpose, value);
-}
-void API_ENTRY(glUniformMatrix2x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
-    CALL_GL_API(glUniformMatrix2x4fv, location, count, transpose, value);
-}
-void API_ENTRY(glUniformMatrix4x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
-    CALL_GL_API(glUniformMatrix4x2fv, location, count, transpose, value);
-}
-void API_ENTRY(glUniformMatrix3x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
-    CALL_GL_API(glUniformMatrix3x4fv, location, count, transpose, value);
-}
-void API_ENTRY(glUniformMatrix4x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
-    CALL_GL_API(glUniformMatrix4x3fv, location, count, transpose, value);
-}
-void API_ENTRY(glBlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {
-    CALL_GL_API(glBlitFramebuffer, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
-}
-void API_ENTRY(glRenderbufferStorageMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
-    CALL_GL_API(glRenderbufferStorageMultisample, target, samples, internalformat, width, height);
-}
-void API_ENTRY(glFramebufferTextureLayer)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) {
-    CALL_GL_API(glFramebufferTextureLayer, target, attachment, texture, level, layer);
-}
-GLvoid* API_ENTRY(glMapBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
-    CALL_GL_API_RETURN(glMapBufferRange, target, offset, length, access);
-}
-void API_ENTRY(glFlushMappedBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length) {
-    CALL_GL_API(glFlushMappedBufferRange, target, offset, length);
-}
-void API_ENTRY(glBindVertexArray)(GLuint array) {
-    CALL_GL_API(glBindVertexArray, array);
-}
-void API_ENTRY(glDeleteVertexArrays)(GLsizei n, const GLuint* arrays) {
-    CALL_GL_API(glDeleteVertexArrays, n, arrays);
-}
-void API_ENTRY(glGenVertexArrays)(GLsizei n, GLuint* arrays) {
-    CALL_GL_API(glGenVertexArrays, n, arrays);
-}
-GLboolean API_ENTRY(glIsVertexArray)(GLuint array) {
-    CALL_GL_API_RETURN(glIsVertexArray, array);
-}
-void API_ENTRY(glGetIntegeri_v)(GLenum target, GLuint index, GLint* data) {
-    CALL_GL_API(glGetIntegeri_v, target, index, data);
-}
-void API_ENTRY(glBeginTransformFeedback)(GLenum primitiveMode) {
-    CALL_GL_API(glBeginTransformFeedback, primitiveMode);
-}
-void API_ENTRY(glEndTransformFeedback)(void) {
-    CALL_GL_API(glEndTransformFeedback);
-}
-void API_ENTRY(glBindBufferRange)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) {
-    CALL_GL_API(glBindBufferRange, target, index, buffer, offset, size);
-}
-void API_ENTRY(glBindBufferBase)(GLenum target, GLuint index, GLuint buffer) {
-    CALL_GL_API(glBindBufferBase, target, index, buffer);
-}
-void API_ENTRY(glTransformFeedbackVaryings)(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) {
-    CALL_GL_API(glTransformFeedbackVaryings, program, count, varyings, bufferMode);
-}
-void API_ENTRY(glGetTransformFeedbackVarying)(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) {
-    CALL_GL_API(glGetTransformFeedbackVarying, program, index, bufSize, length, size, type, name);
-}
-void API_ENTRY(glVertexAttribIPointer)(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) {
-    CALL_GL_API(glVertexAttribIPointer, index, size, type, stride, pointer);
-}
-void API_ENTRY(glGetVertexAttribIiv)(GLuint index, GLenum pname, GLint* params) {
-    CALL_GL_API(glGetVertexAttribIiv, index, pname, params);
-}
-void API_ENTRY(glGetVertexAttribIuiv)(GLuint index, GLenum pname, GLuint* params) {
-    CALL_GL_API(glGetVertexAttribIuiv, index, pname, params);
-}
-void API_ENTRY(glVertexAttribI4i)(GLuint index, GLint x, GLint y, GLint z, GLint w) {
-    CALL_GL_API(glVertexAttribI4i, index, x, y, z, w);
-}
-void API_ENTRY(glVertexAttribI4ui)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) {
-    CALL_GL_API(glVertexAttribI4ui, index, x, y, z, w);
-}
-void API_ENTRY(glVertexAttribI4iv)(GLuint index, const GLint* v) {
-    CALL_GL_API(glVertexAttribI4iv, index, v);
-}
-void API_ENTRY(glVertexAttribI4uiv)(GLuint index, const GLuint* v) {
-    CALL_GL_API(glVertexAttribI4uiv, index, v);
-}
-void API_ENTRY(glGetUniformuiv)(GLuint program, GLint location, GLuint* params) {
-    CALL_GL_API(glGetUniformuiv, program, location, params);
-}
-GLint API_ENTRY(glGetFragDataLocation)(GLuint program, const GLchar *name) {
-    CALL_GL_API_RETURN(glGetFragDataLocation, program, name);
-}
-void API_ENTRY(glUniform1ui)(GLint location, GLuint v0) {
-    CALL_GL_API(glUniform1ui, location, v0);
-}
-void API_ENTRY(glUniform2ui)(GLint location, GLuint v0, GLuint v1) {
-    CALL_GL_API(glUniform2ui, location, v0, v1);
-}
-void API_ENTRY(glUniform3ui)(GLint location, GLuint v0, GLuint v1, GLuint v2) {
-    CALL_GL_API(glUniform3ui, location, v0, v1, v2);
-}
-void API_ENTRY(glUniform4ui)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) {
-    CALL_GL_API(glUniform4ui, location, v0, v1, v2, v3);
-}
-void API_ENTRY(glUniform1uiv)(GLint location, GLsizei count, const GLuint* value) {
-    CALL_GL_API(glUniform1uiv, location, count, value);
-}
-void API_ENTRY(glUniform2uiv)(GLint location, GLsizei count, const GLuint* value) {
-    CALL_GL_API(glUniform2uiv, location, count, value);
-}
-void API_ENTRY(glUniform3uiv)(GLint location, GLsizei count, const GLuint* value) {
-    CALL_GL_API(glUniform3uiv, location, count, value);
-}
-void API_ENTRY(glUniform4uiv)(GLint location, GLsizei count, const GLuint* value) {
-    CALL_GL_API(glUniform4uiv, location, count, value);
-}
-void API_ENTRY(glClearBufferiv)(GLenum buffer, GLint drawbuffer, const GLint* value) {
-    CALL_GL_API(glClearBufferiv, buffer, drawbuffer, value);
-}
-void API_ENTRY(glClearBufferuiv)(GLenum buffer, GLint drawbuffer, const GLuint* value) {
-    CALL_GL_API(glClearBufferuiv, buffer, drawbuffer, value);
-}
-void API_ENTRY(glClearBufferfv)(GLenum buffer, GLint drawbuffer, const GLfloat* value) {
-    CALL_GL_API(glClearBufferfv, buffer, drawbuffer, value);
-}
-void API_ENTRY(glClearBufferfi)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) {
-    CALL_GL_API(glClearBufferfi, buffer, drawbuffer, depth, stencil);
-}
-const GLubyte* API_ENTRY(glGetStringi)(GLenum name, GLuint index) {
-    CALL_GL_API_RETURN(glGetStringi, name, index);
-}
-void API_ENTRY(glCopyBufferSubData)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) {
-    CALL_GL_API(glCopyBufferSubData, readTarget, writeTarget, readOffset, writeOffset, size);
-}
-void API_ENTRY(glGetUniformIndices)(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) {
-    CALL_GL_API(glGetUniformIndices, program, uniformCount, uniformNames, uniformIndices);
-}
-void API_ENTRY(glGetActiveUniformsiv)(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) {
-    CALL_GL_API(glGetActiveUniformsiv, program, uniformCount, uniformIndices, pname, params);
-}
-GLuint API_ENTRY(glGetUniformBlockIndex)(GLuint program, const GLchar* uniformBlockName) {
-    CALL_GL_API_RETURN(glGetUniformBlockIndex, program, uniformBlockName);
-}
-void API_ENTRY(glGetActiveUniformBlockiv)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) {
-    CALL_GL_API(glGetActiveUniformBlockiv, program, uniformBlockIndex, pname, params);
-}
-void API_ENTRY(glGetActiveUniformBlockName)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) {
-    CALL_GL_API(glGetActiveUniformBlockName, program, uniformBlockIndex, bufSize, length, uniformBlockName);
-}
-void API_ENTRY(glUniformBlockBinding)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) {
-    CALL_GL_API(glUniformBlockBinding, program, uniformBlockIndex, uniformBlockBinding);
-}
-void API_ENTRY(glDrawArraysInstanced)(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) {
-    CALL_GL_API(glDrawArraysInstanced, mode, first, count, instanceCount);
-}
-void API_ENTRY(glDrawElementsInstanced)(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) {
-    CALL_GL_API(glDrawElementsInstanced, mode, count, type, indices, instanceCount);
-}
-GLsync API_ENTRY(glFenceSync)(GLenum condition, GLbitfield flags) {
-    CALL_GL_API_RETURN(glFenceSync, condition, flags);
-}
-GLboolean API_ENTRY(glIsSync)(GLsync sync) {
-    CALL_GL_API_RETURN(glIsSync, sync);
-}
-void API_ENTRY(glDeleteSync)(GLsync sync) {
-    CALL_GL_API(glDeleteSync, sync);
-}
-GLenum API_ENTRY(glClientWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout) {
-    CALL_GL_API_RETURN(glClientWaitSync, sync, flags, timeout);
-}
-void API_ENTRY(glWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout) {
-    CALL_GL_API(glWaitSync, sync, flags, timeout);
-}
-void API_ENTRY(glGetInteger64v)(GLenum pname, GLint64* params) {
-    CALL_GL_API(glGetInteger64v, pname, params);
-}
-void API_ENTRY(glGetSynciv)(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) {
-    CALL_GL_API(glGetSynciv, sync, pname, bufSize, length, values);
-}
-void API_ENTRY(glGetInteger64i_v)(GLenum target, GLuint index, GLint64* data) {
-    CALL_GL_API(glGetInteger64i_v, target, index, data);
-}
-void API_ENTRY(glGetBufferParameteri64v)(GLenum target, GLenum pname, GLint64* params) {
-    CALL_GL_API(glGetBufferParameteri64v, target, pname, params);
-}
-void API_ENTRY(glGenSamplers)(GLsizei count, GLuint* samplers) {
-    CALL_GL_API(glGenSamplers, count, samplers);
-}
-void API_ENTRY(glDeleteSamplers)(GLsizei count, const GLuint* samplers) {
-    CALL_GL_API(glDeleteSamplers, count, samplers);
-}
-GLboolean API_ENTRY(glIsSampler)(GLuint sampler) {
-    CALL_GL_API_RETURN(glIsSampler, sampler);
-}
-void API_ENTRY(glBindSampler)(GLuint unit, GLuint sampler) {
-    CALL_GL_API(glBindSampler, unit, sampler);
-}
-void API_ENTRY(glSamplerParameteri)(GLuint sampler, GLenum pname, GLint param) {
-    CALL_GL_API(glSamplerParameteri, sampler, pname, param);
-}
-void API_ENTRY(glSamplerParameteriv)(GLuint sampler, GLenum pname, const GLint* param) {
-    CALL_GL_API(glSamplerParameteriv, sampler, pname, param);
-}
-void API_ENTRY(glSamplerParameterf)(GLuint sampler, GLenum pname, GLfloat param) {
-    CALL_GL_API(glSamplerParameterf, sampler, pname, param);
-}
-void API_ENTRY(glSamplerParameterfv)(GLuint sampler, GLenum pname, const GLfloat* param) {
-    CALL_GL_API(glSamplerParameterfv, sampler, pname, param);
-}
-void API_ENTRY(glGetSamplerParameteriv)(GLuint sampler, GLenum pname, GLint* params) {
-    CALL_GL_API(glGetSamplerParameteriv, sampler, pname, params);
-}
-void API_ENTRY(glGetSamplerParameterfv)(GLuint sampler, GLenum pname, GLfloat* params) {
-    CALL_GL_API(glGetSamplerParameterfv, sampler, pname, params);
-}
-void API_ENTRY(glVertexAttribDivisor)(GLuint index, GLuint divisor) {
-    CALL_GL_API(glVertexAttribDivisor, index, divisor);
-}
-void API_ENTRY(glBindTransformFeedback)(GLenum target, GLuint id) {
-    CALL_GL_API(glBindTransformFeedback, target, id);
-}
-void API_ENTRY(glDeleteTransformFeedbacks)(GLsizei n, const GLuint* ids) {
-    CALL_GL_API(glDeleteTransformFeedbacks, n, ids);
-}
-void API_ENTRY(glGenTransformFeedbacks)(GLsizei n, GLuint* ids) {
-    CALL_GL_API(glGenTransformFeedbacks, n, ids);
-}
-GLboolean API_ENTRY(glIsTransformFeedback)(GLuint id) {
-    CALL_GL_API_RETURN(glIsTransformFeedback, id);
-}
-void API_ENTRY(glPauseTransformFeedback)(void) {
-    CALL_GL_API(glPauseTransformFeedback);
-}
-void API_ENTRY(glResumeTransformFeedback)(void) {
-    CALL_GL_API(glResumeTransformFeedback);
-}
-void API_ENTRY(glGetProgramBinary)(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) {
-    CALL_GL_API(glGetProgramBinary, program, bufSize, length, binaryFormat, binary);
-}
-void API_ENTRY(glProgramBinary)(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) {
-    CALL_GL_API(glProgramBinary, program, binaryFormat, binary, length);
-}
-void API_ENTRY(glProgramParameteri)(GLuint program, GLenum pname, GLint value) {
-    CALL_GL_API(glProgramParameteri, program, pname, value);
-}
-void API_ENTRY(glInvalidateFramebuffer)(GLenum target, GLsizei numAttachments, const GLenum* attachments) {
-    CALL_GL_API(glInvalidateFramebuffer, target, numAttachments, attachments);
-}
-void API_ENTRY(glInvalidateSubFramebuffer)(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) {
-    CALL_GL_API(glInvalidateSubFramebuffer, target, numAttachments, attachments, x, y, width, height);
-}
-void API_ENTRY(glTexStorage2D)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) {
-    CALL_GL_API(glTexStorage2D, target, levels, internalformat, width, height);
-}
-void API_ENTRY(glTexStorage3D)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) {
-    CALL_GL_API(glTexStorage3D, target, levels, internalformat, width, height, depth);
-}
-void API_ENTRY(glGetInternalformativ)(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) {
-    CALL_GL_API(glGetInternalformativ, target, internalformat, pname, bufSize, params);
-}
diff --git a/opengl/libs/GLES_CM/gl.cpp b/opengl/libs/GLES_CM/gl.cpp
index 893577b..8bde4e5 100644
--- a/opengl/libs/GLES_CM/gl.cpp
+++ b/opengl/libs/GLES_CM/gl.cpp
@@ -90,80 +90,255 @@
 
 #undef API_ENTRY
 #undef CALL_GL_API
+#undef CALL_GL_API_INTERNAL_CALL
+#undef CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+#undef CALL_GL_API_INTERNAL_DO_RETURN
 #undef CALL_GL_API_RETURN
 
-#if defined(__arm__) && !USE_SLOW_BINDING
+#if USE_SLOW_BINDING
+
+    #define API_ENTRY(_api) _api
+
+    #define CALL_GL_API_INTERNAL_CALL(_api, ...)                         \
+        gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;  \
+        if (_c) return _c->_api(__VA_ARGS__);
+
+    #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE return 0;
+
+    // This stays blank, since void functions will implicitly return, and
+    // all of the other functions will return 0 based on the previous macro.
+    #define CALL_GL_API_INTERNAL_DO_RETURN
+
+#elif defined(__arm__)
 
     #define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n"
 
-    #define API_ENTRY(_api) __attribute__((noinline)) _api
+    #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
 
-    #define CALL_GL_API(_api, ...)                              \
-         asm volatile(                                          \
-            GET_TLS(r12)                                        \
-            "ldr   r12, [r12, %[tls]] \n"                       \
-            "cmp   r12, #0            \n"                       \
-            "ldrne pc,  [r12, %[api]] \n"                       \
-            :                                                   \
-            : [tls] "J"(TLS_SLOT_OPENGL_API*4),                 \
-              [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api))    \
-            :                                                   \
-            );
+    #define CALL_GL_API_INTERNAL_CALL(_api, ...)                 \
+        asm volatile(                                            \
+            GET_TLS(r12)                                         \
+            "ldr   r12, [r12, %[tls]] \n"                        \
+            "cmp   r12, #0            \n"                        \
+            "ldrne pc,  [r12, %[api]] \n"                        \
+            :                                                    \
+            : [tls] "J"(TLS_SLOT_OPENGL_API*4),                  \
+              [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api)) \
+            : "r0", "r1", "r2", "r3", "r12"                      \
+        );
 
-#elif defined(__mips__) && !USE_SLOW_BINDING
+    #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+        asm volatile(                             \
+            "mov r0, #0 \n"                       \
+            :                                     \
+            :                                     \
+            : "r0"                                \
+        );
 
-    #define API_ENTRY(_api) __attribute__((noinline)) _api
 
-    #define CALL_GL_API(_api, ...)                               \
-        register unsigned int _t0 asm("t0");                     \
-        register unsigned int _fn asm("t1");                     \
-        register unsigned int _tls asm("v1");                    \
-        register unsigned int _v0 asm("v0");                     \
+    #define CALL_GL_API_INTERNAL_DO_RETURN \
+        asm volatile(                      \
+            "bx lr \n"                     \
+            :                              \
+            :                              \
+            : "r0"                         \
+        );
+
+#elif defined(__aarch64__)
+
+    #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
+
+    #define CALL_GL_API_INTERNAL_CALL(_api, ...)                    \
+        asm volatile(                                               \
+            "mrs x16, tpidr_el0\n"                                  \
+            "ldr x16, [x16, %[tls]]\n"                              \
+            "cbz x16, 1f\n"                                         \
+            "ldr x16, [x16, %[api]]\n"                              \
+            "br  x16\n"                                             \
+            "1:\n"                                                  \
+            :                                                       \
+            : [tls] "i" (TLS_SLOT_OPENGL_API * sizeof(void*)),      \
+              [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api))   \
+            : "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x16" \
+        );
+
+    #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+        asm volatile(                             \
+            "mov w0, wzr \n"                      \
+            :                                     \
+            :                                     \
+            : "w0"                                \
+        );
+
+    #define CALL_GL_API_INTERNAL_DO_RETURN \
+        asm volatile(                      \
+            "ret \n"                       \
+            :                              \
+            :                              \
+            :                              \
+        );
+
+#elif defined(__i386__)
+
+    #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
+
+    #define CALL_GL_API_INTERNAL_CALL(_api, ...)                    \
+        __asm__ volatile(                                           \
+            "mov %%gs:0, %%eax\n"                                   \
+            "mov %P[tls](%%eax), %%eax\n"                           \
+            "test %%eax, %%eax\n"                                   \
+            "je 1f\n"                                               \
+            "jmp *%P[api](%%eax)\n"                                 \
+            "1:\n"                                                  \
+            :                                                       \
+            : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)),        \
+              [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api))   \
+            : "cc", "%eax"                                          \
+        );
+
+    #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+        __asm__ volatile(                         \
+            "xor %%eax, %%eax\n"                  \
+            :                                     \
+            :                                     \
+            : "%eax"                              \
+        );
+
+    #define CALL_GL_API_INTERNAL_DO_RETURN \
+        __asm__ volatile(                  \
+            "ret\n"                        \
+            :                              \
+            :                              \
+            :                              \
+        );
+
+#elif defined(__x86_64__)
+
+    #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
+
+    #define CALL_GL_API_INTERNAL_CALL(_api, ...)                    \
+        __asm__ volatile(                                           \
+            "mov %%fs:0, %%rax\n"                                   \
+            "mov %P[tls](%%rax), %%rax\n"                           \
+            "test %%rax, %%rax\n"                                   \
+            "je 1f\n"                                               \
+            "jmp *%P[api](%%rax)\n"                                 \
+            "1:\n"                                                  \
+            :                                                       \
+            : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)),        \
+              [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api))   \
+            : "cc", "%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9",   \
+              "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", \
+              "%xmm6", "%xmm7"                                      \
+        );
+
+    #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+        __asm__ volatile(                         \
+            "xor %%eax, %%eax\n"                  \
+            :                                     \
+            :                                     \
+            : "%eax"                              \
+        );
+
+    #define CALL_GL_API_INTERNAL_DO_RETURN \
+        __asm__ volatile(                  \
+            "retq\n"                       \
+            :                              \
+            :                              \
+            :                              \
+        );
+
+#elif defined(__mips64)
+
+    #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
+
+    // t0:  $12
+    // fn:  $25
+    // tls: $3
+    // v0:  $2
+    #define CALL_GL_API_INTERNAL_CALL(_api, ...)                  \
+        asm volatile(                                             \
+            ".set  push\n\t"                                      \
+            ".set  noreorder\n\t"                                 \
+            "rdhwr $3, $29\n\t"                                   \
+            "ld    $12, %[OPENGL_API]($3)\n\t"                    \
+            "beqz  $12, 1f\n\t"                                   \
+            " move $25, $ra\n\t"                                  \
+            "ld    $12, %[API]($12)\n\t"                          \
+            "beqz  $12, 1f\n\t"                                   \
+            " nop\n\t"                                            \
+            "move  $25, $12\n\t"                                  \
+            "1:\n\t"                                              \
+            "jalr  $0, $25\n\t"                                   \
+            " move $2, $0\n\t"                                    \
+            ".set  pop\n\t"                                       \
+            :                                                     \
+            : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*sizeof(void*)),\
+              [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api))  \
+            : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",     \
+              "$10", "$11", "$12", "$25"                          \
+        );
+
+    #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+    #define CALL_GL_API_INTERNAL_DO_RETURN
+
+#elif defined(__mips__)
+
+    #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
+
+    // t0:  $8
+    // fn:  $25
+    // tls: $3
+    // v0:  $2
+    #define CALL_GL_API_INTERNAL_CALL(_api, ...)                 \
         asm volatile(                                            \
             ".set  push\n\t"                                     \
             ".set  noreorder\n\t"                                \
             ".set  mips32r2\n\t"                                 \
-            "rdhwr %[tls], $29\n\t"                              \
-            "lw    %[t0], %[OPENGL_API](%[tls])\n\t"             \
-            "beqz  %[t0], 1f\n\t"                                \
-            " move %[fn], $ra\n\t"                               \
-            "lw    %[fn], %[API](%[t0])\n\t"                     \
-            "movz  %[fn], $ra, %[fn]\n\t"                        \
+            "rdhwr $3, $29\n\t"                                  \
+            "lw    $3, %[OPENGL_API]($3)\n\t"                    \
+            "beqz  $3, 1f\n\t"                                   \
+            " move $25,$ra\n\t"                                  \
+            "lw    $3, %[API]($3)\n\t"                           \
+            "beqz  $3, 1f\n\t"                                   \
+            " nop\n\t"                                           \
+            "move  $25, $3\n\t"                                  \
             "1:\n\t"                                             \
-            "j     %[fn]\n\t"                                    \
-            " move %[v0], $0\n\t"                                \
+            "jalr  $0, $25\n\t"                                  \
+            " move $2, $0\n\t"                                   \
             ".set  pop\n\t"                                      \
-            : [fn] "=c"(_fn),                                    \
-              [tls] "=&r"(_tls),                                 \
-              [t0] "=&r"(_t0),                                   \
-              [v0] "=&r"(_v0)                                    \
+            :                                                    \
             : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4),           \
               [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \
-            :                                                    \
-            );
+            : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$25"    \
+        );
 
-#else
-
-    #define API_ENTRY(_api) _api
-
-    #define CALL_GL_API(_api, ...)                                       \
-        gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;  \
-        if (_c) return _c->_api(__VA_ARGS__);
+    #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+    #define CALL_GL_API_INTERNAL_DO_RETURN
 
 #endif
 
-#define CALL_GL_API_RETURN(_api, ...) \
-    CALL_GL_API(_api, __VA_ARGS__) \
-    return 0;
+#define CALL_GL_API(_api, ...) \
+    CALL_GL_API_INTERNAL_CALL(_api, __VA_ARGS__) \
+    CALL_GL_API_INTERNAL_DO_RETURN
 
+#define CALL_GL_API_RETURN(_api, ...) \
+    CALL_GL_API_INTERNAL_CALL(_api, __VA_ARGS__) \
+    CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+    CALL_GL_API_INTERNAL_DO_RETURN
 
 extern "C" {
+#pragma GCC diagnostic ignored "-Wunused-parameter"
 #include "gl_api.in"
 #include "glext_api.in"
+#pragma GCC diagnostic warning "-Wunused-parameter"
 }
 
 #undef API_ENTRY
 #undef CALL_GL_API
+#undef CALL_GL_API_INTERNAL_CALL
+#undef CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+#undef CALL_GL_API_INTERNAL_DO_RETURN
 #undef CALL_GL_API_RETURN
 
 /*
diff --git a/opengl/libs/GLES_CM/gl_api.in b/opengl/libs/GLES_CM/gl_api.in
index c8f6b0c..fa975ed 100644
--- a/opengl/libs/GLES_CM/gl_api.in
+++ b/opengl/libs/GLES_CM/gl_api.in
@@ -1,73 +1,73 @@
-void API_ENTRY(glAlphaFunc)(GLenum func, GLclampf ref) {
+void API_ENTRY(glAlphaFunc)(GLenum func, GLfloat ref) {
     CALL_GL_API(glAlphaFunc, func, ref);
 }
-void API_ENTRY(glClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
+void API_ENTRY(glClearColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
     CALL_GL_API(glClearColor, red, green, blue, alpha);
 }
-void API_ENTRY(glClearDepthf)(GLclampf depth) {
-    CALL_GL_API(glClearDepthf, depth);
+void API_ENTRY(glClearDepthf)(GLfloat d) {
+    CALL_GL_API(glClearDepthf, d);
 }
-void API_ENTRY(glClipPlanef)(GLenum plane, const GLfloat *equation) {
-    CALL_GL_API(glClipPlanef, plane, equation);
+void API_ENTRY(glClipPlanef)(GLenum p, const GLfloat * eqn) {
+    CALL_GL_API(glClipPlanef, p, eqn);
 }
 void API_ENTRY(glColor4f)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
     CALL_GL_API(glColor4f, red, green, blue, alpha);
 }
-void API_ENTRY(glDepthRangef)(GLclampf zNear, GLclampf zFar) {
-    CALL_GL_API(glDepthRangef, zNear, zFar);
+void API_ENTRY(glDepthRangef)(GLfloat n, GLfloat f) {
+    CALL_GL_API(glDepthRangef, n, f);
 }
 void API_ENTRY(glFogf)(GLenum pname, GLfloat param) {
     CALL_GL_API(glFogf, pname, param);
 }
-void API_ENTRY(glFogfv)(GLenum pname, const GLfloat *params) {
+void API_ENTRY(glFogfv)(GLenum pname, const GLfloat * params) {
     CALL_GL_API(glFogfv, pname, params);
 }
-void API_ENTRY(glFrustumf)(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) {
-    CALL_GL_API(glFrustumf, left, right, bottom, top, zNear, zFar);
+void API_ENTRY(glFrustumf)(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f) {
+    CALL_GL_API(glFrustumf, l, r, b, t, n, f);
 }
-void API_ENTRY(glGetClipPlanef)(GLenum pname, GLfloat eqn[4]) {
-    CALL_GL_API(glGetClipPlanef, pname, eqn);
+void API_ENTRY(glGetClipPlanef)(GLenum plane, GLfloat * equation) {
+    CALL_GL_API(glGetClipPlanef, plane, equation);
 }
-void API_ENTRY(glGetFloatv)(GLenum pname, GLfloat *params) {
-    CALL_GL_API(glGetFloatv, pname, params);
+void API_ENTRY(glGetFloatv)(GLenum pname, GLfloat * data) {
+    CALL_GL_API(glGetFloatv, pname, data);
 }
-void API_ENTRY(glGetLightfv)(GLenum light, GLenum pname, GLfloat *params) {
+void API_ENTRY(glGetLightfv)(GLenum light, GLenum pname, GLfloat * params) {
     CALL_GL_API(glGetLightfv, light, pname, params);
 }
-void API_ENTRY(glGetMaterialfv)(GLenum face, GLenum pname, GLfloat *params) {
+void API_ENTRY(glGetMaterialfv)(GLenum face, GLenum pname, GLfloat * params) {
     CALL_GL_API(glGetMaterialfv, face, pname, params);
 }
-void API_ENTRY(glGetTexEnvfv)(GLenum env, GLenum pname, GLfloat *params) {
-    CALL_GL_API(glGetTexEnvfv, env, pname, params);
+void API_ENTRY(glGetTexEnvfv)(GLenum target, GLenum pname, GLfloat * params) {
+    CALL_GL_API(glGetTexEnvfv, target, pname, params);
 }
-void API_ENTRY(glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat *params) {
+void API_ENTRY(glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat * params) {
     CALL_GL_API(glGetTexParameterfv, target, pname, params);
 }
 void API_ENTRY(glLightModelf)(GLenum pname, GLfloat param) {
     CALL_GL_API(glLightModelf, pname, param);
 }
-void API_ENTRY(glLightModelfv)(GLenum pname, const GLfloat *params) {
+void API_ENTRY(glLightModelfv)(GLenum pname, const GLfloat * params) {
     CALL_GL_API(glLightModelfv, pname, params);
 }
 void API_ENTRY(glLightf)(GLenum light, GLenum pname, GLfloat param) {
     CALL_GL_API(glLightf, light, pname, param);
 }
-void API_ENTRY(glLightfv)(GLenum light, GLenum pname, const GLfloat *params) {
+void API_ENTRY(glLightfv)(GLenum light, GLenum pname, const GLfloat * params) {
     CALL_GL_API(glLightfv, light, pname, params);
 }
 void API_ENTRY(glLineWidth)(GLfloat width) {
     CALL_GL_API(glLineWidth, width);
 }
-void API_ENTRY(glLoadMatrixf)(const GLfloat *m) {
+void API_ENTRY(glLoadMatrixf)(const GLfloat * m) {
     CALL_GL_API(glLoadMatrixf, m);
 }
 void API_ENTRY(glMaterialf)(GLenum face, GLenum pname, GLfloat param) {
     CALL_GL_API(glMaterialf, face, pname, param);
 }
-void API_ENTRY(glMaterialfv)(GLenum face, GLenum pname, const GLfloat *params) {
+void API_ENTRY(glMaterialfv)(GLenum face, GLenum pname, const GLfloat * params) {
     CALL_GL_API(glMaterialfv, face, pname, params);
 }
-void API_ENTRY(glMultMatrixf)(const GLfloat *m) {
+void API_ENTRY(glMultMatrixf)(const GLfloat * m) {
     CALL_GL_API(glMultMatrixf, m);
 }
 void API_ENTRY(glMultiTexCoord4f)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
@@ -76,13 +76,13 @@
 void API_ENTRY(glNormal3f)(GLfloat nx, GLfloat ny, GLfloat nz) {
     CALL_GL_API(glNormal3f, nx, ny, nz);
 }
-void API_ENTRY(glOrthof)(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) {
-    CALL_GL_API(glOrthof, left, right, bottom, top, zNear, zFar);
+void API_ENTRY(glOrthof)(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f) {
+    CALL_GL_API(glOrthof, l, r, b, t, n, f);
 }
 void API_ENTRY(glPointParameterf)(GLenum pname, GLfloat param) {
     CALL_GL_API(glPointParameterf, pname, param);
 }
-void API_ENTRY(glPointParameterfv)(GLenum pname, const GLfloat *params) {
+void API_ENTRY(glPointParameterfv)(GLenum pname, const GLfloat * params) {
     CALL_GL_API(glPointParameterfv, pname, params);
 }
 void API_ENTRY(glPointSize)(GLfloat size) {
@@ -100,13 +100,13 @@
 void API_ENTRY(glTexEnvf)(GLenum target, GLenum pname, GLfloat param) {
     CALL_GL_API(glTexEnvf, target, pname, param);
 }
-void API_ENTRY(glTexEnvfv)(GLenum target, GLenum pname, const GLfloat *params) {
+void API_ENTRY(glTexEnvfv)(GLenum target, GLenum pname, const GLfloat * params) {
     CALL_GL_API(glTexEnvfv, target, pname, params);
 }
 void API_ENTRY(glTexParameterf)(GLenum target, GLenum pname, GLfloat param) {
     CALL_GL_API(glTexParameterf, target, pname, param);
 }
-void API_ENTRY(glTexParameterfv)(GLenum target, GLenum pname, const GLfloat *params) {
+void API_ENTRY(glTexParameterfv)(GLenum target, GLenum pname, const GLfloat * params) {
     CALL_GL_API(glTexParameterfv, target, pname, params);
 }
 void API_ENTRY(glTranslatef)(GLfloat x, GLfloat y, GLfloat z) {
@@ -115,7 +115,7 @@
 void API_ENTRY(glActiveTexture)(GLenum texture) {
     CALL_GL_API(glActiveTexture, texture);
 }
-void API_ENTRY(glAlphaFuncx)(GLenum func, GLclampx ref) {
+void API_ENTRY(glAlphaFuncx)(GLenum func, GLfixed ref) {
     CALL_GL_API(glAlphaFuncx, func, ref);
 }
 void API_ENTRY(glBindBuffer)(GLenum target, GLuint buffer) {
@@ -127,19 +127,19 @@
 void API_ENTRY(glBlendFunc)(GLenum sfactor, GLenum dfactor) {
     CALL_GL_API(glBlendFunc, sfactor, dfactor);
 }
-void API_ENTRY(glBufferData)(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) {
+void API_ENTRY(glBufferData)(GLenum target, GLsizeiptr size, const void * data, GLenum usage) {
     CALL_GL_API(glBufferData, target, size, data, usage);
 }
-void API_ENTRY(glBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data) {
+void API_ENTRY(glBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data) {
     CALL_GL_API(glBufferSubData, target, offset, size, data);
 }
 void API_ENTRY(glClear)(GLbitfield mask) {
     CALL_GL_API(glClear, mask);
 }
-void API_ENTRY(glClearColorx)(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) {
+void API_ENTRY(glClearColorx)(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) {
     CALL_GL_API(glClearColorx, red, green, blue, alpha);
 }
-void API_ENTRY(glClearDepthx)(GLclampx depth) {
+void API_ENTRY(glClearDepthx)(GLfixed depth) {
     CALL_GL_API(glClearDepthx, depth);
 }
 void API_ENTRY(glClearStencil)(GLint s) {
@@ -148,7 +148,7 @@
 void API_ENTRY(glClientActiveTexture)(GLenum texture) {
     CALL_GL_API(glClientActiveTexture, texture);
 }
-void API_ENTRY(glClipPlanex)(GLenum plane, const GLfixed *equation) {
+void API_ENTRY(glClipPlanex)(GLenum plane, const GLfixed * equation) {
     CALL_GL_API(glClipPlanex, plane, equation);
 }
 void API_ENTRY(glColor4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) {
@@ -160,13 +160,13 @@
 void API_ENTRY(glColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {
     CALL_GL_API(glColorMask, red, green, blue, alpha);
 }
-void API_ENTRY(glColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
+void API_ENTRY(glColorPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer) {
     CALL_GL_API(glColorPointer, size, type, stride, pointer);
 }
-void API_ENTRY(glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) {
+void API_ENTRY(glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data) {
     CALL_GL_API(glCompressedTexImage2D, target, level, internalformat, width, height, border, imageSize, data);
 }
-void API_ENTRY(glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) {
+void API_ENTRY(glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data) {
     CALL_GL_API(glCompressedTexSubImage2D, target, level, xoffset, yoffset, width, height, format, imageSize, data);
 }
 void API_ENTRY(glCopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
@@ -178,10 +178,10 @@
 void API_ENTRY(glCullFace)(GLenum mode) {
     CALL_GL_API(glCullFace, mode);
 }
-void API_ENTRY(glDeleteBuffers)(GLsizei n, const GLuint *buffers) {
+void API_ENTRY(glDeleteBuffers)(GLsizei n, const GLuint * buffers) {
     CALL_GL_API(glDeleteBuffers, n, buffers);
 }
-void API_ENTRY(glDeleteTextures)(GLsizei n, const GLuint *textures) {
+void API_ENTRY(glDeleteTextures)(GLsizei n, const GLuint * textures) {
     CALL_GL_API(glDeleteTextures, n, textures);
 }
 void API_ENTRY(glDepthFunc)(GLenum func) {
@@ -190,8 +190,8 @@
 void API_ENTRY(glDepthMask)(GLboolean flag) {
     CALL_GL_API(glDepthMask, flag);
 }
-void API_ENTRY(glDepthRangex)(GLclampx zNear, GLclampx zFar) {
-    CALL_GL_API(glDepthRangex, zNear, zFar);
+void API_ENTRY(glDepthRangex)(GLfixed n, GLfixed f) {
+    CALL_GL_API(glDepthRangex, n, f);
 }
 void API_ENTRY(glDisable)(GLenum cap) {
     CALL_GL_API(glDisable, cap);
@@ -202,7 +202,7 @@
 void API_ENTRY(glDrawArrays)(GLenum mode, GLint first, GLsizei count) {
     CALL_GL_API(glDrawArrays, mode, first, count);
 }
-void API_ENTRY(glDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) {
+void API_ENTRY(glDrawElements)(GLenum mode, GLsizei count, GLenum type, const void * indices) {
     CALL_GL_API(glDrawElements, mode, count, type, indices);
 }
 void API_ENTRY(glEnable)(GLenum cap) {
@@ -220,61 +220,61 @@
 void API_ENTRY(glFogx)(GLenum pname, GLfixed param) {
     CALL_GL_API(glFogx, pname, param);
 }
-void API_ENTRY(glFogxv)(GLenum pname, const GLfixed *params) {
-    CALL_GL_API(glFogxv, pname, params);
+void API_ENTRY(glFogxv)(GLenum pname, const GLfixed * param) {
+    CALL_GL_API(glFogxv, pname, param);
 }
 void API_ENTRY(glFrontFace)(GLenum mode) {
     CALL_GL_API(glFrontFace, mode);
 }
-void API_ENTRY(glFrustumx)(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) {
-    CALL_GL_API(glFrustumx, left, right, bottom, top, zNear, zFar);
+void API_ENTRY(glFrustumx)(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f) {
+    CALL_GL_API(glFrustumx, l, r, b, t, n, f);
 }
-void API_ENTRY(glGetBooleanv)(GLenum pname, GLboolean *params) {
-    CALL_GL_API(glGetBooleanv, pname, params);
+void API_ENTRY(glGetBooleanv)(GLenum pname, GLboolean * data) {
+    CALL_GL_API(glGetBooleanv, pname, data);
 }
-void API_ENTRY(glGetBufferParameteriv)(GLenum target, GLenum pname, GLint *params) {
+void API_ENTRY(glGetBufferParameteriv)(GLenum target, GLenum pname, GLint * params) {
     CALL_GL_API(glGetBufferParameteriv, target, pname, params);
 }
-void API_ENTRY(glGetClipPlanex)(GLenum pname, GLfixed eqn[4]) {
-    CALL_GL_API(glGetClipPlanex, pname, eqn);
+void API_ENTRY(glGetClipPlanex)(GLenum plane, GLfixed * equation) {
+    CALL_GL_API(glGetClipPlanex, plane, equation);
 }
-void API_ENTRY(glGenBuffers)(GLsizei n, GLuint *buffers) {
+void API_ENTRY(glGenBuffers)(GLsizei n, GLuint * buffers) {
     CALL_GL_API(glGenBuffers, n, buffers);
 }
-void API_ENTRY(glGenTextures)(GLsizei n, GLuint *textures) {
+void API_ENTRY(glGenTextures)(GLsizei n, GLuint * textures) {
     CALL_GL_API(glGenTextures, n, textures);
 }
 GLenum API_ENTRY(glGetError)(void) {
     CALL_GL_API_RETURN(glGetError);
 }
-void API_ENTRY(glGetFixedv)(GLenum pname, GLfixed *params) {
+void API_ENTRY(glGetFixedv)(GLenum pname, GLfixed * params) {
     CALL_GL_API(glGetFixedv, pname, params);
 }
-void API_ENTRY(glGetIntegerv)(GLenum pname, GLint *params) {
-    CALL_GL_API(glGetIntegerv, pname, params);
+void API_ENTRY(glGetIntegerv)(GLenum pname, GLint * data) {
+    CALL_GL_API(glGetIntegerv, pname, data);
 }
-void API_ENTRY(glGetLightxv)(GLenum light, GLenum pname, GLfixed *params) {
+void API_ENTRY(glGetLightxv)(GLenum light, GLenum pname, GLfixed * params) {
     CALL_GL_API(glGetLightxv, light, pname, params);
 }
-void API_ENTRY(glGetMaterialxv)(GLenum face, GLenum pname, GLfixed *params) {
+void API_ENTRY(glGetMaterialxv)(GLenum face, GLenum pname, GLfixed * params) {
     CALL_GL_API(glGetMaterialxv, face, pname, params);
 }
-void API_ENTRY(glGetPointerv)(GLenum pname, GLvoid **params) {
+void API_ENTRY(glGetPointerv)(GLenum pname, void ** params) {
     CALL_GL_API(glGetPointerv, pname, params);
 }
 const GLubyte * API_ENTRY(__glGetString)(GLenum name) {
     CALL_GL_API_RETURN(glGetString, name);
 }
-void API_ENTRY(glGetTexEnviv)(GLenum env, GLenum pname, GLint *params) {
-    CALL_GL_API(glGetTexEnviv, env, pname, params);
+void API_ENTRY(glGetTexEnviv)(GLenum target, GLenum pname, GLint * params) {
+    CALL_GL_API(glGetTexEnviv, target, pname, params);
 }
-void API_ENTRY(glGetTexEnvxv)(GLenum env, GLenum pname, GLfixed *params) {
-    CALL_GL_API(glGetTexEnvxv, env, pname, params);
+void API_ENTRY(glGetTexEnvxv)(GLenum target, GLenum pname, GLfixed * params) {
+    CALL_GL_API(glGetTexEnvxv, target, pname, params);
 }
-void API_ENTRY(glGetTexParameteriv)(GLenum target, GLenum pname, GLint *params) {
+void API_ENTRY(glGetTexParameteriv)(GLenum target, GLenum pname, GLint * params) {
     CALL_GL_API(glGetTexParameteriv, target, pname, params);
 }
-void API_ENTRY(glGetTexParameterxv)(GLenum target, GLenum pname, GLfixed *params) {
+void API_ENTRY(glGetTexParameterxv)(GLenum target, GLenum pname, GLfixed * params) {
     CALL_GL_API(glGetTexParameterxv, target, pname, params);
 }
 void API_ENTRY(glHint)(GLenum target, GLenum mode) {
@@ -292,13 +292,13 @@
 void API_ENTRY(glLightModelx)(GLenum pname, GLfixed param) {
     CALL_GL_API(glLightModelx, pname, param);
 }
-void API_ENTRY(glLightModelxv)(GLenum pname, const GLfixed *params) {
-    CALL_GL_API(glLightModelxv, pname, params);
+void API_ENTRY(glLightModelxv)(GLenum pname, const GLfixed * param) {
+    CALL_GL_API(glLightModelxv, pname, param);
 }
 void API_ENTRY(glLightx)(GLenum light, GLenum pname, GLfixed param) {
     CALL_GL_API(glLightx, light, pname, param);
 }
-void API_ENTRY(glLightxv)(GLenum light, GLenum pname, const GLfixed *params) {
+void API_ENTRY(glLightxv)(GLenum light, GLenum pname, const GLfixed * params) {
     CALL_GL_API(glLightxv, light, pname, params);
 }
 void API_ENTRY(glLineWidthx)(GLfixed width) {
@@ -307,7 +307,7 @@
 void API_ENTRY(glLoadIdentity)(void) {
     CALL_GL_API(glLoadIdentity);
 }
-void API_ENTRY(glLoadMatrixx)(const GLfixed *m) {
+void API_ENTRY(glLoadMatrixx)(const GLfixed * m) {
     CALL_GL_API(glLoadMatrixx, m);
 }
 void API_ENTRY(glLogicOp)(GLenum opcode) {
@@ -316,26 +316,26 @@
 void API_ENTRY(glMaterialx)(GLenum face, GLenum pname, GLfixed param) {
     CALL_GL_API(glMaterialx, face, pname, param);
 }
-void API_ENTRY(glMaterialxv)(GLenum face, GLenum pname, const GLfixed *params) {
-    CALL_GL_API(glMaterialxv, face, pname, params);
+void API_ENTRY(glMaterialxv)(GLenum face, GLenum pname, const GLfixed * param) {
+    CALL_GL_API(glMaterialxv, face, pname, param);
 }
 void API_ENTRY(glMatrixMode)(GLenum mode) {
     CALL_GL_API(glMatrixMode, mode);
 }
-void API_ENTRY(glMultMatrixx)(const GLfixed *m) {
+void API_ENTRY(glMultMatrixx)(const GLfixed * m) {
     CALL_GL_API(glMultMatrixx, m);
 }
-void API_ENTRY(glMultiTexCoord4x)(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) {
-    CALL_GL_API(glMultiTexCoord4x, target, s, t, r, q);
+void API_ENTRY(glMultiTexCoord4x)(GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q) {
+    CALL_GL_API(glMultiTexCoord4x, texture, s, t, r, q);
 }
 void API_ENTRY(glNormal3x)(GLfixed nx, GLfixed ny, GLfixed nz) {
     CALL_GL_API(glNormal3x, nx, ny, nz);
 }
-void API_ENTRY(glNormalPointer)(GLenum type, GLsizei stride, const GLvoid *pointer) {
+void API_ENTRY(glNormalPointer)(GLenum type, GLsizei stride, const void * pointer) {
     CALL_GL_API(glNormalPointer, type, stride, pointer);
 }
-void API_ENTRY(glOrthox)(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) {
-    CALL_GL_API(glOrthox, left, right, bottom, top, zNear, zFar);
+void API_ENTRY(glOrthox)(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f) {
+    CALL_GL_API(glOrthox, l, r, b, t, n, f);
 }
 void API_ENTRY(glPixelStorei)(GLenum pname, GLint param) {
     CALL_GL_API(glPixelStorei, pname, param);
@@ -343,7 +343,7 @@
 void API_ENTRY(glPointParameterx)(GLenum pname, GLfixed param) {
     CALL_GL_API(glPointParameterx, pname, param);
 }
-void API_ENTRY(glPointParameterxv)(GLenum pname, const GLfixed *params) {
+void API_ENTRY(glPointParameterxv)(GLenum pname, const GLfixed * params) {
     CALL_GL_API(glPointParameterxv, pname, params);
 }
 void API_ENTRY(glPointSizex)(GLfixed size) {
@@ -358,13 +358,13 @@
 void API_ENTRY(glPushMatrix)(void) {
     CALL_GL_API(glPushMatrix);
 }
-void API_ENTRY(glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {
+void API_ENTRY(glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels) {
     CALL_GL_API(glReadPixels, x, y, width, height, format, type, pixels);
 }
 void API_ENTRY(glRotatex)(GLfixed angle, GLfixed x, GLfixed y, GLfixed z) {
     CALL_GL_API(glRotatex, angle, x, y, z);
 }
-void API_ENTRY(glSampleCoverage)(GLclampf value, GLboolean invert) {
+void API_ENTRY(glSampleCoverage)(GLfloat value, GLboolean invert) {
     CALL_GL_API(glSampleCoverage, value, invert);
 }
 void API_ENTRY(glSampleCoveragex)(GLclampx value, GLboolean invert) {
@@ -388,7 +388,7 @@
 void API_ENTRY(glStencilOp)(GLenum fail, GLenum zfail, GLenum zpass) {
     CALL_GL_API(glStencilOp, fail, zfail, zpass);
 }
-void API_ENTRY(glTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
+void API_ENTRY(glTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer) {
     CALL_GL_API(glTexCoordPointer, size, type, stride, pointer);
 }
 void API_ENTRY(glTexEnvi)(GLenum target, GLenum pname, GLint param) {
@@ -397,13 +397,13 @@
 void API_ENTRY(glTexEnvx)(GLenum target, GLenum pname, GLfixed param) {
     CALL_GL_API(glTexEnvx, target, pname, param);
 }
-void API_ENTRY(glTexEnviv)(GLenum target, GLenum pname, const GLint *params) {
+void API_ENTRY(glTexEnviv)(GLenum target, GLenum pname, const GLint * params) {
     CALL_GL_API(glTexEnviv, target, pname, params);
 }
-void API_ENTRY(glTexEnvxv)(GLenum target, GLenum pname, const GLfixed *params) {
+void API_ENTRY(glTexEnvxv)(GLenum target, GLenum pname, const GLfixed * params) {
     CALL_GL_API(glTexEnvxv, target, pname, params);
 }
-void API_ENTRY(glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {
+void API_ENTRY(glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels) {
     CALL_GL_API(glTexImage2D, target, level, internalformat, width, height, border, format, type, pixels);
 }
 void API_ENTRY(glTexParameteri)(GLenum target, GLenum pname, GLint param) {
@@ -412,24 +412,21 @@
 void API_ENTRY(glTexParameterx)(GLenum target, GLenum pname, GLfixed param) {
     CALL_GL_API(glTexParameterx, target, pname, param);
 }
-void API_ENTRY(glTexParameteriv)(GLenum target, GLenum pname, const GLint *params) {
+void API_ENTRY(glTexParameteriv)(GLenum target, GLenum pname, const GLint * params) {
     CALL_GL_API(glTexParameteriv, target, pname, params);
 }
-void API_ENTRY(glTexParameterxv)(GLenum target, GLenum pname, const GLfixed *params) {
+void API_ENTRY(glTexParameterxv)(GLenum target, GLenum pname, const GLfixed * params) {
     CALL_GL_API(glTexParameterxv, target, pname, params);
 }
-void API_ENTRY(glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) {
+void API_ENTRY(glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels) {
     CALL_GL_API(glTexSubImage2D, target, level, xoffset, yoffset, width, height, format, type, pixels);
 }
 void API_ENTRY(glTranslatex)(GLfixed x, GLfixed y, GLfixed z) {
     CALL_GL_API(glTranslatex, x, y, z);
 }
-void API_ENTRY(glVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
+void API_ENTRY(glVertexPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer) {
     CALL_GL_API(glVertexPointer, size, type, stride, pointer);
 }
 void API_ENTRY(glViewport)(GLint x, GLint y, GLsizei width, GLsizei height) {
     CALL_GL_API(glViewport, x, y, width, height);
 }
-void API_ENTRY(glPointSizePointerOES)(GLenum type, GLsizei stride, const GLvoid *pointer) {
-    CALL_GL_API(glPointSizePointerOES, type, stride, pointer);
-}
diff --git a/opengl/libs/GLES_CM/glext_api.in b/opengl/libs/GLES_CM/glext_api.in
index 7cd6cb5..c8fba6b 100644
--- a/opengl/libs/GLES_CM/glext_api.in
+++ b/opengl/libs/GLES_CM/glext_api.in
@@ -1,3 +1,9 @@
+void API_ENTRY(glEGLImageTargetTexture2DOES)(GLenum target, GLeglImageOES image) {
+    CALL_GL_API(glEGLImageTargetTexture2DOES, target, image);
+}
+void API_ENTRY(glEGLImageTargetRenderbufferStorageOES)(GLenum target, GLeglImageOES image) {
+    CALL_GL_API(glEGLImageTargetRenderbufferStorageOES, target, image);
+}
 void API_ENTRY(glBlendEquationSeparateOES)(GLenum modeRGB, GLenum modeAlpha) {
     CALL_GL_API(glBlendEquationSeparateOES, modeRGB, modeAlpha);
 }
@@ -7,6 +13,72 @@
 void API_ENTRY(glBlendEquationOES)(GLenum mode) {
     CALL_GL_API(glBlendEquationOES, mode);
 }
+void API_ENTRY(glMultiTexCoord1bOES)(GLenum texture, GLbyte s) {
+    CALL_GL_API(glMultiTexCoord1bOES, texture, s);
+}
+void API_ENTRY(glMultiTexCoord1bvOES)(GLenum texture, const GLbyte * coords) {
+    CALL_GL_API(glMultiTexCoord1bvOES, texture, coords);
+}
+void API_ENTRY(glMultiTexCoord2bOES)(GLenum texture, GLbyte s, GLbyte t) {
+    CALL_GL_API(glMultiTexCoord2bOES, texture, s, t);
+}
+void API_ENTRY(glMultiTexCoord2bvOES)(GLenum texture, const GLbyte * coords) {
+    CALL_GL_API(glMultiTexCoord2bvOES, texture, coords);
+}
+void API_ENTRY(glMultiTexCoord3bOES)(GLenum texture, GLbyte s, GLbyte t, GLbyte r) {
+    CALL_GL_API(glMultiTexCoord3bOES, texture, s, t, r);
+}
+void API_ENTRY(glMultiTexCoord3bvOES)(GLenum texture, const GLbyte * coords) {
+    CALL_GL_API(glMultiTexCoord3bvOES, texture, coords);
+}
+void API_ENTRY(glMultiTexCoord4bOES)(GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q) {
+    CALL_GL_API(glMultiTexCoord4bOES, texture, s, t, r, q);
+}
+void API_ENTRY(glMultiTexCoord4bvOES)(GLenum texture, const GLbyte * coords) {
+    CALL_GL_API(glMultiTexCoord4bvOES, texture, coords);
+}
+void API_ENTRY(glTexCoord1bOES)(GLbyte s) {
+    CALL_GL_API(glTexCoord1bOES, s);
+}
+void API_ENTRY(glTexCoord1bvOES)(const GLbyte * coords) {
+    CALL_GL_API(glTexCoord1bvOES, coords);
+}
+void API_ENTRY(glTexCoord2bOES)(GLbyte s, GLbyte t) {
+    CALL_GL_API(glTexCoord2bOES, s, t);
+}
+void API_ENTRY(glTexCoord2bvOES)(const GLbyte * coords) {
+    CALL_GL_API(glTexCoord2bvOES, coords);
+}
+void API_ENTRY(glTexCoord3bOES)(GLbyte s, GLbyte t, GLbyte r) {
+    CALL_GL_API(glTexCoord3bOES, s, t, r);
+}
+void API_ENTRY(glTexCoord3bvOES)(const GLbyte * coords) {
+    CALL_GL_API(glTexCoord3bvOES, coords);
+}
+void API_ENTRY(glTexCoord4bOES)(GLbyte s, GLbyte t, GLbyte r, GLbyte q) {
+    CALL_GL_API(glTexCoord4bOES, s, t, r, q);
+}
+void API_ENTRY(glTexCoord4bvOES)(const GLbyte * coords) {
+    CALL_GL_API(glTexCoord4bvOES, coords);
+}
+void API_ENTRY(glVertex2bOES)(GLbyte x) {
+    CALL_GL_API(glVertex2bOES, x);
+}
+void API_ENTRY(glVertex2bvOES)(const GLbyte * coords) {
+    CALL_GL_API(glVertex2bvOES, coords);
+}
+void API_ENTRY(glVertex3bOES)(GLbyte x, GLbyte y) {
+    CALL_GL_API(glVertex3bOES, x, y);
+}
+void API_ENTRY(glVertex3bvOES)(const GLbyte * coords) {
+    CALL_GL_API(glVertex3bvOES, coords);
+}
+void API_ENTRY(glVertex4bOES)(GLbyte x, GLbyte y, GLbyte z) {
+    CALL_GL_API(glVertex4bOES, x, y, z);
+}
+void API_ENTRY(glVertex4bvOES)(const GLbyte * coords) {
+    CALL_GL_API(glVertex4bvOES, coords);
+}
 void API_ENTRY(glDrawTexsOES)(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) {
     CALL_GL_API(glDrawTexsOES, x, y, z, width, height);
 }
@@ -16,112 +88,97 @@
 void API_ENTRY(glDrawTexxOES)(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) {
     CALL_GL_API(glDrawTexxOES, x, y, z, width, height);
 }
-void API_ENTRY(glDrawTexsvOES)(const GLshort *coords) {
+void API_ENTRY(glDrawTexsvOES)(const GLshort * coords) {
     CALL_GL_API(glDrawTexsvOES, coords);
 }
-void API_ENTRY(glDrawTexivOES)(const GLint *coords) {
+void API_ENTRY(glDrawTexivOES)(const GLint * coords) {
     CALL_GL_API(glDrawTexivOES, coords);
 }
-void API_ENTRY(glDrawTexxvOES)(const GLfixed *coords) {
+void API_ENTRY(glDrawTexxvOES)(const GLfixed * coords) {
     CALL_GL_API(glDrawTexxvOES, coords);
 }
 void API_ENTRY(glDrawTexfOES)(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) {
     CALL_GL_API(glDrawTexfOES, x, y, z, width, height);
 }
-void API_ENTRY(glDrawTexfvOES)(const GLfloat *coords) {
+void API_ENTRY(glDrawTexfvOES)(const GLfloat * coords) {
     CALL_GL_API(glDrawTexfvOES, coords);
 }
-void API_ENTRY(glEGLImageTargetTexture2DOES)(GLenum target, GLeglImageOES image) {
-    CALL_GL_API(glEGLImageTargetTexture2DOES, target, image);
-}
-void API_ENTRY(glEGLImageTargetRenderbufferStorageOES)(GLenum target, GLeglImageOES image) {
-    CALL_GL_API(glEGLImageTargetRenderbufferStorageOES, target, image);
-}
-void API_ENTRY(glAlphaFuncxOES)(GLenum func, GLclampx ref) {
+void API_ENTRY(glAlphaFuncxOES)(GLenum func, GLfixed ref) {
     CALL_GL_API(glAlphaFuncxOES, func, ref);
 }
-void API_ENTRY(glClearColorxOES)(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) {
+void API_ENTRY(glClearColorxOES)(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) {
     CALL_GL_API(glClearColorxOES, red, green, blue, alpha);
 }
-void API_ENTRY(glClearDepthxOES)(GLclampx depth) {
+void API_ENTRY(glClearDepthxOES)(GLfixed depth) {
     CALL_GL_API(glClearDepthxOES, depth);
 }
-void API_ENTRY(glClipPlanexOES)(GLenum plane, const GLfixed *equation) {
+void API_ENTRY(glClipPlanexOES)(GLenum plane, const GLfixed * equation) {
     CALL_GL_API(glClipPlanexOES, plane, equation);
 }
 void API_ENTRY(glColor4xOES)(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) {
     CALL_GL_API(glColor4xOES, red, green, blue, alpha);
 }
-void API_ENTRY(glDepthRangexOES)(GLclampx zNear, GLclampx zFar) {
-    CALL_GL_API(glDepthRangexOES, zNear, zFar);
+void API_ENTRY(glDepthRangexOES)(GLfixed n, GLfixed f) {
+    CALL_GL_API(glDepthRangexOES, n, f);
 }
 void API_ENTRY(glFogxOES)(GLenum pname, GLfixed param) {
     CALL_GL_API(glFogxOES, pname, param);
 }
-void API_ENTRY(glFogxvOES)(GLenum pname, const GLfixed *params) {
-    CALL_GL_API(glFogxvOES, pname, params);
+void API_ENTRY(glFogxvOES)(GLenum pname, const GLfixed * param) {
+    CALL_GL_API(glFogxvOES, pname, param);
 }
-void API_ENTRY(glFrustumxOES)(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) {
-    CALL_GL_API(glFrustumxOES, left, right, bottom, top, zNear, zFar);
+void API_ENTRY(glFrustumxOES)(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f) {
+    CALL_GL_API(glFrustumxOES, l, r, b, t, n, f);
 }
-void API_ENTRY(glGetClipPlanexOES)(GLenum pname, GLfixed eqn[4]) {
-    CALL_GL_API(glGetClipPlanexOES, pname, eqn);
+void API_ENTRY(glGetClipPlanexOES)(GLenum plane, GLfixed * equation) {
+    CALL_GL_API(glGetClipPlanexOES, plane, equation);
 }
-void API_ENTRY(glGetFixedvOES)(GLenum pname, GLfixed *params) {
+void API_ENTRY(glGetFixedvOES)(GLenum pname, GLfixed * params) {
     CALL_GL_API(glGetFixedvOES, pname, params);
 }
-void API_ENTRY(glGetLightxvOES)(GLenum light, GLenum pname, GLfixed *params) {
-    CALL_GL_API(glGetLightxvOES, light, pname, params);
+void API_ENTRY(glGetTexEnvxvOES)(GLenum target, GLenum pname, GLfixed * params) {
+    CALL_GL_API(glGetTexEnvxvOES, target, pname, params);
 }
-void API_ENTRY(glGetMaterialxvOES)(GLenum face, GLenum pname, GLfixed *params) {
-    CALL_GL_API(glGetMaterialxvOES, face, pname, params);
-}
-void API_ENTRY(glGetTexEnvxvOES)(GLenum env, GLenum pname, GLfixed *params) {
-    CALL_GL_API(glGetTexEnvxvOES, env, pname, params);
-}
-void API_ENTRY(glGetTexParameterxvOES)(GLenum target, GLenum pname, GLfixed *params) {
+void API_ENTRY(glGetTexParameterxvOES)(GLenum target, GLenum pname, GLfixed * params) {
     CALL_GL_API(glGetTexParameterxvOES, target, pname, params);
 }
 void API_ENTRY(glLightModelxOES)(GLenum pname, GLfixed param) {
     CALL_GL_API(glLightModelxOES, pname, param);
 }
-void API_ENTRY(glLightModelxvOES)(GLenum pname, const GLfixed *params) {
-    CALL_GL_API(glLightModelxvOES, pname, params);
+void API_ENTRY(glLightModelxvOES)(GLenum pname, const GLfixed * param) {
+    CALL_GL_API(glLightModelxvOES, pname, param);
 }
 void API_ENTRY(glLightxOES)(GLenum light, GLenum pname, GLfixed param) {
     CALL_GL_API(glLightxOES, light, pname, param);
 }
-void API_ENTRY(glLightxvOES)(GLenum light, GLenum pname, const GLfixed *params) {
+void API_ENTRY(glLightxvOES)(GLenum light, GLenum pname, const GLfixed * params) {
     CALL_GL_API(glLightxvOES, light, pname, params);
 }
 void API_ENTRY(glLineWidthxOES)(GLfixed width) {
     CALL_GL_API(glLineWidthxOES, width);
 }
-void API_ENTRY(glLoadMatrixxOES)(const GLfixed *m) {
+void API_ENTRY(glLoadMatrixxOES)(const GLfixed * m) {
     CALL_GL_API(glLoadMatrixxOES, m);
 }
 void API_ENTRY(glMaterialxOES)(GLenum face, GLenum pname, GLfixed param) {
     CALL_GL_API(glMaterialxOES, face, pname, param);
 }
-void API_ENTRY(glMaterialxvOES)(GLenum face, GLenum pname, const GLfixed *params) {
-    CALL_GL_API(glMaterialxvOES, face, pname, params);
+void API_ENTRY(glMaterialxvOES)(GLenum face, GLenum pname, const GLfixed * param) {
+    CALL_GL_API(glMaterialxvOES, face, pname, param);
 }
-void API_ENTRY(glMultMatrixxOES)(const GLfixed *m) {
+void API_ENTRY(glMultMatrixxOES)(const GLfixed * m) {
     CALL_GL_API(glMultMatrixxOES, m);
 }
-void API_ENTRY(glMultiTexCoord4xOES)(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) {
-    CALL_GL_API(glMultiTexCoord4xOES, target, s, t, r, q);
+void API_ENTRY(glMultiTexCoord4xOES)(GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q) {
+    CALL_GL_API(glMultiTexCoord4xOES, texture, s, t, r, q);
 }
 void API_ENTRY(glNormal3xOES)(GLfixed nx, GLfixed ny, GLfixed nz) {
     CALL_GL_API(glNormal3xOES, nx, ny, nz);
 }
-void API_ENTRY(glOrthoxOES)(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) {
-    CALL_GL_API(glOrthoxOES, left, right, bottom, top, zNear, zFar);
+void API_ENTRY(glOrthoxOES)(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f) {
+    CALL_GL_API(glOrthoxOES, l, r, b, t, n, f);
 }
-void API_ENTRY(glPointParameterxOES)(GLenum pname, GLfixed param) {
-    CALL_GL_API(glPointParameterxOES, pname, param);
-}
-void API_ENTRY(glPointParameterxvOES)(GLenum pname, const GLfixed *params) {
+void API_ENTRY(glPointParameterxvOES)(GLenum pname, const GLfixed * params) {
     CALL_GL_API(glPointParameterxvOES, pname, params);
 }
 void API_ENTRY(glPointSizexOES)(GLfixed size) {
@@ -133,8 +190,8 @@
 void API_ENTRY(glRotatexOES)(GLfixed angle, GLfixed x, GLfixed y, GLfixed z) {
     CALL_GL_API(glRotatexOES, angle, x, y, z);
 }
-void API_ENTRY(glSampleCoveragexOES)(GLclampx value, GLboolean invert) {
-    CALL_GL_API(glSampleCoveragexOES, value, invert);
+void API_ENTRY(glSampleCoverageOES)(GLfixed value, GLboolean invert) {
+    CALL_GL_API(glSampleCoverageOES, value, invert);
 }
 void API_ENTRY(glScalexOES)(GLfixed x, GLfixed y, GLfixed z) {
     CALL_GL_API(glScalexOES, x, y, z);
@@ -142,34 +199,55 @@
 void API_ENTRY(glTexEnvxOES)(GLenum target, GLenum pname, GLfixed param) {
     CALL_GL_API(glTexEnvxOES, target, pname, param);
 }
-void API_ENTRY(glTexEnvxvOES)(GLenum target, GLenum pname, const GLfixed *params) {
+void API_ENTRY(glTexEnvxvOES)(GLenum target, GLenum pname, const GLfixed * params) {
     CALL_GL_API(glTexEnvxvOES, target, pname, params);
 }
 void API_ENTRY(glTexParameterxOES)(GLenum target, GLenum pname, GLfixed param) {
     CALL_GL_API(glTexParameterxOES, target, pname, param);
 }
-void API_ENTRY(glTexParameterxvOES)(GLenum target, GLenum pname, const GLfixed *params) {
+void API_ENTRY(glTexParameterxvOES)(GLenum target, GLenum pname, const GLfixed * params) {
     CALL_GL_API(glTexParameterxvOES, target, pname, params);
 }
 void API_ENTRY(glTranslatexOES)(GLfixed x, GLfixed y, GLfixed z) {
     CALL_GL_API(glTranslatexOES, x, y, z);
 }
+void API_ENTRY(glGetLightxvOES)(GLenum light, GLenum pname, GLfixed * params) {
+    CALL_GL_API(glGetLightxvOES, light, pname, params);
+}
+void API_ENTRY(glGetMaterialxvOES)(GLenum face, GLenum pname, GLfixed * params) {
+    CALL_GL_API(glGetMaterialxvOES, face, pname, params);
+}
+void API_ENTRY(glPointParameterxOES)(GLenum pname, GLfixed param) {
+    CALL_GL_API(glPointParameterxOES, pname, param);
+}
+void API_ENTRY(glSampleCoveragexOES)(GLclampx value, GLboolean invert) {
+    CALL_GL_API(glSampleCoveragexOES, value, invert);
+}
+void API_ENTRY(glGetTexGenxvOES)(GLenum coord, GLenum pname, GLfixed * params) {
+    CALL_GL_API(glGetTexGenxvOES, coord, pname, params);
+}
+void API_ENTRY(glTexGenxOES)(GLenum coord, GLenum pname, GLfixed param) {
+    CALL_GL_API(glTexGenxOES, coord, pname, param);
+}
+void API_ENTRY(glTexGenxvOES)(GLenum coord, GLenum pname, const GLfixed * params) {
+    CALL_GL_API(glTexGenxvOES, coord, pname, params);
+}
 GLboolean API_ENTRY(glIsRenderbufferOES)(GLuint renderbuffer) {
     CALL_GL_API_RETURN(glIsRenderbufferOES, renderbuffer);
 }
 void API_ENTRY(glBindRenderbufferOES)(GLenum target, GLuint renderbuffer) {
     CALL_GL_API(glBindRenderbufferOES, target, renderbuffer);
 }
-void API_ENTRY(glDeleteRenderbuffersOES)(GLsizei n, const GLuint* renderbuffers) {
+void API_ENTRY(glDeleteRenderbuffersOES)(GLsizei n, const GLuint * renderbuffers) {
     CALL_GL_API(glDeleteRenderbuffersOES, n, renderbuffers);
 }
-void API_ENTRY(glGenRenderbuffersOES)(GLsizei n, GLuint* renderbuffers) {
+void API_ENTRY(glGenRenderbuffersOES)(GLsizei n, GLuint * renderbuffers) {
     CALL_GL_API(glGenRenderbuffersOES, n, renderbuffers);
 }
 void API_ENTRY(glRenderbufferStorageOES)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) {
     CALL_GL_API(glRenderbufferStorageOES, target, internalformat, width, height);
 }
-void API_ENTRY(glGetRenderbufferParameterivOES)(GLenum target, GLenum pname, GLint* params) {
+void API_ENTRY(glGetRenderbufferParameterivOES)(GLenum target, GLenum pname, GLint * params) {
     CALL_GL_API(glGetRenderbufferParameterivOES, target, pname, params);
 }
 GLboolean API_ENTRY(glIsFramebufferOES)(GLuint framebuffer) {
@@ -178,10 +256,10 @@
 void API_ENTRY(glBindFramebufferOES)(GLenum target, GLuint framebuffer) {
     CALL_GL_API(glBindFramebufferOES, target, framebuffer);
 }
-void API_ENTRY(glDeleteFramebuffersOES)(GLsizei n, const GLuint* framebuffers) {
+void API_ENTRY(glDeleteFramebuffersOES)(GLsizei n, const GLuint * framebuffers) {
     CALL_GL_API(glDeleteFramebuffersOES, n, framebuffers);
 }
-void API_ENTRY(glGenFramebuffersOES)(GLsizei n, GLuint* framebuffers) {
+void API_ENTRY(glGenFramebuffersOES)(GLsizei n, GLuint * framebuffers) {
     CALL_GL_API(glGenFramebuffersOES, n, framebuffers);
 }
 GLenum API_ENTRY(glCheckFramebufferStatusOES)(GLenum target) {
@@ -193,19 +271,19 @@
 void API_ENTRY(glFramebufferTexture2DOES)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
     CALL_GL_API(glFramebufferTexture2DOES, target, attachment, textarget, texture, level);
 }
-void API_ENTRY(glGetFramebufferAttachmentParameterivOES)(GLenum target, GLenum attachment, GLenum pname, GLint* params) {
+void API_ENTRY(glGetFramebufferAttachmentParameterivOES)(GLenum target, GLenum attachment, GLenum pname, GLint * params) {
     CALL_GL_API(glGetFramebufferAttachmentParameterivOES, target, attachment, pname, params);
 }
 void API_ENTRY(glGenerateMipmapOES)(GLenum target) {
     CALL_GL_API(glGenerateMipmapOES, target);
 }
-void* API_ENTRY(glMapBufferOES)(GLenum target, GLenum access) {
+void * API_ENTRY(glMapBufferOES)(GLenum target, GLenum access) {
     CALL_GL_API_RETURN(glMapBufferOES, target, access);
 }
 GLboolean API_ENTRY(glUnmapBufferOES)(GLenum target) {
     CALL_GL_API_RETURN(glUnmapBufferOES, target);
 }
-void API_ENTRY(glGetBufferPointervOES)(GLenum target, GLenum pname, GLvoid ** params) {
+void API_ENTRY(glGetBufferPointervOES)(GLenum target, GLenum pname, void ** params) {
     CALL_GL_API(glGetBufferPointervOES, target, pname, params);
 }
 void API_ENTRY(glCurrentPaletteMatrixOES)(GLuint matrixpaletteindex) {
@@ -214,103 +292,127 @@
 void API_ENTRY(glLoadPaletteFromModelViewMatrixOES)(void) {
     CALL_GL_API(glLoadPaletteFromModelViewMatrixOES);
 }
-void API_ENTRY(glMatrixIndexPointerOES)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
+void API_ENTRY(glMatrixIndexPointerOES)(GLint size, GLenum type, GLsizei stride, const void * pointer) {
     CALL_GL_API(glMatrixIndexPointerOES, size, type, stride, pointer);
 }
-void API_ENTRY(glWeightPointerOES)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
+void API_ENTRY(glWeightPointerOES)(GLint size, GLenum type, GLsizei stride, const void * pointer) {
     CALL_GL_API(glWeightPointerOES, size, type, stride, pointer);
 }
-GLbitfield API_ENTRY(glQueryMatrixxOES)(GLfixed mantissa[16], GLint exponent[16]) {
+void API_ENTRY(glPointSizePointerOES)(GLenum type, GLsizei stride, const void * pointer) {
+    CALL_GL_API(glPointSizePointerOES, type, stride, pointer);
+}
+GLbitfield API_ENTRY(glQueryMatrixxOES)(GLfixed * mantissa, GLint * exponent) {
     CALL_GL_API_RETURN(glQueryMatrixxOES, mantissa, exponent);
 }
-void API_ENTRY(glDepthRangefOES)(GLclampf zNear, GLclampf zFar) {
-    CALL_GL_API(glDepthRangefOES, zNear, zFar);
-}
-void API_ENTRY(glFrustumfOES)(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) {
-    CALL_GL_API(glFrustumfOES, left, right, bottom, top, zNear, zFar);
-}
-void API_ENTRY(glOrthofOES)(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) {
-    CALL_GL_API(glOrthofOES, left, right, bottom, top, zNear, zFar);
-}
-void API_ENTRY(glClipPlanefOES)(GLenum plane, const GLfloat *equation) {
-    CALL_GL_API(glClipPlanefOES, plane, equation);
-}
-void API_ENTRY(glGetClipPlanefOES)(GLenum pname, GLfloat eqn[4]) {
-    CALL_GL_API(glGetClipPlanefOES, pname, eqn);
-}
 void API_ENTRY(glClearDepthfOES)(GLclampf depth) {
     CALL_GL_API(glClearDepthfOES, depth);
 }
+void API_ENTRY(glClipPlanefOES)(GLenum plane, const GLfloat * equation) {
+    CALL_GL_API(glClipPlanefOES, plane, equation);
+}
+void API_ENTRY(glDepthRangefOES)(GLclampf n, GLclampf f) {
+    CALL_GL_API(glDepthRangefOES, n, f);
+}
+void API_ENTRY(glFrustumfOES)(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f) {
+    CALL_GL_API(glFrustumfOES, l, r, b, t, n, f);
+}
+void API_ENTRY(glGetClipPlanefOES)(GLenum plane, GLfloat * equation) {
+    CALL_GL_API(glGetClipPlanefOES, plane, equation);
+}
+void API_ENTRY(glOrthofOES)(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f) {
+    CALL_GL_API(glOrthofOES, l, r, b, t, n, f);
+}
 void API_ENTRY(glTexGenfOES)(GLenum coord, GLenum pname, GLfloat param) {
     CALL_GL_API(glTexGenfOES, coord, pname, param);
 }
-void API_ENTRY(glTexGenfvOES)(GLenum coord, GLenum pname, const GLfloat *params) {
+void API_ENTRY(glTexGenfvOES)(GLenum coord, GLenum pname, const GLfloat * params) {
     CALL_GL_API(glTexGenfvOES, coord, pname, params);
 }
 void API_ENTRY(glTexGeniOES)(GLenum coord, GLenum pname, GLint param) {
     CALL_GL_API(glTexGeniOES, coord, pname, param);
 }
-void API_ENTRY(glTexGenivOES)(GLenum coord, GLenum pname, const GLint *params) {
+void API_ENTRY(glTexGenivOES)(GLenum coord, GLenum pname, const GLint * params) {
     CALL_GL_API(glTexGenivOES, coord, pname, params);
 }
-void API_ENTRY(glTexGenxOES)(GLenum coord, GLenum pname, GLfixed param) {
-    CALL_GL_API(glTexGenxOES, coord, pname, param);
-}
-void API_ENTRY(glTexGenxvOES)(GLenum coord, GLenum pname, const GLfixed *params) {
-    CALL_GL_API(glTexGenxvOES, coord, pname, params);
-}
-void API_ENTRY(glGetTexGenfvOES)(GLenum coord, GLenum pname, GLfloat *params) {
+void API_ENTRY(glGetTexGenfvOES)(GLenum coord, GLenum pname, GLfloat * params) {
     CALL_GL_API(glGetTexGenfvOES, coord, pname, params);
 }
-void API_ENTRY(glGetTexGenivOES)(GLenum coord, GLenum pname, GLint *params) {
+void API_ENTRY(glGetTexGenivOES)(GLenum coord, GLenum pname, GLint * params) {
     CALL_GL_API(glGetTexGenivOES, coord, pname, params);
 }
-void API_ENTRY(glGetTexGenxvOES)(GLenum coord, GLenum pname, GLfixed *params) {
-    CALL_GL_API(glGetTexGenxvOES, coord, pname, params);
-}
 void API_ENTRY(glBindVertexArrayOES)(GLuint array) {
     CALL_GL_API(glBindVertexArrayOES, array);
 }
-void API_ENTRY(glDeleteVertexArraysOES)(GLsizei n, const GLuint *arrays) {
+void API_ENTRY(glDeleteVertexArraysOES)(GLsizei n, const GLuint * arrays) {
     CALL_GL_API(glDeleteVertexArraysOES, n, arrays);
 }
-void API_ENTRY(glGenVertexArraysOES)(GLsizei n, GLuint *arrays) {
+void API_ENTRY(glGenVertexArraysOES)(GLsizei n, GLuint * arrays) {
     CALL_GL_API(glGenVertexArraysOES, n, arrays);
 }
 GLboolean API_ENTRY(glIsVertexArrayOES)(GLuint array) {
     CALL_GL_API_RETURN(glIsVertexArrayOES, array);
 }
+void API_ENTRY(glCopyTextureLevelsAPPLE)(GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount) {
+    CALL_GL_API(glCopyTextureLevelsAPPLE, destinationTexture, sourceTexture, sourceBaseLevel, sourceLevelCount);
+}
 void API_ENTRY(glRenderbufferStorageMultisampleAPPLE)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
     CALL_GL_API(glRenderbufferStorageMultisampleAPPLE, target, samples, internalformat, width, height);
 }
 void API_ENTRY(glResolveMultisampleFramebufferAPPLE)(void) {
     CALL_GL_API(glResolveMultisampleFramebufferAPPLE);
 }
-void API_ENTRY(glDiscardFramebufferEXT)(GLenum target, GLsizei numAttachments, const GLenum *attachments) {
+GLsync API_ENTRY(glFenceSyncAPPLE)(GLenum condition, GLbitfield flags) {
+    CALL_GL_API_RETURN(glFenceSyncAPPLE, condition, flags);
+}
+GLboolean API_ENTRY(glIsSyncAPPLE)(GLsync sync) {
+    CALL_GL_API_RETURN(glIsSyncAPPLE, sync);
+}
+void API_ENTRY(glDeleteSyncAPPLE)(GLsync sync) {
+    CALL_GL_API(glDeleteSyncAPPLE, sync);
+}
+GLenum API_ENTRY(glClientWaitSyncAPPLE)(GLsync sync, GLbitfield flags, GLuint64 timeout) {
+    CALL_GL_API_RETURN(glClientWaitSyncAPPLE, sync, flags, timeout);
+}
+void API_ENTRY(glWaitSyncAPPLE)(GLsync sync, GLbitfield flags, GLuint64 timeout) {
+    CALL_GL_API(glWaitSyncAPPLE, sync, flags, timeout);
+}
+void API_ENTRY(glGetInteger64vAPPLE)(GLenum pname, GLint64 * params) {
+    CALL_GL_API(glGetInteger64vAPPLE, pname, params);
+}
+void API_ENTRY(glGetSyncivAPPLE)(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values) {
+    CALL_GL_API(glGetSyncivAPPLE, sync, pname, bufSize, length, values);
+}
+void API_ENTRY(glDiscardFramebufferEXT)(GLenum target, GLsizei numAttachments, const GLenum * attachments) {
     CALL_GL_API(glDiscardFramebufferEXT, target, numAttachments, attachments);
 }
+void * API_ENTRY(glMapBufferRangeEXT)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
+    CALL_GL_API_RETURN(glMapBufferRangeEXT, target, offset, length, access);
+}
+void API_ENTRY(glFlushMappedBufferRangeEXT)(GLenum target, GLintptr offset, GLsizeiptr length) {
+    CALL_GL_API(glFlushMappedBufferRangeEXT, target, offset, length);
+}
+void API_ENTRY(glMultiDrawArraysEXT)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei primcount) {
+    CALL_GL_API(glMultiDrawArraysEXT, mode, first, count, primcount);
+}
+void API_ENTRY(glMultiDrawElementsEXT)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei primcount) {
+    CALL_GL_API(glMultiDrawElementsEXT, mode, count, type, indices, primcount);
+}
 void API_ENTRY(glRenderbufferStorageMultisampleEXT)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
     CALL_GL_API(glRenderbufferStorageMultisampleEXT, target, samples, internalformat, width, height);
 }
 void API_ENTRY(glFramebufferTexture2DMultisampleEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) {
     CALL_GL_API(glFramebufferTexture2DMultisampleEXT, target, attachment, textarget, texture, level, samples);
 }
-void API_ENTRY(glMultiDrawArraysEXT)(GLenum mode, GLint *first, GLsizei *count, GLsizei primcount) {
-    CALL_GL_API(glMultiDrawArraysEXT, mode, first, count, primcount);
-}
-void API_ENTRY(glMultiDrawElementsEXT)(GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount) {
-    CALL_GL_API(glMultiDrawElementsEXT, mode, count, type, indices, primcount);
-}
 GLenum API_ENTRY(glGetGraphicsResetStatusEXT)(void) {
     CALL_GL_API_RETURN(glGetGraphicsResetStatusEXT);
 }
-void API_ENTRY(glReadnPixelsEXT)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data) {
+void API_ENTRY(glReadnPixelsEXT)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data) {
     CALL_GL_API(glReadnPixelsEXT, x, y, width, height, format, type, bufSize, data);
 }
-void API_ENTRY(glGetnUniformfvEXT)(GLuint program, GLint location, GLsizei bufSize, float *params) {
+void API_ENTRY(glGetnUniformfvEXT)(GLuint program, GLint location, GLsizei bufSize, GLfloat * params) {
     CALL_GL_API(glGetnUniformfvEXT, program, location, bufSize, params);
 }
-void API_ENTRY(glGetnUniformivEXT)(GLuint program, GLint location, GLsizei bufSize, GLint *params) {
+void API_ENTRY(glGetnUniformivEXT)(GLuint program, GLint location, GLsizei bufSize, GLint * params) {
     CALL_GL_API(glGetnUniformivEXT, program, location, bufSize, params);
 }
 void API_ENTRY(glTexStorage1DEXT)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width) {
@@ -331,22 +433,22 @@
 void API_ENTRY(glTextureStorage3DEXT)(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) {
     CALL_GL_API(glTextureStorage3DEXT, texture, target, levels, internalformat, width, height, depth);
 }
-void API_ENTRY(glClipPlanefIMG)(GLenum p, const GLfloat *eqn) {
-    CALL_GL_API(glClipPlanefIMG, p, eqn);
-}
-void API_ENTRY(glClipPlanexIMG)(GLenum p, const GLfixed *eqn) {
-    CALL_GL_API(glClipPlanexIMG, p, eqn);
-}
 void API_ENTRY(glRenderbufferStorageMultisampleIMG)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
     CALL_GL_API(glRenderbufferStorageMultisampleIMG, target, samples, internalformat, width, height);
 }
 void API_ENTRY(glFramebufferTexture2DMultisampleIMG)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) {
     CALL_GL_API(glFramebufferTexture2DMultisampleIMG, target, attachment, textarget, texture, level, samples);
 }
-void API_ENTRY(glDeleteFencesNV)(GLsizei n, const GLuint *fences) {
+void API_ENTRY(glClipPlanefIMG)(GLenum p, const GLfloat * eqn) {
+    CALL_GL_API(glClipPlanefIMG, p, eqn);
+}
+void API_ENTRY(glClipPlanexIMG)(GLenum p, const GLfixed * eqn) {
+    CALL_GL_API(glClipPlanexIMG, p, eqn);
+}
+void API_ENTRY(glDeleteFencesNV)(GLsizei n, const GLuint * fences) {
     CALL_GL_API(glDeleteFencesNV, n, fences);
 }
-void API_ENTRY(glGenFencesNV)(GLsizei n, GLuint *fences) {
+void API_ENTRY(glGenFencesNV)(GLsizei n, GLuint * fences) {
     CALL_GL_API(glGenFencesNV, n, fences);
 }
 GLboolean API_ENTRY(glIsFenceNV)(GLuint fence) {
@@ -355,7 +457,7 @@
 GLboolean API_ENTRY(glTestFenceNV)(GLuint fence) {
     CALL_GL_API_RETURN(glTestFenceNV, fence);
 }
-void API_ENTRY(glGetFenceivNV)(GLuint fence, GLenum pname, GLint *params) {
+void API_ENTRY(glGetFenceivNV)(GLuint fence, GLenum pname, GLint * params) {
     CALL_GL_API(glGetFenceivNV, fence, pname, params);
 }
 void API_ENTRY(glFinishFenceNV)(GLuint fence) {
@@ -364,10 +466,10 @@
 void API_ENTRY(glSetFenceNV)(GLuint fence, GLenum condition) {
     CALL_GL_API(glSetFenceNV, fence, condition);
 }
-void API_ENTRY(glGetDriverControlsQCOM)(GLint *num, GLsizei size, GLuint *driverControls) {
+void API_ENTRY(glGetDriverControlsQCOM)(GLint * num, GLsizei size, GLuint * driverControls) {
     CALL_GL_API(glGetDriverControlsQCOM, num, size, driverControls);
 }
-void API_ENTRY(glGetDriverControlStringQCOM)(GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString) {
+void API_ENTRY(glGetDriverControlStringQCOM)(GLuint driverControl, GLsizei bufSize, GLsizei * length, GLchar * driverControlString) {
     CALL_GL_API(glGetDriverControlStringQCOM, driverControl, bufSize, length, driverControlString);
 }
 void API_ENTRY(glEnableDriverControlQCOM)(GLuint driverControl) {
@@ -376,40 +478,40 @@
 void API_ENTRY(glDisableDriverControlQCOM)(GLuint driverControl) {
     CALL_GL_API(glDisableDriverControlQCOM, driverControl);
 }
-void API_ENTRY(glExtGetTexturesQCOM)(GLuint *textures, GLint maxTextures, GLint *numTextures) {
+void API_ENTRY(glExtGetTexturesQCOM)(GLuint * textures, GLint maxTextures, GLint * numTextures) {
     CALL_GL_API(glExtGetTexturesQCOM, textures, maxTextures, numTextures);
 }
-void API_ENTRY(glExtGetBuffersQCOM)(GLuint *buffers, GLint maxBuffers, GLint *numBuffers) {
+void API_ENTRY(glExtGetBuffersQCOM)(GLuint * buffers, GLint maxBuffers, GLint * numBuffers) {
     CALL_GL_API(glExtGetBuffersQCOM, buffers, maxBuffers, numBuffers);
 }
-void API_ENTRY(glExtGetRenderbuffersQCOM)(GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers) {
+void API_ENTRY(glExtGetRenderbuffersQCOM)(GLuint * renderbuffers, GLint maxRenderbuffers, GLint * numRenderbuffers) {
     CALL_GL_API(glExtGetRenderbuffersQCOM, renderbuffers, maxRenderbuffers, numRenderbuffers);
 }
-void API_ENTRY(glExtGetFramebuffersQCOM)(GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers) {
+void API_ENTRY(glExtGetFramebuffersQCOM)(GLuint * framebuffers, GLint maxFramebuffers, GLint * numFramebuffers) {
     CALL_GL_API(glExtGetFramebuffersQCOM, framebuffers, maxFramebuffers, numFramebuffers);
 }
-void API_ENTRY(glExtGetTexLevelParameterivQCOM)(GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params) {
+void API_ENTRY(glExtGetTexLevelParameterivQCOM)(GLuint texture, GLenum face, GLint level, GLenum pname, GLint * params) {
     CALL_GL_API(glExtGetTexLevelParameterivQCOM, texture, face, level, pname, params);
 }
 void API_ENTRY(glExtTexObjectStateOverrideiQCOM)(GLenum target, GLenum pname, GLint param) {
     CALL_GL_API(glExtTexObjectStateOverrideiQCOM, target, pname, param);
 }
-void API_ENTRY(glExtGetTexSubImageQCOM)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels) {
+void API_ENTRY(glExtGetTexSubImageQCOM)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void * texels) {
     CALL_GL_API(glExtGetTexSubImageQCOM, target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, texels);
 }
-void API_ENTRY(glExtGetBufferPointervQCOM)(GLenum target, GLvoid **params) {
+void API_ENTRY(glExtGetBufferPointervQCOM)(GLenum target, void ** params) {
     CALL_GL_API(glExtGetBufferPointervQCOM, target, params);
 }
-void API_ENTRY(glExtGetShadersQCOM)(GLuint *shaders, GLint maxShaders, GLint *numShaders) {
+void API_ENTRY(glExtGetShadersQCOM)(GLuint * shaders, GLint maxShaders, GLint * numShaders) {
     CALL_GL_API(glExtGetShadersQCOM, shaders, maxShaders, numShaders);
 }
-void API_ENTRY(glExtGetProgramsQCOM)(GLuint *programs, GLint maxPrograms, GLint *numPrograms) {
+void API_ENTRY(glExtGetProgramsQCOM)(GLuint * programs, GLint maxPrograms, GLint * numPrograms) {
     CALL_GL_API(glExtGetProgramsQCOM, programs, maxPrograms, numPrograms);
 }
 GLboolean API_ENTRY(glExtIsProgramBinaryQCOM)(GLuint program) {
     CALL_GL_API_RETURN(glExtIsProgramBinaryQCOM, program);
 }
-void API_ENTRY(glExtGetProgramBinarySourceQCOM)(GLuint program, GLenum shadertype, GLchar *source, GLint *length) {
+void API_ENTRY(glExtGetProgramBinarySourceQCOM)(GLuint program, GLenum shadertype, GLchar * source, GLint * length) {
     CALL_GL_API(glExtGetProgramBinarySourceQCOM, program, shadertype, source, length);
 }
 void API_ENTRY(glStartTilingQCOM)(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask) {
diff --git a/opengl/libs/GLES_trace/Android.mk b/opengl/libs/GLES_trace/Android.mk
index 846932d..24c4be2 100644
--- a/opengl/libs/GLES_trace/Android.mk
+++ b/opengl/libs/GLES_trace/Android.mk
@@ -1,6 +1,7 @@
 LOCAL_PATH:= $(call my-dir)
 
 include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 
 LOCAL_SRC_FILES := \
     src/gltrace_api.cpp \
@@ -9,20 +10,18 @@
     src/gltrace_eglapi.cpp \
     src/gltrace_fixup.cpp \
     src/gltrace_hooks.cpp \
-    src/gltrace.pb.cpp \
-    src/gltrace_transport.cpp
+    src/gltrace_transport.cpp \
+    $(call all-proto-files-under, proto)
 
 LOCAL_C_INCLUDES := \
     $(LOCAL_PATH) \
     $(LOCAL_PATH)/../ \
-    external/stlport/stlport \
-    external/protobuf/src \
-    external \
-    bionic
+    external
 
-LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI
-LOCAL_STATIC_LIBRARIES := libprotobuf-cpp-2.3.0-lite liblzf
-LOCAL_SHARED_LIBRARIES := libcutils libutils liblog libstlport
+LOCAL_STATIC_LIBRARIES := liblzf
+LOCAL_SHARED_LIBRARIES := libcutils libutils liblog
+
+LOCAL_PROTOC_OPTIMIZE_TYPE := lite
 
 LOCAL_CFLAGS += -DLOG_TAG=\"libGLES_trace\"
 
diff --git a/opengl/libs/GLES_trace/dev.make b/opengl/libs/GLES_trace/dev.make
index a46260c..3405d8e 100644
--- a/opengl/libs/GLES_trace/dev.make
+++ b/opengl/libs/GLES_trace/dev.make
@@ -1,11 +1,6 @@
 ## NOTE
 ## This file is used for development purposes only. It is not used by the build system.
 
-# generate protocol buffer files
-genproto: gltrace.proto
-	aprotoc --cpp_out=src --java_out=java gltrace.proto
-	mv src/gltrace.pb.cc src/gltrace.pb.cpp
-
 sync:
 	adb root
 	adb remount
diff --git a/opengl/libs/GLES_trace/gltrace.proto b/opengl/libs/GLES_trace/proto/gltrace.proto
similarity index 75%
rename from opengl/libs/GLES_trace/gltrace.proto
rename to opengl/libs/GLES_trace/proto/gltrace.proto
index f8f4938..0344787 100644
--- a/opengl/libs/GLES_trace/gltrace.proto
+++ b/opengl/libs/GLES_trace/proto/gltrace.proto
@@ -23,6 +23,8 @@
 
 message GLMessage {
     enum Function {
+        option allow_alias = true;
+
         glActiveTexture = 0;
         glAlphaFunc = 1;
         glAlphaFuncx = 2;
@@ -503,7 +505,28 @@
         glTexStorage2D = 477;
         glTexStorage3D = 478;
         glGetInternalformativ = 479;
-
+        glBeginPerfQueryINTEL = 480;
+        glCreatePerfQueryINTEL = 481;
+        glDeletePerfQueryINTEL = 482;
+        glEndPerfQueryINTEL = 483;
+        glGetFirstPerfQueryIdINTEL = 484;
+        glGetNextPerfQueryIdINTEL = 485;
+        glGetPerfCounterInfoINTEL = 486;
+        glGetPerfQueryDataINTEL = 487;
+        glGetPerfQueryIdByNameINTEL = 488;
+        glGetPerfQueryInfoINTEL = 489;
+        glBlendBarrierKHR = 490;
+        glBlendBarrierNV = 491;
+        glBlendParameteriNV = 492;
+        glBlitFramebufferNV = 493;
+        glFenceSyncAPPLE = 494;
+        glIsSyncAPPLE = 495;
+        glDeleteSyncAPPLE = 496;
+        glClientWaitSyncAPPLE = 497;
+        glWaitSyncAPPLE = 498;
+        glGetInteger64vAPPLE = 499;
+        glGetSyncivAPPLE = 500;
+        glCopyBufferSubDataNV = 501;
         glActiveShaderProgramEXT = 502;
         glAlphaFuncQCOM = 503;
         glBeginQueryEXT = 504;
@@ -565,6 +588,175 @@
         glTextureStorage3DEXT = 559;
         glUseProgramStagesEXT = 560;
         glValidateProgramPipelineEXT = 561;
+        glCopyTextureLevelsAPPLE = 562;
+        glDebugMessageControlKHR = 563;
+        glDebugMessageInsertKHR = 564;
+        glDebugMessageCallbackKHR = 565;
+        glGetDebugMessageLogKHR = 566;
+        glPushDebugGroupKHR = 567;
+        glPopDebugGroupKHR = 568;
+        glObjectLabelKHR = 569;
+        glGetObjectLabelKHR = 570;
+        glObjectPtrLabelKHR = 571;
+        glGetObjectPtrLabelKHR = 572;
+        glGetPointervKHR = 573;
+        glDrawArraysInstancedANGLE = 574;
+        glDrawElementsInstancedANGLE = 575;
+        glVertexAttribDivisorANGLE = 576;
+        glDrawArraysInstancedEXT = 577;
+        glDrawElementsInstancedEXT = 578;
+        glVertexAttribDivisorEXT = 579;
+        glDrawArraysInstancedNV = 580;
+        glDrawElementsInstancedNV = 581;
+        glVertexAttribDivisorNV = 582;
+        glDrawBuffersEXT = 583;
+        glReadBufferIndexedEXT = 584;
+        glDrawBuffersIndexedEXT = 585;
+        glGetIntegeri_vEXT = 586;
+        glMapBufferRangeEXT = 587;
+        glFlushMappedBufferRangeEXT = 588;
+        glQueryCounterEXT = 589;
+        glGetQueryObjecti64vEXT = 590;
+        glGetQueryObjectivEXT = 591;
+        glGetQueryObjectui64vEXT = 592;
+        glGetTranslatedShaderSourceANGLE = 593;
+        glMinSampleShadingOES = 594;
+        glMultiTexCoord1bOES = 595;
+        glMultiTexCoord1bvOES = 596;
+        glMultiTexCoord2bOES = 597;
+        glMultiTexCoord2bvOES = 598;
+        glMultiTexCoord3bOES = 599;
+        glMultiTexCoord3bvOES = 600;
+        glMultiTexCoord4bOES = 601;
+        glMultiTexCoord4bvOES = 602;
+        glTexCoord1bOES = 603;
+        glTexCoord1bvOES = 604;
+        glTexCoord2bOES = 605;
+        glTexCoord2bvOES = 606;
+        glTexCoord3bOES = 607;
+        glTexCoord3bvOES = 608;
+        glTexCoord4bOES = 609;
+        glTexCoord4bvOES = 610;
+        glVertex2bOES = 611;
+        glVertex2bvOES = 612;
+        glVertex3bOES = 613;
+        glVertex3bvOES = 614;
+        glVertex4bOES = 615;
+        glVertex4bvOES = 616;
+        glProgramUniform1uiEXT = 617;
+        glProgramUniform2uiEXT = 618;
+        glProgramUniform3uiEXT = 619;
+        glProgramUniform4uiEXT = 620;
+        glProgramUniform1uivEXT = 621;
+        glProgramUniform2uivEXT = 622;
+        glProgramUniform3uivEXT = 623;
+        glProgramUniform4uivEXT = 624;
+        glProgramUniformMatrix2x3fvEXT = 625;
+        glProgramUniformMatrix3x2fvEXT = 626;
+        glProgramUniformMatrix2x4fvEXT = 627;
+        glProgramUniformMatrix4x2fvEXT = 628;
+        glProgramUniformMatrix3x4fvEXT = 629;
+        glProgramUniformMatrix4x3fvEXT = 630;
+        glRenderbufferStorageMultisampleNV = 631;
+        glSampleCoverageOES = 632;
+        glTexStorage3DMultisampleOES = 633;
+        glUniformMatrix2x3fvNV = 634;
+        glUniformMatrix3x2fvNV = 635;
+        glUniformMatrix2x4fvNV = 636;
+        glUniformMatrix4x2fvNV = 637;
+        glUniformMatrix3x4fvNV = 638;
+        glUniformMatrix4x3fvNV = 639;
+        glActiveShaderProgram = 640;
+        glBindImageTexture = 641;
+        glBindProgramPipeline = 642;
+        glBindVertexBuffer = 643;
+        glCreateShaderProgramv = 644;
+        glDeleteProgramPipelines = 645;
+        glDispatchCompute = 646;
+        glDispatchComputeIndirect = 647;
+        glDrawArraysIndirect = 648;
+        glDrawElementsIndirect = 649;
+        glFramebufferParameteri = 650;
+        glGenProgramPipelines = 651;
+        glGetBooleani_v = 652;
+        glGetFramebufferParameteriv = 653;
+        glGetMultisamplefv = 654;
+        glGetProgramInterfaceiv = 655;
+        glGetProgramPipelineInfoLog = 656;
+        glGetProgramPipelineiv = 657;
+        glGetProgramResourceIndex = 658;
+        glGetProgramResourceLocation = 659;
+        glGetProgramResourceName = 660;
+        glGetProgramResourceiv = 661;
+        glGetTexLevelParameterfv = 662;
+        glGetTexLevelParameteriv = 663;
+        glIsProgramPipeline = 664;
+        glMemoryBarrier = 665;
+        glMemoryBarrierByRegion = 666;
+        glProgramUniform1f = 667;
+        glProgramUniform1fv = 668;
+        glProgramUniform1i = 669;
+        glProgramUniform1iv = 670;
+        glProgramUniform1ui = 671;
+        glProgramUniform1uiv = 672;
+        glProgramUniform2f = 673;
+        glProgramUniform2fv = 674;
+        glProgramUniform2i = 675;
+        glProgramUniform2iv = 676;
+        glProgramUniform2ui = 677;
+        glProgramUniform2uiv = 678;
+        glProgramUniform3f = 679;
+        glProgramUniform3fv = 680;
+        glProgramUniform3i = 681;
+        glProgramUniform3iv = 682;
+        glProgramUniform3ui = 683;
+        glProgramUniform3uiv = 684;
+        glProgramUniform4f = 685;
+        glProgramUniform4fv = 686;
+        glProgramUniform4i = 687;
+        glProgramUniform4iv = 688;
+        glProgramUniform4ui = 689;
+        glProgramUniform4uiv = 690;
+        glProgramUniformMatrix2fv = 691;
+        glProgramUniformMatrix2x3fv = 692;
+        glProgramUniformMatrix2x4fv = 693;
+        glProgramUniformMatrix3fv = 694;
+        glProgramUniformMatrix3x2fv = 695;
+        glProgramUniformMatrix3x4fv = 696;
+        glProgramUniformMatrix4fv = 697;
+        glProgramUniformMatrix4x2fv = 698;
+        glProgramUniformMatrix4x3fv = 699;
+        glSampleMaski = 700;
+        glTexStorage2DMultisample = 701;
+        glUseProgramStages = 702;
+        glValidateProgramPipeline = 703;
+        glVertexAttribBinding = 704;
+        glVertexAttribFormat = 705;
+        glVertexAttribIFormat = 706;
+        glVertexBindingDivisor = 707;
+        glBlendEquationSeparateiEXT = 708;
+        glBlendEquationiEXT = 709;
+        glBlendFuncSeparateiEXT = 710;
+        glBlendFunciEXT = 711;
+        glColorMaskiEXT = 712;
+        glCopyImageSubDataEXT = 713;
+        glDisableiEXT = 714;
+        glEnableiEXT = 715;
+        glFramebufferTextureEXT = 716;
+        glGetSamplerParameterIivEXT = 717;
+        glGetSamplerParameterIuivEXT = 718;
+        glGetTexParameterIivEXT = 719;
+        glGetTexParameterIuivEXT = 720;
+        glIsEnablediEXT = 721;
+        glPatchParameteriEXT = 722;
+        glPrimitiveBoundingBoxEXT = 723;
+        glSamplerParameterIivEXT = 724;
+        glSamplerParameterIuivEXT = 725;
+        glTexBufferEXT = 726;
+        glTexBufferRangeEXT = 727;
+        glTexParameterIivEXT = 728;
+        glTexParameterIuivEXT = 729;
+        glTextureViewEXT = 730;
 
         eglGetDisplay = 2000;
         eglInitialize = 2001;
diff --git a/opengl/libs/GLES_trace/src/gltrace.pb.cpp b/opengl/libs/GLES_trace/src/gltrace.pb.cpp
deleted file mode 100644
index ed9a457..0000000
--- a/opengl/libs/GLES_trace/src/gltrace.pb.cpp
+++ /dev/null
@@ -1,2333 +0,0 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-
-#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
-#include "gltrace.pb.h"
-#include <google/protobuf/stubs/once.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/wire_format_lite_inl.h>
-// @@protoc_insertion_point(includes)
-
-namespace android {
-namespace gltrace {
-
-void protobuf_ShutdownFile_gltrace_2eproto() {
-  delete GLMessage::default_instance_;
-  delete GLMessage_DataType::default_instance_;
-  delete GLMessage_FrameBuffer::default_instance_;
-}
-
-void protobuf_AddDesc_gltrace_2eproto() {
-  static bool already_here = false;
-  if (already_here) return;
-  already_here = true;
-  GOOGLE_PROTOBUF_VERIFY_VERSION;
-
-  GLMessage::default_instance_ = new GLMessage();
-  GLMessage_DataType::default_instance_ = new GLMessage_DataType();
-  GLMessage_FrameBuffer::default_instance_ = new GLMessage_FrameBuffer();
-  GLMessage::default_instance_->InitAsDefaultInstance();
-  GLMessage_DataType::default_instance_->InitAsDefaultInstance();
-  GLMessage_FrameBuffer::default_instance_->InitAsDefaultInstance();
-  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_gltrace_2eproto);
-}
-
-// Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_gltrace_2eproto {
-  StaticDescriptorInitializer_gltrace_2eproto() {
-    protobuf_AddDesc_gltrace_2eproto();
-  }
-} static_descriptor_initializer_gltrace_2eproto_;
-
-
-// ===================================================================
-
-bool GLMessage_Function_IsValid(int value) {
-  switch(value) {
-    case 0:
-    case 1:
-    case 2:
-    case 3:
-    case 4:
-    case 5:
-    case 6:
-    case 7:
-    case 8:
-    case 9:
-    case 10:
-    case 11:
-    case 12:
-    case 13:
-    case 14:
-    case 15:
-    case 16:
-    case 17:
-    case 18:
-    case 19:
-    case 20:
-    case 21:
-    case 22:
-    case 23:
-    case 24:
-    case 25:
-    case 26:
-    case 27:
-    case 28:
-    case 29:
-    case 30:
-    case 31:
-    case 32:
-    case 33:
-    case 34:
-    case 35:
-    case 36:
-    case 37:
-    case 38:
-    case 39:
-    case 40:
-    case 41:
-    case 42:
-    case 43:
-    case 44:
-    case 45:
-    case 46:
-    case 47:
-    case 48:
-    case 49:
-    case 50:
-    case 51:
-    case 52:
-    case 53:
-    case 54:
-    case 55:
-    case 56:
-    case 57:
-    case 58:
-    case 59:
-    case 60:
-    case 61:
-    case 62:
-    case 63:
-    case 64:
-    case 65:
-    case 66:
-    case 67:
-    case 68:
-    case 69:
-    case 70:
-    case 71:
-    case 72:
-    case 73:
-    case 74:
-    case 75:
-    case 76:
-    case 77:
-    case 78:
-    case 79:
-    case 80:
-    case 81:
-    case 82:
-    case 83:
-    case 84:
-    case 85:
-    case 86:
-    case 87:
-    case 88:
-    case 89:
-    case 90:
-    case 91:
-    case 92:
-    case 93:
-    case 94:
-    case 95:
-    case 96:
-    case 97:
-    case 98:
-    case 99:
-    case 100:
-    case 101:
-    case 102:
-    case 103:
-    case 104:
-    case 105:
-    case 106:
-    case 107:
-    case 108:
-    case 109:
-    case 110:
-    case 111:
-    case 112:
-    case 113:
-    case 114:
-    case 115:
-    case 116:
-    case 117:
-    case 118:
-    case 119:
-    case 120:
-    case 121:
-    case 122:
-    case 123:
-    case 124:
-    case 125:
-    case 126:
-    case 127:
-    case 128:
-    case 129:
-    case 130:
-    case 131:
-    case 132:
-    case 133:
-    case 134:
-    case 135:
-    case 136:
-    case 137:
-    case 138:
-    case 139:
-    case 140:
-    case 141:
-    case 142:
-    case 143:
-    case 144:
-    case 145:
-    case 146:
-    case 147:
-    case 148:
-    case 149:
-    case 150:
-    case 151:
-    case 152:
-    case 153:
-    case 154:
-    case 155:
-    case 156:
-    case 157:
-    case 158:
-    case 159:
-    case 160:
-    case 161:
-    case 162:
-    case 163:
-    case 164:
-    case 165:
-    case 166:
-    case 167:
-    case 168:
-    case 169:
-    case 170:
-    case 171:
-    case 172:
-    case 173:
-    case 174:
-    case 175:
-    case 176:
-    case 177:
-    case 178:
-    case 179:
-    case 180:
-    case 181:
-    case 182:
-    case 183:
-    case 184:
-    case 185:
-    case 186:
-    case 187:
-    case 188:
-    case 189:
-    case 190:
-    case 191:
-    case 192:
-    case 193:
-    case 194:
-    case 195:
-    case 196:
-    case 197:
-    case 198:
-    case 199:
-    case 200:
-    case 201:
-    case 202:
-    case 203:
-    case 204:
-    case 205:
-    case 206:
-    case 207:
-    case 208:
-    case 209:
-    case 210:
-    case 211:
-    case 212:
-    case 213:
-    case 214:
-    case 215:
-    case 216:
-    case 217:
-    case 218:
-    case 219:
-    case 220:
-    case 221:
-    case 222:
-    case 223:
-    case 224:
-    case 225:
-    case 226:
-    case 227:
-    case 228:
-    case 229:
-    case 230:
-    case 231:
-    case 232:
-    case 233:
-    case 234:
-    case 235:
-    case 236:
-    case 237:
-    case 238:
-    case 239:
-    case 240:
-    case 241:
-    case 242:
-    case 243:
-    case 244:
-    case 245:
-    case 246:
-    case 247:
-    case 248:
-    case 249:
-    case 250:
-    case 251:
-    case 252:
-    case 253:
-    case 254:
-    case 255:
-    case 256:
-    case 257:
-    case 258:
-    case 259:
-    case 260:
-    case 261:
-    case 262:
-    case 263:
-    case 264:
-    case 265:
-    case 266:
-    case 267:
-    case 268:
-    case 269:
-    case 270:
-    case 271:
-    case 272:
-    case 273:
-    case 274:
-    case 275:
-    case 276:
-    case 277:
-    case 278:
-    case 279:
-    case 280:
-    case 281:
-    case 282:
-    case 283:
-    case 284:
-    case 285:
-    case 286:
-    case 287:
-    case 288:
-    case 289:
-    case 290:
-    case 291:
-    case 292:
-    case 293:
-    case 294:
-    case 295:
-    case 296:
-    case 297:
-    case 298:
-    case 299:
-    case 300:
-    case 301:
-    case 302:
-    case 303:
-    case 304:
-    case 305:
-    case 306:
-    case 307:
-    case 308:
-    case 309:
-    case 310:
-    case 311:
-    case 312:
-    case 313:
-    case 314:
-    case 315:
-    case 316:
-    case 317:
-    case 318:
-    case 319:
-    case 320:
-    case 321:
-    case 322:
-    case 323:
-    case 324:
-    case 325:
-    case 326:
-    case 327:
-    case 328:
-    case 329:
-    case 330:
-    case 331:
-    case 332:
-    case 333:
-    case 334:
-    case 335:
-    case 336:
-    case 337:
-    case 338:
-    case 339:
-    case 340:
-    case 341:
-    case 342:
-    case 343:
-    case 344:
-    case 345:
-    case 346:
-    case 347:
-    case 348:
-    case 349:
-    case 350:
-    case 351:
-    case 352:
-    case 353:
-    case 354:
-    case 355:
-    case 356:
-    case 357:
-    case 358:
-    case 359:
-    case 360:
-    case 361:
-    case 362:
-    case 363:
-    case 364:
-    case 365:
-    case 366:
-    case 367:
-    case 368:
-    case 369:
-    case 370:
-    case 371:
-    case 372:
-    case 373:
-    case 374:
-    case 375:
-    case 376:
-    case 377:
-    case 378:
-    case 379:
-    case 380:
-    case 381:
-    case 382:
-    case 383:
-    case 384:
-    case 385:
-    case 386:
-    case 387:
-    case 388:
-    case 389:
-    case 390:
-    case 391:
-    case 392:
-    case 393:
-    case 394:
-    case 395:
-    case 396:
-    case 397:
-    case 398:
-    case 399:
-    case 400:
-    case 401:
-    case 402:
-    case 403:
-    case 404:
-    case 405:
-    case 406:
-    case 407:
-    case 408:
-    case 409:
-    case 410:
-    case 411:
-    case 412:
-    case 413:
-    case 414:
-    case 415:
-    case 416:
-    case 417:
-    case 418:
-    case 419:
-    case 420:
-    case 421:
-    case 422:
-    case 423:
-    case 424:
-    case 425:
-    case 426:
-    case 427:
-    case 428:
-    case 429:
-    case 430:
-    case 431:
-    case 432:
-    case 433:
-    case 434:
-    case 435:
-    case 436:
-    case 437:
-    case 438:
-    case 439:
-    case 440:
-    case 441:
-    case 442:
-    case 443:
-    case 444:
-    case 445:
-    case 446:
-    case 447:
-    case 448:
-    case 449:
-    case 450:
-    case 451:
-    case 452:
-    case 453:
-    case 454:
-    case 455:
-    case 456:
-    case 457:
-    case 458:
-    case 459:
-    case 460:
-    case 461:
-    case 462:
-    case 463:
-    case 464:
-    case 465:
-    case 466:
-    case 467:
-    case 468:
-    case 469:
-    case 470:
-    case 471:
-    case 472:
-    case 473:
-    case 474:
-    case 475:
-    case 476:
-    case 477:
-    case 478:
-    case 479:
-    case 502:
-    case 503:
-    case 504:
-    case 505:
-    case 506:
-    case 507:
-    case 508:
-    case 509:
-    case 510:
-    case 511:
-    case 512:
-    case 513:
-    case 514:
-    case 515:
-    case 516:
-    case 517:
-    case 518:
-    case 519:
-    case 520:
-    case 521:
-    case 522:
-    case 523:
-    case 524:
-    case 525:
-    case 526:
-    case 527:
-    case 528:
-    case 529:
-    case 530:
-    case 531:
-    case 532:
-    case 533:
-    case 534:
-    case 535:
-    case 536:
-    case 537:
-    case 538:
-    case 539:
-    case 540:
-    case 541:
-    case 542:
-    case 543:
-    case 544:
-    case 545:
-    case 546:
-    case 547:
-    case 548:
-    case 549:
-    case 550:
-    case 551:
-    case 552:
-    case 553:
-    case 554:
-    case 555:
-    case 556:
-    case 557:
-    case 558:
-    case 559:
-    case 560:
-    case 561:
-    case 2000:
-    case 2001:
-    case 2002:
-    case 2003:
-    case 2004:
-    case 2005:
-    case 2006:
-    case 2007:
-    case 2008:
-    case 2009:
-    case 2010:
-    case 2011:
-    case 2012:
-    case 2013:
-    case 2014:
-    case 2015:
-    case 2016:
-    case 2017:
-    case 2018:
-    case 2019:
-    case 2020:
-    case 2021:
-    case 2022:
-    case 2023:
-    case 2024:
-    case 2025:
-    case 2026:
-    case 2027:
-    case 2028:
-    case 2029:
-    case 2030:
-    case 2031:
-    case 2032:
-    case 2033:
-    case 2034:
-    case 2035:
-    case 2036:
-    case 2037:
-    case 2038:
-    case 2039:
-    case 2040:
-    case 2041:
-    case 2042:
-    case 2043:
-    case 2044:
-    case 2045:
-    case 3000:
-    case 3001:
-      return true;
-    default:
-      return false;
-  }
-}
-
-#ifndef _MSC_VER
-const GLMessage_Function GLMessage::glActiveTexture;
-const GLMessage_Function GLMessage::glAlphaFunc;
-const GLMessage_Function GLMessage::glAlphaFuncx;
-const GLMessage_Function GLMessage::glAlphaFuncxOES;
-const GLMessage_Function GLMessage::glAttachShader;
-const GLMessage_Function GLMessage::glBeginPerfMonitorAMD;
-const GLMessage_Function GLMessage::glBindAttribLocation;
-const GLMessage_Function GLMessage::glBindBuffer;
-const GLMessage_Function GLMessage::glBindFramebuffer;
-const GLMessage_Function GLMessage::glBindFramebufferOES;
-const GLMessage_Function GLMessage::glBindRenderbuffer;
-const GLMessage_Function GLMessage::glBindRenderbufferOES;
-const GLMessage_Function GLMessage::glBindTexture;
-const GLMessage_Function GLMessage::glBindVertexArrayOES;
-const GLMessage_Function GLMessage::glBlendColor;
-const GLMessage_Function GLMessage::glBlendEquation;
-const GLMessage_Function GLMessage::glBlendEquationOES;
-const GLMessage_Function GLMessage::glBlendEquationSeparate;
-const GLMessage_Function GLMessage::glBlendEquationSeparateOES;
-const GLMessage_Function GLMessage::glBlendFunc;
-const GLMessage_Function GLMessage::glBlendFuncSeparate;
-const GLMessage_Function GLMessage::glBlendFuncSeparateOES;
-const GLMessage_Function GLMessage::glBufferData;
-const GLMessage_Function GLMessage::glBufferSubData;
-const GLMessage_Function GLMessage::glCheckFramebufferStatus;
-const GLMessage_Function GLMessage::glCheckFramebufferStatusOES;
-const GLMessage_Function GLMessage::glClearColor;
-const GLMessage_Function GLMessage::glClearColorx;
-const GLMessage_Function GLMessage::glClearColorxOES;
-const GLMessage_Function GLMessage::glClearDepthf;
-const GLMessage_Function GLMessage::glClearDepthfOES;
-const GLMessage_Function GLMessage::glClearDepthx;
-const GLMessage_Function GLMessage::glClearDepthxOES;
-const GLMessage_Function GLMessage::glClear;
-const GLMessage_Function GLMessage::glClearStencil;
-const GLMessage_Function GLMessage::glClientActiveTexture;
-const GLMessage_Function GLMessage::glClipPlanef;
-const GLMessage_Function GLMessage::glClipPlanefIMG;
-const GLMessage_Function GLMessage::glClipPlanefOES;
-const GLMessage_Function GLMessage::glClipPlanex;
-const GLMessage_Function GLMessage::glClipPlanexIMG;
-const GLMessage_Function GLMessage::glClipPlanexOES;
-const GLMessage_Function GLMessage::glColor4f;
-const GLMessage_Function GLMessage::glColor4ub;
-const GLMessage_Function GLMessage::glColor4x;
-const GLMessage_Function GLMessage::glColor4xOES;
-const GLMessage_Function GLMessage::glColorMask;
-const GLMessage_Function GLMessage::glColorPointer;
-const GLMessage_Function GLMessage::glCompileShader;
-const GLMessage_Function GLMessage::glCompressedTexImage2D;
-const GLMessage_Function GLMessage::glCompressedTexImage3DOES;
-const GLMessage_Function GLMessage::glCompressedTexSubImage2D;
-const GLMessage_Function GLMessage::glCompressedTexSubImage3DOES;
-const GLMessage_Function GLMessage::glCopyTexImage2D;
-const GLMessage_Function GLMessage::glCopyTexSubImage2D;
-const GLMessage_Function GLMessage::glCopyTexSubImage3DOES;
-const GLMessage_Function GLMessage::glCoverageMaskNV;
-const GLMessage_Function GLMessage::glCoverageOperationNV;
-const GLMessage_Function GLMessage::glCreateProgram;
-const GLMessage_Function GLMessage::glCreateShader;
-const GLMessage_Function GLMessage::glCullFace;
-const GLMessage_Function GLMessage::glCurrentPaletteMatrixOES;
-const GLMessage_Function GLMessage::glDeleteBuffers;
-const GLMessage_Function GLMessage::glDeleteFencesNV;
-const GLMessage_Function GLMessage::glDeleteFramebuffers;
-const GLMessage_Function GLMessage::glDeleteFramebuffersOES;
-const GLMessage_Function GLMessage::glDeletePerfMonitorsAMD;
-const GLMessage_Function GLMessage::glDeleteProgram;
-const GLMessage_Function GLMessage::glDeleteRenderbuffers;
-const GLMessage_Function GLMessage::glDeleteRenderbuffersOES;
-const GLMessage_Function GLMessage::glDeleteShader;
-const GLMessage_Function GLMessage::glDeleteTextures;
-const GLMessage_Function GLMessage::glDeleteVertexArraysOES;
-const GLMessage_Function GLMessage::glDepthFunc;
-const GLMessage_Function GLMessage::glDepthMask;
-const GLMessage_Function GLMessage::glDepthRangef;
-const GLMessage_Function GLMessage::glDepthRangefOES;
-const GLMessage_Function GLMessage::glDepthRangex;
-const GLMessage_Function GLMessage::glDepthRangexOES;
-const GLMessage_Function GLMessage::glDetachShader;
-const GLMessage_Function GLMessage::glDisableClientState;
-const GLMessage_Function GLMessage::glDisableDriverControlQCOM;
-const GLMessage_Function GLMessage::glDisable;
-const GLMessage_Function GLMessage::glDisableVertexAttribArray;
-const GLMessage_Function GLMessage::glDiscardFramebufferEXT;
-const GLMessage_Function GLMessage::glDrawArrays;
-const GLMessage_Function GLMessage::glDrawElements;
-const GLMessage_Function GLMessage::glDrawTexfOES;
-const GLMessage_Function GLMessage::glDrawTexfvOES;
-const GLMessage_Function GLMessage::glDrawTexiOES;
-const GLMessage_Function GLMessage::glDrawTexivOES;
-const GLMessage_Function GLMessage::glDrawTexsOES;
-const GLMessage_Function GLMessage::glDrawTexsvOES;
-const GLMessage_Function GLMessage::glDrawTexxOES;
-const GLMessage_Function GLMessage::glDrawTexxvOES;
-const GLMessage_Function GLMessage::glEGLImageTargetRenderbufferStorageOES;
-const GLMessage_Function GLMessage::glEGLImageTargetTexture2DOES;
-const GLMessage_Function GLMessage::glEnableClientState;
-const GLMessage_Function GLMessage::glEnableDriverControlQCOM;
-const GLMessage_Function GLMessage::glEnable;
-const GLMessage_Function GLMessage::glEnableVertexAttribArray;
-const GLMessage_Function GLMessage::glEndPerfMonitorAMD;
-const GLMessage_Function GLMessage::glEndTilingQCOM;
-const GLMessage_Function GLMessage::glExtGetBufferPointervQCOM;
-const GLMessage_Function GLMessage::glExtGetBuffersQCOM;
-const GLMessage_Function GLMessage::glExtGetFramebuffersQCOM;
-const GLMessage_Function GLMessage::glExtGetProgramBinarySourceQCOM;
-const GLMessage_Function GLMessage::glExtGetProgramsQCOM;
-const GLMessage_Function GLMessage::glExtGetRenderbuffersQCOM;
-const GLMessage_Function GLMessage::glExtGetShadersQCOM;
-const GLMessage_Function GLMessage::glExtGetTexLevelParameterivQCOM;
-const GLMessage_Function GLMessage::glExtGetTexSubImageQCOM;
-const GLMessage_Function GLMessage::glExtGetTexturesQCOM;
-const GLMessage_Function GLMessage::glExtIsProgramBinaryQCOM;
-const GLMessage_Function GLMessage::glExtTexObjectStateOverrideiQCOM;
-const GLMessage_Function GLMessage::glFinishFenceNV;
-const GLMessage_Function GLMessage::glFinish;
-const GLMessage_Function GLMessage::glFlush;
-const GLMessage_Function GLMessage::glFogf;
-const GLMessage_Function GLMessage::glFogfv;
-const GLMessage_Function GLMessage::glFogx;
-const GLMessage_Function GLMessage::glFogxOES;
-const GLMessage_Function GLMessage::glFogxv;
-const GLMessage_Function GLMessage::glFogxvOES;
-const GLMessage_Function GLMessage::glFramebufferRenderbuffer;
-const GLMessage_Function GLMessage::glFramebufferRenderbufferOES;
-const GLMessage_Function GLMessage::glFramebufferTexture2D;
-const GLMessage_Function GLMessage::glFramebufferTexture2DMultisampleIMG;
-const GLMessage_Function GLMessage::glFramebufferTexture2DOES;
-const GLMessage_Function GLMessage::glFramebufferTexture3DOES;
-const GLMessage_Function GLMessage::glFrontFace;
-const GLMessage_Function GLMessage::glFrustumf;
-const GLMessage_Function GLMessage::glFrustumfOES;
-const GLMessage_Function GLMessage::glFrustumx;
-const GLMessage_Function GLMessage::glFrustumxOES;
-const GLMessage_Function GLMessage::glGenBuffers;
-const GLMessage_Function GLMessage::glGenerateMipmap;
-const GLMessage_Function GLMessage::glGenerateMipmapOES;
-const GLMessage_Function GLMessage::glGenFencesNV;
-const GLMessage_Function GLMessage::glGenFramebuffers;
-const GLMessage_Function GLMessage::glGenFramebuffersOES;
-const GLMessage_Function GLMessage::glGenPerfMonitorsAMD;
-const GLMessage_Function GLMessage::glGenRenderbuffers;
-const GLMessage_Function GLMessage::glGenRenderbuffersOES;
-const GLMessage_Function GLMessage::glGenTextures;
-const GLMessage_Function GLMessage::glGenVertexArraysOES;
-const GLMessage_Function GLMessage::glGetActiveAttrib;
-const GLMessage_Function GLMessage::glGetActiveUniform;
-const GLMessage_Function GLMessage::glGetAttachedShaders;
-const GLMessage_Function GLMessage::glGetAttribLocation;
-const GLMessage_Function GLMessage::glGetBooleanv;
-const GLMessage_Function GLMessage::glGetBufferParameteriv;
-const GLMessage_Function GLMessage::glGetBufferPointervOES;
-const GLMessage_Function GLMessage::glGetClipPlanef;
-const GLMessage_Function GLMessage::glGetClipPlanefOES;
-const GLMessage_Function GLMessage::glGetClipPlanex;
-const GLMessage_Function GLMessage::glGetClipPlanexOES;
-const GLMessage_Function GLMessage::glGetDriverControlsQCOM;
-const GLMessage_Function GLMessage::glGetDriverControlStringQCOM;
-const GLMessage_Function GLMessage::glGetError;
-const GLMessage_Function GLMessage::glGetFenceivNV;
-const GLMessage_Function GLMessage::glGetFixedv;
-const GLMessage_Function GLMessage::glGetFixedvOES;
-const GLMessage_Function GLMessage::glGetFloatv;
-const GLMessage_Function GLMessage::glGetFramebufferAttachmentParameteriv;
-const GLMessage_Function GLMessage::glGetFramebufferAttachmentParameterivOES;
-const GLMessage_Function GLMessage::glGetIntegerv;
-const GLMessage_Function GLMessage::glGetLightfv;
-const GLMessage_Function GLMessage::glGetLightxv;
-const GLMessage_Function GLMessage::glGetLightxvOES;
-const GLMessage_Function GLMessage::glGetMaterialfv;
-const GLMessage_Function GLMessage::glGetMaterialxv;
-const GLMessage_Function GLMessage::glGetMaterialxvOES;
-const GLMessage_Function GLMessage::glGetPerfMonitorCounterDataAMD;
-const GLMessage_Function GLMessage::glGetPerfMonitorCounterInfoAMD;
-const GLMessage_Function GLMessage::glGetPerfMonitorCountersAMD;
-const GLMessage_Function GLMessage::glGetPerfMonitorCounterStringAMD;
-const GLMessage_Function GLMessage::glGetPerfMonitorGroupsAMD;
-const GLMessage_Function GLMessage::glGetPerfMonitorGroupStringAMD;
-const GLMessage_Function GLMessage::glGetPointerv;
-const GLMessage_Function GLMessage::glGetProgramBinaryOES;
-const GLMessage_Function GLMessage::glGetProgramInfoLog;
-const GLMessage_Function GLMessage::glGetProgramiv;
-const GLMessage_Function GLMessage::glGetRenderbufferParameteriv;
-const GLMessage_Function GLMessage::glGetRenderbufferParameterivOES;
-const GLMessage_Function GLMessage::glGetShaderInfoLog;
-const GLMessage_Function GLMessage::glGetShaderiv;
-const GLMessage_Function GLMessage::glGetShaderPrecisionFormat;
-const GLMessage_Function GLMessage::glGetShaderSource;
-const GLMessage_Function GLMessage::glGetString;
-const GLMessage_Function GLMessage::glGetTexEnvfv;
-const GLMessage_Function GLMessage::glGetTexEnviv;
-const GLMessage_Function GLMessage::glGetTexEnvxv;
-const GLMessage_Function GLMessage::glGetTexEnvxvOES;
-const GLMessage_Function GLMessage::glGetTexGenfvOES;
-const GLMessage_Function GLMessage::glGetTexGenivOES;
-const GLMessage_Function GLMessage::glGetTexGenxvOES;
-const GLMessage_Function GLMessage::glGetTexParameterfv;
-const GLMessage_Function GLMessage::glGetTexParameteriv;
-const GLMessage_Function GLMessage::glGetTexParameterxv;
-const GLMessage_Function GLMessage::glGetTexParameterxvOES;
-const GLMessage_Function GLMessage::glGetUniformfv;
-const GLMessage_Function GLMessage::glGetUniformiv;
-const GLMessage_Function GLMessage::glGetUniformLocation;
-const GLMessage_Function GLMessage::glGetVertexAttribfv;
-const GLMessage_Function GLMessage::glGetVertexAttribiv;
-const GLMessage_Function GLMessage::glGetVertexAttribPointerv;
-const GLMessage_Function GLMessage::glHint;
-const GLMessage_Function GLMessage::glIsBuffer;
-const GLMessage_Function GLMessage::glIsEnabled;
-const GLMessage_Function GLMessage::glIsFenceNV;
-const GLMessage_Function GLMessage::glIsFramebuffer;
-const GLMessage_Function GLMessage::glIsFramebufferOES;
-const GLMessage_Function GLMessage::glIsProgram;
-const GLMessage_Function GLMessage::glIsRenderbuffer;
-const GLMessage_Function GLMessage::glIsRenderbufferOES;
-const GLMessage_Function GLMessage::glIsShader;
-const GLMessage_Function GLMessage::glIsTexture;
-const GLMessage_Function GLMessage::glIsVertexArrayOES;
-const GLMessage_Function GLMessage::glLightf;
-const GLMessage_Function GLMessage::glLightfv;
-const GLMessage_Function GLMessage::glLightModelf;
-const GLMessage_Function GLMessage::glLightModelfv;
-const GLMessage_Function GLMessage::glLightModelx;
-const GLMessage_Function GLMessage::glLightModelxOES;
-const GLMessage_Function GLMessage::glLightModelxv;
-const GLMessage_Function GLMessage::glLightModelxvOES;
-const GLMessage_Function GLMessage::glLightx;
-const GLMessage_Function GLMessage::glLightxOES;
-const GLMessage_Function GLMessage::glLightxv;
-const GLMessage_Function GLMessage::glLightxvOES;
-const GLMessage_Function GLMessage::glLineWidth;
-const GLMessage_Function GLMessage::glLineWidthx;
-const GLMessage_Function GLMessage::glLineWidthxOES;
-const GLMessage_Function GLMessage::glLinkProgram;
-const GLMessage_Function GLMessage::glLoadIdentity;
-const GLMessage_Function GLMessage::glLoadMatrixf;
-const GLMessage_Function GLMessage::glLoadMatrixx;
-const GLMessage_Function GLMessage::glLoadMatrixxOES;
-const GLMessage_Function GLMessage::glLoadPaletteFromModelViewMatrixOES;
-const GLMessage_Function GLMessage::glLogicOp;
-const GLMessage_Function GLMessage::glMapBufferOES;
-const GLMessage_Function GLMessage::glMaterialf;
-const GLMessage_Function GLMessage::glMaterialfv;
-const GLMessage_Function GLMessage::glMaterialx;
-const GLMessage_Function GLMessage::glMaterialxOES;
-const GLMessage_Function GLMessage::glMaterialxv;
-const GLMessage_Function GLMessage::glMaterialxvOES;
-const GLMessage_Function GLMessage::glMatrixIndexPointerOES;
-const GLMessage_Function GLMessage::glMatrixMode;
-const GLMessage_Function GLMessage::glMultiDrawArraysEXT;
-const GLMessage_Function GLMessage::glMultiDrawElementsEXT;
-const GLMessage_Function GLMessage::glMultiTexCoord4f;
-const GLMessage_Function GLMessage::glMultiTexCoord4x;
-const GLMessage_Function GLMessage::glMultiTexCoord4xOES;
-const GLMessage_Function GLMessage::glMultMatrixf;
-const GLMessage_Function GLMessage::glMultMatrixx;
-const GLMessage_Function GLMessage::glMultMatrixxOES;
-const GLMessage_Function GLMessage::glNormal3f;
-const GLMessage_Function GLMessage::glNormal3x;
-const GLMessage_Function GLMessage::glNormal3xOES;
-const GLMessage_Function GLMessage::glNormalPointer;
-const GLMessage_Function GLMessage::glOrthof;
-const GLMessage_Function GLMessage::glOrthofOES;
-const GLMessage_Function GLMessage::glOrthox;
-const GLMessage_Function GLMessage::glOrthoxOES;
-const GLMessage_Function GLMessage::glPixelStorei;
-const GLMessage_Function GLMessage::glPointParameterf;
-const GLMessage_Function GLMessage::glPointParameterfv;
-const GLMessage_Function GLMessage::glPointParameterx;
-const GLMessage_Function GLMessage::glPointParameterxOES;
-const GLMessage_Function GLMessage::glPointParameterxv;
-const GLMessage_Function GLMessage::glPointParameterxvOES;
-const GLMessage_Function GLMessage::glPointSize;
-const GLMessage_Function GLMessage::glPointSizePointerOES;
-const GLMessage_Function GLMessage::glPointSizex;
-const GLMessage_Function GLMessage::glPointSizexOES;
-const GLMessage_Function GLMessage::glPolygonOffset;
-const GLMessage_Function GLMessage::glPolygonOffsetx;
-const GLMessage_Function GLMessage::glPolygonOffsetxOES;
-const GLMessage_Function GLMessage::glPopMatrix;
-const GLMessage_Function GLMessage::glProgramBinaryOES;
-const GLMessage_Function GLMessage::glPushMatrix;
-const GLMessage_Function GLMessage::glQueryMatrixxOES;
-const GLMessage_Function GLMessage::glReadPixels;
-const GLMessage_Function GLMessage::glReleaseShaderCompiler;
-const GLMessage_Function GLMessage::glRenderbufferStorage;
-const GLMessage_Function GLMessage::glRenderbufferStorageMultisampleIMG;
-const GLMessage_Function GLMessage::glRenderbufferStorageOES;
-const GLMessage_Function GLMessage::glRotatef;
-const GLMessage_Function GLMessage::glRotatex;
-const GLMessage_Function GLMessage::glRotatexOES;
-const GLMessage_Function GLMessage::glSampleCoverage;
-const GLMessage_Function GLMessage::glSampleCoveragex;
-const GLMessage_Function GLMessage::glSampleCoveragexOES;
-const GLMessage_Function GLMessage::glScalef;
-const GLMessage_Function GLMessage::glScalex;
-const GLMessage_Function GLMessage::glScalexOES;
-const GLMessage_Function GLMessage::glScissor;
-const GLMessage_Function GLMessage::glSelectPerfMonitorCountersAMD;
-const GLMessage_Function GLMessage::glSetFenceNV;
-const GLMessage_Function GLMessage::glShadeModel;
-const GLMessage_Function GLMessage::glShaderBinary;
-const GLMessage_Function GLMessage::glShaderSource;
-const GLMessage_Function GLMessage::glStartTilingQCOM;
-const GLMessage_Function GLMessage::glStencilFunc;
-const GLMessage_Function GLMessage::glStencilFuncSeparate;
-const GLMessage_Function GLMessage::glStencilMask;
-const GLMessage_Function GLMessage::glStencilMaskSeparate;
-const GLMessage_Function GLMessage::glStencilOp;
-const GLMessage_Function GLMessage::glStencilOpSeparate;
-const GLMessage_Function GLMessage::glTestFenceNV;
-const GLMessage_Function GLMessage::glTexCoordPointer;
-const GLMessage_Function GLMessage::glTexEnvf;
-const GLMessage_Function GLMessage::glTexEnvfv;
-const GLMessage_Function GLMessage::glTexEnvi;
-const GLMessage_Function GLMessage::glTexEnviv;
-const GLMessage_Function GLMessage::glTexEnvx;
-const GLMessage_Function GLMessage::glTexEnvxOES;
-const GLMessage_Function GLMessage::glTexEnvxv;
-const GLMessage_Function GLMessage::glTexEnvxvOES;
-const GLMessage_Function GLMessage::glTexGenfOES;
-const GLMessage_Function GLMessage::glTexGenfvOES;
-const GLMessage_Function GLMessage::glTexGeniOES;
-const GLMessage_Function GLMessage::glTexGenivOES;
-const GLMessage_Function GLMessage::glTexGenxOES;
-const GLMessage_Function GLMessage::glTexGenxvOES;
-const GLMessage_Function GLMessage::glTexImage2D;
-const GLMessage_Function GLMessage::glTexImage3DOES;
-const GLMessage_Function GLMessage::glTexParameterf;
-const GLMessage_Function GLMessage::glTexParameterfv;
-const GLMessage_Function GLMessage::glTexParameteri;
-const GLMessage_Function GLMessage::glTexParameteriv;
-const GLMessage_Function GLMessage::glTexParameterx;
-const GLMessage_Function GLMessage::glTexParameterxOES;
-const GLMessage_Function GLMessage::glTexParameterxv;
-const GLMessage_Function GLMessage::glTexParameterxvOES;
-const GLMessage_Function GLMessage::glTexSubImage2D;
-const GLMessage_Function GLMessage::glTexSubImage3DOES;
-const GLMessage_Function GLMessage::glTranslatef;
-const GLMessage_Function GLMessage::glTranslatex;
-const GLMessage_Function GLMessage::glTranslatexOES;
-const GLMessage_Function GLMessage::glUniform1f;
-const GLMessage_Function GLMessage::glUniform1fv;
-const GLMessage_Function GLMessage::glUniform1i;
-const GLMessage_Function GLMessage::glUniform1iv;
-const GLMessage_Function GLMessage::glUniform2f;
-const GLMessage_Function GLMessage::glUniform2fv;
-const GLMessage_Function GLMessage::glUniform2i;
-const GLMessage_Function GLMessage::glUniform2iv;
-const GLMessage_Function GLMessage::glUniform3f;
-const GLMessage_Function GLMessage::glUniform3fv;
-const GLMessage_Function GLMessage::glUniform3i;
-const GLMessage_Function GLMessage::glUniform3iv;
-const GLMessage_Function GLMessage::glUniform4f;
-const GLMessage_Function GLMessage::glUniform4fv;
-const GLMessage_Function GLMessage::glUniform4i;
-const GLMessage_Function GLMessage::glUniform4iv;
-const GLMessage_Function GLMessage::glUniformMatrix2fv;
-const GLMessage_Function GLMessage::glUniformMatrix3fv;
-const GLMessage_Function GLMessage::glUniformMatrix4fv;
-const GLMessage_Function GLMessage::glUnmapBufferOES;
-const GLMessage_Function GLMessage::glUseProgram;
-const GLMessage_Function GLMessage::glValidateProgram;
-const GLMessage_Function GLMessage::glVertexAttrib1f;
-const GLMessage_Function GLMessage::glVertexAttrib1fv;
-const GLMessage_Function GLMessage::glVertexAttrib2f;
-const GLMessage_Function GLMessage::glVertexAttrib2fv;
-const GLMessage_Function GLMessage::glVertexAttrib3f;
-const GLMessage_Function GLMessage::glVertexAttrib3fv;
-const GLMessage_Function GLMessage::glVertexAttrib4f;
-const GLMessage_Function GLMessage::glVertexAttrib4fv;
-const GLMessage_Function GLMessage::glVertexAttribPointer;
-const GLMessage_Function GLMessage::glVertexPointer;
-const GLMessage_Function GLMessage::glViewport;
-const GLMessage_Function GLMessage::glWeightPointerOES;
-const GLMessage_Function GLMessage::glReadBuffer;
-const GLMessage_Function GLMessage::glDrawRangeElements;
-const GLMessage_Function GLMessage::glTexImage3D;
-const GLMessage_Function GLMessage::glTexSubImage3D;
-const GLMessage_Function GLMessage::glCopyTexSubImage3D;
-const GLMessage_Function GLMessage::glCompressedTexImage3D;
-const GLMessage_Function GLMessage::glCompressedTexSubImage3D;
-const GLMessage_Function GLMessage::glGenQueries;
-const GLMessage_Function GLMessage::glDeleteQueries;
-const GLMessage_Function GLMessage::glIsQuery;
-const GLMessage_Function GLMessage::glBeginQuery;
-const GLMessage_Function GLMessage::glEndQuery;
-const GLMessage_Function GLMessage::glGetQueryiv;
-const GLMessage_Function GLMessage::glGetQueryObjectuiv;
-const GLMessage_Function GLMessage::glUnmapBuffer;
-const GLMessage_Function GLMessage::glGetBufferPointerv;
-const GLMessage_Function GLMessage::glDrawBuffers;
-const GLMessage_Function GLMessage::glUniformMatrix2x3fv;
-const GLMessage_Function GLMessage::glUniformMatrix3x2fv;
-const GLMessage_Function GLMessage::glUniformMatrix2x4fv;
-const GLMessage_Function GLMessage::glUniformMatrix4x2fv;
-const GLMessage_Function GLMessage::glUniformMatrix3x4fv;
-const GLMessage_Function GLMessage::glUniformMatrix4x3fv;
-const GLMessage_Function GLMessage::glBlitFramebuffer;
-const GLMessage_Function GLMessage::glRenderbufferStorageMultisample;
-const GLMessage_Function GLMessage::glFramebufferTextureLayer;
-const GLMessage_Function GLMessage::glMapBufferRange;
-const GLMessage_Function GLMessage::glFlushMappedBufferRange;
-const GLMessage_Function GLMessage::glBindVertexArray;
-const GLMessage_Function GLMessage::glDeleteVertexArrays;
-const GLMessage_Function GLMessage::glGenVertexArrays;
-const GLMessage_Function GLMessage::glIsVertexArray;
-const GLMessage_Function GLMessage::glGetIntegeri_v;
-const GLMessage_Function GLMessage::glBeginTransformFeedback;
-const GLMessage_Function GLMessage::glEndTransformFeedback;
-const GLMessage_Function GLMessage::glBindBufferRange;
-const GLMessage_Function GLMessage::glBindBufferBase;
-const GLMessage_Function GLMessage::glTransformFeedbackVaryings;
-const GLMessage_Function GLMessage::glGetTransformFeedbackVarying;
-const GLMessage_Function GLMessage::glVertexAttribIPointer;
-const GLMessage_Function GLMessage::glGetVertexAttribIiv;
-const GLMessage_Function GLMessage::glGetVertexAttribIuiv;
-const GLMessage_Function GLMessage::glVertexAttribI4i;
-const GLMessage_Function GLMessage::glVertexAttribI4ui;
-const GLMessage_Function GLMessage::glVertexAttribI4iv;
-const GLMessage_Function GLMessage::glVertexAttribI4uiv;
-const GLMessage_Function GLMessage::glGetUniformuiv;
-const GLMessage_Function GLMessage::glGetFragDataLocation;
-const GLMessage_Function GLMessage::glUniform1ui;
-const GLMessage_Function GLMessage::glUniform2ui;
-const GLMessage_Function GLMessage::glUniform3ui;
-const GLMessage_Function GLMessage::glUniform4ui;
-const GLMessage_Function GLMessage::glUniform1uiv;
-const GLMessage_Function GLMessage::glUniform2uiv;
-const GLMessage_Function GLMessage::glUniform3uiv;
-const GLMessage_Function GLMessage::glUniform4uiv;
-const GLMessage_Function GLMessage::glClearBufferiv;
-const GLMessage_Function GLMessage::glClearBufferuiv;
-const GLMessage_Function GLMessage::glClearBufferfv;
-const GLMessage_Function GLMessage::glClearBufferfi;
-const GLMessage_Function GLMessage::glGetStringi;
-const GLMessage_Function GLMessage::glCopyBufferSubData;
-const GLMessage_Function GLMessage::glGetUniformIndices;
-const GLMessage_Function GLMessage::glGetActiveUniformsiv;
-const GLMessage_Function GLMessage::glGetUniformBlockIndex;
-const GLMessage_Function GLMessage::glGetActiveUniformBlockiv;
-const GLMessage_Function GLMessage::glGetActiveUniformBlockName;
-const GLMessage_Function GLMessage::glUniformBlockBinding;
-const GLMessage_Function GLMessage::glDrawArraysInstanced;
-const GLMessage_Function GLMessage::glDrawElementsInstanced;
-const GLMessage_Function GLMessage::glFenceSync;
-const GLMessage_Function GLMessage::glIsSync;
-const GLMessage_Function GLMessage::glDeleteSync;
-const GLMessage_Function GLMessage::glClientWaitSync;
-const GLMessage_Function GLMessage::glWaitSync;
-const GLMessage_Function GLMessage::glGetInteger64v;
-const GLMessage_Function GLMessage::glGetSynciv;
-const GLMessage_Function GLMessage::glGetInteger64i_v;
-const GLMessage_Function GLMessage::glGetBufferParameteri64v;
-const GLMessage_Function GLMessage::glGenSamplers;
-const GLMessage_Function GLMessage::glDeleteSamplers;
-const GLMessage_Function GLMessage::glIsSampler;
-const GLMessage_Function GLMessage::glBindSampler;
-const GLMessage_Function GLMessage::glSamplerParameteri;
-const GLMessage_Function GLMessage::glSamplerParameteriv;
-const GLMessage_Function GLMessage::glSamplerParameterf;
-const GLMessage_Function GLMessage::glSamplerParameterfv;
-const GLMessage_Function GLMessage::glGetSamplerParameteriv;
-const GLMessage_Function GLMessage::glGetSamplerParameterfv;
-const GLMessage_Function GLMessage::glVertexAttribDivisor;
-const GLMessage_Function GLMessage::glBindTransformFeedback;
-const GLMessage_Function GLMessage::glDeleteTransformFeedbacks;
-const GLMessage_Function GLMessage::glGenTransformFeedbacks;
-const GLMessage_Function GLMessage::glIsTransformFeedback;
-const GLMessage_Function GLMessage::glPauseTransformFeedback;
-const GLMessage_Function GLMessage::glResumeTransformFeedback;
-const GLMessage_Function GLMessage::glGetProgramBinary;
-const GLMessage_Function GLMessage::glProgramBinary;
-const GLMessage_Function GLMessage::glProgramParameteri;
-const GLMessage_Function GLMessage::glInvalidateFramebuffer;
-const GLMessage_Function GLMessage::glInvalidateSubFramebuffer;
-const GLMessage_Function GLMessage::glTexStorage2D;
-const GLMessage_Function GLMessage::glTexStorage3D;
-const GLMessage_Function GLMessage::glGetInternalformativ;
-const GLMessage_Function GLMessage::glActiveShaderProgramEXT;
-const GLMessage_Function GLMessage::glAlphaFuncQCOM;
-const GLMessage_Function GLMessage::glBeginQueryEXT;
-const GLMessage_Function GLMessage::glBindProgramPipelineEXT;
-const GLMessage_Function GLMessage::glBlitFramebufferANGLE;
-const GLMessage_Function GLMessage::glCreateShaderProgramvEXT;
-const GLMessage_Function GLMessage::glDeleteProgramPipelinesEXT;
-const GLMessage_Function GLMessage::glDeleteQueriesEXT;
-const GLMessage_Function GLMessage::glDrawBuffersNV;
-const GLMessage_Function GLMessage::glEndQueryEXT;
-const GLMessage_Function GLMessage::glFramebufferTexture2DMultisampleEXT;
-const GLMessage_Function GLMessage::glGenProgramPipelinesEXT;
-const GLMessage_Function GLMessage::glGenQueriesEXT;
-const GLMessage_Function GLMessage::glGetGraphicsResetStatusEXT;
-const GLMessage_Function GLMessage::glGetObjectLabelEXT;
-const GLMessage_Function GLMessage::glGetProgramPipelineInfoLogEXT;
-const GLMessage_Function GLMessage::glGetProgramPipelineivEXT;
-const GLMessage_Function GLMessage::glGetQueryObjectuivEXT;
-const GLMessage_Function GLMessage::glGetQueryivEXT;
-const GLMessage_Function GLMessage::glGetnUniformfvEXT;
-const GLMessage_Function GLMessage::glGetnUniformivEXT;
-const GLMessage_Function GLMessage::glInsertEventMarkerEXT;
-const GLMessage_Function GLMessage::glIsProgramPipelineEXT;
-const GLMessage_Function GLMessage::glIsQueryEXT;
-const GLMessage_Function GLMessage::glLabelObjectEXT;
-const GLMessage_Function GLMessage::glPopGroupMarkerEXT;
-const GLMessage_Function GLMessage::glProgramParameteriEXT;
-const GLMessage_Function GLMessage::glProgramUniform1fEXT;
-const GLMessage_Function GLMessage::glProgramUniform1fvEXT;
-const GLMessage_Function GLMessage::glProgramUniform1iEXT;
-const GLMessage_Function GLMessage::glProgramUniform1ivEXT;
-const GLMessage_Function GLMessage::glProgramUniform2fEXT;
-const GLMessage_Function GLMessage::glProgramUniform2fvEXT;
-const GLMessage_Function GLMessage::glProgramUniform2iEXT;
-const GLMessage_Function GLMessage::glProgramUniform2ivEXT;
-const GLMessage_Function GLMessage::glProgramUniform3fEXT;
-const GLMessage_Function GLMessage::glProgramUniform3fvEXT;
-const GLMessage_Function GLMessage::glProgramUniform3iEXT;
-const GLMessage_Function GLMessage::glProgramUniform3ivEXT;
-const GLMessage_Function GLMessage::glProgramUniform4fEXT;
-const GLMessage_Function GLMessage::glProgramUniform4fvEXT;
-const GLMessage_Function GLMessage::glProgramUniform4iEXT;
-const GLMessage_Function GLMessage::glProgramUniform4ivEXT;
-const GLMessage_Function GLMessage::glProgramUniformMatrix2fvEXT;
-const GLMessage_Function GLMessage::glProgramUniformMatrix3fvEXT;
-const GLMessage_Function GLMessage::glProgramUniformMatrix4fvEXT;
-const GLMessage_Function GLMessage::glPushGroupMarkerEXT;
-const GLMessage_Function GLMessage::glReadBufferNV;
-const GLMessage_Function GLMessage::glReadnPixelsEXT;
-const GLMessage_Function GLMessage::glRenderbufferStorageMultisampleANGLE;
-const GLMessage_Function GLMessage::glRenderbufferStorageMultisampleAPPLE;
-const GLMessage_Function GLMessage::glRenderbufferStorageMultisampleEXT;
-const GLMessage_Function GLMessage::glResolveMultisampleFramebufferAPPLE;
-const GLMessage_Function GLMessage::glTexStorage1DEXT;
-const GLMessage_Function GLMessage::glTexStorage2DEXT;
-const GLMessage_Function GLMessage::glTexStorage3DEXT;
-const GLMessage_Function GLMessage::glTextureStorage1DEXT;
-const GLMessage_Function GLMessage::glTextureStorage2DEXT;
-const GLMessage_Function GLMessage::glTextureStorage3DEXT;
-const GLMessage_Function GLMessage::glUseProgramStagesEXT;
-const GLMessage_Function GLMessage::glValidateProgramPipelineEXT;
-const GLMessage_Function GLMessage::eglGetDisplay;
-const GLMessage_Function GLMessage::eglInitialize;
-const GLMessage_Function GLMessage::eglTerminate;
-const GLMessage_Function GLMessage::eglGetConfigs;
-const GLMessage_Function GLMessage::eglChooseConfig;
-const GLMessage_Function GLMessage::eglGetConfigAttrib;
-const GLMessage_Function GLMessage::eglCreateWindowSurface;
-const GLMessage_Function GLMessage::eglCreatePixmapSurface;
-const GLMessage_Function GLMessage::eglCreatePbufferSurface;
-const GLMessage_Function GLMessage::eglDestroySurface;
-const GLMessage_Function GLMessage::eglQuerySurface;
-const GLMessage_Function GLMessage::eglCreateContext;
-const GLMessage_Function GLMessage::eglDestroyContext;
-const GLMessage_Function GLMessage::eglMakeCurrent;
-const GLMessage_Function GLMessage::eglGetCurrentContext;
-const GLMessage_Function GLMessage::eglGetCurrentSurface;
-const GLMessage_Function GLMessage::eglGetCurrentDisplay;
-const GLMessage_Function GLMessage::eglQueryContext;
-const GLMessage_Function GLMessage::eglWaitGL;
-const GLMessage_Function GLMessage::eglWaitNative;
-const GLMessage_Function GLMessage::eglSwapBuffers;
-const GLMessage_Function GLMessage::eglCopyBuffers;
-const GLMessage_Function GLMessage::eglGetError;
-const GLMessage_Function GLMessage::eglQueryString;
-const GLMessage_Function GLMessage::eglGetProcAddress;
-const GLMessage_Function GLMessage::eglSurfaceAttrib;
-const GLMessage_Function GLMessage::eglBindTexImage;
-const GLMessage_Function GLMessage::eglReleaseTexImage;
-const GLMessage_Function GLMessage::eglSwapInterval;
-const GLMessage_Function GLMessage::eglBindAPI;
-const GLMessage_Function GLMessage::eglQueryAPI;
-const GLMessage_Function GLMessage::eglWaitClient;
-const GLMessage_Function GLMessage::eglReleaseThread;
-const GLMessage_Function GLMessage::eglCreatePbufferFromClientBuffer;
-const GLMessage_Function GLMessage::eglLockSurfaceKHR;
-const GLMessage_Function GLMessage::eglUnlockSurfaceKHR;
-const GLMessage_Function GLMessage::eglCreateImageKHR;
-const GLMessage_Function GLMessage::eglDestroyImageKHR;
-const GLMessage_Function GLMessage::eglCreateSyncKHR;
-const GLMessage_Function GLMessage::eglDestroySyncKHR;
-const GLMessage_Function GLMessage::eglClientWaitSyncKHR;
-const GLMessage_Function GLMessage::eglGetSyncAttribKHR;
-const GLMessage_Function GLMessage::eglSetSwapRectangleANDROID;
-const GLMessage_Function GLMessage::eglGetRenderBufferANDROID;
-const GLMessage_Function GLMessage::eglGetSystemTimeFrequencyNV;
-const GLMessage_Function GLMessage::eglGetSystemTimeNV;
-const GLMessage_Function GLMessage::invalid;
-const GLMessage_Function GLMessage::glVertexAttribPointerData;
-const GLMessage_Function GLMessage::Function_MIN;
-const GLMessage_Function GLMessage::Function_MAX;
-const int GLMessage::Function_ARRAYSIZE;
-#endif  // _MSC_VER
-bool GLMessage_DataType_Type_IsValid(int value) {
-  switch(value) {
-    case 1:
-    case 2:
-    case 3:
-    case 4:
-    case 5:
-    case 6:
-    case 7:
-    case 8:
-      return true;
-    default:
-      return false;
-  }
-}
-
-#ifndef _MSC_VER
-const GLMessage_DataType_Type GLMessage_DataType::VOID;
-const GLMessage_DataType_Type GLMessage_DataType::CHAR;
-const GLMessage_DataType_Type GLMessage_DataType::BYTE;
-const GLMessage_DataType_Type GLMessage_DataType::INT;
-const GLMessage_DataType_Type GLMessage_DataType::FLOAT;
-const GLMessage_DataType_Type GLMessage_DataType::BOOL;
-const GLMessage_DataType_Type GLMessage_DataType::ENUM;
-const GLMessage_DataType_Type GLMessage_DataType::INT64;
-const GLMessage_DataType_Type GLMessage_DataType::Type_MIN;
-const GLMessage_DataType_Type GLMessage_DataType::Type_MAX;
-const int GLMessage_DataType::Type_ARRAYSIZE;
-#endif  // _MSC_VER
-#ifndef _MSC_VER
-const int GLMessage_DataType::kTypeFieldNumber;
-const int GLMessage_DataType::kIsArrayFieldNumber;
-const int GLMessage_DataType::kIntValueFieldNumber;
-const int GLMessage_DataType::kFloatValueFieldNumber;
-const int GLMessage_DataType::kCharValueFieldNumber;
-const int GLMessage_DataType::kRawBytesFieldNumber;
-const int GLMessage_DataType::kBoolValueFieldNumber;
-const int GLMessage_DataType::kInt64ValueFieldNumber;
-#endif  // !_MSC_VER
-
-GLMessage_DataType::GLMessage_DataType()
-  : ::google::protobuf::MessageLite() {
-  SharedCtor();
-}
-
-void GLMessage_DataType::InitAsDefaultInstance() {
-}
-
-GLMessage_DataType::GLMessage_DataType(const GLMessage_DataType& from)
-  : ::google::protobuf::MessageLite() {
-  SharedCtor();
-  MergeFrom(from);
-}
-
-void GLMessage_DataType::SharedCtor() {
-  _cached_size_ = 0;
-  type_ = 1;
-  isarray_ = false;
-  ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-GLMessage_DataType::~GLMessage_DataType() {
-  SharedDtor();
-}
-
-void GLMessage_DataType::SharedDtor() {
-  if (this != default_instance_) {
-  }
-}
-
-void GLMessage_DataType::SetCachedSize(int size) const {
-  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
-  _cached_size_ = size;
-  GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const GLMessage_DataType& GLMessage_DataType::default_instance() {
-  if (default_instance_ == NULL) protobuf_AddDesc_gltrace_2eproto();  return *default_instance_;
-}
-
-GLMessage_DataType* GLMessage_DataType::default_instance_ = NULL;
-
-GLMessage_DataType* GLMessage_DataType::New() const {
-  return new GLMessage_DataType;
-}
-
-void GLMessage_DataType::Clear() {
-  if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
-    type_ = 1;
-    isarray_ = false;
-  }
-  intvalue_.Clear();
-  floatvalue_.Clear();
-  charvalue_.Clear();
-  rawbytes_.Clear();
-  boolvalue_.Clear();
-  int64value_.Clear();
-  ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-bool GLMessage_DataType::MergePartialFromCodedStream(
-    ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
-  ::google::protobuf::uint32 tag;
-  while ((tag = input->ReadTag()) != 0) {
-    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
-      // required .android.gltrace.GLMessage.DataType.Type type = 1 [default = VOID];
-      case 1: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
-          int value;
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
-                 input, &value)));
-          if (::android::gltrace::GLMessage_DataType_Type_IsValid(value)) {
-            set_type(static_cast< ::android::gltrace::GLMessage_DataType_Type >(value));
-          }
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(16)) goto parse_isArray;
-        break;
-      }
-      
-      // required bool isArray = 2 [default = false];
-      case 2: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
-         parse_isArray:
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
-                 input, &isarray_)));
-          _set_bit(1);
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(24)) goto parse_intValue;
-        break;
-      }
-      
-      // repeated int32 intValue = 3;
-      case 3: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
-         parse_intValue:
-          DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 1, 24, input, this->mutable_intvalue())));
-        } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag)
-                   == ::google::protobuf::internal::WireFormatLite::
-                      WIRETYPE_LENGTH_DELIMITED) {
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 input, this->mutable_intvalue())));
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(24)) goto parse_intValue;
-        if (input->ExpectTag(37)) goto parse_floatValue;
-        break;
-      }
-      
-      // repeated float floatValue = 4;
-      case 4: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) {
-         parse_floatValue:
-          DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
-                   float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
-                 1, 37, input, this->mutable_floatvalue())));
-        } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag)
-                   == ::google::protobuf::internal::WireFormatLite::
-                      WIRETYPE_LENGTH_DELIMITED) {
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
-                   float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
-                 input, this->mutable_floatvalue())));
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(37)) goto parse_floatValue;
-        if (input->ExpectTag(42)) goto parse_charValue;
-        break;
-      }
-      
-      // repeated bytes charValue = 5;
-      case 5: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
-         parse_charValue:
-          DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
-                input, this->add_charvalue()));
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(42)) goto parse_charValue;
-        if (input->ExpectTag(50)) goto parse_rawBytes;
-        break;
-      }
-      
-      // repeated bytes rawBytes = 6;
-      case 6: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
-         parse_rawBytes:
-          DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
-                input, this->add_rawbytes()));
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(50)) goto parse_rawBytes;
-        if (input->ExpectTag(56)) goto parse_boolValue;
-        break;
-      }
-      
-      // repeated bool boolValue = 7;
-      case 7: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
-         parse_boolValue:
-          DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
-                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
-                 1, 56, input, this->mutable_boolvalue())));
-        } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag)
-                   == ::google::protobuf::internal::WireFormatLite::
-                      WIRETYPE_LENGTH_DELIMITED) {
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
-                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
-                 input, this->mutable_boolvalue())));
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(56)) goto parse_boolValue;
-        if (input->ExpectTag(64)) goto parse_int64Value;
-        break;
-      }
-      
-      // repeated int64 int64Value = 8;
-      case 8: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
-         parse_int64Value:
-          DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
-                   ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
-                 1, 64, input, this->mutable_int64value())));
-        } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag)
-                   == ::google::protobuf::internal::WireFormatLite::
-                      WIRETYPE_LENGTH_DELIMITED) {
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
-                   ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
-                 input, this->mutable_int64value())));
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(64)) goto parse_int64Value;
-        if (input->ExpectAtEnd()) return true;
-        break;
-      }
-      
-      default: {
-      handle_uninterpreted:
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
-          return true;
-        }
-        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
-        break;
-      }
-    }
-  }
-  return true;
-#undef DO_
-}
-
-void GLMessage_DataType::SerializeWithCachedSizes(
-    ::google::protobuf::io::CodedOutputStream* output) const {
-  // required .android.gltrace.GLMessage.DataType.Type type = 1 [default = VOID];
-  if (_has_bit(0)) {
-    ::google::protobuf::internal::WireFormatLite::WriteEnum(
-      1, this->type(), output);
-  }
-  
-  // required bool isArray = 2 [default = false];
-  if (_has_bit(1)) {
-    ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->isarray(), output);
-  }
-  
-  // repeated int32 intValue = 3;
-  for (int i = 0; i < this->intvalue_size(); i++) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(
-      3, this->intvalue(i), output);
-  }
-  
-  // repeated float floatValue = 4;
-  for (int i = 0; i < this->floatvalue_size(); i++) {
-    ::google::protobuf::internal::WireFormatLite::WriteFloat(
-      4, this->floatvalue(i), output);
-  }
-  
-  // repeated bytes charValue = 5;
-  for (int i = 0; i < this->charvalue_size(); i++) {
-    ::google::protobuf::internal::WireFormatLite::WriteBytes(
-      5, this->charvalue(i), output);
-  }
-  
-  // repeated bytes rawBytes = 6;
-  for (int i = 0; i < this->rawbytes_size(); i++) {
-    ::google::protobuf::internal::WireFormatLite::WriteBytes(
-      6, this->rawbytes(i), output);
-  }
-  
-  // repeated bool boolValue = 7;
-  for (int i = 0; i < this->boolvalue_size(); i++) {
-    ::google::protobuf::internal::WireFormatLite::WriteBool(
-      7, this->boolvalue(i), output);
-  }
-  
-  // repeated int64 int64Value = 8;
-  for (int i = 0; i < this->int64value_size(); i++) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt64(
-      8, this->int64value(i), output);
-  }
-  
-}
-
-int GLMessage_DataType::ByteSize() const {
-  int total_size = 0;
-  
-  if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
-    // required .android.gltrace.GLMessage.DataType.Type type = 1 [default = VOID];
-    if (has_type()) {
-      total_size += 1 +
-        ::google::protobuf::internal::WireFormatLite::EnumSize(this->type());
-    }
-    
-    // required bool isArray = 2 [default = false];
-    if (has_isarray()) {
-      total_size += 1 + 1;
-    }
-    
-  }
-  // repeated int32 intValue = 3;
-  {
-    int data_size = 0;
-    for (int i = 0; i < this->intvalue_size(); i++) {
-      data_size += ::google::protobuf::internal::WireFormatLite::
-        Int32Size(this->intvalue(i));
-    }
-    total_size += 1 * this->intvalue_size() + data_size;
-  }
-  
-  // repeated float floatValue = 4;
-  {
-    int data_size = 0;
-    data_size = 4 * this->floatvalue_size();
-    total_size += 1 * this->floatvalue_size() + data_size;
-  }
-  
-  // repeated bytes charValue = 5;
-  total_size += 1 * this->charvalue_size();
-  for (int i = 0; i < this->charvalue_size(); i++) {
-    total_size += ::google::protobuf::internal::WireFormatLite::BytesSize(
-      this->charvalue(i));
-  }
-  
-  // repeated bytes rawBytes = 6;
-  total_size += 1 * this->rawbytes_size();
-  for (int i = 0; i < this->rawbytes_size(); i++) {
-    total_size += ::google::protobuf::internal::WireFormatLite::BytesSize(
-      this->rawbytes(i));
-  }
-  
-  // repeated bool boolValue = 7;
-  {
-    int data_size = 0;
-    data_size = 1 * this->boolvalue_size();
-    total_size += 1 * this->boolvalue_size() + data_size;
-  }
-  
-  // repeated int64 int64Value = 8;
-  {
-    int data_size = 0;
-    for (int i = 0; i < this->int64value_size(); i++) {
-      data_size += ::google::protobuf::internal::WireFormatLite::
-        Int64Size(this->int64value(i));
-    }
-    total_size += 1 * this->int64value_size() + data_size;
-  }
-  
-  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
-  _cached_size_ = total_size;
-  GOOGLE_SAFE_CONCURRENT_WRITES_END();
-  return total_size;
-}
-
-void GLMessage_DataType::CheckTypeAndMergeFrom(
-    const ::google::protobuf::MessageLite& from) {
-  MergeFrom(*::google::protobuf::down_cast<const GLMessage_DataType*>(&from));
-}
-
-void GLMessage_DataType::MergeFrom(const GLMessage_DataType& from) {
-  GOOGLE_CHECK_NE(&from, this);
-  intvalue_.MergeFrom(from.intvalue_);
-  floatvalue_.MergeFrom(from.floatvalue_);
-  charvalue_.MergeFrom(from.charvalue_);
-  rawbytes_.MergeFrom(from.rawbytes_);
-  boolvalue_.MergeFrom(from.boolvalue_);
-  int64value_.MergeFrom(from.int64value_);
-  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
-    if (from._has_bit(0)) {
-      set_type(from.type());
-    }
-    if (from._has_bit(1)) {
-      set_isarray(from.isarray());
-    }
-  }
-}
-
-void GLMessage_DataType::CopyFrom(const GLMessage_DataType& from) {
-  if (&from == this) return;
-  Clear();
-  MergeFrom(from);
-}
-
-bool GLMessage_DataType::IsInitialized() const {
-  if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;
-  
-  return true;
-}
-
-void GLMessage_DataType::Swap(GLMessage_DataType* other) {
-  if (other != this) {
-    std::swap(type_, other->type_);
-    std::swap(isarray_, other->isarray_);
-    intvalue_.Swap(&other->intvalue_);
-    floatvalue_.Swap(&other->floatvalue_);
-    charvalue_.Swap(&other->charvalue_);
-    rawbytes_.Swap(&other->rawbytes_);
-    boolvalue_.Swap(&other->boolvalue_);
-    int64value_.Swap(&other->int64value_);
-    std::swap(_has_bits_[0], other->_has_bits_[0]);
-    std::swap(_cached_size_, other->_cached_size_);
-  }
-}
-
-::std::string GLMessage_DataType::GetTypeName() const {
-  return "android.gltrace.GLMessage.DataType";
-}
-
-
-// -------------------------------------------------------------------
-
-#ifndef _MSC_VER
-const int GLMessage_FrameBuffer::kWidthFieldNumber;
-const int GLMessage_FrameBuffer::kHeightFieldNumber;
-const int GLMessage_FrameBuffer::kContentsFieldNumber;
-#endif  // !_MSC_VER
-
-GLMessage_FrameBuffer::GLMessage_FrameBuffer()
-  : ::google::protobuf::MessageLite() {
-  SharedCtor();
-}
-
-void GLMessage_FrameBuffer::InitAsDefaultInstance() {
-}
-
-GLMessage_FrameBuffer::GLMessage_FrameBuffer(const GLMessage_FrameBuffer& from)
-  : ::google::protobuf::MessageLite() {
-  SharedCtor();
-  MergeFrom(from);
-}
-
-void GLMessage_FrameBuffer::SharedCtor() {
-  _cached_size_ = 0;
-  width_ = 0;
-  height_ = 0;
-  ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-GLMessage_FrameBuffer::~GLMessage_FrameBuffer() {
-  SharedDtor();
-}
-
-void GLMessage_FrameBuffer::SharedDtor() {
-  if (this != default_instance_) {
-  }
-}
-
-void GLMessage_FrameBuffer::SetCachedSize(int size) const {
-  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
-  _cached_size_ = size;
-  GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const GLMessage_FrameBuffer& GLMessage_FrameBuffer::default_instance() {
-  if (default_instance_ == NULL) protobuf_AddDesc_gltrace_2eproto();  return *default_instance_;
-}
-
-GLMessage_FrameBuffer* GLMessage_FrameBuffer::default_instance_ = NULL;
-
-GLMessage_FrameBuffer* GLMessage_FrameBuffer::New() const {
-  return new GLMessage_FrameBuffer;
-}
-
-void GLMessage_FrameBuffer::Clear() {
-  if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
-    width_ = 0;
-    height_ = 0;
-  }
-  contents_.Clear();
-  ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-bool GLMessage_FrameBuffer::MergePartialFromCodedStream(
-    ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
-  ::google::protobuf::uint32 tag;
-  while ((tag = input->ReadTag()) != 0) {
-    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
-      // required int32 width = 1;
-      case 1: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 input, &width_)));
-          _set_bit(0);
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(16)) goto parse_height;
-        break;
-      }
-      
-      // required int32 height = 2;
-      case 2: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
-         parse_height:
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 input, &height_)));
-          _set_bit(1);
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(26)) goto parse_contents;
-        break;
-      }
-      
-      // repeated bytes contents = 3;
-      case 3: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
-         parse_contents:
-          DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
-                input, this->add_contents()));
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(26)) goto parse_contents;
-        if (input->ExpectAtEnd()) return true;
-        break;
-      }
-      
-      default: {
-      handle_uninterpreted:
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
-          return true;
-        }
-        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
-        break;
-      }
-    }
-  }
-  return true;
-#undef DO_
-}
-
-void GLMessage_FrameBuffer::SerializeWithCachedSizes(
-    ::google::protobuf::io::CodedOutputStream* output) const {
-  // required int32 width = 1;
-  if (_has_bit(0)) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->width(), output);
-  }
-  
-  // required int32 height = 2;
-  if (_has_bit(1)) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->height(), output);
-  }
-  
-  // repeated bytes contents = 3;
-  for (int i = 0; i < this->contents_size(); i++) {
-    ::google::protobuf::internal::WireFormatLite::WriteBytes(
-      3, this->contents(i), output);
-  }
-  
-}
-
-int GLMessage_FrameBuffer::ByteSize() const {
-  int total_size = 0;
-  
-  if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
-    // required int32 width = 1;
-    if (has_width()) {
-      total_size += 1 +
-        ::google::protobuf::internal::WireFormatLite::Int32Size(
-          this->width());
-    }
-    
-    // required int32 height = 2;
-    if (has_height()) {
-      total_size += 1 +
-        ::google::protobuf::internal::WireFormatLite::Int32Size(
-          this->height());
-    }
-    
-  }
-  // repeated bytes contents = 3;
-  total_size += 1 * this->contents_size();
-  for (int i = 0; i < this->contents_size(); i++) {
-    total_size += ::google::protobuf::internal::WireFormatLite::BytesSize(
-      this->contents(i));
-  }
-  
-  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
-  _cached_size_ = total_size;
-  GOOGLE_SAFE_CONCURRENT_WRITES_END();
-  return total_size;
-}
-
-void GLMessage_FrameBuffer::CheckTypeAndMergeFrom(
-    const ::google::protobuf::MessageLite& from) {
-  MergeFrom(*::google::protobuf::down_cast<const GLMessage_FrameBuffer*>(&from));
-}
-
-void GLMessage_FrameBuffer::MergeFrom(const GLMessage_FrameBuffer& from) {
-  GOOGLE_CHECK_NE(&from, this);
-  contents_.MergeFrom(from.contents_);
-  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
-    if (from._has_bit(0)) {
-      set_width(from.width());
-    }
-    if (from._has_bit(1)) {
-      set_height(from.height());
-    }
-  }
-}
-
-void GLMessage_FrameBuffer::CopyFrom(const GLMessage_FrameBuffer& from) {
-  if (&from == this) return;
-  Clear();
-  MergeFrom(from);
-}
-
-bool GLMessage_FrameBuffer::IsInitialized() const {
-  if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;
-  
-  return true;
-}
-
-void GLMessage_FrameBuffer::Swap(GLMessage_FrameBuffer* other) {
-  if (other != this) {
-    std::swap(width_, other->width_);
-    std::swap(height_, other->height_);
-    contents_.Swap(&other->contents_);
-    std::swap(_has_bits_[0], other->_has_bits_[0]);
-    std::swap(_cached_size_, other->_cached_size_);
-  }
-}
-
-::std::string GLMessage_FrameBuffer::GetTypeName() const {
-  return "android.gltrace.GLMessage.FrameBuffer";
-}
-
-
-// -------------------------------------------------------------------
-
-#ifndef _MSC_VER
-const int GLMessage::kContextIdFieldNumber;
-const int GLMessage::kStartTimeFieldNumber;
-const int GLMessage::kDurationFieldNumber;
-const int GLMessage::kFunctionFieldNumber;
-const int GLMessage::kArgsFieldNumber;
-const int GLMessage::kReturnValueFieldNumber;
-const int GLMessage::kFbFieldNumber;
-const int GLMessage::kThreadtimeFieldNumber;
-#endif  // !_MSC_VER
-
-GLMessage::GLMessage()
-  : ::google::protobuf::MessageLite() {
-  SharedCtor();
-}
-
-void GLMessage::InitAsDefaultInstance() {
-  returnvalue_ = const_cast< ::android::gltrace::GLMessage_DataType*>(&::android::gltrace::GLMessage_DataType::default_instance());
-  fb_ = const_cast< ::android::gltrace::GLMessage_FrameBuffer*>(&::android::gltrace::GLMessage_FrameBuffer::default_instance());
-}
-
-GLMessage::GLMessage(const GLMessage& from)
-  : ::google::protobuf::MessageLite() {
-  SharedCtor();
-  MergeFrom(from);
-}
-
-void GLMessage::SharedCtor() {
-  _cached_size_ = 0;
-  context_id_ = 0;
-  start_time_ = GOOGLE_LONGLONG(0);
-  duration_ = 0;
-  function_ = 3000;
-  returnvalue_ = NULL;
-  fb_ = NULL;
-  threadtime_ = 0;
-  ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-GLMessage::~GLMessage() {
-  SharedDtor();
-}
-
-void GLMessage::SharedDtor() {
-  if (this != default_instance_) {
-    delete returnvalue_;
-    delete fb_;
-  }
-}
-
-void GLMessage::SetCachedSize(int size) const {
-  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
-  _cached_size_ = size;
-  GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const GLMessage& GLMessage::default_instance() {
-  if (default_instance_ == NULL) protobuf_AddDesc_gltrace_2eproto();  return *default_instance_;
-}
-
-GLMessage* GLMessage::default_instance_ = NULL;
-
-GLMessage* GLMessage::New() const {
-  return new GLMessage;
-}
-
-void GLMessage::Clear() {
-  if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
-    context_id_ = 0;
-    start_time_ = GOOGLE_LONGLONG(0);
-    duration_ = 0;
-    function_ = 3000;
-    if (_has_bit(5)) {
-      if (returnvalue_ != NULL) returnvalue_->::android::gltrace::GLMessage_DataType::Clear();
-    }
-    if (_has_bit(6)) {
-      if (fb_ != NULL) fb_->::android::gltrace::GLMessage_FrameBuffer::Clear();
-    }
-    threadtime_ = 0;
-  }
-  args_.Clear();
-  ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-bool GLMessage::MergePartialFromCodedStream(
-    ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
-  ::google::protobuf::uint32 tag;
-  while ((tag = input->ReadTag()) != 0) {
-    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
-      // required int32 context_id = 1;
-      case 1: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 input, &context_id_)));
-          _set_bit(0);
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(16)) goto parse_start_time;
-        break;
-      }
-      
-      // required int64 start_time = 2;
-      case 2: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
-         parse_start_time:
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
-                 input, &start_time_)));
-          _set_bit(1);
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(24)) goto parse_duration;
-        break;
-      }
-      
-      // required int32 duration = 3;
-      case 3: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
-         parse_duration:
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 input, &duration_)));
-          _set_bit(2);
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(32)) goto parse_function;
-        break;
-      }
-      
-      // required .android.gltrace.GLMessage.Function function = 4 [default = invalid];
-      case 4: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
-         parse_function:
-          int value;
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
-                 input, &value)));
-          if (::android::gltrace::GLMessage_Function_IsValid(value)) {
-            set_function(static_cast< ::android::gltrace::GLMessage_Function >(value));
-          }
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(42)) goto parse_args;
-        break;
-      }
-      
-      // repeated .android.gltrace.GLMessage.DataType args = 5;
-      case 5: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
-         parse_args:
-          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
-                input, add_args()));
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(42)) goto parse_args;
-        if (input->ExpectTag(50)) goto parse_returnValue;
-        break;
-      }
-      
-      // optional .android.gltrace.GLMessage.DataType returnValue = 6;
-      case 6: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
-         parse_returnValue:
-          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
-               input, mutable_returnvalue()));
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(58)) goto parse_fb;
-        break;
-      }
-      
-      // optional .android.gltrace.GLMessage.FrameBuffer fb = 7;
-      case 7: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
-         parse_fb:
-          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
-               input, mutable_fb()));
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectTag(64)) goto parse_threadtime;
-        break;
-      }
-      
-      // optional int32 threadtime = 8;
-      case 8: {
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
-         parse_threadtime:
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 input, &threadtime_)));
-          _set_bit(7);
-        } else {
-          goto handle_uninterpreted;
-        }
-        if (input->ExpectAtEnd()) return true;
-        break;
-      }
-      
-      default: {
-      handle_uninterpreted:
-        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
-            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
-          return true;
-        }
-        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
-        break;
-      }
-    }
-  }
-  return true;
-#undef DO_
-}
-
-void GLMessage::SerializeWithCachedSizes(
-    ::google::protobuf::io::CodedOutputStream* output) const {
-  // required int32 context_id = 1;
-  if (_has_bit(0)) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->context_id(), output);
-  }
-  
-  // required int64 start_time = 2;
-  if (_has_bit(1)) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt64(2, this->start_time(), output);
-  }
-  
-  // required int32 duration = 3;
-  if (_has_bit(2)) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->duration(), output);
-  }
-  
-  // required .android.gltrace.GLMessage.Function function = 4 [default = invalid];
-  if (_has_bit(3)) {
-    ::google::protobuf::internal::WireFormatLite::WriteEnum(
-      4, this->function(), output);
-  }
-  
-  // repeated .android.gltrace.GLMessage.DataType args = 5;
-  for (int i = 0; i < this->args_size(); i++) {
-    ::google::protobuf::internal::WireFormatLite::WriteMessage(
-      5, this->args(i), output);
-  }
-  
-  // optional .android.gltrace.GLMessage.DataType returnValue = 6;
-  if (_has_bit(5)) {
-    ::google::protobuf::internal::WireFormatLite::WriteMessage(
-      6, this->returnvalue(), output);
-  }
-  
-  // optional .android.gltrace.GLMessage.FrameBuffer fb = 7;
-  if (_has_bit(6)) {
-    ::google::protobuf::internal::WireFormatLite::WriteMessage(
-      7, this->fb(), output);
-  }
-  
-  // optional int32 threadtime = 8;
-  if (_has_bit(7)) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(8, this->threadtime(), output);
-  }
-  
-}
-
-int GLMessage::ByteSize() const {
-  int total_size = 0;
-  
-  if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
-    // required int32 context_id = 1;
-    if (has_context_id()) {
-      total_size += 1 +
-        ::google::protobuf::internal::WireFormatLite::Int32Size(
-          this->context_id());
-    }
-    
-    // required int64 start_time = 2;
-    if (has_start_time()) {
-      total_size += 1 +
-        ::google::protobuf::internal::WireFormatLite::Int64Size(
-          this->start_time());
-    }
-    
-    // required int32 duration = 3;
-    if (has_duration()) {
-      total_size += 1 +
-        ::google::protobuf::internal::WireFormatLite::Int32Size(
-          this->duration());
-    }
-    
-    // required .android.gltrace.GLMessage.Function function = 4 [default = invalid];
-    if (has_function()) {
-      total_size += 1 +
-        ::google::protobuf::internal::WireFormatLite::EnumSize(this->function());
-    }
-    
-    // optional .android.gltrace.GLMessage.DataType returnValue = 6;
-    if (has_returnvalue()) {
-      total_size += 1 +
-        ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
-          this->returnvalue());
-    }
-    
-    // optional .android.gltrace.GLMessage.FrameBuffer fb = 7;
-    if (has_fb()) {
-      total_size += 1 +
-        ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
-          this->fb());
-    }
-    
-    // optional int32 threadtime = 8;
-    if (has_threadtime()) {
-      total_size += 1 +
-        ::google::protobuf::internal::WireFormatLite::Int32Size(
-          this->threadtime());
-    }
-    
-  }
-  // repeated .android.gltrace.GLMessage.DataType args = 5;
-  total_size += 1 * this->args_size();
-  for (int i = 0; i < this->args_size(); i++) {
-    total_size +=
-      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
-        this->args(i));
-  }
-  
-  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
-  _cached_size_ = total_size;
-  GOOGLE_SAFE_CONCURRENT_WRITES_END();
-  return total_size;
-}
-
-void GLMessage::CheckTypeAndMergeFrom(
-    const ::google::protobuf::MessageLite& from) {
-  MergeFrom(*::google::protobuf::down_cast<const GLMessage*>(&from));
-}
-
-void GLMessage::MergeFrom(const GLMessage& from) {
-  GOOGLE_CHECK_NE(&from, this);
-  args_.MergeFrom(from.args_);
-  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
-    if (from._has_bit(0)) {
-      set_context_id(from.context_id());
-    }
-    if (from._has_bit(1)) {
-      set_start_time(from.start_time());
-    }
-    if (from._has_bit(2)) {
-      set_duration(from.duration());
-    }
-    if (from._has_bit(3)) {
-      set_function(from.function());
-    }
-    if (from._has_bit(5)) {
-      mutable_returnvalue()->::android::gltrace::GLMessage_DataType::MergeFrom(from.returnvalue());
-    }
-    if (from._has_bit(6)) {
-      mutable_fb()->::android::gltrace::GLMessage_FrameBuffer::MergeFrom(from.fb());
-    }
-    if (from._has_bit(7)) {
-      set_threadtime(from.threadtime());
-    }
-  }
-}
-
-void GLMessage::CopyFrom(const GLMessage& from) {
-  if (&from == this) return;
-  Clear();
-  MergeFrom(from);
-}
-
-bool GLMessage::IsInitialized() const {
-  if ((_has_bits_[0] & 0x0000000f) != 0x0000000f) return false;
-  
-  for (int i = 0; i < args_size(); i++) {
-    if (!this->args(i).IsInitialized()) return false;
-  }
-  if (has_returnvalue()) {
-    if (!this->returnvalue().IsInitialized()) return false;
-  }
-  if (has_fb()) {
-    if (!this->fb().IsInitialized()) return false;
-  }
-  return true;
-}
-
-void GLMessage::Swap(GLMessage* other) {
-  if (other != this) {
-    std::swap(context_id_, other->context_id_);
-    std::swap(start_time_, other->start_time_);
-    std::swap(duration_, other->duration_);
-    std::swap(function_, other->function_);
-    args_.Swap(&other->args_);
-    std::swap(returnvalue_, other->returnvalue_);
-    std::swap(fb_, other->fb_);
-    std::swap(threadtime_, other->threadtime_);
-    std::swap(_has_bits_[0], other->_has_bits_[0]);
-    std::swap(_cached_size_, other->_cached_size_);
-  }
-}
-
-::std::string GLMessage::GetTypeName() const {
-  return "android.gltrace.GLMessage";
-}
-
-
-// @@protoc_insertion_point(namespace_scope)
-
-}  // namespace gltrace
-}  // namespace android
-
-// @@protoc_insertion_point(global_scope)
diff --git a/opengl/libs/GLES_trace/src/gltrace.pb.h b/opengl/libs/GLES_trace/src/gltrace.pb.h
deleted file mode 100644
index 9eae26c..0000000
--- a/opengl/libs/GLES_trace/src/gltrace.pb.h
+++ /dev/null
@@ -1,2143 +0,0 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: gltrace.proto
-
-#ifndef PROTOBUF_gltrace_2eproto__INCLUDED
-#define PROTOBUF_gltrace_2eproto__INCLUDED
-
-#include <string>
-
-#include <google/protobuf/stubs/common.h>
-
-#if GOOGLE_PROTOBUF_VERSION < 2003000
-#error This file was generated by a newer version of protoc which is
-#error incompatible with your Protocol Buffer headers.  Please update
-#error your headers.
-#endif
-#if 2003000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
-#error This file was generated by an older version of protoc which is
-#error incompatible with your Protocol Buffer headers.  Please
-#error regenerate this file with a newer version of protoc.
-#endif
-
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/extension_set.h>
-// @@protoc_insertion_point(includes)
-
-namespace android {
-namespace gltrace {
-
-// Internal implementation detail -- do not call these.
-void  protobuf_AddDesc_gltrace_2eproto();
-void protobuf_AssignDesc_gltrace_2eproto();
-void protobuf_ShutdownFile_gltrace_2eproto();
-
-class GLMessage;
-class GLMessage_DataType;
-class GLMessage_FrameBuffer;
-
-enum GLMessage_DataType_Type {
-  GLMessage_DataType_Type_VOID = 1,
-  GLMessage_DataType_Type_CHAR = 2,
-  GLMessage_DataType_Type_BYTE = 3,
-  GLMessage_DataType_Type_INT = 4,
-  GLMessage_DataType_Type_FLOAT = 5,
-  GLMessage_DataType_Type_BOOL = 6,
-  GLMessage_DataType_Type_ENUM = 7,
-  GLMessage_DataType_Type_INT64 = 8
-};
-bool GLMessage_DataType_Type_IsValid(int value);
-const GLMessage_DataType_Type GLMessage_DataType_Type_Type_MIN = GLMessage_DataType_Type_VOID;
-const GLMessage_DataType_Type GLMessage_DataType_Type_Type_MAX = GLMessage_DataType_Type_INT64;
-const int GLMessage_DataType_Type_Type_ARRAYSIZE = GLMessage_DataType_Type_Type_MAX + 1;
-
-enum GLMessage_Function {
-  GLMessage_Function_glActiveTexture = 0,
-  GLMessage_Function_glAlphaFunc = 1,
-  GLMessage_Function_glAlphaFuncx = 2,
-  GLMessage_Function_glAlphaFuncxOES = 3,
-  GLMessage_Function_glAttachShader = 4,
-  GLMessage_Function_glBeginPerfMonitorAMD = 5,
-  GLMessage_Function_glBindAttribLocation = 6,
-  GLMessage_Function_glBindBuffer = 7,
-  GLMessage_Function_glBindFramebuffer = 8,
-  GLMessage_Function_glBindFramebufferOES = 9,
-  GLMessage_Function_glBindRenderbuffer = 10,
-  GLMessage_Function_glBindRenderbufferOES = 11,
-  GLMessage_Function_glBindTexture = 12,
-  GLMessage_Function_glBindVertexArrayOES = 13,
-  GLMessage_Function_glBlendColor = 14,
-  GLMessage_Function_glBlendEquation = 15,
-  GLMessage_Function_glBlendEquationOES = 16,
-  GLMessage_Function_glBlendEquationSeparate = 17,
-  GLMessage_Function_glBlendEquationSeparateOES = 18,
-  GLMessage_Function_glBlendFunc = 19,
-  GLMessage_Function_glBlendFuncSeparate = 20,
-  GLMessage_Function_glBlendFuncSeparateOES = 21,
-  GLMessage_Function_glBufferData = 22,
-  GLMessage_Function_glBufferSubData = 23,
-  GLMessage_Function_glCheckFramebufferStatus = 24,
-  GLMessage_Function_glCheckFramebufferStatusOES = 25,
-  GLMessage_Function_glClearColor = 26,
-  GLMessage_Function_glClearColorx = 27,
-  GLMessage_Function_glClearColorxOES = 28,
-  GLMessage_Function_glClearDepthf = 29,
-  GLMessage_Function_glClearDepthfOES = 30,
-  GLMessage_Function_glClearDepthx = 31,
-  GLMessage_Function_glClearDepthxOES = 32,
-  GLMessage_Function_glClear = 33,
-  GLMessage_Function_glClearStencil = 34,
-  GLMessage_Function_glClientActiveTexture = 35,
-  GLMessage_Function_glClipPlanef = 36,
-  GLMessage_Function_glClipPlanefIMG = 37,
-  GLMessage_Function_glClipPlanefOES = 38,
-  GLMessage_Function_glClipPlanex = 39,
-  GLMessage_Function_glClipPlanexIMG = 40,
-  GLMessage_Function_glClipPlanexOES = 41,
-  GLMessage_Function_glColor4f = 42,
-  GLMessage_Function_glColor4ub = 43,
-  GLMessage_Function_glColor4x = 44,
-  GLMessage_Function_glColor4xOES = 45,
-  GLMessage_Function_glColorMask = 46,
-  GLMessage_Function_glColorPointer = 47,
-  GLMessage_Function_glCompileShader = 48,
-  GLMessage_Function_glCompressedTexImage2D = 49,
-  GLMessage_Function_glCompressedTexImage3DOES = 50,
-  GLMessage_Function_glCompressedTexSubImage2D = 51,
-  GLMessage_Function_glCompressedTexSubImage3DOES = 52,
-  GLMessage_Function_glCopyTexImage2D = 53,
-  GLMessage_Function_glCopyTexSubImage2D = 54,
-  GLMessage_Function_glCopyTexSubImage3DOES = 55,
-  GLMessage_Function_glCoverageMaskNV = 56,
-  GLMessage_Function_glCoverageOperationNV = 57,
-  GLMessage_Function_glCreateProgram = 58,
-  GLMessage_Function_glCreateShader = 59,
-  GLMessage_Function_glCullFace = 60,
-  GLMessage_Function_glCurrentPaletteMatrixOES = 61,
-  GLMessage_Function_glDeleteBuffers = 62,
-  GLMessage_Function_glDeleteFencesNV = 63,
-  GLMessage_Function_glDeleteFramebuffers = 64,
-  GLMessage_Function_glDeleteFramebuffersOES = 65,
-  GLMessage_Function_glDeletePerfMonitorsAMD = 66,
-  GLMessage_Function_glDeleteProgram = 67,
-  GLMessage_Function_glDeleteRenderbuffers = 68,
-  GLMessage_Function_glDeleteRenderbuffersOES = 69,
-  GLMessage_Function_glDeleteShader = 70,
-  GLMessage_Function_glDeleteTextures = 71,
-  GLMessage_Function_glDeleteVertexArraysOES = 72,
-  GLMessage_Function_glDepthFunc = 73,
-  GLMessage_Function_glDepthMask = 74,
-  GLMessage_Function_glDepthRangef = 75,
-  GLMessage_Function_glDepthRangefOES = 76,
-  GLMessage_Function_glDepthRangex = 77,
-  GLMessage_Function_glDepthRangexOES = 78,
-  GLMessage_Function_glDetachShader = 79,
-  GLMessage_Function_glDisableClientState = 80,
-  GLMessage_Function_glDisableDriverControlQCOM = 81,
-  GLMessage_Function_glDisable = 82,
-  GLMessage_Function_glDisableVertexAttribArray = 83,
-  GLMessage_Function_glDiscardFramebufferEXT = 84,
-  GLMessage_Function_glDrawArrays = 85,
-  GLMessage_Function_glDrawElements = 86,
-  GLMessage_Function_glDrawTexfOES = 87,
-  GLMessage_Function_glDrawTexfvOES = 88,
-  GLMessage_Function_glDrawTexiOES = 89,
-  GLMessage_Function_glDrawTexivOES = 90,
-  GLMessage_Function_glDrawTexsOES = 91,
-  GLMessage_Function_glDrawTexsvOES = 92,
-  GLMessage_Function_glDrawTexxOES = 93,
-  GLMessage_Function_glDrawTexxvOES = 94,
-  GLMessage_Function_glEGLImageTargetRenderbufferStorageOES = 95,
-  GLMessage_Function_glEGLImageTargetTexture2DOES = 96,
-  GLMessage_Function_glEnableClientState = 97,
-  GLMessage_Function_glEnableDriverControlQCOM = 98,
-  GLMessage_Function_glEnable = 99,
-  GLMessage_Function_glEnableVertexAttribArray = 100,
-  GLMessage_Function_glEndPerfMonitorAMD = 101,
-  GLMessage_Function_glEndTilingQCOM = 102,
-  GLMessage_Function_glExtGetBufferPointervQCOM = 103,
-  GLMessage_Function_glExtGetBuffersQCOM = 104,
-  GLMessage_Function_glExtGetFramebuffersQCOM = 105,
-  GLMessage_Function_glExtGetProgramBinarySourceQCOM = 106,
-  GLMessage_Function_glExtGetProgramsQCOM = 107,
-  GLMessage_Function_glExtGetRenderbuffersQCOM = 108,
-  GLMessage_Function_glExtGetShadersQCOM = 109,
-  GLMessage_Function_glExtGetTexLevelParameterivQCOM = 110,
-  GLMessage_Function_glExtGetTexSubImageQCOM = 111,
-  GLMessage_Function_glExtGetTexturesQCOM = 112,
-  GLMessage_Function_glExtIsProgramBinaryQCOM = 113,
-  GLMessage_Function_glExtTexObjectStateOverrideiQCOM = 114,
-  GLMessage_Function_glFinishFenceNV = 115,
-  GLMessage_Function_glFinish = 116,
-  GLMessage_Function_glFlush = 117,
-  GLMessage_Function_glFogf = 118,
-  GLMessage_Function_glFogfv = 119,
-  GLMessage_Function_glFogx = 120,
-  GLMessage_Function_glFogxOES = 121,
-  GLMessage_Function_glFogxv = 122,
-  GLMessage_Function_glFogxvOES = 123,
-  GLMessage_Function_glFramebufferRenderbuffer = 124,
-  GLMessage_Function_glFramebufferRenderbufferOES = 125,
-  GLMessage_Function_glFramebufferTexture2D = 126,
-  GLMessage_Function_glFramebufferTexture2DMultisampleIMG = 127,
-  GLMessage_Function_glFramebufferTexture2DOES = 128,
-  GLMessage_Function_glFramebufferTexture3DOES = 129,
-  GLMessage_Function_glFrontFace = 130,
-  GLMessage_Function_glFrustumf = 131,
-  GLMessage_Function_glFrustumfOES = 132,
-  GLMessage_Function_glFrustumx = 133,
-  GLMessage_Function_glFrustumxOES = 134,
-  GLMessage_Function_glGenBuffers = 135,
-  GLMessage_Function_glGenerateMipmap = 136,
-  GLMessage_Function_glGenerateMipmapOES = 137,
-  GLMessage_Function_glGenFencesNV = 138,
-  GLMessage_Function_glGenFramebuffers = 139,
-  GLMessage_Function_glGenFramebuffersOES = 140,
-  GLMessage_Function_glGenPerfMonitorsAMD = 141,
-  GLMessage_Function_glGenRenderbuffers = 142,
-  GLMessage_Function_glGenRenderbuffersOES = 143,
-  GLMessage_Function_glGenTextures = 144,
-  GLMessage_Function_glGenVertexArraysOES = 145,
-  GLMessage_Function_glGetActiveAttrib = 146,
-  GLMessage_Function_glGetActiveUniform = 147,
-  GLMessage_Function_glGetAttachedShaders = 148,
-  GLMessage_Function_glGetAttribLocation = 149,
-  GLMessage_Function_glGetBooleanv = 150,
-  GLMessage_Function_glGetBufferParameteriv = 151,
-  GLMessage_Function_glGetBufferPointervOES = 152,
-  GLMessage_Function_glGetClipPlanef = 153,
-  GLMessage_Function_glGetClipPlanefOES = 154,
-  GLMessage_Function_glGetClipPlanex = 155,
-  GLMessage_Function_glGetClipPlanexOES = 156,
-  GLMessage_Function_glGetDriverControlsQCOM = 157,
-  GLMessage_Function_glGetDriverControlStringQCOM = 158,
-  GLMessage_Function_glGetError = 159,
-  GLMessage_Function_glGetFenceivNV = 160,
-  GLMessage_Function_glGetFixedv = 161,
-  GLMessage_Function_glGetFixedvOES = 162,
-  GLMessage_Function_glGetFloatv = 163,
-  GLMessage_Function_glGetFramebufferAttachmentParameteriv = 164,
-  GLMessage_Function_glGetFramebufferAttachmentParameterivOES = 165,
-  GLMessage_Function_glGetIntegerv = 166,
-  GLMessage_Function_glGetLightfv = 167,
-  GLMessage_Function_glGetLightxv = 168,
-  GLMessage_Function_glGetLightxvOES = 169,
-  GLMessage_Function_glGetMaterialfv = 170,
-  GLMessage_Function_glGetMaterialxv = 171,
-  GLMessage_Function_glGetMaterialxvOES = 172,
-  GLMessage_Function_glGetPerfMonitorCounterDataAMD = 173,
-  GLMessage_Function_glGetPerfMonitorCounterInfoAMD = 174,
-  GLMessage_Function_glGetPerfMonitorCountersAMD = 175,
-  GLMessage_Function_glGetPerfMonitorCounterStringAMD = 176,
-  GLMessage_Function_glGetPerfMonitorGroupsAMD = 177,
-  GLMessage_Function_glGetPerfMonitorGroupStringAMD = 178,
-  GLMessage_Function_glGetPointerv = 179,
-  GLMessage_Function_glGetProgramBinaryOES = 180,
-  GLMessage_Function_glGetProgramInfoLog = 181,
-  GLMessage_Function_glGetProgramiv = 182,
-  GLMessage_Function_glGetRenderbufferParameteriv = 183,
-  GLMessage_Function_glGetRenderbufferParameterivOES = 184,
-  GLMessage_Function_glGetShaderInfoLog = 185,
-  GLMessage_Function_glGetShaderiv = 186,
-  GLMessage_Function_glGetShaderPrecisionFormat = 187,
-  GLMessage_Function_glGetShaderSource = 188,
-  GLMessage_Function_glGetString = 189,
-  GLMessage_Function_glGetTexEnvfv = 190,
-  GLMessage_Function_glGetTexEnviv = 191,
-  GLMessage_Function_glGetTexEnvxv = 192,
-  GLMessage_Function_glGetTexEnvxvOES = 193,
-  GLMessage_Function_glGetTexGenfvOES = 194,
-  GLMessage_Function_glGetTexGenivOES = 195,
-  GLMessage_Function_glGetTexGenxvOES = 196,
-  GLMessage_Function_glGetTexParameterfv = 197,
-  GLMessage_Function_glGetTexParameteriv = 198,
-  GLMessage_Function_glGetTexParameterxv = 199,
-  GLMessage_Function_glGetTexParameterxvOES = 200,
-  GLMessage_Function_glGetUniformfv = 201,
-  GLMessage_Function_glGetUniformiv = 202,
-  GLMessage_Function_glGetUniformLocation = 203,
-  GLMessage_Function_glGetVertexAttribfv = 204,
-  GLMessage_Function_glGetVertexAttribiv = 205,
-  GLMessage_Function_glGetVertexAttribPointerv = 206,
-  GLMessage_Function_glHint = 207,
-  GLMessage_Function_glIsBuffer = 208,
-  GLMessage_Function_glIsEnabled = 209,
-  GLMessage_Function_glIsFenceNV = 210,
-  GLMessage_Function_glIsFramebuffer = 211,
-  GLMessage_Function_glIsFramebufferOES = 212,
-  GLMessage_Function_glIsProgram = 213,
-  GLMessage_Function_glIsRenderbuffer = 214,
-  GLMessage_Function_glIsRenderbufferOES = 215,
-  GLMessage_Function_glIsShader = 216,
-  GLMessage_Function_glIsTexture = 217,
-  GLMessage_Function_glIsVertexArrayOES = 218,
-  GLMessage_Function_glLightf = 219,
-  GLMessage_Function_glLightfv = 220,
-  GLMessage_Function_glLightModelf = 221,
-  GLMessage_Function_glLightModelfv = 222,
-  GLMessage_Function_glLightModelx = 223,
-  GLMessage_Function_glLightModelxOES = 224,
-  GLMessage_Function_glLightModelxv = 225,
-  GLMessage_Function_glLightModelxvOES = 226,
-  GLMessage_Function_glLightx = 227,
-  GLMessage_Function_glLightxOES = 228,
-  GLMessage_Function_glLightxv = 229,
-  GLMessage_Function_glLightxvOES = 230,
-  GLMessage_Function_glLineWidth = 231,
-  GLMessage_Function_glLineWidthx = 232,
-  GLMessage_Function_glLineWidthxOES = 233,
-  GLMessage_Function_glLinkProgram = 234,
-  GLMessage_Function_glLoadIdentity = 235,
-  GLMessage_Function_glLoadMatrixf = 236,
-  GLMessage_Function_glLoadMatrixx = 237,
-  GLMessage_Function_glLoadMatrixxOES = 238,
-  GLMessage_Function_glLoadPaletteFromModelViewMatrixOES = 239,
-  GLMessage_Function_glLogicOp = 240,
-  GLMessage_Function_glMapBufferOES = 241,
-  GLMessage_Function_glMaterialf = 242,
-  GLMessage_Function_glMaterialfv = 243,
-  GLMessage_Function_glMaterialx = 244,
-  GLMessage_Function_glMaterialxOES = 245,
-  GLMessage_Function_glMaterialxv = 246,
-  GLMessage_Function_glMaterialxvOES = 247,
-  GLMessage_Function_glMatrixIndexPointerOES = 248,
-  GLMessage_Function_glMatrixMode = 249,
-  GLMessage_Function_glMultiDrawArraysEXT = 250,
-  GLMessage_Function_glMultiDrawElementsEXT = 251,
-  GLMessage_Function_glMultiTexCoord4f = 252,
-  GLMessage_Function_glMultiTexCoord4x = 253,
-  GLMessage_Function_glMultiTexCoord4xOES = 254,
-  GLMessage_Function_glMultMatrixf = 255,
-  GLMessage_Function_glMultMatrixx = 256,
-  GLMessage_Function_glMultMatrixxOES = 257,
-  GLMessage_Function_glNormal3f = 258,
-  GLMessage_Function_glNormal3x = 259,
-  GLMessage_Function_glNormal3xOES = 260,
-  GLMessage_Function_glNormalPointer = 261,
-  GLMessage_Function_glOrthof = 262,
-  GLMessage_Function_glOrthofOES = 263,
-  GLMessage_Function_glOrthox = 264,
-  GLMessage_Function_glOrthoxOES = 265,
-  GLMessage_Function_glPixelStorei = 266,
-  GLMessage_Function_glPointParameterf = 267,
-  GLMessage_Function_glPointParameterfv = 268,
-  GLMessage_Function_glPointParameterx = 269,
-  GLMessage_Function_glPointParameterxOES = 270,
-  GLMessage_Function_glPointParameterxv = 271,
-  GLMessage_Function_glPointParameterxvOES = 272,
-  GLMessage_Function_glPointSize = 273,
-  GLMessage_Function_glPointSizePointerOES = 274,
-  GLMessage_Function_glPointSizex = 275,
-  GLMessage_Function_glPointSizexOES = 276,
-  GLMessage_Function_glPolygonOffset = 277,
-  GLMessage_Function_glPolygonOffsetx = 278,
-  GLMessage_Function_glPolygonOffsetxOES = 279,
-  GLMessage_Function_glPopMatrix = 280,
-  GLMessage_Function_glProgramBinaryOES = 281,
-  GLMessage_Function_glPushMatrix = 282,
-  GLMessage_Function_glQueryMatrixxOES = 283,
-  GLMessage_Function_glReadPixels = 284,
-  GLMessage_Function_glReleaseShaderCompiler = 285,
-  GLMessage_Function_glRenderbufferStorage = 286,
-  GLMessage_Function_glRenderbufferStorageMultisampleIMG = 287,
-  GLMessage_Function_glRenderbufferStorageOES = 288,
-  GLMessage_Function_glRotatef = 289,
-  GLMessage_Function_glRotatex = 290,
-  GLMessage_Function_glRotatexOES = 291,
-  GLMessage_Function_glSampleCoverage = 292,
-  GLMessage_Function_glSampleCoveragex = 293,
-  GLMessage_Function_glSampleCoveragexOES = 294,
-  GLMessage_Function_glScalef = 295,
-  GLMessage_Function_glScalex = 296,
-  GLMessage_Function_glScalexOES = 297,
-  GLMessage_Function_glScissor = 298,
-  GLMessage_Function_glSelectPerfMonitorCountersAMD = 299,
-  GLMessage_Function_glSetFenceNV = 300,
-  GLMessage_Function_glShadeModel = 301,
-  GLMessage_Function_glShaderBinary = 302,
-  GLMessage_Function_glShaderSource = 303,
-  GLMessage_Function_glStartTilingQCOM = 304,
-  GLMessage_Function_glStencilFunc = 305,
-  GLMessage_Function_glStencilFuncSeparate = 306,
-  GLMessage_Function_glStencilMask = 307,
-  GLMessage_Function_glStencilMaskSeparate = 308,
-  GLMessage_Function_glStencilOp = 309,
-  GLMessage_Function_glStencilOpSeparate = 310,
-  GLMessage_Function_glTestFenceNV = 311,
-  GLMessage_Function_glTexCoordPointer = 312,
-  GLMessage_Function_glTexEnvf = 313,
-  GLMessage_Function_glTexEnvfv = 314,
-  GLMessage_Function_glTexEnvi = 315,
-  GLMessage_Function_glTexEnviv = 316,
-  GLMessage_Function_glTexEnvx = 317,
-  GLMessage_Function_glTexEnvxOES = 318,
-  GLMessage_Function_glTexEnvxv = 319,
-  GLMessage_Function_glTexEnvxvOES = 320,
-  GLMessage_Function_glTexGenfOES = 321,
-  GLMessage_Function_glTexGenfvOES = 322,
-  GLMessage_Function_glTexGeniOES = 323,
-  GLMessage_Function_glTexGenivOES = 324,
-  GLMessage_Function_glTexGenxOES = 325,
-  GLMessage_Function_glTexGenxvOES = 326,
-  GLMessage_Function_glTexImage2D = 327,
-  GLMessage_Function_glTexImage3DOES = 328,
-  GLMessage_Function_glTexParameterf = 329,
-  GLMessage_Function_glTexParameterfv = 330,
-  GLMessage_Function_glTexParameteri = 331,
-  GLMessage_Function_glTexParameteriv = 332,
-  GLMessage_Function_glTexParameterx = 333,
-  GLMessage_Function_glTexParameterxOES = 334,
-  GLMessage_Function_glTexParameterxv = 335,
-  GLMessage_Function_glTexParameterxvOES = 336,
-  GLMessage_Function_glTexSubImage2D = 337,
-  GLMessage_Function_glTexSubImage3DOES = 338,
-  GLMessage_Function_glTranslatef = 339,
-  GLMessage_Function_glTranslatex = 340,
-  GLMessage_Function_glTranslatexOES = 341,
-  GLMessage_Function_glUniform1f = 342,
-  GLMessage_Function_glUniform1fv = 343,
-  GLMessage_Function_glUniform1i = 344,
-  GLMessage_Function_glUniform1iv = 345,
-  GLMessage_Function_glUniform2f = 346,
-  GLMessage_Function_glUniform2fv = 347,
-  GLMessage_Function_glUniform2i = 348,
-  GLMessage_Function_glUniform2iv = 349,
-  GLMessage_Function_glUniform3f = 350,
-  GLMessage_Function_glUniform3fv = 351,
-  GLMessage_Function_glUniform3i = 352,
-  GLMessage_Function_glUniform3iv = 353,
-  GLMessage_Function_glUniform4f = 354,
-  GLMessage_Function_glUniform4fv = 355,
-  GLMessage_Function_glUniform4i = 356,
-  GLMessage_Function_glUniform4iv = 357,
-  GLMessage_Function_glUniformMatrix2fv = 358,
-  GLMessage_Function_glUniformMatrix3fv = 359,
-  GLMessage_Function_glUniformMatrix4fv = 360,
-  GLMessage_Function_glUnmapBufferOES = 361,
-  GLMessage_Function_glUseProgram = 362,
-  GLMessage_Function_glValidateProgram = 363,
-  GLMessage_Function_glVertexAttrib1f = 364,
-  GLMessage_Function_glVertexAttrib1fv = 365,
-  GLMessage_Function_glVertexAttrib2f = 366,
-  GLMessage_Function_glVertexAttrib2fv = 367,
-  GLMessage_Function_glVertexAttrib3f = 368,
-  GLMessage_Function_glVertexAttrib3fv = 369,
-  GLMessage_Function_glVertexAttrib4f = 370,
-  GLMessage_Function_glVertexAttrib4fv = 371,
-  GLMessage_Function_glVertexAttribPointer = 372,
-  GLMessage_Function_glVertexPointer = 373,
-  GLMessage_Function_glViewport = 374,
-  GLMessage_Function_glWeightPointerOES = 375,
-  GLMessage_Function_glReadBuffer = 376,
-  GLMessage_Function_glDrawRangeElements = 377,
-  GLMessage_Function_glTexImage3D = 378,
-  GLMessage_Function_glTexSubImage3D = 379,
-  GLMessage_Function_glCopyTexSubImage3D = 380,
-  GLMessage_Function_glCompressedTexImage3D = 381,
-  GLMessage_Function_glCompressedTexSubImage3D = 382,
-  GLMessage_Function_glGenQueries = 383,
-  GLMessage_Function_glDeleteQueries = 384,
-  GLMessage_Function_glIsQuery = 385,
-  GLMessage_Function_glBeginQuery = 386,
-  GLMessage_Function_glEndQuery = 387,
-  GLMessage_Function_glGetQueryiv = 388,
-  GLMessage_Function_glGetQueryObjectuiv = 389,
-  GLMessage_Function_glUnmapBuffer = 390,
-  GLMessage_Function_glGetBufferPointerv = 391,
-  GLMessage_Function_glDrawBuffers = 392,
-  GLMessage_Function_glUniformMatrix2x3fv = 393,
-  GLMessage_Function_glUniformMatrix3x2fv = 394,
-  GLMessage_Function_glUniformMatrix2x4fv = 395,
-  GLMessage_Function_glUniformMatrix4x2fv = 396,
-  GLMessage_Function_glUniformMatrix3x4fv = 397,
-  GLMessage_Function_glUniformMatrix4x3fv = 398,
-  GLMessage_Function_glBlitFramebuffer = 399,
-  GLMessage_Function_glRenderbufferStorageMultisample = 400,
-  GLMessage_Function_glFramebufferTextureLayer = 401,
-  GLMessage_Function_glMapBufferRange = 402,
-  GLMessage_Function_glFlushMappedBufferRange = 403,
-  GLMessage_Function_glBindVertexArray = 404,
-  GLMessage_Function_glDeleteVertexArrays = 405,
-  GLMessage_Function_glGenVertexArrays = 406,
-  GLMessage_Function_glIsVertexArray = 407,
-  GLMessage_Function_glGetIntegeri_v = 408,
-  GLMessage_Function_glBeginTransformFeedback = 409,
-  GLMessage_Function_glEndTransformFeedback = 410,
-  GLMessage_Function_glBindBufferRange = 411,
-  GLMessage_Function_glBindBufferBase = 412,
-  GLMessage_Function_glTransformFeedbackVaryings = 413,
-  GLMessage_Function_glGetTransformFeedbackVarying = 414,
-  GLMessage_Function_glVertexAttribIPointer = 415,
-  GLMessage_Function_glGetVertexAttribIiv = 416,
-  GLMessage_Function_glGetVertexAttribIuiv = 417,
-  GLMessage_Function_glVertexAttribI4i = 418,
-  GLMessage_Function_glVertexAttribI4ui = 419,
-  GLMessage_Function_glVertexAttribI4iv = 420,
-  GLMessage_Function_glVertexAttribI4uiv = 421,
-  GLMessage_Function_glGetUniformuiv = 422,
-  GLMessage_Function_glGetFragDataLocation = 423,
-  GLMessage_Function_glUniform1ui = 424,
-  GLMessage_Function_glUniform2ui = 425,
-  GLMessage_Function_glUniform3ui = 426,
-  GLMessage_Function_glUniform4ui = 427,
-  GLMessage_Function_glUniform1uiv = 428,
-  GLMessage_Function_glUniform2uiv = 429,
-  GLMessage_Function_glUniform3uiv = 430,
-  GLMessage_Function_glUniform4uiv = 431,
-  GLMessage_Function_glClearBufferiv = 432,
-  GLMessage_Function_glClearBufferuiv = 433,
-  GLMessage_Function_glClearBufferfv = 434,
-  GLMessage_Function_glClearBufferfi = 435,
-  GLMessage_Function_glGetStringi = 436,
-  GLMessage_Function_glCopyBufferSubData = 437,
-  GLMessage_Function_glGetUniformIndices = 438,
-  GLMessage_Function_glGetActiveUniformsiv = 439,
-  GLMessage_Function_glGetUniformBlockIndex = 440,
-  GLMessage_Function_glGetActiveUniformBlockiv = 441,
-  GLMessage_Function_glGetActiveUniformBlockName = 442,
-  GLMessage_Function_glUniformBlockBinding = 443,
-  GLMessage_Function_glDrawArraysInstanced = 444,
-  GLMessage_Function_glDrawElementsInstanced = 445,
-  GLMessage_Function_glFenceSync = 446,
-  GLMessage_Function_glIsSync = 447,
-  GLMessage_Function_glDeleteSync = 448,
-  GLMessage_Function_glClientWaitSync = 449,
-  GLMessage_Function_glWaitSync = 450,
-  GLMessage_Function_glGetInteger64v = 451,
-  GLMessage_Function_glGetSynciv = 452,
-  GLMessage_Function_glGetInteger64i_v = 453,
-  GLMessage_Function_glGetBufferParameteri64v = 454,
-  GLMessage_Function_glGenSamplers = 455,
-  GLMessage_Function_glDeleteSamplers = 456,
-  GLMessage_Function_glIsSampler = 457,
-  GLMessage_Function_glBindSampler = 458,
-  GLMessage_Function_glSamplerParameteri = 459,
-  GLMessage_Function_glSamplerParameteriv = 460,
-  GLMessage_Function_glSamplerParameterf = 461,
-  GLMessage_Function_glSamplerParameterfv = 462,
-  GLMessage_Function_glGetSamplerParameteriv = 463,
-  GLMessage_Function_glGetSamplerParameterfv = 464,
-  GLMessage_Function_glVertexAttribDivisor = 465,
-  GLMessage_Function_glBindTransformFeedback = 466,
-  GLMessage_Function_glDeleteTransformFeedbacks = 467,
-  GLMessage_Function_glGenTransformFeedbacks = 468,
-  GLMessage_Function_glIsTransformFeedback = 469,
-  GLMessage_Function_glPauseTransformFeedback = 470,
-  GLMessage_Function_glResumeTransformFeedback = 471,
-  GLMessage_Function_glGetProgramBinary = 472,
-  GLMessage_Function_glProgramBinary = 473,
-  GLMessage_Function_glProgramParameteri = 474,
-  GLMessage_Function_glInvalidateFramebuffer = 475,
-  GLMessage_Function_glInvalidateSubFramebuffer = 476,
-  GLMessage_Function_glTexStorage2D = 477,
-  GLMessage_Function_glTexStorage3D = 478,
-  GLMessage_Function_glGetInternalformativ = 479,
-  GLMessage_Function_glActiveShaderProgramEXT = 502,
-  GLMessage_Function_glAlphaFuncQCOM = 503,
-  GLMessage_Function_glBeginQueryEXT = 504,
-  GLMessage_Function_glBindProgramPipelineEXT = 505,
-  GLMessage_Function_glBlitFramebufferANGLE = 506,
-  GLMessage_Function_glCreateShaderProgramvEXT = 507,
-  GLMessage_Function_glDeleteProgramPipelinesEXT = 508,
-  GLMessage_Function_glDeleteQueriesEXT = 509,
-  GLMessage_Function_glDrawBuffersNV = 510,
-  GLMessage_Function_glEndQueryEXT = 511,
-  GLMessage_Function_glFramebufferTexture2DMultisampleEXT = 512,
-  GLMessage_Function_glGenProgramPipelinesEXT = 513,
-  GLMessage_Function_glGenQueriesEXT = 514,
-  GLMessage_Function_glGetGraphicsResetStatusEXT = 515,
-  GLMessage_Function_glGetObjectLabelEXT = 516,
-  GLMessage_Function_glGetProgramPipelineInfoLogEXT = 517,
-  GLMessage_Function_glGetProgramPipelineivEXT = 518,
-  GLMessage_Function_glGetQueryObjectuivEXT = 519,
-  GLMessage_Function_glGetQueryivEXT = 520,
-  GLMessage_Function_glGetnUniformfvEXT = 521,
-  GLMessage_Function_glGetnUniformivEXT = 521,
-  GLMessage_Function_glInsertEventMarkerEXT = 522,
-  GLMessage_Function_glIsProgramPipelineEXT = 523,
-  GLMessage_Function_glIsQueryEXT = 524,
-  GLMessage_Function_glLabelObjectEXT = 525,
-  GLMessage_Function_glPopGroupMarkerEXT = 526,
-  GLMessage_Function_glProgramParameteriEXT = 527,
-  GLMessage_Function_glProgramUniform1fEXT = 528,
-  GLMessage_Function_glProgramUniform1fvEXT = 529,
-  GLMessage_Function_glProgramUniform1iEXT = 530,
-  GLMessage_Function_glProgramUniform1ivEXT = 531,
-  GLMessage_Function_glProgramUniform2fEXT = 532,
-  GLMessage_Function_glProgramUniform2fvEXT = 533,
-  GLMessage_Function_glProgramUniform2iEXT = 534,
-  GLMessage_Function_glProgramUniform2ivEXT = 535,
-  GLMessage_Function_glProgramUniform3fEXT = 536,
-  GLMessage_Function_glProgramUniform3fvEXT = 537,
-  GLMessage_Function_glProgramUniform3iEXT = 538,
-  GLMessage_Function_glProgramUniform3ivEXT = 539,
-  GLMessage_Function_glProgramUniform4fEXT = 540,
-  GLMessage_Function_glProgramUniform4fvEXT = 541,
-  GLMessage_Function_glProgramUniform4iEXT = 542,
-  GLMessage_Function_glProgramUniform4ivEXT = 543,
-  GLMessage_Function_glProgramUniformMatrix2fvEXT = 544,
-  GLMessage_Function_glProgramUniformMatrix3fvEXT = 545,
-  GLMessage_Function_glProgramUniformMatrix4fvEXT = 546,
-  GLMessage_Function_glPushGroupMarkerEXT = 547,
-  GLMessage_Function_glReadBufferNV = 548,
-  GLMessage_Function_glReadnPixelsEXT = 549,
-  GLMessage_Function_glRenderbufferStorageMultisampleANGLE = 550,
-  GLMessage_Function_glRenderbufferStorageMultisampleAPPLE = 551,
-  GLMessage_Function_glRenderbufferStorageMultisampleEXT = 552,
-  GLMessage_Function_glResolveMultisampleFramebufferAPPLE = 553,
-  GLMessage_Function_glTexStorage1DEXT = 554,
-  GLMessage_Function_glTexStorage2DEXT = 555,
-  GLMessage_Function_glTexStorage3DEXT = 556,
-  GLMessage_Function_glTextureStorage1DEXT = 557,
-  GLMessage_Function_glTextureStorage2DEXT = 558,
-  GLMessage_Function_glTextureStorage3DEXT = 559,
-  GLMessage_Function_glUseProgramStagesEXT = 560,
-  GLMessage_Function_glValidateProgramPipelineEXT = 561,
-  GLMessage_Function_eglGetDisplay = 2000,
-  GLMessage_Function_eglInitialize = 2001,
-  GLMessage_Function_eglTerminate = 2002,
-  GLMessage_Function_eglGetConfigs = 2003,
-  GLMessage_Function_eglChooseConfig = 2004,
-  GLMessage_Function_eglGetConfigAttrib = 2005,
-  GLMessage_Function_eglCreateWindowSurface = 2006,
-  GLMessage_Function_eglCreatePixmapSurface = 2007,
-  GLMessage_Function_eglCreatePbufferSurface = 2008,
-  GLMessage_Function_eglDestroySurface = 2009,
-  GLMessage_Function_eglQuerySurface = 2010,
-  GLMessage_Function_eglCreateContext = 2011,
-  GLMessage_Function_eglDestroyContext = 2012,
-  GLMessage_Function_eglMakeCurrent = 2013,
-  GLMessage_Function_eglGetCurrentContext = 2014,
-  GLMessage_Function_eglGetCurrentSurface = 2015,
-  GLMessage_Function_eglGetCurrentDisplay = 2016,
-  GLMessage_Function_eglQueryContext = 2017,
-  GLMessage_Function_eglWaitGL = 2018,
-  GLMessage_Function_eglWaitNative = 2019,
-  GLMessage_Function_eglSwapBuffers = 2020,
-  GLMessage_Function_eglCopyBuffers = 2021,
-  GLMessage_Function_eglGetError = 2022,
-  GLMessage_Function_eglQueryString = 2023,
-  GLMessage_Function_eglGetProcAddress = 2024,
-  GLMessage_Function_eglSurfaceAttrib = 2025,
-  GLMessage_Function_eglBindTexImage = 2026,
-  GLMessage_Function_eglReleaseTexImage = 2027,
-  GLMessage_Function_eglSwapInterval = 2028,
-  GLMessage_Function_eglBindAPI = 2029,
-  GLMessage_Function_eglQueryAPI = 2030,
-  GLMessage_Function_eglWaitClient = 2031,
-  GLMessage_Function_eglReleaseThread = 2032,
-  GLMessage_Function_eglCreatePbufferFromClientBuffer = 2033,
-  GLMessage_Function_eglLockSurfaceKHR = 2034,
-  GLMessage_Function_eglUnlockSurfaceKHR = 2035,
-  GLMessage_Function_eglCreateImageKHR = 2036,
-  GLMessage_Function_eglDestroyImageKHR = 2037,
-  GLMessage_Function_eglCreateSyncKHR = 2038,
-  GLMessage_Function_eglDestroySyncKHR = 2039,
-  GLMessage_Function_eglClientWaitSyncKHR = 2040,
-  GLMessage_Function_eglGetSyncAttribKHR = 2041,
-  GLMessage_Function_eglSetSwapRectangleANDROID = 2042,
-  GLMessage_Function_eglGetRenderBufferANDROID = 2043,
-  GLMessage_Function_eglGetSystemTimeFrequencyNV = 2044,
-  GLMessage_Function_eglGetSystemTimeNV = 2045,
-  GLMessage_Function_invalid = 3000,
-  GLMessage_Function_glVertexAttribPointerData = 3001
-};
-bool GLMessage_Function_IsValid(int value);
-const GLMessage_Function GLMessage_Function_Function_MIN = GLMessage_Function_glActiveTexture;
-const GLMessage_Function GLMessage_Function_Function_MAX = GLMessage_Function_glVertexAttribPointerData;
-const int GLMessage_Function_Function_ARRAYSIZE = GLMessage_Function_Function_MAX + 1;
-
-// ===================================================================
-
-class GLMessage_DataType : public ::google::protobuf::MessageLite {
- public:
-  GLMessage_DataType();
-  virtual ~GLMessage_DataType();
-  
-  GLMessage_DataType(const GLMessage_DataType& from);
-  
-  inline GLMessage_DataType& operator=(const GLMessage_DataType& from) {
-    CopyFrom(from);
-    return *this;
-  }
-  
-  static const GLMessage_DataType& default_instance();
-  
-  void Swap(GLMessage_DataType* other);
-  
-  // implements Message ----------------------------------------------
-  
-  GLMessage_DataType* New() const;
-  void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
-  void CopyFrom(const GLMessage_DataType& from);
-  void MergeFrom(const GLMessage_DataType& from);
-  void Clear();
-  bool IsInitialized() const;
-  
-  int ByteSize() const;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input);
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const;
-  int GetCachedSize() const { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const;
-  public:
-  
-  ::std::string GetTypeName() const;
-  
-  // nested types ----------------------------------------------------
-  
-  typedef GLMessage_DataType_Type Type;
-  static const Type VOID = GLMessage_DataType_Type_VOID;
-  static const Type CHAR = GLMessage_DataType_Type_CHAR;
-  static const Type BYTE = GLMessage_DataType_Type_BYTE;
-  static const Type INT = GLMessage_DataType_Type_INT;
-  static const Type FLOAT = GLMessage_DataType_Type_FLOAT;
-  static const Type BOOL = GLMessage_DataType_Type_BOOL;
-  static const Type ENUM = GLMessage_DataType_Type_ENUM;
-  static const Type INT64 = GLMessage_DataType_Type_INT64;
-  static inline bool Type_IsValid(int value) {
-    return GLMessage_DataType_Type_IsValid(value);
-  }
-  static const Type Type_MIN =
-    GLMessage_DataType_Type_Type_MIN;
-  static const Type Type_MAX =
-    GLMessage_DataType_Type_Type_MAX;
-  static const int Type_ARRAYSIZE =
-    GLMessage_DataType_Type_Type_ARRAYSIZE;
-  
-  // accessors -------------------------------------------------------
-  
-  // required .android.gltrace.GLMessage.DataType.Type type = 1 [default = VOID];
-  inline bool has_type() const;
-  inline void clear_type();
-  static const int kTypeFieldNumber = 1;
-  inline ::android::gltrace::GLMessage_DataType_Type type() const;
-  inline void set_type(::android::gltrace::GLMessage_DataType_Type value);
-  
-  // required bool isArray = 2 [default = false];
-  inline bool has_isarray() const;
-  inline void clear_isarray();
-  static const int kIsArrayFieldNumber = 2;
-  inline bool isarray() const;
-  inline void set_isarray(bool value);
-  
-  // repeated int32 intValue = 3;
-  inline int intvalue_size() const;
-  inline void clear_intvalue();
-  static const int kIntValueFieldNumber = 3;
-  inline ::google::protobuf::int32 intvalue(int index) const;
-  inline void set_intvalue(int index, ::google::protobuf::int32 value);
-  inline void add_intvalue(::google::protobuf::int32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
-      intvalue() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
-      mutable_intvalue();
-  
-  // repeated float floatValue = 4;
-  inline int floatvalue_size() const;
-  inline void clear_floatvalue();
-  static const int kFloatValueFieldNumber = 4;
-  inline float floatvalue(int index) const;
-  inline void set_floatvalue(int index, float value);
-  inline void add_floatvalue(float value);
-  inline const ::google::protobuf::RepeatedField< float >&
-      floatvalue() const;
-  inline ::google::protobuf::RepeatedField< float >*
-      mutable_floatvalue();
-  
-  // repeated bytes charValue = 5;
-  inline int charvalue_size() const;
-  inline void clear_charvalue();
-  static const int kCharValueFieldNumber = 5;
-  inline const ::std::string& charvalue(int index) const;
-  inline ::std::string* mutable_charvalue(int index);
-  inline void set_charvalue(int index, const ::std::string& value);
-  inline void set_charvalue(int index, const char* value);
-  inline void set_charvalue(int index, const void* value, size_t size);
-  inline ::std::string* add_charvalue();
-  inline void add_charvalue(const ::std::string& value);
-  inline void add_charvalue(const char* value);
-  inline void add_charvalue(const void* value, size_t size);
-  inline const ::google::protobuf::RepeatedPtrField< ::std::string>& charvalue() const;
-  inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_charvalue();
-  
-  // repeated bytes rawBytes = 6;
-  inline int rawbytes_size() const;
-  inline void clear_rawbytes();
-  static const int kRawBytesFieldNumber = 6;
-  inline const ::std::string& rawbytes(int index) const;
-  inline ::std::string* mutable_rawbytes(int index);
-  inline void set_rawbytes(int index, const ::std::string& value);
-  inline void set_rawbytes(int index, const char* value);
-  inline void set_rawbytes(int index, const void* value, size_t size);
-  inline ::std::string* add_rawbytes();
-  inline void add_rawbytes(const ::std::string& value);
-  inline void add_rawbytes(const char* value);
-  inline void add_rawbytes(const void* value, size_t size);
-  inline const ::google::protobuf::RepeatedPtrField< ::std::string>& rawbytes() const;
-  inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_rawbytes();
-  
-  // repeated bool boolValue = 7;
-  inline int boolvalue_size() const;
-  inline void clear_boolvalue();
-  static const int kBoolValueFieldNumber = 7;
-  inline bool boolvalue(int index) const;
-  inline void set_boolvalue(int index, bool value);
-  inline void add_boolvalue(bool value);
-  inline const ::google::protobuf::RepeatedField< bool >&
-      boolvalue() const;
-  inline ::google::protobuf::RepeatedField< bool >*
-      mutable_boolvalue();
-  
-  // repeated int64 int64Value = 8;
-  inline int int64value_size() const;
-  inline void clear_int64value();
-  static const int kInt64ValueFieldNumber = 8;
-  inline ::google::protobuf::int64 int64value(int index) const;
-  inline void set_int64value(int index, ::google::protobuf::int64 value);
-  inline void add_int64value(::google::protobuf::int64 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >&
-      int64value() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
-      mutable_int64value();
-  
-  // @@protoc_insertion_point(class_scope:android.gltrace.GLMessage.DataType)
- private:
-  mutable int _cached_size_;
-  
-  int type_;
-  bool isarray_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::int32 > intvalue_;
-  ::google::protobuf::RepeatedField< float > floatvalue_;
-  ::google::protobuf::RepeatedPtrField< ::std::string> charvalue_;
-  ::google::protobuf::RepeatedPtrField< ::std::string> rawbytes_;
-  ::google::protobuf::RepeatedField< bool > boolvalue_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::int64 > int64value_;
-  friend void  protobuf_AddDesc_gltrace_2eproto();
-  friend void protobuf_AssignDesc_gltrace_2eproto();
-  friend void protobuf_ShutdownFile_gltrace_2eproto();
-  
-  ::google::protobuf::uint32 _has_bits_[(8 + 31) / 32];
-  
-  // WHY DOES & HAVE LOWER PRECEDENCE THAN != !?
-  inline bool _has_bit(int index) const {
-    return (_has_bits_[index / 32] & (1u << (index % 32))) != 0;
-  }
-  inline void _set_bit(int index) {
-    _has_bits_[index / 32] |= (1u << (index % 32));
-  }
-  inline void _clear_bit(int index) {
-    _has_bits_[index / 32] &= ~(1u << (index % 32));
-  }
-  
-  void InitAsDefaultInstance();
-  static GLMessage_DataType* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class GLMessage_FrameBuffer : public ::google::protobuf::MessageLite {
- public:
-  GLMessage_FrameBuffer();
-  virtual ~GLMessage_FrameBuffer();
-  
-  GLMessage_FrameBuffer(const GLMessage_FrameBuffer& from);
-  
-  inline GLMessage_FrameBuffer& operator=(const GLMessage_FrameBuffer& from) {
-    CopyFrom(from);
-    return *this;
-  }
-  
-  static const GLMessage_FrameBuffer& default_instance();
-  
-  void Swap(GLMessage_FrameBuffer* other);
-  
-  // implements Message ----------------------------------------------
-  
-  GLMessage_FrameBuffer* New() const;
-  void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
-  void CopyFrom(const GLMessage_FrameBuffer& from);
-  void MergeFrom(const GLMessage_FrameBuffer& from);
-  void Clear();
-  bool IsInitialized() const;
-  
-  int ByteSize() const;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input);
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const;
-  int GetCachedSize() const { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const;
-  public:
-  
-  ::std::string GetTypeName() const;
-  
-  // nested types ----------------------------------------------------
-  
-  // accessors -------------------------------------------------------
-  
-  // required int32 width = 1;
-  inline bool has_width() const;
-  inline void clear_width();
-  static const int kWidthFieldNumber = 1;
-  inline ::google::protobuf::int32 width() const;
-  inline void set_width(::google::protobuf::int32 value);
-  
-  // required int32 height = 2;
-  inline bool has_height() const;
-  inline void clear_height();
-  static const int kHeightFieldNumber = 2;
-  inline ::google::protobuf::int32 height() const;
-  inline void set_height(::google::protobuf::int32 value);
-  
-  // repeated bytes contents = 3;
-  inline int contents_size() const;
-  inline void clear_contents();
-  static const int kContentsFieldNumber = 3;
-  inline const ::std::string& contents(int index) const;
-  inline ::std::string* mutable_contents(int index);
-  inline void set_contents(int index, const ::std::string& value);
-  inline void set_contents(int index, const char* value);
-  inline void set_contents(int index, const void* value, size_t size);
-  inline ::std::string* add_contents();
-  inline void add_contents(const ::std::string& value);
-  inline void add_contents(const char* value);
-  inline void add_contents(const void* value, size_t size);
-  inline const ::google::protobuf::RepeatedPtrField< ::std::string>& contents() const;
-  inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_contents();
-  
-  // @@protoc_insertion_point(class_scope:android.gltrace.GLMessage.FrameBuffer)
- private:
-  mutable int _cached_size_;
-  
-  ::google::protobuf::int32 width_;
-  ::google::protobuf::int32 height_;
-  ::google::protobuf::RepeatedPtrField< ::std::string> contents_;
-  friend void  protobuf_AddDesc_gltrace_2eproto();
-  friend void protobuf_AssignDesc_gltrace_2eproto();
-  friend void protobuf_ShutdownFile_gltrace_2eproto();
-  
-  ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32];
-  
-  // WHY DOES & HAVE LOWER PRECEDENCE THAN != !?
-  inline bool _has_bit(int index) const {
-    return (_has_bits_[index / 32] & (1u << (index % 32))) != 0;
-  }
-  inline void _set_bit(int index) {
-    _has_bits_[index / 32] |= (1u << (index % 32));
-  }
-  inline void _clear_bit(int index) {
-    _has_bits_[index / 32] &= ~(1u << (index % 32));
-  }
-  
-  void InitAsDefaultInstance();
-  static GLMessage_FrameBuffer* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class GLMessage : public ::google::protobuf::MessageLite {
- public:
-  GLMessage();
-  virtual ~GLMessage();
-  
-  GLMessage(const GLMessage& from);
-  
-  inline GLMessage& operator=(const GLMessage& from) {
-    CopyFrom(from);
-    return *this;
-  }
-  
-  static const GLMessage& default_instance();
-  
-  void Swap(GLMessage* other);
-  
-  // implements Message ----------------------------------------------
-  
-  GLMessage* New() const;
-  void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
-  void CopyFrom(const GLMessage& from);
-  void MergeFrom(const GLMessage& from);
-  void Clear();
-  bool IsInitialized() const;
-  
-  int ByteSize() const;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input);
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const;
-  int GetCachedSize() const { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const;
-  public:
-  
-  ::std::string GetTypeName() const;
-  
-  // nested types ----------------------------------------------------
-  
-  typedef GLMessage_DataType DataType;
-  typedef GLMessage_FrameBuffer FrameBuffer;
-  
-  typedef GLMessage_Function Function;
-  static const Function glActiveTexture = GLMessage_Function_glActiveTexture;
-  static const Function glAlphaFunc = GLMessage_Function_glAlphaFunc;
-  static const Function glAlphaFuncx = GLMessage_Function_glAlphaFuncx;
-  static const Function glAlphaFuncxOES = GLMessage_Function_glAlphaFuncxOES;
-  static const Function glAttachShader = GLMessage_Function_glAttachShader;
-  static const Function glBeginPerfMonitorAMD = GLMessage_Function_glBeginPerfMonitorAMD;
-  static const Function glBindAttribLocation = GLMessage_Function_glBindAttribLocation;
-  static const Function glBindBuffer = GLMessage_Function_glBindBuffer;
-  static const Function glBindFramebuffer = GLMessage_Function_glBindFramebuffer;
-  static const Function glBindFramebufferOES = GLMessage_Function_glBindFramebufferOES;
-  static const Function glBindRenderbuffer = GLMessage_Function_glBindRenderbuffer;
-  static const Function glBindRenderbufferOES = GLMessage_Function_glBindRenderbufferOES;
-  static const Function glBindTexture = GLMessage_Function_glBindTexture;
-  static const Function glBindVertexArrayOES = GLMessage_Function_glBindVertexArrayOES;
-  static const Function glBlendColor = GLMessage_Function_glBlendColor;
-  static const Function glBlendEquation = GLMessage_Function_glBlendEquation;
-  static const Function glBlendEquationOES = GLMessage_Function_glBlendEquationOES;
-  static const Function glBlendEquationSeparate = GLMessage_Function_glBlendEquationSeparate;
-  static const Function glBlendEquationSeparateOES = GLMessage_Function_glBlendEquationSeparateOES;
-  static const Function glBlendFunc = GLMessage_Function_glBlendFunc;
-  static const Function glBlendFuncSeparate = GLMessage_Function_glBlendFuncSeparate;
-  static const Function glBlendFuncSeparateOES = GLMessage_Function_glBlendFuncSeparateOES;
-  static const Function glBufferData = GLMessage_Function_glBufferData;
-  static const Function glBufferSubData = GLMessage_Function_glBufferSubData;
-  static const Function glCheckFramebufferStatus = GLMessage_Function_glCheckFramebufferStatus;
-  static const Function glCheckFramebufferStatusOES = GLMessage_Function_glCheckFramebufferStatusOES;
-  static const Function glClearColor = GLMessage_Function_glClearColor;
-  static const Function glClearColorx = GLMessage_Function_glClearColorx;
-  static const Function glClearColorxOES = GLMessage_Function_glClearColorxOES;
-  static const Function glClearDepthf = GLMessage_Function_glClearDepthf;
-  static const Function glClearDepthfOES = GLMessage_Function_glClearDepthfOES;
-  static const Function glClearDepthx = GLMessage_Function_glClearDepthx;
-  static const Function glClearDepthxOES = GLMessage_Function_glClearDepthxOES;
-  static const Function glClear = GLMessage_Function_glClear;
-  static const Function glClearStencil = GLMessage_Function_glClearStencil;
-  static const Function glClientActiveTexture = GLMessage_Function_glClientActiveTexture;
-  static const Function glClipPlanef = GLMessage_Function_glClipPlanef;
-  static const Function glClipPlanefIMG = GLMessage_Function_glClipPlanefIMG;
-  static const Function glClipPlanefOES = GLMessage_Function_glClipPlanefOES;
-  static const Function glClipPlanex = GLMessage_Function_glClipPlanex;
-  static const Function glClipPlanexIMG = GLMessage_Function_glClipPlanexIMG;
-  static const Function glClipPlanexOES = GLMessage_Function_glClipPlanexOES;
-  static const Function glColor4f = GLMessage_Function_glColor4f;
-  static const Function glColor4ub = GLMessage_Function_glColor4ub;
-  static const Function glColor4x = GLMessage_Function_glColor4x;
-  static const Function glColor4xOES = GLMessage_Function_glColor4xOES;
-  static const Function glColorMask = GLMessage_Function_glColorMask;
-  static const Function glColorPointer = GLMessage_Function_glColorPointer;
-  static const Function glCompileShader = GLMessage_Function_glCompileShader;
-  static const Function glCompressedTexImage2D = GLMessage_Function_glCompressedTexImage2D;
-  static const Function glCompressedTexImage3DOES = GLMessage_Function_glCompressedTexImage3DOES;
-  static const Function glCompressedTexSubImage2D = GLMessage_Function_glCompressedTexSubImage2D;
-  static const Function glCompressedTexSubImage3DOES = GLMessage_Function_glCompressedTexSubImage3DOES;
-  static const Function glCopyTexImage2D = GLMessage_Function_glCopyTexImage2D;
-  static const Function glCopyTexSubImage2D = GLMessage_Function_glCopyTexSubImage2D;
-  static const Function glCopyTexSubImage3DOES = GLMessage_Function_glCopyTexSubImage3DOES;
-  static const Function glCoverageMaskNV = GLMessage_Function_glCoverageMaskNV;
-  static const Function glCoverageOperationNV = GLMessage_Function_glCoverageOperationNV;
-  static const Function glCreateProgram = GLMessage_Function_glCreateProgram;
-  static const Function glCreateShader = GLMessage_Function_glCreateShader;
-  static const Function glCullFace = GLMessage_Function_glCullFace;
-  static const Function glCurrentPaletteMatrixOES = GLMessage_Function_glCurrentPaletteMatrixOES;
-  static const Function glDeleteBuffers = GLMessage_Function_glDeleteBuffers;
-  static const Function glDeleteFencesNV = GLMessage_Function_glDeleteFencesNV;
-  static const Function glDeleteFramebuffers = GLMessage_Function_glDeleteFramebuffers;
-  static const Function glDeleteFramebuffersOES = GLMessage_Function_glDeleteFramebuffersOES;
-  static const Function glDeletePerfMonitorsAMD = GLMessage_Function_glDeletePerfMonitorsAMD;
-  static const Function glDeleteProgram = GLMessage_Function_glDeleteProgram;
-  static const Function glDeleteRenderbuffers = GLMessage_Function_glDeleteRenderbuffers;
-  static const Function glDeleteRenderbuffersOES = GLMessage_Function_glDeleteRenderbuffersOES;
-  static const Function glDeleteShader = GLMessage_Function_glDeleteShader;
-  static const Function glDeleteTextures = GLMessage_Function_glDeleteTextures;
-  static const Function glDeleteVertexArraysOES = GLMessage_Function_glDeleteVertexArraysOES;
-  static const Function glDepthFunc = GLMessage_Function_glDepthFunc;
-  static const Function glDepthMask = GLMessage_Function_glDepthMask;
-  static const Function glDepthRangef = GLMessage_Function_glDepthRangef;
-  static const Function glDepthRangefOES = GLMessage_Function_glDepthRangefOES;
-  static const Function glDepthRangex = GLMessage_Function_glDepthRangex;
-  static const Function glDepthRangexOES = GLMessage_Function_glDepthRangexOES;
-  static const Function glDetachShader = GLMessage_Function_glDetachShader;
-  static const Function glDisableClientState = GLMessage_Function_glDisableClientState;
-  static const Function glDisableDriverControlQCOM = GLMessage_Function_glDisableDriverControlQCOM;
-  static const Function glDisable = GLMessage_Function_glDisable;
-  static const Function glDisableVertexAttribArray = GLMessage_Function_glDisableVertexAttribArray;
-  static const Function glDiscardFramebufferEXT = GLMessage_Function_glDiscardFramebufferEXT;
-  static const Function glDrawArrays = GLMessage_Function_glDrawArrays;
-  static const Function glDrawElements = GLMessage_Function_glDrawElements;
-  static const Function glDrawTexfOES = GLMessage_Function_glDrawTexfOES;
-  static const Function glDrawTexfvOES = GLMessage_Function_glDrawTexfvOES;
-  static const Function glDrawTexiOES = GLMessage_Function_glDrawTexiOES;
-  static const Function glDrawTexivOES = GLMessage_Function_glDrawTexivOES;
-  static const Function glDrawTexsOES = GLMessage_Function_glDrawTexsOES;
-  static const Function glDrawTexsvOES = GLMessage_Function_glDrawTexsvOES;
-  static const Function glDrawTexxOES = GLMessage_Function_glDrawTexxOES;
-  static const Function glDrawTexxvOES = GLMessage_Function_glDrawTexxvOES;
-  static const Function glEGLImageTargetRenderbufferStorageOES = GLMessage_Function_glEGLImageTargetRenderbufferStorageOES;
-  static const Function glEGLImageTargetTexture2DOES = GLMessage_Function_glEGLImageTargetTexture2DOES;
-  static const Function glEnableClientState = GLMessage_Function_glEnableClientState;
-  static const Function glEnableDriverControlQCOM = GLMessage_Function_glEnableDriverControlQCOM;
-  static const Function glEnable = GLMessage_Function_glEnable;
-  static const Function glEnableVertexAttribArray = GLMessage_Function_glEnableVertexAttribArray;
-  static const Function glEndPerfMonitorAMD = GLMessage_Function_glEndPerfMonitorAMD;
-  static const Function glEndTilingQCOM = GLMessage_Function_glEndTilingQCOM;
-  static const Function glExtGetBufferPointervQCOM = GLMessage_Function_glExtGetBufferPointervQCOM;
-  static const Function glExtGetBuffersQCOM = GLMessage_Function_glExtGetBuffersQCOM;
-  static const Function glExtGetFramebuffersQCOM = GLMessage_Function_glExtGetFramebuffersQCOM;
-  static const Function glExtGetProgramBinarySourceQCOM = GLMessage_Function_glExtGetProgramBinarySourceQCOM;
-  static const Function glExtGetProgramsQCOM = GLMessage_Function_glExtGetProgramsQCOM;
-  static const Function glExtGetRenderbuffersQCOM = GLMessage_Function_glExtGetRenderbuffersQCOM;
-  static const Function glExtGetShadersQCOM = GLMessage_Function_glExtGetShadersQCOM;
-  static const Function glExtGetTexLevelParameterivQCOM = GLMessage_Function_glExtGetTexLevelParameterivQCOM;
-  static const Function glExtGetTexSubImageQCOM = GLMessage_Function_glExtGetTexSubImageQCOM;
-  static const Function glExtGetTexturesQCOM = GLMessage_Function_glExtGetTexturesQCOM;
-  static const Function glExtIsProgramBinaryQCOM = GLMessage_Function_glExtIsProgramBinaryQCOM;
-  static const Function glExtTexObjectStateOverrideiQCOM = GLMessage_Function_glExtTexObjectStateOverrideiQCOM;
-  static const Function glFinishFenceNV = GLMessage_Function_glFinishFenceNV;
-  static const Function glFinish = GLMessage_Function_glFinish;
-  static const Function glFlush = GLMessage_Function_glFlush;
-  static const Function glFogf = GLMessage_Function_glFogf;
-  static const Function glFogfv = GLMessage_Function_glFogfv;
-  static const Function glFogx = GLMessage_Function_glFogx;
-  static const Function glFogxOES = GLMessage_Function_glFogxOES;
-  static const Function glFogxv = GLMessage_Function_glFogxv;
-  static const Function glFogxvOES = GLMessage_Function_glFogxvOES;
-  static const Function glFramebufferRenderbuffer = GLMessage_Function_glFramebufferRenderbuffer;
-  static const Function glFramebufferRenderbufferOES = GLMessage_Function_glFramebufferRenderbufferOES;
-  static const Function glFramebufferTexture2D = GLMessage_Function_glFramebufferTexture2D;
-  static const Function glFramebufferTexture2DMultisampleIMG = GLMessage_Function_glFramebufferTexture2DMultisampleIMG;
-  static const Function glFramebufferTexture2DOES = GLMessage_Function_glFramebufferTexture2DOES;
-  static const Function glFramebufferTexture3DOES = GLMessage_Function_glFramebufferTexture3DOES;
-  static const Function glFrontFace = GLMessage_Function_glFrontFace;
-  static const Function glFrustumf = GLMessage_Function_glFrustumf;
-  static const Function glFrustumfOES = GLMessage_Function_glFrustumfOES;
-  static const Function glFrustumx = GLMessage_Function_glFrustumx;
-  static const Function glFrustumxOES = GLMessage_Function_glFrustumxOES;
-  static const Function glGenBuffers = GLMessage_Function_glGenBuffers;
-  static const Function glGenerateMipmap = GLMessage_Function_glGenerateMipmap;
-  static const Function glGenerateMipmapOES = GLMessage_Function_glGenerateMipmapOES;
-  static const Function glGenFencesNV = GLMessage_Function_glGenFencesNV;
-  static const Function glGenFramebuffers = GLMessage_Function_glGenFramebuffers;
-  static const Function glGenFramebuffersOES = GLMessage_Function_glGenFramebuffersOES;
-  static const Function glGenPerfMonitorsAMD = GLMessage_Function_glGenPerfMonitorsAMD;
-  static const Function glGenRenderbuffers = GLMessage_Function_glGenRenderbuffers;
-  static const Function glGenRenderbuffersOES = GLMessage_Function_glGenRenderbuffersOES;
-  static const Function glGenTextures = GLMessage_Function_glGenTextures;
-  static const Function glGenVertexArraysOES = GLMessage_Function_glGenVertexArraysOES;
-  static const Function glGetActiveAttrib = GLMessage_Function_glGetActiveAttrib;
-  static const Function glGetActiveUniform = GLMessage_Function_glGetActiveUniform;
-  static const Function glGetAttachedShaders = GLMessage_Function_glGetAttachedShaders;
-  static const Function glGetAttribLocation = GLMessage_Function_glGetAttribLocation;
-  static const Function glGetBooleanv = GLMessage_Function_glGetBooleanv;
-  static const Function glGetBufferParameteriv = GLMessage_Function_glGetBufferParameteriv;
-  static const Function glGetBufferPointervOES = GLMessage_Function_glGetBufferPointervOES;
-  static const Function glGetClipPlanef = GLMessage_Function_glGetClipPlanef;
-  static const Function glGetClipPlanefOES = GLMessage_Function_glGetClipPlanefOES;
-  static const Function glGetClipPlanex = GLMessage_Function_glGetClipPlanex;
-  static const Function glGetClipPlanexOES = GLMessage_Function_glGetClipPlanexOES;
-  static const Function glGetDriverControlsQCOM = GLMessage_Function_glGetDriverControlsQCOM;
-  static const Function glGetDriverControlStringQCOM = GLMessage_Function_glGetDriverControlStringQCOM;
-  static const Function glGetError = GLMessage_Function_glGetError;
-  static const Function glGetFenceivNV = GLMessage_Function_glGetFenceivNV;
-  static const Function glGetFixedv = GLMessage_Function_glGetFixedv;
-  static const Function glGetFixedvOES = GLMessage_Function_glGetFixedvOES;
-  static const Function glGetFloatv = GLMessage_Function_glGetFloatv;
-  static const Function glGetFramebufferAttachmentParameteriv = GLMessage_Function_glGetFramebufferAttachmentParameteriv;
-  static const Function glGetFramebufferAttachmentParameterivOES = GLMessage_Function_glGetFramebufferAttachmentParameterivOES;
-  static const Function glGetIntegerv = GLMessage_Function_glGetIntegerv;
-  static const Function glGetLightfv = GLMessage_Function_glGetLightfv;
-  static const Function glGetLightxv = GLMessage_Function_glGetLightxv;
-  static const Function glGetLightxvOES = GLMessage_Function_glGetLightxvOES;
-  static const Function glGetMaterialfv = GLMessage_Function_glGetMaterialfv;
-  static const Function glGetMaterialxv = GLMessage_Function_glGetMaterialxv;
-  static const Function glGetMaterialxvOES = GLMessage_Function_glGetMaterialxvOES;
-  static const Function glGetPerfMonitorCounterDataAMD = GLMessage_Function_glGetPerfMonitorCounterDataAMD;
-  static const Function glGetPerfMonitorCounterInfoAMD = GLMessage_Function_glGetPerfMonitorCounterInfoAMD;
-  static const Function glGetPerfMonitorCountersAMD = GLMessage_Function_glGetPerfMonitorCountersAMD;
-  static const Function glGetPerfMonitorCounterStringAMD = GLMessage_Function_glGetPerfMonitorCounterStringAMD;
-  static const Function glGetPerfMonitorGroupsAMD = GLMessage_Function_glGetPerfMonitorGroupsAMD;
-  static const Function glGetPerfMonitorGroupStringAMD = GLMessage_Function_glGetPerfMonitorGroupStringAMD;
-  static const Function glGetPointerv = GLMessage_Function_glGetPointerv;
-  static const Function glGetProgramBinaryOES = GLMessage_Function_glGetProgramBinaryOES;
-  static const Function glGetProgramInfoLog = GLMessage_Function_glGetProgramInfoLog;
-  static const Function glGetProgramiv = GLMessage_Function_glGetProgramiv;
-  static const Function glGetRenderbufferParameteriv = GLMessage_Function_glGetRenderbufferParameteriv;
-  static const Function glGetRenderbufferParameterivOES = GLMessage_Function_glGetRenderbufferParameterivOES;
-  static const Function glGetShaderInfoLog = GLMessage_Function_glGetShaderInfoLog;
-  static const Function glGetShaderiv = GLMessage_Function_glGetShaderiv;
-  static const Function glGetShaderPrecisionFormat = GLMessage_Function_glGetShaderPrecisionFormat;
-  static const Function glGetShaderSource = GLMessage_Function_glGetShaderSource;
-  static const Function glGetString = GLMessage_Function_glGetString;
-  static const Function glGetTexEnvfv = GLMessage_Function_glGetTexEnvfv;
-  static const Function glGetTexEnviv = GLMessage_Function_glGetTexEnviv;
-  static const Function glGetTexEnvxv = GLMessage_Function_glGetTexEnvxv;
-  static const Function glGetTexEnvxvOES = GLMessage_Function_glGetTexEnvxvOES;
-  static const Function glGetTexGenfvOES = GLMessage_Function_glGetTexGenfvOES;
-  static const Function glGetTexGenivOES = GLMessage_Function_glGetTexGenivOES;
-  static const Function glGetTexGenxvOES = GLMessage_Function_glGetTexGenxvOES;
-  static const Function glGetTexParameterfv = GLMessage_Function_glGetTexParameterfv;
-  static const Function glGetTexParameteriv = GLMessage_Function_glGetTexParameteriv;
-  static const Function glGetTexParameterxv = GLMessage_Function_glGetTexParameterxv;
-  static const Function glGetTexParameterxvOES = GLMessage_Function_glGetTexParameterxvOES;
-  static const Function glGetUniformfv = GLMessage_Function_glGetUniformfv;
-  static const Function glGetUniformiv = GLMessage_Function_glGetUniformiv;
-  static const Function glGetUniformLocation = GLMessage_Function_glGetUniformLocation;
-  static const Function glGetVertexAttribfv = GLMessage_Function_glGetVertexAttribfv;
-  static const Function glGetVertexAttribiv = GLMessage_Function_glGetVertexAttribiv;
-  static const Function glGetVertexAttribPointerv = GLMessage_Function_glGetVertexAttribPointerv;
-  static const Function glHint = GLMessage_Function_glHint;
-  static const Function glIsBuffer = GLMessage_Function_glIsBuffer;
-  static const Function glIsEnabled = GLMessage_Function_glIsEnabled;
-  static const Function glIsFenceNV = GLMessage_Function_glIsFenceNV;
-  static const Function glIsFramebuffer = GLMessage_Function_glIsFramebuffer;
-  static const Function glIsFramebufferOES = GLMessage_Function_glIsFramebufferOES;
-  static const Function glIsProgram = GLMessage_Function_glIsProgram;
-  static const Function glIsRenderbuffer = GLMessage_Function_glIsRenderbuffer;
-  static const Function glIsRenderbufferOES = GLMessage_Function_glIsRenderbufferOES;
-  static const Function glIsShader = GLMessage_Function_glIsShader;
-  static const Function glIsTexture = GLMessage_Function_glIsTexture;
-  static const Function glIsVertexArrayOES = GLMessage_Function_glIsVertexArrayOES;
-  static const Function glLightf = GLMessage_Function_glLightf;
-  static const Function glLightfv = GLMessage_Function_glLightfv;
-  static const Function glLightModelf = GLMessage_Function_glLightModelf;
-  static const Function glLightModelfv = GLMessage_Function_glLightModelfv;
-  static const Function glLightModelx = GLMessage_Function_glLightModelx;
-  static const Function glLightModelxOES = GLMessage_Function_glLightModelxOES;
-  static const Function glLightModelxv = GLMessage_Function_glLightModelxv;
-  static const Function glLightModelxvOES = GLMessage_Function_glLightModelxvOES;
-  static const Function glLightx = GLMessage_Function_glLightx;
-  static const Function glLightxOES = GLMessage_Function_glLightxOES;
-  static const Function glLightxv = GLMessage_Function_glLightxv;
-  static const Function glLightxvOES = GLMessage_Function_glLightxvOES;
-  static const Function glLineWidth = GLMessage_Function_glLineWidth;
-  static const Function glLineWidthx = GLMessage_Function_glLineWidthx;
-  static const Function glLineWidthxOES = GLMessage_Function_glLineWidthxOES;
-  static const Function glLinkProgram = GLMessage_Function_glLinkProgram;
-  static const Function glLoadIdentity = GLMessage_Function_glLoadIdentity;
-  static const Function glLoadMatrixf = GLMessage_Function_glLoadMatrixf;
-  static const Function glLoadMatrixx = GLMessage_Function_glLoadMatrixx;
-  static const Function glLoadMatrixxOES = GLMessage_Function_glLoadMatrixxOES;
-  static const Function glLoadPaletteFromModelViewMatrixOES = GLMessage_Function_glLoadPaletteFromModelViewMatrixOES;
-  static const Function glLogicOp = GLMessage_Function_glLogicOp;
-  static const Function glMapBufferOES = GLMessage_Function_glMapBufferOES;
-  static const Function glMaterialf = GLMessage_Function_glMaterialf;
-  static const Function glMaterialfv = GLMessage_Function_glMaterialfv;
-  static const Function glMaterialx = GLMessage_Function_glMaterialx;
-  static const Function glMaterialxOES = GLMessage_Function_glMaterialxOES;
-  static const Function glMaterialxv = GLMessage_Function_glMaterialxv;
-  static const Function glMaterialxvOES = GLMessage_Function_glMaterialxvOES;
-  static const Function glMatrixIndexPointerOES = GLMessage_Function_glMatrixIndexPointerOES;
-  static const Function glMatrixMode = GLMessage_Function_glMatrixMode;
-  static const Function glMultiDrawArraysEXT = GLMessage_Function_glMultiDrawArraysEXT;
-  static const Function glMultiDrawElementsEXT = GLMessage_Function_glMultiDrawElementsEXT;
-  static const Function glMultiTexCoord4f = GLMessage_Function_glMultiTexCoord4f;
-  static const Function glMultiTexCoord4x = GLMessage_Function_glMultiTexCoord4x;
-  static const Function glMultiTexCoord4xOES = GLMessage_Function_glMultiTexCoord4xOES;
-  static const Function glMultMatrixf = GLMessage_Function_glMultMatrixf;
-  static const Function glMultMatrixx = GLMessage_Function_glMultMatrixx;
-  static const Function glMultMatrixxOES = GLMessage_Function_glMultMatrixxOES;
-  static const Function glNormal3f = GLMessage_Function_glNormal3f;
-  static const Function glNormal3x = GLMessage_Function_glNormal3x;
-  static const Function glNormal3xOES = GLMessage_Function_glNormal3xOES;
-  static const Function glNormalPointer = GLMessage_Function_glNormalPointer;
-  static const Function glOrthof = GLMessage_Function_glOrthof;
-  static const Function glOrthofOES = GLMessage_Function_glOrthofOES;
-  static const Function glOrthox = GLMessage_Function_glOrthox;
-  static const Function glOrthoxOES = GLMessage_Function_glOrthoxOES;
-  static const Function glPixelStorei = GLMessage_Function_glPixelStorei;
-  static const Function glPointParameterf = GLMessage_Function_glPointParameterf;
-  static const Function glPointParameterfv = GLMessage_Function_glPointParameterfv;
-  static const Function glPointParameterx = GLMessage_Function_glPointParameterx;
-  static const Function glPointParameterxOES = GLMessage_Function_glPointParameterxOES;
-  static const Function glPointParameterxv = GLMessage_Function_glPointParameterxv;
-  static const Function glPointParameterxvOES = GLMessage_Function_glPointParameterxvOES;
-  static const Function glPointSize = GLMessage_Function_glPointSize;
-  static const Function glPointSizePointerOES = GLMessage_Function_glPointSizePointerOES;
-  static const Function glPointSizex = GLMessage_Function_glPointSizex;
-  static const Function glPointSizexOES = GLMessage_Function_glPointSizexOES;
-  static const Function glPolygonOffset = GLMessage_Function_glPolygonOffset;
-  static const Function glPolygonOffsetx = GLMessage_Function_glPolygonOffsetx;
-  static const Function glPolygonOffsetxOES = GLMessage_Function_glPolygonOffsetxOES;
-  static const Function glPopMatrix = GLMessage_Function_glPopMatrix;
-  static const Function glProgramBinaryOES = GLMessage_Function_glProgramBinaryOES;
-  static const Function glPushMatrix = GLMessage_Function_glPushMatrix;
-  static const Function glQueryMatrixxOES = GLMessage_Function_glQueryMatrixxOES;
-  static const Function glReadPixels = GLMessage_Function_glReadPixels;
-  static const Function glReleaseShaderCompiler = GLMessage_Function_glReleaseShaderCompiler;
-  static const Function glRenderbufferStorage = GLMessage_Function_glRenderbufferStorage;
-  static const Function glRenderbufferStorageMultisampleIMG = GLMessage_Function_glRenderbufferStorageMultisampleIMG;
-  static const Function glRenderbufferStorageOES = GLMessage_Function_glRenderbufferStorageOES;
-  static const Function glRotatef = GLMessage_Function_glRotatef;
-  static const Function glRotatex = GLMessage_Function_glRotatex;
-  static const Function glRotatexOES = GLMessage_Function_glRotatexOES;
-  static const Function glSampleCoverage = GLMessage_Function_glSampleCoverage;
-  static const Function glSampleCoveragex = GLMessage_Function_glSampleCoveragex;
-  static const Function glSampleCoveragexOES = GLMessage_Function_glSampleCoveragexOES;
-  static const Function glScalef = GLMessage_Function_glScalef;
-  static const Function glScalex = GLMessage_Function_glScalex;
-  static const Function glScalexOES = GLMessage_Function_glScalexOES;
-  static const Function glScissor = GLMessage_Function_glScissor;
-  static const Function glSelectPerfMonitorCountersAMD = GLMessage_Function_glSelectPerfMonitorCountersAMD;
-  static const Function glSetFenceNV = GLMessage_Function_glSetFenceNV;
-  static const Function glShadeModel = GLMessage_Function_glShadeModel;
-  static const Function glShaderBinary = GLMessage_Function_glShaderBinary;
-  static const Function glShaderSource = GLMessage_Function_glShaderSource;
-  static const Function glStartTilingQCOM = GLMessage_Function_glStartTilingQCOM;
-  static const Function glStencilFunc = GLMessage_Function_glStencilFunc;
-  static const Function glStencilFuncSeparate = GLMessage_Function_glStencilFuncSeparate;
-  static const Function glStencilMask = GLMessage_Function_glStencilMask;
-  static const Function glStencilMaskSeparate = GLMessage_Function_glStencilMaskSeparate;
-  static const Function glStencilOp = GLMessage_Function_glStencilOp;
-  static const Function glStencilOpSeparate = GLMessage_Function_glStencilOpSeparate;
-  static const Function glTestFenceNV = GLMessage_Function_glTestFenceNV;
-  static const Function glTexCoordPointer = GLMessage_Function_glTexCoordPointer;
-  static const Function glTexEnvf = GLMessage_Function_glTexEnvf;
-  static const Function glTexEnvfv = GLMessage_Function_glTexEnvfv;
-  static const Function glTexEnvi = GLMessage_Function_glTexEnvi;
-  static const Function glTexEnviv = GLMessage_Function_glTexEnviv;
-  static const Function glTexEnvx = GLMessage_Function_glTexEnvx;
-  static const Function glTexEnvxOES = GLMessage_Function_glTexEnvxOES;
-  static const Function glTexEnvxv = GLMessage_Function_glTexEnvxv;
-  static const Function glTexEnvxvOES = GLMessage_Function_glTexEnvxvOES;
-  static const Function glTexGenfOES = GLMessage_Function_glTexGenfOES;
-  static const Function glTexGenfvOES = GLMessage_Function_glTexGenfvOES;
-  static const Function glTexGeniOES = GLMessage_Function_glTexGeniOES;
-  static const Function glTexGenivOES = GLMessage_Function_glTexGenivOES;
-  static const Function glTexGenxOES = GLMessage_Function_glTexGenxOES;
-  static const Function glTexGenxvOES = GLMessage_Function_glTexGenxvOES;
-  static const Function glTexImage2D = GLMessage_Function_glTexImage2D;
-  static const Function glTexImage3DOES = GLMessage_Function_glTexImage3DOES;
-  static const Function glTexParameterf = GLMessage_Function_glTexParameterf;
-  static const Function glTexParameterfv = GLMessage_Function_glTexParameterfv;
-  static const Function glTexParameteri = GLMessage_Function_glTexParameteri;
-  static const Function glTexParameteriv = GLMessage_Function_glTexParameteriv;
-  static const Function glTexParameterx = GLMessage_Function_glTexParameterx;
-  static const Function glTexParameterxOES = GLMessage_Function_glTexParameterxOES;
-  static const Function glTexParameterxv = GLMessage_Function_glTexParameterxv;
-  static const Function glTexParameterxvOES = GLMessage_Function_glTexParameterxvOES;
-  static const Function glTexSubImage2D = GLMessage_Function_glTexSubImage2D;
-  static const Function glTexSubImage3DOES = GLMessage_Function_glTexSubImage3DOES;
-  static const Function glTranslatef = GLMessage_Function_glTranslatef;
-  static const Function glTranslatex = GLMessage_Function_glTranslatex;
-  static const Function glTranslatexOES = GLMessage_Function_glTranslatexOES;
-  static const Function glUniform1f = GLMessage_Function_glUniform1f;
-  static const Function glUniform1fv = GLMessage_Function_glUniform1fv;
-  static const Function glUniform1i = GLMessage_Function_glUniform1i;
-  static const Function glUniform1iv = GLMessage_Function_glUniform1iv;
-  static const Function glUniform2f = GLMessage_Function_glUniform2f;
-  static const Function glUniform2fv = GLMessage_Function_glUniform2fv;
-  static const Function glUniform2i = GLMessage_Function_glUniform2i;
-  static const Function glUniform2iv = GLMessage_Function_glUniform2iv;
-  static const Function glUniform3f = GLMessage_Function_glUniform3f;
-  static const Function glUniform3fv = GLMessage_Function_glUniform3fv;
-  static const Function glUniform3i = GLMessage_Function_glUniform3i;
-  static const Function glUniform3iv = GLMessage_Function_glUniform3iv;
-  static const Function glUniform4f = GLMessage_Function_glUniform4f;
-  static const Function glUniform4fv = GLMessage_Function_glUniform4fv;
-  static const Function glUniform4i = GLMessage_Function_glUniform4i;
-  static const Function glUniform4iv = GLMessage_Function_glUniform4iv;
-  static const Function glUniformMatrix2fv = GLMessage_Function_glUniformMatrix2fv;
-  static const Function glUniformMatrix3fv = GLMessage_Function_glUniformMatrix3fv;
-  static const Function glUniformMatrix4fv = GLMessage_Function_glUniformMatrix4fv;
-  static const Function glUnmapBufferOES = GLMessage_Function_glUnmapBufferOES;
-  static const Function glUseProgram = GLMessage_Function_glUseProgram;
-  static const Function glValidateProgram = GLMessage_Function_glValidateProgram;
-  static const Function glVertexAttrib1f = GLMessage_Function_glVertexAttrib1f;
-  static const Function glVertexAttrib1fv = GLMessage_Function_glVertexAttrib1fv;
-  static const Function glVertexAttrib2f = GLMessage_Function_glVertexAttrib2f;
-  static const Function glVertexAttrib2fv = GLMessage_Function_glVertexAttrib2fv;
-  static const Function glVertexAttrib3f = GLMessage_Function_glVertexAttrib3f;
-  static const Function glVertexAttrib3fv = GLMessage_Function_glVertexAttrib3fv;
-  static const Function glVertexAttrib4f = GLMessage_Function_glVertexAttrib4f;
-  static const Function glVertexAttrib4fv = GLMessage_Function_glVertexAttrib4fv;
-  static const Function glVertexAttribPointer = GLMessage_Function_glVertexAttribPointer;
-  static const Function glVertexPointer = GLMessage_Function_glVertexPointer;
-  static const Function glViewport = GLMessage_Function_glViewport;
-  static const Function glWeightPointerOES = GLMessage_Function_glWeightPointerOES;
-  static const Function glReadBuffer = GLMessage_Function_glReadBuffer;
-  static const Function glDrawRangeElements = GLMessage_Function_glDrawRangeElements;
-  static const Function glTexImage3D = GLMessage_Function_glTexImage3D;
-  static const Function glTexSubImage3D = GLMessage_Function_glTexSubImage3D;
-  static const Function glCopyTexSubImage3D = GLMessage_Function_glCopyTexSubImage3D;
-  static const Function glCompressedTexImage3D = GLMessage_Function_glCompressedTexImage3D;
-  static const Function glCompressedTexSubImage3D = GLMessage_Function_glCompressedTexSubImage3D;
-  static const Function glGenQueries = GLMessage_Function_glGenQueries;
-  static const Function glDeleteQueries = GLMessage_Function_glDeleteQueries;
-  static const Function glIsQuery = GLMessage_Function_glIsQuery;
-  static const Function glBeginQuery = GLMessage_Function_glBeginQuery;
-  static const Function glEndQuery = GLMessage_Function_glEndQuery;
-  static const Function glGetQueryiv = GLMessage_Function_glGetQueryiv;
-  static const Function glGetQueryObjectuiv = GLMessage_Function_glGetQueryObjectuiv;
-  static const Function glUnmapBuffer = GLMessage_Function_glUnmapBuffer;
-  static const Function glGetBufferPointerv = GLMessage_Function_glGetBufferPointerv;
-  static const Function glDrawBuffers = GLMessage_Function_glDrawBuffers;
-  static const Function glUniformMatrix2x3fv = GLMessage_Function_glUniformMatrix2x3fv;
-  static const Function glUniformMatrix3x2fv = GLMessage_Function_glUniformMatrix3x2fv;
-  static const Function glUniformMatrix2x4fv = GLMessage_Function_glUniformMatrix2x4fv;
-  static const Function glUniformMatrix4x2fv = GLMessage_Function_glUniformMatrix4x2fv;
-  static const Function glUniformMatrix3x4fv = GLMessage_Function_glUniformMatrix3x4fv;
-  static const Function glUniformMatrix4x3fv = GLMessage_Function_glUniformMatrix4x3fv;
-  static const Function glBlitFramebuffer = GLMessage_Function_glBlitFramebuffer;
-  static const Function glRenderbufferStorageMultisample = GLMessage_Function_glRenderbufferStorageMultisample;
-  static const Function glFramebufferTextureLayer = GLMessage_Function_glFramebufferTextureLayer;
-  static const Function glMapBufferRange = GLMessage_Function_glMapBufferRange;
-  static const Function glFlushMappedBufferRange = GLMessage_Function_glFlushMappedBufferRange;
-  static const Function glBindVertexArray = GLMessage_Function_glBindVertexArray;
-  static const Function glDeleteVertexArrays = GLMessage_Function_glDeleteVertexArrays;
-  static const Function glGenVertexArrays = GLMessage_Function_glGenVertexArrays;
-  static const Function glIsVertexArray = GLMessage_Function_glIsVertexArray;
-  static const Function glGetIntegeri_v = GLMessage_Function_glGetIntegeri_v;
-  static const Function glBeginTransformFeedback = GLMessage_Function_glBeginTransformFeedback;
-  static const Function glEndTransformFeedback = GLMessage_Function_glEndTransformFeedback;
-  static const Function glBindBufferRange = GLMessage_Function_glBindBufferRange;
-  static const Function glBindBufferBase = GLMessage_Function_glBindBufferBase;
-  static const Function glTransformFeedbackVaryings = GLMessage_Function_glTransformFeedbackVaryings;
-  static const Function glGetTransformFeedbackVarying = GLMessage_Function_glGetTransformFeedbackVarying;
-  static const Function glVertexAttribIPointer = GLMessage_Function_glVertexAttribIPointer;
-  static const Function glGetVertexAttribIiv = GLMessage_Function_glGetVertexAttribIiv;
-  static const Function glGetVertexAttribIuiv = GLMessage_Function_glGetVertexAttribIuiv;
-  static const Function glVertexAttribI4i = GLMessage_Function_glVertexAttribI4i;
-  static const Function glVertexAttribI4ui = GLMessage_Function_glVertexAttribI4ui;
-  static const Function glVertexAttribI4iv = GLMessage_Function_glVertexAttribI4iv;
-  static const Function glVertexAttribI4uiv = GLMessage_Function_glVertexAttribI4uiv;
-  static const Function glGetUniformuiv = GLMessage_Function_glGetUniformuiv;
-  static const Function glGetFragDataLocation = GLMessage_Function_glGetFragDataLocation;
-  static const Function glUniform1ui = GLMessage_Function_glUniform1ui;
-  static const Function glUniform2ui = GLMessage_Function_glUniform2ui;
-  static const Function glUniform3ui = GLMessage_Function_glUniform3ui;
-  static const Function glUniform4ui = GLMessage_Function_glUniform4ui;
-  static const Function glUniform1uiv = GLMessage_Function_glUniform1uiv;
-  static const Function glUniform2uiv = GLMessage_Function_glUniform2uiv;
-  static const Function glUniform3uiv = GLMessage_Function_glUniform3uiv;
-  static const Function glUniform4uiv = GLMessage_Function_glUniform4uiv;
-  static const Function glClearBufferiv = GLMessage_Function_glClearBufferiv;
-  static const Function glClearBufferuiv = GLMessage_Function_glClearBufferuiv;
-  static const Function glClearBufferfv = GLMessage_Function_glClearBufferfv;
-  static const Function glClearBufferfi = GLMessage_Function_glClearBufferfi;
-  static const Function glGetStringi = GLMessage_Function_glGetStringi;
-  static const Function glCopyBufferSubData = GLMessage_Function_glCopyBufferSubData;
-  static const Function glGetUniformIndices = GLMessage_Function_glGetUniformIndices;
-  static const Function glGetActiveUniformsiv = GLMessage_Function_glGetActiveUniformsiv;
-  static const Function glGetUniformBlockIndex = GLMessage_Function_glGetUniformBlockIndex;
-  static const Function glGetActiveUniformBlockiv = GLMessage_Function_glGetActiveUniformBlockiv;
-  static const Function glGetActiveUniformBlockName = GLMessage_Function_glGetActiveUniformBlockName;
-  static const Function glUniformBlockBinding = GLMessage_Function_glUniformBlockBinding;
-  static const Function glDrawArraysInstanced = GLMessage_Function_glDrawArraysInstanced;
-  static const Function glDrawElementsInstanced = GLMessage_Function_glDrawElementsInstanced;
-  static const Function glFenceSync = GLMessage_Function_glFenceSync;
-  static const Function glIsSync = GLMessage_Function_glIsSync;
-  static const Function glDeleteSync = GLMessage_Function_glDeleteSync;
-  static const Function glClientWaitSync = GLMessage_Function_glClientWaitSync;
-  static const Function glWaitSync = GLMessage_Function_glWaitSync;
-  static const Function glGetInteger64v = GLMessage_Function_glGetInteger64v;
-  static const Function glGetSynciv = GLMessage_Function_glGetSynciv;
-  static const Function glGetInteger64i_v = GLMessage_Function_glGetInteger64i_v;
-  static const Function glGetBufferParameteri64v = GLMessage_Function_glGetBufferParameteri64v;
-  static const Function glGenSamplers = GLMessage_Function_glGenSamplers;
-  static const Function glDeleteSamplers = GLMessage_Function_glDeleteSamplers;
-  static const Function glIsSampler = GLMessage_Function_glIsSampler;
-  static const Function glBindSampler = GLMessage_Function_glBindSampler;
-  static const Function glSamplerParameteri = GLMessage_Function_glSamplerParameteri;
-  static const Function glSamplerParameteriv = GLMessage_Function_glSamplerParameteriv;
-  static const Function glSamplerParameterf = GLMessage_Function_glSamplerParameterf;
-  static const Function glSamplerParameterfv = GLMessage_Function_glSamplerParameterfv;
-  static const Function glGetSamplerParameteriv = GLMessage_Function_glGetSamplerParameteriv;
-  static const Function glGetSamplerParameterfv = GLMessage_Function_glGetSamplerParameterfv;
-  static const Function glVertexAttribDivisor = GLMessage_Function_glVertexAttribDivisor;
-  static const Function glBindTransformFeedback = GLMessage_Function_glBindTransformFeedback;
-  static const Function glDeleteTransformFeedbacks = GLMessage_Function_glDeleteTransformFeedbacks;
-  static const Function glGenTransformFeedbacks = GLMessage_Function_glGenTransformFeedbacks;
-  static const Function glIsTransformFeedback = GLMessage_Function_glIsTransformFeedback;
-  static const Function glPauseTransformFeedback = GLMessage_Function_glPauseTransformFeedback;
-  static const Function glResumeTransformFeedback = GLMessage_Function_glResumeTransformFeedback;
-  static const Function glGetProgramBinary = GLMessage_Function_glGetProgramBinary;
-  static const Function glProgramBinary = GLMessage_Function_glProgramBinary;
-  static const Function glProgramParameteri = GLMessage_Function_glProgramParameteri;
-  static const Function glInvalidateFramebuffer = GLMessage_Function_glInvalidateFramebuffer;
-  static const Function glInvalidateSubFramebuffer = GLMessage_Function_glInvalidateSubFramebuffer;
-  static const Function glTexStorage2D = GLMessage_Function_glTexStorage2D;
-  static const Function glTexStorage3D = GLMessage_Function_glTexStorage3D;
-  static const Function glGetInternalformativ = GLMessage_Function_glGetInternalformativ;
-  static const Function glActiveShaderProgramEXT = GLMessage_Function_glActiveShaderProgramEXT;
-  static const Function glAlphaFuncQCOM = GLMessage_Function_glAlphaFuncQCOM;
-  static const Function glBeginQueryEXT = GLMessage_Function_glBeginQueryEXT;
-  static const Function glBindProgramPipelineEXT = GLMessage_Function_glBindProgramPipelineEXT;
-  static const Function glBlitFramebufferANGLE = GLMessage_Function_glBlitFramebufferANGLE;
-  static const Function glCreateShaderProgramvEXT = GLMessage_Function_glCreateShaderProgramvEXT;
-  static const Function glDeleteProgramPipelinesEXT = GLMessage_Function_glDeleteProgramPipelinesEXT;
-  static const Function glDeleteQueriesEXT = GLMessage_Function_glDeleteQueriesEXT;
-  static const Function glDrawBuffersNV = GLMessage_Function_glDrawBuffersNV;
-  static const Function glEndQueryEXT = GLMessage_Function_glEndQueryEXT;
-  static const Function glFramebufferTexture2DMultisampleEXT = GLMessage_Function_glFramebufferTexture2DMultisampleEXT;
-  static const Function glGenProgramPipelinesEXT = GLMessage_Function_glGenProgramPipelinesEXT;
-  static const Function glGenQueriesEXT = GLMessage_Function_glGenQueriesEXT;
-  static const Function glGetGraphicsResetStatusEXT = GLMessage_Function_glGetGraphicsResetStatusEXT;
-  static const Function glGetObjectLabelEXT = GLMessage_Function_glGetObjectLabelEXT;
-  static const Function glGetProgramPipelineInfoLogEXT = GLMessage_Function_glGetProgramPipelineInfoLogEXT;
-  static const Function glGetProgramPipelineivEXT = GLMessage_Function_glGetProgramPipelineivEXT;
-  static const Function glGetQueryObjectuivEXT = GLMessage_Function_glGetQueryObjectuivEXT;
-  static const Function glGetQueryivEXT = GLMessage_Function_glGetQueryivEXT;
-  static const Function glGetnUniformfvEXT = GLMessage_Function_glGetnUniformfvEXT;
-  static const Function glGetnUniformivEXT = GLMessage_Function_glGetnUniformivEXT;
-  static const Function glInsertEventMarkerEXT = GLMessage_Function_glInsertEventMarkerEXT;
-  static const Function glIsProgramPipelineEXT = GLMessage_Function_glIsProgramPipelineEXT;
-  static const Function glIsQueryEXT = GLMessage_Function_glIsQueryEXT;
-  static const Function glLabelObjectEXT = GLMessage_Function_glLabelObjectEXT;
-  static const Function glPopGroupMarkerEXT = GLMessage_Function_glPopGroupMarkerEXT;
-  static const Function glProgramParameteriEXT = GLMessage_Function_glProgramParameteriEXT;
-  static const Function glProgramUniform1fEXT = GLMessage_Function_glProgramUniform1fEXT;
-  static const Function glProgramUniform1fvEXT = GLMessage_Function_glProgramUniform1fvEXT;
-  static const Function glProgramUniform1iEXT = GLMessage_Function_glProgramUniform1iEXT;
-  static const Function glProgramUniform1ivEXT = GLMessage_Function_glProgramUniform1ivEXT;
-  static const Function glProgramUniform2fEXT = GLMessage_Function_glProgramUniform2fEXT;
-  static const Function glProgramUniform2fvEXT = GLMessage_Function_glProgramUniform2fvEXT;
-  static const Function glProgramUniform2iEXT = GLMessage_Function_glProgramUniform2iEXT;
-  static const Function glProgramUniform2ivEXT = GLMessage_Function_glProgramUniform2ivEXT;
-  static const Function glProgramUniform3fEXT = GLMessage_Function_glProgramUniform3fEXT;
-  static const Function glProgramUniform3fvEXT = GLMessage_Function_glProgramUniform3fvEXT;
-  static const Function glProgramUniform3iEXT = GLMessage_Function_glProgramUniform3iEXT;
-  static const Function glProgramUniform3ivEXT = GLMessage_Function_glProgramUniform3ivEXT;
-  static const Function glProgramUniform4fEXT = GLMessage_Function_glProgramUniform4fEXT;
-  static const Function glProgramUniform4fvEXT = GLMessage_Function_glProgramUniform4fvEXT;
-  static const Function glProgramUniform4iEXT = GLMessage_Function_glProgramUniform4iEXT;
-  static const Function glProgramUniform4ivEXT = GLMessage_Function_glProgramUniform4ivEXT;
-  static const Function glProgramUniformMatrix2fvEXT = GLMessage_Function_glProgramUniformMatrix2fvEXT;
-  static const Function glProgramUniformMatrix3fvEXT = GLMessage_Function_glProgramUniformMatrix3fvEXT;
-  static const Function glProgramUniformMatrix4fvEXT = GLMessage_Function_glProgramUniformMatrix4fvEXT;
-  static const Function glPushGroupMarkerEXT = GLMessage_Function_glPushGroupMarkerEXT;
-  static const Function glReadBufferNV = GLMessage_Function_glReadBufferNV;
-  static const Function glReadnPixelsEXT = GLMessage_Function_glReadnPixelsEXT;
-  static const Function glRenderbufferStorageMultisampleANGLE = GLMessage_Function_glRenderbufferStorageMultisampleANGLE;
-  static const Function glRenderbufferStorageMultisampleAPPLE = GLMessage_Function_glRenderbufferStorageMultisampleAPPLE;
-  static const Function glRenderbufferStorageMultisampleEXT = GLMessage_Function_glRenderbufferStorageMultisampleEXT;
-  static const Function glResolveMultisampleFramebufferAPPLE = GLMessage_Function_glResolveMultisampleFramebufferAPPLE;
-  static const Function glTexStorage1DEXT = GLMessage_Function_glTexStorage1DEXT;
-  static const Function glTexStorage2DEXT = GLMessage_Function_glTexStorage2DEXT;
-  static const Function glTexStorage3DEXT = GLMessage_Function_glTexStorage3DEXT;
-  static const Function glTextureStorage1DEXT = GLMessage_Function_glTextureStorage1DEXT;
-  static const Function glTextureStorage2DEXT = GLMessage_Function_glTextureStorage2DEXT;
-  static const Function glTextureStorage3DEXT = GLMessage_Function_glTextureStorage3DEXT;
-  static const Function glUseProgramStagesEXT = GLMessage_Function_glUseProgramStagesEXT;
-  static const Function glValidateProgramPipelineEXT = GLMessage_Function_glValidateProgramPipelineEXT;
-  static const Function eglGetDisplay = GLMessage_Function_eglGetDisplay;
-  static const Function eglInitialize = GLMessage_Function_eglInitialize;
-  static const Function eglTerminate = GLMessage_Function_eglTerminate;
-  static const Function eglGetConfigs = GLMessage_Function_eglGetConfigs;
-  static const Function eglChooseConfig = GLMessage_Function_eglChooseConfig;
-  static const Function eglGetConfigAttrib = GLMessage_Function_eglGetConfigAttrib;
-  static const Function eglCreateWindowSurface = GLMessage_Function_eglCreateWindowSurface;
-  static const Function eglCreatePixmapSurface = GLMessage_Function_eglCreatePixmapSurface;
-  static const Function eglCreatePbufferSurface = GLMessage_Function_eglCreatePbufferSurface;
-  static const Function eglDestroySurface = GLMessage_Function_eglDestroySurface;
-  static const Function eglQuerySurface = GLMessage_Function_eglQuerySurface;
-  static const Function eglCreateContext = GLMessage_Function_eglCreateContext;
-  static const Function eglDestroyContext = GLMessage_Function_eglDestroyContext;
-  static const Function eglMakeCurrent = GLMessage_Function_eglMakeCurrent;
-  static const Function eglGetCurrentContext = GLMessage_Function_eglGetCurrentContext;
-  static const Function eglGetCurrentSurface = GLMessage_Function_eglGetCurrentSurface;
-  static const Function eglGetCurrentDisplay = GLMessage_Function_eglGetCurrentDisplay;
-  static const Function eglQueryContext = GLMessage_Function_eglQueryContext;
-  static const Function eglWaitGL = GLMessage_Function_eglWaitGL;
-  static const Function eglWaitNative = GLMessage_Function_eglWaitNative;
-  static const Function eglSwapBuffers = GLMessage_Function_eglSwapBuffers;
-  static const Function eglCopyBuffers = GLMessage_Function_eglCopyBuffers;
-  static const Function eglGetError = GLMessage_Function_eglGetError;
-  static const Function eglQueryString = GLMessage_Function_eglQueryString;
-  static const Function eglGetProcAddress = GLMessage_Function_eglGetProcAddress;
-  static const Function eglSurfaceAttrib = GLMessage_Function_eglSurfaceAttrib;
-  static const Function eglBindTexImage = GLMessage_Function_eglBindTexImage;
-  static const Function eglReleaseTexImage = GLMessage_Function_eglReleaseTexImage;
-  static const Function eglSwapInterval = GLMessage_Function_eglSwapInterval;
-  static const Function eglBindAPI = GLMessage_Function_eglBindAPI;
-  static const Function eglQueryAPI = GLMessage_Function_eglQueryAPI;
-  static const Function eglWaitClient = GLMessage_Function_eglWaitClient;
-  static const Function eglReleaseThread = GLMessage_Function_eglReleaseThread;
-  static const Function eglCreatePbufferFromClientBuffer = GLMessage_Function_eglCreatePbufferFromClientBuffer;
-  static const Function eglLockSurfaceKHR = GLMessage_Function_eglLockSurfaceKHR;
-  static const Function eglUnlockSurfaceKHR = GLMessage_Function_eglUnlockSurfaceKHR;
-  static const Function eglCreateImageKHR = GLMessage_Function_eglCreateImageKHR;
-  static const Function eglDestroyImageKHR = GLMessage_Function_eglDestroyImageKHR;
-  static const Function eglCreateSyncKHR = GLMessage_Function_eglCreateSyncKHR;
-  static const Function eglDestroySyncKHR = GLMessage_Function_eglDestroySyncKHR;
-  static const Function eglClientWaitSyncKHR = GLMessage_Function_eglClientWaitSyncKHR;
-  static const Function eglGetSyncAttribKHR = GLMessage_Function_eglGetSyncAttribKHR;
-  static const Function eglSetSwapRectangleANDROID = GLMessage_Function_eglSetSwapRectangleANDROID;
-  static const Function eglGetRenderBufferANDROID = GLMessage_Function_eglGetRenderBufferANDROID;
-  static const Function eglGetSystemTimeFrequencyNV = GLMessage_Function_eglGetSystemTimeFrequencyNV;
-  static const Function eglGetSystemTimeNV = GLMessage_Function_eglGetSystemTimeNV;
-  static const Function invalid = GLMessage_Function_invalid;
-  static const Function glVertexAttribPointerData = GLMessage_Function_glVertexAttribPointerData;
-  static inline bool Function_IsValid(int value) {
-    return GLMessage_Function_IsValid(value);
-  }
-  static const Function Function_MIN =
-    GLMessage_Function_Function_MIN;
-  static const Function Function_MAX =
-    GLMessage_Function_Function_MAX;
-  static const int Function_ARRAYSIZE =
-    GLMessage_Function_Function_ARRAYSIZE;
-  
-  // accessors -------------------------------------------------------
-  
-  // required int32 context_id = 1;
-  inline bool has_context_id() const;
-  inline void clear_context_id();
-  static const int kContextIdFieldNumber = 1;
-  inline ::google::protobuf::int32 context_id() const;
-  inline void set_context_id(::google::protobuf::int32 value);
-  
-  // required int64 start_time = 2;
-  inline bool has_start_time() const;
-  inline void clear_start_time();
-  static const int kStartTimeFieldNumber = 2;
-  inline ::google::protobuf::int64 start_time() const;
-  inline void set_start_time(::google::protobuf::int64 value);
-  
-  // required int32 duration = 3;
-  inline bool has_duration() const;
-  inline void clear_duration();
-  static const int kDurationFieldNumber = 3;
-  inline ::google::protobuf::int32 duration() const;
-  inline void set_duration(::google::protobuf::int32 value);
-  
-  // required .android.gltrace.GLMessage.Function function = 4 [default = invalid];
-  inline bool has_function() const;
-  inline void clear_function();
-  static const int kFunctionFieldNumber = 4;
-  inline ::android::gltrace::GLMessage_Function function() const;
-  inline void set_function(::android::gltrace::GLMessage_Function value);
-  
-  // repeated .android.gltrace.GLMessage.DataType args = 5;
-  inline int args_size() const;
-  inline void clear_args();
-  static const int kArgsFieldNumber = 5;
-  inline const ::android::gltrace::GLMessage_DataType& args(int index) const;
-  inline ::android::gltrace::GLMessage_DataType* mutable_args(int index);
-  inline ::android::gltrace::GLMessage_DataType* add_args();
-  inline const ::google::protobuf::RepeatedPtrField< ::android::gltrace::GLMessage_DataType >&
-      args() const;
-  inline ::google::protobuf::RepeatedPtrField< ::android::gltrace::GLMessage_DataType >*
-      mutable_args();
-  
-  // optional .android.gltrace.GLMessage.DataType returnValue = 6;
-  inline bool has_returnvalue() const;
-  inline void clear_returnvalue();
-  static const int kReturnValueFieldNumber = 6;
-  inline const ::android::gltrace::GLMessage_DataType& returnvalue() const;
-  inline ::android::gltrace::GLMessage_DataType* mutable_returnvalue();
-  
-  // optional .android.gltrace.GLMessage.FrameBuffer fb = 7;
-  inline bool has_fb() const;
-  inline void clear_fb();
-  static const int kFbFieldNumber = 7;
-  inline const ::android::gltrace::GLMessage_FrameBuffer& fb() const;
-  inline ::android::gltrace::GLMessage_FrameBuffer* mutable_fb();
-  
-  // optional int32 threadtime = 8;
-  inline bool has_threadtime() const;
-  inline void clear_threadtime();
-  static const int kThreadtimeFieldNumber = 8;
-  inline ::google::protobuf::int32 threadtime() const;
-  inline void set_threadtime(::google::protobuf::int32 value);
-  
-  // @@protoc_insertion_point(class_scope:android.gltrace.GLMessage)
- private:
-  mutable int _cached_size_;
-  
-  ::google::protobuf::int32 context_id_;
-  ::google::protobuf::int64 start_time_;
-  ::google::protobuf::int32 duration_;
-  int function_;
-  ::google::protobuf::RepeatedPtrField< ::android::gltrace::GLMessage_DataType > args_;
-  ::android::gltrace::GLMessage_DataType* returnvalue_;
-  ::android::gltrace::GLMessage_FrameBuffer* fb_;
-  ::google::protobuf::int32 threadtime_;
-  friend void  protobuf_AddDesc_gltrace_2eproto();
-  friend void protobuf_AssignDesc_gltrace_2eproto();
-  friend void protobuf_ShutdownFile_gltrace_2eproto();
-  
-  ::google::protobuf::uint32 _has_bits_[(8 + 31) / 32];
-  
-  // WHY DOES & HAVE LOWER PRECEDENCE THAN != !?
-  inline bool _has_bit(int index) const {
-    return (_has_bits_[index / 32] & (1u << (index % 32))) != 0;
-  }
-  inline void _set_bit(int index) {
-    _has_bits_[index / 32] |= (1u << (index % 32));
-  }
-  inline void _clear_bit(int index) {
-    _has_bits_[index / 32] &= ~(1u << (index % 32));
-  }
-  
-  void InitAsDefaultInstance();
-  static GLMessage* default_instance_;
-};
-// ===================================================================
-
-
-// ===================================================================
-
-// GLMessage_DataType
-
-// required .android.gltrace.GLMessage.DataType.Type type = 1 [default = VOID];
-inline bool GLMessage_DataType::has_type() const {
-  return _has_bit(0);
-}
-inline void GLMessage_DataType::clear_type() {
-  type_ = 1;
-  _clear_bit(0);
-}
-inline ::android::gltrace::GLMessage_DataType_Type GLMessage_DataType::type() const {
-  return static_cast< ::android::gltrace::GLMessage_DataType_Type >(type_);
-}
-inline void GLMessage_DataType::set_type(::android::gltrace::GLMessage_DataType_Type value) {
-  GOOGLE_DCHECK(::android::gltrace::GLMessage_DataType_Type_IsValid(value));
-  _set_bit(0);
-  type_ = value;
-}
-
-// required bool isArray = 2 [default = false];
-inline bool GLMessage_DataType::has_isarray() const {
-  return _has_bit(1);
-}
-inline void GLMessage_DataType::clear_isarray() {
-  isarray_ = false;
-  _clear_bit(1);
-}
-inline bool GLMessage_DataType::isarray() const {
-  return isarray_;
-}
-inline void GLMessage_DataType::set_isarray(bool value) {
-  _set_bit(1);
-  isarray_ = value;
-}
-
-// repeated int32 intValue = 3;
-inline int GLMessage_DataType::intvalue_size() const {
-  return intvalue_.size();
-}
-inline void GLMessage_DataType::clear_intvalue() {
-  intvalue_.Clear();
-}
-inline ::google::protobuf::int32 GLMessage_DataType::intvalue(int index) const {
-  return intvalue_.Get(index);
-}
-inline void GLMessage_DataType::set_intvalue(int index, ::google::protobuf::int32 value) {
-  intvalue_.Set(index, value);
-}
-inline void GLMessage_DataType::add_intvalue(::google::protobuf::int32 value) {
-  intvalue_.Add(value);
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
-GLMessage_DataType::intvalue() const {
-  return intvalue_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
-GLMessage_DataType::mutable_intvalue() {
-  return &intvalue_;
-}
-
-// repeated float floatValue = 4;
-inline int GLMessage_DataType::floatvalue_size() const {
-  return floatvalue_.size();
-}
-inline void GLMessage_DataType::clear_floatvalue() {
-  floatvalue_.Clear();
-}
-inline float GLMessage_DataType::floatvalue(int index) const {
-  return floatvalue_.Get(index);
-}
-inline void GLMessage_DataType::set_floatvalue(int index, float value) {
-  floatvalue_.Set(index, value);
-}
-inline void GLMessage_DataType::add_floatvalue(float value) {
-  floatvalue_.Add(value);
-}
-inline const ::google::protobuf::RepeatedField< float >&
-GLMessage_DataType::floatvalue() const {
-  return floatvalue_;
-}
-inline ::google::protobuf::RepeatedField< float >*
-GLMessage_DataType::mutable_floatvalue() {
-  return &floatvalue_;
-}
-
-// repeated bytes charValue = 5;
-inline int GLMessage_DataType::charvalue_size() const {
-  return charvalue_.size();
-}
-inline void GLMessage_DataType::clear_charvalue() {
-  charvalue_.Clear();
-}
-inline const ::std::string& GLMessage_DataType::charvalue(int index) const {
-  return charvalue_.Get(index);
-}
-inline ::std::string* GLMessage_DataType::mutable_charvalue(int index) {
-  return charvalue_.Mutable(index);
-}
-inline void GLMessage_DataType::set_charvalue(int index, const ::std::string& value) {
-  charvalue_.Mutable(index)->assign(value);
-}
-inline void GLMessage_DataType::set_charvalue(int index, const char* value) {
-  charvalue_.Mutable(index)->assign(value);
-}
-inline void GLMessage_DataType::set_charvalue(int index, const void* value, size_t size) {
-  charvalue_.Mutable(index)->assign(
-    reinterpret_cast<const char*>(value), size);
-}
-inline ::std::string* GLMessage_DataType::add_charvalue() {
-  return charvalue_.Add();
-}
-inline void GLMessage_DataType::add_charvalue(const ::std::string& value) {
-  charvalue_.Add()->assign(value);
-}
-inline void GLMessage_DataType::add_charvalue(const char* value) {
-  charvalue_.Add()->assign(value);
-}
-inline void GLMessage_DataType::add_charvalue(const void* value, size_t size) {
-  charvalue_.Add()->assign(reinterpret_cast<const char*>(value), size);
-}
-inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
-GLMessage_DataType::charvalue() const {
-  return charvalue_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::std::string>*
-GLMessage_DataType::mutable_charvalue() {
-  return &charvalue_;
-}
-
-// repeated bytes rawBytes = 6;
-inline int GLMessage_DataType::rawbytes_size() const {
-  return rawbytes_.size();
-}
-inline void GLMessage_DataType::clear_rawbytes() {
-  rawbytes_.Clear();
-}
-inline const ::std::string& GLMessage_DataType::rawbytes(int index) const {
-  return rawbytes_.Get(index);
-}
-inline ::std::string* GLMessage_DataType::mutable_rawbytes(int index) {
-  return rawbytes_.Mutable(index);
-}
-inline void GLMessage_DataType::set_rawbytes(int index, const ::std::string& value) {
-  rawbytes_.Mutable(index)->assign(value);
-}
-inline void GLMessage_DataType::set_rawbytes(int index, const char* value) {
-  rawbytes_.Mutable(index)->assign(value);
-}
-inline void GLMessage_DataType::set_rawbytes(int index, const void* value, size_t size) {
-  rawbytes_.Mutable(index)->assign(
-    reinterpret_cast<const char*>(value), size);
-}
-inline ::std::string* GLMessage_DataType::add_rawbytes() {
-  return rawbytes_.Add();
-}
-inline void GLMessage_DataType::add_rawbytes(const ::std::string& value) {
-  rawbytes_.Add()->assign(value);
-}
-inline void GLMessage_DataType::add_rawbytes(const char* value) {
-  rawbytes_.Add()->assign(value);
-}
-inline void GLMessage_DataType::add_rawbytes(const void* value, size_t size) {
-  rawbytes_.Add()->assign(reinterpret_cast<const char*>(value), size);
-}
-inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
-GLMessage_DataType::rawbytes() const {
-  return rawbytes_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::std::string>*
-GLMessage_DataType::mutable_rawbytes() {
-  return &rawbytes_;
-}
-
-// repeated bool boolValue = 7;
-inline int GLMessage_DataType::boolvalue_size() const {
-  return boolvalue_.size();
-}
-inline void GLMessage_DataType::clear_boolvalue() {
-  boolvalue_.Clear();
-}
-inline bool GLMessage_DataType::boolvalue(int index) const {
-  return boolvalue_.Get(index);
-}
-inline void GLMessage_DataType::set_boolvalue(int index, bool value) {
-  boolvalue_.Set(index, value);
-}
-inline void GLMessage_DataType::add_boolvalue(bool value) {
-  boolvalue_.Add(value);
-}
-inline const ::google::protobuf::RepeatedField< bool >&
-GLMessage_DataType::boolvalue() const {
-  return boolvalue_;
-}
-inline ::google::protobuf::RepeatedField< bool >*
-GLMessage_DataType::mutable_boolvalue() {
-  return &boolvalue_;
-}
-
-// repeated int64 int64Value = 8;
-inline int GLMessage_DataType::int64value_size() const {
-  return int64value_.size();
-}
-inline void GLMessage_DataType::clear_int64value() {
-  int64value_.Clear();
-}
-inline ::google::protobuf::int64 GLMessage_DataType::int64value(int index) const {
-  return int64value_.Get(index);
-}
-inline void GLMessage_DataType::set_int64value(int index, ::google::protobuf::int64 value) {
-  int64value_.Set(index, value);
-}
-inline void GLMessage_DataType::add_int64value(::google::protobuf::int64 value) {
-  int64value_.Add(value);
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >&
-GLMessage_DataType::int64value() const {
-  return int64value_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
-GLMessage_DataType::mutable_int64value() {
-  return &int64value_;
-}
-
-// -------------------------------------------------------------------
-
-// GLMessage_FrameBuffer
-
-// required int32 width = 1;
-inline bool GLMessage_FrameBuffer::has_width() const {
-  return _has_bit(0);
-}
-inline void GLMessage_FrameBuffer::clear_width() {
-  width_ = 0;
-  _clear_bit(0);
-}
-inline ::google::protobuf::int32 GLMessage_FrameBuffer::width() const {
-  return width_;
-}
-inline void GLMessage_FrameBuffer::set_width(::google::protobuf::int32 value) {
-  _set_bit(0);
-  width_ = value;
-}
-
-// required int32 height = 2;
-inline bool GLMessage_FrameBuffer::has_height() const {
-  return _has_bit(1);
-}
-inline void GLMessage_FrameBuffer::clear_height() {
-  height_ = 0;
-  _clear_bit(1);
-}
-inline ::google::protobuf::int32 GLMessage_FrameBuffer::height() const {
-  return height_;
-}
-inline void GLMessage_FrameBuffer::set_height(::google::protobuf::int32 value) {
-  _set_bit(1);
-  height_ = value;
-}
-
-// repeated bytes contents = 3;
-inline int GLMessage_FrameBuffer::contents_size() const {
-  return contents_.size();
-}
-inline void GLMessage_FrameBuffer::clear_contents() {
-  contents_.Clear();
-}
-inline const ::std::string& GLMessage_FrameBuffer::contents(int index) const {
-  return contents_.Get(index);
-}
-inline ::std::string* GLMessage_FrameBuffer::mutable_contents(int index) {
-  return contents_.Mutable(index);
-}
-inline void GLMessage_FrameBuffer::set_contents(int index, const ::std::string& value) {
-  contents_.Mutable(index)->assign(value);
-}
-inline void GLMessage_FrameBuffer::set_contents(int index, const char* value) {
-  contents_.Mutable(index)->assign(value);
-}
-inline void GLMessage_FrameBuffer::set_contents(int index, const void* value, size_t size) {
-  contents_.Mutable(index)->assign(
-    reinterpret_cast<const char*>(value), size);
-}
-inline ::std::string* GLMessage_FrameBuffer::add_contents() {
-  return contents_.Add();
-}
-inline void GLMessage_FrameBuffer::add_contents(const ::std::string& value) {
-  contents_.Add()->assign(value);
-}
-inline void GLMessage_FrameBuffer::add_contents(const char* value) {
-  contents_.Add()->assign(value);
-}
-inline void GLMessage_FrameBuffer::add_contents(const void* value, size_t size) {
-  contents_.Add()->assign(reinterpret_cast<const char*>(value), size);
-}
-inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
-GLMessage_FrameBuffer::contents() const {
-  return contents_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::std::string>*
-GLMessage_FrameBuffer::mutable_contents() {
-  return &contents_;
-}
-
-// -------------------------------------------------------------------
-
-// GLMessage
-
-// required int32 context_id = 1;
-inline bool GLMessage::has_context_id() const {
-  return _has_bit(0);
-}
-inline void GLMessage::clear_context_id() {
-  context_id_ = 0;
-  _clear_bit(0);
-}
-inline ::google::protobuf::int32 GLMessage::context_id() const {
-  return context_id_;
-}
-inline void GLMessage::set_context_id(::google::protobuf::int32 value) {
-  _set_bit(0);
-  context_id_ = value;
-}
-
-// required int64 start_time = 2;
-inline bool GLMessage::has_start_time() const {
-  return _has_bit(1);
-}
-inline void GLMessage::clear_start_time() {
-  start_time_ = GOOGLE_LONGLONG(0);
-  _clear_bit(1);
-}
-inline ::google::protobuf::int64 GLMessage::start_time() const {
-  return start_time_;
-}
-inline void GLMessage::set_start_time(::google::protobuf::int64 value) {
-  _set_bit(1);
-  start_time_ = value;
-}
-
-// required int32 duration = 3;
-inline bool GLMessage::has_duration() const {
-  return _has_bit(2);
-}
-inline void GLMessage::clear_duration() {
-  duration_ = 0;
-  _clear_bit(2);
-}
-inline ::google::protobuf::int32 GLMessage::duration() const {
-  return duration_;
-}
-inline void GLMessage::set_duration(::google::protobuf::int32 value) {
-  _set_bit(2);
-  duration_ = value;
-}
-
-// required .android.gltrace.GLMessage.Function function = 4 [default = invalid];
-inline bool GLMessage::has_function() const {
-  return _has_bit(3);
-}
-inline void GLMessage::clear_function() {
-  function_ = 3000;
-  _clear_bit(3);
-}
-inline ::android::gltrace::GLMessage_Function GLMessage::function() const {
-  return static_cast< ::android::gltrace::GLMessage_Function >(function_);
-}
-inline void GLMessage::set_function(::android::gltrace::GLMessage_Function value) {
-  GOOGLE_DCHECK(::android::gltrace::GLMessage_Function_IsValid(value));
-  _set_bit(3);
-  function_ = value;
-}
-
-// repeated .android.gltrace.GLMessage.DataType args = 5;
-inline int GLMessage::args_size() const {
-  return args_.size();
-}
-inline void GLMessage::clear_args() {
-  args_.Clear();
-}
-inline const ::android::gltrace::GLMessage_DataType& GLMessage::args(int index) const {
-  return args_.Get(index);
-}
-inline ::android::gltrace::GLMessage_DataType* GLMessage::mutable_args(int index) {
-  return args_.Mutable(index);
-}
-inline ::android::gltrace::GLMessage_DataType* GLMessage::add_args() {
-  return args_.Add();
-}
-inline const ::google::protobuf::RepeatedPtrField< ::android::gltrace::GLMessage_DataType >&
-GLMessage::args() const {
-  return args_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::android::gltrace::GLMessage_DataType >*
-GLMessage::mutable_args() {
-  return &args_;
-}
-
-// optional .android.gltrace.GLMessage.DataType returnValue = 6;
-inline bool GLMessage::has_returnvalue() const {
-  return _has_bit(5);
-}
-inline void GLMessage::clear_returnvalue() {
-  if (returnvalue_ != NULL) returnvalue_->::android::gltrace::GLMessage_DataType::Clear();
-  _clear_bit(5);
-}
-inline const ::android::gltrace::GLMessage_DataType& GLMessage::returnvalue() const {
-  return returnvalue_ != NULL ? *returnvalue_ : *default_instance_->returnvalue_;
-}
-inline ::android::gltrace::GLMessage_DataType* GLMessage::mutable_returnvalue() {
-  _set_bit(5);
-  if (returnvalue_ == NULL) returnvalue_ = new ::android::gltrace::GLMessage_DataType;
-  return returnvalue_;
-}
-
-// optional .android.gltrace.GLMessage.FrameBuffer fb = 7;
-inline bool GLMessage::has_fb() const {
-  return _has_bit(6);
-}
-inline void GLMessage::clear_fb() {
-  if (fb_ != NULL) fb_->::android::gltrace::GLMessage_FrameBuffer::Clear();
-  _clear_bit(6);
-}
-inline const ::android::gltrace::GLMessage_FrameBuffer& GLMessage::fb() const {
-  return fb_ != NULL ? *fb_ : *default_instance_->fb_;
-}
-inline ::android::gltrace::GLMessage_FrameBuffer* GLMessage::mutable_fb() {
-  _set_bit(6);
-  if (fb_ == NULL) fb_ = new ::android::gltrace::GLMessage_FrameBuffer;
-  return fb_;
-}
-
-// optional int32 threadtime = 8;
-inline bool GLMessage::has_threadtime() const {
-  return _has_bit(7);
-}
-inline void GLMessage::clear_threadtime() {
-  threadtime_ = 0;
-  _clear_bit(7);
-}
-inline ::google::protobuf::int32 GLMessage::threadtime() const {
-  return threadtime_;
-}
-inline void GLMessage::set_threadtime(::google::protobuf::int32 value) {
-  _set_bit(7);
-  threadtime_ = value;
-}
-
-
-// @@protoc_insertion_point(namespace_scope)
-
-}  // namespace gltrace
-}  // namespace android
-
-// @@protoc_insertion_point(global_scope)
-
-#endif  // PROTOBUF_gltrace_2eproto__INCLUDED
diff --git a/opengl/libs/GLES_trace/src/gltrace_api.cpp b/opengl/libs/GLES_trace/src/gltrace_api.cpp
index e2cd0d8..d83b9b4 100644
--- a/opengl/libs/GLES_trace/src/gltrace_api.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_api.cpp
@@ -18,9 +18,8 @@
 
 #include <cutils/log.h>
 #include <utils/Timers.h>
-#include <GLES3/gl3.h>
 
-#include "gltrace.pb.h"
+#include "frameworks/native/opengl/libs/GLES_trace/proto/gltrace.pb.h"
 #include "gltrace_context.h"
 #include "gltrace_fixup.h"
 #include "gltrace_transport.h"
@@ -28,7 +27,7 @@
 namespace android {
 namespace gltrace {
 
-// Definitions for GL3 APIs
+// Definitions for GL2 APIs
 
 void GLTrace_glActiveTexture(GLenum texture) {
     GLMessage glmsg;
@@ -92,7 +91,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glBindAttribLocation(GLuint program, GLuint index, const GLchar* name) {
+void GLTrace_glBindAttribLocation(GLuint program, GLuint index, const GLchar * name) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -411,40 +410,40 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) {
+void GLTrace_glBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glBlendFuncSeparate);
 
-    // copy argument srcRGB
-    GLMessage_DataType *arg_srcRGB = glmsg.add_args();
-    arg_srcRGB->set_isarray(false);
-    arg_srcRGB->set_type(GLMessage::DataType::ENUM);
-    arg_srcRGB->add_intvalue((int)srcRGB);
+    // copy argument sfactorRGB
+    GLMessage_DataType *arg_sfactorRGB = glmsg.add_args();
+    arg_sfactorRGB->set_isarray(false);
+    arg_sfactorRGB->set_type(GLMessage::DataType::ENUM);
+    arg_sfactorRGB->add_intvalue((int)sfactorRGB);
 
-    // copy argument dstRGB
-    GLMessage_DataType *arg_dstRGB = glmsg.add_args();
-    arg_dstRGB->set_isarray(false);
-    arg_dstRGB->set_type(GLMessage::DataType::ENUM);
-    arg_dstRGB->add_intvalue((int)dstRGB);
+    // copy argument dfactorRGB
+    GLMessage_DataType *arg_dfactorRGB = glmsg.add_args();
+    arg_dfactorRGB->set_isarray(false);
+    arg_dfactorRGB->set_type(GLMessage::DataType::ENUM);
+    arg_dfactorRGB->add_intvalue((int)dfactorRGB);
 
-    // copy argument srcAlpha
-    GLMessage_DataType *arg_srcAlpha = glmsg.add_args();
-    arg_srcAlpha->set_isarray(false);
-    arg_srcAlpha->set_type(GLMessage::DataType::ENUM);
-    arg_srcAlpha->add_intvalue((int)srcAlpha);
+    // copy argument sfactorAlpha
+    GLMessage_DataType *arg_sfactorAlpha = glmsg.add_args();
+    arg_sfactorAlpha->set_isarray(false);
+    arg_sfactorAlpha->set_type(GLMessage::DataType::ENUM);
+    arg_sfactorAlpha->add_intvalue((int)sfactorAlpha);
 
-    // copy argument dstAlpha
-    GLMessage_DataType *arg_dstAlpha = glmsg.add_args();
-    arg_dstAlpha->set_isarray(false);
-    arg_dstAlpha->set_type(GLMessage::DataType::ENUM);
-    arg_dstAlpha->add_intvalue((int)dstAlpha);
+    // copy argument dfactorAlpha
+    GLMessage_DataType *arg_dfactorAlpha = glmsg.add_args();
+    arg_dfactorAlpha->set_isarray(false);
+    arg_dfactorAlpha->set_type(GLMessage::DataType::ENUM);
+    arg_dfactorAlpha->add_intvalue((int)dfactorAlpha);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
+    glContext->hooks->gl.glBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -457,7 +456,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) {
+void GLTrace_glBufferData(GLenum target, GLsizeiptr size, const void * data, GLenum usage) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -504,7 +503,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) {
+void GLTrace_glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void * data) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -661,22 +660,22 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glClearDepthf(GLfloat depth) {
+void GLTrace_glClearDepthf(GLfloat d) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glClearDepthf);
 
-    // copy argument depth
-    GLMessage_DataType *arg_depth = glmsg.add_args();
-    arg_depth->set_isarray(false);
-    arg_depth->set_type(GLMessage::DataType::FLOAT);
-    arg_depth->add_floatvalue(depth);
+    // copy argument d
+    GLMessage_DataType *arg_d = glmsg.add_args();
+    arg_d->set_isarray(false);
+    arg_d->set_type(GLMessage::DataType::FLOAT);
+    arg_d->add_floatvalue(d);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glClearDepthf(depth);
+    glContext->hooks->gl.glClearDepthf(d);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -791,7 +790,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data) {
+void GLTrace_glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -862,7 +861,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data) {
+void GLTrace_glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -1173,7 +1172,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDeleteBuffers(GLsizei n, const GLuint* buffers) {
+void GLTrace_glDeleteBuffers(GLsizei n, const GLuint * buffers) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -1208,7 +1207,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) {
+void GLTrace_glDeleteFramebuffers(GLsizei n, const GLuint * framebuffers) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -1271,7 +1270,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) {
+void GLTrace_glDeleteRenderbuffers(GLsizei n, const GLuint * renderbuffers) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -1334,7 +1333,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDeleteTextures(GLsizei n, const GLuint* textures) {
+void GLTrace_glDeleteTextures(GLsizei n, const GLuint * textures) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -1589,7 +1588,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) {
+void GLTrace_glDrawElements(GLenum mode, GLsizei count, GLenum type, const void * indices) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -1862,7 +1861,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGenBuffers(GLsizei n, GLuint* buffers) {
+void GLTrace_glGenBuffers(GLsizei n, GLuint * buffers) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -1925,7 +1924,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGenFramebuffers(GLsizei n, GLuint* framebuffers) {
+void GLTrace_glGenFramebuffers(GLsizei n, GLuint * framebuffers) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -1960,7 +1959,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) {
+void GLTrace_glGenRenderbuffers(GLsizei n, GLuint * renderbuffers) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -1995,7 +1994,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGenTextures(GLsizei n, GLuint* textures) {
+void GLTrace_glGenTextures(GLsizei n, GLuint * textures) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2030,7 +2029,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) {
+void GLTrace_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2048,11 +2047,11 @@
     arg_index->set_type(GLMessage::DataType::INT);
     arg_index->add_intvalue(index);
 
-    // copy argument bufsize
-    GLMessage_DataType *arg_bufsize = glmsg.add_args();
-    arg_bufsize->set_isarray(false);
-    arg_bufsize->set_type(GLMessage::DataType::INT);
-    arg_bufsize->add_intvalue(bufsize);
+    // copy argument bufSize
+    GLMessage_DataType *arg_bufSize = glmsg.add_args();
+    arg_bufSize->set_isarray(false);
+    arg_bufSize->set_type(GLMessage::DataType::INT);
+    arg_bufSize->add_intvalue(bufSize);
 
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
@@ -2081,7 +2080,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetActiveAttrib(program, index, bufsize, length, size, type, name);
+    glContext->hooks->gl.glGetActiveAttrib(program, index, bufSize, length, size, type, name);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -2098,7 +2097,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) {
+void GLTrace_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2116,11 +2115,11 @@
     arg_index->set_type(GLMessage::DataType::INT);
     arg_index->add_intvalue(index);
 
-    // copy argument bufsize
-    GLMessage_DataType *arg_bufsize = glmsg.add_args();
-    arg_bufsize->set_isarray(false);
-    arg_bufsize->set_type(GLMessage::DataType::INT);
-    arg_bufsize->add_intvalue(bufsize);
+    // copy argument bufSize
+    GLMessage_DataType *arg_bufSize = glmsg.add_args();
+    arg_bufSize->set_isarray(false);
+    arg_bufSize->set_type(GLMessage::DataType::INT);
+    arg_bufSize->add_intvalue(bufSize);
 
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
@@ -2149,7 +2148,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetActiveUniform(program, index, bufsize, length, size, type, name);
+    glContext->hooks->gl.glGetActiveUniform(program, index, bufSize, length, size, type, name);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -2166,7 +2165,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) {
+void GLTrace_glGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2178,11 +2177,11 @@
     arg_program->set_type(GLMessage::DataType::INT);
     arg_program->add_intvalue(program);
 
-    // copy argument maxcount
-    GLMessage_DataType *arg_maxcount = glmsg.add_args();
-    arg_maxcount->set_isarray(false);
-    arg_maxcount->set_type(GLMessage::DataType::INT);
-    arg_maxcount->add_intvalue(maxcount);
+    // copy argument maxCount
+    GLMessage_DataType *arg_maxCount = glmsg.add_args();
+    arg_maxCount->set_isarray(false);
+    arg_maxCount->set_type(GLMessage::DataType::INT);
+    arg_maxCount->add_intvalue(maxCount);
 
     // copy argument count
     GLMessage_DataType *arg_count = glmsg.add_args();
@@ -2199,7 +2198,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetAttachedShaders(program, maxcount, count, shaders);
+    glContext->hooks->gl.glGetAttachedShaders(program, maxCount, count, shaders);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -2214,7 +2213,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-GLint GLTrace_glGetAttribLocation(GLuint program, const GLchar* name) {
+GLint GLTrace_glGetAttribLocation(GLuint program, const GLchar * name) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2257,7 +2256,7 @@
     return retValue;
 }
 
-void GLTrace_glGetBooleanv(GLenum pname, GLboolean* params) {
+void GLTrace_glGetBooleanv(GLenum pname, GLboolean * data) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2269,21 +2268,21 @@
     arg_pname->set_type(GLMessage::DataType::ENUM);
     arg_pname->add_intvalue((int)pname);
 
-    // copy argument params
-    GLMessage_DataType *arg_params = glmsg.add_args();
-    arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT64);
-    arg_params->add_int64value((uintptr_t)params);
+    // copy argument data
+    GLMessage_DataType *arg_data = glmsg.add_args();
+    arg_data->set_isarray(false);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetBooleanv(pname, params);
+    glContext->hooks->gl.glGetBooleanv(pname, data);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) params,
+        (void *) data,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -2292,7 +2291,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) {
+void GLTrace_glGetBufferParameteriv(GLenum target, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2363,7 +2362,7 @@
     return retValue;
 }
 
-void GLTrace_glGetFloatv(GLenum pname, GLfloat* params) {
+void GLTrace_glGetFloatv(GLenum pname, GLfloat * data) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2375,21 +2374,21 @@
     arg_pname->set_type(GLMessage::DataType::ENUM);
     arg_pname->add_intvalue((int)pname);
 
-    // copy argument params
-    GLMessage_DataType *arg_params = glmsg.add_args();
-    arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT64);
-    arg_params->add_int64value((uintptr_t)params);
+    // copy argument data
+    GLMessage_DataType *arg_data = glmsg.add_args();
+    arg_data->set_isarray(false);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetFloatv(pname, params);
+    glContext->hooks->gl.glGetFloatv(pname, data);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) params,
+        (void *) data,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -2398,7 +2397,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) {
+void GLTrace_glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2445,7 +2444,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetIntegerv(GLenum pname, GLint* params) {
+void GLTrace_glGetIntegerv(GLenum pname, GLint * data) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2457,21 +2456,21 @@
     arg_pname->set_type(GLMessage::DataType::ENUM);
     arg_pname->add_intvalue((int)pname);
 
-    // copy argument params
-    GLMessage_DataType *arg_params = glmsg.add_args();
-    arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT64);
-    arg_params->add_int64value((uintptr_t)params);
+    // copy argument data
+    GLMessage_DataType *arg_data = glmsg.add_args();
+    arg_data->set_isarray(false);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetIntegerv(pname, params);
+    glContext->hooks->gl.glGetIntegerv(pname, data);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) params,
+        (void *) data,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -2480,7 +2479,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetProgramiv(GLuint program, GLenum pname, GLint* params) {
+void GLTrace_glGetProgramiv(GLuint program, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2521,7 +2520,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) {
+void GLTrace_glGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2533,11 +2532,11 @@
     arg_program->set_type(GLMessage::DataType::INT);
     arg_program->add_intvalue(program);
 
-    // copy argument bufsize
-    GLMessage_DataType *arg_bufsize = glmsg.add_args();
-    arg_bufsize->set_isarray(false);
-    arg_bufsize->set_type(GLMessage::DataType::INT);
-    arg_bufsize->add_intvalue(bufsize);
+    // copy argument bufSize
+    GLMessage_DataType *arg_bufSize = glmsg.add_args();
+    arg_bufSize->set_isarray(false);
+    arg_bufSize->set_type(GLMessage::DataType::INT);
+    arg_bufSize->add_intvalue(bufSize);
 
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
@@ -2545,22 +2544,22 @@
     arg_length->set_type(GLMessage::DataType::INT64);
     arg_length->add_int64value((uintptr_t)length);
 
-    // copy argument infolog
-    GLMessage_DataType *arg_infolog = glmsg.add_args();
-    arg_infolog->set_isarray(false);
-    arg_infolog->set_type(GLMessage::DataType::INT64);
-    arg_infolog->add_int64value((uintptr_t)infolog);
+    // copy argument infoLog
+    GLMessage_DataType *arg_infoLog = glmsg.add_args();
+    arg_infoLog->set_isarray(false);
+    arg_infoLog->set_type(GLMessage::DataType::INT64);
+    arg_infoLog->add_int64value((uintptr_t)infoLog);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetProgramInfoLog(program, bufsize, length, infolog);
+    glContext->hooks->gl.glGetProgramInfoLog(program, bufSize, length, infoLog);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
         (void *) length,
-        (void *) infolog,
+        (void *) infoLog,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -2569,7 +2568,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) {
+void GLTrace_glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2610,7 +2609,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetShaderiv(GLuint shader, GLenum pname, GLint* params) {
+void GLTrace_glGetShaderiv(GLuint shader, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2651,7 +2650,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) {
+void GLTrace_glGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2663,11 +2662,11 @@
     arg_shader->set_type(GLMessage::DataType::INT);
     arg_shader->add_intvalue(shader);
 
-    // copy argument bufsize
-    GLMessage_DataType *arg_bufsize = glmsg.add_args();
-    arg_bufsize->set_isarray(false);
-    arg_bufsize->set_type(GLMessage::DataType::INT);
-    arg_bufsize->add_intvalue(bufsize);
+    // copy argument bufSize
+    GLMessage_DataType *arg_bufSize = glmsg.add_args();
+    arg_bufSize->set_isarray(false);
+    arg_bufSize->set_type(GLMessage::DataType::INT);
+    arg_bufSize->add_intvalue(bufSize);
 
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
@@ -2675,22 +2674,22 @@
     arg_length->set_type(GLMessage::DataType::INT64);
     arg_length->add_int64value((uintptr_t)length);
 
-    // copy argument infolog
-    GLMessage_DataType *arg_infolog = glmsg.add_args();
-    arg_infolog->set_isarray(false);
-    arg_infolog->set_type(GLMessage::DataType::INT64);
-    arg_infolog->add_int64value((uintptr_t)infolog);
+    // copy argument infoLog
+    GLMessage_DataType *arg_infoLog = glmsg.add_args();
+    arg_infoLog->set_isarray(false);
+    arg_infoLog->set_type(GLMessage::DataType::INT64);
+    arg_infoLog->add_int64value((uintptr_t)infoLog);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetShaderInfoLog(shader, bufsize, length, infolog);
+    glContext->hooks->gl.glGetShaderInfoLog(shader, bufSize, length, infoLog);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
         (void *) length,
-        (void *) infolog,
+        (void *) infoLog,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -2699,7 +2698,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
+void GLTrace_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint * range, GLint * precision) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2747,7 +2746,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) {
+void GLTrace_glGetShaderSource(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2759,11 +2758,11 @@
     arg_shader->set_type(GLMessage::DataType::INT);
     arg_shader->add_intvalue(shader);
 
-    // copy argument bufsize
-    GLMessage_DataType *arg_bufsize = glmsg.add_args();
-    arg_bufsize->set_isarray(false);
-    arg_bufsize->set_type(GLMessage::DataType::INT);
-    arg_bufsize->add_intvalue(bufsize);
+    // copy argument bufSize
+    GLMessage_DataType *arg_bufSize = glmsg.add_args();
+    arg_bufSize->set_isarray(false);
+    arg_bufSize->set_type(GLMessage::DataType::INT);
+    arg_bufSize->add_intvalue(bufSize);
 
     // copy argument length
     GLMessage_DataType *arg_length = glmsg.add_args();
@@ -2780,7 +2779,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetShaderSource(shader, bufsize, length, source);
+    glContext->hooks->gl.glGetShaderSource(shader, bufSize, length, source);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -2795,7 +2794,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-const GLubyte* GLTrace_glGetString(GLenum name) {
+const GLubyte * GLTrace_glGetString(GLenum name) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2810,7 +2809,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    const GLubyte* retValue = glContext->hooks->gl.glGetString(name);
+    const GLubyte * retValue = glContext->hooks->gl.glGetString(name);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -2832,7 +2831,7 @@
     return retValue;
 }
 
-void GLTrace_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) {
+void GLTrace_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2873,7 +2872,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) {
+void GLTrace_glGetTexParameteriv(GLenum target, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2914,7 +2913,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetUniformfv(GLuint program, GLint location, GLfloat* params) {
+void GLTrace_glGetUniformfv(GLuint program, GLint location, GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2955,7 +2954,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetUniformiv(GLuint program, GLint location, GLint* params) {
+void GLTrace_glGetUniformiv(GLuint program, GLint location, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -2996,7 +2995,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-GLint GLTrace_glGetUniformLocation(GLuint program, const GLchar* name) {
+GLint GLTrace_glGetUniformLocation(GLuint program, const GLchar * name) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -3039,7 +3038,7 @@
     return retValue;
 }
 
-void GLTrace_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) {
+void GLTrace_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -3080,7 +3079,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) {
+void GLTrace_glGetVertexAttribiv(GLuint index, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -3121,7 +3120,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) {
+void GLTrace_glGetVertexAttribPointerv(GLuint index, GLenum pname, void ** pointer) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -3572,7 +3571,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) {
+void GLTrace_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -3785,17 +3784,17 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length) {
+void GLTrace_glShaderBinary(GLsizei count, const GLuint * shaders, GLenum binaryformat, const void * binary, GLsizei length) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glShaderBinary);
 
-    // copy argument n
-    GLMessage_DataType *arg_n = glmsg.add_args();
-    arg_n->set_isarray(false);
-    arg_n->set_type(GLMessage::DataType::INT);
-    arg_n->add_intvalue(n);
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
 
     // copy argument shaders
     GLMessage_DataType *arg_shaders = glmsg.add_args();
@@ -3824,7 +3823,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glShaderBinary(n, shaders, binaryformat, binary, length);
+    glContext->hooks->gl.glShaderBinary(count, shaders, binaryformat, binary, length);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -3839,7 +3838,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) {
+void GLTrace_glShaderSource(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4075,7 +4074,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) {
+void GLTrace_glStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4087,28 +4086,28 @@
     arg_face->set_type(GLMessage::DataType::ENUM);
     arg_face->add_intvalue((int)face);
 
-    // copy argument fail
-    GLMessage_DataType *arg_fail = glmsg.add_args();
-    arg_fail->set_isarray(false);
-    arg_fail->set_type(GLMessage::DataType::ENUM);
-    arg_fail->add_intvalue((int)fail);
+    // copy argument sfail
+    GLMessage_DataType *arg_sfail = glmsg.add_args();
+    arg_sfail->set_isarray(false);
+    arg_sfail->set_type(GLMessage::DataType::ENUM);
+    arg_sfail->add_intvalue((int)sfail);
 
-    // copy argument zfail
-    GLMessage_DataType *arg_zfail = glmsg.add_args();
-    arg_zfail->set_isarray(false);
-    arg_zfail->set_type(GLMessage::DataType::ENUM);
-    arg_zfail->add_intvalue((int)zfail);
+    // copy argument dpfail
+    GLMessage_DataType *arg_dpfail = glmsg.add_args();
+    arg_dpfail->set_isarray(false);
+    arg_dpfail->set_type(GLMessage::DataType::ENUM);
+    arg_dpfail->add_intvalue((int)dpfail);
 
-    // copy argument zpass
-    GLMessage_DataType *arg_zpass = glmsg.add_args();
-    arg_zpass->set_isarray(false);
-    arg_zpass->set_type(GLMessage::DataType::ENUM);
-    arg_zpass->add_intvalue((int)zpass);
+    // copy argument dppass
+    GLMessage_DataType *arg_dppass = glmsg.add_args();
+    arg_dppass->set_isarray(false);
+    arg_dppass->set_type(GLMessage::DataType::ENUM);
+    arg_dppass->add_intvalue((int)dppass);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glStencilOpSeparate(face, fail, zfail, zpass);
+    glContext->hooks->gl.glStencilOpSeparate(face, sfail, dpfail, dppass);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -4121,7 +4120,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels) {
+void GLTrace_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4238,7 +4237,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) {
+void GLTrace_glTexParameterfv(GLenum target, GLenum pname, const GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4319,7 +4318,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexParameteriv(GLenum target, GLenum pname, const GLint* params) {
+void GLTrace_glTexParameteriv(GLenum target, GLenum pname, const GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4360,7 +4359,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) {
+void GLTrace_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4437,7 +4436,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform1f(GLint location, GLfloat x) {
+void GLTrace_glUniform1f(GLint location, GLfloat v0) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4449,16 +4448,16 @@
     arg_location->set_type(GLMessage::DataType::INT);
     arg_location->add_intvalue(location);
 
-    // copy argument x
-    GLMessage_DataType *arg_x = glmsg.add_args();
-    arg_x->set_isarray(false);
-    arg_x->set_type(GLMessage::DataType::FLOAT);
-    arg_x->add_floatvalue(x);
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::FLOAT);
+    arg_v0->add_floatvalue(v0);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUniform1f(location, x);
+    glContext->hooks->gl.glUniform1f(location, v0);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -4471,7 +4470,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform1fv(GLint location, GLsizei count, const GLfloat* v) {
+void GLTrace_glUniform1fv(GLint location, GLsizei count, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4489,21 +4488,21 @@
     arg_count->set_type(GLMessage::DataType::INT);
     arg_count->add_intvalue(count);
 
-    // copy argument v
-    GLMessage_DataType *arg_v = glmsg.add_args();
-    arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT64);
-    arg_v->add_int64value((uintptr_t)v);
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUniform1fv(location, count, v);
+    glContext->hooks->gl.glUniform1fv(location, count, value);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) v,
+        (void *) value,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -4512,7 +4511,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform1i(GLint location, GLint x) {
+void GLTrace_glUniform1i(GLint location, GLint v0) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4524,16 +4523,16 @@
     arg_location->set_type(GLMessage::DataType::INT);
     arg_location->add_intvalue(location);
 
-    // copy argument x
-    GLMessage_DataType *arg_x = glmsg.add_args();
-    arg_x->set_isarray(false);
-    arg_x->set_type(GLMessage::DataType::INT);
-    arg_x->add_intvalue(x);
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUniform1i(location, x);
+    glContext->hooks->gl.glUniform1i(location, v0);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -4546,7 +4545,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform1iv(GLint location, GLsizei count, const GLint* v) {
+void GLTrace_glUniform1iv(GLint location, GLsizei count, const GLint * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4564,21 +4563,21 @@
     arg_count->set_type(GLMessage::DataType::INT);
     arg_count->add_intvalue(count);
 
-    // copy argument v
-    GLMessage_DataType *arg_v = glmsg.add_args();
-    arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT64);
-    arg_v->add_int64value((uintptr_t)v);
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUniform1iv(location, count, v);
+    glContext->hooks->gl.glUniform1iv(location, count, value);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) v,
+        (void *) value,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -4587,7 +4586,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform2f(GLint location, GLfloat x, GLfloat y) {
+void GLTrace_glUniform2f(GLint location, GLfloat v0, GLfloat v1) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4599,22 +4598,22 @@
     arg_location->set_type(GLMessage::DataType::INT);
     arg_location->add_intvalue(location);
 
-    // copy argument x
-    GLMessage_DataType *arg_x = glmsg.add_args();
-    arg_x->set_isarray(false);
-    arg_x->set_type(GLMessage::DataType::FLOAT);
-    arg_x->add_floatvalue(x);
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::FLOAT);
+    arg_v0->add_floatvalue(v0);
 
-    // copy argument y
-    GLMessage_DataType *arg_y = glmsg.add_args();
-    arg_y->set_isarray(false);
-    arg_y->set_type(GLMessage::DataType::FLOAT);
-    arg_y->add_floatvalue(y);
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::FLOAT);
+    arg_v1->add_floatvalue(v1);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUniform2f(location, x, y);
+    glContext->hooks->gl.glUniform2f(location, v0, v1);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -4627,7 +4626,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform2fv(GLint location, GLsizei count, const GLfloat* v) {
+void GLTrace_glUniform2fv(GLint location, GLsizei count, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4645,21 +4644,21 @@
     arg_count->set_type(GLMessage::DataType::INT);
     arg_count->add_intvalue(count);
 
-    // copy argument v
-    GLMessage_DataType *arg_v = glmsg.add_args();
-    arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT64);
-    arg_v->add_int64value((uintptr_t)v);
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUniform2fv(location, count, v);
+    glContext->hooks->gl.glUniform2fv(location, count, value);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) v,
+        (void *) value,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -4668,7 +4667,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform2i(GLint location, GLint x, GLint y) {
+void GLTrace_glUniform2i(GLint location, GLint v0, GLint v1) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4680,22 +4679,22 @@
     arg_location->set_type(GLMessage::DataType::INT);
     arg_location->add_intvalue(location);
 
-    // copy argument x
-    GLMessage_DataType *arg_x = glmsg.add_args();
-    arg_x->set_isarray(false);
-    arg_x->set_type(GLMessage::DataType::INT);
-    arg_x->add_intvalue(x);
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
 
-    // copy argument y
-    GLMessage_DataType *arg_y = glmsg.add_args();
-    arg_y->set_isarray(false);
-    arg_y->set_type(GLMessage::DataType::INT);
-    arg_y->add_intvalue(y);
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::INT);
+    arg_v1->add_intvalue(v1);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUniform2i(location, x, y);
+    glContext->hooks->gl.glUniform2i(location, v0, v1);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -4708,7 +4707,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform2iv(GLint location, GLsizei count, const GLint* v) {
+void GLTrace_glUniform2iv(GLint location, GLsizei count, const GLint * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4726,21 +4725,21 @@
     arg_count->set_type(GLMessage::DataType::INT);
     arg_count->add_intvalue(count);
 
-    // copy argument v
-    GLMessage_DataType *arg_v = glmsg.add_args();
-    arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT64);
-    arg_v->add_int64value((uintptr_t)v);
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUniform2iv(location, count, v);
+    glContext->hooks->gl.glUniform2iv(location, count, value);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) v,
+        (void *) value,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -4749,7 +4748,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) {
+void GLTrace_glUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4761,28 +4760,28 @@
     arg_location->set_type(GLMessage::DataType::INT);
     arg_location->add_intvalue(location);
 
-    // copy argument x
-    GLMessage_DataType *arg_x = glmsg.add_args();
-    arg_x->set_isarray(false);
-    arg_x->set_type(GLMessage::DataType::FLOAT);
-    arg_x->add_floatvalue(x);
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::FLOAT);
+    arg_v0->add_floatvalue(v0);
 
-    // copy argument y
-    GLMessage_DataType *arg_y = glmsg.add_args();
-    arg_y->set_isarray(false);
-    arg_y->set_type(GLMessage::DataType::FLOAT);
-    arg_y->add_floatvalue(y);
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::FLOAT);
+    arg_v1->add_floatvalue(v1);
 
-    // copy argument z
-    GLMessage_DataType *arg_z = glmsg.add_args();
-    arg_z->set_isarray(false);
-    arg_z->set_type(GLMessage::DataType::FLOAT);
-    arg_z->add_floatvalue(z);
+    // copy argument v2
+    GLMessage_DataType *arg_v2 = glmsg.add_args();
+    arg_v2->set_isarray(false);
+    arg_v2->set_type(GLMessage::DataType::FLOAT);
+    arg_v2->add_floatvalue(v2);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUniform3f(location, x, y, z);
+    glContext->hooks->gl.glUniform3f(location, v0, v1, v2);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -4795,7 +4794,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform3fv(GLint location, GLsizei count, const GLfloat* v) {
+void GLTrace_glUniform3fv(GLint location, GLsizei count, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4813,21 +4812,21 @@
     arg_count->set_type(GLMessage::DataType::INT);
     arg_count->add_intvalue(count);
 
-    // copy argument v
-    GLMessage_DataType *arg_v = glmsg.add_args();
-    arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT64);
-    arg_v->add_int64value((uintptr_t)v);
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUniform3fv(location, count, v);
+    glContext->hooks->gl.glUniform3fv(location, count, value);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) v,
+        (void *) value,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -4836,7 +4835,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform3i(GLint location, GLint x, GLint y, GLint z) {
+void GLTrace_glUniform3i(GLint location, GLint v0, GLint v1, GLint v2) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4848,28 +4847,28 @@
     arg_location->set_type(GLMessage::DataType::INT);
     arg_location->add_intvalue(location);
 
-    // copy argument x
-    GLMessage_DataType *arg_x = glmsg.add_args();
-    arg_x->set_isarray(false);
-    arg_x->set_type(GLMessage::DataType::INT);
-    arg_x->add_intvalue(x);
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
 
-    // copy argument y
-    GLMessage_DataType *arg_y = glmsg.add_args();
-    arg_y->set_isarray(false);
-    arg_y->set_type(GLMessage::DataType::INT);
-    arg_y->add_intvalue(y);
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::INT);
+    arg_v1->add_intvalue(v1);
 
-    // copy argument z
-    GLMessage_DataType *arg_z = glmsg.add_args();
-    arg_z->set_isarray(false);
-    arg_z->set_type(GLMessage::DataType::INT);
-    arg_z->add_intvalue(z);
+    // copy argument v2
+    GLMessage_DataType *arg_v2 = glmsg.add_args();
+    arg_v2->set_isarray(false);
+    arg_v2->set_type(GLMessage::DataType::INT);
+    arg_v2->add_intvalue(v2);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUniform3i(location, x, y, z);
+    glContext->hooks->gl.glUniform3i(location, v0, v1, v2);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -4882,7 +4881,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform3iv(GLint location, GLsizei count, const GLint* v) {
+void GLTrace_glUniform3iv(GLint location, GLsizei count, const GLint * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4900,21 +4899,21 @@
     arg_count->set_type(GLMessage::DataType::INT);
     arg_count->add_intvalue(count);
 
-    // copy argument v
-    GLMessage_DataType *arg_v = glmsg.add_args();
-    arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT64);
-    arg_v->add_int64value((uintptr_t)v);
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUniform3iv(location, count, v);
+    glContext->hooks->gl.glUniform3iv(location, count, value);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) v,
+        (void *) value,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -4923,7 +4922,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
+void GLTrace_glUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4935,34 +4934,34 @@
     arg_location->set_type(GLMessage::DataType::INT);
     arg_location->add_intvalue(location);
 
-    // copy argument x
-    GLMessage_DataType *arg_x = glmsg.add_args();
-    arg_x->set_isarray(false);
-    arg_x->set_type(GLMessage::DataType::FLOAT);
-    arg_x->add_floatvalue(x);
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::FLOAT);
+    arg_v0->add_floatvalue(v0);
 
-    // copy argument y
-    GLMessage_DataType *arg_y = glmsg.add_args();
-    arg_y->set_isarray(false);
-    arg_y->set_type(GLMessage::DataType::FLOAT);
-    arg_y->add_floatvalue(y);
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::FLOAT);
+    arg_v1->add_floatvalue(v1);
 
-    // copy argument z
-    GLMessage_DataType *arg_z = glmsg.add_args();
-    arg_z->set_isarray(false);
-    arg_z->set_type(GLMessage::DataType::FLOAT);
-    arg_z->add_floatvalue(z);
+    // copy argument v2
+    GLMessage_DataType *arg_v2 = glmsg.add_args();
+    arg_v2->set_isarray(false);
+    arg_v2->set_type(GLMessage::DataType::FLOAT);
+    arg_v2->add_floatvalue(v2);
 
-    // copy argument w
-    GLMessage_DataType *arg_w = glmsg.add_args();
-    arg_w->set_isarray(false);
-    arg_w->set_type(GLMessage::DataType::FLOAT);
-    arg_w->add_floatvalue(w);
+    // copy argument v3
+    GLMessage_DataType *arg_v3 = glmsg.add_args();
+    arg_v3->set_isarray(false);
+    arg_v3->set_type(GLMessage::DataType::FLOAT);
+    arg_v3->add_floatvalue(v3);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUniform4f(location, x, y, z, w);
+    glContext->hooks->gl.glUniform4f(location, v0, v1, v2, v3);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -4975,7 +4974,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform4fv(GLint location, GLsizei count, const GLfloat* v) {
+void GLTrace_glUniform4fv(GLint location, GLsizei count, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -4993,21 +4992,21 @@
     arg_count->set_type(GLMessage::DataType::INT);
     arg_count->add_intvalue(count);
 
-    // copy argument v
-    GLMessage_DataType *arg_v = glmsg.add_args();
-    arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT64);
-    arg_v->add_int64value((uintptr_t)v);
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUniform4fv(location, count, v);
+    glContext->hooks->gl.glUniform4fv(location, count, value);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) v,
+        (void *) value,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -5016,7 +5015,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) {
+void GLTrace_glUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -5028,34 +5027,34 @@
     arg_location->set_type(GLMessage::DataType::INT);
     arg_location->add_intvalue(location);
 
-    // copy argument x
-    GLMessage_DataType *arg_x = glmsg.add_args();
-    arg_x->set_isarray(false);
-    arg_x->set_type(GLMessage::DataType::INT);
-    arg_x->add_intvalue(x);
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
 
-    // copy argument y
-    GLMessage_DataType *arg_y = glmsg.add_args();
-    arg_y->set_isarray(false);
-    arg_y->set_type(GLMessage::DataType::INT);
-    arg_y->add_intvalue(y);
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::INT);
+    arg_v1->add_intvalue(v1);
 
-    // copy argument z
-    GLMessage_DataType *arg_z = glmsg.add_args();
-    arg_z->set_isarray(false);
-    arg_z->set_type(GLMessage::DataType::INT);
-    arg_z->add_intvalue(z);
+    // copy argument v2
+    GLMessage_DataType *arg_v2 = glmsg.add_args();
+    arg_v2->set_isarray(false);
+    arg_v2->set_type(GLMessage::DataType::INT);
+    arg_v2->add_intvalue(v2);
 
-    // copy argument w
-    GLMessage_DataType *arg_w = glmsg.add_args();
-    arg_w->set_isarray(false);
-    arg_w->set_type(GLMessage::DataType::INT);
-    arg_w->add_intvalue(w);
+    // copy argument v3
+    GLMessage_DataType *arg_v3 = glmsg.add_args();
+    arg_v3->set_isarray(false);
+    arg_v3->set_type(GLMessage::DataType::INT);
+    arg_v3->add_intvalue(v3);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUniform4i(location, x, y, z, w);
+    glContext->hooks->gl.glUniform4i(location, v0, v1, v2, v3);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -5068,7 +5067,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform4iv(GLint location, GLsizei count, const GLint* v) {
+void GLTrace_glUniform4iv(GLint location, GLsizei count, const GLint * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -5086,21 +5085,21 @@
     arg_count->set_type(GLMessage::DataType::INT);
     arg_count->add_intvalue(count);
 
-    // copy argument v
-    GLMessage_DataType *arg_v = glmsg.add_args();
-    arg_v->set_isarray(false);
-    arg_v->set_type(GLMessage::DataType::INT64);
-    arg_v->add_int64value((uintptr_t)v);
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUniform4iv(location, count, v);
+    glContext->hooks->gl.glUniform4iv(location, count, value);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) v,
+        (void *) value,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -5109,7 +5108,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
+void GLTrace_glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -5156,7 +5155,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
+void GLTrace_glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -5203,7 +5202,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
+void GLTrace_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -5306,17 +5305,17 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glVertexAttrib1f(GLuint indx, GLfloat x) {
+void GLTrace_glVertexAttrib1f(GLuint index, GLfloat x) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glVertexAttrib1f);
 
-    // copy argument indx
-    GLMessage_DataType *arg_indx = glmsg.add_args();
-    arg_indx->set_isarray(false);
-    arg_indx->set_type(GLMessage::DataType::INT);
-    arg_indx->add_intvalue(indx);
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
 
     // copy argument x
     GLMessage_DataType *arg_x = glmsg.add_args();
@@ -5327,7 +5326,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glVertexAttrib1f(indx, x);
+    glContext->hooks->gl.glVertexAttrib1f(index, x);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -5340,33 +5339,33 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glVertexAttrib1fv(GLuint indx, const GLfloat* values) {
+void GLTrace_glVertexAttrib1fv(GLuint index, const GLfloat * v) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glVertexAttrib1fv);
 
-    // copy argument indx
-    GLMessage_DataType *arg_indx = glmsg.add_args();
-    arg_indx->set_isarray(false);
-    arg_indx->set_type(GLMessage::DataType::INT);
-    arg_indx->add_intvalue(indx);
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
 
-    // copy argument values
-    GLMessage_DataType *arg_values = glmsg.add_args();
-    arg_values->set_isarray(false);
-    arg_values->set_type(GLMessage::DataType::INT64);
-    arg_values->add_int64value((uintptr_t)values);
+    // copy argument v
+    GLMessage_DataType *arg_v = glmsg.add_args();
+    arg_v->set_isarray(false);
+    arg_v->set_type(GLMessage::DataType::INT64);
+    arg_v->add_int64value((uintptr_t)v);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glVertexAttrib1fv(indx, values);
+    glContext->hooks->gl.glVertexAttrib1fv(index, v);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) values,
+        (void *) v,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -5375,17 +5374,17 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) {
+void GLTrace_glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glVertexAttrib2f);
 
-    // copy argument indx
-    GLMessage_DataType *arg_indx = glmsg.add_args();
-    arg_indx->set_isarray(false);
-    arg_indx->set_type(GLMessage::DataType::INT);
-    arg_indx->add_intvalue(indx);
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
 
     // copy argument x
     GLMessage_DataType *arg_x = glmsg.add_args();
@@ -5402,7 +5401,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glVertexAttrib2f(indx, x, y);
+    glContext->hooks->gl.glVertexAttrib2f(index, x, y);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -5415,33 +5414,33 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glVertexAttrib2fv(GLuint indx, const GLfloat* values) {
+void GLTrace_glVertexAttrib2fv(GLuint index, const GLfloat * v) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glVertexAttrib2fv);
 
-    // copy argument indx
-    GLMessage_DataType *arg_indx = glmsg.add_args();
-    arg_indx->set_isarray(false);
-    arg_indx->set_type(GLMessage::DataType::INT);
-    arg_indx->add_intvalue(indx);
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
 
-    // copy argument values
-    GLMessage_DataType *arg_values = glmsg.add_args();
-    arg_values->set_isarray(false);
-    arg_values->set_type(GLMessage::DataType::INT64);
-    arg_values->add_int64value((uintptr_t)values);
+    // copy argument v
+    GLMessage_DataType *arg_v = glmsg.add_args();
+    arg_v->set_isarray(false);
+    arg_v->set_type(GLMessage::DataType::INT64);
+    arg_v->add_int64value((uintptr_t)v);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glVertexAttrib2fv(indx, values);
+    glContext->hooks->gl.glVertexAttrib2fv(index, v);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) values,
+        (void *) v,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -5450,17 +5449,17 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) {
+void GLTrace_glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glVertexAttrib3f);
 
-    // copy argument indx
-    GLMessage_DataType *arg_indx = glmsg.add_args();
-    arg_indx->set_isarray(false);
-    arg_indx->set_type(GLMessage::DataType::INT);
-    arg_indx->add_intvalue(indx);
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
 
     // copy argument x
     GLMessage_DataType *arg_x = glmsg.add_args();
@@ -5483,7 +5482,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glVertexAttrib3f(indx, x, y, z);
+    glContext->hooks->gl.glVertexAttrib3f(index, x, y, z);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -5496,33 +5495,33 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glVertexAttrib3fv(GLuint indx, const GLfloat* values) {
+void GLTrace_glVertexAttrib3fv(GLuint index, const GLfloat * v) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glVertexAttrib3fv);
 
-    // copy argument indx
-    GLMessage_DataType *arg_indx = glmsg.add_args();
-    arg_indx->set_isarray(false);
-    arg_indx->set_type(GLMessage::DataType::INT);
-    arg_indx->add_intvalue(indx);
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
 
-    // copy argument values
-    GLMessage_DataType *arg_values = glmsg.add_args();
-    arg_values->set_isarray(false);
-    arg_values->set_type(GLMessage::DataType::INT64);
-    arg_values->add_int64value((uintptr_t)values);
+    // copy argument v
+    GLMessage_DataType *arg_v = glmsg.add_args();
+    arg_v->set_isarray(false);
+    arg_v->set_type(GLMessage::DataType::INT64);
+    arg_v->add_int64value((uintptr_t)v);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glVertexAttrib3fv(indx, values);
+    glContext->hooks->gl.glVertexAttrib3fv(index, v);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) values,
+        (void *) v,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -5531,17 +5530,17 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
+void GLTrace_glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glVertexAttrib4f);
 
-    // copy argument indx
-    GLMessage_DataType *arg_indx = glmsg.add_args();
-    arg_indx->set_isarray(false);
-    arg_indx->set_type(GLMessage::DataType::INT);
-    arg_indx->add_intvalue(indx);
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
 
     // copy argument x
     GLMessage_DataType *arg_x = glmsg.add_args();
@@ -5570,7 +5569,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glVertexAttrib4f(indx, x, y, z, w);
+    glContext->hooks->gl.glVertexAttrib4f(index, x, y, z, w);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -5583,33 +5582,33 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glVertexAttrib4fv(GLuint indx, const GLfloat* values) {
+void GLTrace_glVertexAttrib4fv(GLuint index, const GLfloat * v) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glVertexAttrib4fv);
 
-    // copy argument indx
-    GLMessage_DataType *arg_indx = glmsg.add_args();
-    arg_indx->set_isarray(false);
-    arg_indx->set_type(GLMessage::DataType::INT);
-    arg_indx->add_intvalue(indx);
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
 
-    // copy argument values
-    GLMessage_DataType *arg_values = glmsg.add_args();
-    arg_values->set_isarray(false);
-    arg_values->set_type(GLMessage::DataType::INT64);
-    arg_values->add_int64value((uintptr_t)values);
+    // copy argument v
+    GLMessage_DataType *arg_v = glmsg.add_args();
+    arg_v->set_isarray(false);
+    arg_v->set_type(GLMessage::DataType::INT64);
+    arg_v->add_int64value((uintptr_t)v);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glVertexAttrib4fv(indx, values);
+    glContext->hooks->gl.glVertexAttrib4fv(index, v);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) values,
+        (void *) v,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -5618,17 +5617,17 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr) {
+void GLTrace_glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glVertexAttribPointer);
 
-    // copy argument indx
-    GLMessage_DataType *arg_indx = glmsg.add_args();
-    arg_indx->set_isarray(false);
-    arg_indx->set_type(GLMessage::DataType::INT);
-    arg_indx->add_intvalue(indx);
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
 
     // copy argument size
     GLMessage_DataType *arg_size = glmsg.add_args();
@@ -5654,21 +5653,21 @@
     arg_stride->set_type(GLMessage::DataType::INT);
     arg_stride->add_intvalue(stride);
 
-    // copy argument ptr
-    GLMessage_DataType *arg_ptr = glmsg.add_args();
-    arg_ptr->set_isarray(false);
-    arg_ptr->set_type(GLMessage::DataType::INT64);
-    arg_ptr->add_int64value((uintptr_t)ptr);
+    // copy argument pointer
+    GLMessage_DataType *arg_pointer = glmsg.add_args();
+    arg_pointer->set_isarray(false);
+    arg_pointer->set_type(GLMessage::DataType::INT64);
+    arg_pointer->add_int64value((uintptr_t)pointer);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
+    glContext->hooks->gl.glVertexAttribPointer(index, size, type, normalized, stride, pointer);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) ptr,
+        (void *) pointer,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -5751,7 +5750,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) {
+void GLTrace_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -5810,7 +5809,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) {
+void GLTrace_glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -5893,7 +5892,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) {
+void GLTrace_glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -6058,7 +6057,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) {
+void GLTrace_glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -6135,7 +6134,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) {
+void GLTrace_glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -6224,7 +6223,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGenQueries(GLsizei n, GLuint* ids) {
+void GLTrace_glGenQueries(GLsizei n, GLuint * ids) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -6259,7 +6258,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDeleteQueries(GLsizei n, const GLuint* ids) {
+void GLTrace_glDeleteQueries(GLsizei n, const GLuint * ids) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -6392,7 +6391,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetQueryiv(GLenum target, GLenum pname, GLint* params) {
+void GLTrace_glGetQueryiv(GLenum target, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -6433,7 +6432,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) {
+void GLTrace_glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -6510,7 +6509,7 @@
     return retValue;
 }
 
-void GLTrace_glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) {
+void GLTrace_glGetBufferPointerv(GLenum target, GLenum pname, void ** params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -6551,7 +6550,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDrawBuffers(GLsizei n, const GLenum* bufs) {
+void GLTrace_glDrawBuffers(GLsizei n, const GLenum * bufs) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -6586,7 +6585,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
+void GLTrace_glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -6633,7 +6632,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
+void GLTrace_glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -6680,7 +6679,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
+void GLTrace_glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -6727,7 +6726,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
+void GLTrace_glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -6774,7 +6773,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
+void GLTrace_glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -6821,7 +6820,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
+void GLTrace_glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -7054,7 +7053,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-GLvoid* GLTrace_glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
+void * GLTrace_glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -7087,7 +7086,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    GLvoid* retValue = glContext->hooks->gl.glMapBufferRange(target, offset, length, access);
+    void * retValue = glContext->hooks->gl.glMapBufferRange(target, offset, length, access);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -7177,7 +7176,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDeleteVertexArrays(GLsizei n, const GLuint* arrays) {
+void GLTrace_glDeleteVertexArrays(GLsizei n, const GLuint * arrays) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -7212,7 +7211,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGenVertexArrays(GLsizei n, GLuint* arrays) {
+void GLTrace_glGenVertexArrays(GLsizei n, GLuint * arrays) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -7283,7 +7282,7 @@
     return retValue;
 }
 
-void GLTrace_glGetIntegeri_v(GLenum target, GLuint index, GLint* data) {
+void GLTrace_glGetIntegeri_v(GLenum target, GLuint index, GLint * data) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -7466,7 +7465,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) {
+void GLTrace_glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -7513,7 +7512,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) {
+void GLTrace_glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -7581,7 +7580,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) {
+void GLTrace_glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -7634,7 +7633,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) {
+void GLTrace_glGetVertexAttribIiv(GLuint index, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -7675,7 +7674,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) {
+void GLTrace_glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -7820,7 +7819,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glVertexAttribI4iv(GLuint index, const GLint* v) {
+void GLTrace_glVertexAttribI4iv(GLuint index, const GLint * v) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -7855,7 +7854,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glVertexAttribI4uiv(GLuint index, const GLuint* v) {
+void GLTrace_glVertexAttribI4uiv(GLuint index, const GLuint * v) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -7890,7 +7889,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetUniformuiv(GLuint program, GLint location, GLuint* params) {
+void GLTrace_glGetUniformuiv(GLuint program, GLint location, GLuint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -7931,7 +7930,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-GLint GLTrace_glGetFragDataLocation(GLuint program, const GLchar *name) {
+GLint GLTrace_glGetFragDataLocation(GLuint program, const GLchar * name) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -8146,7 +8145,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform1uiv(GLint location, GLsizei count, const GLuint* value) {
+void GLTrace_glUniform1uiv(GLint location, GLsizei count, const GLuint * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -8187,7 +8186,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform2uiv(GLint location, GLsizei count, const GLuint* value) {
+void GLTrace_glUniform2uiv(GLint location, GLsizei count, const GLuint * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -8228,7 +8227,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform3uiv(GLint location, GLsizei count, const GLuint* value) {
+void GLTrace_glUniform3uiv(GLint location, GLsizei count, const GLuint * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -8269,7 +8268,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUniform4uiv(GLint location, GLsizei count, const GLuint* value) {
+void GLTrace_glUniform4uiv(GLint location, GLsizei count, const GLuint * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -8310,7 +8309,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) {
+void GLTrace_glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -8351,7 +8350,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) {
+void GLTrace_glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -8392,7 +8391,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) {
+void GLTrace_glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -8479,7 +8478,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-const GLubyte* GLTrace_glGetStringi(GLenum name, GLuint index) {
+const GLubyte * GLTrace_glGetStringi(GLenum name, GLuint index) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -8500,7 +8499,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    const GLubyte* retValue = glContext->hooks->gl.glGetStringi(name, index);
+    const GLubyte * retValue = glContext->hooks->gl.glGetStringi(name, index);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -8574,7 +8573,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) {
+void GLTrace_glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -8622,7 +8621,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) {
+void GLTrace_glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -8676,7 +8675,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-GLuint GLTrace_glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) {
+GLuint GLTrace_glGetUniformBlockIndex(GLuint program, const GLchar * uniformBlockName) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -8719,7 +8718,7 @@
     return retValue;
 }
 
-void GLTrace_glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) {
+void GLTrace_glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -8766,7 +8765,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) {
+void GLTrace_glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -8860,7 +8859,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) {
+void GLTrace_glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instancecount) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -8884,16 +8883,16 @@
     arg_count->set_type(GLMessage::DataType::INT);
     arg_count->add_intvalue(count);
 
-    // copy argument instanceCount
-    GLMessage_DataType *arg_instanceCount = glmsg.add_args();
-    arg_instanceCount->set_isarray(false);
-    arg_instanceCount->set_type(GLMessage::DataType::INT);
-    arg_instanceCount->add_intvalue(instanceCount);
+    // copy argument instancecount
+    GLMessage_DataType *arg_instancecount = glmsg.add_args();
+    arg_instancecount->set_isarray(false);
+    arg_instancecount->set_type(GLMessage::DataType::INT);
+    arg_instancecount->add_intvalue(instancecount);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glDrawArraysInstanced(mode, first, count, instanceCount);
+    glContext->hooks->gl.glDrawArraysInstanced(mode, first, count, instancecount);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -8906,7 +8905,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) {
+void GLTrace_glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -8936,16 +8935,16 @@
     arg_indices->set_type(GLMessage::DataType::INT64);
     arg_indices->add_int64value((uintptr_t)indices);
 
-    // copy argument instanceCount
-    GLMessage_DataType *arg_instanceCount = glmsg.add_args();
-    arg_instanceCount->set_isarray(false);
-    arg_instanceCount->set_type(GLMessage::DataType::INT);
-    arg_instanceCount->add_intvalue(instanceCount);
+    // copy argument instancecount
+    GLMessage_DataType *arg_instancecount = glmsg.add_args();
+    arg_instancecount->set_isarray(false);
+    arg_instancecount->set_type(GLMessage::DataType::INT);
+    arg_instancecount->add_intvalue(instancecount);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glDrawElementsInstanced(mode, count, type, indices, instanceCount);
+    glContext->hooks->gl.glDrawElementsInstanced(mode, count, type, indices, instancecount);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -9158,7 +9157,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetInteger64v(GLenum pname, GLint64* params) {
+void GLTrace_glGetInteger64v(GLenum pname, GLint64 * data) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -9170,21 +9169,21 @@
     arg_pname->set_type(GLMessage::DataType::ENUM);
     arg_pname->add_intvalue((int)pname);
 
-    // copy argument params
-    GLMessage_DataType *arg_params = glmsg.add_args();
-    arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT64);
-    arg_params->add_int64value((uintptr_t)params);
+    // copy argument data
+    GLMessage_DataType *arg_data = glmsg.add_args();
+    arg_data->set_isarray(false);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetInteger64v(pname, params);
+    glContext->hooks->gl.glGetInteger64v(pname, data);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) params,
+        (void *) data,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -9193,7 +9192,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) {
+void GLTrace_glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -9248,7 +9247,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) {
+void GLTrace_glGetInteger64i_v(GLenum target, GLuint index, GLint64 * data) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -9289,7 +9288,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) {
+void GLTrace_glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64 * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -9330,7 +9329,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGenSamplers(GLsizei count, GLuint* samplers) {
+void GLTrace_glGenSamplers(GLsizei count, GLuint * samplers) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -9365,7 +9364,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDeleteSamplers(GLsizei count, const GLuint* samplers) {
+void GLTrace_glDeleteSamplers(GLsizei count, const GLuint * samplers) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -9510,7 +9509,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) {
+void GLTrace_glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint * param) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -9591,7 +9590,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) {
+void GLTrace_glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat * param) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -9632,7 +9631,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) {
+void GLTrace_glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -9673,7 +9672,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) {
+void GLTrace_glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -9782,7 +9781,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) {
+void GLTrace_glDeleteTransformFeedbacks(GLsizei n, const GLuint * ids) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -9817,7 +9816,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGenTransformFeedbacks(GLsizei n, GLuint* ids) {
+void GLTrace_glGenTransformFeedbacks(GLsizei n, GLuint * ids) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -9932,7 +9931,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) {
+void GLTrace_glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei * length, GLenum * binaryFormat, void * binary) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -9987,7 +9986,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) {
+void GLTrace_glProgramBinary(GLuint program, GLenum binaryFormat, const void * binary, GLsizei length) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -10074,7 +10073,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) {
+void GLTrace_glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum * attachments) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -10115,7 +10114,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) {
+void GLTrace_glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum * attachments, GLint x, GLint y, GLsizei width, GLsizei height) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -10290,7 +10289,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) {
+void GLTrace_glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -10343,9 +10342,3671 @@
     glContext->traceGLMessage(&glmsg);
 }
 
+void GLTrace_glDispatchCompute(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDispatchCompute);
+
+    // copy argument num_groups_x
+    GLMessage_DataType *arg_num_groups_x = glmsg.add_args();
+    arg_num_groups_x->set_isarray(false);
+    arg_num_groups_x->set_type(GLMessage::DataType::INT);
+    arg_num_groups_x->add_intvalue(num_groups_x);
+
+    // copy argument num_groups_y
+    GLMessage_DataType *arg_num_groups_y = glmsg.add_args();
+    arg_num_groups_y->set_isarray(false);
+    arg_num_groups_y->set_type(GLMessage::DataType::INT);
+    arg_num_groups_y->add_intvalue(num_groups_y);
+
+    // copy argument num_groups_z
+    GLMessage_DataType *arg_num_groups_z = glmsg.add_args();
+    arg_num_groups_z->set_isarray(false);
+    arg_num_groups_z->set_type(GLMessage::DataType::INT);
+    arg_num_groups_z->add_intvalue(num_groups_z);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDispatchCompute(num_groups_x, num_groups_y, num_groups_z);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glDispatchComputeIndirect(GLintptr indirect) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDispatchComputeIndirect);
+
+    // copy argument indirect
+    GLMessage_DataType *arg_indirect = glmsg.add_args();
+    arg_indirect->set_isarray(false);
+    arg_indirect->set_type(GLMessage::DataType::INT);
+    arg_indirect->add_intvalue(indirect);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDispatchComputeIndirect(indirect);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glDrawArraysIndirect(GLenum mode, const void * indirect) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDrawArraysIndirect);
+
+    // copy argument mode
+    GLMessage_DataType *arg_mode = glmsg.add_args();
+    arg_mode->set_isarray(false);
+    arg_mode->set_type(GLMessage::DataType::ENUM);
+    arg_mode->add_intvalue((int)mode);
+
+    // copy argument indirect
+    GLMessage_DataType *arg_indirect = glmsg.add_args();
+    arg_indirect->set_isarray(false);
+    arg_indirect->set_type(GLMessage::DataType::INT64);
+    arg_indirect->add_int64value((uintptr_t)indirect);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDrawArraysIndirect(mode, indirect);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) indirect,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glDrawElementsIndirect(GLenum mode, GLenum type, const void * indirect) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDrawElementsIndirect);
+
+    // copy argument mode
+    GLMessage_DataType *arg_mode = glmsg.add_args();
+    arg_mode->set_isarray(false);
+    arg_mode->set_type(GLMessage::DataType::ENUM);
+    arg_mode->add_intvalue((int)mode);
+
+    // copy argument type
+    GLMessage_DataType *arg_type = glmsg.add_args();
+    arg_type->set_isarray(false);
+    arg_type->set_type(GLMessage::DataType::ENUM);
+    arg_type->add_intvalue((int)type);
+
+    // copy argument indirect
+    GLMessage_DataType *arg_indirect = glmsg.add_args();
+    arg_indirect->set_isarray(false);
+    arg_indirect->set_type(GLMessage::DataType::INT64);
+    arg_indirect->add_int64value((uintptr_t)indirect);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDrawElementsIndirect(mode, type, indirect);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) indirect,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glFramebufferParameteri(GLenum target, GLenum pname, GLint param) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glFramebufferParameteri);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument param
+    GLMessage_DataType *arg_param = glmsg.add_args();
+    arg_param->set_isarray(false);
+    arg_param->set_type(GLMessage::DataType::INT);
+    arg_param->add_intvalue(param);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glFramebufferParameteri(target, pname, param);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetFramebufferParameteriv(GLenum target, GLenum pname, GLint * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetFramebufferParameteriv);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetFramebufferParameteriv(target, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetProgramInterfaceiv(GLuint program, GLenum programInterface, GLenum pname, GLint * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetProgramInterfaceiv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument programInterface
+    GLMessage_DataType *arg_programInterface = glmsg.add_args();
+    arg_programInterface->set_isarray(false);
+    arg_programInterface->set_type(GLMessage::DataType::ENUM);
+    arg_programInterface->add_intvalue((int)programInterface);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetProgramInterfaceiv(program, programInterface, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+GLuint GLTrace_glGetProgramResourceIndex(GLuint program, GLenum programInterface, const GLchar * name) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetProgramResourceIndex);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument programInterface
+    GLMessage_DataType *arg_programInterface = glmsg.add_args();
+    arg_programInterface->set_isarray(false);
+    arg_programInterface->set_type(GLMessage::DataType::ENUM);
+    arg_programInterface->add_intvalue((int)programInterface);
+
+    // copy argument name
+    GLMessage_DataType *arg_name = glmsg.add_args();
+    arg_name->set_isarray(false);
+    arg_name->set_type(GLMessage::DataType::INT64);
+    arg_name->add_int64value((uintptr_t)name);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    GLuint retValue = glContext->hooks->gl.glGetProgramResourceIndex(program, programInterface, name);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    // set return value
+    GLMessage_DataType *rt = glmsg.mutable_returnvalue();
+    rt->set_isarray(false);
+    rt->set_type(GLMessage::DataType::INT);
+    rt->add_intvalue(retValue);
+
+    void *pointerArgs[] = {
+        (void *) name,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+
+    return retValue;
+}
+
+void GLTrace_glGetProgramResourceName(GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei * length, GLchar * name) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetProgramResourceName);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument programInterface
+    GLMessage_DataType *arg_programInterface = glmsg.add_args();
+    arg_programInterface->set_isarray(false);
+    arg_programInterface->set_type(GLMessage::DataType::ENUM);
+    arg_programInterface->add_intvalue((int)programInterface);
+
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
+
+    // copy argument bufSize
+    GLMessage_DataType *arg_bufSize = glmsg.add_args();
+    arg_bufSize->set_isarray(false);
+    arg_bufSize->set_type(GLMessage::DataType::INT);
+    arg_bufSize->add_intvalue(bufSize);
+
+    // copy argument length
+    GLMessage_DataType *arg_length = glmsg.add_args();
+    arg_length->set_isarray(false);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
+
+    // copy argument name
+    GLMessage_DataType *arg_name = glmsg.add_args();
+    arg_name->set_isarray(false);
+    arg_name->set_type(GLMessage::DataType::INT64);
+    arg_name->add_int64value((uintptr_t)name);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetProgramResourceName(program, programInterface, index, bufSize, length, name);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) length,
+        (void *) name,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetProgramResourceiv(GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum * props, GLsizei bufSize, GLsizei * length, GLint * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetProgramResourceiv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument programInterface
+    GLMessage_DataType *arg_programInterface = glmsg.add_args();
+    arg_programInterface->set_isarray(false);
+    arg_programInterface->set_type(GLMessage::DataType::ENUM);
+    arg_programInterface->add_intvalue((int)programInterface);
+
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
+
+    // copy argument propCount
+    GLMessage_DataType *arg_propCount = glmsg.add_args();
+    arg_propCount->set_isarray(false);
+    arg_propCount->set_type(GLMessage::DataType::INT);
+    arg_propCount->add_intvalue(propCount);
+
+    // copy argument props
+    GLMessage_DataType *arg_props = glmsg.add_args();
+    arg_props->set_isarray(false);
+    arg_props->set_type(GLMessage::DataType::INT64);
+    arg_props->add_int64value((uintptr_t)props);
+
+    // copy argument bufSize
+    GLMessage_DataType *arg_bufSize = glmsg.add_args();
+    arg_bufSize->set_isarray(false);
+    arg_bufSize->set_type(GLMessage::DataType::INT);
+    arg_bufSize->add_intvalue(bufSize);
+
+    // copy argument length
+    GLMessage_DataType *arg_length = glmsg.add_args();
+    arg_length->set_isarray(false);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetProgramResourceiv(program, programInterface, index, propCount, props, bufSize, length, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) props,
+        (void *) length,
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+GLint GLTrace_glGetProgramResourceLocation(GLuint program, GLenum programInterface, const GLchar * name) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetProgramResourceLocation);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument programInterface
+    GLMessage_DataType *arg_programInterface = glmsg.add_args();
+    arg_programInterface->set_isarray(false);
+    arg_programInterface->set_type(GLMessage::DataType::ENUM);
+    arg_programInterface->add_intvalue((int)programInterface);
+
+    // copy argument name
+    GLMessage_DataType *arg_name = glmsg.add_args();
+    arg_name->set_isarray(false);
+    arg_name->set_type(GLMessage::DataType::INT64);
+    arg_name->add_int64value((uintptr_t)name);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    GLint retValue = glContext->hooks->gl.glGetProgramResourceLocation(program, programInterface, name);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    // set return value
+    GLMessage_DataType *rt = glmsg.mutable_returnvalue();
+    rt->set_isarray(false);
+    rt->set_type(GLMessage::DataType::INT);
+    rt->add_intvalue(retValue);
+
+    void *pointerArgs[] = {
+        (void *) name,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+
+    return retValue;
+}
+
+void GLTrace_glUseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glUseProgramStages);
+
+    // copy argument pipeline
+    GLMessage_DataType *arg_pipeline = glmsg.add_args();
+    arg_pipeline->set_isarray(false);
+    arg_pipeline->set_type(GLMessage::DataType::INT);
+    arg_pipeline->add_intvalue(pipeline);
+
+    // copy argument stages
+    GLMessage_DataType *arg_stages = glmsg.add_args();
+    arg_stages->set_isarray(false);
+    arg_stages->set_type(GLMessage::DataType::INT);
+    arg_stages->add_intvalue(stages);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glUseProgramStages(pipeline, stages, program);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glActiveShaderProgram(GLuint pipeline, GLuint program) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glActiveShaderProgram);
+
+    // copy argument pipeline
+    GLMessage_DataType *arg_pipeline = glmsg.add_args();
+    arg_pipeline->set_isarray(false);
+    arg_pipeline->set_type(GLMessage::DataType::INT);
+    arg_pipeline->add_intvalue(pipeline);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glActiveShaderProgram(pipeline, program);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+GLuint GLTrace_glCreateShaderProgramv(GLenum type, GLsizei count, const GLchar *const* strings) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glCreateShaderProgramv);
+
+    // copy argument type
+    GLMessage_DataType *arg_type = glmsg.add_args();
+    arg_type->set_isarray(false);
+    arg_type->set_type(GLMessage::DataType::ENUM);
+    arg_type->add_intvalue((int)type);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument strings
+    GLMessage_DataType *arg_strings = glmsg.add_args();
+    arg_strings->set_isarray(false);
+    arg_strings->set_type(GLMessage::DataType::INT64);
+    arg_strings->add_int64value((uintptr_t)strings);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    GLuint retValue = glContext->hooks->gl.glCreateShaderProgramv(type, count, strings);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    // set return value
+    GLMessage_DataType *rt = glmsg.mutable_returnvalue();
+    rt->set_isarray(false);
+    rt->set_type(GLMessage::DataType::INT);
+    rt->add_intvalue(retValue);
+
+    void *pointerArgs[] = {
+        (void *) strings,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+
+    return retValue;
+}
+
+void GLTrace_glBindProgramPipeline(GLuint pipeline) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glBindProgramPipeline);
+
+    // copy argument pipeline
+    GLMessage_DataType *arg_pipeline = glmsg.add_args();
+    arg_pipeline->set_isarray(false);
+    arg_pipeline->set_type(GLMessage::DataType::INT);
+    arg_pipeline->add_intvalue(pipeline);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glBindProgramPipeline(pipeline);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glDeleteProgramPipelines(GLsizei n, const GLuint * pipelines) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDeleteProgramPipelines);
+
+    // copy argument n
+    GLMessage_DataType *arg_n = glmsg.add_args();
+    arg_n->set_isarray(false);
+    arg_n->set_type(GLMessage::DataType::INT);
+    arg_n->add_intvalue(n);
+
+    // copy argument pipelines
+    GLMessage_DataType *arg_pipelines = glmsg.add_args();
+    arg_pipelines->set_isarray(false);
+    arg_pipelines->set_type(GLMessage::DataType::INT64);
+    arg_pipelines->add_int64value((uintptr_t)pipelines);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDeleteProgramPipelines(n, pipelines);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) pipelines,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGenProgramPipelines(GLsizei n, GLuint * pipelines) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGenProgramPipelines);
+
+    // copy argument n
+    GLMessage_DataType *arg_n = glmsg.add_args();
+    arg_n->set_isarray(false);
+    arg_n->set_type(GLMessage::DataType::INT);
+    arg_n->add_intvalue(n);
+
+    // copy argument pipelines
+    GLMessage_DataType *arg_pipelines = glmsg.add_args();
+    arg_pipelines->set_isarray(false);
+    arg_pipelines->set_type(GLMessage::DataType::INT64);
+    arg_pipelines->add_int64value((uintptr_t)pipelines);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGenProgramPipelines(n, pipelines);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) pipelines,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+GLboolean GLTrace_glIsProgramPipeline(GLuint pipeline) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glIsProgramPipeline);
+
+    // copy argument pipeline
+    GLMessage_DataType *arg_pipeline = glmsg.add_args();
+    arg_pipeline->set_isarray(false);
+    arg_pipeline->set_type(GLMessage::DataType::INT);
+    arg_pipeline->add_intvalue(pipeline);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    GLboolean retValue = glContext->hooks->gl.glIsProgramPipeline(pipeline);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    // set return value
+    GLMessage_DataType *rt = glmsg.mutable_returnvalue();
+    rt->set_isarray(false);
+    rt->set_type(GLMessage::DataType::BOOL);
+    rt->add_boolvalue(retValue);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+
+    return retValue;
+}
+
+void GLTrace_glGetProgramPipelineiv(GLuint pipeline, GLenum pname, GLint * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetProgramPipelineiv);
+
+    // copy argument pipeline
+    GLMessage_DataType *arg_pipeline = glmsg.add_args();
+    arg_pipeline->set_isarray(false);
+    arg_pipeline->set_type(GLMessage::DataType::INT);
+    arg_pipeline->add_intvalue(pipeline);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetProgramPipelineiv(pipeline, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform1i(GLuint program, GLint location, GLint v0) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform1i);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform1i(program, location, v0);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform2i(GLuint program, GLint location, GLint v0, GLint v1) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform2i);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::INT);
+    arg_v1->add_intvalue(v1);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform2i(program, location, v0, v1);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform3i(GLuint program, GLint location, GLint v0, GLint v1, GLint v2) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform3i);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::INT);
+    arg_v1->add_intvalue(v1);
+
+    // copy argument v2
+    GLMessage_DataType *arg_v2 = glmsg.add_args();
+    arg_v2->set_isarray(false);
+    arg_v2->set_type(GLMessage::DataType::INT);
+    arg_v2->add_intvalue(v2);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform3i(program, location, v0, v1, v2);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform4i(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform4i);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::INT);
+    arg_v1->add_intvalue(v1);
+
+    // copy argument v2
+    GLMessage_DataType *arg_v2 = glmsg.add_args();
+    arg_v2->set_isarray(false);
+    arg_v2->set_type(GLMessage::DataType::INT);
+    arg_v2->add_intvalue(v2);
+
+    // copy argument v3
+    GLMessage_DataType *arg_v3 = glmsg.add_args();
+    arg_v3->set_isarray(false);
+    arg_v3->set_type(GLMessage::DataType::INT);
+    arg_v3->add_intvalue(v3);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform4i(program, location, v0, v1, v2, v3);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform1ui(GLuint program, GLint location, GLuint v0) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform1ui);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform1ui(program, location, v0);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform2ui(GLuint program, GLint location, GLuint v0, GLuint v1) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform2ui);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::INT);
+    arg_v1->add_intvalue(v1);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform2ui(program, location, v0, v1);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform3ui(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform3ui);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::INT);
+    arg_v1->add_intvalue(v1);
+
+    // copy argument v2
+    GLMessage_DataType *arg_v2 = glmsg.add_args();
+    arg_v2->set_isarray(false);
+    arg_v2->set_type(GLMessage::DataType::INT);
+    arg_v2->add_intvalue(v2);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform3ui(program, location, v0, v1, v2);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform4ui(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform4ui);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::INT);
+    arg_v1->add_intvalue(v1);
+
+    // copy argument v2
+    GLMessage_DataType *arg_v2 = glmsg.add_args();
+    arg_v2->set_isarray(false);
+    arg_v2->set_type(GLMessage::DataType::INT);
+    arg_v2->add_intvalue(v2);
+
+    // copy argument v3
+    GLMessage_DataType *arg_v3 = glmsg.add_args();
+    arg_v3->set_isarray(false);
+    arg_v3->set_type(GLMessage::DataType::INT);
+    arg_v3->add_intvalue(v3);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform4ui(program, location, v0, v1, v2, v3);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform1f(GLuint program, GLint location, GLfloat v0) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform1f);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::FLOAT);
+    arg_v0->add_floatvalue(v0);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform1f(program, location, v0);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform2f(GLuint program, GLint location, GLfloat v0, GLfloat v1) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform2f);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::FLOAT);
+    arg_v0->add_floatvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::FLOAT);
+    arg_v1->add_floatvalue(v1);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform2f(program, location, v0, v1);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform3f(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform3f);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::FLOAT);
+    arg_v0->add_floatvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::FLOAT);
+    arg_v1->add_floatvalue(v1);
+
+    // copy argument v2
+    GLMessage_DataType *arg_v2 = glmsg.add_args();
+    arg_v2->set_isarray(false);
+    arg_v2->set_type(GLMessage::DataType::FLOAT);
+    arg_v2->add_floatvalue(v2);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform3f(program, location, v0, v1, v2);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform4f(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform4f);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::FLOAT);
+    arg_v0->add_floatvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::FLOAT);
+    arg_v1->add_floatvalue(v1);
+
+    // copy argument v2
+    GLMessage_DataType *arg_v2 = glmsg.add_args();
+    arg_v2->set_isarray(false);
+    arg_v2->set_type(GLMessage::DataType::FLOAT);
+    arg_v2->add_floatvalue(v2);
+
+    // copy argument v3
+    GLMessage_DataType *arg_v3 = glmsg.add_args();
+    arg_v3->set_isarray(false);
+    arg_v3->set_type(GLMessage::DataType::FLOAT);
+    arg_v3->add_floatvalue(v3);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform4f(program, location, v0, v1, v2, v3);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform1iv(GLuint program, GLint location, GLsizei count, const GLint * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform1iv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform1iv(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform2iv(GLuint program, GLint location, GLsizei count, const GLint * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform2iv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform2iv(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform3iv(GLuint program, GLint location, GLsizei count, const GLint * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform3iv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform3iv(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform4iv(GLuint program, GLint location, GLsizei count, const GLint * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform4iv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform4iv(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform1uiv(GLuint program, GLint location, GLsizei count, const GLuint * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform1uiv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform1uiv(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform2uiv(GLuint program, GLint location, GLsizei count, const GLuint * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform2uiv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform2uiv(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform3uiv(GLuint program, GLint location, GLsizei count, const GLuint * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform3uiv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform3uiv(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform4uiv(GLuint program, GLint location, GLsizei count, const GLuint * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform4uiv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform4uiv(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform1fv(GLuint program, GLint location, GLsizei count, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform1fv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform1fv(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform2fv(GLuint program, GLint location, GLsizei count, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform2fv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform2fv(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform3fv(GLuint program, GLint location, GLsizei count, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform3fv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform3fv(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform4fv(GLuint program, GLint location, GLsizei count, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform4fv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform4fv(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniformMatrix2fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniformMatrix2fv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniformMatrix2fv(program, location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniformMatrix3fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniformMatrix3fv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniformMatrix3fv(program, location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniformMatrix4fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniformMatrix4fv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniformMatrix4fv(program, location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniformMatrix2x3fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniformMatrix2x3fv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniformMatrix2x3fv(program, location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniformMatrix3x2fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniformMatrix3x2fv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniformMatrix3x2fv(program, location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniformMatrix2x4fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniformMatrix2x4fv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniformMatrix2x4fv(program, location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniformMatrix4x2fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniformMatrix4x2fv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniformMatrix4x2fv(program, location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniformMatrix3x4fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniformMatrix3x4fv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniformMatrix3x4fv(program, location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniformMatrix4x3fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniformMatrix4x3fv);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniformMatrix4x3fv(program, location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glValidateProgramPipeline(GLuint pipeline) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glValidateProgramPipeline);
+
+    // copy argument pipeline
+    GLMessage_DataType *arg_pipeline = glmsg.add_args();
+    arg_pipeline->set_isarray(false);
+    arg_pipeline->set_type(GLMessage::DataType::INT);
+    arg_pipeline->add_intvalue(pipeline);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glValidateProgramPipeline(pipeline);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetProgramPipelineInfoLog(GLuint pipeline, GLsizei bufSize, GLsizei * length, GLchar * infoLog) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetProgramPipelineInfoLog);
+
+    // copy argument pipeline
+    GLMessage_DataType *arg_pipeline = glmsg.add_args();
+    arg_pipeline->set_isarray(false);
+    arg_pipeline->set_type(GLMessage::DataType::INT);
+    arg_pipeline->add_intvalue(pipeline);
+
+    // copy argument bufSize
+    GLMessage_DataType *arg_bufSize = glmsg.add_args();
+    arg_bufSize->set_isarray(false);
+    arg_bufSize->set_type(GLMessage::DataType::INT);
+    arg_bufSize->add_intvalue(bufSize);
+
+    // copy argument length
+    GLMessage_DataType *arg_length = glmsg.add_args();
+    arg_length->set_isarray(false);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
+
+    // copy argument infoLog
+    GLMessage_DataType *arg_infoLog = glmsg.add_args();
+    arg_infoLog->set_isarray(false);
+    arg_infoLog->set_type(GLMessage::DataType::INT64);
+    arg_infoLog->add_int64value((uintptr_t)infoLog);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetProgramPipelineInfoLog(pipeline, bufSize, length, infoLog);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) length,
+        (void *) infoLog,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glBindImageTexture(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glBindImageTexture);
+
+    // copy argument unit
+    GLMessage_DataType *arg_unit = glmsg.add_args();
+    arg_unit->set_isarray(false);
+    arg_unit->set_type(GLMessage::DataType::INT);
+    arg_unit->add_intvalue(unit);
+
+    // copy argument texture
+    GLMessage_DataType *arg_texture = glmsg.add_args();
+    arg_texture->set_isarray(false);
+    arg_texture->set_type(GLMessage::DataType::INT);
+    arg_texture->add_intvalue(texture);
+
+    // copy argument level
+    GLMessage_DataType *arg_level = glmsg.add_args();
+    arg_level->set_isarray(false);
+    arg_level->set_type(GLMessage::DataType::INT);
+    arg_level->add_intvalue(level);
+
+    // copy argument layered
+    GLMessage_DataType *arg_layered = glmsg.add_args();
+    arg_layered->set_isarray(false);
+    arg_layered->set_type(GLMessage::DataType::BOOL);
+    arg_layered->add_boolvalue(layered);
+
+    // copy argument layer
+    GLMessage_DataType *arg_layer = glmsg.add_args();
+    arg_layer->set_isarray(false);
+    arg_layer->set_type(GLMessage::DataType::INT);
+    arg_layer->add_intvalue(layer);
+
+    // copy argument access
+    GLMessage_DataType *arg_access = glmsg.add_args();
+    arg_access->set_isarray(false);
+    arg_access->set_type(GLMessage::DataType::ENUM);
+    arg_access->add_intvalue((int)access);
+
+    // copy argument format
+    GLMessage_DataType *arg_format = glmsg.add_args();
+    arg_format->set_isarray(false);
+    arg_format->set_type(GLMessage::DataType::ENUM);
+    arg_format->add_intvalue((int)format);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glBindImageTexture(unit, texture, level, layered, layer, access, format);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetBooleani_v(GLenum target, GLuint index, GLboolean * data) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetBooleani_v);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
+
+    // copy argument data
+    GLMessage_DataType *arg_data = glmsg.add_args();
+    arg_data->set_isarray(false);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetBooleani_v(target, index, data);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) data,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glMemoryBarrier(GLbitfield barriers) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glMemoryBarrier);
+
+    // copy argument barriers
+    GLMessage_DataType *arg_barriers = glmsg.add_args();
+    arg_barriers->set_isarray(false);
+    arg_barriers->set_type(GLMessage::DataType::INT);
+    arg_barriers->add_intvalue(barriers);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glMemoryBarrier(barriers);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glMemoryBarrierByRegion(GLbitfield barriers) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glMemoryBarrierByRegion);
+
+    // copy argument barriers
+    GLMessage_DataType *arg_barriers = glmsg.add_args();
+    arg_barriers->set_isarray(false);
+    arg_barriers->set_type(GLMessage::DataType::INT);
+    arg_barriers->add_intvalue(barriers);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glMemoryBarrierByRegion(barriers);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glTexStorage2DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTexStorage2DMultisample);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument samples
+    GLMessage_DataType *arg_samples = glmsg.add_args();
+    arg_samples->set_isarray(false);
+    arg_samples->set_type(GLMessage::DataType::INT);
+    arg_samples->add_intvalue(samples);
+
+    // copy argument internalformat
+    GLMessage_DataType *arg_internalformat = glmsg.add_args();
+    arg_internalformat->set_isarray(false);
+    arg_internalformat->set_type(GLMessage::DataType::ENUM);
+    arg_internalformat->add_intvalue((int)internalformat);
+
+    // copy argument width
+    GLMessage_DataType *arg_width = glmsg.add_args();
+    arg_width->set_isarray(false);
+    arg_width->set_type(GLMessage::DataType::INT);
+    arg_width->add_intvalue(width);
+
+    // copy argument height
+    GLMessage_DataType *arg_height = glmsg.add_args();
+    arg_height->set_isarray(false);
+    arg_height->set_type(GLMessage::DataType::INT);
+    arg_height->add_intvalue(height);
+
+    // copy argument fixedsamplelocations
+    GLMessage_DataType *arg_fixedsamplelocations = glmsg.add_args();
+    arg_fixedsamplelocations->set_isarray(false);
+    arg_fixedsamplelocations->set_type(GLMessage::DataType::BOOL);
+    arg_fixedsamplelocations->add_boolvalue(fixedsamplelocations);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTexStorage2DMultisample(target, samples, internalformat, width, height, fixedsamplelocations);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetMultisamplefv(GLenum pname, GLuint index, GLfloat * val) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetMultisamplefv);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
+
+    // copy argument val
+    GLMessage_DataType *arg_val = glmsg.add_args();
+    arg_val->set_isarray(false);
+    arg_val->set_type(GLMessage::DataType::INT64);
+    arg_val->add_int64value((uintptr_t)val);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetMultisamplefv(pname, index, val);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) val,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glSampleMaski(GLuint maskNumber, GLbitfield mask) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glSampleMaski);
+
+    // copy argument maskNumber
+    GLMessage_DataType *arg_maskNumber = glmsg.add_args();
+    arg_maskNumber->set_isarray(false);
+    arg_maskNumber->set_type(GLMessage::DataType::INT);
+    arg_maskNumber->add_intvalue(maskNumber);
+
+    // copy argument mask
+    GLMessage_DataType *arg_mask = glmsg.add_args();
+    arg_mask->set_isarray(false);
+    arg_mask->set_type(GLMessage::DataType::INT);
+    arg_mask->add_intvalue(mask);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glSampleMaski(maskNumber, mask);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetTexLevelParameteriv);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument level
+    GLMessage_DataType *arg_level = glmsg.add_args();
+    arg_level->set_isarray(false);
+    arg_level->set_type(GLMessage::DataType::INT);
+    arg_level->add_intvalue(level);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetTexLevelParameteriv(target, level, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetTexLevelParameterfv);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument level
+    GLMessage_DataType *arg_level = glmsg.add_args();
+    arg_level->set_isarray(false);
+    arg_level->set_type(GLMessage::DataType::INT);
+    arg_level->add_intvalue(level);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetTexLevelParameterfv(target, level, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glBindVertexBuffer(GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glBindVertexBuffer);
+
+    // copy argument bindingindex
+    GLMessage_DataType *arg_bindingindex = glmsg.add_args();
+    arg_bindingindex->set_isarray(false);
+    arg_bindingindex->set_type(GLMessage::DataType::INT);
+    arg_bindingindex->add_intvalue(bindingindex);
+
+    // copy argument buffer
+    GLMessage_DataType *arg_buffer = glmsg.add_args();
+    arg_buffer->set_isarray(false);
+    arg_buffer->set_type(GLMessage::DataType::INT);
+    arg_buffer->add_intvalue(buffer);
+
+    // copy argument offset
+    GLMessage_DataType *arg_offset = glmsg.add_args();
+    arg_offset->set_isarray(false);
+    arg_offset->set_type(GLMessage::DataType::INT);
+    arg_offset->add_intvalue(offset);
+
+    // copy argument stride
+    GLMessage_DataType *arg_stride = glmsg.add_args();
+    arg_stride->set_isarray(false);
+    arg_stride->set_type(GLMessage::DataType::INT);
+    arg_stride->add_intvalue(stride);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glBindVertexBuffer(bindingindex, buffer, offset, stride);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glVertexAttribFormat(GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glVertexAttribFormat);
+
+    // copy argument attribindex
+    GLMessage_DataType *arg_attribindex = glmsg.add_args();
+    arg_attribindex->set_isarray(false);
+    arg_attribindex->set_type(GLMessage::DataType::INT);
+    arg_attribindex->add_intvalue(attribindex);
+
+    // copy argument size
+    GLMessage_DataType *arg_size = glmsg.add_args();
+    arg_size->set_isarray(false);
+    arg_size->set_type(GLMessage::DataType::INT);
+    arg_size->add_intvalue(size);
+
+    // copy argument type
+    GLMessage_DataType *arg_type = glmsg.add_args();
+    arg_type->set_isarray(false);
+    arg_type->set_type(GLMessage::DataType::ENUM);
+    arg_type->add_intvalue((int)type);
+
+    // copy argument normalized
+    GLMessage_DataType *arg_normalized = glmsg.add_args();
+    arg_normalized->set_isarray(false);
+    arg_normalized->set_type(GLMessage::DataType::BOOL);
+    arg_normalized->add_boolvalue(normalized);
+
+    // copy argument relativeoffset
+    GLMessage_DataType *arg_relativeoffset = glmsg.add_args();
+    arg_relativeoffset->set_isarray(false);
+    arg_relativeoffset->set_type(GLMessage::DataType::INT);
+    arg_relativeoffset->add_intvalue(relativeoffset);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glVertexAttribFormat(attribindex, size, type, normalized, relativeoffset);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glVertexAttribIFormat(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glVertexAttribIFormat);
+
+    // copy argument attribindex
+    GLMessage_DataType *arg_attribindex = glmsg.add_args();
+    arg_attribindex->set_isarray(false);
+    arg_attribindex->set_type(GLMessage::DataType::INT);
+    arg_attribindex->add_intvalue(attribindex);
+
+    // copy argument size
+    GLMessage_DataType *arg_size = glmsg.add_args();
+    arg_size->set_isarray(false);
+    arg_size->set_type(GLMessage::DataType::INT);
+    arg_size->add_intvalue(size);
+
+    // copy argument type
+    GLMessage_DataType *arg_type = glmsg.add_args();
+    arg_type->set_isarray(false);
+    arg_type->set_type(GLMessage::DataType::ENUM);
+    arg_type->add_intvalue((int)type);
+
+    // copy argument relativeoffset
+    GLMessage_DataType *arg_relativeoffset = glmsg.add_args();
+    arg_relativeoffset->set_isarray(false);
+    arg_relativeoffset->set_type(GLMessage::DataType::INT);
+    arg_relativeoffset->add_intvalue(relativeoffset);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glVertexAttribIFormat(attribindex, size, type, relativeoffset);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glVertexAttribBinding(GLuint attribindex, GLuint bindingindex) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glVertexAttribBinding);
+
+    // copy argument attribindex
+    GLMessage_DataType *arg_attribindex = glmsg.add_args();
+    arg_attribindex->set_isarray(false);
+    arg_attribindex->set_type(GLMessage::DataType::INT);
+    arg_attribindex->add_intvalue(attribindex);
+
+    // copy argument bindingindex
+    GLMessage_DataType *arg_bindingindex = glmsg.add_args();
+    arg_bindingindex->set_isarray(false);
+    arg_bindingindex->set_type(GLMessage::DataType::INT);
+    arg_bindingindex->add_intvalue(bindingindex);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glVertexAttribBinding(attribindex, bindingindex);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glVertexBindingDivisor(GLuint bindingindex, GLuint divisor) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glVertexBindingDivisor);
+
+    // copy argument bindingindex
+    GLMessage_DataType *arg_bindingindex = glmsg.add_args();
+    arg_bindingindex->set_isarray(false);
+    arg_bindingindex->set_type(GLMessage::DataType::INT);
+    arg_bindingindex->add_intvalue(bindingindex);
+
+    // copy argument divisor
+    GLMessage_DataType *arg_divisor = glmsg.add_args();
+    arg_divisor->set_isarray(false);
+    arg_divisor->set_type(GLMessage::DataType::INT);
+    arg_divisor->add_intvalue(divisor);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glVertexBindingDivisor(bindingindex, divisor);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
 
 // Definitions for GL2Ext APIs
 
+void GLTrace_glBlendBarrierKHR(void) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glBlendBarrierKHR);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glBlendBarrierKHR();
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glDebugMessageControlKHR(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDebugMessageControlKHR);
+
+    // copy argument source
+    GLMessage_DataType *arg_source = glmsg.add_args();
+    arg_source->set_isarray(false);
+    arg_source->set_type(GLMessage::DataType::ENUM);
+    arg_source->add_intvalue((int)source);
+
+    // copy argument type
+    GLMessage_DataType *arg_type = glmsg.add_args();
+    arg_type->set_isarray(false);
+    arg_type->set_type(GLMessage::DataType::ENUM);
+    arg_type->add_intvalue((int)type);
+
+    // copy argument severity
+    GLMessage_DataType *arg_severity = glmsg.add_args();
+    arg_severity->set_isarray(false);
+    arg_severity->set_type(GLMessage::DataType::ENUM);
+    arg_severity->add_intvalue((int)severity);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument ids
+    GLMessage_DataType *arg_ids = glmsg.add_args();
+    arg_ids->set_isarray(false);
+    arg_ids->set_type(GLMessage::DataType::INT64);
+    arg_ids->add_int64value((uintptr_t)ids);
+
+    // copy argument enabled
+    GLMessage_DataType *arg_enabled = glmsg.add_args();
+    arg_enabled->set_isarray(false);
+    arg_enabled->set_type(GLMessage::DataType::BOOL);
+    arg_enabled->add_boolvalue(enabled);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDebugMessageControlKHR(source, type, severity, count, ids, enabled);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) ids,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glDebugMessageInsertKHR(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDebugMessageInsertKHR);
+
+    // copy argument source
+    GLMessage_DataType *arg_source = glmsg.add_args();
+    arg_source->set_isarray(false);
+    arg_source->set_type(GLMessage::DataType::ENUM);
+    arg_source->add_intvalue((int)source);
+
+    // copy argument type
+    GLMessage_DataType *arg_type = glmsg.add_args();
+    arg_type->set_isarray(false);
+    arg_type->set_type(GLMessage::DataType::ENUM);
+    arg_type->add_intvalue((int)type);
+
+    // copy argument id
+    GLMessage_DataType *arg_id = glmsg.add_args();
+    arg_id->set_isarray(false);
+    arg_id->set_type(GLMessage::DataType::INT);
+    arg_id->add_intvalue(id);
+
+    // copy argument severity
+    GLMessage_DataType *arg_severity = glmsg.add_args();
+    arg_severity->set_isarray(false);
+    arg_severity->set_type(GLMessage::DataType::ENUM);
+    arg_severity->add_intvalue((int)severity);
+
+    // copy argument length
+    GLMessage_DataType *arg_length = glmsg.add_args();
+    arg_length->set_isarray(false);
+    arg_length->set_type(GLMessage::DataType::INT);
+    arg_length->add_intvalue(length);
+
+    // copy argument buf
+    GLMessage_DataType *arg_buf = glmsg.add_args();
+    arg_buf->set_isarray(false);
+    arg_buf->set_type(GLMessage::DataType::INT64);
+    arg_buf->add_int64value((uintptr_t)buf);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDebugMessageInsertKHR(source, type, id, severity, length, buf);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) buf,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glDebugMessageCallbackKHR(GLDEBUGPROCKHR callback, const void * userParam) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDebugMessageCallbackKHR);
+
+    // copy argument callback
+    GLMessage_DataType *arg_callback = glmsg.add_args();
+    arg_callback->set_isarray(false);
+    arg_callback->set_type(GLMessage::DataType::INT64);
+    arg_callback->add_int64value((uintptr_t)callback);
+
+    // copy argument userParam
+    GLMessage_DataType *arg_userParam = glmsg.add_args();
+    arg_userParam->set_isarray(false);
+    arg_userParam->set_type(GLMessage::DataType::INT64);
+    arg_userParam->add_int64value((uintptr_t)userParam);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDebugMessageCallbackKHR(callback, userParam);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) callback,
+        (void *) userParam,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+GLuint GLTrace_glGetDebugMessageLogKHR(GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetDebugMessageLogKHR);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument bufSize
+    GLMessage_DataType *arg_bufSize = glmsg.add_args();
+    arg_bufSize->set_isarray(false);
+    arg_bufSize->set_type(GLMessage::DataType::INT);
+    arg_bufSize->add_intvalue(bufSize);
+
+    // copy argument sources
+    GLMessage_DataType *arg_sources = glmsg.add_args();
+    arg_sources->set_isarray(false);
+    arg_sources->set_type(GLMessage::DataType::INT64);
+    arg_sources->add_int64value((uintptr_t)sources);
+
+    // copy argument types
+    GLMessage_DataType *arg_types = glmsg.add_args();
+    arg_types->set_isarray(false);
+    arg_types->set_type(GLMessage::DataType::INT64);
+    arg_types->add_int64value((uintptr_t)types);
+
+    // copy argument ids
+    GLMessage_DataType *arg_ids = glmsg.add_args();
+    arg_ids->set_isarray(false);
+    arg_ids->set_type(GLMessage::DataType::INT64);
+    arg_ids->add_int64value((uintptr_t)ids);
+
+    // copy argument severities
+    GLMessage_DataType *arg_severities = glmsg.add_args();
+    arg_severities->set_isarray(false);
+    arg_severities->set_type(GLMessage::DataType::INT64);
+    arg_severities->add_int64value((uintptr_t)severities);
+
+    // copy argument lengths
+    GLMessage_DataType *arg_lengths = glmsg.add_args();
+    arg_lengths->set_isarray(false);
+    arg_lengths->set_type(GLMessage::DataType::INT64);
+    arg_lengths->add_int64value((uintptr_t)lengths);
+
+    // copy argument messageLog
+    GLMessage_DataType *arg_messageLog = glmsg.add_args();
+    arg_messageLog->set_isarray(false);
+    arg_messageLog->set_type(GLMessage::DataType::INT64);
+    arg_messageLog->add_int64value((uintptr_t)messageLog);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    GLuint retValue = glContext->hooks->gl.glGetDebugMessageLogKHR(count, bufSize, sources, types, ids, severities, lengths, messageLog);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    // set return value
+    GLMessage_DataType *rt = glmsg.mutable_returnvalue();
+    rt->set_isarray(false);
+    rt->set_type(GLMessage::DataType::INT);
+    rt->add_intvalue(retValue);
+
+    void *pointerArgs[] = {
+        (void *) sources,
+        (void *) types,
+        (void *) ids,
+        (void *) severities,
+        (void *) lengths,
+        (void *) messageLog,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+
+    return retValue;
+}
+
+void GLTrace_glPushDebugGroupKHR(GLenum source, GLuint id, GLsizei length, const GLchar * message) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glPushDebugGroupKHR);
+
+    // copy argument source
+    GLMessage_DataType *arg_source = glmsg.add_args();
+    arg_source->set_isarray(false);
+    arg_source->set_type(GLMessage::DataType::ENUM);
+    arg_source->add_intvalue((int)source);
+
+    // copy argument id
+    GLMessage_DataType *arg_id = glmsg.add_args();
+    arg_id->set_isarray(false);
+    arg_id->set_type(GLMessage::DataType::INT);
+    arg_id->add_intvalue(id);
+
+    // copy argument length
+    GLMessage_DataType *arg_length = glmsg.add_args();
+    arg_length->set_isarray(false);
+    arg_length->set_type(GLMessage::DataType::INT);
+    arg_length->add_intvalue(length);
+
+    // copy argument message
+    GLMessage_DataType *arg_message = glmsg.add_args();
+    arg_message->set_isarray(false);
+    arg_message->set_type(GLMessage::DataType::INT64);
+    arg_message->add_int64value((uintptr_t)message);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glPushDebugGroupKHR(source, id, length, message);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) message,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glPopDebugGroupKHR(void) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glPopDebugGroupKHR);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glPopDebugGroupKHR();
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glObjectLabelKHR(GLenum identifier, GLuint name, GLsizei length, const GLchar * label) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glObjectLabelKHR);
+
+    // copy argument identifier
+    GLMessage_DataType *arg_identifier = glmsg.add_args();
+    arg_identifier->set_isarray(false);
+    arg_identifier->set_type(GLMessage::DataType::ENUM);
+    arg_identifier->add_intvalue((int)identifier);
+
+    // copy argument name
+    GLMessage_DataType *arg_name = glmsg.add_args();
+    arg_name->set_isarray(false);
+    arg_name->set_type(GLMessage::DataType::INT);
+    arg_name->add_intvalue(name);
+
+    // copy argument length
+    GLMessage_DataType *arg_length = glmsg.add_args();
+    arg_length->set_isarray(false);
+    arg_length->set_type(GLMessage::DataType::INT);
+    arg_length->add_intvalue(length);
+
+    // copy argument label
+    GLMessage_DataType *arg_label = glmsg.add_args();
+    arg_label->set_isarray(false);
+    arg_label->set_type(GLMessage::DataType::INT64);
+    arg_label->add_int64value((uintptr_t)label);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glObjectLabelKHR(identifier, name, length, label);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) label,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetObjectLabelKHR(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetObjectLabelKHR);
+
+    // copy argument identifier
+    GLMessage_DataType *arg_identifier = glmsg.add_args();
+    arg_identifier->set_isarray(false);
+    arg_identifier->set_type(GLMessage::DataType::ENUM);
+    arg_identifier->add_intvalue((int)identifier);
+
+    // copy argument name
+    GLMessage_DataType *arg_name = glmsg.add_args();
+    arg_name->set_isarray(false);
+    arg_name->set_type(GLMessage::DataType::INT);
+    arg_name->add_intvalue(name);
+
+    // copy argument bufSize
+    GLMessage_DataType *arg_bufSize = glmsg.add_args();
+    arg_bufSize->set_isarray(false);
+    arg_bufSize->set_type(GLMessage::DataType::INT);
+    arg_bufSize->add_intvalue(bufSize);
+
+    // copy argument length
+    GLMessage_DataType *arg_length = glmsg.add_args();
+    arg_length->set_isarray(false);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
+
+    // copy argument label
+    GLMessage_DataType *arg_label = glmsg.add_args();
+    arg_label->set_isarray(false);
+    arg_label->set_type(GLMessage::DataType::INT64);
+    arg_label->add_int64value((uintptr_t)label);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetObjectLabelKHR(identifier, name, bufSize, length, label);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) length,
+        (void *) label,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glObjectPtrLabelKHR(const void * ptr, GLsizei length, const GLchar * label) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glObjectPtrLabelKHR);
+
+    // copy argument ptr
+    GLMessage_DataType *arg_ptr = glmsg.add_args();
+    arg_ptr->set_isarray(false);
+    arg_ptr->set_type(GLMessage::DataType::INT64);
+    arg_ptr->add_int64value((uintptr_t)ptr);
+
+    // copy argument length
+    GLMessage_DataType *arg_length = glmsg.add_args();
+    arg_length->set_isarray(false);
+    arg_length->set_type(GLMessage::DataType::INT);
+    arg_length->add_intvalue(length);
+
+    // copy argument label
+    GLMessage_DataType *arg_label = glmsg.add_args();
+    arg_label->set_isarray(false);
+    arg_label->set_type(GLMessage::DataType::INT64);
+    arg_label->add_int64value((uintptr_t)label);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glObjectPtrLabelKHR(ptr, length, label);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) ptr,
+        (void *) label,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetObjectPtrLabelKHR(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetObjectPtrLabelKHR);
+
+    // copy argument ptr
+    GLMessage_DataType *arg_ptr = glmsg.add_args();
+    arg_ptr->set_isarray(false);
+    arg_ptr->set_type(GLMessage::DataType::INT64);
+    arg_ptr->add_int64value((uintptr_t)ptr);
+
+    // copy argument bufSize
+    GLMessage_DataType *arg_bufSize = glmsg.add_args();
+    arg_bufSize->set_isarray(false);
+    arg_bufSize->set_type(GLMessage::DataType::INT);
+    arg_bufSize->add_intvalue(bufSize);
+
+    // copy argument length
+    GLMessage_DataType *arg_length = glmsg.add_args();
+    arg_length->set_isarray(false);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
+
+    // copy argument label
+    GLMessage_DataType *arg_label = glmsg.add_args();
+    arg_label->set_isarray(false);
+    arg_label->set_type(GLMessage::DataType::INT64);
+    arg_label->add_int64value((uintptr_t)label);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetObjectPtrLabelKHR(ptr, bufSize, length, label);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) ptr,
+        (void *) length,
+        (void *) label,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetPointervKHR(GLenum pname, void ** params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetPointervKHR);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetPointervKHR(pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
 void GLTrace_glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
@@ -10416,7 +14077,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary) {
+void GLTrace_glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei * length, GLenum * binaryFormat, void * binary) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -10471,7 +14132,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length) {
+void GLTrace_glProgramBinaryOES(GLuint program, GLenum binaryFormat, const void * binary, GLint length) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -10518,7 +14179,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void* GLTrace_glMapBufferOES(GLenum target, GLenum access) {
+void * GLTrace_glMapBufferOES(GLenum target, GLenum access) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -10539,7 +14200,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    void* retValue = glContext->hooks->gl.glMapBufferOES(target, access);
+    void * retValue = glContext->hooks->gl.glMapBufferOES(target, access);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -10597,7 +14258,7 @@
     return retValue;
 }
 
-void GLTrace_glGetBufferPointervOES(GLenum target, GLenum pname, GLvoid** params) {
+void GLTrace_glGetBufferPointervOES(GLenum target, GLenum pname, void ** params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -10638,7 +14299,35 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) {
+void GLTrace_glMinSampleShadingOES(GLfloat value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glMinSampleShadingOES);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::FLOAT);
+    arg_value->add_floatvalue(value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glMinSampleShadingOES(value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -10721,7 +14410,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) {
+void GLTrace_glTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -10886,7 +14575,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glCompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) {
+void GLTrace_glCompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -10963,7 +14652,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glCompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) {
+void GLTrace_glCompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -11110,6 +14799,70 @@
     glContext->traceGLMessage(&glmsg);
 }
 
+void GLTrace_glTexStorage3DMultisampleOES(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTexStorage3DMultisampleOES);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument samples
+    GLMessage_DataType *arg_samples = glmsg.add_args();
+    arg_samples->set_isarray(false);
+    arg_samples->set_type(GLMessage::DataType::INT);
+    arg_samples->add_intvalue(samples);
+
+    // copy argument internalformat
+    GLMessage_DataType *arg_internalformat = glmsg.add_args();
+    arg_internalformat->set_isarray(false);
+    arg_internalformat->set_type(GLMessage::DataType::ENUM);
+    arg_internalformat->add_intvalue((int)internalformat);
+
+    // copy argument width
+    GLMessage_DataType *arg_width = glmsg.add_args();
+    arg_width->set_isarray(false);
+    arg_width->set_type(GLMessage::DataType::INT);
+    arg_width->add_intvalue(width);
+
+    // copy argument height
+    GLMessage_DataType *arg_height = glmsg.add_args();
+    arg_height->set_isarray(false);
+    arg_height->set_type(GLMessage::DataType::INT);
+    arg_height->add_intvalue(height);
+
+    // copy argument depth
+    GLMessage_DataType *arg_depth = glmsg.add_args();
+    arg_depth->set_isarray(false);
+    arg_depth->set_type(GLMessage::DataType::INT);
+    arg_depth->add_intvalue(depth);
+
+    // copy argument fixedsamplelocations
+    GLMessage_DataType *arg_fixedsamplelocations = glmsg.add_args();
+    arg_fixedsamplelocations->set_isarray(false);
+    arg_fixedsamplelocations->set_type(GLMessage::DataType::BOOL);
+    arg_fixedsamplelocations->add_boolvalue(fixedsamplelocations);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTexStorage3DMultisampleOES(target, samples, internalformat, width, height, depth, fixedsamplelocations);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
 void GLTrace_glBindVertexArrayOES(GLuint array) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
@@ -11138,7 +14891,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDeleteVertexArraysOES(GLsizei n, const GLuint *arrays) {
+void GLTrace_glDeleteVertexArraysOES(GLsizei n, const GLuint * arrays) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -11173,7 +14926,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGenVertexArraysOES(GLsizei n, GLuint *arrays) {
+void GLTrace_glGenVertexArraysOES(GLsizei n, GLuint * arrays) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -11244,7 +14997,7 @@
     return retValue;
 }
 
-void GLTrace_glGetPerfMonitorGroupsAMD(GLint *numGroups, GLsizei groupsSize, GLuint *groups) {
+void GLTrace_glGetPerfMonitorGroupsAMD(GLint * numGroups, GLsizei groupsSize, GLuint * groups) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -11286,7 +15039,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetPerfMonitorCountersAMD(GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters) {
+void GLTrace_glGetPerfMonitorCountersAMD(GLuint group, GLint * numCounters, GLint * maxActiveCounters, GLsizei counterSize, GLuint * counters) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -11341,7 +15094,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetPerfMonitorGroupStringAMD(GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString) {
+void GLTrace_glGetPerfMonitorGroupStringAMD(GLuint group, GLsizei bufSize, GLsizei * length, GLchar * groupString) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -11389,7 +15142,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetPerfMonitorCounterStringAMD(GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString) {
+void GLTrace_glGetPerfMonitorCounterStringAMD(GLuint group, GLuint counter, GLsizei bufSize, GLsizei * length, GLchar * counterString) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -11443,7 +15196,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetPerfMonitorCounterInfoAMD(GLuint group, GLuint counter, GLenum pname, GLvoid *data) {
+void GLTrace_glGetPerfMonitorCounterInfoAMD(GLuint group, GLuint counter, GLenum pname, void * data) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -11490,7 +15243,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGenPerfMonitorsAMD(GLsizei n, GLuint *monitors) {
+void GLTrace_glGenPerfMonitorsAMD(GLsizei n, GLuint * monitors) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -11525,7 +15278,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDeletePerfMonitorsAMD(GLsizei n, GLuint *monitors) {
+void GLTrace_glDeletePerfMonitorsAMD(GLsizei n, GLuint * monitors) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -11560,7 +15313,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glSelectPerfMonitorCountersAMD(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList) {
+void GLTrace_glSelectPerfMonitorCountersAMD(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint * counterList) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -11590,21 +15343,21 @@
     arg_numCounters->set_type(GLMessage::DataType::INT);
     arg_numCounters->add_intvalue(numCounters);
 
-    // copy argument countersList
-    GLMessage_DataType *arg_countersList = glmsg.add_args();
-    arg_countersList->set_isarray(false);
-    arg_countersList->set_type(GLMessage::DataType::INT64);
-    arg_countersList->add_int64value((uintptr_t)countersList);
+    // copy argument counterList
+    GLMessage_DataType *arg_counterList = glmsg.add_args();
+    arg_counterList->set_isarray(false);
+    arg_counterList->set_type(GLMessage::DataType::INT64);
+    arg_counterList->add_int64value((uintptr_t)counterList);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glSelectPerfMonitorCountersAMD(monitor, enable, group, numCounters, countersList);
+    glContext->hooks->gl.glSelectPerfMonitorCountersAMD(monitor, enable, group, numCounters, counterList);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) countersList,
+        (void *) counterList,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -11669,7 +15422,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetPerfMonitorCounterDataAMD(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten) {
+void GLTrace_glGetPerfMonitorCounterDataAMD(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint * data, GLint * bytesWritten) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -11857,6 +15610,233 @@
     glContext->traceGLMessage(&glmsg);
 }
 
+void GLTrace_glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDrawArraysInstancedANGLE);
+
+    // copy argument mode
+    GLMessage_DataType *arg_mode = glmsg.add_args();
+    arg_mode->set_isarray(false);
+    arg_mode->set_type(GLMessage::DataType::ENUM);
+    arg_mode->add_intvalue((int)mode);
+
+    // copy argument first
+    GLMessage_DataType *arg_first = glmsg.add_args();
+    arg_first->set_isarray(false);
+    arg_first->set_type(GLMessage::DataType::INT);
+    arg_first->add_intvalue(first);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument primcount
+    GLMessage_DataType *arg_primcount = glmsg.add_args();
+    arg_primcount->set_isarray(false);
+    arg_primcount->set_type(GLMessage::DataType::INT);
+    arg_primcount->add_intvalue(primcount);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDrawArraysInstancedANGLE(mode, first, count, primcount);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDrawElementsInstancedANGLE);
+
+    // copy argument mode
+    GLMessage_DataType *arg_mode = glmsg.add_args();
+    arg_mode->set_isarray(false);
+    arg_mode->set_type(GLMessage::DataType::ENUM);
+    arg_mode->add_intvalue((int)mode);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument type
+    GLMessage_DataType *arg_type = glmsg.add_args();
+    arg_type->set_isarray(false);
+    arg_type->set_type(GLMessage::DataType::ENUM);
+    arg_type->add_intvalue((int)type);
+
+    // copy argument indices
+    GLMessage_DataType *arg_indices = glmsg.add_args();
+    arg_indices->set_isarray(false);
+    arg_indices->set_type(GLMessage::DataType::INT64);
+    arg_indices->add_int64value((uintptr_t)indices);
+
+    // copy argument primcount
+    GLMessage_DataType *arg_primcount = glmsg.add_args();
+    arg_primcount->set_isarray(false);
+    arg_primcount->set_type(GLMessage::DataType::INT);
+    arg_primcount->add_intvalue(primcount);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDrawElementsInstancedANGLE(mode, count, type, indices, primcount);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) indices,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glVertexAttribDivisorANGLE);
+
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
+
+    // copy argument divisor
+    GLMessage_DataType *arg_divisor = glmsg.add_args();
+    arg_divisor->set_isarray(false);
+    arg_divisor->set_type(GLMessage::DataType::INT);
+    arg_divisor->add_intvalue(divisor);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glVertexAttribDivisorANGLE(index, divisor);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei * length, GLchar * source) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetTranslatedShaderSourceANGLE);
+
+    // copy argument shader
+    GLMessage_DataType *arg_shader = glmsg.add_args();
+    arg_shader->set_isarray(false);
+    arg_shader->set_type(GLMessage::DataType::INT);
+    arg_shader->add_intvalue(shader);
+
+    // copy argument bufsize
+    GLMessage_DataType *arg_bufsize = glmsg.add_args();
+    arg_bufsize->set_isarray(false);
+    arg_bufsize->set_type(GLMessage::DataType::INT);
+    arg_bufsize->add_intvalue(bufsize);
+
+    // copy argument length
+    GLMessage_DataType *arg_length = glmsg.add_args();
+    arg_length->set_isarray(false);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
+
+    // copy argument source
+    GLMessage_DataType *arg_source = glmsg.add_args();
+    arg_source->set_isarray(false);
+    arg_source->set_type(GLMessage::DataType::INT64);
+    arg_source->add_int64value((uintptr_t)source);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetTranslatedShaderSourceANGLE(shader, bufsize, length, source);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) length,
+        (void *) source,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glCopyTextureLevelsAPPLE(GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glCopyTextureLevelsAPPLE);
+
+    // copy argument destinationTexture
+    GLMessage_DataType *arg_destinationTexture = glmsg.add_args();
+    arg_destinationTexture->set_isarray(false);
+    arg_destinationTexture->set_type(GLMessage::DataType::INT);
+    arg_destinationTexture->add_intvalue(destinationTexture);
+
+    // copy argument sourceTexture
+    GLMessage_DataType *arg_sourceTexture = glmsg.add_args();
+    arg_sourceTexture->set_isarray(false);
+    arg_sourceTexture->set_type(GLMessage::DataType::INT);
+    arg_sourceTexture->add_intvalue(sourceTexture);
+
+    // copy argument sourceBaseLevel
+    GLMessage_DataType *arg_sourceBaseLevel = glmsg.add_args();
+    arg_sourceBaseLevel->set_isarray(false);
+    arg_sourceBaseLevel->set_type(GLMessage::DataType::INT);
+    arg_sourceBaseLevel->add_intvalue(sourceBaseLevel);
+
+    // copy argument sourceLevelCount
+    GLMessage_DataType *arg_sourceLevelCount = glmsg.add_args();
+    arg_sourceLevelCount->set_isarray(false);
+    arg_sourceLevelCount->set_type(GLMessage::DataType::INT);
+    arg_sourceLevelCount->add_intvalue(sourceLevelCount);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glCopyTextureLevelsAPPLE(destinationTexture, sourceTexture, sourceBaseLevel, sourceLevelCount);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
 void GLTrace_glRenderbufferStorageMultisampleAPPLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
@@ -11931,7 +15911,408 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glLabelObjectEXT(GLenum type, GLuint object, GLsizei length, const GLchar *label) {
+GLsync GLTrace_glFenceSyncAPPLE(GLenum condition, GLbitfield flags) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glFenceSyncAPPLE);
+
+    // copy argument condition
+    GLMessage_DataType *arg_condition = glmsg.add_args();
+    arg_condition->set_isarray(false);
+    arg_condition->set_type(GLMessage::DataType::ENUM);
+    arg_condition->add_intvalue((int)condition);
+
+    // copy argument flags
+    GLMessage_DataType *arg_flags = glmsg.add_args();
+    arg_flags->set_isarray(false);
+    arg_flags->set_type(GLMessage::DataType::INT);
+    arg_flags->add_intvalue(flags);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    GLsync retValue = glContext->hooks->gl.glFenceSyncAPPLE(condition, flags);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    // set return value
+    GLMessage_DataType *rt = glmsg.mutable_returnvalue();
+    rt->set_isarray(false);
+    rt->set_type(GLMessage::DataType::INT64);
+    rt->add_int64value((uintptr_t)retValue);
+
+    void *pointerArgs[] = {
+        (void *) retValue,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+
+    return retValue;
+}
+
+GLboolean GLTrace_glIsSyncAPPLE(GLsync sync) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glIsSyncAPPLE);
+
+    // copy argument sync
+    GLMessage_DataType *arg_sync = glmsg.add_args();
+    arg_sync->set_isarray(false);
+    arg_sync->set_type(GLMessage::DataType::INT64);
+    arg_sync->add_int64value((uintptr_t)sync);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    GLboolean retValue = glContext->hooks->gl.glIsSyncAPPLE(sync);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    // set return value
+    GLMessage_DataType *rt = glmsg.mutable_returnvalue();
+    rt->set_isarray(false);
+    rt->set_type(GLMessage::DataType::BOOL);
+    rt->add_boolvalue(retValue);
+
+    void *pointerArgs[] = {
+        (void *) sync,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+
+    return retValue;
+}
+
+void GLTrace_glDeleteSyncAPPLE(GLsync sync) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDeleteSyncAPPLE);
+
+    // copy argument sync
+    GLMessage_DataType *arg_sync = glmsg.add_args();
+    arg_sync->set_isarray(false);
+    arg_sync->set_type(GLMessage::DataType::INT64);
+    arg_sync->add_int64value((uintptr_t)sync);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDeleteSyncAPPLE(sync);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) sync,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+GLenum GLTrace_glClientWaitSyncAPPLE(GLsync sync, GLbitfield flags, GLuint64 timeout) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glClientWaitSyncAPPLE);
+
+    // copy argument sync
+    GLMessage_DataType *arg_sync = glmsg.add_args();
+    arg_sync->set_isarray(false);
+    arg_sync->set_type(GLMessage::DataType::INT64);
+    arg_sync->add_int64value((uintptr_t)sync);
+
+    // copy argument flags
+    GLMessage_DataType *arg_flags = glmsg.add_args();
+    arg_flags->set_isarray(false);
+    arg_flags->set_type(GLMessage::DataType::INT);
+    arg_flags->add_intvalue(flags);
+
+    // copy argument timeout
+    GLMessage_DataType *arg_timeout = glmsg.add_args();
+    arg_timeout->set_isarray(false);
+    arg_timeout->set_type(GLMessage::DataType::INT64);
+    arg_timeout->add_int64value(timeout);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    GLenum retValue = glContext->hooks->gl.glClientWaitSyncAPPLE(sync, flags, timeout);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    // set return value
+    GLMessage_DataType *rt = glmsg.mutable_returnvalue();
+    rt->set_isarray(false);
+    rt->set_type(GLMessage::DataType::ENUM);
+    rt->add_intvalue((int)retValue);
+
+    void *pointerArgs[] = {
+        (void *) sync,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+
+    return retValue;
+}
+
+void GLTrace_glWaitSyncAPPLE(GLsync sync, GLbitfield flags, GLuint64 timeout) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glWaitSyncAPPLE);
+
+    // copy argument sync
+    GLMessage_DataType *arg_sync = glmsg.add_args();
+    arg_sync->set_isarray(false);
+    arg_sync->set_type(GLMessage::DataType::INT64);
+    arg_sync->add_int64value((uintptr_t)sync);
+
+    // copy argument flags
+    GLMessage_DataType *arg_flags = glmsg.add_args();
+    arg_flags->set_isarray(false);
+    arg_flags->set_type(GLMessage::DataType::INT);
+    arg_flags->add_intvalue(flags);
+
+    // copy argument timeout
+    GLMessage_DataType *arg_timeout = glmsg.add_args();
+    arg_timeout->set_isarray(false);
+    arg_timeout->set_type(GLMessage::DataType::INT64);
+    arg_timeout->add_int64value(timeout);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glWaitSyncAPPLE(sync, flags, timeout);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) sync,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetInteger64vAPPLE(GLenum pname, GLint64 * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetInteger64vAPPLE);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetInteger64vAPPLE(pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetSyncivAPPLE(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetSyncivAPPLE);
+
+    // copy argument sync
+    GLMessage_DataType *arg_sync = glmsg.add_args();
+    arg_sync->set_isarray(false);
+    arg_sync->set_type(GLMessage::DataType::INT64);
+    arg_sync->add_int64value((uintptr_t)sync);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument bufSize
+    GLMessage_DataType *arg_bufSize = glmsg.add_args();
+    arg_bufSize->set_isarray(false);
+    arg_bufSize->set_type(GLMessage::DataType::INT);
+    arg_bufSize->add_intvalue(bufSize);
+
+    // copy argument length
+    GLMessage_DataType *arg_length = glmsg.add_args();
+    arg_length->set_isarray(false);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
+
+    // copy argument values
+    GLMessage_DataType *arg_values = glmsg.add_args();
+    arg_values->set_isarray(false);
+    arg_values->set_type(GLMessage::DataType::INT64);
+    arg_values->add_int64value((uintptr_t)values);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetSyncivAPPLE(sync, pname, bufSize, length, values);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) sync,
+        (void *) length,
+        (void *) values,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glCopyImageSubDataEXT(GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glCopyImageSubDataEXT);
+
+    // copy argument srcName
+    GLMessage_DataType *arg_srcName = glmsg.add_args();
+    arg_srcName->set_isarray(false);
+    arg_srcName->set_type(GLMessage::DataType::INT);
+    arg_srcName->add_intvalue(srcName);
+
+    // copy argument srcTarget
+    GLMessage_DataType *arg_srcTarget = glmsg.add_args();
+    arg_srcTarget->set_isarray(false);
+    arg_srcTarget->set_type(GLMessage::DataType::ENUM);
+    arg_srcTarget->add_intvalue((int)srcTarget);
+
+    // copy argument srcLevel
+    GLMessage_DataType *arg_srcLevel = glmsg.add_args();
+    arg_srcLevel->set_isarray(false);
+    arg_srcLevel->set_type(GLMessage::DataType::INT);
+    arg_srcLevel->add_intvalue(srcLevel);
+
+    // copy argument srcX
+    GLMessage_DataType *arg_srcX = glmsg.add_args();
+    arg_srcX->set_isarray(false);
+    arg_srcX->set_type(GLMessage::DataType::INT);
+    arg_srcX->add_intvalue(srcX);
+
+    // copy argument srcY
+    GLMessage_DataType *arg_srcY = glmsg.add_args();
+    arg_srcY->set_isarray(false);
+    arg_srcY->set_type(GLMessage::DataType::INT);
+    arg_srcY->add_intvalue(srcY);
+
+    // copy argument srcZ
+    GLMessage_DataType *arg_srcZ = glmsg.add_args();
+    arg_srcZ->set_isarray(false);
+    arg_srcZ->set_type(GLMessage::DataType::INT);
+    arg_srcZ->add_intvalue(srcZ);
+
+    // copy argument dstName
+    GLMessage_DataType *arg_dstName = glmsg.add_args();
+    arg_dstName->set_isarray(false);
+    arg_dstName->set_type(GLMessage::DataType::INT);
+    arg_dstName->add_intvalue(dstName);
+
+    // copy argument dstTarget
+    GLMessage_DataType *arg_dstTarget = glmsg.add_args();
+    arg_dstTarget->set_isarray(false);
+    arg_dstTarget->set_type(GLMessage::DataType::ENUM);
+    arg_dstTarget->add_intvalue((int)dstTarget);
+
+    // copy argument dstLevel
+    GLMessage_DataType *arg_dstLevel = glmsg.add_args();
+    arg_dstLevel->set_isarray(false);
+    arg_dstLevel->set_type(GLMessage::DataType::INT);
+    arg_dstLevel->add_intvalue(dstLevel);
+
+    // copy argument dstX
+    GLMessage_DataType *arg_dstX = glmsg.add_args();
+    arg_dstX->set_isarray(false);
+    arg_dstX->set_type(GLMessage::DataType::INT);
+    arg_dstX->add_intvalue(dstX);
+
+    // copy argument dstY
+    GLMessage_DataType *arg_dstY = glmsg.add_args();
+    arg_dstY->set_isarray(false);
+    arg_dstY->set_type(GLMessage::DataType::INT);
+    arg_dstY->add_intvalue(dstY);
+
+    // copy argument dstZ
+    GLMessage_DataType *arg_dstZ = glmsg.add_args();
+    arg_dstZ->set_isarray(false);
+    arg_dstZ->set_type(GLMessage::DataType::INT);
+    arg_dstZ->add_intvalue(dstZ);
+
+    // copy argument srcWidth
+    GLMessage_DataType *arg_srcWidth = glmsg.add_args();
+    arg_srcWidth->set_isarray(false);
+    arg_srcWidth->set_type(GLMessage::DataType::INT);
+    arg_srcWidth->add_intvalue(srcWidth);
+
+    // copy argument srcHeight
+    GLMessage_DataType *arg_srcHeight = glmsg.add_args();
+    arg_srcHeight->set_isarray(false);
+    arg_srcHeight->set_type(GLMessage::DataType::INT);
+    arg_srcHeight->add_intvalue(srcHeight);
+
+    // copy argument srcDepth
+    GLMessage_DataType *arg_srcDepth = glmsg.add_args();
+    arg_srcDepth->set_isarray(false);
+    arg_srcDepth->set_type(GLMessage::DataType::INT);
+    arg_srcDepth->add_intvalue(srcDepth);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glCopyImageSubDataEXT(srcName, srcTarget, srcLevel, srcX, srcY, srcZ, dstName, dstTarget, dstLevel, dstX, dstY, dstZ, srcWidth, srcHeight, srcDepth);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glLabelObjectEXT(GLenum type, GLuint object, GLsizei length, const GLchar * label) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -11978,7 +16359,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetObjectLabelEXT(GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label) {
+void GLTrace_glGetObjectLabelEXT(GLenum type, GLuint object, GLsizei bufSize, GLsizei * length, GLchar * label) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -12032,7 +16413,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glInsertEventMarkerEXT(GLsizei length, const GLchar *marker) {
+void GLTrace_glInsertEventMarkerEXT(GLsizei length, const GLchar * marker) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -12067,7 +16448,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glPushGroupMarkerEXT(GLsizei length, const GLchar *marker) {
+void GLTrace_glPushGroupMarkerEXT(GLsizei length, const GLchar * marker) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -12124,7 +16505,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum *attachments) {
+void GLTrace_glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum * attachments) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -12165,219 +16546,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glRenderbufferStorageMultisampleEXT(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glRenderbufferStorageMultisampleEXT);
-
-    // copy argument target
-    GLMessage_DataType *arg_target = glmsg.add_args();
-    arg_target->set_isarray(false);
-    arg_target->set_type(GLMessage::DataType::ENUM);
-    arg_target->add_intvalue((int)target);
-
-    // copy argument samples
-    GLMessage_DataType *arg_samples = glmsg.add_args();
-    arg_samples->set_isarray(false);
-    arg_samples->set_type(GLMessage::DataType::INT);
-    arg_samples->add_intvalue(samples);
-
-    // copy argument internalformat
-    GLMessage_DataType *arg_internalformat = glmsg.add_args();
-    arg_internalformat->set_isarray(false);
-    arg_internalformat->set_type(GLMessage::DataType::ENUM);
-    arg_internalformat->add_intvalue((int)internalformat);
-
-    // copy argument width
-    GLMessage_DataType *arg_width = glmsg.add_args();
-    arg_width->set_isarray(false);
-    arg_width->set_type(GLMessage::DataType::INT);
-    arg_width->add_intvalue(width);
-
-    // copy argument height
-    GLMessage_DataType *arg_height = glmsg.add_args();
-    arg_height->set_isarray(false);
-    arg_height->set_type(GLMessage::DataType::INT);
-    arg_height->add_intvalue(height);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glRenderbufferStorageMultisampleEXT(target, samples, internalformat, width, height);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glFramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glFramebufferTexture2DMultisampleEXT);
-
-    // copy argument target
-    GLMessage_DataType *arg_target = glmsg.add_args();
-    arg_target->set_isarray(false);
-    arg_target->set_type(GLMessage::DataType::ENUM);
-    arg_target->add_intvalue((int)target);
-
-    // copy argument attachment
-    GLMessage_DataType *arg_attachment = glmsg.add_args();
-    arg_attachment->set_isarray(false);
-    arg_attachment->set_type(GLMessage::DataType::ENUM);
-    arg_attachment->add_intvalue((int)attachment);
-
-    // copy argument textarget
-    GLMessage_DataType *arg_textarget = glmsg.add_args();
-    arg_textarget->set_isarray(false);
-    arg_textarget->set_type(GLMessage::DataType::ENUM);
-    arg_textarget->add_intvalue((int)textarget);
-
-    // copy argument texture
-    GLMessage_DataType *arg_texture = glmsg.add_args();
-    arg_texture->set_isarray(false);
-    arg_texture->set_type(GLMessage::DataType::INT);
-    arg_texture->add_intvalue(texture);
-
-    // copy argument level
-    GLMessage_DataType *arg_level = glmsg.add_args();
-    arg_level->set_isarray(false);
-    arg_level->set_type(GLMessage::DataType::INT);
-    arg_level->add_intvalue(level);
-
-    // copy argument samples
-    GLMessage_DataType *arg_samples = glmsg.add_args();
-    arg_samples->set_isarray(false);
-    arg_samples->set_type(GLMessage::DataType::INT);
-    arg_samples->add_intvalue(samples);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glFramebufferTexture2DMultisampleEXT(target, attachment, textarget, texture, level, samples);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glMultiDrawArraysEXT(GLenum mode, GLint *first, GLsizei *count, GLsizei primcount) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glMultiDrawArraysEXT);
-
-    // copy argument mode
-    GLMessage_DataType *arg_mode = glmsg.add_args();
-    arg_mode->set_isarray(false);
-    arg_mode->set_type(GLMessage::DataType::ENUM);
-    arg_mode->add_intvalue((int)mode);
-
-    // copy argument first
-    GLMessage_DataType *arg_first = glmsg.add_args();
-    arg_first->set_isarray(false);
-    arg_first->set_type(GLMessage::DataType::INT64);
-    arg_first->add_int64value((uintptr_t)first);
-
-    // copy argument count
-    GLMessage_DataType *arg_count = glmsg.add_args();
-    arg_count->set_isarray(false);
-    arg_count->set_type(GLMessage::DataType::INT64);
-    arg_count->add_int64value((uintptr_t)count);
-
-    // copy argument primcount
-    GLMessage_DataType *arg_primcount = glmsg.add_args();
-    arg_primcount->set_isarray(false);
-    arg_primcount->set_type(GLMessage::DataType::INT);
-    arg_primcount->add_intvalue(primcount);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glMultiDrawArraysEXT(mode, first, count, primcount);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-        (void *) first,
-        (void *) count,
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glMultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glMultiDrawElementsEXT);
-
-    // copy argument mode
-    GLMessage_DataType *arg_mode = glmsg.add_args();
-    arg_mode->set_isarray(false);
-    arg_mode->set_type(GLMessage::DataType::ENUM);
-    arg_mode->add_intvalue((int)mode);
-
-    // copy argument count
-    GLMessage_DataType *arg_count = glmsg.add_args();
-    arg_count->set_isarray(false);
-    arg_count->set_type(GLMessage::DataType::INT64);
-    arg_count->add_int64value((uintptr_t)count);
-
-    // copy argument type
-    GLMessage_DataType *arg_type = glmsg.add_args();
-    arg_type->set_isarray(false);
-    arg_type->set_type(GLMessage::DataType::ENUM);
-    arg_type->add_intvalue((int)type);
-
-    // copy argument indices
-    GLMessage_DataType *arg_indices = glmsg.add_args();
-    arg_indices->set_isarray(false);
-    arg_indices->set_type(GLMessage::DataType::INT64);
-    arg_indices->add_int64value((uintptr_t)indices);
-
-    // copy argument primcount
-    GLMessage_DataType *arg_primcount = glmsg.add_args();
-    arg_primcount->set_isarray(false);
-    arg_primcount->set_type(GLMessage::DataType::INT);
-    arg_primcount->add_intvalue(primcount);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glMultiDrawElementsEXT(mode, count, type, indices, primcount);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-        (void *) count,
-        (void *) indices,
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glGenQueriesEXT(GLsizei n, GLuint *ids) {
+void GLTrace_glGenQueriesEXT(GLsizei n, GLuint * ids) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -12412,7 +16581,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDeleteQueriesEXT(GLsizei n, const GLuint *ids) {
+void GLTrace_glDeleteQueriesEXT(GLsizei n, const GLuint * ids) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -12545,7 +16714,41 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetQueryivEXT(GLenum target, GLenum pname, GLint *params) {
+void GLTrace_glQueryCounterEXT(GLuint id, GLenum target) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glQueryCounterEXT);
+
+    // copy argument id
+    GLMessage_DataType *arg_id = glmsg.add_args();
+    arg_id->set_isarray(false);
+    arg_id->set_type(GLMessage::DataType::INT);
+    arg_id->add_intvalue(id);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glQueryCounterEXT(id, target);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetQueryivEXT(GLenum target, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -12586,7 +16789,48 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) {
+void GLTrace_glGetQueryObjectivEXT(GLuint id, GLenum pname, GLint * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetQueryObjectivEXT);
+
+    // copy argument id
+    GLMessage_DataType *arg_id = glmsg.add_args();
+    arg_id->set_isarray(false);
+    arg_id->set_type(GLMessage::DataType::INT);
+    arg_id->add_intvalue(id);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetQueryObjectivEXT(id, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -12627,6 +16871,1124 @@
     glContext->traceGLMessage(&glmsg);
 }
 
+void GLTrace_glGetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64 * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetQueryObjecti64vEXT);
+
+    // copy argument id
+    GLMessage_DataType *arg_id = glmsg.add_args();
+    arg_id->set_isarray(false);
+    arg_id->set_type(GLMessage::DataType::INT);
+    arg_id->add_intvalue(id);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetQueryObjecti64vEXT(id, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64 * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetQueryObjectui64vEXT);
+
+    // copy argument id
+    GLMessage_DataType *arg_id = glmsg.add_args();
+    arg_id->set_isarray(false);
+    arg_id->set_type(GLMessage::DataType::INT);
+    arg_id->add_intvalue(id);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetQueryObjectui64vEXT(id, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glDrawBuffersEXT(GLsizei n, const GLenum * bufs) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDrawBuffersEXT);
+
+    // copy argument n
+    GLMessage_DataType *arg_n = glmsg.add_args();
+    arg_n->set_isarray(false);
+    arg_n->set_type(GLMessage::DataType::INT);
+    arg_n->add_intvalue(n);
+
+    // copy argument bufs
+    GLMessage_DataType *arg_bufs = glmsg.add_args();
+    arg_bufs->set_isarray(false);
+    arg_bufs->set_type(GLMessage::DataType::INT64);
+    arg_bufs->add_int64value((uintptr_t)bufs);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDrawBuffersEXT(n, bufs);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) bufs,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glEnableiEXT(GLenum target, GLuint index) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glEnableiEXT);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glEnableiEXT(target, index);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glDisableiEXT(GLenum target, GLuint index) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDisableiEXT);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDisableiEXT(target, index);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glBlendEquationiEXT(GLuint buf, GLenum mode) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glBlendEquationiEXT);
+
+    // copy argument buf
+    GLMessage_DataType *arg_buf = glmsg.add_args();
+    arg_buf->set_isarray(false);
+    arg_buf->set_type(GLMessage::DataType::INT);
+    arg_buf->add_intvalue(buf);
+
+    // copy argument mode
+    GLMessage_DataType *arg_mode = glmsg.add_args();
+    arg_mode->set_isarray(false);
+    arg_mode->set_type(GLMessage::DataType::ENUM);
+    arg_mode->add_intvalue((int)mode);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glBlendEquationiEXT(buf, mode);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glBlendEquationSeparateiEXT(GLuint buf, GLenum modeRGB, GLenum modeAlpha) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glBlendEquationSeparateiEXT);
+
+    // copy argument buf
+    GLMessage_DataType *arg_buf = glmsg.add_args();
+    arg_buf->set_isarray(false);
+    arg_buf->set_type(GLMessage::DataType::INT);
+    arg_buf->add_intvalue(buf);
+
+    // copy argument modeRGB
+    GLMessage_DataType *arg_modeRGB = glmsg.add_args();
+    arg_modeRGB->set_isarray(false);
+    arg_modeRGB->set_type(GLMessage::DataType::ENUM);
+    arg_modeRGB->add_intvalue((int)modeRGB);
+
+    // copy argument modeAlpha
+    GLMessage_DataType *arg_modeAlpha = glmsg.add_args();
+    arg_modeAlpha->set_isarray(false);
+    arg_modeAlpha->set_type(GLMessage::DataType::ENUM);
+    arg_modeAlpha->add_intvalue((int)modeAlpha);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glBlendEquationSeparateiEXT(buf, modeRGB, modeAlpha);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glBlendFunciEXT(GLuint buf, GLenum src, GLenum dst) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glBlendFunciEXT);
+
+    // copy argument buf
+    GLMessage_DataType *arg_buf = glmsg.add_args();
+    arg_buf->set_isarray(false);
+    arg_buf->set_type(GLMessage::DataType::INT);
+    arg_buf->add_intvalue(buf);
+
+    // copy argument src
+    GLMessage_DataType *arg_src = glmsg.add_args();
+    arg_src->set_isarray(false);
+    arg_src->set_type(GLMessage::DataType::ENUM);
+    arg_src->add_intvalue((int)src);
+
+    // copy argument dst
+    GLMessage_DataType *arg_dst = glmsg.add_args();
+    arg_dst->set_isarray(false);
+    arg_dst->set_type(GLMessage::DataType::ENUM);
+    arg_dst->add_intvalue((int)dst);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glBlendFunciEXT(buf, src, dst);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glBlendFuncSeparateiEXT(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glBlendFuncSeparateiEXT);
+
+    // copy argument buf
+    GLMessage_DataType *arg_buf = glmsg.add_args();
+    arg_buf->set_isarray(false);
+    arg_buf->set_type(GLMessage::DataType::INT);
+    arg_buf->add_intvalue(buf);
+
+    // copy argument srcRGB
+    GLMessage_DataType *arg_srcRGB = glmsg.add_args();
+    arg_srcRGB->set_isarray(false);
+    arg_srcRGB->set_type(GLMessage::DataType::ENUM);
+    arg_srcRGB->add_intvalue((int)srcRGB);
+
+    // copy argument dstRGB
+    GLMessage_DataType *arg_dstRGB = glmsg.add_args();
+    arg_dstRGB->set_isarray(false);
+    arg_dstRGB->set_type(GLMessage::DataType::ENUM);
+    arg_dstRGB->add_intvalue((int)dstRGB);
+
+    // copy argument srcAlpha
+    GLMessage_DataType *arg_srcAlpha = glmsg.add_args();
+    arg_srcAlpha->set_isarray(false);
+    arg_srcAlpha->set_type(GLMessage::DataType::ENUM);
+    arg_srcAlpha->add_intvalue((int)srcAlpha);
+
+    // copy argument dstAlpha
+    GLMessage_DataType *arg_dstAlpha = glmsg.add_args();
+    arg_dstAlpha->set_isarray(false);
+    arg_dstAlpha->set_type(GLMessage::DataType::ENUM);
+    arg_dstAlpha->add_intvalue((int)dstAlpha);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glBlendFuncSeparateiEXT(buf, srcRGB, dstRGB, srcAlpha, dstAlpha);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glColorMaskiEXT(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glColorMaskiEXT);
+
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
+
+    // copy argument r
+    GLMessage_DataType *arg_r = glmsg.add_args();
+    arg_r->set_isarray(false);
+    arg_r->set_type(GLMessage::DataType::BOOL);
+    arg_r->add_boolvalue(r);
+
+    // copy argument g
+    GLMessage_DataType *arg_g = glmsg.add_args();
+    arg_g->set_isarray(false);
+    arg_g->set_type(GLMessage::DataType::BOOL);
+    arg_g->add_boolvalue(g);
+
+    // copy argument b
+    GLMessage_DataType *arg_b = glmsg.add_args();
+    arg_b->set_isarray(false);
+    arg_b->set_type(GLMessage::DataType::BOOL);
+    arg_b->add_boolvalue(b);
+
+    // copy argument a
+    GLMessage_DataType *arg_a = glmsg.add_args();
+    arg_a->set_isarray(false);
+    arg_a->set_type(GLMessage::DataType::BOOL);
+    arg_a->add_boolvalue(a);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glColorMaskiEXT(index, r, g, b, a);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+GLboolean GLTrace_glIsEnablediEXT(GLenum target, GLuint index) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glIsEnablediEXT);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    GLboolean retValue = glContext->hooks->gl.glIsEnablediEXT(target, index);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    // set return value
+    GLMessage_DataType *rt = glmsg.mutable_returnvalue();
+    rt->set_isarray(false);
+    rt->set_type(GLMessage::DataType::BOOL);
+    rt->add_boolvalue(retValue);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+
+    return retValue;
+}
+
+void GLTrace_glDrawArraysInstancedEXT(GLenum mode, GLint start, GLsizei count, GLsizei primcount) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDrawArraysInstancedEXT);
+
+    // copy argument mode
+    GLMessage_DataType *arg_mode = glmsg.add_args();
+    arg_mode->set_isarray(false);
+    arg_mode->set_type(GLMessage::DataType::ENUM);
+    arg_mode->add_intvalue((int)mode);
+
+    // copy argument start
+    GLMessage_DataType *arg_start = glmsg.add_args();
+    arg_start->set_isarray(false);
+    arg_start->set_type(GLMessage::DataType::INT);
+    arg_start->add_intvalue(start);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument primcount
+    GLMessage_DataType *arg_primcount = glmsg.add_args();
+    arg_primcount->set_isarray(false);
+    arg_primcount->set_type(GLMessage::DataType::INT);
+    arg_primcount->add_intvalue(primcount);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDrawArraysInstancedEXT(mode, start, count, primcount);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glDrawElementsInstancedEXT(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDrawElementsInstancedEXT);
+
+    // copy argument mode
+    GLMessage_DataType *arg_mode = glmsg.add_args();
+    arg_mode->set_isarray(false);
+    arg_mode->set_type(GLMessage::DataType::ENUM);
+    arg_mode->add_intvalue((int)mode);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument type
+    GLMessage_DataType *arg_type = glmsg.add_args();
+    arg_type->set_isarray(false);
+    arg_type->set_type(GLMessage::DataType::ENUM);
+    arg_type->add_intvalue((int)type);
+
+    // copy argument indices
+    GLMessage_DataType *arg_indices = glmsg.add_args();
+    arg_indices->set_isarray(false);
+    arg_indices->set_type(GLMessage::DataType::INT64);
+    arg_indices->add_int64value((uintptr_t)indices);
+
+    // copy argument primcount
+    GLMessage_DataType *arg_primcount = glmsg.add_args();
+    arg_primcount->set_isarray(false);
+    arg_primcount->set_type(GLMessage::DataType::INT);
+    arg_primcount->add_intvalue(primcount);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDrawElementsInstancedEXT(mode, count, type, indices, primcount);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) indices,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glFramebufferTextureEXT(GLenum target, GLenum attachment, GLuint texture, GLint level) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glFramebufferTextureEXT);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument attachment
+    GLMessage_DataType *arg_attachment = glmsg.add_args();
+    arg_attachment->set_isarray(false);
+    arg_attachment->set_type(GLMessage::DataType::ENUM);
+    arg_attachment->add_intvalue((int)attachment);
+
+    // copy argument texture
+    GLMessage_DataType *arg_texture = glmsg.add_args();
+    arg_texture->set_isarray(false);
+    arg_texture->set_type(GLMessage::DataType::INT);
+    arg_texture->add_intvalue(texture);
+
+    // copy argument level
+    GLMessage_DataType *arg_level = glmsg.add_args();
+    arg_level->set_isarray(false);
+    arg_level->set_type(GLMessage::DataType::INT);
+    arg_level->add_intvalue(level);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glFramebufferTextureEXT(target, attachment, texture, level);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glVertexAttribDivisorEXT(GLuint index, GLuint divisor) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glVertexAttribDivisorEXT);
+
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
+
+    // copy argument divisor
+    GLMessage_DataType *arg_divisor = glmsg.add_args();
+    arg_divisor->set_isarray(false);
+    arg_divisor->set_type(GLMessage::DataType::INT);
+    arg_divisor->add_intvalue(divisor);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glVertexAttribDivisorEXT(index, divisor);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void * GLTrace_glMapBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glMapBufferRangeEXT);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument offset
+    GLMessage_DataType *arg_offset = glmsg.add_args();
+    arg_offset->set_isarray(false);
+    arg_offset->set_type(GLMessage::DataType::INT);
+    arg_offset->add_intvalue(offset);
+
+    // copy argument length
+    GLMessage_DataType *arg_length = glmsg.add_args();
+    arg_length->set_isarray(false);
+    arg_length->set_type(GLMessage::DataType::INT);
+    arg_length->add_intvalue(length);
+
+    // copy argument access
+    GLMessage_DataType *arg_access = glmsg.add_args();
+    arg_access->set_isarray(false);
+    arg_access->set_type(GLMessage::DataType::INT);
+    arg_access->add_intvalue(access);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    void * retValue = glContext->hooks->gl.glMapBufferRangeEXT(target, offset, length, access);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    // set return value
+    GLMessage_DataType *rt = glmsg.mutable_returnvalue();
+    rt->set_isarray(false);
+    rt->set_type(GLMessage::DataType::INT64);
+    rt->add_int64value((uintptr_t)retValue);
+
+    void *pointerArgs[] = {
+        (void *) retValue,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+
+    return retValue;
+}
+
+void GLTrace_glFlushMappedBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glFlushMappedBufferRangeEXT);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument offset
+    GLMessage_DataType *arg_offset = glmsg.add_args();
+    arg_offset->set_isarray(false);
+    arg_offset->set_type(GLMessage::DataType::INT);
+    arg_offset->add_intvalue(offset);
+
+    // copy argument length
+    GLMessage_DataType *arg_length = glmsg.add_args();
+    arg_length->set_isarray(false);
+    arg_length->set_type(GLMessage::DataType::INT);
+    arg_length->add_intvalue(length);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glFlushMappedBufferRangeEXT(target, offset, length);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glMultiDrawArraysEXT(GLenum mode, const GLint * first, const GLsizei * count, GLsizei primcount) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glMultiDrawArraysEXT);
+
+    // copy argument mode
+    GLMessage_DataType *arg_mode = glmsg.add_args();
+    arg_mode->set_isarray(false);
+    arg_mode->set_type(GLMessage::DataType::ENUM);
+    arg_mode->add_intvalue((int)mode);
+
+    // copy argument first
+    GLMessage_DataType *arg_first = glmsg.add_args();
+    arg_first->set_isarray(false);
+    arg_first->set_type(GLMessage::DataType::INT64);
+    arg_first->add_int64value((uintptr_t)first);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT64);
+    arg_count->add_int64value((uintptr_t)count);
+
+    // copy argument primcount
+    GLMessage_DataType *arg_primcount = glmsg.add_args();
+    arg_primcount->set_isarray(false);
+    arg_primcount->set_type(GLMessage::DataType::INT);
+    arg_primcount->add_intvalue(primcount);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glMultiDrawArraysEXT(mode, first, count, primcount);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) first,
+        (void *) count,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glMultiDrawElementsEXT(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei primcount) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glMultiDrawElementsEXT);
+
+    // copy argument mode
+    GLMessage_DataType *arg_mode = glmsg.add_args();
+    arg_mode->set_isarray(false);
+    arg_mode->set_type(GLMessage::DataType::ENUM);
+    arg_mode->add_intvalue((int)mode);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT64);
+    arg_count->add_int64value((uintptr_t)count);
+
+    // copy argument type
+    GLMessage_DataType *arg_type = glmsg.add_args();
+    arg_type->set_isarray(false);
+    arg_type->set_type(GLMessage::DataType::ENUM);
+    arg_type->add_intvalue((int)type);
+
+    // copy argument indices
+    GLMessage_DataType *arg_indices = glmsg.add_args();
+    arg_indices->set_isarray(false);
+    arg_indices->set_type(GLMessage::DataType::INT64);
+    arg_indices->add_int64value((uintptr_t)indices);
+
+    // copy argument primcount
+    GLMessage_DataType *arg_primcount = glmsg.add_args();
+    arg_primcount->set_isarray(false);
+    arg_primcount->set_type(GLMessage::DataType::INT);
+    arg_primcount->add_intvalue(primcount);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glMultiDrawElementsEXT(mode, count, type, indices, primcount);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) count,
+        (void *) indices,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glRenderbufferStorageMultisampleEXT(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glRenderbufferStorageMultisampleEXT);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument samples
+    GLMessage_DataType *arg_samples = glmsg.add_args();
+    arg_samples->set_isarray(false);
+    arg_samples->set_type(GLMessage::DataType::INT);
+    arg_samples->add_intvalue(samples);
+
+    // copy argument internalformat
+    GLMessage_DataType *arg_internalformat = glmsg.add_args();
+    arg_internalformat->set_isarray(false);
+    arg_internalformat->set_type(GLMessage::DataType::ENUM);
+    arg_internalformat->add_intvalue((int)internalformat);
+
+    // copy argument width
+    GLMessage_DataType *arg_width = glmsg.add_args();
+    arg_width->set_isarray(false);
+    arg_width->set_type(GLMessage::DataType::INT);
+    arg_width->add_intvalue(width);
+
+    // copy argument height
+    GLMessage_DataType *arg_height = glmsg.add_args();
+    arg_height->set_isarray(false);
+    arg_height->set_type(GLMessage::DataType::INT);
+    arg_height->add_intvalue(height);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glRenderbufferStorageMultisampleEXT(target, samples, internalformat, width, height);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glFramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glFramebufferTexture2DMultisampleEXT);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument attachment
+    GLMessage_DataType *arg_attachment = glmsg.add_args();
+    arg_attachment->set_isarray(false);
+    arg_attachment->set_type(GLMessage::DataType::ENUM);
+    arg_attachment->add_intvalue((int)attachment);
+
+    // copy argument textarget
+    GLMessage_DataType *arg_textarget = glmsg.add_args();
+    arg_textarget->set_isarray(false);
+    arg_textarget->set_type(GLMessage::DataType::ENUM);
+    arg_textarget->add_intvalue((int)textarget);
+
+    // copy argument texture
+    GLMessage_DataType *arg_texture = glmsg.add_args();
+    arg_texture->set_isarray(false);
+    arg_texture->set_type(GLMessage::DataType::INT);
+    arg_texture->add_intvalue(texture);
+
+    // copy argument level
+    GLMessage_DataType *arg_level = glmsg.add_args();
+    arg_level->set_isarray(false);
+    arg_level->set_type(GLMessage::DataType::INT);
+    arg_level->add_intvalue(level);
+
+    // copy argument samples
+    GLMessage_DataType *arg_samples = glmsg.add_args();
+    arg_samples->set_isarray(false);
+    arg_samples->set_type(GLMessage::DataType::INT);
+    arg_samples->add_intvalue(samples);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glFramebufferTexture2DMultisampleEXT(target, attachment, textarget, texture, level, samples);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glReadBufferIndexedEXT(GLenum src, GLint index) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glReadBufferIndexedEXT);
+
+    // copy argument src
+    GLMessage_DataType *arg_src = glmsg.add_args();
+    arg_src->set_isarray(false);
+    arg_src->set_type(GLMessage::DataType::ENUM);
+    arg_src->add_intvalue((int)src);
+
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glReadBufferIndexedEXT(src, index);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glDrawBuffersIndexedEXT(GLint n, const GLenum * location, const GLint * indices) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDrawBuffersIndexedEXT);
+
+    // copy argument n
+    GLMessage_DataType *arg_n = glmsg.add_args();
+    arg_n->set_isarray(false);
+    arg_n->set_type(GLMessage::DataType::INT);
+    arg_n->add_intvalue(n);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT64);
+    arg_location->add_int64value((uintptr_t)location);
+
+    // copy argument indices
+    GLMessage_DataType *arg_indices = glmsg.add_args();
+    arg_indices->set_isarray(false);
+    arg_indices->set_type(GLMessage::DataType::INT64);
+    arg_indices->add_int64value((uintptr_t)indices);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDrawBuffersIndexedEXT(n, location, indices);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) location,
+        (void *) indices,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetIntegeri_vEXT(GLenum target, GLuint index, GLint * data) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetIntegeri_vEXT);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
+
+    // copy argument data
+    GLMessage_DataType *arg_data = glmsg.add_args();
+    arg_data->set_isarray(false);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetIntegeri_vEXT(target, index, data);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) data,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glPrimitiveBoundingBoxEXT(GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glPrimitiveBoundingBoxEXT);
+
+    // copy argument minX
+    GLMessage_DataType *arg_minX = glmsg.add_args();
+    arg_minX->set_isarray(false);
+    arg_minX->set_type(GLMessage::DataType::FLOAT);
+    arg_minX->add_floatvalue(minX);
+
+    // copy argument minY
+    GLMessage_DataType *arg_minY = glmsg.add_args();
+    arg_minY->set_isarray(false);
+    arg_minY->set_type(GLMessage::DataType::FLOAT);
+    arg_minY->add_floatvalue(minY);
+
+    // copy argument minZ
+    GLMessage_DataType *arg_minZ = glmsg.add_args();
+    arg_minZ->set_isarray(false);
+    arg_minZ->set_type(GLMessage::DataType::FLOAT);
+    arg_minZ->add_floatvalue(minZ);
+
+    // copy argument minW
+    GLMessage_DataType *arg_minW = glmsg.add_args();
+    arg_minW->set_isarray(false);
+    arg_minW->set_type(GLMessage::DataType::FLOAT);
+    arg_minW->add_floatvalue(minW);
+
+    // copy argument maxX
+    GLMessage_DataType *arg_maxX = glmsg.add_args();
+    arg_maxX->set_isarray(false);
+    arg_maxX->set_type(GLMessage::DataType::FLOAT);
+    arg_maxX->add_floatvalue(maxX);
+
+    // copy argument maxY
+    GLMessage_DataType *arg_maxY = glmsg.add_args();
+    arg_maxY->set_isarray(false);
+    arg_maxY->set_type(GLMessage::DataType::FLOAT);
+    arg_maxY->add_floatvalue(maxY);
+
+    // copy argument maxZ
+    GLMessage_DataType *arg_maxZ = glmsg.add_args();
+    arg_maxZ->set_isarray(false);
+    arg_maxZ->set_type(GLMessage::DataType::FLOAT);
+    arg_maxZ->add_floatvalue(maxZ);
+
+    // copy argument maxW
+    GLMessage_DataType *arg_maxW = glmsg.add_args();
+    arg_maxW->set_isarray(false);
+    arg_maxW->set_type(GLMessage::DataType::FLOAT);
+    arg_maxW->add_floatvalue(maxW);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glPrimitiveBoundingBoxEXT(minX, minY, minZ, minW, maxX, maxY, maxZ, maxW);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
 GLenum GLTrace_glGetGraphicsResetStatusEXT(void) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
@@ -12657,7 +18019,7 @@
     return retValue;
 }
 
-void GLTrace_glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data) {
+void GLTrace_glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -12728,7 +18090,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, float *params) {
+void GLTrace_glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -12775,7 +18137,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint *params) {
+void GLTrace_glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -12822,46 +18184,6 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glUseProgramStagesEXT(GLuint pipeline, GLbitfield stages, GLuint program) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glUseProgramStagesEXT);
-
-    // copy argument pipeline
-    GLMessage_DataType *arg_pipeline = glmsg.add_args();
-    arg_pipeline->set_isarray(false);
-    arg_pipeline->set_type(GLMessage::DataType::INT);
-    arg_pipeline->add_intvalue(pipeline);
-
-    // copy argument stages
-    GLMessage_DataType *arg_stages = glmsg.add_args();
-    arg_stages->set_isarray(false);
-    arg_stages->set_type(GLMessage::DataType::INT);
-    arg_stages->add_intvalue(stages);
-
-    // copy argument program
-    GLMessage_DataType *arg_program = glmsg.add_args();
-    arg_program->set_isarray(false);
-    arg_program->set_type(GLMessage::DataType::INT);
-    arg_program->add_intvalue(program);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glUseProgramStagesEXT(pipeline, stages, program);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
 void GLTrace_glActiveShaderProgramEXT(GLuint pipeline, GLuint program) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
@@ -12896,7 +18218,35 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-GLuint GLTrace_glCreateShaderProgramvEXT(GLenum type, GLsizei count, const GLchar **strings) {
+void GLTrace_glBindProgramPipelineEXT(GLuint pipeline) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glBindProgramPipelineEXT);
+
+    // copy argument pipeline
+    GLMessage_DataType *arg_pipeline = glmsg.add_args();
+    arg_pipeline->set_isarray(false);
+    arg_pipeline->set_type(GLMessage::DataType::INT);
+    arg_pipeline->add_intvalue(pipeline);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glBindProgramPipelineEXT(pipeline);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+GLuint GLTrace_glCreateShaderProgramvEXT(GLenum type, GLsizei count, const GLchar ** strings) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -12945,35 +18295,7 @@
     return retValue;
 }
 
-void GLTrace_glBindProgramPipelineEXT(GLuint pipeline) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glBindProgramPipelineEXT);
-
-    // copy argument pipeline
-    GLMessage_DataType *arg_pipeline = glmsg.add_args();
-    arg_pipeline->set_isarray(false);
-    arg_pipeline->set_type(GLMessage::DataType::INT);
-    arg_pipeline->add_intvalue(pipeline);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glBindProgramPipelineEXT(pipeline);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glDeleteProgramPipelinesEXT(GLsizei n, const GLuint *pipelines) {
+void GLTrace_glDeleteProgramPipelinesEXT(GLsizei n, const GLuint * pipelines) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -13008,7 +18330,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGenProgramPipelinesEXT(GLsizei n, GLuint *pipelines) {
+void GLTrace_glGenProgramPipelinesEXT(GLsizei n, GLuint * pipelines) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -13043,6 +18365,95 @@
     glContext->traceGLMessage(&glmsg);
 }
 
+void GLTrace_glGetProgramPipelineInfoLogEXT(GLuint pipeline, GLsizei bufSize, GLsizei * length, GLchar * infoLog) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetProgramPipelineInfoLogEXT);
+
+    // copy argument pipeline
+    GLMessage_DataType *arg_pipeline = glmsg.add_args();
+    arg_pipeline->set_isarray(false);
+    arg_pipeline->set_type(GLMessage::DataType::INT);
+    arg_pipeline->add_intvalue(pipeline);
+
+    // copy argument bufSize
+    GLMessage_DataType *arg_bufSize = glmsg.add_args();
+    arg_bufSize->set_isarray(false);
+    arg_bufSize->set_type(GLMessage::DataType::INT);
+    arg_bufSize->add_intvalue(bufSize);
+
+    // copy argument length
+    GLMessage_DataType *arg_length = glmsg.add_args();
+    arg_length->set_isarray(false);
+    arg_length->set_type(GLMessage::DataType::INT64);
+    arg_length->add_int64value((uintptr_t)length);
+
+    // copy argument infoLog
+    GLMessage_DataType *arg_infoLog = glmsg.add_args();
+    arg_infoLog->set_isarray(false);
+    arg_infoLog->set_type(GLMessage::DataType::INT64);
+    arg_infoLog->add_int64value((uintptr_t)infoLog);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetProgramPipelineInfoLogEXT(pipeline, bufSize, length, infoLog);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) length,
+        (void *) infoLog,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetProgramPipelineivEXT(GLuint pipeline, GLenum pname, GLint * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetProgramPipelineivEXT);
+
+    // copy argument pipeline
+    GLMessage_DataType *arg_pipeline = glmsg.add_args();
+    arg_pipeline->set_isarray(false);
+    arg_pipeline->set_type(GLMessage::DataType::INT);
+    arg_pipeline->add_intvalue(pipeline);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetProgramPipelineivEXT(pipeline, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
 GLboolean GLTrace_glIsProgramPipelineEXT(GLuint pipeline) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
@@ -13119,244 +18530,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetProgramPipelineivEXT(GLuint pipeline, GLenum pname, GLint *params) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glGetProgramPipelineivEXT);
-
-    // copy argument pipeline
-    GLMessage_DataType *arg_pipeline = glmsg.add_args();
-    arg_pipeline->set_isarray(false);
-    arg_pipeline->set_type(GLMessage::DataType::INT);
-    arg_pipeline->add_intvalue(pipeline);
-
-    // copy argument pname
-    GLMessage_DataType *arg_pname = glmsg.add_args();
-    arg_pname->set_isarray(false);
-    arg_pname->set_type(GLMessage::DataType::ENUM);
-    arg_pname->add_intvalue((int)pname);
-
-    // copy argument params
-    GLMessage_DataType *arg_params = glmsg.add_args();
-    arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT64);
-    arg_params->add_int64value((uintptr_t)params);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetProgramPipelineivEXT(pipeline, pname, params);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-        (void *) params,
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glProgramUniform1iEXT(GLuint program, GLint location, GLint x) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glProgramUniform1iEXT);
-
-    // copy argument program
-    GLMessage_DataType *arg_program = glmsg.add_args();
-    arg_program->set_isarray(false);
-    arg_program->set_type(GLMessage::DataType::INT);
-    arg_program->add_intvalue(program);
-
-    // copy argument location
-    GLMessage_DataType *arg_location = glmsg.add_args();
-    arg_location->set_isarray(false);
-    arg_location->set_type(GLMessage::DataType::INT);
-    arg_location->add_intvalue(location);
-
-    // copy argument x
-    GLMessage_DataType *arg_x = glmsg.add_args();
-    arg_x->set_isarray(false);
-    arg_x->set_type(GLMessage::DataType::INT);
-    arg_x->add_intvalue(x);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glProgramUniform1iEXT(program, location, x);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glProgramUniform2iEXT(GLuint program, GLint location, GLint x, GLint y) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glProgramUniform2iEXT);
-
-    // copy argument program
-    GLMessage_DataType *arg_program = glmsg.add_args();
-    arg_program->set_isarray(false);
-    arg_program->set_type(GLMessage::DataType::INT);
-    arg_program->add_intvalue(program);
-
-    // copy argument location
-    GLMessage_DataType *arg_location = glmsg.add_args();
-    arg_location->set_isarray(false);
-    arg_location->set_type(GLMessage::DataType::INT);
-    arg_location->add_intvalue(location);
-
-    // copy argument x
-    GLMessage_DataType *arg_x = glmsg.add_args();
-    arg_x->set_isarray(false);
-    arg_x->set_type(GLMessage::DataType::INT);
-    arg_x->add_intvalue(x);
-
-    // copy argument y
-    GLMessage_DataType *arg_y = glmsg.add_args();
-    arg_y->set_isarray(false);
-    arg_y->set_type(GLMessage::DataType::INT);
-    arg_y->add_intvalue(y);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glProgramUniform2iEXT(program, location, x, y);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glProgramUniform3iEXT(GLuint program, GLint location, GLint x, GLint y, GLint z) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glProgramUniform3iEXT);
-
-    // copy argument program
-    GLMessage_DataType *arg_program = glmsg.add_args();
-    arg_program->set_isarray(false);
-    arg_program->set_type(GLMessage::DataType::INT);
-    arg_program->add_intvalue(program);
-
-    // copy argument location
-    GLMessage_DataType *arg_location = glmsg.add_args();
-    arg_location->set_isarray(false);
-    arg_location->set_type(GLMessage::DataType::INT);
-    arg_location->add_intvalue(location);
-
-    // copy argument x
-    GLMessage_DataType *arg_x = glmsg.add_args();
-    arg_x->set_isarray(false);
-    arg_x->set_type(GLMessage::DataType::INT);
-    arg_x->add_intvalue(x);
-
-    // copy argument y
-    GLMessage_DataType *arg_y = glmsg.add_args();
-    arg_y->set_isarray(false);
-    arg_y->set_type(GLMessage::DataType::INT);
-    arg_y->add_intvalue(y);
-
-    // copy argument z
-    GLMessage_DataType *arg_z = glmsg.add_args();
-    arg_z->set_isarray(false);
-    arg_z->set_type(GLMessage::DataType::INT);
-    arg_z->add_intvalue(z);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glProgramUniform3iEXT(program, location, x, y, z);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glProgramUniform4iEXT(GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glProgramUniform4iEXT);
-
-    // copy argument program
-    GLMessage_DataType *arg_program = glmsg.add_args();
-    arg_program->set_isarray(false);
-    arg_program->set_type(GLMessage::DataType::INT);
-    arg_program->add_intvalue(program);
-
-    // copy argument location
-    GLMessage_DataType *arg_location = glmsg.add_args();
-    arg_location->set_isarray(false);
-    arg_location->set_type(GLMessage::DataType::INT);
-    arg_location->add_intvalue(location);
-
-    // copy argument x
-    GLMessage_DataType *arg_x = glmsg.add_args();
-    arg_x->set_isarray(false);
-    arg_x->set_type(GLMessage::DataType::INT);
-    arg_x->add_intvalue(x);
-
-    // copy argument y
-    GLMessage_DataType *arg_y = glmsg.add_args();
-    arg_y->set_isarray(false);
-    arg_y->set_type(GLMessage::DataType::INT);
-    arg_y->add_intvalue(y);
-
-    // copy argument z
-    GLMessage_DataType *arg_z = glmsg.add_args();
-    arg_z->set_isarray(false);
-    arg_z->set_type(GLMessage::DataType::INT);
-    arg_z->add_intvalue(z);
-
-    // copy argument w
-    GLMessage_DataType *arg_w = glmsg.add_args();
-    arg_w->set_isarray(false);
-    arg_w->set_type(GLMessage::DataType::INT);
-    arg_w->add_intvalue(w);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glProgramUniform4iEXT(program, location, x, y, z, w);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glProgramUniform1fEXT(GLuint program, GLint location, GLfloat x) {
+void GLTrace_glProgramUniform1fEXT(GLuint program, GLint location, GLfloat v0) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -13374,16 +18548,16 @@
     arg_location->set_type(GLMessage::DataType::INT);
     arg_location->add_intvalue(location);
 
-    // copy argument x
-    GLMessage_DataType *arg_x = glmsg.add_args();
-    arg_x->set_isarray(false);
-    arg_x->set_type(GLMessage::DataType::FLOAT);
-    arg_x->add_floatvalue(x);
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::FLOAT);
+    arg_v0->add_floatvalue(v0);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glProgramUniform1fEXT(program, location, x);
+    glContext->hooks->gl.glProgramUniform1fEXT(program, location, v0);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -13396,351 +18570,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glProgramUniform2fEXT(GLuint program, GLint location, GLfloat x, GLfloat y) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glProgramUniform2fEXT);
-
-    // copy argument program
-    GLMessage_DataType *arg_program = glmsg.add_args();
-    arg_program->set_isarray(false);
-    arg_program->set_type(GLMessage::DataType::INT);
-    arg_program->add_intvalue(program);
-
-    // copy argument location
-    GLMessage_DataType *arg_location = glmsg.add_args();
-    arg_location->set_isarray(false);
-    arg_location->set_type(GLMessage::DataType::INT);
-    arg_location->add_intvalue(location);
-
-    // copy argument x
-    GLMessage_DataType *arg_x = glmsg.add_args();
-    arg_x->set_isarray(false);
-    arg_x->set_type(GLMessage::DataType::FLOAT);
-    arg_x->add_floatvalue(x);
-
-    // copy argument y
-    GLMessage_DataType *arg_y = glmsg.add_args();
-    arg_y->set_isarray(false);
-    arg_y->set_type(GLMessage::DataType::FLOAT);
-    arg_y->add_floatvalue(y);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glProgramUniform2fEXT(program, location, x, y);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glProgramUniform3fEXT(GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glProgramUniform3fEXT);
-
-    // copy argument program
-    GLMessage_DataType *arg_program = glmsg.add_args();
-    arg_program->set_isarray(false);
-    arg_program->set_type(GLMessage::DataType::INT);
-    arg_program->add_intvalue(program);
-
-    // copy argument location
-    GLMessage_DataType *arg_location = glmsg.add_args();
-    arg_location->set_isarray(false);
-    arg_location->set_type(GLMessage::DataType::INT);
-    arg_location->add_intvalue(location);
-
-    // copy argument x
-    GLMessage_DataType *arg_x = glmsg.add_args();
-    arg_x->set_isarray(false);
-    arg_x->set_type(GLMessage::DataType::FLOAT);
-    arg_x->add_floatvalue(x);
-
-    // copy argument y
-    GLMessage_DataType *arg_y = glmsg.add_args();
-    arg_y->set_isarray(false);
-    arg_y->set_type(GLMessage::DataType::FLOAT);
-    arg_y->add_floatvalue(y);
-
-    // copy argument z
-    GLMessage_DataType *arg_z = glmsg.add_args();
-    arg_z->set_isarray(false);
-    arg_z->set_type(GLMessage::DataType::FLOAT);
-    arg_z->add_floatvalue(z);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glProgramUniform3fEXT(program, location, x, y, z);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glProgramUniform4fEXT(GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glProgramUniform4fEXT);
-
-    // copy argument program
-    GLMessage_DataType *arg_program = glmsg.add_args();
-    arg_program->set_isarray(false);
-    arg_program->set_type(GLMessage::DataType::INT);
-    arg_program->add_intvalue(program);
-
-    // copy argument location
-    GLMessage_DataType *arg_location = glmsg.add_args();
-    arg_location->set_isarray(false);
-    arg_location->set_type(GLMessage::DataType::INT);
-    arg_location->add_intvalue(location);
-
-    // copy argument x
-    GLMessage_DataType *arg_x = glmsg.add_args();
-    arg_x->set_isarray(false);
-    arg_x->set_type(GLMessage::DataType::FLOAT);
-    arg_x->add_floatvalue(x);
-
-    // copy argument y
-    GLMessage_DataType *arg_y = glmsg.add_args();
-    arg_y->set_isarray(false);
-    arg_y->set_type(GLMessage::DataType::FLOAT);
-    arg_y->add_floatvalue(y);
-
-    // copy argument z
-    GLMessage_DataType *arg_z = glmsg.add_args();
-    arg_z->set_isarray(false);
-    arg_z->set_type(GLMessage::DataType::FLOAT);
-    arg_z->add_floatvalue(z);
-
-    // copy argument w
-    GLMessage_DataType *arg_w = glmsg.add_args();
-    arg_w->set_isarray(false);
-    arg_w->set_type(GLMessage::DataType::FLOAT);
-    arg_w->add_floatvalue(w);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glProgramUniform4fEXT(program, location, x, y, z, w);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glProgramUniform1ivEXT(GLuint program, GLint location, GLsizei count, const GLint *value) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glProgramUniform1ivEXT);
-
-    // copy argument program
-    GLMessage_DataType *arg_program = glmsg.add_args();
-    arg_program->set_isarray(false);
-    arg_program->set_type(GLMessage::DataType::INT);
-    arg_program->add_intvalue(program);
-
-    // copy argument location
-    GLMessage_DataType *arg_location = glmsg.add_args();
-    arg_location->set_isarray(false);
-    arg_location->set_type(GLMessage::DataType::INT);
-    arg_location->add_intvalue(location);
-
-    // copy argument count
-    GLMessage_DataType *arg_count = glmsg.add_args();
-    arg_count->set_isarray(false);
-    arg_count->set_type(GLMessage::DataType::INT);
-    arg_count->add_intvalue(count);
-
-    // copy argument value
-    GLMessage_DataType *arg_value = glmsg.add_args();
-    arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT64);
-    arg_value->add_int64value((uintptr_t)value);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glProgramUniform1ivEXT(program, location, count, value);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-        (void *) value,
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glProgramUniform2ivEXT(GLuint program, GLint location, GLsizei count, const GLint *value) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glProgramUniform2ivEXT);
-
-    // copy argument program
-    GLMessage_DataType *arg_program = glmsg.add_args();
-    arg_program->set_isarray(false);
-    arg_program->set_type(GLMessage::DataType::INT);
-    arg_program->add_intvalue(program);
-
-    // copy argument location
-    GLMessage_DataType *arg_location = glmsg.add_args();
-    arg_location->set_isarray(false);
-    arg_location->set_type(GLMessage::DataType::INT);
-    arg_location->add_intvalue(location);
-
-    // copy argument count
-    GLMessage_DataType *arg_count = glmsg.add_args();
-    arg_count->set_isarray(false);
-    arg_count->set_type(GLMessage::DataType::INT);
-    arg_count->add_intvalue(count);
-
-    // copy argument value
-    GLMessage_DataType *arg_value = glmsg.add_args();
-    arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT64);
-    arg_value->add_int64value((uintptr_t)value);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glProgramUniform2ivEXT(program, location, count, value);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-        (void *) value,
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glProgramUniform3ivEXT(GLuint program, GLint location, GLsizei count, const GLint *value) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glProgramUniform3ivEXT);
-
-    // copy argument program
-    GLMessage_DataType *arg_program = glmsg.add_args();
-    arg_program->set_isarray(false);
-    arg_program->set_type(GLMessage::DataType::INT);
-    arg_program->add_intvalue(program);
-
-    // copy argument location
-    GLMessage_DataType *arg_location = glmsg.add_args();
-    arg_location->set_isarray(false);
-    arg_location->set_type(GLMessage::DataType::INT);
-    arg_location->add_intvalue(location);
-
-    // copy argument count
-    GLMessage_DataType *arg_count = glmsg.add_args();
-    arg_count->set_isarray(false);
-    arg_count->set_type(GLMessage::DataType::INT);
-    arg_count->add_intvalue(count);
-
-    // copy argument value
-    GLMessage_DataType *arg_value = glmsg.add_args();
-    arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT64);
-    arg_value->add_int64value((uintptr_t)value);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glProgramUniform3ivEXT(program, location, count, value);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-        (void *) value,
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glProgramUniform4ivEXT(GLuint program, GLint location, GLsizei count, const GLint *value) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glProgramUniform4ivEXT);
-
-    // copy argument program
-    GLMessage_DataType *arg_program = glmsg.add_args();
-    arg_program->set_isarray(false);
-    arg_program->set_type(GLMessage::DataType::INT);
-    arg_program->add_intvalue(program);
-
-    // copy argument location
-    GLMessage_DataType *arg_location = glmsg.add_args();
-    arg_location->set_isarray(false);
-    arg_location->set_type(GLMessage::DataType::INT);
-    arg_location->add_intvalue(location);
-
-    // copy argument count
-    GLMessage_DataType *arg_count = glmsg.add_args();
-    arg_count->set_isarray(false);
-    arg_count->set_type(GLMessage::DataType::INT);
-    arg_count->add_intvalue(count);
-
-    // copy argument value
-    GLMessage_DataType *arg_value = glmsg.add_args();
-    arg_value->set_isarray(false);
-    arg_value->set_type(GLMessage::DataType::INT64);
-    arg_value->add_int64value((uintptr_t)value);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glProgramUniform4ivEXT(program, location, count, value);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-        (void *) value,
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glProgramUniform1fvEXT(GLuint program, GLint location, GLsizei count, const GLfloat *value) {
+void GLTrace_glProgramUniform1fvEXT(GLuint program, GLint location, GLsizei count, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -13787,7 +18617,140 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glProgramUniform2fvEXT(GLuint program, GLint location, GLsizei count, const GLfloat *value) {
+void GLTrace_glProgramUniform1iEXT(GLuint program, GLint location, GLint v0) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform1iEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform1iEXT(program, location, v0);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform1ivEXT(GLuint program, GLint location, GLsizei count, const GLint * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform1ivEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform1ivEXT(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform2fEXT(GLuint program, GLint location, GLfloat v0, GLfloat v1) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform2fEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::FLOAT);
+    arg_v0->add_floatvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::FLOAT);
+    arg_v1->add_floatvalue(v1);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform2fEXT(program, location, v0, v1);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform2fvEXT(GLuint program, GLint location, GLsizei count, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -13834,7 +18797,152 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glProgramUniform3fvEXT(GLuint program, GLint location, GLsizei count, const GLfloat *value) {
+void GLTrace_glProgramUniform2iEXT(GLuint program, GLint location, GLint v0, GLint v1) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform2iEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::INT);
+    arg_v1->add_intvalue(v1);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform2iEXT(program, location, v0, v1);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform2ivEXT(GLuint program, GLint location, GLsizei count, const GLint * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform2ivEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform2ivEXT(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform3fEXT(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform3fEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::FLOAT);
+    arg_v0->add_floatvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::FLOAT);
+    arg_v1->add_floatvalue(v1);
+
+    // copy argument v2
+    GLMessage_DataType *arg_v2 = glmsg.add_args();
+    arg_v2->set_isarray(false);
+    arg_v2->set_type(GLMessage::DataType::FLOAT);
+    arg_v2->add_floatvalue(v2);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform3fEXT(program, location, v0, v1, v2);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform3fvEXT(GLuint program, GLint location, GLsizei count, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -13881,7 +18989,164 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glProgramUniform4fvEXT(GLuint program, GLint location, GLsizei count, const GLfloat *value) {
+void GLTrace_glProgramUniform3iEXT(GLuint program, GLint location, GLint v0, GLint v1, GLint v2) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform3iEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::INT);
+    arg_v1->add_intvalue(v1);
+
+    // copy argument v2
+    GLMessage_DataType *arg_v2 = glmsg.add_args();
+    arg_v2->set_isarray(false);
+    arg_v2->set_type(GLMessage::DataType::INT);
+    arg_v2->add_intvalue(v2);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform3iEXT(program, location, v0, v1, v2);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform3ivEXT(GLuint program, GLint location, GLsizei count, const GLint * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform3ivEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform3ivEXT(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform4fEXT(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform4fEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::FLOAT);
+    arg_v0->add_floatvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::FLOAT);
+    arg_v1->add_floatvalue(v1);
+
+    // copy argument v2
+    GLMessage_DataType *arg_v2 = glmsg.add_args();
+    arg_v2->set_isarray(false);
+    arg_v2->set_type(GLMessage::DataType::FLOAT);
+    arg_v2->add_floatvalue(v2);
+
+    // copy argument v3
+    GLMessage_DataType *arg_v3 = glmsg.add_args();
+    arg_v3->set_isarray(false);
+    arg_v3->set_type(GLMessage::DataType::FLOAT);
+    arg_v3->add_floatvalue(v3);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform4fEXT(program, location, v0, v1, v2, v3);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform4fvEXT(GLuint program, GLint location, GLsizei count, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -13928,7 +19193,112 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glProgramUniformMatrix2fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {
+void GLTrace_glProgramUniform4iEXT(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform4iEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::INT);
+    arg_v1->add_intvalue(v1);
+
+    // copy argument v2
+    GLMessage_DataType *arg_v2 = glmsg.add_args();
+    arg_v2->set_isarray(false);
+    arg_v2->set_type(GLMessage::DataType::INT);
+    arg_v2->add_intvalue(v2);
+
+    // copy argument v3
+    GLMessage_DataType *arg_v3 = glmsg.add_args();
+    arg_v3->set_isarray(false);
+    arg_v3->set_type(GLMessage::DataType::INT);
+    arg_v3->add_intvalue(v3);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform4iEXT(program, location, v0, v1, v2, v3);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform4ivEXT(GLuint program, GLint location, GLsizei count, const GLint * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform4ivEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform4ivEXT(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniformMatrix2fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -13981,7 +19351,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glProgramUniformMatrix3fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {
+void GLTrace_glProgramUniformMatrix3fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -14034,7 +19404,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glProgramUniformMatrix4fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {
+void GLTrace_glProgramUniformMatrix4fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -14087,6 +19457,46 @@
     glContext->traceGLMessage(&glmsg);
 }
 
+void GLTrace_glUseProgramStagesEXT(GLuint pipeline, GLbitfield stages, GLuint program) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glUseProgramStagesEXT);
+
+    // copy argument pipeline
+    GLMessage_DataType *arg_pipeline = glmsg.add_args();
+    arg_pipeline->set_isarray(false);
+    arg_pipeline->set_type(GLMessage::DataType::INT);
+    arg_pipeline->add_intvalue(pipeline);
+
+    // copy argument stages
+    GLMessage_DataType *arg_stages = glmsg.add_args();
+    arg_stages->set_isarray(false);
+    arg_stages->set_type(GLMessage::DataType::INT);
+    arg_stages->add_intvalue(stages);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glUseProgramStagesEXT(pipeline, stages, program);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
 void GLTrace_glValidateProgramPipelineEXT(GLuint pipeline) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
@@ -14115,46 +19525,1154 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetProgramPipelineInfoLogEXT(GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog) {
+void GLTrace_glProgramUniform1uiEXT(GLuint program, GLint location, GLuint v0) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
-    glmsg.set_function(GLMessage::glGetProgramPipelineInfoLogEXT);
+    glmsg.set_function(GLMessage::glProgramUniform1uiEXT);
 
-    // copy argument pipeline
-    GLMessage_DataType *arg_pipeline = glmsg.add_args();
-    arg_pipeline->set_isarray(false);
-    arg_pipeline->set_type(GLMessage::DataType::INT);
-    arg_pipeline->add_intvalue(pipeline);
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
 
-    // copy argument bufSize
-    GLMessage_DataType *arg_bufSize = glmsg.add_args();
-    arg_bufSize->set_isarray(false);
-    arg_bufSize->set_type(GLMessage::DataType::INT);
-    arg_bufSize->add_intvalue(bufSize);
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
 
-    // copy argument length
-    GLMessage_DataType *arg_length = glmsg.add_args();
-    arg_length->set_isarray(false);
-    arg_length->set_type(GLMessage::DataType::INT64);
-    arg_length->add_int64value((uintptr_t)length);
-
-    // copy argument infoLog
-    GLMessage_DataType *arg_infoLog = glmsg.add_args();
-    arg_infoLog->set_isarray(false);
-    arg_infoLog->set_type(GLMessage::DataType::INT64);
-    arg_infoLog->add_int64value((uintptr_t)infoLog);
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetProgramPipelineInfoLogEXT(pipeline, bufSize, length, infoLog);
+    glContext->hooks->gl.glProgramUniform1uiEXT(program, location, v0);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) length,
-        (void *) infoLog,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform2uiEXT(GLuint program, GLint location, GLuint v0, GLuint v1) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform2uiEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::INT);
+    arg_v1->add_intvalue(v1);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform2uiEXT(program, location, v0, v1);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform3uiEXT(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform3uiEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::INT);
+    arg_v1->add_intvalue(v1);
+
+    // copy argument v2
+    GLMessage_DataType *arg_v2 = glmsg.add_args();
+    arg_v2->set_isarray(false);
+    arg_v2->set_type(GLMessage::DataType::INT);
+    arg_v2->add_intvalue(v2);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform3uiEXT(program, location, v0, v1, v2);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform4uiEXT(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform4uiEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument v0
+    GLMessage_DataType *arg_v0 = glmsg.add_args();
+    arg_v0->set_isarray(false);
+    arg_v0->set_type(GLMessage::DataType::INT);
+    arg_v0->add_intvalue(v0);
+
+    // copy argument v1
+    GLMessage_DataType *arg_v1 = glmsg.add_args();
+    arg_v1->set_isarray(false);
+    arg_v1->set_type(GLMessage::DataType::INT);
+    arg_v1->add_intvalue(v1);
+
+    // copy argument v2
+    GLMessage_DataType *arg_v2 = glmsg.add_args();
+    arg_v2->set_isarray(false);
+    arg_v2->set_type(GLMessage::DataType::INT);
+    arg_v2->add_intvalue(v2);
+
+    // copy argument v3
+    GLMessage_DataType *arg_v3 = glmsg.add_args();
+    arg_v3->set_isarray(false);
+    arg_v3->set_type(GLMessage::DataType::INT);
+    arg_v3->add_intvalue(v3);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform4uiEXT(program, location, v0, v1, v2, v3);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform1uivEXT(GLuint program, GLint location, GLsizei count, const GLuint * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform1uivEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform1uivEXT(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform2uivEXT(GLuint program, GLint location, GLsizei count, const GLuint * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform2uivEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform2uivEXT(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform3uivEXT(GLuint program, GLint location, GLsizei count, const GLuint * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform3uivEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform3uivEXT(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniform4uivEXT(GLuint program, GLint location, GLsizei count, const GLuint * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniform4uivEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniform4uivEXT(program, location, count, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniformMatrix2x3fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniformMatrix2x3fvEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniformMatrix2x3fvEXT(program, location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniformMatrix3x2fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniformMatrix3x2fvEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniformMatrix3x2fvEXT(program, location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniformMatrix2x4fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniformMatrix2x4fvEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniformMatrix2x4fvEXT(program, location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniformMatrix4x2fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniformMatrix4x2fvEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniformMatrix4x2fvEXT(program, location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniformMatrix3x4fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniformMatrix3x4fvEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniformMatrix3x4fvEXT(program, location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glProgramUniformMatrix4x3fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glProgramUniformMatrix4x3fvEXT);
+
+    // copy argument program
+    GLMessage_DataType *arg_program = glmsg.add_args();
+    arg_program->set_isarray(false);
+    arg_program->set_type(GLMessage::DataType::INT);
+    arg_program->add_intvalue(program);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glProgramUniformMatrix4x3fvEXT(program, location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glPatchParameteriEXT(GLenum pname, GLint value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glPatchParameteriEXT);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT);
+    arg_value->add_intvalue(value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glPatchParameteriEXT(pname, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glTexParameterIivEXT(GLenum target, GLenum pname, const GLint * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTexParameterIivEXT);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTexParameterIivEXT(target, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glTexParameterIuivEXT(GLenum target, GLenum pname, const GLuint * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTexParameterIuivEXT);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTexParameterIuivEXT(target, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetTexParameterIivEXT(GLenum target, GLenum pname, GLint * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetTexParameterIivEXT);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetTexParameterIivEXT(target, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetTexParameterIuivEXT(GLenum target, GLenum pname, GLuint * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetTexParameterIuivEXT);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetTexParameterIuivEXT(target, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glSamplerParameterIivEXT(GLuint sampler, GLenum pname, const GLint * param) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glSamplerParameterIivEXT);
+
+    // copy argument sampler
+    GLMessage_DataType *arg_sampler = glmsg.add_args();
+    arg_sampler->set_isarray(false);
+    arg_sampler->set_type(GLMessage::DataType::INT);
+    arg_sampler->add_intvalue(sampler);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument param
+    GLMessage_DataType *arg_param = glmsg.add_args();
+    arg_param->set_isarray(false);
+    arg_param->set_type(GLMessage::DataType::INT64);
+    arg_param->add_int64value((uintptr_t)param);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glSamplerParameterIivEXT(sampler, pname, param);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) param,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glSamplerParameterIuivEXT(GLuint sampler, GLenum pname, const GLuint * param) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glSamplerParameterIuivEXT);
+
+    // copy argument sampler
+    GLMessage_DataType *arg_sampler = glmsg.add_args();
+    arg_sampler->set_isarray(false);
+    arg_sampler->set_type(GLMessage::DataType::INT);
+    arg_sampler->add_intvalue(sampler);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument param
+    GLMessage_DataType *arg_param = glmsg.add_args();
+    arg_param->set_isarray(false);
+    arg_param->set_type(GLMessage::DataType::INT64);
+    arg_param->add_int64value((uintptr_t)param);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glSamplerParameterIuivEXT(sampler, pname, param);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) param,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetSamplerParameterIivEXT(GLuint sampler, GLenum pname, GLint * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetSamplerParameterIivEXT);
+
+    // copy argument sampler
+    GLMessage_DataType *arg_sampler = glmsg.add_args();
+    arg_sampler->set_isarray(false);
+    arg_sampler->set_type(GLMessage::DataType::INT);
+    arg_sampler->add_intvalue(sampler);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetSamplerParameterIivEXT(sampler, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetSamplerParameterIuivEXT(GLuint sampler, GLenum pname, GLuint * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetSamplerParameterIuivEXT);
+
+    // copy argument sampler
+    GLMessage_DataType *arg_sampler = glmsg.add_args();
+    arg_sampler->set_isarray(false);
+    arg_sampler->set_type(GLMessage::DataType::INT);
+    arg_sampler->add_intvalue(sampler);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetSamplerParameterIuivEXT(sampler, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glTexBufferEXT(GLenum target, GLenum internalformat, GLuint buffer) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTexBufferEXT);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument internalformat
+    GLMessage_DataType *arg_internalformat = glmsg.add_args();
+    arg_internalformat->set_isarray(false);
+    arg_internalformat->set_type(GLMessage::DataType::ENUM);
+    arg_internalformat->add_intvalue((int)internalformat);
+
+    // copy argument buffer
+    GLMessage_DataType *arg_buffer = glmsg.add_args();
+    arg_buffer->set_isarray(false);
+    arg_buffer->set_type(GLMessage::DataType::INT);
+    arg_buffer->add_intvalue(buffer);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTexBufferEXT(target, internalformat, buffer);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glTexBufferRangeEXT(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTexBufferRangeEXT);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument internalformat
+    GLMessage_DataType *arg_internalformat = glmsg.add_args();
+    arg_internalformat->set_isarray(false);
+    arg_internalformat->set_type(GLMessage::DataType::ENUM);
+    arg_internalformat->add_intvalue((int)internalformat);
+
+    // copy argument buffer
+    GLMessage_DataType *arg_buffer = glmsg.add_args();
+    arg_buffer->set_isarray(false);
+    arg_buffer->set_type(GLMessage::DataType::INT);
+    arg_buffer->add_intvalue(buffer);
+
+    // copy argument offset
+    GLMessage_DataType *arg_offset = glmsg.add_args();
+    arg_offset->set_isarray(false);
+    arg_offset->set_type(GLMessage::DataType::INT);
+    arg_offset->add_intvalue(offset);
+
+    // copy argument size
+    GLMessage_DataType *arg_size = glmsg.add_args();
+    arg_size->set_isarray(false);
+    arg_size->set_type(GLMessage::DataType::INT);
+    arg_size->add_intvalue(size);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTexBufferRangeEXT(target, internalformat, buffer, offset, size);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -14493,6 +21011,76 @@
     glContext->traceGLMessage(&glmsg);
 }
 
+void GLTrace_glTextureViewEXT(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTextureViewEXT);
+
+    // copy argument texture
+    GLMessage_DataType *arg_texture = glmsg.add_args();
+    arg_texture->set_isarray(false);
+    arg_texture->set_type(GLMessage::DataType::INT);
+    arg_texture->add_intvalue(texture);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument origtexture
+    GLMessage_DataType *arg_origtexture = glmsg.add_args();
+    arg_origtexture->set_isarray(false);
+    arg_origtexture->set_type(GLMessage::DataType::INT);
+    arg_origtexture->add_intvalue(origtexture);
+
+    // copy argument internalformat
+    GLMessage_DataType *arg_internalformat = glmsg.add_args();
+    arg_internalformat->set_isarray(false);
+    arg_internalformat->set_type(GLMessage::DataType::ENUM);
+    arg_internalformat->add_intvalue((int)internalformat);
+
+    // copy argument minlevel
+    GLMessage_DataType *arg_minlevel = glmsg.add_args();
+    arg_minlevel->set_isarray(false);
+    arg_minlevel->set_type(GLMessage::DataType::INT);
+    arg_minlevel->add_intvalue(minlevel);
+
+    // copy argument numlevels
+    GLMessage_DataType *arg_numlevels = glmsg.add_args();
+    arg_numlevels->set_isarray(false);
+    arg_numlevels->set_type(GLMessage::DataType::INT);
+    arg_numlevels->add_intvalue(numlevels);
+
+    // copy argument minlayer
+    GLMessage_DataType *arg_minlayer = glmsg.add_args();
+    arg_minlayer->set_isarray(false);
+    arg_minlayer->set_type(GLMessage::DataType::INT);
+    arg_minlayer->add_intvalue(minlayer);
+
+    // copy argument numlayers
+    GLMessage_DataType *arg_numlayers = glmsg.add_args();
+    arg_numlayers->set_isarray(false);
+    arg_numlayers->set_type(GLMessage::DataType::INT);
+    arg_numlayers->add_intvalue(numlayers);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTextureViewEXT(texture, target, origtexture, internalformat, minlevel, numlevels, minlayer, numlayers);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
 void GLTrace_glRenderbufferStorageMultisampleIMG(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
@@ -14603,6 +21191,551 @@
     glContext->traceGLMessage(&glmsg);
 }
 
+void GLTrace_glBeginPerfQueryINTEL(GLuint queryHandle) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glBeginPerfQueryINTEL);
+
+    // copy argument queryHandle
+    GLMessage_DataType *arg_queryHandle = glmsg.add_args();
+    arg_queryHandle->set_isarray(false);
+    arg_queryHandle->set_type(GLMessage::DataType::INT);
+    arg_queryHandle->add_intvalue(queryHandle);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glBeginPerfQueryINTEL(queryHandle);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glCreatePerfQueryINTEL(GLuint queryId, GLuint * queryHandle) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glCreatePerfQueryINTEL);
+
+    // copy argument queryId
+    GLMessage_DataType *arg_queryId = glmsg.add_args();
+    arg_queryId->set_isarray(false);
+    arg_queryId->set_type(GLMessage::DataType::INT);
+    arg_queryId->add_intvalue(queryId);
+
+    // copy argument queryHandle
+    GLMessage_DataType *arg_queryHandle = glmsg.add_args();
+    arg_queryHandle->set_isarray(false);
+    arg_queryHandle->set_type(GLMessage::DataType::INT64);
+    arg_queryHandle->add_int64value((uintptr_t)queryHandle);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glCreatePerfQueryINTEL(queryId, queryHandle);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) queryHandle,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glDeletePerfQueryINTEL(GLuint queryHandle) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDeletePerfQueryINTEL);
+
+    // copy argument queryHandle
+    GLMessage_DataType *arg_queryHandle = glmsg.add_args();
+    arg_queryHandle->set_isarray(false);
+    arg_queryHandle->set_type(GLMessage::DataType::INT);
+    arg_queryHandle->add_intvalue(queryHandle);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDeletePerfQueryINTEL(queryHandle);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glEndPerfQueryINTEL(GLuint queryHandle) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glEndPerfQueryINTEL);
+
+    // copy argument queryHandle
+    GLMessage_DataType *arg_queryHandle = glmsg.add_args();
+    arg_queryHandle->set_isarray(false);
+    arg_queryHandle->set_type(GLMessage::DataType::INT);
+    arg_queryHandle->add_intvalue(queryHandle);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glEndPerfQueryINTEL(queryHandle);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetFirstPerfQueryIdINTEL(GLuint * queryId) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetFirstPerfQueryIdINTEL);
+
+    // copy argument queryId
+    GLMessage_DataType *arg_queryId = glmsg.add_args();
+    arg_queryId->set_isarray(false);
+    arg_queryId->set_type(GLMessage::DataType::INT64);
+    arg_queryId->add_int64value((uintptr_t)queryId);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetFirstPerfQueryIdINTEL(queryId);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) queryId,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetNextPerfQueryIdINTEL(GLuint queryId, GLuint * nextQueryId) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetNextPerfQueryIdINTEL);
+
+    // copy argument queryId
+    GLMessage_DataType *arg_queryId = glmsg.add_args();
+    arg_queryId->set_isarray(false);
+    arg_queryId->set_type(GLMessage::DataType::INT);
+    arg_queryId->add_intvalue(queryId);
+
+    // copy argument nextQueryId
+    GLMessage_DataType *arg_nextQueryId = glmsg.add_args();
+    arg_nextQueryId->set_isarray(false);
+    arg_nextQueryId->set_type(GLMessage::DataType::INT64);
+    arg_nextQueryId->add_int64value((uintptr_t)nextQueryId);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetNextPerfQueryIdINTEL(queryId, nextQueryId);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) nextQueryId,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetPerfCounterInfoINTEL(GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar * counterName, GLuint counterDescLength, GLchar * counterDesc, GLuint * counterOffset, GLuint * counterDataSize, GLuint * counterTypeEnum, GLuint * counterDataTypeEnum, GLuint64 * rawCounterMaxValue) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetPerfCounterInfoINTEL);
+
+    // copy argument queryId
+    GLMessage_DataType *arg_queryId = glmsg.add_args();
+    arg_queryId->set_isarray(false);
+    arg_queryId->set_type(GLMessage::DataType::INT);
+    arg_queryId->add_intvalue(queryId);
+
+    // copy argument counterId
+    GLMessage_DataType *arg_counterId = glmsg.add_args();
+    arg_counterId->set_isarray(false);
+    arg_counterId->set_type(GLMessage::DataType::INT);
+    arg_counterId->add_intvalue(counterId);
+
+    // copy argument counterNameLength
+    GLMessage_DataType *arg_counterNameLength = glmsg.add_args();
+    arg_counterNameLength->set_isarray(false);
+    arg_counterNameLength->set_type(GLMessage::DataType::INT);
+    arg_counterNameLength->add_intvalue(counterNameLength);
+
+    // copy argument counterName
+    GLMessage_DataType *arg_counterName = glmsg.add_args();
+    arg_counterName->set_isarray(false);
+    arg_counterName->set_type(GLMessage::DataType::INT64);
+    arg_counterName->add_int64value((uintptr_t)counterName);
+
+    // copy argument counterDescLength
+    GLMessage_DataType *arg_counterDescLength = glmsg.add_args();
+    arg_counterDescLength->set_isarray(false);
+    arg_counterDescLength->set_type(GLMessage::DataType::INT);
+    arg_counterDescLength->add_intvalue(counterDescLength);
+
+    // copy argument counterDesc
+    GLMessage_DataType *arg_counterDesc = glmsg.add_args();
+    arg_counterDesc->set_isarray(false);
+    arg_counterDesc->set_type(GLMessage::DataType::INT64);
+    arg_counterDesc->add_int64value((uintptr_t)counterDesc);
+
+    // copy argument counterOffset
+    GLMessage_DataType *arg_counterOffset = glmsg.add_args();
+    arg_counterOffset->set_isarray(false);
+    arg_counterOffset->set_type(GLMessage::DataType::INT64);
+    arg_counterOffset->add_int64value((uintptr_t)counterOffset);
+
+    // copy argument counterDataSize
+    GLMessage_DataType *arg_counterDataSize = glmsg.add_args();
+    arg_counterDataSize->set_isarray(false);
+    arg_counterDataSize->set_type(GLMessage::DataType::INT64);
+    arg_counterDataSize->add_int64value((uintptr_t)counterDataSize);
+
+    // copy argument counterTypeEnum
+    GLMessage_DataType *arg_counterTypeEnum = glmsg.add_args();
+    arg_counterTypeEnum->set_isarray(false);
+    arg_counterTypeEnum->set_type(GLMessage::DataType::INT64);
+    arg_counterTypeEnum->add_int64value((uintptr_t)counterTypeEnum);
+
+    // copy argument counterDataTypeEnum
+    GLMessage_DataType *arg_counterDataTypeEnum = glmsg.add_args();
+    arg_counterDataTypeEnum->set_isarray(false);
+    arg_counterDataTypeEnum->set_type(GLMessage::DataType::INT64);
+    arg_counterDataTypeEnum->add_int64value((uintptr_t)counterDataTypeEnum);
+
+    // copy argument rawCounterMaxValue
+    GLMessage_DataType *arg_rawCounterMaxValue = glmsg.add_args();
+    arg_rawCounterMaxValue->set_isarray(false);
+    arg_rawCounterMaxValue->set_type(GLMessage::DataType::INT64);
+    arg_rawCounterMaxValue->add_int64value((uintptr_t)rawCounterMaxValue);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetPerfCounterInfoINTEL(queryId, counterId, counterNameLength, counterName, counterDescLength, counterDesc, counterOffset, counterDataSize, counterTypeEnum, counterDataTypeEnum, rawCounterMaxValue);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) counterName,
+        (void *) counterDesc,
+        (void *) counterOffset,
+        (void *) counterDataSize,
+        (void *) counterTypeEnum,
+        (void *) counterDataTypeEnum,
+        (void *) rawCounterMaxValue,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetPerfQueryDataINTEL(GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid * data, GLuint * bytesWritten) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetPerfQueryDataINTEL);
+
+    // copy argument queryHandle
+    GLMessage_DataType *arg_queryHandle = glmsg.add_args();
+    arg_queryHandle->set_isarray(false);
+    arg_queryHandle->set_type(GLMessage::DataType::INT);
+    arg_queryHandle->add_intvalue(queryHandle);
+
+    // copy argument flags
+    GLMessage_DataType *arg_flags = glmsg.add_args();
+    arg_flags->set_isarray(false);
+    arg_flags->set_type(GLMessage::DataType::INT);
+    arg_flags->add_intvalue(flags);
+
+    // copy argument dataSize
+    GLMessage_DataType *arg_dataSize = glmsg.add_args();
+    arg_dataSize->set_isarray(false);
+    arg_dataSize->set_type(GLMessage::DataType::INT);
+    arg_dataSize->add_intvalue(dataSize);
+
+    // copy argument data
+    GLMessage_DataType *arg_data = glmsg.add_args();
+    arg_data->set_isarray(false);
+    arg_data->set_type(GLMessage::DataType::INT64);
+    arg_data->add_int64value((uintptr_t)data);
+
+    // copy argument bytesWritten
+    GLMessage_DataType *arg_bytesWritten = glmsg.add_args();
+    arg_bytesWritten->set_isarray(false);
+    arg_bytesWritten->set_type(GLMessage::DataType::INT64);
+    arg_bytesWritten->add_int64value((uintptr_t)bytesWritten);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetPerfQueryDataINTEL(queryHandle, flags, dataSize, data, bytesWritten);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) data,
+        (void *) bytesWritten,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetPerfQueryIdByNameINTEL(GLchar * queryName, GLuint * queryId) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetPerfQueryIdByNameINTEL);
+
+    // copy argument queryName
+    GLMessage_DataType *arg_queryName = glmsg.add_args();
+    arg_queryName->set_isarray(false);
+    arg_queryName->set_type(GLMessage::DataType::INT64);
+    arg_queryName->add_int64value((uintptr_t)queryName);
+
+    // copy argument queryId
+    GLMessage_DataType *arg_queryId = glmsg.add_args();
+    arg_queryId->set_isarray(false);
+    arg_queryId->set_type(GLMessage::DataType::INT64);
+    arg_queryId->add_int64value((uintptr_t)queryId);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetPerfQueryIdByNameINTEL(queryName, queryId);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) queryName,
+        (void *) queryId,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetPerfQueryInfoINTEL(GLuint queryId, GLuint queryNameLength, GLchar * queryName, GLuint * dataSize, GLuint * noCounters, GLuint * noInstances, GLuint * capsMask) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetPerfQueryInfoINTEL);
+
+    // copy argument queryId
+    GLMessage_DataType *arg_queryId = glmsg.add_args();
+    arg_queryId->set_isarray(false);
+    arg_queryId->set_type(GLMessage::DataType::INT);
+    arg_queryId->add_intvalue(queryId);
+
+    // copy argument queryNameLength
+    GLMessage_DataType *arg_queryNameLength = glmsg.add_args();
+    arg_queryNameLength->set_isarray(false);
+    arg_queryNameLength->set_type(GLMessage::DataType::INT);
+    arg_queryNameLength->add_intvalue(queryNameLength);
+
+    // copy argument queryName
+    GLMessage_DataType *arg_queryName = glmsg.add_args();
+    arg_queryName->set_isarray(false);
+    arg_queryName->set_type(GLMessage::DataType::INT64);
+    arg_queryName->add_int64value((uintptr_t)queryName);
+
+    // copy argument dataSize
+    GLMessage_DataType *arg_dataSize = glmsg.add_args();
+    arg_dataSize->set_isarray(false);
+    arg_dataSize->set_type(GLMessage::DataType::INT64);
+    arg_dataSize->add_int64value((uintptr_t)dataSize);
+
+    // copy argument noCounters
+    GLMessage_DataType *arg_noCounters = glmsg.add_args();
+    arg_noCounters->set_isarray(false);
+    arg_noCounters->set_type(GLMessage::DataType::INT64);
+    arg_noCounters->add_int64value((uintptr_t)noCounters);
+
+    // copy argument noInstances
+    GLMessage_DataType *arg_noInstances = glmsg.add_args();
+    arg_noInstances->set_isarray(false);
+    arg_noInstances->set_type(GLMessage::DataType::INT64);
+    arg_noInstances->add_int64value((uintptr_t)noInstances);
+
+    // copy argument capsMask
+    GLMessage_DataType *arg_capsMask = glmsg.add_args();
+    arg_capsMask->set_isarray(false);
+    arg_capsMask->set_type(GLMessage::DataType::INT64);
+    arg_capsMask->add_int64value((uintptr_t)capsMask);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetPerfQueryInfoINTEL(queryId, queryNameLength, queryName, dataSize, noCounters, noInstances, capsMask);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) queryName,
+        (void *) dataSize,
+        (void *) noCounters,
+        (void *) noInstances,
+        (void *) capsMask,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glBlendParameteriNV(GLenum pname, GLint value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glBlendParameteriNV);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT);
+    arg_value->add_intvalue(value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glBlendParameteriNV(pname, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glBlendBarrierNV(void) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glBlendBarrierNV);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glBlendBarrierNV();
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glCopyBufferSubDataNV(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glCopyBufferSubDataNV);
+
+    // copy argument readTarget
+    GLMessage_DataType *arg_readTarget = glmsg.add_args();
+    arg_readTarget->set_isarray(false);
+    arg_readTarget->set_type(GLMessage::DataType::ENUM);
+    arg_readTarget->add_intvalue((int)readTarget);
+
+    // copy argument writeTarget
+    GLMessage_DataType *arg_writeTarget = glmsg.add_args();
+    arg_writeTarget->set_isarray(false);
+    arg_writeTarget->set_type(GLMessage::DataType::ENUM);
+    arg_writeTarget->add_intvalue((int)writeTarget);
+
+    // copy argument readOffset
+    GLMessage_DataType *arg_readOffset = glmsg.add_args();
+    arg_readOffset->set_isarray(false);
+    arg_readOffset->set_type(GLMessage::DataType::INT);
+    arg_readOffset->add_intvalue(readOffset);
+
+    // copy argument writeOffset
+    GLMessage_DataType *arg_writeOffset = glmsg.add_args();
+    arg_writeOffset->set_isarray(false);
+    arg_writeOffset->set_type(GLMessage::DataType::INT);
+    arg_writeOffset->add_intvalue(writeOffset);
+
+    // copy argument size
+    GLMessage_DataType *arg_size = glmsg.add_args();
+    arg_size->set_isarray(false);
+    arg_size->set_type(GLMessage::DataType::INT);
+    arg_size->add_intvalue(size);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glCopyBufferSubDataNV(readTarget, writeTarget, readOffset, writeOffset, size);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
 void GLTrace_glCoverageMaskNV(GLboolean mask) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
@@ -14659,7 +21792,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDrawBuffersNV(GLsizei n, const GLenum *bufs) {
+void GLTrace_glDrawBuffersNV(GLsizei n, const GLenum * bufs) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -14694,7 +21827,106 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDeleteFencesNV(GLsizei n, const GLuint *fences) {
+void GLTrace_glDrawArraysInstancedNV(GLenum mode, GLint first, GLsizei count, GLsizei primcount) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDrawArraysInstancedNV);
+
+    // copy argument mode
+    GLMessage_DataType *arg_mode = glmsg.add_args();
+    arg_mode->set_isarray(false);
+    arg_mode->set_type(GLMessage::DataType::ENUM);
+    arg_mode->add_intvalue((int)mode);
+
+    // copy argument first
+    GLMessage_DataType *arg_first = glmsg.add_args();
+    arg_first->set_isarray(false);
+    arg_first->set_type(GLMessage::DataType::INT);
+    arg_first->add_intvalue(first);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument primcount
+    GLMessage_DataType *arg_primcount = glmsg.add_args();
+    arg_primcount->set_isarray(false);
+    arg_primcount->set_type(GLMessage::DataType::INT);
+    arg_primcount->add_intvalue(primcount);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDrawArraysInstancedNV(mode, first, count, primcount);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glDrawElementsInstancedNV(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glDrawElementsInstancedNV);
+
+    // copy argument mode
+    GLMessage_DataType *arg_mode = glmsg.add_args();
+    arg_mode->set_isarray(false);
+    arg_mode->set_type(GLMessage::DataType::ENUM);
+    arg_mode->add_intvalue((int)mode);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument type
+    GLMessage_DataType *arg_type = glmsg.add_args();
+    arg_type->set_isarray(false);
+    arg_type->set_type(GLMessage::DataType::ENUM);
+    arg_type->add_intvalue((int)type);
+
+    // copy argument indices
+    GLMessage_DataType *arg_indices = glmsg.add_args();
+    arg_indices->set_isarray(false);
+    arg_indices->set_type(GLMessage::DataType::INT64);
+    arg_indices->add_int64value((uintptr_t)indices);
+
+    // copy argument primcount
+    GLMessage_DataType *arg_primcount = glmsg.add_args();
+    arg_primcount->set_isarray(false);
+    arg_primcount->set_type(GLMessage::DataType::INT);
+    arg_primcount->add_intvalue(primcount);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glDrawElementsInstancedNV(mode, count, type, indices, primcount);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) indices,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glDeleteFencesNV(GLsizei n, const GLuint * fences) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -14729,7 +21961,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGenFencesNV(GLsizei n, GLuint *fences) {
+void GLTrace_glGenFencesNV(GLsizei n, GLuint * fences) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -14836,7 +22068,7 @@
     return retValue;
 }
 
-void GLTrace_glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) {
+void GLTrace_glGetFenceivNV(GLuint fence, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -14939,6 +22171,456 @@
     glContext->traceGLMessage(&glmsg);
 }
 
+void GLTrace_glBlitFramebufferNV(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glBlitFramebufferNV);
+
+    // copy argument srcX0
+    GLMessage_DataType *arg_srcX0 = glmsg.add_args();
+    arg_srcX0->set_isarray(false);
+    arg_srcX0->set_type(GLMessage::DataType::INT);
+    arg_srcX0->add_intvalue(srcX0);
+
+    // copy argument srcY0
+    GLMessage_DataType *arg_srcY0 = glmsg.add_args();
+    arg_srcY0->set_isarray(false);
+    arg_srcY0->set_type(GLMessage::DataType::INT);
+    arg_srcY0->add_intvalue(srcY0);
+
+    // copy argument srcX1
+    GLMessage_DataType *arg_srcX1 = glmsg.add_args();
+    arg_srcX1->set_isarray(false);
+    arg_srcX1->set_type(GLMessage::DataType::INT);
+    arg_srcX1->add_intvalue(srcX1);
+
+    // copy argument srcY1
+    GLMessage_DataType *arg_srcY1 = glmsg.add_args();
+    arg_srcY1->set_isarray(false);
+    arg_srcY1->set_type(GLMessage::DataType::INT);
+    arg_srcY1->add_intvalue(srcY1);
+
+    // copy argument dstX0
+    GLMessage_DataType *arg_dstX0 = glmsg.add_args();
+    arg_dstX0->set_isarray(false);
+    arg_dstX0->set_type(GLMessage::DataType::INT);
+    arg_dstX0->add_intvalue(dstX0);
+
+    // copy argument dstY0
+    GLMessage_DataType *arg_dstY0 = glmsg.add_args();
+    arg_dstY0->set_isarray(false);
+    arg_dstY0->set_type(GLMessage::DataType::INT);
+    arg_dstY0->add_intvalue(dstY0);
+
+    // copy argument dstX1
+    GLMessage_DataType *arg_dstX1 = glmsg.add_args();
+    arg_dstX1->set_isarray(false);
+    arg_dstX1->set_type(GLMessage::DataType::INT);
+    arg_dstX1->add_intvalue(dstX1);
+
+    // copy argument dstY1
+    GLMessage_DataType *arg_dstY1 = glmsg.add_args();
+    arg_dstY1->set_isarray(false);
+    arg_dstY1->set_type(GLMessage::DataType::INT);
+    arg_dstY1->add_intvalue(dstY1);
+
+    // copy argument mask
+    GLMessage_DataType *arg_mask = glmsg.add_args();
+    arg_mask->set_isarray(false);
+    arg_mask->set_type(GLMessage::DataType::INT);
+    arg_mask->add_intvalue(mask);
+
+    // copy argument filter
+    GLMessage_DataType *arg_filter = glmsg.add_args();
+    arg_filter->set_isarray(false);
+    arg_filter->set_type(GLMessage::DataType::ENUM);
+    arg_filter->add_intvalue((int)filter);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glBlitFramebufferNV(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glRenderbufferStorageMultisampleNV(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glRenderbufferStorageMultisampleNV);
+
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
+
+    // copy argument samples
+    GLMessage_DataType *arg_samples = glmsg.add_args();
+    arg_samples->set_isarray(false);
+    arg_samples->set_type(GLMessage::DataType::INT);
+    arg_samples->add_intvalue(samples);
+
+    // copy argument internalformat
+    GLMessage_DataType *arg_internalformat = glmsg.add_args();
+    arg_internalformat->set_isarray(false);
+    arg_internalformat->set_type(GLMessage::DataType::ENUM);
+    arg_internalformat->add_intvalue((int)internalformat);
+
+    // copy argument width
+    GLMessage_DataType *arg_width = glmsg.add_args();
+    arg_width->set_isarray(false);
+    arg_width->set_type(GLMessage::DataType::INT);
+    arg_width->add_intvalue(width);
+
+    // copy argument height
+    GLMessage_DataType *arg_height = glmsg.add_args();
+    arg_height->set_isarray(false);
+    arg_height->set_type(GLMessage::DataType::INT);
+    arg_height->add_intvalue(height);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glRenderbufferStorageMultisampleNV(target, samples, internalformat, width, height);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glVertexAttribDivisorNV(GLuint index, GLuint divisor) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glVertexAttribDivisorNV);
+
+    // copy argument index
+    GLMessage_DataType *arg_index = glmsg.add_args();
+    arg_index->set_isarray(false);
+    arg_index->set_type(GLMessage::DataType::INT);
+    arg_index->add_intvalue(index);
+
+    // copy argument divisor
+    GLMessage_DataType *arg_divisor = glmsg.add_args();
+    arg_divisor->set_isarray(false);
+    arg_divisor->set_type(GLMessage::DataType::INT);
+    arg_divisor->add_intvalue(divisor);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glVertexAttribDivisorNV(index, divisor);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glUniformMatrix2x3fvNV(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glUniformMatrix2x3fvNV);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glUniformMatrix2x3fvNV(location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glUniformMatrix3x2fvNV(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glUniformMatrix3x2fvNV);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glUniformMatrix3x2fvNV(location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glUniformMatrix2x4fvNV(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glUniformMatrix2x4fvNV);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glUniformMatrix2x4fvNV(location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glUniformMatrix4x2fvNV(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glUniformMatrix4x2fvNV);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glUniformMatrix4x2fvNV(location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glUniformMatrix3x4fvNV(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glUniformMatrix3x4fvNV);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glUniformMatrix3x4fvNV(location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glUniformMatrix4x3fvNV(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glUniformMatrix4x3fvNV);
+
+    // copy argument location
+    GLMessage_DataType *arg_location = glmsg.add_args();
+    arg_location->set_isarray(false);
+    arg_location->set_type(GLMessage::DataType::INT);
+    arg_location->add_intvalue(location);
+
+    // copy argument count
+    GLMessage_DataType *arg_count = glmsg.add_args();
+    arg_count->set_isarray(false);
+    arg_count->set_type(GLMessage::DataType::INT);
+    arg_count->add_intvalue(count);
+
+    // copy argument transpose
+    GLMessage_DataType *arg_transpose = glmsg.add_args();
+    arg_transpose->set_isarray(false);
+    arg_transpose->set_type(GLMessage::DataType::BOOL);
+    arg_transpose->add_boolvalue(transpose);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT64);
+    arg_value->add_int64value((uintptr_t)value);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glUniformMatrix4x3fvNV(location, count, transpose, value);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) value,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
 void GLTrace_glReadBufferNV(GLenum mode) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
@@ -15001,7 +22683,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetDriverControlsQCOM(GLint *num, GLsizei size, GLuint *driverControls) {
+void GLTrace_glGetDriverControlsQCOM(GLint * num, GLsizei size, GLuint * driverControls) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -15043,7 +22725,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString) {
+void GLTrace_glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei * length, GLchar * driverControlString) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -15147,7 +22829,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glExtGetTexturesQCOM(GLuint *textures, GLint maxTextures, GLint *numTextures) {
+void GLTrace_glExtGetTexturesQCOM(GLuint * textures, GLint maxTextures, GLint * numTextures) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -15189,7 +22871,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glExtGetBuffersQCOM(GLuint *buffers, GLint maxBuffers, GLint *numBuffers) {
+void GLTrace_glExtGetBuffersQCOM(GLuint * buffers, GLint maxBuffers, GLint * numBuffers) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -15231,7 +22913,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glExtGetRenderbuffersQCOM(GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers) {
+void GLTrace_glExtGetRenderbuffersQCOM(GLuint * renderbuffers, GLint maxRenderbuffers, GLint * numRenderbuffers) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -15273,7 +22955,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glExtGetFramebuffersQCOM(GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers) {
+void GLTrace_glExtGetFramebuffersQCOM(GLuint * framebuffers, GLint maxFramebuffers, GLint * numFramebuffers) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -15315,7 +22997,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params) {
+void GLTrace_glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -15408,7 +23090,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels) {
+void GLTrace_glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void * texels) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -15497,7 +23179,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glExtGetBufferPointervQCOM(GLenum target, GLvoid **params) {
+void GLTrace_glExtGetBufferPointervQCOM(GLenum target, void ** params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -15532,7 +23214,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glExtGetShadersQCOM(GLuint *shaders, GLint maxShaders, GLint *numShaders) {
+void GLTrace_glExtGetShadersQCOM(GLuint * shaders, GLint maxShaders, GLint * numShaders) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -15574,7 +23256,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glExtGetProgramsQCOM(GLuint *programs, GLint maxPrograms, GLint *numPrograms) {
+void GLTrace_glExtGetProgramsQCOM(GLuint * programs, GLint maxPrograms, GLint * numPrograms) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -15652,7 +23334,7 @@
     return retValue;
 }
 
-void GLTrace_glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar *source, GLint *length) {
+void GLTrace_glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar * source, GLint * length) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -15783,7 +23465,7 @@
 
 // Definitions for GL1 APIs
 
-void GLTrace_glAlphaFunc(GLenum func, GLclampf ref) {
+void GLTrace_glAlphaFunc(GLenum func, GLfloat ref) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -15817,33 +23499,33 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glClipPlanef(GLenum plane, const GLfloat *equation) {
+void GLTrace_glClipPlanef(GLenum p, const GLfloat * eqn) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glClipPlanef);
 
-    // copy argument plane
-    GLMessage_DataType *arg_plane = glmsg.add_args();
-    arg_plane->set_isarray(false);
-    arg_plane->set_type(GLMessage::DataType::ENUM);
-    arg_plane->add_intvalue((int)plane);
+    // copy argument p
+    GLMessage_DataType *arg_p = glmsg.add_args();
+    arg_p->set_isarray(false);
+    arg_p->set_type(GLMessage::DataType::ENUM);
+    arg_p->add_intvalue((int)p);
 
-    // copy argument equation
-    GLMessage_DataType *arg_equation = glmsg.add_args();
-    arg_equation->set_isarray(false);
-    arg_equation->set_type(GLMessage::DataType::INT64);
-    arg_equation->add_int64value((uintptr_t)equation);
+    // copy argument eqn
+    GLMessage_DataType *arg_eqn = glmsg.add_args();
+    arg_eqn->set_isarray(false);
+    arg_eqn->set_type(GLMessage::DataType::INT64);
+    arg_eqn->add_int64value((uintptr_t)eqn);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glClipPlanef(plane, equation);
+    glContext->hooks->gl.glClipPlanef(p, eqn);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) equation,
+        (void *) eqn,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -15932,7 +23614,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glFogfv(GLenum pname, const GLfloat *params) {
+void GLTrace_glFogfv(GLenum pname, const GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -15967,52 +23649,52 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glFrustumf(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) {
+void GLTrace_glFrustumf(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glFrustumf);
 
-    // copy argument left
-    GLMessage_DataType *arg_left = glmsg.add_args();
-    arg_left->set_isarray(false);
-    arg_left->set_type(GLMessage::DataType::FLOAT);
-    arg_left->add_floatvalue(left);
+    // copy argument l
+    GLMessage_DataType *arg_l = glmsg.add_args();
+    arg_l->set_isarray(false);
+    arg_l->set_type(GLMessage::DataType::FLOAT);
+    arg_l->add_floatvalue(l);
 
-    // copy argument right
-    GLMessage_DataType *arg_right = glmsg.add_args();
-    arg_right->set_isarray(false);
-    arg_right->set_type(GLMessage::DataType::FLOAT);
-    arg_right->add_floatvalue(right);
+    // copy argument r
+    GLMessage_DataType *arg_r = glmsg.add_args();
+    arg_r->set_isarray(false);
+    arg_r->set_type(GLMessage::DataType::FLOAT);
+    arg_r->add_floatvalue(r);
 
-    // copy argument bottom
-    GLMessage_DataType *arg_bottom = glmsg.add_args();
-    arg_bottom->set_isarray(false);
-    arg_bottom->set_type(GLMessage::DataType::FLOAT);
-    arg_bottom->add_floatvalue(bottom);
+    // copy argument b
+    GLMessage_DataType *arg_b = glmsg.add_args();
+    arg_b->set_isarray(false);
+    arg_b->set_type(GLMessage::DataType::FLOAT);
+    arg_b->add_floatvalue(b);
 
-    // copy argument top
-    GLMessage_DataType *arg_top = glmsg.add_args();
-    arg_top->set_isarray(false);
-    arg_top->set_type(GLMessage::DataType::FLOAT);
-    arg_top->add_floatvalue(top);
+    // copy argument t
+    GLMessage_DataType *arg_t = glmsg.add_args();
+    arg_t->set_isarray(false);
+    arg_t->set_type(GLMessage::DataType::FLOAT);
+    arg_t->add_floatvalue(t);
 
-    // copy argument zNear
-    GLMessage_DataType *arg_zNear = glmsg.add_args();
-    arg_zNear->set_isarray(false);
-    arg_zNear->set_type(GLMessage::DataType::FLOAT);
-    arg_zNear->add_floatvalue(zNear);
+    // copy argument n
+    GLMessage_DataType *arg_n = glmsg.add_args();
+    arg_n->set_isarray(false);
+    arg_n->set_type(GLMessage::DataType::FLOAT);
+    arg_n->add_floatvalue(n);
 
-    // copy argument zFar
-    GLMessage_DataType *arg_zFar = glmsg.add_args();
-    arg_zFar->set_isarray(false);
-    arg_zFar->set_type(GLMessage::DataType::FLOAT);
-    arg_zFar->add_floatvalue(zFar);
+    // copy argument f
+    GLMessage_DataType *arg_f = glmsg.add_args();
+    arg_f->set_isarray(false);
+    arg_f->set_type(GLMessage::DataType::FLOAT);
+    arg_f->add_floatvalue(f);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glFrustumf(left, right, bottom, top, zNear, zFar);
+    glContext->hooks->gl.glFrustumf(l, r, b, t, n, f);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -16025,33 +23707,33 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetClipPlanef(GLenum pname, GLfloat eqn[4]) {
+void GLTrace_glGetClipPlanef(GLenum plane, GLfloat * equation) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glGetClipPlanef);
 
-    // copy argument pname
-    GLMessage_DataType *arg_pname = glmsg.add_args();
-    arg_pname->set_isarray(false);
-    arg_pname->set_type(GLMessage::DataType::ENUM);
-    arg_pname->add_intvalue((int)pname);
+    // copy argument plane
+    GLMessage_DataType *arg_plane = glmsg.add_args();
+    arg_plane->set_isarray(false);
+    arg_plane->set_type(GLMessage::DataType::ENUM);
+    arg_plane->add_intvalue((int)plane);
 
-    // copy argument eqn
-    GLMessage_DataType *arg_eqn = glmsg.add_args();
-    arg_eqn->set_isarray(false);
-    arg_eqn->set_type(GLMessage::DataType::INT64);
-    arg_eqn->add_int64value((uintptr_t)eqn);
+    // copy argument equation
+    GLMessage_DataType *arg_equation = glmsg.add_args();
+    arg_equation->set_isarray(false);
+    arg_equation->set_type(GLMessage::DataType::INT64);
+    arg_equation->add_int64value((uintptr_t)equation);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetClipPlanef(pname, eqn);
+    glContext->hooks->gl.glGetClipPlanef(plane, equation);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) eqn,
+        (void *) equation,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -16060,7 +23742,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetLightfv(GLenum light, GLenum pname, GLfloat *params) {
+void GLTrace_glGetLightfv(GLenum light, GLenum pname, GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -16101,7 +23783,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params) {
+void GLTrace_glGetMaterialfv(GLenum face, GLenum pname, GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -16142,17 +23824,17 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetTexEnvfv(GLenum env, GLenum pname, GLfloat *params) {
+void GLTrace_glGetTexEnvfv(GLenum target, GLenum pname, GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glGetTexEnvfv);
 
-    // copy argument env
-    GLMessage_DataType *arg_env = glmsg.add_args();
-    arg_env->set_isarray(false);
-    arg_env->set_type(GLMessage::DataType::ENUM);
-    arg_env->add_intvalue((int)env);
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
 
     // copy argument pname
     GLMessage_DataType *arg_pname = glmsg.add_args();
@@ -16169,7 +23851,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetTexEnvfv(env, pname, params);
+    glContext->hooks->gl.glGetTexEnvfv(target, pname, params);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -16217,7 +23899,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glLightModelfv(GLenum pname, const GLfloat *params) {
+void GLTrace_glLightModelfv(GLenum pname, const GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -16292,7 +23974,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glLightfv(GLenum light, GLenum pname, const GLfloat *params) {
+void GLTrace_glLightfv(GLenum light, GLenum pname, const GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -16333,7 +24015,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glLoadMatrixf(const GLfloat *m) {
+void GLTrace_glLoadMatrixf(const GLfloat * m) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -16402,7 +24084,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glMaterialfv(GLenum face, GLenum pname, const GLfloat *params) {
+void GLTrace_glMaterialfv(GLenum face, GLenum pname, const GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -16443,7 +24125,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glMultMatrixf(const GLfloat *m) {
+void GLTrace_glMultMatrixf(const GLfloat * m) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -16564,52 +24246,52 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) {
+void GLTrace_glOrthof(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glOrthof);
 
-    // copy argument left
-    GLMessage_DataType *arg_left = glmsg.add_args();
-    arg_left->set_isarray(false);
-    arg_left->set_type(GLMessage::DataType::FLOAT);
-    arg_left->add_floatvalue(left);
+    // copy argument l
+    GLMessage_DataType *arg_l = glmsg.add_args();
+    arg_l->set_isarray(false);
+    arg_l->set_type(GLMessage::DataType::FLOAT);
+    arg_l->add_floatvalue(l);
 
-    // copy argument right
-    GLMessage_DataType *arg_right = glmsg.add_args();
-    arg_right->set_isarray(false);
-    arg_right->set_type(GLMessage::DataType::FLOAT);
-    arg_right->add_floatvalue(right);
+    // copy argument r
+    GLMessage_DataType *arg_r = glmsg.add_args();
+    arg_r->set_isarray(false);
+    arg_r->set_type(GLMessage::DataType::FLOAT);
+    arg_r->add_floatvalue(r);
 
-    // copy argument bottom
-    GLMessage_DataType *arg_bottom = glmsg.add_args();
-    arg_bottom->set_isarray(false);
-    arg_bottom->set_type(GLMessage::DataType::FLOAT);
-    arg_bottom->add_floatvalue(bottom);
+    // copy argument b
+    GLMessage_DataType *arg_b = glmsg.add_args();
+    arg_b->set_isarray(false);
+    arg_b->set_type(GLMessage::DataType::FLOAT);
+    arg_b->add_floatvalue(b);
 
-    // copy argument top
-    GLMessage_DataType *arg_top = glmsg.add_args();
-    arg_top->set_isarray(false);
-    arg_top->set_type(GLMessage::DataType::FLOAT);
-    arg_top->add_floatvalue(top);
+    // copy argument t
+    GLMessage_DataType *arg_t = glmsg.add_args();
+    arg_t->set_isarray(false);
+    arg_t->set_type(GLMessage::DataType::FLOAT);
+    arg_t->add_floatvalue(t);
 
-    // copy argument zNear
-    GLMessage_DataType *arg_zNear = glmsg.add_args();
-    arg_zNear->set_isarray(false);
-    arg_zNear->set_type(GLMessage::DataType::FLOAT);
-    arg_zNear->add_floatvalue(zNear);
+    // copy argument n
+    GLMessage_DataType *arg_n = glmsg.add_args();
+    arg_n->set_isarray(false);
+    arg_n->set_type(GLMessage::DataType::FLOAT);
+    arg_n->add_floatvalue(n);
 
-    // copy argument zFar
-    GLMessage_DataType *arg_zFar = glmsg.add_args();
-    arg_zFar->set_isarray(false);
-    arg_zFar->set_type(GLMessage::DataType::FLOAT);
-    arg_zFar->add_floatvalue(zFar);
+    // copy argument f
+    GLMessage_DataType *arg_f = glmsg.add_args();
+    arg_f->set_isarray(false);
+    arg_f->set_type(GLMessage::DataType::FLOAT);
+    arg_f->add_floatvalue(f);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glOrthof(left, right, bottom, top, zNear, zFar);
+    glContext->hooks->gl.glOrthof(l, r, b, t, n, f);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -16656,7 +24338,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glPointParameterfv(GLenum pname, const GLfloat *params) {
+void GLTrace_glPointParameterfv(GLenum pname, const GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -16845,7 +24527,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexEnvfv(GLenum target, GLenum pname, const GLfloat *params) {
+void GLTrace_glTexEnvfv(GLenum target, GLenum pname, const GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -16926,7 +24608,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glAlphaFuncx(GLenum func, GLclampx ref) {
+void GLTrace_glAlphaFuncx(GLenum func, GLfixed ref) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -16960,7 +24642,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glClearColorx(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) {
+void GLTrace_glClearColorx(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -17006,7 +24688,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glClearDepthx(GLclampx depth) {
+void GLTrace_glClearDepthx(GLfixed depth) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -17062,7 +24744,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glClipPlanex(GLenum plane, const GLfixed *equation) {
+void GLTrace_glClipPlanex(GLenum plane, const GLfixed * equation) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -17189,7 +24871,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
+void GLTrace_glColorPointer(GLint size, GLenum type, GLsizei stride, const void * pointer) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -17236,28 +24918,28 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDepthRangex(GLclampx zNear, GLclampx zFar) {
+void GLTrace_glDepthRangex(GLfixed n, GLfixed f) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glDepthRangex);
 
-    // copy argument zNear
-    GLMessage_DataType *arg_zNear = glmsg.add_args();
-    arg_zNear->set_isarray(false);
-    arg_zNear->set_type(GLMessage::DataType::INT);
-    arg_zNear->add_intvalue(zNear);
+    // copy argument n
+    GLMessage_DataType *arg_n = glmsg.add_args();
+    arg_n->set_isarray(false);
+    arg_n->set_type(GLMessage::DataType::INT);
+    arg_n->add_intvalue(n);
 
-    // copy argument zFar
-    GLMessage_DataType *arg_zFar = glmsg.add_args();
-    arg_zFar->set_isarray(false);
-    arg_zFar->set_type(GLMessage::DataType::INT);
-    arg_zFar->add_intvalue(zFar);
+    // copy argument f
+    GLMessage_DataType *arg_f = glmsg.add_args();
+    arg_f->set_isarray(false);
+    arg_f->set_type(GLMessage::DataType::INT);
+    arg_f->add_intvalue(f);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glDepthRangex(zNear, zFar);
+    glContext->hooks->gl.glDepthRangex(n, f);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -17360,7 +25042,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glFogxv(GLenum pname, const GLfixed *params) {
+void GLTrace_glFogxv(GLenum pname, const GLfixed * param) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -17372,21 +25054,21 @@
     arg_pname->set_type(GLMessage::DataType::ENUM);
     arg_pname->add_intvalue((int)pname);
 
-    // copy argument params
-    GLMessage_DataType *arg_params = glmsg.add_args();
-    arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT64);
-    arg_params->add_int64value((uintptr_t)params);
+    // copy argument param
+    GLMessage_DataType *arg_param = glmsg.add_args();
+    arg_param->set_isarray(false);
+    arg_param->set_type(GLMessage::DataType::INT64);
+    arg_param->add_int64value((uintptr_t)param);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glFogxv(pname, params);
+    glContext->hooks->gl.glFogxv(pname, param);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) params,
+        (void *) param,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -17395,52 +25077,52 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glFrustumx(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) {
+void GLTrace_glFrustumx(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glFrustumx);
 
-    // copy argument left
-    GLMessage_DataType *arg_left = glmsg.add_args();
-    arg_left->set_isarray(false);
-    arg_left->set_type(GLMessage::DataType::INT);
-    arg_left->add_intvalue(left);
+    // copy argument l
+    GLMessage_DataType *arg_l = glmsg.add_args();
+    arg_l->set_isarray(false);
+    arg_l->set_type(GLMessage::DataType::INT);
+    arg_l->add_intvalue(l);
 
-    // copy argument right
-    GLMessage_DataType *arg_right = glmsg.add_args();
-    arg_right->set_isarray(false);
-    arg_right->set_type(GLMessage::DataType::INT);
-    arg_right->add_intvalue(right);
+    // copy argument r
+    GLMessage_DataType *arg_r = glmsg.add_args();
+    arg_r->set_isarray(false);
+    arg_r->set_type(GLMessage::DataType::INT);
+    arg_r->add_intvalue(r);
 
-    // copy argument bottom
-    GLMessage_DataType *arg_bottom = glmsg.add_args();
-    arg_bottom->set_isarray(false);
-    arg_bottom->set_type(GLMessage::DataType::INT);
-    arg_bottom->add_intvalue(bottom);
+    // copy argument b
+    GLMessage_DataType *arg_b = glmsg.add_args();
+    arg_b->set_isarray(false);
+    arg_b->set_type(GLMessage::DataType::INT);
+    arg_b->add_intvalue(b);
 
-    // copy argument top
-    GLMessage_DataType *arg_top = glmsg.add_args();
-    arg_top->set_isarray(false);
-    arg_top->set_type(GLMessage::DataType::INT);
-    arg_top->add_intvalue(top);
+    // copy argument t
+    GLMessage_DataType *arg_t = glmsg.add_args();
+    arg_t->set_isarray(false);
+    arg_t->set_type(GLMessage::DataType::INT);
+    arg_t->add_intvalue(t);
 
-    // copy argument zNear
-    GLMessage_DataType *arg_zNear = glmsg.add_args();
-    arg_zNear->set_isarray(false);
-    arg_zNear->set_type(GLMessage::DataType::INT);
-    arg_zNear->add_intvalue(zNear);
+    // copy argument n
+    GLMessage_DataType *arg_n = glmsg.add_args();
+    arg_n->set_isarray(false);
+    arg_n->set_type(GLMessage::DataType::INT);
+    arg_n->add_intvalue(n);
 
-    // copy argument zFar
-    GLMessage_DataType *arg_zFar = glmsg.add_args();
-    arg_zFar->set_isarray(false);
-    arg_zFar->set_type(GLMessage::DataType::INT);
-    arg_zFar->add_intvalue(zFar);
+    // copy argument f
+    GLMessage_DataType *arg_f = glmsg.add_args();
+    arg_f->set_isarray(false);
+    arg_f->set_type(GLMessage::DataType::INT);
+    arg_f->add_intvalue(f);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glFrustumx(left, right, bottom, top, zNear, zFar);
+    glContext->hooks->gl.glFrustumx(l, r, b, t, n, f);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -17453,33 +25135,33 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetClipPlanex(GLenum pname, GLfixed eqn[4]) {
+void GLTrace_glGetClipPlanex(GLenum plane, GLfixed * equation) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glGetClipPlanex);
 
-    // copy argument pname
-    GLMessage_DataType *arg_pname = glmsg.add_args();
-    arg_pname->set_isarray(false);
-    arg_pname->set_type(GLMessage::DataType::ENUM);
-    arg_pname->add_intvalue((int)pname);
+    // copy argument plane
+    GLMessage_DataType *arg_plane = glmsg.add_args();
+    arg_plane->set_isarray(false);
+    arg_plane->set_type(GLMessage::DataType::ENUM);
+    arg_plane->add_intvalue((int)plane);
 
-    // copy argument eqn
-    GLMessage_DataType *arg_eqn = glmsg.add_args();
-    arg_eqn->set_isarray(false);
-    arg_eqn->set_type(GLMessage::DataType::INT64);
-    arg_eqn->add_int64value((uintptr_t)eqn);
+    // copy argument equation
+    GLMessage_DataType *arg_equation = glmsg.add_args();
+    arg_equation->set_isarray(false);
+    arg_equation->set_type(GLMessage::DataType::INT64);
+    arg_equation->add_int64value((uintptr_t)equation);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetClipPlanex(pname, eqn);
+    glContext->hooks->gl.glGetClipPlanex(plane, equation);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) eqn,
+        (void *) equation,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -17488,7 +25170,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetFixedv(GLenum pname, GLfixed *params) {
+void GLTrace_glGetFixedv(GLenum pname, GLfixed * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -17523,7 +25205,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetLightxv(GLenum light, GLenum pname, GLfixed *params) {
+void GLTrace_glGetLightxv(GLenum light, GLenum pname, GLfixed * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -17564,7 +25246,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetMaterialxv(GLenum face, GLenum pname, GLfixed *params) {
+void GLTrace_glGetMaterialxv(GLenum face, GLenum pname, GLfixed * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -17605,7 +25287,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetPointerv(GLenum pname, GLvoid **params) {
+void GLTrace_glGetPointerv(GLenum pname, void ** params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -17640,17 +25322,17 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetTexEnviv(GLenum env, GLenum pname, GLint *params) {
+void GLTrace_glGetTexEnviv(GLenum target, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glGetTexEnviv);
 
-    // copy argument env
-    GLMessage_DataType *arg_env = glmsg.add_args();
-    arg_env->set_isarray(false);
-    arg_env->set_type(GLMessage::DataType::ENUM);
-    arg_env->add_intvalue((int)env);
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
 
     // copy argument pname
     GLMessage_DataType *arg_pname = glmsg.add_args();
@@ -17667,7 +25349,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetTexEnviv(env, pname, params);
+    glContext->hooks->gl.glGetTexEnviv(target, pname, params);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -17681,17 +25363,17 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetTexEnvxv(GLenum env, GLenum pname, GLfixed *params) {
+void GLTrace_glGetTexEnvxv(GLenum target, GLenum pname, GLfixed * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glGetTexEnvxv);
 
-    // copy argument env
-    GLMessage_DataType *arg_env = glmsg.add_args();
-    arg_env->set_isarray(false);
-    arg_env->set_type(GLMessage::DataType::ENUM);
-    arg_env->add_intvalue((int)env);
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
 
     // copy argument pname
     GLMessage_DataType *arg_pname = glmsg.add_args();
@@ -17708,7 +25390,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetTexEnvxv(env, pname, params);
+    glContext->hooks->gl.glGetTexEnvxv(target, pname, params);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -17722,7 +25404,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetTexParameterxv(GLenum target, GLenum pname, GLfixed *params) {
+void GLTrace_glGetTexParameterxv(GLenum target, GLenum pname, GLfixed * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -17797,7 +25479,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glLightModelxv(GLenum pname, const GLfixed *params) {
+void GLTrace_glLightModelxv(GLenum pname, const GLfixed * param) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -17809,21 +25491,21 @@
     arg_pname->set_type(GLMessage::DataType::ENUM);
     arg_pname->add_intvalue((int)pname);
 
-    // copy argument params
-    GLMessage_DataType *arg_params = glmsg.add_args();
-    arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT64);
-    arg_params->add_int64value((uintptr_t)params);
+    // copy argument param
+    GLMessage_DataType *arg_param = glmsg.add_args();
+    arg_param->set_isarray(false);
+    arg_param->set_type(GLMessage::DataType::INT64);
+    arg_param->add_int64value((uintptr_t)param);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glLightModelxv(pname, params);
+    glContext->hooks->gl.glLightModelxv(pname, param);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) params,
+        (void *) param,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -17872,7 +25554,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glLightxv(GLenum light, GLenum pname, const GLfixed *params) {
+void GLTrace_glLightxv(GLenum light, GLenum pname, const GLfixed * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -17963,7 +25645,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glLoadMatrixx(const GLfixed *m) {
+void GLTrace_glLoadMatrixx(const GLfixed * m) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -18060,7 +25742,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glMaterialxv(GLenum face, GLenum pname, const GLfixed *params) {
+void GLTrace_glMaterialxv(GLenum face, GLenum pname, const GLfixed * param) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -18078,21 +25760,21 @@
     arg_pname->set_type(GLMessage::DataType::ENUM);
     arg_pname->add_intvalue((int)pname);
 
-    // copy argument params
-    GLMessage_DataType *arg_params = glmsg.add_args();
-    arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT64);
-    arg_params->add_int64value((uintptr_t)params);
+    // copy argument param
+    GLMessage_DataType *arg_param = glmsg.add_args();
+    arg_param->set_isarray(false);
+    arg_param->set_type(GLMessage::DataType::INT64);
+    arg_param->add_int64value((uintptr_t)param);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glMaterialxv(face, pname, params);
+    glContext->hooks->gl.glMaterialxv(face, pname, param);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) params,
+        (void *) param,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -18129,7 +25811,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glMultMatrixx(const GLfixed *m) {
+void GLTrace_glMultMatrixx(const GLfixed * m) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -18158,17 +25840,17 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glMultiTexCoord4x(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) {
+void GLTrace_glMultiTexCoord4x(GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glMultiTexCoord4x);
 
-    // copy argument target
-    GLMessage_DataType *arg_target = glmsg.add_args();
-    arg_target->set_isarray(false);
-    arg_target->set_type(GLMessage::DataType::ENUM);
-    arg_target->add_intvalue((int)target);
+    // copy argument texture
+    GLMessage_DataType *arg_texture = glmsg.add_args();
+    arg_texture->set_isarray(false);
+    arg_texture->set_type(GLMessage::DataType::ENUM);
+    arg_texture->add_intvalue((int)texture);
 
     // copy argument s
     GLMessage_DataType *arg_s = glmsg.add_args();
@@ -18197,7 +25879,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glMultiTexCoord4x(target, s, t, r, q);
+    glContext->hooks->gl.glMultiTexCoord4x(texture, s, t, r, q);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -18250,7 +25932,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer) {
+void GLTrace_glNormalPointer(GLenum type, GLsizei stride, const void * pointer) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -18291,52 +25973,52 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glOrthox(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) {
+void GLTrace_glOrthox(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glOrthox);
 
-    // copy argument left
-    GLMessage_DataType *arg_left = glmsg.add_args();
-    arg_left->set_isarray(false);
-    arg_left->set_type(GLMessage::DataType::INT);
-    arg_left->add_intvalue(left);
+    // copy argument l
+    GLMessage_DataType *arg_l = glmsg.add_args();
+    arg_l->set_isarray(false);
+    arg_l->set_type(GLMessage::DataType::INT);
+    arg_l->add_intvalue(l);
 
-    // copy argument right
-    GLMessage_DataType *arg_right = glmsg.add_args();
-    arg_right->set_isarray(false);
-    arg_right->set_type(GLMessage::DataType::INT);
-    arg_right->add_intvalue(right);
+    // copy argument r
+    GLMessage_DataType *arg_r = glmsg.add_args();
+    arg_r->set_isarray(false);
+    arg_r->set_type(GLMessage::DataType::INT);
+    arg_r->add_intvalue(r);
 
-    // copy argument bottom
-    GLMessage_DataType *arg_bottom = glmsg.add_args();
-    arg_bottom->set_isarray(false);
-    arg_bottom->set_type(GLMessage::DataType::INT);
-    arg_bottom->add_intvalue(bottom);
+    // copy argument b
+    GLMessage_DataType *arg_b = glmsg.add_args();
+    arg_b->set_isarray(false);
+    arg_b->set_type(GLMessage::DataType::INT);
+    arg_b->add_intvalue(b);
 
-    // copy argument top
-    GLMessage_DataType *arg_top = glmsg.add_args();
-    arg_top->set_isarray(false);
-    arg_top->set_type(GLMessage::DataType::INT);
-    arg_top->add_intvalue(top);
+    // copy argument t
+    GLMessage_DataType *arg_t = glmsg.add_args();
+    arg_t->set_isarray(false);
+    arg_t->set_type(GLMessage::DataType::INT);
+    arg_t->add_intvalue(t);
 
-    // copy argument zNear
-    GLMessage_DataType *arg_zNear = glmsg.add_args();
-    arg_zNear->set_isarray(false);
-    arg_zNear->set_type(GLMessage::DataType::INT);
-    arg_zNear->add_intvalue(zNear);
+    // copy argument n
+    GLMessage_DataType *arg_n = glmsg.add_args();
+    arg_n->set_isarray(false);
+    arg_n->set_type(GLMessage::DataType::INT);
+    arg_n->add_intvalue(n);
 
-    // copy argument zFar
-    GLMessage_DataType *arg_zFar = glmsg.add_args();
-    arg_zFar->set_isarray(false);
-    arg_zFar->set_type(GLMessage::DataType::INT);
-    arg_zFar->add_intvalue(zFar);
+    // copy argument f
+    GLMessage_DataType *arg_f = glmsg.add_args();
+    arg_f->set_isarray(false);
+    arg_f->set_type(GLMessage::DataType::INT);
+    arg_f->add_intvalue(f);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glOrthox(left, right, bottom, top, zNear, zFar);
+    glContext->hooks->gl.glOrthox(l, r, b, t, n, f);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -18383,7 +26065,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glPointParameterxv(GLenum pname, const GLfixed *params) {
+void GLTrace_glPointParameterxv(GLenum pname, const GLfixed * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -18672,7 +26354,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
+void GLTrace_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const void * pointer) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -18799,7 +26481,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexEnviv(GLenum target, GLenum pname, const GLint *params) {
+void GLTrace_glTexEnviv(GLenum target, GLenum pname, const GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -18840,7 +26522,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexEnvxv(GLenum target, GLenum pname, const GLfixed *params) {
+void GLTrace_glTexEnvxv(GLenum target, GLenum pname, const GLfixed * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -18921,7 +26603,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexParameterxv(GLenum target, GLenum pname, const GLfixed *params) {
+void GLTrace_glTexParameterxv(GLenum target, GLenum pname, const GLfixed * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -19002,7 +26684,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
+void GLTrace_glVertexPointer(GLint size, GLenum type, GLsizei stride, const void * pointer) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -19049,47 +26731,6 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glPointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *pointer) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glPointSizePointerOES);
-
-    // copy argument type
-    GLMessage_DataType *arg_type = glmsg.add_args();
-    arg_type->set_isarray(false);
-    arg_type->set_type(GLMessage::DataType::ENUM);
-    arg_type->add_intvalue((int)type);
-
-    // copy argument stride
-    GLMessage_DataType *arg_stride = glmsg.add_args();
-    arg_stride->set_isarray(false);
-    arg_stride->set_type(GLMessage::DataType::INT);
-    arg_stride->add_intvalue(stride);
-
-    // copy argument pointer
-    GLMessage_DataType *arg_pointer = glmsg.add_args();
-    arg_pointer->set_isarray(false);
-    arg_pointer->set_type(GLMessage::DataType::INT64);
-    arg_pointer->add_int64value((uintptr_t)pointer);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glPointSizePointerOES(type, stride, pointer);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-        (void *) pointer,
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
 
 // Definitions for GL1Ext APIs
 
@@ -19201,6 +26842,771 @@
     glContext->traceGLMessage(&glmsg);
 }
 
+void GLTrace_glMultiTexCoord1bOES(GLenum texture, GLbyte s) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glMultiTexCoord1bOES);
+
+    // copy argument texture
+    GLMessage_DataType *arg_texture = glmsg.add_args();
+    arg_texture->set_isarray(false);
+    arg_texture->set_type(GLMessage::DataType::ENUM);
+    arg_texture->add_intvalue((int)texture);
+
+    // copy argument s
+    GLMessage_DataType *arg_s = glmsg.add_args();
+    arg_s->set_isarray(false);
+    arg_s->set_type(GLMessage::DataType::BYTE);
+    arg_s->add_intvalue((int)s);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glMultiTexCoord1bOES(texture, s);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glMultiTexCoord1bvOES(GLenum texture, const GLbyte * coords) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glMultiTexCoord1bvOES);
+
+    // copy argument texture
+    GLMessage_DataType *arg_texture = glmsg.add_args();
+    arg_texture->set_isarray(false);
+    arg_texture->set_type(GLMessage::DataType::ENUM);
+    arg_texture->add_intvalue((int)texture);
+
+    // copy argument coords
+    GLMessage_DataType *arg_coords = glmsg.add_args();
+    arg_coords->set_isarray(false);
+    arg_coords->set_type(GLMessage::DataType::INT64);
+    arg_coords->add_int64value((uintptr_t)coords);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glMultiTexCoord1bvOES(texture, coords);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) coords,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glMultiTexCoord2bOES(GLenum texture, GLbyte s, GLbyte t) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glMultiTexCoord2bOES);
+
+    // copy argument texture
+    GLMessage_DataType *arg_texture = glmsg.add_args();
+    arg_texture->set_isarray(false);
+    arg_texture->set_type(GLMessage::DataType::ENUM);
+    arg_texture->add_intvalue((int)texture);
+
+    // copy argument s
+    GLMessage_DataType *arg_s = glmsg.add_args();
+    arg_s->set_isarray(false);
+    arg_s->set_type(GLMessage::DataType::BYTE);
+    arg_s->add_intvalue((int)s);
+
+    // copy argument t
+    GLMessage_DataType *arg_t = glmsg.add_args();
+    arg_t->set_isarray(false);
+    arg_t->set_type(GLMessage::DataType::BYTE);
+    arg_t->add_intvalue((int)t);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glMultiTexCoord2bOES(texture, s, t);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glMultiTexCoord2bvOES(GLenum texture, const GLbyte * coords) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glMultiTexCoord2bvOES);
+
+    // copy argument texture
+    GLMessage_DataType *arg_texture = glmsg.add_args();
+    arg_texture->set_isarray(false);
+    arg_texture->set_type(GLMessage::DataType::ENUM);
+    arg_texture->add_intvalue((int)texture);
+
+    // copy argument coords
+    GLMessage_DataType *arg_coords = glmsg.add_args();
+    arg_coords->set_isarray(false);
+    arg_coords->set_type(GLMessage::DataType::INT64);
+    arg_coords->add_int64value((uintptr_t)coords);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glMultiTexCoord2bvOES(texture, coords);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) coords,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glMultiTexCoord3bOES(GLenum texture, GLbyte s, GLbyte t, GLbyte r) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glMultiTexCoord3bOES);
+
+    // copy argument texture
+    GLMessage_DataType *arg_texture = glmsg.add_args();
+    arg_texture->set_isarray(false);
+    arg_texture->set_type(GLMessage::DataType::ENUM);
+    arg_texture->add_intvalue((int)texture);
+
+    // copy argument s
+    GLMessage_DataType *arg_s = glmsg.add_args();
+    arg_s->set_isarray(false);
+    arg_s->set_type(GLMessage::DataType::BYTE);
+    arg_s->add_intvalue((int)s);
+
+    // copy argument t
+    GLMessage_DataType *arg_t = glmsg.add_args();
+    arg_t->set_isarray(false);
+    arg_t->set_type(GLMessage::DataType::BYTE);
+    arg_t->add_intvalue((int)t);
+
+    // copy argument r
+    GLMessage_DataType *arg_r = glmsg.add_args();
+    arg_r->set_isarray(false);
+    arg_r->set_type(GLMessage::DataType::BYTE);
+    arg_r->add_intvalue((int)r);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glMultiTexCoord3bOES(texture, s, t, r);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glMultiTexCoord3bvOES(GLenum texture, const GLbyte * coords) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glMultiTexCoord3bvOES);
+
+    // copy argument texture
+    GLMessage_DataType *arg_texture = glmsg.add_args();
+    arg_texture->set_isarray(false);
+    arg_texture->set_type(GLMessage::DataType::ENUM);
+    arg_texture->add_intvalue((int)texture);
+
+    // copy argument coords
+    GLMessage_DataType *arg_coords = glmsg.add_args();
+    arg_coords->set_isarray(false);
+    arg_coords->set_type(GLMessage::DataType::INT64);
+    arg_coords->add_int64value((uintptr_t)coords);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glMultiTexCoord3bvOES(texture, coords);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) coords,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glMultiTexCoord4bOES(GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glMultiTexCoord4bOES);
+
+    // copy argument texture
+    GLMessage_DataType *arg_texture = glmsg.add_args();
+    arg_texture->set_isarray(false);
+    arg_texture->set_type(GLMessage::DataType::ENUM);
+    arg_texture->add_intvalue((int)texture);
+
+    // copy argument s
+    GLMessage_DataType *arg_s = glmsg.add_args();
+    arg_s->set_isarray(false);
+    arg_s->set_type(GLMessage::DataType::BYTE);
+    arg_s->add_intvalue((int)s);
+
+    // copy argument t
+    GLMessage_DataType *arg_t = glmsg.add_args();
+    arg_t->set_isarray(false);
+    arg_t->set_type(GLMessage::DataType::BYTE);
+    arg_t->add_intvalue((int)t);
+
+    // copy argument r
+    GLMessage_DataType *arg_r = glmsg.add_args();
+    arg_r->set_isarray(false);
+    arg_r->set_type(GLMessage::DataType::BYTE);
+    arg_r->add_intvalue((int)r);
+
+    // copy argument q
+    GLMessage_DataType *arg_q = glmsg.add_args();
+    arg_q->set_isarray(false);
+    arg_q->set_type(GLMessage::DataType::BYTE);
+    arg_q->add_intvalue((int)q);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glMultiTexCoord4bOES(texture, s, t, r, q);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glMultiTexCoord4bvOES(GLenum texture, const GLbyte * coords) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glMultiTexCoord4bvOES);
+
+    // copy argument texture
+    GLMessage_DataType *arg_texture = glmsg.add_args();
+    arg_texture->set_isarray(false);
+    arg_texture->set_type(GLMessage::DataType::ENUM);
+    arg_texture->add_intvalue((int)texture);
+
+    // copy argument coords
+    GLMessage_DataType *arg_coords = glmsg.add_args();
+    arg_coords->set_isarray(false);
+    arg_coords->set_type(GLMessage::DataType::INT64);
+    arg_coords->add_int64value((uintptr_t)coords);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glMultiTexCoord4bvOES(texture, coords);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) coords,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glTexCoord1bOES(GLbyte s) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTexCoord1bOES);
+
+    // copy argument s
+    GLMessage_DataType *arg_s = glmsg.add_args();
+    arg_s->set_isarray(false);
+    arg_s->set_type(GLMessage::DataType::BYTE);
+    arg_s->add_intvalue((int)s);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTexCoord1bOES(s);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glTexCoord1bvOES(const GLbyte * coords) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTexCoord1bvOES);
+
+    // copy argument coords
+    GLMessage_DataType *arg_coords = glmsg.add_args();
+    arg_coords->set_isarray(false);
+    arg_coords->set_type(GLMessage::DataType::INT64);
+    arg_coords->add_int64value((uintptr_t)coords);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTexCoord1bvOES(coords);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) coords,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glTexCoord2bOES(GLbyte s, GLbyte t) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTexCoord2bOES);
+
+    // copy argument s
+    GLMessage_DataType *arg_s = glmsg.add_args();
+    arg_s->set_isarray(false);
+    arg_s->set_type(GLMessage::DataType::BYTE);
+    arg_s->add_intvalue((int)s);
+
+    // copy argument t
+    GLMessage_DataType *arg_t = glmsg.add_args();
+    arg_t->set_isarray(false);
+    arg_t->set_type(GLMessage::DataType::BYTE);
+    arg_t->add_intvalue((int)t);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTexCoord2bOES(s, t);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glTexCoord2bvOES(const GLbyte * coords) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTexCoord2bvOES);
+
+    // copy argument coords
+    GLMessage_DataType *arg_coords = glmsg.add_args();
+    arg_coords->set_isarray(false);
+    arg_coords->set_type(GLMessage::DataType::INT64);
+    arg_coords->add_int64value((uintptr_t)coords);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTexCoord2bvOES(coords);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) coords,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glTexCoord3bOES(GLbyte s, GLbyte t, GLbyte r) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTexCoord3bOES);
+
+    // copy argument s
+    GLMessage_DataType *arg_s = glmsg.add_args();
+    arg_s->set_isarray(false);
+    arg_s->set_type(GLMessage::DataType::BYTE);
+    arg_s->add_intvalue((int)s);
+
+    // copy argument t
+    GLMessage_DataType *arg_t = glmsg.add_args();
+    arg_t->set_isarray(false);
+    arg_t->set_type(GLMessage::DataType::BYTE);
+    arg_t->add_intvalue((int)t);
+
+    // copy argument r
+    GLMessage_DataType *arg_r = glmsg.add_args();
+    arg_r->set_isarray(false);
+    arg_r->set_type(GLMessage::DataType::BYTE);
+    arg_r->add_intvalue((int)r);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTexCoord3bOES(s, t, r);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glTexCoord3bvOES(const GLbyte * coords) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTexCoord3bvOES);
+
+    // copy argument coords
+    GLMessage_DataType *arg_coords = glmsg.add_args();
+    arg_coords->set_isarray(false);
+    arg_coords->set_type(GLMessage::DataType::INT64);
+    arg_coords->add_int64value((uintptr_t)coords);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTexCoord3bvOES(coords);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) coords,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glTexCoord4bOES(GLbyte s, GLbyte t, GLbyte r, GLbyte q) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTexCoord4bOES);
+
+    // copy argument s
+    GLMessage_DataType *arg_s = glmsg.add_args();
+    arg_s->set_isarray(false);
+    arg_s->set_type(GLMessage::DataType::BYTE);
+    arg_s->add_intvalue((int)s);
+
+    // copy argument t
+    GLMessage_DataType *arg_t = glmsg.add_args();
+    arg_t->set_isarray(false);
+    arg_t->set_type(GLMessage::DataType::BYTE);
+    arg_t->add_intvalue((int)t);
+
+    // copy argument r
+    GLMessage_DataType *arg_r = glmsg.add_args();
+    arg_r->set_isarray(false);
+    arg_r->set_type(GLMessage::DataType::BYTE);
+    arg_r->add_intvalue((int)r);
+
+    // copy argument q
+    GLMessage_DataType *arg_q = glmsg.add_args();
+    arg_q->set_isarray(false);
+    arg_q->set_type(GLMessage::DataType::BYTE);
+    arg_q->add_intvalue((int)q);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTexCoord4bOES(s, t, r, q);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glTexCoord4bvOES(const GLbyte * coords) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTexCoord4bvOES);
+
+    // copy argument coords
+    GLMessage_DataType *arg_coords = glmsg.add_args();
+    arg_coords->set_isarray(false);
+    arg_coords->set_type(GLMessage::DataType::INT64);
+    arg_coords->add_int64value((uintptr_t)coords);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTexCoord4bvOES(coords);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) coords,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glVertex2bOES(GLbyte x) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glVertex2bOES);
+
+    // copy argument x
+    GLMessage_DataType *arg_x = glmsg.add_args();
+    arg_x->set_isarray(false);
+    arg_x->set_type(GLMessage::DataType::BYTE);
+    arg_x->add_intvalue((int)x);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glVertex2bOES(x);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glVertex2bvOES(const GLbyte * coords) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glVertex2bvOES);
+
+    // copy argument coords
+    GLMessage_DataType *arg_coords = glmsg.add_args();
+    arg_coords->set_isarray(false);
+    arg_coords->set_type(GLMessage::DataType::INT64);
+    arg_coords->add_int64value((uintptr_t)coords);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glVertex2bvOES(coords);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) coords,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glVertex3bOES(GLbyte x, GLbyte y) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glVertex3bOES);
+
+    // copy argument x
+    GLMessage_DataType *arg_x = glmsg.add_args();
+    arg_x->set_isarray(false);
+    arg_x->set_type(GLMessage::DataType::BYTE);
+    arg_x->add_intvalue((int)x);
+
+    // copy argument y
+    GLMessage_DataType *arg_y = glmsg.add_args();
+    arg_y->set_isarray(false);
+    arg_y->set_type(GLMessage::DataType::BYTE);
+    arg_y->add_intvalue((int)y);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glVertex3bOES(x, y);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glVertex3bvOES(const GLbyte * coords) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glVertex3bvOES);
+
+    // copy argument coords
+    GLMessage_DataType *arg_coords = glmsg.add_args();
+    arg_coords->set_isarray(false);
+    arg_coords->set_type(GLMessage::DataType::INT64);
+    arg_coords->add_int64value((uintptr_t)coords);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glVertex3bvOES(coords);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) coords,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glVertex4bOES(GLbyte x, GLbyte y, GLbyte z) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glVertex4bOES);
+
+    // copy argument x
+    GLMessage_DataType *arg_x = glmsg.add_args();
+    arg_x->set_isarray(false);
+    arg_x->set_type(GLMessage::DataType::BYTE);
+    arg_x->add_intvalue((int)x);
+
+    // copy argument y
+    GLMessage_DataType *arg_y = glmsg.add_args();
+    arg_y->set_isarray(false);
+    arg_y->set_type(GLMessage::DataType::BYTE);
+    arg_y->add_intvalue((int)y);
+
+    // copy argument z
+    GLMessage_DataType *arg_z = glmsg.add_args();
+    arg_z->set_isarray(false);
+    arg_z->set_type(GLMessage::DataType::BYTE);
+    arg_z->add_intvalue((int)z);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glVertex4bOES(x, y, z);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glVertex4bvOES(const GLbyte * coords) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glVertex4bvOES);
+
+    // copy argument coords
+    GLMessage_DataType *arg_coords = glmsg.add_args();
+    arg_coords->set_isarray(false);
+    arg_coords->set_type(GLMessage::DataType::INT64);
+    arg_coords->add_int64value((uintptr_t)coords);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glVertex4bvOES(coords);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) coords,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
 void GLTrace_glDrawTexsOES(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
@@ -19357,7 +27763,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDrawTexsvOES(const GLshort *coords) {
+void GLTrace_glDrawTexsvOES(const GLshort * coords) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -19386,7 +27792,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDrawTexivOES(const GLint *coords) {
+void GLTrace_glDrawTexivOES(const GLint * coords) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -19415,7 +27821,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDrawTexxvOES(const GLfixed *coords) {
+void GLTrace_glDrawTexxvOES(const GLfixed * coords) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -19496,7 +27902,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDrawTexfvOES(const GLfloat *coords) {
+void GLTrace_glDrawTexfvOES(const GLfloat * coords) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -19525,7 +27931,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glAlphaFuncxOES(GLenum func, GLclampx ref) {
+void GLTrace_glAlphaFuncxOES(GLenum func, GLfixed ref) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -19559,7 +27965,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glClearColorxOES(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) {
+void GLTrace_glClearColorxOES(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -19605,7 +28011,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glClearDepthxOES(GLclampx depth) {
+void GLTrace_glClearDepthxOES(GLfixed depth) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -19633,7 +28039,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glClipPlanexOES(GLenum plane, const GLfixed *equation) {
+void GLTrace_glClipPlanexOES(GLenum plane, const GLfixed * equation) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -19714,28 +28120,28 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDepthRangexOES(GLclampx zNear, GLclampx zFar) {
+void GLTrace_glDepthRangexOES(GLfixed n, GLfixed f) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glDepthRangexOES);
 
-    // copy argument zNear
-    GLMessage_DataType *arg_zNear = glmsg.add_args();
-    arg_zNear->set_isarray(false);
-    arg_zNear->set_type(GLMessage::DataType::INT);
-    arg_zNear->add_intvalue(zNear);
+    // copy argument n
+    GLMessage_DataType *arg_n = glmsg.add_args();
+    arg_n->set_isarray(false);
+    arg_n->set_type(GLMessage::DataType::INT);
+    arg_n->add_intvalue(n);
 
-    // copy argument zFar
-    GLMessage_DataType *arg_zFar = glmsg.add_args();
-    arg_zFar->set_isarray(false);
-    arg_zFar->set_type(GLMessage::DataType::INT);
-    arg_zFar->add_intvalue(zFar);
+    // copy argument f
+    GLMessage_DataType *arg_f = glmsg.add_args();
+    arg_f->set_isarray(false);
+    arg_f->set_type(GLMessage::DataType::INT);
+    arg_f->add_intvalue(f);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glDepthRangexOES(zNear, zFar);
+    glContext->hooks->gl.glDepthRangexOES(n, f);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -19782,7 +28188,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glFogxvOES(GLenum pname, const GLfixed *params) {
+void GLTrace_glFogxvOES(GLenum pname, const GLfixed * param) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -19794,21 +28200,21 @@
     arg_pname->set_type(GLMessage::DataType::ENUM);
     arg_pname->add_intvalue((int)pname);
 
-    // copy argument params
-    GLMessage_DataType *arg_params = glmsg.add_args();
-    arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT64);
-    arg_params->add_int64value((uintptr_t)params);
+    // copy argument param
+    GLMessage_DataType *arg_param = glmsg.add_args();
+    arg_param->set_isarray(false);
+    arg_param->set_type(GLMessage::DataType::INT64);
+    arg_param->add_int64value((uintptr_t)param);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glFogxvOES(pname, params);
+    glContext->hooks->gl.glFogxvOES(pname, param);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) params,
+        (void *) param,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -19817,52 +28223,52 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glFrustumxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) {
+void GLTrace_glFrustumxOES(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glFrustumxOES);
 
-    // copy argument left
-    GLMessage_DataType *arg_left = glmsg.add_args();
-    arg_left->set_isarray(false);
-    arg_left->set_type(GLMessage::DataType::INT);
-    arg_left->add_intvalue(left);
+    // copy argument l
+    GLMessage_DataType *arg_l = glmsg.add_args();
+    arg_l->set_isarray(false);
+    arg_l->set_type(GLMessage::DataType::INT);
+    arg_l->add_intvalue(l);
 
-    // copy argument right
-    GLMessage_DataType *arg_right = glmsg.add_args();
-    arg_right->set_isarray(false);
-    arg_right->set_type(GLMessage::DataType::INT);
-    arg_right->add_intvalue(right);
+    // copy argument r
+    GLMessage_DataType *arg_r = glmsg.add_args();
+    arg_r->set_isarray(false);
+    arg_r->set_type(GLMessage::DataType::INT);
+    arg_r->add_intvalue(r);
 
-    // copy argument bottom
-    GLMessage_DataType *arg_bottom = glmsg.add_args();
-    arg_bottom->set_isarray(false);
-    arg_bottom->set_type(GLMessage::DataType::INT);
-    arg_bottom->add_intvalue(bottom);
+    // copy argument b
+    GLMessage_DataType *arg_b = glmsg.add_args();
+    arg_b->set_isarray(false);
+    arg_b->set_type(GLMessage::DataType::INT);
+    arg_b->add_intvalue(b);
 
-    // copy argument top
-    GLMessage_DataType *arg_top = glmsg.add_args();
-    arg_top->set_isarray(false);
-    arg_top->set_type(GLMessage::DataType::INT);
-    arg_top->add_intvalue(top);
+    // copy argument t
+    GLMessage_DataType *arg_t = glmsg.add_args();
+    arg_t->set_isarray(false);
+    arg_t->set_type(GLMessage::DataType::INT);
+    arg_t->add_intvalue(t);
 
-    // copy argument zNear
-    GLMessage_DataType *arg_zNear = glmsg.add_args();
-    arg_zNear->set_isarray(false);
-    arg_zNear->set_type(GLMessage::DataType::INT);
-    arg_zNear->add_intvalue(zNear);
+    // copy argument n
+    GLMessage_DataType *arg_n = glmsg.add_args();
+    arg_n->set_isarray(false);
+    arg_n->set_type(GLMessage::DataType::INT);
+    arg_n->add_intvalue(n);
 
-    // copy argument zFar
-    GLMessage_DataType *arg_zFar = glmsg.add_args();
-    arg_zFar->set_isarray(false);
-    arg_zFar->set_type(GLMessage::DataType::INT);
-    arg_zFar->add_intvalue(zFar);
+    // copy argument f
+    GLMessage_DataType *arg_f = glmsg.add_args();
+    arg_f->set_isarray(false);
+    arg_f->set_type(GLMessage::DataType::INT);
+    arg_f->add_intvalue(f);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glFrustumxOES(left, right, bottom, top, zNear, zFar);
+    glContext->hooks->gl.glFrustumxOES(l, r, b, t, n, f);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -19875,33 +28281,33 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetClipPlanexOES(GLenum pname, GLfixed eqn[4]) {
+void GLTrace_glGetClipPlanexOES(GLenum plane, GLfixed * equation) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glGetClipPlanexOES);
 
-    // copy argument pname
-    GLMessage_DataType *arg_pname = glmsg.add_args();
-    arg_pname->set_isarray(false);
-    arg_pname->set_type(GLMessage::DataType::ENUM);
-    arg_pname->add_intvalue((int)pname);
+    // copy argument plane
+    GLMessage_DataType *arg_plane = glmsg.add_args();
+    arg_plane->set_isarray(false);
+    arg_plane->set_type(GLMessage::DataType::ENUM);
+    arg_plane->add_intvalue((int)plane);
 
-    // copy argument eqn
-    GLMessage_DataType *arg_eqn = glmsg.add_args();
-    arg_eqn->set_isarray(false);
-    arg_eqn->set_type(GLMessage::DataType::INT64);
-    arg_eqn->add_int64value((uintptr_t)eqn);
+    // copy argument equation
+    GLMessage_DataType *arg_equation = glmsg.add_args();
+    arg_equation->set_isarray(false);
+    arg_equation->set_type(GLMessage::DataType::INT64);
+    arg_equation->add_int64value((uintptr_t)equation);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetClipPlanexOES(pname, eqn);
+    glContext->hooks->gl.glGetClipPlanexOES(plane, equation);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) eqn,
+        (void *) equation,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -19910,7 +28316,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetFixedvOES(GLenum pname, GLfixed *params) {
+void GLTrace_glGetFixedvOES(GLenum pname, GLfixed * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -19945,99 +28351,17 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetLightxvOES(GLenum light, GLenum pname, GLfixed *params) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glGetLightxvOES);
-
-    // copy argument light
-    GLMessage_DataType *arg_light = glmsg.add_args();
-    arg_light->set_isarray(false);
-    arg_light->set_type(GLMessage::DataType::ENUM);
-    arg_light->add_intvalue((int)light);
-
-    // copy argument pname
-    GLMessage_DataType *arg_pname = glmsg.add_args();
-    arg_pname->set_isarray(false);
-    arg_pname->set_type(GLMessage::DataType::ENUM);
-    arg_pname->add_intvalue((int)pname);
-
-    // copy argument params
-    GLMessage_DataType *arg_params = glmsg.add_args();
-    arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT64);
-    arg_params->add_int64value((uintptr_t)params);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetLightxvOES(light, pname, params);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-        (void *) params,
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glGetMaterialxvOES(GLenum face, GLenum pname, GLfixed *params) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glGetMaterialxvOES);
-
-    // copy argument face
-    GLMessage_DataType *arg_face = glmsg.add_args();
-    arg_face->set_isarray(false);
-    arg_face->set_type(GLMessage::DataType::ENUM);
-    arg_face->add_intvalue((int)face);
-
-    // copy argument pname
-    GLMessage_DataType *arg_pname = glmsg.add_args();
-    arg_pname->set_isarray(false);
-    arg_pname->set_type(GLMessage::DataType::ENUM);
-    arg_pname->add_intvalue((int)pname);
-
-    // copy argument params
-    GLMessage_DataType *arg_params = glmsg.add_args();
-    arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT64);
-    arg_params->add_int64value((uintptr_t)params);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetMaterialxvOES(face, pname, params);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-        (void *) params,
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glGetTexEnvxvOES(GLenum env, GLenum pname, GLfixed *params) {
+void GLTrace_glGetTexEnvxvOES(GLenum target, GLenum pname, GLfixed * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glGetTexEnvxvOES);
 
-    // copy argument env
-    GLMessage_DataType *arg_env = glmsg.add_args();
-    arg_env->set_isarray(false);
-    arg_env->set_type(GLMessage::DataType::ENUM);
-    arg_env->add_intvalue((int)env);
+    // copy argument target
+    GLMessage_DataType *arg_target = glmsg.add_args();
+    arg_target->set_isarray(false);
+    arg_target->set_type(GLMessage::DataType::ENUM);
+    arg_target->add_intvalue((int)target);
 
     // copy argument pname
     GLMessage_DataType *arg_pname = glmsg.add_args();
@@ -20054,7 +28378,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetTexEnvxvOES(env, pname, params);
+    glContext->hooks->gl.glGetTexEnvxvOES(target, pname, params);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -20068,7 +28392,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetTexParameterxvOES(GLenum target, GLenum pname, GLfixed *params) {
+void GLTrace_glGetTexParameterxvOES(GLenum target, GLenum pname, GLfixed * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -20143,7 +28467,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glLightModelxvOES(GLenum pname, const GLfixed *params) {
+void GLTrace_glLightModelxvOES(GLenum pname, const GLfixed * param) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -20155,21 +28479,21 @@
     arg_pname->set_type(GLMessage::DataType::ENUM);
     arg_pname->add_intvalue((int)pname);
 
-    // copy argument params
-    GLMessage_DataType *arg_params = glmsg.add_args();
-    arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT64);
-    arg_params->add_int64value((uintptr_t)params);
+    // copy argument param
+    GLMessage_DataType *arg_param = glmsg.add_args();
+    arg_param->set_isarray(false);
+    arg_param->set_type(GLMessage::DataType::INT64);
+    arg_param->add_int64value((uintptr_t)param);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glLightModelxvOES(pname, params);
+    glContext->hooks->gl.glLightModelxvOES(pname, param);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) params,
+        (void *) param,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -20218,7 +28542,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glLightxvOES(GLenum light, GLenum pname, const GLfixed *params) {
+void GLTrace_glLightxvOES(GLenum light, GLenum pname, const GLfixed * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -20287,7 +28611,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glLoadMatrixxOES(const GLfixed *m) {
+void GLTrace_glLoadMatrixxOES(const GLfixed * m) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -20356,7 +28680,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glMaterialxvOES(GLenum face, GLenum pname, const GLfixed *params) {
+void GLTrace_glMaterialxvOES(GLenum face, GLenum pname, const GLfixed * param) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -20374,21 +28698,21 @@
     arg_pname->set_type(GLMessage::DataType::ENUM);
     arg_pname->add_intvalue((int)pname);
 
-    // copy argument params
-    GLMessage_DataType *arg_params = glmsg.add_args();
-    arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT64);
-    arg_params->add_int64value((uintptr_t)params);
+    // copy argument param
+    GLMessage_DataType *arg_param = glmsg.add_args();
+    arg_param->set_isarray(false);
+    arg_param->set_type(GLMessage::DataType::INT64);
+    arg_param->add_int64value((uintptr_t)param);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glMaterialxvOES(face, pname, params);
+    glContext->hooks->gl.glMaterialxvOES(face, pname, param);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) params,
+        (void *) param,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -20397,7 +28721,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glMultMatrixxOES(const GLfixed *m) {
+void GLTrace_glMultMatrixxOES(const GLfixed * m) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -20426,17 +28750,17 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glMultiTexCoord4xOES(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) {
+void GLTrace_glMultiTexCoord4xOES(GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glMultiTexCoord4xOES);
 
-    // copy argument target
-    GLMessage_DataType *arg_target = glmsg.add_args();
-    arg_target->set_isarray(false);
-    arg_target->set_type(GLMessage::DataType::ENUM);
-    arg_target->add_intvalue((int)target);
+    // copy argument texture
+    GLMessage_DataType *arg_texture = glmsg.add_args();
+    arg_texture->set_isarray(false);
+    arg_texture->set_type(GLMessage::DataType::ENUM);
+    arg_texture->add_intvalue((int)texture);
 
     // copy argument s
     GLMessage_DataType *arg_s = glmsg.add_args();
@@ -20465,7 +28789,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glMultiTexCoord4xOES(target, s, t, r, q);
+    glContext->hooks->gl.glMultiTexCoord4xOES(texture, s, t, r, q);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -20518,52 +28842,52 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glOrthoxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) {
+void GLTrace_glOrthoxOES(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
     glmsg.set_function(GLMessage::glOrthoxOES);
 
-    // copy argument left
-    GLMessage_DataType *arg_left = glmsg.add_args();
-    arg_left->set_isarray(false);
-    arg_left->set_type(GLMessage::DataType::INT);
-    arg_left->add_intvalue(left);
+    // copy argument l
+    GLMessage_DataType *arg_l = glmsg.add_args();
+    arg_l->set_isarray(false);
+    arg_l->set_type(GLMessage::DataType::INT);
+    arg_l->add_intvalue(l);
 
-    // copy argument right
-    GLMessage_DataType *arg_right = glmsg.add_args();
-    arg_right->set_isarray(false);
-    arg_right->set_type(GLMessage::DataType::INT);
-    arg_right->add_intvalue(right);
+    // copy argument r
+    GLMessage_DataType *arg_r = glmsg.add_args();
+    arg_r->set_isarray(false);
+    arg_r->set_type(GLMessage::DataType::INT);
+    arg_r->add_intvalue(r);
 
-    // copy argument bottom
-    GLMessage_DataType *arg_bottom = glmsg.add_args();
-    arg_bottom->set_isarray(false);
-    arg_bottom->set_type(GLMessage::DataType::INT);
-    arg_bottom->add_intvalue(bottom);
+    // copy argument b
+    GLMessage_DataType *arg_b = glmsg.add_args();
+    arg_b->set_isarray(false);
+    arg_b->set_type(GLMessage::DataType::INT);
+    arg_b->add_intvalue(b);
 
-    // copy argument top
-    GLMessage_DataType *arg_top = glmsg.add_args();
-    arg_top->set_isarray(false);
-    arg_top->set_type(GLMessage::DataType::INT);
-    arg_top->add_intvalue(top);
+    // copy argument t
+    GLMessage_DataType *arg_t = glmsg.add_args();
+    arg_t->set_isarray(false);
+    arg_t->set_type(GLMessage::DataType::INT);
+    arg_t->add_intvalue(t);
 
-    // copy argument zNear
-    GLMessage_DataType *arg_zNear = glmsg.add_args();
-    arg_zNear->set_isarray(false);
-    arg_zNear->set_type(GLMessage::DataType::INT);
-    arg_zNear->add_intvalue(zNear);
+    // copy argument n
+    GLMessage_DataType *arg_n = glmsg.add_args();
+    arg_n->set_isarray(false);
+    arg_n->set_type(GLMessage::DataType::INT);
+    arg_n->add_intvalue(n);
 
-    // copy argument zFar
-    GLMessage_DataType *arg_zFar = glmsg.add_args();
-    arg_zFar->set_isarray(false);
-    arg_zFar->set_type(GLMessage::DataType::INT);
-    arg_zFar->add_intvalue(zFar);
+    // copy argument f
+    GLMessage_DataType *arg_f = glmsg.add_args();
+    arg_f->set_isarray(false);
+    arg_f->set_type(GLMessage::DataType::INT);
+    arg_f->add_intvalue(f);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glOrthoxOES(left, right, bottom, top, zNear, zFar);
+    glContext->hooks->gl.glOrthoxOES(l, r, b, t, n, f);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -20576,41 +28900,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glPointParameterxOES(GLenum pname, GLfixed param) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glPointParameterxOES);
-
-    // copy argument pname
-    GLMessage_DataType *arg_pname = glmsg.add_args();
-    arg_pname->set_isarray(false);
-    arg_pname->set_type(GLMessage::DataType::ENUM);
-    arg_pname->add_intvalue((int)pname);
-
-    // copy argument param
-    GLMessage_DataType *arg_param = glmsg.add_args();
-    arg_param->set_isarray(false);
-    arg_param->set_type(GLMessage::DataType::INT);
-    arg_param->add_intvalue(param);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glPointParameterxOES(pname, param);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glPointParameterxvOES(GLenum pname, const GLfixed *params) {
+void GLTrace_glPointParameterxvOES(GLenum pname, const GLfixed * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -20753,11 +29043,11 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glSampleCoveragexOES(GLclampx value, GLboolean invert) {
+void GLTrace_glSampleCoverageOES(GLfixed value, GLboolean invert) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
-    glmsg.set_function(GLMessage::glSampleCoveragexOES);
+    glmsg.set_function(GLMessage::glSampleCoverageOES);
 
     // copy argument value
     GLMessage_DataType *arg_value = glmsg.add_args();
@@ -20774,7 +29064,7 @@
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glSampleCoveragexOES(value, invert);
+    glContext->hooks->gl.glSampleCoverageOES(value, invert);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -20867,7 +29157,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexEnvxvOES(GLenum target, GLenum pname, const GLfixed *params) {
+void GLTrace_glTexEnvxvOES(GLenum target, GLenum pname, const GLfixed * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -20948,7 +29238,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexParameterxvOES(GLenum target, GLenum pname, const GLfixed *params) {
+void GLTrace_glTexParameterxvOES(GLenum target, GLenum pname, const GLfixed * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -21029,6 +29319,278 @@
     glContext->traceGLMessage(&glmsg);
 }
 
+void GLTrace_glGetLightxvOES(GLenum light, GLenum pname, GLfixed * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetLightxvOES);
+
+    // copy argument light
+    GLMessage_DataType *arg_light = glmsg.add_args();
+    arg_light->set_isarray(false);
+    arg_light->set_type(GLMessage::DataType::ENUM);
+    arg_light->add_intvalue((int)light);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetLightxvOES(light, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetMaterialxvOES(GLenum face, GLenum pname, GLfixed * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetMaterialxvOES);
+
+    // copy argument face
+    GLMessage_DataType *arg_face = glmsg.add_args();
+    arg_face->set_isarray(false);
+    arg_face->set_type(GLMessage::DataType::ENUM);
+    arg_face->add_intvalue((int)face);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetMaterialxvOES(face, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glPointParameterxOES(GLenum pname, GLfixed param) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glPointParameterxOES);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument param
+    GLMessage_DataType *arg_param = glmsg.add_args();
+    arg_param->set_isarray(false);
+    arg_param->set_type(GLMessage::DataType::INT);
+    arg_param->add_intvalue(param);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glPointParameterxOES(pname, param);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glSampleCoveragexOES(GLclampx value, GLboolean invert) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glSampleCoveragexOES);
+
+    // copy argument value
+    GLMessage_DataType *arg_value = glmsg.add_args();
+    arg_value->set_isarray(false);
+    arg_value->set_type(GLMessage::DataType::INT);
+    arg_value->add_intvalue(value);
+
+    // copy argument invert
+    GLMessage_DataType *arg_invert = glmsg.add_args();
+    arg_invert->set_isarray(false);
+    arg_invert->set_type(GLMessage::DataType::BOOL);
+    arg_invert->add_boolvalue(invert);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glSampleCoveragexOES(value, invert);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetTexGenxvOES(GLenum coord, GLenum pname, GLfixed * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetTexGenxvOES);
+
+    // copy argument coord
+    GLMessage_DataType *arg_coord = glmsg.add_args();
+    arg_coord->set_isarray(false);
+    arg_coord->set_type(GLMessage::DataType::ENUM);
+    arg_coord->add_intvalue((int)coord);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetTexGenxvOES(coord, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glTexGenxOES(GLenum coord, GLenum pname, GLfixed param) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTexGenxOES);
+
+    // copy argument coord
+    GLMessage_DataType *arg_coord = glmsg.add_args();
+    arg_coord->set_isarray(false);
+    arg_coord->set_type(GLMessage::DataType::ENUM);
+    arg_coord->add_intvalue((int)coord);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument param
+    GLMessage_DataType *arg_param = glmsg.add_args();
+    arg_param->set_isarray(false);
+    arg_param->set_type(GLMessage::DataType::INT);
+    arg_param->add_intvalue(param);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTexGenxOES(coord, pname, param);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glTexGenxvOES(GLenum coord, GLenum pname, const GLfixed * params) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glTexGenxvOES);
+
+    // copy argument coord
+    GLMessage_DataType *arg_coord = glmsg.add_args();
+    arg_coord->set_isarray(false);
+    arg_coord->set_type(GLMessage::DataType::ENUM);
+    arg_coord->add_intvalue((int)coord);
+
+    // copy argument pname
+    GLMessage_DataType *arg_pname = glmsg.add_args();
+    arg_pname->set_isarray(false);
+    arg_pname->set_type(GLMessage::DataType::ENUM);
+    arg_pname->add_intvalue((int)pname);
+
+    // copy argument params
+    GLMessage_DataType *arg_params = glmsg.add_args();
+    arg_params->set_isarray(false);
+    arg_params->set_type(GLMessage::DataType::INT64);
+    arg_params->add_int64value((uintptr_t)params);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glTexGenxvOES(coord, pname, params);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) params,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
 GLboolean GLTrace_glIsRenderbufferOES(GLuint renderbuffer) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
@@ -21099,7 +29661,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDeleteRenderbuffersOES(GLsizei n, const GLuint* renderbuffers) {
+void GLTrace_glDeleteRenderbuffersOES(GLsizei n, const GLuint * renderbuffers) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -21134,7 +29696,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGenRenderbuffersOES(GLsizei n, GLuint* renderbuffers) {
+void GLTrace_glGenRenderbuffersOES(GLsizei n, GLuint * renderbuffers) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -21215,7 +29777,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint* params) {
+void GLTrace_glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -21326,7 +29888,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glDeleteFramebuffersOES(GLsizei n, const GLuint* framebuffers) {
+void GLTrace_glDeleteFramebuffersOES(GLsizei n, const GLuint * framebuffers) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -21361,7 +29923,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGenFramebuffersOES(GLsizei n, GLuint* framebuffers) {
+void GLTrace_glGenFramebuffersOES(GLsizei n, GLuint * framebuffers) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -21530,7 +30092,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint* params) {
+void GLTrace_glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -21655,7 +30217,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
+void GLTrace_glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, const void * pointer) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -21702,7 +30264,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glWeightPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
+void GLTrace_glWeightPointerOES(GLint size, GLenum type, GLsizei stride, const void * pointer) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -21749,7 +30311,48 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-GLbitfield GLTrace_glQueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]) {
+void GLTrace_glPointSizePointerOES(GLenum type, GLsizei stride, const void * pointer) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glPointSizePointerOES);
+
+    // copy argument type
+    GLMessage_DataType *arg_type = glmsg.add_args();
+    arg_type->set_isarray(false);
+    arg_type->set_type(GLMessage::DataType::ENUM);
+    arg_type->add_intvalue((int)type);
+
+    // copy argument stride
+    GLMessage_DataType *arg_stride = glmsg.add_args();
+    arg_stride->set_isarray(false);
+    arg_stride->set_type(GLMessage::DataType::INT);
+    arg_stride->add_intvalue(stride);
+
+    // copy argument pointer
+    GLMessage_DataType *arg_pointer = glmsg.add_args();
+    arg_pointer->set_isarray(false);
+    arg_pointer->set_type(GLMessage::DataType::INT64);
+    arg_pointer->add_int64value((uintptr_t)pointer);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glPointSizePointerOES(type, stride, pointer);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) pointer,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+GLbitfield GLTrace_glQueryMatrixxOES(GLfixed * mantissa, GLint * exponent) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -21793,28 +30396,22 @@
     return retValue;
 }
 
-void GLTrace_glDepthRangefOES(GLclampf zNear, GLclampf zFar) {
+void GLTrace_glClearDepthfOES(GLclampf depth) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
-    glmsg.set_function(GLMessage::glDepthRangefOES);
+    glmsg.set_function(GLMessage::glClearDepthfOES);
 
-    // copy argument zNear
-    GLMessage_DataType *arg_zNear = glmsg.add_args();
-    arg_zNear->set_isarray(false);
-    arg_zNear->set_type(GLMessage::DataType::FLOAT);
-    arg_zNear->add_floatvalue(zNear);
-
-    // copy argument zFar
-    GLMessage_DataType *arg_zFar = glmsg.add_args();
-    arg_zFar->set_isarray(false);
-    arg_zFar->set_type(GLMessage::DataType::FLOAT);
-    arg_zFar->add_floatvalue(zFar);
+    // copy argument depth
+    GLMessage_DataType *arg_depth = glmsg.add_args();
+    arg_depth->set_isarray(false);
+    arg_depth->set_type(GLMessage::DataType::FLOAT);
+    arg_depth->add_floatvalue(depth);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glDepthRangefOES(zNear, zFar);
+    glContext->hooks->gl.glClearDepthfOES(depth);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -21827,123 +30424,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glFrustumfOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glFrustumfOES);
-
-    // copy argument left
-    GLMessage_DataType *arg_left = glmsg.add_args();
-    arg_left->set_isarray(false);
-    arg_left->set_type(GLMessage::DataType::FLOAT);
-    arg_left->add_floatvalue(left);
-
-    // copy argument right
-    GLMessage_DataType *arg_right = glmsg.add_args();
-    arg_right->set_isarray(false);
-    arg_right->set_type(GLMessage::DataType::FLOAT);
-    arg_right->add_floatvalue(right);
-
-    // copy argument bottom
-    GLMessage_DataType *arg_bottom = glmsg.add_args();
-    arg_bottom->set_isarray(false);
-    arg_bottom->set_type(GLMessage::DataType::FLOAT);
-    arg_bottom->add_floatvalue(bottom);
-
-    // copy argument top
-    GLMessage_DataType *arg_top = glmsg.add_args();
-    arg_top->set_isarray(false);
-    arg_top->set_type(GLMessage::DataType::FLOAT);
-    arg_top->add_floatvalue(top);
-
-    // copy argument zNear
-    GLMessage_DataType *arg_zNear = glmsg.add_args();
-    arg_zNear->set_isarray(false);
-    arg_zNear->set_type(GLMessage::DataType::FLOAT);
-    arg_zNear->add_floatvalue(zNear);
-
-    // copy argument zFar
-    GLMessage_DataType *arg_zFar = glmsg.add_args();
-    arg_zFar->set_isarray(false);
-    arg_zFar->set_type(GLMessage::DataType::FLOAT);
-    arg_zFar->add_floatvalue(zFar);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glFrustumfOES(left, right, bottom, top, zNear, zFar);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glOrthofOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glOrthofOES);
-
-    // copy argument left
-    GLMessage_DataType *arg_left = glmsg.add_args();
-    arg_left->set_isarray(false);
-    arg_left->set_type(GLMessage::DataType::FLOAT);
-    arg_left->add_floatvalue(left);
-
-    // copy argument right
-    GLMessage_DataType *arg_right = glmsg.add_args();
-    arg_right->set_isarray(false);
-    arg_right->set_type(GLMessage::DataType::FLOAT);
-    arg_right->add_floatvalue(right);
-
-    // copy argument bottom
-    GLMessage_DataType *arg_bottom = glmsg.add_args();
-    arg_bottom->set_isarray(false);
-    arg_bottom->set_type(GLMessage::DataType::FLOAT);
-    arg_bottom->add_floatvalue(bottom);
-
-    // copy argument top
-    GLMessage_DataType *arg_top = glmsg.add_args();
-    arg_top->set_isarray(false);
-    arg_top->set_type(GLMessage::DataType::FLOAT);
-    arg_top->add_floatvalue(top);
-
-    // copy argument zNear
-    GLMessage_DataType *arg_zNear = glmsg.add_args();
-    arg_zNear->set_isarray(false);
-    arg_zNear->set_type(GLMessage::DataType::FLOAT);
-    arg_zNear->add_floatvalue(zNear);
-
-    // copy argument zFar
-    GLMessage_DataType *arg_zFar = glmsg.add_args();
-    arg_zFar->set_isarray(false);
-    arg_zFar->set_type(GLMessage::DataType::FLOAT);
-    arg_zFar->add_floatvalue(zFar);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glOrthofOES(left, right, bottom, top, zNear, zFar);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glClipPlanefOES(GLenum plane, const GLfloat *equation) {
+void GLTrace_glClipPlanefOES(GLenum plane, const GLfloat * equation) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -21978,33 +30459,32 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetClipPlanefOES(GLenum pname, GLfloat eqn[4]) {
+void GLTrace_glDepthRangefOES(GLclampf n, GLclampf f) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
-    glmsg.set_function(GLMessage::glGetClipPlanefOES);
+    glmsg.set_function(GLMessage::glDepthRangefOES);
 
-    // copy argument pname
-    GLMessage_DataType *arg_pname = glmsg.add_args();
-    arg_pname->set_isarray(false);
-    arg_pname->set_type(GLMessage::DataType::ENUM);
-    arg_pname->add_intvalue((int)pname);
+    // copy argument n
+    GLMessage_DataType *arg_n = glmsg.add_args();
+    arg_n->set_isarray(false);
+    arg_n->set_type(GLMessage::DataType::FLOAT);
+    arg_n->add_floatvalue(n);
 
-    // copy argument eqn
-    GLMessage_DataType *arg_eqn = glmsg.add_args();
-    arg_eqn->set_isarray(false);
-    arg_eqn->set_type(GLMessage::DataType::INT64);
-    arg_eqn->add_int64value((uintptr_t)eqn);
+    // copy argument f
+    GLMessage_DataType *arg_f = glmsg.add_args();
+    arg_f->set_isarray(false);
+    arg_f->set_type(GLMessage::DataType::FLOAT);
+    arg_f->add_floatvalue(f);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetClipPlanefOES(pname, eqn);
+    glContext->hooks->gl.glDepthRangefOES(n, f);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
     void *pointerArgs[] = {
-        (void *) eqn,
     };
 
     fixupGLMessage(glContext, wallStartTime, wallEndTime,
@@ -22013,22 +30493,145 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glClearDepthfOES(GLclampf depth) {
+void GLTrace_glFrustumfOES(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
-    glmsg.set_function(GLMessage::glClearDepthfOES);
+    glmsg.set_function(GLMessage::glFrustumfOES);
 
-    // copy argument depth
-    GLMessage_DataType *arg_depth = glmsg.add_args();
-    arg_depth->set_isarray(false);
-    arg_depth->set_type(GLMessage::DataType::FLOAT);
-    arg_depth->add_floatvalue(depth);
+    // copy argument l
+    GLMessage_DataType *arg_l = glmsg.add_args();
+    arg_l->set_isarray(false);
+    arg_l->set_type(GLMessage::DataType::FLOAT);
+    arg_l->add_floatvalue(l);
+
+    // copy argument r
+    GLMessage_DataType *arg_r = glmsg.add_args();
+    arg_r->set_isarray(false);
+    arg_r->set_type(GLMessage::DataType::FLOAT);
+    arg_r->add_floatvalue(r);
+
+    // copy argument b
+    GLMessage_DataType *arg_b = glmsg.add_args();
+    arg_b->set_isarray(false);
+    arg_b->set_type(GLMessage::DataType::FLOAT);
+    arg_b->add_floatvalue(b);
+
+    // copy argument t
+    GLMessage_DataType *arg_t = glmsg.add_args();
+    arg_t->set_isarray(false);
+    arg_t->set_type(GLMessage::DataType::FLOAT);
+    arg_t->add_floatvalue(t);
+
+    // copy argument n
+    GLMessage_DataType *arg_n = glmsg.add_args();
+    arg_n->set_isarray(false);
+    arg_n->set_type(GLMessage::DataType::FLOAT);
+    arg_n->add_floatvalue(n);
+
+    // copy argument f
+    GLMessage_DataType *arg_f = glmsg.add_args();
+    arg_f->set_isarray(false);
+    arg_f->set_type(GLMessage::DataType::FLOAT);
+    arg_f->add_floatvalue(f);
 
     // call function
     nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
     nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glClearDepthfOES(depth);
+    glContext->hooks->gl.glFrustumfOES(l, r, b, t, n, f);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glGetClipPlanefOES(GLenum plane, GLfloat * equation) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glGetClipPlanefOES);
+
+    // copy argument plane
+    GLMessage_DataType *arg_plane = glmsg.add_args();
+    arg_plane->set_isarray(false);
+    arg_plane->set_type(GLMessage::DataType::ENUM);
+    arg_plane->add_intvalue((int)plane);
+
+    // copy argument equation
+    GLMessage_DataType *arg_equation = glmsg.add_args();
+    arg_equation->set_isarray(false);
+    arg_equation->set_type(GLMessage::DataType::INT64);
+    arg_equation->add_int64value((uintptr_t)equation);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glGetClipPlanefOES(plane, equation);
+    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
+    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
+
+    void *pointerArgs[] = {
+        (void *) equation,
+    };
+
+    fixupGLMessage(glContext, wallStartTime, wallEndTime,
+                              threadStartTime, threadEndTime,
+                              &glmsg, pointerArgs);
+    glContext->traceGLMessage(&glmsg);
+}
+
+void GLTrace_glOrthofOES(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f) {
+    GLMessage glmsg;
+    GLTraceContext *glContext = getGLTraceContext();
+
+    glmsg.set_function(GLMessage::glOrthofOES);
+
+    // copy argument l
+    GLMessage_DataType *arg_l = glmsg.add_args();
+    arg_l->set_isarray(false);
+    arg_l->set_type(GLMessage::DataType::FLOAT);
+    arg_l->add_floatvalue(l);
+
+    // copy argument r
+    GLMessage_DataType *arg_r = glmsg.add_args();
+    arg_r->set_isarray(false);
+    arg_r->set_type(GLMessage::DataType::FLOAT);
+    arg_r->add_floatvalue(r);
+
+    // copy argument b
+    GLMessage_DataType *arg_b = glmsg.add_args();
+    arg_b->set_isarray(false);
+    arg_b->set_type(GLMessage::DataType::FLOAT);
+    arg_b->add_floatvalue(b);
+
+    // copy argument t
+    GLMessage_DataType *arg_t = glmsg.add_args();
+    arg_t->set_isarray(false);
+    arg_t->set_type(GLMessage::DataType::FLOAT);
+    arg_t->add_floatvalue(t);
+
+    // copy argument n
+    GLMessage_DataType *arg_n = glmsg.add_args();
+    arg_n->set_isarray(false);
+    arg_n->set_type(GLMessage::DataType::FLOAT);
+    arg_n->add_floatvalue(n);
+
+    // copy argument f
+    GLMessage_DataType *arg_f = glmsg.add_args();
+    arg_f->set_isarray(false);
+    arg_f->set_type(GLMessage::DataType::FLOAT);
+    arg_f->add_floatvalue(f);
+
+    // call function
+    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
+    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
+    glContext->hooks->gl.glOrthofOES(l, r, b, t, n, f);
     nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
     nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
 
@@ -22081,7 +30684,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexGenfvOES(GLenum coord, GLenum pname, const GLfloat *params) {
+void GLTrace_glTexGenfvOES(GLenum coord, GLenum pname, const GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -22162,7 +30765,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexGenivOES(GLenum coord, GLenum pname, const GLint *params) {
+void GLTrace_glTexGenivOES(GLenum coord, GLenum pname, const GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -22203,88 +30806,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glTexGenxOES(GLenum coord, GLenum pname, GLfixed param) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glTexGenxOES);
-
-    // copy argument coord
-    GLMessage_DataType *arg_coord = glmsg.add_args();
-    arg_coord->set_isarray(false);
-    arg_coord->set_type(GLMessage::DataType::ENUM);
-    arg_coord->add_intvalue((int)coord);
-
-    // copy argument pname
-    GLMessage_DataType *arg_pname = glmsg.add_args();
-    arg_pname->set_isarray(false);
-    arg_pname->set_type(GLMessage::DataType::ENUM);
-    arg_pname->add_intvalue((int)pname);
-
-    // copy argument param
-    GLMessage_DataType *arg_param = glmsg.add_args();
-    arg_param->set_isarray(false);
-    arg_param->set_type(GLMessage::DataType::INT);
-    arg_param->add_intvalue(param);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glTexGenxOES(coord, pname, param);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glTexGenxvOES(GLenum coord, GLenum pname, const GLfixed *params) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glTexGenxvOES);
-
-    // copy argument coord
-    GLMessage_DataType *arg_coord = glmsg.add_args();
-    arg_coord->set_isarray(false);
-    arg_coord->set_type(GLMessage::DataType::ENUM);
-    arg_coord->add_intvalue((int)coord);
-
-    // copy argument pname
-    GLMessage_DataType *arg_pname = glmsg.add_args();
-    arg_pname->set_isarray(false);
-    arg_pname->set_type(GLMessage::DataType::ENUM);
-    arg_pname->add_intvalue((int)pname);
-
-    // copy argument params
-    GLMessage_DataType *arg_params = glmsg.add_args();
-    arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT64);
-    arg_params->add_int64value((uintptr_t)params);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glTexGenxvOES(coord, pname, params);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-        (void *) params,
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glGetTexGenfvOES(GLenum coord, GLenum pname, GLfloat *params) {
+void GLTrace_glGetTexGenfvOES(GLenum coord, GLenum pname, GLfloat * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -22325,7 +30847,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetTexGenivOES(GLenum coord, GLenum pname, GLint *params) {
+void GLTrace_glGetTexGenivOES(GLenum coord, GLenum pname, GLint * params) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -22366,48 +30888,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glGetTexGenxvOES(GLenum coord, GLenum pname, GLfixed *params) {
-    GLMessage glmsg;
-    GLTraceContext *glContext = getGLTraceContext();
-
-    glmsg.set_function(GLMessage::glGetTexGenxvOES);
-
-    // copy argument coord
-    GLMessage_DataType *arg_coord = glmsg.add_args();
-    arg_coord->set_isarray(false);
-    arg_coord->set_type(GLMessage::DataType::ENUM);
-    arg_coord->add_intvalue((int)coord);
-
-    // copy argument pname
-    GLMessage_DataType *arg_pname = glmsg.add_args();
-    arg_pname->set_isarray(false);
-    arg_pname->set_type(GLMessage::DataType::ENUM);
-    arg_pname->add_intvalue((int)pname);
-
-    // copy argument params
-    GLMessage_DataType *arg_params = glmsg.add_args();
-    arg_params->set_isarray(false);
-    arg_params->set_type(GLMessage::DataType::INT64);
-    arg_params->add_int64value((uintptr_t)params);
-
-    // call function
-    nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
-    nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD);
-    glContext->hooks->gl.glGetTexGenxvOES(coord, pname, params);
-    nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD);
-    nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
-    void *pointerArgs[] = {
-        (void *) params,
-    };
-
-    fixupGLMessage(glContext, wallStartTime, wallEndTime,
-                              threadStartTime, threadEndTime,
-                              &glmsg, pointerArgs);
-    glContext->traceGLMessage(&glmsg);
-}
-
-void GLTrace_glClipPlanefIMG(GLenum p, const GLfloat *eqn) {
+void GLTrace_glClipPlanefIMG(GLenum p, const GLfloat * eqn) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
@@ -22442,7 +30923,7 @@
     glContext->traceGLMessage(&glmsg);
 }
 
-void GLTrace_glClipPlanexIMG(GLenum p, const GLfixed *eqn) {
+void GLTrace_glClipPlanexIMG(GLenum p, const GLfixed * eqn) {
     GLMessage glmsg;
     GLTraceContext *glContext = getGLTraceContext();
 
diff --git a/opengl/libs/GLES_trace/src/gltrace_api.h b/opengl/libs/GLES_trace/src/gltrace_api.h
index 3a839dd..a9ca3c4 100644
--- a/opengl/libs/GLES_trace/src/gltrace_api.h
+++ b/opengl/libs/GLES_trace/src/gltrace_api.h
@@ -19,11 +19,11 @@
 namespace android {
 namespace gltrace {
 
-// Declarations for GL3 APIs
+// Declarations for GL2 APIs
 
 void GLTrace_glActiveTexture(GLenum texture);
 void GLTrace_glAttachShader(GLuint program, GLuint shader);
-void GLTrace_glBindAttribLocation(GLuint program, GLuint index, const GLchar* name);
+void GLTrace_glBindAttribLocation(GLuint program, GLuint index, const GLchar * name);
 void GLTrace_glBindBuffer(GLenum target, GLuint buffer);
 void GLTrace_glBindFramebuffer(GLenum target, GLuint framebuffer);
 void GLTrace_glBindRenderbuffer(GLenum target, GLuint renderbuffer);
@@ -32,29 +32,29 @@
 void GLTrace_glBlendEquation(GLenum mode);
 void GLTrace_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
 void GLTrace_glBlendFunc(GLenum sfactor, GLenum dfactor);
-void GLTrace_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
-void GLTrace_glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
-void GLTrace_glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
+void GLTrace_glBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+void GLTrace_glBufferData(GLenum target, GLsizeiptr size, const void * data, GLenum usage);
+void GLTrace_glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void * data);
 GLenum GLTrace_glCheckFramebufferStatus(GLenum target);
 void GLTrace_glClear(GLbitfield mask);
 void GLTrace_glClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
-void GLTrace_glClearDepthf(GLfloat depth);
+void GLTrace_glClearDepthf(GLfloat d);
 void GLTrace_glClearStencil(GLint s);
 void GLTrace_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
 void GLTrace_glCompileShader(GLuint shader);
-void GLTrace_glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
-void GLTrace_glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);
+void GLTrace_glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data);
+void GLTrace_glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data);
 void GLTrace_glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
 void GLTrace_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
 GLuint GLTrace_glCreateProgram(void);
 GLuint GLTrace_glCreateShader(GLenum type);
 void GLTrace_glCullFace(GLenum mode);
-void GLTrace_glDeleteBuffers(GLsizei n, const GLuint* buffers);
-void GLTrace_glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers);
+void GLTrace_glDeleteBuffers(GLsizei n, const GLuint * buffers);
+void GLTrace_glDeleteFramebuffers(GLsizei n, const GLuint * framebuffers);
 void GLTrace_glDeleteProgram(GLuint program);
-void GLTrace_glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers);
+void GLTrace_glDeleteRenderbuffers(GLsizei n, const GLuint * renderbuffers);
 void GLTrace_glDeleteShader(GLuint shader);
-void GLTrace_glDeleteTextures(GLsizei n, const GLuint* textures);
+void GLTrace_glDeleteTextures(GLsizei n, const GLuint * textures);
 void GLTrace_glDepthFunc(GLenum func);
 void GLTrace_glDepthMask(GLboolean flag);
 void GLTrace_glDepthRangef(GLfloat n, GLfloat f);
@@ -62,7 +62,7 @@
 void GLTrace_glDisable(GLenum cap);
 void GLTrace_glDisableVertexAttribArray(GLuint index);
 void GLTrace_glDrawArrays(GLenum mode, GLint first, GLsizei count);
-void GLTrace_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
+void GLTrace_glDrawElements(GLenum mode, GLsizei count, GLenum type, const void * indices);
 void GLTrace_glEnable(GLenum cap);
 void GLTrace_glEnableVertexAttribArray(GLuint index);
 void GLTrace_glFinish(void);
@@ -70,37 +70,37 @@
 void GLTrace_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
 void GLTrace_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
 void GLTrace_glFrontFace(GLenum mode);
-void GLTrace_glGenBuffers(GLsizei n, GLuint* buffers);
+void GLTrace_glGenBuffers(GLsizei n, GLuint * buffers);
 void GLTrace_glGenerateMipmap(GLenum target);
-void GLTrace_glGenFramebuffers(GLsizei n, GLuint* framebuffers);
-void GLTrace_glGenRenderbuffers(GLsizei n, GLuint* renderbuffers);
-void GLTrace_glGenTextures(GLsizei n, GLuint* textures);
-void GLTrace_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
-void GLTrace_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
-void GLTrace_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
-GLint GLTrace_glGetAttribLocation(GLuint program, const GLchar* name);
-void GLTrace_glGetBooleanv(GLenum pname, GLboolean* params);
-void GLTrace_glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params);
+void GLTrace_glGenFramebuffers(GLsizei n, GLuint * framebuffers);
+void GLTrace_glGenRenderbuffers(GLsizei n, GLuint * renderbuffers);
+void GLTrace_glGenTextures(GLsizei n, GLuint * textures);
+void GLTrace_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
+void GLTrace_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
+void GLTrace_glGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders);
+GLint GLTrace_glGetAttribLocation(GLuint program, const GLchar * name);
+void GLTrace_glGetBooleanv(GLenum pname, GLboolean * data);
+void GLTrace_glGetBufferParameteriv(GLenum target, GLenum pname, GLint * params);
 GLenum GLTrace_glGetError(void);
-void GLTrace_glGetFloatv(GLenum pname, GLfloat* params);
-void GLTrace_glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params);
-void GLTrace_glGetIntegerv(GLenum pname, GLint* params);
-void GLTrace_glGetProgramiv(GLuint program, GLenum pname, GLint* params);
-void GLTrace_glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
-void GLTrace_glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params);
-void GLTrace_glGetShaderiv(GLuint shader, GLenum pname, GLint* params);
-void GLTrace_glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
-void GLTrace_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
-void GLTrace_glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
-const GLubyte* GLTrace_glGetString(GLenum name);
-void GLTrace_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params);
-void GLTrace_glGetTexParameteriv(GLenum target, GLenum pname, GLint* params);
-void GLTrace_glGetUniformfv(GLuint program, GLint location, GLfloat* params);
-void GLTrace_glGetUniformiv(GLuint program, GLint location, GLint* params);
-GLint GLTrace_glGetUniformLocation(GLuint program, const GLchar* name);
-void GLTrace_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params);
-void GLTrace_glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params);
-void GLTrace_glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer);
+void GLTrace_glGetFloatv(GLenum pname, GLfloat * data);
+void GLTrace_glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint * params);
+void GLTrace_glGetIntegerv(GLenum pname, GLint * data);
+void GLTrace_glGetProgramiv(GLuint program, GLenum pname, GLint * params);
+void GLTrace_glGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
+void GLTrace_glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint * params);
+void GLTrace_glGetShaderiv(GLuint shader, GLenum pname, GLint * params);
+void GLTrace_glGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
+void GLTrace_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint * range, GLint * precision);
+void GLTrace_glGetShaderSource(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source);
+const GLubyte * GLTrace_glGetString(GLenum name);
+void GLTrace_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat * params);
+void GLTrace_glGetTexParameteriv(GLenum target, GLenum pname, GLint * params);
+void GLTrace_glGetUniformfv(GLuint program, GLint location, GLfloat * params);
+void GLTrace_glGetUniformiv(GLuint program, GLint location, GLint * params);
+GLint GLTrace_glGetUniformLocation(GLuint program, const GLchar * name);
+void GLTrace_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat * params);
+void GLTrace_glGetVertexAttribiv(GLuint index, GLenum pname, GLint * params);
+void GLTrace_glGetVertexAttribPointerv(GLuint index, GLenum pname, void ** pointer);
 void GLTrace_glHint(GLenum target, GLenum mode);
 GLboolean GLTrace_glIsBuffer(GLuint buffer);
 GLboolean GLTrace_glIsEnabled(GLenum cap);
@@ -113,356 +113,524 @@
 void GLTrace_glLinkProgram(GLuint program);
 void GLTrace_glPixelStorei(GLenum pname, GLint param);
 void GLTrace_glPolygonOffset(GLfloat factor, GLfloat units);
-void GLTrace_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
+void GLTrace_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels);
 void GLTrace_glReleaseShaderCompiler(void);
 void GLTrace_glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
 void GLTrace_glSampleCoverage(GLfloat value, GLboolean invert);
 void GLTrace_glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
-void GLTrace_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
-void GLTrace_glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
+void GLTrace_glShaderBinary(GLsizei count, const GLuint * shaders, GLenum binaryformat, const void * binary, GLsizei length);
+void GLTrace_glShaderSource(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length);
 void GLTrace_glStencilFunc(GLenum func, GLint ref, GLuint mask);
 void GLTrace_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
 void GLTrace_glStencilMask(GLuint mask);
 void GLTrace_glStencilMaskSeparate(GLenum face, GLuint mask);
 void GLTrace_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass);
-void GLTrace_glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
-void GLTrace_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+void GLTrace_glStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+void GLTrace_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels);
 void GLTrace_glTexParameterf(GLenum target, GLenum pname, GLfloat param);
-void GLTrace_glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params);
+void GLTrace_glTexParameterfv(GLenum target, GLenum pname, const GLfloat * params);
 void GLTrace_glTexParameteri(GLenum target, GLenum pname, GLint param);
-void GLTrace_glTexParameteriv(GLenum target, GLenum pname, const GLint* params);
-void GLTrace_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
-void GLTrace_glUniform1f(GLint location, GLfloat x);
-void GLTrace_glUniform1fv(GLint location, GLsizei count, const GLfloat* v);
-void GLTrace_glUniform1i(GLint location, GLint x);
-void GLTrace_glUniform1iv(GLint location, GLsizei count, const GLint* v);
-void GLTrace_glUniform2f(GLint location, GLfloat x, GLfloat y);
-void GLTrace_glUniform2fv(GLint location, GLsizei count, const GLfloat* v);
-void GLTrace_glUniform2i(GLint location, GLint x, GLint y);
-void GLTrace_glUniform2iv(GLint location, GLsizei count, const GLint* v);
-void GLTrace_glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z);
-void GLTrace_glUniform3fv(GLint location, GLsizei count, const GLfloat* v);
-void GLTrace_glUniform3i(GLint location, GLint x, GLint y, GLint z);
-void GLTrace_glUniform3iv(GLint location, GLsizei count, const GLint* v);
-void GLTrace_glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-void GLTrace_glUniform4fv(GLint location, GLsizei count, const GLfloat* v);
-void GLTrace_glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w);
-void GLTrace_glUniform4iv(GLint location, GLsizei count, const GLint* v);
-void GLTrace_glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-void GLTrace_glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-void GLTrace_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+void GLTrace_glTexParameteriv(GLenum target, GLenum pname, const GLint * params);
+void GLTrace_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels);
+void GLTrace_glUniform1f(GLint location, GLfloat v0);
+void GLTrace_glUniform1fv(GLint location, GLsizei count, const GLfloat * value);
+void GLTrace_glUniform1i(GLint location, GLint v0);
+void GLTrace_glUniform1iv(GLint location, GLsizei count, const GLint * value);
+void GLTrace_glUniform2f(GLint location, GLfloat v0, GLfloat v1);
+void GLTrace_glUniform2fv(GLint location, GLsizei count, const GLfloat * value);
+void GLTrace_glUniform2i(GLint location, GLint v0, GLint v1);
+void GLTrace_glUniform2iv(GLint location, GLsizei count, const GLint * value);
+void GLTrace_glUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+void GLTrace_glUniform3fv(GLint location, GLsizei count, const GLfloat * value);
+void GLTrace_glUniform3i(GLint location, GLint v0, GLint v1, GLint v2);
+void GLTrace_glUniform3iv(GLint location, GLsizei count, const GLint * value);
+void GLTrace_glUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+void GLTrace_glUniform4fv(GLint location, GLsizei count, const GLfloat * value);
+void GLTrace_glUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+void GLTrace_glUniform4iv(GLint location, GLsizei count, const GLint * value);
+void GLTrace_glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
 void GLTrace_glUseProgram(GLuint program);
 void GLTrace_glValidateProgram(GLuint program);
-void GLTrace_glVertexAttrib1f(GLuint indx, GLfloat x);
-void GLTrace_glVertexAttrib1fv(GLuint indx, const GLfloat* values);
-void GLTrace_glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
-void GLTrace_glVertexAttrib2fv(GLuint indx, const GLfloat* values);
-void GLTrace_glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
-void GLTrace_glVertexAttrib3fv(GLuint indx, const GLfloat* values);
-void GLTrace_glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-void GLTrace_glVertexAttrib4fv(GLuint indx, const GLfloat* values);
-void GLTrace_glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);
+void GLTrace_glVertexAttrib1f(GLuint index, GLfloat x);
+void GLTrace_glVertexAttrib1fv(GLuint index, const GLfloat * v);
+void GLTrace_glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y);
+void GLTrace_glVertexAttrib2fv(GLuint index, const GLfloat * v);
+void GLTrace_glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z);
+void GLTrace_glVertexAttrib3fv(GLuint index, const GLfloat * v);
+void GLTrace_glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+void GLTrace_glVertexAttrib4fv(GLuint index, const GLfloat * v);
+void GLTrace_glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer);
 void GLTrace_glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
 void GLTrace_glReadBuffer(GLenum mode);
-void GLTrace_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices);
-void GLTrace_glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
-void GLTrace_glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
+void GLTrace_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices);
+void GLTrace_glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels);
+void GLTrace_glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels);
 void GLTrace_glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-void GLTrace_glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
-void GLTrace_glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
-void GLTrace_glGenQueries(GLsizei n, GLuint* ids);
-void GLTrace_glDeleteQueries(GLsizei n, const GLuint* ids);
+void GLTrace_glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data);
+void GLTrace_glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data);
+void GLTrace_glGenQueries(GLsizei n, GLuint * ids);
+void GLTrace_glDeleteQueries(GLsizei n, const GLuint * ids);
 GLboolean GLTrace_glIsQuery(GLuint id);
 void GLTrace_glBeginQuery(GLenum target, GLuint id);
 void GLTrace_glEndQuery(GLenum target);
-void GLTrace_glGetQueryiv(GLenum target, GLenum pname, GLint* params);
-void GLTrace_glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params);
+void GLTrace_glGetQueryiv(GLenum target, GLenum pname, GLint * params);
+void GLTrace_glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint * params);
 GLboolean GLTrace_glUnmapBuffer(GLenum target);
-void GLTrace_glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params);
-void GLTrace_glDrawBuffers(GLsizei n, const GLenum* bufs);
-void GLTrace_glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-void GLTrace_glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-void GLTrace_glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-void GLTrace_glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-void GLTrace_glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-void GLTrace_glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+void GLTrace_glGetBufferPointerv(GLenum target, GLenum pname, void ** params);
+void GLTrace_glDrawBuffers(GLsizei n, const GLenum * bufs);
+void GLTrace_glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
 void GLTrace_glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
 void GLTrace_glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
 void GLTrace_glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
-GLvoid* GLTrace_glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+void * GLTrace_glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
 void GLTrace_glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length);
 void GLTrace_glBindVertexArray(GLuint array);
-void GLTrace_glDeleteVertexArrays(GLsizei n, const GLuint* arrays);
-void GLTrace_glGenVertexArrays(GLsizei n, GLuint* arrays);
+void GLTrace_glDeleteVertexArrays(GLsizei n, const GLuint * arrays);
+void GLTrace_glGenVertexArrays(GLsizei n, GLuint * arrays);
 GLboolean GLTrace_glIsVertexArray(GLuint array);
-void GLTrace_glGetIntegeri_v(GLenum target, GLuint index, GLint* data);
+void GLTrace_glGetIntegeri_v(GLenum target, GLuint index, GLint * data);
 void GLTrace_glBeginTransformFeedback(GLenum primitiveMode);
 void GLTrace_glEndTransformFeedback(void);
 void GLTrace_glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
 void GLTrace_glBindBufferBase(GLenum target, GLuint index, GLuint buffer);
-void GLTrace_glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode);
-void GLTrace_glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name);
-void GLTrace_glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
-void GLTrace_glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params);
-void GLTrace_glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params);
+void GLTrace_glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode);
+void GLTrace_glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name);
+void GLTrace_glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer);
+void GLTrace_glGetVertexAttribIiv(GLuint index, GLenum pname, GLint * params);
+void GLTrace_glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint * params);
 void GLTrace_glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w);
 void GLTrace_glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
-void GLTrace_glVertexAttribI4iv(GLuint index, const GLint* v);
-void GLTrace_glVertexAttribI4uiv(GLuint index, const GLuint* v);
-void GLTrace_glGetUniformuiv(GLuint program, GLint location, GLuint* params);
-GLint GLTrace_glGetFragDataLocation(GLuint program, const GLchar *name);
+void GLTrace_glVertexAttribI4iv(GLuint index, const GLint * v);
+void GLTrace_glVertexAttribI4uiv(GLuint index, const GLuint * v);
+void GLTrace_glGetUniformuiv(GLuint program, GLint location, GLuint * params);
+GLint GLTrace_glGetFragDataLocation(GLuint program, const GLchar * name);
 void GLTrace_glUniform1ui(GLint location, GLuint v0);
 void GLTrace_glUniform2ui(GLint location, GLuint v0, GLuint v1);
 void GLTrace_glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2);
 void GLTrace_glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
-void GLTrace_glUniform1uiv(GLint location, GLsizei count, const GLuint* value);
-void GLTrace_glUniform2uiv(GLint location, GLsizei count, const GLuint* value);
-void GLTrace_glUniform3uiv(GLint location, GLsizei count, const GLuint* value);
-void GLTrace_glUniform4uiv(GLint location, GLsizei count, const GLuint* value);
-void GLTrace_glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value);
-void GLTrace_glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value);
-void GLTrace_glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value);
+void GLTrace_glUniform1uiv(GLint location, GLsizei count, const GLuint * value);
+void GLTrace_glUniform2uiv(GLint location, GLsizei count, const GLuint * value);
+void GLTrace_glUniform3uiv(GLint location, GLsizei count, const GLuint * value);
+void GLTrace_glUniform4uiv(GLint location, GLsizei count, const GLuint * value);
+void GLTrace_glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint * value);
+void GLTrace_glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint * value);
+void GLTrace_glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat * value);
 void GLTrace_glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
-const GLubyte* GLTrace_glGetStringi(GLenum name, GLuint index);
+const GLubyte * GLTrace_glGetStringi(GLenum name, GLuint index);
 void GLTrace_glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
-void GLTrace_glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices);
-void GLTrace_glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params);
-GLuint GLTrace_glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName);
-void GLTrace_glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params);
-void GLTrace_glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName);
+void GLTrace_glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices);
+void GLTrace_glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params);
+GLuint GLTrace_glGetUniformBlockIndex(GLuint program, const GLchar * uniformBlockName);
+void GLTrace_glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params);
+void GLTrace_glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName);
 void GLTrace_glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
-void GLTrace_glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount);
-void GLTrace_glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount);
+void GLTrace_glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
+void GLTrace_glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount);
 GLsync GLTrace_glFenceSync(GLenum condition, GLbitfield flags);
 GLboolean GLTrace_glIsSync(GLsync sync);
 void GLTrace_glDeleteSync(GLsync sync);
 GLenum GLTrace_glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout);
 void GLTrace_glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout);
-void GLTrace_glGetInteger64v(GLenum pname, GLint64* params);
-void GLTrace_glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values);
-void GLTrace_glGetInteger64i_v(GLenum target, GLuint index, GLint64* data);
-void GLTrace_glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params);
-void GLTrace_glGenSamplers(GLsizei count, GLuint* samplers);
-void GLTrace_glDeleteSamplers(GLsizei count, const GLuint* samplers);
+void GLTrace_glGetInteger64v(GLenum pname, GLint64 * data);
+void GLTrace_glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values);
+void GLTrace_glGetInteger64i_v(GLenum target, GLuint index, GLint64 * data);
+void GLTrace_glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64 * params);
+void GLTrace_glGenSamplers(GLsizei count, GLuint * samplers);
+void GLTrace_glDeleteSamplers(GLsizei count, const GLuint * samplers);
 GLboolean GLTrace_glIsSampler(GLuint sampler);
 void GLTrace_glBindSampler(GLuint unit, GLuint sampler);
 void GLTrace_glSamplerParameteri(GLuint sampler, GLenum pname, GLint param);
-void GLTrace_glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param);
+void GLTrace_glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint * param);
 void GLTrace_glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param);
-void GLTrace_glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param);
-void GLTrace_glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params);
-void GLTrace_glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params);
+void GLTrace_glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat * param);
+void GLTrace_glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint * params);
+void GLTrace_glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat * params);
 void GLTrace_glVertexAttribDivisor(GLuint index, GLuint divisor);
 void GLTrace_glBindTransformFeedback(GLenum target, GLuint id);
-void GLTrace_glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids);
-void GLTrace_glGenTransformFeedbacks(GLsizei n, GLuint* ids);
+void GLTrace_glDeleteTransformFeedbacks(GLsizei n, const GLuint * ids);
+void GLTrace_glGenTransformFeedbacks(GLsizei n, GLuint * ids);
 GLboolean GLTrace_glIsTransformFeedback(GLuint id);
 void GLTrace_glPauseTransformFeedback(void);
 void GLTrace_glResumeTransformFeedback(void);
-void GLTrace_glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary);
-void GLTrace_glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length);
+void GLTrace_glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei * length, GLenum * binaryFormat, void * binary);
+void GLTrace_glProgramBinary(GLuint program, GLenum binaryFormat, const void * binary, GLsizei length);
 void GLTrace_glProgramParameteri(GLuint program, GLenum pname, GLint value);
-void GLTrace_glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments);
-void GLTrace_glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height);
+void GLTrace_glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum * attachments);
+void GLTrace_glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum * attachments, GLint x, GLint y, GLsizei width, GLsizei height);
 void GLTrace_glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
 void GLTrace_glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-void GLTrace_glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params);
+void GLTrace_glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint * params);
+void GLTrace_glDispatchCompute(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);
+void GLTrace_glDispatchComputeIndirect(GLintptr indirect);
+void GLTrace_glDrawArraysIndirect(GLenum mode, const void * indirect);
+void GLTrace_glDrawElementsIndirect(GLenum mode, GLenum type, const void * indirect);
+void GLTrace_glFramebufferParameteri(GLenum target, GLenum pname, GLint param);
+void GLTrace_glGetFramebufferParameteriv(GLenum target, GLenum pname, GLint * params);
+void GLTrace_glGetProgramInterfaceiv(GLuint program, GLenum programInterface, GLenum pname, GLint * params);
+GLuint GLTrace_glGetProgramResourceIndex(GLuint program, GLenum programInterface, const GLchar * name);
+void GLTrace_glGetProgramResourceName(GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei * length, GLchar * name);
+void GLTrace_glGetProgramResourceiv(GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum * props, GLsizei bufSize, GLsizei * length, GLint * params);
+GLint GLTrace_glGetProgramResourceLocation(GLuint program, GLenum programInterface, const GLchar * name);
+void GLTrace_glUseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program);
+void GLTrace_glActiveShaderProgram(GLuint pipeline, GLuint program);
+GLuint GLTrace_glCreateShaderProgramv(GLenum type, GLsizei count, const GLchar *const* strings);
+void GLTrace_glBindProgramPipeline(GLuint pipeline);
+void GLTrace_glDeleteProgramPipelines(GLsizei n, const GLuint * pipelines);
+void GLTrace_glGenProgramPipelines(GLsizei n, GLuint * pipelines);
+GLboolean GLTrace_glIsProgramPipeline(GLuint pipeline);
+void GLTrace_glGetProgramPipelineiv(GLuint pipeline, GLenum pname, GLint * params);
+void GLTrace_glProgramUniform1i(GLuint program, GLint location, GLint v0);
+void GLTrace_glProgramUniform2i(GLuint program, GLint location, GLint v0, GLint v1);
+void GLTrace_glProgramUniform3i(GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+void GLTrace_glProgramUniform4i(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+void GLTrace_glProgramUniform1ui(GLuint program, GLint location, GLuint v0);
+void GLTrace_glProgramUniform2ui(GLuint program, GLint location, GLuint v0, GLuint v1);
+void GLTrace_glProgramUniform3ui(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+void GLTrace_glProgramUniform4ui(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+void GLTrace_glProgramUniform1f(GLuint program, GLint location, GLfloat v0);
+void GLTrace_glProgramUniform2f(GLuint program, GLint location, GLfloat v0, GLfloat v1);
+void GLTrace_glProgramUniform3f(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+void GLTrace_glProgramUniform4f(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+void GLTrace_glProgramUniform1iv(GLuint program, GLint location, GLsizei count, const GLint * value);
+void GLTrace_glProgramUniform2iv(GLuint program, GLint location, GLsizei count, const GLint * value);
+void GLTrace_glProgramUniform3iv(GLuint program, GLint location, GLsizei count, const GLint * value);
+void GLTrace_glProgramUniform4iv(GLuint program, GLint location, GLsizei count, const GLint * value);
+void GLTrace_glProgramUniform1uiv(GLuint program, GLint location, GLsizei count, const GLuint * value);
+void GLTrace_glProgramUniform2uiv(GLuint program, GLint location, GLsizei count, const GLuint * value);
+void GLTrace_glProgramUniform3uiv(GLuint program, GLint location, GLsizei count, const GLuint * value);
+void GLTrace_glProgramUniform4uiv(GLuint program, GLint location, GLsizei count, const GLuint * value);
+void GLTrace_glProgramUniform1fv(GLuint program, GLint location, GLsizei count, const GLfloat * value);
+void GLTrace_glProgramUniform2fv(GLuint program, GLint location, GLsizei count, const GLfloat * value);
+void GLTrace_glProgramUniform3fv(GLuint program, GLint location, GLsizei count, const GLfloat * value);
+void GLTrace_glProgramUniform4fv(GLuint program, GLint location, GLsizei count, const GLfloat * value);
+void GLTrace_glProgramUniformMatrix2fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glProgramUniformMatrix3fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glProgramUniformMatrix4fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glProgramUniformMatrix2x3fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glProgramUniformMatrix3x2fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glProgramUniformMatrix2x4fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glProgramUniformMatrix4x2fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glProgramUniformMatrix3x4fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glProgramUniformMatrix4x3fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glValidateProgramPipeline(GLuint pipeline);
+void GLTrace_glGetProgramPipelineInfoLog(GLuint pipeline, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
+void GLTrace_glBindImageTexture(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
+void GLTrace_glGetBooleani_v(GLenum target, GLuint index, GLboolean * data);
+void GLTrace_glMemoryBarrier(GLbitfield barriers);
+void GLTrace_glMemoryBarrierByRegion(GLbitfield barriers);
+void GLTrace_glTexStorage2DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+void GLTrace_glGetMultisamplefv(GLenum pname, GLuint index, GLfloat * val);
+void GLTrace_glSampleMaski(GLuint maskNumber, GLbitfield mask);
+void GLTrace_glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint * params);
+void GLTrace_glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat * params);
+void GLTrace_glBindVertexBuffer(GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
+void GLTrace_glVertexAttribFormat(GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
+void GLTrace_glVertexAttribIFormat(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+void GLTrace_glVertexAttribBinding(GLuint attribindex, GLuint bindingindex);
+void GLTrace_glVertexBindingDivisor(GLuint bindingindex, GLuint divisor);
 
 // Declarations for GL2Ext APIs
 
+void GLTrace_glBlendBarrierKHR(void);
+void GLTrace_glDebugMessageControlKHR(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled);
+void GLTrace_glDebugMessageInsertKHR(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf);
+void GLTrace_glDebugMessageCallbackKHR(GLDEBUGPROCKHR callback, const void * userParam);
+GLuint GLTrace_glGetDebugMessageLogKHR(GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog);
+void GLTrace_glPushDebugGroupKHR(GLenum source, GLuint id, GLsizei length, const GLchar * message);
+void GLTrace_glPopDebugGroupKHR(void);
+void GLTrace_glObjectLabelKHR(GLenum identifier, GLuint name, GLsizei length, const GLchar * label);
+void GLTrace_glGetObjectLabelKHR(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label);
+void GLTrace_glObjectPtrLabelKHR(const void * ptr, GLsizei length, const GLchar * label);
+void GLTrace_glGetObjectPtrLabelKHR(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label);
+void GLTrace_glGetPointervKHR(GLenum pname, void ** params);
 void GLTrace_glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image);
 void GLTrace_glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image);
-void GLTrace_glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
-void GLTrace_glProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
-void* GLTrace_glMapBufferOES(GLenum target, GLenum access);
+void GLTrace_glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei * length, GLenum * binaryFormat, void * binary);
+void GLTrace_glProgramBinaryOES(GLuint program, GLenum binaryFormat, const void * binary, GLint length);
+void * GLTrace_glMapBufferOES(GLenum target, GLenum access);
 GLboolean GLTrace_glUnmapBufferOES(GLenum target);
-void GLTrace_glGetBufferPointervOES(GLenum target, GLenum pname, GLvoid** params);
-void GLTrace_glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
-void GLTrace_glTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
+void GLTrace_glGetBufferPointervOES(GLenum target, GLenum pname, void ** params);
+void GLTrace_glMinSampleShadingOES(GLfloat value);
+void GLTrace_glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels);
+void GLTrace_glTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels);
 void GLTrace_glCopyTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-void GLTrace_glCompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
-void GLTrace_glCompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
+void GLTrace_glCompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data);
+void GLTrace_glCompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data);
 void GLTrace_glFramebufferTexture3DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+void GLTrace_glTexStorage3DMultisampleOES(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
 void GLTrace_glBindVertexArrayOES(GLuint array);
-void GLTrace_glDeleteVertexArraysOES(GLsizei n, const GLuint *arrays);
-void GLTrace_glGenVertexArraysOES(GLsizei n, GLuint *arrays);
+void GLTrace_glDeleteVertexArraysOES(GLsizei n, const GLuint * arrays);
+void GLTrace_glGenVertexArraysOES(GLsizei n, GLuint * arrays);
 GLboolean GLTrace_glIsVertexArrayOES(GLuint array);
-void GLTrace_glGetPerfMonitorGroupsAMD(GLint *numGroups, GLsizei groupsSize, GLuint *groups);
-void GLTrace_glGetPerfMonitorCountersAMD(GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
-void GLTrace_glGetPerfMonitorGroupStringAMD(GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
-void GLTrace_glGetPerfMonitorCounterStringAMD(GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
-void GLTrace_glGetPerfMonitorCounterInfoAMD(GLuint group, GLuint counter, GLenum pname, GLvoid *data);
-void GLTrace_glGenPerfMonitorsAMD(GLsizei n, GLuint *monitors);
-void GLTrace_glDeletePerfMonitorsAMD(GLsizei n, GLuint *monitors);
-void GLTrace_glSelectPerfMonitorCountersAMD(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList);
+void GLTrace_glGetPerfMonitorGroupsAMD(GLint * numGroups, GLsizei groupsSize, GLuint * groups);
+void GLTrace_glGetPerfMonitorCountersAMD(GLuint group, GLint * numCounters, GLint * maxActiveCounters, GLsizei counterSize, GLuint * counters);
+void GLTrace_glGetPerfMonitorGroupStringAMD(GLuint group, GLsizei bufSize, GLsizei * length, GLchar * groupString);
+void GLTrace_glGetPerfMonitorCounterStringAMD(GLuint group, GLuint counter, GLsizei bufSize, GLsizei * length, GLchar * counterString);
+void GLTrace_glGetPerfMonitorCounterInfoAMD(GLuint group, GLuint counter, GLenum pname, void * data);
+void GLTrace_glGenPerfMonitorsAMD(GLsizei n, GLuint * monitors);
+void GLTrace_glDeletePerfMonitorsAMD(GLsizei n, GLuint * monitors);
+void GLTrace_glSelectPerfMonitorCountersAMD(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint * counterList);
 void GLTrace_glBeginPerfMonitorAMD(GLuint monitor);
 void GLTrace_glEndPerfMonitorAMD(GLuint monitor);
-void GLTrace_glGetPerfMonitorCounterDataAMD(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
+void GLTrace_glGetPerfMonitorCounterDataAMD(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint * data, GLint * bytesWritten);
 void GLTrace_glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
 void GLTrace_glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+void GLTrace_glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+void GLTrace_glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount);
+void GLTrace_glVertexAttribDivisorANGLE(GLuint index, GLuint divisor);
+void GLTrace_glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei * length, GLchar * source);
+void GLTrace_glCopyTextureLevelsAPPLE(GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
 void GLTrace_glRenderbufferStorageMultisampleAPPLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
 void GLTrace_glResolveMultisampleFramebufferAPPLE(void);
-void GLTrace_glLabelObjectEXT(GLenum type, GLuint object, GLsizei length, const GLchar *label);
-void GLTrace_glGetObjectLabelEXT(GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label);
-void GLTrace_glInsertEventMarkerEXT(GLsizei length, const GLchar *marker);
-void GLTrace_glPushGroupMarkerEXT(GLsizei length, const GLchar *marker);
+GLsync GLTrace_glFenceSyncAPPLE(GLenum condition, GLbitfield flags);
+GLboolean GLTrace_glIsSyncAPPLE(GLsync sync);
+void GLTrace_glDeleteSyncAPPLE(GLsync sync);
+GLenum GLTrace_glClientWaitSyncAPPLE(GLsync sync, GLbitfield flags, GLuint64 timeout);
+void GLTrace_glWaitSyncAPPLE(GLsync sync, GLbitfield flags, GLuint64 timeout);
+void GLTrace_glGetInteger64vAPPLE(GLenum pname, GLint64 * params);
+void GLTrace_glGetSyncivAPPLE(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values);
+void GLTrace_glCopyImageSubDataEXT(GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
+void GLTrace_glLabelObjectEXT(GLenum type, GLuint object, GLsizei length, const GLchar * label);
+void GLTrace_glGetObjectLabelEXT(GLenum type, GLuint object, GLsizei bufSize, GLsizei * length, GLchar * label);
+void GLTrace_glInsertEventMarkerEXT(GLsizei length, const GLchar * marker);
+void GLTrace_glPushGroupMarkerEXT(GLsizei length, const GLchar * marker);
 void GLTrace_glPopGroupMarkerEXT(void);
-void GLTrace_glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum *attachments);
-void GLTrace_glRenderbufferStorageMultisampleEXT(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-void GLTrace_glFramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
-void GLTrace_glMultiDrawArraysEXT(GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
-void GLTrace_glMultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
-void GLTrace_glGenQueriesEXT(GLsizei n, GLuint *ids);
-void GLTrace_glDeleteQueriesEXT(GLsizei n, const GLuint *ids);
+void GLTrace_glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum * attachments);
+void GLTrace_glGenQueriesEXT(GLsizei n, GLuint * ids);
+void GLTrace_glDeleteQueriesEXT(GLsizei n, const GLuint * ids);
 GLboolean GLTrace_glIsQueryEXT(GLuint id);
 void GLTrace_glBeginQueryEXT(GLenum target, GLuint id);
 void GLTrace_glEndQueryEXT(GLenum target);
-void GLTrace_glGetQueryivEXT(GLenum target, GLenum pname, GLint *params);
-void GLTrace_glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params);
+void GLTrace_glQueryCounterEXT(GLuint id, GLenum target);
+void GLTrace_glGetQueryivEXT(GLenum target, GLenum pname, GLint * params);
+void GLTrace_glGetQueryObjectivEXT(GLuint id, GLenum pname, GLint * params);
+void GLTrace_glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint * params);
+void GLTrace_glGetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64 * params);
+void GLTrace_glGetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64 * params);
+void GLTrace_glDrawBuffersEXT(GLsizei n, const GLenum * bufs);
+void GLTrace_glEnableiEXT(GLenum target, GLuint index);
+void GLTrace_glDisableiEXT(GLenum target, GLuint index);
+void GLTrace_glBlendEquationiEXT(GLuint buf, GLenum mode);
+void GLTrace_glBlendEquationSeparateiEXT(GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+void GLTrace_glBlendFunciEXT(GLuint buf, GLenum src, GLenum dst);
+void GLTrace_glBlendFuncSeparateiEXT(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+void GLTrace_glColorMaskiEXT(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+GLboolean GLTrace_glIsEnablediEXT(GLenum target, GLuint index);
+void GLTrace_glDrawArraysInstancedEXT(GLenum mode, GLint start, GLsizei count, GLsizei primcount);
+void GLTrace_glDrawElementsInstancedEXT(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount);
+void GLTrace_glFramebufferTextureEXT(GLenum target, GLenum attachment, GLuint texture, GLint level);
+void GLTrace_glVertexAttribDivisorEXT(GLuint index, GLuint divisor);
+void * GLTrace_glMapBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+void GLTrace_glFlushMappedBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length);
+void GLTrace_glMultiDrawArraysEXT(GLenum mode, const GLint * first, const GLsizei * count, GLsizei primcount);
+void GLTrace_glMultiDrawElementsEXT(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei primcount);
+void GLTrace_glRenderbufferStorageMultisampleEXT(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+void GLTrace_glFramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+void GLTrace_glReadBufferIndexedEXT(GLenum src, GLint index);
+void GLTrace_glDrawBuffersIndexedEXT(GLint n, const GLenum * location, const GLint * indices);
+void GLTrace_glGetIntegeri_vEXT(GLenum target, GLuint index, GLint * data);
+void GLTrace_glPrimitiveBoundingBoxEXT(GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
 GLenum GLTrace_glGetGraphicsResetStatusEXT(void);
-void GLTrace_glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
-void GLTrace_glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, float *params);
-void GLTrace_glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint *params);
-void GLTrace_glUseProgramStagesEXT(GLuint pipeline, GLbitfield stages, GLuint program);
+void GLTrace_glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data);
+void GLTrace_glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat * params);
+void GLTrace_glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint * params);
 void GLTrace_glActiveShaderProgramEXT(GLuint pipeline, GLuint program);
-GLuint GLTrace_glCreateShaderProgramvEXT(GLenum type, GLsizei count, const GLchar **strings);
 void GLTrace_glBindProgramPipelineEXT(GLuint pipeline);
-void GLTrace_glDeleteProgramPipelinesEXT(GLsizei n, const GLuint *pipelines);
-void GLTrace_glGenProgramPipelinesEXT(GLsizei n, GLuint *pipelines);
+GLuint GLTrace_glCreateShaderProgramvEXT(GLenum type, GLsizei count, const GLchar ** strings);
+void GLTrace_glDeleteProgramPipelinesEXT(GLsizei n, const GLuint * pipelines);
+void GLTrace_glGenProgramPipelinesEXT(GLsizei n, GLuint * pipelines);
+void GLTrace_glGetProgramPipelineInfoLogEXT(GLuint pipeline, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
+void GLTrace_glGetProgramPipelineivEXT(GLuint pipeline, GLenum pname, GLint * params);
 GLboolean GLTrace_glIsProgramPipelineEXT(GLuint pipeline);
 void GLTrace_glProgramParameteriEXT(GLuint program, GLenum pname, GLint value);
-void GLTrace_glGetProgramPipelineivEXT(GLuint pipeline, GLenum pname, GLint *params);
-void GLTrace_glProgramUniform1iEXT(GLuint program, GLint location, GLint x);
-void GLTrace_glProgramUniform2iEXT(GLuint program, GLint location, GLint x, GLint y);
-void GLTrace_glProgramUniform3iEXT(GLuint program, GLint location, GLint x, GLint y, GLint z);
-void GLTrace_glProgramUniform4iEXT(GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w);
-void GLTrace_glProgramUniform1fEXT(GLuint program, GLint location, GLfloat x);
-void GLTrace_glProgramUniform2fEXT(GLuint program, GLint location, GLfloat x, GLfloat y);
-void GLTrace_glProgramUniform3fEXT(GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z);
-void GLTrace_glProgramUniform4fEXT(GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-void GLTrace_glProgramUniform1ivEXT(GLuint program, GLint location, GLsizei count, const GLint *value);
-void GLTrace_glProgramUniform2ivEXT(GLuint program, GLint location, GLsizei count, const GLint *value);
-void GLTrace_glProgramUniform3ivEXT(GLuint program, GLint location, GLsizei count, const GLint *value);
-void GLTrace_glProgramUniform4ivEXT(GLuint program, GLint location, GLsizei count, const GLint *value);
-void GLTrace_glProgramUniform1fvEXT(GLuint program, GLint location, GLsizei count, const GLfloat *value);
-void GLTrace_glProgramUniform2fvEXT(GLuint program, GLint location, GLsizei count, const GLfloat *value);
-void GLTrace_glProgramUniform3fvEXT(GLuint program, GLint location, GLsizei count, const GLfloat *value);
-void GLTrace_glProgramUniform4fvEXT(GLuint program, GLint location, GLsizei count, const GLfloat *value);
-void GLTrace_glProgramUniformMatrix2fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-void GLTrace_glProgramUniformMatrix3fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-void GLTrace_glProgramUniformMatrix4fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+void GLTrace_glProgramUniform1fEXT(GLuint program, GLint location, GLfloat v0);
+void GLTrace_glProgramUniform1fvEXT(GLuint program, GLint location, GLsizei count, const GLfloat * value);
+void GLTrace_glProgramUniform1iEXT(GLuint program, GLint location, GLint v0);
+void GLTrace_glProgramUniform1ivEXT(GLuint program, GLint location, GLsizei count, const GLint * value);
+void GLTrace_glProgramUniform2fEXT(GLuint program, GLint location, GLfloat v0, GLfloat v1);
+void GLTrace_glProgramUniform2fvEXT(GLuint program, GLint location, GLsizei count, const GLfloat * value);
+void GLTrace_glProgramUniform2iEXT(GLuint program, GLint location, GLint v0, GLint v1);
+void GLTrace_glProgramUniform2ivEXT(GLuint program, GLint location, GLsizei count, const GLint * value);
+void GLTrace_glProgramUniform3fEXT(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+void GLTrace_glProgramUniform3fvEXT(GLuint program, GLint location, GLsizei count, const GLfloat * value);
+void GLTrace_glProgramUniform3iEXT(GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+void GLTrace_glProgramUniform3ivEXT(GLuint program, GLint location, GLsizei count, const GLint * value);
+void GLTrace_glProgramUniform4fEXT(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+void GLTrace_glProgramUniform4fvEXT(GLuint program, GLint location, GLsizei count, const GLfloat * value);
+void GLTrace_glProgramUniform4iEXT(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+void GLTrace_glProgramUniform4ivEXT(GLuint program, GLint location, GLsizei count, const GLint * value);
+void GLTrace_glProgramUniformMatrix2fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glProgramUniformMatrix3fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glProgramUniformMatrix4fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glUseProgramStagesEXT(GLuint pipeline, GLbitfield stages, GLuint program);
 void GLTrace_glValidateProgramPipelineEXT(GLuint pipeline);
-void GLTrace_glGetProgramPipelineInfoLogEXT(GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+void GLTrace_glProgramUniform1uiEXT(GLuint program, GLint location, GLuint v0);
+void GLTrace_glProgramUniform2uiEXT(GLuint program, GLint location, GLuint v0, GLuint v1);
+void GLTrace_glProgramUniform3uiEXT(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+void GLTrace_glProgramUniform4uiEXT(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+void GLTrace_glProgramUniform1uivEXT(GLuint program, GLint location, GLsizei count, const GLuint * value);
+void GLTrace_glProgramUniform2uivEXT(GLuint program, GLint location, GLsizei count, const GLuint * value);
+void GLTrace_glProgramUniform3uivEXT(GLuint program, GLint location, GLsizei count, const GLuint * value);
+void GLTrace_glProgramUniform4uivEXT(GLuint program, GLint location, GLsizei count, const GLuint * value);
+void GLTrace_glProgramUniformMatrix2x3fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glProgramUniformMatrix3x2fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glProgramUniformMatrix2x4fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glProgramUniformMatrix4x2fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glProgramUniformMatrix3x4fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glProgramUniformMatrix4x3fvEXT(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glPatchParameteriEXT(GLenum pname, GLint value);
+void GLTrace_glTexParameterIivEXT(GLenum target, GLenum pname, const GLint * params);
+void GLTrace_glTexParameterIuivEXT(GLenum target, GLenum pname, const GLuint * params);
+void GLTrace_glGetTexParameterIivEXT(GLenum target, GLenum pname, GLint * params);
+void GLTrace_glGetTexParameterIuivEXT(GLenum target, GLenum pname, GLuint * params);
+void GLTrace_glSamplerParameterIivEXT(GLuint sampler, GLenum pname, const GLint * param);
+void GLTrace_glSamplerParameterIuivEXT(GLuint sampler, GLenum pname, const GLuint * param);
+void GLTrace_glGetSamplerParameterIivEXT(GLuint sampler, GLenum pname, GLint * params);
+void GLTrace_glGetSamplerParameterIuivEXT(GLuint sampler, GLenum pname, GLuint * params);
+void GLTrace_glTexBufferEXT(GLenum target, GLenum internalformat, GLuint buffer);
+void GLTrace_glTexBufferRangeEXT(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
 void GLTrace_glTexStorage1DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
 void GLTrace_glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
 void GLTrace_glTexStorage3DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
 void GLTrace_glTextureStorage1DEXT(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
 void GLTrace_glTextureStorage2DEXT(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
 void GLTrace_glTextureStorage3DEXT(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+void GLTrace_glTextureViewEXT(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
 void GLTrace_glRenderbufferStorageMultisampleIMG(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
 void GLTrace_glFramebufferTexture2DMultisampleIMG(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+void GLTrace_glBeginPerfQueryINTEL(GLuint queryHandle);
+void GLTrace_glCreatePerfQueryINTEL(GLuint queryId, GLuint * queryHandle);
+void GLTrace_glDeletePerfQueryINTEL(GLuint queryHandle);
+void GLTrace_glEndPerfQueryINTEL(GLuint queryHandle);
+void GLTrace_glGetFirstPerfQueryIdINTEL(GLuint * queryId);
+void GLTrace_glGetNextPerfQueryIdINTEL(GLuint queryId, GLuint * nextQueryId);
+void GLTrace_glGetPerfCounterInfoINTEL(GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar * counterName, GLuint counterDescLength, GLchar * counterDesc, GLuint * counterOffset, GLuint * counterDataSize, GLuint * counterTypeEnum, GLuint * counterDataTypeEnum, GLuint64 * rawCounterMaxValue);
+void GLTrace_glGetPerfQueryDataINTEL(GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid * data, GLuint * bytesWritten);
+void GLTrace_glGetPerfQueryIdByNameINTEL(GLchar * queryName, GLuint * queryId);
+void GLTrace_glGetPerfQueryInfoINTEL(GLuint queryId, GLuint queryNameLength, GLchar * queryName, GLuint * dataSize, GLuint * noCounters, GLuint * noInstances, GLuint * capsMask);
+void GLTrace_glBlendParameteriNV(GLenum pname, GLint value);
+void GLTrace_glBlendBarrierNV(void);
+void GLTrace_glCopyBufferSubDataNV(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
 void GLTrace_glCoverageMaskNV(GLboolean mask);
 void GLTrace_glCoverageOperationNV(GLenum operation);
-void GLTrace_glDrawBuffersNV(GLsizei n, const GLenum *bufs);
-void GLTrace_glDeleteFencesNV(GLsizei n, const GLuint *fences);
-void GLTrace_glGenFencesNV(GLsizei n, GLuint *fences);
+void GLTrace_glDrawBuffersNV(GLsizei n, const GLenum * bufs);
+void GLTrace_glDrawArraysInstancedNV(GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+void GLTrace_glDrawElementsInstancedNV(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount);
+void GLTrace_glDeleteFencesNV(GLsizei n, const GLuint * fences);
+void GLTrace_glGenFencesNV(GLsizei n, GLuint * fences);
 GLboolean GLTrace_glIsFenceNV(GLuint fence);
 GLboolean GLTrace_glTestFenceNV(GLuint fence);
-void GLTrace_glGetFenceivNV(GLuint fence, GLenum pname, GLint *params);
+void GLTrace_glGetFenceivNV(GLuint fence, GLenum pname, GLint * params);
 void GLTrace_glFinishFenceNV(GLuint fence);
 void GLTrace_glSetFenceNV(GLuint fence, GLenum condition);
+void GLTrace_glBlitFramebufferNV(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+void GLTrace_glRenderbufferStorageMultisampleNV(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+void GLTrace_glVertexAttribDivisorNV(GLuint index, GLuint divisor);
+void GLTrace_glUniformMatrix2x3fvNV(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glUniformMatrix3x2fvNV(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glUniformMatrix2x4fvNV(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glUniformMatrix4x2fvNV(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glUniformMatrix3x4fvNV(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+void GLTrace_glUniformMatrix4x3fvNV(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
 void GLTrace_glReadBufferNV(GLenum mode);
 void GLTrace_glAlphaFuncQCOM(GLenum func, GLclampf ref);
-void GLTrace_glGetDriverControlsQCOM(GLint *num, GLsizei size, GLuint *driverControls);
-void GLTrace_glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
+void GLTrace_glGetDriverControlsQCOM(GLint * num, GLsizei size, GLuint * driverControls);
+void GLTrace_glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei * length, GLchar * driverControlString);
 void GLTrace_glEnableDriverControlQCOM(GLuint driverControl);
 void GLTrace_glDisableDriverControlQCOM(GLuint driverControl);
-void GLTrace_glExtGetTexturesQCOM(GLuint *textures, GLint maxTextures, GLint *numTextures);
-void GLTrace_glExtGetBuffersQCOM(GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
-void GLTrace_glExtGetRenderbuffersQCOM(GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);
-void GLTrace_glExtGetFramebuffersQCOM(GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
-void GLTrace_glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
+void GLTrace_glExtGetTexturesQCOM(GLuint * textures, GLint maxTextures, GLint * numTextures);
+void GLTrace_glExtGetBuffersQCOM(GLuint * buffers, GLint maxBuffers, GLint * numBuffers);
+void GLTrace_glExtGetRenderbuffersQCOM(GLuint * renderbuffers, GLint maxRenderbuffers, GLint * numRenderbuffers);
+void GLTrace_glExtGetFramebuffersQCOM(GLuint * framebuffers, GLint maxFramebuffers, GLint * numFramebuffers);
+void GLTrace_glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint * params);
 void GLTrace_glExtTexObjectStateOverrideiQCOM(GLenum target, GLenum pname, GLint param);
-void GLTrace_glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels);
-void GLTrace_glExtGetBufferPointervQCOM(GLenum target, GLvoid **params);
-void GLTrace_glExtGetShadersQCOM(GLuint *shaders, GLint maxShaders, GLint *numShaders);
-void GLTrace_glExtGetProgramsQCOM(GLuint *programs, GLint maxPrograms, GLint *numPrograms);
+void GLTrace_glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void * texels);
+void GLTrace_glExtGetBufferPointervQCOM(GLenum target, void ** params);
+void GLTrace_glExtGetShadersQCOM(GLuint * shaders, GLint maxShaders, GLint * numShaders);
+void GLTrace_glExtGetProgramsQCOM(GLuint * programs, GLint maxPrograms, GLint * numPrograms);
 GLboolean GLTrace_glExtIsProgramBinaryQCOM(GLuint program);
-void GLTrace_glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar *source, GLint *length);
+void GLTrace_glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar * source, GLint * length);
 void GLTrace_glStartTilingQCOM(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
 void GLTrace_glEndTilingQCOM(GLbitfield preserveMask);
 
 // Declarations for GL1 APIs
 
-void GLTrace_glAlphaFunc(GLenum func, GLclampf ref);
-void GLTrace_glClipPlanef(GLenum plane, const GLfloat *equation);
+void GLTrace_glAlphaFunc(GLenum func, GLfloat ref);
+void GLTrace_glClipPlanef(GLenum p, const GLfloat * eqn);
 void GLTrace_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
 void GLTrace_glFogf(GLenum pname, GLfloat param);
-void GLTrace_glFogfv(GLenum pname, const GLfloat *params);
-void GLTrace_glFrustumf(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
-void GLTrace_glGetClipPlanef(GLenum pname, GLfloat eqn[4]);
-void GLTrace_glGetLightfv(GLenum light, GLenum pname, GLfloat *params);
-void GLTrace_glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params);
-void GLTrace_glGetTexEnvfv(GLenum env, GLenum pname, GLfloat *params);
+void GLTrace_glFogfv(GLenum pname, const GLfloat * params);
+void GLTrace_glFrustumf(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);
+void GLTrace_glGetClipPlanef(GLenum plane, GLfloat * equation);
+void GLTrace_glGetLightfv(GLenum light, GLenum pname, GLfloat * params);
+void GLTrace_glGetMaterialfv(GLenum face, GLenum pname, GLfloat * params);
+void GLTrace_glGetTexEnvfv(GLenum target, GLenum pname, GLfloat * params);
 void GLTrace_glLightModelf(GLenum pname, GLfloat param);
-void GLTrace_glLightModelfv(GLenum pname, const GLfloat *params);
+void GLTrace_glLightModelfv(GLenum pname, const GLfloat * params);
 void GLTrace_glLightf(GLenum light, GLenum pname, GLfloat param);
-void GLTrace_glLightfv(GLenum light, GLenum pname, const GLfloat *params);
-void GLTrace_glLoadMatrixf(const GLfloat *m);
+void GLTrace_glLightfv(GLenum light, GLenum pname, const GLfloat * params);
+void GLTrace_glLoadMatrixf(const GLfloat * m);
 void GLTrace_glMaterialf(GLenum face, GLenum pname, GLfloat param);
-void GLTrace_glMaterialfv(GLenum face, GLenum pname, const GLfloat *params);
-void GLTrace_glMultMatrixf(const GLfloat *m);
+void GLTrace_glMaterialfv(GLenum face, GLenum pname, const GLfloat * params);
+void GLTrace_glMultMatrixf(const GLfloat * m);
 void GLTrace_glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
 void GLTrace_glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz);
-void GLTrace_glOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+void GLTrace_glOrthof(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);
 void GLTrace_glPointParameterf(GLenum pname, GLfloat param);
-void GLTrace_glPointParameterfv(GLenum pname, const GLfloat *params);
+void GLTrace_glPointParameterfv(GLenum pname, const GLfloat * params);
 void GLTrace_glPointSize(GLfloat size);
 void GLTrace_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
 void GLTrace_glScalef(GLfloat x, GLfloat y, GLfloat z);
 void GLTrace_glTexEnvf(GLenum target, GLenum pname, GLfloat param);
-void GLTrace_glTexEnvfv(GLenum target, GLenum pname, const GLfloat *params);
+void GLTrace_glTexEnvfv(GLenum target, GLenum pname, const GLfloat * params);
 void GLTrace_glTranslatef(GLfloat x, GLfloat y, GLfloat z);
-void GLTrace_glAlphaFuncx(GLenum func, GLclampx ref);
-void GLTrace_glClearColorx(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
-void GLTrace_glClearDepthx(GLclampx depth);
+void GLTrace_glAlphaFuncx(GLenum func, GLfixed ref);
+void GLTrace_glClearColorx(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+void GLTrace_glClearDepthx(GLfixed depth);
 void GLTrace_glClientActiveTexture(GLenum texture);
-void GLTrace_glClipPlanex(GLenum plane, const GLfixed *equation);
+void GLTrace_glClipPlanex(GLenum plane, const GLfixed * equation);
 void GLTrace_glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
 void GLTrace_glColor4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
-void GLTrace_glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-void GLTrace_glDepthRangex(GLclampx zNear, GLclampx zFar);
+void GLTrace_glColorPointer(GLint size, GLenum type, GLsizei stride, const void * pointer);
+void GLTrace_glDepthRangex(GLfixed n, GLfixed f);
 void GLTrace_glDisableClientState(GLenum array);
 void GLTrace_glEnableClientState(GLenum array);
 void GLTrace_glFogx(GLenum pname, GLfixed param);
-void GLTrace_glFogxv(GLenum pname, const GLfixed *params);
-void GLTrace_glFrustumx(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
-void GLTrace_glGetClipPlanex(GLenum pname, GLfixed eqn[4]);
-void GLTrace_glGetFixedv(GLenum pname, GLfixed *params);
-void GLTrace_glGetLightxv(GLenum light, GLenum pname, GLfixed *params);
-void GLTrace_glGetMaterialxv(GLenum face, GLenum pname, GLfixed *params);
-void GLTrace_glGetPointerv(GLenum pname, GLvoid **params);
-void GLTrace_glGetTexEnviv(GLenum env, GLenum pname, GLint *params);
-void GLTrace_glGetTexEnvxv(GLenum env, GLenum pname, GLfixed *params);
-void GLTrace_glGetTexParameterxv(GLenum target, GLenum pname, GLfixed *params);
+void GLTrace_glFogxv(GLenum pname, const GLfixed * param);
+void GLTrace_glFrustumx(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f);
+void GLTrace_glGetClipPlanex(GLenum plane, GLfixed * equation);
+void GLTrace_glGetFixedv(GLenum pname, GLfixed * params);
+void GLTrace_glGetLightxv(GLenum light, GLenum pname, GLfixed * params);
+void GLTrace_glGetMaterialxv(GLenum face, GLenum pname, GLfixed * params);
+void GLTrace_glGetPointerv(GLenum pname, void ** params);
+void GLTrace_glGetTexEnviv(GLenum target, GLenum pname, GLint * params);
+void GLTrace_glGetTexEnvxv(GLenum target, GLenum pname, GLfixed * params);
+void GLTrace_glGetTexParameterxv(GLenum target, GLenum pname, GLfixed * params);
 void GLTrace_glLightModelx(GLenum pname, GLfixed param);
-void GLTrace_glLightModelxv(GLenum pname, const GLfixed *params);
+void GLTrace_glLightModelxv(GLenum pname, const GLfixed * param);
 void GLTrace_glLightx(GLenum light, GLenum pname, GLfixed param);
-void GLTrace_glLightxv(GLenum light, GLenum pname, const GLfixed *params);
+void GLTrace_glLightxv(GLenum light, GLenum pname, const GLfixed * params);
 void GLTrace_glLineWidthx(GLfixed width);
 void GLTrace_glLoadIdentity(void);
-void GLTrace_glLoadMatrixx(const GLfixed *m);
+void GLTrace_glLoadMatrixx(const GLfixed * m);
 void GLTrace_glLogicOp(GLenum opcode);
 void GLTrace_glMaterialx(GLenum face, GLenum pname, GLfixed param);
-void GLTrace_glMaterialxv(GLenum face, GLenum pname, const GLfixed *params);
+void GLTrace_glMaterialxv(GLenum face, GLenum pname, const GLfixed * param);
 void GLTrace_glMatrixMode(GLenum mode);
-void GLTrace_glMultMatrixx(const GLfixed *m);
-void GLTrace_glMultiTexCoord4x(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+void GLTrace_glMultMatrixx(const GLfixed * m);
+void GLTrace_glMultiTexCoord4x(GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
 void GLTrace_glNormal3x(GLfixed nx, GLfixed ny, GLfixed nz);
-void GLTrace_glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer);
-void GLTrace_glOrthox(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+void GLTrace_glNormalPointer(GLenum type, GLsizei stride, const void * pointer);
+void GLTrace_glOrthox(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f);
 void GLTrace_glPointParameterx(GLenum pname, GLfixed param);
-void GLTrace_glPointParameterxv(GLenum pname, const GLfixed *params);
+void GLTrace_glPointParameterxv(GLenum pname, const GLfixed * params);
 void GLTrace_glPointSizex(GLfixed size);
 void GLTrace_glPolygonOffsetx(GLfixed factor, GLfixed units);
 void GLTrace_glPopMatrix(void);
@@ -471,106 +639,129 @@
 void GLTrace_glSampleCoveragex(GLclampx value, GLboolean invert);
 void GLTrace_glScalex(GLfixed x, GLfixed y, GLfixed z);
 void GLTrace_glShadeModel(GLenum mode);
-void GLTrace_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+void GLTrace_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const void * pointer);
 void GLTrace_glTexEnvi(GLenum target, GLenum pname, GLint param);
 void GLTrace_glTexEnvx(GLenum target, GLenum pname, GLfixed param);
-void GLTrace_glTexEnviv(GLenum target, GLenum pname, const GLint *params);
-void GLTrace_glTexEnvxv(GLenum target, GLenum pname, const GLfixed *params);
+void GLTrace_glTexEnviv(GLenum target, GLenum pname, const GLint * params);
+void GLTrace_glTexEnvxv(GLenum target, GLenum pname, const GLfixed * params);
 void GLTrace_glTexParameterx(GLenum target, GLenum pname, GLfixed param);
-void GLTrace_glTexParameterxv(GLenum target, GLenum pname, const GLfixed *params);
+void GLTrace_glTexParameterxv(GLenum target, GLenum pname, const GLfixed * params);
 void GLTrace_glTranslatex(GLfixed x, GLfixed y, GLfixed z);
-void GLTrace_glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-void GLTrace_glPointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *pointer);
+void GLTrace_glVertexPointer(GLint size, GLenum type, GLsizei stride, const void * pointer);
 
 // Declarations for GL1Ext APIs
 
 void GLTrace_glBlendEquationSeparateOES(GLenum modeRGB, GLenum modeAlpha);
 void GLTrace_glBlendFuncSeparateOES(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
 void GLTrace_glBlendEquationOES(GLenum mode);
+void GLTrace_glMultiTexCoord1bOES(GLenum texture, GLbyte s);
+void GLTrace_glMultiTexCoord1bvOES(GLenum texture, const GLbyte * coords);
+void GLTrace_glMultiTexCoord2bOES(GLenum texture, GLbyte s, GLbyte t);
+void GLTrace_glMultiTexCoord2bvOES(GLenum texture, const GLbyte * coords);
+void GLTrace_glMultiTexCoord3bOES(GLenum texture, GLbyte s, GLbyte t, GLbyte r);
+void GLTrace_glMultiTexCoord3bvOES(GLenum texture, const GLbyte * coords);
+void GLTrace_glMultiTexCoord4bOES(GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q);
+void GLTrace_glMultiTexCoord4bvOES(GLenum texture, const GLbyte * coords);
+void GLTrace_glTexCoord1bOES(GLbyte s);
+void GLTrace_glTexCoord1bvOES(const GLbyte * coords);
+void GLTrace_glTexCoord2bOES(GLbyte s, GLbyte t);
+void GLTrace_glTexCoord2bvOES(const GLbyte * coords);
+void GLTrace_glTexCoord3bOES(GLbyte s, GLbyte t, GLbyte r);
+void GLTrace_glTexCoord3bvOES(const GLbyte * coords);
+void GLTrace_glTexCoord4bOES(GLbyte s, GLbyte t, GLbyte r, GLbyte q);
+void GLTrace_glTexCoord4bvOES(const GLbyte * coords);
+void GLTrace_glVertex2bOES(GLbyte x);
+void GLTrace_glVertex2bvOES(const GLbyte * coords);
+void GLTrace_glVertex3bOES(GLbyte x, GLbyte y);
+void GLTrace_glVertex3bvOES(const GLbyte * coords);
+void GLTrace_glVertex4bOES(GLbyte x, GLbyte y, GLbyte z);
+void GLTrace_glVertex4bvOES(const GLbyte * coords);
 void GLTrace_glDrawTexsOES(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height);
 void GLTrace_glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height);
 void GLTrace_glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height);
-void GLTrace_glDrawTexsvOES(const GLshort *coords);
-void GLTrace_glDrawTexivOES(const GLint *coords);
-void GLTrace_glDrawTexxvOES(const GLfixed *coords);
+void GLTrace_glDrawTexsvOES(const GLshort * coords);
+void GLTrace_glDrawTexivOES(const GLint * coords);
+void GLTrace_glDrawTexxvOES(const GLfixed * coords);
 void GLTrace_glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
-void GLTrace_glDrawTexfvOES(const GLfloat *coords);
-void GLTrace_glAlphaFuncxOES(GLenum func, GLclampx ref);
-void GLTrace_glClearColorxOES(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
-void GLTrace_glClearDepthxOES(GLclampx depth);
-void GLTrace_glClipPlanexOES(GLenum plane, const GLfixed *equation);
+void GLTrace_glDrawTexfvOES(const GLfloat * coords);
+void GLTrace_glAlphaFuncxOES(GLenum func, GLfixed ref);
+void GLTrace_glClearColorxOES(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+void GLTrace_glClearDepthxOES(GLfixed depth);
+void GLTrace_glClipPlanexOES(GLenum plane, const GLfixed * equation);
 void GLTrace_glColor4xOES(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
-void GLTrace_glDepthRangexOES(GLclampx zNear, GLclampx zFar);
+void GLTrace_glDepthRangexOES(GLfixed n, GLfixed f);
 void GLTrace_glFogxOES(GLenum pname, GLfixed param);
-void GLTrace_glFogxvOES(GLenum pname, const GLfixed *params);
-void GLTrace_glFrustumxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
-void GLTrace_glGetClipPlanexOES(GLenum pname, GLfixed eqn[4]);
-void GLTrace_glGetFixedvOES(GLenum pname, GLfixed *params);
-void GLTrace_glGetLightxvOES(GLenum light, GLenum pname, GLfixed *params);
-void GLTrace_glGetMaterialxvOES(GLenum face, GLenum pname, GLfixed *params);
-void GLTrace_glGetTexEnvxvOES(GLenum env, GLenum pname, GLfixed *params);
-void GLTrace_glGetTexParameterxvOES(GLenum target, GLenum pname, GLfixed *params);
+void GLTrace_glFogxvOES(GLenum pname, const GLfixed * param);
+void GLTrace_glFrustumxOES(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f);
+void GLTrace_glGetClipPlanexOES(GLenum plane, GLfixed * equation);
+void GLTrace_glGetFixedvOES(GLenum pname, GLfixed * params);
+void GLTrace_glGetTexEnvxvOES(GLenum target, GLenum pname, GLfixed * params);
+void GLTrace_glGetTexParameterxvOES(GLenum target, GLenum pname, GLfixed * params);
 void GLTrace_glLightModelxOES(GLenum pname, GLfixed param);
-void GLTrace_glLightModelxvOES(GLenum pname, const GLfixed *params);
+void GLTrace_glLightModelxvOES(GLenum pname, const GLfixed * param);
 void GLTrace_glLightxOES(GLenum light, GLenum pname, GLfixed param);
-void GLTrace_glLightxvOES(GLenum light, GLenum pname, const GLfixed *params);
+void GLTrace_glLightxvOES(GLenum light, GLenum pname, const GLfixed * params);
 void GLTrace_glLineWidthxOES(GLfixed width);
-void GLTrace_glLoadMatrixxOES(const GLfixed *m);
+void GLTrace_glLoadMatrixxOES(const GLfixed * m);
 void GLTrace_glMaterialxOES(GLenum face, GLenum pname, GLfixed param);
-void GLTrace_glMaterialxvOES(GLenum face, GLenum pname, const GLfixed *params);
-void GLTrace_glMultMatrixxOES(const GLfixed *m);
-void GLTrace_glMultiTexCoord4xOES(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+void GLTrace_glMaterialxvOES(GLenum face, GLenum pname, const GLfixed * param);
+void GLTrace_glMultMatrixxOES(const GLfixed * m);
+void GLTrace_glMultiTexCoord4xOES(GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
 void GLTrace_glNormal3xOES(GLfixed nx, GLfixed ny, GLfixed nz);
-void GLTrace_glOrthoxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
-void GLTrace_glPointParameterxOES(GLenum pname, GLfixed param);
-void GLTrace_glPointParameterxvOES(GLenum pname, const GLfixed *params);
+void GLTrace_glOrthoxOES(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f);
+void GLTrace_glPointParameterxvOES(GLenum pname, const GLfixed * params);
 void GLTrace_glPointSizexOES(GLfixed size);
 void GLTrace_glPolygonOffsetxOES(GLfixed factor, GLfixed units);
 void GLTrace_glRotatexOES(GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
-void GLTrace_glSampleCoveragexOES(GLclampx value, GLboolean invert);
+void GLTrace_glSampleCoverageOES(GLfixed value, GLboolean invert);
 void GLTrace_glScalexOES(GLfixed x, GLfixed y, GLfixed z);
 void GLTrace_glTexEnvxOES(GLenum target, GLenum pname, GLfixed param);
-void GLTrace_glTexEnvxvOES(GLenum target, GLenum pname, const GLfixed *params);
+void GLTrace_glTexEnvxvOES(GLenum target, GLenum pname, const GLfixed * params);
 void GLTrace_glTexParameterxOES(GLenum target, GLenum pname, GLfixed param);
-void GLTrace_glTexParameterxvOES(GLenum target, GLenum pname, const GLfixed *params);
+void GLTrace_glTexParameterxvOES(GLenum target, GLenum pname, const GLfixed * params);
 void GLTrace_glTranslatexOES(GLfixed x, GLfixed y, GLfixed z);
+void GLTrace_glGetLightxvOES(GLenum light, GLenum pname, GLfixed * params);
+void GLTrace_glGetMaterialxvOES(GLenum face, GLenum pname, GLfixed * params);
+void GLTrace_glPointParameterxOES(GLenum pname, GLfixed param);
+void GLTrace_glSampleCoveragexOES(GLclampx value, GLboolean invert);
+void GLTrace_glGetTexGenxvOES(GLenum coord, GLenum pname, GLfixed * params);
+void GLTrace_glTexGenxOES(GLenum coord, GLenum pname, GLfixed param);
+void GLTrace_glTexGenxvOES(GLenum coord, GLenum pname, const GLfixed * params);
 GLboolean GLTrace_glIsRenderbufferOES(GLuint renderbuffer);
 void GLTrace_glBindRenderbufferOES(GLenum target, GLuint renderbuffer);
-void GLTrace_glDeleteRenderbuffersOES(GLsizei n, const GLuint* renderbuffers);
-void GLTrace_glGenRenderbuffersOES(GLsizei n, GLuint* renderbuffers);
+void GLTrace_glDeleteRenderbuffersOES(GLsizei n, const GLuint * renderbuffers);
+void GLTrace_glGenRenderbuffersOES(GLsizei n, GLuint * renderbuffers);
 void GLTrace_glRenderbufferStorageOES(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-void GLTrace_glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint* params);
+void GLTrace_glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint * params);
 GLboolean GLTrace_glIsFramebufferOES(GLuint framebuffer);
 void GLTrace_glBindFramebufferOES(GLenum target, GLuint framebuffer);
-void GLTrace_glDeleteFramebuffersOES(GLsizei n, const GLuint* framebuffers);
-void GLTrace_glGenFramebuffersOES(GLsizei n, GLuint* framebuffers);
+void GLTrace_glDeleteFramebuffersOES(GLsizei n, const GLuint * framebuffers);
+void GLTrace_glGenFramebuffersOES(GLsizei n, GLuint * framebuffers);
 GLenum GLTrace_glCheckFramebufferStatusOES(GLenum target);
 void GLTrace_glFramebufferRenderbufferOES(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
 void GLTrace_glFramebufferTexture2DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-void GLTrace_glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint* params);
+void GLTrace_glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint * params);
 void GLTrace_glGenerateMipmapOES(GLenum target);
 void GLTrace_glCurrentPaletteMatrixOES(GLuint matrixpaletteindex);
 void GLTrace_glLoadPaletteFromModelViewMatrixOES(void);
-void GLTrace_glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-void GLTrace_glWeightPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-GLbitfield GLTrace_glQueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]);
-void GLTrace_glDepthRangefOES(GLclampf zNear, GLclampf zFar);
-void GLTrace_glFrustumfOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
-void GLTrace_glOrthofOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
-void GLTrace_glClipPlanefOES(GLenum plane, const GLfloat *equation);
-void GLTrace_glGetClipPlanefOES(GLenum pname, GLfloat eqn[4]);
+void GLTrace_glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, const void * pointer);
+void GLTrace_glWeightPointerOES(GLint size, GLenum type, GLsizei stride, const void * pointer);
+void GLTrace_glPointSizePointerOES(GLenum type, GLsizei stride, const void * pointer);
+GLbitfield GLTrace_glQueryMatrixxOES(GLfixed * mantissa, GLint * exponent);
 void GLTrace_glClearDepthfOES(GLclampf depth);
+void GLTrace_glClipPlanefOES(GLenum plane, const GLfloat * equation);
+void GLTrace_glDepthRangefOES(GLclampf n, GLclampf f);
+void GLTrace_glFrustumfOES(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);
+void GLTrace_glGetClipPlanefOES(GLenum plane, GLfloat * equation);
+void GLTrace_glOrthofOES(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);
 void GLTrace_glTexGenfOES(GLenum coord, GLenum pname, GLfloat param);
-void GLTrace_glTexGenfvOES(GLenum coord, GLenum pname, const GLfloat *params);
+void GLTrace_glTexGenfvOES(GLenum coord, GLenum pname, const GLfloat * params);
 void GLTrace_glTexGeniOES(GLenum coord, GLenum pname, GLint param);
-void GLTrace_glTexGenivOES(GLenum coord, GLenum pname, const GLint *params);
-void GLTrace_glTexGenxOES(GLenum coord, GLenum pname, GLfixed param);
-void GLTrace_glTexGenxvOES(GLenum coord, GLenum pname, const GLfixed *params);
-void GLTrace_glGetTexGenfvOES(GLenum coord, GLenum pname, GLfloat *params);
-void GLTrace_glGetTexGenivOES(GLenum coord, GLenum pname, GLint *params);
-void GLTrace_glGetTexGenxvOES(GLenum coord, GLenum pname, GLfixed *params);
-void GLTrace_glClipPlanefIMG(GLenum p, const GLfloat *eqn);
-void GLTrace_glClipPlanexIMG(GLenum p, const GLfixed *eqn);
+void GLTrace_glTexGenivOES(GLenum coord, GLenum pname, const GLint * params);
+void GLTrace_glGetTexGenfvOES(GLenum coord, GLenum pname, GLfloat * params);
+void GLTrace_glGetTexGenivOES(GLenum coord, GLenum pname, GLint * params);
+void GLTrace_glClipPlanefIMG(GLenum p, const GLfloat * eqn);
+void GLTrace_glClipPlanexIMG(GLenum p, const GLfixed * eqn);
 
 }; // namespace gltrace
 }; // namespace android
diff --git a/opengl/libs/GLES_trace/src/gltrace_context.cpp b/opengl/libs/GLES_trace/src/gltrace_context.cpp
index 0323e8f..d1b3586 100644
--- a/opengl/libs/GLES_trace/src/gltrace_context.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_context.cpp
@@ -133,6 +133,9 @@
         BufferedOutputStream *stream) :
     mId(id),
     mVersion(version),
+    mVersionMajor(0),
+    mVersionMinor(0),
+    mVersionParsed(false),
     mState(state),
     mBufferedOutputStream(stream),
     mElementArrayBuffers(DefaultKeyedVector<GLuint, ElementArrayBuffer*>(NULL))
@@ -149,10 +152,40 @@
     return mVersion;
 }
 
+int GLTraceContext::getVersionMajor() {
+    if (!mVersionParsed) {
+        parseGlesVersion();
+        mVersionParsed = true;
+    }
+    return mVersionMajor;
+}
+
+int GLTraceContext::getVersionMinor() {
+    if (!mVersionParsed) {
+        parseGlesVersion();
+        mVersionParsed = true;
+    }
+    return mVersionMinor;
+}
+
 GLTraceState *GLTraceContext::getGlobalTraceState() {
     return mState;
 }
 
+void GLTraceContext::parseGlesVersion() {
+    const char* str = (const char*)hooks->gl.glGetString(GL_VERSION);
+    int major, minor;
+    if (sscanf(str, "OpenGL ES-CM %d.%d", &major, &minor) != 2) {
+        if (sscanf(str, "OpenGL ES %d.%d", &major, &minor) != 2) {
+            ALOGW("Unable to parse GL_VERSION string: \"%s\"", str);
+            major = 1;
+            minor = 0;
+        }
+    }
+    mVersionMajor = major;
+    mVersionMinor = minor;
+}
+
 void GLTraceContext::resizeFBMemory(unsigned minSize) {
     if (fbcontentsSize >= minSize) {
         return;
diff --git a/opengl/libs/GLES_trace/src/gltrace_context.h b/opengl/libs/GLES_trace/src/gltrace_context.h
index 4c38bba..38c7315 100644
--- a/opengl/libs/GLES_trace/src/gltrace_context.h
+++ b/opengl/libs/GLES_trace/src/gltrace_context.h
@@ -51,6 +51,9 @@
 class GLTraceContext {
     int mId;                    /* unique context id */
     int mVersion;               /* GL version, e.g: egl_connection_t::GLESv2_INDEX */
+    int mVersionMajor;          /* GL major version. Lazily parsed in getVersionX(). */
+    int mVersionMinor;          /* GL minor version. Lazily parsed in getVersionX(). */
+    bool mVersionParsed;        /* True if major and minor versions have been parsed. */
     GLTraceState *mState;       /* parent GL Trace state (for per process GL Trace State Info) */
 
     void *fbcontents;           /* memory area to read framebuffer contents */
@@ -62,6 +65,9 @@
     /* list of element array buffers in use. */
     DefaultKeyedVector<GLuint, ElementArrayBuffer*> mElementArrayBuffers;
 
+    /* Parses the GL version string returned from glGetString(GL_VERSION) to get find the major and
+       minor versions of the GLES API. The context must be current before calling. */
+    void parseGlesVersion();
     void resizeFBMemory(unsigned minSize);
 public:
     gl_hooks_t *hooks;
@@ -69,6 +75,8 @@
     GLTraceContext(int id, int version, GLTraceState *state, BufferedOutputStream *stream);
     int getId();
     int getVersion();
+    int getVersionMajor();
+    int getVersionMinor();
     GLTraceState *getGlobalTraceState();
     void getCompressedFB(void **fb, unsigned *fbsize,
                             unsigned *fbwidth, unsigned *fbheight,
diff --git a/opengl/libs/GLES_trace/src/gltrace_egl.cpp b/opengl/libs/GLES_trace/src/gltrace_egl.cpp
index 4f9b006..a7878f2 100644
--- a/opengl/libs/GLES_trace/src/gltrace_egl.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_egl.cpp
@@ -17,7 +17,7 @@
 #include <cutils/log.h>
 #include <utils/Timers.h>
 
-#include "gltrace.pb.h"
+#include "frameworks/native/opengl/libs/GLES_trace/proto/gltrace.pb.h"
 #include "gltrace_context.h"
 #include "gltrace_fixup.h"
 #include "gltrace_transport.h"
diff --git a/opengl/libs/GLES_trace/src/gltrace_fixup.cpp b/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
index a6c024b..a4a187a 100644
--- a/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
@@ -21,7 +21,7 @@
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 
-#include "gltrace.pb.h"
+#include "frameworks/native/opengl/libs/GLES_trace/proto/gltrace.pb.h"
 #include "gltrace_api.h"
 #include "gltrace_context.h"
 #include "gltrace_fixup.h"
@@ -29,6 +29,33 @@
 namespace android {
 namespace gltrace {
 
+GLint glGetInteger(GLTraceContext *context, GLenum param) {
+    GLint x;
+    context->hooks->gl.glGetIntegerv(param, &x);
+    return x;
+}
+
+GLint glGetVertexAttrib(GLTraceContext *context, GLuint index, GLenum pname) {
+    GLint x;
+    context->hooks->gl.glGetVertexAttribiv(index, pname, &x);
+    return x;
+}
+
+bool isUsingPixelBuffers(GLTraceContext *context) {
+    if (context->getVersionMajor() < 3) {
+        return false; // PBOs not supported prior to GLES 3.0
+    }
+    return glGetInteger(context, GL_PIXEL_UNPACK_BUFFER_BINDING) != 0;
+}
+
+bool isUsingArrayBuffers(GLTraceContext *context) {
+    return glGetInteger(context, GL_ARRAY_BUFFER_BINDING) != 0;
+}
+
+bool isUsingElementArrayBuffers(GLTraceContext *context) {
+    return glGetInteger(context, GL_ELEMENT_ARRAY_BUFFER_BINDING) != 0;
+}
+
 unsigned getBytesPerTexel(const GLenum format, const GLenum type) {
     /*
     Description from glTexImage2D spec:
@@ -156,7 +183,8 @@
 }
 
 /** Common fixup routing for glTexImage2D & glTexSubImage2D. */
-void fixup_glTexImage(int widthIndex, int heightIndex, GLMessage *glmsg, void *dataSrc) {
+void fixup_glTexImage(GLTraceContext *context, int widthIndex, int heightIndex, GLMessage *glmsg,
+                        void *dataSrc) {
     GLMessage_DataType arg_width  = glmsg->args(widthIndex);
     GLMessage_DataType arg_height = glmsg->args(heightIndex);
 
@@ -175,7 +203,7 @@
     arg_data->set_type(GLMessage::DataType::BYTE);
     arg_data->clear_rawbytes();
 
-    if (data != NULL) {
+    if (data != NULL && !isUsingPixelBuffers(context)) {
         arg_data->set_isarray(true);
         arg_data->add_rawbytes(data, bytesPerTexel * width * height);
     } else {
@@ -185,7 +213,7 @@
 }
 
 
-void fixup_glTexImage2D(GLMessage *glmsg, void *pointersToFixup[]) {
+void fixup_glTexImage2D(GLTraceContext *context, GLMessage *glmsg, void *pointersToFixup[]) {
     /* void glTexImage2D(GLenum target,
                         GLint level,
                         GLint internalformat,
@@ -198,10 +226,10 @@
     */
     int widthIndex = 3;
     int heightIndex = 4;
-    fixup_glTexImage(widthIndex, heightIndex, glmsg, pointersToFixup[0]);
+    fixup_glTexImage(context, widthIndex, heightIndex, glmsg, pointersToFixup[0]);
 }
 
-void fixup_glTexSubImage2D(GLMessage *glmsg, void *pointersToFixup[]) {
+void fixup_glTexSubImage2D(GLTraceContext *context, GLMessage *glmsg, void *pointersToFixup[]) {
     /*
     void glTexSubImage2D(GLenum target,
                         GLint level,
@@ -215,7 +243,62 @@
     */
     int widthIndex = 4;
     int heightIndex = 5;
-    fixup_glTexImage(widthIndex, heightIndex, glmsg, pointersToFixup[0]);
+    fixup_glTexImage(context, widthIndex, heightIndex, glmsg, pointersToFixup[0]);
+}
+
+void fixup_glCompressedTexImage2D(GLTraceContext *context, GLMessage *glmsg,
+                                    void *pointersToFixup[]) {
+    /* void glCompressedTexImage2D(GLenum target,
+                                   GLint level,
+                                   GLenum internalformat,
+                                   GLsizei width,
+                                   GLsizei height,
+                                   GLint border,
+                                   GLsizei imageSize,
+                                   const GLvoid* data);
+    */
+    GLsizei size  = glmsg->args(6).intvalue(0);
+    void *data = pointersToFixup[0];
+
+    GLMessage_DataType *arg_data  = glmsg->mutable_args(7);
+    arg_data->set_type(GLMessage::DataType::BYTE);
+    arg_data->clear_rawbytes();
+
+    if (data != NULL && !isUsingPixelBuffers(context)) {
+        arg_data->set_isarray(true);
+        arg_data->add_rawbytes(data, size);
+    } else {
+        arg_data->set_isarray(false);
+        arg_data->set_type(GLMessage::DataType::VOID);
+    }
+}
+
+void fixup_glCompressedTexSubImage2D(GLTraceContext *context, GLMessage *glmsg,
+                                        void *pointersToFixup[]) {
+    /* void glCompressedTexSubImage2D(GLenum target,
+                                      GLint level,
+                                      GLint xoffset,
+                                      GLint yoffset,
+                                      GLsizei width,
+                                      GLsizei height,
+                                      GLenum format,
+                                      GLsizei imageSize,
+                                      const GLvoid* data);
+    */
+    GLsizei size  = glmsg->args(7).intvalue(0);
+    void *data = pointersToFixup[0];
+
+    GLMessage_DataType *arg_data  = glmsg->mutable_args(8);
+    arg_data->set_type(GLMessage::DataType::BYTE);
+    arg_data->clear_rawbytes();
+
+    if (data != NULL && !isUsingPixelBuffers(context)) {
+        arg_data->set_isarray(true);
+        arg_data->add_rawbytes(data, size);
+    } else {
+        arg_data->set_isarray(false);
+        arg_data->set_type(GLMessage::DataType::VOID);
+    }
 }
 
 void fixup_glShaderSource(GLMessage *glmsg, void *pointersToFixup[]) {
@@ -244,14 +327,18 @@
     arg_strpp->add_charvalue(src);
 }
 
-void fixup_glUniformGenericInteger(int argIndex, int nIntegers, GLMessage *glmsg,
+void fixup_glUniformGenericInteger(int argIndex, int nElemsPerVector, GLMessage *glmsg,
                                                                     void *pointersToFixup[]) {
     /* void glUniform?iv(GLint location, GLsizei count, const GLint *value); */
-    fixup_GenericIntArray(argIndex, nIntegers, glmsg, pointersToFixup[0]);
+    GLMessage_DataType arg_count  = glmsg->args(1);
+    int n_vectors = arg_count.intvalue(0);
+    fixup_GenericIntArray(argIndex, nElemsPerVector * n_vectors, glmsg, pointersToFixup[0]);
 }
 
-void fixup_glUniformGeneric(int argIndex, int nFloats, GLMessage *glmsg, void *src) {
-    fixup_GenericFloatArray(argIndex, nFloats, glmsg, src);
+void fixup_glUniformGeneric(int argIndex, int nElemsPerVector, GLMessage *glmsg, void *src) {
+    GLMessage_DataType arg_count  = glmsg->args(1);
+    int n_vectors = arg_count.intvalue(0);
+    fixup_GenericFloatArray(argIndex, nElemsPerVector * n_vectors, glmsg, src);
 }
 
 void fixup_glUniformMatrixGeneric(int matrixSize, GLMessage *glmsg, void *pointersToFixup[]) {
@@ -379,26 +466,6 @@
     arg_location->add_intvalue(location);
 }
 
-GLint glGetInteger(GLTraceContext *context, GLenum param) {
-    GLint x;
-    context->hooks->gl.glGetIntegerv(param, &x);
-    return x;
-}
-
-GLint glGetVertexAttrib(GLTraceContext *context, GLuint index, GLenum pname) {
-    GLint x;
-    context->hooks->gl.glGetVertexAttribiv(index, pname, &x);
-    return x;
-}
-
-bool isUsingArrayBuffers(GLTraceContext *context) {
-    return glGetInteger(context, GL_ARRAY_BUFFER_BINDING) != 0;
-}
-
-bool isUsingElementArrayBuffers(GLTraceContext *context) {
-    return glGetInteger(context, GL_ELEMENT_ARRAY_BUFFER_BINDING) != 0;
-}
-
 /** Copy @len bytes of data from @src into the @dataIndex'th argument of the message. */
 void addGlBufferData(GLMessage *glmsg, int dataIndex, GLvoid *src, GLsizeiptr len) {
     GLMessage_DataType *arg_datap = glmsg->mutable_args(dataIndex);
@@ -752,12 +819,22 @@
         break;
     case GLMessage::glTexImage2D:
         if (context->getGlobalTraceState()->shouldCollectTextureDataOnGlTexImage()) {
-            fixup_glTexImage2D(glmsg, pointersToFixup);
+            fixup_glTexImage2D(context, glmsg, pointersToFixup);
         }
         break;
     case GLMessage::glTexSubImage2D:
         if (context->getGlobalTraceState()->shouldCollectTextureDataOnGlTexImage()) {
-            fixup_glTexSubImage2D(glmsg, pointersToFixup);
+            fixup_glTexSubImage2D(context, glmsg, pointersToFixup);
+        }
+        break;
+    case GLMessage::glCompressedTexImage2D:
+        if (context->getGlobalTraceState()->shouldCollectTextureDataOnGlTexImage()) {
+            fixup_glCompressedTexImage2D(context, glmsg, pointersToFixup);
+        }
+        break;
+    case GLMessage::glCompressedTexSubImage2D:
+        if (context->getGlobalTraceState()->shouldCollectTextureDataOnGlTexImage()) {
+            fixup_glCompressedTexSubImage2D(context, glmsg, pointersToFixup);
         }
         break;
     case GLMessage::glShaderSource:
diff --git a/opengl/libs/GLES_trace/src/gltrace_fixup.h b/opengl/libs/GLES_trace/src/gltrace_fixup.h
index fe30125..c90dbeb 100644
--- a/opengl/libs/GLES_trace/src/gltrace_fixup.h
+++ b/opengl/libs/GLES_trace/src/gltrace_fixup.h
@@ -19,7 +19,7 @@
 
 #include <utils/Timers.h>
 
-#include "gltrace.pb.h"
+#include "frameworks/native/opengl/libs/GLES_trace/proto/gltrace.pb.h"
 #include "gltrace_context.h"
 
 namespace android {
diff --git a/opengl/libs/GLES_trace/src/gltrace_transport.h b/opengl/libs/GLES_trace/src/gltrace_transport.h
index 9cf5b45..fd6cb8c 100644
--- a/opengl/libs/GLES_trace/src/gltrace_transport.h
+++ b/opengl/libs/GLES_trace/src/gltrace_transport.h
@@ -19,7 +19,7 @@
 
 #include <pthread.h>
 
-#include "gltrace.pb.h"
+#include "frameworks/native/opengl/libs/GLES_trace/proto/gltrace.pb.h"
 
 namespace android {
 namespace gltrace {
diff --git a/opengl/libs/GLES_trace/tools/genapi.py b/opengl/libs/GLES_trace/tools/genapi.py
index 76f7c78..c44b985 100755
--- a/opengl/libs/GLES_trace/tools/genapi.py
+++ b/opengl/libs/GLES_trace/tools/genapi.py
@@ -18,7 +18,7 @@
 #   This script is used to generate the trace implementations of all
 #   OpenGL calls. When executed, it reads the specs for the OpenGL calls
 #   from the files GLES2/gl2_api.in, GLES2/gl2ext_api.in, GLES_CM/gl_api.in,
-#   and GLES_CM/glext_api.in, and generates trace versions for all the 
+#   and GLES_CM/glext_api.in, and generates trace versions for all the
 #   defined functions.
 #
 # PREREQUISITES
@@ -103,11 +103,10 @@
     "GLint64":DataType.INT64,
     "GLuint64":DataType.INT64,
     "GLsync":DataType.POINTER,
+    "GLDEBUGPROCKHR":DataType.POINTER,
 }
 
 API_SPECS = [
-    ('GL3','../GLES2/gl3_api.in'),
-    ('GL3Ext','../GLES2/gl3ext_api.in'),
     ('GL2','../GLES2/gl2_api.in'),
     ('GL2Ext','../GLES2/gl2ext_api.in'),
     ('GL1','../GLES_CM/gl_api.in'),
@@ -136,7 +135,6 @@
 HEADER_INCLUDES = """
 #include <cutils/log.h>
 #include <utils/Timers.h>
-#include <GLES3/gl3.h>
 
 #include "gltrace.pb.h"
 #include "gltrace_context.h"
@@ -233,7 +231,7 @@
 
         # if name is a pointer (e.g. "*ptr"), then remove the "*" from the name
         # and add it to the data type
-        pointersInName = name.count("*")            
+        pointersInName = name.count("*")
         if pointersInName > 0:
             name = name.replace("*", "")
             dataType += "*" * pointersInName
@@ -269,7 +267,7 @@
     API_ENTRY_REGEX = "(.*)API_ENTRY\(.*?\)\((.*?)\)"
 
     # Regex to match CALL_GL_API specification:
-    #       e.g. CALL_GL_API(glCullFace, mode); 
+    #       e.g. CALL_GL_API(glCullFace, mode);
     #            CALL_GL_API_RETURN(glCreateProgram);
     CALL_GL_API_REGEX = "CALL_GL_API(_RETURN)?\((.*)\);"
 
@@ -281,7 +279,7 @@
         defn: specification line containing API_ENTRY macro
               e.g: void API_ENTRY(glActiveTexture)(GLenum texture) {
         callsite: specification line containing CALL_GL_API macro
-              e.g: CALL_GL_API(glActiveTexture, texture);        
+              e.g: CALL_GL_API(glActiveTexture, texture);
         """
         self.prefix = prefix
         self.ret = self.getReturnType(apientry)
@@ -297,7 +295,7 @@
         '''Extract the return type from the API_ENTRY specification'''
         m = re.search(self.API_ENTRY_REGEX, apientry)
         if not m:
-            raise ValueError("%s does not match API_ENTRY specification %s" 
+            raise ValueError("%s does not match API_ENTRY specification %s"
                              % (apientry, self.API_ENTRY_REGEX))
 
         return m.group(1).strip()
@@ -306,7 +304,7 @@
         '''Extract the argument list from the API_ENTRY specification'''
         m = re.search(self.API_ENTRY_REGEX, apientry)
         if not m:
-            raise ValueError("%s does not match API_ENTRY specification %s" 
+            raise ValueError("%s does not match API_ENTRY specification %s"
                              % (apientry, self.API_ENTRY_REGEX))
 
         return m.group(2).strip()
@@ -337,7 +335,7 @@
         return "%s GLTrace_%s(%s);" % (self.ret, self.func, self.arglist)
 
     def genCode(self):
-        return TRACE_CALL_TEMPLATE(func = self.func, 
+        return TRACE_CALL_TEMPLATE(func = self.func,
                                    retType = self.ret,
                                    retDataType = getDataTypeFromKw(self.ret),
                                    inputArgList = self.arglist,
diff --git a/opengl/libs/debug.in b/opengl/libs/debug.in
deleted file mode 100644
index 882b2da..0000000
--- a/opengl/libs/debug.in
+++ /dev/null
@@ -1,235 +0,0 @@
-// the following functions are not defined in GLESv2_dbg
-TRACE_GL_VOID(glAlphaFunc, (GLenum func, GLclampf ref), (func, ref), 2, "GLenum", func, "GLclampf", ref)
-TRACE_GL_VOID(glAlphaFuncx, (GLenum func, GLclampx ref), (func, ref), 2, "GLenum", func, "GLclampx", ref)
-TRACE_GL_VOID(glAlphaFuncxOES, (GLenum func, GLclampx ref), (func, ref), 2, "GLenum", func, "GLclampx", ref)
-TRACE_GL_VOID(glBeginPerfMonitorAMD, (GLuint monitor), (monitor), 1, "GLuint", monitor)
-TRACE_GL_VOID(glBindFramebufferOES, (GLenum target, GLuint framebuffer), (target, framebuffer), 2, "GLenum", target, "GLuint", framebuffer)
-TRACE_GL_VOID(glBindRenderbufferOES, (GLenum target, GLuint renderbuffer), (target, renderbuffer), 2, "GLenum", target, "GLuint", renderbuffer)
-TRACE_GL_VOID(glBindVertexArrayOES, (GLuint array), (array), 1, "GLuint", array)
-TRACE_GL_VOID(glBlendEquationOES, (GLenum mode), (mode), 1, "GLenum", mode)
-TRACE_GL_VOID(glBlendEquationSeparateOES, (GLenum modeRGB, GLenum modeAlpha), (modeRGB, modeAlpha), 2, "GLenum", modeRGB, "GLenum", modeAlpha)
-TRACE_GL_VOID(glBlendFuncSeparateOES, (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha), (srcRGB, dstRGB, srcAlpha, dstAlpha), 4, "GLenum", srcRGB, "GLenum", dstRGB, "GLenum", srcAlpha, "GLenum", dstAlpha)
-TRACE_GL(GLenum, glCheckFramebufferStatusOES, (GLenum target), (target), 1, "GLenum", target)
-TRACE_GL_VOID(glClearColorx, (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha), (red, green, blue, alpha), 4, "GLclampx", red, "GLclampx", green, "GLclampx", blue, "GLclampx", alpha)
-TRACE_GL_VOID(glClearColorxOES, (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha), (red, green, blue, alpha), 4, "GLclampx", red, "GLclampx", green, "GLclampx", blue, "GLclampx", alpha)
-TRACE_GL_VOID(glClearDepthfOES, (GLclampf depth), (depth), 1, "GLclampf", depth)
-TRACE_GL_VOID(glClearDepthx, (GLclampx depth), (depth), 1, "GLclampx", depth)
-TRACE_GL_VOID(glClearDepthxOES, (GLclampx depth), (depth), 1, "GLclampx", depth)
-TRACE_GL_VOID(glClientActiveTexture, (GLenum texture), (texture), 1, "GLenum", texture)
-TRACE_GL_VOID(glClipPlanef, (GLenum plane, const GLfloat *equation), (plane, equation), 2, "GLenum", plane, "const GLfloat *", equation)
-TRACE_GL_VOID(glClipPlanefIMG, (GLenum p, const GLfloat *eqn), (p, eqn), 2, "GLenum", p, "const GLfloat *", eqn)
-TRACE_GL_VOID(glClipPlanefOES, (GLenum plane, const GLfloat *equation), (plane, equation), 2, "GLenum", plane, "const GLfloat *", equation)
-TRACE_GL_VOID(glClipPlanex, (GLenum plane, const GLfixed *equation), (plane, equation), 2, "GLenum", plane, "const GLfixed *", equation)
-TRACE_GL_VOID(glClipPlanexIMG, (GLenum p, const GLfixed *eqn), (p, eqn), 2, "GLenum", p, "const GLfixed *", eqn)
-TRACE_GL_VOID(glClipPlanexOES, (GLenum plane, const GLfixed *equation), (plane, equation), 2, "GLenum", plane, "const GLfixed *", equation)
-TRACE_GL_VOID(glColor4f, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha), (red, green, blue, alpha), 4, "GLfloat", red, "GLfloat", green, "GLfloat", blue, "GLfloat", alpha)
-TRACE_GL_VOID(glColor4ub, (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha), (red, green, blue, alpha), 4, "GLubyte", red, "GLubyte", green, "GLubyte", blue, "GLubyte", alpha)
-TRACE_GL_VOID(glColor4x, (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha), (red, green, blue, alpha), 4, "GLfixed", red, "GLfixed", green, "GLfixed", blue, "GLfixed", alpha)
-TRACE_GL_VOID(glColor4xOES, (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha), (red, green, blue, alpha), 4, "GLfixed", red, "GLfixed", green, "GLfixed", blue, "GLfixed", alpha)
-TRACE_GL_VOID(glColorPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer), (size, type, stride, pointer), 4, "GLint", size, "GLenum", type, "GLsizei", stride, "const GLvoid *", pointer)
-TRACE_GL_VOID(glCompressedTexImage3DOES, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data), (target, level, internalformat, width, height, depth, border, imageSize, data), 9, "GLenum", target, "GLint", level, "GLenum", internalformat, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLint", border, "GLsizei", imageSize, "const GLvoid*", data)
-TRACE_GL_VOID(glCompressedTexSubImage3DOES, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data), (target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data), 11, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", zoffset, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLenum", format, "GLsizei", imageSize, "const GLvoid*", data)
-TRACE_GL_VOID(glCopyTexSubImage3DOES, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height), (target, level, xoffset, yoffset, zoffset, x, y, width, height), 9, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", zoffset, "GLint", x, "GLint", y, "GLsizei", width, "GLsizei", height)
-TRACE_GL_VOID(glCoverageMaskNV, (GLboolean mask), (mask), 1, "GLboolean", mask)
-TRACE_GL_VOID(glCoverageOperationNV, (GLenum operation), (operation), 1, "GLenum", operation)
-TRACE_GL_VOID(glCurrentPaletteMatrixOES, (GLuint matrixpaletteindex), (matrixpaletteindex), 1, "GLuint", matrixpaletteindex)
-TRACE_GL_VOID(glDeleteFencesNV, (GLsizei n, const GLuint *fences), (n, fences), 2, "GLsizei", n, "const GLuint *", fences)
-TRACE_GL_VOID(glDeleteFramebuffersOES, (GLsizei n, const GLuint* framebuffers), (n, framebuffers), 2, "GLsizei", n, "const GLuint*", framebuffers)
-TRACE_GL_VOID(glDeletePerfMonitorsAMD, (GLsizei n, GLuint *monitors), (n, monitors), 2, "GLsizei", n, "GLuint *", monitors)
-TRACE_GL_VOID(glDeleteRenderbuffersOES, (GLsizei n, const GLuint* renderbuffers), (n, renderbuffers), 2, "GLsizei", n, "const GLuint*", renderbuffers)
-TRACE_GL_VOID(glDeleteVertexArraysOES, (GLsizei n, const GLuint *arrays), (n, arrays), 2, "GLsizei", n, "const GLuint *", arrays)
-TRACE_GL_VOID(glDepthRangefOES, (GLclampf zNear, GLclampf zFar), (zNear, zFar), 2, "GLclampf", zNear, "GLclampf", zFar)
-TRACE_GL_VOID(glDepthRangex, (GLclampx zNear, GLclampx zFar), (zNear, zFar), 2, "GLclampx", zNear, "GLclampx", zFar)
-TRACE_GL_VOID(glDepthRangexOES, (GLclampx zNear, GLclampx zFar), (zNear, zFar), 2, "GLclampx", zNear, "GLclampx", zFar)
-TRACE_GL_VOID(glDisableClientState, (GLenum array), (array), 1, "GLenum", array)
-TRACE_GL_VOID(glDisableDriverControlQCOM, (GLuint driverControl), (driverControl), 1, "GLuint", driverControl)
-TRACE_GL_VOID(glDiscardFramebufferEXT, (GLenum target, GLsizei numAttachments, const GLenum *attachments), (target, numAttachments, attachments), 3, "GLenum", target, "GLsizei", numAttachments, "const GLenum *", attachments)
-TRACE_GL_VOID(glDrawTexfOES, (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height), (x, y, z, width, height), 5, "GLfloat", x, "GLfloat", y, "GLfloat", z, "GLfloat", width, "GLfloat", height)
-TRACE_GL_VOID(glDrawTexfvOES, (const GLfloat *coords), (coords), 1, "const GLfloat *", coords)
-TRACE_GL_VOID(glDrawTexiOES, (GLint x, GLint y, GLint z, GLint width, GLint height), (x, y, z, width, height), 5, "GLint", x, "GLint", y, "GLint", z, "GLint", width, "GLint", height)
-TRACE_GL_VOID(glDrawTexivOES, (const GLint *coords), (coords), 1, "const GLint *", coords)
-TRACE_GL_VOID(glDrawTexsOES, (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height), (x, y, z, width, height), 5, "GLshort", x, "GLshort", y, "GLshort", z, "GLshort", width, "GLshort", height)
-TRACE_GL_VOID(glDrawTexsvOES, (const GLshort *coords), (coords), 1, "const GLshort *", coords)
-TRACE_GL_VOID(glDrawTexxOES, (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height), (x, y, z, width, height), 5, "GLfixed", x, "GLfixed", y, "GLfixed", z, "GLfixed", width, "GLfixed", height)
-TRACE_GL_VOID(glDrawTexxvOES, (const GLfixed *coords), (coords), 1, "const GLfixed *", coords)
-TRACE_GL_VOID(glEGLImageTargetRenderbufferStorageOES, (GLenum target, GLeglImageOES image), (target, image), 2, "GLenum", target, "GLeglImageOES", image)
-TRACE_GL_VOID(glEGLImageTargetTexture2DOES, (GLenum target, GLeglImageOES image), (target, image), 2, "GLenum", target, "GLeglImageOES", image)
-TRACE_GL_VOID(glEnableClientState, (GLenum array), (array), 1, "GLenum", array)
-TRACE_GL_VOID(glEnableDriverControlQCOM, (GLuint driverControl), (driverControl), 1, "GLuint", driverControl)
-TRACE_GL_VOID(glEndPerfMonitorAMD, (GLuint monitor), (monitor), 1, "GLuint", monitor)
-TRACE_GL_VOID(glEndTilingQCOM, (GLbitfield preserveMask), (preserveMask), 1, "GLbitfield", preserveMask)
-TRACE_GL_VOID(glExtGetBufferPointervQCOM, (GLenum target, GLvoid **params), (target, params), 2, "GLenum", target, "GLvoid **", params)
-TRACE_GL_VOID(glExtGetBuffersQCOM, (GLuint *buffers, GLint maxBuffers, GLint *numBuffers), (buffers, maxBuffers, numBuffers), 3, "GLuint *", buffers, "GLint", maxBuffers, "GLint *", numBuffers)
-TRACE_GL_VOID(glExtGetFramebuffersQCOM, (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers), (framebuffers, maxFramebuffers, numFramebuffers), 3, "GLuint *", framebuffers, "GLint", maxFramebuffers, "GLint *", numFramebuffers)
-TRACE_GL_VOID(glExtGetProgramBinarySourceQCOM, (GLuint program, GLenum shadertype, GLchar *source, GLint *length), (program, shadertype, source, length), 4, "GLuint", program, "GLenum", shadertype, "GLchar *", source, "GLint *", length)
-TRACE_GL_VOID(glExtGetProgramsQCOM, (GLuint *programs, GLint maxPrograms, GLint *numPrograms), (programs, maxPrograms, numPrograms), 3, "GLuint *", programs, "GLint", maxPrograms, "GLint *", numPrograms)
-TRACE_GL_VOID(glExtGetRenderbuffersQCOM, (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers), (renderbuffers, maxRenderbuffers, numRenderbuffers), 3, "GLuint *", renderbuffers, "GLint", maxRenderbuffers, "GLint *", numRenderbuffers)
-TRACE_GL_VOID(glExtGetShadersQCOM, (GLuint *shaders, GLint maxShaders, GLint *numShaders), (shaders, maxShaders, numShaders), 3, "GLuint *", shaders, "GLint", maxShaders, "GLint *", numShaders)
-TRACE_GL_VOID(glExtGetTexLevelParameterivQCOM, (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params), (texture, face, level, pname, params), 5, "GLuint", texture, "GLenum", face, "GLint", level, "GLenum", pname, "GLint *", params)
-TRACE_GL_VOID(glExtGetTexSubImageQCOM, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels), (target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, texels), 11, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", zoffset, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLenum", format, "GLenum", type, "GLvoid *", texels)
-TRACE_GL_VOID(glExtGetTexturesQCOM, (GLuint *textures, GLint maxTextures, GLint *numTextures), (textures, maxTextures, numTextures), 3, "GLuint *", textures, "GLint", maxTextures, "GLint *", numTextures)
-TRACE_GL(GLboolean, glExtIsProgramBinaryQCOM, (GLuint program), (program), 1, "GLuint", program)
-TRACE_GL_VOID(glExtTexObjectStateOverrideiQCOM, (GLenum target, GLenum pname, GLint param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLint", param)
-TRACE_GL_VOID(glFinishFenceNV, (GLuint fence), (fence), 1, "GLuint", fence)
-TRACE_GL_VOID(glFogf, (GLenum pname, GLfloat param), (pname, param), 2, "GLenum", pname, "GLfloat", param)
-TRACE_GL_VOID(glFogfv, (GLenum pname, const GLfloat *params), (pname, params), 2, "GLenum", pname, "const GLfloat *", params)
-TRACE_GL_VOID(glFogx, (GLenum pname, GLfixed param), (pname, param), 2, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glFogxOES, (GLenum pname, GLfixed param), (pname, param), 2, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glFogxv, (GLenum pname, const GLfixed *params), (pname, params), 2, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glFogxvOES, (GLenum pname, const GLfixed *params), (pname, params), 2, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glFramebufferRenderbufferOES, (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer), (target, attachment, renderbuffertarget, renderbuffer), 4, "GLenum", target, "GLenum", attachment, "GLenum", renderbuffertarget, "GLuint", renderbuffer)
-TRACE_GL_VOID(glFramebufferTexture2DMultisampleIMG, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples), (target, attachment, textarget, texture, level, samples), 6, "GLenum", target, "GLenum", attachment, "GLenum", textarget, "GLuint", texture, "GLint", level, "GLsizei", samples)
-TRACE_GL_VOID(glFramebufferTexture2DOES, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level), (target, attachment, textarget, texture, level), 5, "GLenum", target, "GLenum", attachment, "GLenum", textarget, "GLuint", texture, "GLint", level)
-TRACE_GL_VOID(glFramebufferTexture3DOES, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset), (target, attachment, textarget, texture, level, zoffset), 6, "GLenum", target, "GLenum", attachment, "GLenum", textarget, "GLuint", texture, "GLint", level, "GLint", zoffset)
-TRACE_GL_VOID(glFrustumf, (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar), (left, right, bottom, top, zNear, zFar), 6, "GLfloat", left, "GLfloat", right, "GLfloat", bottom, "GLfloat", top, "GLfloat", zNear, "GLfloat", zFar)
-TRACE_GL_VOID(glFrustumfOES, (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar), (left, right, bottom, top, zNear, zFar), 6, "GLfloat", left, "GLfloat", right, "GLfloat", bottom, "GLfloat", top, "GLfloat", zNear, "GLfloat", zFar)
-TRACE_GL_VOID(glFrustumx, (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar), (left, right, bottom, top, zNear, zFar), 6, "GLfixed", left, "GLfixed", right, "GLfixed", bottom, "GLfixed", top, "GLfixed", zNear, "GLfixed", zFar)
-TRACE_GL_VOID(glFrustumxOES, (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar), (left, right, bottom, top, zNear, zFar), 6, "GLfixed", left, "GLfixed", right, "GLfixed", bottom, "GLfixed", top, "GLfixed", zNear, "GLfixed", zFar)
-TRACE_GL_VOID(glGenFencesNV, (GLsizei n, GLuint *fences), (n, fences), 2, "GLsizei", n, "GLuint *", fences)
-TRACE_GL_VOID(glGenFramebuffersOES, (GLsizei n, GLuint* framebuffers), (n, framebuffers), 2, "GLsizei", n, "GLuint*", framebuffers)
-TRACE_GL_VOID(glGenPerfMonitorsAMD, (GLsizei n, GLuint *monitors), (n, monitors), 2, "GLsizei", n, "GLuint *", monitors)
-TRACE_GL_VOID(glGenRenderbuffersOES, (GLsizei n, GLuint* renderbuffers), (n, renderbuffers), 2, "GLsizei", n, "GLuint*", renderbuffers)
-TRACE_GL_VOID(glGenVertexArraysOES, (GLsizei n, GLuint *arrays), (n, arrays), 2, "GLsizei", n, "GLuint *", arrays)
-TRACE_GL_VOID(glGenerateMipmapOES, (GLenum target), (target), 1, "GLenum", target)
-TRACE_GL_VOID(glGetBufferPointervOES, (GLenum target, GLenum pname, GLvoid ** params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLvoid **", params)
-TRACE_GL_VOID(glGetClipPlanef, (GLenum pname, GLfloat eqn[4]), (pname, eqn), 2, "GLenum", pname, "GLfloat", eqn)
-TRACE_GL_VOID(glGetClipPlanefOES, (GLenum pname, GLfloat eqn[4]), (pname, eqn), 2, "GLenum", pname, "GLfloat", eqn)
-TRACE_GL_VOID(glGetClipPlanex, (GLenum pname, GLfixed eqn[4]), (pname, eqn), 2, "GLenum", pname, "GLfixed", eqn)
-TRACE_GL_VOID(glGetClipPlanexOES, (GLenum pname, GLfixed eqn[4]), (pname, eqn), 2, "GLenum", pname, "GLfixed", eqn)
-TRACE_GL_VOID(glGetDriverControlStringQCOM, (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString), (driverControl, bufSize, length, driverControlString), 4, "GLuint", driverControl, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", driverControlString)
-TRACE_GL_VOID(glGetDriverControlsQCOM, (GLint *num, GLsizei size, GLuint *driverControls), (num, size, driverControls), 3, "GLint *", num, "GLsizei", size, "GLuint *", driverControls)
-TRACE_GL_VOID(glGetFenceivNV, (GLuint fence, GLenum pname, GLint *params), (fence, pname, params), 3, "GLuint", fence, "GLenum", pname, "GLint *", params)
-TRACE_GL_VOID(glGetFixedv, (GLenum pname, GLfixed *params), (pname, params), 2, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetFixedvOES, (GLenum pname, GLfixed *params), (pname, params), 2, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetFramebufferAttachmentParameterivOES, (GLenum target, GLenum attachment, GLenum pname, GLint* params), (target, attachment, pname, params), 4, "GLenum", target, "GLenum", attachment, "GLenum", pname, "GLint*", params)
-TRACE_GL_VOID(glGetLightfv, (GLenum light, GLenum pname, GLfloat *params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "GLfloat *", params)
-TRACE_GL_VOID(glGetLightxv, (GLenum light, GLenum pname, GLfixed *params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetLightxvOES, (GLenum light, GLenum pname, GLfixed *params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetMaterialfv, (GLenum face, GLenum pname, GLfloat *params), (face, pname, params), 3, "GLenum", face, "GLenum", pname, "GLfloat *", params)
-TRACE_GL_VOID(glGetMaterialxv, (GLenum face, GLenum pname, GLfixed *params), (face, pname, params), 3, "GLenum", face, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetMaterialxvOES, (GLenum face, GLenum pname, GLfixed *params), (face, pname, params), 3, "GLenum", face, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetPerfMonitorCounterDataAMD, (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten), (monitor, pname, dataSize, data, bytesWritten), 5, "GLuint", monitor, "GLenum", pname, "GLsizei", dataSize, "GLuint *", data, "GLint *", bytesWritten)
-TRACE_GL_VOID(glGetPerfMonitorCounterInfoAMD, (GLuint group, GLuint counter, GLenum pname, GLvoid *data), (group, counter, pname, data), 4, "GLuint", group, "GLuint", counter, "GLenum", pname, "GLvoid *", data)
-TRACE_GL_VOID(glGetPerfMonitorCounterStringAMD, (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString), (group, counter, bufSize, length, counterString), 5, "GLuint", group, "GLuint", counter, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", counterString)
-TRACE_GL_VOID(glGetPerfMonitorCountersAMD, (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters), (group, numCounters, maxActiveCounters, counterSize, counters), 5, "GLuint", group, "GLint *", numCounters, "GLint *", maxActiveCounters, "GLsizei", counterSize, "GLuint *", counters)
-TRACE_GL_VOID(glGetPerfMonitorGroupStringAMD, (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString), (group, bufSize, length, groupString), 4, "GLuint", group, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", groupString)
-TRACE_GL_VOID(glGetPerfMonitorGroupsAMD, (GLint *numGroups, GLsizei groupsSize, GLuint *groups), (numGroups, groupsSize, groups), 3, "GLint *", numGroups, "GLsizei", groupsSize, "GLuint *", groups)
-TRACE_GL_VOID(glGetPointerv, (GLenum pname, GLvoid **params), (pname, params), 2, "GLenum", pname, "GLvoid **", params)
-TRACE_GL_VOID(glGetProgramBinaryOES, (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary), (program, bufSize, length, binaryFormat, binary), 5, "GLuint", program, "GLsizei", bufSize, "GLsizei *", length, "GLenum *", binaryFormat, "GLvoid *", binary)
-TRACE_GL_VOID(glGetRenderbufferParameterivOES, (GLenum target, GLenum pname, GLint* params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint*", params)
-TRACE_GL_VOID(glGetTexEnvfv, (GLenum env, GLenum pname, GLfloat *params), (env, pname, params), 3, "GLenum", env, "GLenum", pname, "GLfloat *", params)
-TRACE_GL_VOID(glGetTexEnviv, (GLenum env, GLenum pname, GLint *params), (env, pname, params), 3, "GLenum", env, "GLenum", pname, "GLint *", params)
-TRACE_GL_VOID(glGetTexEnvxv, (GLenum env, GLenum pname, GLfixed *params), (env, pname, params), 3, "GLenum", env, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetTexEnvxvOES, (GLenum env, GLenum pname, GLfixed *params), (env, pname, params), 3, "GLenum", env, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetTexGenfvOES, (GLenum coord, GLenum pname, GLfloat *params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "GLfloat *", params)
-TRACE_GL_VOID(glGetTexGenivOES, (GLenum coord, GLenum pname, GLint *params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "GLint *", params)
-TRACE_GL_VOID(glGetTexGenxvOES, (GLenum coord, GLenum pname, GLfixed *params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetTexParameterxv, (GLenum target, GLenum pname, GLfixed *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetTexParameterxvOES, (GLenum target, GLenum pname, GLfixed *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLfixed *", params)
-TRACE_GL(GLboolean, glIsFenceNV, (GLuint fence), (fence), 1, "GLuint", fence)
-TRACE_GL(GLboolean, glIsFramebufferOES, (GLuint framebuffer), (framebuffer), 1, "GLuint", framebuffer)
-TRACE_GL(GLboolean, glIsRenderbufferOES, (GLuint renderbuffer), (renderbuffer), 1, "GLuint", renderbuffer)
-TRACE_GL(GLboolean, glIsVertexArrayOES, (GLuint array), (array), 1, "GLuint", array)
-TRACE_GL_VOID(glLightModelf, (GLenum pname, GLfloat param), (pname, param), 2, "GLenum", pname, "GLfloat", param)
-TRACE_GL_VOID(glLightModelfv, (GLenum pname, const GLfloat *params), (pname, params), 2, "GLenum", pname, "const GLfloat *", params)
-TRACE_GL_VOID(glLightModelx, (GLenum pname, GLfixed param), (pname, param), 2, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glLightModelxOES, (GLenum pname, GLfixed param), (pname, param), 2, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glLightModelxv, (GLenum pname, const GLfixed *params), (pname, params), 2, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glLightModelxvOES, (GLenum pname, const GLfixed *params), (pname, params), 2, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glLightf, (GLenum light, GLenum pname, GLfloat param), (light, pname, param), 3, "GLenum", light, "GLenum", pname, "GLfloat", param)
-TRACE_GL_VOID(glLightfv, (GLenum light, GLenum pname, const GLfloat *params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "const GLfloat *", params)
-TRACE_GL_VOID(glLightx, (GLenum light, GLenum pname, GLfixed param), (light, pname, param), 3, "GLenum", light, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glLightxOES, (GLenum light, GLenum pname, GLfixed param), (light, pname, param), 3, "GLenum", light, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glLightxv, (GLenum light, GLenum pname, const GLfixed *params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glLightxvOES, (GLenum light, GLenum pname, const GLfixed *params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glLineWidthx, (GLfixed width), (width), 1, "GLfixed", width)
-TRACE_GL_VOID(glLineWidthxOES, (GLfixed width), (width), 1, "GLfixed", width)
-TRACE_GL_VOID(glLoadIdentity, (void), (), 0)
-TRACE_GL_VOID(glLoadMatrixf, (const GLfloat *m), (m), 1, "const GLfloat *", m)
-TRACE_GL_VOID(glLoadMatrixx, (const GLfixed *m), (m), 1, "const GLfixed *", m)
-TRACE_GL_VOID(glLoadMatrixxOES, (const GLfixed *m), (m), 1, "const GLfixed *", m)
-TRACE_GL_VOID(glLoadPaletteFromModelViewMatrixOES, (void), (), 0)
-TRACE_GL_VOID(glLogicOp, (GLenum opcode), (opcode), 1, "GLenum", opcode)
-TRACE_GL(void*, glMapBufferOES, (GLenum target, GLenum access), (target, access), 2, "GLenum", target, "GLenum", access)
-TRACE_GL_VOID(glMaterialf, (GLenum face, GLenum pname, GLfloat param), (face, pname, param), 3, "GLenum", face, "GLenum", pname, "GLfloat", param)
-TRACE_GL_VOID(glMaterialfv, (GLenum face, GLenum pname, const GLfloat *params), (face, pname, params), 3, "GLenum", face, "GLenum", pname, "const GLfloat *", params)
-TRACE_GL_VOID(glMaterialx, (GLenum face, GLenum pname, GLfixed param), (face, pname, param), 3, "GLenum", face, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glMaterialxOES, (GLenum face, GLenum pname, GLfixed param), (face, pname, param), 3, "GLenum", face, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glMaterialxv, (GLenum face, GLenum pname, const GLfixed *params), (face, pname, params), 3, "GLenum", face, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glMaterialxvOES, (GLenum face, GLenum pname, const GLfixed *params), (face, pname, params), 3, "GLenum", face, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glMatrixIndexPointerOES, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer), (size, type, stride, pointer), 4, "GLint", size, "GLenum", type, "GLsizei", stride, "const GLvoid *", pointer)
-TRACE_GL_VOID(glMatrixMode, (GLenum mode), (mode), 1, "GLenum", mode)
-TRACE_GL_VOID(glMultMatrixf, (const GLfloat *m), (m), 1, "const GLfloat *", m)
-TRACE_GL_VOID(glMultMatrixx, (const GLfixed *m), (m), 1, "const GLfixed *", m)
-TRACE_GL_VOID(glMultMatrixxOES, (const GLfixed *m), (m), 1, "const GLfixed *", m)
-TRACE_GL_VOID(glMultiDrawArraysEXT, (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount), (mode, first, count, primcount), 4, "GLenum", mode, "GLint *", first, "GLsizei *", count, "GLsizei", primcount)
-TRACE_GL_VOID(glMultiDrawElementsEXT, (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount), (mode, count, type, indices, primcount), 5, "GLenum", mode, "const GLsizei *", count, "GLenum", type, "const GLvoid* *", indices, "GLsizei", primcount)
-TRACE_GL_VOID(glMultiTexCoord4f, (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q), (target, s, t, r, q), 5, "GLenum", target, "GLfloat", s, "GLfloat", t, "GLfloat", r, "GLfloat", q)
-TRACE_GL_VOID(glMultiTexCoord4x, (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q), (target, s, t, r, q), 5, "GLenum", target, "GLfixed", s, "GLfixed", t, "GLfixed", r, "GLfixed", q)
-TRACE_GL_VOID(glMultiTexCoord4xOES, (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q), (target, s, t, r, q), 5, "GLenum", target, "GLfixed", s, "GLfixed", t, "GLfixed", r, "GLfixed", q)
-TRACE_GL_VOID(glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz), (nx, ny, nz), 3, "GLfloat", nx, "GLfloat", ny, "GLfloat", nz)
-TRACE_GL_VOID(glNormal3x, (GLfixed nx, GLfixed ny, GLfixed nz), (nx, ny, nz), 3, "GLfixed", nx, "GLfixed", ny, "GLfixed", nz)
-TRACE_GL_VOID(glNormal3xOES, (GLfixed nx, GLfixed ny, GLfixed nz), (nx, ny, nz), 3, "GLfixed", nx, "GLfixed", ny, "GLfixed", nz)
-TRACE_GL_VOID(glNormalPointer, (GLenum type, GLsizei stride, const GLvoid *pointer), (type, stride, pointer), 3, "GLenum", type, "GLsizei", stride, "const GLvoid *", pointer)
-TRACE_GL_VOID(glOrthof, (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar), (left, right, bottom, top, zNear, zFar), 6, "GLfloat", left, "GLfloat", right, "GLfloat", bottom, "GLfloat", top, "GLfloat", zNear, "GLfloat", zFar)
-TRACE_GL_VOID(glOrthofOES, (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar), (left, right, bottom, top, zNear, zFar), 6, "GLfloat", left, "GLfloat", right, "GLfloat", bottom, "GLfloat", top, "GLfloat", zNear, "GLfloat", zFar)
-TRACE_GL_VOID(glOrthox, (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar), (left, right, bottom, top, zNear, zFar), 6, "GLfixed", left, "GLfixed", right, "GLfixed", bottom, "GLfixed", top, "GLfixed", zNear, "GLfixed", zFar)
-TRACE_GL_VOID(glOrthoxOES, (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar), (left, right, bottom, top, zNear, zFar), 6, "GLfixed", left, "GLfixed", right, "GLfixed", bottom, "GLfixed", top, "GLfixed", zNear, "GLfixed", zFar)
-TRACE_GL_VOID(glPointParameterf, (GLenum pname, GLfloat param), (pname, param), 2, "GLenum", pname, "GLfloat", param)
-TRACE_GL_VOID(glPointParameterfv, (GLenum pname, const GLfloat *params), (pname, params), 2, "GLenum", pname, "const GLfloat *", params)
-TRACE_GL_VOID(glPointParameterx, (GLenum pname, GLfixed param), (pname, param), 2, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glPointParameterxOES, (GLenum pname, GLfixed param), (pname, param), 2, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glPointParameterxv, (GLenum pname, const GLfixed *params), (pname, params), 2, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glPointParameterxvOES, (GLenum pname, const GLfixed *params), (pname, params), 2, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glPointSize, (GLfloat size), (size), 1, "GLfloat", size)
-TRACE_GL_VOID(glPointSizePointerOES, (GLenum type, GLsizei stride, const GLvoid *pointer), (type, stride, pointer), 3, "GLenum", type, "GLsizei", stride, "const GLvoid *", pointer)
-TRACE_GL_VOID(glPointSizex, (GLfixed size), (size), 1, "GLfixed", size)
-TRACE_GL_VOID(glPointSizexOES, (GLfixed size), (size), 1, "GLfixed", size)
-TRACE_GL_VOID(glPolygonOffsetx, (GLfixed factor, GLfixed units), (factor, units), 2, "GLfixed", factor, "GLfixed", units)
-TRACE_GL_VOID(glPolygonOffsetxOES, (GLfixed factor, GLfixed units), (factor, units), 2, "GLfixed", factor, "GLfixed", units)
-TRACE_GL_VOID(glPopMatrix, (void), (), 0)
-TRACE_GL_VOID(glProgramBinaryOES, (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length), (program, binaryFormat, binary, length), 4, "GLuint", program, "GLenum", binaryFormat, "const GLvoid *", binary, "GLint", length)
-TRACE_GL_VOID(glPushMatrix, (void), (), 0)
-TRACE_GL(GLbitfield, glQueryMatrixxOES, (GLfixed mantissa[16], GLint exponent[16]), (mantissa, exponent), 2, "GLfixed", mantissa, "GLint", exponent)
-TRACE_GL_VOID(glRenderbufferStorageMultisampleIMG, (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height), (target, samples, internalformat, width, height), 5, "GLenum", target, "GLsizei", samples, "GLenum", internalformat, "GLsizei", width, "GLsizei", height)
-TRACE_GL_VOID(glRenderbufferStorageOES, (GLenum target, GLenum internalformat, GLsizei width, GLsizei height), (target, internalformat, width, height), 4, "GLenum", target, "GLenum", internalformat, "GLsizei", width, "GLsizei", height)
-TRACE_GL_VOID(glRotatef, (GLfloat angle, GLfloat x, GLfloat y, GLfloat z), (angle, x, y, z), 4, "GLfloat", angle, "GLfloat", x, "GLfloat", y, "GLfloat", z)
-TRACE_GL_VOID(glRotatex, (GLfixed angle, GLfixed x, GLfixed y, GLfixed z), (angle, x, y, z), 4, "GLfixed", angle, "GLfixed", x, "GLfixed", y, "GLfixed", z)
-TRACE_GL_VOID(glRotatexOES, (GLfixed angle, GLfixed x, GLfixed y, GLfixed z), (angle, x, y, z), 4, "GLfixed", angle, "GLfixed", x, "GLfixed", y, "GLfixed", z)
-TRACE_GL_VOID(glSampleCoveragex, (GLclampx value, GLboolean invert), (value, invert), 2, "GLclampx", value, "GLboolean", invert)
-TRACE_GL_VOID(glSampleCoveragexOES, (GLclampx value, GLboolean invert), (value, invert), 2, "GLclampx", value, "GLboolean", invert)
-TRACE_GL_VOID(glScalef, (GLfloat x, GLfloat y, GLfloat z), (x, y, z), 3, "GLfloat", x, "GLfloat", y, "GLfloat", z)
-TRACE_GL_VOID(glScalex, (GLfixed x, GLfixed y, GLfixed z), (x, y, z), 3, "GLfixed", x, "GLfixed", y, "GLfixed", z)
-TRACE_GL_VOID(glScalexOES, (GLfixed x, GLfixed y, GLfixed z), (x, y, z), 3, "GLfixed", x, "GLfixed", y, "GLfixed", z)
-TRACE_GL_VOID(glSelectPerfMonitorCountersAMD, (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList), (monitor, enable, group, numCounters, countersList), 5, "GLuint", monitor, "GLboolean", enable, "GLuint", group, "GLint", numCounters, "GLuint *", countersList)
-TRACE_GL_VOID(glSetFenceNV, (GLuint fence, GLenum condition), (fence, condition), 2, "GLuint", fence, "GLenum", condition)
-TRACE_GL_VOID(glShadeModel, (GLenum mode), (mode), 1, "GLenum", mode)
-TRACE_GL_VOID(glStartTilingQCOM, (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask), (x, y, width, height, preserveMask), 5, "GLuint", x, "GLuint", y, "GLuint", width, "GLuint", height, "GLbitfield", preserveMask)
-TRACE_GL(GLboolean, glTestFenceNV, (GLuint fence), (fence), 1, "GLuint", fence)
-TRACE_GL_VOID(glTexCoordPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer), (size, type, stride, pointer), 4, "GLint", size, "GLenum", type, "GLsizei", stride, "const GLvoid *", pointer)
-TRACE_GL_VOID(glTexEnvf, (GLenum target, GLenum pname, GLfloat param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLfloat", param)
-TRACE_GL_VOID(glTexEnvfv, (GLenum target, GLenum pname, const GLfloat *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfloat *", params)
-TRACE_GL_VOID(glTexEnvi, (GLenum target, GLenum pname, GLint param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLint", param)
-TRACE_GL_VOID(glTexEnviv, (GLenum target, GLenum pname, const GLint *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLint *", params)
-TRACE_GL_VOID(glTexEnvx, (GLenum target, GLenum pname, GLfixed param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glTexEnvxOES, (GLenum target, GLenum pname, GLfixed param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glTexEnvxv, (GLenum target, GLenum pname, const GLfixed *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glTexEnvxvOES, (GLenum target, GLenum pname, const GLfixed *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glTexGenfOES, (GLenum coord, GLenum pname, GLfloat param), (coord, pname, param), 3, "GLenum", coord, "GLenum", pname, "GLfloat", param)
-TRACE_GL_VOID(glTexGenfvOES, (GLenum coord, GLenum pname, const GLfloat *params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "const GLfloat *", params)
-TRACE_GL_VOID(glTexGeniOES, (GLenum coord, GLenum pname, GLint param), (coord, pname, param), 3, "GLenum", coord, "GLenum", pname, "GLint", param)
-TRACE_GL_VOID(glTexGenivOES, (GLenum coord, GLenum pname, const GLint *params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "const GLint *", params)
-TRACE_GL_VOID(glTexGenxOES, (GLenum coord, GLenum pname, GLfixed param), (coord, pname, param), 3, "GLenum", coord, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glTexGenxvOES, (GLenum coord, GLenum pname, const GLfixed *params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glTexImage3DOES, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels), (target, level, internalformat, width, height, depth, border, format, type, pixels), 10, "GLenum", target, "GLint", level, "GLenum", internalformat, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLint", border, "GLenum", format, "GLenum", type, "const GLvoid*", pixels)
-TRACE_GL_VOID(glTexParameterx, (GLenum target, GLenum pname, GLfixed param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glTexParameterxOES, (GLenum target, GLenum pname, GLfixed param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glTexParameterxv, (GLenum target, GLenum pname, const GLfixed *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glTexParameterxvOES, (GLenum target, GLenum pname, const GLfixed *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glTexSubImage3DOES, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels), (target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels), 11, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", zoffset, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLenum", format, "GLenum", type, "const GLvoid*", pixels)
-TRACE_GL_VOID(glTranslatef, (GLfloat x, GLfloat y, GLfloat z), (x, y, z), 3, "GLfloat", x, "GLfloat", y, "GLfloat", z)
-TRACE_GL_VOID(glTranslatex, (GLfixed x, GLfixed y, GLfixed z), (x, y, z), 3, "GLfixed", x, "GLfixed", y, "GLfixed", z)
-TRACE_GL_VOID(glTranslatexOES, (GLfixed x, GLfixed y, GLfixed z), (x, y, z), 3, "GLfixed", x, "GLfixed", y, "GLfixed", z)
-TRACE_GL(GLboolean, glUnmapBufferOES, (GLenum target), (target), 1, "GLenum", target)
-TRACE_GL_VOID(glVertexPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer), (size, type, stride, pointer), 4, "GLint", size, "GLenum", type, "GLsizei", stride, "const GLvoid *", pointer)
-TRACE_GL_VOID(glWeightPointerOES, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer), (size, type, stride, pointer), 4, "GLint", size, "GLenum", type, "GLsizei", stride, "const GLvoid *", pointer)
diff --git a/opengl/libs/egl_impl.h b/opengl/libs/egl_impl.h
index cb0e908..c0990ec 100644
--- a/opengl/libs/egl_impl.h
+++ b/opengl/libs/egl_impl.h
@@ -30,6 +30,9 @@
 // ----------------------------------------------------------------------------
 
 EGLAPI const GLubyte * egl_get_string_for_current_context(GLenum name);
+EGLAPI const GLubyte * egl_get_string_for_current_context(GLenum name,
+                                                          GLuint index);
+EGLAPI GLint egl_get_num_extensions_for_current_context();
 
 // ----------------------------------------------------------------------------
 }; // namespace android
diff --git a/opengl/libs/entries.in b/opengl/libs/entries.in
index 43c2676..0dee45d 100644
--- a/opengl/libs/entries.in
+++ b/opengl/libs/entries.in
@@ -1,20 +1,24 @@
+GL_ENTRY(void, glActiveShaderProgram, GLuint pipeline, GLuint program)
 GL_ENTRY(void, glActiveShaderProgramEXT, GLuint pipeline, GLuint program)
 GL_ENTRY(void, glActiveTexture, GLenum texture)
-GL_ENTRY(void, glAlphaFunc, GLenum func, GLclampf ref)
+GL_ENTRY(void, glAlphaFunc, GLenum func, GLfloat ref)
 GL_ENTRY(void, glAlphaFuncQCOM, GLenum func, GLclampf ref)
-GL_ENTRY(void, glAlphaFuncx, GLenum func, GLclampx ref)
-GL_ENTRY(void, glAlphaFuncxOES, GLenum func, GLclampx ref)
+GL_ENTRY(void, glAlphaFuncx, GLenum func, GLfixed ref)
+GL_ENTRY(void, glAlphaFuncxOES, GLenum func, GLfixed ref)
 GL_ENTRY(void, glAttachShader, GLuint program, GLuint shader)
 GL_ENTRY(void, glBeginPerfMonitorAMD, GLuint monitor)
+GL_ENTRY(void, glBeginPerfQueryINTEL, GLuint queryHandle)
 GL_ENTRY(void, glBeginQuery, GLenum target, GLuint id)
 GL_ENTRY(void, glBeginQueryEXT, GLenum target, GLuint id)
 GL_ENTRY(void, glBeginTransformFeedback, GLenum primitiveMode)
-GL_ENTRY(void, glBindAttribLocation, GLuint program, GLuint index, const GLchar* name)
+GL_ENTRY(void, glBindAttribLocation, GLuint program, GLuint index, const GLchar * name)
 GL_ENTRY(void, glBindBuffer, GLenum target, GLuint buffer)
 GL_ENTRY(void, glBindBufferBase, GLenum target, GLuint index, GLuint buffer)
 GL_ENTRY(void, glBindBufferRange, GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
 GL_ENTRY(void, glBindFramebuffer, GLenum target, GLuint framebuffer)
 GL_ENTRY(void, glBindFramebufferOES, GLenum target, GLuint framebuffer)
+GL_ENTRY(void, glBindImageTexture, GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format)
+GL_ENTRY(void, glBindProgramPipeline, GLuint pipeline)
 GL_ENTRY(void, glBindProgramPipelineEXT, GLuint pipeline)
 GL_ENTRY(void, glBindRenderbuffer, GLenum target, GLuint renderbuffer)
 GL_ENTRY(void, glBindRenderbufferOES, GLenum target, GLuint renderbuffer)
@@ -23,145 +27,185 @@
 GL_ENTRY(void, glBindTransformFeedback, GLenum target, GLuint id)
 GL_ENTRY(void, glBindVertexArray, GLuint array)
 GL_ENTRY(void, glBindVertexArrayOES, GLuint array)
-GL_ENTRY(void, glBlendColor, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
-GL_ENTRY(void, glBlendEquation,  GLenum mode )
+GL_ENTRY(void, glBindVertexBuffer, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride)
+GL_ENTRY(void, glBlendBarrierKHR, void)
+GL_ENTRY(void, glBlendBarrierNV, void)
+GL_ENTRY(void, glBlendColor, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
+GL_ENTRY(void, glBlendEquation, GLenum mode)
 GL_ENTRY(void, glBlendEquationOES, GLenum mode)
 GL_ENTRY(void, glBlendEquationSeparate, GLenum modeRGB, GLenum modeAlpha)
 GL_ENTRY(void, glBlendEquationSeparateOES, GLenum modeRGB, GLenum modeAlpha)
+GL_ENTRY(void, glBlendEquationSeparateiEXT, GLuint buf, GLenum modeRGB, GLenum modeAlpha)
+GL_ENTRY(void, glBlendEquationiEXT, GLuint buf, GLenum mode)
 GL_ENTRY(void, glBlendFunc, GLenum sfactor, GLenum dfactor)
-GL_ENTRY(void, glBlendFuncSeparate, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+GL_ENTRY(void, glBlendFuncSeparate, GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
 GL_ENTRY(void, glBlendFuncSeparateOES, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+GL_ENTRY(void, glBlendFuncSeparateiEXT, GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+GL_ENTRY(void, glBlendFunciEXT, GLuint buf, GLenum src, GLenum dst)
+GL_ENTRY(void, glBlendParameteriNV, GLenum pname, GLint value)
 GL_ENTRY(void, glBlitFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
 GL_ENTRY(void, glBlitFramebufferANGLE, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
-GL_ENTRY(void, glBufferData, GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)
-GL_ENTRY(void, glBufferSubData, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data)
+GL_ENTRY(void, glBlitFramebufferNV, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
+GL_ENTRY(void, glBufferData, GLenum target, GLsizeiptr size, const void * data, GLenum usage)
+GL_ENTRY(void, glBufferSubData, GLenum target, GLintptr offset, GLsizeiptr size, const void * data)
 GL_ENTRY(GLenum, glCheckFramebufferStatus, GLenum target)
 GL_ENTRY(GLenum, glCheckFramebufferStatusOES, GLenum target)
 GL_ENTRY(void, glClear, GLbitfield mask)
 GL_ENTRY(void, glClearBufferfi, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
-GL_ENTRY(void, glClearBufferfv, GLenum buffer, GLint drawbuffer, const GLfloat* value)
-GL_ENTRY(void, glClearBufferiv, GLenum buffer, GLint drawbuffer, const GLint* value)
-GL_ENTRY(void, glClearBufferuiv, GLenum buffer, GLint drawbuffer, const GLuint* value)
-GL_ENTRY(void, glClearColor, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
-GL_ENTRY(void, glClearColorx, GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)
-GL_ENTRY(void, glClearColorxOES, GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)
-GL_ENTRY(void, glClearDepthf, GLclampf depth)
+GL_ENTRY(void, glClearBufferfv, GLenum buffer, GLint drawbuffer, const GLfloat * value)
+GL_ENTRY(void, glClearBufferiv, GLenum buffer, GLint drawbuffer, const GLint * value)
+GL_ENTRY(void, glClearBufferuiv, GLenum buffer, GLint drawbuffer, const GLuint * value)
+GL_ENTRY(void, glClearColor, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
+GL_ENTRY(void, glClearColorx, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
+GL_ENTRY(void, glClearColorxOES, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
+GL_ENTRY(void, glClearDepthf, GLfloat d)
 GL_ENTRY(void, glClearDepthfOES, GLclampf depth)
-GL_ENTRY(void, glClearDepthx, GLclampx depth)
-GL_ENTRY(void, glClearDepthxOES, GLclampx depth)
+GL_ENTRY(void, glClearDepthx, GLfixed depth)
+GL_ENTRY(void, glClearDepthxOES, GLfixed depth)
 GL_ENTRY(void, glClearStencil, GLint s)
 GL_ENTRY(void, glClientActiveTexture, GLenum texture)
 GL_ENTRY(GLenum, glClientWaitSync, GLsync sync, GLbitfield flags, GLuint64 timeout)
-GL_ENTRY(void, glClipPlanef, GLenum plane, const GLfloat *equation)
-GL_ENTRY(void, glClipPlanefIMG, GLenum p, const GLfloat *eqn)
-GL_ENTRY(void, glClipPlanefOES, GLenum plane, const GLfloat *equation)
-GL_ENTRY(void, glClipPlanex, GLenum plane, const GLfixed *equation)
-GL_ENTRY(void, glClipPlanexIMG, GLenum p, const GLfixed *eqn)
-GL_ENTRY(void, glClipPlanexOES, GLenum plane, const GLfixed *equation)
+GL_ENTRY(GLenum, glClientWaitSyncAPPLE, GLsync sync, GLbitfield flags, GLuint64 timeout)
+GL_ENTRY(void, glClipPlanef, GLenum p, const GLfloat * eqn)
+GL_ENTRY(void, glClipPlanefIMG, GLenum p, const GLfloat * eqn)
+GL_ENTRY(void, glClipPlanefOES, GLenum plane, const GLfloat * equation)
+GL_ENTRY(void, glClipPlanex, GLenum plane, const GLfixed * equation)
+GL_ENTRY(void, glClipPlanexIMG, GLenum p, const GLfixed * eqn)
+GL_ENTRY(void, glClipPlanexOES, GLenum plane, const GLfixed * equation)
 GL_ENTRY(void, glColor4f, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
 GL_ENTRY(void, glColor4ub, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
 GL_ENTRY(void, glColor4x, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
 GL_ENTRY(void, glColor4xOES, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
 GL_ENTRY(void, glColorMask, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
-GL_ENTRY(void, glColorPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
+GL_ENTRY(void, glColorMaskiEXT, GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a)
+GL_ENTRY(void, glColorPointer, GLint size, GLenum type, GLsizei stride, const void * pointer)
 GL_ENTRY(void, glCompileShader, GLuint shader)
-GL_ENTRY(void, glCompressedTexImage2D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data)
-GL_ENTRY(void, glCompressedTexImage3D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
-GL_ENTRY(void, glCompressedTexImage3DOES, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
-GL_ENTRY(void, glCompressedTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data)
-GL_ENTRY(void, 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_ENTRY(void, glCompressedTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
+GL_ENTRY(void, glCompressedTexImage2D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data)
+GL_ENTRY(void, glCompressedTexImage3D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data)
+GL_ENTRY(void, glCompressedTexImage3DOES, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data)
+GL_ENTRY(void, glCompressedTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data)
+GL_ENTRY(void, glCompressedTexSubImage3D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data)
+GL_ENTRY(void, glCompressedTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data)
 GL_ENTRY(void, glCopyBufferSubData, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
+GL_ENTRY(void, glCopyBufferSubDataNV, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
+GL_ENTRY(void, glCopyImageSubDataEXT, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth)
 GL_ENTRY(void, glCopyTexImage2D, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
 GL_ENTRY(void, glCopyTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
 GL_ENTRY(void, glCopyTexSubImage3D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
 GL_ENTRY(void, glCopyTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+GL_ENTRY(void, glCopyTextureLevelsAPPLE, GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount)
 GL_ENTRY(void, glCoverageMaskNV, GLboolean mask)
 GL_ENTRY(void, glCoverageOperationNV, GLenum operation)
+GL_ENTRY(void, glCreatePerfQueryINTEL, GLuint queryId, GLuint * queryHandle)
 GL_ENTRY(GLuint, glCreateProgram, void)
 GL_ENTRY(GLuint, glCreateShader, GLenum type)
-GL_ENTRY(GLuint, glCreateShaderProgramvEXT, GLenum type, GLsizei count, const GLchar **strings)
+GL_ENTRY(GLuint, glCreateShaderProgramv, GLenum type, GLsizei count, const GLchar *const* strings)
+GL_ENTRY(GLuint, glCreateShaderProgramvEXT, GLenum type, GLsizei count, const GLchar ** strings)
 GL_ENTRY(void, glCullFace, GLenum mode)
 GL_ENTRY(void, glCurrentPaletteMatrixOES, GLuint matrixpaletteindex)
-GL_ENTRY(void, glDeleteBuffers, GLsizei n, const GLuint *buffers)
-GL_ENTRY(void, glDeleteFencesNV, GLsizei n, const GLuint *fences)
-GL_ENTRY(void, glDeleteFramebuffers, GLsizei n, const GLuint* framebuffers)
-GL_ENTRY(void, glDeleteFramebuffersOES, GLsizei n, const GLuint* framebuffers)
-GL_ENTRY(void, glDeletePerfMonitorsAMD, GLsizei n, GLuint *monitors)
+GL_ENTRY(void, glDebugMessageCallbackKHR, GLDEBUGPROCKHR callback, const void * userParam)
+GL_ENTRY(void, glDebugMessageControlKHR, GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled)
+GL_ENTRY(void, glDebugMessageInsertKHR, GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf)
+GL_ENTRY(void, glDeleteBuffers, GLsizei n, const GLuint * buffers)
+GL_ENTRY(void, glDeleteFencesNV, GLsizei n, const GLuint * fences)
+GL_ENTRY(void, glDeleteFramebuffers, GLsizei n, const GLuint * framebuffers)
+GL_ENTRY(void, glDeleteFramebuffersOES, GLsizei n, const GLuint * framebuffers)
+GL_ENTRY(void, glDeletePerfMonitorsAMD, GLsizei n, GLuint * monitors)
+GL_ENTRY(void, glDeletePerfQueryINTEL, GLuint queryHandle)
 GL_ENTRY(void, glDeleteProgram, GLuint program)
-GL_ENTRY(void, glDeleteProgramPipelinesEXT, GLsizei n, const GLuint *pipelines)
-GL_ENTRY(void, glDeleteQueries, GLsizei n, const GLuint* ids)
-GL_ENTRY(void, glDeleteQueriesEXT, GLsizei n, const GLuint *ids)
-GL_ENTRY(void, glDeleteRenderbuffers, GLsizei n, const GLuint* renderbuffers)
-GL_ENTRY(void, glDeleteRenderbuffersOES, GLsizei n, const GLuint* renderbuffers)
-GL_ENTRY(void, glDeleteSamplers, GLsizei count, const GLuint* samplers)
+GL_ENTRY(void, glDeleteProgramPipelines, GLsizei n, const GLuint * pipelines)
+GL_ENTRY(void, glDeleteProgramPipelinesEXT, GLsizei n, const GLuint * pipelines)
+GL_ENTRY(void, glDeleteQueries, GLsizei n, const GLuint * ids)
+GL_ENTRY(void, glDeleteQueriesEXT, GLsizei n, const GLuint * ids)
+GL_ENTRY(void, glDeleteRenderbuffers, GLsizei n, const GLuint * renderbuffers)
+GL_ENTRY(void, glDeleteRenderbuffersOES, GLsizei n, const GLuint * renderbuffers)
+GL_ENTRY(void, glDeleteSamplers, GLsizei count, const GLuint * samplers)
 GL_ENTRY(void, glDeleteShader, GLuint shader)
 GL_ENTRY(void, glDeleteSync, GLsync sync)
-GL_ENTRY(void, glDeleteTextures, GLsizei n, const GLuint *textures)
-GL_ENTRY(void, glDeleteTransformFeedbacks, GLsizei n, const GLuint* ids)
-GL_ENTRY(void, glDeleteVertexArrays, GLsizei n, const GLuint* arrays)
-GL_ENTRY(void, glDeleteVertexArraysOES, GLsizei n, const GLuint *arrays)
+GL_ENTRY(void, glDeleteSyncAPPLE, GLsync sync)
+GL_ENTRY(void, glDeleteTextures, GLsizei n, const GLuint * textures)
+GL_ENTRY(void, glDeleteTransformFeedbacks, GLsizei n, const GLuint * ids)
+GL_ENTRY(void, glDeleteVertexArrays, GLsizei n, const GLuint * arrays)
+GL_ENTRY(void, glDeleteVertexArraysOES, GLsizei n, const GLuint * arrays)
 GL_ENTRY(void, glDepthFunc, GLenum func)
 GL_ENTRY(void, glDepthMask, GLboolean flag)
-GL_ENTRY(void, glDepthRangef, GLclampf zNear, GLclampf zFar)
-GL_ENTRY(void, glDepthRangefOES, GLclampf zNear, GLclampf zFar)
-GL_ENTRY(void, glDepthRangex, GLclampx zNear, GLclampx zFar)
-GL_ENTRY(void, glDepthRangexOES, GLclampx zNear, GLclampx zFar)
+GL_ENTRY(void, glDepthRangef, GLfloat n, GLfloat f)
+GL_ENTRY(void, glDepthRangefOES, GLclampf n, GLclampf f)
+GL_ENTRY(void, glDepthRangex, GLfixed n, GLfixed f)
+GL_ENTRY(void, glDepthRangexOES, GLfixed n, GLfixed f)
 GL_ENTRY(void, glDetachShader, GLuint program, GLuint shader)
 GL_ENTRY(void, glDisable, GLenum cap)
 GL_ENTRY(void, glDisableClientState, GLenum array)
 GL_ENTRY(void, glDisableDriverControlQCOM, GLuint driverControl)
 GL_ENTRY(void, glDisableVertexAttribArray, GLuint index)
-GL_ENTRY(void, glDiscardFramebufferEXT, GLenum target, GLsizei numAttachments, const GLenum *attachments)
+GL_ENTRY(void, glDisableiEXT, GLenum target, GLuint index)
+GL_ENTRY(void, glDiscardFramebufferEXT, GLenum target, GLsizei numAttachments, const GLenum * attachments)
+GL_ENTRY(void, glDispatchCompute, GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z)
+GL_ENTRY(void, glDispatchComputeIndirect, GLintptr indirect)
 GL_ENTRY(void, glDrawArrays, GLenum mode, GLint first, GLsizei count)
-GL_ENTRY(void, glDrawArraysInstanced, GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
-GL_ENTRY(void, glDrawBuffers, GLsizei n, const GLenum* bufs)
-GL_ENTRY(void, glDrawBuffersNV, GLsizei n, const GLenum *bufs)
-GL_ENTRY(void, glDrawElements, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
-GL_ENTRY(void, glDrawElementsInstanced, GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
-GL_ENTRY(void, glDrawRangeElements, GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
+GL_ENTRY(void, glDrawArraysIndirect, GLenum mode, const void * indirect)
+GL_ENTRY(void, glDrawArraysInstanced, GLenum mode, GLint first, GLsizei count, GLsizei instancecount)
+GL_ENTRY(void, glDrawArraysInstancedANGLE, GLenum mode, GLint first, GLsizei count, GLsizei primcount)
+GL_ENTRY(void, glDrawArraysInstancedEXT, GLenum mode, GLint start, GLsizei count, GLsizei primcount)
+GL_ENTRY(void, glDrawArraysInstancedNV, GLenum mode, GLint first, GLsizei count, GLsizei primcount)
+GL_ENTRY(void, glDrawBuffers, GLsizei n, const GLenum * bufs)
+GL_ENTRY(void, glDrawBuffersEXT, GLsizei n, const GLenum * bufs)
+GL_ENTRY(void, glDrawBuffersIndexedEXT, GLint n, const GLenum * location, const GLint * indices)
+GL_ENTRY(void, glDrawBuffersNV, GLsizei n, const GLenum * bufs)
+GL_ENTRY(void, glDrawElements, GLenum mode, GLsizei count, GLenum type, const void * indices)
+GL_ENTRY(void, glDrawElementsIndirect, GLenum mode, GLenum type, const void * indirect)
+GL_ENTRY(void, glDrawElementsInstanced, GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount)
+GL_ENTRY(void, glDrawElementsInstancedANGLE, GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount)
+GL_ENTRY(void, glDrawElementsInstancedEXT, GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount)
+GL_ENTRY(void, glDrawElementsInstancedNV, GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount)
+GL_ENTRY(void, glDrawRangeElements, GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices)
 GL_ENTRY(void, glDrawTexfOES, GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height)
-GL_ENTRY(void, glDrawTexfvOES, const GLfloat *coords)
+GL_ENTRY(void, glDrawTexfvOES, const GLfloat * coords)
 GL_ENTRY(void, glDrawTexiOES, GLint x, GLint y, GLint z, GLint width, GLint height)
-GL_ENTRY(void, glDrawTexivOES, const GLint *coords)
+GL_ENTRY(void, glDrawTexivOES, const GLint * coords)
 GL_ENTRY(void, glDrawTexsOES, GLshort x, GLshort y, GLshort z, GLshort width, GLshort height)
-GL_ENTRY(void, glDrawTexsvOES, const GLshort *coords)
+GL_ENTRY(void, glDrawTexsvOES, const GLshort * coords)
 GL_ENTRY(void, glDrawTexxOES, GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height)
-GL_ENTRY(void, glDrawTexxvOES, const GLfixed *coords)
+GL_ENTRY(void, glDrawTexxvOES, const GLfixed * coords)
 GL_ENTRY(void, glEGLImageTargetRenderbufferStorageOES, GLenum target, GLeglImageOES image)
 GL_ENTRY(void, glEGLImageTargetTexture2DOES, GLenum target, GLeglImageOES image)
 GL_ENTRY(void, glEnable, GLenum cap)
 GL_ENTRY(void, glEnableClientState, GLenum array)
 GL_ENTRY(void, glEnableDriverControlQCOM, GLuint driverControl)
 GL_ENTRY(void, glEnableVertexAttribArray, GLuint index)
+GL_ENTRY(void, glEnableiEXT, GLenum target, GLuint index)
 GL_ENTRY(void, glEndPerfMonitorAMD, GLuint monitor)
+GL_ENTRY(void, glEndPerfQueryINTEL, GLuint queryHandle)
 GL_ENTRY(void, glEndQuery, GLenum target)
 GL_ENTRY(void, glEndQueryEXT, GLenum target)
 GL_ENTRY(void, glEndTilingQCOM, GLbitfield preserveMask)
 GL_ENTRY(void, glEndTransformFeedback, void)
-GL_ENTRY(void, glExtGetBufferPointervQCOM, GLenum target, GLvoid **params)
-GL_ENTRY(void, glExtGetBuffersQCOM, GLuint *buffers, GLint maxBuffers, GLint *numBuffers)
-GL_ENTRY(void, glExtGetFramebuffersQCOM, GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers)
-GL_ENTRY(void, glExtGetProgramBinarySourceQCOM, GLuint program, GLenum shadertype, GLchar *source, GLint *length)
-GL_ENTRY(void, glExtGetProgramsQCOM, GLuint *programs, GLint maxPrograms, GLint *numPrograms)
-GL_ENTRY(void, glExtGetRenderbuffersQCOM, GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers)
-GL_ENTRY(void, glExtGetShadersQCOM, GLuint *shaders, GLint maxShaders, GLint *numShaders)
-GL_ENTRY(void, glExtGetTexLevelParameterivQCOM, GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params)
-GL_ENTRY(void, glExtGetTexSubImageQCOM, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels)
-GL_ENTRY(void, glExtGetTexturesQCOM, GLuint *textures, GLint maxTextures, GLint *numTextures)
+GL_ENTRY(void, glExtGetBufferPointervQCOM, GLenum target, void ** params)
+GL_ENTRY(void, glExtGetBuffersQCOM, GLuint * buffers, GLint maxBuffers, GLint * numBuffers)
+GL_ENTRY(void, glExtGetFramebuffersQCOM, GLuint * framebuffers, GLint maxFramebuffers, GLint * numFramebuffers)
+GL_ENTRY(void, glExtGetProgramBinarySourceQCOM, GLuint program, GLenum shadertype, GLchar * source, GLint * length)
+GL_ENTRY(void, glExtGetProgramsQCOM, GLuint * programs, GLint maxPrograms, GLint * numPrograms)
+GL_ENTRY(void, glExtGetRenderbuffersQCOM, GLuint * renderbuffers, GLint maxRenderbuffers, GLint * numRenderbuffers)
+GL_ENTRY(void, glExtGetShadersQCOM, GLuint * shaders, GLint maxShaders, GLint * numShaders)
+GL_ENTRY(void, glExtGetTexLevelParameterivQCOM, GLuint texture, GLenum face, GLint level, GLenum pname, GLint * params)
+GL_ENTRY(void, glExtGetTexSubImageQCOM, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void * texels)
+GL_ENTRY(void, glExtGetTexturesQCOM, GLuint * textures, GLint maxTextures, GLint * numTextures)
 GL_ENTRY(GLboolean, glExtIsProgramBinaryQCOM, GLuint program)
 GL_ENTRY(void, glExtTexObjectStateOverrideiQCOM, GLenum target, GLenum pname, GLint param)
 GL_ENTRY(GLsync, glFenceSync, GLenum condition, GLbitfield flags)
+GL_ENTRY(GLsync, glFenceSyncAPPLE, GLenum condition, GLbitfield flags)
 GL_ENTRY(void, glFinish, void)
 GL_ENTRY(void, glFinishFenceNV, GLuint fence)
 GL_ENTRY(void, glFlush, void)
 GL_ENTRY(void, glFlushMappedBufferRange, GLenum target, GLintptr offset, GLsizeiptr length)
+GL_ENTRY(void, glFlushMappedBufferRangeEXT, GLenum target, GLintptr offset, GLsizeiptr length)
 GL_ENTRY(void, glFogf, GLenum pname, GLfloat param)
-GL_ENTRY(void, glFogfv, GLenum pname, const GLfloat *params)
+GL_ENTRY(void, glFogfv, GLenum pname, const GLfloat * params)
 GL_ENTRY(void, glFogx, GLenum pname, GLfixed param)
 GL_ENTRY(void, glFogxOES, GLenum pname, GLfixed param)
-GL_ENTRY(void, glFogxv, GLenum pname, const GLfixed *params)
-GL_ENTRY(void, glFogxvOES, GLenum pname, const GLfixed *params)
+GL_ENTRY(void, glFogxv, GLenum pname, const GLfixed * param)
+GL_ENTRY(void, glFogxvOES, GLenum pname, const GLfixed * param)
+GL_ENTRY(void, glFramebufferParameteri, GLenum target, GLenum pname, GLint param)
 GL_ENTRY(void, glFramebufferRenderbuffer, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
 GL_ENTRY(void, glFramebufferRenderbufferOES, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
 GL_ENTRY(void, glFramebufferTexture2D, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
@@ -169,131 +213,168 @@
 GL_ENTRY(void, glFramebufferTexture2DMultisampleIMG, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples)
 GL_ENTRY(void, glFramebufferTexture2DOES, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
 GL_ENTRY(void, glFramebufferTexture3DOES, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
+GL_ENTRY(void, glFramebufferTextureEXT, GLenum target, GLenum attachment, GLuint texture, GLint level)
 GL_ENTRY(void, glFramebufferTextureLayer, GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
 GL_ENTRY(void, glFrontFace, GLenum mode)
-GL_ENTRY(void, glFrustumf, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
-GL_ENTRY(void, glFrustumfOES, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
-GL_ENTRY(void, glFrustumx, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
-GL_ENTRY(void, glFrustumxOES, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
-GL_ENTRY(void, glGenBuffers, GLsizei n, GLuint *buffers)
-GL_ENTRY(void, glGenFencesNV, GLsizei n, GLuint *fences)
-GL_ENTRY(void, glGenFramebuffers, GLsizei n, GLuint* framebuffers)
-GL_ENTRY(void, glGenFramebuffersOES, GLsizei n, GLuint* framebuffers)
-GL_ENTRY(void, glGenPerfMonitorsAMD, GLsizei n, GLuint *monitors)
-GL_ENTRY(void, glGenProgramPipelinesEXT, GLsizei n, GLuint *pipelines)
-GL_ENTRY(void, glGenQueries, GLsizei n, GLuint* ids)
-GL_ENTRY(void, glGenQueriesEXT, GLsizei n, GLuint *ids)
-GL_ENTRY(void, glGenRenderbuffers, GLsizei n, GLuint* renderbuffers)
-GL_ENTRY(void, glGenRenderbuffersOES, GLsizei n, GLuint* renderbuffers)
-GL_ENTRY(void, glGenSamplers, GLsizei count, GLuint* samplers)
-GL_ENTRY(void, glGenTextures, GLsizei n, GLuint *textures)
-GL_ENTRY(void, glGenTransformFeedbacks, GLsizei n, GLuint* ids)
-GL_ENTRY(void, glGenVertexArrays, GLsizei n, GLuint* arrays)
-GL_ENTRY(void, glGenVertexArraysOES, GLsizei n, GLuint *arrays)
+GL_ENTRY(void, glFrustumf, GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f)
+GL_ENTRY(void, glFrustumfOES, GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f)
+GL_ENTRY(void, glFrustumx, GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f)
+GL_ENTRY(void, glFrustumxOES, GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f)
+GL_ENTRY(void, glGenBuffers, GLsizei n, GLuint * buffers)
+GL_ENTRY(void, glGenFencesNV, GLsizei n, GLuint * fences)
+GL_ENTRY(void, glGenFramebuffers, GLsizei n, GLuint * framebuffers)
+GL_ENTRY(void, glGenFramebuffersOES, GLsizei n, GLuint * framebuffers)
+GL_ENTRY(void, glGenPerfMonitorsAMD, GLsizei n, GLuint * monitors)
+GL_ENTRY(void, glGenProgramPipelines, GLsizei n, GLuint * pipelines)
+GL_ENTRY(void, glGenProgramPipelinesEXT, GLsizei n, GLuint * pipelines)
+GL_ENTRY(void, glGenQueries, GLsizei n, GLuint * ids)
+GL_ENTRY(void, glGenQueriesEXT, GLsizei n, GLuint * ids)
+GL_ENTRY(void, glGenRenderbuffers, GLsizei n, GLuint * renderbuffers)
+GL_ENTRY(void, glGenRenderbuffersOES, GLsizei n, GLuint * renderbuffers)
+GL_ENTRY(void, glGenSamplers, GLsizei count, GLuint * samplers)
+GL_ENTRY(void, glGenTextures, GLsizei n, GLuint * textures)
+GL_ENTRY(void, glGenTransformFeedbacks, GLsizei n, GLuint * ids)
+GL_ENTRY(void, glGenVertexArrays, GLsizei n, GLuint * arrays)
+GL_ENTRY(void, glGenVertexArraysOES, GLsizei n, GLuint * arrays)
 GL_ENTRY(void, glGenerateMipmap, GLenum target)
 GL_ENTRY(void, glGenerateMipmapOES, GLenum target)
-GL_ENTRY(void, glGetActiveAttrib, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
-GL_ENTRY(void, glGetActiveUniform, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
-GL_ENTRY(void, glGetActiveUniformBlockName, GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
-GL_ENTRY(void, glGetActiveUniformBlockiv, GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
-GL_ENTRY(void, glGetActiveUniformsiv, GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
-GL_ENTRY(void, glGetAttachedShaders, GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
-GL_ENTRY(GLint, glGetAttribLocation, GLuint program, const GLchar* name)
-GL_ENTRY(void, glGetBooleanv, GLenum pname, GLboolean *params)
-GL_ENTRY(void, glGetBufferParameteri64v, GLenum target, GLenum pname, GLint64* params)
-GL_ENTRY(void, glGetBufferParameteriv, GLenum target, GLenum pname, GLint *params)
-GL_ENTRY(void, glGetBufferPointerv, GLenum target, GLenum pname, GLvoid** params)
-GL_ENTRY(void, glGetBufferPointervOES, GLenum target, GLenum pname, GLvoid ** params)
-GL_ENTRY(void, glGetClipPlanef, GLenum pname, GLfloat eqn[4])
-GL_ENTRY(void, glGetClipPlanefOES, GLenum pname, GLfloat eqn[4])
-GL_ENTRY(void, glGetClipPlanex, GLenum pname, GLfixed eqn[4])
-GL_ENTRY(void, glGetClipPlanexOES, GLenum pname, GLfixed eqn[4])
-GL_ENTRY(void, glGetDriverControlStringQCOM, GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString)
-GL_ENTRY(void, glGetDriverControlsQCOM, GLint *num, GLsizei size, GLuint *driverControls)
+GL_ENTRY(void, glGetActiveAttrib, GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name)
+GL_ENTRY(void, glGetActiveUniform, GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name)
+GL_ENTRY(void, glGetActiveUniformBlockName, GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName)
+GL_ENTRY(void, glGetActiveUniformBlockiv, GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetActiveUniformsiv, GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetAttachedShaders, GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders)
+GL_ENTRY(GLint, glGetAttribLocation, GLuint program, const GLchar * name)
+GL_ENTRY(void, glGetBooleani_v, GLenum target, GLuint index, GLboolean * data)
+GL_ENTRY(void, glGetBooleanv, GLenum pname, GLboolean * data)
+GL_ENTRY(void, glGetBufferParameteri64v, GLenum target, GLenum pname, GLint64 * params)
+GL_ENTRY(void, glGetBufferParameteriv, GLenum target, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetBufferPointerv, GLenum target, GLenum pname, void ** params)
+GL_ENTRY(void, glGetBufferPointervOES, GLenum target, GLenum pname, void ** params)
+GL_ENTRY(void, glGetClipPlanef, GLenum plane, GLfloat * equation)
+GL_ENTRY(void, glGetClipPlanefOES, GLenum plane, GLfloat * equation)
+GL_ENTRY(void, glGetClipPlanex, GLenum plane, GLfixed * equation)
+GL_ENTRY(void, glGetClipPlanexOES, GLenum plane, GLfixed * equation)
+GL_ENTRY(GLuint, glGetDebugMessageLogKHR, GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog)
+GL_ENTRY(void, glGetDriverControlStringQCOM, GLuint driverControl, GLsizei bufSize, GLsizei * length, GLchar * driverControlString)
+GL_ENTRY(void, glGetDriverControlsQCOM, GLint * num, GLsizei size, GLuint * driverControls)
 GL_ENTRY(GLenum, glGetError, void)
-GL_ENTRY(void, glGetFenceivNV, GLuint fence, GLenum pname, GLint *params)
-GL_ENTRY(void, glGetFixedv, GLenum pname, GLfixed *params)
-GL_ENTRY(void, glGetFixedvOES, GLenum pname, GLfixed *params)
-GL_ENTRY(void, glGetFloatv, GLenum pname, GLfloat *params)
-GL_ENTRY(GLint, glGetFragDataLocation, GLuint program, const GLchar *name)
-GL_ENTRY(void, glGetFramebufferAttachmentParameteriv, GLenum target, GLenum attachment, GLenum pname, GLint* params)
-GL_ENTRY(void, glGetFramebufferAttachmentParameterivOES, GLenum target, GLenum attachment, GLenum pname, GLint* params)
+GL_ENTRY(void, glGetFenceivNV, GLuint fence, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetFirstPerfQueryIdINTEL, GLuint * queryId)
+GL_ENTRY(void, glGetFixedv, GLenum pname, GLfixed * params)
+GL_ENTRY(void, glGetFixedvOES, GLenum pname, GLfixed * params)
+GL_ENTRY(void, glGetFloatv, GLenum pname, GLfloat * data)
+GL_ENTRY(GLint, glGetFragDataLocation, GLuint program, const GLchar * name)
+GL_ENTRY(void, glGetFramebufferAttachmentParameteriv, GLenum target, GLenum attachment, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetFramebufferAttachmentParameterivOES, GLenum target, GLenum attachment, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetFramebufferParameteriv, GLenum target, GLenum pname, GLint * params)
 GL_ENTRY(GLenum, glGetGraphicsResetStatusEXT, void)
-GL_ENTRY(void, glGetInteger64i_v, GLenum target, GLuint index, GLint64* data)
-GL_ENTRY(void, glGetInteger64v, GLenum pname, GLint64* params)
-GL_ENTRY(void, glGetIntegeri_v, GLenum target, GLuint index, GLint* data)
-GL_ENTRY(void, glGetIntegerv, GLenum pname, GLint *params)
-GL_ENTRY(void, glGetInternalformativ, GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
-GL_ENTRY(void, glGetLightfv, GLenum light, GLenum pname, GLfloat *params)
-GL_ENTRY(void, glGetLightxv, GLenum light, GLenum pname, GLfixed *params)
-GL_ENTRY(void, glGetLightxvOES, GLenum light, GLenum pname, GLfixed *params)
-GL_ENTRY(void, glGetMaterialfv, GLenum face, GLenum pname, GLfloat *params)
-GL_ENTRY(void, glGetMaterialxv, GLenum face, GLenum pname, GLfixed *params)
-GL_ENTRY(void, glGetMaterialxvOES, GLenum face, GLenum pname, GLfixed *params)
-GL_ENTRY(void, glGetObjectLabelEXT, GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label)
-GL_ENTRY(void, glGetPerfMonitorCounterDataAMD, GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten)
-GL_ENTRY(void, glGetPerfMonitorCounterInfoAMD, GLuint group, GLuint counter, GLenum pname, GLvoid *data)
-GL_ENTRY(void, glGetPerfMonitorCounterStringAMD, GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString)
-GL_ENTRY(void, glGetPerfMonitorCountersAMD, GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters)
-GL_ENTRY(void, glGetPerfMonitorGroupStringAMD, GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString)
-GL_ENTRY(void, glGetPerfMonitorGroupsAMD, GLint *numGroups, GLsizei groupsSize, GLuint *groups)
-GL_ENTRY(void, glGetPointerv, GLenum pname, GLvoid **params)
-GL_ENTRY(void, glGetProgramBinary, GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
-GL_ENTRY(void, glGetProgramBinaryOES, GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary)
-GL_ENTRY(void, glGetProgramInfoLog, GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
-GL_ENTRY(void, glGetProgramPipelineInfoLogEXT, GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog)
-GL_ENTRY(void, glGetProgramPipelineivEXT, GLuint pipeline, GLenum pname, GLint *params)
-GL_ENTRY(void, glGetProgramiv, GLuint program, GLenum pname, GLint* params)
-GL_ENTRY(void, glGetQueryObjectuiv, GLuint id, GLenum pname, GLuint* params)
-GL_ENTRY(void, glGetQueryObjectuivEXT, GLuint id, GLenum pname, GLuint *params)
-GL_ENTRY(void, glGetQueryiv, GLenum target, GLenum pname, GLint* params)
-GL_ENTRY(void, glGetQueryivEXT, GLenum target, GLenum pname, GLint *params)
-GL_ENTRY(void, glGetRenderbufferParameteriv, GLenum target, GLenum pname, GLint* params)
-GL_ENTRY(void, glGetRenderbufferParameterivOES, GLenum target, GLenum pname, GLint* params)
-GL_ENTRY(void, glGetSamplerParameterfv, GLuint sampler, GLenum pname, GLfloat* params)
-GL_ENTRY(void, glGetSamplerParameteriv, GLuint sampler, GLenum pname, GLint* params)
-GL_ENTRY(void, glGetShaderInfoLog, GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
-GL_ENTRY(void, glGetShaderPrecisionFormat, GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
-GL_ENTRY(void, glGetShaderSource, GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
-GL_ENTRY(void, glGetShaderiv, GLuint shader, GLenum pname, GLint* params)
+GL_ENTRY(void, glGetInteger64i_v, GLenum target, GLuint index, GLint64 * data)
+GL_ENTRY(void, glGetInteger64v, GLenum pname, GLint64 * data)
+GL_ENTRY(void, glGetInteger64vAPPLE, GLenum pname, GLint64 * params)
+GL_ENTRY(void, glGetIntegeri_v, GLenum target, GLuint index, GLint * data)
+GL_ENTRY(void, glGetIntegeri_vEXT, GLenum target, GLuint index, GLint * data)
+GL_ENTRY(void, glGetIntegerv, GLenum pname, GLint * data)
+GL_ENTRY(void, glGetInternalformativ, GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint * params)
+GL_ENTRY(void, glGetLightfv, GLenum light, GLenum pname, GLfloat * params)
+GL_ENTRY(void, glGetLightxv, GLenum light, GLenum pname, GLfixed * params)
+GL_ENTRY(void, glGetLightxvOES, GLenum light, GLenum pname, GLfixed * params)
+GL_ENTRY(void, glGetMaterialfv, GLenum face, GLenum pname, GLfloat * params)
+GL_ENTRY(void, glGetMaterialxv, GLenum face, GLenum pname, GLfixed * params)
+GL_ENTRY(void, glGetMaterialxvOES, GLenum face, GLenum pname, GLfixed * params)
+GL_ENTRY(void, glGetMultisamplefv, GLenum pname, GLuint index, GLfloat * val)
+GL_ENTRY(void, glGetNextPerfQueryIdINTEL, GLuint queryId, GLuint * nextQueryId)
+GL_ENTRY(void, glGetObjectLabelEXT, GLenum type, GLuint object, GLsizei bufSize, GLsizei * length, GLchar * label)
+GL_ENTRY(void, glGetObjectLabelKHR, GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label)
+GL_ENTRY(void, glGetObjectPtrLabelKHR, const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label)
+GL_ENTRY(void, glGetPerfCounterInfoINTEL, GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar * counterName, GLuint counterDescLength, GLchar * counterDesc, GLuint * counterOffset, GLuint * counterDataSize, GLuint * counterTypeEnum, GLuint * counterDataTypeEnum, GLuint64 * rawCounterMaxValue)
+GL_ENTRY(void, glGetPerfMonitorCounterDataAMD, GLuint monitor, GLenum pname, GLsizei dataSize, GLuint * data, GLint * bytesWritten)
+GL_ENTRY(void, glGetPerfMonitorCounterInfoAMD, GLuint group, GLuint counter, GLenum pname, void * data)
+GL_ENTRY(void, glGetPerfMonitorCounterStringAMD, GLuint group, GLuint counter, GLsizei bufSize, GLsizei * length, GLchar * counterString)
+GL_ENTRY(void, glGetPerfMonitorCountersAMD, GLuint group, GLint * numCounters, GLint * maxActiveCounters, GLsizei counterSize, GLuint * counters)
+GL_ENTRY(void, glGetPerfMonitorGroupStringAMD, GLuint group, GLsizei bufSize, GLsizei * length, GLchar * groupString)
+GL_ENTRY(void, glGetPerfMonitorGroupsAMD, GLint * numGroups, GLsizei groupsSize, GLuint * groups)
+GL_ENTRY(void, glGetPerfQueryDataINTEL, GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid * data, GLuint * bytesWritten)
+GL_ENTRY(void, glGetPerfQueryIdByNameINTEL, GLchar * queryName, GLuint * queryId)
+GL_ENTRY(void, glGetPerfQueryInfoINTEL, GLuint queryId, GLuint queryNameLength, GLchar * queryName, GLuint * dataSize, GLuint * noCounters, GLuint * noInstances, GLuint * capsMask)
+GL_ENTRY(void, glGetPointerv, GLenum pname, void ** params)
+GL_ENTRY(void, glGetPointervKHR, GLenum pname, void ** params)
+GL_ENTRY(void, glGetProgramBinary, GLuint program, GLsizei bufSize, GLsizei * length, GLenum * binaryFormat, void * binary)
+GL_ENTRY(void, glGetProgramBinaryOES, GLuint program, GLsizei bufSize, GLsizei * length, GLenum * binaryFormat, void * binary)
+GL_ENTRY(void, glGetProgramInfoLog, GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog)
+GL_ENTRY(void, glGetProgramInterfaceiv, GLuint program, GLenum programInterface, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetProgramPipelineInfoLog, GLuint pipeline, GLsizei bufSize, GLsizei * length, GLchar * infoLog)
+GL_ENTRY(void, glGetProgramPipelineInfoLogEXT, GLuint pipeline, GLsizei bufSize, GLsizei * length, GLchar * infoLog)
+GL_ENTRY(void, glGetProgramPipelineiv, GLuint pipeline, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetProgramPipelineivEXT, GLuint pipeline, GLenum pname, GLint * params)
+GL_ENTRY(GLuint, glGetProgramResourceIndex, GLuint program, GLenum programInterface, const GLchar * name)
+GL_ENTRY(GLint, glGetProgramResourceLocation, GLuint program, GLenum programInterface, const GLchar * name)
+GL_ENTRY(void, glGetProgramResourceName, GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei * length, GLchar * name)
+GL_ENTRY(void, glGetProgramResourceiv, GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum * props, GLsizei bufSize, GLsizei * length, GLint * params)
+GL_ENTRY(void, glGetProgramiv, GLuint program, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetQueryObjecti64vEXT, GLuint id, GLenum pname, GLint64 * params)
+GL_ENTRY(void, glGetQueryObjectivEXT, GLuint id, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetQueryObjectui64vEXT, GLuint id, GLenum pname, GLuint64 * params)
+GL_ENTRY(void, glGetQueryObjectuiv, GLuint id, GLenum pname, GLuint * params)
+GL_ENTRY(void, glGetQueryObjectuivEXT, GLuint id, GLenum pname, GLuint * params)
+GL_ENTRY(void, glGetQueryiv, GLenum target, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetQueryivEXT, GLenum target, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetRenderbufferParameteriv, GLenum target, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetRenderbufferParameterivOES, GLenum target, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetSamplerParameterIivEXT, GLuint sampler, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetSamplerParameterIuivEXT, GLuint sampler, GLenum pname, GLuint * params)
+GL_ENTRY(void, glGetSamplerParameterfv, GLuint sampler, GLenum pname, GLfloat * params)
+GL_ENTRY(void, glGetSamplerParameteriv, GLuint sampler, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetShaderInfoLog, GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog)
+GL_ENTRY(void, glGetShaderPrecisionFormat, GLenum shadertype, GLenum precisiontype, GLint * range, GLint * precision)
+GL_ENTRY(void, glGetShaderSource, GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source)
+GL_ENTRY(void, glGetShaderiv, GLuint shader, GLenum pname, GLint * params)
 GL_ENTRY(const GLubyte *, glGetString, GLenum name)
-GL_ENTRY(const GLubyte*, glGetStringi, GLenum name, GLuint index)
-GL_ENTRY(void, glGetSynciv, GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
-GL_ENTRY(void, glGetTexEnvfv, GLenum env, GLenum pname, GLfloat *params)
-GL_ENTRY(void, glGetTexEnviv, GLenum env, GLenum pname, GLint *params)
-GL_ENTRY(void, glGetTexEnvxv, GLenum env, GLenum pname, GLfixed *params)
-GL_ENTRY(void, glGetTexEnvxvOES, GLenum env, GLenum pname, GLfixed *params)
-GL_ENTRY(void, glGetTexGenfvOES, GLenum coord, GLenum pname, GLfloat *params)
-GL_ENTRY(void, glGetTexGenivOES, GLenum coord, GLenum pname, GLint *params)
-GL_ENTRY(void, glGetTexGenxvOES, GLenum coord, GLenum pname, GLfixed *params)
-GL_ENTRY(void, glGetTexParameterfv, GLenum target, GLenum pname, GLfloat *params)
-GL_ENTRY(void, glGetTexParameteriv, GLenum target, GLenum pname, GLint *params)
-GL_ENTRY(void, glGetTexParameterxv, GLenum target, GLenum pname, GLfixed *params)
-GL_ENTRY(void, glGetTexParameterxvOES, GLenum target, GLenum pname, GLfixed *params)
-GL_ENTRY(void, glGetTransformFeedbackVarying, GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
-GL_ENTRY(GLuint, glGetUniformBlockIndex, GLuint program, const GLchar* uniformBlockName)
-GL_ENTRY(void, glGetUniformIndices, GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
-GL_ENTRY(GLint, glGetUniformLocation, GLuint program, const GLchar* name)
-GL_ENTRY(void, glGetUniformfv, GLuint program, GLint location, GLfloat* params)
-GL_ENTRY(void, glGetUniformiv, GLuint program, GLint location, GLint* params)
-GL_ENTRY(void, glGetUniformuiv, GLuint program, GLint location, GLuint* params)
-GL_ENTRY(void, glGetVertexAttribIiv, GLuint index, GLenum pname, GLint* params)
-GL_ENTRY(void, glGetVertexAttribIuiv, GLuint index, GLenum pname, GLuint* params)
-GL_ENTRY(void, glGetVertexAttribPointerv, GLuint index, GLenum pname, GLvoid** pointer)
-GL_ENTRY(void, glGetVertexAttribfv, GLuint index, GLenum pname, GLfloat* params)
-GL_ENTRY(void, glGetVertexAttribiv, GLuint index, GLenum pname, GLint* params)
-GL_ENTRY(void, glGetnUniformfvEXT, GLuint program, GLint location, GLsizei bufSize, float *params)
-GL_ENTRY(void, glGetnUniformivEXT, GLuint program, GLint location, GLsizei bufSize, GLint *params)
+GL_ENTRY(const GLubyte *, glGetStringi, GLenum name, GLuint index)
+GL_ENTRY(void, glGetSynciv, GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values)
+GL_ENTRY(void, glGetSyncivAPPLE, GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values)
+GL_ENTRY(void, glGetTexEnvfv, GLenum target, GLenum pname, GLfloat * params)
+GL_ENTRY(void, glGetTexEnviv, GLenum target, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetTexEnvxv, GLenum target, GLenum pname, GLfixed * params)
+GL_ENTRY(void, glGetTexEnvxvOES, GLenum target, GLenum pname, GLfixed * params)
+GL_ENTRY(void, glGetTexGenfvOES, GLenum coord, GLenum pname, GLfloat * params)
+GL_ENTRY(void, glGetTexGenivOES, GLenum coord, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetTexGenxvOES, GLenum coord, GLenum pname, GLfixed * params)
+GL_ENTRY(void, glGetTexLevelParameterfv, GLenum target, GLint level, GLenum pname, GLfloat * params)
+GL_ENTRY(void, glGetTexLevelParameteriv, GLenum target, GLint level, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetTexParameterIivEXT, GLenum target, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetTexParameterIuivEXT, GLenum target, GLenum pname, GLuint * params)
+GL_ENTRY(void, glGetTexParameterfv, GLenum target, GLenum pname, GLfloat * params)
+GL_ENTRY(void, glGetTexParameteriv, GLenum target, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetTexParameterxv, GLenum target, GLenum pname, GLfixed * params)
+GL_ENTRY(void, glGetTexParameterxvOES, GLenum target, GLenum pname, GLfixed * params)
+GL_ENTRY(void, glGetTransformFeedbackVarying, GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name)
+GL_ENTRY(void, glGetTranslatedShaderSourceANGLE, GLuint shader, GLsizei bufsize, GLsizei * length, GLchar * source)
+GL_ENTRY(GLuint, glGetUniformBlockIndex, GLuint program, const GLchar * uniformBlockName)
+GL_ENTRY(void, glGetUniformIndices, GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices)
+GL_ENTRY(GLint, glGetUniformLocation, GLuint program, const GLchar * name)
+GL_ENTRY(void, glGetUniformfv, GLuint program, GLint location, GLfloat * params)
+GL_ENTRY(void, glGetUniformiv, GLuint program, GLint location, GLint * params)
+GL_ENTRY(void, glGetUniformuiv, GLuint program, GLint location, GLuint * params)
+GL_ENTRY(void, glGetVertexAttribIiv, GLuint index, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetVertexAttribIuiv, GLuint index, GLenum pname, GLuint * params)
+GL_ENTRY(void, glGetVertexAttribPointerv, GLuint index, GLenum pname, void ** pointer)
+GL_ENTRY(void, glGetVertexAttribfv, GLuint index, GLenum pname, GLfloat * params)
+GL_ENTRY(void, glGetVertexAttribiv, GLuint index, GLenum pname, GLint * params)
+GL_ENTRY(void, glGetnUniformfvEXT, GLuint program, GLint location, GLsizei bufSize, GLfloat * params)
+GL_ENTRY(void, glGetnUniformivEXT, GLuint program, GLint location, GLsizei bufSize, GLint * params)
 GL_ENTRY(void, glHint, GLenum target, GLenum mode)
-GL_ENTRY(void, glInsertEventMarkerEXT, GLsizei length, const GLchar *marker)
-GL_ENTRY(void, glInvalidateFramebuffer, GLenum target, GLsizei numAttachments, const GLenum* attachments)
-GL_ENTRY(void, glInvalidateSubFramebuffer, GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
+GL_ENTRY(void, glInsertEventMarkerEXT, GLsizei length, const GLchar * marker)
+GL_ENTRY(void, glInvalidateFramebuffer, GLenum target, GLsizei numAttachments, const GLenum * attachments)
+GL_ENTRY(void, glInvalidateSubFramebuffer, GLenum target, GLsizei numAttachments, const GLenum * attachments, GLint x, GLint y, GLsizei width, GLsizei height)
 GL_ENTRY(GLboolean, glIsBuffer, GLuint buffer)
 GL_ENTRY(GLboolean, glIsEnabled, GLenum cap)
+GL_ENTRY(GLboolean, glIsEnablediEXT, GLenum target, GLuint index)
 GL_ENTRY(GLboolean, glIsFenceNV, GLuint fence)
 GL_ENTRY(GLboolean, glIsFramebuffer, GLuint framebuffer)
 GL_ENTRY(GLboolean, glIsFramebufferOES, GLuint framebuffer)
 GL_ENTRY(GLboolean, glIsProgram, GLuint program)
+GL_ENTRY(GLboolean, glIsProgramPipeline, GLuint pipeline)
 GL_ENTRY(GLboolean, glIsProgramPipelineEXT, GLuint pipeline)
 GL_ENTRY(GLboolean, glIsQuery, GLuint id)
 GL_ENTRY(GLboolean, glIsQueryEXT, GLuint id)
@@ -302,106 +383,174 @@
 GL_ENTRY(GLboolean, glIsSampler, GLuint sampler)
 GL_ENTRY(GLboolean, glIsShader, GLuint shader)
 GL_ENTRY(GLboolean, glIsSync, GLsync sync)
+GL_ENTRY(GLboolean, glIsSyncAPPLE, GLsync sync)
 GL_ENTRY(GLboolean, glIsTexture, GLuint texture)
 GL_ENTRY(GLboolean, glIsTransformFeedback, GLuint id)
 GL_ENTRY(GLboolean, glIsVertexArray, GLuint array)
 GL_ENTRY(GLboolean, glIsVertexArrayOES, GLuint array)
-GL_ENTRY(void, glLabelObjectEXT, GLenum type, GLuint object, GLsizei length, const GLchar *label)
+GL_ENTRY(void, glLabelObjectEXT, GLenum type, GLuint object, GLsizei length, const GLchar * label)
 GL_ENTRY(void, glLightModelf, GLenum pname, GLfloat param)
-GL_ENTRY(void, glLightModelfv, GLenum pname, const GLfloat *params)
+GL_ENTRY(void, glLightModelfv, GLenum pname, const GLfloat * params)
 GL_ENTRY(void, glLightModelx, GLenum pname, GLfixed param)
 GL_ENTRY(void, glLightModelxOES, GLenum pname, GLfixed param)
-GL_ENTRY(void, glLightModelxv, GLenum pname, const GLfixed *params)
-GL_ENTRY(void, glLightModelxvOES, GLenum pname, const GLfixed *params)
+GL_ENTRY(void, glLightModelxv, GLenum pname, const GLfixed * param)
+GL_ENTRY(void, glLightModelxvOES, GLenum pname, const GLfixed * param)
 GL_ENTRY(void, glLightf, GLenum light, GLenum pname, GLfloat param)
-GL_ENTRY(void, glLightfv, GLenum light, GLenum pname, const GLfloat *params)
+GL_ENTRY(void, glLightfv, GLenum light, GLenum pname, const GLfloat * params)
 GL_ENTRY(void, glLightx, GLenum light, GLenum pname, GLfixed param)
 GL_ENTRY(void, glLightxOES, GLenum light, GLenum pname, GLfixed param)
-GL_ENTRY(void, glLightxv, GLenum light, GLenum pname, const GLfixed *params)
-GL_ENTRY(void, glLightxvOES, GLenum light, GLenum pname, const GLfixed *params)
+GL_ENTRY(void, glLightxv, GLenum light, GLenum pname, const GLfixed * params)
+GL_ENTRY(void, glLightxvOES, GLenum light, GLenum pname, const GLfixed * params)
 GL_ENTRY(void, glLineWidth, GLfloat width)
 GL_ENTRY(void, glLineWidthx, GLfixed width)
 GL_ENTRY(void, glLineWidthxOES, GLfixed width)
 GL_ENTRY(void, glLinkProgram, GLuint program)
 GL_ENTRY(void, glLoadIdentity, void)
-GL_ENTRY(void, glLoadMatrixf, const GLfloat *m)
-GL_ENTRY(void, glLoadMatrixx, const GLfixed *m)
-GL_ENTRY(void, glLoadMatrixxOES, const GLfixed *m)
+GL_ENTRY(void, glLoadMatrixf, const GLfloat * m)
+GL_ENTRY(void, glLoadMatrixx, const GLfixed * m)
+GL_ENTRY(void, glLoadMatrixxOES, const GLfixed * m)
 GL_ENTRY(void, glLoadPaletteFromModelViewMatrixOES, void)
 GL_ENTRY(void, glLogicOp, GLenum opcode)
-GL_ENTRY(void*, glMapBufferOES, GLenum target, GLenum access)
-GL_ENTRY(GLvoid*, glMapBufferRange, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
+GL_ENTRY(void *, glMapBufferOES, GLenum target, GLenum access)
+GL_ENTRY(void *, glMapBufferRange, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
+GL_ENTRY(void *, glMapBufferRangeEXT, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
 GL_ENTRY(void, glMaterialf, GLenum face, GLenum pname, GLfloat param)
-GL_ENTRY(void, glMaterialfv, GLenum face, GLenum pname, const GLfloat *params)
+GL_ENTRY(void, glMaterialfv, GLenum face, GLenum pname, const GLfloat * params)
 GL_ENTRY(void, glMaterialx, GLenum face, GLenum pname, GLfixed param)
 GL_ENTRY(void, glMaterialxOES, GLenum face, GLenum pname, GLfixed param)
-GL_ENTRY(void, glMaterialxv, GLenum face, GLenum pname, const GLfixed *params)
-GL_ENTRY(void, glMaterialxvOES, GLenum face, GLenum pname, const GLfixed *params)
-GL_ENTRY(void, glMatrixIndexPointerOES, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
+GL_ENTRY(void, glMaterialxv, GLenum face, GLenum pname, const GLfixed * param)
+GL_ENTRY(void, glMaterialxvOES, GLenum face, GLenum pname, const GLfixed * param)
+GL_ENTRY(void, glMatrixIndexPointerOES, GLint size, GLenum type, GLsizei stride, const void * pointer)
 GL_ENTRY(void, glMatrixMode, GLenum mode)
-GL_ENTRY(void, glMultMatrixf, const GLfloat *m)
-GL_ENTRY(void, glMultMatrixx, const GLfixed *m)
-GL_ENTRY(void, glMultMatrixxOES, const GLfixed *m)
-GL_ENTRY(void, glMultiDrawArraysEXT, GLenum mode, GLint *first, GLsizei *count, GLsizei primcount)
-GL_ENTRY(void, glMultiDrawElementsEXT, GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount)
+GL_ENTRY(void, glMemoryBarrier, GLbitfield barriers)
+GL_ENTRY(void, glMemoryBarrierByRegion, GLbitfield barriers)
+GL_ENTRY(void, glMinSampleShadingOES, GLfloat value)
+GL_ENTRY(void, glMultMatrixf, const GLfloat * m)
+GL_ENTRY(void, glMultMatrixx, const GLfixed * m)
+GL_ENTRY(void, glMultMatrixxOES, const GLfixed * m)
+GL_ENTRY(void, glMultiDrawArraysEXT, GLenum mode, const GLint * first, const GLsizei * count, GLsizei primcount)
+GL_ENTRY(void, glMultiDrawElementsEXT, GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei primcount)
+GL_ENTRY(void, glMultiTexCoord1bOES, GLenum texture, GLbyte s)
+GL_ENTRY(void, glMultiTexCoord1bvOES, GLenum texture, const GLbyte * coords)
+GL_ENTRY(void, glMultiTexCoord2bOES, GLenum texture, GLbyte s, GLbyte t)
+GL_ENTRY(void, glMultiTexCoord2bvOES, GLenum texture, const GLbyte * coords)
+GL_ENTRY(void, glMultiTexCoord3bOES, GLenum texture, GLbyte s, GLbyte t, GLbyte r)
+GL_ENTRY(void, glMultiTexCoord3bvOES, GLenum texture, const GLbyte * coords)
+GL_ENTRY(void, glMultiTexCoord4bOES, GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q)
+GL_ENTRY(void, glMultiTexCoord4bvOES, GLenum texture, const GLbyte * coords)
 GL_ENTRY(void, glMultiTexCoord4f, GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
-GL_ENTRY(void, glMultiTexCoord4x, GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
-GL_ENTRY(void, glMultiTexCoord4xOES, GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
+GL_ENTRY(void, glMultiTexCoord4x, GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
+GL_ENTRY(void, glMultiTexCoord4xOES, GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
 GL_ENTRY(void, glNormal3f, GLfloat nx, GLfloat ny, GLfloat nz)
 GL_ENTRY(void, glNormal3x, GLfixed nx, GLfixed ny, GLfixed nz)
 GL_ENTRY(void, glNormal3xOES, GLfixed nx, GLfixed ny, GLfixed nz)
-GL_ENTRY(void, glNormalPointer, GLenum type, GLsizei stride, const GLvoid *pointer)
-GL_ENTRY(void, glOrthof, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
-GL_ENTRY(void, glOrthofOES, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
-GL_ENTRY(void, glOrthox, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
-GL_ENTRY(void, glOrthoxOES, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+GL_ENTRY(void, glNormalPointer, GLenum type, GLsizei stride, const void * pointer)
+GL_ENTRY(void, glObjectLabelKHR, GLenum identifier, GLuint name, GLsizei length, const GLchar * label)
+GL_ENTRY(void, glObjectPtrLabelKHR, const void * ptr, GLsizei length, const GLchar * label)
+GL_ENTRY(void, glOrthof, GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f)
+GL_ENTRY(void, glOrthofOES, GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f)
+GL_ENTRY(void, glOrthox, GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f)
+GL_ENTRY(void, glOrthoxOES, GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f)
+GL_ENTRY(void, glPatchParameteriEXT, GLenum pname, GLint value)
 GL_ENTRY(void, glPauseTransformFeedback, void)
 GL_ENTRY(void, glPixelStorei, GLenum pname, GLint param)
 GL_ENTRY(void, glPointParameterf, GLenum pname, GLfloat param)
-GL_ENTRY(void, glPointParameterfv, GLenum pname, const GLfloat *params)
+GL_ENTRY(void, glPointParameterfv, GLenum pname, const GLfloat * params)
 GL_ENTRY(void, glPointParameterx, GLenum pname, GLfixed param)
 GL_ENTRY(void, glPointParameterxOES, GLenum pname, GLfixed param)
-GL_ENTRY(void, glPointParameterxv, GLenum pname, const GLfixed *params)
-GL_ENTRY(void, glPointParameterxvOES, GLenum pname, const GLfixed *params)
+GL_ENTRY(void, glPointParameterxv, GLenum pname, const GLfixed * params)
+GL_ENTRY(void, glPointParameterxvOES, GLenum pname, const GLfixed * params)
 GL_ENTRY(void, glPointSize, GLfloat size)
-GL_ENTRY(void, glPointSizePointerOES, GLenum type, GLsizei stride, const GLvoid *pointer)
+GL_ENTRY(void, glPointSizePointerOES, GLenum type, GLsizei stride, const void * pointer)
 GL_ENTRY(void, glPointSizex, GLfixed size)
 GL_ENTRY(void, glPointSizexOES, GLfixed size)
 GL_ENTRY(void, glPolygonOffset, GLfloat factor, GLfloat units)
 GL_ENTRY(void, glPolygonOffsetx, GLfixed factor, GLfixed units)
 GL_ENTRY(void, glPolygonOffsetxOES, GLfixed factor, GLfixed units)
+GL_ENTRY(void, glPopDebugGroupKHR, void)
 GL_ENTRY(void, glPopGroupMarkerEXT, void)
 GL_ENTRY(void, glPopMatrix, void)
-GL_ENTRY(void, glProgramBinary, GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
-GL_ENTRY(void, glProgramBinaryOES, GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length)
+GL_ENTRY(void, glPrimitiveBoundingBoxEXT, GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW)
+GL_ENTRY(void, glProgramBinary, GLuint program, GLenum binaryFormat, const void * binary, GLsizei length)
+GL_ENTRY(void, glProgramBinaryOES, GLuint program, GLenum binaryFormat, const void * binary, GLint length)
 GL_ENTRY(void, glProgramParameteri, GLuint program, GLenum pname, GLint value)
 GL_ENTRY(void, glProgramParameteriEXT, GLuint program, GLenum pname, GLint value)
-GL_ENTRY(void, glProgramUniform1fEXT, GLuint program, GLint location, GLfloat x)
-GL_ENTRY(void, glProgramUniform1fvEXT, GLuint program, GLint location, GLsizei count, const GLfloat *value)
-GL_ENTRY(void, glProgramUniform1iEXT, GLuint program, GLint location, GLint x)
-GL_ENTRY(void, glProgramUniform1ivEXT, GLuint program, GLint location, GLsizei count, const GLint *value)
-GL_ENTRY(void, glProgramUniform2fEXT, GLuint program, GLint location, GLfloat x, GLfloat y)
-GL_ENTRY(void, glProgramUniform2fvEXT, GLuint program, GLint location, GLsizei count, const GLfloat *value)
-GL_ENTRY(void, glProgramUniform2iEXT, GLuint program, GLint location, GLint x, GLint y)
-GL_ENTRY(void, glProgramUniform2ivEXT, GLuint program, GLint location, GLsizei count, const GLint *value)
-GL_ENTRY(void, glProgramUniform3fEXT, GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z)
-GL_ENTRY(void, glProgramUniform3fvEXT, GLuint program, GLint location, GLsizei count, const GLfloat *value)
-GL_ENTRY(void, glProgramUniform3iEXT, GLuint program, GLint location, GLint x, GLint y, GLint z)
-GL_ENTRY(void, glProgramUniform3ivEXT, GLuint program, GLint location, GLsizei count, const GLint *value)
-GL_ENTRY(void, glProgramUniform4fEXT, GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-GL_ENTRY(void, glProgramUniform4fvEXT, GLuint program, GLint location, GLsizei count, const GLfloat *value)
-GL_ENTRY(void, glProgramUniform4iEXT, GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w)
-GL_ENTRY(void, glProgramUniform4ivEXT, GLuint program, GLint location, GLsizei count, const GLint *value)
-GL_ENTRY(void, glProgramUniformMatrix2fvEXT, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-GL_ENTRY(void, glProgramUniformMatrix3fvEXT, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-GL_ENTRY(void, glProgramUniformMatrix4fvEXT, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-GL_ENTRY(void, glPushGroupMarkerEXT, GLsizei length, const GLchar *marker)
+GL_ENTRY(void, glProgramUniform1f, GLuint program, GLint location, GLfloat v0)
+GL_ENTRY(void, glProgramUniform1fEXT, GLuint program, GLint location, GLfloat v0)
+GL_ENTRY(void, glProgramUniform1fv, GLuint program, GLint location, GLsizei count, const GLfloat * value)
+GL_ENTRY(void, glProgramUniform1fvEXT, GLuint program, GLint location, GLsizei count, const GLfloat * value)
+GL_ENTRY(void, glProgramUniform1i, GLuint program, GLint location, GLint v0)
+GL_ENTRY(void, glProgramUniform1iEXT, GLuint program, GLint location, GLint v0)
+GL_ENTRY(void, glProgramUniform1iv, GLuint program, GLint location, GLsizei count, const GLint * value)
+GL_ENTRY(void, glProgramUniform1ivEXT, GLuint program, GLint location, GLsizei count, const GLint * value)
+GL_ENTRY(void, glProgramUniform1ui, GLuint program, GLint location, GLuint v0)
+GL_ENTRY(void, glProgramUniform1uiEXT, GLuint program, GLint location, GLuint v0)
+GL_ENTRY(void, glProgramUniform1uiv, GLuint program, GLint location, GLsizei count, const GLuint * value)
+GL_ENTRY(void, glProgramUniform1uivEXT, GLuint program, GLint location, GLsizei count, const GLuint * value)
+GL_ENTRY(void, glProgramUniform2f, GLuint program, GLint location, GLfloat v0, GLfloat v1)
+GL_ENTRY(void, glProgramUniform2fEXT, GLuint program, GLint location, GLfloat v0, GLfloat v1)
+GL_ENTRY(void, glProgramUniform2fv, GLuint program, GLint location, GLsizei count, const GLfloat * value)
+GL_ENTRY(void, glProgramUniform2fvEXT, GLuint program, GLint location, GLsizei count, const GLfloat * value)
+GL_ENTRY(void, glProgramUniform2i, GLuint program, GLint location, GLint v0, GLint v1)
+GL_ENTRY(void, glProgramUniform2iEXT, GLuint program, GLint location, GLint v0, GLint v1)
+GL_ENTRY(void, glProgramUniform2iv, GLuint program, GLint location, GLsizei count, const GLint * value)
+GL_ENTRY(void, glProgramUniform2ivEXT, GLuint program, GLint location, GLsizei count, const GLint * value)
+GL_ENTRY(void, glProgramUniform2ui, GLuint program, GLint location, GLuint v0, GLuint v1)
+GL_ENTRY(void, glProgramUniform2uiEXT, GLuint program, GLint location, GLuint v0, GLuint v1)
+GL_ENTRY(void, glProgramUniform2uiv, GLuint program, GLint location, GLsizei count, const GLuint * value)
+GL_ENTRY(void, glProgramUniform2uivEXT, GLuint program, GLint location, GLsizei count, const GLuint * value)
+GL_ENTRY(void, glProgramUniform3f, GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
+GL_ENTRY(void, glProgramUniform3fEXT, GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
+GL_ENTRY(void, glProgramUniform3fv, GLuint program, GLint location, GLsizei count, const GLfloat * value)
+GL_ENTRY(void, glProgramUniform3fvEXT, GLuint program, GLint location, GLsizei count, const GLfloat * value)
+GL_ENTRY(void, glProgramUniform3i, GLuint program, GLint location, GLint v0, GLint v1, GLint v2)
+GL_ENTRY(void, glProgramUniform3iEXT, GLuint program, GLint location, GLint v0, GLint v1, GLint v2)
+GL_ENTRY(void, glProgramUniform3iv, GLuint program, GLint location, GLsizei count, const GLint * value)
+GL_ENTRY(void, glProgramUniform3ivEXT, GLuint program, GLint location, GLsizei count, const GLint * value)
+GL_ENTRY(void, glProgramUniform3ui, GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2)
+GL_ENTRY(void, glProgramUniform3uiEXT, GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2)
+GL_ENTRY(void, glProgramUniform3uiv, GLuint program, GLint location, GLsizei count, const GLuint * value)
+GL_ENTRY(void, glProgramUniform3uivEXT, GLuint program, GLint location, GLsizei count, const GLuint * value)
+GL_ENTRY(void, glProgramUniform4f, GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
+GL_ENTRY(void, glProgramUniform4fEXT, GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
+GL_ENTRY(void, glProgramUniform4fv, GLuint program, GLint location, GLsizei count, const GLfloat * value)
+GL_ENTRY(void, glProgramUniform4fvEXT, GLuint program, GLint location, GLsizei count, const GLfloat * value)
+GL_ENTRY(void, glProgramUniform4i, GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
+GL_ENTRY(void, glProgramUniform4iEXT, GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
+GL_ENTRY(void, glProgramUniform4iv, GLuint program, GLint location, GLsizei count, const GLint * value)
+GL_ENTRY(void, glProgramUniform4ivEXT, GLuint program, GLint location, GLsizei count, const GLint * value)
+GL_ENTRY(void, glProgramUniform4ui, GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
+GL_ENTRY(void, glProgramUniform4uiEXT, GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
+GL_ENTRY(void, glProgramUniform4uiv, GLuint program, GLint location, GLsizei count, const GLuint * value)
+GL_ENTRY(void, glProgramUniform4uivEXT, GLuint program, GLint location, GLsizei count, const GLuint * value)
+GL_ENTRY(void, glProgramUniformMatrix2fv, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix2fvEXT, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix2x3fv, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix2x3fvEXT, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix2x4fv, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix2x4fvEXT, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix3fv, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix3fvEXT, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix3x2fv, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix3x2fvEXT, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix3x4fv, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix3x4fvEXT, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix4fv, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix4fvEXT, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix4x2fv, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix4x2fvEXT, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix4x3fv, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glProgramUniformMatrix4x3fvEXT, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glPushDebugGroupKHR, GLenum source, GLuint id, GLsizei length, const GLchar * message)
+GL_ENTRY(void, glPushGroupMarkerEXT, GLsizei length, const GLchar * marker)
 GL_ENTRY(void, glPushMatrix, void)
-GL_ENTRY(GLbitfield, glQueryMatrixxOES, GLfixed mantissa[16], GLint exponent[16])
+GL_ENTRY(void, glQueryCounterEXT, GLuint id, GLenum target)
+GL_ENTRY(GLbitfield, glQueryMatrixxOES, GLfixed * mantissa, GLint * exponent)
 GL_ENTRY(void, glReadBuffer, GLenum mode)
+GL_ENTRY(void, glReadBufferIndexedEXT, GLenum src, GLint index)
 GL_ENTRY(void, glReadBufferNV, GLenum mode)
-GL_ENTRY(void, glReadPixels, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
-GL_ENTRY(void, glReadnPixelsEXT, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data)
+GL_ENTRY(void, glReadPixels, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels)
+GL_ENTRY(void, glReadnPixelsEXT, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data)
 GL_ENTRY(void, glReleaseShaderCompiler, void)
 GL_ENTRY(void, glRenderbufferStorage, GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
 GL_ENTRY(void, glRenderbufferStorageMultisample, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
@@ -409,133 +558,175 @@
 GL_ENTRY(void, glRenderbufferStorageMultisampleAPPLE, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
 GL_ENTRY(void, glRenderbufferStorageMultisampleEXT, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
 GL_ENTRY(void, glRenderbufferStorageMultisampleIMG, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
+GL_ENTRY(void, glRenderbufferStorageMultisampleNV, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
 GL_ENTRY(void, glRenderbufferStorageOES, GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
 GL_ENTRY(void, glResolveMultisampleFramebufferAPPLE, void)
 GL_ENTRY(void, glResumeTransformFeedback, void)
 GL_ENTRY(void, glRotatef, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
 GL_ENTRY(void, glRotatex, GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
 GL_ENTRY(void, glRotatexOES, GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
-GL_ENTRY(void, glSampleCoverage, GLclampf value, GLboolean invert)
+GL_ENTRY(void, glSampleCoverage, GLfloat value, GLboolean invert)
+GL_ENTRY(void, glSampleCoverageOES, GLfixed value, GLboolean invert)
 GL_ENTRY(void, glSampleCoveragex, GLclampx value, GLboolean invert)
 GL_ENTRY(void, glSampleCoveragexOES, GLclampx value, GLboolean invert)
+GL_ENTRY(void, glSampleMaski, GLuint maskNumber, GLbitfield mask)
+GL_ENTRY(void, glSamplerParameterIivEXT, GLuint sampler, GLenum pname, const GLint * param)
+GL_ENTRY(void, glSamplerParameterIuivEXT, GLuint sampler, GLenum pname, const GLuint * param)
 GL_ENTRY(void, glSamplerParameterf, GLuint sampler, GLenum pname, GLfloat param)
-GL_ENTRY(void, glSamplerParameterfv, GLuint sampler, GLenum pname, const GLfloat* param)
+GL_ENTRY(void, glSamplerParameterfv, GLuint sampler, GLenum pname, const GLfloat * param)
 GL_ENTRY(void, glSamplerParameteri, GLuint sampler, GLenum pname, GLint param)
-GL_ENTRY(void, glSamplerParameteriv, GLuint sampler, GLenum pname, const GLint* param)
+GL_ENTRY(void, glSamplerParameteriv, GLuint sampler, GLenum pname, const GLint * param)
 GL_ENTRY(void, glScalef, GLfloat x, GLfloat y, GLfloat z)
 GL_ENTRY(void, glScalex, GLfixed x, GLfixed y, GLfixed z)
 GL_ENTRY(void, glScalexOES, GLfixed x, GLfixed y, GLfixed z)
 GL_ENTRY(void, glScissor, GLint x, GLint y, GLsizei width, GLsizei height)
-GL_ENTRY(void, glSelectPerfMonitorCountersAMD, GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList)
+GL_ENTRY(void, glSelectPerfMonitorCountersAMD, GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint * counterList)
 GL_ENTRY(void, glSetFenceNV, GLuint fence, GLenum condition)
 GL_ENTRY(void, glShadeModel, GLenum mode)
-GL_ENTRY(void, glShaderBinary, GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
-GL_ENTRY(void, glShaderSource, GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
+GL_ENTRY(void, glShaderBinary, GLsizei count, const GLuint * shaders, GLenum binaryformat, const void * binary, GLsizei length)
+GL_ENTRY(void, glShaderSource, GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length)
 GL_ENTRY(void, glStartTilingQCOM, GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask)
 GL_ENTRY(void, glStencilFunc, GLenum func, GLint ref, GLuint mask)
 GL_ENTRY(void, glStencilFuncSeparate, GLenum face, GLenum func, GLint ref, GLuint mask)
 GL_ENTRY(void, glStencilMask, GLuint mask)
 GL_ENTRY(void, glStencilMaskSeparate, GLenum face, GLuint mask)
 GL_ENTRY(void, glStencilOp, GLenum fail, GLenum zfail, GLenum zpass)
-GL_ENTRY(void, glStencilOpSeparate, GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+GL_ENTRY(void, glStencilOpSeparate, GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass)
 GL_ENTRY(GLboolean, glTestFenceNV, GLuint fence)
-GL_ENTRY(void, glTexCoordPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
+GL_ENTRY(void, glTexBufferEXT, GLenum target, GLenum internalformat, GLuint buffer)
+GL_ENTRY(void, glTexBufferRangeEXT, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size)
+GL_ENTRY(void, glTexCoord1bOES, GLbyte s)
+GL_ENTRY(void, glTexCoord1bvOES, const GLbyte * coords)
+GL_ENTRY(void, glTexCoord2bOES, GLbyte s, GLbyte t)
+GL_ENTRY(void, glTexCoord2bvOES, const GLbyte * coords)
+GL_ENTRY(void, glTexCoord3bOES, GLbyte s, GLbyte t, GLbyte r)
+GL_ENTRY(void, glTexCoord3bvOES, const GLbyte * coords)
+GL_ENTRY(void, glTexCoord4bOES, GLbyte s, GLbyte t, GLbyte r, GLbyte q)
+GL_ENTRY(void, glTexCoord4bvOES, const GLbyte * coords)
+GL_ENTRY(void, glTexCoordPointer, GLint size, GLenum type, GLsizei stride, const void * pointer)
 GL_ENTRY(void, glTexEnvf, GLenum target, GLenum pname, GLfloat param)
-GL_ENTRY(void, glTexEnvfv, GLenum target, GLenum pname, const GLfloat *params)
+GL_ENTRY(void, glTexEnvfv, GLenum target, GLenum pname, const GLfloat * params)
 GL_ENTRY(void, glTexEnvi, GLenum target, GLenum pname, GLint param)
-GL_ENTRY(void, glTexEnviv, GLenum target, GLenum pname, const GLint *params)
+GL_ENTRY(void, glTexEnviv, GLenum target, GLenum pname, const GLint * params)
 GL_ENTRY(void, glTexEnvx, GLenum target, GLenum pname, GLfixed param)
 GL_ENTRY(void, glTexEnvxOES, GLenum target, GLenum pname, GLfixed param)
-GL_ENTRY(void, glTexEnvxv, GLenum target, GLenum pname, const GLfixed *params)
-GL_ENTRY(void, glTexEnvxvOES, GLenum target, GLenum pname, const GLfixed *params)
+GL_ENTRY(void, glTexEnvxv, GLenum target, GLenum pname, const GLfixed * params)
+GL_ENTRY(void, glTexEnvxvOES, GLenum target, GLenum pname, const GLfixed * params)
 GL_ENTRY(void, glTexGenfOES, GLenum coord, GLenum pname, GLfloat param)
-GL_ENTRY(void, glTexGenfvOES, GLenum coord, GLenum pname, const GLfloat *params)
+GL_ENTRY(void, glTexGenfvOES, GLenum coord, GLenum pname, const GLfloat * params)
 GL_ENTRY(void, glTexGeniOES, GLenum coord, GLenum pname, GLint param)
-GL_ENTRY(void, glTexGenivOES, GLenum coord, GLenum pname, const GLint *params)
+GL_ENTRY(void, glTexGenivOES, GLenum coord, GLenum pname, const GLint * params)
 GL_ENTRY(void, glTexGenxOES, GLenum coord, GLenum pname, GLfixed param)
-GL_ENTRY(void, glTexGenxvOES, GLenum coord, GLenum pname, const GLfixed *params)
-GL_ENTRY(void, glTexImage2D, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
-GL_ENTRY(void, glTexImage3D, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
-GL_ENTRY(void, glTexImage3DOES, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
+GL_ENTRY(void, glTexGenxvOES, GLenum coord, GLenum pname, const GLfixed * params)
+GL_ENTRY(void, glTexImage2D, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels)
+GL_ENTRY(void, glTexImage3D, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels)
+GL_ENTRY(void, glTexImage3DOES, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels)
+GL_ENTRY(void, glTexParameterIivEXT, GLenum target, GLenum pname, const GLint * params)
+GL_ENTRY(void, glTexParameterIuivEXT, GLenum target, GLenum pname, const GLuint * params)
 GL_ENTRY(void, glTexParameterf, GLenum target, GLenum pname, GLfloat param)
-GL_ENTRY(void, glTexParameterfv, GLenum target, GLenum pname, const GLfloat *params)
+GL_ENTRY(void, glTexParameterfv, GLenum target, GLenum pname, const GLfloat * params)
 GL_ENTRY(void, glTexParameteri, GLenum target, GLenum pname, GLint param)
-GL_ENTRY(void, glTexParameteriv, GLenum target, GLenum pname, const GLint *params)
+GL_ENTRY(void, glTexParameteriv, GLenum target, GLenum pname, const GLint * params)
 GL_ENTRY(void, glTexParameterx, GLenum target, GLenum pname, GLfixed param)
 GL_ENTRY(void, glTexParameterxOES, GLenum target, GLenum pname, GLfixed param)
-GL_ENTRY(void, glTexParameterxv, GLenum target, GLenum pname, const GLfixed *params)
-GL_ENTRY(void, glTexParameterxvOES, GLenum target, GLenum pname, const GLfixed *params)
+GL_ENTRY(void, glTexParameterxv, GLenum target, GLenum pname, const GLfixed * params)
+GL_ENTRY(void, glTexParameterxvOES, GLenum target, GLenum pname, const GLfixed * params)
 GL_ENTRY(void, glTexStorage1DEXT, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width)
 GL_ENTRY(void, glTexStorage2D, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
 GL_ENTRY(void, glTexStorage2DEXT, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
+GL_ENTRY(void, glTexStorage2DMultisample, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations)
 GL_ENTRY(void, glTexStorage3D, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
 GL_ENTRY(void, glTexStorage3DEXT, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
-GL_ENTRY(void, glTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
-GL_ENTRY(void, 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_ENTRY(void, glTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
+GL_ENTRY(void, glTexStorage3DMultisampleOES, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations)
+GL_ENTRY(void, glTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels)
+GL_ENTRY(void, glTexSubImage3D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels)
+GL_ENTRY(void, glTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels)
 GL_ENTRY(void, glTextureStorage1DEXT, GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width)
 GL_ENTRY(void, glTextureStorage2DEXT, GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
 GL_ENTRY(void, glTextureStorage3DEXT, GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
-GL_ENTRY(void, glTransformFeedbackVaryings, GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
+GL_ENTRY(void, glTextureViewEXT, GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers)
+GL_ENTRY(void, glTransformFeedbackVaryings, GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode)
 GL_ENTRY(void, glTranslatef, GLfloat x, GLfloat y, GLfloat z)
 GL_ENTRY(void, glTranslatex, GLfixed x, GLfixed y, GLfixed z)
 GL_ENTRY(void, glTranslatexOES, GLfixed x, GLfixed y, GLfixed z)
-GL_ENTRY(void, glUniform1f, GLint location, GLfloat x)
-GL_ENTRY(void, glUniform1fv, GLint location, GLsizei count, const GLfloat* v)
-GL_ENTRY(void, glUniform1i, GLint location, GLint x)
-GL_ENTRY(void, glUniform1iv, GLint location, GLsizei count, const GLint* v)
+GL_ENTRY(void, glUniform1f, GLint location, GLfloat v0)
+GL_ENTRY(void, glUniform1fv, GLint location, GLsizei count, const GLfloat * value)
+GL_ENTRY(void, glUniform1i, GLint location, GLint v0)
+GL_ENTRY(void, glUniform1iv, GLint location, GLsizei count, const GLint * value)
 GL_ENTRY(void, glUniform1ui, GLint location, GLuint v0)
-GL_ENTRY(void, glUniform1uiv, GLint location, GLsizei count, const GLuint* value)
-GL_ENTRY(void, glUniform2f, GLint location, GLfloat x, GLfloat y)
-GL_ENTRY(void, glUniform2fv, GLint location, GLsizei count, const GLfloat* v)
-GL_ENTRY(void, glUniform2i, GLint location, GLint x, GLint y)
-GL_ENTRY(void, glUniform2iv, GLint location, GLsizei count, const GLint* v)
+GL_ENTRY(void, glUniform1uiv, GLint location, GLsizei count, const GLuint * value)
+GL_ENTRY(void, glUniform2f, GLint location, GLfloat v0, GLfloat v1)
+GL_ENTRY(void, glUniform2fv, GLint location, GLsizei count, const GLfloat * value)
+GL_ENTRY(void, glUniform2i, GLint location, GLint v0, GLint v1)
+GL_ENTRY(void, glUniform2iv, GLint location, GLsizei count, const GLint * value)
 GL_ENTRY(void, glUniform2ui, GLint location, GLuint v0, GLuint v1)
-GL_ENTRY(void, glUniform2uiv, GLint location, GLsizei count, const GLuint* value)
-GL_ENTRY(void, glUniform3f, GLint location, GLfloat x, GLfloat y, GLfloat z)
-GL_ENTRY(void, glUniform3fv, GLint location, GLsizei count, const GLfloat* v)
-GL_ENTRY(void, glUniform3i, GLint location, GLint x, GLint y, GLint z)
-GL_ENTRY(void, glUniform3iv, GLint location, GLsizei count, const GLint* v)
+GL_ENTRY(void, glUniform2uiv, GLint location, GLsizei count, const GLuint * value)
+GL_ENTRY(void, glUniform3f, GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
+GL_ENTRY(void, glUniform3fv, GLint location, GLsizei count, const GLfloat * value)
+GL_ENTRY(void, glUniform3i, GLint location, GLint v0, GLint v1, GLint v2)
+GL_ENTRY(void, glUniform3iv, GLint location, GLsizei count, const GLint * value)
 GL_ENTRY(void, glUniform3ui, GLint location, GLuint v0, GLuint v1, GLuint v2)
-GL_ENTRY(void, glUniform3uiv, GLint location, GLsizei count, const GLuint* value)
-GL_ENTRY(void, glUniform4f, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-GL_ENTRY(void, glUniform4fv, GLint location, GLsizei count, const GLfloat* v)
-GL_ENTRY(void, glUniform4i, GLint location, GLint x, GLint y, GLint z, GLint w)
-GL_ENTRY(void, glUniform4iv, GLint location, GLsizei count, const GLint* v)
+GL_ENTRY(void, glUniform3uiv, GLint location, GLsizei count, const GLuint * value)
+GL_ENTRY(void, glUniform4f, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
+GL_ENTRY(void, glUniform4fv, GLint location, GLsizei count, const GLfloat * value)
+GL_ENTRY(void, glUniform4i, GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
+GL_ENTRY(void, glUniform4iv, GLint location, GLsizei count, const GLint * value)
 GL_ENTRY(void, glUniform4ui, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
-GL_ENTRY(void, glUniform4uiv, GLint location, GLsizei count, const GLuint* value)
+GL_ENTRY(void, glUniform4uiv, GLint location, GLsizei count, const GLuint * value)
 GL_ENTRY(void, glUniformBlockBinding, GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
-GL_ENTRY(void, glUniformMatrix2fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-GL_ENTRY(void, glUniformMatrix2x3fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-GL_ENTRY(void, glUniformMatrix2x4fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-GL_ENTRY(void, glUniformMatrix3fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-GL_ENTRY(void, glUniformMatrix3x2fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-GL_ENTRY(void, glUniformMatrix3x4fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-GL_ENTRY(void, glUniformMatrix4fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-GL_ENTRY(void, glUniformMatrix4x2fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-GL_ENTRY(void, glUniformMatrix4x3fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+GL_ENTRY(void, glUniformMatrix2fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glUniformMatrix2x3fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glUniformMatrix2x3fvNV, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glUniformMatrix2x4fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glUniformMatrix2x4fvNV, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glUniformMatrix3fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glUniformMatrix3x2fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glUniformMatrix3x2fvNV, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glUniformMatrix3x4fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glUniformMatrix3x4fvNV, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glUniformMatrix4fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glUniformMatrix4x2fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glUniformMatrix4x2fvNV, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glUniformMatrix4x3fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+GL_ENTRY(void, glUniformMatrix4x3fvNV, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
 GL_ENTRY(GLboolean, glUnmapBuffer, GLenum target)
 GL_ENTRY(GLboolean, glUnmapBufferOES, GLenum target)
 GL_ENTRY(void, glUseProgram, GLuint program)
+GL_ENTRY(void, glUseProgramStages, GLuint pipeline, GLbitfield stages, GLuint program)
 GL_ENTRY(void, glUseProgramStagesEXT, GLuint pipeline, GLbitfield stages, GLuint program)
 GL_ENTRY(void, glValidateProgram, GLuint program)
+GL_ENTRY(void, glValidateProgramPipeline, GLuint pipeline)
 GL_ENTRY(void, glValidateProgramPipelineEXT, GLuint pipeline)
-GL_ENTRY(void, glVertexAttrib1f, GLuint indx, GLfloat x)
-GL_ENTRY(void, glVertexAttrib1fv, GLuint indx, const GLfloat* values)
-GL_ENTRY(void, glVertexAttrib2f, GLuint indx, GLfloat x, GLfloat y)
-GL_ENTRY(void, glVertexAttrib2fv, GLuint indx, const GLfloat* values)
-GL_ENTRY(void, glVertexAttrib3f, GLuint indx, GLfloat x, GLfloat y, GLfloat z)
-GL_ENTRY(void, glVertexAttrib3fv, GLuint indx, const GLfloat* values)
-GL_ENTRY(void, glVertexAttrib4f, GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-GL_ENTRY(void, glVertexAttrib4fv, GLuint indx, const GLfloat* values)
+GL_ENTRY(void, glVertex2bOES, GLbyte x)
+GL_ENTRY(void, glVertex2bvOES, const GLbyte * coords)
+GL_ENTRY(void, glVertex3bOES, GLbyte x, GLbyte y)
+GL_ENTRY(void, glVertex3bvOES, const GLbyte * coords)
+GL_ENTRY(void, glVertex4bOES, GLbyte x, GLbyte y, GLbyte z)
+GL_ENTRY(void, glVertex4bvOES, const GLbyte * coords)
+GL_ENTRY(void, glVertexAttrib1f, GLuint index, GLfloat x)
+GL_ENTRY(void, glVertexAttrib1fv, GLuint index, const GLfloat * v)
+GL_ENTRY(void, glVertexAttrib2f, GLuint index, GLfloat x, GLfloat y)
+GL_ENTRY(void, glVertexAttrib2fv, GLuint index, const GLfloat * v)
+GL_ENTRY(void, glVertexAttrib3f, GLuint index, GLfloat x, GLfloat y, GLfloat z)
+GL_ENTRY(void, glVertexAttrib3fv, GLuint index, const GLfloat * v)
+GL_ENTRY(void, glVertexAttrib4f, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+GL_ENTRY(void, glVertexAttrib4fv, GLuint index, const GLfloat * v)
+GL_ENTRY(void, glVertexAttribBinding, GLuint attribindex, GLuint bindingindex)
 GL_ENTRY(void, glVertexAttribDivisor, GLuint index, GLuint divisor)
+GL_ENTRY(void, glVertexAttribDivisorANGLE, GLuint index, GLuint divisor)
+GL_ENTRY(void, glVertexAttribDivisorEXT, GLuint index, GLuint divisor)
+GL_ENTRY(void, glVertexAttribDivisorNV, GLuint index, GLuint divisor)
+GL_ENTRY(void, glVertexAttribFormat, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset)
 GL_ENTRY(void, glVertexAttribI4i, GLuint index, GLint x, GLint y, GLint z, GLint w)
-GL_ENTRY(void, glVertexAttribI4iv, GLuint index, const GLint* v)
+GL_ENTRY(void, glVertexAttribI4iv, GLuint index, const GLint * v)
 GL_ENTRY(void, glVertexAttribI4ui, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
-GL_ENTRY(void, glVertexAttribI4uiv, GLuint index, const GLuint* v)
-GL_ENTRY(void, glVertexAttribIPointer, GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
-GL_ENTRY(void, glVertexAttribPointer, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
-GL_ENTRY(void, glVertexPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
+GL_ENTRY(void, glVertexAttribI4uiv, GLuint index, const GLuint * v)
+GL_ENTRY(void, glVertexAttribIFormat, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset)
+GL_ENTRY(void, glVertexAttribIPointer, GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer)
+GL_ENTRY(void, glVertexAttribPointer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer)
+GL_ENTRY(void, glVertexBindingDivisor, GLuint bindingindex, GLuint divisor)
+GL_ENTRY(void, glVertexPointer, GLint size, GLenum type, GLsizei stride, const void * pointer)
 GL_ENTRY(void, glViewport, GLint x, GLint y, GLsizei width, GLsizei height)
 GL_ENTRY(void, glWaitSync, GLsync sync, GLbitfield flags, GLuint64 timeout)
-GL_ENTRY(void, glWeightPointerOES, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
+GL_ENTRY(void, glWaitSyncAPPLE, GLsync sync, GLbitfield flags, GLuint64 timeout)
+GL_ENTRY(void, glWeightPointerOES, GLint size, GLenum type, GLsizei stride, const void * pointer)
diff --git a/opengl/libs/enums.in b/opengl/libs/enums.in
index 4279574..f3d216d 100644
--- a/opengl/libs/enums.in
+++ b/opengl/libs/enums.in
@@ -1,13 +1,10 @@
 GL_ENUM(0x0000,GL_POINTS)
-GL_ENUM(0x00000001,GL_VERTEX_SHADER_BIT_EXT)
-GL_ENUM(0x00000002,GL_FRAGMENT_SHADER_BIT_EXT)
 GL_ENUM(0x0001,GL_LINES)
 GL_ENUM(0x0002,GL_LINE_LOOP)
 GL_ENUM(0x0003,GL_LINE_STRIP)
 GL_ENUM(0x0004,GL_TRIANGLES)
 GL_ENUM(0x0005,GL_TRIANGLE_STRIP)
 GL_ENUM(0x0006,GL_TRIANGLE_FAN)
-GL_ENUM(0x0104,GL_ADD)
 GL_ENUM(0x0200,GL_NEVER)
 GL_ENUM(0x0201,GL_LESS)
 GL_ENUM(0x0202,GL_EQUAL)
@@ -25,49 +22,74 @@
 GL_ENUM(0x0306,GL_DST_COLOR)
 GL_ENUM(0x0307,GL_ONE_MINUS_DST_COLOR)
 GL_ENUM(0x0308,GL_SRC_ALPHA_SATURATE)
+GL_ENUM(0x3000,GL_CLIP_PLANE0)
+GL_ENUM(0x3001,GL_CLIP_PLANE1)
+GL_ENUM(0x3002,GL_CLIP_PLANE2)
+GL_ENUM(0x3003,GL_CLIP_PLANE3)
+GL_ENUM(0x3004,GL_CLIP_PLANE4)
+GL_ENUM(0x3005,GL_CLIP_PLANE5)
 GL_ENUM(0x0404,GL_FRONT)
 GL_ENUM(0x0405,GL_BACK)
 GL_ENUM(0x0408,GL_FRONT_AND_BACK)
+GL_ENUM(0x0B60,GL_FOG)
+GL_ENUM(0x0B50,GL_LIGHTING)
+GL_ENUM(0x0DE1,GL_TEXTURE_2D)
+GL_ENUM(0x0B44,GL_CULL_FACE)
+GL_ENUM(0x0BC0,GL_ALPHA_TEST)
+GL_ENUM(0x0BE2,GL_BLEND)
+GL_ENUM(0x0BF2,GL_COLOR_LOGIC_OP)
+GL_ENUM(0x0BD0,GL_DITHER)
+GL_ENUM(0x0B90,GL_STENCIL_TEST)
+GL_ENUM(0x0B71,GL_DEPTH_TEST)
+GL_ENUM(0x0B10,GL_POINT_SMOOTH)
+GL_ENUM(0x0B20,GL_LINE_SMOOTH)
+GL_ENUM(0x0C11,GL_SCISSOR_TEST)
+GL_ENUM(0x0B57,GL_COLOR_MATERIAL)
+GL_ENUM(0x0BA1,GL_NORMALIZE)
+GL_ENUM(0x803A,GL_RESCALE_NORMAL)
+GL_ENUM(0x8074,GL_VERTEX_ARRAY)
+GL_ENUM(0x8075,GL_NORMAL_ARRAY)
+GL_ENUM(0x8076,GL_COLOR_ARRAY)
+GL_ENUM(0x8078,GL_TEXTURE_COORD_ARRAY)
+GL_ENUM(0x809D,GL_MULTISAMPLE)
+GL_ENUM(0x809E,GL_SAMPLE_ALPHA_TO_COVERAGE)
+GL_ENUM(0x809F,GL_SAMPLE_ALPHA_TO_ONE)
+GL_ENUM(0x80A0,GL_SAMPLE_COVERAGE)
 GL_ENUM(0x0500,GL_INVALID_ENUM)
 GL_ENUM(0x0501,GL_INVALID_VALUE)
 GL_ENUM(0x0502,GL_INVALID_OPERATION)
 GL_ENUM(0x0503,GL_STACK_OVERFLOW)
 GL_ENUM(0x0504,GL_STACK_UNDERFLOW)
 GL_ENUM(0x0505,GL_OUT_OF_MEMORY)
-GL_ENUM(0x0506,GL_INVALID_FRAMEBUFFER_OPERATION_OES)
 GL_ENUM(0x0800,GL_EXP)
 GL_ENUM(0x0801,GL_EXP2)
-GL_ENUM(0x0900,GL_CW)
-GL_ENUM(0x0901,GL_CCW)
-GL_ENUM(0x0B00,GL_CURRENT_COLOR)
-GL_ENUM(0x0B02,GL_CURRENT_NORMAL)
-GL_ENUM(0x0B03,GL_CURRENT_TEXTURE_COORDS)
-GL_ENUM(0x0B10,GL_POINT_SMOOTH)
-GL_ENUM(0x0B11,GL_POINT_SIZE)
-GL_ENUM(0x0B12,GL_SMOOTH_POINT_SIZE_RANGE)
-GL_ENUM(0x0B20,GL_LINE_SMOOTH)
-GL_ENUM(0x0B21,GL_LINE_WIDTH)
-GL_ENUM(0x0B22,GL_SMOOTH_LINE_WIDTH_RANGE)
-GL_ENUM(0x0B44,GL_CULL_FACE)
-GL_ENUM(0x0B45,GL_CULL_FACE_MODE)
-GL_ENUM(0x0B46,GL_FRONT_FACE)
-GL_ENUM(0x0B50,GL_LIGHTING)
-GL_ENUM(0x0B52,GL_LIGHT_MODEL_TWO_SIDE)
-GL_ENUM(0x0B53,GL_LIGHT_MODEL_AMBIENT)
-GL_ENUM(0x0B54,GL_SHADE_MODEL)
-GL_ENUM(0x0B57,GL_COLOR_MATERIAL)
-GL_ENUM(0x0B60,GL_FOG)
 GL_ENUM(0x0B62,GL_FOG_DENSITY)
 GL_ENUM(0x0B63,GL_FOG_START)
 GL_ENUM(0x0B64,GL_FOG_END)
 GL_ENUM(0x0B65,GL_FOG_MODE)
 GL_ENUM(0x0B66,GL_FOG_COLOR)
+GL_ENUM(0x0900,GL_CW)
+GL_ENUM(0x0901,GL_CCW)
+GL_ENUM(0x0B00,GL_CURRENT_COLOR)
+GL_ENUM(0x0B02,GL_CURRENT_NORMAL)
+GL_ENUM(0x0B03,GL_CURRENT_TEXTURE_COORDS)
+GL_ENUM(0x0B11,GL_POINT_SIZE)
+GL_ENUM(0x8126,GL_POINT_SIZE_MIN)
+GL_ENUM(0x8127,GL_POINT_SIZE_MAX)
+GL_ENUM(0x8128,GL_POINT_FADE_THRESHOLD_SIZE)
+GL_ENUM(0x8129,GL_POINT_DISTANCE_ATTENUATION)
+GL_ENUM(0x0B12,GL_SMOOTH_POINT_SIZE_RANGE)
+GL_ENUM(0x0B21,GL_LINE_WIDTH)
+GL_ENUM(0x0B22,GL_SMOOTH_LINE_WIDTH_RANGE)
+GL_ENUM(0x846D,GL_ALIASED_POINT_SIZE_RANGE)
+GL_ENUM(0x846E,GL_ALIASED_LINE_WIDTH_RANGE)
+GL_ENUM(0x0B45,GL_CULL_FACE_MODE)
+GL_ENUM(0x0B46,GL_FRONT_FACE)
+GL_ENUM(0x0B54,GL_SHADE_MODEL)
 GL_ENUM(0x0B70,GL_DEPTH_RANGE)
-GL_ENUM(0x0B71,GL_DEPTH_TEST)
 GL_ENUM(0x0B72,GL_DEPTH_WRITEMASK)
 GL_ENUM(0x0B73,GL_DEPTH_CLEAR_VALUE)
 GL_ENUM(0x0B74,GL_DEPTH_FUNC)
-GL_ENUM(0x0B90,GL_STENCIL_TEST)
 GL_ENUM(0x0B91,GL_STENCIL_CLEAR_VALUE)
 GL_ENUM(0x0B92,GL_STENCIL_FUNC)
 GL_ENUM(0x0B93,GL_STENCIL_VALUE_MASK)
@@ -77,7 +99,6 @@
 GL_ENUM(0x0B97,GL_STENCIL_REF)
 GL_ENUM(0x0B98,GL_STENCIL_WRITEMASK)
 GL_ENUM(0x0BA0,GL_MATRIX_MODE)
-GL_ENUM(0x0BA1,GL_NORMALIZE)
 GL_ENUM(0x0BA2,GL_VIEWPORT)
 GL_ENUM(0x0BA3,GL_MODELVIEW_STACK_DEPTH)
 GL_ENUM(0x0BA4,GL_PROJECTION_STACK_DEPTH)
@@ -85,33 +106,14 @@
 GL_ENUM(0x0BA6,GL_MODELVIEW_MATRIX)
 GL_ENUM(0x0BA7,GL_PROJECTION_MATRIX)
 GL_ENUM(0x0BA8,GL_TEXTURE_MATRIX)
-GL_ENUM(0x0BC0,GL_ALPHA_TEST)
 GL_ENUM(0x0BC1,GL_ALPHA_TEST_FUNC)
 GL_ENUM(0x0BC2,GL_ALPHA_TEST_REF)
-GL_ENUM(0x0BD0,GL_DITHER)
 GL_ENUM(0x0BE0,GL_BLEND_DST)
 GL_ENUM(0x0BE1,GL_BLEND_SRC)
-GL_ENUM(0x0BE2,GL_BLEND)
 GL_ENUM(0x0BF0,GL_LOGIC_OP_MODE)
-GL_ENUM(0x0BF2,GL_COLOR_LOGIC_OP)
-GL_ENUM(0x0C02,GL_READ_BUFFER_NV)
 GL_ENUM(0x0C10,GL_SCISSOR_BOX)
-GL_ENUM(0x0C11,GL_SCISSOR_TEST)
 GL_ENUM(0x0C22,GL_COLOR_CLEAR_VALUE)
 GL_ENUM(0x0C23,GL_COLOR_WRITEMASK)
-GL_ENUM(0x0C50,GL_PERSPECTIVE_CORRECTION_HINT)
-GL_ENUM(0x0C51,GL_POINT_SMOOTH_HINT)
-GL_ENUM(0x0C52,GL_LINE_SMOOTH_HINT)
-GL_ENUM(0x0C54,GL_FOG_HINT)
-GL_ENUM(0x0CF2,GL_UNPACK_ROW_LENGTH)
-GL_ENUM(0x0CF3,GL_UNPACK_SKIP_ROWS)
-GL_ENUM(0x0CF4,GL_UNPACK_SKIP_PIXELS)
-GL_ENUM(0x0CF5,GL_UNPACK_ALIGNMENT)
-GL_ENUM(0x0D02,GL_PACK_ROW_LENGTH)
-GL_ENUM(0x0D03,GL_PACK_SKIP_ROWS)
-GL_ENUM(0x0D04,GL_PACK_SKIP_PIXELS)
-GL_ENUM(0x0D05,GL_PACK_ALIGNMENT)
-GL_ENUM(0x0D1C,GL_ALPHA_SCALE)
 GL_ENUM(0x0D31,GL_MAX_LIGHTS)
 GL_ENUM(0x0D32,GL_MAX_CLIP_PLANES)
 GL_ENUM(0x0D33,GL_MAX_TEXTURE_SIZE)
@@ -119,6 +121,7 @@
 GL_ENUM(0x0D38,GL_MAX_PROJECTION_STACK_DEPTH)
 GL_ENUM(0x0D39,GL_MAX_TEXTURE_STACK_DEPTH)
 GL_ENUM(0x0D3A,GL_MAX_VIEWPORT_DIMS)
+GL_ENUM(0x84E2,GL_MAX_TEXTURE_UNITS)
 GL_ENUM(0x0D50,GL_SUBPIXEL_BITS)
 GL_ENUM(0x0D52,GL_RED_BITS)
 GL_ENUM(0x0D53,GL_GREEN_BITS)
@@ -126,10 +129,41 @@
 GL_ENUM(0x0D55,GL_ALPHA_BITS)
 GL_ENUM(0x0D56,GL_DEPTH_BITS)
 GL_ENUM(0x0D57,GL_STENCIL_BITS)
-GL_ENUM(0x0DE1,GL_TEXTURE_2D)
+GL_ENUM(0x2A00,GL_POLYGON_OFFSET_UNITS)
+GL_ENUM(0x8037,GL_POLYGON_OFFSET_FILL)
+GL_ENUM(0x8038,GL_POLYGON_OFFSET_FACTOR)
+GL_ENUM(0x8069,GL_TEXTURE_BINDING_2D)
+GL_ENUM(0x807A,GL_VERTEX_ARRAY_SIZE)
+GL_ENUM(0x807B,GL_VERTEX_ARRAY_TYPE)
+GL_ENUM(0x807C,GL_VERTEX_ARRAY_STRIDE)
+GL_ENUM(0x807E,GL_NORMAL_ARRAY_TYPE)
+GL_ENUM(0x807F,GL_NORMAL_ARRAY_STRIDE)
+GL_ENUM(0x8081,GL_COLOR_ARRAY_SIZE)
+GL_ENUM(0x8082,GL_COLOR_ARRAY_TYPE)
+GL_ENUM(0x8083,GL_COLOR_ARRAY_STRIDE)
+GL_ENUM(0x8088,GL_TEXTURE_COORD_ARRAY_SIZE)
+GL_ENUM(0x8089,GL_TEXTURE_COORD_ARRAY_TYPE)
+GL_ENUM(0x808A,GL_TEXTURE_COORD_ARRAY_STRIDE)
+GL_ENUM(0x808E,GL_VERTEX_ARRAY_POINTER)
+GL_ENUM(0x808F,GL_NORMAL_ARRAY_POINTER)
+GL_ENUM(0x8090,GL_COLOR_ARRAY_POINTER)
+GL_ENUM(0x8092,GL_TEXTURE_COORD_ARRAY_POINTER)
+GL_ENUM(0x80A8,GL_SAMPLE_BUFFERS)
+GL_ENUM(0x80A9,GL_SAMPLES)
+GL_ENUM(0x80AA,GL_SAMPLE_COVERAGE_VALUE)
+GL_ENUM(0x80AB,GL_SAMPLE_COVERAGE_INVERT)
+GL_ENUM(0x86A2,GL_NUM_COMPRESSED_TEXTURE_FORMATS)
+GL_ENUM(0x86A3,GL_COMPRESSED_TEXTURE_FORMATS)
 GL_ENUM(0x1100,GL_DONT_CARE)
 GL_ENUM(0x1101,GL_FASTEST)
 GL_ENUM(0x1102,GL_NICEST)
+GL_ENUM(0x0C50,GL_PERSPECTIVE_CORRECTION_HINT)
+GL_ENUM(0x0C51,GL_POINT_SMOOTH_HINT)
+GL_ENUM(0x0C52,GL_LINE_SMOOTH_HINT)
+GL_ENUM(0x0C54,GL_FOG_HINT)
+GL_ENUM(0x8192,GL_GENERATE_MIPMAP_HINT)
+GL_ENUM(0x0B53,GL_LIGHT_MODEL_AMBIENT)
+GL_ENUM(0x0B52,GL_LIGHT_MODEL_TWO_SIDE)
 GL_ENUM(0x1200,GL_AMBIENT)
 GL_ENUM(0x1201,GL_DIFFUSE)
 GL_ENUM(0x1202,GL_SPECULAR)
@@ -144,10 +178,7 @@
 GL_ENUM(0x1401,GL_UNSIGNED_BYTE)
 GL_ENUM(0x1402,GL_SHORT)
 GL_ENUM(0x1403,GL_UNSIGNED_SHORT)
-GL_ENUM(0x1404,GL_INT)
-GL_ENUM(0x1405,GL_UNSIGNED_INT)
 GL_ENUM(0x1406,GL_FLOAT)
-GL_ENUM(0x140B,GL_HALF_FLOAT)
 GL_ENUM(0x140C,GL_FIXED)
 GL_ENUM(0x1500,GL_CLEAR)
 GL_ENUM(0x1501,GL_AND)
@@ -171,19 +202,16 @@
 GL_ENUM(0x1700,GL_MODELVIEW)
 GL_ENUM(0x1701,GL_PROJECTION)
 GL_ENUM(0x1702,GL_TEXTURE)
-GL_ENUM(0x1800,GL_COLOR_EXT)
-GL_ENUM(0x1801,GL_DEPTH_EXT)
-GL_ENUM(0x1802,GL_STENCIL_EXT)
-GL_ENUM(0x1901,GL_STENCIL_INDEX)
-GL_ENUM(0x1902,GL_DEPTH_COMPONENT)
-GL_ENUM(0x1903,GL_RED_EXT)
-GL_ENUM(0x1904,GL_GREEN)
-GL_ENUM(0x1905,GL_BLUE)
 GL_ENUM(0x1906,GL_ALPHA)
 GL_ENUM(0x1907,GL_RGB)
 GL_ENUM(0x1908,GL_RGBA)
 GL_ENUM(0x1909,GL_LUMINANCE)
 GL_ENUM(0x190A,GL_LUMINANCE_ALPHA)
+GL_ENUM(0x0CF5,GL_UNPACK_ALIGNMENT)
+GL_ENUM(0x0D05,GL_PACK_ALIGNMENT)
+GL_ENUM(0x8033,GL_UNSIGNED_SHORT_4_4_4_4)
+GL_ENUM(0x8034,GL_UNSIGNED_SHORT_5_5_5_1)
+GL_ENUM(0x8363,GL_UNSIGNED_SHORT_5_6_5)
 GL_ENUM(0x1D00,GL_FLAT)
 GL_ENUM(0x1D01,GL_SMOOTH)
 GL_ENUM(0x1E00,GL_KEEP)
@@ -196,10 +224,10 @@
 GL_ENUM(0x1F03,GL_EXTENSIONS)
 GL_ENUM(0x2100,GL_MODULATE)
 GL_ENUM(0x2101,GL_DECAL)
+GL_ENUM(0x0104,GL_ADD)
 GL_ENUM(0x2200,GL_TEXTURE_ENV_MODE)
 GL_ENUM(0x2201,GL_TEXTURE_ENV_COLOR)
 GL_ENUM(0x2300,GL_TEXTURE_ENV)
-GL_ENUM(0x2500,GL_TEXTURE_GEN_MODE_OES)
 GL_ENUM(0x2600,GL_NEAREST)
 GL_ENUM(0x2601,GL_LINEAR)
 GL_ENUM(0x2700,GL_NEAREST_MIPMAP_NEAREST)
@@ -210,157 +238,7 @@
 GL_ENUM(0x2801,GL_TEXTURE_MIN_FILTER)
 GL_ENUM(0x2802,GL_TEXTURE_WRAP_S)
 GL_ENUM(0x2803,GL_TEXTURE_WRAP_T)
-GL_ENUM(0x2901,GL_REPEAT)
-GL_ENUM(0x2A00,GL_POLYGON_OFFSET_UNITS)
-GL_ENUM(0x3000,GL_CLIP_PLANE0)
-GL_ENUM(0x3001,GL_CLIP_PLANE1)
-GL_ENUM(0x3002,GL_CLIP_PLANE2)
-GL_ENUM(0x3003,GL_CLIP_PLANE3)
-GL_ENUM(0x3004,GL_CLIP_PLANE4)
-GL_ENUM(0x3005,GL_CLIP_PLANE5)
-GL_ENUM(0x4000,GL_LIGHT0)
-GL_ENUM(0x4001,GL_LIGHT1)
-GL_ENUM(0x4002,GL_LIGHT2)
-GL_ENUM(0x4003,GL_LIGHT3)
-GL_ENUM(0x4004,GL_LIGHT4)
-GL_ENUM(0x4005,GL_LIGHT5)
-GL_ENUM(0x4006,GL_LIGHT6)
-GL_ENUM(0x4007,GL_LIGHT7)
-GL_ENUM(0x8000,GL_COVERAGE_BUFFER_BIT_NV)
-GL_ENUM(0x8001,GL_CONSTANT_COLOR)
-GL_ENUM(0x8002,GL_ONE_MINUS_CONSTANT_COLOR)
-GL_ENUM(0x8003,GL_CONSTANT_ALPHA)
-GL_ENUM(0x8004,GL_ONE_MINUS_CONSTANT_ALPHA)
-GL_ENUM(0x8005,GL_BLEND_COLOR)
-GL_ENUM(0x8006,GL_FUNC_ADD_OES)
-GL_ENUM(0x8007,GL_MIN_EXT)
-GL_ENUM(0x8008,GL_MAX_EXT)
-GL_ENUM(0x8009,GL_BLEND_EQUATION_RGB_OES)
-GL_ENUM(0x800A,GL_FUNC_SUBTRACT_OES)
-GL_ENUM(0x800B,GL_FUNC_REVERSE_SUBTRACT_OES)
-GL_ENUM(0x8033,GL_UNSIGNED_SHORT_4_4_4_4)
-GL_ENUM(0x8034,GL_UNSIGNED_SHORT_5_5_5_1)
-GL_ENUM(0x8037,GL_POLYGON_OFFSET_FILL)
-GL_ENUM(0x8038,GL_POLYGON_OFFSET_FACTOR)
-GL_ENUM(0x803A,GL_RESCALE_NORMAL)
-GL_ENUM(0x803C,GL_ALPHA8_EXT)
-GL_ENUM(0x8040,GL_LUMINANCE8_EXT)
-GL_ENUM(0x8045,GL_LUMINANCE8_ALPHA8_EXT)
-GL_ENUM(0x8051,GL_RGB8_OES)
-GL_ENUM(0x8052,GL_RGB10_EXT)
-GL_ENUM(0x8056,GL_RGBA4_OES)
-GL_ENUM(0x8057,GL_RGB5_A1_OES)
-GL_ENUM(0x8058,GL_RGBA8_OES)
-GL_ENUM(0x8059,GL_RGB10_A2_EXT)
-GL_ENUM(0x8069,GL_TEXTURE_BINDING_2D)
-GL_ENUM(0x806A,GL_TEXTURE_BINDING_3D_OES)
-GL_ENUM(0x806D,GL_UNPACK_SKIP_IMAGES)
-GL_ENUM(0x806E,GL_UNPACK_IMAGE_HEIGHT)
-GL_ENUM(0x806F,GL_TEXTURE_3D_OES)
-GL_ENUM(0x8072,GL_TEXTURE_WRAP_R_OES)
-GL_ENUM(0x8073,GL_MAX_3D_TEXTURE_SIZE_OES)
-GL_ENUM(0x8074,GL_VERTEX_ARRAY)
-GL_ENUM(0x8075,GL_NORMAL_ARRAY)
-GL_ENUM(0x8076,GL_COLOR_ARRAY)
-GL_ENUM(0x8078,GL_TEXTURE_COORD_ARRAY)
-GL_ENUM(0x807A,GL_VERTEX_ARRAY_SIZE)
-GL_ENUM(0x807B,GL_VERTEX_ARRAY_TYPE)
-GL_ENUM(0x807C,GL_VERTEX_ARRAY_STRIDE)
-GL_ENUM(0x807E,GL_NORMAL_ARRAY_TYPE)
-GL_ENUM(0x807F,GL_NORMAL_ARRAY_STRIDE)
-GL_ENUM(0x8081,GL_COLOR_ARRAY_SIZE)
-GL_ENUM(0x8082,GL_COLOR_ARRAY_TYPE)
-GL_ENUM(0x8083,GL_COLOR_ARRAY_STRIDE)
-GL_ENUM(0x8088,GL_TEXTURE_COORD_ARRAY_SIZE)
-GL_ENUM(0x8089,GL_TEXTURE_COORD_ARRAY_TYPE)
-GL_ENUM(0x808A,GL_TEXTURE_COORD_ARRAY_STRIDE)
-GL_ENUM(0x808E,GL_VERTEX_ARRAY_POINTER)
-GL_ENUM(0x808F,GL_NORMAL_ARRAY_POINTER)
-GL_ENUM(0x8090,GL_COLOR_ARRAY_POINTER)
-GL_ENUM(0x8092,GL_TEXTURE_COORD_ARRAY_POINTER)
-GL_ENUM(0x809D,GL_MULTISAMPLE)
-GL_ENUM(0x809E,GL_SAMPLE_ALPHA_TO_COVERAGE)
-GL_ENUM(0x809F,GL_SAMPLE_ALPHA_TO_ONE)
-GL_ENUM(0x80A0,GL_SAMPLE_COVERAGE)
-GL_ENUM(0x80A8,GL_SAMPLE_BUFFERS)
-GL_ENUM(0x80A9,GL_SAMPLES)
-GL_ENUM(0x80AA,GL_SAMPLE_COVERAGE_VALUE)
-GL_ENUM(0x80AB,GL_SAMPLE_COVERAGE_INVERT)
-GL_ENUM(0x80C8,GL_BLEND_DST_RGB_OES)
-GL_ENUM(0x80C9,GL_BLEND_SRC_RGB_OES)
-GL_ENUM(0x80CA,GL_BLEND_DST_ALPHA_OES)
-GL_ENUM(0x80CB,GL_BLEND_SRC_ALPHA_OES)
-GL_ENUM(0x80E1,GL_BGRA_EXT)
-GL_ENUM(0x80E8,GL_MAX_ELEMENTS_VERTICES)
-GL_ENUM(0x80E9,GL_MAX_ELEMENTS_INDICES)
-GL_ENUM(0x8126,GL_POINT_SIZE_MIN)
-GL_ENUM(0x8127,GL_POINT_SIZE_MAX)
-GL_ENUM(0x8128,GL_POINT_FADE_THRESHOLD_SIZE)
-GL_ENUM(0x8129,GL_POINT_DISTANCE_ATTENUATION)
-GL_ENUM(0x812F,GL_CLAMP_TO_EDGE)
-GL_ENUM(0x813A,GL_TEXTURE_MIN_LOD)
-GL_ENUM(0x813B,GL_TEXTURE_MAX_LOD)
-GL_ENUM(0x813C,GL_TEXTURE_BASE_LEVEL)
-GL_ENUM(0x813D,GL_TEXTURE_MAX_LEVEL_APPLE)
 GL_ENUM(0x8191,GL_GENERATE_MIPMAP)
-GL_ENUM(0x8192,GL_GENERATE_MIPMAP_HINT)
-GL_ENUM(0x81A5,GL_DEPTH_COMPONENT16_OES)
-GL_ENUM(0x81A6,GL_DEPTH_COMPONENT24_OES)
-GL_ENUM(0x81A7,GL_DEPTH_COMPONENT32_OES)
-GL_ENUM(0x8210,GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT)
-GL_ENUM(0x8211,GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT)
-GL_ENUM(0x8212,GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE)
-GL_ENUM(0x8213,GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE)
-GL_ENUM(0x8214,GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE)
-GL_ENUM(0x8215,GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE)
-GL_ENUM(0x8216,GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE)
-GL_ENUM(0x8217,GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE)
-GL_ENUM(0x8218,GL_FRAMEBUFFER_DEFAULT)
-GL_ENUM(0x8219,GL_FRAMEBUFFER_UNDEFINED)
-GL_ENUM(0x821A,GL_DEPTH_STENCIL_ATTACHMENT)
-GL_ENUM(0x821B,GL_MAJOR_VERSION)
-GL_ENUM(0x821C,GL_MINOR_VERSION)
-GL_ENUM(0x821D,GL_NUM_EXTENSIONS)
-GL_ENUM(0x8227,GL_RG_EXT)
-GL_ENUM(0x8228,GL_RG_INTEGER)
-GL_ENUM(0x8229,GL_R8_EXT)
-GL_ENUM(0x822B,GL_RG8_EXT)
-GL_ENUM(0x822D,GL_R16F_EXT)
-GL_ENUM(0x822E,GL_R32F)
-GL_ENUM(0x822F,GL_RG16F_EXT)
-GL_ENUM(0x8230,GL_RG32F)
-GL_ENUM(0x8231,GL_R8I)
-GL_ENUM(0x8232,GL_R8UI)
-GL_ENUM(0x8233,GL_R16I)
-GL_ENUM(0x8234,GL_R16UI)
-GL_ENUM(0x8235,GL_R32I)
-GL_ENUM(0x8236,GL_R32UI)
-GL_ENUM(0x8237,GL_RG8I)
-GL_ENUM(0x8238,GL_RG8UI)
-GL_ENUM(0x8239,GL_RG16I)
-GL_ENUM(0x823A,GL_RG16UI)
-GL_ENUM(0x823B,GL_RG32I)
-GL_ENUM(0x823C,GL_RG32UI)
-GL_ENUM(0x8252,GL_LOSE_CONTEXT_ON_RESET_EXT)
-GL_ENUM(0x8253,GL_GUILTY_CONTEXT_RESET_EXT)
-GL_ENUM(0x8254,GL_INNOCENT_CONTEXT_RESET_EXT)
-GL_ENUM(0x8255,GL_UNKNOWN_CONTEXT_RESET_EXT)
-GL_ENUM(0x8256,GL_RESET_NOTIFICATION_STRATEGY_EXT)
-GL_ENUM(0x8257,GL_PROGRAM_BINARY_RETRIEVABLE_HINT)
-GL_ENUM(0x8258,GL_PROGRAM_SEPARABLE_EXT)
-GL_ENUM(0x8259,GL_ACTIVE_PROGRAM_EXT)
-GL_ENUM(0x825A,GL_PROGRAM_PIPELINE_BINDING_EXT)
-GL_ENUM(0x8261,GL_NO_RESET_NOTIFICATION_EXT)
-GL_ENUM(0x82DF,GL_TEXTURE_IMMUTABLE_LEVELS)
-GL_ENUM(0x8363,GL_UNSIGNED_SHORT_5_6_5)
-GL_ENUM(0x8365,GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT)
-GL_ENUM(0x8366,GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT)
-GL_ENUM(0x8368,GL_UNSIGNED_INT_2_10_10_10_REV_EXT)
-GL_ENUM(0x8370,GL_MIRRORED_REPEAT_OES)
-GL_ENUM(0x83F0,GL_COMPRESSED_RGB_S3TC_DXT1_EXT)
-GL_ENUM(0x83F1,GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)
-GL_ENUM(0x846D,GL_ALIASED_POINT_SIZE_RANGE)
-GL_ENUM(0x846E,GL_ALIASED_LINE_WIDTH_RANGE)
 GL_ENUM(0x84C0,GL_TEXTURE0)
 GL_ENUM(0x84C1,GL_TEXTURE1)
 GL_ENUM(0x84C2,GL_TEXTURE2)
@@ -395,32 +273,29 @@
 GL_ENUM(0x84DF,GL_TEXTURE31)
 GL_ENUM(0x84E0,GL_ACTIVE_TEXTURE)
 GL_ENUM(0x84E1,GL_CLIENT_ACTIVE_TEXTURE)
-GL_ENUM(0x84E2,GL_MAX_TEXTURE_UNITS)
+GL_ENUM(0x2901,GL_REPEAT)
+GL_ENUM(0x812F,GL_CLAMP_TO_EDGE)
+GL_ENUM(0x4000,GL_LIGHT0)
+GL_ENUM(0x4001,GL_LIGHT1)
+GL_ENUM(0x4002,GL_LIGHT2)
+GL_ENUM(0x4003,GL_LIGHT3)
+GL_ENUM(0x4004,GL_LIGHT4)
+GL_ENUM(0x4005,GL_LIGHT5)
+GL_ENUM(0x4006,GL_LIGHT6)
+GL_ENUM(0x4007,GL_LIGHT7)
+GL_ENUM(0x8892,GL_ARRAY_BUFFER)
+GL_ENUM(0x8893,GL_ELEMENT_ARRAY_BUFFER)
+GL_ENUM(0x8894,GL_ARRAY_BUFFER_BINDING)
+GL_ENUM(0x8895,GL_ELEMENT_ARRAY_BUFFER_BINDING)
+GL_ENUM(0x8896,GL_VERTEX_ARRAY_BUFFER_BINDING)
+GL_ENUM(0x8897,GL_NORMAL_ARRAY_BUFFER_BINDING)
+GL_ENUM(0x8898,GL_COLOR_ARRAY_BUFFER_BINDING)
+GL_ENUM(0x889A,GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING)
+GL_ENUM(0x88E4,GL_STATIC_DRAW)
+GL_ENUM(0x88E8,GL_DYNAMIC_DRAW)
+GL_ENUM(0x8764,GL_BUFFER_SIZE)
+GL_ENUM(0x8765,GL_BUFFER_USAGE)
 GL_ENUM(0x84E7,GL_SUBTRACT)
-GL_ENUM(0x84E8,GL_MAX_RENDERBUFFER_SIZE_OES)
-GL_ENUM(0x84F2,GL_ALL_COMPLETED_NV)
-GL_ENUM(0x84F3,GL_FENCE_STATUS_NV)
-GL_ENUM(0x84F4,GL_FENCE_CONDITION_NV)
-GL_ENUM(0x84F9,GL_DEPTH_STENCIL_OES)
-GL_ENUM(0x84FA,GL_UNSIGNED_INT_24_8_OES)
-GL_ENUM(0x84FD,GL_MAX_TEXTURE_LOD_BIAS_EXT)
-GL_ENUM(0x84FE,GL_TEXTURE_MAX_ANISOTROPY_EXT)
-GL_ENUM(0x84FF,GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)
-GL_ENUM(0x8500,GL_TEXTURE_FILTER_CONTROL_EXT)
-GL_ENUM(0x8501,GL_TEXTURE_LOD_BIAS_EXT)
-GL_ENUM(0x8507,GL_INCR_WRAP_OES)
-GL_ENUM(0x8508,GL_DECR_WRAP_OES)
-GL_ENUM(0x8511,GL_NORMAL_MAP_OES)
-GL_ENUM(0x8512,GL_REFLECTION_MAP_OES)
-GL_ENUM(0x8513,GL_TEXTURE_CUBE_MAP_OES)
-GL_ENUM(0x8514,GL_TEXTURE_BINDING_CUBE_MAP_OES)
-GL_ENUM(0x8515,GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES)
-GL_ENUM(0x8516,GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES)
-GL_ENUM(0x8517,GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES)
-GL_ENUM(0x8518,GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES)
-GL_ENUM(0x8519,GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES)
-GL_ENUM(0x851A,GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES)
-GL_ENUM(0x851C,GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES)
 GL_ENUM(0x8570,GL_COMBINE)
 GL_ENUM(0x8571,GL_COMBINE_RGB)
 GL_ENUM(0x8572,GL_COMBINE_ALPHA)
@@ -430,140 +305,363 @@
 GL_ENUM(0x8576,GL_CONSTANT)
 GL_ENUM(0x8577,GL_PRIMARY_COLOR)
 GL_ENUM(0x8578,GL_PREVIOUS)
-GL_ENUM(0x8580,GL_SRC0_RGB)
-GL_ENUM(0x8581,GL_SRC1_RGB)
-GL_ENUM(0x8582,GL_SRC2_RGB)
-GL_ENUM(0x8588,GL_SRC0_ALPHA)
-GL_ENUM(0x8589,GL_SRC1_ALPHA)
-GL_ENUM(0x858A,GL_SRC2_ALPHA)
 GL_ENUM(0x8590,GL_OPERAND0_RGB)
 GL_ENUM(0x8591,GL_OPERAND1_RGB)
 GL_ENUM(0x8592,GL_OPERAND2_RGB)
 GL_ENUM(0x8598,GL_OPERAND0_ALPHA)
 GL_ENUM(0x8599,GL_OPERAND1_ALPHA)
 GL_ENUM(0x859A,GL_OPERAND2_ALPHA)
-GL_ENUM(0x85B5,GL_VERTEX_ARRAY_BINDING_OES)
-GL_ENUM(0x85BA,GL_UNSIGNED_SHORT_8_8_APPLE)
-GL_ENUM(0x85BB,GL_UNSIGNED_SHORT_8_8_REV_APPLE)
-GL_ENUM(0x8622,GL_VERTEX_ATTRIB_ARRAY_ENABLED)
-GL_ENUM(0x8623,GL_VERTEX_ATTRIB_ARRAY_SIZE)
-GL_ENUM(0x8624,GL_VERTEX_ATTRIB_ARRAY_STRIDE)
-GL_ENUM(0x8625,GL_VERTEX_ATTRIB_ARRAY_TYPE)
-GL_ENUM(0x8626,GL_CURRENT_VERTEX_ATTRIB)
-GL_ENUM(0x8645,GL_VERTEX_ATTRIB_ARRAY_POINTER)
-GL_ENUM(0x86A2,GL_NUM_COMPRESSED_TEXTURE_FORMATS)
-GL_ENUM(0x86A3,GL_COMPRESSED_TEXTURE_FORMATS)
-GL_ENUM(0x86A4,GL_MAX_VERTEX_UNITS_OES)
-GL_ENUM(0x86A9,GL_WEIGHT_ARRAY_TYPE_OES)
-GL_ENUM(0x86AA,GL_WEIGHT_ARRAY_STRIDE_OES)
-GL_ENUM(0x86AB,GL_WEIGHT_ARRAY_SIZE_OES)
-GL_ENUM(0x86AC,GL_WEIGHT_ARRAY_POINTER_OES)
-GL_ENUM(0x86AD,GL_WEIGHT_ARRAY_OES)
+GL_ENUM(0x0D1C,GL_ALPHA_SCALE)
+GL_ENUM(0x8580,GL_SRC0_RGB)
+GL_ENUM(0x8581,GL_SRC1_RGB)
+GL_ENUM(0x8582,GL_SRC2_RGB)
+GL_ENUM(0x8588,GL_SRC0_ALPHA)
+GL_ENUM(0x8589,GL_SRC1_ALPHA)
+GL_ENUM(0x858A,GL_SRC2_ALPHA)
 GL_ENUM(0x86AE,GL_DOT3_RGB)
 GL_ENUM(0x86AF,GL_DOT3_RGBA)
-GL_ENUM(0x8740,GL_Z400_BINARY_AMD)
-GL_ENUM(0x8741,GL_PROGRAM_BINARY_LENGTH_OES)
-GL_ENUM(0x8764,GL_BUFFER_SIZE)
-GL_ENUM(0x8765,GL_BUFFER_USAGE)
-GL_ENUM(0x87EE,GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD)
-GL_ENUM(0x87F9,GL_3DC_X_AMD)
-GL_ENUM(0x87FA,GL_3DC_XY_AMD)
-GL_ENUM(0x87FE,GL_NUM_PROGRAM_BINARY_FORMATS_OES)
-GL_ENUM(0x87FF,GL_PROGRAM_BINARY_FORMATS_OES)
+GL_ENUM(0x8006,GL_FUNC_ADD)
+GL_ENUM(0x8009,GL_BLEND_EQUATION)
+GL_ENUM(0x883D,GL_BLEND_EQUATION_ALPHA)
+GL_ENUM(0x800A,GL_FUNC_SUBTRACT)
+GL_ENUM(0x800B,GL_FUNC_REVERSE_SUBTRACT)
+GL_ENUM(0x80C8,GL_BLEND_DST_RGB)
+GL_ENUM(0x80C9,GL_BLEND_SRC_RGB)
+GL_ENUM(0x80CA,GL_BLEND_DST_ALPHA)
+GL_ENUM(0x80CB,GL_BLEND_SRC_ALPHA)
+GL_ENUM(0x8001,GL_CONSTANT_COLOR)
+GL_ENUM(0x8002,GL_ONE_MINUS_CONSTANT_COLOR)
+GL_ENUM(0x8003,GL_CONSTANT_ALPHA)
+GL_ENUM(0x8004,GL_ONE_MINUS_CONSTANT_ALPHA)
+GL_ENUM(0x8005,GL_BLEND_COLOR)
+GL_ENUM(0x88E0,GL_STREAM_DRAW)
+GL_ENUM(0x8626,GL_CURRENT_VERTEX_ATTRIB)
 GL_ENUM(0x8800,GL_STENCIL_BACK_FUNC)
 GL_ENUM(0x8801,GL_STENCIL_BACK_FAIL)
 GL_ENUM(0x8802,GL_STENCIL_BACK_PASS_DEPTH_FAIL)
 GL_ENUM(0x8803,GL_STENCIL_BACK_PASS_DEPTH_PASS)
-GL_ENUM(0x8814,GL_RGBA32F_EXT)
-GL_ENUM(0x8815,GL_RGB32F_EXT)
-GL_ENUM(0x8816,GL_ALPHA32F_EXT)
-GL_ENUM(0x8818,GL_LUMINANCE32F_EXT)
-GL_ENUM(0x8819,GL_LUMINANCE_ALPHA32F_EXT)
-GL_ENUM(0x881A,GL_RGBA16F_EXT)
-GL_ENUM(0x881B,GL_RGB16F_EXT)
-GL_ENUM(0x881C,GL_ALPHA16F_EXT)
-GL_ENUM(0x881E,GL_LUMINANCE16F_EXT)
-GL_ENUM(0x881F,GL_LUMINANCE_ALPHA16F_EXT)
-GL_ENUM(0x8823,GL_WRITEONLY_RENDERING_QCOM)
-GL_ENUM(0x8824,GL_MAX_DRAW_BUFFERS_NV)
-GL_ENUM(0x8825,GL_DRAW_BUFFER0_NV)
-GL_ENUM(0x8826,GL_DRAW_BUFFER1_NV)
-GL_ENUM(0x8827,GL_DRAW_BUFFER2_NV)
-GL_ENUM(0x8828,GL_DRAW_BUFFER3_NV)
-GL_ENUM(0x8829,GL_DRAW_BUFFER4_NV)
-GL_ENUM(0x882A,GL_DRAW_BUFFER5_NV)
-GL_ENUM(0x882B,GL_DRAW_BUFFER6_NV)
-GL_ENUM(0x882C,GL_DRAW_BUFFER7_NV)
-GL_ENUM(0x882D,GL_DRAW_BUFFER8_NV)
-GL_ENUM(0x882E,GL_DRAW_BUFFER9_NV)
-GL_ENUM(0x882F,GL_DRAW_BUFFER10_NV)
-GL_ENUM(0x8830,GL_DRAW_BUFFER11_NV)
-GL_ENUM(0x8831,GL_DRAW_BUFFER12_NV)
-GL_ENUM(0x8832,GL_DRAW_BUFFER13_NV)
-GL_ENUM(0x8833,GL_DRAW_BUFFER14_NV)
-GL_ENUM(0x8834,GL_DRAW_BUFFER15_NV)
-GL_ENUM(0x883D,GL_BLEND_EQUATION_ALPHA_OES)
-GL_ENUM(0x8840,GL_MATRIX_PALETTE_OES)
-GL_ENUM(0x8842,GL_MAX_PALETTE_MATRICES_OES)
-GL_ENUM(0x8843,GL_CURRENT_PALETTE_MATRIX_OES)
-GL_ENUM(0x8844,GL_MATRIX_INDEX_ARRAY_OES)
-GL_ENUM(0x8846,GL_MATRIX_INDEX_ARRAY_SIZE_OES)
-GL_ENUM(0x8847,GL_MATRIX_INDEX_ARRAY_TYPE_OES)
-GL_ENUM(0x8848,GL_MATRIX_INDEX_ARRAY_STRIDE_OES)
-GL_ENUM(0x8849,GL_MATRIX_INDEX_ARRAY_POINTER_OES)
-GL_ENUM(0x884C,GL_TEXTURE_COMPARE_MODE_EXT)
-GL_ENUM(0x884D,GL_TEXTURE_COMPARE_FUNC_EXT)
-GL_ENUM(0x884E,GL_COMPARE_REF_TO_TEXTURE_EXT)
-GL_ENUM(0x8861,GL_POINT_SPRITE_OES)
-GL_ENUM(0x8862,GL_COORD_REPLACE_OES)
-GL_ENUM(0x8865,GL_CURRENT_QUERY_EXT)
-GL_ENUM(0x8866,GL_QUERY_RESULT_EXT)
-GL_ENUM(0x8867,GL_QUERY_RESULT_AVAILABLE_EXT)
+GL_ENUM(0x8CA3,GL_STENCIL_BACK_REF)
+GL_ENUM(0x8CA4,GL_STENCIL_BACK_VALUE_MASK)
+GL_ENUM(0x8CA5,GL_STENCIL_BACK_WRITEMASK)
+GL_ENUM(0x1404,GL_INT)
+GL_ENUM(0x1405,GL_UNSIGNED_INT)
+GL_ENUM(0x1902,GL_DEPTH_COMPONENT)
+GL_ENUM(0x8B30,GL_FRAGMENT_SHADER)
+GL_ENUM(0x8B31,GL_VERTEX_SHADER)
 GL_ENUM(0x8869,GL_MAX_VERTEX_ATTRIBS)
-GL_ENUM(0x886A,GL_VERTEX_ATTRIB_ARRAY_NORMALIZED)
+GL_ENUM(0x8DFB,GL_MAX_VERTEX_UNIFORM_VECTORS)
+GL_ENUM(0x8DFC,GL_MAX_VARYING_VECTORS)
+GL_ENUM(0x8B4D,GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS)
+GL_ENUM(0x8B4C,GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS)
 GL_ENUM(0x8872,GL_MAX_TEXTURE_IMAGE_UNITS)
-GL_ENUM(0x8892,GL_ARRAY_BUFFER)
-GL_ENUM(0x8893,GL_ELEMENT_ARRAY_BUFFER)
-GL_ENUM(0x8894,GL_ARRAY_BUFFER_BINDING)
-GL_ENUM(0x8895,GL_ELEMENT_ARRAY_BUFFER_BINDING)
-GL_ENUM(0x8896,GL_VERTEX_ARRAY_BUFFER_BINDING)
-GL_ENUM(0x8897,GL_NORMAL_ARRAY_BUFFER_BINDING)
-GL_ENUM(0x8898,GL_COLOR_ARRAY_BUFFER_BINDING)
-GL_ENUM(0x889A,GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING)
-GL_ENUM(0x889E,GL_WEIGHT_ARRAY_BUFFER_BINDING_OES)
+GL_ENUM(0x8DFD,GL_MAX_FRAGMENT_UNIFORM_VECTORS)
+GL_ENUM(0x8B4F,GL_SHADER_TYPE)
+GL_ENUM(0x8B80,GL_DELETE_STATUS)
+GL_ENUM(0x8B82,GL_LINK_STATUS)
+GL_ENUM(0x8B83,GL_VALIDATE_STATUS)
+GL_ENUM(0x8B85,GL_ATTACHED_SHADERS)
+GL_ENUM(0x8B86,GL_ACTIVE_UNIFORMS)
+GL_ENUM(0x8B87,GL_ACTIVE_UNIFORM_MAX_LENGTH)
+GL_ENUM(0x8B89,GL_ACTIVE_ATTRIBUTES)
+GL_ENUM(0x8B8A,GL_ACTIVE_ATTRIBUTE_MAX_LENGTH)
+GL_ENUM(0x8B8C,GL_SHADING_LANGUAGE_VERSION)
+GL_ENUM(0x8B8D,GL_CURRENT_PROGRAM)
+GL_ENUM(0x8507,GL_INCR_WRAP)
+GL_ENUM(0x8508,GL_DECR_WRAP)
+GL_ENUM(0x8513,GL_TEXTURE_CUBE_MAP)
+GL_ENUM(0x8514,GL_TEXTURE_BINDING_CUBE_MAP)
+GL_ENUM(0x8515,GL_TEXTURE_CUBE_MAP_POSITIVE_X)
+GL_ENUM(0x8516,GL_TEXTURE_CUBE_MAP_NEGATIVE_X)
+GL_ENUM(0x8517,GL_TEXTURE_CUBE_MAP_POSITIVE_Y)
+GL_ENUM(0x8518,GL_TEXTURE_CUBE_MAP_NEGATIVE_Y)
+GL_ENUM(0x8519,GL_TEXTURE_CUBE_MAP_POSITIVE_Z)
+GL_ENUM(0x851A,GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)
+GL_ENUM(0x851C,GL_MAX_CUBE_MAP_TEXTURE_SIZE)
+GL_ENUM(0x8370,GL_MIRRORED_REPEAT)
+GL_ENUM(0x8B50,GL_FLOAT_VEC2)
+GL_ENUM(0x8B51,GL_FLOAT_VEC3)
+GL_ENUM(0x8B52,GL_FLOAT_VEC4)
+GL_ENUM(0x8B53,GL_INT_VEC2)
+GL_ENUM(0x8B54,GL_INT_VEC3)
+GL_ENUM(0x8B55,GL_INT_VEC4)
+GL_ENUM(0x8B56,GL_BOOL)
+GL_ENUM(0x8B57,GL_BOOL_VEC2)
+GL_ENUM(0x8B58,GL_BOOL_VEC3)
+GL_ENUM(0x8B59,GL_BOOL_VEC4)
+GL_ENUM(0x8B5A,GL_FLOAT_MAT2)
+GL_ENUM(0x8B5B,GL_FLOAT_MAT3)
+GL_ENUM(0x8B5C,GL_FLOAT_MAT4)
+GL_ENUM(0x8B5E,GL_SAMPLER_2D)
+GL_ENUM(0x8B60,GL_SAMPLER_CUBE)
+GL_ENUM(0x8622,GL_VERTEX_ATTRIB_ARRAY_ENABLED)
+GL_ENUM(0x8623,GL_VERTEX_ATTRIB_ARRAY_SIZE)
+GL_ENUM(0x8624,GL_VERTEX_ATTRIB_ARRAY_STRIDE)
+GL_ENUM(0x8625,GL_VERTEX_ATTRIB_ARRAY_TYPE)
+GL_ENUM(0x886A,GL_VERTEX_ATTRIB_ARRAY_NORMALIZED)
+GL_ENUM(0x8645,GL_VERTEX_ATTRIB_ARRAY_POINTER)
 GL_ENUM(0x889F,GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING)
-GL_ENUM(0x88B9,GL_WRITE_ONLY_OES)
-GL_ENUM(0x88BB,GL_BUFFER_ACCESS_OES)
-GL_ENUM(0x88BC,GL_BUFFER_MAPPED_OES)
-GL_ENUM(0x88BD,GL_BUFFER_MAP_POINTER_OES)
-GL_ENUM(0x88E0,GL_STREAM_DRAW)
+GL_ENUM(0x8B9A,GL_IMPLEMENTATION_COLOR_READ_TYPE)
+GL_ENUM(0x8B9B,GL_IMPLEMENTATION_COLOR_READ_FORMAT)
+GL_ENUM(0x8B81,GL_COMPILE_STATUS)
+GL_ENUM(0x8B84,GL_INFO_LOG_LENGTH)
+GL_ENUM(0x8B88,GL_SHADER_SOURCE_LENGTH)
+GL_ENUM(0x8DFA,GL_SHADER_COMPILER)
+GL_ENUM(0x8DF8,GL_SHADER_BINARY_FORMATS)
+GL_ENUM(0x8DF9,GL_NUM_SHADER_BINARY_FORMATS)
+GL_ENUM(0x8DF0,GL_LOW_FLOAT)
+GL_ENUM(0x8DF1,GL_MEDIUM_FLOAT)
+GL_ENUM(0x8DF2,GL_HIGH_FLOAT)
+GL_ENUM(0x8DF3,GL_LOW_INT)
+GL_ENUM(0x8DF4,GL_MEDIUM_INT)
+GL_ENUM(0x8DF5,GL_HIGH_INT)
+GL_ENUM(0x8D40,GL_FRAMEBUFFER)
+GL_ENUM(0x8D41,GL_RENDERBUFFER)
+GL_ENUM(0x8056,GL_RGBA4)
+GL_ENUM(0x8057,GL_RGB5_A1)
+GL_ENUM(0x8D62,GL_RGB565)
+GL_ENUM(0x81A5,GL_DEPTH_COMPONENT16)
+GL_ENUM(0x8D48,GL_STENCIL_INDEX8)
+GL_ENUM(0x8D42,GL_RENDERBUFFER_WIDTH)
+GL_ENUM(0x8D43,GL_RENDERBUFFER_HEIGHT)
+GL_ENUM(0x8D44,GL_RENDERBUFFER_INTERNAL_FORMAT)
+GL_ENUM(0x8D50,GL_RENDERBUFFER_RED_SIZE)
+GL_ENUM(0x8D51,GL_RENDERBUFFER_GREEN_SIZE)
+GL_ENUM(0x8D52,GL_RENDERBUFFER_BLUE_SIZE)
+GL_ENUM(0x8D53,GL_RENDERBUFFER_ALPHA_SIZE)
+GL_ENUM(0x8D54,GL_RENDERBUFFER_DEPTH_SIZE)
+GL_ENUM(0x8D55,GL_RENDERBUFFER_STENCIL_SIZE)
+GL_ENUM(0x8CD0,GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE)
+GL_ENUM(0x8CD1,GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME)
+GL_ENUM(0x8CD2,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL)
+GL_ENUM(0x8CD3,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE)
+GL_ENUM(0x8CE0,GL_COLOR_ATTACHMENT0)
+GL_ENUM(0x8D00,GL_DEPTH_ATTACHMENT)
+GL_ENUM(0x8D20,GL_STENCIL_ATTACHMENT)
+GL_ENUM(0x8CD5,GL_FRAMEBUFFER_COMPLETE)
+GL_ENUM(0x8CD6,GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT)
+GL_ENUM(0x8CD7,GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT)
+GL_ENUM(0x8CD9,GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS)
+GL_ENUM(0x8CDD,GL_FRAMEBUFFER_UNSUPPORTED)
+GL_ENUM(0x8CA6,GL_FRAMEBUFFER_BINDING)
+GL_ENUM(0x8CA7,GL_RENDERBUFFER_BINDING)
+GL_ENUM(0x84E8,GL_MAX_RENDERBUFFER_SIZE)
+GL_ENUM(0x0506,GL_INVALID_FRAMEBUFFER_OPERATION)
+GL_ENUM(0x0C02,GL_READ_BUFFER)
+GL_ENUM(0x0CF2,GL_UNPACK_ROW_LENGTH)
+GL_ENUM(0x0CF3,GL_UNPACK_SKIP_ROWS)
+GL_ENUM(0x0CF4,GL_UNPACK_SKIP_PIXELS)
+GL_ENUM(0x0D02,GL_PACK_ROW_LENGTH)
+GL_ENUM(0x0D03,GL_PACK_SKIP_ROWS)
+GL_ENUM(0x0D04,GL_PACK_SKIP_PIXELS)
+GL_ENUM(0x1800,GL_COLOR)
+GL_ENUM(0x1801,GL_DEPTH)
+GL_ENUM(0x1802,GL_STENCIL)
+GL_ENUM(0x1903,GL_RED)
+GL_ENUM(0x8051,GL_RGB8)
+GL_ENUM(0x8058,GL_RGBA8)
+GL_ENUM(0x8059,GL_RGB10_A2)
+GL_ENUM(0x806A,GL_TEXTURE_BINDING_3D)
+GL_ENUM(0x806D,GL_UNPACK_SKIP_IMAGES)
+GL_ENUM(0x806E,GL_UNPACK_IMAGE_HEIGHT)
+GL_ENUM(0x806F,GL_TEXTURE_3D)
+GL_ENUM(0x8072,GL_TEXTURE_WRAP_R)
+GL_ENUM(0x8073,GL_MAX_3D_TEXTURE_SIZE)
+GL_ENUM(0x8368,GL_UNSIGNED_INT_2_10_10_10_REV)
+GL_ENUM(0x80E8,GL_MAX_ELEMENTS_VERTICES)
+GL_ENUM(0x80E9,GL_MAX_ELEMENTS_INDICES)
+GL_ENUM(0x813A,GL_TEXTURE_MIN_LOD)
+GL_ENUM(0x813B,GL_TEXTURE_MAX_LOD)
+GL_ENUM(0x813C,GL_TEXTURE_BASE_LEVEL)
+GL_ENUM(0x813D,GL_TEXTURE_MAX_LEVEL)
+GL_ENUM(0x8007,GL_MIN)
+GL_ENUM(0x8008,GL_MAX)
+GL_ENUM(0x81A6,GL_DEPTH_COMPONENT24)
+GL_ENUM(0x84FD,GL_MAX_TEXTURE_LOD_BIAS)
+GL_ENUM(0x884C,GL_TEXTURE_COMPARE_MODE)
+GL_ENUM(0x884D,GL_TEXTURE_COMPARE_FUNC)
+GL_ENUM(0x8865,GL_CURRENT_QUERY)
+GL_ENUM(0x8866,GL_QUERY_RESULT)
+GL_ENUM(0x8867,GL_QUERY_RESULT_AVAILABLE)
+GL_ENUM(0x88BC,GL_BUFFER_MAPPED)
+GL_ENUM(0x88BD,GL_BUFFER_MAP_POINTER)
 GL_ENUM(0x88E1,GL_STREAM_READ)
 GL_ENUM(0x88E2,GL_STREAM_COPY)
-GL_ENUM(0x88E4,GL_STATIC_DRAW)
 GL_ENUM(0x88E5,GL_STATIC_READ)
 GL_ENUM(0x88E6,GL_STATIC_COPY)
-GL_ENUM(0x88E8,GL_DYNAMIC_DRAW)
 GL_ENUM(0x88E9,GL_DYNAMIC_READ)
 GL_ENUM(0x88EA,GL_DYNAMIC_COPY)
+GL_ENUM(0x8824,GL_MAX_DRAW_BUFFERS)
+GL_ENUM(0x8825,GL_DRAW_BUFFER0)
+GL_ENUM(0x8826,GL_DRAW_BUFFER1)
+GL_ENUM(0x8827,GL_DRAW_BUFFER2)
+GL_ENUM(0x8828,GL_DRAW_BUFFER3)
+GL_ENUM(0x8829,GL_DRAW_BUFFER4)
+GL_ENUM(0x882A,GL_DRAW_BUFFER5)
+GL_ENUM(0x882B,GL_DRAW_BUFFER6)
+GL_ENUM(0x882C,GL_DRAW_BUFFER7)
+GL_ENUM(0x882D,GL_DRAW_BUFFER8)
+GL_ENUM(0x882E,GL_DRAW_BUFFER9)
+GL_ENUM(0x882F,GL_DRAW_BUFFER10)
+GL_ENUM(0x8830,GL_DRAW_BUFFER11)
+GL_ENUM(0x8831,GL_DRAW_BUFFER12)
+GL_ENUM(0x8832,GL_DRAW_BUFFER13)
+GL_ENUM(0x8833,GL_DRAW_BUFFER14)
+GL_ENUM(0x8834,GL_DRAW_BUFFER15)
+GL_ENUM(0x8B49,GL_MAX_FRAGMENT_UNIFORM_COMPONENTS)
+GL_ENUM(0x8B4A,GL_MAX_VERTEX_UNIFORM_COMPONENTS)
+GL_ENUM(0x8B5F,GL_SAMPLER_3D)
+GL_ENUM(0x8B62,GL_SAMPLER_2D_SHADOW)
+GL_ENUM(0x8B8B,GL_FRAGMENT_SHADER_DERIVATIVE_HINT)
 GL_ENUM(0x88EB,GL_PIXEL_PACK_BUFFER)
 GL_ENUM(0x88EC,GL_PIXEL_UNPACK_BUFFER)
 GL_ENUM(0x88ED,GL_PIXEL_PACK_BUFFER_BINDING)
 GL_ENUM(0x88EF,GL_PIXEL_UNPACK_BUFFER_BINDING)
-GL_ENUM(0x88F0,GL_DEPTH24_STENCIL8_OES)
+GL_ENUM(0x8B65,GL_FLOAT_MAT2x3)
+GL_ENUM(0x8B66,GL_FLOAT_MAT2x4)
+GL_ENUM(0x8B67,GL_FLOAT_MAT3x2)
+GL_ENUM(0x8B68,GL_FLOAT_MAT3x4)
+GL_ENUM(0x8B69,GL_FLOAT_MAT4x2)
+GL_ENUM(0x8B6A,GL_FLOAT_MAT4x3)
+GL_ENUM(0x8C40,GL_SRGB)
+GL_ENUM(0x8C41,GL_SRGB8)
+GL_ENUM(0x8C43,GL_SRGB8_ALPHA8)
+GL_ENUM(0x884E,GL_COMPARE_REF_TO_TEXTURE)
+GL_ENUM(0x821B,GL_MAJOR_VERSION)
+GL_ENUM(0x821C,GL_MINOR_VERSION)
+GL_ENUM(0x821D,GL_NUM_EXTENSIONS)
+GL_ENUM(0x8814,GL_RGBA32F)
+GL_ENUM(0x8815,GL_RGB32F)
+GL_ENUM(0x881A,GL_RGBA16F)
+GL_ENUM(0x881B,GL_RGB16F)
 GL_ENUM(0x88FD,GL_VERTEX_ATTRIB_ARRAY_INTEGER)
-GL_ENUM(0x88FE,GL_VERTEX_ATTRIB_ARRAY_DIVISOR)
 GL_ENUM(0x88FF,GL_MAX_ARRAY_TEXTURE_LAYERS)
 GL_ENUM(0x8904,GL_MIN_PROGRAM_TEXEL_OFFSET)
 GL_ENUM(0x8905,GL_MAX_PROGRAM_TEXEL_OFFSET)
-GL_ENUM(0x8919,GL_SAMPLER_BINDING)
-GL_ENUM(0x898A,GL_POINT_SIZE_ARRAY_TYPE_OES)
-GL_ENUM(0x898B,GL_POINT_SIZE_ARRAY_STRIDE_OES)
-GL_ENUM(0x898C,GL_POINT_SIZE_ARRAY_POINTER_OES)
-GL_ENUM(0x898D,GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES)
-GL_ENUM(0x898E,GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES)
-GL_ENUM(0x898F,GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES)
+GL_ENUM(0x8B4B,GL_MAX_VARYING_COMPONENTS)
+GL_ENUM(0x8C1A,GL_TEXTURE_2D_ARRAY)
+GL_ENUM(0x8C1D,GL_TEXTURE_BINDING_2D_ARRAY)
+GL_ENUM(0x8C3A,GL_R11F_G11F_B10F)
+GL_ENUM(0x8C3B,GL_UNSIGNED_INT_10F_11F_11F_REV)
+GL_ENUM(0x8C3D,GL_RGB9_E5)
+GL_ENUM(0x8C3E,GL_UNSIGNED_INT_5_9_9_9_REV)
+GL_ENUM(0x8C76,GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH)
+GL_ENUM(0x8C7F,GL_TRANSFORM_FEEDBACK_BUFFER_MODE)
+GL_ENUM(0x8C80,GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS)
+GL_ENUM(0x8C83,GL_TRANSFORM_FEEDBACK_VARYINGS)
+GL_ENUM(0x8C84,GL_TRANSFORM_FEEDBACK_BUFFER_START)
+GL_ENUM(0x8C85,GL_TRANSFORM_FEEDBACK_BUFFER_SIZE)
+GL_ENUM(0x8C88,GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN)
+GL_ENUM(0x8C89,GL_RASTERIZER_DISCARD)
+GL_ENUM(0x8C8A,GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS)
+GL_ENUM(0x8C8B,GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS)
+GL_ENUM(0x8C8C,GL_INTERLEAVED_ATTRIBS)
+GL_ENUM(0x8C8D,GL_SEPARATE_ATTRIBS)
+GL_ENUM(0x8C8E,GL_TRANSFORM_FEEDBACK_BUFFER)
+GL_ENUM(0x8C8F,GL_TRANSFORM_FEEDBACK_BUFFER_BINDING)
+GL_ENUM(0x8D70,GL_RGBA32UI)
+GL_ENUM(0x8D71,GL_RGB32UI)
+GL_ENUM(0x8D76,GL_RGBA16UI)
+GL_ENUM(0x8D77,GL_RGB16UI)
+GL_ENUM(0x8D7C,GL_RGBA8UI)
+GL_ENUM(0x8D7D,GL_RGB8UI)
+GL_ENUM(0x8D82,GL_RGBA32I)
+GL_ENUM(0x8D83,GL_RGB32I)
+GL_ENUM(0x8D88,GL_RGBA16I)
+GL_ENUM(0x8D89,GL_RGB16I)
+GL_ENUM(0x8D8E,GL_RGBA8I)
+GL_ENUM(0x8D8F,GL_RGB8I)
+GL_ENUM(0x8D94,GL_RED_INTEGER)
+GL_ENUM(0x8D98,GL_RGB_INTEGER)
+GL_ENUM(0x8D99,GL_RGBA_INTEGER)
+GL_ENUM(0x8DC1,GL_SAMPLER_2D_ARRAY)
+GL_ENUM(0x8DC4,GL_SAMPLER_2D_ARRAY_SHADOW)
+GL_ENUM(0x8DC5,GL_SAMPLER_CUBE_SHADOW)
+GL_ENUM(0x8DC6,GL_UNSIGNED_INT_VEC2)
+GL_ENUM(0x8DC7,GL_UNSIGNED_INT_VEC3)
+GL_ENUM(0x8DC8,GL_UNSIGNED_INT_VEC4)
+GL_ENUM(0x8DCA,GL_INT_SAMPLER_2D)
+GL_ENUM(0x8DCB,GL_INT_SAMPLER_3D)
+GL_ENUM(0x8DCC,GL_INT_SAMPLER_CUBE)
+GL_ENUM(0x8DCF,GL_INT_SAMPLER_2D_ARRAY)
+GL_ENUM(0x8DD2,GL_UNSIGNED_INT_SAMPLER_2D)
+GL_ENUM(0x8DD3,GL_UNSIGNED_INT_SAMPLER_3D)
+GL_ENUM(0x8DD4,GL_UNSIGNED_INT_SAMPLER_CUBE)
+GL_ENUM(0x8DD7,GL_UNSIGNED_INT_SAMPLER_2D_ARRAY)
+GL_ENUM(0x911F,GL_BUFFER_ACCESS_FLAGS)
+GL_ENUM(0x9120,GL_BUFFER_MAP_LENGTH)
+GL_ENUM(0x9121,GL_BUFFER_MAP_OFFSET)
+GL_ENUM(0x8CAC,GL_DEPTH_COMPONENT32F)
+GL_ENUM(0x8CAD,GL_DEPTH32F_STENCIL8)
+GL_ENUM(0x8DAD,GL_FLOAT_32_UNSIGNED_INT_24_8_REV)
+GL_ENUM(0x8210,GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING)
+GL_ENUM(0x8211,GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE)
+GL_ENUM(0x8212,GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE)
+GL_ENUM(0x8213,GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE)
+GL_ENUM(0x8214,GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE)
+GL_ENUM(0x8215,GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE)
+GL_ENUM(0x8216,GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE)
+GL_ENUM(0x8217,GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE)
+GL_ENUM(0x8218,GL_FRAMEBUFFER_DEFAULT)
+GL_ENUM(0x8219,GL_FRAMEBUFFER_UNDEFINED)
+GL_ENUM(0x821A,GL_DEPTH_STENCIL_ATTACHMENT)
+GL_ENUM(0x84F9,GL_DEPTH_STENCIL)
+GL_ENUM(0x84FA,GL_UNSIGNED_INT_24_8)
+GL_ENUM(0x88F0,GL_DEPTH24_STENCIL8)
+GL_ENUM(0x8C17,GL_UNSIGNED_NORMALIZED)
+GL_ENUM(0x8CA8,GL_READ_FRAMEBUFFER)
+GL_ENUM(0x8CA9,GL_DRAW_FRAMEBUFFER)
+GL_ENUM(0x8CAA,GL_READ_FRAMEBUFFER_BINDING)
+GL_ENUM(0x8CAB,GL_RENDERBUFFER_SAMPLES)
+GL_ENUM(0x8CD4,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER)
+GL_ENUM(0x8CDF,GL_MAX_COLOR_ATTACHMENTS)
+GL_ENUM(0x8CE1,GL_COLOR_ATTACHMENT1)
+GL_ENUM(0x8CE2,GL_COLOR_ATTACHMENT2)
+GL_ENUM(0x8CE3,GL_COLOR_ATTACHMENT3)
+GL_ENUM(0x8CE4,GL_COLOR_ATTACHMENT4)
+GL_ENUM(0x8CE5,GL_COLOR_ATTACHMENT5)
+GL_ENUM(0x8CE6,GL_COLOR_ATTACHMENT6)
+GL_ENUM(0x8CE7,GL_COLOR_ATTACHMENT7)
+GL_ENUM(0x8CE8,GL_COLOR_ATTACHMENT8)
+GL_ENUM(0x8CE9,GL_COLOR_ATTACHMENT9)
+GL_ENUM(0x8CEA,GL_COLOR_ATTACHMENT10)
+GL_ENUM(0x8CEB,GL_COLOR_ATTACHMENT11)
+GL_ENUM(0x8CEC,GL_COLOR_ATTACHMENT12)
+GL_ENUM(0x8CED,GL_COLOR_ATTACHMENT13)
+GL_ENUM(0x8CEE,GL_COLOR_ATTACHMENT14)
+GL_ENUM(0x8CEF,GL_COLOR_ATTACHMENT15)
+GL_ENUM(0x8D56,GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE)
+GL_ENUM(0x8D57,GL_MAX_SAMPLES)
+GL_ENUM(0x140B,GL_HALF_FLOAT)
+GL_ENUM(0x8227,GL_RG)
+GL_ENUM(0x8228,GL_RG_INTEGER)
+GL_ENUM(0x8229,GL_R8)
+GL_ENUM(0x822B,GL_RG8)
+GL_ENUM(0x822D,GL_R16F)
+GL_ENUM(0x822E,GL_R32F)
+GL_ENUM(0x822F,GL_RG16F)
+GL_ENUM(0x8230,GL_RG32F)
+GL_ENUM(0x8231,GL_R8I)
+GL_ENUM(0x8232,GL_R8UI)
+GL_ENUM(0x8233,GL_R16I)
+GL_ENUM(0x8234,GL_R16UI)
+GL_ENUM(0x8235,GL_R32I)
+GL_ENUM(0x8236,GL_R32UI)
+GL_ENUM(0x8237,GL_RG8I)
+GL_ENUM(0x8238,GL_RG8UI)
+GL_ENUM(0x8239,GL_RG16I)
+GL_ENUM(0x823A,GL_RG16UI)
+GL_ENUM(0x823B,GL_RG32I)
+GL_ENUM(0x823C,GL_RG32UI)
+GL_ENUM(0x85B5,GL_VERTEX_ARRAY_BINDING)
+GL_ENUM(0x8F94,GL_R8_SNORM)
+GL_ENUM(0x8F95,GL_RG8_SNORM)
+GL_ENUM(0x8F96,GL_RGB8_SNORM)
+GL_ENUM(0x8F97,GL_RGBA8_SNORM)
+GL_ENUM(0x8F9C,GL_SIGNED_NORMALIZED)
+GL_ENUM(0x8D69,GL_PRIMITIVE_RESTART_FIXED_INDEX)
+GL_ENUM(0x8F36,GL_COPY_READ_BUFFER)
+GL_ENUM(0x8F37,GL_COPY_WRITE_BUFFER)
 GL_ENUM(0x8A11,GL_UNIFORM_BUFFER)
-GL_ENUM(0x8A1F,GL_RGB_422_APPLE)
 GL_ENUM(0x8A28,GL_UNIFORM_BUFFER_BINDING)
 GL_ENUM(0x8A29,GL_UNIFORM_BUFFER_START)
 GL_ENUM(0x8A2A,GL_UNIFORM_BUFFER_SIZE)
@@ -592,270 +690,9 @@
 GL_ENUM(0x8A43,GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES)
 GL_ENUM(0x8A44,GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER)
 GL_ENUM(0x8A46,GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER)
-GL_ENUM(0x8A4F,GL_PROGRAM_PIPELINE_OBJECT_EXT)
-GL_ENUM(0x8B30,GL_FRAGMENT_SHADER)
-GL_ENUM(0x8B31,GL_VERTEX_SHADER)
-GL_ENUM(0x8B40,GL_PROGRAM_OBJECT_EXT)
-GL_ENUM(0x8B48,GL_SHADER_OBJECT_EXT)
-GL_ENUM(0x8B49,GL_MAX_FRAGMENT_UNIFORM_COMPONENTS)
-GL_ENUM(0x8B4A,GL_MAX_VERTEX_UNIFORM_COMPONENTS)
-GL_ENUM(0x8B4B,GL_MAX_VARYING_COMPONENTS)
-GL_ENUM(0x8B4C,GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS)
-GL_ENUM(0x8B4D,GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS)
-GL_ENUM(0x8B4F,GL_SHADER_TYPE)
-GL_ENUM(0x8B50,GL_FLOAT_VEC2)
-GL_ENUM(0x8B51,GL_FLOAT_VEC3)
-GL_ENUM(0x8B52,GL_FLOAT_VEC4)
-GL_ENUM(0x8B53,GL_INT_VEC2)
-GL_ENUM(0x8B54,GL_INT_VEC3)
-GL_ENUM(0x8B55,GL_INT_VEC4)
-GL_ENUM(0x8B56,GL_BOOL)
-GL_ENUM(0x8B57,GL_BOOL_VEC2)
-GL_ENUM(0x8B58,GL_BOOL_VEC3)
-GL_ENUM(0x8B59,GL_BOOL_VEC4)
-GL_ENUM(0x8B5A,GL_FLOAT_MAT2)
-GL_ENUM(0x8B5B,GL_FLOAT_MAT3)
-GL_ENUM(0x8B5C,GL_FLOAT_MAT4)
-GL_ENUM(0x8B5E,GL_SAMPLER_2D)
-GL_ENUM(0x8B5F,GL_SAMPLER_3D_OES)
-GL_ENUM(0x8B60,GL_SAMPLER_CUBE)
-GL_ENUM(0x8B62,GL_SAMPLER_2D_SHADOW_EXT)
-GL_ENUM(0x8B65,GL_FLOAT_MAT2x3)
-GL_ENUM(0x8B66,GL_FLOAT_MAT2x4)
-GL_ENUM(0x8B67,GL_FLOAT_MAT3x2)
-GL_ENUM(0x8B68,GL_FLOAT_MAT3x4)
-GL_ENUM(0x8B69,GL_FLOAT_MAT4x2)
-GL_ENUM(0x8B6A,GL_FLOAT_MAT4x3)
-GL_ENUM(0x8B80,GL_DELETE_STATUS)
-GL_ENUM(0x8B81,GL_COMPILE_STATUS)
-GL_ENUM(0x8B82,GL_LINK_STATUS)
-GL_ENUM(0x8B83,GL_VALIDATE_STATUS)
-GL_ENUM(0x8B84,GL_INFO_LOG_LENGTH)
-GL_ENUM(0x8B85,GL_ATTACHED_SHADERS)
-GL_ENUM(0x8B86,GL_ACTIVE_UNIFORMS)
-GL_ENUM(0x8B87,GL_ACTIVE_UNIFORM_MAX_LENGTH)
-GL_ENUM(0x8B88,GL_SHADER_SOURCE_LENGTH)
-GL_ENUM(0x8B89,GL_ACTIVE_ATTRIBUTES)
-GL_ENUM(0x8B8A,GL_ACTIVE_ATTRIBUTE_MAX_LENGTH)
-GL_ENUM(0x8B8B,GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES)
-GL_ENUM(0x8B8C,GL_SHADING_LANGUAGE_VERSION)
-GL_ENUM(0x8B8D,GL_CURRENT_PROGRAM)
-GL_ENUM(0x8B90,GL_PALETTE4_RGB8_OES)
-GL_ENUM(0x8B91,GL_PALETTE4_RGBA8_OES)
-GL_ENUM(0x8B92,GL_PALETTE4_R5_G6_B5_OES)
-GL_ENUM(0x8B93,GL_PALETTE4_RGBA4_OES)
-GL_ENUM(0x8B94,GL_PALETTE4_RGB5_A1_OES)
-GL_ENUM(0x8B95,GL_PALETTE8_RGB8_OES)
-GL_ENUM(0x8B96,GL_PALETTE8_RGBA8_OES)
-GL_ENUM(0x8B97,GL_PALETTE8_R5_G6_B5_OES)
-GL_ENUM(0x8B98,GL_PALETTE8_RGBA4_OES)
-GL_ENUM(0x8B99,GL_PALETTE8_RGB5_A1_OES)
-GL_ENUM(0x8B9A,GL_IMPLEMENTATION_COLOR_READ_TYPE_OES)
-GL_ENUM(0x8B9B,GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES)
-GL_ENUM(0x8B9C,GL_POINT_SIZE_ARRAY_OES)
-GL_ENUM(0x8B9D,GL_TEXTURE_CROP_RECT_OES)
-GL_ENUM(0x8B9E,GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES)
-GL_ENUM(0x8B9F,GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES)
-GL_ENUM(0x8BC0,GL_COUNTER_TYPE_AMD)
-GL_ENUM(0x8BC1,GL_COUNTER_RANGE_AMD)
-GL_ENUM(0x8BC2,GL_UNSIGNED_INT64_AMD)
-GL_ENUM(0x8BC3,GL_PERCENTAGE_AMD)
-GL_ENUM(0x8BC4,GL_PERFMON_RESULT_AVAILABLE_AMD)
-GL_ENUM(0x8BC5,GL_PERFMON_RESULT_SIZE_AMD)
-GL_ENUM(0x8BC6,GL_PERFMON_RESULT_AMD)
-GL_ENUM(0x8BD2,GL_TEXTURE_WIDTH_QCOM)
-GL_ENUM(0x8BD3,GL_TEXTURE_HEIGHT_QCOM)
-GL_ENUM(0x8BD4,GL_TEXTURE_DEPTH_QCOM)
-GL_ENUM(0x8BD5,GL_TEXTURE_INTERNAL_FORMAT_QCOM)
-GL_ENUM(0x8BD6,GL_TEXTURE_FORMAT_QCOM)
-GL_ENUM(0x8BD7,GL_TEXTURE_TYPE_QCOM)
-GL_ENUM(0x8BD8,GL_TEXTURE_IMAGE_VALID_QCOM)
-GL_ENUM(0x8BD9,GL_TEXTURE_NUM_LEVELS_QCOM)
-GL_ENUM(0x8BDA,GL_TEXTURE_TARGET_QCOM)
-GL_ENUM(0x8BDB,GL_TEXTURE_OBJECT_VALID_QCOM)
-GL_ENUM(0x8BDC,GL_STATE_RESTORE)
-GL_ENUM(0x8C00,GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG)
-GL_ENUM(0x8C01,GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG)
-GL_ENUM(0x8C02,GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG)
-GL_ENUM(0x8C03,GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG)
-GL_ENUM(0x8C04,GL_MODULATE_COLOR_IMG)
-GL_ENUM(0x8C05,GL_RECIP_ADD_SIGNED_ALPHA_IMG)
-GL_ENUM(0x8C06,GL_TEXTURE_ALPHA_MODULATE_IMG)
-GL_ENUM(0x8C07,GL_FACTOR_ALPHA_MODULATE_IMG)
-GL_ENUM(0x8C08,GL_FRAGMENT_ALPHA_MODULATE_IMG)
-GL_ENUM(0x8C09,GL_ADD_BLEND_IMG)
-GL_ENUM(0x8C0A,GL_SGX_BINARY_IMG)
-GL_ENUM(0x8C17,GL_UNSIGNED_NORMALIZED_EXT)
-GL_ENUM(0x8C1A,GL_TEXTURE_2D_ARRAY)
-GL_ENUM(0x8C1D,GL_TEXTURE_BINDING_2D_ARRAY)
-GL_ENUM(0x8C2F,GL_ANY_SAMPLES_PASSED_EXT)
-GL_ENUM(0x8C3A,GL_R11F_G11F_B10F)
-GL_ENUM(0x8C3B,GL_UNSIGNED_INT_10F_11F_11F_REV)
-GL_ENUM(0x8C3D,GL_RGB9_E5)
-GL_ENUM(0x8C3E,GL_UNSIGNED_INT_5_9_9_9_REV)
-GL_ENUM(0x8C40,GL_SRGB_EXT)
-GL_ENUM(0x8C41,GL_SRGB8)
-GL_ENUM(0x8C42,GL_SRGB_ALPHA_EXT)
-GL_ENUM(0x8C43,GL_SRGB8_ALPHA8_EXT)
-GL_ENUM(0x8C76,GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH)
-GL_ENUM(0x8C7F,GL_TRANSFORM_FEEDBACK_BUFFER_MODE)
-GL_ENUM(0x8C80,GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS)
-GL_ENUM(0x8C83,GL_TRANSFORM_FEEDBACK_VARYINGS)
-GL_ENUM(0x8C84,GL_TRANSFORM_FEEDBACK_BUFFER_START)
-GL_ENUM(0x8C85,GL_TRANSFORM_FEEDBACK_BUFFER_SIZE)
-GL_ENUM(0x8C88,GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN)
-GL_ENUM(0x8C89,GL_RASTERIZER_DISCARD)
-GL_ENUM(0x8C8A,GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS)
-GL_ENUM(0x8C8B,GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS)
-GL_ENUM(0x8C8C,GL_INTERLEAVED_ATTRIBS)
-GL_ENUM(0x8C8D,GL_SEPARATE_ATTRIBS)
-GL_ENUM(0x8C8E,GL_TRANSFORM_FEEDBACK_BUFFER)
-GL_ENUM(0x8C8F,GL_TRANSFORM_FEEDBACK_BUFFER_BINDING)
-GL_ENUM(0x8C92,GL_ATC_RGB_AMD)
-GL_ENUM(0x8C93,GL_ATC_RGBA_EXPLICIT_ALPHA_AMD)
-GL_ENUM(0x8CA3,GL_STENCIL_BACK_REF)
-GL_ENUM(0x8CA4,GL_STENCIL_BACK_VALUE_MASK)
-GL_ENUM(0x8CA5,GL_STENCIL_BACK_WRITEMASK)
-GL_ENUM(0x8CA6,GL_FRAMEBUFFER_BINDING_OES)
-GL_ENUM(0x8CA7,GL_RENDERBUFFER_BINDING_OES)
-GL_ENUM(0x8CA8,GL_READ_FRAMEBUFFER_APPLE)
-GL_ENUM(0x8CA9,GL_DRAW_FRAMEBUFFER_APPLE)
-GL_ENUM(0x8CAA,GL_READ_FRAMEBUFFER_BINDING_APPLE)
-GL_ENUM(0x8CAB,GL_RENDERBUFFER_SAMPLES_APPLE)
-GL_ENUM(0x8CAC,GL_DEPTH_COMPONENT32F)
-GL_ENUM(0x8CAD,GL_DEPTH32F_STENCIL8)
-GL_ENUM(0x8CD0,GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES)
-GL_ENUM(0x8CD1,GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES)
-GL_ENUM(0x8CD2,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES)
-GL_ENUM(0x8CD3,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES)
-GL_ENUM(0x8CD4,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES)
-GL_ENUM(0x8CD5,GL_FRAMEBUFFER_COMPLETE_OES)
-GL_ENUM(0x8CD6,GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES)
-GL_ENUM(0x8CD7,GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES)
-GL_ENUM(0x8CD9,GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES)
-GL_ENUM(0x8CDA,GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES)
-GL_ENUM(0x8CDD,GL_FRAMEBUFFER_UNSUPPORTED_OES)
-GL_ENUM(0x8CDF,GL_MAX_COLOR_ATTACHMENTS_NV)
-GL_ENUM(0x8CE0,GL_COLOR_ATTACHMENT0_OES)
-GL_ENUM(0x8CE1,GL_COLOR_ATTACHMENT1_NV)
-GL_ENUM(0x8CE2,GL_COLOR_ATTACHMENT2_NV)
-GL_ENUM(0x8CE3,GL_COLOR_ATTACHMENT3_NV)
-GL_ENUM(0x8CE4,GL_COLOR_ATTACHMENT4_NV)
-GL_ENUM(0x8CE5,GL_COLOR_ATTACHMENT5_NV)
-GL_ENUM(0x8CE6,GL_COLOR_ATTACHMENT6_NV)
-GL_ENUM(0x8CE7,GL_COLOR_ATTACHMENT7_NV)
-GL_ENUM(0x8CE8,GL_COLOR_ATTACHMENT8_NV)
-GL_ENUM(0x8CE9,GL_COLOR_ATTACHMENT9_NV)
-GL_ENUM(0x8CEA,GL_COLOR_ATTACHMENT10_NV)
-GL_ENUM(0x8CEB,GL_COLOR_ATTACHMENT11_NV)
-GL_ENUM(0x8CEC,GL_COLOR_ATTACHMENT12_NV)
-GL_ENUM(0x8CED,GL_COLOR_ATTACHMENT13_NV)
-GL_ENUM(0x8CEE,GL_COLOR_ATTACHMENT14_NV)
-GL_ENUM(0x8CEF,GL_COLOR_ATTACHMENT15_NV)
-GL_ENUM(0x8D00,GL_DEPTH_ATTACHMENT_OES)
-GL_ENUM(0x8D20,GL_STENCIL_ATTACHMENT_OES)
-GL_ENUM(0x8D40,GL_FRAMEBUFFER_OES)
-GL_ENUM(0x8D41,GL_RENDERBUFFER_OES)
-GL_ENUM(0x8D42,GL_RENDERBUFFER_WIDTH_OES)
-GL_ENUM(0x8D43,GL_RENDERBUFFER_HEIGHT_OES)
-GL_ENUM(0x8D44,GL_RENDERBUFFER_INTERNAL_FORMAT_OES)
-GL_ENUM(0x8D46,GL_STENCIL_INDEX1_OES)
-GL_ENUM(0x8D47,GL_STENCIL_INDEX4_OES)
-GL_ENUM(0x8D48,GL_STENCIL_INDEX8_OES)
-GL_ENUM(0x8D50,GL_RENDERBUFFER_RED_SIZE_OES)
-GL_ENUM(0x8D51,GL_RENDERBUFFER_GREEN_SIZE_OES)
-GL_ENUM(0x8D52,GL_RENDERBUFFER_BLUE_SIZE_OES)
-GL_ENUM(0x8D53,GL_RENDERBUFFER_ALPHA_SIZE_OES)
-GL_ENUM(0x8D54,GL_RENDERBUFFER_DEPTH_SIZE_OES)
-GL_ENUM(0x8D55,GL_RENDERBUFFER_STENCIL_SIZE_OES)
-GL_ENUM(0x8D56,GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE)
-GL_ENUM(0x8D57,GL_MAX_SAMPLES_APPLE)
-GL_ENUM(0x8D60,GL_TEXTURE_GEN_STR_OES)
-GL_ENUM(0x8D61,GL_HALF_FLOAT_OES)
-GL_ENUM(0x8D62,GL_RGB565_OES)
-GL_ENUM(0x8D64,GL_ETC1_RGB8_OES)
-GL_ENUM(0x8D65,GL_TEXTURE_EXTERNAL_OES)
-GL_ENUM(0x8D66,GL_SAMPLER_EXTERNAL_OES)
-GL_ENUM(0x8D67,GL_TEXTURE_BINDING_EXTERNAL_OES)
-GL_ENUM(0x8D68,GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES)
-GL_ENUM(0x8D69,GL_PRIMITIVE_RESTART_FIXED_INDEX)
-GL_ENUM(0x8D6A,GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT)
-GL_ENUM(0x8D6B,GL_MAX_ELEMENT_INDEX)
-GL_ENUM(0x8D6C,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT)
-GL_ENUM(0x8D70,GL_RGBA32UI)
-GL_ENUM(0x8D71,GL_RGB32UI)
-GL_ENUM(0x8D76,GL_RGBA16UI)
-GL_ENUM(0x8D77,GL_RGB16UI)
-GL_ENUM(0x8D7C,GL_RGBA8UI)
-GL_ENUM(0x8D7D,GL_RGB8UI)
-GL_ENUM(0x8D82,GL_RGBA32I)
-GL_ENUM(0x8D83,GL_RGB32I)
-GL_ENUM(0x8D88,GL_RGBA16I)
-GL_ENUM(0x8D89,GL_RGB16I)
-GL_ENUM(0x8D8E,GL_RGBA8I)
-GL_ENUM(0x8D8F,GL_RGB8I)
-GL_ENUM(0x8D94,GL_RED_INTEGER)
-GL_ENUM(0x8D98,GL_RGB_INTEGER)
-GL_ENUM(0x8D99,GL_RGBA_INTEGER)
-GL_ENUM(0x8D9F,GL_INT_2_10_10_10_REV)
-GL_ENUM(0x8DAD,GL_FLOAT_32_UNSIGNED_INT_24_8_REV)
-GL_ENUM(0x8DC1,GL_SAMPLER_2D_ARRAY)
-GL_ENUM(0x8DC4,GL_SAMPLER_2D_ARRAY_SHADOW)
-GL_ENUM(0x8DC5,GL_SAMPLER_CUBE_SHADOW)
-GL_ENUM(0x8DC6,GL_UNSIGNED_INT_VEC2)
-GL_ENUM(0x8DC7,GL_UNSIGNED_INT_VEC3)
-GL_ENUM(0x8DC8,GL_UNSIGNED_INT_VEC4)
-GL_ENUM(0x8DCA,GL_INT_SAMPLER_2D)
-GL_ENUM(0x8DCB,GL_INT_SAMPLER_3D)
-GL_ENUM(0x8DCC,GL_INT_SAMPLER_CUBE)
-GL_ENUM(0x8DCF,GL_INT_SAMPLER_2D_ARRAY)
-GL_ENUM(0x8DD2,GL_UNSIGNED_INT_SAMPLER_2D)
-GL_ENUM(0x8DD3,GL_UNSIGNED_INT_SAMPLER_3D)
-GL_ENUM(0x8DD4,GL_UNSIGNED_INT_SAMPLER_CUBE)
-GL_ENUM(0x8DD7,GL_UNSIGNED_INT_SAMPLER_2D_ARRAY)
-GL_ENUM(0x8DF0,GL_LOW_FLOAT)
-GL_ENUM(0x8DF1,GL_MEDIUM_FLOAT)
-GL_ENUM(0x8DF2,GL_HIGH_FLOAT)
-GL_ENUM(0x8DF3,GL_LOW_INT)
-GL_ENUM(0x8DF4,GL_MEDIUM_INT)
-GL_ENUM(0x8DF5,GL_HIGH_INT)
-GL_ENUM(0x8DF6,GL_UNSIGNED_INT_10_10_10_2_OES)
-GL_ENUM(0x8DF7,GL_INT_10_10_10_2_OES)
-GL_ENUM(0x8DF8,GL_SHADER_BINARY_FORMATS)
-GL_ENUM(0x8DF9,GL_NUM_SHADER_BINARY_FORMATS)
-GL_ENUM(0x8DFA,GL_SHADER_COMPILER)
-GL_ENUM(0x8DFB,GL_MAX_VERTEX_UNIFORM_VECTORS)
-GL_ENUM(0x8DFC,GL_MAX_VARYING_VECTORS)
-GL_ENUM(0x8DFD,GL_MAX_FRAGMENT_UNIFORM_VECTORS)
-GL_ENUM(0x8E22,GL_TRANSFORM_FEEDBACK)
-GL_ENUM(0x8E23,GL_TRANSFORM_FEEDBACK_PAUSED)
-GL_ENUM(0x8E24,GL_TRANSFORM_FEEDBACK_ACTIVE)
-GL_ENUM(0x8E25,GL_TRANSFORM_FEEDBACK_BINDING)
-GL_ENUM(0x8E2C,GL_DEPTH_COMPONENT16_NONLINEAR_NV)
-GL_ENUM(0x8E42,GL_TEXTURE_SWIZZLE_R)
-GL_ENUM(0x8E43,GL_TEXTURE_SWIZZLE_G)
-GL_ENUM(0x8E44,GL_TEXTURE_SWIZZLE_B)
-GL_ENUM(0x8E45,GL_TEXTURE_SWIZZLE_A)
-GL_ENUM(0x8ED0,GL_COVERAGE_COMPONENT_NV)
-GL_ENUM(0x8ED1,GL_COVERAGE_COMPONENT4_NV)
-GL_ENUM(0x8ED2,GL_COVERAGE_ATTACHMENT_NV)
-GL_ENUM(0x8ED3,GL_COVERAGE_BUFFERS_NV)
-GL_ENUM(0x8ED4,GL_COVERAGE_SAMPLES_NV)
-GL_ENUM(0x8ED5,GL_COVERAGE_ALL_FRAGMENTS_NV)
-GL_ENUM(0x8ED6,GL_COVERAGE_EDGE_FRAGMENTS_NV)
-GL_ENUM(0x8ED7,GL_COVERAGE_AUTOMATIC_NV)
-GL_ENUM(0x8F36,GL_COPY_READ_BUFFER)
-GL_ENUM(0x8F37,GL_COPY_WRITE_BUFFER)
-GL_ENUM(0x8F60,GL_MALI_SHADER_BINARY_ARM)
-GL_ENUM(0x8F94,GL_R8_SNORM)
-GL_ENUM(0x8F95,GL_RG8_SNORM)
-GL_ENUM(0x8F96,GL_RGB8_SNORM)
-GL_ENUM(0x8F97,GL_RGBA8_SNORM)
-GL_ENUM(0x8F9C,GL_SIGNED_NORMALIZED)
-GL_ENUM(0x8FA0,GL_PERFMON_GLOBAL_MODE_QCOM)
-GL_ENUM(0x8FC4,GL_SHADER_BINARY_VIV)
-GL_ENUM(0x906F,GL_RGB10_A2UI)
-GL_ENUM(0x90F3,GL_CONTEXT_ROBUST_ACCESS_EXT)
+GL_ENUM(0xFFFFFFFFu,GL_INVALID_INDEX)
+GL_ENUM(0x9122,GL_MAX_VERTEX_OUTPUT_COMPONENTS)
+GL_ENUM(0x9125,GL_MAX_FRAGMENT_INPUT_COMPONENTS)
 GL_ENUM(0x9111,GL_MAX_SERVER_WAIT_TIMEOUT)
 GL_ENUM(0x9112,GL_OBJECT_TYPE)
 GL_ENUM(0x9113,GL_SYNC_CONDITION)
@@ -869,21 +706,27 @@
 GL_ENUM(0x911B,GL_TIMEOUT_EXPIRED)
 GL_ENUM(0x911C,GL_CONDITION_SATISFIED)
 GL_ENUM(0x911D,GL_WAIT_FAILED)
-GL_ENUM(0x911F,GL_BUFFER_ACCESS_FLAGS)
-GL_ENUM(0x9120,GL_BUFFER_MAP_LENGTH)
-GL_ENUM(0x9121,GL_BUFFER_MAP_OFFSET)
-GL_ENUM(0x9122,GL_MAX_VERTEX_OUTPUT_COMPONENTS)
-GL_ENUM(0x9125,GL_MAX_FRAGMENT_INPUT_COMPONENTS)
-GL_ENUM(0x912F,GL_TEXTURE_IMMUTABLE_FORMAT_EXT)
-GL_ENUM(0x9130,GL_SGX_PROGRAM_BINARY_IMG)
-GL_ENUM(0x9133,GL_RENDERBUFFER_SAMPLES_EXT)
-GL_ENUM(0x9134,GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT)
-GL_ENUM(0x9135,GL_MAX_SAMPLES_EXT)
-GL_ENUM(0x9136,GL_TEXTURE_SAMPLES_IMG)
-GL_ENUM(0x9151,GL_BUFFER_OBJECT_EXT)
-GL_ENUM(0x9153,GL_QUERY_OBJECT_EXT)
-GL_ENUM(0x9154,GL_VERTEX_ARRAY_OBJECT_EXT)
-GL_ENUM(0x9250,GL_SHADER_BINARY_DMP)
+GL_ENUM(0xFFFFFFFFFFFFFFFFull,GL_TIMEOUT_IGNORED)
+GL_ENUM(0x88FE,GL_VERTEX_ATTRIB_ARRAY_DIVISOR)
+GL_ENUM(0x8C2F,GL_ANY_SAMPLES_PASSED)
+GL_ENUM(0x8D6A,GL_ANY_SAMPLES_PASSED_CONSERVATIVE)
+GL_ENUM(0x8919,GL_SAMPLER_BINDING)
+GL_ENUM(0x906F,GL_RGB10_A2UI)
+GL_ENUM(0x8E42,GL_TEXTURE_SWIZZLE_R)
+GL_ENUM(0x8E43,GL_TEXTURE_SWIZZLE_G)
+GL_ENUM(0x8E44,GL_TEXTURE_SWIZZLE_B)
+GL_ENUM(0x8E45,GL_TEXTURE_SWIZZLE_A)
+GL_ENUM(0x1904,GL_GREEN)
+GL_ENUM(0x1905,GL_BLUE)
+GL_ENUM(0x8D9F,GL_INT_2_10_10_10_REV)
+GL_ENUM(0x8E22,GL_TRANSFORM_FEEDBACK)
+GL_ENUM(0x8E23,GL_TRANSFORM_FEEDBACK_PAUSED)
+GL_ENUM(0x8E24,GL_TRANSFORM_FEEDBACK_ACTIVE)
+GL_ENUM(0x8E25,GL_TRANSFORM_FEEDBACK_BINDING)
+GL_ENUM(0x8257,GL_PROGRAM_BINARY_RETRIEVABLE_HINT)
+GL_ENUM(0x8741,GL_PROGRAM_BINARY_LENGTH)
+GL_ENUM(0x87FE,GL_NUM_PROGRAM_BINARY_FORMATS)
+GL_ENUM(0x87FF,GL_PROGRAM_BINARY_FORMATS)
 GL_ENUM(0x9270,GL_COMPRESSED_R11_EAC)
 GL_ENUM(0x9271,GL_COMPRESSED_SIGNED_R11_EAC)
 GL_ENUM(0x9272,GL_COMPRESSED_RG11_EAC)
@@ -894,8 +737,624 @@
 GL_ENUM(0x9277,GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2)
 GL_ENUM(0x9278,GL_COMPRESSED_RGBA8_ETC2_EAC)
 GL_ENUM(0x9279,GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC)
+GL_ENUM(0x912F,GL_TEXTURE_IMMUTABLE_FORMAT)
+GL_ENUM(0x8D6B,GL_MAX_ELEMENT_INDEX)
 GL_ENUM(0x9380,GL_NUM_SAMPLE_COUNTS)
+GL_ENUM(0x82DF,GL_TEXTURE_IMMUTABLE_LEVELS)
+GL_ENUM(0x91B9,GL_COMPUTE_SHADER)
+GL_ENUM(0x91BB,GL_MAX_COMPUTE_UNIFORM_BLOCKS)
+GL_ENUM(0x91BC,GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS)
+GL_ENUM(0x91BD,GL_MAX_COMPUTE_IMAGE_UNIFORMS)
+GL_ENUM(0x8262,GL_MAX_COMPUTE_SHARED_MEMORY_SIZE)
+GL_ENUM(0x8263,GL_MAX_COMPUTE_UNIFORM_COMPONENTS)
+GL_ENUM(0x8264,GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS)
+GL_ENUM(0x8265,GL_MAX_COMPUTE_ATOMIC_COUNTERS)
+GL_ENUM(0x8266,GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS)
+GL_ENUM(0x90EB,GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS)
+GL_ENUM(0x91BE,GL_MAX_COMPUTE_WORK_GROUP_COUNT)
+GL_ENUM(0x91BF,GL_MAX_COMPUTE_WORK_GROUP_SIZE)
+GL_ENUM(0x8267,GL_COMPUTE_WORK_GROUP_SIZE)
+GL_ENUM(0x90EE,GL_DISPATCH_INDIRECT_BUFFER)
+GL_ENUM(0x90EF,GL_DISPATCH_INDIRECT_BUFFER_BINDING)
+GL_ENUM(0x8F3F,GL_DRAW_INDIRECT_BUFFER)
+GL_ENUM(0x8F43,GL_DRAW_INDIRECT_BUFFER_BINDING)
+GL_ENUM(0x826E,GL_MAX_UNIFORM_LOCATIONS)
+GL_ENUM(0x9310,GL_FRAMEBUFFER_DEFAULT_WIDTH)
+GL_ENUM(0x9311,GL_FRAMEBUFFER_DEFAULT_HEIGHT)
+GL_ENUM(0x9313,GL_FRAMEBUFFER_DEFAULT_SAMPLES)
+GL_ENUM(0x9314,GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS)
+GL_ENUM(0x9315,GL_MAX_FRAMEBUFFER_WIDTH)
+GL_ENUM(0x9316,GL_MAX_FRAMEBUFFER_HEIGHT)
+GL_ENUM(0x9318,GL_MAX_FRAMEBUFFER_SAMPLES)
+GL_ENUM(0x92E1,GL_UNIFORM)
+GL_ENUM(0x92E2,GL_UNIFORM_BLOCK)
+GL_ENUM(0x92E3,GL_PROGRAM_INPUT)
+GL_ENUM(0x92E4,GL_PROGRAM_OUTPUT)
+GL_ENUM(0x92E5,GL_BUFFER_VARIABLE)
+GL_ENUM(0x92E6,GL_SHADER_STORAGE_BLOCK)
+GL_ENUM(0x92C0,GL_ATOMIC_COUNTER_BUFFER)
+GL_ENUM(0x92F4,GL_TRANSFORM_FEEDBACK_VARYING)
+GL_ENUM(0x92F5,GL_ACTIVE_RESOURCES)
+GL_ENUM(0x92F6,GL_MAX_NAME_LENGTH)
+GL_ENUM(0x92F7,GL_MAX_NUM_ACTIVE_VARIABLES)
+GL_ENUM(0x92F9,GL_NAME_LENGTH)
+GL_ENUM(0x92FA,GL_TYPE)
+GL_ENUM(0x92FB,GL_ARRAY_SIZE)
+GL_ENUM(0x92FC,GL_OFFSET)
+GL_ENUM(0x92FD,GL_BLOCK_INDEX)
+GL_ENUM(0x92FE,GL_ARRAY_STRIDE)
+GL_ENUM(0x92FF,GL_MATRIX_STRIDE)
+GL_ENUM(0x9300,GL_IS_ROW_MAJOR)
+GL_ENUM(0x9301,GL_ATOMIC_COUNTER_BUFFER_INDEX)
+GL_ENUM(0x9302,GL_BUFFER_BINDING)
+GL_ENUM(0x9303,GL_BUFFER_DATA_SIZE)
+GL_ENUM(0x9304,GL_NUM_ACTIVE_VARIABLES)
+GL_ENUM(0x9305,GL_ACTIVE_VARIABLES)
+GL_ENUM(0x9306,GL_REFERENCED_BY_VERTEX_SHADER)
+GL_ENUM(0x930A,GL_REFERENCED_BY_FRAGMENT_SHADER)
+GL_ENUM(0x930B,GL_REFERENCED_BY_COMPUTE_SHADER)
+GL_ENUM(0x930C,GL_TOP_LEVEL_ARRAY_SIZE)
+GL_ENUM(0x930D,GL_TOP_LEVEL_ARRAY_STRIDE)
+GL_ENUM(0x930E,GL_LOCATION)
+GL_ENUM(0xFFFFFFFF,GL_ALL_SHADER_BITS)
+GL_ENUM(0x8258,GL_PROGRAM_SEPARABLE)
+GL_ENUM(0x8259,GL_ACTIVE_PROGRAM)
+GL_ENUM(0x825A,GL_PROGRAM_PIPELINE_BINDING)
+GL_ENUM(0x92C1,GL_ATOMIC_COUNTER_BUFFER_BINDING)
+GL_ENUM(0x92C2,GL_ATOMIC_COUNTER_BUFFER_START)
+GL_ENUM(0x92C3,GL_ATOMIC_COUNTER_BUFFER_SIZE)
+GL_ENUM(0x92CC,GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS)
+GL_ENUM(0x92D0,GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS)
+GL_ENUM(0x92D1,GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS)
+GL_ENUM(0x92D2,GL_MAX_VERTEX_ATOMIC_COUNTERS)
+GL_ENUM(0x92D6,GL_MAX_FRAGMENT_ATOMIC_COUNTERS)
+GL_ENUM(0x92D7,GL_MAX_COMBINED_ATOMIC_COUNTERS)
+GL_ENUM(0x92D8,GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE)
+GL_ENUM(0x92DC,GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS)
+GL_ENUM(0x92D9,GL_ACTIVE_ATOMIC_COUNTER_BUFFERS)
+GL_ENUM(0x92DB,GL_UNSIGNED_INT_ATOMIC_COUNTER)
+GL_ENUM(0x8F38,GL_MAX_IMAGE_UNITS)
+GL_ENUM(0x90CA,GL_MAX_VERTEX_IMAGE_UNIFORMS)
+GL_ENUM(0x90CE,GL_MAX_FRAGMENT_IMAGE_UNIFORMS)
+GL_ENUM(0x90CF,GL_MAX_COMBINED_IMAGE_UNIFORMS)
+GL_ENUM(0x8F3A,GL_IMAGE_BINDING_NAME)
+GL_ENUM(0x8F3B,GL_IMAGE_BINDING_LEVEL)
+GL_ENUM(0x8F3C,GL_IMAGE_BINDING_LAYERED)
+GL_ENUM(0x8F3D,GL_IMAGE_BINDING_LAYER)
+GL_ENUM(0x8F3E,GL_IMAGE_BINDING_ACCESS)
+GL_ENUM(0x906E,GL_IMAGE_BINDING_FORMAT)
+GL_ENUM(0x904D,GL_IMAGE_2D)
+GL_ENUM(0x904E,GL_IMAGE_3D)
+GL_ENUM(0x9050,GL_IMAGE_CUBE)
+GL_ENUM(0x9053,GL_IMAGE_2D_ARRAY)
+GL_ENUM(0x9058,GL_INT_IMAGE_2D)
+GL_ENUM(0x9059,GL_INT_IMAGE_3D)
+GL_ENUM(0x905B,GL_INT_IMAGE_CUBE)
+GL_ENUM(0x905E,GL_INT_IMAGE_2D_ARRAY)
+GL_ENUM(0x9063,GL_UNSIGNED_INT_IMAGE_2D)
+GL_ENUM(0x9064,GL_UNSIGNED_INT_IMAGE_3D)
+GL_ENUM(0x9066,GL_UNSIGNED_INT_IMAGE_CUBE)
+GL_ENUM(0x9069,GL_UNSIGNED_INT_IMAGE_2D_ARRAY)
+GL_ENUM(0x90C7,GL_IMAGE_FORMAT_COMPATIBILITY_TYPE)
+GL_ENUM(0x90C8,GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE)
+GL_ENUM(0x90C9,GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS)
+GL_ENUM(0x88B8,GL_READ_ONLY)
+GL_ENUM(0x88B9,GL_WRITE_ONLY)
+GL_ENUM(0x88BA,GL_READ_WRITE)
+GL_ENUM(0x90D2,GL_SHADER_STORAGE_BUFFER)
+GL_ENUM(0x90D3,GL_SHADER_STORAGE_BUFFER_BINDING)
+GL_ENUM(0x90D4,GL_SHADER_STORAGE_BUFFER_START)
+GL_ENUM(0x90D5,GL_SHADER_STORAGE_BUFFER_SIZE)
+GL_ENUM(0x90D6,GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS)
+GL_ENUM(0x90DA,GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS)
+GL_ENUM(0x90DB,GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS)
+GL_ENUM(0x90DC,GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS)
+GL_ENUM(0x90DD,GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS)
+GL_ENUM(0x90DE,GL_MAX_SHADER_STORAGE_BLOCK_SIZE)
+GL_ENUM(0x90DF,GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT)
+GL_ENUM(0x8F39,GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES)
+GL_ENUM(0x90EA,GL_DEPTH_STENCIL_TEXTURE_MODE)
+GL_ENUM(0x1901,GL_STENCIL_INDEX)
+GL_ENUM(0x8E5E,GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET)
+GL_ENUM(0x8E5F,GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET)
+GL_ENUM(0x8E50,GL_SAMPLE_POSITION)
+GL_ENUM(0x8E51,GL_SAMPLE_MASK)
+GL_ENUM(0x8E52,GL_SAMPLE_MASK_VALUE)
+GL_ENUM(0x9100,GL_TEXTURE_2D_MULTISAMPLE)
+GL_ENUM(0x8E59,GL_MAX_SAMPLE_MASK_WORDS)
+GL_ENUM(0x910E,GL_MAX_COLOR_TEXTURE_SAMPLES)
+GL_ENUM(0x910F,GL_MAX_DEPTH_TEXTURE_SAMPLES)
+GL_ENUM(0x9110,GL_MAX_INTEGER_SAMPLES)
+GL_ENUM(0x9104,GL_TEXTURE_BINDING_2D_MULTISAMPLE)
+GL_ENUM(0x9106,GL_TEXTURE_SAMPLES)
+GL_ENUM(0x9107,GL_TEXTURE_FIXED_SAMPLE_LOCATIONS)
+GL_ENUM(0x1000,GL_TEXTURE_WIDTH)
+GL_ENUM(0x1001,GL_TEXTURE_HEIGHT)
+GL_ENUM(0x8071,GL_TEXTURE_DEPTH)
+GL_ENUM(0x1003,GL_TEXTURE_INTERNAL_FORMAT)
+GL_ENUM(0x805C,GL_TEXTURE_RED_SIZE)
+GL_ENUM(0x805D,GL_TEXTURE_GREEN_SIZE)
+GL_ENUM(0x805E,GL_TEXTURE_BLUE_SIZE)
+GL_ENUM(0x805F,GL_TEXTURE_ALPHA_SIZE)
+GL_ENUM(0x884A,GL_TEXTURE_DEPTH_SIZE)
+GL_ENUM(0x88F1,GL_TEXTURE_STENCIL_SIZE)
+GL_ENUM(0x8C3F,GL_TEXTURE_SHARED_SIZE)
+GL_ENUM(0x8C10,GL_TEXTURE_RED_TYPE)
+GL_ENUM(0x8C11,GL_TEXTURE_GREEN_TYPE)
+GL_ENUM(0x8C12,GL_TEXTURE_BLUE_TYPE)
+GL_ENUM(0x8C13,GL_TEXTURE_ALPHA_TYPE)
+GL_ENUM(0x8C16,GL_TEXTURE_DEPTH_TYPE)
+GL_ENUM(0x86A1,GL_TEXTURE_COMPRESSED)
+GL_ENUM(0x9108,GL_SAMPLER_2D_MULTISAMPLE)
+GL_ENUM(0x9109,GL_INT_SAMPLER_2D_MULTISAMPLE)
+GL_ENUM(0x910A,GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE)
+GL_ENUM(0x82D4,GL_VERTEX_ATTRIB_BINDING)
+GL_ENUM(0x82D5,GL_VERTEX_ATTRIB_RELATIVE_OFFSET)
+GL_ENUM(0x82D6,GL_VERTEX_BINDING_DIVISOR)
+GL_ENUM(0x82D7,GL_VERTEX_BINDING_OFFSET)
+GL_ENUM(0x82D8,GL_VERTEX_BINDING_STRIDE)
+GL_ENUM(0x8F4F,GL_VERTEX_BINDING_BUFFER)
+GL_ENUM(0x82D9,GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET)
+GL_ENUM(0x82DA,GL_MAX_VERTEX_ATTRIB_BINDINGS)
+GL_ENUM(0x82E5,GL_MAX_VERTEX_ATTRIB_STRIDE)
+GL_ENUM(0x8D65,GL_TEXTURE_EXTERNAL_OES)
+GL_ENUM(0x8D67,GL_TEXTURE_BINDING_EXTERNAL_OES)
+GL_ENUM(0x8D68,GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES)
+GL_ENUM(0x8D64,GL_ETC1_RGB8_OES)
+GL_ENUM(0x8B90,GL_PALETTE4_RGB8_OES)
+GL_ENUM(0x8B91,GL_PALETTE4_RGBA8_OES)
+GL_ENUM(0x8B92,GL_PALETTE4_R5_G6_B5_OES)
+GL_ENUM(0x8B93,GL_PALETTE4_RGBA4_OES)
+GL_ENUM(0x8B94,GL_PALETTE4_RGB5_A1_OES)
+GL_ENUM(0x8B95,GL_PALETTE8_RGB8_OES)
+GL_ENUM(0x8B96,GL_PALETTE8_RGBA8_OES)
+GL_ENUM(0x8B97,GL_PALETTE8_R5_G6_B5_OES)
+GL_ENUM(0x8B98,GL_PALETTE8_RGBA4_OES)
+GL_ENUM(0x8B99,GL_PALETTE8_RGB5_A1_OES)
+GL_ENUM(0x81A7,GL_DEPTH_COMPONENT32_OES)
+GL_ENUM(0x8B9D,GL_TEXTURE_CROP_RECT_OES)
+GL_ENUM(0x8CDA,GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES)
+GL_ENUM(0x88BB,GL_BUFFER_ACCESS_OES)
+GL_ENUM(0x898D,GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES)
+GL_ENUM(0x898E,GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES)
+GL_ENUM(0x898F,GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES)
+GL_ENUM(0x86A4,GL_MAX_VERTEX_UNITS_OES)
+GL_ENUM(0x8842,GL_MAX_PALETTE_MATRICES_OES)
+GL_ENUM(0x8840,GL_MATRIX_PALETTE_OES)
+GL_ENUM(0x8844,GL_MATRIX_INDEX_ARRAY_OES)
+GL_ENUM(0x86AD,GL_WEIGHT_ARRAY_OES)
+GL_ENUM(0x8843,GL_CURRENT_PALETTE_MATRIX_OES)
+GL_ENUM(0x8846,GL_MATRIX_INDEX_ARRAY_SIZE_OES)
+GL_ENUM(0x8847,GL_MATRIX_INDEX_ARRAY_TYPE_OES)
+GL_ENUM(0x8848,GL_MATRIX_INDEX_ARRAY_STRIDE_OES)
+GL_ENUM(0x8849,GL_MATRIX_INDEX_ARRAY_POINTER_OES)
+GL_ENUM(0x8B9E,GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES)
+GL_ENUM(0x86AB,GL_WEIGHT_ARRAY_SIZE_OES)
+GL_ENUM(0x86A9,GL_WEIGHT_ARRAY_TYPE_OES)
+GL_ENUM(0x86AA,GL_WEIGHT_ARRAY_STRIDE_OES)
+GL_ENUM(0x86AC,GL_WEIGHT_ARRAY_POINTER_OES)
+GL_ENUM(0x889E,GL_WEIGHT_ARRAY_BUFFER_BINDING_OES)
+GL_ENUM(0x8B9C,GL_POINT_SIZE_ARRAY_OES)
+GL_ENUM(0x898A,GL_POINT_SIZE_ARRAY_TYPE_OES)
+GL_ENUM(0x898B,GL_POINT_SIZE_ARRAY_STRIDE_OES)
+GL_ENUM(0x898C,GL_POINT_SIZE_ARRAY_POINTER_OES)
+GL_ENUM(0x8B9F,GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES)
+GL_ENUM(0x8861,GL_POINT_SPRITE_OES)
+GL_ENUM(0x8862,GL_COORD_REPLACE_OES)
+GL_ENUM(0x803C,GL_ALPHA8_OES)
+GL_ENUM(0x8043,GL_LUMINANCE4_ALPHA4_OES)
+GL_ENUM(0x8045,GL_LUMINANCE8_ALPHA8_OES)
+GL_ENUM(0x8040,GL_LUMINANCE8_OES)
+GL_ENUM(0x8052,GL_RGB10_EXT)
+GL_ENUM(0x8D46,GL_STENCIL_INDEX1_OES)
+GL_ENUM(0x8D47,GL_STENCIL_INDEX4_OES)
+GL_ENUM(0x8511,GL_NORMAL_MAP_OES)
+GL_ENUM(0x8512,GL_REFLECTION_MAP_OES)
+GL_ENUM(0x2500,GL_TEXTURE_GEN_MODE_OES)
+GL_ENUM(0x8D60,GL_TEXTURE_GEN_STR_OES)
+GL_ENUM(0x87F9,GL_3DC_X_AMD)
+GL_ENUM(0x87FA,GL_3DC_XY_AMD)
+GL_ENUM(0x8C92,GL_ATC_RGB_AMD)
+GL_ENUM(0x8C93,GL_ATC_RGBA_EXPLICIT_ALPHA_AMD)
+GL_ENUM(0x87EE,GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD)
+GL_ENUM(0x8A53,GL_SYNC_OBJECT_APPLE)
+GL_ENUM(0x80E1,GL_BGRA_EXT)
 GL_ENUM(0x93A1,GL_BGRA8_EXT)
-GL_ENUM(0xFFFFFFFF,GL_ALL_SHADER_BITS_EXT)
-GL_ENUM(0xFFFFFFFFFFFFFFFFull,GL_TIMEOUT_IGNORED)
-GL_ENUM(0xFFFFFFFFu,GL_INVALID_INDEX)
+GL_ENUM(0x8D6C,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT)
+GL_ENUM(0x8365,GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT)
+GL_ENUM(0x8366,GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT)
+GL_ENUM(0x8253,GL_GUILTY_CONTEXT_RESET_EXT)
+GL_ENUM(0x8254,GL_INNOCENT_CONTEXT_RESET_EXT)
+GL_ENUM(0x8255,GL_UNKNOWN_CONTEXT_RESET_EXT)
+GL_ENUM(0x90F3,GL_CONTEXT_ROBUST_ACCESS_EXT)
+GL_ENUM(0x8256,GL_RESET_NOTIFICATION_STRATEGY_EXT)
+GL_ENUM(0x8252,GL_LOSE_CONTEXT_ON_RESET_EXT)
+GL_ENUM(0x8261,GL_NO_RESET_NOTIFICATION_EXT)
+GL_ENUM(0x8C42,GL_SRGB_ALPHA_EXT)
+GL_ENUM(0x83F0,GL_COMPRESSED_RGB_S3TC_DXT1_EXT)
+GL_ENUM(0x83F1,GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)
+GL_ENUM(0x84FE,GL_TEXTURE_MAX_ANISOTROPY_EXT)
+GL_ENUM(0x84FF,GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)
+GL_ENUM(0x8500,GL_TEXTURE_FILTER_CONTROL_EXT)
+GL_ENUM(0x8501,GL_TEXTURE_LOD_BIAS_EXT)
+GL_ENUM(0x8816,GL_ALPHA32F_EXT)
+GL_ENUM(0x8818,GL_LUMINANCE32F_EXT)
+GL_ENUM(0x8819,GL_LUMINANCE_ALPHA32F_EXT)
+GL_ENUM(0x881C,GL_ALPHA16F_EXT)
+GL_ENUM(0x881E,GL_LUMINANCE16F_EXT)
+GL_ENUM(0x881F,GL_LUMINANCE_ALPHA16F_EXT)
+GL_ENUM(0x9133,GL_RENDERBUFFER_SAMPLES_IMG)
+GL_ENUM(0x9134,GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG)
+GL_ENUM(0x9135,GL_MAX_SAMPLES_IMG)
+GL_ENUM(0x9136,GL_TEXTURE_SAMPLES_IMG)
+GL_ENUM(0x8C00,GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG)
+GL_ENUM(0x8C01,GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG)
+GL_ENUM(0x8C02,GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG)
+GL_ENUM(0x8C03,GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG)
+GL_ENUM(0x8C04,GL_MODULATE_COLOR_IMG)
+GL_ENUM(0x8C05,GL_RECIP_ADD_SIGNED_ALPHA_IMG)
+GL_ENUM(0x8C06,GL_TEXTURE_ALPHA_MODULATE_IMG)
+GL_ENUM(0x8C07,GL_FACTOR_ALPHA_MODULATE_IMG)
+GL_ENUM(0x8C08,GL_FRAGMENT_ALPHA_MODULATE_IMG)
+GL_ENUM(0x8C09,GL_ADD_BLEND_IMG)
+GL_ENUM(0x84F2,GL_ALL_COMPLETED_NV)
+GL_ENUM(0x84F3,GL_FENCE_STATUS_NV)
+GL_ENUM(0x84F4,GL_FENCE_CONDITION_NV)
+GL_ENUM(0x8BD2,GL_TEXTURE_WIDTH_QCOM)
+GL_ENUM(0x8BD3,GL_TEXTURE_HEIGHT_QCOM)
+GL_ENUM(0x8BD4,GL_TEXTURE_DEPTH_QCOM)
+GL_ENUM(0x8BD5,GL_TEXTURE_INTERNAL_FORMAT_QCOM)
+GL_ENUM(0x8BD6,GL_TEXTURE_FORMAT_QCOM)
+GL_ENUM(0x8BD7,GL_TEXTURE_TYPE_QCOM)
+GL_ENUM(0x8BD8,GL_TEXTURE_IMAGE_VALID_QCOM)
+GL_ENUM(0x8BD9,GL_TEXTURE_NUM_LEVELS_QCOM)
+GL_ENUM(0x8BDA,GL_TEXTURE_TARGET_QCOM)
+GL_ENUM(0x8BDB,GL_TEXTURE_OBJECT_VALID_QCOM)
+GL_ENUM(0x8BDC,GL_STATE_RESTORE)
+GL_ENUM(0x8FA0,GL_PERFMON_GLOBAL_MODE_QCOM)
+GL_ENUM(0x8823,GL_WRITEONLY_RENDERING_QCOM)
+GL_ENUM(0x9285,GL_BLEND_ADVANCED_COHERENT_KHR)
+GL_ENUM(0x9294,GL_MULTIPLY_KHR)
+GL_ENUM(0x9295,GL_SCREEN_KHR)
+GL_ENUM(0x9296,GL_OVERLAY_KHR)
+GL_ENUM(0x9297,GL_DARKEN_KHR)
+GL_ENUM(0x9298,GL_LIGHTEN_KHR)
+GL_ENUM(0x9299,GL_COLORDODGE_KHR)
+GL_ENUM(0x929A,GL_COLORBURN_KHR)
+GL_ENUM(0x929B,GL_HARDLIGHT_KHR)
+GL_ENUM(0x929C,GL_SOFTLIGHT_KHR)
+GL_ENUM(0x929E,GL_DIFFERENCE_KHR)
+GL_ENUM(0x92A0,GL_EXCLUSION_KHR)
+GL_ENUM(0x92AD,GL_HSL_HUE_KHR)
+GL_ENUM(0x92AE,GL_HSL_SATURATION_KHR)
+GL_ENUM(0x92AF,GL_HSL_COLOR_KHR)
+GL_ENUM(0x92B0,GL_HSL_LUMINOSITY_KHR)
+GL_ENUM(0x82E6,GL_SAMPLER)
+GL_ENUM(0x8242,GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR)
+GL_ENUM(0x8243,GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR)
+GL_ENUM(0x8244,GL_DEBUG_CALLBACK_FUNCTION_KHR)
+GL_ENUM(0x8245,GL_DEBUG_CALLBACK_USER_PARAM_KHR)
+GL_ENUM(0x8246,GL_DEBUG_SOURCE_API_KHR)
+GL_ENUM(0x8247,GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR)
+GL_ENUM(0x8248,GL_DEBUG_SOURCE_SHADER_COMPILER_KHR)
+GL_ENUM(0x8249,GL_DEBUG_SOURCE_THIRD_PARTY_KHR)
+GL_ENUM(0x824A,GL_DEBUG_SOURCE_APPLICATION_KHR)
+GL_ENUM(0x824B,GL_DEBUG_SOURCE_OTHER_KHR)
+GL_ENUM(0x824C,GL_DEBUG_TYPE_ERROR_KHR)
+GL_ENUM(0x824D,GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR)
+GL_ENUM(0x824E,GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR)
+GL_ENUM(0x824F,GL_DEBUG_TYPE_PORTABILITY_KHR)
+GL_ENUM(0x8250,GL_DEBUG_TYPE_PERFORMANCE_KHR)
+GL_ENUM(0x8251,GL_DEBUG_TYPE_OTHER_KHR)
+GL_ENUM(0x8268,GL_DEBUG_TYPE_MARKER_KHR)
+GL_ENUM(0x8269,GL_DEBUG_TYPE_PUSH_GROUP_KHR)
+GL_ENUM(0x826A,GL_DEBUG_TYPE_POP_GROUP_KHR)
+GL_ENUM(0x826B,GL_DEBUG_SEVERITY_NOTIFICATION_KHR)
+GL_ENUM(0x826C,GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR)
+GL_ENUM(0x826D,GL_DEBUG_GROUP_STACK_DEPTH_KHR)
+GL_ENUM(0x82E0,GL_BUFFER_KHR)
+GL_ENUM(0x82E1,GL_SHADER_KHR)
+GL_ENUM(0x82E2,GL_PROGRAM_KHR)
+GL_ENUM(0x82E3,GL_QUERY_KHR)
+GL_ENUM(0x82E8,GL_MAX_LABEL_LENGTH_KHR)
+GL_ENUM(0x9143,GL_MAX_DEBUG_MESSAGE_LENGTH_KHR)
+GL_ENUM(0x9144,GL_MAX_DEBUG_LOGGED_MESSAGES_KHR)
+GL_ENUM(0x9145,GL_DEBUG_LOGGED_MESSAGES_KHR)
+GL_ENUM(0x9146,GL_DEBUG_SEVERITY_HIGH_KHR)
+GL_ENUM(0x9147,GL_DEBUG_SEVERITY_MEDIUM_KHR)
+GL_ENUM(0x9148,GL_DEBUG_SEVERITY_LOW_KHR)
+GL_ENUM(0x92E0,GL_DEBUG_OUTPUT_KHR)
+GL_ENUM(0x93B0,GL_COMPRESSED_RGBA_ASTC_4x4_KHR)
+GL_ENUM(0x93B1,GL_COMPRESSED_RGBA_ASTC_5x4_KHR)
+GL_ENUM(0x93B2,GL_COMPRESSED_RGBA_ASTC_5x5_KHR)
+GL_ENUM(0x93B3,GL_COMPRESSED_RGBA_ASTC_6x5_KHR)
+GL_ENUM(0x93B4,GL_COMPRESSED_RGBA_ASTC_6x6_KHR)
+GL_ENUM(0x93B5,GL_COMPRESSED_RGBA_ASTC_8x5_KHR)
+GL_ENUM(0x93B6,GL_COMPRESSED_RGBA_ASTC_8x6_KHR)
+GL_ENUM(0x93B7,GL_COMPRESSED_RGBA_ASTC_8x8_KHR)
+GL_ENUM(0x93B8,GL_COMPRESSED_RGBA_ASTC_10x5_KHR)
+GL_ENUM(0x93B9,GL_COMPRESSED_RGBA_ASTC_10x6_KHR)
+GL_ENUM(0x93BA,GL_COMPRESSED_RGBA_ASTC_10x8_KHR)
+GL_ENUM(0x93BB,GL_COMPRESSED_RGBA_ASTC_10x10_KHR)
+GL_ENUM(0x93BC,GL_COMPRESSED_RGBA_ASTC_12x10_KHR)
+GL_ENUM(0x93BD,GL_COMPRESSED_RGBA_ASTC_12x12_KHR)
+GL_ENUM(0x93D0,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR)
+GL_ENUM(0x93D1,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR)
+GL_ENUM(0x93D2,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR)
+GL_ENUM(0x93D3,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR)
+GL_ENUM(0x93D4,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR)
+GL_ENUM(0x93D5,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR)
+GL_ENUM(0x93D6,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR)
+GL_ENUM(0x93D7,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR)
+GL_ENUM(0x93D8,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR)
+GL_ENUM(0x93D9,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR)
+GL_ENUM(0x93DA,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR)
+GL_ENUM(0x93DB,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR)
+GL_ENUM(0x93DC,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR)
+GL_ENUM(0x93DD,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR)
+GL_ENUM(0x8D66,GL_SAMPLER_EXTERNAL_OES)
+GL_ENUM(0x8C36,GL_SAMPLE_SHADING_OES)
+GL_ENUM(0x8C37,GL_MIN_SAMPLE_SHADING_VALUE_OES)
+GL_ENUM(0x8E5B,GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES)
+GL_ENUM(0x8E5C,GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES)
+GL_ENUM(0x8E5D,GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES)
+GL_ENUM(0x93C0,GL_COMPRESSED_RGBA_ASTC_3x3x3_OES)
+GL_ENUM(0x93C1,GL_COMPRESSED_RGBA_ASTC_4x3x3_OES)
+GL_ENUM(0x93C2,GL_COMPRESSED_RGBA_ASTC_4x4x3_OES)
+GL_ENUM(0x93C3,GL_COMPRESSED_RGBA_ASTC_4x4x4_OES)
+GL_ENUM(0x93C4,GL_COMPRESSED_RGBA_ASTC_5x4x4_OES)
+GL_ENUM(0x93C5,GL_COMPRESSED_RGBA_ASTC_5x5x4_OES)
+GL_ENUM(0x93C6,GL_COMPRESSED_RGBA_ASTC_5x5x5_OES)
+GL_ENUM(0x93C7,GL_COMPRESSED_RGBA_ASTC_6x5x5_OES)
+GL_ENUM(0x93C8,GL_COMPRESSED_RGBA_ASTC_6x6x5_OES)
+GL_ENUM(0x93C9,GL_COMPRESSED_RGBA_ASTC_6x6x6_OES)
+GL_ENUM(0x93E0,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES)
+GL_ENUM(0x93E1,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES)
+GL_ENUM(0x93E2,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES)
+GL_ENUM(0x93E3,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES)
+GL_ENUM(0x93E4,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES)
+GL_ENUM(0x93E5,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES)
+GL_ENUM(0x93E6,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES)
+GL_ENUM(0x93E7,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES)
+GL_ENUM(0x93E8,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES)
+GL_ENUM(0x93E9,GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES)
+GL_ENUM(0x8D61,GL_HALF_FLOAT_OES)
+GL_ENUM(0x9102,GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES)
+GL_ENUM(0x9105,GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES)
+GL_ENUM(0x910B,GL_SAMPLER_2D_MULTISAMPLE_ARRAY_OES)
+GL_ENUM(0x910C,GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES)
+GL_ENUM(0x910D,GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES)
+GL_ENUM(0x8DF6,GL_UNSIGNED_INT_10_10_10_2_OES)
+GL_ENUM(0x8DF7,GL_INT_10_10_10_2_OES)
+GL_ENUM(0x8BC0,GL_COUNTER_TYPE_AMD)
+GL_ENUM(0x8BC1,GL_COUNTER_RANGE_AMD)
+GL_ENUM(0x8BC2,GL_UNSIGNED_INT64_AMD)
+GL_ENUM(0x8BC3,GL_PERCENTAGE_AMD)
+GL_ENUM(0x8BC4,GL_PERFMON_RESULT_AVAILABLE_AMD)
+GL_ENUM(0x8BC5,GL_PERFMON_RESULT_SIZE_AMD)
+GL_ENUM(0x8BC6,GL_PERFMON_RESULT_AMD)
+GL_ENUM(0x8740,GL_Z400_BINARY_AMD)
+GL_ENUM(0x93A4,GL_PACK_REVERSE_ROW_ORDER_ANGLE)
+GL_ENUM(0x93A6,GL_PROGRAM_BINARY_ANGLE)
+GL_ENUM(0x83F2,GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE)
+GL_ENUM(0x83F3,GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE)
+GL_ENUM(0x93A2,GL_TEXTURE_USAGE_ANGLE)
+GL_ENUM(0x93A3,GL_FRAMEBUFFER_ATTACHMENT_ANGLE)
+GL_ENUM(0x93A0,GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE)
+GL_ENUM(0x8A1F,GL_RGB_422_APPLE)
+GL_ENUM(0x85BA,GL_UNSIGNED_SHORT_8_8_APPLE)
+GL_ENUM(0x85BB,GL_UNSIGNED_SHORT_8_8_REV_APPLE)
+GL_ENUM(0x8A51,GL_RGB_RAW_422_APPLE)
+GL_ENUM(0x8F61,GL_MALI_PROGRAM_BINARY_ARM)
+GL_ENUM(0x8F60,GL_MALI_SHADER_BINARY_ARM)
+GL_ENUM(0x8F65,GL_FETCH_PER_SAMPLE_ARM)
+GL_ENUM(0x8F66,GL_FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM)
+GL_ENUM(0x9250,GL_SHADER_BINARY_DMP)
+GL_ENUM(0x8A4F,GL_PROGRAM_PIPELINE_OBJECT_EXT)
+GL_ENUM(0x8B40,GL_PROGRAM_OBJECT_EXT)
+GL_ENUM(0x8B48,GL_SHADER_OBJECT_EXT)
+GL_ENUM(0x9151,GL_BUFFER_OBJECT_EXT)
+GL_ENUM(0x9153,GL_QUERY_OBJECT_EXT)
+GL_ENUM(0x9154,GL_VERTEX_ARRAY_OBJECT_EXT)
+GL_ENUM(0x8864,GL_QUERY_COUNTER_BITS_EXT)
+GL_ENUM(0x88BF,GL_TIME_ELAPSED_EXT)
+GL_ENUM(0x8E28,GL_TIMESTAMP_EXT)
+GL_ENUM(0x8FBB,GL_GPU_DISJOINT_EXT)
+GL_ENUM(0x8DD9,GL_GEOMETRY_SHADER_EXT)
+GL_ENUM(0x8916,GL_GEOMETRY_LINKED_VERTICES_OUT_EXT)
+GL_ENUM(0x8917,GL_GEOMETRY_LINKED_INPUT_TYPE_EXT)
+GL_ENUM(0x8918,GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT)
+GL_ENUM(0x887F,GL_GEOMETRY_SHADER_INVOCATIONS_EXT)
+GL_ENUM(0x825E,GL_LAYER_PROVOKING_VERTEX_EXT)
+GL_ENUM(0x000A,GL_LINES_ADJACENCY_EXT)
+GL_ENUM(0x000B,GL_LINE_STRIP_ADJACENCY_EXT)
+GL_ENUM(0x000C,GL_TRIANGLES_ADJACENCY_EXT)
+GL_ENUM(0x000D,GL_TRIANGLE_STRIP_ADJACENCY_EXT)
+GL_ENUM(0x8DDF,GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT)
+GL_ENUM(0x8A2C,GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT)
+GL_ENUM(0x8A32,GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT)
+GL_ENUM(0x9123,GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT)
+GL_ENUM(0x9124,GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT)
+GL_ENUM(0x8DE0,GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT)
+GL_ENUM(0x8DE1,GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT)
+GL_ENUM(0x8E5A,GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT)
+GL_ENUM(0x8C29,GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT)
+GL_ENUM(0x92CF,GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT)
+GL_ENUM(0x92D5,GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT)
+GL_ENUM(0x90CD,GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT)
+GL_ENUM(0x90D7,GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT)
+GL_ENUM(0x8E4D,GL_FIRST_VERTEX_CONVENTION_EXT)
+GL_ENUM(0x8E4E,GL_LAST_VERTEX_CONVENTION_EXT)
+GL_ENUM(0x8260,GL_UNDEFINED_VERTEX_EXT)
+GL_ENUM(0x8C87,GL_PRIMITIVES_GENERATED_EXT)
+GL_ENUM(0x9312,GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT)
+GL_ENUM(0x9317,GL_MAX_FRAMEBUFFER_LAYERS_EXT)
+GL_ENUM(0x8DA8,GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT)
+GL_ENUM(0x8DA7,GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT)
+GL_ENUM(0x9309,GL_REFERENCED_BY_GEOMETRY_SHADER_EXT)
+GL_ENUM(0x90F0,GL_COLOR_ATTACHMENT_EXT)
+GL_ENUM(0x90F1,GL_MULTIVIEW_EXT)
+GL_ENUM(0x0C01,GL_DRAW_BUFFER_EXT)
+GL_ENUM(0x90F2,GL_MAX_MULTIVIEW_BUFFERS_EXT)
+GL_ENUM(0x92BE,GL_PRIMITIVE_BOUNDING_BOX_EXT)
+GL_ENUM(0x8A54,GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT)
+GL_ENUM(0x8A55,GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT)
+GL_ENUM(0x8A56,GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT)
+GL_ENUM(0x8A57,GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT)
+GL_ENUM(0x93F0,GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG)
+GL_ENUM(0x93F1,GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG)
+GL_ENUM(0x8DB9,GL_FRAMEBUFFER_SRGB_EXT)
+GL_ENUM(0x8A52,GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT)
+GL_ENUM(0x8F63,GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT)
+GL_ENUM(0x8F67,GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE_EXT)
+GL_ENUM(0x8F64,GL_SHADER_PIXEL_LOCAL_STORAGE_EXT)
+GL_ENUM(0x000E,GL_PATCHES_EXT)
+GL_ENUM(0x8E72,GL_PATCH_VERTICES_EXT)
+GL_ENUM(0x8E75,GL_TESS_CONTROL_OUTPUT_VERTICES_EXT)
+GL_ENUM(0x8E76,GL_TESS_GEN_MODE_EXT)
+GL_ENUM(0x8E77,GL_TESS_GEN_SPACING_EXT)
+GL_ENUM(0x8E78,GL_TESS_GEN_VERTEX_ORDER_EXT)
+GL_ENUM(0x8E79,GL_TESS_GEN_POINT_MODE_EXT)
+GL_ENUM(0x8E7A,GL_ISOLINES_EXT)
+GL_ENUM(0x0007,GL_QUADS_EXT)
+GL_ENUM(0x8E7B,GL_FRACTIONAL_ODD_EXT)
+GL_ENUM(0x8E7C,GL_FRACTIONAL_EVEN_EXT)
+GL_ENUM(0x8E7D,GL_MAX_PATCH_VERTICES_EXT)
+GL_ENUM(0x8E7E,GL_MAX_TESS_GEN_LEVEL_EXT)
+GL_ENUM(0x8E7F,GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT)
+GL_ENUM(0x8E80,GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT)
+GL_ENUM(0x8E81,GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT)
+GL_ENUM(0x8E82,GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT)
+GL_ENUM(0x8E83,GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT)
+GL_ENUM(0x8E84,GL_MAX_TESS_PATCH_COMPONENTS_EXT)
+GL_ENUM(0x8E85,GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT)
+GL_ENUM(0x8E86,GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT)
+GL_ENUM(0x8E89,GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT)
+GL_ENUM(0x8E8A,GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT)
+GL_ENUM(0x886C,GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT)
+GL_ENUM(0x886D,GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT)
+GL_ENUM(0x8E1E,GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT)
+GL_ENUM(0x8E1F,GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT)
+GL_ENUM(0x92CD,GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT)
+GL_ENUM(0x92CE,GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT)
+GL_ENUM(0x92D3,GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT)
+GL_ENUM(0x92D4,GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT)
+GL_ENUM(0x90CB,GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT)
+GL_ENUM(0x90CC,GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT)
+GL_ENUM(0x90D8,GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT)
+GL_ENUM(0x90D9,GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT)
+GL_ENUM(0x8221,GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED)
+GL_ENUM(0x92E7,GL_IS_PER_PATCH_EXT)
+GL_ENUM(0x9307,GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT)
+GL_ENUM(0x9308,GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT)
+GL_ENUM(0x8E88,GL_TESS_CONTROL_SHADER_EXT)
+GL_ENUM(0x8E87,GL_TESS_EVALUATION_SHADER_EXT)
+GL_ENUM(0x1004,GL_TEXTURE_BORDER_COLOR_EXT)
+GL_ENUM(0x812D,GL_CLAMP_TO_BORDER_EXT)
+GL_ENUM(0x8C2A,GL_TEXTURE_BUFFER_EXT)
+GL_ENUM(0x8C2B,GL_MAX_TEXTURE_BUFFER_SIZE_EXT)
+GL_ENUM(0x8C2C,GL_TEXTURE_BINDING_BUFFER_EXT)
+GL_ENUM(0x8C2D,GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT)
+GL_ENUM(0x919F,GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT)
+GL_ENUM(0x8DC2,GL_SAMPLER_BUFFER_EXT)
+GL_ENUM(0x8DD0,GL_INT_SAMPLER_BUFFER_EXT)
+GL_ENUM(0x8DD8,GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT)
+GL_ENUM(0x9051,GL_IMAGE_BUFFER_EXT)
+GL_ENUM(0x905C,GL_INT_IMAGE_BUFFER_EXT)
+GL_ENUM(0x9067,GL_UNSIGNED_INT_IMAGE_BUFFER_EXT)
+GL_ENUM(0x919D,GL_TEXTURE_BUFFER_OFFSET_EXT)
+GL_ENUM(0x919E,GL_TEXTURE_BUFFER_SIZE_EXT)
+GL_ENUM(0x9009,GL_TEXTURE_CUBE_MAP_ARRAY_EXT)
+GL_ENUM(0x900A,GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT)
+GL_ENUM(0x900C,GL_SAMPLER_CUBE_MAP_ARRAY_EXT)
+GL_ENUM(0x900D,GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT)
+GL_ENUM(0x900E,GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT)
+GL_ENUM(0x900F,GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT)
+GL_ENUM(0x9054,GL_IMAGE_CUBE_MAP_ARRAY_EXT)
+GL_ENUM(0x905F,GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT)
+GL_ENUM(0x906A,GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT)
+GL_ENUM(0x8A48,GL_TEXTURE_SRGB_DECODE_EXT)
+GL_ENUM(0x8A49,GL_DECODE_EXT)
+GL_ENUM(0x8A4A,GL_SKIP_DECODE_EXT)
+GL_ENUM(0x82DB,GL_TEXTURE_VIEW_MIN_LEVEL_EXT)
+GL_ENUM(0x82DC,GL_TEXTURE_VIEW_NUM_LEVELS_EXT)
+GL_ENUM(0x82DD,GL_TEXTURE_VIEW_MIN_LAYER_EXT)
+GL_ENUM(0x82DE,GL_TEXTURE_VIEW_NUM_LAYERS_EXT)
+GL_ENUM(0x9260,GL_GCCSO_SHADER_BINARY_FJ)
+GL_ENUM(0x9130,GL_SGX_PROGRAM_BINARY_IMG)
+GL_ENUM(0x8C0A,GL_SGX_BINARY_IMG)
+GL_ENUM(0x9137,GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG)
+GL_ENUM(0x9138,GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG)
+GL_ENUM(0x00000000,GL_PERFQUERY_SINGLE_CONTEXT_INTEL)
+GL_ENUM(0x00000001,GL_PERFQUERY_GLOBAL_CONTEXT_INTEL)
+GL_ENUM(0x83FB,GL_PERFQUERY_WAIT_INTEL)
+GL_ENUM(0x83FA,GL_PERFQUERY_FLUSH_INTEL)
+GL_ENUM(0x83F9,GL_PERFQUERY_DONOT_FLUSH_INTEL)
+GL_ENUM(0x94F0,GL_PERFQUERY_COUNTER_EVENT_INTEL)
+GL_ENUM(0x94F1,GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL)
+GL_ENUM(0x94F2,GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL)
+GL_ENUM(0x94F3,GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL)
+GL_ENUM(0x94F4,GL_PERFQUERY_COUNTER_RAW_INTEL)
+GL_ENUM(0x94F5,GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL)
+GL_ENUM(0x94F8,GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL)
+GL_ENUM(0x94F9,GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL)
+GL_ENUM(0x94FA,GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL)
+GL_ENUM(0x94FB,GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL)
+GL_ENUM(0x94FC,GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL)
+GL_ENUM(0x94FD,GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL)
+GL_ENUM(0x94FE,GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL)
+GL_ENUM(0x94FF,GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL)
+GL_ENUM(0x9500,GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL)
+GL_ENUM(0x9281,GL_BLEND_OVERLAP_NV)
+GL_ENUM(0x9280,GL_BLEND_PREMULTIPLIED_SRC_NV)
+GL_ENUM(0x9284,GL_CONJOINT_NV)
+GL_ENUM(0x92A1,GL_CONTRAST_NV)
+GL_ENUM(0x9283,GL_DISJOINT_NV)
+GL_ENUM(0x928F,GL_DST_ATOP_NV)
+GL_ENUM(0x928B,GL_DST_IN_NV)
+GL_ENUM(0x9287,GL_DST_NV)
+GL_ENUM(0x928D,GL_DST_OUT_NV)
+GL_ENUM(0x9289,GL_DST_OVER_NV)
+GL_ENUM(0x92A9,GL_HARDMIX_NV)
+GL_ENUM(0x92B4,GL_INVERT_OVG_NV)
+GL_ENUM(0x92A3,GL_INVERT_RGB_NV)
+GL_ENUM(0x92A5,GL_LINEARBURN_NV)
+GL_ENUM(0x92A4,GL_LINEARDODGE_NV)
+GL_ENUM(0x92A7,GL_LINEARLIGHT_NV)
+GL_ENUM(0x92B3,GL_MINUS_CLAMPED_NV)
+GL_ENUM(0x929F,GL_MINUS_NV)
+GL_ENUM(0x92A8,GL_PINLIGHT_NV)
+GL_ENUM(0x92B2,GL_PLUS_CLAMPED_ALPHA_NV)
+GL_ENUM(0x92B1,GL_PLUS_CLAMPED_NV)
+GL_ENUM(0x9292,GL_PLUS_DARKER_NV)
+GL_ENUM(0x9291,GL_PLUS_NV)
+GL_ENUM(0x928E,GL_SRC_ATOP_NV)
+GL_ENUM(0x928A,GL_SRC_IN_NV)
+GL_ENUM(0x9286,GL_SRC_NV)
+GL_ENUM(0x928C,GL_SRC_OUT_NV)
+GL_ENUM(0x9288,GL_SRC_OVER_NV)
+GL_ENUM(0x9282,GL_UNCORRELATED_NV)
+GL_ENUM(0x92A6,GL_VIVIDLIGHT_NV)
+GL_ENUM(0x8ED0,GL_COVERAGE_COMPONENT_NV)
+GL_ENUM(0x8ED1,GL_COVERAGE_COMPONENT4_NV)
+GL_ENUM(0x8ED2,GL_COVERAGE_ATTACHMENT_NV)
+GL_ENUM(0x8ED3,GL_COVERAGE_BUFFERS_NV)
+GL_ENUM(0x8ED4,GL_COVERAGE_SAMPLES_NV)
+GL_ENUM(0x8ED5,GL_COVERAGE_ALL_FRAGMENTS_NV)
+GL_ENUM(0x8ED6,GL_COVERAGE_EDGE_FRAGMENTS_NV)
+GL_ENUM(0x8ED7,GL_COVERAGE_AUTOMATIC_NV)
+GL_ENUM(0x8E2C,GL_DEPTH_COMPONENT16_NONLINEAR_NV)
+GL_ENUM(0x8C46,GL_SLUMINANCE_NV)
+GL_ENUM(0x8C44,GL_SLUMINANCE_ALPHA_NV)
+GL_ENUM(0x8C47,GL_SLUMINANCE8_NV)
+GL_ENUM(0x8C45,GL_SLUMINANCE8_ALPHA8_NV)
+GL_ENUM(0x8C4C,GL_COMPRESSED_SRGB_S3TC_DXT1_NV)
+GL_ENUM(0x8C4D,GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV)
+GL_ENUM(0x8C4E,GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV)
+GL_ENUM(0x8C4F,GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV)
+GL_ENUM(0x88EE,GL_ETC1_SRGB8_NV)
+GL_ENUM(0x8FB0,GL_BINNING_CONTROL_HINT_QCOM)
+GL_ENUM(0x8FB1,GL_CPU_OPTIMIZED_QCOM)
+GL_ENUM(0x8FB2,GL_GPU_OPTIMIZED_QCOM)
+GL_ENUM(0x8FB3,GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM)
+GL_ENUM(0x8FC4,GL_SHADER_BINARY_VIV)
diff --git a/opengl/libs/hooks.h b/opengl/libs/hooks.h
index 4b43198..5010776 100644
--- a/opengl/libs/hooks.h
+++ b/opengl/libs/hooks.h
@@ -30,7 +30,7 @@
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 #include <GLES3/gl3.h>
-#include <GLES3/gl3ext.h>
+#include <GLES3/gl31.h>
 
 // set to 1 for debugging
 #define USE_SLOW_BINDING    0
@@ -55,8 +55,8 @@
 
 #undef GL_ENTRY
 #undef EGL_ENTRY
-#define GL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__);
-#define EGL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__);
+#define GL_ENTRY(_r, _api, ...) _r (*(_api))(__VA_ARGS__);
+#define EGL_ENTRY(_r, _api, ...) _r (*(_api))(__VA_ARGS__);
 
 struct egl_t {
     #include "EGL/egl_entries.in"
diff --git a/opengl/libs/tools/genfiles b/opengl/libs/tools/genfiles
index f92c9ab..a4a1958 100755
--- a/opengl/libs/tools/genfiles
+++ b/opengl/libs/tools/genfiles
@@ -20,17 +20,13 @@
 
 ./glapigen ../../include/GLES/gl.h      > ../GLES_CM/gl_api.in
 ./glapigen ../../include/GLES/glext.h   > ../GLES_CM/glext_api.in
-./glapigen ../../include/GLES2/gl2.h    > ../GLES2/gl2_api.in
+./glapigen ../../include/GLES3/gl3.h    > ../GLES2/gl2_api.in
 ./glapigen ../../include/GLES2/gl2ext.h > ../GLES2/gl2ext_api.in
-./glapigen ../../include/GLES3/gl3.h    > ../GLES2/gl3_api.in
-./glapigen ../../include/GLES3/gl3ext.h > ../GLES2/gl3ext_api.in
 
 ./glentrygen ../../include/GLES/gl.h      > /tmp/gl_entries.in
 ./glentrygen ../../include/GLES/glext.h   > /tmp/glext_entries.in
-./glentrygen ../../include/GLES2/gl2.h    > /tmp/gl2_entries.in
+./glentrygen ../../include/GLES3/gl3.h    > /tmp/gl2_entries.in
 ./glentrygen ../../include/GLES2/gl2ext.h > /tmp/gl2ext_entries.in
-./glentrygen ../../include/GLES3/gl3.h    > /tmp/gl3_entries.in
-./glentrygen ../../include/GLES3/gl3ext.h > /tmp/gl3ext_entries.in
 
 # The awk command removes lines with the same function name as an earlier
 # line, even if the rest of the line differs. Although signatures of
@@ -40,8 +36,6 @@
     /tmp/glext_entries.in \
     /tmp/gl2_entries.in \
     /tmp/gl2ext_entries.in \
-    /tmp/gl3_entries.in \
-    /tmp/gl3ext_entries.in \
         | sort -t, -k2 \
         | awk -F, '!_[$2]++' \
             > ../entries.in
@@ -50,10 +44,8 @@
 
 cat ../../include/GLES/gl.h \
     ../../include/GLES/glext.h \
-    ../../include/GLES2/gl2.h \
     ../../include/GLES2/gl2ext.h \
     ../../include/GLES3/gl3.h \
-    ../../include/GLES3/gl3ext.h \
         | ./glenumsgen \
         | sort \
         > ../enums.in
diff --git a/opengl/libs/trace.in b/opengl/libs/trace.in
index 188d81b..4375a94 100644
--- a/opengl/libs/trace.in
+++ b/opengl/libs/trace.in
@@ -1,20 +1,24 @@
+TRACE_GL_VOID(glActiveShaderProgram, (GLuint pipeline, GLuint program), (pipeline, program), 2, "GLuint", pipeline, "GLuint", program)
 TRACE_GL_VOID(glActiveShaderProgramEXT, (GLuint pipeline, GLuint program), (pipeline, program), 2, "GLuint", pipeline, "GLuint", program)
 TRACE_GL_VOID(glActiveTexture, (GLenum texture), (texture), 1, "GLenum", texture)
-TRACE_GL_VOID(glAlphaFunc, (GLenum func, GLclampf ref), (func, ref), 2, "GLenum", func, "GLclampf", ref)
+TRACE_GL_VOID(glAlphaFunc, (GLenum func, GLfloat ref), (func, ref), 2, "GLenum", func, "GLfloat", ref)
 TRACE_GL_VOID(glAlphaFuncQCOM, (GLenum func, GLclampf ref), (func, ref), 2, "GLenum", func, "GLclampf", ref)
-TRACE_GL_VOID(glAlphaFuncx, (GLenum func, GLclampx ref), (func, ref), 2, "GLenum", func, "GLclampx", ref)
-TRACE_GL_VOID(glAlphaFuncxOES, (GLenum func, GLclampx ref), (func, ref), 2, "GLenum", func, "GLclampx", ref)
+TRACE_GL_VOID(glAlphaFuncx, (GLenum func, GLfixed ref), (func, ref), 2, "GLenum", func, "GLfixed", ref)
+TRACE_GL_VOID(glAlphaFuncxOES, (GLenum func, GLfixed ref), (func, ref), 2, "GLenum", func, "GLfixed", ref)
 TRACE_GL_VOID(glAttachShader, (GLuint program, GLuint shader), (program, shader), 2, "GLuint", program, "GLuint", shader)
 TRACE_GL_VOID(glBeginPerfMonitorAMD, (GLuint monitor), (monitor), 1, "GLuint", monitor)
+TRACE_GL_VOID(glBeginPerfQueryINTEL, (GLuint queryHandle), (queryHandle), 1, "GLuint", queryHandle)
 TRACE_GL_VOID(glBeginQuery, (GLenum target, GLuint id), (target, id), 2, "GLenum", target, "GLuint", id)
 TRACE_GL_VOID(glBeginQueryEXT, (GLenum target, GLuint id), (target, id), 2, "GLenum", target, "GLuint", id)
 TRACE_GL_VOID(glBeginTransformFeedback, (GLenum primitiveMode), (primitiveMode), 1, "GLenum", primitiveMode)
-TRACE_GL_VOID(glBindAttribLocation, (GLuint program, GLuint index, const GLchar* name), (program, index, name), 3, "GLuint", program, "GLuint", index, "const GLchar*", name)
+TRACE_GL_VOID(glBindAttribLocation, (GLuint program, GLuint index, const GLchar * name), (program, index, name), 3, "GLuint", program, "GLuint", index, "const GLchar *", name)
 TRACE_GL_VOID(glBindBuffer, (GLenum target, GLuint buffer), (target, buffer), 2, "GLenum", target, "GLuint", buffer)
 TRACE_GL_VOID(glBindBufferBase, (GLenum target, GLuint index, GLuint buffer), (target, index, buffer), 3, "GLenum", target, "GLuint", index, "GLuint", buffer)
 TRACE_GL_VOID(glBindBufferRange, (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size), (target, index, buffer, offset, size), 5, "GLenum", target, "GLuint", index, "GLuint", buffer, "GLintptr", offset, "GLsizeiptr", size)
 TRACE_GL_VOID(glBindFramebuffer, (GLenum target, GLuint framebuffer), (target, framebuffer), 2, "GLenum", target, "GLuint", framebuffer)
 TRACE_GL_VOID(glBindFramebufferOES, (GLenum target, GLuint framebuffer), (target, framebuffer), 2, "GLenum", target, "GLuint", framebuffer)
+TRACE_GL_VOID(glBindImageTexture, (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), (unit, texture, level, layered, layer, access, format), 7, "GLuint", unit, "GLuint", texture, "GLint", level, "GLboolean", layered, "GLint", layer, "GLenum", access, "GLenum", format)
+TRACE_GL_VOID(glBindProgramPipeline, (GLuint pipeline), (pipeline), 1, "GLuint", pipeline)
 TRACE_GL_VOID(glBindProgramPipelineEXT, (GLuint pipeline), (pipeline), 1, "GLuint", pipeline)
 TRACE_GL_VOID(glBindRenderbuffer, (GLenum target, GLuint renderbuffer), (target, renderbuffer), 2, "GLenum", target, "GLuint", renderbuffer)
 TRACE_GL_VOID(glBindRenderbufferOES, (GLenum target, GLuint renderbuffer), (target, renderbuffer), 2, "GLenum", target, "GLuint", renderbuffer)
@@ -23,145 +27,185 @@
 TRACE_GL_VOID(glBindTransformFeedback, (GLenum target, GLuint id), (target, id), 2, "GLenum", target, "GLuint", id)
 TRACE_GL_VOID(glBindVertexArray, (GLuint array), (array), 1, "GLuint", array)
 TRACE_GL_VOID(glBindVertexArrayOES, (GLuint array), (array), 1, "GLuint", array)
-TRACE_GL_VOID(glBlendColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha), (red, green, blue, alpha), 4, "GLclampf", red, "GLclampf", green, "GLclampf", blue, "GLclampf", alpha)
-TRACE_GL_VOID(glBlendEquation, ( GLenum mode ), (mode), 1, "GLenum", mode)
+TRACE_GL_VOID(glBindVertexBuffer, (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride), (bindingindex, buffer, offset, stride), 4, "GLuint", bindingindex, "GLuint", buffer, "GLintptr", offset, "GLsizei", stride)
+TRACE_GL_VOID(glBlendBarrierKHR, (void), (), 0)
+TRACE_GL_VOID(glBlendBarrierNV, (void), (), 0)
+TRACE_GL_VOID(glBlendColor, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha), (red, green, blue, alpha), 4, "GLfloat", red, "GLfloat", green, "GLfloat", blue, "GLfloat", alpha)
+TRACE_GL_VOID(glBlendEquation, (GLenum mode), (mode), 1, "GLenum", mode)
 TRACE_GL_VOID(glBlendEquationOES, (GLenum mode), (mode), 1, "GLenum", mode)
 TRACE_GL_VOID(glBlendEquationSeparate, (GLenum modeRGB, GLenum modeAlpha), (modeRGB, modeAlpha), 2, "GLenum", modeRGB, "GLenum", modeAlpha)
 TRACE_GL_VOID(glBlendEquationSeparateOES, (GLenum modeRGB, GLenum modeAlpha), (modeRGB, modeAlpha), 2, "GLenum", modeRGB, "GLenum", modeAlpha)
+TRACE_GL_VOID(glBlendEquationSeparateiEXT, (GLuint buf, GLenum modeRGB, GLenum modeAlpha), (buf, modeRGB, modeAlpha), 3, "GLuint", buf, "GLenum", modeRGB, "GLenum", modeAlpha)
+TRACE_GL_VOID(glBlendEquationiEXT, (GLuint buf, GLenum mode), (buf, mode), 2, "GLuint", buf, "GLenum", mode)
 TRACE_GL_VOID(glBlendFunc, (GLenum sfactor, GLenum dfactor), (sfactor, dfactor), 2, "GLenum", sfactor, "GLenum", dfactor)
-TRACE_GL_VOID(glBlendFuncSeparate, (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha), (srcRGB, dstRGB, srcAlpha, dstAlpha), 4, "GLenum", srcRGB, "GLenum", dstRGB, "GLenum", srcAlpha, "GLenum", dstAlpha)
+TRACE_GL_VOID(glBlendFuncSeparate, (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha), (sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha), 4, "GLenum", sfactorRGB, "GLenum", dfactorRGB, "GLenum", sfactorAlpha, "GLenum", dfactorAlpha)
 TRACE_GL_VOID(glBlendFuncSeparateOES, (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha), (srcRGB, dstRGB, srcAlpha, dstAlpha), 4, "GLenum", srcRGB, "GLenum", dstRGB, "GLenum", srcAlpha, "GLenum", dstAlpha)
+TRACE_GL_VOID(glBlendFuncSeparateiEXT, (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha), (buf, srcRGB, dstRGB, srcAlpha, dstAlpha), 5, "GLuint", buf, "GLenum", srcRGB, "GLenum", dstRGB, "GLenum", srcAlpha, "GLenum", dstAlpha)
+TRACE_GL_VOID(glBlendFunciEXT, (GLuint buf, GLenum src, GLenum dst), (buf, src, dst), 3, "GLuint", buf, "GLenum", src, "GLenum", dst)
+TRACE_GL_VOID(glBlendParameteriNV, (GLenum pname, GLint value), (pname, value), 2, "GLenum", pname, "GLint", value)
 TRACE_GL_VOID(glBlitFramebuffer, (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter), (srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter), 10, "GLint", srcX0, "GLint", srcY0, "GLint", srcX1, "GLint", srcY1, "GLint", dstX0, "GLint", dstY0, "GLint", dstX1, "GLint", dstY1, "GLbitfield", mask, "GLenum", filter)
 TRACE_GL_VOID(glBlitFramebufferANGLE, (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter), (srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter), 10, "GLint", srcX0, "GLint", srcY0, "GLint", srcX1, "GLint", srcY1, "GLint", dstX0, "GLint", dstY0, "GLint", dstX1, "GLint", dstY1, "GLbitfield", mask, "GLenum", filter)
-TRACE_GL_VOID(glBufferData, (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage), (target, size, data, usage), 4, "GLenum", target, "GLsizeiptr", size, "const GLvoid *", data, "GLenum", usage)
-TRACE_GL_VOID(glBufferSubData, (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data), (target, offset, size, data), 4, "GLenum", target, "GLintptr", offset, "GLsizeiptr", size, "const GLvoid *", data)
+TRACE_GL_VOID(glBlitFramebufferNV, (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter), (srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter), 10, "GLint", srcX0, "GLint", srcY0, "GLint", srcX1, "GLint", srcY1, "GLint", dstX0, "GLint", dstY0, "GLint", dstX1, "GLint", dstY1, "GLbitfield", mask, "GLenum", filter)
+TRACE_GL_VOID(glBufferData, (GLenum target, GLsizeiptr size, const void * data, GLenum usage), (target, size, data, usage), 4, "GLenum", target, "GLsizeiptr", size, "const void *", data, "GLenum", usage)
+TRACE_GL_VOID(glBufferSubData, (GLenum target, GLintptr offset, GLsizeiptr size, const void * data), (target, offset, size, data), 4, "GLenum", target, "GLintptr", offset, "GLsizeiptr", size, "const void *", data)
 TRACE_GL(GLenum, glCheckFramebufferStatus, (GLenum target), (target), 1, "GLenum", target)
 TRACE_GL(GLenum, glCheckFramebufferStatusOES, (GLenum target), (target), 1, "GLenum", target)
 TRACE_GL_VOID(glClear, (GLbitfield mask), (mask), 1, "GLbitfield", mask)
 TRACE_GL_VOID(glClearBufferfi, (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil), (buffer, drawbuffer, depth, stencil), 4, "GLenum", buffer, "GLint", drawbuffer, "GLfloat", depth, "GLint", stencil)
-TRACE_GL_VOID(glClearBufferfv, (GLenum buffer, GLint drawbuffer, const GLfloat* value), (buffer, drawbuffer, value), 3, "GLenum", buffer, "GLint", drawbuffer, "const GLfloat*", value)
-TRACE_GL_VOID(glClearBufferiv, (GLenum buffer, GLint drawbuffer, const GLint* value), (buffer, drawbuffer, value), 3, "GLenum", buffer, "GLint", drawbuffer, "const GLint*", value)
-TRACE_GL_VOID(glClearBufferuiv, (GLenum buffer, GLint drawbuffer, const GLuint* value), (buffer, drawbuffer, value), 3, "GLenum", buffer, "GLint", drawbuffer, "const GLuint*", value)
-TRACE_GL_VOID(glClearColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha), (red, green, blue, alpha), 4, "GLclampf", red, "GLclampf", green, "GLclampf", blue, "GLclampf", alpha)
-TRACE_GL_VOID(glClearColorx, (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha), (red, green, blue, alpha), 4, "GLclampx", red, "GLclampx", green, "GLclampx", blue, "GLclampx", alpha)
-TRACE_GL_VOID(glClearColorxOES, (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha), (red, green, blue, alpha), 4, "GLclampx", red, "GLclampx", green, "GLclampx", blue, "GLclampx", alpha)
-TRACE_GL_VOID(glClearDepthf, (GLclampf depth), (depth), 1, "GLclampf", depth)
+TRACE_GL_VOID(glClearBufferfv, (GLenum buffer, GLint drawbuffer, const GLfloat * value), (buffer, drawbuffer, value), 3, "GLenum", buffer, "GLint", drawbuffer, "const GLfloat *", value)
+TRACE_GL_VOID(glClearBufferiv, (GLenum buffer, GLint drawbuffer, const GLint * value), (buffer, drawbuffer, value), 3, "GLenum", buffer, "GLint", drawbuffer, "const GLint *", value)
+TRACE_GL_VOID(glClearBufferuiv, (GLenum buffer, GLint drawbuffer, const GLuint * value), (buffer, drawbuffer, value), 3, "GLenum", buffer, "GLint", drawbuffer, "const GLuint *", value)
+TRACE_GL_VOID(glClearColor, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha), (red, green, blue, alpha), 4, "GLfloat", red, "GLfloat", green, "GLfloat", blue, "GLfloat", alpha)
+TRACE_GL_VOID(glClearColorx, (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha), (red, green, blue, alpha), 4, "GLfixed", red, "GLfixed", green, "GLfixed", blue, "GLfixed", alpha)
+TRACE_GL_VOID(glClearColorxOES, (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha), (red, green, blue, alpha), 4, "GLfixed", red, "GLfixed", green, "GLfixed", blue, "GLfixed", alpha)
+TRACE_GL_VOID(glClearDepthf, (GLfloat d), (d), 1, "GLfloat", d)
 TRACE_GL_VOID(glClearDepthfOES, (GLclampf depth), (depth), 1, "GLclampf", depth)
-TRACE_GL_VOID(glClearDepthx, (GLclampx depth), (depth), 1, "GLclampx", depth)
-TRACE_GL_VOID(glClearDepthxOES, (GLclampx depth), (depth), 1, "GLclampx", depth)
+TRACE_GL_VOID(glClearDepthx, (GLfixed depth), (depth), 1, "GLfixed", depth)
+TRACE_GL_VOID(glClearDepthxOES, (GLfixed depth), (depth), 1, "GLfixed", depth)
 TRACE_GL_VOID(glClearStencil, (GLint s), (s), 1, "GLint", s)
 TRACE_GL_VOID(glClientActiveTexture, (GLenum texture), (texture), 1, "GLenum", texture)
 TRACE_GL(GLenum, glClientWaitSync, (GLsync sync, GLbitfield flags, GLuint64 timeout), (sync, flags, timeout), 3, "GLsync", sync, "GLbitfield", flags, "GLuint64", timeout)
-TRACE_GL_VOID(glClipPlanef, (GLenum plane, const GLfloat *equation), (plane, equation), 2, "GLenum", plane, "const GLfloat *", equation)
-TRACE_GL_VOID(glClipPlanefIMG, (GLenum p, const GLfloat *eqn), (p, eqn), 2, "GLenum", p, "const GLfloat *", eqn)
-TRACE_GL_VOID(glClipPlanefOES, (GLenum plane, const GLfloat *equation), (plane, equation), 2, "GLenum", plane, "const GLfloat *", equation)
-TRACE_GL_VOID(glClipPlanex, (GLenum plane, const GLfixed *equation), (plane, equation), 2, "GLenum", plane, "const GLfixed *", equation)
-TRACE_GL_VOID(glClipPlanexIMG, (GLenum p, const GLfixed *eqn), (p, eqn), 2, "GLenum", p, "const GLfixed *", eqn)
-TRACE_GL_VOID(glClipPlanexOES, (GLenum plane, const GLfixed *equation), (plane, equation), 2, "GLenum", plane, "const GLfixed *", equation)
+TRACE_GL(GLenum, glClientWaitSyncAPPLE, (GLsync sync, GLbitfield flags, GLuint64 timeout), (sync, flags, timeout), 3, "GLsync", sync, "GLbitfield", flags, "GLuint64", timeout)
+TRACE_GL_VOID(glClipPlanef, (GLenum p, const GLfloat * eqn), (p, eqn), 2, "GLenum", p, "const GLfloat *", eqn)
+TRACE_GL_VOID(glClipPlanefIMG, (GLenum p, const GLfloat * eqn), (p, eqn), 2, "GLenum", p, "const GLfloat *", eqn)
+TRACE_GL_VOID(glClipPlanefOES, (GLenum plane, const GLfloat * equation), (plane, equation), 2, "GLenum", plane, "const GLfloat *", equation)
+TRACE_GL_VOID(glClipPlanex, (GLenum plane, const GLfixed * equation), (plane, equation), 2, "GLenum", plane, "const GLfixed *", equation)
+TRACE_GL_VOID(glClipPlanexIMG, (GLenum p, const GLfixed * eqn), (p, eqn), 2, "GLenum", p, "const GLfixed *", eqn)
+TRACE_GL_VOID(glClipPlanexOES, (GLenum plane, const GLfixed * equation), (plane, equation), 2, "GLenum", plane, "const GLfixed *", equation)
 TRACE_GL_VOID(glColor4f, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha), (red, green, blue, alpha), 4, "GLfloat", red, "GLfloat", green, "GLfloat", blue, "GLfloat", alpha)
 TRACE_GL_VOID(glColor4ub, (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha), (red, green, blue, alpha), 4, "GLubyte", red, "GLubyte", green, "GLubyte", blue, "GLubyte", alpha)
 TRACE_GL_VOID(glColor4x, (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha), (red, green, blue, alpha), 4, "GLfixed", red, "GLfixed", green, "GLfixed", blue, "GLfixed", alpha)
 TRACE_GL_VOID(glColor4xOES, (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha), (red, green, blue, alpha), 4, "GLfixed", red, "GLfixed", green, "GLfixed", blue, "GLfixed", alpha)
 TRACE_GL_VOID(glColorMask, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha), (red, green, blue, alpha), 4, "GLboolean", red, "GLboolean", green, "GLboolean", blue, "GLboolean", alpha)
-TRACE_GL_VOID(glColorPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer), (size, type, stride, pointer), 4, "GLint", size, "GLenum", type, "GLsizei", stride, "const GLvoid *", pointer)
+TRACE_GL_VOID(glColorMaskiEXT, (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a), (index, r, g, b, a), 5, "GLuint", index, "GLboolean", r, "GLboolean", g, "GLboolean", b, "GLboolean", a)
+TRACE_GL_VOID(glColorPointer, (GLint size, GLenum type, GLsizei stride, const void * pointer), (size, type, stride, pointer), 4, "GLint", size, "GLenum", type, "GLsizei", stride, "const void *", pointer)
 TRACE_GL_VOID(glCompileShader, (GLuint shader), (shader), 1, "GLuint", shader)
-TRACE_GL_VOID(glCompressedTexImage2D, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data), (target, level, internalformat, width, height, border, imageSize, data), 8, "GLenum", target, "GLint", level, "GLenum", internalformat, "GLsizei", width, "GLsizei", height, "GLint", border, "GLsizei", imageSize, "const GLvoid *", data)
-TRACE_GL_VOID(glCompressedTexImage3D, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data), (target, level, internalformat, width, height, depth, border, imageSize, data), 9, "GLenum", target, "GLint", level, "GLenum", internalformat, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLint", border, "GLsizei", imageSize, "const GLvoid*", data)
-TRACE_GL_VOID(glCompressedTexImage3DOES, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data), (target, level, internalformat, width, height, depth, border, imageSize, data), 9, "GLenum", target, "GLint", level, "GLenum", internalformat, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLint", border, "GLsizei", imageSize, "const GLvoid*", data)
-TRACE_GL_VOID(glCompressedTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data), (target, level, xoffset, yoffset, width, height, format, imageSize, data), 9, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLsizei", width, "GLsizei", height, "GLenum", format, "GLsizei", imageSize, "const GLvoid *", data)
-TRACE_GL_VOID(glCompressedTexSubImage3D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data), (target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data), 11, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", zoffset, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLenum", format, "GLsizei", imageSize, "const GLvoid*", data)
-TRACE_GL_VOID(glCompressedTexSubImage3DOES, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data), (target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data), 11, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", zoffset, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLenum", format, "GLsizei", imageSize, "const GLvoid*", data)
+TRACE_GL_VOID(glCompressedTexImage2D, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data), (target, level, internalformat, width, height, border, imageSize, data), 8, "GLenum", target, "GLint", level, "GLenum", internalformat, "GLsizei", width, "GLsizei", height, "GLint", border, "GLsizei", imageSize, "const void *", data)
+TRACE_GL_VOID(glCompressedTexImage3D, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data), (target, level, internalformat, width, height, depth, border, imageSize, data), 9, "GLenum", target, "GLint", level, "GLenum", internalformat, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLint", border, "GLsizei", imageSize, "const void *", data)
+TRACE_GL_VOID(glCompressedTexImage3DOES, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data), (target, level, internalformat, width, height, depth, border, imageSize, data), 9, "GLenum", target, "GLint", level, "GLenum", internalformat, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLint", border, "GLsizei", imageSize, "const void *", data)
+TRACE_GL_VOID(glCompressedTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data), (target, level, xoffset, yoffset, width, height, format, imageSize, data), 9, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLsizei", width, "GLsizei", height, "GLenum", format, "GLsizei", imageSize, "const void *", data)
+TRACE_GL_VOID(glCompressedTexSubImage3D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data), (target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data), 11, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", zoffset, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLenum", format, "GLsizei", imageSize, "const void *", data)
+TRACE_GL_VOID(glCompressedTexSubImage3DOES, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data), (target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data), 11, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", zoffset, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLenum", format, "GLsizei", imageSize, "const void *", data)
 TRACE_GL_VOID(glCopyBufferSubData, (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size), (readTarget, writeTarget, readOffset, writeOffset, size), 5, "GLenum", readTarget, "GLenum", writeTarget, "GLintptr", readOffset, "GLintptr", writeOffset, "GLsizeiptr", size)
+TRACE_GL_VOID(glCopyBufferSubDataNV, (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size), (readTarget, writeTarget, readOffset, writeOffset, size), 5, "GLenum", readTarget, "GLenum", writeTarget, "GLintptr", readOffset, "GLintptr", writeOffset, "GLsizeiptr", size)
+TRACE_GL_VOID(glCopyImageSubDataEXT, (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth), (srcName, srcTarget, srcLevel, srcX, srcY, srcZ, dstName, dstTarget, dstLevel, dstX, dstY, dstZ, srcWidth, srcHeight, srcDepth), 15, "GLuint", srcName, "GLenum", srcTarget, "GLint", srcLevel, "GLint", srcX, "GLint", srcY, "GLint", srcZ, "GLuint", dstName, "GLenum", dstTarget, "GLint", dstLevel, "GLint", dstX, "GLint", dstY, "GLint", dstZ, "GLsizei", srcWidth, "GLsizei", srcHeight, "GLsizei", srcDepth)
 TRACE_GL_VOID(glCopyTexImage2D, (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border), (target, level, internalformat, x, y, width, height, border), 8, "GLenum", target, "GLint", level, "GLenum", internalformat, "GLint", x, "GLint", y, "GLsizei", width, "GLsizei", height, "GLint", border)
 TRACE_GL_VOID(glCopyTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height), (target, level, xoffset, yoffset, x, y, width, height), 8, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", x, "GLint", y, "GLsizei", width, "GLsizei", height)
 TRACE_GL_VOID(glCopyTexSubImage3D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height), (target, level, xoffset, yoffset, zoffset, x, y, width, height), 9, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", zoffset, "GLint", x, "GLint", y, "GLsizei", width, "GLsizei", height)
 TRACE_GL_VOID(glCopyTexSubImage3DOES, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height), (target, level, xoffset, yoffset, zoffset, x, y, width, height), 9, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", zoffset, "GLint", x, "GLint", y, "GLsizei", width, "GLsizei", height)
+TRACE_GL_VOID(glCopyTextureLevelsAPPLE, (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount), (destinationTexture, sourceTexture, sourceBaseLevel, sourceLevelCount), 4, "GLuint", destinationTexture, "GLuint", sourceTexture, "GLint", sourceBaseLevel, "GLsizei", sourceLevelCount)
 TRACE_GL_VOID(glCoverageMaskNV, (GLboolean mask), (mask), 1, "GLboolean", mask)
 TRACE_GL_VOID(glCoverageOperationNV, (GLenum operation), (operation), 1, "GLenum", operation)
+TRACE_GL_VOID(glCreatePerfQueryINTEL, (GLuint queryId, GLuint * queryHandle), (queryId, queryHandle), 2, "GLuint", queryId, "GLuint *", queryHandle)
 TRACE_GL(GLuint, glCreateProgram, (void), (), 0)
 TRACE_GL(GLuint, glCreateShader, (GLenum type), (type), 1, "GLenum", type)
-TRACE_GL(GLuint, glCreateShaderProgramvEXT, (GLenum type, GLsizei count, const GLchar **strings), (type, count, strings), 3, "GLenum", type, "GLsizei", count, "const GLchar **", strings)
+TRACE_GL(GLuint, glCreateShaderProgramv, (GLenum type, GLsizei count, const GLchar *const* strings), (type, count, strings), 3, "GLenum", type, "GLsizei", count, "const GLchar *const*", strings)
+TRACE_GL(GLuint, glCreateShaderProgramvEXT, (GLenum type, GLsizei count, const GLchar ** strings), (type, count, strings), 3, "GLenum", type, "GLsizei", count, "const GLchar **", strings)
 TRACE_GL_VOID(glCullFace, (GLenum mode), (mode), 1, "GLenum", mode)
 TRACE_GL_VOID(glCurrentPaletteMatrixOES, (GLuint matrixpaletteindex), (matrixpaletteindex), 1, "GLuint", matrixpaletteindex)
-TRACE_GL_VOID(glDeleteBuffers, (GLsizei n, const GLuint *buffers), (n, buffers), 2, "GLsizei", n, "const GLuint *", buffers)
-TRACE_GL_VOID(glDeleteFencesNV, (GLsizei n, const GLuint *fences), (n, fences), 2, "GLsizei", n, "const GLuint *", fences)
-TRACE_GL_VOID(glDeleteFramebuffers, (GLsizei n, const GLuint* framebuffers), (n, framebuffers), 2, "GLsizei", n, "const GLuint*", framebuffers)
-TRACE_GL_VOID(glDeleteFramebuffersOES, (GLsizei n, const GLuint* framebuffers), (n, framebuffers), 2, "GLsizei", n, "const GLuint*", framebuffers)
-TRACE_GL_VOID(glDeletePerfMonitorsAMD, (GLsizei n, GLuint *monitors), (n, monitors), 2, "GLsizei", n, "GLuint *", monitors)
+TRACE_GL_VOID(glDebugMessageCallbackKHR, (GLDEBUGPROCKHR callback, const void * userParam), (callback, userParam), 2, "GLDEBUGPROCKHR", callback, "const void *", userParam)
+TRACE_GL_VOID(glDebugMessageControlKHR, (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled), (source, type, severity, count, ids, enabled), 6, "GLenum", source, "GLenum", type, "GLenum", severity, "GLsizei", count, "const GLuint *", ids, "GLboolean", enabled)
+TRACE_GL_VOID(glDebugMessageInsertKHR, (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf), (source, type, id, severity, length, buf), 6, "GLenum", source, "GLenum", type, "GLuint", id, "GLenum", severity, "GLsizei", length, "const GLchar *", buf)
+TRACE_GL_VOID(glDeleteBuffers, (GLsizei n, const GLuint * buffers), (n, buffers), 2, "GLsizei", n, "const GLuint *", buffers)
+TRACE_GL_VOID(glDeleteFencesNV, (GLsizei n, const GLuint * fences), (n, fences), 2, "GLsizei", n, "const GLuint *", fences)
+TRACE_GL_VOID(glDeleteFramebuffers, (GLsizei n, const GLuint * framebuffers), (n, framebuffers), 2, "GLsizei", n, "const GLuint *", framebuffers)
+TRACE_GL_VOID(glDeleteFramebuffersOES, (GLsizei n, const GLuint * framebuffers), (n, framebuffers), 2, "GLsizei", n, "const GLuint *", framebuffers)
+TRACE_GL_VOID(glDeletePerfMonitorsAMD, (GLsizei n, GLuint * monitors), (n, monitors), 2, "GLsizei", n, "GLuint *", monitors)
+TRACE_GL_VOID(glDeletePerfQueryINTEL, (GLuint queryHandle), (queryHandle), 1, "GLuint", queryHandle)
 TRACE_GL_VOID(glDeleteProgram, (GLuint program), (program), 1, "GLuint", program)
-TRACE_GL_VOID(glDeleteProgramPipelinesEXT, (GLsizei n, const GLuint *pipelines), (n, pipelines), 2, "GLsizei", n, "const GLuint *", pipelines)
-TRACE_GL_VOID(glDeleteQueries, (GLsizei n, const GLuint* ids), (n, ids), 2, "GLsizei", n, "const GLuint*", ids)
-TRACE_GL_VOID(glDeleteQueriesEXT, (GLsizei n, const GLuint *ids), (n, ids), 2, "GLsizei", n, "const GLuint *", ids)
-TRACE_GL_VOID(glDeleteRenderbuffers, (GLsizei n, const GLuint* renderbuffers), (n, renderbuffers), 2, "GLsizei", n, "const GLuint*", renderbuffers)
-TRACE_GL_VOID(glDeleteRenderbuffersOES, (GLsizei n, const GLuint* renderbuffers), (n, renderbuffers), 2, "GLsizei", n, "const GLuint*", renderbuffers)
-TRACE_GL_VOID(glDeleteSamplers, (GLsizei count, const GLuint* samplers), (count, samplers), 2, "GLsizei", count, "const GLuint*", samplers)
+TRACE_GL_VOID(glDeleteProgramPipelines, (GLsizei n, const GLuint * pipelines), (n, pipelines), 2, "GLsizei", n, "const GLuint *", pipelines)
+TRACE_GL_VOID(glDeleteProgramPipelinesEXT, (GLsizei n, const GLuint * pipelines), (n, pipelines), 2, "GLsizei", n, "const GLuint *", pipelines)
+TRACE_GL_VOID(glDeleteQueries, (GLsizei n, const GLuint * ids), (n, ids), 2, "GLsizei", n, "const GLuint *", ids)
+TRACE_GL_VOID(glDeleteQueriesEXT, (GLsizei n, const GLuint * ids), (n, ids), 2, "GLsizei", n, "const GLuint *", ids)
+TRACE_GL_VOID(glDeleteRenderbuffers, (GLsizei n, const GLuint * renderbuffers), (n, renderbuffers), 2, "GLsizei", n, "const GLuint *", renderbuffers)
+TRACE_GL_VOID(glDeleteRenderbuffersOES, (GLsizei n, const GLuint * renderbuffers), (n, renderbuffers), 2, "GLsizei", n, "const GLuint *", renderbuffers)
+TRACE_GL_VOID(glDeleteSamplers, (GLsizei count, const GLuint * samplers), (count, samplers), 2, "GLsizei", count, "const GLuint *", samplers)
 TRACE_GL_VOID(glDeleteShader, (GLuint shader), (shader), 1, "GLuint", shader)
 TRACE_GL_VOID(glDeleteSync, (GLsync sync), (sync), 1, "GLsync", sync)
-TRACE_GL_VOID(glDeleteTextures, (GLsizei n, const GLuint *textures), (n, textures), 2, "GLsizei", n, "const GLuint *", textures)
-TRACE_GL_VOID(glDeleteTransformFeedbacks, (GLsizei n, const GLuint* ids), (n, ids), 2, "GLsizei", n, "const GLuint*", ids)
-TRACE_GL_VOID(glDeleteVertexArrays, (GLsizei n, const GLuint* arrays), (n, arrays), 2, "GLsizei", n, "const GLuint*", arrays)
-TRACE_GL_VOID(glDeleteVertexArraysOES, (GLsizei n, const GLuint *arrays), (n, arrays), 2, "GLsizei", n, "const GLuint *", arrays)
+TRACE_GL_VOID(glDeleteSyncAPPLE, (GLsync sync), (sync), 1, "GLsync", sync)
+TRACE_GL_VOID(glDeleteTextures, (GLsizei n, const GLuint * textures), (n, textures), 2, "GLsizei", n, "const GLuint *", textures)
+TRACE_GL_VOID(glDeleteTransformFeedbacks, (GLsizei n, const GLuint * ids), (n, ids), 2, "GLsizei", n, "const GLuint *", ids)
+TRACE_GL_VOID(glDeleteVertexArrays, (GLsizei n, const GLuint * arrays), (n, arrays), 2, "GLsizei", n, "const GLuint *", arrays)
+TRACE_GL_VOID(glDeleteVertexArraysOES, (GLsizei n, const GLuint * arrays), (n, arrays), 2, "GLsizei", n, "const GLuint *", arrays)
 TRACE_GL_VOID(glDepthFunc, (GLenum func), (func), 1, "GLenum", func)
 TRACE_GL_VOID(glDepthMask, (GLboolean flag), (flag), 1, "GLboolean", flag)
-TRACE_GL_VOID(glDepthRangef, (GLclampf zNear, GLclampf zFar), (zNear, zFar), 2, "GLclampf", zNear, "GLclampf", zFar)
-TRACE_GL_VOID(glDepthRangefOES, (GLclampf zNear, GLclampf zFar), (zNear, zFar), 2, "GLclampf", zNear, "GLclampf", zFar)
-TRACE_GL_VOID(glDepthRangex, (GLclampx zNear, GLclampx zFar), (zNear, zFar), 2, "GLclampx", zNear, "GLclampx", zFar)
-TRACE_GL_VOID(glDepthRangexOES, (GLclampx zNear, GLclampx zFar), (zNear, zFar), 2, "GLclampx", zNear, "GLclampx", zFar)
+TRACE_GL_VOID(glDepthRangef, (GLfloat n, GLfloat f), (n, f), 2, "GLfloat", n, "GLfloat", f)
+TRACE_GL_VOID(glDepthRangefOES, (GLclampf n, GLclampf f), (n, f), 2, "GLclampf", n, "GLclampf", f)
+TRACE_GL_VOID(glDepthRangex, (GLfixed n, GLfixed f), (n, f), 2, "GLfixed", n, "GLfixed", f)
+TRACE_GL_VOID(glDepthRangexOES, (GLfixed n, GLfixed f), (n, f), 2, "GLfixed", n, "GLfixed", f)
 TRACE_GL_VOID(glDetachShader, (GLuint program, GLuint shader), (program, shader), 2, "GLuint", program, "GLuint", shader)
 TRACE_GL_VOID(glDisable, (GLenum cap), (cap), 1, "GLenum", cap)
 TRACE_GL_VOID(glDisableClientState, (GLenum array), (array), 1, "GLenum", array)
 TRACE_GL_VOID(glDisableDriverControlQCOM, (GLuint driverControl), (driverControl), 1, "GLuint", driverControl)
 TRACE_GL_VOID(glDisableVertexAttribArray, (GLuint index), (index), 1, "GLuint", index)
-TRACE_GL_VOID(glDiscardFramebufferEXT, (GLenum target, GLsizei numAttachments, const GLenum *attachments), (target, numAttachments, attachments), 3, "GLenum", target, "GLsizei", numAttachments, "const GLenum *", attachments)
+TRACE_GL_VOID(glDisableiEXT, (GLenum target, GLuint index), (target, index), 2, "GLenum", target, "GLuint", index)
+TRACE_GL_VOID(glDiscardFramebufferEXT, (GLenum target, GLsizei numAttachments, const GLenum * attachments), (target, numAttachments, attachments), 3, "GLenum", target, "GLsizei", numAttachments, "const GLenum *", attachments)
+TRACE_GL_VOID(glDispatchCompute, (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z), (num_groups_x, num_groups_y, num_groups_z), 3, "GLuint", num_groups_x, "GLuint", num_groups_y, "GLuint", num_groups_z)
+TRACE_GL_VOID(glDispatchComputeIndirect, (GLintptr indirect), (indirect), 1, "GLintptr", indirect)
 TRACE_GL_VOID(glDrawArrays, (GLenum mode, GLint first, GLsizei count), (mode, first, count), 3, "GLenum", mode, "GLint", first, "GLsizei", count)
-TRACE_GL_VOID(glDrawArraysInstanced, (GLenum mode, GLint first, GLsizei count, GLsizei instanceCount), (mode, first, count, instanceCount), 4, "GLenum", mode, "GLint", first, "GLsizei", count, "GLsizei", instanceCount)
-TRACE_GL_VOID(glDrawBuffers, (GLsizei n, const GLenum* bufs), (n, bufs), 2, "GLsizei", n, "const GLenum*", bufs)
-TRACE_GL_VOID(glDrawBuffersNV, (GLsizei n, const GLenum *bufs), (n, bufs), 2, "GLsizei", n, "const GLenum *", bufs)
-TRACE_GL_VOID(glDrawElements, (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices), (mode, count, type, indices), 4, "GLenum", mode, "GLsizei", count, "GLenum", type, "const GLvoid *", indices)
-TRACE_GL_VOID(glDrawElementsInstanced, (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount), (mode, count, type, indices, instanceCount), 5, "GLenum", mode, "GLsizei", count, "GLenum", type, "const GLvoid*", indices, "GLsizei", instanceCount)
-TRACE_GL_VOID(glDrawRangeElements, (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices), (mode, start, end, count, type, indices), 6, "GLenum", mode, "GLuint", start, "GLuint", end, "GLsizei", count, "GLenum", type, "const GLvoid*", indices)
+TRACE_GL_VOID(glDrawArraysIndirect, (GLenum mode, const void * indirect), (mode, indirect), 2, "GLenum", mode, "const void *", indirect)
+TRACE_GL_VOID(glDrawArraysInstanced, (GLenum mode, GLint first, GLsizei count, GLsizei instancecount), (mode, first, count, instancecount), 4, "GLenum", mode, "GLint", first, "GLsizei", count, "GLsizei", instancecount)
+TRACE_GL_VOID(glDrawArraysInstancedANGLE, (GLenum mode, GLint first, GLsizei count, GLsizei primcount), (mode, first, count, primcount), 4, "GLenum", mode, "GLint", first, "GLsizei", count, "GLsizei", primcount)
+TRACE_GL_VOID(glDrawArraysInstancedEXT, (GLenum mode, GLint start, GLsizei count, GLsizei primcount), (mode, start, count, primcount), 4, "GLenum", mode, "GLint", start, "GLsizei", count, "GLsizei", primcount)
+TRACE_GL_VOID(glDrawArraysInstancedNV, (GLenum mode, GLint first, GLsizei count, GLsizei primcount), (mode, first, count, primcount), 4, "GLenum", mode, "GLint", first, "GLsizei", count, "GLsizei", primcount)
+TRACE_GL_VOID(glDrawBuffers, (GLsizei n, const GLenum * bufs), (n, bufs), 2, "GLsizei", n, "const GLenum *", bufs)
+TRACE_GL_VOID(glDrawBuffersEXT, (GLsizei n, const GLenum * bufs), (n, bufs), 2, "GLsizei", n, "const GLenum *", bufs)
+TRACE_GL_VOID(glDrawBuffersIndexedEXT, (GLint n, const GLenum * location, const GLint * indices), (n, location, indices), 3, "GLint", n, "const GLenum *", location, "const GLint *", indices)
+TRACE_GL_VOID(glDrawBuffersNV, (GLsizei n, const GLenum * bufs), (n, bufs), 2, "GLsizei", n, "const GLenum *", bufs)
+TRACE_GL_VOID(glDrawElements, (GLenum mode, GLsizei count, GLenum type, const void * indices), (mode, count, type, indices), 4, "GLenum", mode, "GLsizei", count, "GLenum", type, "const void *", indices)
+TRACE_GL_VOID(glDrawElementsIndirect, (GLenum mode, GLenum type, const void * indirect), (mode, type, indirect), 3, "GLenum", mode, "GLenum", type, "const void *", indirect)
+TRACE_GL_VOID(glDrawElementsInstanced, (GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount), (mode, count, type, indices, instancecount), 5, "GLenum", mode, "GLsizei", count, "GLenum", type, "const void *", indices, "GLsizei", instancecount)
+TRACE_GL_VOID(glDrawElementsInstancedANGLE, (GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount), (mode, count, type, indices, primcount), 5, "GLenum", mode, "GLsizei", count, "GLenum", type, "const void *", indices, "GLsizei", primcount)
+TRACE_GL_VOID(glDrawElementsInstancedEXT, (GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount), (mode, count, type, indices, primcount), 5, "GLenum", mode, "GLsizei", count, "GLenum", type, "const void *", indices, "GLsizei", primcount)
+TRACE_GL_VOID(glDrawElementsInstancedNV, (GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount), (mode, count, type, indices, primcount), 5, "GLenum", mode, "GLsizei", count, "GLenum", type, "const void *", indices, "GLsizei", primcount)
+TRACE_GL_VOID(glDrawRangeElements, (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices), (mode, start, end, count, type, indices), 6, "GLenum", mode, "GLuint", start, "GLuint", end, "GLsizei", count, "GLenum", type, "const void *", indices)
 TRACE_GL_VOID(glDrawTexfOES, (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height), (x, y, z, width, height), 5, "GLfloat", x, "GLfloat", y, "GLfloat", z, "GLfloat", width, "GLfloat", height)
-TRACE_GL_VOID(glDrawTexfvOES, (const GLfloat *coords), (coords), 1, "const GLfloat *", coords)
+TRACE_GL_VOID(glDrawTexfvOES, (const GLfloat * coords), (coords), 1, "const GLfloat *", coords)
 TRACE_GL_VOID(glDrawTexiOES, (GLint x, GLint y, GLint z, GLint width, GLint height), (x, y, z, width, height), 5, "GLint", x, "GLint", y, "GLint", z, "GLint", width, "GLint", height)
-TRACE_GL_VOID(glDrawTexivOES, (const GLint *coords), (coords), 1, "const GLint *", coords)
+TRACE_GL_VOID(glDrawTexivOES, (const GLint * coords), (coords), 1, "const GLint *", coords)
 TRACE_GL_VOID(glDrawTexsOES, (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height), (x, y, z, width, height), 5, "GLshort", x, "GLshort", y, "GLshort", z, "GLshort", width, "GLshort", height)
-TRACE_GL_VOID(glDrawTexsvOES, (const GLshort *coords), (coords), 1, "const GLshort *", coords)
+TRACE_GL_VOID(glDrawTexsvOES, (const GLshort * coords), (coords), 1, "const GLshort *", coords)
 TRACE_GL_VOID(glDrawTexxOES, (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height), (x, y, z, width, height), 5, "GLfixed", x, "GLfixed", y, "GLfixed", z, "GLfixed", width, "GLfixed", height)
-TRACE_GL_VOID(glDrawTexxvOES, (const GLfixed *coords), (coords), 1, "const GLfixed *", coords)
+TRACE_GL_VOID(glDrawTexxvOES, (const GLfixed * coords), (coords), 1, "const GLfixed *", coords)
 TRACE_GL_VOID(glEGLImageTargetRenderbufferStorageOES, (GLenum target, GLeglImageOES image), (target, image), 2, "GLenum", target, "GLeglImageOES", image)
 TRACE_GL_VOID(glEGLImageTargetTexture2DOES, (GLenum target, GLeglImageOES image), (target, image), 2, "GLenum", target, "GLeglImageOES", image)
 TRACE_GL_VOID(glEnable, (GLenum cap), (cap), 1, "GLenum", cap)
 TRACE_GL_VOID(glEnableClientState, (GLenum array), (array), 1, "GLenum", array)
 TRACE_GL_VOID(glEnableDriverControlQCOM, (GLuint driverControl), (driverControl), 1, "GLuint", driverControl)
 TRACE_GL_VOID(glEnableVertexAttribArray, (GLuint index), (index), 1, "GLuint", index)
+TRACE_GL_VOID(glEnableiEXT, (GLenum target, GLuint index), (target, index), 2, "GLenum", target, "GLuint", index)
 TRACE_GL_VOID(glEndPerfMonitorAMD, (GLuint monitor), (monitor), 1, "GLuint", monitor)
+TRACE_GL_VOID(glEndPerfQueryINTEL, (GLuint queryHandle), (queryHandle), 1, "GLuint", queryHandle)
 TRACE_GL_VOID(glEndQuery, (GLenum target), (target), 1, "GLenum", target)
 TRACE_GL_VOID(glEndQueryEXT, (GLenum target), (target), 1, "GLenum", target)
 TRACE_GL_VOID(glEndTilingQCOM, (GLbitfield preserveMask), (preserveMask), 1, "GLbitfield", preserveMask)
 TRACE_GL_VOID(glEndTransformFeedback, (void), (), 0)
-TRACE_GL_VOID(glExtGetBufferPointervQCOM, (GLenum target, GLvoid **params), (target, params), 2, "GLenum", target, "GLvoid **", params)
-TRACE_GL_VOID(glExtGetBuffersQCOM, (GLuint *buffers, GLint maxBuffers, GLint *numBuffers), (buffers, maxBuffers, numBuffers), 3, "GLuint *", buffers, "GLint", maxBuffers, "GLint *", numBuffers)
-TRACE_GL_VOID(glExtGetFramebuffersQCOM, (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers), (framebuffers, maxFramebuffers, numFramebuffers), 3, "GLuint *", framebuffers, "GLint", maxFramebuffers, "GLint *", numFramebuffers)
-TRACE_GL_VOID(glExtGetProgramBinarySourceQCOM, (GLuint program, GLenum shadertype, GLchar *source, GLint *length), (program, shadertype, source, length), 4, "GLuint", program, "GLenum", shadertype, "GLchar *", source, "GLint *", length)
-TRACE_GL_VOID(glExtGetProgramsQCOM, (GLuint *programs, GLint maxPrograms, GLint *numPrograms), (programs, maxPrograms, numPrograms), 3, "GLuint *", programs, "GLint", maxPrograms, "GLint *", numPrograms)
-TRACE_GL_VOID(glExtGetRenderbuffersQCOM, (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers), (renderbuffers, maxRenderbuffers, numRenderbuffers), 3, "GLuint *", renderbuffers, "GLint", maxRenderbuffers, "GLint *", numRenderbuffers)
-TRACE_GL_VOID(glExtGetShadersQCOM, (GLuint *shaders, GLint maxShaders, GLint *numShaders), (shaders, maxShaders, numShaders), 3, "GLuint *", shaders, "GLint", maxShaders, "GLint *", numShaders)
-TRACE_GL_VOID(glExtGetTexLevelParameterivQCOM, (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params), (texture, face, level, pname, params), 5, "GLuint", texture, "GLenum", face, "GLint", level, "GLenum", pname, "GLint *", params)
-TRACE_GL_VOID(glExtGetTexSubImageQCOM, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels), (target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, texels), 11, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", zoffset, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLenum", format, "GLenum", type, "GLvoid *", texels)
-TRACE_GL_VOID(glExtGetTexturesQCOM, (GLuint *textures, GLint maxTextures, GLint *numTextures), (textures, maxTextures, numTextures), 3, "GLuint *", textures, "GLint", maxTextures, "GLint *", numTextures)
+TRACE_GL_VOID(glExtGetBufferPointervQCOM, (GLenum target, void ** params), (target, params), 2, "GLenum", target, "void **", params)
+TRACE_GL_VOID(glExtGetBuffersQCOM, (GLuint * buffers, GLint maxBuffers, GLint * numBuffers), (buffers, maxBuffers, numBuffers), 3, "GLuint *", buffers, "GLint", maxBuffers, "GLint *", numBuffers)
+TRACE_GL_VOID(glExtGetFramebuffersQCOM, (GLuint * framebuffers, GLint maxFramebuffers, GLint * numFramebuffers), (framebuffers, maxFramebuffers, numFramebuffers), 3, "GLuint *", framebuffers, "GLint", maxFramebuffers, "GLint *", numFramebuffers)
+TRACE_GL_VOID(glExtGetProgramBinarySourceQCOM, (GLuint program, GLenum shadertype, GLchar * source, GLint * length), (program, shadertype, source, length), 4, "GLuint", program, "GLenum", shadertype, "GLchar *", source, "GLint *", length)
+TRACE_GL_VOID(glExtGetProgramsQCOM, (GLuint * programs, GLint maxPrograms, GLint * numPrograms), (programs, maxPrograms, numPrograms), 3, "GLuint *", programs, "GLint", maxPrograms, "GLint *", numPrograms)
+TRACE_GL_VOID(glExtGetRenderbuffersQCOM, (GLuint * renderbuffers, GLint maxRenderbuffers, GLint * numRenderbuffers), (renderbuffers, maxRenderbuffers, numRenderbuffers), 3, "GLuint *", renderbuffers, "GLint", maxRenderbuffers, "GLint *", numRenderbuffers)
+TRACE_GL_VOID(glExtGetShadersQCOM, (GLuint * shaders, GLint maxShaders, GLint * numShaders), (shaders, maxShaders, numShaders), 3, "GLuint *", shaders, "GLint", maxShaders, "GLint *", numShaders)
+TRACE_GL_VOID(glExtGetTexLevelParameterivQCOM, (GLuint texture, GLenum face, GLint level, GLenum pname, GLint * params), (texture, face, level, pname, params), 5, "GLuint", texture, "GLenum", face, "GLint", level, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glExtGetTexSubImageQCOM, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void * texels), (target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, texels), 11, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", zoffset, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLenum", format, "GLenum", type, "void *", texels)
+TRACE_GL_VOID(glExtGetTexturesQCOM, (GLuint * textures, GLint maxTextures, GLint * numTextures), (textures, maxTextures, numTextures), 3, "GLuint *", textures, "GLint", maxTextures, "GLint *", numTextures)
 TRACE_GL(GLboolean, glExtIsProgramBinaryQCOM, (GLuint program), (program), 1, "GLuint", program)
 TRACE_GL_VOID(glExtTexObjectStateOverrideiQCOM, (GLenum target, GLenum pname, GLint param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLint", param)
 TRACE_GL(GLsync, glFenceSync, (GLenum condition, GLbitfield flags), (condition, flags), 2, "GLenum", condition, "GLbitfield", flags)
+TRACE_GL(GLsync, glFenceSyncAPPLE, (GLenum condition, GLbitfield flags), (condition, flags), 2, "GLenum", condition, "GLbitfield", flags)
 TRACE_GL_VOID(glFinish, (void), (), 0)
 TRACE_GL_VOID(glFinishFenceNV, (GLuint fence), (fence), 1, "GLuint", fence)
 TRACE_GL_VOID(glFlush, (void), (), 0)
 TRACE_GL_VOID(glFlushMappedBufferRange, (GLenum target, GLintptr offset, GLsizeiptr length), (target, offset, length), 3, "GLenum", target, "GLintptr", offset, "GLsizeiptr", length)
+TRACE_GL_VOID(glFlushMappedBufferRangeEXT, (GLenum target, GLintptr offset, GLsizeiptr length), (target, offset, length), 3, "GLenum", target, "GLintptr", offset, "GLsizeiptr", length)
 TRACE_GL_VOID(glFogf, (GLenum pname, GLfloat param), (pname, param), 2, "GLenum", pname, "GLfloat", param)
-TRACE_GL_VOID(glFogfv, (GLenum pname, const GLfloat *params), (pname, params), 2, "GLenum", pname, "const GLfloat *", params)
+TRACE_GL_VOID(glFogfv, (GLenum pname, const GLfloat * params), (pname, params), 2, "GLenum", pname, "const GLfloat *", params)
 TRACE_GL_VOID(glFogx, (GLenum pname, GLfixed param), (pname, param), 2, "GLenum", pname, "GLfixed", param)
 TRACE_GL_VOID(glFogxOES, (GLenum pname, GLfixed param), (pname, param), 2, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glFogxv, (GLenum pname, const GLfixed *params), (pname, params), 2, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glFogxvOES, (GLenum pname, const GLfixed *params), (pname, params), 2, "GLenum", pname, "const GLfixed *", params)
+TRACE_GL_VOID(glFogxv, (GLenum pname, const GLfixed * param), (pname, param), 2, "GLenum", pname, "const GLfixed *", param)
+TRACE_GL_VOID(glFogxvOES, (GLenum pname, const GLfixed * param), (pname, param), 2, "GLenum", pname, "const GLfixed *", param)
+TRACE_GL_VOID(glFramebufferParameteri, (GLenum target, GLenum pname, GLint param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLint", param)
 TRACE_GL_VOID(glFramebufferRenderbuffer, (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer), (target, attachment, renderbuffertarget, renderbuffer), 4, "GLenum", target, "GLenum", attachment, "GLenum", renderbuffertarget, "GLuint", renderbuffer)
 TRACE_GL_VOID(glFramebufferRenderbufferOES, (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer), (target, attachment, renderbuffertarget, renderbuffer), 4, "GLenum", target, "GLenum", attachment, "GLenum", renderbuffertarget, "GLuint", renderbuffer)
 TRACE_GL_VOID(glFramebufferTexture2D, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level), (target, attachment, textarget, texture, level), 5, "GLenum", target, "GLenum", attachment, "GLenum", textarget, "GLuint", texture, "GLint", level)
@@ -169,131 +213,168 @@
 TRACE_GL_VOID(glFramebufferTexture2DMultisampleIMG, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples), (target, attachment, textarget, texture, level, samples), 6, "GLenum", target, "GLenum", attachment, "GLenum", textarget, "GLuint", texture, "GLint", level, "GLsizei", samples)
 TRACE_GL_VOID(glFramebufferTexture2DOES, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level), (target, attachment, textarget, texture, level), 5, "GLenum", target, "GLenum", attachment, "GLenum", textarget, "GLuint", texture, "GLint", level)
 TRACE_GL_VOID(glFramebufferTexture3DOES, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset), (target, attachment, textarget, texture, level, zoffset), 6, "GLenum", target, "GLenum", attachment, "GLenum", textarget, "GLuint", texture, "GLint", level, "GLint", zoffset)
+TRACE_GL_VOID(glFramebufferTextureEXT, (GLenum target, GLenum attachment, GLuint texture, GLint level), (target, attachment, texture, level), 4, "GLenum", target, "GLenum", attachment, "GLuint", texture, "GLint", level)
 TRACE_GL_VOID(glFramebufferTextureLayer, (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer), (target, attachment, texture, level, layer), 5, "GLenum", target, "GLenum", attachment, "GLuint", texture, "GLint", level, "GLint", layer)
 TRACE_GL_VOID(glFrontFace, (GLenum mode), (mode), 1, "GLenum", mode)
-TRACE_GL_VOID(glFrustumf, (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar), (left, right, bottom, top, zNear, zFar), 6, "GLfloat", left, "GLfloat", right, "GLfloat", bottom, "GLfloat", top, "GLfloat", zNear, "GLfloat", zFar)
-TRACE_GL_VOID(glFrustumfOES, (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar), (left, right, bottom, top, zNear, zFar), 6, "GLfloat", left, "GLfloat", right, "GLfloat", bottom, "GLfloat", top, "GLfloat", zNear, "GLfloat", zFar)
-TRACE_GL_VOID(glFrustumx, (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar), (left, right, bottom, top, zNear, zFar), 6, "GLfixed", left, "GLfixed", right, "GLfixed", bottom, "GLfixed", top, "GLfixed", zNear, "GLfixed", zFar)
-TRACE_GL_VOID(glFrustumxOES, (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar), (left, right, bottom, top, zNear, zFar), 6, "GLfixed", left, "GLfixed", right, "GLfixed", bottom, "GLfixed", top, "GLfixed", zNear, "GLfixed", zFar)
-TRACE_GL_VOID(glGenBuffers, (GLsizei n, GLuint *buffers), (n, buffers), 2, "GLsizei", n, "GLuint *", buffers)
-TRACE_GL_VOID(glGenFencesNV, (GLsizei n, GLuint *fences), (n, fences), 2, "GLsizei", n, "GLuint *", fences)
-TRACE_GL_VOID(glGenFramebuffers, (GLsizei n, GLuint* framebuffers), (n, framebuffers), 2, "GLsizei", n, "GLuint*", framebuffers)
-TRACE_GL_VOID(glGenFramebuffersOES, (GLsizei n, GLuint* framebuffers), (n, framebuffers), 2, "GLsizei", n, "GLuint*", framebuffers)
-TRACE_GL_VOID(glGenPerfMonitorsAMD, (GLsizei n, GLuint *monitors), (n, monitors), 2, "GLsizei", n, "GLuint *", monitors)
-TRACE_GL_VOID(glGenProgramPipelinesEXT, (GLsizei n, GLuint *pipelines), (n, pipelines), 2, "GLsizei", n, "GLuint *", pipelines)
-TRACE_GL_VOID(glGenQueries, (GLsizei n, GLuint* ids), (n, ids), 2, "GLsizei", n, "GLuint*", ids)
-TRACE_GL_VOID(glGenQueriesEXT, (GLsizei n, GLuint *ids), (n, ids), 2, "GLsizei", n, "GLuint *", ids)
-TRACE_GL_VOID(glGenRenderbuffers, (GLsizei n, GLuint* renderbuffers), (n, renderbuffers), 2, "GLsizei", n, "GLuint*", renderbuffers)
-TRACE_GL_VOID(glGenRenderbuffersOES, (GLsizei n, GLuint* renderbuffers), (n, renderbuffers), 2, "GLsizei", n, "GLuint*", renderbuffers)
-TRACE_GL_VOID(glGenSamplers, (GLsizei count, GLuint* samplers), (count, samplers), 2, "GLsizei", count, "GLuint*", samplers)
-TRACE_GL_VOID(glGenTextures, (GLsizei n, GLuint *textures), (n, textures), 2, "GLsizei", n, "GLuint *", textures)
-TRACE_GL_VOID(glGenTransformFeedbacks, (GLsizei n, GLuint* ids), (n, ids), 2, "GLsizei", n, "GLuint*", ids)
-TRACE_GL_VOID(glGenVertexArrays, (GLsizei n, GLuint* arrays), (n, arrays), 2, "GLsizei", n, "GLuint*", arrays)
-TRACE_GL_VOID(glGenVertexArraysOES, (GLsizei n, GLuint *arrays), (n, arrays), 2, "GLsizei", n, "GLuint *", arrays)
+TRACE_GL_VOID(glFrustumf, (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f), (l, r, b, t, n, f), 6, "GLfloat", l, "GLfloat", r, "GLfloat", b, "GLfloat", t, "GLfloat", n, "GLfloat", f)
+TRACE_GL_VOID(glFrustumfOES, (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f), (l, r, b, t, n, f), 6, "GLfloat", l, "GLfloat", r, "GLfloat", b, "GLfloat", t, "GLfloat", n, "GLfloat", f)
+TRACE_GL_VOID(glFrustumx, (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f), (l, r, b, t, n, f), 6, "GLfixed", l, "GLfixed", r, "GLfixed", b, "GLfixed", t, "GLfixed", n, "GLfixed", f)
+TRACE_GL_VOID(glFrustumxOES, (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f), (l, r, b, t, n, f), 6, "GLfixed", l, "GLfixed", r, "GLfixed", b, "GLfixed", t, "GLfixed", n, "GLfixed", f)
+TRACE_GL_VOID(glGenBuffers, (GLsizei n, GLuint * buffers), (n, buffers), 2, "GLsizei", n, "GLuint *", buffers)
+TRACE_GL_VOID(glGenFencesNV, (GLsizei n, GLuint * fences), (n, fences), 2, "GLsizei", n, "GLuint *", fences)
+TRACE_GL_VOID(glGenFramebuffers, (GLsizei n, GLuint * framebuffers), (n, framebuffers), 2, "GLsizei", n, "GLuint *", framebuffers)
+TRACE_GL_VOID(glGenFramebuffersOES, (GLsizei n, GLuint * framebuffers), (n, framebuffers), 2, "GLsizei", n, "GLuint *", framebuffers)
+TRACE_GL_VOID(glGenPerfMonitorsAMD, (GLsizei n, GLuint * monitors), (n, monitors), 2, "GLsizei", n, "GLuint *", monitors)
+TRACE_GL_VOID(glGenProgramPipelines, (GLsizei n, GLuint * pipelines), (n, pipelines), 2, "GLsizei", n, "GLuint *", pipelines)
+TRACE_GL_VOID(glGenProgramPipelinesEXT, (GLsizei n, GLuint * pipelines), (n, pipelines), 2, "GLsizei", n, "GLuint *", pipelines)
+TRACE_GL_VOID(glGenQueries, (GLsizei n, GLuint * ids), (n, ids), 2, "GLsizei", n, "GLuint *", ids)
+TRACE_GL_VOID(glGenQueriesEXT, (GLsizei n, GLuint * ids), (n, ids), 2, "GLsizei", n, "GLuint *", ids)
+TRACE_GL_VOID(glGenRenderbuffers, (GLsizei n, GLuint * renderbuffers), (n, renderbuffers), 2, "GLsizei", n, "GLuint *", renderbuffers)
+TRACE_GL_VOID(glGenRenderbuffersOES, (GLsizei n, GLuint * renderbuffers), (n, renderbuffers), 2, "GLsizei", n, "GLuint *", renderbuffers)
+TRACE_GL_VOID(glGenSamplers, (GLsizei count, GLuint * samplers), (count, samplers), 2, "GLsizei", count, "GLuint *", samplers)
+TRACE_GL_VOID(glGenTextures, (GLsizei n, GLuint * textures), (n, textures), 2, "GLsizei", n, "GLuint *", textures)
+TRACE_GL_VOID(glGenTransformFeedbacks, (GLsizei n, GLuint * ids), (n, ids), 2, "GLsizei", n, "GLuint *", ids)
+TRACE_GL_VOID(glGenVertexArrays, (GLsizei n, GLuint * arrays), (n, arrays), 2, "GLsizei", n, "GLuint *", arrays)
+TRACE_GL_VOID(glGenVertexArraysOES, (GLsizei n, GLuint * arrays), (n, arrays), 2, "GLsizei", n, "GLuint *", arrays)
 TRACE_GL_VOID(glGenerateMipmap, (GLenum target), (target), 1, "GLenum", target)
 TRACE_GL_VOID(glGenerateMipmapOES, (GLenum target), (target), 1, "GLenum", target)
-TRACE_GL_VOID(glGetActiveAttrib, (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name), (program, index, bufsize, length, size, type, name), 7, "GLuint", program, "GLuint", index, "GLsizei", bufsize, "GLsizei*", length, "GLint*", size, "GLenum*", type, "GLchar*", name)
-TRACE_GL_VOID(glGetActiveUniform, (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name), (program, index, bufsize, length, size, type, name), 7, "GLuint", program, "GLuint", index, "GLsizei", bufsize, "GLsizei*", length, "GLint*", size, "GLenum*", type, "GLchar*", name)
-TRACE_GL_VOID(glGetActiveUniformBlockName, (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName), (program, uniformBlockIndex, bufSize, length, uniformBlockName), 5, "GLuint", program, "GLuint", uniformBlockIndex, "GLsizei", bufSize, "GLsizei*", length, "GLchar*", uniformBlockName)
-TRACE_GL_VOID(glGetActiveUniformBlockiv, (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params), (program, uniformBlockIndex, pname, params), 4, "GLuint", program, "GLuint", uniformBlockIndex, "GLenum", pname, "GLint*", params)
-TRACE_GL_VOID(glGetActiveUniformsiv, (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params), (program, uniformCount, uniformIndices, pname, params), 5, "GLuint", program, "GLsizei", uniformCount, "const GLuint*", uniformIndices, "GLenum", pname, "GLint*", params)
-TRACE_GL_VOID(glGetAttachedShaders, (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders), (program, maxcount, count, shaders), 4, "GLuint", program, "GLsizei", maxcount, "GLsizei*", count, "GLuint*", shaders)
-TRACE_GL(GLint, glGetAttribLocation, (GLuint program, const GLchar* name), (program, name), 2, "GLuint", program, "const GLchar*", name)
-TRACE_GL_VOID(glGetBooleanv, (GLenum pname, GLboolean *params), (pname, params), 2, "GLenum", pname, "GLboolean *", params)
-TRACE_GL_VOID(glGetBufferParameteri64v, (GLenum target, GLenum pname, GLint64* params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint64*", params)
-TRACE_GL_VOID(glGetBufferParameteriv, (GLenum target, GLenum pname, GLint *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint *", params)
-TRACE_GL_VOID(glGetBufferPointerv, (GLenum target, GLenum pname, GLvoid** params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLvoid**", params)
-TRACE_GL_VOID(glGetBufferPointervOES, (GLenum target, GLenum pname, GLvoid ** params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLvoid **", params)
-TRACE_GL_VOID(glGetClipPlanef, (GLenum pname, GLfloat eqn[4]), (pname, eqn), 2, "GLenum", pname, "GLfloat", eqn)
-TRACE_GL_VOID(glGetClipPlanefOES, (GLenum pname, GLfloat eqn[4]), (pname, eqn), 2, "GLenum", pname, "GLfloat", eqn)
-TRACE_GL_VOID(glGetClipPlanex, (GLenum pname, GLfixed eqn[4]), (pname, eqn), 2, "GLenum", pname, "GLfixed", eqn)
-TRACE_GL_VOID(glGetClipPlanexOES, (GLenum pname, GLfixed eqn[4]), (pname, eqn), 2, "GLenum", pname, "GLfixed", eqn)
-TRACE_GL_VOID(glGetDriverControlStringQCOM, (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString), (driverControl, bufSize, length, driverControlString), 4, "GLuint", driverControl, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", driverControlString)
-TRACE_GL_VOID(glGetDriverControlsQCOM, (GLint *num, GLsizei size, GLuint *driverControls), (num, size, driverControls), 3, "GLint *", num, "GLsizei", size, "GLuint *", driverControls)
+TRACE_GL_VOID(glGetActiveAttrib, (GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name), (program, index, bufSize, length, size, type, name), 7, "GLuint", program, "GLuint", index, "GLsizei", bufSize, "GLsizei *", length, "GLint *", size, "GLenum *", type, "GLchar *", name)
+TRACE_GL_VOID(glGetActiveUniform, (GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name), (program, index, bufSize, length, size, type, name), 7, "GLuint", program, "GLuint", index, "GLsizei", bufSize, "GLsizei *", length, "GLint *", size, "GLenum *", type, "GLchar *", name)
+TRACE_GL_VOID(glGetActiveUniformBlockName, (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName), (program, uniformBlockIndex, bufSize, length, uniformBlockName), 5, "GLuint", program, "GLuint", uniformBlockIndex, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", uniformBlockName)
+TRACE_GL_VOID(glGetActiveUniformBlockiv, (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params), (program, uniformBlockIndex, pname, params), 4, "GLuint", program, "GLuint", uniformBlockIndex, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetActiveUniformsiv, (GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params), (program, uniformCount, uniformIndices, pname, params), 5, "GLuint", program, "GLsizei", uniformCount, "const GLuint *", uniformIndices, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetAttachedShaders, (GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders), (program, maxCount, count, shaders), 4, "GLuint", program, "GLsizei", maxCount, "GLsizei *", count, "GLuint *", shaders)
+TRACE_GL(GLint, glGetAttribLocation, (GLuint program, const GLchar * name), (program, name), 2, "GLuint", program, "const GLchar *", name)
+TRACE_GL_VOID(glGetBooleani_v, (GLenum target, GLuint index, GLboolean * data), (target, index, data), 3, "GLenum", target, "GLuint", index, "GLboolean *", data)
+TRACE_GL_VOID(glGetBooleanv, (GLenum pname, GLboolean * data), (pname, data), 2, "GLenum", pname, "GLboolean *", data)
+TRACE_GL_VOID(glGetBufferParameteri64v, (GLenum target, GLenum pname, GLint64 * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint64 *", params)
+TRACE_GL_VOID(glGetBufferParameteriv, (GLenum target, GLenum pname, GLint * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetBufferPointerv, (GLenum target, GLenum pname, void ** params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "void **", params)
+TRACE_GL_VOID(glGetBufferPointervOES, (GLenum target, GLenum pname, void ** params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "void **", params)
+TRACE_GL_VOID(glGetClipPlanef, (GLenum plane, GLfloat * equation), (plane, equation), 2, "GLenum", plane, "GLfloat *", equation)
+TRACE_GL_VOID(glGetClipPlanefOES, (GLenum plane, GLfloat * equation), (plane, equation), 2, "GLenum", plane, "GLfloat *", equation)
+TRACE_GL_VOID(glGetClipPlanex, (GLenum plane, GLfixed * equation), (plane, equation), 2, "GLenum", plane, "GLfixed *", equation)
+TRACE_GL_VOID(glGetClipPlanexOES, (GLenum plane, GLfixed * equation), (plane, equation), 2, "GLenum", plane, "GLfixed *", equation)
+TRACE_GL(GLuint, glGetDebugMessageLogKHR, (GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog), (count, bufSize, sources, types, ids, severities, lengths, messageLog), 8, "GLuint", count, "GLsizei", bufSize, "GLenum *", sources, "GLenum *", types, "GLuint *", ids, "GLenum *", severities, "GLsizei *", lengths, "GLchar *", messageLog)
+TRACE_GL_VOID(glGetDriverControlStringQCOM, (GLuint driverControl, GLsizei bufSize, GLsizei * length, GLchar * driverControlString), (driverControl, bufSize, length, driverControlString), 4, "GLuint", driverControl, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", driverControlString)
+TRACE_GL_VOID(glGetDriverControlsQCOM, (GLint * num, GLsizei size, GLuint * driverControls), (num, size, driverControls), 3, "GLint *", num, "GLsizei", size, "GLuint *", driverControls)
 TRACE_GL(GLenum, glGetError, (void), (), 0)
-TRACE_GL_VOID(glGetFenceivNV, (GLuint fence, GLenum pname, GLint *params), (fence, pname, params), 3, "GLuint", fence, "GLenum", pname, "GLint *", params)
-TRACE_GL_VOID(glGetFixedv, (GLenum pname, GLfixed *params), (pname, params), 2, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetFixedvOES, (GLenum pname, GLfixed *params), (pname, params), 2, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetFloatv, (GLenum pname, GLfloat *params), (pname, params), 2, "GLenum", pname, "GLfloat *", params)
-TRACE_GL(GLint, glGetFragDataLocation, (GLuint program, const GLchar *name), (program, name), 2, "GLuint", program, "const GLchar *", name)
-TRACE_GL_VOID(glGetFramebufferAttachmentParameteriv, (GLenum target, GLenum attachment, GLenum pname, GLint* params), (target, attachment, pname, params), 4, "GLenum", target, "GLenum", attachment, "GLenum", pname, "GLint*", params)
-TRACE_GL_VOID(glGetFramebufferAttachmentParameterivOES, (GLenum target, GLenum attachment, GLenum pname, GLint* params), (target, attachment, pname, params), 4, "GLenum", target, "GLenum", attachment, "GLenum", pname, "GLint*", params)
+TRACE_GL_VOID(glGetFenceivNV, (GLuint fence, GLenum pname, GLint * params), (fence, pname, params), 3, "GLuint", fence, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetFirstPerfQueryIdINTEL, (GLuint * queryId), (queryId), 1, "GLuint *", queryId)
+TRACE_GL_VOID(glGetFixedv, (GLenum pname, GLfixed * params), (pname, params), 2, "GLenum", pname, "GLfixed *", params)
+TRACE_GL_VOID(glGetFixedvOES, (GLenum pname, GLfixed * params), (pname, params), 2, "GLenum", pname, "GLfixed *", params)
+TRACE_GL_VOID(glGetFloatv, (GLenum pname, GLfloat * data), (pname, data), 2, "GLenum", pname, "GLfloat *", data)
+TRACE_GL(GLint, glGetFragDataLocation, (GLuint program, const GLchar * name), (program, name), 2, "GLuint", program, "const GLchar *", name)
+TRACE_GL_VOID(glGetFramebufferAttachmentParameteriv, (GLenum target, GLenum attachment, GLenum pname, GLint * params), (target, attachment, pname, params), 4, "GLenum", target, "GLenum", attachment, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetFramebufferAttachmentParameterivOES, (GLenum target, GLenum attachment, GLenum pname, GLint * params), (target, attachment, pname, params), 4, "GLenum", target, "GLenum", attachment, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetFramebufferParameteriv, (GLenum target, GLenum pname, GLint * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint *", params)
 TRACE_GL(GLenum, glGetGraphicsResetStatusEXT, (void), (), 0)
-TRACE_GL_VOID(glGetInteger64i_v, (GLenum target, GLuint index, GLint64* data), (target, index, data), 3, "GLenum", target, "GLuint", index, "GLint64*", data)
-TRACE_GL_VOID(glGetInteger64v, (GLenum pname, GLint64* params), (pname, params), 2, "GLenum", pname, "GLint64*", params)
-TRACE_GL_VOID(glGetIntegeri_v, (GLenum target, GLuint index, GLint* data), (target, index, data), 3, "GLenum", target, "GLuint", index, "GLint*", data)
-TRACE_GL_VOID(glGetIntegerv, (GLenum pname, GLint *params), (pname, params), 2, "GLenum", pname, "GLint *", params)
-TRACE_GL_VOID(glGetInternalformativ, (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params), (target, internalformat, pname, bufSize, params), 5, "GLenum", target, "GLenum", internalformat, "GLenum", pname, "GLsizei", bufSize, "GLint*", params)
-TRACE_GL_VOID(glGetLightfv, (GLenum light, GLenum pname, GLfloat *params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "GLfloat *", params)
-TRACE_GL_VOID(glGetLightxv, (GLenum light, GLenum pname, GLfixed *params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetLightxvOES, (GLenum light, GLenum pname, GLfixed *params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetMaterialfv, (GLenum face, GLenum pname, GLfloat *params), (face, pname, params), 3, "GLenum", face, "GLenum", pname, "GLfloat *", params)
-TRACE_GL_VOID(glGetMaterialxv, (GLenum face, GLenum pname, GLfixed *params), (face, pname, params), 3, "GLenum", face, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetMaterialxvOES, (GLenum face, GLenum pname, GLfixed *params), (face, pname, params), 3, "GLenum", face, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetObjectLabelEXT, (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label), (type, object, bufSize, length, label), 5, "GLenum", type, "GLuint", object, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", label)
-TRACE_GL_VOID(glGetPerfMonitorCounterDataAMD, (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten), (monitor, pname, dataSize, data, bytesWritten), 5, "GLuint", monitor, "GLenum", pname, "GLsizei", dataSize, "GLuint *", data, "GLint *", bytesWritten)
-TRACE_GL_VOID(glGetPerfMonitorCounterInfoAMD, (GLuint group, GLuint counter, GLenum pname, GLvoid *data), (group, counter, pname, data), 4, "GLuint", group, "GLuint", counter, "GLenum", pname, "GLvoid *", data)
-TRACE_GL_VOID(glGetPerfMonitorCounterStringAMD, (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString), (group, counter, bufSize, length, counterString), 5, "GLuint", group, "GLuint", counter, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", counterString)
-TRACE_GL_VOID(glGetPerfMonitorCountersAMD, (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters), (group, numCounters, maxActiveCounters, counterSize, counters), 5, "GLuint", group, "GLint *", numCounters, "GLint *", maxActiveCounters, "GLsizei", counterSize, "GLuint *", counters)
-TRACE_GL_VOID(glGetPerfMonitorGroupStringAMD, (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString), (group, bufSize, length, groupString), 4, "GLuint", group, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", groupString)
-TRACE_GL_VOID(glGetPerfMonitorGroupsAMD, (GLint *numGroups, GLsizei groupsSize, GLuint *groups), (numGroups, groupsSize, groups), 3, "GLint *", numGroups, "GLsizei", groupsSize, "GLuint *", groups)
-TRACE_GL_VOID(glGetPointerv, (GLenum pname, GLvoid **params), (pname, params), 2, "GLenum", pname, "GLvoid **", params)
-TRACE_GL_VOID(glGetProgramBinary, (GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary), (program, bufSize, length, binaryFormat, binary), 5, "GLuint", program, "GLsizei", bufSize, "GLsizei*", length, "GLenum*", binaryFormat, "GLvoid*", binary)
-TRACE_GL_VOID(glGetProgramBinaryOES, (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary), (program, bufSize, length, binaryFormat, binary), 5, "GLuint", program, "GLsizei", bufSize, "GLsizei *", length, "GLenum *", binaryFormat, "GLvoid *", binary)
-TRACE_GL_VOID(glGetProgramInfoLog, (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog), (program, bufsize, length, infolog), 4, "GLuint", program, "GLsizei", bufsize, "GLsizei*", length, "GLchar*", infolog)
-TRACE_GL_VOID(glGetProgramPipelineInfoLogEXT, (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog), (pipeline, bufSize, length, infoLog), 4, "GLuint", pipeline, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", infoLog)
-TRACE_GL_VOID(glGetProgramPipelineivEXT, (GLuint pipeline, GLenum pname, GLint *params), (pipeline, pname, params), 3, "GLuint", pipeline, "GLenum", pname, "GLint *", params)
-TRACE_GL_VOID(glGetProgramiv, (GLuint program, GLenum pname, GLint* params), (program, pname, params), 3, "GLuint", program, "GLenum", pname, "GLint*", params)
-TRACE_GL_VOID(glGetQueryObjectuiv, (GLuint id, GLenum pname, GLuint* params), (id, pname, params), 3, "GLuint", id, "GLenum", pname, "GLuint*", params)
-TRACE_GL_VOID(glGetQueryObjectuivEXT, (GLuint id, GLenum pname, GLuint *params), (id, pname, params), 3, "GLuint", id, "GLenum", pname, "GLuint *", params)
-TRACE_GL_VOID(glGetQueryiv, (GLenum target, GLenum pname, GLint* params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint*", params)
-TRACE_GL_VOID(glGetQueryivEXT, (GLenum target, GLenum pname, GLint *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint *", params)
-TRACE_GL_VOID(glGetRenderbufferParameteriv, (GLenum target, GLenum pname, GLint* params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint*", params)
-TRACE_GL_VOID(glGetRenderbufferParameterivOES, (GLenum target, GLenum pname, GLint* params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint*", params)
-TRACE_GL_VOID(glGetSamplerParameterfv, (GLuint sampler, GLenum pname, GLfloat* params), (sampler, pname, params), 3, "GLuint", sampler, "GLenum", pname, "GLfloat*", params)
-TRACE_GL_VOID(glGetSamplerParameteriv, (GLuint sampler, GLenum pname, GLint* params), (sampler, pname, params), 3, "GLuint", sampler, "GLenum", pname, "GLint*", params)
-TRACE_GL_VOID(glGetShaderInfoLog, (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog), (shader, bufsize, length, infolog), 4, "GLuint", shader, "GLsizei", bufsize, "GLsizei*", length, "GLchar*", infolog)
-TRACE_GL_VOID(glGetShaderPrecisionFormat, (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision), (shadertype, precisiontype, range, precision), 4, "GLenum", shadertype, "GLenum", precisiontype, "GLint*", range, "GLint*", precision)
-TRACE_GL_VOID(glGetShaderSource, (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source), (shader, bufsize, length, source), 4, "GLuint", shader, "GLsizei", bufsize, "GLsizei*", length, "GLchar*", source)
-TRACE_GL_VOID(glGetShaderiv, (GLuint shader, GLenum pname, GLint* params), (shader, pname, params), 3, "GLuint", shader, "GLenum", pname, "GLint*", params)
+TRACE_GL_VOID(glGetInteger64i_v, (GLenum target, GLuint index, GLint64 * data), (target, index, data), 3, "GLenum", target, "GLuint", index, "GLint64 *", data)
+TRACE_GL_VOID(glGetInteger64v, (GLenum pname, GLint64 * data), (pname, data), 2, "GLenum", pname, "GLint64 *", data)
+TRACE_GL_VOID(glGetInteger64vAPPLE, (GLenum pname, GLint64 * params), (pname, params), 2, "GLenum", pname, "GLint64 *", params)
+TRACE_GL_VOID(glGetIntegeri_v, (GLenum target, GLuint index, GLint * data), (target, index, data), 3, "GLenum", target, "GLuint", index, "GLint *", data)
+TRACE_GL_VOID(glGetIntegeri_vEXT, (GLenum target, GLuint index, GLint * data), (target, index, data), 3, "GLenum", target, "GLuint", index, "GLint *", data)
+TRACE_GL_VOID(glGetIntegerv, (GLenum pname, GLint * data), (pname, data), 2, "GLenum", pname, "GLint *", data)
+TRACE_GL_VOID(glGetInternalformativ, (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint * params), (target, internalformat, pname, bufSize, params), 5, "GLenum", target, "GLenum", internalformat, "GLenum", pname, "GLsizei", bufSize, "GLint *", params)
+TRACE_GL_VOID(glGetLightfv, (GLenum light, GLenum pname, GLfloat * params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "GLfloat *", params)
+TRACE_GL_VOID(glGetLightxv, (GLenum light, GLenum pname, GLfixed * params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "GLfixed *", params)
+TRACE_GL_VOID(glGetLightxvOES, (GLenum light, GLenum pname, GLfixed * params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "GLfixed *", params)
+TRACE_GL_VOID(glGetMaterialfv, (GLenum face, GLenum pname, GLfloat * params), (face, pname, params), 3, "GLenum", face, "GLenum", pname, "GLfloat *", params)
+TRACE_GL_VOID(glGetMaterialxv, (GLenum face, GLenum pname, GLfixed * params), (face, pname, params), 3, "GLenum", face, "GLenum", pname, "GLfixed *", params)
+TRACE_GL_VOID(glGetMaterialxvOES, (GLenum face, GLenum pname, GLfixed * params), (face, pname, params), 3, "GLenum", face, "GLenum", pname, "GLfixed *", params)
+TRACE_GL_VOID(glGetMultisamplefv, (GLenum pname, GLuint index, GLfloat * val), (pname, index, val), 3, "GLenum", pname, "GLuint", index, "GLfloat *", val)
+TRACE_GL_VOID(glGetNextPerfQueryIdINTEL, (GLuint queryId, GLuint * nextQueryId), (queryId, nextQueryId), 2, "GLuint", queryId, "GLuint *", nextQueryId)
+TRACE_GL_VOID(glGetObjectLabelEXT, (GLenum type, GLuint object, GLsizei bufSize, GLsizei * length, GLchar * label), (type, object, bufSize, length, label), 5, "GLenum", type, "GLuint", object, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", label)
+TRACE_GL_VOID(glGetObjectLabelKHR, (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label), (identifier, name, bufSize, length, label), 5, "GLenum", identifier, "GLuint", name, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", label)
+TRACE_GL_VOID(glGetObjectPtrLabelKHR, (const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label), (ptr, bufSize, length, label), 4, "const void *", ptr, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", label)
+TRACE_GL_VOID(glGetPerfCounterInfoINTEL, (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar * counterName, GLuint counterDescLength, GLchar * counterDesc, GLuint * counterOffset, GLuint * counterDataSize, GLuint * counterTypeEnum, GLuint * counterDataTypeEnum, GLuint64 * rawCounterMaxValue), (queryId, counterId, counterNameLength, counterName, counterDescLength, counterDesc, counterOffset, counterDataSize, counterTypeEnum, counterDataTypeEnum, rawCounterMaxValue), 11, "GLuint", queryId, "GLuint", counterId, "GLuint", counterNameLength, "GLchar *", counterName, "GLuint", counterDescLength, "GLchar *", counterDesc, "GLuint *", counterOffset, "GLuint *", counterDataSize, "GLuint *", counterTypeEnum, "GLuint *", counterDataTypeEnum, "GLuint64 *", rawCounterMaxValue)
+TRACE_GL_VOID(glGetPerfMonitorCounterDataAMD, (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint * data, GLint * bytesWritten), (monitor, pname, dataSize, data, bytesWritten), 5, "GLuint", monitor, "GLenum", pname, "GLsizei", dataSize, "GLuint *", data, "GLint *", bytesWritten)
+TRACE_GL_VOID(glGetPerfMonitorCounterInfoAMD, (GLuint group, GLuint counter, GLenum pname, void * data), (group, counter, pname, data), 4, "GLuint", group, "GLuint", counter, "GLenum", pname, "void *", data)
+TRACE_GL_VOID(glGetPerfMonitorCounterStringAMD, (GLuint group, GLuint counter, GLsizei bufSize, GLsizei * length, GLchar * counterString), (group, counter, bufSize, length, counterString), 5, "GLuint", group, "GLuint", counter, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", counterString)
+TRACE_GL_VOID(glGetPerfMonitorCountersAMD, (GLuint group, GLint * numCounters, GLint * maxActiveCounters, GLsizei counterSize, GLuint * counters), (group, numCounters, maxActiveCounters, counterSize, counters), 5, "GLuint", group, "GLint *", numCounters, "GLint *", maxActiveCounters, "GLsizei", counterSize, "GLuint *", counters)
+TRACE_GL_VOID(glGetPerfMonitorGroupStringAMD, (GLuint group, GLsizei bufSize, GLsizei * length, GLchar * groupString), (group, bufSize, length, groupString), 4, "GLuint", group, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", groupString)
+TRACE_GL_VOID(glGetPerfMonitorGroupsAMD, (GLint * numGroups, GLsizei groupsSize, GLuint * groups), (numGroups, groupsSize, groups), 3, "GLint *", numGroups, "GLsizei", groupsSize, "GLuint *", groups)
+TRACE_GL_VOID(glGetPerfQueryDataINTEL, (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid * data, GLuint * bytesWritten), (queryHandle, flags, dataSize, data, bytesWritten), 5, "GLuint", queryHandle, "GLuint", flags, "GLsizei", dataSize, "GLvoid *", data, "GLuint *", bytesWritten)
+TRACE_GL_VOID(glGetPerfQueryIdByNameINTEL, (GLchar * queryName, GLuint * queryId), (queryName, queryId), 2, "GLchar *", queryName, "GLuint *", queryId)
+TRACE_GL_VOID(glGetPerfQueryInfoINTEL, (GLuint queryId, GLuint queryNameLength, GLchar * queryName, GLuint * dataSize, GLuint * noCounters, GLuint * noInstances, GLuint * capsMask), (queryId, queryNameLength, queryName, dataSize, noCounters, noInstances, capsMask), 7, "GLuint", queryId, "GLuint", queryNameLength, "GLchar *", queryName, "GLuint *", dataSize, "GLuint *", noCounters, "GLuint *", noInstances, "GLuint *", capsMask)
+TRACE_GL_VOID(glGetPointerv, (GLenum pname, void ** params), (pname, params), 2, "GLenum", pname, "void **", params)
+TRACE_GL_VOID(glGetPointervKHR, (GLenum pname, void ** params), (pname, params), 2, "GLenum", pname, "void **", params)
+TRACE_GL_VOID(glGetProgramBinary, (GLuint program, GLsizei bufSize, GLsizei * length, GLenum * binaryFormat, void * binary), (program, bufSize, length, binaryFormat, binary), 5, "GLuint", program, "GLsizei", bufSize, "GLsizei *", length, "GLenum *", binaryFormat, "void *", binary)
+TRACE_GL_VOID(glGetProgramBinaryOES, (GLuint program, GLsizei bufSize, GLsizei * length, GLenum * binaryFormat, void * binary), (program, bufSize, length, binaryFormat, binary), 5, "GLuint", program, "GLsizei", bufSize, "GLsizei *", length, "GLenum *", binaryFormat, "void *", binary)
+TRACE_GL_VOID(glGetProgramInfoLog, (GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog), (program, bufSize, length, infoLog), 4, "GLuint", program, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", infoLog)
+TRACE_GL_VOID(glGetProgramInterfaceiv, (GLuint program, GLenum programInterface, GLenum pname, GLint * params), (program, programInterface, pname, params), 4, "GLuint", program, "GLenum", programInterface, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetProgramPipelineInfoLog, (GLuint pipeline, GLsizei bufSize, GLsizei * length, GLchar * infoLog), (pipeline, bufSize, length, infoLog), 4, "GLuint", pipeline, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", infoLog)
+TRACE_GL_VOID(glGetProgramPipelineInfoLogEXT, (GLuint pipeline, GLsizei bufSize, GLsizei * length, GLchar * infoLog), (pipeline, bufSize, length, infoLog), 4, "GLuint", pipeline, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", infoLog)
+TRACE_GL_VOID(glGetProgramPipelineiv, (GLuint pipeline, GLenum pname, GLint * params), (pipeline, pname, params), 3, "GLuint", pipeline, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetProgramPipelineivEXT, (GLuint pipeline, GLenum pname, GLint * params), (pipeline, pname, params), 3, "GLuint", pipeline, "GLenum", pname, "GLint *", params)
+TRACE_GL(GLuint, glGetProgramResourceIndex, (GLuint program, GLenum programInterface, const GLchar * name), (program, programInterface, name), 3, "GLuint", program, "GLenum", programInterface, "const GLchar *", name)
+TRACE_GL(GLint, glGetProgramResourceLocation, (GLuint program, GLenum programInterface, const GLchar * name), (program, programInterface, name), 3, "GLuint", program, "GLenum", programInterface, "const GLchar *", name)
+TRACE_GL_VOID(glGetProgramResourceName, (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei * length, GLchar * name), (program, programInterface, index, bufSize, length, name), 6, "GLuint", program, "GLenum", programInterface, "GLuint", index, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", name)
+TRACE_GL_VOID(glGetProgramResourceiv, (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum * props, GLsizei bufSize, GLsizei * length, GLint * params), (program, programInterface, index, propCount, props, bufSize, length, params), 8, "GLuint", program, "GLenum", programInterface, "GLuint", index, "GLsizei", propCount, "const GLenum *", props, "GLsizei", bufSize, "GLsizei *", length, "GLint *", params)
+TRACE_GL_VOID(glGetProgramiv, (GLuint program, GLenum pname, GLint * params), (program, pname, params), 3, "GLuint", program, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetQueryObjecti64vEXT, (GLuint id, GLenum pname, GLint64 * params), (id, pname, params), 3, "GLuint", id, "GLenum", pname, "GLint64 *", params)
+TRACE_GL_VOID(glGetQueryObjectivEXT, (GLuint id, GLenum pname, GLint * params), (id, pname, params), 3, "GLuint", id, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetQueryObjectui64vEXT, (GLuint id, GLenum pname, GLuint64 * params), (id, pname, params), 3, "GLuint", id, "GLenum", pname, "GLuint64 *", params)
+TRACE_GL_VOID(glGetQueryObjectuiv, (GLuint id, GLenum pname, GLuint * params), (id, pname, params), 3, "GLuint", id, "GLenum", pname, "GLuint *", params)
+TRACE_GL_VOID(glGetQueryObjectuivEXT, (GLuint id, GLenum pname, GLuint * params), (id, pname, params), 3, "GLuint", id, "GLenum", pname, "GLuint *", params)
+TRACE_GL_VOID(glGetQueryiv, (GLenum target, GLenum pname, GLint * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetQueryivEXT, (GLenum target, GLenum pname, GLint * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetRenderbufferParameteriv, (GLenum target, GLenum pname, GLint * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetRenderbufferParameterivOES, (GLenum target, GLenum pname, GLint * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetSamplerParameterIivEXT, (GLuint sampler, GLenum pname, GLint * params), (sampler, pname, params), 3, "GLuint", sampler, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetSamplerParameterIuivEXT, (GLuint sampler, GLenum pname, GLuint * params), (sampler, pname, params), 3, "GLuint", sampler, "GLenum", pname, "GLuint *", params)
+TRACE_GL_VOID(glGetSamplerParameterfv, (GLuint sampler, GLenum pname, GLfloat * params), (sampler, pname, params), 3, "GLuint", sampler, "GLenum", pname, "GLfloat *", params)
+TRACE_GL_VOID(glGetSamplerParameteriv, (GLuint sampler, GLenum pname, GLint * params), (sampler, pname, params), 3, "GLuint", sampler, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetShaderInfoLog, (GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog), (shader, bufSize, length, infoLog), 4, "GLuint", shader, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", infoLog)
+TRACE_GL_VOID(glGetShaderPrecisionFormat, (GLenum shadertype, GLenum precisiontype, GLint * range, GLint * precision), (shadertype, precisiontype, range, precision), 4, "GLenum", shadertype, "GLenum", precisiontype, "GLint *", range, "GLint *", precision)
+TRACE_GL_VOID(glGetShaderSource, (GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source), (shader, bufSize, length, source), 4, "GLuint", shader, "GLsizei", bufSize, "GLsizei *", length, "GLchar *", source)
+TRACE_GL_VOID(glGetShaderiv, (GLuint shader, GLenum pname, GLint * params), (shader, pname, params), 3, "GLuint", shader, "GLenum", pname, "GLint *", params)
 TRACE_GL(const GLubyte *, glGetString, (GLenum name), (name), 1, "GLenum", name)
-TRACE_GL(const GLubyte*, glGetStringi, (GLenum name, GLuint index), (name, index), 2, "GLenum", name, "GLuint", index)
-TRACE_GL_VOID(glGetSynciv, (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values), (sync, pname, bufSize, length, values), 5, "GLsync", sync, "GLenum", pname, "GLsizei", bufSize, "GLsizei*", length, "GLint*", values)
-TRACE_GL_VOID(glGetTexEnvfv, (GLenum env, GLenum pname, GLfloat *params), (env, pname, params), 3, "GLenum", env, "GLenum", pname, "GLfloat *", params)
-TRACE_GL_VOID(glGetTexEnviv, (GLenum env, GLenum pname, GLint *params), (env, pname, params), 3, "GLenum", env, "GLenum", pname, "GLint *", params)
-TRACE_GL_VOID(glGetTexEnvxv, (GLenum env, GLenum pname, GLfixed *params), (env, pname, params), 3, "GLenum", env, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetTexEnvxvOES, (GLenum env, GLenum pname, GLfixed *params), (env, pname, params), 3, "GLenum", env, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetTexGenfvOES, (GLenum coord, GLenum pname, GLfloat *params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "GLfloat *", params)
-TRACE_GL_VOID(glGetTexGenivOES, (GLenum coord, GLenum pname, GLint *params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "GLint *", params)
-TRACE_GL_VOID(glGetTexGenxvOES, (GLenum coord, GLenum pname, GLfixed *params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetTexParameterfv, (GLenum target, GLenum pname, GLfloat *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLfloat *", params)
-TRACE_GL_VOID(glGetTexParameteriv, (GLenum target, GLenum pname, GLint *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint *", params)
-TRACE_GL_VOID(glGetTexParameterxv, (GLenum target, GLenum pname, GLfixed *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetTexParameterxvOES, (GLenum target, GLenum pname, GLfixed *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLfixed *", params)
-TRACE_GL_VOID(glGetTransformFeedbackVarying, (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name), (program, index, bufSize, length, size, type, name), 7, "GLuint", program, "GLuint", index, "GLsizei", bufSize, "GLsizei*", length, "GLsizei*", size, "GLenum*", type, "GLchar*", name)
-TRACE_GL(GLuint, glGetUniformBlockIndex, (GLuint program, const GLchar* uniformBlockName), (program, uniformBlockName), 2, "GLuint", program, "const GLchar*", uniformBlockName)
-TRACE_GL_VOID(glGetUniformIndices, (GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices), (program, uniformCount, uniformNames, uniformIndices), 4, "GLuint", program, "GLsizei", uniformCount, "const GLchar* const*", uniformNames, "GLuint*", uniformIndices)
-TRACE_GL(GLint, glGetUniformLocation, (GLuint program, const GLchar* name), (program, name), 2, "GLuint", program, "const GLchar*", name)
-TRACE_GL_VOID(glGetUniformfv, (GLuint program, GLint location, GLfloat* params), (program, location, params), 3, "GLuint", program, "GLint", location, "GLfloat*", params)
-TRACE_GL_VOID(glGetUniformiv, (GLuint program, GLint location, GLint* params), (program, location, params), 3, "GLuint", program, "GLint", location, "GLint*", params)
-TRACE_GL_VOID(glGetUniformuiv, (GLuint program, GLint location, GLuint* params), (program, location, params), 3, "GLuint", program, "GLint", location, "GLuint*", params)
-TRACE_GL_VOID(glGetVertexAttribIiv, (GLuint index, GLenum pname, GLint* params), (index, pname, params), 3, "GLuint", index, "GLenum", pname, "GLint*", params)
-TRACE_GL_VOID(glGetVertexAttribIuiv, (GLuint index, GLenum pname, GLuint* params), (index, pname, params), 3, "GLuint", index, "GLenum", pname, "GLuint*", params)
-TRACE_GL_VOID(glGetVertexAttribPointerv, (GLuint index, GLenum pname, GLvoid** pointer), (index, pname, pointer), 3, "GLuint", index, "GLenum", pname, "GLvoid**", pointer)
-TRACE_GL_VOID(glGetVertexAttribfv, (GLuint index, GLenum pname, GLfloat* params), (index, pname, params), 3, "GLuint", index, "GLenum", pname, "GLfloat*", params)
-TRACE_GL_VOID(glGetVertexAttribiv, (GLuint index, GLenum pname, GLint* params), (index, pname, params), 3, "GLuint", index, "GLenum", pname, "GLint*", params)
-TRACE_GL_VOID(glGetnUniformfvEXT, (GLuint program, GLint location, GLsizei bufSize, float *params), (program, location, bufSize, params), 4, "GLuint", program, "GLint", location, "GLsizei", bufSize, "float *", params)
-TRACE_GL_VOID(glGetnUniformivEXT, (GLuint program, GLint location, GLsizei bufSize, GLint *params), (program, location, bufSize, params), 4, "GLuint", program, "GLint", location, "GLsizei", bufSize, "GLint *", params)
+TRACE_GL(const GLubyte *, glGetStringi, (GLenum name, GLuint index), (name, index), 2, "GLenum", name, "GLuint", index)
+TRACE_GL_VOID(glGetSynciv, (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values), (sync, pname, bufSize, length, values), 5, "GLsync", sync, "GLenum", pname, "GLsizei", bufSize, "GLsizei *", length, "GLint *", values)
+TRACE_GL_VOID(glGetSyncivAPPLE, (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values), (sync, pname, bufSize, length, values), 5, "GLsync", sync, "GLenum", pname, "GLsizei", bufSize, "GLsizei *", length, "GLint *", values)
+TRACE_GL_VOID(glGetTexEnvfv, (GLenum target, GLenum pname, GLfloat * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLfloat *", params)
+TRACE_GL_VOID(glGetTexEnviv, (GLenum target, GLenum pname, GLint * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetTexEnvxv, (GLenum target, GLenum pname, GLfixed * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLfixed *", params)
+TRACE_GL_VOID(glGetTexEnvxvOES, (GLenum target, GLenum pname, GLfixed * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLfixed *", params)
+TRACE_GL_VOID(glGetTexGenfvOES, (GLenum coord, GLenum pname, GLfloat * params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "GLfloat *", params)
+TRACE_GL_VOID(glGetTexGenivOES, (GLenum coord, GLenum pname, GLint * params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetTexGenxvOES, (GLenum coord, GLenum pname, GLfixed * params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "GLfixed *", params)
+TRACE_GL_VOID(glGetTexLevelParameterfv, (GLenum target, GLint level, GLenum pname, GLfloat * params), (target, level, pname, params), 4, "GLenum", target, "GLint", level, "GLenum", pname, "GLfloat *", params)
+TRACE_GL_VOID(glGetTexLevelParameteriv, (GLenum target, GLint level, GLenum pname, GLint * params), (target, level, pname, params), 4, "GLenum", target, "GLint", level, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetTexParameterIivEXT, (GLenum target, GLenum pname, GLint * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetTexParameterIuivEXT, (GLenum target, GLenum pname, GLuint * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLuint *", params)
+TRACE_GL_VOID(glGetTexParameterfv, (GLenum target, GLenum pname, GLfloat * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLfloat *", params)
+TRACE_GL_VOID(glGetTexParameteriv, (GLenum target, GLenum pname, GLint * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetTexParameterxv, (GLenum target, GLenum pname, GLfixed * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLfixed *", params)
+TRACE_GL_VOID(glGetTexParameterxvOES, (GLenum target, GLenum pname, GLfixed * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLfixed *", params)
+TRACE_GL_VOID(glGetTransformFeedbackVarying, (GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name), (program, index, bufSize, length, size, type, name), 7, "GLuint", program, "GLuint", index, "GLsizei", bufSize, "GLsizei *", length, "GLsizei *", size, "GLenum *", type, "GLchar *", name)
+TRACE_GL_VOID(glGetTranslatedShaderSourceANGLE, (GLuint shader, GLsizei bufsize, GLsizei * length, GLchar * source), (shader, bufsize, length, source), 4, "GLuint", shader, "GLsizei", bufsize, "GLsizei *", length, "GLchar *", source)
+TRACE_GL(GLuint, glGetUniformBlockIndex, (GLuint program, const GLchar * uniformBlockName), (program, uniformBlockName), 2, "GLuint", program, "const GLchar *", uniformBlockName)
+TRACE_GL_VOID(glGetUniformIndices, (GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices), (program, uniformCount, uniformNames, uniformIndices), 4, "GLuint", program, "GLsizei", uniformCount, "const GLchar *const*", uniformNames, "GLuint *", uniformIndices)
+TRACE_GL(GLint, glGetUniformLocation, (GLuint program, const GLchar * name), (program, name), 2, "GLuint", program, "const GLchar *", name)
+TRACE_GL_VOID(glGetUniformfv, (GLuint program, GLint location, GLfloat * params), (program, location, params), 3, "GLuint", program, "GLint", location, "GLfloat *", params)
+TRACE_GL_VOID(glGetUniformiv, (GLuint program, GLint location, GLint * params), (program, location, params), 3, "GLuint", program, "GLint", location, "GLint *", params)
+TRACE_GL_VOID(glGetUniformuiv, (GLuint program, GLint location, GLuint * params), (program, location, params), 3, "GLuint", program, "GLint", location, "GLuint *", params)
+TRACE_GL_VOID(glGetVertexAttribIiv, (GLuint index, GLenum pname, GLint * params), (index, pname, params), 3, "GLuint", index, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetVertexAttribIuiv, (GLuint index, GLenum pname, GLuint * params), (index, pname, params), 3, "GLuint", index, "GLenum", pname, "GLuint *", params)
+TRACE_GL_VOID(glGetVertexAttribPointerv, (GLuint index, GLenum pname, void ** pointer), (index, pname, pointer), 3, "GLuint", index, "GLenum", pname, "void **", pointer)
+TRACE_GL_VOID(glGetVertexAttribfv, (GLuint index, GLenum pname, GLfloat * params), (index, pname, params), 3, "GLuint", index, "GLenum", pname, "GLfloat *", params)
+TRACE_GL_VOID(glGetVertexAttribiv, (GLuint index, GLenum pname, GLint * params), (index, pname, params), 3, "GLuint", index, "GLenum", pname, "GLint *", params)
+TRACE_GL_VOID(glGetnUniformfvEXT, (GLuint program, GLint location, GLsizei bufSize, GLfloat * params), (program, location, bufSize, params), 4, "GLuint", program, "GLint", location, "GLsizei", bufSize, "GLfloat *", params)
+TRACE_GL_VOID(glGetnUniformivEXT, (GLuint program, GLint location, GLsizei bufSize, GLint * params), (program, location, bufSize, params), 4, "GLuint", program, "GLint", location, "GLsizei", bufSize, "GLint *", params)
 TRACE_GL_VOID(glHint, (GLenum target, GLenum mode), (target, mode), 2, "GLenum", target, "GLenum", mode)
-TRACE_GL_VOID(glInsertEventMarkerEXT, (GLsizei length, const GLchar *marker), (length, marker), 2, "GLsizei", length, "const GLchar *", marker)
-TRACE_GL_VOID(glInvalidateFramebuffer, (GLenum target, GLsizei numAttachments, const GLenum* attachments), (target, numAttachments, attachments), 3, "GLenum", target, "GLsizei", numAttachments, "const GLenum*", attachments)
-TRACE_GL_VOID(glInvalidateSubFramebuffer, (GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height), (target, numAttachments, attachments, x, y, width, height), 7, "GLenum", target, "GLsizei", numAttachments, "const GLenum*", attachments, "GLint", x, "GLint", y, "GLsizei", width, "GLsizei", height)
+TRACE_GL_VOID(glInsertEventMarkerEXT, (GLsizei length, const GLchar * marker), (length, marker), 2, "GLsizei", length, "const GLchar *", marker)
+TRACE_GL_VOID(glInvalidateFramebuffer, (GLenum target, GLsizei numAttachments, const GLenum * attachments), (target, numAttachments, attachments), 3, "GLenum", target, "GLsizei", numAttachments, "const GLenum *", attachments)
+TRACE_GL_VOID(glInvalidateSubFramebuffer, (GLenum target, GLsizei numAttachments, const GLenum * attachments, GLint x, GLint y, GLsizei width, GLsizei height), (target, numAttachments, attachments, x, y, width, height), 7, "GLenum", target, "GLsizei", numAttachments, "const GLenum *", attachments, "GLint", x, "GLint", y, "GLsizei", width, "GLsizei", height)
 TRACE_GL(GLboolean, glIsBuffer, (GLuint buffer), (buffer), 1, "GLuint", buffer)
 TRACE_GL(GLboolean, glIsEnabled, (GLenum cap), (cap), 1, "GLenum", cap)
+TRACE_GL(GLboolean, glIsEnablediEXT, (GLenum target, GLuint index), (target, index), 2, "GLenum", target, "GLuint", index)
 TRACE_GL(GLboolean, glIsFenceNV, (GLuint fence), (fence), 1, "GLuint", fence)
 TRACE_GL(GLboolean, glIsFramebuffer, (GLuint framebuffer), (framebuffer), 1, "GLuint", framebuffer)
 TRACE_GL(GLboolean, glIsFramebufferOES, (GLuint framebuffer), (framebuffer), 1, "GLuint", framebuffer)
 TRACE_GL(GLboolean, glIsProgram, (GLuint program), (program), 1, "GLuint", program)
+TRACE_GL(GLboolean, glIsProgramPipeline, (GLuint pipeline), (pipeline), 1, "GLuint", pipeline)
 TRACE_GL(GLboolean, glIsProgramPipelineEXT, (GLuint pipeline), (pipeline), 1, "GLuint", pipeline)
 TRACE_GL(GLboolean, glIsQuery, (GLuint id), (id), 1, "GLuint", id)
 TRACE_GL(GLboolean, glIsQueryEXT, (GLuint id), (id), 1, "GLuint", id)
@@ -302,106 +383,174 @@
 TRACE_GL(GLboolean, glIsSampler, (GLuint sampler), (sampler), 1, "GLuint", sampler)
 TRACE_GL(GLboolean, glIsShader, (GLuint shader), (shader), 1, "GLuint", shader)
 TRACE_GL(GLboolean, glIsSync, (GLsync sync), (sync), 1, "GLsync", sync)
+TRACE_GL(GLboolean, glIsSyncAPPLE, (GLsync sync), (sync), 1, "GLsync", sync)
 TRACE_GL(GLboolean, glIsTexture, (GLuint texture), (texture), 1, "GLuint", texture)
 TRACE_GL(GLboolean, glIsTransformFeedback, (GLuint id), (id), 1, "GLuint", id)
 TRACE_GL(GLboolean, glIsVertexArray, (GLuint array), (array), 1, "GLuint", array)
 TRACE_GL(GLboolean, glIsVertexArrayOES, (GLuint array), (array), 1, "GLuint", array)
-TRACE_GL_VOID(glLabelObjectEXT, (GLenum type, GLuint object, GLsizei length, const GLchar *label), (type, object, length, label), 4, "GLenum", type, "GLuint", object, "GLsizei", length, "const GLchar *", label)
+TRACE_GL_VOID(glLabelObjectEXT, (GLenum type, GLuint object, GLsizei length, const GLchar * label), (type, object, length, label), 4, "GLenum", type, "GLuint", object, "GLsizei", length, "const GLchar *", label)
 TRACE_GL_VOID(glLightModelf, (GLenum pname, GLfloat param), (pname, param), 2, "GLenum", pname, "GLfloat", param)
-TRACE_GL_VOID(glLightModelfv, (GLenum pname, const GLfloat *params), (pname, params), 2, "GLenum", pname, "const GLfloat *", params)
+TRACE_GL_VOID(glLightModelfv, (GLenum pname, const GLfloat * params), (pname, params), 2, "GLenum", pname, "const GLfloat *", params)
 TRACE_GL_VOID(glLightModelx, (GLenum pname, GLfixed param), (pname, param), 2, "GLenum", pname, "GLfixed", param)
 TRACE_GL_VOID(glLightModelxOES, (GLenum pname, GLfixed param), (pname, param), 2, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glLightModelxv, (GLenum pname, const GLfixed *params), (pname, params), 2, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glLightModelxvOES, (GLenum pname, const GLfixed *params), (pname, params), 2, "GLenum", pname, "const GLfixed *", params)
+TRACE_GL_VOID(glLightModelxv, (GLenum pname, const GLfixed * param), (pname, param), 2, "GLenum", pname, "const GLfixed *", param)
+TRACE_GL_VOID(glLightModelxvOES, (GLenum pname, const GLfixed * param), (pname, param), 2, "GLenum", pname, "const GLfixed *", param)
 TRACE_GL_VOID(glLightf, (GLenum light, GLenum pname, GLfloat param), (light, pname, param), 3, "GLenum", light, "GLenum", pname, "GLfloat", param)
-TRACE_GL_VOID(glLightfv, (GLenum light, GLenum pname, const GLfloat *params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "const GLfloat *", params)
+TRACE_GL_VOID(glLightfv, (GLenum light, GLenum pname, const GLfloat * params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "const GLfloat *", params)
 TRACE_GL_VOID(glLightx, (GLenum light, GLenum pname, GLfixed param), (light, pname, param), 3, "GLenum", light, "GLenum", pname, "GLfixed", param)
 TRACE_GL_VOID(glLightxOES, (GLenum light, GLenum pname, GLfixed param), (light, pname, param), 3, "GLenum", light, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glLightxv, (GLenum light, GLenum pname, const GLfixed *params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glLightxvOES, (GLenum light, GLenum pname, const GLfixed *params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "const GLfixed *", params)
+TRACE_GL_VOID(glLightxv, (GLenum light, GLenum pname, const GLfixed * params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "const GLfixed *", params)
+TRACE_GL_VOID(glLightxvOES, (GLenum light, GLenum pname, const GLfixed * params), (light, pname, params), 3, "GLenum", light, "GLenum", pname, "const GLfixed *", params)
 TRACE_GL_VOID(glLineWidth, (GLfloat width), (width), 1, "GLfloat", width)
 TRACE_GL_VOID(glLineWidthx, (GLfixed width), (width), 1, "GLfixed", width)
 TRACE_GL_VOID(glLineWidthxOES, (GLfixed width), (width), 1, "GLfixed", width)
 TRACE_GL_VOID(glLinkProgram, (GLuint program), (program), 1, "GLuint", program)
 TRACE_GL_VOID(glLoadIdentity, (void), (), 0)
-TRACE_GL_VOID(glLoadMatrixf, (const GLfloat *m), (m), 1, "const GLfloat *", m)
-TRACE_GL_VOID(glLoadMatrixx, (const GLfixed *m), (m), 1, "const GLfixed *", m)
-TRACE_GL_VOID(glLoadMatrixxOES, (const GLfixed *m), (m), 1, "const GLfixed *", m)
+TRACE_GL_VOID(glLoadMatrixf, (const GLfloat * m), (m), 1, "const GLfloat *", m)
+TRACE_GL_VOID(glLoadMatrixx, (const GLfixed * m), (m), 1, "const GLfixed *", m)
+TRACE_GL_VOID(glLoadMatrixxOES, (const GLfixed * m), (m), 1, "const GLfixed *", m)
 TRACE_GL_VOID(glLoadPaletteFromModelViewMatrixOES, (void), (), 0)
 TRACE_GL_VOID(glLogicOp, (GLenum opcode), (opcode), 1, "GLenum", opcode)
-TRACE_GL(void*, glMapBufferOES, (GLenum target, GLenum access), (target, access), 2, "GLenum", target, "GLenum", access)
-TRACE_GL(GLvoid*, glMapBufferRange, (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access), (target, offset, length, access), 4, "GLenum", target, "GLintptr", offset, "GLsizeiptr", length, "GLbitfield", access)
+TRACE_GL(void *, glMapBufferOES, (GLenum target, GLenum access), (target, access), 2, "GLenum", target, "GLenum", access)
+TRACE_GL(void *, glMapBufferRange, (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access), (target, offset, length, access), 4, "GLenum", target, "GLintptr", offset, "GLsizeiptr", length, "GLbitfield", access)
+TRACE_GL(void *, glMapBufferRangeEXT, (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access), (target, offset, length, access), 4, "GLenum", target, "GLintptr", offset, "GLsizeiptr", length, "GLbitfield", access)
 TRACE_GL_VOID(glMaterialf, (GLenum face, GLenum pname, GLfloat param), (face, pname, param), 3, "GLenum", face, "GLenum", pname, "GLfloat", param)
-TRACE_GL_VOID(glMaterialfv, (GLenum face, GLenum pname, const GLfloat *params), (face, pname, params), 3, "GLenum", face, "GLenum", pname, "const GLfloat *", params)
+TRACE_GL_VOID(glMaterialfv, (GLenum face, GLenum pname, const GLfloat * params), (face, pname, params), 3, "GLenum", face, "GLenum", pname, "const GLfloat *", params)
 TRACE_GL_VOID(glMaterialx, (GLenum face, GLenum pname, GLfixed param), (face, pname, param), 3, "GLenum", face, "GLenum", pname, "GLfixed", param)
 TRACE_GL_VOID(glMaterialxOES, (GLenum face, GLenum pname, GLfixed param), (face, pname, param), 3, "GLenum", face, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glMaterialxv, (GLenum face, GLenum pname, const GLfixed *params), (face, pname, params), 3, "GLenum", face, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glMaterialxvOES, (GLenum face, GLenum pname, const GLfixed *params), (face, pname, params), 3, "GLenum", face, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glMatrixIndexPointerOES, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer), (size, type, stride, pointer), 4, "GLint", size, "GLenum", type, "GLsizei", stride, "const GLvoid *", pointer)
+TRACE_GL_VOID(glMaterialxv, (GLenum face, GLenum pname, const GLfixed * param), (face, pname, param), 3, "GLenum", face, "GLenum", pname, "const GLfixed *", param)
+TRACE_GL_VOID(glMaterialxvOES, (GLenum face, GLenum pname, const GLfixed * param), (face, pname, param), 3, "GLenum", face, "GLenum", pname, "const GLfixed *", param)
+TRACE_GL_VOID(glMatrixIndexPointerOES, (GLint size, GLenum type, GLsizei stride, const void * pointer), (size, type, stride, pointer), 4, "GLint", size, "GLenum", type, "GLsizei", stride, "const void *", pointer)
 TRACE_GL_VOID(glMatrixMode, (GLenum mode), (mode), 1, "GLenum", mode)
-TRACE_GL_VOID(glMultMatrixf, (const GLfloat *m), (m), 1, "const GLfloat *", m)
-TRACE_GL_VOID(glMultMatrixx, (const GLfixed *m), (m), 1, "const GLfixed *", m)
-TRACE_GL_VOID(glMultMatrixxOES, (const GLfixed *m), (m), 1, "const GLfixed *", m)
-TRACE_GL_VOID(glMultiDrawArraysEXT, (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount), (mode, first, count, primcount), 4, "GLenum", mode, "GLint *", first, "GLsizei *", count, "GLsizei", primcount)
-TRACE_GL_VOID(glMultiDrawElementsEXT, (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount), (mode, count, type, indices, primcount), 5, "GLenum", mode, "const GLsizei *", count, "GLenum", type, "const GLvoid* *", indices, "GLsizei", primcount)
+TRACE_GL_VOID(glMemoryBarrier, (GLbitfield barriers), (barriers), 1, "GLbitfield", barriers)
+TRACE_GL_VOID(glMemoryBarrierByRegion, (GLbitfield barriers), (barriers), 1, "GLbitfield", barriers)
+TRACE_GL_VOID(glMinSampleShadingOES, (GLfloat value), (value), 1, "GLfloat", value)
+TRACE_GL_VOID(glMultMatrixf, (const GLfloat * m), (m), 1, "const GLfloat *", m)
+TRACE_GL_VOID(glMultMatrixx, (const GLfixed * m), (m), 1, "const GLfixed *", m)
+TRACE_GL_VOID(glMultMatrixxOES, (const GLfixed * m), (m), 1, "const GLfixed *", m)
+TRACE_GL_VOID(glMultiDrawArraysEXT, (GLenum mode, const GLint * first, const GLsizei * count, GLsizei primcount), (mode, first, count, primcount), 4, "GLenum", mode, "const GLint *", first, "const GLsizei *", count, "GLsizei", primcount)
+TRACE_GL_VOID(glMultiDrawElementsEXT, (GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei primcount), (mode, count, type, indices, primcount), 5, "GLenum", mode, "const GLsizei *", count, "GLenum", type, "const void *const*", indices, "GLsizei", primcount)
+TRACE_GL_VOID(glMultiTexCoord1bOES, (GLenum texture, GLbyte s), (texture, s), 2, "GLenum", texture, "GLbyte", s)
+TRACE_GL_VOID(glMultiTexCoord1bvOES, (GLenum texture, const GLbyte * coords), (texture, coords), 2, "GLenum", texture, "const GLbyte *", coords)
+TRACE_GL_VOID(glMultiTexCoord2bOES, (GLenum texture, GLbyte s, GLbyte t), (texture, s, t), 3, "GLenum", texture, "GLbyte", s, "GLbyte", t)
+TRACE_GL_VOID(glMultiTexCoord2bvOES, (GLenum texture, const GLbyte * coords), (texture, coords), 2, "GLenum", texture, "const GLbyte *", coords)
+TRACE_GL_VOID(glMultiTexCoord3bOES, (GLenum texture, GLbyte s, GLbyte t, GLbyte r), (texture, s, t, r), 4, "GLenum", texture, "GLbyte", s, "GLbyte", t, "GLbyte", r)
+TRACE_GL_VOID(glMultiTexCoord3bvOES, (GLenum texture, const GLbyte * coords), (texture, coords), 2, "GLenum", texture, "const GLbyte *", coords)
+TRACE_GL_VOID(glMultiTexCoord4bOES, (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q), (texture, s, t, r, q), 5, "GLenum", texture, "GLbyte", s, "GLbyte", t, "GLbyte", r, "GLbyte", q)
+TRACE_GL_VOID(glMultiTexCoord4bvOES, (GLenum texture, const GLbyte * coords), (texture, coords), 2, "GLenum", texture, "const GLbyte *", coords)
 TRACE_GL_VOID(glMultiTexCoord4f, (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q), (target, s, t, r, q), 5, "GLenum", target, "GLfloat", s, "GLfloat", t, "GLfloat", r, "GLfloat", q)
-TRACE_GL_VOID(glMultiTexCoord4x, (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q), (target, s, t, r, q), 5, "GLenum", target, "GLfixed", s, "GLfixed", t, "GLfixed", r, "GLfixed", q)
-TRACE_GL_VOID(glMultiTexCoord4xOES, (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q), (target, s, t, r, q), 5, "GLenum", target, "GLfixed", s, "GLfixed", t, "GLfixed", r, "GLfixed", q)
+TRACE_GL_VOID(glMultiTexCoord4x, (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q), (texture, s, t, r, q), 5, "GLenum", texture, "GLfixed", s, "GLfixed", t, "GLfixed", r, "GLfixed", q)
+TRACE_GL_VOID(glMultiTexCoord4xOES, (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q), (texture, s, t, r, q), 5, "GLenum", texture, "GLfixed", s, "GLfixed", t, "GLfixed", r, "GLfixed", q)
 TRACE_GL_VOID(glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz), (nx, ny, nz), 3, "GLfloat", nx, "GLfloat", ny, "GLfloat", nz)
 TRACE_GL_VOID(glNormal3x, (GLfixed nx, GLfixed ny, GLfixed nz), (nx, ny, nz), 3, "GLfixed", nx, "GLfixed", ny, "GLfixed", nz)
 TRACE_GL_VOID(glNormal3xOES, (GLfixed nx, GLfixed ny, GLfixed nz), (nx, ny, nz), 3, "GLfixed", nx, "GLfixed", ny, "GLfixed", nz)
-TRACE_GL_VOID(glNormalPointer, (GLenum type, GLsizei stride, const GLvoid *pointer), (type, stride, pointer), 3, "GLenum", type, "GLsizei", stride, "const GLvoid *", pointer)
-TRACE_GL_VOID(glOrthof, (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar), (left, right, bottom, top, zNear, zFar), 6, "GLfloat", left, "GLfloat", right, "GLfloat", bottom, "GLfloat", top, "GLfloat", zNear, "GLfloat", zFar)
-TRACE_GL_VOID(glOrthofOES, (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar), (left, right, bottom, top, zNear, zFar), 6, "GLfloat", left, "GLfloat", right, "GLfloat", bottom, "GLfloat", top, "GLfloat", zNear, "GLfloat", zFar)
-TRACE_GL_VOID(glOrthox, (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar), (left, right, bottom, top, zNear, zFar), 6, "GLfixed", left, "GLfixed", right, "GLfixed", bottom, "GLfixed", top, "GLfixed", zNear, "GLfixed", zFar)
-TRACE_GL_VOID(glOrthoxOES, (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar), (left, right, bottom, top, zNear, zFar), 6, "GLfixed", left, "GLfixed", right, "GLfixed", bottom, "GLfixed", top, "GLfixed", zNear, "GLfixed", zFar)
+TRACE_GL_VOID(glNormalPointer, (GLenum type, GLsizei stride, const void * pointer), (type, stride, pointer), 3, "GLenum", type, "GLsizei", stride, "const void *", pointer)
+TRACE_GL_VOID(glObjectLabelKHR, (GLenum identifier, GLuint name, GLsizei length, const GLchar * label), (identifier, name, length, label), 4, "GLenum", identifier, "GLuint", name, "GLsizei", length, "const GLchar *", label)
+TRACE_GL_VOID(glObjectPtrLabelKHR, (const void * ptr, GLsizei length, const GLchar * label), (ptr, length, label), 3, "const void *", ptr, "GLsizei", length, "const GLchar *", label)
+TRACE_GL_VOID(glOrthof, (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f), (l, r, b, t, n, f), 6, "GLfloat", l, "GLfloat", r, "GLfloat", b, "GLfloat", t, "GLfloat", n, "GLfloat", f)
+TRACE_GL_VOID(glOrthofOES, (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f), (l, r, b, t, n, f), 6, "GLfloat", l, "GLfloat", r, "GLfloat", b, "GLfloat", t, "GLfloat", n, "GLfloat", f)
+TRACE_GL_VOID(glOrthox, (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f), (l, r, b, t, n, f), 6, "GLfixed", l, "GLfixed", r, "GLfixed", b, "GLfixed", t, "GLfixed", n, "GLfixed", f)
+TRACE_GL_VOID(glOrthoxOES, (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f), (l, r, b, t, n, f), 6, "GLfixed", l, "GLfixed", r, "GLfixed", b, "GLfixed", t, "GLfixed", n, "GLfixed", f)
+TRACE_GL_VOID(glPatchParameteriEXT, (GLenum pname, GLint value), (pname, value), 2, "GLenum", pname, "GLint", value)
 TRACE_GL_VOID(glPauseTransformFeedback, (void), (), 0)
 TRACE_GL_VOID(glPixelStorei, (GLenum pname, GLint param), (pname, param), 2, "GLenum", pname, "GLint", param)
 TRACE_GL_VOID(glPointParameterf, (GLenum pname, GLfloat param), (pname, param), 2, "GLenum", pname, "GLfloat", param)
-TRACE_GL_VOID(glPointParameterfv, (GLenum pname, const GLfloat *params), (pname, params), 2, "GLenum", pname, "const GLfloat *", params)
+TRACE_GL_VOID(glPointParameterfv, (GLenum pname, const GLfloat * params), (pname, params), 2, "GLenum", pname, "const GLfloat *", params)
 TRACE_GL_VOID(glPointParameterx, (GLenum pname, GLfixed param), (pname, param), 2, "GLenum", pname, "GLfixed", param)
 TRACE_GL_VOID(glPointParameterxOES, (GLenum pname, GLfixed param), (pname, param), 2, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glPointParameterxv, (GLenum pname, const GLfixed *params), (pname, params), 2, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glPointParameterxvOES, (GLenum pname, const GLfixed *params), (pname, params), 2, "GLenum", pname, "const GLfixed *", params)
+TRACE_GL_VOID(glPointParameterxv, (GLenum pname, const GLfixed * params), (pname, params), 2, "GLenum", pname, "const GLfixed *", params)
+TRACE_GL_VOID(glPointParameterxvOES, (GLenum pname, const GLfixed * params), (pname, params), 2, "GLenum", pname, "const GLfixed *", params)
 TRACE_GL_VOID(glPointSize, (GLfloat size), (size), 1, "GLfloat", size)
-TRACE_GL_VOID(glPointSizePointerOES, (GLenum type, GLsizei stride, const GLvoid *pointer), (type, stride, pointer), 3, "GLenum", type, "GLsizei", stride, "const GLvoid *", pointer)
+TRACE_GL_VOID(glPointSizePointerOES, (GLenum type, GLsizei stride, const void * pointer), (type, stride, pointer), 3, "GLenum", type, "GLsizei", stride, "const void *", pointer)
 TRACE_GL_VOID(glPointSizex, (GLfixed size), (size), 1, "GLfixed", size)
 TRACE_GL_VOID(glPointSizexOES, (GLfixed size), (size), 1, "GLfixed", size)
 TRACE_GL_VOID(glPolygonOffset, (GLfloat factor, GLfloat units), (factor, units), 2, "GLfloat", factor, "GLfloat", units)
 TRACE_GL_VOID(glPolygonOffsetx, (GLfixed factor, GLfixed units), (factor, units), 2, "GLfixed", factor, "GLfixed", units)
 TRACE_GL_VOID(glPolygonOffsetxOES, (GLfixed factor, GLfixed units), (factor, units), 2, "GLfixed", factor, "GLfixed", units)
+TRACE_GL_VOID(glPopDebugGroupKHR, (void), (), 0)
 TRACE_GL_VOID(glPopGroupMarkerEXT, (void), (), 0)
 TRACE_GL_VOID(glPopMatrix, (void), (), 0)
-TRACE_GL_VOID(glProgramBinary, (GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length), (program, binaryFormat, binary, length), 4, "GLuint", program, "GLenum", binaryFormat, "const GLvoid*", binary, "GLsizei", length)
-TRACE_GL_VOID(glProgramBinaryOES, (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length), (program, binaryFormat, binary, length), 4, "GLuint", program, "GLenum", binaryFormat, "const GLvoid *", binary, "GLint", length)
+TRACE_GL_VOID(glPrimitiveBoundingBoxEXT, (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW), (minX, minY, minZ, minW, maxX, maxY, maxZ, maxW), 8, "GLfloat", minX, "GLfloat", minY, "GLfloat", minZ, "GLfloat", minW, "GLfloat", maxX, "GLfloat", maxY, "GLfloat", maxZ, "GLfloat", maxW)
+TRACE_GL_VOID(glProgramBinary, (GLuint program, GLenum binaryFormat, const void * binary, GLsizei length), (program, binaryFormat, binary, length), 4, "GLuint", program, "GLenum", binaryFormat, "const void *", binary, "GLsizei", length)
+TRACE_GL_VOID(glProgramBinaryOES, (GLuint program, GLenum binaryFormat, const void * binary, GLint length), (program, binaryFormat, binary, length), 4, "GLuint", program, "GLenum", binaryFormat, "const void *", binary, "GLint", length)
 TRACE_GL_VOID(glProgramParameteri, (GLuint program, GLenum pname, GLint value), (program, pname, value), 3, "GLuint", program, "GLenum", pname, "GLint", value)
 TRACE_GL_VOID(glProgramParameteriEXT, (GLuint program, GLenum pname, GLint value), (program, pname, value), 3, "GLuint", program, "GLenum", pname, "GLint", value)
-TRACE_GL_VOID(glProgramUniform1fEXT, (GLuint program, GLint location, GLfloat x), (program, location, x), 3, "GLuint", program, "GLint", location, "GLfloat", x)
-TRACE_GL_VOID(glProgramUniform1fvEXT, (GLuint program, GLint location, GLsizei count, const GLfloat *value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLfloat *", value)
-TRACE_GL_VOID(glProgramUniform1iEXT, (GLuint program, GLint location, GLint x), (program, location, x), 3, "GLuint", program, "GLint", location, "GLint", x)
-TRACE_GL_VOID(glProgramUniform1ivEXT, (GLuint program, GLint location, GLsizei count, const GLint *value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLint *", value)
-TRACE_GL_VOID(glProgramUniform2fEXT, (GLuint program, GLint location, GLfloat x, GLfloat y), (program, location, x, y), 4, "GLuint", program, "GLint", location, "GLfloat", x, "GLfloat", y)
-TRACE_GL_VOID(glProgramUniform2fvEXT, (GLuint program, GLint location, GLsizei count, const GLfloat *value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLfloat *", value)
-TRACE_GL_VOID(glProgramUniform2iEXT, (GLuint program, GLint location, GLint x, GLint y), (program, location, x, y), 4, "GLuint", program, "GLint", location, "GLint", x, "GLint", y)
-TRACE_GL_VOID(glProgramUniform2ivEXT, (GLuint program, GLint location, GLsizei count, const GLint *value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLint *", value)
-TRACE_GL_VOID(glProgramUniform3fEXT, (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z), (program, location, x, y, z), 5, "GLuint", program, "GLint", location, "GLfloat", x, "GLfloat", y, "GLfloat", z)
-TRACE_GL_VOID(glProgramUniform3fvEXT, (GLuint program, GLint location, GLsizei count, const GLfloat *value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLfloat *", value)
-TRACE_GL_VOID(glProgramUniform3iEXT, (GLuint program, GLint location, GLint x, GLint y, GLint z), (program, location, x, y, z), 5, "GLuint", program, "GLint", location, "GLint", x, "GLint", y, "GLint", z)
-TRACE_GL_VOID(glProgramUniform3ivEXT, (GLuint program, GLint location, GLsizei count, const GLint *value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLint *", value)
-TRACE_GL_VOID(glProgramUniform4fEXT, (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w), (program, location, x, y, z, w), 6, "GLuint", program, "GLint", location, "GLfloat", x, "GLfloat", y, "GLfloat", z, "GLfloat", w)
-TRACE_GL_VOID(glProgramUniform4fvEXT, (GLuint program, GLint location, GLsizei count, const GLfloat *value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLfloat *", value)
-TRACE_GL_VOID(glProgramUniform4iEXT, (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w), (program, location, x, y, z, w), 6, "GLuint", program, "GLint", location, "GLint", x, "GLint", y, "GLint", z, "GLint", w)
-TRACE_GL_VOID(glProgramUniform4ivEXT, (GLuint program, GLint location, GLsizei count, const GLint *value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLint *", value)
-TRACE_GL_VOID(glProgramUniformMatrix2fvEXT, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
-TRACE_GL_VOID(glProgramUniformMatrix3fvEXT, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
-TRACE_GL_VOID(glProgramUniformMatrix4fvEXT, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
-TRACE_GL_VOID(glPushGroupMarkerEXT, (GLsizei length, const GLchar *marker), (length, marker), 2, "GLsizei", length, "const GLchar *", marker)
+TRACE_GL_VOID(glProgramUniform1f, (GLuint program, GLint location, GLfloat v0), (program, location, v0), 3, "GLuint", program, "GLint", location, "GLfloat", v0)
+TRACE_GL_VOID(glProgramUniform1fEXT, (GLuint program, GLint location, GLfloat v0), (program, location, v0), 3, "GLuint", program, "GLint", location, "GLfloat", v0)
+TRACE_GL_VOID(glProgramUniform1fv, (GLuint program, GLint location, GLsizei count, const GLfloat * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniform1fvEXT, (GLuint program, GLint location, GLsizei count, const GLfloat * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniform1i, (GLuint program, GLint location, GLint v0), (program, location, v0), 3, "GLuint", program, "GLint", location, "GLint", v0)
+TRACE_GL_VOID(glProgramUniform1iEXT, (GLuint program, GLint location, GLint v0), (program, location, v0), 3, "GLuint", program, "GLint", location, "GLint", v0)
+TRACE_GL_VOID(glProgramUniform1iv, (GLuint program, GLint location, GLsizei count, const GLint * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLint *", value)
+TRACE_GL_VOID(glProgramUniform1ivEXT, (GLuint program, GLint location, GLsizei count, const GLint * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLint *", value)
+TRACE_GL_VOID(glProgramUniform1ui, (GLuint program, GLint location, GLuint v0), (program, location, v0), 3, "GLuint", program, "GLint", location, "GLuint", v0)
+TRACE_GL_VOID(glProgramUniform1uiEXT, (GLuint program, GLint location, GLuint v0), (program, location, v0), 3, "GLuint", program, "GLint", location, "GLuint", v0)
+TRACE_GL_VOID(glProgramUniform1uiv, (GLuint program, GLint location, GLsizei count, const GLuint * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLuint *", value)
+TRACE_GL_VOID(glProgramUniform1uivEXT, (GLuint program, GLint location, GLsizei count, const GLuint * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLuint *", value)
+TRACE_GL_VOID(glProgramUniform2f, (GLuint program, GLint location, GLfloat v0, GLfloat v1), (program, location, v0, v1), 4, "GLuint", program, "GLint", location, "GLfloat", v0, "GLfloat", v1)
+TRACE_GL_VOID(glProgramUniform2fEXT, (GLuint program, GLint location, GLfloat v0, GLfloat v1), (program, location, v0, v1), 4, "GLuint", program, "GLint", location, "GLfloat", v0, "GLfloat", v1)
+TRACE_GL_VOID(glProgramUniform2fv, (GLuint program, GLint location, GLsizei count, const GLfloat * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniform2fvEXT, (GLuint program, GLint location, GLsizei count, const GLfloat * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniform2i, (GLuint program, GLint location, GLint v0, GLint v1), (program, location, v0, v1), 4, "GLuint", program, "GLint", location, "GLint", v0, "GLint", v1)
+TRACE_GL_VOID(glProgramUniform2iEXT, (GLuint program, GLint location, GLint v0, GLint v1), (program, location, v0, v1), 4, "GLuint", program, "GLint", location, "GLint", v0, "GLint", v1)
+TRACE_GL_VOID(glProgramUniform2iv, (GLuint program, GLint location, GLsizei count, const GLint * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLint *", value)
+TRACE_GL_VOID(glProgramUniform2ivEXT, (GLuint program, GLint location, GLsizei count, const GLint * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLint *", value)
+TRACE_GL_VOID(glProgramUniform2ui, (GLuint program, GLint location, GLuint v0, GLuint v1), (program, location, v0, v1), 4, "GLuint", program, "GLint", location, "GLuint", v0, "GLuint", v1)
+TRACE_GL_VOID(glProgramUniform2uiEXT, (GLuint program, GLint location, GLuint v0, GLuint v1), (program, location, v0, v1), 4, "GLuint", program, "GLint", location, "GLuint", v0, "GLuint", v1)
+TRACE_GL_VOID(glProgramUniform2uiv, (GLuint program, GLint location, GLsizei count, const GLuint * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLuint *", value)
+TRACE_GL_VOID(glProgramUniform2uivEXT, (GLuint program, GLint location, GLsizei count, const GLuint * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLuint *", value)
+TRACE_GL_VOID(glProgramUniform3f, (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2), (program, location, v0, v1, v2), 5, "GLuint", program, "GLint", location, "GLfloat", v0, "GLfloat", v1, "GLfloat", v2)
+TRACE_GL_VOID(glProgramUniform3fEXT, (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2), (program, location, v0, v1, v2), 5, "GLuint", program, "GLint", location, "GLfloat", v0, "GLfloat", v1, "GLfloat", v2)
+TRACE_GL_VOID(glProgramUniform3fv, (GLuint program, GLint location, GLsizei count, const GLfloat * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniform3fvEXT, (GLuint program, GLint location, GLsizei count, const GLfloat * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniform3i, (GLuint program, GLint location, GLint v0, GLint v1, GLint v2), (program, location, v0, v1, v2), 5, "GLuint", program, "GLint", location, "GLint", v0, "GLint", v1, "GLint", v2)
+TRACE_GL_VOID(glProgramUniform3iEXT, (GLuint program, GLint location, GLint v0, GLint v1, GLint v2), (program, location, v0, v1, v2), 5, "GLuint", program, "GLint", location, "GLint", v0, "GLint", v1, "GLint", v2)
+TRACE_GL_VOID(glProgramUniform3iv, (GLuint program, GLint location, GLsizei count, const GLint * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLint *", value)
+TRACE_GL_VOID(glProgramUniform3ivEXT, (GLuint program, GLint location, GLsizei count, const GLint * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLint *", value)
+TRACE_GL_VOID(glProgramUniform3ui, (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2), (program, location, v0, v1, v2), 5, "GLuint", program, "GLint", location, "GLuint", v0, "GLuint", v1, "GLuint", v2)
+TRACE_GL_VOID(glProgramUniform3uiEXT, (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2), (program, location, v0, v1, v2), 5, "GLuint", program, "GLint", location, "GLuint", v0, "GLuint", v1, "GLuint", v2)
+TRACE_GL_VOID(glProgramUniform3uiv, (GLuint program, GLint location, GLsizei count, const GLuint * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLuint *", value)
+TRACE_GL_VOID(glProgramUniform3uivEXT, (GLuint program, GLint location, GLsizei count, const GLuint * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLuint *", value)
+TRACE_GL_VOID(glProgramUniform4f, (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3), (program, location, v0, v1, v2, v3), 6, "GLuint", program, "GLint", location, "GLfloat", v0, "GLfloat", v1, "GLfloat", v2, "GLfloat", v3)
+TRACE_GL_VOID(glProgramUniform4fEXT, (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3), (program, location, v0, v1, v2, v3), 6, "GLuint", program, "GLint", location, "GLfloat", v0, "GLfloat", v1, "GLfloat", v2, "GLfloat", v3)
+TRACE_GL_VOID(glProgramUniform4fv, (GLuint program, GLint location, GLsizei count, const GLfloat * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniform4fvEXT, (GLuint program, GLint location, GLsizei count, const GLfloat * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniform4i, (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3), (program, location, v0, v1, v2, v3), 6, "GLuint", program, "GLint", location, "GLint", v0, "GLint", v1, "GLint", v2, "GLint", v3)
+TRACE_GL_VOID(glProgramUniform4iEXT, (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3), (program, location, v0, v1, v2, v3), 6, "GLuint", program, "GLint", location, "GLint", v0, "GLint", v1, "GLint", v2, "GLint", v3)
+TRACE_GL_VOID(glProgramUniform4iv, (GLuint program, GLint location, GLsizei count, const GLint * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLint *", value)
+TRACE_GL_VOID(glProgramUniform4ivEXT, (GLuint program, GLint location, GLsizei count, const GLint * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLint *", value)
+TRACE_GL_VOID(glProgramUniform4ui, (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3), (program, location, v0, v1, v2, v3), 6, "GLuint", program, "GLint", location, "GLuint", v0, "GLuint", v1, "GLuint", v2, "GLuint", v3)
+TRACE_GL_VOID(glProgramUniform4uiEXT, (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3), (program, location, v0, v1, v2, v3), 6, "GLuint", program, "GLint", location, "GLuint", v0, "GLuint", v1, "GLuint", v2, "GLuint", v3)
+TRACE_GL_VOID(glProgramUniform4uiv, (GLuint program, GLint location, GLsizei count, const GLuint * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLuint *", value)
+TRACE_GL_VOID(glProgramUniform4uivEXT, (GLuint program, GLint location, GLsizei count, const GLuint * value), (program, location, count, value), 4, "GLuint", program, "GLint", location, "GLsizei", count, "const GLuint *", value)
+TRACE_GL_VOID(glProgramUniformMatrix2fv, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix2fvEXT, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix2x3fv, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix2x3fvEXT, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix2x4fv, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix2x4fvEXT, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix3fv, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix3fvEXT, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix3x2fv, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix3x2fvEXT, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix3x4fv, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix3x4fvEXT, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix4fv, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix4fvEXT, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix4x2fv, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix4x2fvEXT, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix4x3fv, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glProgramUniformMatrix4x3fvEXT, (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (program, location, count, transpose, value), 5, "GLuint", program, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glPushDebugGroupKHR, (GLenum source, GLuint id, GLsizei length, const GLchar * message), (source, id, length, message), 4, "GLenum", source, "GLuint", id, "GLsizei", length, "const GLchar *", message)
+TRACE_GL_VOID(glPushGroupMarkerEXT, (GLsizei length, const GLchar * marker), (length, marker), 2, "GLsizei", length, "const GLchar *", marker)
 TRACE_GL_VOID(glPushMatrix, (void), (), 0)
-TRACE_GL(GLbitfield, glQueryMatrixxOES, (GLfixed mantissa[16], GLint exponent[16]), (mantissa, exponent), 2, "GLfixed", mantissa, "GLint", exponent)
+TRACE_GL_VOID(glQueryCounterEXT, (GLuint id, GLenum target), (id, target), 2, "GLuint", id, "GLenum", target)
+TRACE_GL(GLbitfield, glQueryMatrixxOES, (GLfixed * mantissa, GLint * exponent), (mantissa, exponent), 2, "GLfixed *", mantissa, "GLint *", exponent)
 TRACE_GL_VOID(glReadBuffer, (GLenum mode), (mode), 1, "GLenum", mode)
+TRACE_GL_VOID(glReadBufferIndexedEXT, (GLenum src, GLint index), (src, index), 2, "GLenum", src, "GLint", index)
 TRACE_GL_VOID(glReadBufferNV, (GLenum mode), (mode), 1, "GLenum", mode)
-TRACE_GL_VOID(glReadPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels), (x, y, width, height, format, type, pixels), 7, "GLint", x, "GLint", y, "GLsizei", width, "GLsizei", height, "GLenum", format, "GLenum", type, "GLvoid *", pixels)
-TRACE_GL_VOID(glReadnPixelsEXT, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data), (x, y, width, height, format, type, bufSize, data), 8, "GLint", x, "GLint", y, "GLsizei", width, "GLsizei", height, "GLenum", format, "GLenum", type, "GLsizei", bufSize, "void *", data)
+TRACE_GL_VOID(glReadPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels), (x, y, width, height, format, type, pixels), 7, "GLint", x, "GLint", y, "GLsizei", width, "GLsizei", height, "GLenum", format, "GLenum", type, "void *", pixels)
+TRACE_GL_VOID(glReadnPixelsEXT, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data), (x, y, width, height, format, type, bufSize, data), 8, "GLint", x, "GLint", y, "GLsizei", width, "GLsizei", height, "GLenum", format, "GLenum", type, "GLsizei", bufSize, "void *", data)
 TRACE_GL_VOID(glReleaseShaderCompiler, (void), (), 0)
 TRACE_GL_VOID(glRenderbufferStorage, (GLenum target, GLenum internalformat, GLsizei width, GLsizei height), (target, internalformat, width, height), 4, "GLenum", target, "GLenum", internalformat, "GLsizei", width, "GLsizei", height)
 TRACE_GL_VOID(glRenderbufferStorageMultisample, (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height), (target, samples, internalformat, width, height), 5, "GLenum", target, "GLsizei", samples, "GLenum", internalformat, "GLsizei", width, "GLsizei", height)
@@ -409,133 +558,175 @@
 TRACE_GL_VOID(glRenderbufferStorageMultisampleAPPLE, (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height), (target, samples, internalformat, width, height), 5, "GLenum", target, "GLsizei", samples, "GLenum", internalformat, "GLsizei", width, "GLsizei", height)
 TRACE_GL_VOID(glRenderbufferStorageMultisampleEXT, (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height), (target, samples, internalformat, width, height), 5, "GLenum", target, "GLsizei", samples, "GLenum", internalformat, "GLsizei", width, "GLsizei", height)
 TRACE_GL_VOID(glRenderbufferStorageMultisampleIMG, (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height), (target, samples, internalformat, width, height), 5, "GLenum", target, "GLsizei", samples, "GLenum", internalformat, "GLsizei", width, "GLsizei", height)
+TRACE_GL_VOID(glRenderbufferStorageMultisampleNV, (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height), (target, samples, internalformat, width, height), 5, "GLenum", target, "GLsizei", samples, "GLenum", internalformat, "GLsizei", width, "GLsizei", height)
 TRACE_GL_VOID(glRenderbufferStorageOES, (GLenum target, GLenum internalformat, GLsizei width, GLsizei height), (target, internalformat, width, height), 4, "GLenum", target, "GLenum", internalformat, "GLsizei", width, "GLsizei", height)
 TRACE_GL_VOID(glResolveMultisampleFramebufferAPPLE, (void), (), 0)
 TRACE_GL_VOID(glResumeTransformFeedback, (void), (), 0)
 TRACE_GL_VOID(glRotatef, (GLfloat angle, GLfloat x, GLfloat y, GLfloat z), (angle, x, y, z), 4, "GLfloat", angle, "GLfloat", x, "GLfloat", y, "GLfloat", z)
 TRACE_GL_VOID(glRotatex, (GLfixed angle, GLfixed x, GLfixed y, GLfixed z), (angle, x, y, z), 4, "GLfixed", angle, "GLfixed", x, "GLfixed", y, "GLfixed", z)
 TRACE_GL_VOID(glRotatexOES, (GLfixed angle, GLfixed x, GLfixed y, GLfixed z), (angle, x, y, z), 4, "GLfixed", angle, "GLfixed", x, "GLfixed", y, "GLfixed", z)
-TRACE_GL_VOID(glSampleCoverage, (GLclampf value, GLboolean invert), (value, invert), 2, "GLclampf", value, "GLboolean", invert)
+TRACE_GL_VOID(glSampleCoverage, (GLfloat value, GLboolean invert), (value, invert), 2, "GLfloat", value, "GLboolean", invert)
+TRACE_GL_VOID(glSampleCoverageOES, (GLfixed value, GLboolean invert), (value, invert), 2, "GLfixed", value, "GLboolean", invert)
 TRACE_GL_VOID(glSampleCoveragex, (GLclampx value, GLboolean invert), (value, invert), 2, "GLclampx", value, "GLboolean", invert)
 TRACE_GL_VOID(glSampleCoveragexOES, (GLclampx value, GLboolean invert), (value, invert), 2, "GLclampx", value, "GLboolean", invert)
+TRACE_GL_VOID(glSampleMaski, (GLuint maskNumber, GLbitfield mask), (maskNumber, mask), 2, "GLuint", maskNumber, "GLbitfield", mask)
+TRACE_GL_VOID(glSamplerParameterIivEXT, (GLuint sampler, GLenum pname, const GLint * param), (sampler, pname, param), 3, "GLuint", sampler, "GLenum", pname, "const GLint *", param)
+TRACE_GL_VOID(glSamplerParameterIuivEXT, (GLuint sampler, GLenum pname, const GLuint * param), (sampler, pname, param), 3, "GLuint", sampler, "GLenum", pname, "const GLuint *", param)
 TRACE_GL_VOID(glSamplerParameterf, (GLuint sampler, GLenum pname, GLfloat param), (sampler, pname, param), 3, "GLuint", sampler, "GLenum", pname, "GLfloat", param)
-TRACE_GL_VOID(glSamplerParameterfv, (GLuint sampler, GLenum pname, const GLfloat* param), (sampler, pname, param), 3, "GLuint", sampler, "GLenum", pname, "const GLfloat*", param)
+TRACE_GL_VOID(glSamplerParameterfv, (GLuint sampler, GLenum pname, const GLfloat * param), (sampler, pname, param), 3, "GLuint", sampler, "GLenum", pname, "const GLfloat *", param)
 TRACE_GL_VOID(glSamplerParameteri, (GLuint sampler, GLenum pname, GLint param), (sampler, pname, param), 3, "GLuint", sampler, "GLenum", pname, "GLint", param)
-TRACE_GL_VOID(glSamplerParameteriv, (GLuint sampler, GLenum pname, const GLint* param), (sampler, pname, param), 3, "GLuint", sampler, "GLenum", pname, "const GLint*", param)
+TRACE_GL_VOID(glSamplerParameteriv, (GLuint sampler, GLenum pname, const GLint * param), (sampler, pname, param), 3, "GLuint", sampler, "GLenum", pname, "const GLint *", param)
 TRACE_GL_VOID(glScalef, (GLfloat x, GLfloat y, GLfloat z), (x, y, z), 3, "GLfloat", x, "GLfloat", y, "GLfloat", z)
 TRACE_GL_VOID(glScalex, (GLfixed x, GLfixed y, GLfixed z), (x, y, z), 3, "GLfixed", x, "GLfixed", y, "GLfixed", z)
 TRACE_GL_VOID(glScalexOES, (GLfixed x, GLfixed y, GLfixed z), (x, y, z), 3, "GLfixed", x, "GLfixed", y, "GLfixed", z)
 TRACE_GL_VOID(glScissor, (GLint x, GLint y, GLsizei width, GLsizei height), (x, y, width, height), 4, "GLint", x, "GLint", y, "GLsizei", width, "GLsizei", height)
-TRACE_GL_VOID(glSelectPerfMonitorCountersAMD, (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList), (monitor, enable, group, numCounters, countersList), 5, "GLuint", monitor, "GLboolean", enable, "GLuint", group, "GLint", numCounters, "GLuint *", countersList)
+TRACE_GL_VOID(glSelectPerfMonitorCountersAMD, (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint * counterList), (monitor, enable, group, numCounters, counterList), 5, "GLuint", monitor, "GLboolean", enable, "GLuint", group, "GLint", numCounters, "GLuint *", counterList)
 TRACE_GL_VOID(glSetFenceNV, (GLuint fence, GLenum condition), (fence, condition), 2, "GLuint", fence, "GLenum", condition)
 TRACE_GL_VOID(glShadeModel, (GLenum mode), (mode), 1, "GLenum", mode)
-TRACE_GL_VOID(glShaderBinary, (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length), (n, shaders, binaryformat, binary, length), 5, "GLsizei", n, "const GLuint*", shaders, "GLenum", binaryformat, "const GLvoid*", binary, "GLsizei", length)
-TRACE_GL_VOID(glShaderSource, (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length), (shader, count, string, length), 4, "GLuint", shader, "GLsizei", count, "const GLchar* const*", string, "const GLint*", length)
+TRACE_GL_VOID(glShaderBinary, (GLsizei count, const GLuint * shaders, GLenum binaryformat, const void * binary, GLsizei length), (count, shaders, binaryformat, binary, length), 5, "GLsizei", count, "const GLuint *", shaders, "GLenum", binaryformat, "const void *", binary, "GLsizei", length)
+TRACE_GL_VOID(glShaderSource, (GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length), (shader, count, string, length), 4, "GLuint", shader, "GLsizei", count, "const GLchar *const*", string, "const GLint *", length)
 TRACE_GL_VOID(glStartTilingQCOM, (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask), (x, y, width, height, preserveMask), 5, "GLuint", x, "GLuint", y, "GLuint", width, "GLuint", height, "GLbitfield", preserveMask)
 TRACE_GL_VOID(glStencilFunc, (GLenum func, GLint ref, GLuint mask), (func, ref, mask), 3, "GLenum", func, "GLint", ref, "GLuint", mask)
 TRACE_GL_VOID(glStencilFuncSeparate, (GLenum face, GLenum func, GLint ref, GLuint mask), (face, func, ref, mask), 4, "GLenum", face, "GLenum", func, "GLint", ref, "GLuint", mask)
 TRACE_GL_VOID(glStencilMask, (GLuint mask), (mask), 1, "GLuint", mask)
 TRACE_GL_VOID(glStencilMaskSeparate, (GLenum face, GLuint mask), (face, mask), 2, "GLenum", face, "GLuint", mask)
 TRACE_GL_VOID(glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass), (fail, zfail, zpass), 3, "GLenum", fail, "GLenum", zfail, "GLenum", zpass)
-TRACE_GL_VOID(glStencilOpSeparate, (GLenum face, GLenum fail, GLenum zfail, GLenum zpass), (face, fail, zfail, zpass), 4, "GLenum", face, "GLenum", fail, "GLenum", zfail, "GLenum", zpass)
+TRACE_GL_VOID(glStencilOpSeparate, (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass), (face, sfail, dpfail, dppass), 4, "GLenum", face, "GLenum", sfail, "GLenum", dpfail, "GLenum", dppass)
 TRACE_GL(GLboolean, glTestFenceNV, (GLuint fence), (fence), 1, "GLuint", fence)
-TRACE_GL_VOID(glTexCoordPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer), (size, type, stride, pointer), 4, "GLint", size, "GLenum", type, "GLsizei", stride, "const GLvoid *", pointer)
+TRACE_GL_VOID(glTexBufferEXT, (GLenum target, GLenum internalformat, GLuint buffer), (target, internalformat, buffer), 3, "GLenum", target, "GLenum", internalformat, "GLuint", buffer)
+TRACE_GL_VOID(glTexBufferRangeEXT, (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size), (target, internalformat, buffer, offset, size), 5, "GLenum", target, "GLenum", internalformat, "GLuint", buffer, "GLintptr", offset, "GLsizeiptr", size)
+TRACE_GL_VOID(glTexCoord1bOES, (GLbyte s), (s), 1, "GLbyte", s)
+TRACE_GL_VOID(glTexCoord1bvOES, (const GLbyte * coords), (coords), 1, "const GLbyte *", coords)
+TRACE_GL_VOID(glTexCoord2bOES, (GLbyte s, GLbyte t), (s, t), 2, "GLbyte", s, "GLbyte", t)
+TRACE_GL_VOID(glTexCoord2bvOES, (const GLbyte * coords), (coords), 1, "const GLbyte *", coords)
+TRACE_GL_VOID(glTexCoord3bOES, (GLbyte s, GLbyte t, GLbyte r), (s, t, r), 3, "GLbyte", s, "GLbyte", t, "GLbyte", r)
+TRACE_GL_VOID(glTexCoord3bvOES, (const GLbyte * coords), (coords), 1, "const GLbyte *", coords)
+TRACE_GL_VOID(glTexCoord4bOES, (GLbyte s, GLbyte t, GLbyte r, GLbyte q), (s, t, r, q), 4, "GLbyte", s, "GLbyte", t, "GLbyte", r, "GLbyte", q)
+TRACE_GL_VOID(glTexCoord4bvOES, (const GLbyte * coords), (coords), 1, "const GLbyte *", coords)
+TRACE_GL_VOID(glTexCoordPointer, (GLint size, GLenum type, GLsizei stride, const void * pointer), (size, type, stride, pointer), 4, "GLint", size, "GLenum", type, "GLsizei", stride, "const void *", pointer)
 TRACE_GL_VOID(glTexEnvf, (GLenum target, GLenum pname, GLfloat param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLfloat", param)
-TRACE_GL_VOID(glTexEnvfv, (GLenum target, GLenum pname, const GLfloat *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfloat *", params)
+TRACE_GL_VOID(glTexEnvfv, (GLenum target, GLenum pname, const GLfloat * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfloat *", params)
 TRACE_GL_VOID(glTexEnvi, (GLenum target, GLenum pname, GLint param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLint", param)
-TRACE_GL_VOID(glTexEnviv, (GLenum target, GLenum pname, const GLint *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLint *", params)
+TRACE_GL_VOID(glTexEnviv, (GLenum target, GLenum pname, const GLint * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLint *", params)
 TRACE_GL_VOID(glTexEnvx, (GLenum target, GLenum pname, GLfixed param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLfixed", param)
 TRACE_GL_VOID(glTexEnvxOES, (GLenum target, GLenum pname, GLfixed param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glTexEnvxv, (GLenum target, GLenum pname, const GLfixed *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glTexEnvxvOES, (GLenum target, GLenum pname, const GLfixed *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfixed *", params)
+TRACE_GL_VOID(glTexEnvxv, (GLenum target, GLenum pname, const GLfixed * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfixed *", params)
+TRACE_GL_VOID(glTexEnvxvOES, (GLenum target, GLenum pname, const GLfixed * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfixed *", params)
 TRACE_GL_VOID(glTexGenfOES, (GLenum coord, GLenum pname, GLfloat param), (coord, pname, param), 3, "GLenum", coord, "GLenum", pname, "GLfloat", param)
-TRACE_GL_VOID(glTexGenfvOES, (GLenum coord, GLenum pname, const GLfloat *params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "const GLfloat *", params)
+TRACE_GL_VOID(glTexGenfvOES, (GLenum coord, GLenum pname, const GLfloat * params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "const GLfloat *", params)
 TRACE_GL_VOID(glTexGeniOES, (GLenum coord, GLenum pname, GLint param), (coord, pname, param), 3, "GLenum", coord, "GLenum", pname, "GLint", param)
-TRACE_GL_VOID(glTexGenivOES, (GLenum coord, GLenum pname, const GLint *params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "const GLint *", params)
+TRACE_GL_VOID(glTexGenivOES, (GLenum coord, GLenum pname, const GLint * params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "const GLint *", params)
 TRACE_GL_VOID(glTexGenxOES, (GLenum coord, GLenum pname, GLfixed param), (coord, pname, param), 3, "GLenum", coord, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glTexGenxvOES, (GLenum coord, GLenum pname, const GLfixed *params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glTexImage2D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels), (target, level, internalformat, width, height, border, format, type, pixels), 9, "GLenum", target, "GLint", level, "GLint", internalformat, "GLsizei", width, "GLsizei", height, "GLint", border, "GLenum", format, "GLenum", type, "const GLvoid *", pixels)
-TRACE_GL_VOID(glTexImage3D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels), (target, level, internalformat, width, height, depth, border, format, type, pixels), 10, "GLenum", target, "GLint", level, "GLint", internalformat, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLint", border, "GLenum", format, "GLenum", type, "const GLvoid*", pixels)
-TRACE_GL_VOID(glTexImage3DOES, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels), (target, level, internalformat, width, height, depth, border, format, type, pixels), 10, "GLenum", target, "GLint", level, "GLenum", internalformat, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLint", border, "GLenum", format, "GLenum", type, "const GLvoid*", pixels)
+TRACE_GL_VOID(glTexGenxvOES, (GLenum coord, GLenum pname, const GLfixed * params), (coord, pname, params), 3, "GLenum", coord, "GLenum", pname, "const GLfixed *", params)
+TRACE_GL_VOID(glTexImage2D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels), (target, level, internalformat, width, height, border, format, type, pixels), 9, "GLenum", target, "GLint", level, "GLint", internalformat, "GLsizei", width, "GLsizei", height, "GLint", border, "GLenum", format, "GLenum", type, "const void *", pixels)
+TRACE_GL_VOID(glTexImage3D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels), (target, level, internalformat, width, height, depth, border, format, type, pixels), 10, "GLenum", target, "GLint", level, "GLint", internalformat, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLint", border, "GLenum", format, "GLenum", type, "const void *", pixels)
+TRACE_GL_VOID(glTexImage3DOES, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels), (target, level, internalformat, width, height, depth, border, format, type, pixels), 10, "GLenum", target, "GLint", level, "GLenum", internalformat, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLint", border, "GLenum", format, "GLenum", type, "const void *", pixels)
+TRACE_GL_VOID(glTexParameterIivEXT, (GLenum target, GLenum pname, const GLint * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLint *", params)
+TRACE_GL_VOID(glTexParameterIuivEXT, (GLenum target, GLenum pname, const GLuint * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLuint *", params)
 TRACE_GL_VOID(glTexParameterf, (GLenum target, GLenum pname, GLfloat param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLfloat", param)
-TRACE_GL_VOID(glTexParameterfv, (GLenum target, GLenum pname, const GLfloat *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfloat *", params)
+TRACE_GL_VOID(glTexParameterfv, (GLenum target, GLenum pname, const GLfloat * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfloat *", params)
 TRACE_GL_VOID(glTexParameteri, (GLenum target, GLenum pname, GLint param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLint", param)
-TRACE_GL_VOID(glTexParameteriv, (GLenum target, GLenum pname, const GLint *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLint *", params)
+TRACE_GL_VOID(glTexParameteriv, (GLenum target, GLenum pname, const GLint * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLint *", params)
 TRACE_GL_VOID(glTexParameterx, (GLenum target, GLenum pname, GLfixed param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLfixed", param)
 TRACE_GL_VOID(glTexParameterxOES, (GLenum target, GLenum pname, GLfixed param), (target, pname, param), 3, "GLenum", target, "GLenum", pname, "GLfixed", param)
-TRACE_GL_VOID(glTexParameterxv, (GLenum target, GLenum pname, const GLfixed *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfixed *", params)
-TRACE_GL_VOID(glTexParameterxvOES, (GLenum target, GLenum pname, const GLfixed *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfixed *", params)
+TRACE_GL_VOID(glTexParameterxv, (GLenum target, GLenum pname, const GLfixed * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfixed *", params)
+TRACE_GL_VOID(glTexParameterxvOES, (GLenum target, GLenum pname, const GLfixed * params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "const GLfixed *", params)
 TRACE_GL_VOID(glTexStorage1DEXT, (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width), (target, levels, internalformat, width), 4, "GLenum", target, "GLsizei", levels, "GLenum", internalformat, "GLsizei", width)
 TRACE_GL_VOID(glTexStorage2D, (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height), (target, levels, internalformat, width, height), 5, "GLenum", target, "GLsizei", levels, "GLenum", internalformat, "GLsizei", width, "GLsizei", height)
 TRACE_GL_VOID(glTexStorage2DEXT, (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height), (target, levels, internalformat, width, height), 5, "GLenum", target, "GLsizei", levels, "GLenum", internalformat, "GLsizei", width, "GLsizei", height)
+TRACE_GL_VOID(glTexStorage2DMultisample, (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations), (target, samples, internalformat, width, height, fixedsamplelocations), 6, "GLenum", target, "GLsizei", samples, "GLenum", internalformat, "GLsizei", width, "GLsizei", height, "GLboolean", fixedsamplelocations)
 TRACE_GL_VOID(glTexStorage3D, (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth), (target, levels, internalformat, width, height, depth), 6, "GLenum", target, "GLsizei", levels, "GLenum", internalformat, "GLsizei", width, "GLsizei", height, "GLsizei", depth)
 TRACE_GL_VOID(glTexStorage3DEXT, (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth), (target, levels, internalformat, width, height, depth), 6, "GLenum", target, "GLsizei", levels, "GLenum", internalformat, "GLsizei", width, "GLsizei", height, "GLsizei", depth)
-TRACE_GL_VOID(glTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels), (target, level, xoffset, yoffset, width, height, format, type, pixels), 9, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLsizei", width, "GLsizei", height, "GLenum", format, "GLenum", type, "const GLvoid *", pixels)
-TRACE_GL_VOID(glTexSubImage3D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels), (target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels), 11, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", zoffset, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLenum", format, "GLenum", type, "const GLvoid*", pixels)
-TRACE_GL_VOID(glTexSubImage3DOES, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels), (target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels), 11, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", zoffset, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLenum", format, "GLenum", type, "const GLvoid*", pixels)
+TRACE_GL_VOID(glTexStorage3DMultisampleOES, (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations), (target, samples, internalformat, width, height, depth, fixedsamplelocations), 7, "GLenum", target, "GLsizei", samples, "GLenum", internalformat, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLboolean", fixedsamplelocations)
+TRACE_GL_VOID(glTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels), (target, level, xoffset, yoffset, width, height, format, type, pixels), 9, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLsizei", width, "GLsizei", height, "GLenum", format, "GLenum", type, "const void *", pixels)
+TRACE_GL_VOID(glTexSubImage3D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels), (target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels), 11, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", zoffset, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLenum", format, "GLenum", type, "const void *", pixels)
+TRACE_GL_VOID(glTexSubImage3DOES, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels), (target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels), 11, "GLenum", target, "GLint", level, "GLint", xoffset, "GLint", yoffset, "GLint", zoffset, "GLsizei", width, "GLsizei", height, "GLsizei", depth, "GLenum", format, "GLenum", type, "const void *", pixels)
 TRACE_GL_VOID(glTextureStorage1DEXT, (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width), (texture, target, levels, internalformat, width), 5, "GLuint", texture, "GLenum", target, "GLsizei", levels, "GLenum", internalformat, "GLsizei", width)
 TRACE_GL_VOID(glTextureStorage2DEXT, (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height), (texture, target, levels, internalformat, width, height), 6, "GLuint", texture, "GLenum", target, "GLsizei", levels, "GLenum", internalformat, "GLsizei", width, "GLsizei", height)
 TRACE_GL_VOID(glTextureStorage3DEXT, (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth), (texture, target, levels, internalformat, width, height, depth), 7, "GLuint", texture, "GLenum", target, "GLsizei", levels, "GLenum", internalformat, "GLsizei", width, "GLsizei", height, "GLsizei", depth)
-TRACE_GL_VOID(glTransformFeedbackVaryings, (GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode), (program, count, varyings, bufferMode), 4, "GLuint", program, "GLsizei", count, "const GLchar* const*", varyings, "GLenum", bufferMode)
+TRACE_GL_VOID(glTextureViewEXT, (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers), (texture, target, origtexture, internalformat, minlevel, numlevels, minlayer, numlayers), 8, "GLuint", texture, "GLenum", target, "GLuint", origtexture, "GLenum", internalformat, "GLuint", minlevel, "GLuint", numlevels, "GLuint", minlayer, "GLuint", numlayers)
+TRACE_GL_VOID(glTransformFeedbackVaryings, (GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode), (program, count, varyings, bufferMode), 4, "GLuint", program, "GLsizei", count, "const GLchar *const*", varyings, "GLenum", bufferMode)
 TRACE_GL_VOID(glTranslatef, (GLfloat x, GLfloat y, GLfloat z), (x, y, z), 3, "GLfloat", x, "GLfloat", y, "GLfloat", z)
 TRACE_GL_VOID(glTranslatex, (GLfixed x, GLfixed y, GLfixed z), (x, y, z), 3, "GLfixed", x, "GLfixed", y, "GLfixed", z)
 TRACE_GL_VOID(glTranslatexOES, (GLfixed x, GLfixed y, GLfixed z), (x, y, z), 3, "GLfixed", x, "GLfixed", y, "GLfixed", z)
-TRACE_GL_VOID(glUniform1f, (GLint location, GLfloat x), (location, x), 2, "GLint", location, "GLfloat", x)
-TRACE_GL_VOID(glUniform1fv, (GLint location, GLsizei count, const GLfloat* v), (location, count, v), 3, "GLint", location, "GLsizei", count, "const GLfloat*", v)
-TRACE_GL_VOID(glUniform1i, (GLint location, GLint x), (location, x), 2, "GLint", location, "GLint", x)
-TRACE_GL_VOID(glUniform1iv, (GLint location, GLsizei count, const GLint* v), (location, count, v), 3, "GLint", location, "GLsizei", count, "const GLint*", v)
+TRACE_GL_VOID(glUniform1f, (GLint location, GLfloat v0), (location, v0), 2, "GLint", location, "GLfloat", v0)
+TRACE_GL_VOID(glUniform1fv, (GLint location, GLsizei count, const GLfloat * value), (location, count, value), 3, "GLint", location, "GLsizei", count, "const GLfloat *", value)
+TRACE_GL_VOID(glUniform1i, (GLint location, GLint v0), (location, v0), 2, "GLint", location, "GLint", v0)
+TRACE_GL_VOID(glUniform1iv, (GLint location, GLsizei count, const GLint * value), (location, count, value), 3, "GLint", location, "GLsizei", count, "const GLint *", value)
 TRACE_GL_VOID(glUniform1ui, (GLint location, GLuint v0), (location, v0), 2, "GLint", location, "GLuint", v0)
-TRACE_GL_VOID(glUniform1uiv, (GLint location, GLsizei count, const GLuint* value), (location, count, value), 3, "GLint", location, "GLsizei", count, "const GLuint*", value)
-TRACE_GL_VOID(glUniform2f, (GLint location, GLfloat x, GLfloat y), (location, x, y), 3, "GLint", location, "GLfloat", x, "GLfloat", y)
-TRACE_GL_VOID(glUniform2fv, (GLint location, GLsizei count, const GLfloat* v), (location, count, v), 3, "GLint", location, "GLsizei", count, "const GLfloat*", v)
-TRACE_GL_VOID(glUniform2i, (GLint location, GLint x, GLint y), (location, x, y), 3, "GLint", location, "GLint", x, "GLint", y)
-TRACE_GL_VOID(glUniform2iv, (GLint location, GLsizei count, const GLint* v), (location, count, v), 3, "GLint", location, "GLsizei", count, "const GLint*", v)
+TRACE_GL_VOID(glUniform1uiv, (GLint location, GLsizei count, const GLuint * value), (location, count, value), 3, "GLint", location, "GLsizei", count, "const GLuint *", value)
+TRACE_GL_VOID(glUniform2f, (GLint location, GLfloat v0, GLfloat v1), (location, v0, v1), 3, "GLint", location, "GLfloat", v0, "GLfloat", v1)
+TRACE_GL_VOID(glUniform2fv, (GLint location, GLsizei count, const GLfloat * value), (location, count, value), 3, "GLint", location, "GLsizei", count, "const GLfloat *", value)
+TRACE_GL_VOID(glUniform2i, (GLint location, GLint v0, GLint v1), (location, v0, v1), 3, "GLint", location, "GLint", v0, "GLint", v1)
+TRACE_GL_VOID(glUniform2iv, (GLint location, GLsizei count, const GLint * value), (location, count, value), 3, "GLint", location, "GLsizei", count, "const GLint *", value)
 TRACE_GL_VOID(glUniform2ui, (GLint location, GLuint v0, GLuint v1), (location, v0, v1), 3, "GLint", location, "GLuint", v0, "GLuint", v1)
-TRACE_GL_VOID(glUniform2uiv, (GLint location, GLsizei count, const GLuint* value), (location, count, value), 3, "GLint", location, "GLsizei", count, "const GLuint*", value)
-TRACE_GL_VOID(glUniform3f, (GLint location, GLfloat x, GLfloat y, GLfloat z), (location, x, y, z), 4, "GLint", location, "GLfloat", x, "GLfloat", y, "GLfloat", z)
-TRACE_GL_VOID(glUniform3fv, (GLint location, GLsizei count, const GLfloat* v), (location, count, v), 3, "GLint", location, "GLsizei", count, "const GLfloat*", v)
-TRACE_GL_VOID(glUniform3i, (GLint location, GLint x, GLint y, GLint z), (location, x, y, z), 4, "GLint", location, "GLint", x, "GLint", y, "GLint", z)
-TRACE_GL_VOID(glUniform3iv, (GLint location, GLsizei count, const GLint* v), (location, count, v), 3, "GLint", location, "GLsizei", count, "const GLint*", v)
+TRACE_GL_VOID(glUniform2uiv, (GLint location, GLsizei count, const GLuint * value), (location, count, value), 3, "GLint", location, "GLsizei", count, "const GLuint *", value)
+TRACE_GL_VOID(glUniform3f, (GLint location, GLfloat v0, GLfloat v1, GLfloat v2), (location, v0, v1, v2), 4, "GLint", location, "GLfloat", v0, "GLfloat", v1, "GLfloat", v2)
+TRACE_GL_VOID(glUniform3fv, (GLint location, GLsizei count, const GLfloat * value), (location, count, value), 3, "GLint", location, "GLsizei", count, "const GLfloat *", value)
+TRACE_GL_VOID(glUniform3i, (GLint location, GLint v0, GLint v1, GLint v2), (location, v0, v1, v2), 4, "GLint", location, "GLint", v0, "GLint", v1, "GLint", v2)
+TRACE_GL_VOID(glUniform3iv, (GLint location, GLsizei count, const GLint * value), (location, count, value), 3, "GLint", location, "GLsizei", count, "const GLint *", value)
 TRACE_GL_VOID(glUniform3ui, (GLint location, GLuint v0, GLuint v1, GLuint v2), (location, v0, v1, v2), 4, "GLint", location, "GLuint", v0, "GLuint", v1, "GLuint", v2)
-TRACE_GL_VOID(glUniform3uiv, (GLint location, GLsizei count, const GLuint* value), (location, count, value), 3, "GLint", location, "GLsizei", count, "const GLuint*", value)
-TRACE_GL_VOID(glUniform4f, (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w), (location, x, y, z, w), 5, "GLint", location, "GLfloat", x, "GLfloat", y, "GLfloat", z, "GLfloat", w)
-TRACE_GL_VOID(glUniform4fv, (GLint location, GLsizei count, const GLfloat* v), (location, count, v), 3, "GLint", location, "GLsizei", count, "const GLfloat*", v)
-TRACE_GL_VOID(glUniform4i, (GLint location, GLint x, GLint y, GLint z, GLint w), (location, x, y, z, w), 5, "GLint", location, "GLint", x, "GLint", y, "GLint", z, "GLint", w)
-TRACE_GL_VOID(glUniform4iv, (GLint location, GLsizei count, const GLint* v), (location, count, v), 3, "GLint", location, "GLsizei", count, "const GLint*", v)
+TRACE_GL_VOID(glUniform3uiv, (GLint location, GLsizei count, const GLuint * value), (location, count, value), 3, "GLint", location, "GLsizei", count, "const GLuint *", value)
+TRACE_GL_VOID(glUniform4f, (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3), (location, v0, v1, v2, v3), 5, "GLint", location, "GLfloat", v0, "GLfloat", v1, "GLfloat", v2, "GLfloat", v3)
+TRACE_GL_VOID(glUniform4fv, (GLint location, GLsizei count, const GLfloat * value), (location, count, value), 3, "GLint", location, "GLsizei", count, "const GLfloat *", value)
+TRACE_GL_VOID(glUniform4i, (GLint location, GLint v0, GLint v1, GLint v2, GLint v3), (location, v0, v1, v2, v3), 5, "GLint", location, "GLint", v0, "GLint", v1, "GLint", v2, "GLint", v3)
+TRACE_GL_VOID(glUniform4iv, (GLint location, GLsizei count, const GLint * value), (location, count, value), 3, "GLint", location, "GLsizei", count, "const GLint *", value)
 TRACE_GL_VOID(glUniform4ui, (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3), (location, v0, v1, v2, v3), 5, "GLint", location, "GLuint", v0, "GLuint", v1, "GLuint", v2, "GLuint", v3)
-TRACE_GL_VOID(glUniform4uiv, (GLint location, GLsizei count, const GLuint* value), (location, count, value), 3, "GLint", location, "GLsizei", count, "const GLuint*", value)
+TRACE_GL_VOID(glUniform4uiv, (GLint location, GLsizei count, const GLuint * value), (location, count, value), 3, "GLint", location, "GLsizei", count, "const GLuint *", value)
 TRACE_GL_VOID(glUniformBlockBinding, (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding), (program, uniformBlockIndex, uniformBlockBinding), 3, "GLuint", program, "GLuint", uniformBlockIndex, "GLuint", uniformBlockBinding)
-TRACE_GL_VOID(glUniformMatrix2fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat*", value)
-TRACE_GL_VOID(glUniformMatrix2x3fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat*", value)
-TRACE_GL_VOID(glUniformMatrix2x4fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat*", value)
-TRACE_GL_VOID(glUniformMatrix3fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat*", value)
-TRACE_GL_VOID(glUniformMatrix3x2fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat*", value)
-TRACE_GL_VOID(glUniformMatrix3x4fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat*", value)
-TRACE_GL_VOID(glUniformMatrix4fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat*", value)
-TRACE_GL_VOID(glUniformMatrix4x2fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat*", value)
-TRACE_GL_VOID(glUniformMatrix4x3fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat*", value)
+TRACE_GL_VOID(glUniformMatrix2fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glUniformMatrix2x3fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glUniformMatrix2x3fvNV, (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glUniformMatrix2x4fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glUniformMatrix2x4fvNV, (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glUniformMatrix3fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glUniformMatrix3x2fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glUniformMatrix3x2fvNV, (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glUniformMatrix3x4fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glUniformMatrix3x4fvNV, (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glUniformMatrix4fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glUniformMatrix4x2fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glUniformMatrix4x2fvNV, (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glUniformMatrix4x3fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
+TRACE_GL_VOID(glUniformMatrix4x3fvNV, (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value), (location, count, transpose, value), 4, "GLint", location, "GLsizei", count, "GLboolean", transpose, "const GLfloat *", value)
 TRACE_GL(GLboolean, glUnmapBuffer, (GLenum target), (target), 1, "GLenum", target)
 TRACE_GL(GLboolean, glUnmapBufferOES, (GLenum target), (target), 1, "GLenum", target)
 TRACE_GL_VOID(glUseProgram, (GLuint program), (program), 1, "GLuint", program)
+TRACE_GL_VOID(glUseProgramStages, (GLuint pipeline, GLbitfield stages, GLuint program), (pipeline, stages, program), 3, "GLuint", pipeline, "GLbitfield", stages, "GLuint", program)
 TRACE_GL_VOID(glUseProgramStagesEXT, (GLuint pipeline, GLbitfield stages, GLuint program), (pipeline, stages, program), 3, "GLuint", pipeline, "GLbitfield", stages, "GLuint", program)
 TRACE_GL_VOID(glValidateProgram, (GLuint program), (program), 1, "GLuint", program)
+TRACE_GL_VOID(glValidateProgramPipeline, (GLuint pipeline), (pipeline), 1, "GLuint", pipeline)
 TRACE_GL_VOID(glValidateProgramPipelineEXT, (GLuint pipeline), (pipeline), 1, "GLuint", pipeline)
-TRACE_GL_VOID(glVertexAttrib1f, (GLuint indx, GLfloat x), (indx, x), 2, "GLuint", indx, "GLfloat", x)
-TRACE_GL_VOID(glVertexAttrib1fv, (GLuint indx, const GLfloat* values), (indx, values), 2, "GLuint", indx, "const GLfloat*", values)
-TRACE_GL_VOID(glVertexAttrib2f, (GLuint indx, GLfloat x, GLfloat y), (indx, x, y), 3, "GLuint", indx, "GLfloat", x, "GLfloat", y)
-TRACE_GL_VOID(glVertexAttrib2fv, (GLuint indx, const GLfloat* values), (indx, values), 2, "GLuint", indx, "const GLfloat*", values)
-TRACE_GL_VOID(glVertexAttrib3f, (GLuint indx, GLfloat x, GLfloat y, GLfloat z), (indx, x, y, z), 4, "GLuint", indx, "GLfloat", x, "GLfloat", y, "GLfloat", z)
-TRACE_GL_VOID(glVertexAttrib3fv, (GLuint indx, const GLfloat* values), (indx, values), 2, "GLuint", indx, "const GLfloat*", values)
-TRACE_GL_VOID(glVertexAttrib4f, (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w), (indx, x, y, z, w), 5, "GLuint", indx, "GLfloat", x, "GLfloat", y, "GLfloat", z, "GLfloat", w)
-TRACE_GL_VOID(glVertexAttrib4fv, (GLuint indx, const GLfloat* values), (indx, values), 2, "GLuint", indx, "const GLfloat*", values)
+TRACE_GL_VOID(glVertex2bOES, (GLbyte x), (x), 1, "GLbyte", x)
+TRACE_GL_VOID(glVertex2bvOES, (const GLbyte * coords), (coords), 1, "const GLbyte *", coords)
+TRACE_GL_VOID(glVertex3bOES, (GLbyte x, GLbyte y), (x, y), 2, "GLbyte", x, "GLbyte", y)
+TRACE_GL_VOID(glVertex3bvOES, (const GLbyte * coords), (coords), 1, "const GLbyte *", coords)
+TRACE_GL_VOID(glVertex4bOES, (GLbyte x, GLbyte y, GLbyte z), (x, y, z), 3, "GLbyte", x, "GLbyte", y, "GLbyte", z)
+TRACE_GL_VOID(glVertex4bvOES, (const GLbyte * coords), (coords), 1, "const GLbyte *", coords)
+TRACE_GL_VOID(glVertexAttrib1f, (GLuint index, GLfloat x), (index, x), 2, "GLuint", index, "GLfloat", x)
+TRACE_GL_VOID(glVertexAttrib1fv, (GLuint index, const GLfloat * v), (index, v), 2, "GLuint", index, "const GLfloat *", v)
+TRACE_GL_VOID(glVertexAttrib2f, (GLuint index, GLfloat x, GLfloat y), (index, x, y), 3, "GLuint", index, "GLfloat", x, "GLfloat", y)
+TRACE_GL_VOID(glVertexAttrib2fv, (GLuint index, const GLfloat * v), (index, v), 2, "GLuint", index, "const GLfloat *", v)
+TRACE_GL_VOID(glVertexAttrib3f, (GLuint index, GLfloat x, GLfloat y, GLfloat z), (index, x, y, z), 4, "GLuint", index, "GLfloat", x, "GLfloat", y, "GLfloat", z)
+TRACE_GL_VOID(glVertexAttrib3fv, (GLuint index, const GLfloat * v), (index, v), 2, "GLuint", index, "const GLfloat *", v)
+TRACE_GL_VOID(glVertexAttrib4f, (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w), (index, x, y, z, w), 5, "GLuint", index, "GLfloat", x, "GLfloat", y, "GLfloat", z, "GLfloat", w)
+TRACE_GL_VOID(glVertexAttrib4fv, (GLuint index, const GLfloat * v), (index, v), 2, "GLuint", index, "const GLfloat *", v)
+TRACE_GL_VOID(glVertexAttribBinding, (GLuint attribindex, GLuint bindingindex), (attribindex, bindingindex), 2, "GLuint", attribindex, "GLuint", bindingindex)
 TRACE_GL_VOID(glVertexAttribDivisor, (GLuint index, GLuint divisor), (index, divisor), 2, "GLuint", index, "GLuint", divisor)
+TRACE_GL_VOID(glVertexAttribDivisorANGLE, (GLuint index, GLuint divisor), (index, divisor), 2, "GLuint", index, "GLuint", divisor)
+TRACE_GL_VOID(glVertexAttribDivisorEXT, (GLuint index, GLuint divisor), (index, divisor), 2, "GLuint", index, "GLuint", divisor)
+TRACE_GL_VOID(glVertexAttribDivisorNV, (GLuint index, GLuint divisor), (index, divisor), 2, "GLuint", index, "GLuint", divisor)
+TRACE_GL_VOID(glVertexAttribFormat, (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset), (attribindex, size, type, normalized, relativeoffset), 5, "GLuint", attribindex, "GLint", size, "GLenum", type, "GLboolean", normalized, "GLuint", relativeoffset)
 TRACE_GL_VOID(glVertexAttribI4i, (GLuint index, GLint x, GLint y, GLint z, GLint w), (index, x, y, z, w), 5, "GLuint", index, "GLint", x, "GLint", y, "GLint", z, "GLint", w)
-TRACE_GL_VOID(glVertexAttribI4iv, (GLuint index, const GLint* v), (index, v), 2, "GLuint", index, "const GLint*", v)
+TRACE_GL_VOID(glVertexAttribI4iv, (GLuint index, const GLint * v), (index, v), 2, "GLuint", index, "const GLint *", v)
 TRACE_GL_VOID(glVertexAttribI4ui, (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w), (index, x, y, z, w), 5, "GLuint", index, "GLuint", x, "GLuint", y, "GLuint", z, "GLuint", w)
-TRACE_GL_VOID(glVertexAttribI4uiv, (GLuint index, const GLuint* v), (index, v), 2, "GLuint", index, "const GLuint*", v)
-TRACE_GL_VOID(glVertexAttribIPointer, (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer), (index, size, type, stride, pointer), 5, "GLuint", index, "GLint", size, "GLenum", type, "GLsizei", stride, "const GLvoid*", pointer)
-TRACE_GL_VOID(glVertexAttribPointer, (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr), (indx, size, type, normalized, stride, ptr), 6, "GLuint", indx, "GLint", size, "GLenum", type, "GLboolean", normalized, "GLsizei", stride, "const GLvoid*", ptr)
-TRACE_GL_VOID(glVertexPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer), (size, type, stride, pointer), 4, "GLint", size, "GLenum", type, "GLsizei", stride, "const GLvoid *", pointer)
+TRACE_GL_VOID(glVertexAttribI4uiv, (GLuint index, const GLuint * v), (index, v), 2, "GLuint", index, "const GLuint *", v)
+TRACE_GL_VOID(glVertexAttribIFormat, (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset), (attribindex, size, type, relativeoffset), 4, "GLuint", attribindex, "GLint", size, "GLenum", type, "GLuint", relativeoffset)
+TRACE_GL_VOID(glVertexAttribIPointer, (GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer), (index, size, type, stride, pointer), 5, "GLuint", index, "GLint", size, "GLenum", type, "GLsizei", stride, "const void *", pointer)
+TRACE_GL_VOID(glVertexAttribPointer, (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer), (index, size, type, normalized, stride, pointer), 6, "GLuint", index, "GLint", size, "GLenum", type, "GLboolean", normalized, "GLsizei", stride, "const void *", pointer)
+TRACE_GL_VOID(glVertexBindingDivisor, (GLuint bindingindex, GLuint divisor), (bindingindex, divisor), 2, "GLuint", bindingindex, "GLuint", divisor)
+TRACE_GL_VOID(glVertexPointer, (GLint size, GLenum type, GLsizei stride, const void * pointer), (size, type, stride, pointer), 4, "GLint", size, "GLenum", type, "GLsizei", stride, "const void *", pointer)
 TRACE_GL_VOID(glViewport, (GLint x, GLint y, GLsizei width, GLsizei height), (x, y, width, height), 4, "GLint", x, "GLint", y, "GLsizei", width, "GLsizei", height)
 TRACE_GL_VOID(glWaitSync, (GLsync sync, GLbitfield flags, GLuint64 timeout), (sync, flags, timeout), 3, "GLsync", sync, "GLbitfield", flags, "GLuint64", timeout)
-TRACE_GL_VOID(glWeightPointerOES, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer), (size, type, stride, pointer), 4, "GLint", size, "GLenum", type, "GLsizei", stride, "const GLvoid *", pointer)
+TRACE_GL_VOID(glWaitSyncAPPLE, (GLsync sync, GLbitfield flags, GLuint64 timeout), (sync, flags, timeout), 3, "GLsync", sync, "GLbitfield", flags, "GLuint64", timeout)
+TRACE_GL_VOID(glWeightPointerOES, (GLint size, GLenum type, GLsizei stride, const void * pointer), (size, type, stride, pointer), 4, "GLint", size, "GLenum", type, "GLsizei", stride, "const void *", pointer)
diff --git a/opengl/tests/EGLTest/Android.mk b/opengl/tests/EGLTest/Android.mk
index f37efec..80e4867 100644
--- a/opengl/tests/EGLTest/Android.mk
+++ b/opengl/tests/EGLTest/Android.mk
@@ -1,6 +1,7 @@
 # Build the unit tests.
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 
 LOCAL_MODULE := EGL_test
 
@@ -14,27 +15,18 @@
 	libEGL \
 	libcutils \
 	libbinder \
-	libstlport \
 	libutils \
 	libgui \
 
-LOCAL_STATIC_LIBRARIES := \
-	libgtest \
-	libgtest_main \
-
 LOCAL_C_INCLUDES := \
-    bionic \
     bionic/libc/private \
-    bionic/libstdc++/include \
-    external/gtest/include \
-    external/stlport/stlport \
     frameworks/native/opengl/libs \
     frameworks/native/opengl/libs/EGL \
 
 # gold in binutils 2.22 will warn about the usage of mktemp
 LOCAL_LDFLAGS += -Wl,--no-fatal-warnings
 
-include $(BUILD_EXECUTABLE)
+include $(BUILD_NATIVE_TEST)
 
 # Include subdirectory makefiles
 # ============================================================
diff --git a/opengl/tests/EGLTest/EGL_test.cpp b/opengl/tests/EGLTest/EGL_test.cpp
index f6644fb..d69a275 100644
--- a/opengl/tests/EGLTest/EGL_test.cpp
+++ b/opengl/tests/EGLTest/EGL_test.cpp
@@ -101,14 +101,17 @@
     EXPECT_TRUE(eglChooseConfig(mEglDisplay, attrs, &config, 1, &numConfigs));
 
     struct DummyConsumer : public BnConsumerListener {
-        virtual void onFrameAvailable() {}
+        virtual void onFrameAvailable(const BufferItem& /* item */) {}
         virtual void onBuffersReleased() {}
+        virtual void onSidebandStreamChanged() {}
     };
 
     // Create a EGLSurface
-    sp<BufferQueue> bq = new BufferQueue();
-    bq->consumerConnect(new DummyConsumer, false);
-    sp<Surface> mSTC = new Surface(static_cast<sp<IGraphicBufferProducer> >( bq));
+    sp<IGraphicBufferProducer> producer;
+    sp<IGraphicBufferConsumer> consumer;
+    BufferQueue::createBufferQueue(&producer, &consumer);
+    consumer->consumerConnect(new DummyConsumer, false);
+    sp<Surface> mSTC = new Surface(producer);
     sp<ANativeWindow> mANW = mSTC;
 
     EGLSurface eglSurface = eglCreateWindowSurface(mEglDisplay, config,
diff --git a/opengl/tests/EGLTest/egl_cache_test.cpp b/opengl/tests/EGLTest/egl_cache_test.cpp
index c7d9e3e..c5bf296 100644
--- a/opengl/tests/EGLTest/egl_cache_test.cpp
+++ b/opengl/tests/EGLTest/egl_cache_test.cpp
@@ -41,7 +41,7 @@
 };
 
 TEST_F(EGLCacheTest, UninitializedCacheAlwaysMisses) {
-    char buf[4] = { 0xee, 0xee, 0xee, 0xee };
+    uint8_t buf[4] = { 0xee, 0xee, 0xee, 0xee };
     mCache->setBlob("abcd", 4, "efgh", 4);
     ASSERT_EQ(0, mCache->getBlob("abcd", 4, buf, 4));
     ASSERT_EQ(0xee, buf[0]);
@@ -51,7 +51,7 @@
 }
 
 TEST_F(EGLCacheTest, InitializedCacheAlwaysHits) {
-    char buf[4] = { 0xee, 0xee, 0xee, 0xee };
+    uint8_t buf[4] = { 0xee, 0xee, 0xee, 0xee };
     mCache->initialize(egl_display_t::get(EGL_DEFAULT_DISPLAY));
     mCache->setBlob("abcd", 4, "efgh", 4);
     ASSERT_EQ(4, mCache->getBlob("abcd", 4, buf, 4));
@@ -62,7 +62,7 @@
 }
 
 TEST_F(EGLCacheTest, TerminatedCacheAlwaysMisses) {
-    char buf[4] = { 0xee, 0xee, 0xee, 0xee };
+    uint8_t buf[4] = { 0xee, 0xee, 0xee, 0xee };
     mCache->initialize(egl_display_t::get(EGL_DEFAULT_DISPLAY));
     mCache->setBlob("abcd", 4, "efgh", 4);
     mCache->terminate();
@@ -94,7 +94,7 @@
 };
 
 TEST_F(EGLCacheSerializationTest, ReinitializedCacheContainsValues) {
-    char buf[4] = { 0xee, 0xee, 0xee, 0xee };
+    uint8_t buf[4] = { 0xee, 0xee, 0xee, 0xee };
     mCache->setCacheFilename(mFilename);
     mCache->initialize(egl_display_t::get(EGL_DEFAULT_DISPLAY));
     mCache->setBlob("abcd", 4, "efgh", 4);
diff --git a/opengl/tests/angeles/Android.mk b/opengl/tests/angeles/Android.mk
index ae4f76d..c78224e 100644
--- a/opengl/tests/angeles/Android.mk
+++ b/opengl/tests/angeles/Android.mk
@@ -3,7 +3,8 @@
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES:= app-linux.cpp demo.c.arm
-LOCAL_SHARED_LIBRARIES := libEGL libGLESv1_CM libui
+LOCAL_SHARED_LIBRARIES := libEGL libGLESv1_CM libui libgui libutils
+LOCAL_STATIC_LIBRARIES += libglTest
 LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes)
 LOCAL_MODULE:= angeles
 LOCAL_MODULE_TAGS := optional
diff --git a/opengl/tests/angeles/app-linux.cpp b/opengl/tests/angeles/app-linux.cpp
index 6ac68a2..ced8786 100644
--- a/opengl/tests/angeles/app-linux.cpp
+++ b/opengl/tests/angeles/app-linux.cpp
@@ -52,8 +52,8 @@
 #include <EGL/egl.h>
 #include <GLES/gl.h>
 
-#include <ui/FramebufferNativeWindow.h>
-#include "EGLUtils.h"
+#include <EGLUtils.h>
+#include <WindowSurface.h>
 
 using namespace android;
 
@@ -118,7 +118,7 @@
         fprintf(stderr, "EGL Error: 0x%04x\n", (int)error);
 }
 
-static int initGraphics(unsigned samples)
+static int initGraphics(EGLint samples, const WindowSurface& windowSurface)
 {
     EGLint configAttribs[] = {
             EGL_DEPTH_SIZE, 16,
@@ -135,7 +135,7 @@
     EGLint w, h;
     EGLDisplay dpy;
 
-    EGLNativeWindowType window = android_createDisplaySurface();
+    EGLNativeWindowType window = windowSurface.getSurface();
 
     dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
     eglInitialize(dpy, &majorVersion, &minorVersion);
@@ -193,7 +193,8 @@
         printf("Multisample enabled: GL_SAMPLES = %u\n", samples);
     }
 
-    if (!initGraphics(samples))
+    WindowSurface windowSurface;
+    if (!initGraphics(samples, windowSurface))
     {
         fprintf(stderr, "Graphics initialization failed.\n");
         return EXIT_FAILURE;
diff --git a/opengl/tests/angeles/demo.c b/opengl/tests/angeles/demo.c
index 802f398..39d871e 100644
--- a/opengl/tests/angeles/demo.c
+++ b/opengl/tests/angeles/demo.c
@@ -666,7 +666,7 @@
         y[2] /= mag;
     }
 
-#define M(row,col)  m[col*4+row]
+#define M(row,col)  m[(col)*4+(row)]
     M(0, 0) = x[0];
     M(0, 1) = x[1];
     M(0, 2) = x[2];
diff --git a/opengl/tests/fillrate/Android.mk b/opengl/tests/fillrate/Android.mk
index 4dade21..21ff52a 100644
--- a/opengl/tests/fillrate/Android.mk
+++ b/opengl/tests/fillrate/Android.mk
@@ -9,7 +9,10 @@
 	libutils \
     libEGL \
     libGLESv1_CM \
-    libui
+    libui \
+    libgui
+
+LOCAL_STATIC_LIBRARIES += libglTest
 
 LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes)
 
diff --git a/opengl/tests/fillrate/fillrate.cpp b/opengl/tests/fillrate/fillrate.cpp
index a708647..2db63d7 100644
--- a/opengl/tests/fillrate/fillrate.cpp
+++ b/opengl/tests/fillrate/fillrate.cpp
@@ -25,8 +25,8 @@
 #include <GLES/glext.h>
 
 #include <utils/StopWatch.h>
-#include <ui/FramebufferNativeWindow.h>
-#include "EGLUtils.h"
+#include <WindowSurface.h>
+#include <EGLUtils.h>
 
 using namespace android;
 
@@ -45,7 +45,8 @@
      EGLint w, h;
      EGLDisplay dpy;
 
-     EGLNativeWindowType window = android_createDisplaySurface();
+     WindowSurface windowSurface;
+     EGLNativeWindowType window = windowSurface.getSurface();
      
      dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
      eglInitialize(dpy, &majorVersion, &minorVersion);
@@ -90,11 +91,13 @@
          }
      }
 
+     const GLfloat fh = h;
+     const GLfloat fw = w;
      const GLfloat vertices[4][2] = {
-             { 0,  0 },
-             { 0,  h },
-             { w,  h },
-             { w,  0 }
+             { 0,   0  },
+             { 0,   fh },
+             { fw,  fh },
+             { fw,  0  }
      };
 
      const GLfloat texCoords[4][2] = {
diff --git a/opengl/tests/filter/Android.mk b/opengl/tests/filter/Android.mk
index d3e4d38..4cf9c96 100644
--- a/opengl/tests/filter/Android.mk
+++ b/opengl/tests/filter/Android.mk
@@ -8,7 +8,11 @@
 	libcutils \
     libEGL \
     libGLESv1_CM \
-    libui
+    libui \
+    libgui \
+    libutils
+
+LOCAL_STATIC_LIBRARIES += libglTest
 
 LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes)
 
diff --git a/opengl/tests/filter/filter.cpp b/opengl/tests/filter/filter.cpp
index 0067327..287ee93 100644
--- a/opengl/tests/filter/filter.cpp
+++ b/opengl/tests/filter/filter.cpp
@@ -5,8 +5,8 @@
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
-#include <ui/FramebufferNativeWindow.h>
-#include "EGLUtils.h"
+#include <WindowSurface.h>
+#include <EGLUtils.h>
 
 using namespace android;
 
@@ -40,8 +40,10 @@
      EGLDisplay dpy;
 
      EGLNativeWindowType window = 0;
+     WindowSurface* windowSurface = NULL;
      if (!usePbuffer) {
-         window = android_createDisplaySurface();
+         windowSurface = new WindowSurface();
+         window = windowSurface->getSurface();
      }
      
      dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
@@ -138,11 +140,12 @@
 
      //glDrawTexiOES(0, 0, 0, dim, dim);
      
+     const GLfloat fdim = dim;
      const GLfloat vertices[4][2] = {
-             { 0,    0   },
-             { 0,    dim },
-             { dim,  dim },
-             { dim,  0   }
+             { 0,     0    },
+             { 0,     fdim },
+             { fdim,  fdim },
+             { fdim,  0    }
      };
 
      const GLfloat texCoords[4][2] = {
@@ -186,5 +189,6 @@
      }
 
      eglTerminate(dpy);
+     delete windowSurface;
      return 0;
 }
diff --git a/opengl/tests/finish/Android.mk b/opengl/tests/finish/Android.mk
index aa8adca..0b9b7ea 100644
--- a/opengl/tests/finish/Android.mk
+++ b/opengl/tests/finish/Android.mk
@@ -9,7 +9,10 @@
 	libutils \
     libEGL \
     libGLESv1_CM \
-    libui
+    libui \
+    libgui
+
+LOCAL_STATIC_LIBRARIES += libglTest
 
 LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes)
 
diff --git a/opengl/tests/finish/finish.cpp b/opengl/tests/finish/finish.cpp
index 11f0c22..ea3a60f 100644
--- a/opengl/tests/finish/finish.cpp
+++ b/opengl/tests/finish/finish.cpp
@@ -26,8 +26,8 @@
 
 #include <utils/Timers.h>
 
-#include <ui/FramebufferNativeWindow.h>
-#include "EGLUtils.h"
+#include <WindowSurface.h>
+#include <EGLUtils.h>
 
 using namespace android;
 
@@ -46,7 +46,8 @@
      EGLint w, h;
      EGLDisplay dpy;
 
-     EGLNativeWindowType window = android_createDisplaySurface();
+     WindowSurface windowSurface;
+     EGLNativeWindowType window = windowSurface.getSurface();
      
      dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
      eglInitialize(dpy, &majorVersion, &minorVersion);
diff --git a/opengl/tests/gl2_basic/Android.mk b/opengl/tests/gl2_basic/Android.mk
index d7819a1..520395c 100644
--- a/opengl/tests/gl2_basic/Android.mk
+++ b/opengl/tests/gl2_basic/Android.mk
@@ -8,7 +8,11 @@
 	libcutils \
     libEGL \
     libGLESv2 \
-    libui
+    libui \
+    libgui \
+    libutils
+
+LOCAL_STATIC_LIBRARIES += libglTest
 
 LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes)
 
diff --git a/opengl/tests/gl2_basic/gl2_basic.cpp b/opengl/tests/gl2_basic/gl2_basic.cpp
index 7007871..cdbf1cf 100644
--- a/opengl/tests/gl2_basic/gl2_basic.cpp
+++ b/opengl/tests/gl2_basic/gl2_basic.cpp
@@ -26,8 +26,8 @@
 
 #include <utils/Timers.h>
 
-#include <ui/FramebufferNativeWindow.h>
-#include "EGLUtils.h"
+#include <WindowSurface.h>
+#include <EGLUtils.h>
 
 using namespace android;
 
@@ -298,7 +298,8 @@
 
     checkEglError("printEGLConfigurations");
 
-    EGLNativeWindowType window = android_createDisplaySurface();

+    WindowSurface windowSurface;
+    EGLNativeWindowType window = windowSurface.getSurface();
     returnValue = EGLUtils::selectConfigForNativeWindow(dpy, s_configAttribs, window, &myConfig);
     if (returnValue) {
         printf("EGLUtils::selectConfigForNativeWindow() returned %d", returnValue);
diff --git a/opengl/tests/gl2_copyTexImage/Android.mk b/opengl/tests/gl2_copyTexImage/Android.mk
index 005c383..ff43558 100644
--- a/opengl/tests/gl2_copyTexImage/Android.mk
+++ b/opengl/tests/gl2_copyTexImage/Android.mk
@@ -8,7 +8,11 @@
 	libcutils \
     libEGL \
     libGLESv2 \
-    libui
+    libui \
+    libgui \
+    libutils
+
+LOCAL_STATIC_LIBRARIES += libglTest
 
 LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes)
 
diff --git a/opengl/tests/gl2_copyTexImage/gl2_copyTexImage.cpp b/opengl/tests/gl2_copyTexImage/gl2_copyTexImage.cpp
index 988d7ac..405a3f0 100644
--- a/opengl/tests/gl2_copyTexImage/gl2_copyTexImage.cpp
+++ b/opengl/tests/gl2_copyTexImage/gl2_copyTexImage.cpp
@@ -26,8 +26,8 @@
 
 #include <utils/Timers.h>
 
-#include <ui/FramebufferNativeWindow.h>
-#include "EGLUtils.h"
+#include <WindowSurface.h>
+#include <EGLUtils.h>
 
 using namespace android;
 
@@ -406,7 +406,8 @@
 
     checkEglError("printEGLConfigurations");
 
-    EGLNativeWindowType window = android_createDisplaySurface();
+    WindowSurface windowSurface;
+    EGLNativeWindowType window = windowSurface.getSurface();
     EGLint numConfigs = -1, n = 0;
     eglChooseConfig(dpy, s_configAttribs, 0, 0, &numConfigs);
     if (numConfigs) {
diff --git a/opengl/tests/gl2_yuvtex/Android.mk b/opengl/tests/gl2_yuvtex/Android.mk
index bb3cc0c..42cf771 100644
--- a/opengl/tests/gl2_yuvtex/Android.mk
+++ b/opengl/tests/gl2_yuvtex/Android.mk
@@ -9,7 +9,11 @@
     libEGL \
     libGLESv2 \
     libutils \
-    libui
+    libui \
+    libgui \
+    libutils
+
+LOCAL_STATIC_LIBRARIES += libglTest
 
 LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes)
 
diff --git a/opengl/tests/gl2_yuvtex/gl2_yuvtex.cpp b/opengl/tests/gl2_yuvtex/gl2_yuvtex.cpp
index d3e4932..98d8aa8 100644
--- a/opengl/tests/gl2_yuvtex/gl2_yuvtex.cpp
+++ b/opengl/tests/gl2_yuvtex/gl2_yuvtex.cpp
@@ -27,9 +27,9 @@
 
 #include <utils/Timers.h>
 
-#include <ui/FramebufferNativeWindow.h>
+#include <WindowSurface.h>
 #include <ui/GraphicBuffer.h>
-#include "EGLUtils.h"
+#include <EGLUtils.h>
 
 using namespace android;
 
@@ -364,7 +364,8 @@
         return 0;
     }
 
-    EGLNativeWindowType window = android_createDisplaySurface();
+    WindowSurface windowSurface;
+    EGLNativeWindowType window = windowSurface.getSurface();
     returnValue = EGLUtils::selectConfigForNativeWindow(dpy, s_configAttribs, window, &myConfig);
     if (returnValue) {
         printf("EGLUtils::selectConfigForNativeWindow() returned %d", returnValue);
diff --git a/opengl/tests/gl_basic/Android.mk b/opengl/tests/gl_basic/Android.mk
index 46bcc60..7f2259e 100644
--- a/opengl/tests/gl_basic/Android.mk
+++ b/opengl/tests/gl_basic/Android.mk
@@ -8,7 +8,11 @@
 	libcutils \
     libEGL \
     libGLESv1_CM \
-    libui
+    libui \
+    libgui \
+    libutils
+
+LOCAL_STATIC_LIBRARIES += libglTest
 
 LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes)
 
diff --git a/opengl/tests/gl_basic/gl_basic.cpp b/opengl/tests/gl_basic/gl_basic.cpp
index 23ce934..e50d88f 100644
--- a/opengl/tests/gl_basic/gl_basic.cpp
+++ b/opengl/tests/gl_basic/gl_basic.cpp
@@ -5,8 +5,8 @@
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
-#include <ui/FramebufferNativeWindow.h>
-#include "EGLUtils.h"
+#include <WindowSurface.h>
+#include <EGLUtils.h>
 
 #include <stdio.h>
 
@@ -23,7 +23,7 @@
 #define FIXED_ONE 0x10000
 #define ITERATIONS 50
 
-int init_gl_surface(void);
+int init_gl_surface(const WindowSurface& windowSurface);
 void free_gl_surface(void);
 void init_scene(void);
 void render();
@@ -194,7 +194,8 @@
     int q;
     int start, end;
     printf("Initializing EGL...\n");
-    if(!init_gl_surface())
+    WindowSurface windowSurface;
+    if(!init_gl_surface(windowSurface))
     {
         printf("GL initialisation failed - exiting\n");
         return 0;
@@ -209,7 +210,7 @@
     return 0;
 }
 
-int init_gl_surface(void)
+int init_gl_surface(const WindowSurface& windowSurface)
 {
     EGLint numConfigs = 1;
     EGLConfig myConfig = {0};
@@ -236,7 +237,7 @@
         return 0;
     }
 
-    EGLNativeWindowType window = android_createDisplaySurface();
+    EGLNativeWindowType window = windowSurface.getSurface();
     EGLUtils::selectConfigForNativeWindow(eglDisplay, attrib, window, &myConfig);
 
     if ( (eglSurface = eglCreateWindowSurface(eglDisplay, myConfig,
diff --git a/opengl/tests/gl_perf/Android.mk b/opengl/tests/gl_perf/Android.mk
index b0f825c..9a93fab 100644
--- a/opengl/tests/gl_perf/Android.mk
+++ b/opengl/tests/gl_perf/Android.mk
@@ -10,7 +10,11 @@
     liblog \
     libEGL \
     libGLESv2 \
-    libui
+    libui \
+    libgui \
+    libutils
+
+LOCAL_STATIC_LIBRARIES += libglTest
 
 LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes)
 
diff --git a/opengl/tests/gl_perf/gl2_perf.cpp b/opengl/tests/gl_perf/gl2_perf.cpp
index 224acaf..35df84f 100644
--- a/opengl/tests/gl_perf/gl2_perf.cpp
+++ b/opengl/tests/gl_perf/gl2_perf.cpp
@@ -26,8 +26,8 @@
 
 #include <utils/Timers.h>
 
-#include <ui/FramebufferNativeWindow.h>
-#include "EGLUtils.h"
+#include <WindowSurface.h>
+#include <EGLUtils.h>
 
 using namespace android;
 
@@ -86,7 +86,8 @@
         return 0;
     }
 
-    EGLNativeWindowType window = android_createDisplaySurface();

+    WindowSurface windowSurface;
+    EGLNativeWindowType window = windowSurface.getSurface();
     returnValue = EGLUtils::selectConfigForNativeWindow(dpy, s_configAttribs, window, &myConfig);
     if (returnValue) {
         printf("EGLUtils::selectConfigForNativeWindow() returned %d", returnValue);
diff --git a/opengl/tests/gl_perfapp/jni/gl_code.cpp b/opengl/tests/gl_perfapp/jni/gl_code.cpp
index 2f04183..378c8e8 100644
--- a/opengl/tests/gl_perfapp/jni/gl_code.cpp
+++ b/opengl/tests/gl_perfapp/jni/gl_code.cpp
@@ -26,8 +26,6 @@
 // The stateClock starts at zero and increments by 1 every time we draw a frame. It is used to control which phase of the test we are in.
 
 int stateClock;
-const int doLoopStates = 2;
-const int doSingleTestStates = 2;
 bool done;
 
 // Saves the parameters of the test (so we can print them out when we finish the timing.)
diff --git a/opengl/tests/gl_yuvtex/Android.mk b/opengl/tests/gl_yuvtex/Android.mk
index e0e2c16..7f2020a 100644
--- a/opengl/tests/gl_yuvtex/Android.mk
+++ b/opengl/tests/gl_yuvtex/Android.mk
@@ -9,7 +9,10 @@
     libEGL \
     libGLESv1_CM \
     libutils \
-    libui
+    libui \
+    libgui
+
+LOCAL_STATIC_LIBRARIES += libglTest
 
 LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes)
 
diff --git a/opengl/tests/gl_yuvtex/gl_yuvtex.cpp b/opengl/tests/gl_yuvtex/gl_yuvtex.cpp
index 7a00f76..c923b07 100644
--- a/opengl/tests/gl_yuvtex/gl_yuvtex.cpp
+++ b/opengl/tests/gl_yuvtex/gl_yuvtex.cpp
@@ -27,9 +27,9 @@
 
 #include <utils/Timers.h>
 
-#include <ui/FramebufferNativeWindow.h>
+#include <WindowSurface.h>
 #include <ui/GraphicBuffer.h>
-#include "EGLUtils.h"
+#include <EGLUtils.h>
 
 using namespace android;
 
@@ -254,7 +254,8 @@
         return 0;
     }
 
-    EGLNativeWindowType window = android_createDisplaySurface();
+    WindowSurface windowSurface;
+    EGLNativeWindowType window = windowSurface.getSurface();
     returnValue = EGLUtils::selectConfigForNativeWindow(dpy, s_configAttribs, window, &myConfig);
     if (returnValue) {
         printf("EGLUtils::selectConfigForNativeWindow() returned %d", returnValue);
diff --git a/opengl/tests/hwc/Android.mk b/opengl/tests/hwc/Android.mk
index 2fdfcf8..f83846b 100644
--- a/opengl/tests/hwc/Android.mk
+++ b/opengl/tests/hwc/Android.mk
@@ -15,24 +15,25 @@
 LOCAL_PATH:= $(call my-dir)
 
 include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+
 LOCAL_MODULE_TAGS := tests
 LOCAL_MODULE:= libhwcTest
+LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
+LOCAL_CXX_STL := libc++
 LOCAL_SRC_FILES:= hwcTestLib.cpp
 LOCAL_C_INCLUDES += system/extras/tests/include \
-    bionic \
-    bionic/libstdc++/include \
-    external/stlport/stlport \
-	$(call include-path-for, opengl-tests-includes)
-
-LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
-
-LOCAL_SHARED_LIBRARIES += libcutils libutils libstlport
-LOCAL_STATIC_LIBRARIES += libglTest
-
+    $(call include-path-for, opengl-tests-includes) \
 
 include $(BUILD_STATIC_LIBRARY)
 
 include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+
+LOCAL_MODULE:= hwcStress
+LOCAL_MODULE_TAGS := tests
+LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
+LOCAL_CXX_STL := libc++
 LOCAL_SRC_FILES:= hwcStress.cpp
 
 LOCAL_SHARED_LIBRARIES := \
@@ -52,20 +53,17 @@
 LOCAL_C_INCLUDES += \
     system/extras/tests/include \
     hardware/libhardware/include \
-	$(call include-path-for, opengl-tests-includes)
-
-LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
-
-LOCAL_MODULE:= hwcStress
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativestresstest
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
+    $(call include-path-for, opengl-tests-includes) \
 
 include $(BUILD_NATIVE_TEST)
 
 include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+
+LOCAL_MODULE:= hwcRects
+LOCAL_MODULE_TAGS := tests
+LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
+LOCAL_CXX_STL := libc++
 LOCAL_SRC_FILES:= hwcRects.cpp
 
 LOCAL_SHARED_LIBRARIES := \
@@ -85,18 +83,17 @@
 LOCAL_C_INCLUDES += \
     system/extras/tests/include \
     hardware/libhardware/include \
-	$(call include-path-for, opengl-tests-includes)
-
-LOCAL_MODULE:= hwcRects
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativeutil
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
+    $(call include-path-for, opengl-tests-includes) \
 
 include $(BUILD_NATIVE_TEST)
 
 include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+
+LOCAL_MODULE:= hwcColorEquiv
+LOCAL_MODULE_TAGS := tests
+LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
+LOCAL_CXX_STL := libc++
 LOCAL_SRC_FILES:= hwcColorEquiv.cpp
 
 LOCAL_SHARED_LIBRARIES := \
@@ -116,18 +113,17 @@
 LOCAL_C_INCLUDES += \
     system/extras/tests/include \
     hardware/libhardware/include \
-	$(call include-path-for, opengl-tests-includes)
-
-LOCAL_MODULE:= hwcColorEquiv
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativeutil
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
+    $(call include-path-for, opengl-tests-includes) \
 
 include $(BUILD_NATIVE_TEST)
 
 include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+
+LOCAL_MODULE:= hwcCommit
+LOCAL_MODULE_TAGS := tests
+LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
+LOCAL_CXX_STL := libc++
 LOCAL_SRC_FILES:= hwcCommit.cpp
 
 LOCAL_SHARED_LIBRARIES := \
@@ -147,13 +143,6 @@
 LOCAL_C_INCLUDES += \
     system/extras/tests/include \
     hardware/libhardware/include \
-	$(call include-path-for, opengl-tests-includes)
-
-LOCAL_MODULE:= hwcCommit
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativebenchmark
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
+    $(call include-path-for, opengl-tests-includes) \
 
 include $(BUILD_NATIVE_TEST)
diff --git a/opengl/tests/hwc/hwcColorEquiv.cpp b/opengl/tests/hwc/hwcColorEquiv.cpp
index 160906d..085f374 100644
--- a/opengl/tests/hwc/hwcColorEquiv.cpp
+++ b/opengl/tests/hwc/hwcColorEquiv.cpp
@@ -85,7 +85,6 @@
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 
-#include <ui/FramebufferNativeWindow.h>
 #include <ui/GraphicBuffer.h>
 
 #define LOG_TAG "hwcColorEquivTest"
@@ -116,7 +115,7 @@
 #define CMD_START_FRAMEWORK  "start 2>&1"
 
 // Macros
-#define NUMA(a) (sizeof(a) / sizeof(a [0])) // Num elements in an array
+#define NUMA(a) (sizeof(a) / sizeof((a)[0])) // Num elements in an array
 #define MEMCLR(addr, size) do { \
         memset((addr), 0, (size)); \
     } while (0)
@@ -167,7 +166,6 @@
     int rv, opt;
     bool error;
     char *chptr;
-    unsigned int pass;
     char cmd[MAXCMD];
     string str;
 
@@ -294,14 +292,12 @@
     // Use the upper third of the display for the reference frame and
     // the middle third for the equivalence frame.
     unsigned int refHeight = height / 3;
-    unsigned int refPosY = 0; // Reference frame Y position
     unsigned int refPosX = 0; // Reference frame X position
     unsigned int refWidth = width - refPosX;
     if ((refWidth & refFormat->wMod) != 0) {
         refWidth += refFormat->wMod - (refWidth % refFormat->wMod);
     }
     unsigned int equivHeight = height / 3;
-    unsigned int equivPosY = refHeight; // Equivalence frame Y position
     unsigned int equivPosX = 0;         // Equivalence frame X position
     unsigned int equivWidth = width - equivPosX;
     if ((equivWidth & equivFormat->wMod) != 0) {
diff --git a/opengl/tests/hwc/hwcCommit.cpp b/opengl/tests/hwc/hwcCommit.cpp
index 3681fbb..6005b99 100644
--- a/opengl/tests/hwc/hwcCommit.cpp
+++ b/opengl/tests/hwc/hwcCommit.cpp
@@ -96,7 +96,6 @@
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 
-#include <ui/FramebufferNativeWindow.h>
 #include <ui/GraphicBuffer.h>
 
 #define LOG_TAG "hwcCommitTest"
@@ -158,12 +157,12 @@
 #define CMD_START_FRAMEWORK  "start 2>&1"
 
 // Macros
-#define NUMA(a) (sizeof(a) / sizeof(a [0])) // Num elements in an array
+#define NUMA(a) (sizeof(a) / sizeof((a)[0])) // Num elements in an array
 
 // Local types
 class Rectangle {
 public:
-    Rectangle(uint32_t graphicFormat = defaultFormat,
+    explicit Rectangle(uint32_t graphicFormat = defaultFormat,
               HwcTestDim dfDim = HwcTestDim(1, 1),
               HwcTestDim sDim = HwcTestDim(1, 1));
     void setSourceDim(HwcTestDim dim);
@@ -339,7 +338,6 @@
 main(int argc, char *argv[])
 {
     int     rv, opt;
-    char   *chptr;
     bool    error;
     string  str;
     char cmd[MAXCMD];
diff --git a/opengl/tests/hwc/hwcRects.cpp b/opengl/tests/hwc/hwcRects.cpp
index ec0403f..ba242ab 100644
--- a/opengl/tests/hwc/hwcRects.cpp
+++ b/opengl/tests/hwc/hwcRects.cpp
@@ -104,7 +104,6 @@
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 
-#include <ui/FramebufferNativeWindow.h>
 #include <ui/GraphicBuffer.h>
 
 #define LOG_TAG "hwcRectsTest"
@@ -138,7 +137,7 @@
 #define CMD_START_FRAMEWORK  "start 2>&1"
 
 // Macros
-#define NUMA(a) (sizeof(a) / sizeof(a [0])) // Num elements in an array
+#define NUMA(a) (sizeof(a) / sizeof((a)[0])) // Num elements in an array
 
 // Local types
 class Rectangle {
@@ -205,7 +204,6 @@
 {
     int     rv, opt;
     char   *chptr;
-    bool    error;
     string  str;
     char cmd[MAXCMD];
 
@@ -368,7 +366,6 @@
     istringstream in(rectStr);
     const struct hwcTestGraphicFormat *format;
     Rectangle rect;
-    struct hwc_rect hwcRect;
 
     // Graphic Format
     in >> str;
diff --git a/opengl/tests/hwc/hwcStress.cpp b/opengl/tests/hwc/hwcStress.cpp
index dfaa6c1..e6e5194 100644
--- a/opengl/tests/hwc/hwcStress.cpp
+++ b/opengl/tests/hwc/hwcStress.cpp
@@ -101,7 +101,6 @@
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 
-#include <ui/FramebufferNativeWindow.h>
 #include <ui/GraphicBuffer.h>
 
 #define LOG_TAG "hwcStressTest"
@@ -162,7 +161,7 @@
 #define CMD_STOP_FRAMEWORK   "stop 2>&1"
 #define CMD_START_FRAMEWORK  "start 2>&1"
 
-#define NUMA(a) (sizeof(a) / sizeof(a [0]))
+#define NUMA(a) (sizeof(a) / sizeof((a)[0]))
 #define MEMCLR(addr, size) do { \
         memset((addr), 0, (size)); \
     } while (0)
diff --git a/opengl/tests/hwc/hwcTestLib.cpp b/opengl/tests/hwc/hwcTestLib.cpp
index 9b224e2..3b0ca74 100644
--- a/opengl/tests/hwc/hwcTestLib.cpp
+++ b/opengl/tests/hwc/hwcTestLib.cpp
@@ -20,22 +20,22 @@
  * Utility library functions for use by the Hardware Composer test cases
  */
 
+#include <arpa/inet.h> // For ntohl() and htonl()
+
+#include <cmath>
 #include <sstream>
 #include <string>
 
-#include <arpa/inet.h> // For ntohl() and htonl()
-
 #include "hwcTestLib.h"
 
 #include "EGLUtils.h"
 
 // Defines
-#define NUMA(a) (sizeof(a) / sizeof(a [0]))
+#define NUMA(a) (sizeof(a) / sizeof((a)[0]))
 
 // Function Prototypes
 static void printGLString(const char *name, GLenum s);
 static void checkEglError(const char* op, EGLBoolean returnVal = EGL_TRUE);
-static void checkGlError(const char* op);
 static void printEGLConfiguration(EGLDisplay dpy, EGLConfig config);
 
 using namespace std;
@@ -51,8 +51,6 @@
 {
     static EGLContext context;
 
-    int rv;
-
     EGLBoolean returnValue;
     EGLConfig myConfig = {0};
     EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
@@ -80,7 +78,11 @@
         exit(71);
     }
 
-    EGLNativeWindowType window = android_createDisplaySurface();
+    // The tests want to stop the framework and play with the hardware
+    // composer, which means it doesn't make sense to use WindowSurface
+    // here.  android_createDisplaySurface() is going away, so just
+    // politely fail here.
+    EGLNativeWindowType window = NULL; //android_createDisplaySurface();
     if (window == NULL) {
         testPrintE("android_createDisplaySurface failed");
         exit(72);
@@ -664,7 +666,6 @@
 
     for (unsigned int x = 0; x < gBuf->getStride(); x++) {
         for (unsigned int y = 0; y < gBuf->getHeight(); y++) {
-            uint32_t val = pixel;
             hwcTestSetPixel(gBuf, buf, x, y, (x < gBuf->getWidth())
                             ? pixel : testRand());
         }
@@ -961,14 +962,6 @@
     }
 }
 
-static void checkGlError(const char* op)
-{
-    for (GLint error = glGetError(); error; error
-            = glGetError()) {
-        testPrintE("after %s() glError (0x%x)", op, error);
-    }
-}
-
 static void printEGLConfiguration(EGLDisplay dpy, EGLConfig config)
 {
 
diff --git a/opengl/tests/hwc/hwcTestLib.h b/opengl/tests/hwc/hwcTestLib.h
index d403308..a942c10 100644
--- a/opengl/tests/hwc/hwcTestLib.h
+++ b/opengl/tests/hwc/hwcTestLib.h
@@ -27,7 +27,6 @@
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 
-#include <ui/FramebufferNativeWindow.h>
 #include <ui/GraphicBuffer.h>
 
 #include <utils/Log.h>
diff --git a/opengl/tests/include/WindowSurface.h b/opengl/tests/include/WindowSurface.h
new file mode 100644
index 0000000..0ec1404
--- /dev/null
+++ b/opengl/tests/include/WindowSurface.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OPENGL_TESTS_WINDOWSURFACE_H
+#define OPENGL_TESTS_WINDOWSURFACE_H
+
+#include <gui/SurfaceControl.h>
+
+#include <EGL/egl.h>
+
+namespace android {
+
+/*
+ * A window that covers the entire display surface.
+ *
+ * The window is destroyed when this object is destroyed, so don't try
+ * to use the surface after that point.
+ */
+class WindowSurface {
+public:
+    // Creates the window.
+    WindowSurface();
+
+    // Retrieves a handle to the window.
+    EGLNativeWindowType getSurface() const;
+
+private:
+    WindowSurface(const WindowSurface&);
+    WindowSurface& operator=(const WindowSurface&);
+
+    sp<SurfaceControl> mSurfaceControl;
+};
+
+} // namespace android
+
+#endif /* OPENGL_TESTS_WINDOWSURFACE_H */
diff --git a/opengl/tests/lib/Android.mk b/opengl/tests/lib/Android.mk
index 0352a37..e5124ad 100644
--- a/opengl/tests/lib/Android.mk
+++ b/opengl/tests/lib/Android.mk
@@ -15,18 +15,13 @@
 LOCAL_PATH:= $(call my-dir)
 
 include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 LOCAL_MODULE_TAGS := tests
 LOCAL_MODULE:= libglTest
-LOCAL_SRC_FILES:= glTestLib.cpp
+LOCAL_SRC_FILES:= glTestLib.cpp WindowSurface.cpp
 LOCAL_C_INCLUDES += system/extras/tests/include \
-    bionic \
-    bionic/libstdc++/include \
-    external/stlport/stlport \
 	$(call include-path-for, opengl-tests-includes)
 
 LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
 
-LOCAL_SHARED_LIBRARIES += libcutils libutils libstlport
-
-
 include $(BUILD_STATIC_LIBRARY)
diff --git a/opengl/tests/lib/WindowSurface.cpp b/opengl/tests/lib/WindowSurface.cpp
new file mode 100644
index 0000000..1428945
--- /dev/null
+++ b/opengl/tests/lib/WindowSurface.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <WindowSurface.h>
+
+#include <gui/SurfaceComposerClient.h>
+#include <gui/ISurfaceComposer.h>
+#include <gui/Surface.h>
+#include <ui/DisplayInfo.h>
+
+using namespace android;
+
+WindowSurface::WindowSurface() {
+    status_t err;
+
+    sp<SurfaceComposerClient> surfaceComposerClient = new SurfaceComposerClient;
+    err = surfaceComposerClient->initCheck();
+    if (err != NO_ERROR) {
+        fprintf(stderr, "SurfaceComposerClient::initCheck error: %#x\n", err);
+        return;
+    }
+
+    // Get main display parameters.
+    sp<IBinder> mainDpy = SurfaceComposerClient::getBuiltInDisplay(
+            ISurfaceComposer::eDisplayIdMain);
+    DisplayInfo mainDpyInfo;
+    err = SurfaceComposerClient::getDisplayInfo(mainDpy, &mainDpyInfo);
+    if (err != NO_ERROR) {
+        fprintf(stderr, "ERROR: unable to get display characteristics\n");
+        return;
+    }
+
+    uint32_t width, height;
+    if (mainDpyInfo.orientation != DISPLAY_ORIENTATION_0 &&
+            mainDpyInfo.orientation != DISPLAY_ORIENTATION_180) {
+        // rotated
+        width = mainDpyInfo.h;
+        height = mainDpyInfo.w;
+    } else {
+        width = mainDpyInfo.w;
+        height = mainDpyInfo.h;
+    }
+
+    sp<SurfaceControl> sc = surfaceComposerClient->createSurface(
+            String8("Benchmark"), width, height,
+            PIXEL_FORMAT_RGBX_8888, ISurfaceComposerClient::eOpaque);
+    if (sc == NULL || !sc->isValid()) {
+        fprintf(stderr, "Failed to create SurfaceControl\n");
+        return;
+    }
+
+    SurfaceComposerClient::openGlobalTransaction();
+    err = sc->setLayer(0x7FFFFFFF);     // always on top
+    if (err != NO_ERROR) {
+        fprintf(stderr, "SurfaceComposer::setLayer error: %#x\n", err);
+        return;
+    }
+
+    err = sc->show();
+    if (err != NO_ERROR) {
+        fprintf(stderr, "SurfaceComposer::show error: %#x\n", err);
+        return;
+    }
+    SurfaceComposerClient::closeGlobalTransaction();
+
+    mSurfaceControl = sc;
+}
+
+EGLNativeWindowType WindowSurface::getSurface() const {
+    sp<ANativeWindow> anw = mSurfaceControl->getSurface();
+    return (EGLNativeWindowType) anw.get();
+}
+
diff --git a/opengl/tests/linetex/Android.mk b/opengl/tests/linetex/Android.mk
index 5b6384e..968756a 100644
--- a/opengl/tests/linetex/Android.mk
+++ b/opengl/tests/linetex/Android.mk
@@ -8,7 +8,11 @@
 	libcutils \
     libEGL \
     libGLESv1_CM \
-    libui
+    libui \
+    libgui \
+    libutils
+
+LOCAL_STATIC_LIBRARIES += libglTest
 
 LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes)
 
diff --git a/opengl/tests/linetex/linetex.cpp b/opengl/tests/linetex/linetex.cpp
index 8669492..5ad695b 100644
--- a/opengl/tests/linetex/linetex.cpp
+++ b/opengl/tests/linetex/linetex.cpp
@@ -15,8 +15,6 @@
 ** limitations under the License.
 */
 
-#define LOG_TAG "fillrate"
-
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -26,8 +24,8 @@
 #include <GLES/glext.h>
 
 #include <utils/StopWatch.h>
-#include <ui/FramebufferNativeWindow.h>
-#include "EGLUtils.h"
+#include <WindowSurface.h>
+#include <EGLUtils.h>
 
 using namespace android;
 
@@ -46,7 +44,8 @@
      EGLint w, h;
      EGLDisplay dpy;
 
-     EGLNativeWindowType window = android_createDisplaySurface();
+     WindowSurface windowSurface;
+     EGLNativeWindowType window = windowSurface.getSurface();
      
      dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
      eglInitialize(dpy, &majorVersion, &minorVersion);
@@ -81,9 +80,11 @@
      // default pack-alignment is 4
      const uint16_t t16[64] = { 0xFFFF, 0, 0xF800, 0, 0x07E0, 0, 0x001F, 0 };
 
+     const GLfloat fh = h;
+     const GLfloat fw2 = w/2;
      const GLfloat vertices[4][2] = {
-             { w/2,  0 },
-             { w/2,  h }
+             { fw2,  0  },
+             { fw2,  fh }
      };
 
      const GLfloat texCoords[4][2] = {
diff --git a/opengl/tests/swapinterval/Android.mk b/opengl/tests/swapinterval/Android.mk
index 5517f60..b0b15eb 100644
--- a/opengl/tests/swapinterval/Android.mk
+++ b/opengl/tests/swapinterval/Android.mk
@@ -9,7 +9,10 @@
 	libutils \
     libEGL \
     libGLESv1_CM \
-    libui
+    libui \
+    libgui
+
+LOCAL_STATIC_LIBRARIES += libglTest
 
 LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes)
 
diff --git a/opengl/tests/swapinterval/swapinterval.cpp b/opengl/tests/swapinterval/swapinterval.cpp
index a0f4bc4..3a8a8a1 100644
--- a/opengl/tests/swapinterval/swapinterval.cpp
+++ b/opengl/tests/swapinterval/swapinterval.cpp
@@ -23,8 +23,8 @@
 #include <GLES/glext.h>
 
 #include <utils/StopWatch.h>
-#include <ui/FramebufferNativeWindow.h>
-#include "EGLUtils.h"
+#include <WindowSurface.h>
+#include <EGLUtils.h>
 
 using namespace android;
 
@@ -45,7 +45,8 @@
     EGLDisplay dpy;
 
     
-    EGLNativeWindowType window = android_createDisplaySurface();
+    WindowSurface windowSurface;
+    EGLNativeWindowType window = windowSurface.getSurface();
 
     dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
     eglInitialize(dpy, &majorVersion, &minorVersion);
diff --git a/opengl/tests/textures/Android.mk b/opengl/tests/textures/Android.mk
index 97697d7..bee61f9 100644
--- a/opengl/tests/textures/Android.mk
+++ b/opengl/tests/textures/Android.mk
@@ -8,7 +8,11 @@
 	libcutils \
     libEGL \
     libGLESv1_CM \
-    libui
+    libui \
+    libgui \
+    libutils
+
+LOCAL_STATIC_LIBRARIES += libglTest
 
 LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes)
 
diff --git a/opengl/tests/textures/textures.cpp b/opengl/tests/textures/textures.cpp
index 5d3d94e..1e55db0 100644
--- a/opengl/tests/textures/textures.cpp
+++ b/opengl/tests/textures/textures.cpp
@@ -22,8 +22,8 @@
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
-#include <ui/FramebufferNativeWindow.h>
-#include "EGLUtils.h"
+#include <WindowSurface.h>
+#include <EGLUtils.h>
 
 using namespace android;
 
@@ -42,7 +42,8 @@
      EGLint w, h;
      EGLDisplay dpy;
 
-     EGLNativeWindowType window = android_createDisplaySurface();
+     WindowSurface windowSurface;
+     EGLNativeWindowType window = windowSurface.getSurface();
      
      dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
      eglInitialize(dpy, &majorVersion, &minorVersion);
@@ -114,5 +115,7 @@
      glDrawTexiOES(dim/2, dim/2, 0, dim/2, dim/2);
 
      eglSwapBuffers(dpy, surface);
+
+     sleep(2);      // so you have a chance to admire it
      return 0;
 }
diff --git a/opengl/tests/tritex/Android.mk b/opengl/tests/tritex/Android.mk
index 89faa87..64382ed 100644
--- a/opengl/tests/tritex/Android.mk
+++ b/opengl/tests/tritex/Android.mk
@@ -8,7 +8,11 @@
 	libcutils \
     libEGL \
     libGLESv1_CM \
-    libui
+    libui \
+    libgui \
+    libutils
+
+LOCAL_STATIC_LIBRARIES += libglTest
 
 LOCAL_C_INCLUDES += $(call include-path-for, opengl-tests-includes)
 
diff --git a/opengl/tests/tritex/tritex.cpp b/opengl/tests/tritex/tritex.cpp
index f183483..2db73ef 100644
--- a/opengl/tests/tritex/tritex.cpp
+++ b/opengl/tests/tritex/tritex.cpp
@@ -8,8 +8,8 @@
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
-#include <ui/FramebufferNativeWindow.h>
-#include "EGLUtils.h"
+#include <WindowSurface.h>
+#include <EGLUtils.h>
 
 #include <stdio.h>

 #include <stdlib.h>
@@ -25,7 +25,7 @@
 #define FIXED_ONE 0x10000
 #define ITERATIONS 50

 

-int init_gl_surface(void);

+int init_gl_surface(const WindowSurface&);

 void free_gl_surface(void);

 void init_scene(void);

 void render(int quads);

@@ -98,7 +98,8 @@
 
     printf("Initializing EGL...\n");
 

-    if(!init_gl_surface())

+    WindowSurface windowSurface;
+    if(!init_gl_surface(windowSurface))

     {

         printf("GL initialisation failed - exiting\n");

         return 0;

@@ -117,7 +118,7 @@
     return 0;

 }

 

-int init_gl_surface(void)

+int init_gl_surface(const WindowSurface& windowSurface)

 {

     EGLint numConfigs = 1;

     EGLConfig myConfig = {0};

@@ -140,7 +141,7 @@
         return 0;

     }

 
-    EGLNativeWindowType window = android_createDisplaySurface();

+    EGLNativeWindowType window = windowSurface.getSurface();

     EGLUtils::selectConfigForNativeWindow(eglDisplay, attrib, window, &myConfig);

 

     if ( (eglSurface = eglCreateWindowSurface(eglDisplay, myConfig,
diff --git a/opengl/tools/glgen/gen b/opengl/tools/glgen/gen
index 7146a29..84a94c8 100755
--- a/opengl/tools/glgen/gen
+++ b/opengl/tools/glgen/gen
@@ -105,7 +105,9 @@
                     android/opengl/GLES11.java \
                     android/opengl/GLES11Ext.java \
                     android/opengl/GLES20.java \
-                    android/opengl/GLES30.java
+                    android/opengl/GLES30.java \
+                    android/opengl/GLES31.java \
+                    android/opengl/GLES31Ext.java
 popd > /dev/null
 JAVA_RESULT=$?
 if [ $JAVA_RESULT -ne 0 ]; then
@@ -152,7 +154,7 @@
     compareGenerated ../../../../base/opengl/java/javax/microedition/khronos/opengles generated/javax/microedition/khronos/opengles $x
 done
 
-for x in EGL14 EGLExt GLES10 GLES10Ext GLES11 GLES11Ext GLES20 GLES30
+for x in EGL14 EGLExt GLES10 GLES10Ext GLES11 GLES11Ext GLES20 GLES30 GLES31 GLES31Ext
 do
     compareGenerated ../../../../base/opengl/java/android/opengl generated/android/opengl ${x}.java
     compareGenerated ../../../../base/core/jni generated/C android_opengl_${x}.cpp
diff --git a/opengl/tools/glgen/specs/gles11/GLES31.spec b/opengl/tools/glgen/specs/gles11/GLES31.spec
new file mode 100644
index 0000000..28c1e8b
--- /dev/null
+++ b/opengl/tools/glgen/specs/gles11/GLES31.spec
@@ -0,0 +1,68 @@
+void glDispatchCompute ( GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z )
+void glDispatchComputeIndirect ( GLintptr indirect )
+void glDrawArraysIndirect ( GLenum mode, const void *indirect )
+void glDrawElementsIndirect ( GLenum mode, GLenum type, const void *indirect )
+void glFramebufferParameteri ( GLenum target, GLenum pname, GLint param )
+void glGetFramebufferParameteriv ( GLenum target, GLenum pname, GLint *params )
+void glGetProgramInterfaceiv ( GLuint program, GLenum programInterface, GLenum pname, GLint *params )
+GLuint glGetProgramResourceIndex ( GLuint program, GLenum programInterface, const GLchar *name )
+void glGetProgramResourceName ( GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name )
+void glGetProgramResourceiv ( GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params )
+GLint glGetProgramResourceLocation ( GLuint program, GLenum programInterface, const GLchar *name )
+void glUseProgramStages ( GLuint pipeline, GLbitfield stages, GLuint program )
+void glActiveShaderProgram ( GLuint pipeline, GLuint program )
+GLuint glCreateShaderProgramv ( GLenum type, GLsizei count, const GLchar *const *strings )
+void glBindProgramPipeline ( GLuint pipeline )
+void glDeleteProgramPipelines ( GLsizei n, const GLuint *pipelines )
+void glGenProgramPipelines ( GLsizei n, GLuint *pipelines )
+GLboolean glIsProgramPipeline ( GLuint pipeline )
+void glGetProgramPipelineiv ( GLuint pipeline, GLenum pname, GLint *params )
+void glProgramUniform1i ( GLuint program, GLint location, GLint v0 )
+void glProgramUniform2i ( GLuint program, GLint location, GLint v0, GLint v1 )
+void glProgramUniform3i ( GLuint program, GLint location, GLint v0, GLint v1, GLint v2 )
+void glProgramUniform4i ( GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3 )
+void glProgramUniform1ui ( GLuint program, GLint location, GLuint v0 )
+void glProgramUniform2ui ( GLuint program, GLint location, GLuint v0, GLuint v1 )
+void glProgramUniform3ui ( GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2 )
+void glProgramUniform4ui ( GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3 )
+void glProgramUniform1f ( GLuint program, GLint location, GLfloat v0 )
+void glProgramUniform2f ( GLuint program, GLint location, GLfloat v0, GLfloat v1 )
+void glProgramUniform3f ( GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2 )
+void glProgramUniform4f ( GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3 )
+void glProgramUniform1iv ( GLuint program, GLint location, GLsizei count, const GLint *value )
+void glProgramUniform2iv ( GLuint program, GLint location, GLsizei count, const GLint *value )
+void glProgramUniform3iv ( GLuint program, GLint location, GLsizei count, const GLint *value )
+void glProgramUniform4iv ( GLuint program, GLint location, GLsizei count, const GLint *value )
+void glProgramUniform1uiv ( GLuint program, GLint location, GLsizei count, const GLuint *value )
+void glProgramUniform2uiv ( GLuint program, GLint location, GLsizei count, const GLuint *value )
+void glProgramUniform3uiv ( GLuint program, GLint location, GLsizei count, const GLuint *value )
+void glProgramUniform4uiv ( GLuint program, GLint location, GLsizei count, const GLuint *value )
+void glProgramUniform1fv ( GLuint program, GLint location, GLsizei count, const GLfloat *value )
+void glProgramUniform2fv ( GLuint program, GLint location, GLsizei count, const GLfloat *value )
+void glProgramUniform3fv ( GLuint program, GLint location, GLsizei count, const GLfloat *value )
+void glProgramUniform4fv ( GLuint program, GLint location, GLsizei count, const GLfloat *value )
+void glProgramUniformMatrix2fv ( GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value )
+void glProgramUniformMatrix3fv ( GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value )
+void glProgramUniformMatrix4fv ( GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value )
+void glProgramUniformMatrix2x3fv ( GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value )
+void glProgramUniformMatrix3x2fv ( GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value )
+void glProgramUniformMatrix2x4fv ( GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value )
+void glProgramUniformMatrix4x2fv ( GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value )
+void glProgramUniformMatrix3x4fv ( GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value )
+void glProgramUniformMatrix4x3fv ( GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value )
+void glValidateProgramPipeline ( GLuint pipeline )
+void glGetProgramPipelineInfoLog ( GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog )
+void glBindImageTexture ( GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format )
+void glGetBooleani_v ( GLenum target, GLuint index, GLboolean *data )
+void glMemoryBarrier ( GLbitfield barriers )
+void glMemoryBarrierByRegion ( GLbitfield barriers )
+void glTexStorage2DMultisample ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations )
+void glGetMultisamplefv ( GLenum pname, GLuint index, GLfloat *val )
+void glSampleMaski ( GLuint maskNumber, GLbitfield mask )
+void glGetTexLevelParameteriv ( GLenum target, GLint level, GLenum pname, GLint *params )
+void glGetTexLevelParameterfv ( GLenum target, GLint level, GLenum pname, GLfloat *params )
+void glBindVertexBuffer ( GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride )
+void glVertexAttribFormat ( GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset )
+void glVertexAttribIFormat ( GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset )
+void glVertexAttribBinding ( GLuint attribindex, GLuint bindingindex )
+void glVertexBindingDivisor ( GLuint bindingindex, GLuint divisor )
diff --git a/opengl/tools/glgen/specs/gles11/GLES31Ext.spec b/opengl/tools/glgen/specs/gles11/GLES31Ext.spec
new file mode 100644
index 0000000..2898c7f
--- /dev/null
+++ b/opengl/tools/glgen/specs/gles11/GLES31Ext.spec
@@ -0,0 +1,36 @@
+void glBlendBarrierKHR ( void )
+void glDebugMessageControlKHR ( GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled )
+void glDebugMessageInsertKHR ( GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf )
+void glDebugMessageCallbackKHR ( GLDEBUGPROCKHR callback, const void *userParam )
+GLuint glGetDebugMessageLogKHR ( GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog )
+void glPushDebugGroupKHR ( GLenum source, GLuint id, GLsizei length, const GLchar *message )
+void glPopDebugGroupKHR ( void )
+void glObjectLabelKHR ( GLenum identifier, GLuint name, GLsizei length, const GLchar *label )
+void glGetObjectLabelKHR ( GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label )
+void glObjectPtrLabelKHR ( const void *ptr, GLsizei length, const GLchar *label )
+void glGetObjectPtrLabelKHR ( const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label )
+void glGetPointervKHR ( GLenum pname, void **params )
+void glMinSampleShadingOES ( GLfloat value )
+void glTexStorage3DMultisampleOES ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations )
+void glCopyImageSubDataEXT ( GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth )
+void glEnableiEXT ( GLenum target, GLuint index )
+void glDisableiEXT ( GLenum target, GLuint index )
+void glBlendEquationiEXT ( GLuint buf, GLenum mode )
+void glBlendEquationSeparateiEXT ( GLuint buf, GLenum modeRGB, GLenum modeAlpha )
+void glBlendFunciEXT ( GLuint buf, GLenum src, GLenum dst )
+void glBlendFuncSeparateiEXT ( GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha )
+void glColorMaskiEXT ( GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a )
+GLboolean glIsEnablediEXT ( GLenum target, GLuint index )
+void glFramebufferTextureEXT ( GLenum target, GLenum attachment, GLuint texture, GLint level )
+void glPrimitiveBoundingBoxEXT ( GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW )
+void glPatchParameteriEXT ( GLenum pname, GLint value )
+void glTexParameterIivEXT ( GLenum target, GLenum pname, const GLint *params )
+void glTexParameterIuivEXT ( GLenum target, GLenum pname, const GLuint *params )
+void glGetTexParameterIivEXT ( GLenum target, GLenum pname, GLint *params )
+void glGetTexParameterIuivEXT ( GLenum target, GLenum pname, GLuint *params )
+void glSamplerParameterIivEXT ( GLuint sampler, GLenum pname, const GLint *param )
+void glSamplerParameterIuivEXT ( GLuint sampler, GLenum pname, const GLuint *param )
+void glGetSamplerParameterIivEXT ( GLuint sampler, GLenum pname, GLint *params )
+void glGetSamplerParameterIuivEXT ( GLuint sampler, GLenum pname, GLuint *params )
+void glTexBufferEXT ( GLenum target, GLenum internalformat, GLuint buffer )
+void glTexBufferRangeEXT ( GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size )
diff --git a/opengl/tools/glgen/src/GenerateGLES.java b/opengl/tools/glgen/src/GenerateGLES.java
index c99c45d..5693ef3 100644
--- a/opengl/tools/glgen/src/GenerateGLES.java
+++ b/opengl/tools/glgen/src/GenerateGLES.java
@@ -84,7 +84,8 @@
 
         // Generate files
         for(String suffix: new String[] {"GLES10", "GLES10Ext",
-                "GLES11", "GLES11Ext", "GLES20", "GLES30"})
+                "GLES11", "GLES11Ext", "GLES20",
+                "GLES30", "GLES31", "GLES31Ext"})
         {
             BufferedReader spec11Reader =
                 new BufferedReader(new FileReader("specs/gles11/"
diff --git a/opengl/tools/glgen/src/JType.java b/opengl/tools/glgen/src/JType.java
index c6e227e..5803a44 100644
--- a/opengl/tools/glgen/src/JType.java
+++ b/opengl/tools/glgen/src/JType.java
@@ -191,6 +191,84 @@
         (baseType.indexOf("Buffer") != -1);
     }
 
+    public JType getArrayTypeForTypedBuffer() {
+      if (!isTypedBuffer()) {
+          throw new RuntimeException("Not typed buffer type " + this);
+      }
+      switch (baseType) {
+        case "java.nio.ByteBuffer":
+          return new JType("byte", false, true);
+        case "java.nio.BooleanBuffer":
+          return new JType("boolean", false, true);
+        case "java.nio.ShortBuffer":
+          return new JType("short", false, true);
+        case "java.nio.CharBuffer":
+          return new JType("char", false, true);
+        case "java.nio.IntBuffer":
+          return new JType("int", false, true);
+        case "java.nio.LongBuffer":
+          return new JType("long", false, true);
+        case "java.nio.FloatBuffer":
+          return new JType("float", false, true);
+        case "java.nio.DoubleBuffer":
+          return new JType("double", false, true);
+        default:
+          throw new RuntimeException("Unknown typed buffer type " + this);
+      }
+    }
+
+    public String getArrayGetterForPrimitiveArray() {
+      if (!isArray() || isClass()) {
+          throw new RuntimeException("Not array type " + this);
+      }
+      switch (baseType) {
+        case "byte":
+          return "GetByteArrayElements";
+        case "boolean":
+          return "GetBooleanArrayElements";
+        case "short":
+          return "GetShortArrayElements";
+        case "char":
+          return "GetCharArrayElements";
+        case "int":
+          return "GetIntArrayElements";
+        case "long":
+          return "GetLongArrayElements";
+        case "float":
+          return "GetFloatArrayElements";
+        case "double":
+          return "GetDoubleArrayElements";
+        default:
+          throw new RuntimeException("Unknown array type " + this);
+      }
+    }
+
+    public String getArrayReleaserForPrimitiveArray() {
+      if (!isArray() || isClass()) {
+          throw new RuntimeException("Not array type " + this);
+      }
+      switch (baseType) {
+        case "byte":
+          return "ReleaseByteArrayElements";
+        case "boolean":
+          return "ReleaseBooleanArrayElements";
+        case "short":
+          return "ReleaseShortArrayElements";
+        case "char":
+          return "ReleaseCharArrayElements";
+        case "int":
+          return "ReleaseIntArrayElements";
+        case "long":
+          return "ReleaseLongArrayElements";
+        case "float":
+          return "ReleaseFloatArrayElements";
+        case "double":
+          return "ReleaseDoubleArrayElements";
+        default:
+          throw new RuntimeException("Unknown array type " + this);
+      }
+    }
+
     public boolean isEGLHandle() {
     return !isPrimitive() &&
         (baseType.startsWith("EGL"));
diff --git a/opengl/tools/glgen/src/JniCodeEmitter.java b/opengl/tools/glgen/src/JniCodeEmitter.java
index e51b7a2..5a412bf 100644
--- a/opengl/tools/glgen/src/JniCodeEmitter.java
+++ b/opengl/tools/glgen/src/JniCodeEmitter.java
@@ -673,7 +673,7 @@
                         "\";");
         cStream.println();
 
-        cStream.println("static JNINativeMethod methods[] = {");
+        cStream.println("static const JNINativeMethod methods[] = {");
 
         cStream.println("{\"_nativeClassInit\", \"()V\", (void*)nativeClassInit },");
 
@@ -812,6 +812,7 @@
         List<Integer> stringArgs = new ArrayList<Integer>();
         int numBufferArgs = 0;
         List<String> bufferArgNames = new ArrayList<String>();
+        List<JType> bufferArgTypes = new ArrayList<JType>();
 
         // Emit JNI signature (arguments)
         //
@@ -835,6 +836,7 @@
                     int cIndex = jfunc.getArgCIndex(i);
                     String cname = cfunc.getArgName(cIndex);
                     bufferArgNames.add(cname);
+                    bufferArgTypes.add(jfunc.getArgType(i));
                     numBufferArgs++;
                 }
             }
@@ -948,12 +950,25 @@
 
         // Emit a single _array or multiple _XXXArray variables
         if (numBufferArgs == 1) {
+            JType bufferType = bufferArgTypes.get(0);
+            if (bufferType.isTypedBuffer()) {
+                String typedArrayType = getJniType(bufferType.getArrayTypeForTypedBuffer());
+                out.println(indent + typedArrayType + " _array = (" + typedArrayType + ") 0;");
+            } else {
                 out.println(indent + "jarray _array = (jarray) 0;");
-                out.println(indent + "jint _bufferOffset = (jint) 0;");
+            }
+            out.println(indent + "jint _bufferOffset = (jint) 0;");
         } else {
             for (int i = 0; i < numBufferArgs; i++) {
-                out.println(indent + "jarray _" + bufferArgNames.get(i) +
-                            "Array = (jarray) 0;");
+                JType bufferType = bufferArgTypes.get(0);
+                if (bufferType.isTypedBuffer()) {
+                    String typedArrayType = getJniType(bufferType.getArrayTypeForTypedBuffer());
+                    out.println(indent + typedArrayType + " _" + bufferArgNames.get(i) +
+                                "Array = (" + typedArrayType + ") 0;");
+                } else {
+                    out.println(indent + "jarray _" + bufferArgNames.get(i) +
+                                "Array = (jarray) 0;");
+                }
                 out.println(indent + "jint _" + bufferArgNames.get(i) +
                             "BufferOffset = (jint) 0;");
             }
@@ -1135,9 +1150,10 @@
                                 "_base = (" +
                                 cfunc.getArgType(cIndex).getDeclaration() +
                                 ")");
+                    String arrayGetter = jfunc.getArgType(idx).getArrayGetterForPrimitiveArray();
                     out.println(indent + "    " +
                                 (mUseCPlusPlus ? "_env" : "(*_env)") +
-                                "->GetPrimitiveArrayCritical(" +
+                                "->" + arrayGetter + "(" +
                                 (mUseCPlusPlus ? "" : "_env, ") +
                                 jfunc.getArgName(idx) +
                                 "_ref, (jboolean *)0);");
@@ -1209,7 +1225,7 @@
                                     cfunc.getArgType(cIndex).getDeclaration() +
                                     ")getPointer(_env, " +
                                     cname +
-                                    "_buf, &" + array + ", &" + remaining + ", &" + bufferOffset +
+                                    "_buf, (jarray*)&" + array + ", &" + remaining + ", &" + bufferOffset +
                                     ");");
                     }
 
@@ -1244,9 +1260,17 @@
                 } else {
                     out.println(indent + "if (" + cname +" == NULL) {");
                 }
-                out.println(indent + indent + "char * _" + cname + "Base = (char *)_env->GetPrimitiveArrayCritical(" + array + ", (jboolean *) 0);");
-                out.println(indent + indent + cname + " = (" +cfunc.getArgType(cIndex).getDeclaration() +") (_" + cname + "Base + " + bufferOffset + ");");
-                out.println(indent + "}");
+                JType argType = jfunc.getArgType(idx);
+                if (argType.isTypedBuffer()) {
+                    String arrayGetter = argType.getArrayTypeForTypedBuffer().getArrayGetterForPrimitiveArray();
+                    out.println(indent + indent + "char * _" + cname + "Base = (char *)_env->" + arrayGetter + "(" + array + ", (jboolean *) 0);");
+                    out.println(indent + indent + cname + " = (" +cfunc.getArgType(cIndex).getDeclaration() +") (_" + cname + "Base + " + bufferOffset + ");");
+                    out.println(indent + "}");
+                } else {
+                    out.println(indent + indent + "char * _" + cname + "Base = (char *)_env->GetPrimitiveArrayCritical(" + array + ", (jboolean *) 0);");
+                    out.println(indent + indent + cname + " = (" +cfunc.getArgType(cIndex).getDeclaration() +") (_" + cname + "Base + " + bufferOffset + ");");
+                    out.println(indent + "}");
+                }
              }
         }
 
@@ -1336,12 +1360,13 @@
                     // the need to write back to the Java array
                     out.println(indent +
                                 "if (" + jfunc.getArgName(idx) + "_base) {");
+                    String arrayReleaser = jfunc.getArgType(idx).getArrayReleaserForPrimitiveArray();
                     out.println(indent + indent +
                                 (mUseCPlusPlus ? "_env" : "(*_env)") +
-                                "->ReleasePrimitiveArrayCritical(" +
+                                "->" + arrayReleaser + "(" +
                                 (mUseCPlusPlus ? "" : "_env, ") +
                                 jfunc.getArgName(idx) + "_ref, " +
-                                cfunc.getArgName(cIndex) +
+                                "(j" + jfunc.getArgType(idx).getBaseType() + "*)" + cfunc.getArgName(cIndex) +
                                 "_base,");
                     out.println(indent + indent + indent +
                                 (cfunc.getArgType(cIndex).isConst() ?
@@ -1350,17 +1375,32 @@
                     out.println(indent + "}");
                 } else if (jfunc.getArgType(idx).isBuffer()) {
                     if (! isPointerFunc) {
+                        JType argType = jfunc.getArgType(idx);
                         String array = numBufferArgs <= 1 ? "_array" :
                             "_" + cfunc.getArgName(cIndex) + "Array";
                         out.println(indent + "if (" + array + ") {");
-                        out.println(indent + indent +
-                                    "releasePointer(_env, " + array + ", " +
-                                    cfunc.getArgName(cIndex) +
-                                    ", " +
-                                    (cfunc.getArgType(cIndex).isConst() ?
-                                     "JNI_FALSE" : (emitExceptionCheck ?
-                                     "_exception ? JNI_FALSE : JNI_TRUE" : "JNI_TRUE")) +
-                                    ");");
+                        if (argType.isTypedBuffer()) {
+                            String arrayReleaser =
+                                argType.getArrayTypeForTypedBuffer().getArrayReleaserForPrimitiveArray();
+                            out.println(indent + indent +
+                                "_env->" + arrayReleaser + "(" + array + ", " +
+                                "(j" + argType.getArrayTypeForTypedBuffer().getBaseType() + "*)" +
+                                cfunc.getArgName(cIndex) +
+                                ", " +
+                                (cfunc.getArgType(cIndex).isConst() ?
+                                    "JNI_ABORT" : (emitExceptionCheck ?
+                                        "_exception ? JNI_ABORT : 0" : "0")) +
+                                ");");
+                        } else {
+                            out.println(indent + indent +
+                                "releasePointer(_env, " + array + ", " +
+                                cfunc.getArgName(cIndex) +
+                                ", " +
+                                (cfunc.getArgType(cIndex).isConst() ?
+                                    "JNI_FALSE" : (emitExceptionCheck ?
+                                        "_exception ? JNI_FALSE : JNI_TRUE" : "JNI_TRUE")) +
+                                ");");
+                        }
                         out.println(indent + "}");
                     }
                 }
diff --git a/opengl/tools/glgen/static/egl/EGLObjectHandle.java b/opengl/tools/glgen/static/egl/EGLObjectHandle.java
index e6e3976..f961eb7 100644
--- a/opengl/tools/glgen/static/egl/EGLObjectHandle.java
+++ b/opengl/tools/glgen/static/egl/EGLObjectHandle.java
@@ -24,18 +24,28 @@
 public abstract class EGLObjectHandle {
     private final long mHandle;
 
-    // TODO Deprecate EGLObjectHandle(int) method
+    /**
+     * @deprecated Use {@link #EGLObjectHandle(long)} instead. Handles
+     *     on 64 bit platforms will be wider than java ints.
+     */
+    @Deprecated
     protected EGLObjectHandle(int handle) {
         mHandle = handle;
     }
-    // TODO Unhide the EGLObjectHandle(long) method
-    /**
-     * {@hide}
-     */
     protected EGLObjectHandle(long handle) {
         mHandle = handle;
     }
-    // TODO Deprecate getHandle() method in favor of getNativeHandle()
+    /**
+     * @deprecated Use {@link #getNativeHandle()} instead. Handles on
+     *     64 bit platforms will be wider than java ints.
+     */
+    @Deprecated
+    public int getHandle() {
+        if ((mHandle & 0xffffffffL) != mHandle) {
+            throw new UnsupportedOperationException();
+        }
+        return (int)mHandle;
+    }
     /**
      * Returns the native handle of the wrapped EGL object. This handle can be
      * cast to the corresponding native type on the native side.
@@ -44,17 +54,6 @@
      *
      * @return the native handle of the wrapped EGL object.
      */
-    public int getHandle() {
-        if ((mHandle & 0xffffffffL) != mHandle) {
-            throw new UnsupportedOperationException();
-        }
-        return (int)mHandle;
-    }
-
-    // TODO Unhide getNativeHandle() method
-    /**
-     * {@hide}
-     */
     public long getNativeHandle() {
         return mHandle;
     }
diff --git a/opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp b/opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp
index a372362..f6813fd 100644
--- a/opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp
+++ b/opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp
@@ -16,6 +16,10 @@
 
 // This source file is automatically generated
 
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#pragma GCC diagnostic ignored "-Wunused-function"
+
 #include "jni.h"
 #include "JNIHelp.h"
 #include <android_runtime/AndroidRuntime.h>
diff --git a/opengl/tools/glgen/stubs/egl/EGLExtcHeader.cpp b/opengl/tools/glgen/stubs/egl/EGLExtcHeader.cpp
index b5c19df..4df61d3 100644
--- a/opengl/tools/glgen/stubs/egl/EGLExtcHeader.cpp
+++ b/opengl/tools/glgen/stubs/egl/EGLExtcHeader.cpp
@@ -16,6 +16,10 @@
 
 // This source file is automatically generated
 
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#pragma GCC diagnostic ignored "-Wunused-function"
+
 #include "jni.h"
 #include "JNIHelp.h"
 #include <android_runtime/AndroidRuntime.h>
@@ -81,23 +85,19 @@
     eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(J)V");
     eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(J)V");
 
-    jobject localeglNoContextObject = _env->NewObject(eglcontextClass, eglcontextConstructor, reinterpret_cast<jlong>(EGL_NO_CONTEXT));
-    eglNoContextObject = _env->NewGlobalRef(localeglNoContextObject);
-    jobject localeglNoDisplayObject = _env->NewObject(egldisplayClass, egldisplayConstructor, reinterpret_cast<jlong>(EGL_NO_DISPLAY));
-    eglNoDisplayObject = _env->NewGlobalRef(localeglNoDisplayObject);
-    jobject localeglNoSurfaceObject = _env->NewObject(eglsurfaceClass, eglsurfaceConstructor, reinterpret_cast<jlong>(EGL_NO_SURFACE));
-    eglNoSurfaceObject = _env->NewGlobalRef(localeglNoSurfaceObject);
-
 
     jclass eglClass = _env->FindClass("android/opengl/EGL14");
     jfieldID noContextFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_CONTEXT", "Landroid/opengl/EGLContext;");
-    _env->SetStaticObjectField(eglClass, noContextFieldID, eglNoContextObject);
+    jobject localeglNoContextObject = _env->GetStaticObjectField(eglClass, noContextFieldID);
+    eglNoContextObject = _env->NewGlobalRef(localeglNoContextObject);
 
     jfieldID noDisplayFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_DISPLAY", "Landroid/opengl/EGLDisplay;");
-    _env->SetStaticObjectField(eglClass, noDisplayFieldID, eglNoDisplayObject);
+    jobject localeglNoDisplayObject = _env->GetStaticObjectField(eglClass, noDisplayFieldID);
+    eglNoDisplayObject = _env->NewGlobalRef(localeglNoDisplayObject);
 
     jfieldID noSurfaceFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_SURFACE", "Landroid/opengl/EGLSurface;");
-    _env->SetStaticObjectField(eglClass, noSurfaceFieldID, eglNoSurfaceObject);
+    jobject localeglNoSurfaceObject = _env->GetStaticObjectField(eglClass, noSurfaceFieldID);
+    eglNoSurfaceObject = _env->NewGlobalRef(localeglNoSurfaceObject);
 }
 
 static void *
diff --git a/opengl/tools/glgen/stubs/egl/eglCreatePbufferFromClientBuffer.cpp b/opengl/tools/glgen/stubs/egl/eglCreatePbufferFromClientBuffer.cpp
index f09c171..6199637 100755
--- a/opengl/tools/glgen/stubs/egl/eglCreatePbufferFromClientBuffer.cpp
+++ b/opengl/tools/glgen/stubs/egl/eglCreatePbufferFromClientBuffer.cpp
@@ -27,7 +27,7 @@
     }
     _remaining = _env->GetArrayLength(attrib_list_ref) - offset;
     attrib_list_base = (EGLint *)
-        _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0);
+        _env->GetIntArrayElements(attrib_list_ref, (jboolean *)0);
     attrib_list = attrib_list_base + offset;
     attrib_list_sentinel = false;
     for (int i = _remaining - 1; i >= 0; i--)  {
@@ -53,7 +53,7 @@
 
 exit:
     if (attrib_list_base) {
-        _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base,
+        _env->ReleaseIntArrayElements(attrib_list_ref, attrib_list_base,
             JNI_ABORT);
     }
     if (_exception) {
@@ -71,4 +71,3 @@
     }
     return android_eglCreatePbufferFromClientBuffer(_env, _this, dpy, buftype, buffer, config, attrib_list_ref, offset);
 }
-
diff --git a/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.cpp b/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.cpp
index 0b6bf58..cc7b85d 100644
--- a/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.cpp
+++ b/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.cpp
@@ -41,7 +41,7 @@
 
     _remaining = _env->GetArrayLength(attrib_list_ref) - offset;
     attrib_list_base = (EGLint *)
-        _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0);
+        _env->GetIntArrayElements(attrib_list_ref, (jboolean *)0);
     attrib_list = attrib_list_base + offset;
     attrib_list_sentinel = 0;
     for (int i = _remaining - 1; i >= 0; i--)  {
@@ -66,7 +66,7 @@
 
 exit:
     if (attrib_list_base) {
-        _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base,
+        _env->ReleaseIntArrayElements(attrib_list_ref, attrib_list_base,
             JNI_ABORT);
     }
     if (_exception) {
@@ -123,7 +123,7 @@
 
     _remaining = _env->GetArrayLength(attrib_list_ref) - offset;
     attrib_list_base = (EGLint *)
-        _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0);
+        _env->GetIntArrayElements(attrib_list_ref, (jboolean *)0);
     attrib_list = attrib_list_base + offset;
     attrib_list_sentinel = 0;
     for (int i = _remaining - 1; i >= 0; i--)  {
@@ -148,7 +148,7 @@
 
 exit:
     if (attrib_list_base) {
-        _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base,
+        _env->ReleaseIntArrayElements(attrib_list_ref, attrib_list_base,
             JNI_ABORT);
     }
     if (_exception) {
diff --git a/opengl/tools/glgen/stubs/egl/eglGetDisplay.cpp b/opengl/tools/glgen/stubs/egl/eglGetDisplay.cpp
index 003efd3..2abc916 100755
--- a/opengl/tools/glgen/stubs/egl/eglGetDisplay.cpp
+++ b/opengl/tools/glgen/stubs/egl/eglGetDisplay.cpp
@@ -14,7 +14,8 @@
 android_eglGetDisplayInt
   (JNIEnv *_env, jobject _this, jint display_id) {
 
-    if ((EGLNativeDisplayType)display_id != EGL_DEFAULT_DISPLAY) {
+    if (static_cast<uintptr_t>(display_id) !=
+        reinterpret_cast<uintptr_t>(EGL_DEFAULT_DISPLAY)) {
         jniThrowException(_env, "java/lang/UnsupportedOperationException", "eglGetDisplay");
         return 0;
     }
diff --git a/opengl/tools/glgen/stubs/gles11/GLES10ExtHeader.java-if b/opengl/tools/glgen/stubs/gles11/GLES10ExtHeader.java-if
index 146d883..648fa82 100644
--- a/opengl/tools/glgen/stubs/gles11/GLES10ExtHeader.java-if
+++ b/opengl/tools/glgen/stubs/gles11/GLES10ExtHeader.java-if
@@ -22,6 +22,6 @@
 public class GLES10Ext {
     native private static void _nativeClassInit();
     static {
-	    _nativeClassInit();
+        _nativeClassInit();
     }
     
\ No newline at end of file
diff --git a/opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp
index 8a1d5ed..1fa9275 100644
--- a/opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp
+++ b/opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp
@@ -17,6 +17,10 @@
 
 // This source file is automatically generated
 
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#pragma GCC diagnostic ignored "-Wunused-function"
+
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
diff --git a/opengl/tools/glgen/stubs/gles11/GLES10Header.java-if b/opengl/tools/glgen/stubs/gles11/GLES10Header.java-if
index 16cab04..baabbed 100644
--- a/opengl/tools/glgen/stubs/gles11/GLES10Header.java-if
+++ b/opengl/tools/glgen/stubs/gles11/GLES10Header.java-if
@@ -262,7 +262,7 @@
 
     native private static void _nativeClassInit();
     static {
-	    _nativeClassInit();
+        _nativeClassInit();
     }
 
     private static Buffer _colorPointer;
diff --git a/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp
index 8a1d5ed..1fa9275 100644
--- a/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp
+++ b/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp
@@ -17,6 +17,10 @@
 
 // This source file is automatically generated
 
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#pragma GCC diagnostic ignored "-Wunused-function"
+
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
diff --git a/opengl/tools/glgen/stubs/gles11/GLES11ExtHeader.java-if b/opengl/tools/glgen/stubs/gles11/GLES11ExtHeader.java-if
index efaf867..233562e 100644
--- a/opengl/tools/glgen/stubs/gles11/GLES11ExtHeader.java-if
+++ b/opengl/tools/glgen/stubs/gles11/GLES11ExtHeader.java-if
@@ -132,7 +132,7 @@
 
     native private static void _nativeClassInit();
     static {
-	    _nativeClassInit();
+        _nativeClassInit();
     }
     
     private static final int GL_BYTE = GLES10.GL_BYTE;
diff --git a/opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp
index 8a1d5ed..1fa9275 100644
--- a/opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp
+++ b/opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp
@@ -17,6 +17,10 @@
 
 // This source file is automatically generated
 
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#pragma GCC diagnostic ignored "-Wunused-function"
+
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
diff --git a/opengl/tools/glgen/stubs/gles11/GLES11Header.java-if b/opengl/tools/glgen/stubs/gles11/GLES11Header.java-if
index e63d470..2b3e40e 100644
--- a/opengl/tools/glgen/stubs/gles11/GLES11Header.java-if
+++ b/opengl/tools/glgen/stubs/gles11/GLES11Header.java-if
@@ -147,7 +147,7 @@
 
     native private static void _nativeClassInit();
     static {
-	    _nativeClassInit();
+        _nativeClassInit();
     }
 
     private static Buffer _pointSizePointerOES;
diff --git a/opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp
index 8a1d5ed..1fa9275 100644
--- a/opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp
+++ b/opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp
@@ -17,6 +17,10 @@
 
 // This source file is automatically generated
 
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#pragma GCC diagnostic ignored "-Wunused-function"
+
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
diff --git a/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp
index 2389563..4004a7d 100644
--- a/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp
+++ b/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp
@@ -17,6 +17,10 @@
 
 // This source file is automatically generated
 
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#pragma GCC diagnostic ignored "-Wunused-function"
+
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 
diff --git a/opengl/tools/glgen/stubs/gles11/GLES30cHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES30cHeader.cpp
index f5ec455..c5bdf32 100644
--- a/opengl/tools/glgen/stubs/gles11/GLES30cHeader.cpp
+++ b/opengl/tools/glgen/stubs/gles11/GLES30cHeader.cpp
@@ -17,6 +17,10 @@
 
 // This source file is automatically generated
 
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#pragma GCC diagnostic ignored "-Wunused-function"
+
 #include <GLES3/gl3.h>
 #include <GLES3/gl3ext.h>
 
diff --git a/opengl/tools/glgen/stubs/gles11/GLES31ExtHeader.java-if b/opengl/tools/glgen/stubs/gles11/GLES31ExtHeader.java-if
new file mode 100644
index 0000000..8fc2f1c
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/GLES31ExtHeader.java-if
@@ -0,0 +1,256 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// This source file is automatically generated
+
+package android.opengl;
+
+public class GLES31Ext {
+
+    // GL_KHR_blend_equation_advanced
+    public static final int GL_BLEND_ADVANCED_COHERENT_KHR                          = 0x9285;
+    public static final int GL_MULTIPLY_KHR                                         = 0x9294;
+    public static final int GL_SCREEN_KHR                                           = 0x9295;
+    public static final int GL_OVERLAY_KHR                                          = 0x9296;
+    public static final int GL_DARKEN_KHR                                           = 0x9297;
+    public static final int GL_LIGHTEN_KHR                                          = 0x9298;
+    public static final int GL_COLORDODGE_KHR                                       = 0x9299;
+    public static final int GL_COLORBURN_KHR                                        = 0x929A;
+    public static final int GL_HARDLIGHT_KHR                                        = 0x929B;
+    public static final int GL_SOFTLIGHT_KHR                                        = 0x929C;
+    public static final int GL_DIFFERENCE_KHR                                       = 0x929E;
+    public static final int GL_EXCLUSION_KHR                                        = 0x92A0;
+    public static final int GL_HSL_HUE_KHR                                          = 0x92AD;
+    public static final int GL_HSL_SATURATION_KHR                                   = 0x92AE;
+    public static final int GL_HSL_COLOR_KHR                                        = 0x92AF;
+    public static final int GL_HSL_LUMINOSITY_KHR                                   = 0x92B0;
+
+    // GL_KHR_debug
+    public static final int GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR                         = 0x8242;
+    public static final int GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR                 = 0x8243;
+    public static final int GL_DEBUG_CALLBACK_FUNCTION_KHR                          = 0x8244;
+    public static final int GL_DEBUG_CALLBACK_USER_PARAM_KHR                        = 0x8245;
+    public static final int GL_DEBUG_SOURCE_API_KHR                                 = 0x8246;
+    public static final int GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR                       = 0x8247;
+    public static final int GL_DEBUG_SOURCE_SHADER_COMPILER_KHR                     = 0x8248;
+    public static final int GL_DEBUG_SOURCE_THIRD_PARTY_KHR                         = 0x8249;
+    public static final int GL_DEBUG_SOURCE_APPLICATION_KHR                         = 0x824A;
+    public static final int GL_DEBUG_SOURCE_OTHER_KHR                               = 0x824B;
+    public static final int GL_DEBUG_TYPE_ERROR_KHR                                 = 0x824C;
+    public static final int GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR                   = 0x824D;
+    public static final int GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR                    = 0x824E;
+    public static final int GL_DEBUG_TYPE_PORTABILITY_KHR                           = 0x824F;
+    public static final int GL_DEBUG_TYPE_PERFORMANCE_KHR                           = 0x8250;
+    public static final int GL_DEBUG_TYPE_OTHER_KHR                                 = 0x8251;
+    public static final int GL_DEBUG_TYPE_MARKER_KHR                                = 0x8268;
+    public static final int GL_DEBUG_TYPE_PUSH_GROUP_KHR                            = 0x8269;
+    public static final int GL_DEBUG_TYPE_POP_GROUP_KHR                             = 0x826A;
+    public static final int GL_DEBUG_SEVERITY_NOTIFICATION_KHR                      = 0x826B;
+    public static final int GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR                      = 0x826C;
+    public static final int GL_DEBUG_GROUP_STACK_DEPTH_KHR                          = 0x826D;
+    public static final int GL_BUFFER_KHR                                           = 0x82E0;
+    public static final int GL_SHADER_KHR                                           = 0x82E1;
+    public static final int GL_PROGRAM_KHR                                          = 0x82E2;
+    public static final int GL_VERTEX_ARRAY_KHR                                     = 0x8074;
+    public static final int GL_QUERY_KHR                                            = 0x82E3;
+    public static final int GL_SAMPLER_KHR                                          = 0x82E6;
+    public static final int GL_MAX_LABEL_LENGTH_KHR                                 = 0x82E8;
+    public static final int GL_MAX_DEBUG_MESSAGE_LENGTH_KHR                         = 0x9143;
+    public static final int GL_MAX_DEBUG_LOGGED_MESSAGES_KHR                        = 0x9144;
+    public static final int GL_DEBUG_LOGGED_MESSAGES_KHR                            = 0x9145;
+    public static final int GL_DEBUG_SEVERITY_HIGH_KHR                              = 0x9146;
+    public static final int GL_DEBUG_SEVERITY_MEDIUM_KHR                            = 0x9147;
+    public static final int GL_DEBUG_SEVERITY_LOW_KHR                               = 0x9148;
+    public static final int GL_DEBUG_OUTPUT_KHR                                     = 0x92E0;
+    public static final int GL_CONTEXT_FLAG_DEBUG_BIT_KHR                           = 0x00000002;
+    public static final int GL_STACK_OVERFLOW_KHR                                   = 0x0503;
+    public static final int GL_STACK_UNDERFLOW_KHR                                  = 0x0504;
+
+    // GL_KHR_texture_compression_astc_ldr
+    public static final int GL_COMPRESSED_RGBA_ASTC_4x4_KHR                         = 0x93B0;
+    public static final int GL_COMPRESSED_RGBA_ASTC_5x4_KHR                         = 0x93B1;
+    public static final int GL_COMPRESSED_RGBA_ASTC_5x5_KHR                         = 0x93B2;
+    public static final int GL_COMPRESSED_RGBA_ASTC_6x5_KHR                         = 0x93B3;
+    public static final int GL_COMPRESSED_RGBA_ASTC_6x6_KHR                         = 0x93B4;
+    public static final int GL_COMPRESSED_RGBA_ASTC_8x5_KHR                         = 0x93B5;
+    public static final int GL_COMPRESSED_RGBA_ASTC_8x6_KHR                         = 0x93B6;
+    public static final int GL_COMPRESSED_RGBA_ASTC_8x8_KHR                         = 0x93B7;
+    public static final int GL_COMPRESSED_RGBA_ASTC_10x5_KHR                        = 0x93B8;
+    public static final int GL_COMPRESSED_RGBA_ASTC_10x6_KHR                        = 0x93B9;
+    public static final int GL_COMPRESSED_RGBA_ASTC_10x8_KHR                        = 0x93BA;
+    public static final int GL_COMPRESSED_RGBA_ASTC_10x10_KHR                       = 0x93BB;
+    public static final int GL_COMPRESSED_RGBA_ASTC_12x10_KHR                       = 0x93BC;
+    public static final int GL_COMPRESSED_RGBA_ASTC_12x12_KHR                       = 0x93BD;
+    public static final int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR                 = 0x93D0;
+    public static final int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR                 = 0x93D1;
+    public static final int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR                 = 0x93D2;
+    public static final int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR                 = 0x93D3;
+    public static final int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR                 = 0x93D4;
+    public static final int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR                 = 0x93D5;
+    public static final int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR                 = 0x93D6;
+    public static final int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR                 = 0x93D7;
+    public static final int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR                = 0x93D8;
+    public static final int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR                = 0x93D9;
+    public static final int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR                = 0x93DA;
+    public static final int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR               = 0x93DB;
+    public static final int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR               = 0x93DC;
+    public static final int GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR               = 0x93DD;
+
+    // GL_OES_sample_shading
+    public static final int GL_SAMPLE_SHADING_OES                                   = 0x8C36;
+    public static final int GL_MIN_SAMPLE_SHADING_VALUE_OES                         = 0x8C37;
+
+    // GL_OES_shader_multisample_interpolation
+    public static final int GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES                = 0x8E5B;
+    public static final int GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES                = 0x8E5C;
+    public static final int GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES               = 0x8E5D;
+
+    // GL_OES_texture_stencil8
+    public static final int GL_STENCIL_INDEX_OES                                    = 0x1901;
+    public static final int GL_STENCIL_INDEX8_OES                                   = 0x8D48;
+
+    // GL_OES_texture_storage_multisample_2d_array
+    public static final int GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES                     = 0x9102;
+    public static final int GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES             = 0x9105;
+    public static final int GL_SAMPLER_2D_MULTISAMPLE_ARRAY_OES                     = 0x910B;
+    public static final int GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES                 = 0x910C;
+    public static final int GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES        = 0x910D;
+
+    // GL_EXT_geometry_shader
+    public static final int GL_GEOMETRY_SHADER_EXT                                  = 0x8DD9;
+    public static final int GL_GEOMETRY_SHADER_BIT_EXT                              = 0x00000004;
+    public static final int GL_GEOMETRY_LINKED_VERTICES_OUT_EXT                     = 0x8916;
+    public static final int GL_GEOMETRY_LINKED_INPUT_TYPE_EXT                       = 0x8917;
+    public static final int GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT                      = 0x8918;
+    public static final int GL_GEOMETRY_SHADER_INVOCATIONS_EXT                      = 0x887F;
+    public static final int GL_LAYER_PROVOKING_VERTEX_EXT                           = 0x825E;
+    public static final int GL_LINES_ADJACENCY_EXT                                  = 0x000A;
+    public static final int GL_LINE_STRIP_ADJACENCY_EXT                             = 0x000B;
+    public static final int GL_TRIANGLES_ADJACENCY_EXT                              = 0x000C;
+    public static final int GL_TRIANGLE_STRIP_ADJACENCY_EXT                         = 0x000D;
+    public static final int GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT                  = 0x8DDF;
+    public static final int GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT                      = 0x8A2C;
+    public static final int GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT         = 0x8A32;
+    public static final int GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT                    = 0x9123;
+    public static final int GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT                   = 0x9124;
+    public static final int GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT                     = 0x8DE0;
+    public static final int GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT             = 0x8DE1;
+    public static final int GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT                  = 0x8E5A;
+    public static final int GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT                 = 0x8C29;
+    public static final int GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT              = 0x92CF;
+    public static final int GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT                     = 0x92D5;
+    public static final int GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT                      = 0x90CD;
+    public static final int GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT               = 0x90D7;
+    public static final int GL_FIRST_VERTEX_CONVENTION_EXT                          = 0x8E4D;
+    public static final int GL_LAST_VERTEX_CONVENTION_EXT                           = 0x8E4E;
+    public static final int GL_UNDEFINED_VERTEX_EXT                                 = 0x8260;
+    public static final int GL_PRIMITIVES_GENERATED_EXT                             = 0x8C87;
+    public static final int GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT                       = 0x9312;
+    public static final int GL_MAX_FRAMEBUFFER_LAYERS_EXT                           = 0x9317;
+    public static final int GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT             = 0x8DA8;
+    public static final int GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT                   = 0x8DA7;
+    public static final int GL_REFERENCED_BY_GEOMETRY_SHADER_EXT                    = 0x9309;
+
+    // GL_EXT_primitive_bounding_box
+    public static final int GL_PRIMITIVE_BOUNDING_BOX_EXT                           = 0x92BE;
+
+    // GL_EXT_tessellation_shader
+    public static final int GL_PATCHES_EXT                                          = 0x000E;
+    public static final int GL_PATCH_VERTICES_EXT                                   = 0x8E72;
+    public static final int GL_TESS_CONTROL_OUTPUT_VERTICES_EXT                     = 0x8E75;
+    public static final int GL_TESS_GEN_MODE_EXT                                    = 0x8E76;
+    public static final int GL_TESS_GEN_SPACING_EXT                                 = 0x8E77;
+    public static final int GL_TESS_GEN_VERTEX_ORDER_EXT                            = 0x8E78;
+    public static final int GL_TESS_GEN_POINT_MODE_EXT                              = 0x8E79;
+    public static final int GL_ISOLINES_EXT                                         = 0x8E7A;
+    public static final int GL_QUADS_EXT                                            = 0x0007;
+    public static final int GL_FRACTIONAL_ODD_EXT                                   = 0x8E7B;
+    public static final int GL_FRACTIONAL_EVEN_EXT                                  = 0x8E7C;
+    public static final int GL_MAX_PATCH_VERTICES_EXT                               = 0x8E7D;
+    public static final int GL_MAX_TESS_GEN_LEVEL_EXT                               = 0x8E7E;
+    public static final int GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT              = 0x8E7F;
+    public static final int GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT           = 0x8E80;
+    public static final int GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT             = 0x8E81;
+    public static final int GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT          = 0x8E82;
+    public static final int GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT               = 0x8E83;
+    public static final int GL_MAX_TESS_PATCH_COMPONENTS_EXT                        = 0x8E84;
+    public static final int GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT         = 0x8E85;
+    public static final int GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT            = 0x8E86;
+    public static final int GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT                  = 0x8E89;
+    public static final int GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT               = 0x8E8A;
+    public static final int GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT                = 0x886C;
+    public static final int GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT             = 0x886D;
+    public static final int GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT     = 0x8E1E;
+    public static final int GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT  = 0x8E1F;
+    public static final int GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT          = 0x92CD;
+    public static final int GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT       = 0x92CE;
+    public static final int GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT                 = 0x92D3;
+    public static final int GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT              = 0x92D4;
+    public static final int GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT                  = 0x90CB;
+    public static final int GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT               = 0x90CC;
+    public static final int GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT           = 0x90D8;
+    public static final int GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT        = 0x90D9;
+    public static final int GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED              = 0x8221;
+    public static final int GL_IS_PER_PATCH_EXT                                     = 0x92E7;
+    public static final int GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT                = 0x9307;
+    public static final int GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT             = 0x9308;
+    public static final int GL_TESS_CONTROL_SHADER_EXT                              = 0x8E88;
+    public static final int GL_TESS_EVALUATION_SHADER_EXT                           = 0x8E87;
+    public static final int GL_TESS_CONTROL_SHADER_BIT_EXT                          = 0x00000008;
+    public static final int GL_TESS_EVALUATION_SHADER_BIT_EXT                       = 0x00000010;
+
+    // GL_EXT_texture_border_clamp
+    public static final int GL_TEXTURE_BORDER_COLOR_EXT                             = 0x1004;
+    public static final int GL_CLAMP_TO_BORDER_EXT                                  = 0x812D;
+
+    // GL_EXT_texture_buffer
+    public static final int GL_TEXTURE_BUFFER_EXT                                   = 0x8C2A;
+    public static final int GL_TEXTURE_BUFFER_BINDING_EXT                           = 0x8C2A;
+    public static final int GL_MAX_TEXTURE_BUFFER_SIZE_EXT                          = 0x8C2B;
+    public static final int GL_TEXTURE_BINDING_BUFFER_EXT                           = 0x8C2C;
+    public static final int GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT                = 0x8C2D;
+    public static final int GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT                  = 0x919F;
+    public static final int GL_SAMPLER_BUFFER_EXT                                   = 0x8DC2;
+    public static final int GL_INT_SAMPLER_BUFFER_EXT                               = 0x8DD0;
+    public static final int GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT                      = 0x8DD8;
+    public static final int GL_IMAGE_BUFFER_EXT                                     = 0x9051;
+    public static final int GL_INT_IMAGE_BUFFER_EXT                                 = 0x905C;
+    public static final int GL_UNSIGNED_INT_IMAGE_BUFFER_EXT                        = 0x9067;
+    public static final int GL_TEXTURE_BUFFER_OFFSET_EXT                            = 0x919D;
+    public static final int GL_TEXTURE_BUFFER_SIZE_EXT                              = 0x919E;
+
+    // GL_EXT_texture_cube_map_array
+    public static final int GL_TEXTURE_CUBE_MAP_ARRAY_EXT                           = 0x9009;
+    public static final int GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT                   = 0x900A;
+    public static final int GL_SAMPLER_CUBE_MAP_ARRAY_EXT                           = 0x900C;
+    public static final int GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT                    = 0x900D;
+    public static final int GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT                       = 0x900E;
+    public static final int GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT              = 0x900F;
+    public static final int GL_IMAGE_CUBE_MAP_ARRAY_EXT                             = 0x9054;
+    public static final int GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT                         = 0x905F;
+    public static final int GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT                = 0x906A;
+
+    // GL_EXT_texture_sRGB_decode
+    public static final int GL_TEXTURE_SRGB_DECODE_EXT                              = 0x8A48;
+    public static final int GL_DECODE_EXT                                           = 0x8A49;
+    public static final int GL_SKIP_DECODE_EXT                                      = 0x8A4A;
+
+    native private static void _nativeClassInit();
+    static {
+        _nativeClassInit();
+    }
+
+    private GLES31Ext() {}
diff --git a/cmds/dumpstate/libdumpstate_default.c b/opengl/tools/glgen/stubs/gles11/GLES31ExtcHeader.cpp
similarity index 64%
copy from cmds/dumpstate/libdumpstate_default.c
copy to opengl/tools/glgen/stubs/gles11/GLES31ExtcHeader.cpp
index fd840df..2260a80 100644
--- a/cmds/dumpstate/libdumpstate_default.c
+++ b/opengl/tools/glgen/stubs/gles11/GLES31ExtcHeader.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 The Android Open Source Project
+ * Copyright 2014 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,9 +14,12 @@
  * limitations under the License.
  */
 
-#include "dumpstate.h"
+// This source file is automatically generated
 
-void dumpstate_board(void)
-{
-}
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#pragma GCC diagnostic ignored "-Wunused-function"
+
+#include <GLES3/gl31.h>
+#include <GLES2/gl2ext.h>
 
diff --git a/opengl/tools/glgen/stubs/gles11/GLES31Header.java-if b/opengl/tools/glgen/stubs/gles11/GLES31Header.java-if
new file mode 100644
index 0000000..5b45df4
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/GLES31Header.java-if
@@ -0,0 +1,201 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// This source file is automatically generated
+
+package android.opengl;
+
+/** OpenGL ES 3.1
+ */
+public class GLES31 extends GLES30 {
+
+    public static final int GL_VERTEX_SHADER_BIT                            = 0x00000001;
+    public static final int GL_FRAGMENT_SHADER_BIT                          = 0x00000002;
+    public static final int GL_UNIFORM_BARRIER_BIT                          = 0x00000004;
+    public static final int GL_TEXTURE_FETCH_BARRIER_BIT                    = 0x00000008;
+    public static final int GL_COMPUTE_SHADER_BIT                           = 0x00000020;
+    public static final int GL_COMMAND_BARRIER_BIT                          = 0x00000040;
+    public static final int GL_PIXEL_BUFFER_BARRIER_BIT                     = 0x00000080;
+    public static final int GL_TEXTURE_UPDATE_BARRIER_BIT                   = 0x00000100;
+    public static final int GL_BUFFER_UPDATE_BARRIER_BIT                    = 0x00000200;
+    public static final int GL_FRAMEBUFFER_BARRIER_BIT                      = 0x00000400;
+    public static final int GL_TRANSFORM_FEEDBACK_BARRIER_BIT               = 0x00000800;
+    public static final int GL_ATOMIC_COUNTER_BARRIER_BIT                   = 0x00001000;
+    public static final int GL_SHADER_STORAGE_BARRIER_BIT                   = 0x00002000;
+    public static final int GL_ALL_SHADER_BITS                              = -1; // 0xFFFFFFFF
+
+    public static final int GL_TEXTURE_WIDTH                                = 0x1000;
+    public static final int GL_TEXTURE_HEIGHT                               = 0x1001;
+    public static final int GL_TEXTURE_INTERNAL_FORMAT                      = 0x1003;
+    public static final int GL_STENCIL_INDEX                                = 0x1901;
+    public static final int GL_TEXTURE_RED_SIZE                             = 0x805C;
+    public static final int GL_TEXTURE_GREEN_SIZE                           = 0x805D;
+    public static final int GL_TEXTURE_BLUE_SIZE                            = 0x805E;
+    public static final int GL_TEXTURE_ALPHA_SIZE                           = 0x805F;
+    public static final int GL_TEXTURE_DEPTH                                = 0x8071;
+    public static final int GL_PROGRAM_SEPARABLE                            = 0x8258;
+    public static final int GL_ACTIVE_PROGRAM                               = 0x8259;
+    public static final int GL_PROGRAM_PIPELINE_BINDING                     = 0x825A;
+    public static final int GL_MAX_COMPUTE_SHARED_MEMORY_SIZE               = 0x8262;
+    public static final int GL_MAX_COMPUTE_UNIFORM_COMPONENTS               = 0x8263;
+    public static final int GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS           = 0x8264;
+    public static final int GL_MAX_COMPUTE_ATOMIC_COUNTERS                  = 0x8265;
+    public static final int GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS      = 0x8266;
+    public static final int GL_COMPUTE_WORK_GROUP_SIZE                      = 0x8267;
+    public static final int GL_MAX_UNIFORM_LOCATIONS                        = 0x826E;
+    public static final int GL_VERTEX_ATTRIB_BINDING                        = 0x82D4;
+    public static final int GL_VERTEX_ATTRIB_RELATIVE_OFFSET                = 0x82D5;
+    public static final int GL_VERTEX_BINDING_DIVISOR                       = 0x82D6;
+    public static final int GL_VERTEX_BINDING_OFFSET                        = 0x82D7;
+    public static final int GL_VERTEX_BINDING_STRIDE                        = 0x82D8;
+    public static final int GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET            = 0x82D9;
+    public static final int GL_MAX_VERTEX_ATTRIB_BINDINGS                   = 0x82DA;
+    public static final int GL_MAX_VERTEX_ATTRIB_STRIDE                     = 0x82E5;
+    public static final int GL_TEXTURE_COMPRESSED                           = 0x86A1;
+    public static final int GL_TEXTURE_DEPTH_SIZE                           = 0x884A;
+    public static final int GL_READ_ONLY                                    = 0x88B8;
+    public static final int GL_WRITE_ONLY                                   = 0x88B9;
+    public static final int GL_READ_WRITE                                   = 0x88BA;
+    public static final int GL_TEXTURE_STENCIL_SIZE                         = 0x88F1;
+    public static final int GL_TEXTURE_RED_TYPE                             = 0x8C10;
+    public static final int GL_TEXTURE_GREEN_TYPE                           = 0x8C11;
+    public static final int GL_TEXTURE_BLUE_TYPE                            = 0x8C12;
+    public static final int GL_TEXTURE_ALPHA_TYPE                           = 0x8C13;
+    public static final int GL_TEXTURE_DEPTH_TYPE                           = 0x8C16;
+    public static final int GL_TEXTURE_SHARED_SIZE                          = 0x8C3F;
+    public static final int GL_SAMPLE_POSITION                              = 0x8E50;
+    public static final int GL_SAMPLE_MASK                                  = 0x8E51;
+    public static final int GL_SAMPLE_MASK_VALUE                            = 0x8E52;
+    public static final int GL_MAX_SAMPLE_MASK_WORDS                        = 0x8E59;
+    public static final int GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET            = 0x8E5E;
+    public static final int GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET            = 0x8E5F;
+    public static final int GL_MAX_IMAGE_UNITS                              = 0x8F38;
+    public static final int GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES         = 0x8F39;
+    public static final int GL_IMAGE_BINDING_NAME                           = 0x8F3A;
+    public static final int GL_IMAGE_BINDING_LEVEL                          = 0x8F3B;
+    public static final int GL_IMAGE_BINDING_LAYERED                        = 0x8F3C;
+    public static final int GL_IMAGE_BINDING_LAYER                          = 0x8F3D;
+    public static final int GL_IMAGE_BINDING_ACCESS                         = 0x8F3E;
+    public static final int GL_DRAW_INDIRECT_BUFFER                         = 0x8F3F;
+    public static final int GL_DRAW_INDIRECT_BUFFER_BINDING                 = 0x8F43;
+    public static final int GL_VERTEX_BINDING_BUFFER                        = 0x8F4F;
+    public static final int GL_IMAGE_2D                                     = 0x904D;
+    public static final int GL_IMAGE_3D                                     = 0x904E;
+    public static final int GL_IMAGE_CUBE                                   = 0x9050;
+    public static final int GL_IMAGE_2D_ARRAY                               = 0x9053;
+    public static final int GL_INT_IMAGE_2D                                 = 0x9058;
+    public static final int GL_INT_IMAGE_3D                                 = 0x9059;
+    public static final int GL_INT_IMAGE_CUBE                               = 0x905B;
+    public static final int GL_INT_IMAGE_2D_ARRAY                           = 0x905E;
+    public static final int GL_UNSIGNED_INT_IMAGE_2D                        = 0x9063;
+    public static final int GL_UNSIGNED_INT_IMAGE_3D                        = 0x9064;
+    public static final int GL_UNSIGNED_INT_IMAGE_CUBE                      = 0x9066;
+    public static final int GL_UNSIGNED_INT_IMAGE_2D_ARRAY                  = 0x9069;
+    public static final int GL_IMAGE_BINDING_FORMAT                         = 0x906E;
+    public static final int GL_IMAGE_FORMAT_COMPATIBILITY_TYPE              = 0x90C7;
+    public static final int GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE           = 0x90C8;
+    public static final int GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS          = 0x90C9;
+    public static final int GL_MAX_VERTEX_IMAGE_UNIFORMS                    = 0x90CA;
+    public static final int GL_MAX_FRAGMENT_IMAGE_UNIFORMS                  = 0x90CE;
+    public static final int GL_MAX_COMBINED_IMAGE_UNIFORMS                  = 0x90CF;
+    public static final int GL_SHADER_STORAGE_BUFFER                        = 0x90D2;
+    public static final int GL_SHADER_STORAGE_BUFFER_BINDING                = 0x90D3;
+    public static final int GL_SHADER_STORAGE_BUFFER_START                  = 0x90D4;
+    public static final int GL_SHADER_STORAGE_BUFFER_SIZE                   = 0x90D5;
+    public static final int GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS             = 0x90D6;
+    public static final int GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS           = 0x90DA;
+    public static final int GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS            = 0x90DB;
+    public static final int GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS           = 0x90DC;
+    public static final int GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS           = 0x90DD;
+    public static final int GL_MAX_SHADER_STORAGE_BLOCK_SIZE                = 0x90DE;
+    public static final int GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT       = 0x90DF;
+    public static final int GL_DEPTH_STENCIL_TEXTURE_MODE                   = 0x90EA;
+    public static final int GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS           = 0x90EB;
+    public static final int GL_DISPATCH_INDIRECT_BUFFER                     = 0x90EE;
+    public static final int GL_DISPATCH_INDIRECT_BUFFER_BINDING             = 0x90EF;
+    public static final int GL_TEXTURE_2D_MULTISAMPLE                       = 0x9100;
+    public static final int GL_TEXTURE_BINDING_2D_MULTISAMPLE               = 0x9104;
+    public static final int GL_TEXTURE_SAMPLES                              = 0x9106;
+    public static final int GL_TEXTURE_FIXED_SAMPLE_LOCATIONS               = 0x9107;
+    public static final int GL_SAMPLER_2D_MULTISAMPLE                       = 0x9108;
+    public static final int GL_INT_SAMPLER_2D_MULTISAMPLE                   = 0x9109;
+    public static final int GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE          = 0x910A;
+    public static final int GL_MAX_COLOR_TEXTURE_SAMPLES                    = 0x910E;
+    public static final int GL_MAX_DEPTH_TEXTURE_SAMPLES                    = 0x910F;
+    public static final int GL_MAX_INTEGER_SAMPLES                          = 0x9110;
+    public static final int GL_COMPUTE_SHADER                               = 0x91B9;
+    public static final int GL_MAX_COMPUTE_UNIFORM_BLOCKS                   = 0x91BB;
+    public static final int GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS              = 0x91BC;
+    public static final int GL_MAX_COMPUTE_IMAGE_UNIFORMS                   = 0x91BD;
+    public static final int GL_MAX_COMPUTE_WORK_GROUP_COUNT                 = 0x91BE;
+    public static final int GL_MAX_COMPUTE_WORK_GROUP_SIZE                  = 0x91BF;
+    public static final int GL_ATOMIC_COUNTER_BUFFER                        = 0x92C0;
+    public static final int GL_ATOMIC_COUNTER_BUFFER_BINDING                = 0x92C1;
+    public static final int GL_ATOMIC_COUNTER_BUFFER_START                  = 0x92C2;
+    public static final int GL_ATOMIC_COUNTER_BUFFER_SIZE                   = 0x92C3;
+    public static final int GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS            = 0x92CC;
+    public static final int GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS          = 0x92D0;
+    public static final int GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS          = 0x92D1;
+    public static final int GL_MAX_VERTEX_ATOMIC_COUNTERS                   = 0x92D2;
+    public static final int GL_MAX_FRAGMENT_ATOMIC_COUNTERS                 = 0x92D6;
+    public static final int GL_MAX_COMBINED_ATOMIC_COUNTERS                 = 0x92D7;
+    public static final int GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE               = 0x92D8;
+    public static final int GL_ACTIVE_ATOMIC_COUNTER_BUFFERS                = 0x92D9;
+    public static final int GL_UNSIGNED_INT_ATOMIC_COUNTER                  = 0x92DB;
+    public static final int GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS           = 0x92DC;
+    public static final int GL_UNIFORM                                      = 0x92E1;
+    public static final int GL_UNIFORM_BLOCK                                = 0x92E2;
+    public static final int GL_PROGRAM_INPUT                                = 0x92E3;
+    public static final int GL_PROGRAM_OUTPUT                               = 0x92E4;
+    public static final int GL_BUFFER_VARIABLE                              = 0x92E5;
+    public static final int GL_SHADER_STORAGE_BLOCK                         = 0x92E6;
+    public static final int GL_TRANSFORM_FEEDBACK_VARYING                   = 0x92F4;
+    public static final int GL_ACTIVE_RESOURCES                             = 0x92F5;
+    public static final int GL_MAX_NAME_LENGTH                              = 0x92F6;
+    public static final int GL_MAX_NUM_ACTIVE_VARIABLES                     = 0x92F7;
+    public static final int GL_NAME_LENGTH                                  = 0x92F9;
+    public static final int GL_TYPE                                         = 0x92FA;
+    public static final int GL_ARRAY_SIZE                                   = 0x92FB;
+    public static final int GL_OFFSET                                       = 0x92FC;
+    public static final int GL_BLOCK_INDEX                                  = 0x92FD;
+    public static final int GL_ARRAY_STRIDE                                 = 0x92FE;
+    public static final int GL_MATRIX_STRIDE                                = 0x92FF;
+    public static final int GL_IS_ROW_MAJOR                                 = 0x9300;
+    public static final int GL_ATOMIC_COUNTER_BUFFER_INDEX                  = 0x9301;
+    public static final int GL_BUFFER_BINDING                               = 0x9302;
+    public static final int GL_BUFFER_DATA_SIZE                             = 0x9303;
+    public static final int GL_NUM_ACTIVE_VARIABLES                         = 0x9304;
+    public static final int GL_ACTIVE_VARIABLES                             = 0x9305;
+    public static final int GL_REFERENCED_BY_VERTEX_SHADER                  = 0x9306;
+    public static final int GL_REFERENCED_BY_FRAGMENT_SHADER                = 0x930A;
+    public static final int GL_REFERENCED_BY_COMPUTE_SHADER                 = 0x930B;
+    public static final int GL_TOP_LEVEL_ARRAY_SIZE                         = 0x930C;
+    public static final int GL_TOP_LEVEL_ARRAY_STRIDE                       = 0x930D;
+    public static final int GL_LOCATION                                     = 0x930E;
+    public static final int GL_FRAMEBUFFER_DEFAULT_WIDTH                    = 0x9310;
+    public static final int GL_FRAMEBUFFER_DEFAULT_HEIGHT                   = 0x9311;
+    public static final int GL_FRAMEBUFFER_DEFAULT_SAMPLES                  = 0x9313;
+    public static final int GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS   = 0x9314;
+    public static final int GL_MAX_FRAMEBUFFER_WIDTH                        = 0x9315;
+    public static final int GL_MAX_FRAMEBUFFER_HEIGHT                       = 0x9316;
+    public static final int GL_MAX_FRAMEBUFFER_SAMPLES                      = 0x9318;
+
+    native private static void _nativeClassInit();
+    static {
+        _nativeClassInit();
+    }
+
+    private GLES31() {}
diff --git a/cmds/dumpstate/libdumpstate_default.c b/opengl/tools/glgen/stubs/gles11/GLES31cHeader.cpp
similarity index 64%
copy from cmds/dumpstate/libdumpstate_default.c
copy to opengl/tools/glgen/stubs/gles11/GLES31cHeader.cpp
index fd840df..130612d 100644
--- a/cmds/dumpstate/libdumpstate_default.c
+++ b/opengl/tools/glgen/stubs/gles11/GLES31cHeader.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 The Android Open Source Project
+ * Copyright 2014 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,9 +14,11 @@
  * limitations under the License.
  */
 
-#include "dumpstate.h"
+// This source file is automatically generated
 
-void dumpstate_board(void)
-{
-}
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#pragma GCC diagnostic ignored "-Wunused-function"
 
+#include <stdint.h>
+#include <GLES3/gl31.h>
diff --git a/opengl/tools/glgen/stubs/gles11/common.cpp b/opengl/tools/glgen/stubs/gles11/common.cpp
index c5a7a24..18ec5e3 100644
--- a/opengl/tools/glgen/stubs/gles11/common.cpp
+++ b/opengl/tools/glgen/stubs/gles11/common.cpp
@@ -1,5 +1,5 @@
-#include "jni.h"
-#include "JNIHelp.h"
+#include <jni.h>
+#include <JNIHelp.h>
 #include <android_runtime/AndroidRuntime.h>
 #include <utils/misc.h>
 #include <assert.h>
@@ -100,6 +100,116 @@
     return NULL;
 }
 
+class ByteArrayGetter {
+public:
+    static void* Get(JNIEnv* _env, jbyteArray array, jboolean* is_copy) {
+        return _env->GetByteArrayElements(array, is_copy);
+    }
+};
+class BooleanArrayGetter {
+public:
+    static void* Get(JNIEnv* _env, jbooleanArray array, jboolean* is_copy) {
+        return _env->GetBooleanArrayElements(array, is_copy);
+    }
+};
+class CharArrayGetter {
+public:
+    static void* Get(JNIEnv* _env, jcharArray array, jboolean* is_copy) {
+        return _env->GetCharArrayElements(array, is_copy);
+    }
+};
+class ShortArrayGetter {
+public:
+    static void* Get(JNIEnv* _env, jshortArray array, jboolean* is_copy) {
+        return _env->GetShortArrayElements(array, is_copy);
+    }
+};
+class IntArrayGetter {
+public:
+    static void* Get(JNIEnv* _env, jintArray array, jboolean* is_copy) {
+        return _env->GetIntArrayElements(array, is_copy);
+    }
+};
+class LongArrayGetter {
+public:
+    static void* Get(JNIEnv* _env, jlongArray array, jboolean* is_copy) {
+        return _env->GetLongArrayElements(array, is_copy);
+    }
+};
+class FloatArrayGetter {
+public:
+    static void* Get(JNIEnv* _env, jfloatArray array, jboolean* is_copy) {
+        return _env->GetFloatArrayElements(array, is_copy);
+    }
+};
+class DoubleArrayGetter {
+public:
+    static void* Get(JNIEnv* _env, jdoubleArray array, jboolean* is_copy) {
+        return _env->GetDoubleArrayElements(array, is_copy);
+    }
+};
+
+template<typename JTYPEARRAY, typename ARRAYGETTER>
+static void*
+getArrayPointer(JNIEnv *_env, JTYPEARRAY array, jboolean* is_copy) {
+    return ARRAYGETTER::Get(_env, array, is_copy);
+}
+
+class ByteArrayReleaser {
+public:
+    static void Release(JNIEnv* _env, jbyteArray array, jbyte* data, jboolean commit) {
+        _env->ReleaseByteArrayElements(array, data, commit ? 0 : JNI_ABORT);
+    }
+};
+class BooleanArrayReleaser {
+public:
+    static void Release(JNIEnv* _env, jbooleanArray array, jboolean* data, jboolean commit) {
+        _env->ReleaseBooleanArrayElements(array, data, commit ? 0 : JNI_ABORT);
+    }
+};
+class CharArrayReleaser {
+public:
+    static void Release(JNIEnv* _env, jcharArray array, jchar* data, jboolean commit) {
+        _env->ReleaseCharArrayElements(array, data, commit ? 0 : JNI_ABORT);
+    }
+};
+class ShortArrayReleaser {
+public:
+    static void Release(JNIEnv* _env, jshortArray array, jshort* data, jboolean commit) {
+        _env->ReleaseShortArrayElements(array, data, commit ? 0 : JNI_ABORT);
+    }
+};
+class IntArrayReleaser {
+public:
+    static void Release(JNIEnv* _env, jintArray array, jint* data, jboolean commit) {
+        _env->ReleaseIntArrayElements(array, data, commit ? 0 : JNI_ABORT);
+    }
+};
+class LongArrayReleaser {
+public:
+    static void Release(JNIEnv* _env, jlongArray array, jlong* data, jboolean commit) {
+        _env->ReleaseLongArrayElements(array, data, commit ? 0 : JNI_ABORT);
+    }
+};
+class FloatArrayReleaser {
+public:
+    static void Release(JNIEnv* _env, jfloatArray array, jfloat* data, jboolean commit) {
+        _env->ReleaseFloatArrayElements(array, data, commit ? 0 : JNI_ABORT);
+    }
+};
+class DoubleArrayReleaser {
+public:
+    static void Release(JNIEnv* _env, jdoubleArray array, jdouble* data, jboolean commit) {
+        _env->ReleaseDoubleArrayElements(array, data, commit ? 0 : JNI_ABORT);
+    }
+};
+
+template<typename JTYPEARRAY, typename NTYPEARRAY, typename ARRAYRELEASER>
+static void
+releaseArrayPointer(JNIEnv *_env, JTYPEARRAY array, NTYPEARRAY data, jboolean commit) {
+    ARRAYRELEASER::Release(_env, array, data, commit);
+}
+
 static void
 releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit)
 {
@@ -203,7 +313,8 @@
     return needed;
 }
 
-template <typename JTYPEARRAY, typename CTYPE, void GET(GLenum, CTYPE*)>
+template <typename JTYPEARRAY, typename ARRAYGETTER, typename NTYPEARRAY,
+          typename ARRAYRELEASER, typename CTYPE, void GET(GLenum, CTYPE*)>
 static void
 get
   (JNIEnv *_env, jobject _this, jint pname, JTYPEARRAY params_ref, jint offset) {
@@ -238,8 +349,8 @@
         _exceptionMessage = "length - offset < needed";
         goto exit;
     }
-    params_base = (CTYPE *)
-        _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0);
+    params_base = (CTYPE *) getArrayPointer<JTYPEARRAY, ARRAYGETTER>(
+        _env, params_ref, (jboolean *)0);
     params = params_base + offset;
 
     GET(
@@ -249,8 +360,8 @@
 
 exit:
     if (params_base) {
-        _env->ReleasePrimitiveArrayCritical(params_ref, params_base,
-            _exception ? JNI_ABORT: 0);
+        releaseArrayPointer<JTYPEARRAY, NTYPEARRAY, ARRAYRELEASER>(
+            _env, params_ref, params_base, !_exception);
     }
     if (_exception) {
         jniThrowException(_env, _exceptionType, _exceptionMessage);
@@ -258,20 +369,21 @@
 }
 
 
-template <typename CTYPE, void GET(GLenum, CTYPE*)>
+template <typename CTYPE, typename JTYPEARRAY, typename ARRAYGETTER, typename NTYPEARRAY,
+          typename ARRAYRELEASER, void GET(GLenum, CTYPE*)>
 static void
 getarray
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
     jint _exception = 0;
     const char * _exceptionType;
     const char * _exceptionMessage;
-    jarray _array = (jarray) 0;
+    JTYPEARRAY _array = (JTYPEARRAY) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     CTYPE *params = (CTYPE *) 0;
     int _needed = 0;
 
-    params = (CTYPE *)getPointer(_env, params_buf, &_array, &_remaining, &_bufferOffset);
+    params = (CTYPE *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
     _remaining /= sizeof(CTYPE);    // convert from bytes to item count
     _needed = getNeededCount(pname);
     // if we didn't find this pname, we just assume the user passed
@@ -284,7 +396,8 @@
         goto exit;
     }
     if (params == NULL) {
-        char * _paramsBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
+        char * _paramsBase = (char *) getArrayPointer<JTYPEARRAY, ARRAYGETTER>(
+            _env, _array, (jboolean *) 0);
         params = (CTYPE *) (_paramsBase + _bufferOffset);
     }
     GET(
@@ -294,7 +407,8 @@
 
 exit:
     if (_array) {
-        releasePointer(_env, _array, params, _exception ? JNI_FALSE : JNI_TRUE);
+        releaseArrayPointer<JTYPEARRAY, NTYPEARRAY, ARRAYRELEASER>(
+            _env, _array, (NTYPEARRAY)params, _exception ? JNI_FALSE : JNI_TRUE);
     }
     if (_exception) {
         jniThrowException(_env, _exceptionType, _exceptionMessage);
diff --git a/opengl/tools/glgen/stubs/gles11/glBindVertexBuffer.cpp b/opengl/tools/glgen/stubs/gles11/glBindVertexBuffer.cpp
new file mode 100644
index 0000000..b3b70cc
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glBindVertexBuffer.cpp
@@ -0,0 +1,15 @@
+/* void glBindVertexBuffer ( GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride ) */
+static void
+android_glBindVertexBuffer__IIJI
+  (JNIEnv *_env, jobject _this, jint bindingindex, jint buffer, jlong offset, jint stride) {
+    if (sizeof(GLintptr) != sizeof(jlong) && (offset < LONG_MIN || offset > LONG_MAX)) {
+        jniThrowException(_env, "java/lang/IllegalArgumentException", "offset too large");
+        return;
+    }
+    glBindVertexBuffer(
+        (GLuint)bindingindex,
+        (GLuint)buffer,
+        (GLintptr)offset,
+        (GLsizei)stride
+    );
+}
diff --git a/opengl/tools/glgen/stubs/gles11/glBindVertexBuffer.java b/opengl/tools/glgen/stubs/gles11/glBindVertexBuffer.java
new file mode 100644
index 0000000..bab2e89
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glBindVertexBuffer.java
@@ -0,0 +1,9 @@
+    // C function void glBindVertexBuffer ( GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride )
+
+    public static native void glBindVertexBuffer(
+        int bindingindex,
+        int buffer,
+        long offset,
+        int stride
+    );
+
diff --git a/opengl/tools/glgen/stubs/gles11/glBindVertexBuffer.nativeReg b/opengl/tools/glgen/stubs/gles11/glBindVertexBuffer.nativeReg
new file mode 100644
index 0000000..f3d5979
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glBindVertexBuffer.nativeReg
@@ -0,0 +1 @@
+{"glBindVertexBuffer", "(IIJI)V", (void *) android_glBindVertexBuffer__IIJI },
diff --git a/opengl/tools/glgen/stubs/gles11/glCreateShaderProgramv.cpp b/opengl/tools/glgen/stubs/gles11/glCreateShaderProgramv.cpp
new file mode 100644
index 0000000..e701481
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glCreateShaderProgramv.cpp
@@ -0,0 +1,8 @@
+/* GLuint glCreateShaderProgramv ( GLenum type, GLsizei count, const GLchar *const *strings ) */
+static jint
+android_glCreateShaderProgramv
+  (JNIEnv *_env, jobject _this, jint type, jobjectArray strings) {
+
+    jniThrowException(_env, "java/lang/UnsupportedOperationException", "not yet implemented");
+    return 0;
+}
diff --git a/opengl/tools/glgen/stubs/gles11/glCreateShaderProgramv.java b/opengl/tools/glgen/stubs/gles11/glCreateShaderProgramv.java
new file mode 100644
index 0000000..5f7b41b
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glCreateShaderProgramv.java
@@ -0,0 +1,7 @@
+    // C function GLuint glCreateShaderProgramv ( GLenum type, GLsizei count, const GLchar *const *strings )
+
+    public static native int glCreateShaderProgramv(
+        int type,
+        String[] strings
+    );
+
diff --git a/opengl/tools/glgen/stubs/gles11/glCreateShaderProgramv.nativeReg b/opengl/tools/glgen/stubs/gles11/glCreateShaderProgramv.nativeReg
new file mode 100644
index 0000000..2079d83
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glCreateShaderProgramv.nativeReg
@@ -0,0 +1 @@
+{"glCreateShaderProgramv", "(I[Ljava/lang/String;)I", (void *) android_glCreateShaderProgramv },
diff --git a/opengl/tools/glgen/stubs/gles11/glDebugMessageCallbackKHR.cpp b/opengl/tools/glgen/stubs/gles11/glDebugMessageCallbackKHR.cpp
new file mode 100644
index 0000000..8601242
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glDebugMessageCallbackKHR.cpp
@@ -0,0 +1,5 @@
+/* void glDebugMessageCallbackKHR ( GLDEBUGPROCKHR callback, const void *userParam ) */
+static void
+android_glDebugMessageCallbackKHR(JNIEnv *_env, jobject _this, jobject callback) {
+    jniThrowException(_env, "java/lang/UnsupportedOperationException", "not yet implemented");
+}
diff --git a/opengl/tools/glgen/stubs/gles11/glDebugMessageCallbackKHR.java b/opengl/tools/glgen/stubs/gles11/glDebugMessageCallbackKHR.java
new file mode 100644
index 0000000..3e8cf22
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glDebugMessageCallbackKHR.java
@@ -0,0 +1,8 @@
+    // C function void glDebugMessageCallbackKHR ( GLDEBUGPROCKHR callback, const void *userParam )
+
+    public interface DebugProcKHR {
+        void onMessage(int source, int type, int id, int severity, String message);
+    }
+
+    public static native void glDebugMessageCallbackKHR(DebugProcKHR callback);
+
diff --git a/opengl/tools/glgen/stubs/gles11/glDebugMessageCallbackKHR.nativeReg b/opengl/tools/glgen/stubs/gles11/glDebugMessageCallbackKHR.nativeReg
new file mode 100644
index 0000000..8e94658
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glDebugMessageCallbackKHR.nativeReg
@@ -0,0 +1 @@
+{"glDebugMessageCallbackKHR", "(Landroid/opengl/GLES31Ext$DebugProcKHR;)V", (void *) android_glDebugMessageCallbackKHR },
diff --git a/opengl/tools/glgen/stubs/gles11/glDebugMessageInsertKHR.cpp b/opengl/tools/glgen/stubs/gles11/glDebugMessageInsertKHR.cpp
new file mode 100644
index 0000000..9633c93
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glDebugMessageInsertKHR.cpp
@@ -0,0 +1,38 @@
+/* void glDebugMessageInsertKHR ( GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf ) */
+static void
+android_glDebugMessageInsertKHR__IIIILjava_lang_String_2
+  (JNIEnv *_env, jobject _this, jint source, jint type, jint id, jint severity, jstring buf) {
+    jint _exception = 0;
+    const char * _exceptionType = NULL;
+    const char * _exceptionMessage = NULL;
+    const char* _nativebuf = 0;
+    jint _length = 0;
+
+    if (!buf) {
+        _exception = 1;
+        _exceptionType = "java/lang/IllegalArgumentException";
+        _exceptionMessage = "buf == null";
+        goto exit;
+    }
+    _nativebuf = _env->GetStringUTFChars(buf, 0);
+    _length = _env->GetStringUTFLength(buf);
+
+    glDebugMessageInsertKHR(
+        (GLenum)source,
+        (GLenum)type,
+        (GLuint)id,
+        (GLenum)severity,
+        (GLsizei)_length,
+        (GLchar *)_nativebuf
+    );
+
+exit:
+    if (_nativebuf) {
+        _env->ReleaseStringUTFChars(buf, _nativebuf);
+    }
+
+    if (_exception) {
+        jniThrowException(_env, _exceptionType, _exceptionMessage);
+    }
+}
+
diff --git a/opengl/tools/glgen/stubs/gles11/glDebugMessageInsertKHR.java b/opengl/tools/glgen/stubs/gles11/glDebugMessageInsertKHR.java
new file mode 100644
index 0000000..eb471c6
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glDebugMessageInsertKHR.java
@@ -0,0 +1,10 @@
+    // C function void glDebugMessageInsertKHR ( GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf )
+
+    public static native void glDebugMessageInsertKHR(
+        int source,
+        int type,
+        int id,
+        int severity,
+        String buf
+    );
+
diff --git a/opengl/tools/glgen/stubs/gles11/glDebugMessageInsertKHR.nativeReg b/opengl/tools/glgen/stubs/gles11/glDebugMessageInsertKHR.nativeReg
new file mode 100644
index 0000000..7e6e975
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glDebugMessageInsertKHR.nativeReg
@@ -0,0 +1 @@
+{"glDebugMessageInsertKHR", "(IIIILjava/lang/String;)V", (void *) android_glDebugMessageInsertKHR__IIIILjava_lang_String_2 },
diff --git a/opengl/tools/glgen/stubs/gles11/glDispatchComputeIndirect.cpp b/opengl/tools/glgen/stubs/gles11/glDispatchComputeIndirect.cpp
new file mode 100644
index 0000000..3f89a8b
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glDispatchComputeIndirect.cpp
@@ -0,0 +1,13 @@
+/* void glDispatchComputeIndirect ( GLintptr indirect ) */
+static void android_glDispatchComputeIndirect(JNIEnv *_env, jobject, jlong indirect) {
+    // 'indirect' is a byte offset, not a pointer. GL checks for negative and too-large values.
+    // Here we only need to check for successful 64-bit to 32-bit conversion.
+    // - jlong is a int64_t (jni.h)
+    // - GLintptr is a long (khrplatform.h)
+    if (sizeof(GLintptr) != sizeof(jlong) && (indirect < LONG_MIN || indirect > LONG_MAX)) {
+        jniThrowException(_env, "java/lang/IllegalArgumentException", "indirect offset too large");
+        return;
+    }
+    glDispatchComputeIndirect((GLintptr)indirect);
+}
+
diff --git a/opengl/tools/glgen/stubs/gles11/glDispatchComputeIndirect.java b/opengl/tools/glgen/stubs/gles11/glDispatchComputeIndirect.java
new file mode 100644
index 0000000..92862f3
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glDispatchComputeIndirect.java
@@ -0,0 +1,4 @@
+    // C function void glDispatchComputeIndirect ( GLintptr indirect );
+
+    public static native void glDispatchComputeIndirect(long indirect);
+
diff --git a/opengl/tools/glgen/stubs/gles11/glDispatchComputeIndirect.nativeReg b/opengl/tools/glgen/stubs/gles11/glDispatchComputeIndirect.nativeReg
new file mode 100644
index 0000000..9ed264a
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glDispatchComputeIndirect.nativeReg
@@ -0,0 +1 @@
+{"glDispatchComputeIndirect", "(J)V", (void *) android_glDispatchComputeIndirect },
diff --git a/opengl/tools/glgen/stubs/gles11/glDrawArraysIndirect.cpp b/opengl/tools/glgen/stubs/gles11/glDrawArraysIndirect.cpp
new file mode 100644
index 0000000..eda2e46
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glDrawArraysIndirect.cpp
@@ -0,0 +1,12 @@
+/* void glDrawArraysIndirect ( GLenum mode, const void *indirect ) */
+static void android_glDrawArraysIndirect(JNIEnv *_env, jobject, int mode, jlong indirect) {
+    // In OpenGL ES, 'indirect' is a byte offset into a buffer, not a raw pointer.
+    // GL checks for too-large values. Here we only need to check for successful signed 64-bit
+    // to unsigned 32-bit conversion.
+    if (sizeof(void*) != sizeof(jlong) && indirect > static_cast<jlong>(UINT32_MAX)) {
+        jniThrowException(_env, "java/lang/IllegalArgumentException", "indirect offset too large");
+        return;
+    }
+    glDrawArraysIndirect(mode, (const void*)indirect);
+}
+
diff --git a/opengl/tools/glgen/stubs/gles11/glDrawArraysIndirect.java b/opengl/tools/glgen/stubs/gles11/glDrawArraysIndirect.java
new file mode 100644
index 0000000..a8f0a80
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glDrawArraysIndirect.java
@@ -0,0 +1,4 @@
+    // C function void glDrawArraysIndirect ( GLenum mode, const void *indirect );
+
+    public static native void glDrawArraysIndirect(int mode, long indirect);
+
diff --git a/opengl/tools/glgen/stubs/gles11/glDrawArraysIndirect.nativeReg b/opengl/tools/glgen/stubs/gles11/glDrawArraysIndirect.nativeReg
new file mode 100644
index 0000000..7e6b0e6
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glDrawArraysIndirect.nativeReg
@@ -0,0 +1 @@
+{"glDrawArraysIndirect", "(IJ)V", (void *) android_glDrawArraysIndirect },
diff --git a/opengl/tools/glgen/stubs/gles11/glDrawElementsIndirect.cpp b/opengl/tools/glgen/stubs/gles11/glDrawElementsIndirect.cpp
new file mode 100644
index 0000000..a091dc9
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glDrawElementsIndirect.cpp
@@ -0,0 +1,12 @@
+/* void glDrawElementsIndirect ( GLenum mode, GLenum type, const void *indirect ) */
+static void android_glDrawElementsIndirect(JNIEnv *_env, jobject, jint mode, jint type, jlong indirect) {
+    // In OpenGL ES, 'indirect' is a byte offset into a buffer, not a raw pointer.
+    // GL checks for too-large values. Here we only need to check for successful signed 64-bit
+    // to unsigned 32-bit conversion.
+    if (sizeof(void*) != sizeof(jlong) && indirect > static_cast<jlong>(UINT32_MAX)) {
+        jniThrowException(_env, "java/lang/IllegalArgumentException", "indirect offset too large");
+        return;
+    }
+    glDrawElementsIndirect(mode, type, (const void*)indirect);
+}
+
diff --git a/opengl/tools/glgen/stubs/gles11/glDrawElementsIndirect.java b/opengl/tools/glgen/stubs/gles11/glDrawElementsIndirect.java
new file mode 100644
index 0000000..4a8d84d
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glDrawElementsIndirect.java
@@ -0,0 +1,4 @@
+    // C function glDrawElementsIndirect ( GLenum mode, GLenum type, const void *indirect );
+
+    public static native void glDrawElementsIndirect(int mode, int type, long indirect);
+
diff --git a/opengl/tools/glgen/stubs/gles11/glDrawElementsIndirect.nativeReg b/opengl/tools/glgen/stubs/gles11/glDrawElementsIndirect.nativeReg
new file mode 100644
index 0000000..0c11fd2
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glDrawElementsIndirect.nativeReg
@@ -0,0 +1 @@
+{"glDrawElementsIndirect", "(IIJ)V", (void *) android_glDrawElementsIndirect },
diff --git a/opengl/tools/glgen/stubs/gles11/glDrawElementsInstanced.cpp b/opengl/tools/glgen/stubs/gles11/glDrawElementsInstanced.cpp
index 41df486..86decfb 100644
--- a/opengl/tools/glgen/stubs/gles11/glDrawElementsInstanced.cpp
+++ b/opengl/tools/glgen/stubs/gles11/glDrawElementsInstanced.cpp
@@ -32,8 +32,7 @@
         (GLenum)mode,
         (GLsizei)count,
         (GLenum)type,
-        (GLvoid *)indicesOffset,
+        (GLvoid *)static_cast<uintptr_t>(indicesOffset),
         (GLsizei)instanceCount
     );
 }
-
diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.cpp b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.cpp
index 7d414d8..a8d63d9 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.cpp
+++ b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.cpp
@@ -32,7 +32,7 @@
     }
     _lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset;
     length_base = (GLsizei *)
-        _env->GetPrimitiveArrayCritical(length_ref, (jboolean *)0);
+        _env->GetIntArrayElements(length_ref, (jboolean *)0);
     length = length_base + lengthOffset;
 
     if (!size_ref) {
@@ -49,7 +49,7 @@
     }
     _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset;
     size_base = (GLint *)
-        _env->GetPrimitiveArrayCritical(size_ref, (jboolean *)0);
+        _env->GetIntArrayElements(size_ref, (jboolean *)0);
     size = size_base + sizeOffset;
 
     if (!type_ref) {
@@ -66,7 +66,7 @@
     }
     _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset;
     type_base = (GLenum *)
-        _env->GetPrimitiveArrayCritical(type_ref, (jboolean *)0);
+        _env->GetIntArrayElements(type_ref, (jboolean *)0);
     type = type_base + typeOffset;
 
     if (!name_ref) {
@@ -83,7 +83,7 @@
     }
     _nameRemaining = _env->GetArrayLength(name_ref) - nameOffset;
     name_base = (char *)
-        _env->GetPrimitiveArrayCritical(name_ref, (jboolean *)0);
+        _env->GetByteArrayElements(name_ref, (jboolean *)0);
     name = name_base + nameOffset;
 
     glGetActiveAttrib(
@@ -98,19 +98,19 @@
 
 exit:
     if (name_base) {
-        _env->ReleasePrimitiveArrayCritical(name_ref, name_base,
+        _env->ReleaseByteArrayElements(name_ref, (jbyte*)name_base,
             _exception ? JNI_ABORT: 0);
     }
     if (type_base) {
-        _env->ReleasePrimitiveArrayCritical(type_ref, type_base,
+        _env->ReleaseIntArrayElements(type_ref, (jint*)type_base,
             _exception ? JNI_ABORT: 0);
     }
     if (size_base) {
-        _env->ReleasePrimitiveArrayCritical(size_ref, size_base,
+        _env->ReleaseIntArrayElements(size_ref, (jint*)size_base,
             _exception ? JNI_ABORT: 0);
     }
     if (length_base) {
-        _env->ReleasePrimitiveArrayCritical(length_ref, length_base,
+        _env->ReleaseIntArrayElements(length_ref, (jint*)length_base,
             _exception ? JNI_ABORT: 0);
     }
     if (_exception) {
@@ -122,11 +122,11 @@
 static void
 android_glGetActiveAttrib__IIILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2B
   (JNIEnv *_env, jobject _this, jint program, jint index, jint bufsize, jobject length_buf, jobject size_buf, jobject type_buf, jbyte name) {
-    jarray _lengthArray = (jarray) 0;
+    jintArray _lengthArray = (jintArray) 0;
     jint _lengthBufferOffset = (jint) 0;
-    jarray _sizeArray = (jarray) 0;
+    jintArray _sizeArray = (jintArray) 0;
     jint _sizeBufferOffset = (jint) 0;
-    jarray _typeArray = (jarray) 0;
+    jintArray _typeArray = (jintArray) 0;
     jint _typeBufferOffset = (jint) 0;
     jint _lengthRemaining;
     GLsizei *length = (GLsizei *) 0;
@@ -135,19 +135,19 @@
     jint _typeRemaining;
     GLenum *type = (GLenum *) 0;
 
-    length = (GLsizei *)getPointer(_env, length_buf, &_lengthArray, &_lengthRemaining, &_lengthBufferOffset);
-    size = (GLint *)getPointer(_env, size_buf, &_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
-    type = (GLenum *)getPointer(_env, type_buf, &_typeArray, &_typeRemaining, &_typeBufferOffset);
+    length = (GLsizei *)getPointer(_env, length_buf, (jarray*)&_lengthArray, &_lengthRemaining, &_lengthBufferOffset);
+    size = (GLint *)getPointer(_env, size_buf, (jarray*)&_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
+    type = (GLenum *)getPointer(_env, type_buf, (jarray*)&_typeArray, &_typeRemaining, &_typeBufferOffset);
     if (length == NULL) {
-        char * _lengthBase = (char *)_env->GetPrimitiveArrayCritical(_lengthArray, (jboolean *) 0);
+        char * _lengthBase = (char *)_env->GetIntArrayElements(_lengthArray, (jboolean *) 0);
         length = (GLsizei *) (_lengthBase + _lengthBufferOffset);
     }
     if (size == NULL) {
-        char * _sizeBase = (char *)_env->GetPrimitiveArrayCritical(_sizeArray, (jboolean *) 0);
+        char * _sizeBase = (char *)_env->GetIntArrayElements(_sizeArray, (jboolean *) 0);
         size = (GLint *) (_sizeBase + _sizeBufferOffset);
     }
     if (type == NULL) {
-        char * _typeBase = (char *)_env->GetPrimitiveArrayCritical(_typeArray, (jboolean *) 0);
+        char * _typeBase = (char *)_env->GetIntArrayElements(_typeArray, (jboolean *) 0);
         type = (GLenum *) (_typeBase + _typeBufferOffset);
     }
     glGetActiveAttrib(
@@ -160,13 +160,13 @@
         reinterpret_cast<char *>(name)
     );
     if (_typeArray) {
-        releasePointer(_env, _typeArray, type, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _typeArray, (jint*)type, JNI_TRUE);
     }
     if (_sizeArray) {
-        releasePointer(_env, _sizeArray, size, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _sizeArray, (jint*)size, JNI_TRUE);
     }
     if (_lengthArray) {
-        releasePointer(_env, _lengthArray, length, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _lengthArray, (jint*)length, JNI_TRUE);
     }
 }
 
@@ -211,7 +211,7 @@
     }
     _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset;
     size_base = (GLint *)
-        _env->GetPrimitiveArrayCritical(size_ref, (jboolean *)0);
+        _env->GetIntArrayElements(size_ref, (jboolean *)0);
     size = size_base + sizeOffset;
 
     if (!type_ref) {
@@ -228,7 +228,7 @@
     }
     _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset;
     type_base = (GLenum *)
-        _env->GetPrimitiveArrayCritical(type_ref, (jboolean *)0);
+        _env->GetIntArrayElements(type_ref, (jboolean *)0);
     type = type_base + typeOffset;
 
     glGetActiveAttrib(
@@ -242,11 +242,11 @@
     );
 exit:
     if (type_base) {
-        _env->ReleasePrimitiveArrayCritical(type_ref, type_base,
+        _env->ReleaseIntArrayElements(type_ref, (jint*)type_base,
             _exception ? JNI_ABORT: 0);
     }
     if (size_base) {
-        _env->ReleasePrimitiveArrayCritical(size_ref, size_base,
+        _env->ReleaseIntArrayElements(size_ref, (jint*)size_base,
             _exception ? JNI_ABORT: 0);
     }
     if (_exception != 1) {
@@ -269,9 +269,9 @@
 static jstring
 android_glGetActiveAttrib2
   (JNIEnv *_env, jobject _this, jint program, jint index, jobject size_buf, jobject type_buf) {
-    jarray _sizeArray = (jarray) 0;
+    jintArray _sizeArray = (jintArray) 0;
     jint _sizeBufferOffset = (jint) 0;
-    jarray _typeArray = (jarray) 0;
+    jintArray _typeArray = (jintArray) 0;
     jint _typeBufferOffset = (jint) 0;
     jint _lengthRemaining;
     GLsizei *length = (GLsizei *) 0;
@@ -294,14 +294,14 @@
         return NULL;
     }
 
-    size = (GLint *)getPointer(_env, size_buf, &_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
-    type = (GLenum *)getPointer(_env, type_buf, &_typeArray, &_typeRemaining, &_typeBufferOffset);
+    size = (GLint *)getPointer(_env, size_buf, (jarray*)&_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
+    type = (GLenum *)getPointer(_env, type_buf, (jarray*)&_typeArray, &_typeRemaining, &_typeBufferOffset);
     if (size == NULL) {
-        char * _sizeBase = (char *)_env->GetPrimitiveArrayCritical(_sizeArray, (jboolean *) 0);
+        char * _sizeBase = (char *)_env->GetIntArrayElements(_sizeArray, (jboolean *) 0);
         size = (GLint *) (_sizeBase + _sizeBufferOffset);
     }
     if (type == NULL) {
-        char * _typeBase = (char *)_env->GetPrimitiveArrayCritical(_typeArray, (jboolean *) 0);
+        char * _typeBase = (char *)_env->GetIntArrayElements(_typeArray, (jboolean *) 0);
         type = (GLenum *) (_typeBase + _typeBufferOffset);
     }
     glGetActiveAttrib(
@@ -315,10 +315,10 @@
     );
 
     if (_typeArray) {
-        releasePointer(_env, _typeArray, type, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _typeArray, (jint*)type, JNI_TRUE);
     }
     if (_sizeArray) {
-        releasePointer(_env, _sizeArray, size, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _sizeArray, (jint*)size, JNI_TRUE);
     }
     result = _env->NewStringUTF(buf);
     if (buf) {
diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.java b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.java
index bad2137..d66200f 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.java
+++ b/opengl/tools/glgen/stubs/gles11/glGetActiveAttrib.java
@@ -16,6 +16,7 @@
 
     // C function void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name )
 
+    /** @hide Method is broken, but used to be public (b/6006380) */
     public static native void glGetActiveAttrib(
         int program,
         int index,
diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.cpp b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.cpp
index a7376ba..68e8389 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.cpp
+++ b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.cpp
@@ -32,7 +32,7 @@
     }
     _lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset;
     length_base = (GLsizei *)
-        _env->GetPrimitiveArrayCritical(length_ref, (jboolean *)0);
+        _env->GetIntArrayElements(length_ref, (jboolean *)0);
     length = length_base + lengthOffset;
 
     if (!size_ref) {
@@ -49,7 +49,7 @@
     }
     _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset;
     size_base = (GLint *)
-        _env->GetPrimitiveArrayCritical(size_ref, (jboolean *)0);
+        _env->GetIntArrayElements(size_ref, (jboolean *)0);
     size = size_base + sizeOffset;
 
     if (!type_ref) {
@@ -66,7 +66,7 @@
     }
     _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset;
     type_base = (GLenum *)
-        _env->GetPrimitiveArrayCritical(type_ref, (jboolean *)0);
+        _env->GetIntArrayElements(type_ref, (jboolean *)0);
     type = type_base + typeOffset;
 
     if (!name_ref) {
@@ -83,7 +83,7 @@
     }
     _nameRemaining = _env->GetArrayLength(name_ref) - nameOffset;
     name_base = (char *)
-        _env->GetPrimitiveArrayCritical(name_ref, (jboolean *)0);
+        _env->GetByteArrayElements(name_ref, (jboolean *)0);
     name = name_base + nameOffset;
 
     glGetActiveUniform(
@@ -98,19 +98,19 @@
 
 exit:
     if (name_base) {
-        _env->ReleasePrimitiveArrayCritical(name_ref, name_base,
+        _env->ReleaseByteArrayElements(name_ref, (jbyte*)name_base,
             _exception ? JNI_ABORT: 0);
     }
     if (type_base) {
-        _env->ReleasePrimitiveArrayCritical(type_ref, type_base,
+        _env->ReleaseIntArrayElements(type_ref, (jint*)type_base,
             _exception ? JNI_ABORT: 0);
     }
     if (size_base) {
-        _env->ReleasePrimitiveArrayCritical(size_ref, size_base,
+        _env->ReleaseIntArrayElements(size_ref, (jint*)size_base,
             _exception ? JNI_ABORT: 0);
     }
     if (length_base) {
-        _env->ReleasePrimitiveArrayCritical(length_ref, length_base,
+        _env->ReleaseIntArrayElements(length_ref, (jint*)length_base,
             _exception ? JNI_ABORT: 0);
     }
     if (_exception) {
@@ -122,11 +122,11 @@
 static void
 android_glGetActiveUniform__IIILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2B
   (JNIEnv *_env, jobject _this, jint program, jint index, jint bufsize, jobject length_buf, jobject size_buf, jobject type_buf, jbyte name) {
-    jarray _lengthArray = (jarray) 0;
+    jintArray _lengthArray = (jintArray) 0;
     jint _lengthBufferOffset = (jint) 0;
-    jarray _sizeArray = (jarray) 0;
+    jintArray _sizeArray = (jintArray) 0;
     jint _sizeBufferOffset = (jint) 0;
-    jarray _typeArray = (jarray) 0;
+    jintArray _typeArray = (jintArray) 0;
     jint _typeBufferOffset = (jint) 0;
     jint _lengthRemaining;
     GLsizei *length = (GLsizei *) 0;
@@ -135,19 +135,19 @@
     jint _typeRemaining;
     GLenum *type = (GLenum *) 0;
 
-    length = (GLsizei *)getPointer(_env, length_buf, &_lengthArray, &_lengthRemaining, &_lengthBufferOffset);
-    size = (GLint *)getPointer(_env, size_buf, &_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
-    type = (GLenum *)getPointer(_env, type_buf, &_typeArray, &_typeRemaining, &_typeBufferOffset);
+    length = (GLsizei *)getPointer(_env, length_buf, (jarray*)&_lengthArray, &_lengthRemaining, &_lengthBufferOffset);
+    size = (GLint *)getPointer(_env, size_buf, (jarray*)&_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
+    type = (GLenum *)getPointer(_env, type_buf, (jarray*)&_typeArray, &_typeRemaining, &_typeBufferOffset);
     if (length == NULL) {
-        char * _lengthBase = (char *)_env->GetPrimitiveArrayCritical(_lengthArray, (jboolean *) 0);
+        char * _lengthBase = (char *)_env->GetIntArrayElements(_lengthArray, (jboolean *) 0);
         length = (GLsizei *) (_lengthBase + _lengthBufferOffset);
     }
     if (size == NULL) {
-        char * _sizeBase = (char *)_env->GetPrimitiveArrayCritical(_sizeArray, (jboolean *) 0);
+        char * _sizeBase = (char *)_env->GetIntArrayElements(_sizeArray, (jboolean *) 0);
         size = (GLint *) (_sizeBase + _sizeBufferOffset);
     }
     if (type == NULL) {
-        char * _typeBase = (char *)_env->GetPrimitiveArrayCritical(_typeArray, (jboolean *) 0);
+        char * _typeBase = (char *)_env->GetIntArrayElements(_typeArray, (jboolean *) 0);
         type = (GLenum *) (_typeBase + _typeBufferOffset);
     }
     glGetActiveUniform(
@@ -160,13 +160,13 @@
         reinterpret_cast<char *>(name)
     );
     if (_typeArray) {
-        releasePointer(_env, _typeArray, type, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _typeArray, (jint*)type, JNI_TRUE);
     }
     if (_sizeArray) {
-        releasePointer(_env, _sizeArray, size, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _sizeArray, (jint*)size, JNI_TRUE);
     }
     if (_lengthArray) {
-        releasePointer(_env, _lengthArray, length, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _lengthArray, (jint*)length, JNI_TRUE);
     }
 }
 
@@ -214,7 +214,7 @@
     }
     _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset;
     size_base = (GLint *)
-        _env->GetPrimitiveArrayCritical(size_ref, (jboolean *)0);
+        _env->GetIntArrayElements(size_ref, (jboolean *)0);
     size = size_base + sizeOffset;
 
     if (!type_ref) {
@@ -231,7 +231,7 @@
     }
     _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset;
     type_base = (GLenum *)
-        _env->GetPrimitiveArrayCritical(type_ref, (jboolean *)0);
+        _env->GetIntArrayElements(type_ref, (jboolean *)0);
     type = type_base + typeOffset;
 
     glGetActiveUniform(
@@ -246,11 +246,11 @@
 
 exit:
     if (type_base) {
-        _env->ReleasePrimitiveArrayCritical(type_ref, type_base,
+        _env->ReleaseIntArrayElements(type_ref, (jint*)type_base,
             _exception ? JNI_ABORT: 0);
     }
     if (size_base) {
-        _env->ReleasePrimitiveArrayCritical(size_ref, size_base,
+        _env->ReleaseIntArrayElements(size_ref, (jint*)size_base,
             _exception ? JNI_ABORT: 0);
     }
     if (_exception != 1) {
@@ -272,9 +272,9 @@
 static jstring
 android_glGetActiveUniform2
   (JNIEnv *_env, jobject _this, jint program, jint index, jobject size_buf, jobject type_buf) {
-    jarray _sizeArray = (jarray) 0;
+    jintArray _sizeArray = (jintArray) 0;
     jint _sizeBufferOffset = (jint) 0;
-    jarray _typeArray = (jarray) 0;
+    jintArray _typeArray = (jintArray) 0;
     jint _typeBufferOffset = (jint) 0;
     jint _sizeRemaining;
     GLint *size = (GLint *) 0;
@@ -294,15 +294,15 @@
         return NULL;
     }
 
-    size = (GLint *)getPointer(_env, size_buf, &_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
-    type = (GLenum *)getPointer(_env, type_buf, &_typeArray, &_typeRemaining, &_typeBufferOffset);
+    size = (GLint *)getPointer(_env, size_buf, (jarray*)&_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
+    type = (GLenum *)getPointer(_env, type_buf, (jarray*)&_typeArray, &_typeRemaining, &_typeBufferOffset);
 
     if (size == NULL) {
-        char * _sizeBase = (char *)_env->GetPrimitiveArrayCritical(_sizeArray, (jboolean *) 0);
+        char * _sizeBase = (char *)_env->GetIntArrayElements(_sizeArray, (jboolean *) 0);
         size = (GLint *) (_sizeBase + _sizeBufferOffset);
     }
     if (type == NULL) {
-        char * _typeBase = (char *)_env->GetPrimitiveArrayCritical(_typeArray, (jboolean *) 0);
+        char * _typeBase = (char *)_env->GetIntArrayElements(_typeArray, (jboolean *) 0);
         type = (GLenum *) (_typeBase + _typeBufferOffset);
     }
     glGetActiveUniform(
@@ -316,10 +316,10 @@
     );
 
     if (_typeArray) {
-        releasePointer(_env, _typeArray, type, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _typeArray, (jint*)type, JNI_TRUE);
     }
     if (_sizeArray) {
-        releasePointer(_env, _sizeArray, size, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _sizeArray, (jint*)size, JNI_TRUE);
     }
     result = _env->NewStringUTF(buf);
     if (buf) {
diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.java b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.java
index 28aaa78..8c8d5a2 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.java
+++ b/opengl/tools/glgen/stubs/gles11/glGetActiveUniform.java
@@ -16,6 +16,7 @@
 
     // C function void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name )
 
+    /** @hide Method is broken, but used to be public (b/6006380) */
     public static native void glGetActiveUniform(
         int program,
         int index,
diff --git a/opengl/tools/glgen/stubs/gles11/glGetActiveUniformBlockName.cpp b/opengl/tools/glgen/stubs/gles11/glGetActiveUniformBlockName.cpp
index bb6ae7c..6104c84 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetActiveUniformBlockName.cpp
+++ b/opengl/tools/glgen/stubs/gles11/glGetActiveUniformBlockName.cpp
@@ -25,7 +25,7 @@
         goto exit;
     }
     _lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset;
-    _length_base = (GLsizei*)_env->GetPrimitiveArrayCritical(
+    _length_base = (GLsizei*)_env->GetIntArrayElements(
             length_ref, (jboolean*)0);
     _length = _length_base + lengthOffset;
 
@@ -42,7 +42,7 @@
         goto exit;
     }
     _nameRemaining = _env->GetArrayLength(name_ref) - nameOffset;
-    _name_base = (GLchar*)_env->GetPrimitiveArrayCritical(
+    _name_base = (GLchar*)_env->GetByteArrayElements(
             name_ref, (jboolean*)0);
     _name = _name_base + nameOffset;
 
@@ -56,11 +56,11 @@
 
 exit:
     if (_name_base) {
-        _env->ReleasePrimitiveArrayCritical(name_ref, _name_base,
+        _env->ReleaseByteArrayElements(name_ref, (jbyte*)_name_base,
             _exception ? JNI_ABORT: 0);
     }
     if (_length_base) {
-        _env->ReleasePrimitiveArrayCritical(length_ref, _length_base,
+        _env->ReleaseIntArrayElements(length_ref, (jint*)_length_base,
             _exception ? JNI_ABORT: 0);
     }
     if (_exception) {
@@ -124,4 +124,3 @@
     free(name);
     return result;
 }
-
diff --git a/opengl/tools/glgen/stubs/gles11/glGetBooleanv.cpp b/opengl/tools/glgen/stubs/gles11/glGetBooleanv.cpp
index 00c52af..7874bd8 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetBooleanv.cpp
+++ b/opengl/tools/glgen/stubs/gles11/glGetBooleanv.cpp
@@ -2,12 +2,14 @@
 static void
 android_glGetBooleanv__I_3ZI
   (JNIEnv *_env, jobject _this, jint pname, jbooleanArray params_ref, jint offset) {
-    get<jbooleanArray, GLboolean, glGetBooleanv>(_env, _this, pname, params_ref, offset);
+    get<jbooleanArray, BooleanArrayGetter, jboolean*, BooleanArrayReleaser, GLboolean, glGetBooleanv>(
+        _env, _this, pname, params_ref, offset);
 }
 
 /* void glGetBooleanv ( GLenum pname, GLboolean *params ) */
 static void
 android_glGetBooleanv__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
-    getarray<GLboolean, glGetBooleanv>(_env, _this, pname, params_buf);
+    getarray<GLboolean, jintArray, IntArrayGetter, jint*, IntArrayReleaser, glGetBooleanv>(
+        _env, _this, pname, params_buf);
 }
diff --git a/opengl/tools/glgen/stubs/gles11/glGetDebugMessageLogKHR.cpp b/opengl/tools/glgen/stubs/gles11/glGetDebugMessageLogKHR.cpp
new file mode 100644
index 0000000..98bcbdf
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetDebugMessageLogKHR.cpp
@@ -0,0 +1,31 @@
+/* GLuint glGetDebugMessageLogKHR ( GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog ) */
+static jint
+android_glGetDebugMessageLogKHR__II_3II_3II_3II_3II_3II_3BI
+  (JNIEnv *_env, jobject _this, jint count, jint bufSize, jintArray sources_ref, jint sourcesOffset, jintArray types_ref, jint typesOffset, jintArray ids_ref, jint idsOffset, jintArray severities_ref, jint severitiesOffset, jintArray lengths_ref, jint lengthsOffset, jbyteArray messageLog_ref, jint messageLogOffset) {
+    jniThrowException(_env, "java/lang/UnsupportedOperationException", "not yet implemented");
+    return 0;
+}
+
+/* GLuint glGetDebugMessageLogKHR ( GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog ) */
+static uint
+android_glGetDebugMessageLogKHR__ILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_ByteBuffer_2
+  (JNIEnv *_env, jobject _this, jint count, jobject sources_ref, jobject types_ref, jobject ids_ref, jobject severities_ref, jobject lengths_ref, jobject messageLog_ref) {
+    jniThrowException(_env, "java/lang/UnsupportedOperationException", "not yet implemented");
+    return 0;
+}
+
+/* GLuint glGetDebugMessageLogKHR ( GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog ) */
+static jobjectArray
+android_glGetDebugMessageLogKHR__I_3II_3II_3II_3II
+  (JNIEnv *_env, jobject _this, jint count, jintArray sources_ref, jint sourcesOffset, jintArray types_ref, jint typesOffset, jintArray ids_ref, jint idsOffset, jintArray severities_ref, jint severitiesOffset) {
+    jniThrowException(_env, "java/lang/UnsupportedOperationException", "not yet implemented");
+    return 0;
+}
+
+/* GLuint glGetDebugMessageLogKHR ( GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog ) */
+static jobjectArray
+android_glGetDebugMessageLogKHR__ILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2
+  (JNIEnv *_env, jobject _this, jint count, jobject sources_ref, jobject types_ref, jobject ids_ref, jobject severities_ref) {
+    jniThrowException(_env, "java/lang/UnsupportedOperationException", "not yet implemented");
+    return 0;
+}
diff --git a/opengl/tools/glgen/stubs/gles11/glGetDebugMessageLogKHR.java b/opengl/tools/glgen/stubs/gles11/glGetDebugMessageLogKHR.java
new file mode 100644
index 0000000..a3c4a42
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetDebugMessageLogKHR.java
@@ -0,0 +1,51 @@
+    // C function GLuint glGetDebugMessageLogKHR ( GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog )
+
+    public static native int glGetDebugMessageLogKHR(
+        int count,
+        int bufSize,
+        int[] sources,
+        int sourcesOffset,
+        int[] types,
+        int typesOffset,
+        int[] ids,
+        int idsOffset,
+        int[] severities,
+        int severitiesOffset,
+        int[] lengths,
+        int lengthsOffset,
+        byte[] messageLog,
+        int messageLogOffset);
+
+    // C function GLuint glGetDebugMessageLogKHR ( GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog )
+
+    public static native int glGetDebugMessageLogKHR(
+        int count,
+        java.nio.IntBuffer sources,
+        java.nio.IntBuffer types,
+        java.nio.IntBuffer ids,
+        java.nio.IntBuffer severities,
+        java.nio.IntBuffer lengths,
+        java.nio.ByteBuffer messageLog);
+
+    // C function GLuint glGetDebugMessageLogKHR ( GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog )
+
+    public static native String[] glGetDebugMessageLogKHR(
+        int count,
+        int[] sources,
+        int sourcesOffset,
+        int[] types,
+        int typesOffset,
+        int[] ids,
+        int idsOffset,
+        int[] severities,
+        int severitiesOffset);
+
+    // C function GLuint glGetDebugMessageLogKHR ( GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog )
+
+    public static native String[] glGetDebugMessageLogKHR(
+        int count,
+        java.nio.IntBuffer sources,
+        java.nio.IntBuffer types,
+        java.nio.IntBuffer ids,
+        java.nio.IntBuffer severities);
+
diff --git a/opengl/tools/glgen/stubs/gles11/glGetDebugMessageLogKHR.nativeReg b/opengl/tools/glgen/stubs/gles11/glGetDebugMessageLogKHR.nativeReg
new file mode 100644
index 0000000..9a311ad
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetDebugMessageLogKHR.nativeReg
@@ -0,0 +1,4 @@
+{"glGetDebugMessageLogKHR", "(II[II[II[II[II[II[BI)I", (void *) android_glGetDebugMessageLogKHR__II_3II_3II_3II_3II_3II_3BI },
+{"glGetDebugMessageLogKHR", "(ILjava/nio/IntBuffer;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;Ljava/nio/ByteBuffer;)I", (void *) android_glGetDebugMessageLogKHR__ILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_ByteBuffer_2 },
+{"glGetDebugMessageLogKHR", "(I[II[II[II[II)[Ljava/lang/String;", (void *) android_glGetDebugMessageLogKHR__I_3II_3II_3II_3II },
+{"glGetDebugMessageLogKHR", "(ILjava/nio/IntBuffer;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;)[Ljava/lang/String;", (void *) android_glGetDebugMessageLogKHR__ILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2 },
diff --git a/opengl/tools/glgen/stubs/gles11/glGetFloatv.cpp b/opengl/tools/glgen/stubs/gles11/glGetFloatv.cpp
index 71c399d..2f41fd1 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetFloatv.cpp
+++ b/opengl/tools/glgen/stubs/gles11/glGetFloatv.cpp
@@ -2,12 +2,14 @@
 static void
 android_glGetFloatv__I_3FI
   (JNIEnv *_env, jobject _this, jint pname, jfloatArray params_ref, jint offset) {
-    get<jfloatArray, GLfloat, glGetFloatv>(_env, _this, pname, params_ref, offset);
+    get<jfloatArray, FloatArrayGetter, jfloat*, FloatArrayReleaser, GLfloat, glGetFloatv>(
+        _env, _this, pname, params_ref, offset);
 }
 
 /* void glGetFloatv ( GLenum pname, GLfloat *params ) */
 static void
 android_glGetFloatv__ILjava_nio_FloatBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
-    getarray<GLfloat, glGetFloatv>(_env, _this, pname, params_buf);
+    getarray<GLfloat, jfloatArray, FloatArrayGetter, jfloat*, FloatArrayReleaser, glGetFloatv>(
+        _env, _this, pname, params_buf);
 }
diff --git a/opengl/tools/glgen/stubs/gles11/glGetIntegerv.cpp b/opengl/tools/glgen/stubs/gles11/glGetIntegerv.cpp
index 9000ece..c960f31 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetIntegerv.cpp
+++ b/opengl/tools/glgen/stubs/gles11/glGetIntegerv.cpp
@@ -2,13 +2,14 @@
 static void
 android_glGetIntegerv__I_3II
   (JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
-    get<jintArray, GLint, glGetIntegerv>(_env, _this, pname, params_ref, offset);
+    get<jintArray, IntArrayGetter, jint*, IntArrayReleaser, GLint, glGetIntegerv>(
+        _env, _this, pname, params_ref, offset);
 }
 
 /* void glGetIntegerv ( GLenum pname, GLint *params ) */
 static void
 android_glGetIntegerv__ILjava_nio_IntBuffer_2
   (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
-    getarray<GLint, glGetIntegerv>(_env, _this, pname, params_buf);
+    getarray<GLint, jintArray, IntArrayGetter, jint*, IntArrayReleaser, glGetIntegerv>(
+        _env, _this, pname, params_buf);
 }
-
diff --git a/opengl/tools/glgen/stubs/gles11/glGetObjectLabelKHR.cpp b/opengl/tools/glgen/stubs/gles11/glGetObjectLabelKHR.cpp
new file mode 100644
index 0000000..49d237b
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetObjectLabelKHR.cpp
@@ -0,0 +1,7 @@
+/* void glGetObjectLabelKHR ( GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label ) */
+static jstring
+android_glGetObjectLabelKHR(JNIEnv *_env, jobject _this, jint identifier, jint name) {
+    jniThrowException(_env, "java/lang/UnsupportedOperationException", "not yet implemented");
+    return NULL;
+}
+
diff --git a/opengl/tools/glgen/stubs/gles11/glGetObjectLabelKHR.java b/opengl/tools/glgen/stubs/gles11/glGetObjectLabelKHR.java
new file mode 100644
index 0000000..d38c4f1
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetObjectLabelKHR.java
@@ -0,0 +1,4 @@
+    // C function void glGetObjectLabelKHR ( GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label )
+
+    public static native String glGetObjectLabelKHR(int identifier, int name);
+
diff --git a/opengl/tools/glgen/stubs/gles11/glGetObjectLabelKHR.nativeReg b/opengl/tools/glgen/stubs/gles11/glGetObjectLabelKHR.nativeReg
new file mode 100644
index 0000000..8b7167e
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetObjectLabelKHR.nativeReg
@@ -0,0 +1 @@
+{"glGetObjectLabelKHR", "(II)Ljava/lang/String;", (void *) android_glGetObjectLabelKHR },
diff --git a/opengl/tools/glgen/stubs/gles11/glGetObjectPtrLabelKHR.cpp b/opengl/tools/glgen/stubs/gles11/glGetObjectPtrLabelKHR.cpp
new file mode 100644
index 0000000..e107867
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetObjectPtrLabelKHR.cpp
@@ -0,0 +1,7 @@
+/* void glGetObjectPtrLabelKHR ( const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label ) */
+static jstring
+android_glGetObjectPtrLabelKHR(JNIEnv *_env, jobject _this, jlong ptr) {
+    jniThrowException(_env, "java/lang/UnsupportedOperationException", "not yet implemented");
+    return NULL;
+}
+
diff --git a/opengl/tools/glgen/stubs/gles11/glGetObjectPtrLabelKHR.java b/opengl/tools/glgen/stubs/gles11/glGetObjectPtrLabelKHR.java
new file mode 100644
index 0000000..874e003
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetObjectPtrLabelKHR.java
@@ -0,0 +1,4 @@
+    // C function void glGetObjectPtrLabelKHR ( const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label )
+
+    public static native String glGetObjectPtrLabelKHR(long ptr);
+
diff --git a/opengl/tools/glgen/stubs/gles11/glGetObjectPtrLabelKHR.nativeReg b/opengl/tools/glgen/stubs/gles11/glGetObjectPtrLabelKHR.nativeReg
new file mode 100644
index 0000000..e84f006
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetObjectPtrLabelKHR.nativeReg
@@ -0,0 +1 @@
+{"glGetObjectPtrLabelKHR", "(J)Ljava/lang/String;", (void *) android_glGetObjectPtrLabelKHR },
diff --git a/opengl/tools/glgen/stubs/gles11/glGetPointervKHR.cpp b/opengl/tools/glgen/stubs/gles11/glGetPointervKHR.cpp
new file mode 100644
index 0000000..0498507
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetPointervKHR.cpp
@@ -0,0 +1,7 @@
+/* void glGetPointervKHR ( GLenum pname, void **params ) */
+static jobject
+android_glGetDebugMessageCallbackKHR(JNIEnv *_env, jobject _this) {
+    jniThrowException(_env, "java/lang/UnsupportedOperationException", "not yet implemented");
+    return NULL;
+}
+
diff --git a/opengl/tools/glgen/stubs/gles11/glGetPointervKHR.java b/opengl/tools/glgen/stubs/gles11/glGetPointervKHR.java
new file mode 100644
index 0000000..cfb13a3
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetPointervKHR.java
@@ -0,0 +1,4 @@
+    // C function void glGetPointervKHR ( GLenum pname, void **params )
+
+    public static native DebugProcKHR glGetDebugMessageCallbackKHR();
+
diff --git a/opengl/tools/glgen/stubs/gles11/glGetPointervKHR.nativeReg b/opengl/tools/glgen/stubs/gles11/glGetPointervKHR.nativeReg
new file mode 100644
index 0000000..d835696
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetPointervKHR.nativeReg
@@ -0,0 +1 @@
+{"glGetDebugMessageCallbackKHR", "()Landroid/opengl/GLES31Ext$DebugProcKHR;", (void *) android_glGetDebugMessageCallbackKHR },
diff --git a/opengl/tools/glgen/stubs/gles11/glGetProgramPipelineInfoLog.cpp b/opengl/tools/glgen/stubs/gles11/glGetProgramPipelineInfoLog.cpp
new file mode 100644
index 0000000..5b556d5
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetProgramPipelineInfoLog.cpp
@@ -0,0 +1,19 @@
+#include <stdlib.h>
+
+/* void glGetProgramPipelineInfoLog ( GLuint shader, GLsizei maxLength, GLsizei* length, GLchar* infoLog ) */
+static jstring android_glGetProgramPipelineInfoLog(JNIEnv *_env, jobject, jint shader) {
+    GLint infoLen = 0;
+    glGetProgramPipelineiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
+    if (!infoLen) {
+        return _env->NewStringUTF("");
+    }
+    char* buf = (char*) malloc(infoLen);
+    if (buf == NULL) {
+        jniThrowException(_env, "java/lang/OutOfMemoryError", "out of memory");
+        return NULL;
+    }
+    glGetProgramPipelineInfoLog(shader, infoLen, NULL, buf);
+    jstring result = _env->NewStringUTF(buf);
+    free(buf);
+    return result;
+}
diff --git a/opengl/tools/glgen/stubs/gles11/glGetProgramPipelineInfoLog.java b/opengl/tools/glgen/stubs/gles11/glGetProgramPipelineInfoLog.java
new file mode 100644
index 0000000..f6b0f7b
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetProgramPipelineInfoLog.java
@@ -0,0 +1,6 @@
+    // C function void glGetProgramPipelineInfoLog( GLuint program, GLsizei maxLength, GLsizei * length, GLchar * infoLog);
+
+    public static native String glGetProgramPipelineInfoLog(
+        int program
+    );
+
diff --git a/opengl/tools/glgen/stubs/gles11/glGetProgramPipelineInfoLog.nativeReg b/opengl/tools/glgen/stubs/gles11/glGetProgramPipelineInfoLog.nativeReg
new file mode 100644
index 0000000..9a99e08
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetProgramPipelineInfoLog.nativeReg
@@ -0,0 +1 @@
+{"glGetProgramPipelineInfoLog", "(I)Ljava/lang/String;", (void *) android_glGetProgramPipelineInfoLog },
diff --git a/opengl/tools/glgen/stubs/gles11/glGetProgramResourceName.cpp b/opengl/tools/glgen/stubs/gles11/glGetProgramResourceName.cpp
new file mode 100644
index 0000000..b07e59c
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetProgramResourceName.cpp
@@ -0,0 +1,8 @@
+/* void glGetProgramResourceName ( GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name ) */
+static jstring
+android_glGetProgramResourceName
+  (JNIEnv *_env, jobject _this, jint program, jint programInterface, jint index) {
+    jniThrowException(_env, "java/lang/UnsupportedOperationException", "not yet implemented");
+    return NULL;
+}
+
diff --git a/opengl/tools/glgen/stubs/gles11/glGetProgramResourceName.java b/opengl/tools/glgen/stubs/gles11/glGetProgramResourceName.java
new file mode 100644
index 0000000..43d6806
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetProgramResourceName.java
@@ -0,0 +1,8 @@
+    // C function void glGetProgramResourceName ( GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name )
+
+    public static native String glGetProgramResourceName(
+        int program,
+        int programInterface,
+        int index
+    );
+
diff --git a/opengl/tools/glgen/stubs/gles11/glGetProgramResourceName.nativeReg b/opengl/tools/glgen/stubs/gles11/glGetProgramResourceName.nativeReg
new file mode 100644
index 0000000..f0b5fe1
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glGetProgramResourceName.nativeReg
@@ -0,0 +1 @@
+{"glGetProgramResourceName", "(III)Ljava/lang/String;", (void *) android_glGetProgramResourceName },
diff --git a/opengl/tools/glgen/stubs/gles11/glGetShaderSource.cpp b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.cpp
index c995d9c..d9808ef 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetShaderSource.cpp
+++ b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.cpp
@@ -26,7 +26,7 @@
     }
     _lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset;
     length_base = (GLsizei *)
-        _env->GetPrimitiveArrayCritical(length_ref, (jboolean *)0);
+        _env->GetIntArrayElements(length_ref, (jboolean *)0);
     length = length_base + lengthOffset;
 
     if (!source_ref) {
@@ -43,7 +43,7 @@
     }
     _sourceRemaining = _env->GetArrayLength(source_ref) - sourceOffset;
     source_base = (char *)
-        _env->GetPrimitiveArrayCritical(source_ref, (jboolean *)0);
+        _env->GetByteArrayElements(source_ref, (jboolean *)0);
     source = source_base + sourceOffset;
 
     glGetShaderSource(
@@ -55,11 +55,11 @@
 
 exit:
     if (source_base) {
-        _env->ReleasePrimitiveArrayCritical(source_ref, source_base,
+        _env->ReleaseByteArrayElements(source_ref, (jbyte*)source_base,
             _exception ? JNI_ABORT: 0);
     }
     if (length_base) {
-        _env->ReleasePrimitiveArrayCritical(length_ref, length_base,
+        _env->ReleaseIntArrayElements(length_ref, (jint*)length_base,
             _exception ? JNI_ABORT: 0);
     }
     if (_exception) {
@@ -71,14 +71,14 @@
 static void
 android_glGetShaderSource__IILjava_nio_IntBuffer_2B
   (JNIEnv *_env, jobject _this, jint shader, jint bufsize, jobject length_buf, jbyte source) {
-    jarray _array = (jarray) 0;
+    jintArray _array = (jintArray) 0;
     jint _bufferOffset = (jint) 0;
     jint _remaining;
     GLsizei *length = (GLsizei *) 0;
 
-    length = (GLsizei *)getPointer(_env, length_buf, &_array, &_remaining, &_bufferOffset);
+    length = (GLsizei *)getPointer(_env, length_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
     if (length == NULL) {
-        char * _lengthBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
+        char * _lengthBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
         length = (GLsizei *) (_lengthBase + _bufferOffset);
     }
     glGetShaderSource(
@@ -88,7 +88,7 @@
         reinterpret_cast<char *>(source)
     );
     if (_array) {
-        releasePointer(_env, _array, length, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _array, (jint*)length, JNI_TRUE);
     }
 }
 
diff --git a/opengl/tools/glgen/stubs/gles11/glGetShaderSource.java b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.java
index 199d93a..afbaaca 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetShaderSource.java
+++ b/opengl/tools/glgen/stubs/gles11/glGetShaderSource.java
@@ -11,6 +11,7 @@
 
     // C function void glGetShaderSource ( GLuint shader, GLsizei bufsize, GLsizei *length, char *source )
 
+    /** @hide Method is broken, but used to be public (b/6006380) */
     public static native void glGetShaderSource(
         int shader,
         int bufsize,
diff --git a/opengl/tools/glgen/stubs/gles11/glGetTransformFeedbackVarying.cpp b/opengl/tools/glgen/stubs/gles11/glGetTransformFeedbackVarying.cpp
index 0514fe9..cb656c8 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetTransformFeedbackVarying.cpp
+++ b/opengl/tools/glgen/stubs/gles11/glGetTransformFeedbackVarying.cpp
@@ -32,7 +32,7 @@
     }
     _lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset;
     length_base = (GLsizei *)
-        _env->GetPrimitiveArrayCritical(length_ref, (jboolean *)0);
+        _env->GetIntArrayElements(length_ref, (jboolean *)0);
     length = length_base + lengthOffset;
 
     if (!size_ref) {
@@ -49,7 +49,7 @@
     }
     _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset;
     size_base = (GLint *)
-        _env->GetPrimitiveArrayCritical(size_ref, (jboolean *)0);
+        _env->GetIntArrayElements(size_ref, (jboolean *)0);
     size = size_base + sizeOffset;
 
     if (!type_ref) {
@@ -66,7 +66,7 @@
     }
     _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset;
     type_base = (GLenum *)
-        _env->GetPrimitiveArrayCritical(type_ref, (jboolean *)0);
+        _env->GetIntArrayElements(type_ref, (jboolean *)0);
     type = type_base + typeOffset;
 
     if (!name_ref) {
@@ -83,7 +83,7 @@
     }
     _nameRemaining = _env->GetArrayLength(name_ref) - nameOffset;
     name_base = (char *)
-        _env->GetPrimitiveArrayCritical(name_ref, (jboolean *)0);
+        _env->GetByteArrayElements(name_ref, (jboolean *)0);
     name = name_base + nameOffset;
 
     glGetTransformFeedbackVarying(
@@ -98,19 +98,19 @@
 
 exit:
     if (name_base) {
-        _env->ReleasePrimitiveArrayCritical(name_ref, name_base,
+        _env->ReleaseByteArrayElements(name_ref, (jbyte*)name_base,
             _exception ? JNI_ABORT: 0);
     }
     if (type_base) {
-        _env->ReleasePrimitiveArrayCritical(type_ref, type_base,
+        _env->ReleaseIntArrayElements(type_ref, (jint*)type_base,
             _exception ? JNI_ABORT: 0);
     }
     if (size_base) {
-        _env->ReleasePrimitiveArrayCritical(size_ref, size_base,
+        _env->ReleaseIntArrayElements(size_ref, (jint*)size_base,
             _exception ? JNI_ABORT: 0);
     }
     if (length_base) {
-        _env->ReleasePrimitiveArrayCritical(length_ref, length_base,
+        _env->ReleaseIntArrayElements(length_ref, (jint*)length_base,
             _exception ? JNI_ABORT: 0);
     }
     if (_exception) {
@@ -122,11 +122,11 @@
 static void
 android_glGetTransformFeedbackVarying__IIILjava_nio_IntBuffer_2Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2B
   (JNIEnv *_env, jobject _this, jint program, jint index, jint bufsize, jobject length_buf, jobject size_buf, jobject type_buf, jbyte name) {
-    jarray _lengthArray = (jarray) 0;
+    jintArray _lengthArray = (jintArray) 0;
     jint _lengthBufferOffset = (jint) 0;
-    jarray _sizeArray = (jarray) 0;
+    jintArray _sizeArray = (jintArray) 0;
     jint _sizeBufferOffset = (jint) 0;
-    jarray _typeArray = (jarray) 0;
+    jintArray _typeArray = (jintArray) 0;
     jint _typeBufferOffset = (jint) 0;
     jint _lengthRemaining;
     GLsizei *length = (GLsizei *) 0;
@@ -135,19 +135,19 @@
     jint _typeRemaining;
     GLenum *type = (GLenum *) 0;
 
-    length = (GLsizei *)getPointer(_env, length_buf, &_lengthArray, &_lengthRemaining, &_lengthBufferOffset);
-    size = (GLint *)getPointer(_env, size_buf, &_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
-    type = (GLenum *)getPointer(_env, type_buf, &_typeArray, &_typeRemaining, &_typeBufferOffset);
+    length = (GLsizei *)getPointer(_env, length_buf, (jarray*)&_lengthArray, &_lengthRemaining, &_lengthBufferOffset);
+    size = (GLint *)getPointer(_env, size_buf, (jarray*)&_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
+    type = (GLenum *)getPointer(_env, type_buf, (jarray*)&_typeArray, &_typeRemaining, &_typeBufferOffset);
     if (length == NULL) {
-        char * _lengthBase = (char *)_env->GetPrimitiveArrayCritical(_lengthArray, (jboolean *) 0);
+        char * _lengthBase = (char *)_env->GetIntArrayElements(_lengthArray, (jboolean *) 0);
         length = (GLsizei *) (_lengthBase + _lengthBufferOffset);
     }
     if (size == NULL) {
-        char * _sizeBase = (char *)_env->GetPrimitiveArrayCritical(_sizeArray, (jboolean *) 0);
+        char * _sizeBase = (char *)_env->GetIntArrayElements(_sizeArray, (jboolean *) 0);
         size = (GLint *) (_sizeBase + _sizeBufferOffset);
     }
     if (type == NULL) {
-        char * _typeBase = (char *)_env->GetPrimitiveArrayCritical(_typeArray, (jboolean *) 0);
+        char * _typeBase = (char *)_env->GetIntArrayElements(_typeArray, (jboolean *) 0);
         type = (GLenum *) (_typeBase + _typeBufferOffset);
     }
     glGetTransformFeedbackVarying(
@@ -157,16 +157,20 @@
         (GLsizei *)length,
         (GLint *)size,
         (GLenum *)type,
-        (char *)name
+        // The cast below is incorrect. The driver will end up writing to the
+        // address specified by name, which will always crash the process since
+        // it is guaranteed to be in low memory. The additional static_cast
+        // suppresses the warning for now. http://b/19478262
+        (char *)static_cast<uintptr_t>(name)
     );
     if (_typeArray) {
-        releasePointer(_env, _typeArray, type, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _typeArray, (jint*)type, JNI_TRUE);
     }
     if (_sizeArray) {
-        releasePointer(_env, _sizeArray, size, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _sizeArray, (jint*)size, JNI_TRUE);
     }
     if (_lengthArray) {
-        releasePointer(_env, _lengthArray, length, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _lengthArray, (jint*)length, JNI_TRUE);
     }
 }
 
@@ -211,7 +215,7 @@
     }
     _sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset;
     size_base = (GLint *)
-        _env->GetPrimitiveArrayCritical(size_ref, (jboolean *)0);
+        _env->GetIntArrayElements(size_ref, (jboolean *)0);
     size = size_base + sizeOffset;
 
     if (!type_ref) {
@@ -228,7 +232,7 @@
     }
     _typeRemaining = _env->GetArrayLength(type_ref) - typeOffset;
     type_base = (GLenum *)
-        _env->GetPrimitiveArrayCritical(type_ref, (jboolean *)0);
+        _env->GetIntArrayElements(type_ref, (jboolean *)0);
     type = type_base + typeOffset;
 
     glGetTransformFeedbackVarying(
@@ -242,11 +246,11 @@
     );
 exit:
     if (type_base) {
-        _env->ReleasePrimitiveArrayCritical(type_ref, type_base,
+        _env->ReleaseIntArrayElements(type_ref, (jint*)type_base,
             _exception ? JNI_ABORT: 0);
     }
     if (size_base) {
-        _env->ReleasePrimitiveArrayCritical(size_ref, size_base,
+        _env->ReleaseIntArrayElements(size_ref, (jint*)size_base,
             _exception ? JNI_ABORT: 0);
     }
     if (_exception != 1) {
@@ -269,9 +273,9 @@
 static jstring
 android_glGetTransformFeedbackVarying2
   (JNIEnv *_env, jobject _this, jint program, jint index, jobject size_buf, jobject type_buf) {
-    jarray _sizeArray = (jarray) 0;
+    jintArray _sizeArray = (jintArray) 0;
     jint _sizeBufferOffset = (jint) 0;
-    jarray _typeArray = (jarray) 0;
+    jintArray _typeArray = (jintArray) 0;
     jint _typeBufferOffset = (jint) 0;
     jint _lengthRemaining;
     GLsizei *length = (GLsizei *) 0;
@@ -294,14 +298,14 @@
         return NULL;
     }
 
-    size = (GLint *)getPointer(_env, size_buf, &_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
-    type = (GLenum *)getPointer(_env, type_buf, &_typeArray, &_typeRemaining, &_typeBufferOffset);
+    size = (GLint *)getPointer(_env, size_buf, (jarray*)&_sizeArray, &_sizeRemaining, &_sizeBufferOffset);
+    type = (GLenum *)getPointer(_env, type_buf, (jarray*)&_typeArray, &_typeRemaining, &_typeBufferOffset);
     if (size == NULL) {
-        char * _sizeBase = (char *)_env->GetPrimitiveArrayCritical(_sizeArray, (jboolean *) 0);
+        char * _sizeBase = (char *)_env->GetIntArrayElements(_sizeArray, (jboolean *) 0);
         size = (GLint *) (_sizeBase + _sizeBufferOffset);
     }
     if (type == NULL) {
-        char * _typeBase = (char *)_env->GetPrimitiveArrayCritical(_typeArray, (jboolean *) 0);
+        char * _typeBase = (char *)_env->GetIntArrayElements(_typeArray, (jboolean *) 0);
         type = (GLenum *) (_typeBase + _typeBufferOffset);
     }
     glGetTransformFeedbackVarying(
@@ -315,10 +319,10 @@
     );
 
     if (_typeArray) {
-        releasePointer(_env, _typeArray, type, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _typeArray, (jint*)type, JNI_TRUE);
     }
     if (_sizeArray) {
-        releasePointer(_env, _sizeArray, size, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(_env, _sizeArray, (jint*)size, JNI_TRUE);
     }
     result = _env->NewStringUTF(buf);
     if (buf) {
diff --git a/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.cpp b/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.cpp
index fb137ab..13ef01e 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.cpp
+++ b/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.cpp
@@ -49,7 +49,7 @@
         _exceptionMessage = "not enough space in uniformIndices";
         goto exit;
     }
-    _indices_base = (GLuint*)_env->GetPrimitiveArrayCritical(
+    _indices_base = (GLuint*)_env->GetIntArrayElements(
             uniformIndices_ref, 0);
     _indices = _indices_base + uniformIndicesOffset;
 
@@ -57,8 +57,8 @@
 
 exit:
     if (_indices_base) {
-        _env->ReleasePrimitiveArrayCritical(uniformIndices_ref, _indices_base,
-                _exception ? JNI_ABORT : 0);
+        _env->ReleaseIntArrayElements(uniformIndices_ref, (jint*)_indices_base,
+            _exception ? JNI_ABORT : 0);
     }
     for (_i = _count - 1; _i >= 0; _i--) {
         if (_names[_i]) {
@@ -85,7 +85,7 @@
     jint _count = 0;
     jint _i;
     const char** _names = NULL;
-    jarray _uniformIndicesArray = (jarray)0;
+    jintArray _uniformIndicesArray = (jintArray)0;
     jint _uniformIndicesRemaining;
     jint _uniformIndicesOffset = 0;
     GLuint* _indices = NULL;
@@ -118,11 +118,11 @@
     }
 
     _indices = (GLuint*)getPointer(_env, uniformIndices_buf,
-            &_uniformIndicesArray, &_uniformIndicesRemaining,
+            (jarray*)&_uniformIndicesArray, &_uniformIndicesRemaining,
             &_uniformIndicesOffset);
     if (!_indices) {
-        _indicesBase = (char*)_env->GetPrimitiveArrayCritical(
-                _uniformIndicesArray, 0);
+        _indicesBase = (char*)_env->GetIntArrayElements(
+            _uniformIndicesArray, 0);
         _indices = (GLuint*)(_indicesBase + _uniformIndicesOffset);
     }
     if (_uniformIndicesRemaining < _count) {
@@ -136,7 +136,8 @@
 
 exit:
     if (_uniformIndicesArray) {
-        releasePointer(_env, _uniformIndicesArray, _indicesBase, JNI_TRUE);
+        releaseArrayPointer<jintArray, jint*, IntArrayReleaser>(
+            _env, _uniformIndicesArray, (jint*)_indicesBase, JNI_TRUE);
     }
     for (_i = _count - 1; _i >= 0; _i--) {
         if (_names[_i]) {
@@ -151,4 +152,3 @@
         jniThrowException(_env, _exceptionType, _exceptionMessage);
     }
 }
-
diff --git a/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.java b/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.java
index 719429b..7780e23 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.java
+++ b/opengl/tools/glgen/stubs/gles11/glGetUniformIndices.java
@@ -1,11 +1,11 @@
-	// C function void glGetUniformIndices ( GLuint program, GLsizei uniformCount, const GLchar *const *uniformNames, GLuint *uniformIndices )
+    // C function void glGetUniformIndices ( GLuint program, GLsizei uniformCount, const GLchar *const *uniformNames, GLuint *uniformIndices )
 
-	public static native void glGetUniformIndices(
+    public static native void glGetUniformIndices(
         int program,
         String[] uniformNames,
         int[] uniformIndices,
         int uniformIndicesOffset
-	);
+    );
 
     // C function void glGetUniformIndices ( GLuint program, GLsizei uniformCount, const GLchar *const *uniformNames, GLuint *uniformIndices )
 
diff --git a/opengl/tools/glgen/stubs/gles11/glObjectPtrLabelKHR.cpp b/opengl/tools/glgen/stubs/gles11/glObjectPtrLabelKHR.cpp
new file mode 100644
index 0000000..2bd851a
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glObjectPtrLabelKHR.cpp
@@ -0,0 +1,6 @@
+/* void glObjectPtrLabelKHR ( const void *ptr, GLsizei length, const GLchar *label ) */
+static void
+android_glObjectPtrLabelKHR(JNIEnv *_env, jobject _this, jlong ptr, jstring label) {
+    jniThrowException(_env, "java/lang/UnsupportedOperationException", "not yet implemented");
+}
+
diff --git a/opengl/tools/glgen/stubs/gles11/glObjectPtrLabelKHR.java b/opengl/tools/glgen/stubs/gles11/glObjectPtrLabelKHR.java
new file mode 100644
index 0000000..1198898
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glObjectPtrLabelKHR.java
@@ -0,0 +1,4 @@
+    // C function void glObjectPtrLabelKHR ( const void *ptr, GLsizei length, const GLchar *label )
+
+    public static native void glObjectPtrLabelKHR(long ptr, String label);
+
diff --git a/opengl/tools/glgen/stubs/gles11/glObjectPtrLabelKHR.nativeReg b/opengl/tools/glgen/stubs/gles11/glObjectPtrLabelKHR.nativeReg
new file mode 100644
index 0000000..7b7add1
--- /dev/null
+++ b/opengl/tools/glgen/stubs/gles11/glObjectPtrLabelKHR.nativeReg
@@ -0,0 +1 @@
+{"glObjectPtrLabelKHR", "(JLjava/lang/String;)V", (void *) android_glObjectPtrLabelKHR },
diff --git a/opengl/tools/glgen/stubs/gles11/glTransformFeedbackVaryings.java b/opengl/tools/glgen/stubs/gles11/glTransformFeedbackVaryings.java
index c824344..b63a11d 100644
--- a/opengl/tools/glgen/stubs/gles11/glTransformFeedbackVaryings.java
+++ b/opengl/tools/glgen/stubs/gles11/glTransformFeedbackVaryings.java
@@ -1,8 +1,8 @@
-	// C function void glTransformFeedbackVaryings ( GLuint program, GLsizei count, const GLchar *varyings, GLenum bufferMode )
+    // C function void glTransformFeedbackVaryings ( GLuint program, GLsizei count, const GLchar *varyings, GLenum bufferMode )
 
-	public static native void glTransformFeedbackVaryings(
+    public static native void glTransformFeedbackVaryings(
         int program,
         String[] varyings,
         int bufferMode
-	);
+    );
 
diff --git a/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp b/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp
index df11c53..f5506ba 100644
--- a/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp
+++ b/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp
@@ -16,6 +16,10 @@
 
 // This source file is automatically generated
 
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#pragma GCC diagnostic ignored "-Wunused-function"
+
 #include "jni.h"
 #include "JNIHelp.h"
 #include <android_runtime/AndroidRuntime.h>
diff --git a/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl b/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl
index 9740235..afcc3eb 100644
--- a/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl
+++ b/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl
@@ -38,7 +38,7 @@
 
     native private static void _nativeClassInit();
     static {
-	_nativeClassInit();
+        _nativeClassInit();
     }
 
     Buffer _colorPointer = null;
diff --git a/opengl/tools/glgen2/.gitignore b/opengl/tools/glgen2/.gitignore
new file mode 100644
index 0000000..6d459f7
--- /dev/null
+++ b/opengl/tools/glgen2/.gitignore
@@ -0,0 +1 @@
+registry/reg.pyc
diff --git a/opengl/tools/glgen2/glgen.py b/opengl/tools/glgen2/glgen.py
new file mode 100755
index 0000000..9b30fd1
--- /dev/null
+++ b/opengl/tools/glgen2/glgen.py
@@ -0,0 +1,328 @@
+#!/usr/bin/env python
+#
+# Copyright 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from __future__ import print_function
+from operator import itemgetter
+import collections
+import os.path
+import re
+import sys
+
+
+# Avoid endlessly adding to the path if this module is imported multiple
+# times, e.g. in an interactive session
+regpath = os.path.join(sys.path[0], "registry")
+if sys.path[1] != regpath:
+    sys.path.insert(1, regpath)
+import reg
+
+
+AEP_EXTENSIONS = [
+    'GL_KHR_blend_equation_advanced',
+    'GL_KHR_debug',
+    'GL_KHR_texture_compression_astc_ldr',
+    'GL_OES_sample_shading',
+    'GL_OES_sample_variables',
+    'GL_OES_shader_image_atomic',
+    'GL_OES_shader_multisample_interpolation',
+    'GL_OES_texture_stencil8',
+    'GL_OES_texture_storage_multisample_2d_array',
+    'GL_EXT_copy_image',
+    'GL_EXT_draw_buffers_indexed',
+    'GL_EXT_geometry_shader',
+    'GL_EXT_gpu_shader5',
+    'GL_EXT_primitive_bounding_box',
+    'GL_EXT_shader_io_blocks',
+    'GL_EXT_tessellation_shader',
+    'GL_EXT_texture_border_clamp',
+    'GL_EXT_texture_buffer',
+    'GL_EXT_texture_cube_map_array',
+    'GL_EXT_texture_sRGB_decode']
+
+
+def nonestr(s):
+    return s if s else ""
+
+
+def parseTypedName(elem):
+    type = [nonestr(elem.text)]
+    name = None
+    for subelem in elem:
+        text = nonestr(subelem.text)
+        tail = nonestr(subelem.tail)
+        if subelem.tag == 'name':
+            name = text
+            break
+        else:
+            type.extend([text, tail])
+    return (''.join(type).strip(), name)
+
+
+# Format a list of (type, name) tuples as a C-style parameter list
+def fmtParams(params):
+    if not params:
+        return 'void'
+    return ', '.join(['%s %s' % (p[0], p[1]) for p in params])
+
+# Format a list of (type, name) tuples as a C-style argument list
+def fmtArgs(params):
+    return ', '.join(p[1] for p in params)
+
+# Format a list of (type, name) tuples as comma-separated '"type", name'
+def fmtTypeNameList(params):
+    return ', '.join(['"%s", %s' % (p[0], p[1]) for p in params])
+
+
+def overrideSymbolName(sym, apiname):
+    # The wrapper intercepts various glGet and glGetString functions and
+    # (sometimes) calls the generated thunk which dispatches to the
+    # driver's implementation
+    wrapped_get_syms = {
+        'gles1' : [
+            'glGetString'
+        ],
+        'gles2' : [
+            'glGetString',
+            'glGetStringi',
+            'glGetBooleanv',
+            'glGetFloatv',
+            'glGetIntegerv',
+            'glGetInteger64v',
+        ],
+    }
+    if sym in wrapped_get_syms.get(apiname):
+        return '__' + sym
+    else:
+        return sym
+
+
+# Generate API trampoline templates:
+#   <rtype> API_ENTRY(<name>)(<params>) {
+#       CALL_GL_API(<name>, <args>);
+#       // or
+#       CALL_GL_API_RETURN(<name>, <args>);
+#   }
+class TrampolineGen(reg.OutputGenerator):
+    def __init__(self):
+        reg.OutputGenerator.__init__(self, sys.stderr, sys.stderr, None)
+
+    def genCmd(self, cmd, name):
+        reg.OutputGenerator.genCmd(self, cmd, name)
+
+        rtype, fname = parseTypedName(cmd.elem.find('proto'))
+        params = [parseTypedName(p) for p in cmd.elem.findall('param')]
+
+        call = 'CALL_GL_API' if rtype == 'void' else 'CALL_GL_API_RETURN'
+        print('%s API_ENTRY(%s)(%s) {\n'
+              '    %s(%s%s%s);\n'
+              '}'
+              % (rtype, overrideSymbolName(fname, self.genOpts.apiname),
+                 fmtParams(params), call, fname,
+                 ', ' if len(params) > 0 else '',
+                 fmtArgs(params)),
+              file=self.outFile)
+
+
+
+# Collect all API prototypes across all families, remove duplicates,
+# emit to entries.in and trace.in files.
+class ApiGenerator(reg.OutputGenerator):
+    def __init__(self):
+        reg.OutputGenerator.__init__(self, sys.stderr, sys.stderr, None)
+        self.cmds = []
+        self.enums = collections.OrderedDict()
+
+    def genCmd(self, cmd, name):
+        reg.OutputGenerator.genCmd(self, cmd, name)
+        rtype, fname = parseTypedName(cmd.elem.find('proto'))
+        params = [parseTypedName(p) for p in cmd.elem.findall('param')]
+        self.cmds.append({'rtype': rtype, 'name': fname, 'params': params})
+
+    def genEnum(self, enuminfo, name):
+        reg.OutputGenerator.genEnum(self, enuminfo, name)
+        value = enuminfo.elem.get('value')
+
+        # Skip bitmask enums. Pattern matches:
+        # - GL_DEPTH_BUFFER_BIT
+        # - GL_MAP_INVALIDATE_BUFFER_BIT_EXT
+        # - GL_COLOR_BUFFER_BIT1_QCOM
+        # but not
+        # - GL_DEPTH_BITS
+        # - GL_QUERY_COUNTER_BITS_EXT
+        #
+        # TODO: Assuming a naming pattern and using a regex is what the
+        # old glenumsgen script did. But the registry XML knows which enums are
+        # parts of bitmask groups, so we should just use that. I'm not sure how
+        # to get the information out though, and it's not critical right now,
+        # so leaving for later.
+        if re.search('_BIT($|\d*_)', name):
+            return
+
+        # Skip non-hex values (GL_TRUE, GL_FALSE, header guard junk)
+        if not re.search('0x[0-9A-Fa-f]+', value):
+            return
+
+        # Append 'u' or 'ull' type suffix if present
+        type = enuminfo.elem.get('type')
+        if type and type != 'i':
+            value += type
+
+        if value not in self.enums:
+            self.enums[value] = name
+
+    def finish(self):
+        # sort by function name, remove duplicates
+        self.cmds.sort(key=itemgetter('name'))
+        cmds = []
+        for cmd in self.cmds:
+            if len(cmds) == 0 or cmd != cmds[-1]:
+                cmds.append(cmd)
+        self.cmds = cmds
+
+    # Write entries.in
+    def writeEntries(self, outfile):
+        for cmd in self.cmds:
+            print('GL_ENTRY(%s, %s, %s)'
+                  % (cmd['rtype'], cmd['name'], fmtParams(cmd['params'])),
+                  file=outfile)
+
+    # Write traces.in
+    def writeTrace(self, outfile):
+        for cmd in self.cmds:
+            if cmd['rtype'] == 'void':
+                ret = '_VOID('
+            else:
+                ret = '(%s, ' % cmd['rtype']
+
+            params = cmd['params']
+            if len(params) > 0:
+                typeNameList = ', ' + fmtTypeNameList(params)
+            else:
+                typeNameList = ''
+
+            print('TRACE_GL%s%s, (%s), (%s), %d%s)'
+                  % (ret, cmd['name'],
+                     fmtParams(params), fmtArgs(params),
+                     len(params), typeNameList),
+                  file=outfile)
+
+    # Write enums.in
+    def writeEnums(self, outfile):
+        for enum in self.enums.iteritems():
+            print('GL_ENUM(%s,%s)' % (enum[0], enum[1]), file=outfile)
+
+
+# Generate .spec entries for use by legacy 'gen' script
+class SpecGenerator(reg.OutputGenerator):
+    def __init__(self):
+        reg.OutputGenerator.__init__(self, sys.stderr, sys.stderr, None)
+
+    def genCmd(self, cmd, name):
+        reg.OutputGenerator.genCmd(self, cmd, name)
+        rtype, fname = parseTypedName(cmd.elem.find('proto'))
+        params = [parseTypedName(p) for p in cmd.elem.findall('param')]
+
+        print('%s %s ( %s )' % (rtype, fname, fmtParams(params)),
+              file=self.outFile)
+
+
+if __name__ == '__main__':
+    registry = reg.Registry()
+    registry.loadFile('registry/gl.xml')
+
+    registry.setGenerator(TrampolineGen())
+    TRAMPOLINE_OPTIONS = [
+        reg.GeneratorOptions(
+            apiname             = 'gles1',
+            profile             = 'common',
+            filename            = '../../libs/GLES_CM/gl_api.in'),
+        reg.GeneratorOptions(
+            apiname             = 'gles1',
+            profile             = 'common',
+            emitversions        = None,
+            defaultExtensions   = 'gles1',
+            filename            = '../../libs/GLES_CM/glext_api.in'),
+        reg.GeneratorOptions(
+            apiname             = 'gles2',
+            profile             = 'common',
+            filename            = '../../libs/GLES2/gl2_api.in'),
+        reg.GeneratorOptions(
+            apiname             = 'gles2',
+            profile             = 'common',
+            emitversions        = None,
+            defaultExtensions   = 'gles2',
+            filename            = '../../libs/GLES2/gl2ext_api.in')]
+    for opts in TRAMPOLINE_OPTIONS:
+        registry.apiGen(opts)
+
+    apigen = ApiGenerator()
+    registry.setGenerator(apigen)
+    API_OPTIONS = [
+        # Generate non-extension versions of each API first, then extensions,
+        # so that if an extension enum was later standardized, we see the non-
+        # suffixed version first.
+        reg.GeneratorOptions(
+            apiname             = 'gles1',
+            profile             = 'common'),
+        reg.GeneratorOptions(
+            apiname             = 'gles2',
+            profile             = 'common'),
+        reg.GeneratorOptions(
+            apiname             = 'gles1',
+            profile             = 'common',
+            emitversions        = None,
+            defaultExtensions   = 'gles1'),
+        reg.GeneratorOptions(
+            apiname             = 'gles2',
+            profile             = 'common',
+            emitversions        = None,
+            defaultExtensions   = 'gles2')]
+    for opts in API_OPTIONS:
+        registry.apiGen(opts)
+    apigen.finish()
+    with open('../../libs/entries.in', 'w') as f:
+        apigen.writeEntries(f)
+    with open('../../libs/trace.in', 'w') as f:
+        apigen.writeTrace(f)
+    with open('../../libs/enums.in', 'w') as f:
+        apigen.writeEnums(f)
+
+    registry.setGenerator(SpecGenerator())
+    SPEC_OPTIONS = [
+        reg.GeneratorOptions(
+            apiname             = 'gles2',
+            profile             = 'common',
+            versions            = '3\.1',
+            filename            = '../glgen/specs/gles11/GLES31.spec'),
+        reg.GeneratorOptions(
+            apiname             = 'gles2',
+            profile             = 'common',
+            emitversions        = None,
+            defaultExtensions   = None,
+            addExtensions       = '^({})$'.format('|'.join(AEP_EXTENSIONS)),
+            filename            = '../glgen/specs/gles11/GLES31Ext.spec')]
+    # SpecGenerator creates a good starting point, but the CFunc.java parser is
+    # so terrible that the .spec file needs a lot of manual massaging before
+    # it works. Commenting this out to avoid accidentally overwriting all the
+    # manual modifications.
+    #
+    # Eventually this script should generate the Java and JNI code directly,
+    # skipping the intermediate .spec step, and obsoleting the existing
+    # ../glgen system.
+    #
+    # for opts in SPEC_OPTIONS:
+    #     registry.apiGen(opts)
+
diff --git a/opengl/tools/glgen2/registry/egl.xml b/opengl/tools/glgen2/registry/egl.xml
new file mode 100755
index 0000000..6f6ebc3
--- /dev/null
+++ b/opengl/tools/glgen2/registry/egl.xml
@@ -0,0 +1,1966 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<registry>
+    <!--
+    Copyright (c) 2013-2014 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.
+    -->
+    <!--
+    This file, egl.xml, is the EGL API Registry. The older ".spec" file
+    format has been retired and will no longer be updated with new
+    extensions and API versions. The canonical version of the registry,
+    together with documentation, schema, and Python generator scripts used
+    to generate C header files for EGL, can be found in the Khronos Registry
+    at
+        http://www.opengl.org/registry/
+    -->
+
+    <!-- SECTION: EGL type definitions. Does not include GL types. -->
+    <types>
+            <!-- These are dependencies EGL types require to be declared legally -->
+        <type name="khrplatform">#include &lt;KHR/khrplatform.h&gt;</type>
+        <type name="eglplatform" requires="khrplatform">#include &lt;EGL/eglplatform.h&gt;</type>
+        <type name="khronos_utime_nanoseconds_t" requires="khrplatform"/>
+        <type name="khronos_uint64_t" requires="khrplatform"/>
+        <type name="khronos_ssize_t" requires="khrplatform"/>
+        <type name="EGLNativeDisplayType" requires="eglplatform"/>
+        <type name="EGLNativePixmapType" requires="eglplatform"/>
+        <type name="EGLNativeWindowType" requires="eglplatform"/>
+        <type name="EGLint" requires="eglplatform"/>
+        <type name="NativeDisplayType" requires="eglplatform"/>
+        <type name="NativePixmapType" requires="eglplatform"/>
+        <type name="NativeWindowType" requires="eglplatform"/>
+        <!-- Dummy placeholders for non-EGL types -->
+        <type name="Bool"/>
+            <!-- These are actual EGL types.  -->
+        <type>typedef unsigned int <name>EGLBoolean</name>;</type>
+        <type>typedef unsigned int <name>EGLenum</name>;</type>
+        <type requires="khrplatform">typedef intptr_t <name>EGLAttribKHR</name>;</type>
+        <type requires="khrplatform">typedef intptr_t <name>EGLAttrib</name>;</type>
+        <type>typedef void *<name>EGLConfig</name>;</type>
+        <type>typedef void *<name>EGLContext</name>;</type>
+        <type>typedef void *<name>EGLDisplay</name>;</type>
+        <type>typedef void *<name>EGLSurface</name>;</type>
+        <type>typedef void *<name>EGLClientBuffer</name>;</type>
+        <type>typedef void (*<name>__eglMustCastToProperFunctionPointerType</name>)(void);</type>
+        <type>typedef void *<name>EGLImageKHR</name>;</type>
+        <type>typedef void *<name>EGLImage</name>;</type>
+        <type>typedef void *<name>EGLSyncKHR</name>;</type>
+        <type>typedef void *<name>EGLSync</name>;</type>
+        <type requires="khrplatform">typedef khronos_utime_nanoseconds_t <name>EGLTimeKHR</name>;</type>
+        <type requires="khrplatform">typedef khronos_utime_nanoseconds_t <name>EGLTime</name>;</type>
+        <type>typedef void *<name>EGLSyncNV</name>;</type>
+        <type requires="khrplatform">typedef khronos_utime_nanoseconds_t <name>EGLTimeNV</name>;</type>
+        <type requires="khrplatform">typedef khronos_utime_nanoseconds_t <name>EGLuint64NV</name>;</type>
+        <type>typedef void *<name>EGLStreamKHR</name>;</type>
+        <type requires="khrplatform">typedef khronos_uint64_t <name>EGLuint64KHR</name>;</type>
+        <type>typedef int <name>EGLNativeFileDescriptorKHR</name>;</type>
+        <type requires="khrplatform">typedef khronos_ssize_t <name>EGLsizeiANDROID</name>;</type>
+        <type requires="EGLsizeiANDROID">typedef void (*<name>EGLSetBlobFuncANDROID</name>) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize);</type>
+        <type requires="EGLsizeiANDROID">typedef EGLsizeiANDROID (*<name>EGLGetBlobFuncANDROID</name>) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize);</type>
+        <type>struct <name>EGLClientPixmapHI</name> {
+    void  *pData;
+    EGLint iWidth;
+    EGLint iHeight;
+    EGLint iStride;
+};</type>
+    </types>
+
+    <!-- SECTION: EGL enumerant (token) definitions. -->
+
+    <!-- Bitmasks each have their own namespace, as do a few other
+         categories of enumeration -->
+
+    <enums namespace="EGLSurfaceTypeMask" type="bitmask" comment="EGL_SURFACE_TYPE bits">
+        <enum value="0x0001" name="EGL_PBUFFER_BIT"/>
+        <enum value="0x0002" name="EGL_PIXMAP_BIT"/>
+        <enum value="0x0004" name="EGL_WINDOW_BIT"/>
+        <enum value="0x0008" name="EGL_PBUFFER_IMAGE_BIT_TAO" comment="Unreleased TAO extension"/>
+        <enum value="0x0010" name="EGL_PBUFFER_PALETTE_IMAGE_BIT_TAO" comment="Unreleased TAO extension"/>
+        <enum value="0x0020" name="EGL_VG_COLORSPACE_LINEAR_BIT"/>
+        <enum value="0x0020" name="EGL_VG_COLORSPACE_LINEAR_BIT_KHR"/>
+        <enum value="0x0040" name="EGL_VG_ALPHA_FORMAT_PRE_BIT"/>
+        <enum value="0x0040" name="EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR"/>
+        <enum value="0x0080" name="EGL_LOCK_SURFACE_BIT_KHR"/>
+        <enum value="0x0100" name="EGL_OPTIMAL_FORMAT_BIT_KHR"/>
+        <enum value="0x0200" name="EGL_MULTISAMPLE_RESOLVE_BOX_BIT"/>
+        <enum value="0x0400" name="EGL_SWAP_BEHAVIOR_PRESERVED_BIT"/>
+        <enum value="0x0800" name="EGL_STREAM_BIT_KHR"/>
+            <!--
+        <enum value="0x0800"      name="EGL_STREAM_BIT_NV" comment="Draft EGL_NV_stream_producer_eglsurface extension (bug 8064)"/>
+            -->
+    </enums>
+
+    <enums namespace="EGLRenderableTypeMask" type="bitmask" comment="EGL_RENDERABLE_TYPE bits">
+        <enum value="0x0001" name="EGL_OPENGL_ES_BIT"/>
+        <enum value="0x0002" name="EGL_OPENVG_BIT"/>
+        <enum value="0x0004" name="EGL_OPENGL_ES2_BIT"/>
+        <enum value="0x0008" name="EGL_OPENGL_BIT"/>
+        <enum value="0x0010" name="EGL_INTEROP_BIT_KHR" comment="EGL_KHR_interop"/>
+        <enum value="0x0020" name="EGL_OPENMAX_IL_BIT_KHR" comment="EGL_KHR_interop"/>
+        <enum value="0x00000040" name="EGL_OPENGL_ES3_BIT"/>
+        <enum value="0x00000040" name="EGL_OPENGL_ES3_BIT_KHR" alias="EGL_OPENGL_ES3_BIT"/>
+    </enums>
+
+    <enums namespace="EGLLockUsageHintKHRMask" type="bitmask" comment="EGL_LOCK_USAGE_HINT_KHR bits">
+        <enum value="0x0001" name="EGL_READ_SURFACE_BIT_KHR"/>
+        <enum value="0x0002" name="EGL_WRITE_SURFACE_BIT_KHR"/>
+    </enums>
+
+    <enums namespace="EGLSyncFlagsKHR" type="bitmask" comment="Fence/reusable sync wait bits">
+        <enum value="0x0001" name="EGL_SYNC_FLUSH_COMMANDS_BIT"/>
+        <enum value="0x0001" name="EGL_SYNC_FLUSH_COMMANDS_BIT_KHR" alias="EGL_SYNC_FLUSH_COMMANDS_BIT"/>
+        <enum value="0x0001" name="EGL_SYNC_FLUSH_COMMANDS_BIT_NV" alias="EGL_SYNC_FLUSH_COMMANDS_BIT"/>
+    </enums>
+
+    <enums namespace="EGLDRMBufferUseMESAMask" type="bitmask" comment="EGL_DRM_BUFFER_USE_MESA bits">
+        <enum value="0x00000001" name="EGL_DRM_BUFFER_USE_SCANOUT_MESA"/>
+        <enum value="0x00000002" name="EGL_DRM_BUFFER_USE_SHARE_MESA"/>
+    </enums>
+
+    <!-- Should be shared with GL, but aren't aren't since the
+         FORWARD_COMPATIBLE and DEBUG_BIT values are swapped in the
+         corresponding GL enums. Oops :-( -->
+    <enums namespace="EGLContextFlagMask" type="bitmask" comment="EGL_CONTEXT_FLAGS_KHR bits">
+        <enum value="0x00000001" name="EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR"/>
+        <enum value="0x00000002" name="EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR"/>
+        <enum value="0x00000004" name="EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR"/>
+    </enums>
+
+    <enums namespace="EGLContextProfileMask" type="bitmask" comment="Shared with GL">
+        <enum value="0x00000001" name="EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT"/>
+        <enum value="0x00000001" name="EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR" alias="EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT"/>
+        <enum value="0x00000002" name="EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT"/>
+        <enum value="0x00000002" name="EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR" alias="EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT"/>
+    </enums>
+
+    <!-- The default ("API") enum namespace starts here. While some
+         assigned values may overlap, and different parts of the
+         namespace are reserved for different purposes, it is a single
+         namespace. The "class" attribute indicates some of the reserved
+         purposes but is by no means complete (and cannot be, since many
+         tokens are reused for different purposes in different
+         extensions and API versions). -->
+
+    <enums namespace="EGL" start="0x0000" end="0x2FFF" vendor="ARB"/>
+
+    <enums namespace="EGL" group="Boolean" vendor="ARB">
+        <enum value="0" name="EGL_FALSE"/>
+        <enum value="1" name="EGL_TRUE"/>
+    </enums>
+
+    <enums namespace="EGL" group="SpecialNumbers" vendor="ARB" comment="Tokens whose numeric value is intrinsically meaningful">
+        <enum value="((EGLint)-1)" name="EGL_DONT_CARE"/>
+        <enum value="((EGLint)-1)" name="EGL_UNKNOWN"/>
+        <enum value="-1" name="EGL_NO_NATIVE_FENCE_FD_ANDROID"/>
+        <enum value="0" name="EGL_DEPTH_ENCODING_NONE_NV"/>
+        <enum value="((EGLContext)0)" name="EGL_NO_CONTEXT"/>
+        <enum value="((EGLDisplay)0)" name="EGL_NO_DISPLAY"/>
+        <enum value="((EGLImageKHR)0)" name="EGL_NO_IMAGE_KHR"/>
+        <enum value="((EGLNativeDisplayType)0)" name="EGL_DEFAULT_DISPLAY"/>
+        <enum value="((EGLNativeFileDescriptorKHR)(-1))" name="EGL_NO_FILE_DESCRIPTOR_KHR"/>
+        <enum value="((EGLStreamKHR)0)" name="EGL_NO_STREAM_KHR"/>
+        <enum value="((EGLSurface)0)" name="EGL_NO_SURFACE"/>
+        <enum value="((EGLSync)0)" name="EGL_NO_SYNC"/>
+        <enum value="((EGLSyncKHR)0)" name="EGL_NO_SYNC_KHR" alias="EGL_NO_SYNC"/>
+        <enum value="((EGLSyncNV)0)" name="EGL_NO_SYNC_NV" alias="EGL_NO_SYNC"/>
+        <enum value="10000" name="EGL_DISPLAY_SCALING"/>
+        <enum value="0xFFFFFFFFFFFFFFFF" name="EGL_FOREVER" type="ull"/>
+        <enum value="0xFFFFFFFFFFFFFFFF" name="EGL_FOREVER_KHR" type="ull" alias="EGL_FOREVER"/>
+        <enum value="0xFFFFFFFFFFFFFFFF" name="EGL_FOREVER_NV" type="ull" alias="EGL_FOREVER"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3000" end="0x305F" vendor="KHR">
+        <enum value="0x3000" name="EGL_SUCCESS"/>
+        <enum value="0x3001" name="EGL_NOT_INITIALIZED"/>
+        <enum value="0x3002" name="EGL_BAD_ACCESS"/>
+        <enum value="0x3003" name="EGL_BAD_ALLOC"/>
+        <enum value="0x3004" name="EGL_BAD_ATTRIBUTE"/>
+        <enum value="0x3005" name="EGL_BAD_CONFIG"/>
+        <enum value="0x3006" name="EGL_BAD_CONTEXT"/>
+        <enum value="0x3007" name="EGL_BAD_CURRENT_SURFACE"/>
+        <enum value="0x3008" name="EGL_BAD_DISPLAY"/>
+        <enum value="0x3009" name="EGL_BAD_MATCH"/>
+        <enum value="0x300A" name="EGL_BAD_NATIVE_PIXMAP"/>
+        <enum value="0x300B" name="EGL_BAD_NATIVE_WINDOW"/>
+        <enum value="0x300C" name="EGL_BAD_PARAMETER"/>
+        <enum value="0x300D" name="EGL_BAD_SURFACE"/>
+        <enum value="0x300E" name="EGL_CONTEXT_LOST"/>
+            <unused start="0x300F" end="0x301F" comment="for additional errors"/>
+        <enum value="0x3020" name="EGL_BUFFER_SIZE"/>
+        <enum value="0x3021" name="EGL_ALPHA_SIZE"/>
+        <enum value="0x3022" name="EGL_BLUE_SIZE"/>
+        <enum value="0x3023" name="EGL_GREEN_SIZE"/>
+        <enum value="0x3024" name="EGL_RED_SIZE"/>
+        <enum value="0x3025" name="EGL_DEPTH_SIZE"/>
+        <enum value="0x3026" name="EGL_STENCIL_SIZE"/>
+        <enum value="0x3027" name="EGL_CONFIG_CAVEAT"/>
+        <enum value="0x3028" name="EGL_CONFIG_ID"/>
+        <enum value="0x3029" name="EGL_LEVEL"/>
+        <enum value="0x302A" name="EGL_MAX_PBUFFER_HEIGHT"/>
+        <enum value="0x302B" name="EGL_MAX_PBUFFER_PIXELS"/>
+        <enum value="0x302C" name="EGL_MAX_PBUFFER_WIDTH"/>
+        <enum value="0x302D" name="EGL_NATIVE_RENDERABLE"/>
+        <enum value="0x302E" name="EGL_NATIVE_VISUAL_ID"/>
+        <enum value="0x302F" name="EGL_NATIVE_VISUAL_TYPE"/>
+        <enum value="0x3031" name="EGL_SAMPLES"/>
+        <enum value="0x3032" name="EGL_SAMPLE_BUFFERS"/>
+        <enum value="0x3033" name="EGL_SURFACE_TYPE"/>
+        <enum value="0x3034" name="EGL_TRANSPARENT_TYPE"/>
+        <enum value="0x3035" name="EGL_TRANSPARENT_BLUE_VALUE"/>
+        <enum value="0x3036" name="EGL_TRANSPARENT_GREEN_VALUE"/>
+        <enum value="0x3037" name="EGL_TRANSPARENT_RED_VALUE"/>
+        <enum value="0x3038" name="EGL_NONE" comment="Attribute list terminator"/>
+        <enum value="0x3039" name="EGL_BIND_TO_TEXTURE_RGB"/>
+        <enum value="0x303A" name="EGL_BIND_TO_TEXTURE_RGBA"/>
+        <enum value="0x303B" name="EGL_MIN_SWAP_INTERVAL"/>
+        <enum value="0x303C" name="EGL_MAX_SWAP_INTERVAL"/>
+        <enum value="0x303D" name="EGL_LUMINANCE_SIZE"/>
+        <enum value="0x303E" name="EGL_ALPHA_MASK_SIZE"/>
+        <enum value="0x303F" name="EGL_COLOR_BUFFER_TYPE"/>
+        <enum value="0x3040" name="EGL_RENDERABLE_TYPE"/>
+        <enum value="0x3041" name="EGL_MATCH_NATIVE_PIXMAP"/>
+        <enum value="0x3042" name="EGL_CONFORMANT"/>
+        <enum value="0x3042" name="EGL_CONFORMANT_KHR"/>
+        <enum value="0x3043" name="EGL_MATCH_FORMAT_KHR"/>
+            <unused start="0x3044" end="0x304F" comment="for additional config attributes"/>
+        <enum value="0x3050" name="EGL_SLOW_CONFIG"/>
+        <enum value="0x3051" name="EGL_NON_CONFORMANT_CONFIG"/>
+        <enum value="0x3052" name="EGL_TRANSPARENT_RGB"/>
+        <enum value="0x3053" name="EGL_VENDOR"/>
+        <enum value="0x3054" name="EGL_VERSION"/>
+        <enum value="0x3055" name="EGL_EXTENSIONS"/>
+        <enum value="0x3056" name="EGL_HEIGHT"/>
+        <enum value="0x3057" name="EGL_WIDTH"/>
+        <enum value="0x3058" name="EGL_LARGEST_PBUFFER"/>
+        <enum value="0x3059" name="EGL_DRAW"/>
+        <enum value="0x305A" name="EGL_READ"/>
+        <enum value="0x305B" name="EGL_CORE_NATIVE_ENGINE"/>
+        <enum value="0x305C" name="EGL_NO_TEXTURE"/>
+        <enum value="0x305D" name="EGL_TEXTURE_RGB"/>
+        <enum value="0x305E" name="EGL_TEXTURE_RGBA"/>
+        <enum value="0x305F" name="EGL_TEXTURE_2D"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3060-0x306F" vendor="TAO" comment="Reserved for Phil Huxley">
+        <unused start="0x3060" end="0x306F"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3070-0x307F" vendor="NOK" comment="Reserved for Jani Vaarala">
+        <unused start="0x3070" end="0x307E"/>
+        <enum value="0x307F" name="EGL_Y_INVERTED_NOK"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3080-0x30AF" vendor="KHR">
+        <enum value="0x3080" name="EGL_TEXTURE_FORMAT"/>
+        <enum value="0x3081" name="EGL_TEXTURE_TARGET"/>
+        <enum value="0x3082" name="EGL_MIPMAP_TEXTURE"/>
+        <enum value="0x3083" name="EGL_MIPMAP_LEVEL"/>
+        <enum value="0x3084" name="EGL_BACK_BUFFER"/>
+        <enum value="0x3085" name="EGL_SINGLE_BUFFER"/>
+        <enum value="0x3086" name="EGL_RENDER_BUFFER"/>
+        <enum value="0x3087" name="EGL_COLORSPACE" alias="EGL_VG_COLORSPACE"/>
+        <enum value="0x3087" name="EGL_VG_COLORSPACE"/>
+        <enum value="0x3088" name="EGL_ALPHA_FORMAT" alias="EGL_VG_ALPHA_FORMAT"/>
+        <enum value="0x3088" name="EGL_VG_ALPHA_FORMAT"/>
+        <enum value="0x3089" name="EGL_COLORSPACE_sRGB"/>
+        <enum value="0x3089" name="EGL_GL_COLORSPACE_SRGB" alias="EGL_COLORSPACE_sRGB"/>
+        <enum value="0x3089" name="EGL_GL_COLORSPACE_SRGB_KHR" alias="EGL_COLORSPACE_sRGB"/>
+        <enum value="0x3089" name="EGL_VG_COLORSPACE_sRGB" alias="EGL_COLORSPACE_sRGB"/>
+        <enum value="0x308A" name="EGL_COLORSPACE_LINEAR"/>
+        <enum value="0x308A" name="EGL_GL_COLORSPACE_LINEAR" alias="EGL_COLORSPACE_LINEAR"/>
+        <enum value="0x308A" name="EGL_GL_COLORSPACE_LINEAR_KHR" alias="EGL_COLORSPACE_LINEAR"/>
+        <enum value="0x308A" name="EGL_VG_COLORSPACE_LINEAR" alias="EGL_COLORSPACE_LINEAR"/>
+        <enum value="0x308B" name="EGL_ALPHA_FORMAT_NONPRE" alias="EGL_VG_ALPHA_FORMAT_NONPRE"/>
+        <enum value="0x308B" name="EGL_VG_ALPHA_FORMAT_NONPRE"/>
+        <enum value="0x308C" name="EGL_ALPHA_FORMAT_PRE" alias="EGL_VG_ALPHA_FORMAT_PRE"/>
+        <enum value="0x308C" name="EGL_VG_ALPHA_FORMAT_PRE"/>
+        <enum value="0x308D" name="EGL_CLIENT_APIS"/>
+        <enum value="0x308E" name="EGL_RGB_BUFFER"/>
+        <enum value="0x308F" name="EGL_LUMINANCE_BUFFER"/>
+        <enum value="0x3090" name="EGL_HORIZONTAL_RESOLUTION"/>
+        <enum value="0x3091" name="EGL_VERTICAL_RESOLUTION"/>
+        <enum value="0x3092" name="EGL_PIXEL_ASPECT_RATIO"/>
+        <enum value="0x3093" name="EGL_SWAP_BEHAVIOR"/>
+        <enum value="0x3094" name="EGL_BUFFER_PRESERVED"/>
+        <enum value="0x3095" name="EGL_BUFFER_DESTROYED"/>
+        <enum value="0x3096" name="EGL_OPENVG_IMAGE"/>
+        <enum value="0x3097" name="EGL_CONTEXT_CLIENT_TYPE"/>
+        <enum value="0x3098" name="EGL_CONTEXT_CLIENT_VERSION"/>
+        <enum value="0x3098" name="EGL_CONTEXT_MAJOR_VERSION" alias="EGL_CONTEXT_CLIENT_VERSION"/>
+        <enum value="0x3098" name="EGL_CONTEXT_MAJOR_VERSION_KHR" alias="EGL_CONTEXT_CLIENT_VERSION"/>
+        <enum value="0x3099" name="EGL_MULTISAMPLE_RESOLVE"/>
+        <enum value="0x309A" name="EGL_MULTISAMPLE_RESOLVE_DEFAULT"/>
+        <enum value="0x309B" name="EGL_MULTISAMPLE_RESOLVE_BOX"/>
+        <enum value="0x309C" name="EGL_CL_EVENT_HANDLE"/>
+        <enum value="0x309C" name="EGL_CL_EVENT_HANDLE_KHR" alias="EGL_CL_EVENT_HANDLE"/>
+        <enum value="0x309D" name="EGL_GL_COLORSPACE"/>
+        <enum value="0x309D" name="EGL_GL_COLORSPACE_KHR" alias="EGL_GL_COLORSPACE"/>
+            <unused start="0x309E" end="0x309F"/>
+        <enum value="0x30A0" name="EGL_OPENGL_ES_API"/>
+        <enum value="0x30A1" name="EGL_OPENVG_API"/>
+        <enum value="0x30A2" name="EGL_OPENGL_API"/>
+            <unused start="0x30A3" end="0x30AF" comment="for additional client API names"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x30B0-0x30BF" vendor="NV" comment="Reserved for Ignacio Llamas">
+        <enum value="0x30B0" name="EGL_NATIVE_PIXMAP_KHR"/>
+        <enum value="0x30B1" name="EGL_GL_TEXTURE_2D"/>
+        <enum value="0x30B1" name="EGL_GL_TEXTURE_2D_KHR" alias="EGL_GL_TEXTURE_2D"/>
+        <enum value="0x30B2" name="EGL_GL_TEXTURE_3D"/>
+        <enum value="0x30B2" name="EGL_GL_TEXTURE_3D_KHR" alias="EGL_GL_TEXTURE_3D"/>
+        <enum value="0x30B3" name="EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X"/>
+        <enum value="0x30B3" name="EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR" alias="EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X"/>
+        <enum value="0x30B4" name="EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X"/>
+        <enum value="0x30B4" name="EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR" alias="EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X"/>
+        <enum value="0x30B5" name="EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y"/>
+        <enum value="0x30B5" name="EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR" alias="EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y"/>
+        <enum value="0x30B6" name="EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y"/>
+        <enum value="0x30B6" name="EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR" alias="EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y"/>
+        <enum value="0x30B7" name="EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z"/>
+        <enum value="0x30B7" name="EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR" alias="EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z"/>
+        <enum value="0x30B8" name="EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z"/>
+        <enum value="0x30B8" name="EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR" alias="EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z"/>
+        <enum value="0x30B9" name="EGL_GL_RENDERBUFFER"/>
+        <enum value="0x30B9" name="EGL_GL_RENDERBUFFER_KHR" alias="EGL_GL_RENDERBUFFER"/>
+        <enum value="0x30BA" name="EGL_VG_PARENT_IMAGE_KHR"/>
+        <enum value="0x30BC" name="EGL_GL_TEXTURE_LEVEL"/>
+        <enum value="0x30BC" name="EGL_GL_TEXTURE_LEVEL_KHR" alias="EGL_GL_TEXTURE_LEVEL"/>
+        <enum value="0x30BD" name="EGL_GL_TEXTURE_ZOFFSET"/>
+        <enum value="0x30BD" name="EGL_GL_TEXTURE_ZOFFSET_KHR" alias="EGL_GL_TEXTURE_ZOFFSET"/>
+        <enum value="0x30BE" name="EGL_POST_SUB_BUFFER_SUPPORTED_NV"/>
+        <enum value="0x30BF" name="EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT" alias="EGL_CONTEXT_OPENGL_ROBUST_ACCESS"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x30C0-0x30CF" vendor="KHR">
+        <enum value="0x30C0" name="EGL_FORMAT_RGB_565_EXACT_KHR"/>
+        <enum value="0x30C1" name="EGL_FORMAT_RGB_565_KHR"/>
+        <enum value="0x30C2" name="EGL_FORMAT_RGBA_8888_EXACT_KHR"/>
+        <enum value="0x30C3" name="EGL_FORMAT_RGBA_8888_KHR"/>
+        <enum value="0x30C4" name="EGL_MAP_PRESERVE_PIXELS_KHR"/>
+        <enum value="0x30C5" name="EGL_LOCK_USAGE_HINT_KHR"/>
+        <enum value="0x30C6" name="EGL_BITMAP_POINTER_KHR"/>
+        <enum value="0x30C7" name="EGL_BITMAP_PITCH_KHR"/>
+        <enum value="0x30C8" name="EGL_BITMAP_ORIGIN_KHR"/>
+        <enum value="0x30C9" name="EGL_BITMAP_PIXEL_RED_OFFSET_KHR"/>
+        <enum value="0x30CA" name="EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR"/>
+        <enum value="0x30CB" name="EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR"/>
+        <enum value="0x30CC" name="EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR"/>
+        <enum value="0x30CD" name="EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR"/>
+        <enum value="0x30CE" name="EGL_LOWER_LEFT_KHR"/>
+        <enum value="0x30CF" name="EGL_UPPER_LEFT_KHR"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x30D0" end="0x30DF" vendor="Symbian" comment="Reserved for Robert Palmer (bug #2545)">
+            <unused start="0x30D0" end="0x30D1"/>
+        <enum value="0x30D2" name="EGL_IMAGE_PRESERVED_KHR"/>
+            <unused start="0x30D3" end="0x30D9"/>
+        <enum value="0x30DA" name="EGL_SHARED_IMAGE_NOK" comment="Unreleased extension"/>
+            <unused start="0x30DB" end="0x30DF"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x30E0" end="0x30EF" vendor="NV" comment="Reserved for Russell Pflughaupt (bug #3314)">
+        <enum value="0x30E0" name="EGL_COVERAGE_BUFFERS_NV"/>
+        <enum value="0x30E1" name="EGL_COVERAGE_SAMPLES_NV"/>
+        <enum value="0x30E2" name="EGL_DEPTH_ENCODING_NV"/>
+        <enum value="0x30E3" name="EGL_DEPTH_ENCODING_NONLINEAR_NV"/>
+            <unused start="0x30E4" end="0x30E5"/>
+        <enum value="0x30E6" name="EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV"/>
+        <enum value="0x30E7" name="EGL_SYNC_STATUS_NV"/>
+        <enum value="0x30E8" name="EGL_SIGNALED_NV"/>
+        <enum value="0x30E9" name="EGL_UNSIGNALED_NV"/>
+        <enum value="0x30EA" name="EGL_ALREADY_SIGNALED_NV"/>
+        <enum value="0x30EB" name="EGL_TIMEOUT_EXPIRED_NV"/>
+        <enum value="0x30EC" name="EGL_CONDITION_SATISFIED_NV"/>
+        <enum value="0x30ED" name="EGL_SYNC_TYPE_NV"/>
+        <enum value="0x30EE" name="EGL_SYNC_CONDITION_NV"/>
+        <enum value="0x30EF" name="EGL_SYNC_FENCE_NV"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x30F0" end="0x30FF" vendor="KHR">
+        <enum value="0x30F0" name="EGL_SYNC_PRIOR_COMMANDS_COMPLETE"/>
+        <enum value="0x30F0" name="EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR" alias="EGL_SYNC_PRIOR_COMMANDS_COMPLETE"/>
+        <enum value="0x30F1" name="EGL_SYNC_STATUS"/>
+        <enum value="0x30F1" name="EGL_SYNC_STATUS_KHR" alias="EGL_SYNC_STATUS"/>
+        <enum value="0x30F2" name="EGL_SIGNALED"/>
+        <enum value="0x30F2" name="EGL_SIGNALED_KHR" alias="EGL_SIGNALED"/>
+        <enum value="0x30F3" name="EGL_UNSIGNALED"/>
+        <enum value="0x30F3" name="EGL_UNSIGNALED_KHR" alias="EGL_UNSIGNALED"/>
+        <enum value="0x30F5" name="EGL_TIMEOUT_EXPIRED"/>
+        <enum value="0x30F5" name="EGL_TIMEOUT_EXPIRED_KHR" alias="EGL_TIMEOUT_EXPIRED"/>
+        <enum value="0x30F6" name="EGL_CONDITION_SATISFIED"/>
+        <enum value="0x30F6" name="EGL_CONDITION_SATISFIED_KHR" alias="EGL_CONDITION_SATISFIED"/>
+        <enum value="0x30F7" name="EGL_SYNC_TYPE"/>
+        <enum value="0x30F7" name="EGL_SYNC_TYPE_KHR" alias="EGL_SYNC_TYPE"/>
+        <enum value="0x30F8" name="EGL_SYNC_CONDITION"/>
+        <enum value="0x30F8" name="EGL_SYNC_CONDITION_KHR" alias="EGL_SYNC_CONDITION"/>
+        <enum value="0x30F9" name="EGL_SYNC_FENCE"/>
+        <enum value="0x30F9" name="EGL_SYNC_FENCE_KHR" alias="EGL_SYNC_FENCE"/>
+        <enum value="0x30FA" name="EGL_SYNC_REUSABLE_KHR"/>
+        <enum value="0x30FB" name="EGL_CONTEXT_MINOR_VERSION"/>
+        <enum value="0x30FB" name="EGL_CONTEXT_MINOR_VERSION_KHR" alias="EGL_CONTEXT_MINOR_VERSION"/>
+        <enum value="0x30FC" name="EGL_CONTEXT_FLAGS_KHR"/>
+        <enum value="0x30FD" name="EGL_CONTEXT_OPENGL_PROFILE_MASK"/>
+        <enum value="0x30FD" name="EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR" alias="EGL_CONTEXT_OPENGL_PROFILE_MASK"/>
+        <enum value="0x30FE" name="EGL_SYNC_CL_EVENT"/>
+        <enum value="0x30FE" name="EGL_SYNC_CL_EVENT_KHR" alias="EGL_SYNC_CL_EVENT"/>
+        <enum value="0x30FF" name="EGL_SYNC_CL_EVENT_COMPLETE"/>
+        <enum value="0x30FF" name="EGL_SYNC_CL_EVENT_COMPLETE_KHR" alias="EGL_SYNC_CL_EVENT_COMPLETE"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3100" end="0x310F" vendor="IMG" comment="Reserved for Ben Bowman (Khronos bug 4748)">
+        <enum value="0x3100" name="EGL_CONTEXT_PRIORITY_LEVEL_IMG"/>
+        <enum value="0x3101" name="EGL_CONTEXT_PRIORITY_HIGH_IMG"/>
+        <enum value="0x3102" name="EGL_CONTEXT_PRIORITY_MEDIUM_IMG"/>
+        <enum value="0x3103" name="EGL_CONTEXT_PRIORITY_LOW_IMG"/>
+            <unused start="0x3104" end="0x310F"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3110" end="0x311F" vendor="ATX" comment="Reserved for Tim Renouf, Antix (Khronos bug 4949)">
+        <enum value="0x3110" name="EGL_BITMAP_PIXEL_SIZE_KHR"/>
+            <unused start="0x3111" end="0x311F"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3120" end="0x312F" vendor="AMD" comment="Reserved for David Garcia (Khronos bug 5149)">
+            <unused start="0x3120" end="0x312F"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3130" end="0x313F" vendor="NV" comment="Reserved for Greg Prisament (Khronos bug 5166)">
+            <unused start="0x3130"/>
+        <enum value="0x3131" name="EGL_COVERAGE_SAMPLE_RESOLVE_NV"/>
+        <enum value="0x3132" name="EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV"/>
+        <enum value="0x3133" name="EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV"/>
+        <enum value="0x3134" name="EGL_MULTIVIEW_VIEW_COUNT_EXT"/>
+            <unused start="0x3135"/>
+        <enum value="0x3136" name="EGL_AUTO_STEREO_NV"/>
+            <unused start="0x3137"/>
+        <enum value="0x3138" name="EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT"/>
+            <unused start="0x3139" end="0x313C"/>
+        <enum value="0x313D" name="EGL_BUFFER_AGE_EXT"/>
+            <unused start="0x313E" end="0x313F"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3140" end="0x314F" vendor="Google" comment="Reserved for Mathias Agopian (Khronos bug 5199)">
+        <enum value="0x3140" name="EGL_NATIVE_BUFFER_ANDROID"/>
+        <enum value="0x3141" name="EGL_PLATFORM_ANDROID_KHR"/>
+        <enum value="0x3142" name="EGL_RECORDABLE_ANDROID"/>
+            <unused start="0x3143"/>
+        <enum value="0x3144" name="EGL_SYNC_NATIVE_FENCE_ANDROID"/>
+        <enum value="0x3145" name="EGL_SYNC_NATIVE_FENCE_FD_ANDROID"/>
+        <enum value="0x3146" name="EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID"/>
+        <enum value="0x3147" name="EGL_FRAMEBUFFER_TARGET_ANDROID"/>
+            <unused start="0x3148" end="0x314F"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3150" end="0x315F" vendor="NOK" comment="Reserved for Robert Palmer (Khronos bug 5368)">
+            <unused start="0x3150" end="0x315F"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3160" end="0x316F" vendor="Seaweed" comment="Reserved for Sree Sridharan (Khronos public bug 198)">
+            <unused start="0x3160" end="0x316F"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3170" end="0x318F" vendor="QNX" comment="Reserved for Joel Pilon (Khronos bug 5834)">
+            <unused start="0x3170" end="0x318F"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3190" end="0x31AF" vendor="FSL" comment="Reserved for Brian Murray, Freescale (Khronos bug 5939)">
+            <unused start="0x3190" end="0x31AF"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x31B0" end="0x31BF" vendor="KHR" comment="Reserved for Marcus Lorentzon (Khronos bug 6437)">
+        <enum value="0x31B0" name="EGL_CONTEXT_OPENGL_DEBUG"/>
+        <enum value="0x31B1" name="EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE"/>
+        <enum value="0x31B2" name="EGL_CONTEXT_OPENGL_ROBUST_ACCESS"/>
+            <unused start="0x31B3" end="0x31BC" comment="Formerly reserved for EGL_image_stream"/>
+        <enum value="0x31BD" name="EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR" alias="EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY"/>
+        <enum value="0x31BD" name="EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY"/>
+        <enum value="0x31BE" name="EGL_NO_RESET_NOTIFICATION"/>
+        <enum value="0x31BE" name="EGL_NO_RESET_NOTIFICATION_KHR" alias="EGL_NO_RESET_NOTIFICATION"/>
+        <enum value="0x31BE" name="EGL_NO_RESET_NOTIFICATION_EXT" alias="EGL_NO_RESET_NOTIFICATION"/>
+        <enum value="0x31BF" name="EGL_LOSE_CONTEXT_ON_RESET"/>
+        <enum value="0x31BF" name="EGL_LOSE_CONTEXT_ON_RESET_KHR" alias="EGL_LOSE_CONTEXT_ON_RESET"/>
+        <enum value="0x31BF" name="EGL_LOSE_CONTEXT_ON_RESET_EXT" alias="EGL_LOSE_CONTEXT_ON_RESET"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x31C0" end="0x31CF" vendor="QCOM" comment="Reserved for Maurice Ribble (Khronos bug 6644) - EGL_QCOM_create_image spec TBD">
+            <unused start="0x31C0" end="0x31CF"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x31D0" end="0x31DF" vendor="MESA" comment="Reserved for Kristian H&#248;gsberg (Khronos bug 6757)">
+        <enum value="0x31D0" name="EGL_DRM_BUFFER_FORMAT_MESA"/>
+        <enum value="0x31D1" name="EGL_DRM_BUFFER_USE_MESA"/>
+        <enum value="0x31D2" name="EGL_DRM_BUFFER_FORMAT_ARGB32_MESA"/>
+        <enum value="0x31D3" name="EGL_DRM_BUFFER_MESA"/>
+        <enum value="0x31D4" name="EGL_DRM_BUFFER_STRIDE_MESA"/>
+        <enum value="0x31D5" name="EGL_PLATFORM_X11_KHR"/>
+        <enum value="0x31D5" name="EGL_PLATFORM_X11_EXT" alias="EGL_PLATFORM_X11_KHR"/>
+        <enum value="0x31D6" name="EGL_PLATFORM_X11_SCREEN_KHR"/>
+        <enum value="0x31D6" name="EGL_PLATFORM_X11_SCREEN_EXT" alias="EGL_PLATFORM_X11_SCREEN_KHR"/>
+        <enum value="0x31D7" name="EGL_PLATFORM_GBM_KHR"/>
+        <enum value="0x31D7" name="EGL_PLATFORM_GBM_MESA" alias="EGL_PLATFORM_GBM_KHR"/>
+        <enum value="0x31D8" name="EGL_PLATFORM_WAYLAND_KHR"/>
+        <enum value="0x31D8" name="EGL_PLATFORM_WAYLAND_EXT" alias="EGL_PLATFORM_WAYLAND_KHR"/>
+            <unused start="0x31D9" end="0x31DF"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x31E0" end="0x31EF" vendor="HI" comment="Reserved for Mark Callow (Khronos bug 6799)">
+            <unused start="0x31E0" end="0x31EF"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x31F0" end="0x31FF" vendor="KHR">
+            <unused start="0x31F0" end="0x31FB" comment="Placeholders for draft extensions follow"/>
+        <!--
+            <enum value="0x31F0" name="EGL_IMAGE_USE_AS_OPENGL_ES1_RENDERBUFFER_KHR"        comment="Draft KHR_image_use_gl1_renderbuffer"/>
+            <enum value="0x31F1" name="EGL_IMAGE_USE_AS_OPENGL_ES1_TEXTURE_2D_KHR"          comment="Draft KHR_image_use_gl1_texture_2d"/>
+            <enum value="0x31F2" name="EGL_IMAGE_USE_AS_OPENGL_ES1_TEXTURE_EXTERNAL_KHR"    comment="Draft KHR_image_use_gl1_texture_external"/>
+            <enum value="0x31F3" name="EGL_IMAGE_USE_AS_OPENGL_ES2_RENDERBUFFER_KHR"        comment="Draft KHR_image_use_gl2_renderbuffer"/>
+            <enum value="0x31F4" name="EGL_IMAGE_USE_AS_OPENGL_ES2_TEXTURE_2D_KHR"          comment="Draft KHR_image_use_gl2_texture_2d"/>
+            <enum value="0x31F5" name="EGL_IMAGE_USE_AS_OPENGL_ES2_TEXTURE_EXTERNAL_KHR"    comment="Draft KHR_image_use_gl2_texture_external"/>
+            <enum value="0x31F6" name="EGL_IMAGE_USE_AS_OPENVG_IMAGE_KHR"                   comment="Draft KHR_image_use_vg_vgimage"/>
+            <enum value="0x31F7" name="EGL_STREAM_CONSUMER_ATTACHMENT_MESA"                 comment="Draft EGL_MESA_image_stream_internal"/>
+            <enum value="0x31F8" name="EGL_NO_FORMAT_MESA"                                  comment="Draft EGL_MESA_image_stream_internal"/>
+            <enum value="0x31F9" name="EGL_FORMAT_RGBA8888_MESA"                            comment="Draft EGL_MESA_image_stream_internal"/>
+            <enum value="0x31FA" name="EGL_FORMAT_RGB888_MESA"                              comment="Draft EGL_MESA_image_stream_internal"/>
+            <enum value="0x31FB" name="EGL_FORMAT_RGB565_MESA"                              comment="Draft EGL_MESA_image_stream_internal"/>
+        -->
+        <enum value="0x31FC" name="EGL_STREAM_FIFO_LENGTH_KHR"/>
+        <enum value="0x31FD" name="EGL_STREAM_TIME_NOW_KHR"/>
+        <enum value="0x31FE" name="EGL_STREAM_TIME_CONSUMER_KHR"/>
+        <enum value="0x31FF" name="EGL_STREAM_TIME_PRODUCER_KHR"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3200" end="0x320F" vendor="ANGLE" comment="Reserved for Daniel Koch, ANGLE Project (Khronos bug 7139)">
+        <enum value="0x3200" name="EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE"/>
+            <unused start="0x3201" end="0x320F"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3210" end="0x321F" vendor="KHR">
+        <enum value="0x3210" name="EGL_CONSUMER_LATENCY_USEC_KHR"/>
+            <unused start="0x3211"/>
+        <enum value="0x3212" name="EGL_PRODUCER_FRAME_KHR"/>
+        <enum value="0x3213" name="EGL_CONSUMER_FRAME_KHR"/>
+        <enum value="0x3214" name="EGL_STREAM_STATE_KHR"/>
+        <enum value="0x3215" name="EGL_STREAM_STATE_CREATED_KHR"/>
+        <enum value="0x3216" name="EGL_STREAM_STATE_CONNECTING_KHR"/>
+        <enum value="0x3217" name="EGL_STREAM_STATE_EMPTY_KHR"/>
+        <enum value="0x3218" name="EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR"/>
+        <enum value="0x3219" name="EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR"/>
+        <enum value="0x321A" name="EGL_STREAM_STATE_DISCONNECTED_KHR"/>
+        <enum value="0x321B" name="EGL_BAD_STREAM_KHR"/>
+        <enum value="0x321C" name="EGL_BAD_STATE_KHR"/>
+        <enum value="0x321D" name="EGL_BUFFER_COUNT_NV" comment="From EGL_NV_stream_producer_eglsurface, which has no known specification and was replaced by a KHR extension"/>
+        <enum value="0x321E" name="EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR"/>
+        <enum value="0x321F" name="EGL_SYNC_NEW_FRAME_NV"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3220" end="0x325F" vendor="NV" comment="Reserved for Greg Roth (Bug 8220)">
+            <unused start="0x3220" end="0x325F"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3260" end="0x326F" vendor="BCOM" comment="Reserved for Gary Sweet, Broadcom (Public bug 620)">
+            <unused start="0x3260" end="0x326F"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3270" end="0x328F" vendor="ARM" comment="Reserved for Tom Cooksey (Bug 9963)">
+        <enum value="0x3270" name="EGL_LINUX_DMA_BUF_EXT"/>
+        <enum value="0x3271" name="EGL_LINUX_DRM_FOURCC_EXT"/>
+        <enum value="0x3272" name="EGL_DMA_BUF_PLANE0_FD_EXT"/>
+        <enum value="0x3273" name="EGL_DMA_BUF_PLANE0_OFFSET_EXT"/>
+        <enum value="0x3274" name="EGL_DMA_BUF_PLANE0_PITCH_EXT"/>
+        <enum value="0x3275" name="EGL_DMA_BUF_PLANE1_FD_EXT"/>
+        <enum value="0x3276" name="EGL_DMA_BUF_PLANE1_OFFSET_EXT"/>
+        <enum value="0x3277" name="EGL_DMA_BUF_PLANE1_PITCH_EXT"/>
+        <enum value="0x3278" name="EGL_DMA_BUF_PLANE2_FD_EXT"/>
+        <enum value="0x3279" name="EGL_DMA_BUF_PLANE2_OFFSET_EXT"/>
+        <enum value="0x327A" name="EGL_DMA_BUF_PLANE2_PITCH_EXT"/>
+        <enum value="0x327B" name="EGL_YUV_COLOR_SPACE_HINT_EXT"/>
+        <enum value="0x327C" name="EGL_SAMPLE_RANGE_HINT_EXT"/>
+        <enum value="0x327D" name="EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT"/>
+        <enum value="0x327E" name="EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT"/>
+        <enum value="0x327F" name="EGL_ITU_REC601_EXT"/>
+        <enum value="0x3280" name="EGL_ITU_REC709_EXT"/>
+        <enum value="0x3281" name="EGL_ITU_REC2020_EXT"/>
+        <enum value="0x3282" name="EGL_YUV_FULL_RANGE_EXT"/>
+        <enum value="0x3283" name="EGL_YUV_NARROW_RANGE_EXT"/>
+        <enum value="0x3284" name="EGL_YUV_CHROMA_SITING_0_EXT"/>
+        <enum value="0x3285" name="EGL_YUV_CHROMA_SITING_0_5_EXT"/>
+        <enum value="0x3286" name="EGL_DISCARD_SAMPLES_ARM"/>
+            <unused start="0x3287" end="0x328F"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x3290" end="0x329F" vendor="MESA" comment="Reserved for John K&#229;re Alsaker (Public bug 757)">
+            <unused start="0x3290" end="0x329F"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x32A0" end="0x32AF" vendor="Samsung" comment="Reserved for Dongyeon Kim (Public bug 880)">
+            <unused start="0x32A0" end="0x32AF"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x32B0" end="0x32BF" vendor="QCOM" comment="Reserved for Jeff Vigil (Bug 10663) - EGL_QCOM_lock_image spec TBD">
+            <unused start="0x32B0" end="0x32BF"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x32C0" end="0x32CF" vendor="Vivante" comment="Reserved for Yanjun Zhang (Bug 11498)">
+        <enum value="0x32C0" name="EGL_PROTECTED_CONTENT_EXT"/>
+            <unused start="0x32C1" end="0x32CF"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x32D0" end="0x32DF" vendor="QCOM" comment="Reserved for Jeff Vigil (Bug 11735) - EGL_QCOM_gpu_perf spec TBD">
+            <unused start="0x32D0" end="0x32DF"/>
+    </enums>
+
+<!-- Please remember that new enumerant allocations must be obtained by
+     request to the Khronos API registrar (see comments at the top of this
+     file) File requests in the Khronos Bugzilla, EGL project, Registry
+     component. Also note that some EGL enum values are shared with other
+     Khronos APIs, and new ranges should be allocated with such overlaps in
+     mind. -->
+
+<!-- Reservable for future use: 0x32E0-0x3FFF.
+     To generate a new range, allocate multiples of 16 starting at the
+     lowest available point in this block. -->
+    <enums namespace="EGL" start="0x32E0" end="0x3FFF" vendor="KHR">
+            <unused start="0x32E0" end="0x3FFF" comment="Reserved for future use"/>
+    </enums>
+
+    <enums namespace="EGL" start="0x8F70" end="0x8F7F" vendor="HI" comment="For Mark Callow, Khronos bug 4055. Shared with GL.">
+        <enum value="0x8F70" name="EGL_COLOR_FORMAT_HI"/>
+        <enum value="0x8F71" name="EGL_COLOR_RGB_HI"/>
+        <enum value="0x8F72" name="EGL_COLOR_RGBA_HI"/>
+        <enum value="0x8F73" name="EGL_COLOR_ARGB_HI"/>
+        <enum value="0x8F74" name="EGL_CLIENT_PIXMAP_POINTER_HI"/>
+    </enums>
+
+    <!-- SECTION: EGL command definitions. -->
+    <commands namespace="EGL">
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglBindAPI</name></proto>
+            <param><ptype>EGLenum</ptype> <name>api</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglBindTexImage</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surface</name></param>
+            <param><ptype>EGLint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglChooseConfig</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+            <param><ptype>EGLConfig</ptype> *<name>configs</name></param>
+            <param><ptype>EGLint</ptype> <name>config_size</name></param>
+            <param><ptype>EGLint</ptype> *<name>num_config</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLint</ptype> <name>eglClientWaitSync</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSync</ptype> <name>sync</name></param>
+            <param><ptype>EGLint</ptype> <name>flags</name></param>
+            <param><ptype>EGLTime</ptype> <name>timeout</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLint</ptype> <name>eglClientWaitSyncKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSyncKHR</ptype> <name>sync</name></param>
+            <param><ptype>EGLint</ptype> <name>flags</name></param>
+            <param><ptype>EGLTimeKHR</ptype> <name>timeout</name></param>
+            <alias name="eglClientWaitSync"/>
+        </command>
+        <command>
+            <proto><ptype>EGLint</ptype> <name>eglClientWaitSyncNV</name></proto>
+            <param><ptype>EGLSyncNV</ptype> <name>sync</name></param>
+            <param><ptype>EGLint</ptype> <name>flags</name></param>
+            <param><ptype>EGLTimeNV</ptype> <name>timeout</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglCopyBuffers</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surface</name></param>
+            <param><ptype>EGLNativePixmapType</ptype> <name>target</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLContext</ptype> <name>eglCreateContext</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLConfig</ptype> <name>config</name></param>
+            <param><ptype>EGLContext</ptype> <name>share_context</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLImageKHR</ptype> <name>eglCreateDRMImageMESA</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLSyncNV</ptype> <name>eglCreateFenceSyncNV</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLenum</ptype> <name>condition</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLImageKHR</ptype> <name>eglCreateImageKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLContext</ptype> <name>ctx</name></param>
+            <param><ptype>EGLenum</ptype> <name>target</name></param>
+            <param><ptype>EGLClientBuffer</ptype> <name>buffer</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLSurface</ptype> <name>eglCreatePbufferFromClientBuffer</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLenum</ptype> <name>buftype</name></param>
+            <param><ptype>EGLClientBuffer</ptype> <name>buffer</name></param>
+            <param><ptype>EGLConfig</ptype> <name>config</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLSurface</ptype> <name>eglCreatePbufferSurface</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLConfig</ptype> <name>config</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLSurface</ptype> <name>eglCreatePixmapSurface</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLConfig</ptype> <name>config</name></param>
+            <param><ptype>EGLNativePixmapType</ptype> <name>pixmap</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLSurface</ptype> <name>eglCreatePixmapSurfaceHI</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLConfig</ptype> <name>config</name></param>
+            <param>struct <ptype>EGLClientPixmapHI</ptype> *<name>pixmap</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLSurface</ptype> <name>eglCreatePlatformPixmapSurface</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLConfig</ptype> <name>config</name></param>
+            <param>void *<name>native_pixmap</name></param>
+            <param>const <ptype>EGLAttrib</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLSurface</ptype> <name>eglCreatePlatformPixmapSurfaceEXT</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLConfig</ptype> <name>config</name></param>
+            <param>void *<name>native_pixmap</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLSurface</ptype> <name>eglCreatePlatformWindowSurface</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLConfig</ptype> <name>config</name></param>
+            <param>void *<name>native_window</name></param>
+            <param>const <ptype>EGLAttrib</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLSurface</ptype> <name>eglCreatePlatformWindowSurfaceEXT</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLConfig</ptype> <name>config</name></param>
+            <param>void *<name>native_window</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLStreamKHR</ptype> <name>eglCreateStreamFromFileDescriptorKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLNativeFileDescriptorKHR</ptype> <name>file_descriptor</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLStreamKHR</ptype> <name>eglCreateStreamKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLSurface</ptype> <name>eglCreateStreamProducerSurfaceKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLConfig</ptype> <name>config</name></param>
+            <param><ptype>EGLStreamKHR</ptype> <name>stream</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLSyncKHR</ptype> <name>eglCreateStreamSyncNV</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLStreamKHR</ptype> <name>stream</name></param>
+            <param><ptype>EGLenum</ptype> <name>type</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLSync</ptype> <name>eglCreateSync</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLenum</ptype> <name>type</name></param>
+            <param>const <ptype>EGLAttrib</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLSyncKHR</ptype> <name>eglCreateSyncKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLenum</ptype> <name>type</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLSyncKHR</ptype> <name>eglCreateSync64KHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLenum</ptype> <name>type</name></param>
+            <param>const <ptype>EGLAttribKHR</ptype> *<name>attrib_list</name></param>
+            <alias name="eglCreateSync"/>
+        </command>
+        <command>
+            <proto><ptype>EGLSurface</ptype> <name>eglCreateWindowSurface</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLConfig</ptype> <name>config</name></param>
+            <param><ptype>EGLNativeWindowType</ptype> <name>win</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglDestroyContext</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLContext</ptype> <name>ctx</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglDestroyImageKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLImageKHR</ptype> <name>image</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglDestroyStreamKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLStreamKHR</ptype> <name>stream</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglDestroySurface</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surface</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglDestroySync</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSync</ptype> <name>sync</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglDestroySyncKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSyncKHR</ptype> <name>sync</name></param>
+            <alias name="eglDestroySync"/>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglDestroySyncNV</name></proto>
+            <param><ptype>EGLSyncNV</ptype> <name>sync</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLint</ptype> <name>eglDupNativeFenceFDANDROID</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSyncKHR</ptype> <name>sync</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglExportDRMImageMESA</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLImageKHR</ptype> <name>image</name></param>
+            <param><ptype>EGLint</ptype> *<name>name</name></param>
+            <param><ptype>EGLint</ptype> *<name>handle</name></param>
+            <param><ptype>EGLint</ptype> *<name>stride</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglFenceNV</name></proto>
+            <param><ptype>EGLSyncNV</ptype> <name>sync</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglGetConfigAttrib</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLConfig</ptype> <name>config</name></param>
+            <param><ptype>EGLint</ptype> <name>attribute</name></param>
+            <param><ptype>EGLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglGetConfigs</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLConfig</ptype> *<name>configs</name></param>
+            <param><ptype>EGLint</ptype> <name>config_size</name></param>
+            <param><ptype>EGLint</ptype> *<name>num_config</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLContext</ptype> <name>eglGetCurrentContext</name></proto>
+        </command>
+        <command>
+            <proto><ptype>EGLDisplay</ptype> <name>eglGetCurrentDisplay</name></proto>
+        </command>
+        <command>
+            <proto><ptype>EGLSurface</ptype> <name>eglGetCurrentSurface</name></proto>
+            <param><ptype>EGLint</ptype> <name>readdraw</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLDisplay</ptype> <name>eglGetDisplay</name></proto>
+            <param><ptype>EGLNativeDisplayType</ptype> <name>display_id</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLint</ptype> <name>eglGetError</name></proto>
+        </command>
+        <command>
+            <proto><ptype>EGLDisplay</ptype> <name>eglGetPlatformDisplay</name></proto>
+            <param><ptype>EGLenum</ptype> <name>platform</name></param>
+            <param>void *<name>native_display</name></param>
+            <param>const <ptype>EGLAttrib</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLDisplay</ptype> <name>eglGetPlatformDisplayEXT</name></proto>
+            <param><ptype>EGLenum</ptype> <name>platform</name></param>
+            <param>void *<name>native_display</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>__eglMustCastToProperFunctionPointerType</ptype> <name>eglGetProcAddress</name></proto>
+            <param>const char *<name>procname</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLNativeFileDescriptorKHR</ptype> <name>eglGetStreamFileDescriptorKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLStreamKHR</ptype> <name>stream</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglGetSyncAttrib</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSync</ptype> <name>sync</name></param>
+            <param><ptype>EGLint</ptype> <name>attribute</name></param>
+            <param><ptype>EGLAttrib</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglGetSyncAttribKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSyncKHR</ptype> <name>sync</name></param>
+            <param><ptype>EGLint</ptype> <name>attribute</name></param>
+            <param><ptype>EGLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglGetSyncAttribNV</name></proto>
+            <param><ptype>EGLSyncNV</ptype> <name>sync</name></param>
+            <param><ptype>EGLint</ptype> <name>attribute</name></param>
+            <param><ptype>EGLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLuint64NV</ptype> <name>eglGetSystemTimeFrequencyNV</name></proto>
+        </command>
+        <command>
+            <proto><ptype>EGLuint64NV</ptype> <name>eglGetSystemTimeNV</name></proto>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglInitialize</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLint</ptype> *<name>major</name></param>
+            <param><ptype>EGLint</ptype> *<name>minor</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglLockSurfaceKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surface</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>attrib_list</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglMakeCurrent</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>draw</name></param>
+            <param><ptype>EGLSurface</ptype> <name>read</name></param>
+            <param><ptype>EGLContext</ptype> <name>ctx</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglPostSubBufferNV</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surface</name></param>
+            <param><ptype>EGLint</ptype> <name>x</name></param>
+            <param><ptype>EGLint</ptype> <name>y</name></param>
+            <param><ptype>EGLint</ptype> <name>width</name></param>
+            <param><ptype>EGLint</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLenum</ptype> <name>eglQueryAPI</name></proto>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglQueryContext</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLContext</ptype> <name>ctx</name></param>
+            <param><ptype>EGLint</ptype> <name>attribute</name></param>
+            <param><ptype>EGLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglQueryNativeDisplayNV</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLNativeDisplayType</ptype> *<name>display_id</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglQueryNativePixmapNV</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surf</name></param>
+            <param><ptype>EGLNativePixmapType</ptype> *<name>pixmap</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglQueryNativeWindowNV</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surf</name></param>
+            <param><ptype>EGLNativeWindowType</ptype> *<name>window</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglQueryStreamKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLStreamKHR</ptype> <name>stream</name></param>
+            <param><ptype>EGLenum</ptype> <name>attribute</name></param>
+            <param><ptype>EGLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglQueryStreamTimeKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLStreamKHR</ptype> <name>stream</name></param>
+            <param><ptype>EGLenum</ptype> <name>attribute</name></param>
+            <param><ptype>EGLTimeKHR</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglQueryStreamu64KHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLStreamKHR</ptype> <name>stream</name></param>
+            <param><ptype>EGLenum</ptype> <name>attribute</name></param>
+            <param><ptype>EGLuint64KHR</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>const char *<name>eglQueryString</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLint</ptype> <name>name</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglQuerySurface</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surface</name></param>
+            <param><ptype>EGLint</ptype> <name>attribute</name></param>
+            <param><ptype>EGLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglQuerySurface64KHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surface</name></param>
+            <param><ptype>EGLint</ptype> <name>attribute</name></param>
+            <param><ptype>EGLAttribKHR</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglQuerySurfacePointerANGLE</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surface</name></param>
+            <param><ptype>EGLint</ptype> <name>attribute</name></param>
+            <param>void **<name>value</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglReleaseTexImage</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surface</name></param>
+            <param><ptype>EGLint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglReleaseThread</name></proto>
+        </command>
+        <command>
+            <proto>void <name>eglSetBlobCacheFuncsANDROID</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSetBlobFuncANDROID</ptype> <name>set</name></param>
+            <param><ptype>EGLGetBlobFuncANDROID</ptype> <name>get</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglSignalSyncKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSyncKHR</ptype> <name>sync</name></param>
+            <param><ptype>EGLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglSignalSyncNV</name></proto>
+            <param><ptype>EGLSyncNV</ptype> <name>sync</name></param>
+            <param><ptype>EGLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglStreamAttribKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLStreamKHR</ptype> <name>stream</name></param>
+            <param><ptype>EGLenum</ptype> <name>attribute</name></param>
+            <param><ptype>EGLint</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglStreamConsumerAcquireKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLStreamKHR</ptype> <name>stream</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglStreamConsumerGLTextureExternalKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLStreamKHR</ptype> <name>stream</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglStreamConsumerReleaseKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLStreamKHR</ptype> <name>stream</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglSurfaceAttrib</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surface</name></param>
+            <param><ptype>EGLint</ptype> <name>attribute</name></param>
+            <param><ptype>EGLint</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglSwapBuffers</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surface</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglSwapBuffersWithDamageEXT</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surface</name></param>
+            <param><ptype>EGLint</ptype> *<name>rects</name></param>
+            <param><ptype>EGLint</ptype> <name>n_rects</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglSwapBuffersRegionNOK</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surface</name></param>
+            <param><ptype>EGLint</ptype> <name>numRects</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>rects</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglSwapBuffersRegion2NOK</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surface</name></param>
+            <param><ptype>EGLint</ptype> <name>numRects</name></param>
+            <param>const <ptype>EGLint</ptype> *<name>rects</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglSwapInterval</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLint</ptype> <name>interval</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglTerminate</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglUnlockSurfaceKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surface</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglWaitClient</name></proto>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglWaitGL</name></proto>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglWaitNative</name></proto>
+            <param><ptype>EGLint</ptype> <name>engine</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglWaitSync</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSync</ptype> <name>sync</name></param>
+            <param><ptype>EGLint</ptype> <name>flags</name></param>
+        </command>
+        <command>
+            <proto><ptype>EGLint</ptype> <name>eglWaitSyncKHR</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSyncKHR</ptype> <name>sync</name></param>
+            <param><ptype>EGLint</ptype> <name>flags</name></param>
+        </command>
+    </commands>
+
+    <!-- SECTION: EGL API interface definitions. -->
+    <feature api="egl" name="EGL_VERSION_1_0" number="1.0">
+        <require>
+            <enum name="EGL_ALPHA_SIZE"/>
+            <enum name="EGL_BAD_ACCESS"/>
+            <enum name="EGL_BAD_ALLOC"/>
+            <enum name="EGL_BAD_ATTRIBUTE"/>
+            <enum name="EGL_BAD_CONFIG"/>
+            <enum name="EGL_BAD_CONTEXT"/>
+            <enum name="EGL_BAD_CURRENT_SURFACE"/>
+            <enum name="EGL_BAD_DISPLAY"/>
+            <enum name="EGL_BAD_MATCH"/>
+            <enum name="EGL_BAD_NATIVE_PIXMAP"/>
+            <enum name="EGL_BAD_NATIVE_WINDOW"/>
+            <enum name="EGL_BAD_PARAMETER"/>
+            <enum name="EGL_BAD_SURFACE"/>
+            <enum name="EGL_BLUE_SIZE"/>
+            <enum name="EGL_BUFFER_SIZE"/>
+            <enum name="EGL_CONFIG_CAVEAT"/>
+            <enum name="EGL_CONFIG_ID"/>
+            <enum name="EGL_CORE_NATIVE_ENGINE"/>
+            <enum name="EGL_DEPTH_SIZE"/>
+            <enum name="EGL_DONT_CARE"/>
+            <enum name="EGL_DRAW"/>
+            <enum name="EGL_EXTENSIONS"/>
+            <enum name="EGL_FALSE"/>
+            <enum name="EGL_GREEN_SIZE"/>
+            <enum name="EGL_HEIGHT"/>
+            <enum name="EGL_LARGEST_PBUFFER"/>
+            <enum name="EGL_LEVEL"/>
+            <enum name="EGL_MAX_PBUFFER_HEIGHT"/>
+            <enum name="EGL_MAX_PBUFFER_PIXELS"/>
+            <enum name="EGL_MAX_PBUFFER_WIDTH"/>
+            <enum name="EGL_NATIVE_RENDERABLE"/>
+            <enum name="EGL_NATIVE_VISUAL_ID"/>
+            <enum name="EGL_NATIVE_VISUAL_TYPE"/>
+            <enum name="EGL_NONE"/>
+            <enum name="EGL_NON_CONFORMANT_CONFIG"/>
+            <enum name="EGL_NOT_INITIALIZED"/>
+            <enum name="EGL_NO_CONTEXT"/>
+            <enum name="EGL_NO_DISPLAY"/>
+            <enum name="EGL_NO_SURFACE"/>
+            <enum name="EGL_PBUFFER_BIT"/>
+            <enum name="EGL_PIXMAP_BIT"/>
+            <enum name="EGL_READ"/>
+            <enum name="EGL_RED_SIZE"/>
+            <enum name="EGL_SAMPLES"/>
+            <enum name="EGL_SAMPLE_BUFFERS"/>
+            <enum name="EGL_SLOW_CONFIG"/>
+            <enum name="EGL_STENCIL_SIZE"/>
+            <enum name="EGL_SUCCESS"/>
+            <enum name="EGL_SURFACE_TYPE"/>
+            <enum name="EGL_TRANSPARENT_BLUE_VALUE"/>
+            <enum name="EGL_TRANSPARENT_GREEN_VALUE"/>
+            <enum name="EGL_TRANSPARENT_RED_VALUE"/>
+            <enum name="EGL_TRANSPARENT_RGB"/>
+            <enum name="EGL_TRANSPARENT_TYPE"/>
+            <enum name="EGL_TRUE"/>
+            <enum name="EGL_VENDOR"/>
+            <enum name="EGL_VERSION"/>
+            <enum name="EGL_WIDTH"/>
+            <enum name="EGL_WINDOW_BIT"/>
+            <command name="eglChooseConfig"/>
+            <command name="eglCopyBuffers"/>
+            <command name="eglCreateContext"/>
+            <command name="eglCreatePbufferSurface"/>
+            <command name="eglCreatePixmapSurface"/>
+            <command name="eglCreateWindowSurface"/>
+            <command name="eglDestroyContext"/>
+            <command name="eglDestroySurface"/>
+            <command name="eglGetConfigAttrib"/>
+            <command name="eglGetConfigs"/>
+            <command name="eglGetCurrentDisplay"/>
+            <command name="eglGetCurrentSurface"/>
+            <command name="eglGetDisplay"/>
+            <command name="eglGetError"/>
+            <command name="eglGetProcAddress"/>
+            <command name="eglInitialize"/>
+            <command name="eglMakeCurrent"/>
+            <command name="eglQueryContext"/>
+            <command name="eglQueryString"/>
+            <command name="eglQuerySurface"/>
+            <command name="eglSwapBuffers"/>
+            <command name="eglTerminate"/>
+            <command name="eglWaitGL"/>
+            <command name="eglWaitNative"/>
+        </require>
+    </feature>
+    <feature api="egl" name="EGL_VERSION_1_1" number="1.1">
+        <require>
+            <enum name="EGL_BACK_BUFFER"/>
+            <enum name="EGL_BIND_TO_TEXTURE_RGB"/>
+            <enum name="EGL_BIND_TO_TEXTURE_RGBA"/>
+            <enum name="EGL_CONTEXT_LOST"/>
+            <enum name="EGL_MIN_SWAP_INTERVAL"/>
+            <enum name="EGL_MAX_SWAP_INTERVAL"/>
+            <enum name="EGL_MIPMAP_TEXTURE"/>
+            <enum name="EGL_MIPMAP_LEVEL"/>
+            <enum name="EGL_NO_TEXTURE"/>
+            <enum name="EGL_TEXTURE_2D"/>
+            <enum name="EGL_TEXTURE_FORMAT"/>
+            <enum name="EGL_TEXTURE_RGB"/>
+            <enum name="EGL_TEXTURE_RGBA"/>
+            <enum name="EGL_TEXTURE_TARGET"/>
+            <command name="eglBindTexImage"/>
+            <command name="eglReleaseTexImage"/>
+            <command name="eglSurfaceAttrib"/>
+            <command name="eglSwapInterval"/>
+        </require>
+    </feature>
+    <feature api="egl" name="EGL_VERSION_1_2" number="1.2">
+        <require>
+            <enum name="EGL_ALPHA_FORMAT"/>
+            <enum name="EGL_ALPHA_FORMAT_NONPRE"/>
+            <enum name="EGL_ALPHA_FORMAT_PRE"/>
+            <enum name="EGL_ALPHA_MASK_SIZE"/>
+            <enum name="EGL_BUFFER_PRESERVED"/>
+            <enum name="EGL_BUFFER_DESTROYED"/>
+            <enum name="EGL_CLIENT_APIS"/>
+            <enum name="EGL_COLORSPACE"/>
+            <enum name="EGL_COLORSPACE_sRGB"/>
+            <enum name="EGL_COLORSPACE_LINEAR"/>
+            <enum name="EGL_COLOR_BUFFER_TYPE"/>
+            <enum name="EGL_CONTEXT_CLIENT_TYPE"/>
+            <enum name="EGL_DISPLAY_SCALING"/>
+            <enum name="EGL_HORIZONTAL_RESOLUTION"/>
+            <enum name="EGL_LUMINANCE_BUFFER"/>
+            <enum name="EGL_LUMINANCE_SIZE"/>
+            <enum name="EGL_OPENGL_ES_BIT"/>
+            <enum name="EGL_OPENVG_BIT"/>
+            <enum name="EGL_OPENGL_ES_API"/>
+            <enum name="EGL_OPENVG_API"/>
+            <enum name="EGL_OPENVG_IMAGE"/>
+            <enum name="EGL_PIXEL_ASPECT_RATIO"/>
+            <enum name="EGL_RENDERABLE_TYPE"/>
+            <enum name="EGL_RENDER_BUFFER"/>
+            <enum name="EGL_RGB_BUFFER"/>
+            <enum name="EGL_SINGLE_BUFFER"/>
+            <enum name="EGL_SWAP_BEHAVIOR"/>
+            <enum name="EGL_UNKNOWN"/>
+            <enum name="EGL_VERTICAL_RESOLUTION"/>
+            <command name="eglBindAPI"/>
+            <command name="eglQueryAPI"/>
+            <command name="eglCreatePbufferFromClientBuffer"/>
+            <command name="eglReleaseThread"/>
+            <command name="eglWaitClient"/>
+        </require>
+    </feature>
+    <feature api="egl" name="EGL_VERSION_1_3" number="1.3">
+        <require>
+            <enum name="EGL_CONFORMANT"/>
+            <enum name="EGL_CONTEXT_CLIENT_VERSION"/>
+            <enum name="EGL_MATCH_NATIVE_PIXMAP"/>
+            <enum name="EGL_OPENGL_ES2_BIT"/>
+            <enum name="EGL_VG_ALPHA_FORMAT"/>
+            <enum name="EGL_VG_ALPHA_FORMAT_NONPRE"/>
+            <enum name="EGL_VG_ALPHA_FORMAT_PRE"/>
+            <enum name="EGL_VG_ALPHA_FORMAT_PRE_BIT"/>
+            <enum name="EGL_VG_COLORSPACE"/>
+            <enum name="EGL_VG_COLORSPACE_sRGB"/>
+            <enum name="EGL_VG_COLORSPACE_LINEAR"/>
+            <enum name="EGL_VG_COLORSPACE_LINEAR_BIT"/>
+        </require>
+    </feature>
+    <feature api="egl" name="EGL_VERSION_1_4" number="1.4">
+        <require>
+            <enum name="EGL_DEFAULT_DISPLAY"/>
+            <enum name="EGL_MULTISAMPLE_RESOLVE_BOX_BIT"/>
+            <enum name="EGL_MULTISAMPLE_RESOLVE"/>
+            <enum name="EGL_MULTISAMPLE_RESOLVE_DEFAULT"/>
+            <enum name="EGL_MULTISAMPLE_RESOLVE_BOX"/>
+            <enum name="EGL_OPENGL_API"/>
+            <enum name="EGL_OPENGL_BIT"/>
+            <enum name="EGL_SWAP_BEHAVIOR_PRESERVED_BIT"/>
+            <command name="eglGetCurrentContext"/>
+        </require>
+    </feature>
+    <feature api="egl" name="EGL_VERSION_1_5" number="1.5">
+        <require comment="EGL_KHR_create_context features">
+            <enum name="EGL_CONTEXT_MAJOR_VERSION"/>
+            <enum name="EGL_CONTEXT_MINOR_VERSION"/>
+            <enum name="EGL_CONTEXT_OPENGL_PROFILE_MASK"/>
+            <enum name="EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY"/>
+            <enum name="EGL_NO_RESET_NOTIFICATION"/>
+            <enum name="EGL_LOSE_CONTEXT_ON_RESET"/>
+            <enum name="EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT"/>
+            <enum name="EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT"/>
+            <enum name="EGL_CONTEXT_OPENGL_DEBUG"/>
+            <enum name="EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE"/>
+            <enum name="EGL_CONTEXT_OPENGL_ROBUST_ACCESS"/>
+            <enum name="EGL_OPENGL_ES3_BIT"/>
+        </require>
+        <require comment="EGL_EXT_create_context_robustness">
+            <enum name="EGL_CONTEXT_OPENGL_ROBUST_ACCESS"/>
+            <enum name="EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY"/>
+        </require>
+        <require comment="EGL_EXT_client_extensions"/>
+        <require comment="EGL_KHR_cl_event2">
+            <enum name="EGL_CL_EVENT_HANDLE"/>
+            <enum name="EGL_SYNC_CL_EVENT"/>
+            <enum name="EGL_SYNC_CL_EVENT_COMPLETE"/>
+        </require>
+        <require comment="EGL_KHR_fence_sync">
+            <enum name="EGL_SYNC_PRIOR_COMMANDS_COMPLETE"/>
+            <enum name="EGL_SYNC_TYPE"/>
+            <enum name="EGL_SYNC_STATUS"/>
+            <enum name="EGL_SYNC_CONDITION"/>
+            <enum name="EGL_SIGNALED"/>
+            <enum name="EGL_UNSIGNALED"/>
+            <enum name="EGL_SYNC_FLUSH_COMMANDS_BIT"/>
+            <enum name="EGL_FOREVER"/>
+            <enum name="EGL_TIMEOUT_EXPIRED"/>
+            <enum name="EGL_CONDITION_SATISFIED"/>
+            <enum name="EGL_NO_SYNC"/>
+            <enum name="EGL_SYNC_FENCE"/>
+            <command name="eglCreateSync"/>
+            <command name="eglDestroySync"/>
+            <command name="eglClientWaitSync"/>
+            <command name="eglGetSyncAttrib"/>
+        </require>
+        <require comment="EGL_KHR_get_all_proc_addresses"/>
+        <require comment="EGL_KHR_client_get_all_proc_addresses"/>
+        <require comment="EGL_KHR_gl_colorspace">
+            <enum name="EGL_GL_COLORSPACE"/>
+            <enum name="EGL_GL_COLORSPACE_SRGB"/>
+            <enum name="EGL_GL_COLORSPACE_LINEAR"/>
+        </require>
+        <require comment="EGL_KHR_gl_renderbuffer_image">
+            <enum name="EGL_GL_RENDERBUFFER"/>
+        </require>
+        <require comment="EGL_KHR_gl_texture_2D_image">
+            <enum name="EGL_GL_TEXTURE_2D"/>
+            <enum name="EGL_GL_TEXTURE_LEVEL"/>
+        </require>
+        <require comment="EGL_KHR_gl_texture_3D_image">
+            <enum name="EGL_GL_TEXTURE_3D"/>
+            <enum name="EGL_GL_TEXTURE_ZOFFSET"/>
+        </require>
+        <require comment="EGL_KHR_gl_texture_cubemap_image">
+            <enum name="EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X"/>
+            <enum name="EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X"/>
+            <enum name="EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y"/>
+            <enum name="EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y"/>
+            <enum name="EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z"/>
+            <enum name="EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z"/>
+        </require>
+        <require comment="EGL_EXT_platform_base">
+            <command name="eglGetPlatformDisplay"/>
+            <command name="eglCreatePlatformWindowSurface"/>
+            <command name="eglCreatePlatformPixmapSurface"/>
+        </require>
+        <require comment="EGL_KHR_surfaceless_context - just relaxes an error condition"/>
+        <require comment="EGL_KHR_wait_sync">
+            <command name="eglWaitSync"/>
+        </require>
+    </feature>
+
+    <!-- SECTION: EGL extension interface definitions -->
+    <extensions>
+        <extension name="EGL_ANDROID_blob_cache" supported="egl">
+            <require>
+                <command name="eglSetBlobCacheFuncsANDROID"/>
+            </require>
+        </extension>
+        <extension name="EGL_ANDROID_framebuffer_target" supported="egl">
+            <require>
+                <enum name="EGL_FRAMEBUFFER_TARGET_ANDROID"/>
+            </require>
+        </extension>
+        <extension name="EGL_ANDROID_image_native_buffer" supported="egl">
+            <require>
+                <enum name="EGL_NATIVE_BUFFER_ANDROID"/>
+            </require>
+        </extension>
+        <extension name="EGL_ANDROID_native_fence_sync" supported="egl">
+            <require>
+                <enum name="EGL_SYNC_NATIVE_FENCE_ANDROID"/>
+                <enum name="EGL_SYNC_NATIVE_FENCE_FD_ANDROID"/>
+                <enum name="EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID"/>
+                <enum name="EGL_NO_NATIVE_FENCE_FD_ANDROID"/>
+                <command name="eglDupNativeFenceFDANDROID"/>
+            </require>
+        </extension>
+        <extension name="EGL_ANDROID_recordable" supported="egl">
+            <require>
+                <enum name="EGL_RECORDABLE_ANDROID"/>
+            </require>
+        </extension>
+        <extension name="EGL_ANGLE_d3d_share_handle_client_buffer" supported="egl">
+            <require>
+                <enum name="EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE"/>
+            </require>
+        </extension>
+        <extension name="EGL_ANGLE_query_surface_pointer" supported="egl">
+            <require>
+                <command name="eglQuerySurfacePointerANGLE"/>
+            </require>
+        </extension>
+        <extension name="EGL_ANGLE_surface_d3d_texture_2d_share_handle" supported="egl">
+            <require>
+                <enum name="EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE"/>
+            </require>
+        </extension>
+        <extension name="EGL_ARM_pixmap_multisample_discard" supported="egl">
+            <require>
+                <enum name="EGL_DISCARD_SAMPLES_ARM"/>
+            </require>
+        </extension>
+        <extension name="EGL_EXT_buffer_age" supported="egl">
+            <require>
+                <enum name="EGL_BUFFER_AGE_EXT"/>
+            </require>
+        </extension>
+        <extension name="EGL_EXT_client_extensions" supported="egl"/>
+        <extension name="EGL_EXT_create_context_robustness" supported="egl">
+            <require>
+                <enum name="EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT"/>
+                <enum name="EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT"/>
+                <enum name="EGL_NO_RESET_NOTIFICATION_EXT"/>
+                <enum name="EGL_LOSE_CONTEXT_ON_RESET_EXT"/>
+            </require>
+        </extension>
+        <extension name="EGL_EXT_image_dma_buf_import" supported="egl">
+            <require>
+                <enum name="EGL_LINUX_DMA_BUF_EXT"/>
+                <enum name="EGL_LINUX_DRM_FOURCC_EXT"/>
+                <enum name="EGL_DMA_BUF_PLANE0_FD_EXT"/>
+                <enum name="EGL_DMA_BUF_PLANE0_OFFSET_EXT"/>
+                <enum name="EGL_DMA_BUF_PLANE0_PITCH_EXT"/>
+                <enum name="EGL_DMA_BUF_PLANE1_FD_EXT"/>
+                <enum name="EGL_DMA_BUF_PLANE1_OFFSET_EXT"/>
+                <enum name="EGL_DMA_BUF_PLANE1_PITCH_EXT"/>
+                <enum name="EGL_DMA_BUF_PLANE2_FD_EXT"/>
+                <enum name="EGL_DMA_BUF_PLANE2_OFFSET_EXT"/>
+                <enum name="EGL_DMA_BUF_PLANE2_PITCH_EXT"/>
+                <enum name="EGL_YUV_COLOR_SPACE_HINT_EXT"/>
+                <enum name="EGL_SAMPLE_RANGE_HINT_EXT"/>
+                <enum name="EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT"/>
+                <enum name="EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT"/>
+                <enum name="EGL_ITU_REC601_EXT"/>
+                <enum name="EGL_ITU_REC709_EXT"/>
+                <enum name="EGL_ITU_REC2020_EXT"/>
+                <enum name="EGL_YUV_FULL_RANGE_EXT"/>
+                <enum name="EGL_YUV_NARROW_RANGE_EXT"/>
+                <enum name="EGL_YUV_CHROMA_SITING_0_EXT"/>
+                <enum name="EGL_YUV_CHROMA_SITING_0_5_EXT"/>
+            </require>
+        </extension>
+        <extension name="EGL_EXT_multiview_window" supported="egl">
+            <require>
+                <enum name="EGL_MULTIVIEW_VIEW_COUNT_EXT"/>
+            </require>
+        </extension>
+        <extension name="EGL_EXT_platform_base" supported="egl">
+            <require>
+                <command name="eglGetPlatformDisplayEXT"/>
+                <command name="eglCreatePlatformWindowSurfaceEXT"/>
+                <command name="eglCreatePlatformPixmapSurfaceEXT"/>
+            </require>
+        </extension>
+        <extension name="EGL_EXT_platform_wayland" supported="egl">
+            <require>
+                <enum name="EGL_PLATFORM_WAYLAND_EXT"/>
+            </require>
+        </extension>
+        <extension name="EGL_EXT_platform_x11" supported="egl">
+            <require>
+                <enum name="EGL_PLATFORM_X11_EXT"/>
+                <enum name="EGL_PLATFORM_X11_SCREEN_EXT"/>
+            </require>
+        </extension>
+        <extension name="EGL_EXT_protected_surface" supported="egl">
+            <require>
+                <enum name="EGL_PROTECTED_CONTENT_EXT"/>
+            </require>
+        </extension>
+        <extension name="EGL_EXT_swap_buffers_with_damage" supported="egl">
+            <require>
+                <command name="eglSwapBuffersWithDamageEXT"/>
+            </require>
+        </extension>
+        <extension name="EGL_HI_clientpixmap" supported="egl">
+            <require>
+                <enum name="EGL_CLIENT_PIXMAP_POINTER_HI"/>
+                <command name="eglCreatePixmapSurfaceHI"/>
+            </require>
+        </extension>
+        <extension name="EGL_HI_colorformats" supported="egl">
+            <require>
+                <enum name="EGL_COLOR_FORMAT_HI"/>
+                <enum name="EGL_COLOR_RGB_HI"/>
+                <enum name="EGL_COLOR_RGBA_HI"/>
+                <enum name="EGL_COLOR_ARGB_HI"/>
+            </require>
+        </extension>
+        <extension name="EGL_IMG_context_priority" supported="egl">
+            <require>
+                <enum name="EGL_CONTEXT_PRIORITY_LEVEL_IMG"/>
+                <enum name="EGL_CONTEXT_PRIORITY_HIGH_IMG"/>
+                <enum name="EGL_CONTEXT_PRIORITY_MEDIUM_IMG"/>
+                <enum name="EGL_CONTEXT_PRIORITY_LOW_IMG"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_cl_event" supported="egl">
+            <require>
+                <enum name="EGL_CL_EVENT_HANDLE_KHR"/>
+                <enum name="EGL_SYNC_CL_EVENT_KHR"/>
+                <enum name="EGL_SYNC_CL_EVENT_COMPLETE_KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_cl_event2" supported="egl">
+            <require>
+                <enum name="EGL_CL_EVENT_HANDLE_KHR"/>
+                <enum name="EGL_SYNC_CL_EVENT_KHR"/>
+                <enum name="EGL_SYNC_CL_EVENT_COMPLETE_KHR"/>
+                <command name="eglCreateSync64KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_config_attribs" supported="egl">
+            <require>
+                <enum name="EGL_CONFORMANT_KHR"/>
+                <enum name="EGL_VG_COLORSPACE_LINEAR_BIT_KHR"/>
+                <enum name="EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_client_get_all_proc_addresses" supported="egl" comment="Alias of EGL_KHR_get_all_proc_addresses"/>
+        <extension name="EGL_KHR_create_context" supported="egl">
+            <require>
+                <enum name="EGL_CONTEXT_MAJOR_VERSION_KHR"/>
+                <enum name="EGL_CONTEXT_MINOR_VERSION_KHR"/>
+                <enum name="EGL_CONTEXT_FLAGS_KHR"/>
+                <enum name="EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR"/>
+                <enum name="EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR"/>
+                <enum name="EGL_NO_RESET_NOTIFICATION_KHR"/>
+                <enum name="EGL_LOSE_CONTEXT_ON_RESET_KHR"/>
+                <enum name="EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR"/>
+                <enum name="EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR"/>
+                <enum name="EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR"/>
+                <enum name="EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR"/>
+                <enum name="EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR"/>
+                <enum name="EGL_OPENGL_ES3_BIT"/>
+                <enum name="EGL_OPENGL_ES3_BIT_KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_fence_sync" protect="KHRONOS_SUPPORT_INT64" supported="egl">
+            <require>
+                <!-- @ Most interfaces defined by EGL_KHR_reusable sync -->
+                <enum name="EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR"/>
+                <enum name="EGL_SYNC_CONDITION_KHR"/>
+                <enum name="EGL_SYNC_FENCE_KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_get_all_proc_addresses" supported="egl"/>
+        <extension name="EGL_KHR_gl_colorspace" supported="egl">
+            <require>
+                <enum name="EGL_GL_COLORSPACE_KHR"/>
+                <enum name="EGL_GL_COLORSPACE_SRGB_KHR"/>
+                <enum name="EGL_GL_COLORSPACE_LINEAR_KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_gl_renderbuffer_image" supported="egl">
+            <require>
+                <enum name="EGL_GL_RENDERBUFFER_KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_gl_texture_2D_image" supported="egl">
+            <require>
+                <enum name="EGL_GL_TEXTURE_2D_KHR"/>
+                <enum name="EGL_GL_TEXTURE_LEVEL_KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_gl_texture_3D_image" supported="egl">
+            <require>
+                <enum name="EGL_GL_TEXTURE_3D_KHR"/>
+                <enum name="EGL_GL_TEXTURE_ZOFFSET_KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_gl_texture_cubemap_image" supported="egl">
+            <require>
+                <enum name="EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR"/>
+                <enum name="EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR"/>
+                <enum name="EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR"/>
+                <enum name="EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR"/>
+                <enum name="EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR"/>
+                <enum name="EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_image" supported="egl">
+            <require>
+                <enum name="EGL_NATIVE_PIXMAP_KHR"/>
+                <enum name="EGL_NO_IMAGE_KHR"/>
+                <command name="eglCreateImageKHR"/>
+                <command name="eglDestroyImageKHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_image_base" supported="egl">
+            <require>
+                <enum name="EGL_IMAGE_PRESERVED_KHR"/>
+                <enum name="EGL_NO_IMAGE_KHR"/>
+                <command name="eglCreateImageKHR"/>
+                <command name="eglDestroyImageKHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_image_pixmap" supported="egl">
+            <require>
+                <enum name="EGL_NATIVE_PIXMAP_KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_lock_surface" supported="egl">
+            <require>
+                <enum name="EGL_READ_SURFACE_BIT_KHR"/>
+                <enum name="EGL_WRITE_SURFACE_BIT_KHR"/>
+                <enum name="EGL_LOCK_SURFACE_BIT_KHR"/>
+                <enum name="EGL_OPTIMAL_FORMAT_BIT_KHR"/>
+                <enum name="EGL_MATCH_FORMAT_KHR"/>
+                <enum name="EGL_FORMAT_RGB_565_EXACT_KHR"/>
+                <enum name="EGL_FORMAT_RGB_565_KHR"/>
+                <enum name="EGL_FORMAT_RGBA_8888_EXACT_KHR"/>
+                <enum name="EGL_FORMAT_RGBA_8888_KHR"/>
+                <enum name="EGL_MAP_PRESERVE_PIXELS_KHR"/>
+                <enum name="EGL_LOCK_USAGE_HINT_KHR"/>
+                <enum name="EGL_BITMAP_POINTER_KHR"/>
+                <enum name="EGL_BITMAP_PITCH_KHR"/>
+                <enum name="EGL_BITMAP_ORIGIN_KHR"/>
+                <enum name="EGL_BITMAP_PIXEL_RED_OFFSET_KHR"/>
+                <enum name="EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR"/>
+                <enum name="EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR"/>
+                <enum name="EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR"/>
+                <enum name="EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR"/>
+                <enum name="EGL_LOWER_LEFT_KHR"/>
+                <enum name="EGL_UPPER_LEFT_KHR"/>
+                <command name="eglLockSurfaceKHR"/>
+                <command name="eglUnlockSurfaceKHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_lock_surface2" supported="egl">
+            <require>
+                <enum name="EGL_BITMAP_PIXEL_SIZE_KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_lock_surface3" supported="egl">
+            <require>
+                <enum name="EGL_READ_SURFACE_BIT_KHR"/>
+                <enum name="EGL_WRITE_SURFACE_BIT_KHR"/>
+                <enum name="EGL_LOCK_SURFACE_BIT_KHR"/>
+                <enum name="EGL_OPTIMAL_FORMAT_BIT_KHR"/>
+                <enum name="EGL_MATCH_FORMAT_KHR"/>
+                <enum name="EGL_FORMAT_RGB_565_EXACT_KHR"/>
+                <enum name="EGL_FORMAT_RGB_565_KHR"/>
+                <enum name="EGL_FORMAT_RGBA_8888_EXACT_KHR"/>
+                <enum name="EGL_FORMAT_RGBA_8888_KHR"/>
+                <enum name="EGL_MAP_PRESERVE_PIXELS_KHR"/>
+                <enum name="EGL_LOCK_USAGE_HINT_KHR"/>
+                <enum name="EGL_BITMAP_PITCH_KHR"/>
+                <enum name="EGL_BITMAP_ORIGIN_KHR"/>
+                <enum name="EGL_BITMAP_PIXEL_RED_OFFSET_KHR"/>
+                <enum name="EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR"/>
+                <enum name="EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR"/>
+                <enum name="EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR"/>
+                <enum name="EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR"/>
+                <enum name="EGL_BITMAP_PIXEL_SIZE_KHR"/>
+                <enum name="EGL_BITMAP_POINTER_KHR"/>
+                <enum name="EGL_LOWER_LEFT_KHR"/>
+                <enum name="EGL_UPPER_LEFT_KHR"/>
+                <command name="eglLockSurfaceKHR"/>
+                <command name="eglUnlockSurfaceKHR"/>
+                <command name="eglQuerySurface64KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_platform_android" supported="egl">
+            <require>
+                <enum name="EGL_PLATFORM_ANDROID_KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_platform_gbm" supported="egl">
+            <require>
+                <enum name="EGL_PLATFORM_GBM_KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_platform_wayland" supported="egl">
+            <require>
+                <enum name="EGL_PLATFORM_WAYLAND_KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_platform_x11" supported="egl">
+            <require>
+                <enum name="EGL_PLATFORM_X11_KHR"/>
+                <enum name="EGL_PLATFORM_X11_SCREEN_KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_reusable_sync" protect="KHRONOS_SUPPORT_INT64" supported="egl">
+            <require>
+                <enum name="EGL_SYNC_STATUS_KHR"/>
+                <enum name="EGL_SIGNALED_KHR"/>
+                <enum name="EGL_UNSIGNALED_KHR"/>
+                <enum name="EGL_TIMEOUT_EXPIRED_KHR"/>
+                <enum name="EGL_CONDITION_SATISFIED_KHR"/>
+                <enum name="EGL_SYNC_TYPE_KHR"/>
+                <enum name="EGL_SYNC_REUSABLE_KHR"/>
+                <enum name="EGL_SYNC_FLUSH_COMMANDS_BIT_KHR"/>
+                <enum name="EGL_FOREVER_KHR"/>
+                <enum name="EGL_NO_SYNC_KHR"/>
+                <command name="eglCreateSyncKHR"/>
+                <command name="eglDestroySyncKHR"/>
+                <command name="eglClientWaitSyncKHR"/>
+                <command name="eglSignalSyncKHR"/>
+                <command name="eglGetSyncAttribKHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_stream" protect="KHRONOS_SUPPORT_INT64" supported="egl">
+            <require>
+                <enum name="EGL_NO_STREAM_KHR"/>
+                <enum name="EGL_CONSUMER_LATENCY_USEC_KHR"/>
+                <enum name="EGL_PRODUCER_FRAME_KHR"/>
+                <enum name="EGL_CONSUMER_FRAME_KHR"/>
+                <enum name="EGL_STREAM_STATE_KHR"/>
+                <enum name="EGL_STREAM_STATE_CREATED_KHR"/>
+                <enum name="EGL_STREAM_STATE_CONNECTING_KHR"/>
+                <enum name="EGL_STREAM_STATE_EMPTY_KHR"/>
+                <enum name="EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR"/>
+                <enum name="EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR"/>
+                <enum name="EGL_STREAM_STATE_DISCONNECTED_KHR"/>
+                <enum name="EGL_BAD_STREAM_KHR"/>
+                <enum name="EGL_BAD_STATE_KHR"/>
+                <command name="eglCreateStreamKHR"/>
+                <command name="eglDestroyStreamKHR"/>
+                <command name="eglStreamAttribKHR"/>
+                <command name="eglQueryStreamKHR"/>
+                <command name="eglQueryStreamu64KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_stream_consumer_gltexture" protect="EGL_KHR_stream" supported="egl">
+            <require>
+                <enum name="EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR"/>
+                <command name="eglStreamConsumerGLTextureExternalKHR"/>
+                <command name="eglStreamConsumerAcquireKHR"/>
+                <command name="eglStreamConsumerReleaseKHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_stream_cross_process_fd" protect="EGL_KHR_stream" supported="egl">
+            <require>
+                <enum name="EGL_NO_FILE_DESCRIPTOR_KHR"/>
+                <command name="eglGetStreamFileDescriptorKHR"/>
+                <command name="eglCreateStreamFromFileDescriptorKHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_stream_fifo" protect="EGL_KHR_stream" supported="egl">
+            <require>
+                <enum name="EGL_STREAM_FIFO_LENGTH_KHR"/>
+                <enum name="EGL_STREAM_TIME_NOW_KHR"/>
+                <enum name="EGL_STREAM_TIME_CONSUMER_KHR"/>
+                <enum name="EGL_STREAM_TIME_PRODUCER_KHR"/>
+                <command name="eglQueryStreamTimeKHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_stream_producer_aldatalocator" protect="EGL_KHR_stream" supported="egl"/>
+        <extension name="EGL_KHR_stream_producer_eglsurface" protect="EGL_KHR_stream" supported="egl">
+            <require>
+                <enum name="EGL_STREAM_BIT_KHR"/>
+                <command name="eglCreateStreamProducerSurfaceKHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_surfaceless_context" supported="egl" comment="Just relaxes an error condition"/>
+        <extension name="EGL_KHR_vg_parent_image" supported="egl">
+            <require>
+                <enum name="EGL_VG_PARENT_IMAGE_KHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_KHR_wait_sync" supported="egl">
+            <require>
+                <command name="eglWaitSyncKHR"/>
+            </require>
+        </extension>
+        <extension name="EGL_MESA_drm_image" supported="egl">
+            <require>
+                <enum name="EGL_DRM_BUFFER_FORMAT_MESA"/>
+                <enum name="EGL_DRM_BUFFER_USE_MESA"/>
+                <enum name="EGL_DRM_BUFFER_FORMAT_ARGB32_MESA"/>
+                <enum name="EGL_DRM_BUFFER_MESA"/>
+                <enum name="EGL_DRM_BUFFER_STRIDE_MESA"/>
+                <enum name="EGL_DRM_BUFFER_USE_SCANOUT_MESA"/>
+                <enum name="EGL_DRM_BUFFER_USE_SHARE_MESA"/>
+                <command name="eglCreateDRMImageMESA"/>
+                <command name="eglExportDRMImageMESA"/>
+            </require>
+        </extension>
+        <extension name="EGL_MESA_platform_gbm" supported="egl">
+            <require>
+                <enum name="EGL_PLATFORM_GBM_MESA"/>
+            </require>
+        </extension>
+        <extension name="EGL_NOK_swap_region" supported="egl">
+            <require>
+                <command name="eglSwapBuffersRegionNOK"/>
+            </require>
+        </extension>
+        <extension name="EGL_NOK_swap_region2" supported="egl">
+            <require>
+                <command name="eglSwapBuffersRegion2NOK"/>
+            </require>
+        </extension>
+        <extension name="EGL_NOK_texture_from_pixmap" supported="egl">
+            <require>
+                <enum name="EGL_Y_INVERTED_NOK"/>
+            </require>
+        </extension>
+        <extension name="EGL_NV_3dvision_surface" supported="egl">
+            <require>
+                <enum name="EGL_AUTO_STEREO_NV"/>
+            </require>
+        </extension>
+        <extension name="EGL_NV_coverage_sample" supported="egl">
+            <require>
+                <enum name="EGL_COVERAGE_BUFFERS_NV"/>
+                <enum name="EGL_COVERAGE_SAMPLES_NV"/>
+            </require>
+        </extension>
+        <extension name="EGL_NV_coverage_sample_resolve" supported="egl">
+            <require>
+                <enum name="EGL_COVERAGE_SAMPLE_RESOLVE_NV"/>
+                <enum name="EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV"/>
+                <enum name="EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV"/>
+            </require>
+        </extension>
+        <extension name="EGL_NV_depth_nonlinear" supported="egl">
+            <require>
+                <enum name="EGL_DEPTH_ENCODING_NV"/>
+                <enum name="EGL_DEPTH_ENCODING_NONE_NV"/>
+                <enum name="EGL_DEPTH_ENCODING_NONLINEAR_NV"/>
+            </require>
+        </extension>
+        <extension name="EGL_NV_native_query" supported="egl">
+            <require>
+                <command name="eglQueryNativeDisplayNV"/>
+                <command name="eglQueryNativeWindowNV"/>
+                <command name="eglQueryNativePixmapNV"/>
+            </require>
+        </extension>
+        <extension name="EGL_NV_post_convert_rounding" supported="egl">
+            <require>
+            </require>
+        </extension>
+        <extension name="EGL_NV_post_sub_buffer" supported="egl">
+            <require>
+                <enum name="EGL_POST_SUB_BUFFER_SUPPORTED_NV"/>
+                <command name="eglPostSubBufferNV"/>
+            </require>
+        </extension>
+        <extension name="EGL_NV_stream_sync" supported="egl">
+            <require>
+                <enum name="EGL_SYNC_TYPE_KHR"/>
+                <enum name="EGL_SYNC_NEW_FRAME_NV"/>
+                <command name="eglCreateStreamSyncNV"/>
+            </require>
+        </extension>
+        <extension name="EGL_NV_sync" protect="KHRONOS_SUPPORT_INT64" supported="egl">
+            <require>
+                <enum name="EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV"/>
+                <enum name="EGL_SYNC_STATUS_NV"/>
+                <enum name="EGL_SIGNALED_NV"/>
+                <enum name="EGL_UNSIGNALED_NV"/>
+                <enum name="EGL_SYNC_FLUSH_COMMANDS_BIT_NV"/>
+                <enum name="EGL_FOREVER_NV"/>
+                <enum name="EGL_ALREADY_SIGNALED_NV"/>
+                <enum name="EGL_TIMEOUT_EXPIRED_NV"/>
+                <enum name="EGL_CONDITION_SATISFIED_NV"/>
+                <enum name="EGL_SYNC_TYPE_NV"/>
+                <enum name="EGL_SYNC_CONDITION_NV"/>
+                <enum name="EGL_SYNC_FENCE_NV"/>
+                <enum name="EGL_NO_SYNC_NV"/>
+                <command name="eglCreateFenceSyncNV"/>
+                <command name="eglDestroySyncNV"/>
+                <command name="eglFenceNV"/>
+                <command name="eglClientWaitSyncNV"/>
+                <command name="eglSignalSyncNV"/>
+                <command name="eglGetSyncAttribNV"/>
+            </require>
+        </extension>
+        <extension name="EGL_NV_system_time" protect="KHRONOS_SUPPORT_INT64" supported="egl">
+            <require>
+                <command name="eglGetSystemTimeFrequencyNV"/>
+                <command name="eglGetSystemTimeNV"/>
+            </require>
+        </extension>
+    </extensions>
+</registry>
diff --git a/opengl/tools/glgen2/registry/genheaders.py b/opengl/tools/glgen2/registry/genheaders.py
new file mode 100755
index 0000000..78a4a43
--- /dev/null
+++ b/opengl/tools/glgen2/registry/genheaders.py
@@ -0,0 +1,578 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2013-2014 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.
+
+import sys, time, pdb, string, cProfile
+from reg import *
+
+# debug - start header generation in debugger
+# dump - dump registry after loading
+# profile - enable Python profiling
+# protect - whether to use #ifndef protections
+# registry <filename> - use specified XML registry instead of gl.xml
+# target - string name of target header, or all targets if None
+# timeit - time length of registry loading & header generation
+# validate - validate return & parameter group tags against <group>
+debug   = False
+dump    = False
+profile = False
+protect = True
+target  = None
+timeit  = False
+validate= False
+# Default input / log files
+errFilename = None
+diagFilename = 'diag.txt'
+regFilename = 'gl.xml'
+
+if __name__ == '__main__':
+    i = 1
+    while (i < len(sys.argv)):
+        arg = sys.argv[i]
+        i = i + 1
+        if (arg == '-debug'):
+            write('Enabling debug (-debug)', file=sys.stderr)
+            debug = True
+        elif (arg == '-dump'):
+            write('Enabling dump (-dump)', file=sys.stderr)
+            dump = True
+        elif (arg == '-noprotect'):
+            write('Disabling inclusion protection in output headers', file=sys.stderr)
+            protect = False
+        elif (arg == '-profile'):
+            write('Enabling profiling (-profile)', file=sys.stderr)
+            profile = True
+        elif (arg == '-registry'):
+            regFilename = sys.argv[i]
+            i = i+1
+            write('Using registry ', regFilename, file=sys.stderr)
+        elif (arg == '-time'):
+            write('Enabling timing (-time)', file=sys.stderr)
+            timeit = True
+        elif (arg == '-validate'):
+            write('Enabling group validation (-validate)', file=sys.stderr)
+            validate = True
+        elif (arg[0:1] == '-'):
+            write('Unrecognized argument:', arg, file=sys.stderr)
+            exit(1)
+        else:
+            target = arg
+            write('Using target', target, file=sys.stderr)
+
+# Simple timer functions
+startTime = None
+def startTimer():
+    global startTime
+    startTime = time.clock()
+def endTimer(msg):
+    global startTime
+    endTime = time.clock()
+    if (timeit):
+        write(msg, endTime - startTime)
+        startTime = None
+
+# Load & parse registry
+reg = Registry()
+
+startTimer()
+tree = etree.parse(regFilename)
+endTimer('Time to make ElementTree =')
+
+startTimer()
+reg.loadElementTree(tree)
+endTimer('Time to parse ElementTree =')
+
+if (validate):
+    reg.validateGroups()
+
+if (dump):
+    write('***************************************')
+    write('Performing Registry dump to regdump.txt')
+    write('***************************************')
+    reg.dumpReg(filehandle = open('regdump.txt','w'))
+
+# Turn a list of strings into a regexp string matching exactly those strings
+def makeREstring(list):
+    return '^(' + '|'.join(list) + ')$'
+
+# These are "mandatory" OpenGL ES 1 extensions, to
+# be included in the core GLES/gl.h header.
+es1CoreList = [
+    'GL_OES_read_format',
+    'GL_OES_compressed_paletted_texture',
+    'GL_OES_point_size_array',
+    'GL_OES_point_sprite'
+]
+
+# Descriptive names for various regexp patterns used to select
+# versions and extensions
+
+allVersions     = allExtensions = '.*'
+noVersions      = noExtensions = None
+gl12andLaterPat = '1\.[2-9]|[234]\.[0-9]'
+gles2onlyPat    = '2\.[0-9]'
+gles2and30Pat   = '2\.[0-9]|3.0'
+gles2and30and31Pat    = '2.[0-9]|3.[01]'
+es1CorePat      = makeREstring(es1CoreList)
+# Extensions in old glcorearb.h but not yet tagged accordingly in gl.xml
+glCoreARBPat    = None
+glx13andLaterPat = '1\.[3-9]'
+
+# Copyright text prefixing all headers (list of strings).
+prefixStrings = [
+    '/*',
+    '** Copyright (c) 2013-2014 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.',
+    '*/',
+    '/*',
+    '** This header is generated from the Khronos OpenGL / OpenGL ES XML',
+    '** API Registry. The current version of the Registry, generator scripts',
+    '** used to make the header, and the header can be found at',
+    '**   http://www.opengl.org/registry/',
+    '**',
+    '** Khronos $' + 'Revision$ on $' + 'Date$',
+    '*/',
+    ''
+]
+
+# glext.h / glcorearb.h define calling conventions inline (no GL *platform.h)
+glExtPlatformStrings = [
+    '#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)',
+    '#ifndef WIN32_LEAN_AND_MEAN',
+    '#define WIN32_LEAN_AND_MEAN 1',
+    '#endif',
+    '#include <windows.h>',
+    '#endif',
+    '',
+    '#ifndef APIENTRY',
+    '#define APIENTRY',
+    '#endif',
+    '#ifndef APIENTRYP',
+    '#define APIENTRYP APIENTRY *',
+    '#endif',
+    '#ifndef GLAPI',
+    '#define GLAPI extern',
+    '#endif',
+    ''
+]
+
+glCorearbPlatformStrings = glExtPlatformStrings + [
+    '/* glcorearb.h is for use with OpenGL core profile implementations.',
+    '** It should should be placed in the same directory as gl.h and',
+    '** included as <GL/glcorearb.h>.',
+    '**',
+    '** glcorearb.h includes only APIs in the latest OpenGL core profile',
+    '** implementation together with APIs in newer ARB extensions which ',
+    '** can be supported by the core profile. It does not, and never will',
+    '** include functionality removed from the core profile, such as',
+    '** fixed-function vertex and fragment processing.',
+    '**',
+    '** Do not #include both <GL/glcorearb.h> and either of <GL/gl.h> or',
+    '** <GL/glext.h> in the same source file.',
+    '*/',
+    ''
+]
+
+# wglext.h needs Windows include
+wglPlatformStrings = [
+    '#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)',
+    '#define WIN32_LEAN_AND_MEAN 1',
+    '#include <windows.h>',
+    '#endif',
+    '',
+]
+
+# GLES 1/2/3 core .h have separate *platform.h files to define calling conventions
+gles1PlatformStrings = [ '#include <GLES/glplatform.h>', '' ]
+gles2PlatformStrings = [ '#include <GLES2/gl2platform.h>', '' ]
+gles3PlatformStrings = [ '#include <GLES3/gl3platform.h>', '' ]
+eglPlatformStrings   = [ '#include <EGL/eglplatform.h>', '' ]
+
+# GLES 1/2 extension .h have small addition to calling convention headers
+gles1ExtPlatformStrings = gles2ExtPlatformStrings = [
+    '#ifndef GL_APIENTRYP',
+    '#define GL_APIENTRYP GL_APIENTRY*',
+    '#endif',
+    ''
+]
+
+# Insert generation date in a comment for headers not having *GLEXT_VERSION macros
+genDateCommentString = [
+    format("/* Generated on date %s */" % time.strftime("%Y%m%d")),
+    ''
+]
+
+# GL_GLEXT_VERSION is defined only in glext.h
+glextVersionStrings = [
+    format("#define GL_GLEXT_VERSION %s" % time.strftime("%Y%m%d")),
+    ''
+]
+# WGL_WGLEXT_VERSION is defined only in wglext.h
+wglextVersionStrings = [
+    format("#define WGL_WGLEXT_VERSION %s" % time.strftime("%Y%m%d")),
+    ''
+]
+# GLX_GLXEXT_VERSION is defined only in glxext.h
+glxextVersionStrings = [
+    format("#define GLX_GLXEXT_VERSION %s" % time.strftime("%Y%m%d")),
+    ''
+]
+# EGL_EGLEXT_VERSION is defined only in eglext.h
+eglextVersionStrings = [
+    format("#define EGL_EGLEXT_VERSION %s" % time.strftime("%Y%m%d")),
+    ''
+]
+
+# Defaults for generating re-inclusion protection wrappers (or not)
+protectFile = protect
+protectFeature = protect
+protectProto = protect
+
+buildList = [
+    # GL API 1.2+ + extensions - GL/glext.h
+    CGeneratorOptions(
+        filename          = 'GL/glext.h',
+        apiname           = 'gl',
+        profile           = 'compatibility',
+        versions          = allVersions,
+        emitversions      = gl12andLaterPat,
+        defaultExtensions = 'gl',                   # Default extensions for GL
+        addExtensions     = None,
+        removeExtensions  = None,
+        prefixText        = prefixStrings + glExtPlatformStrings + glextVersionStrings,
+        genFuncPointers   = True,
+        protectFile       = protectFile,
+        protectFeature    = protectFeature,
+        protectProto      = protectProto,
+        protectProtoStr   = 'GL_GLEXT_PROTOTYPES',
+        apicall           = 'GLAPI ',
+        apientry          = 'APIENTRY ',
+        apientryp         = 'APIENTRYP '),
+    # GL core profile + extensions - GL/glcorearb.h
+    CGeneratorOptions(
+        filename          = 'GL/glcorearb.h',
+        apiname           = 'gl',
+        profile           = 'core',
+        versions          = allVersions,
+        emitversions      = allVersions,
+        defaultExtensions = 'glcore',               # Default extensions for GL core profile (only)
+        addExtensions     = glCoreARBPat,
+        removeExtensions  = None,
+        prefixText        = prefixStrings + glCorearbPlatformStrings,
+        genFuncPointers   = True,
+        protectFile       = protectFile,
+        protectFeature    = protectFeature,
+        protectProto      = protectProto,
+        protectProtoStr   = 'GL_GLEXT_PROTOTYPES',
+        apicall           = 'GLAPI ',
+        apientry          = 'APIENTRY ',
+        apientryp         = 'APIENTRYP '),
+    # GLES 1.x API + mandatory extensions - GLES/gl.h (no function pointers)
+    CGeneratorOptions(
+        filename          = 'GLES/gl.h',
+        apiname           = 'gles1',
+        profile           = 'common',
+        versions          = allVersions,
+        emitversions      = allVersions,
+        defaultExtensions = None,                   # No default extensions
+        addExtensions     = es1CorePat,             # Add mandatory ES1 extensions in GLES1/gl.h
+        removeExtensions  = None,
+        prefixText        = prefixStrings + gles1PlatformStrings + genDateCommentString,
+        genFuncPointers   = False,
+        protectFile       = protectFile,
+        protectFeature    = protectFeature,
+        protectProto      = False,                  # Core ES API functions are in the static link libraries
+        protectProtoStr   = 'GL_GLEXT_PROTOTYPES',
+        apicall           = 'GL_API ',
+        apientry          = 'GL_APIENTRY ',
+        apientryp         = 'GL_APIENTRYP '),
+    # GLES 1.x extensions - GLES/glext.h
+    CGeneratorOptions(
+        filename          = 'GLES/glext.h',
+        apiname           = 'gles1',
+        profile           = 'common',
+        versions          = allVersions,
+        emitversions      = noVersions,
+        defaultExtensions = 'gles1',                # Default extensions for GLES 1
+        addExtensions     = None,
+        removeExtensions  = es1CorePat,             # Remove mandatory ES1 extensions in GLES1/glext.h
+        prefixText        = prefixStrings + gles1ExtPlatformStrings + genDateCommentString,
+        genFuncPointers   = True,
+        protectFile       = protectFile,
+        protectFeature    = protectFeature,
+        protectProto      = protectProto,
+        protectProtoStr   = 'GL_GLEXT_PROTOTYPES',
+        apicall           = 'GL_API ',
+        apientry          = 'GL_APIENTRY ',
+        apientryp         = 'GL_APIENTRYP '),
+    # GLES 2.0 API - GLES2/gl2.h (no function pointers)
+    CGeneratorOptions(
+        filename          = 'GLES2/gl2.h',
+        apiname           = 'gles2',
+        profile           = 'common',
+        versions          = gles2onlyPat,
+        emitversions      = allVersions,
+        defaultExtensions = None,                   # No default extensions
+        addExtensions     = None,
+        removeExtensions  = None,
+        prefixText        = prefixStrings + gles2PlatformStrings + genDateCommentString,
+        genFuncPointers   = False,
+        protectFile       = protectFile,
+        protectFeature    = protectFeature,
+        protectProto      = False,                  # Core ES API functions are in the static link libraries
+        protectProtoStr   = 'GL_GLEXT_PROTOTYPES',
+        apicall           = 'GL_APICALL ',
+        apientry          = 'GL_APIENTRY ',
+        apientryp         = 'GL_APIENTRYP '),
+    # GLES 3.1 / 3.0 / 2.0 extensions - GLES2/gl2ext.h
+    CGeneratorOptions(
+        filename          = 'GLES2/gl2ext.h',
+        apiname           = 'gles2',
+        profile           = 'common',
+        versions          = gles2onlyPat,
+        emitversions      = None,
+        defaultExtensions = 'gles2',                # Default extensions for GLES 2
+        addExtensions     = None,
+        removeExtensions  = None,
+        prefixText        = prefixStrings + gles2ExtPlatformStrings + genDateCommentString,
+        genFuncPointers   = True,
+        protectFile       = protectFile,
+        protectFeature    = protectFeature,
+        protectProto      = protectProto,
+        protectProtoStr   = 'GL_GLEXT_PROTOTYPES',
+        apicall           = 'GL_APICALL ',
+        apientry          = 'GL_APIENTRY ',
+        apientryp         = 'GL_APIENTRYP '),
+    # GLES 3.1 API - GLES3/gl31.h (no function pointers)
+    CGeneratorOptions(
+        filename          = 'GLES3/gl31.h',
+        apiname           = 'gles2',
+        profile           = 'common',
+        versions          = gles2and30and31Pat,
+        emitversions      = allVersions,
+        defaultExtensions = None,                   # No default extensions
+        addExtensions     = None,
+        removeExtensions  = None,
+        prefixText        = prefixStrings + gles3PlatformStrings + genDateCommentString,
+        genFuncPointers   = False,
+        protectFile       = protectFile,
+        protectFeature    = protectFeature,
+        protectProto      = False,                  # Core ES API functions are in the static link libraries
+        protectProtoStr   = 'GL_GLEXT_PROTOTYPES',
+        apicall           = 'GL_APICALL ',
+        apientry          = 'GL_APIENTRY ',
+        apientryp         = 'GL_APIENTRYP '),
+    # GLES 3.0 API - GLES3/gl3.h (no function pointers)
+    CGeneratorOptions(
+        filename          = 'GLES3/gl3.h',
+        apiname           = 'gles2',
+        profile           = 'common',
+        versions          = gles2and30Pat,
+        emitversions      = allVersions,
+        defaultExtensions = None,                   # No default extensions
+        addExtensions     = None,
+        removeExtensions  = None,
+        prefixText        = prefixStrings + gles3PlatformStrings + genDateCommentString,
+        genFuncPointers   = False,
+        protectFile       = protectFile,
+        protectFeature    = protectFeature,
+        protectProto      = False,                  # Core ES API functions are in the static link libraries
+        protectProtoStr   = 'GL_GLEXT_PROTOTYPES',
+        apicall           = 'GL_APICALL ',
+        apientry          = 'GL_APIENTRY ',
+        apientryp         = 'GL_APIENTRYP '),
+    # EGL API - EGL/egl.h (no function pointers, yet @@@)
+    CGeneratorOptions(
+        filename          = 'EGL/egl.h',
+        apiname           = 'egl',
+        profile           = None,
+        versions          = allVersions,
+        emitversions      = allVersions,
+        defaultExtensions = None,                   # No default extensions
+        addExtensions     = None,
+        removeExtensions  = None,
+        prefixText        = prefixStrings + eglPlatformStrings + genDateCommentString,
+        genFuncPointers   = False,
+        protectFile       = protectFile,
+        protectFeature    = protectFeature,
+        protectProto      = False,
+        protectProtoStr   = 'EGL_EGLEXT_PROTOTYPES',
+        apicall           = 'EGLAPI ',
+        apientry          = 'EGLAPIENTRY ',
+        apientryp         = 'EGLAPIENTRYP '),
+    # EGL extensions - EGL/eglext.h (no function pointers, yet @@@)
+    CGeneratorOptions(
+        filename          = 'EGL/eglext.h',
+        apiname           = 'egl',
+        profile           = None,
+        versions          = allVersions,
+        emitversions      = None,
+        defaultExtensions = 'egl',                  # Default extensions for EGL
+        addExtensions     = None,
+        removeExtensions  = None,
+        prefixText        = prefixStrings + eglPlatformStrings + eglextVersionStrings,
+        genFuncPointers   = True,
+        protectFile       = protectFile,
+        protectFeature    = protectFeature,
+        protectProto      = protectProto,
+        protectProtoStr   = 'EGL_EGLEXT_PROTOTYPES',
+        apicall           = 'EGLAPI ',
+        apientry          = 'EGLAPIENTRY ',
+        apientryp         = 'EGLAPIENTRYP '),
+    # GLX 1.* API - GL/glx.h
+    CGeneratorOptions(
+        filename          = 'GL/glx.h',
+        apiname           = 'glx',
+        profile           = None,
+        versions          = allVersions,
+        emitversions      = allVersions,
+        defaultExtensions = None,                   # No default extensions
+        addExtensions     = None,
+        removeExtensions  = None,
+        # add glXPlatformStrings?
+        prefixText        = prefixStrings + genDateCommentString,
+        genFuncPointers   = True,
+        protectFile       = protectFile,
+        protectFeature    = protectFeature,
+        protectProto      = protectProto,
+        protectProtoStr   = 'GLX_GLXEXT_PROTOTYPES',
+        apicall           = '',
+        apientry          = '',
+        apientryp         = ' *'),
+    # GLX 1.3+ API + extensions - GL/glxext.h (no function pointers, yet @@@)
+    CGeneratorOptions(
+        filename          = 'GL/glxext.h',
+        apiname           = 'glx',
+        profile           = None,
+        versions          = allVersions,
+        emitversions      = glx13andLaterPat,
+        defaultExtensions = 'glx',                  # Default extensions for GLX
+        addExtensions     = None,
+        removeExtensions  = None,
+        # add glXPlatformStrings?
+        prefixText        = prefixStrings + glxextVersionStrings,
+        genFuncPointers   = True,
+        protectFile       = protectFile,
+        protectFeature    = protectFeature,
+        protectProto      = protectProto,
+        protectProtoStr   = 'GLX_GLXEXT_PROTOTYPES',
+        apicall           = '',
+        apientry          = '',
+        apientryp         = ' *'),
+    # WGL API + extensions - GL/wgl.h (no function pointers, yet @@@)
+    CGeneratorOptions(
+        filename          = 'GL/wgl.h',
+        apiname           = 'wgl',
+        profile           = None,
+        versions          = allVersions,
+        emitversions      = allVersions,
+        defaultExtensions = 'wgl',                  # Default extensions for WGL
+        addExtensions     = None,
+        removeExtensions  = None,
+        prefixText        = prefixStrings + wglPlatformStrings + genDateCommentString,
+        genFuncPointers   = True,
+        protectFile       = protectFile,
+        protectFeature    = protectFeature,
+        protectProto      = protectProto,
+        protectProtoStr   = 'WGL_WGLEXT_PROTOTYPES',
+        apicall           = '',
+        apientry          = 'WINAPI ',
+        apientryp         = 'WINAPI * '),
+    # WGL extensions - GL/wglext.h (no function pointers, yet @@@)
+    CGeneratorOptions(
+        filename          = 'GL/wglext.h',
+        apiname           = 'wgl',
+        profile           = None,
+        versions          = allVersions,
+        emitversions      = None,
+        defaultExtensions = 'wgl',                  # Default extensions for WGL
+        addExtensions     = None,
+        removeExtensions  = None,
+        prefixText        = prefixStrings + wglPlatformStrings + wglextVersionStrings,
+        genFuncPointers   = True,
+        protectFile       = protectFile,
+        protectFeature    = protectFeature,
+        protectProto      = protectProto,
+        protectProtoStr   = 'WGL_WGLEXT_PROTOTYPES',
+        apicall           = '',
+        apientry          = 'WINAPI ',
+        apientryp         = 'WINAPI * '),
+    # End of list
+    None
+]
+
+# create error/warning & diagnostic files
+if (errFilename):
+    errWarn = open(errFilename,'w')
+else:
+    errWarn = sys.stderr
+diag = open(diagFilename, 'w')
+
+def genHeaders():
+    # Loop over targets, building each
+    generated = 0
+    for genOpts in buildList:
+        if (genOpts == None):
+            break
+        if (target and target != genOpts.filename):
+            # write('*** Skipping', genOpts.filename)
+            continue
+        write('*** Building', genOpts.filename)
+        generated = generated + 1
+        startTimer()
+        gen = COutputGenerator(errFile=errWarn,
+                               warnFile=errWarn,
+                               diagFile=diag)
+        reg.setGenerator(gen)
+        reg.apiGen(genOpts)
+        write('** Generated', genOpts.filename)
+        endTimer('Time to generate ' + genOpts.filename + ' =')
+    if (target and generated == 0):
+        write('Failed to generate target:', target)
+
+if (debug):
+    pdb.run('genHeaders()')
+elif (profile):
+    import cProfile, pstats
+    cProfile.run('genHeaders()', 'profile.txt')
+    p = pstats.Stats('profile.txt')
+    p.strip_dirs().sort_stats('time').print_stats(50)
+else:
+    genHeaders()
diff --git a/opengl/tools/glgen2/registry/gl.xml b/opengl/tools/glgen2/registry/gl.xml
new file mode 100755
index 0000000..3f0697a
--- /dev/null
+++ b/opengl/tools/glgen2/registry/gl.xml
@@ -0,0 +1,42184 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<registry>
+    <comment>
+Copyright (c) 2013-2014 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.
+
+------------------------------------------------------------------------
+
+This file, gl.xml, is the OpenGL and OpenGL API Registry. The older
+".spec" file format has been retired and will no longer be updated with
+new extensions and API versions. The canonical version of the registry,
+together with documentation, schema, and Python generator scripts used
+to generate C header files for OpenGL and OpenGL ES, can always be found
+in the Khronos Registry at
+        http://www.opengl.org/registry/
+    </comment>
+
+    <!-- SECTION: GL type definitions. -->
+    <types>
+            <!-- These are dependencies GL types require to be declared legally -->
+        <type name="stddef">#include &lt;stddef.h&gt;</type>
+        <type name="khrplatform">#include &lt;KHR/khrplatform.h&gt;</type>
+        <type name="inttypes">#ifndef GLEXT_64_TYPES_DEFINED
+/* This code block is duplicated in glxext.h, so must be protected */
+#define GLEXT_64_TYPES_DEFINED
+/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
+/* (as used in the GL_EXT_timer_query extension). */
+#if defined(__STDC_VERSION__) &amp;&amp; __STDC_VERSION__ &gt;= 199901L
+#include &lt;inttypes.h&gt;
+#elif defined(__sun__) || defined(__digital__)
+#include &lt;inttypes.h&gt;
+#if defined(__STDC__)
+#if defined(__arch64__) || defined(_LP64)
+typedef long int int64_t;
+typedef unsigned long int uint64_t;
+#else
+typedef long long int int64_t;
+typedef unsigned long long int uint64_t;
+#endif /* __arch64__ */
+#endif /* __STDC__ */
+#elif defined( __VMS ) || defined(__sgi)
+#include &lt;inttypes.h&gt;
+#elif defined(__SCO__) || defined(__USLC__)
+#include &lt;stdint.h&gt;
+#elif defined(__UNIXOS2__) || defined(__SOL64__)
+typedef long int int32_t;
+typedef long long int int64_t;
+typedef unsigned long long int uint64_t;
+#elif defined(_WIN32) &amp;&amp; defined(__GNUC__)
+#include &lt;stdint.h&gt;
+#elif defined(_WIN32)
+typedef __int32 int32_t;
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#else
+/* Fallback if nothing above works */
+#include &lt;inttypes.h&gt;
+#endif
+#endif</type>
+            <!-- These are actual GL types -->
+        <type>typedef unsigned int <name>GLenum</name>;</type>
+        <type>typedef unsigned char <name>GLboolean</name>;</type>
+        <type>typedef unsigned int <name>GLbitfield</name>;</type>
+        <type comment="Not an actual GL type, though used in headers in the past">typedef void <name>GLvoid</name>;</type>
+        <type>typedef signed char <name>GLbyte</name>;</type>
+        <type>typedef short <name>GLshort</name>;</type>
+        <type>typedef int <name>GLint</name>;</type>
+        <type>typedef int <name>GLclampx</name>;</type>
+        <type>typedef unsigned char <name>GLubyte</name>;</type>
+        <type>typedef unsigned short <name>GLushort</name>;</type>
+        <type>typedef unsigned int <name>GLuint</name>;</type>
+        <type>typedef int <name>GLsizei</name>;</type>
+        <type>typedef float <name>GLfloat</name>;</type>
+        <type>typedef float <name>GLclampf</name>;</type>
+        <type>typedef double <name>GLdouble</name>;</type>
+        <type>typedef double <name>GLclampd</name>;</type>
+        <type>typedef void *<name>GLeglImageOES</name>;</type>
+        <type>typedef char <name>GLchar</name>;</type>
+        <type>typedef char <name>GLcharARB</name>;</type>
+        <type name="GLhandleARB">#ifdef __APPLE__
+typedef void *GLhandleARB;
+#else
+typedef unsigned int GLhandleARB;
+#endif</type>
+        <type>typedef unsigned short <name>GLhalfARB</name>;</type>
+        <type>typedef unsigned short <name>GLhalf</name>;</type>
+        <type comment="Must be 32 bits">typedef GLint <name>GLfixed</name>;</type>
+        <type requires="stddef">typedef ptrdiff_t <name>GLintptr</name>;</type>
+        <type requires="stddef">typedef ptrdiff_t <name>GLsizeiptr</name>;</type>
+        <type requires="inttypes">typedef int64_t <name>GLint64</name>;</type>
+        <type requires="inttypes">typedef uint64_t <name>GLuint64</name>;</type>
+        <type requires="stddef">typedef ptrdiff_t <name>GLintptrARB</name>;</type>
+        <type requires="stddef">typedef ptrdiff_t <name>GLsizeiptrARB</name>;</type>
+        <type requires="inttypes">typedef int64_t <name>GLint64EXT</name>;</type>
+        <type requires="inttypes">typedef uint64_t <name>GLuint64EXT</name>;</type>
+        <type>typedef struct __GLsync *<name>GLsync</name>;</type>
+        <type comment="compatible with OpenCL cl_context"><name>struct _cl_context</name>;</type>
+        <type comment="compatible with OpenCL cl_event"><name>struct _cl_event</name>;</type>
+        <type>typedef void (<apientry/> *<name>GLDEBUGPROC</name>)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);</type>
+        <type>typedef void (<apientry/> *<name>GLDEBUGPROCARB</name>)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);</type>
+        <type>typedef void (<apientry/> *<name>GLDEBUGPROCKHR</name>)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);</type>
+            <!-- GLES 1 types -->
+        <type api="gles1" requires="khrplatform">typedef khronos_int32_t <name>GLclampx</name>;</type>
+            <!-- GLES 1/2 types (tagged for GLES 1) -->
+        <type api="gles1" requires="khrplatform">typedef khronos_int8_t <name>GLbyte</name>;</type>
+        <type api="gles1" requires="khrplatform">typedef khronos_uint8_t <name>GLubyte</name>;</type>
+        <type api="gles1" requires="khrplatform">typedef khronos_float_t <name>GLfloat</name>;</type>
+        <type api="gles1" requires="khrplatform">typedef khronos_float_t <name>GLclampf</name>;</type>
+        <type api="gles1" requires="khrplatform">typedef khronos_int32_t <name>GLfixed</name>;</type>
+        <type api="gles1" requires="khrplatform">typedef khronos_int64_t <name>GLint64</name>;</type>
+        <type api="gles1" requires="khrplatform">typedef khronos_uint64_t <name>GLuint64</name>;</type>
+        <type api="gles1" requires="khrplatform">typedef khronos_intptr_t <name>GLintptr</name>;</type>
+        <type api="gles1" requires="khrplatform">typedef khronos_ssize_t <name>GLsizeiptr</name>;</type>
+            <!-- GLES 1/2 types (tagged for GLES 2 - attribute syntax is limited) -->
+        <type api="gles2" requires="khrplatform">typedef khronos_int8_t <name>GLbyte</name>;</type>
+        <type api="gles2" requires="khrplatform">typedef khronos_uint8_t <name>GLubyte</name>;</type>
+        <type api="gles2" requires="khrplatform">typedef khronos_float_t <name>GLfloat</name>;</type>
+        <type api="gles2" requires="khrplatform">typedef khronos_float_t <name>GLclampf</name>;</type>
+        <type api="gles2" requires="khrplatform">typedef khronos_int32_t <name>GLfixed</name>;</type>
+        <type api="gles2" requires="khrplatform">typedef khronos_int64_t <name>GLint64</name>;</type>
+        <type api="gles2" requires="khrplatform">typedef khronos_uint64_t <name>GLuint64</name>;</type>
+        <type api="gles2" requires="khrplatform">typedef khronos_int64_t <name>GLint64EXT</name>;</type>
+        <type api="gles2" requires="khrplatform">typedef khronos_uint64_t <name>GLuint64EXT</name>;</type>
+        <type api="gles2" requires="khrplatform">typedef khronos_intptr_t <name>GLintptr</name>;</type>
+        <type api="gles2" requires="khrplatform">typedef khronos_ssize_t <name>GLsizeiptr</name>;</type>
+            <!-- GLES 2 types (none currently) -->
+            <!-- Vendor extension types -->
+        <type>typedef void (<apientry/> *<name>GLDEBUGPROCAMD</name>)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);</type>
+        <type>typedef unsigned short <name>GLhalfNV</name>;</type>
+        <type requires="GLintptr">typedef GLintptr <name>GLvdpauSurfaceNV</name>;</type>
+    </types>
+
+    <!-- SECTION: GL parameter class type definitions. -->
+
+    <groups>
+        <group name="AccumOp">
+            <enum name="GL_ACCUM"/>
+            <enum name="GL_LOAD"/>
+            <enum name="GL_RETURN"/>
+            <enum name="GL_MULT"/>
+            <enum name="GL_ADD"/>
+        </group>
+
+        <group name="AttribMask">
+            <enum name="GL_ACCUM_BUFFER_BIT"/>
+            <enum name="GL_ALL_ATTRIB_BITS"/>
+            <enum name="GL_COLOR_BUFFER_BIT"/>
+            <enum name="GL_CURRENT_BIT"/>
+            <enum name="GL_DEPTH_BUFFER_BIT"/>
+            <enum name="GL_ENABLE_BIT"/>
+            <enum name="GL_EVAL_BIT"/>
+            <enum name="GL_FOG_BIT"/>
+            <enum name="GL_HINT_BIT"/>
+            <enum name="GL_LIGHTING_BIT"/>
+            <enum name="GL_LINE_BIT"/>
+            <enum name="GL_LIST_BIT"/>
+            <enum name="GL_MULTISAMPLE_BIT"/>
+            <enum name="GL_MULTISAMPLE_BIT_3DFX"/>
+            <enum name="GL_MULTISAMPLE_BIT_ARB"/>
+            <enum name="GL_MULTISAMPLE_BIT_EXT"/>
+            <enum name="GL_PIXEL_MODE_BIT"/>
+            <enum name="GL_POINT_BIT"/>
+            <enum name="GL_POLYGON_BIT"/>
+            <enum name="GL_POLYGON_STIPPLE_BIT"/>
+            <enum name="GL_SCISSOR_BIT"/>
+            <enum name="GL_STENCIL_BUFFER_BIT"/>
+            <enum name="GL_TEXTURE_BIT"/>
+            <enum name="GL_TRANSFORM_BIT"/>
+            <enum name="GL_VIEWPORT_BIT"/>
+        </group>
+
+        <group name="AlphaFunction">
+            <enum name="GL_ALWAYS"/>
+            <enum name="GL_EQUAL"/>
+            <enum name="GL_GEQUAL"/>
+            <enum name="GL_GREATER"/>
+            <enum name="GL_LEQUAL"/>
+            <enum name="GL_LESS"/>
+            <enum name="GL_NEVER"/>
+            <enum name="GL_NOTEQUAL"/>
+        </group>
+
+        <group name="BlendEquationModeEXT">
+            <enum name="GL_ALPHA_MAX_SGIX"/>
+            <enum name="GL_ALPHA_MIN_SGIX"/>
+            <enum name="GL_FUNC_ADD_EXT"/>
+            <enum name="GL_FUNC_REVERSE_SUBTRACT_EXT"/>
+            <enum name="GL_FUNC_SUBTRACT_EXT"/>
+            <enum name="GL_LOGIC_OP"/>
+            <enum name="GL_MAX_EXT"/>
+            <enum name="GL_MIN_EXT"/>
+        </group>
+
+        <group name="BlendingFactorDest">
+            <enum name="GL_CONSTANT_ALPHA_EXT"/>
+            <enum name="GL_CONSTANT_COLOR_EXT"/>
+            <enum name="GL_DST_ALPHA"/>
+            <enum name="GL_ONE"/>
+            <enum name="GL_ONE_MINUS_CONSTANT_ALPHA_EXT"/>
+            <enum name="GL_ONE_MINUS_CONSTANT_COLOR_EXT"/>
+            <enum name="GL_ONE_MINUS_DST_ALPHA"/>
+            <enum name="GL_ONE_MINUS_SRC_ALPHA"/>
+            <enum name="GL_ONE_MINUS_SRC_COLOR"/>
+            <enum name="GL_SRC_ALPHA"/>
+            <enum name="GL_SRC_COLOR"/>
+            <enum name="GL_ZERO"/>
+        </group>
+
+        <group name="BlendingFactorSrc">
+            <enum name="GL_CONSTANT_ALPHA_EXT"/>
+            <enum name="GL_CONSTANT_COLOR_EXT"/>
+            <enum name="GL_DST_ALPHA"/>
+            <enum name="GL_DST_COLOR"/>
+            <enum name="GL_ONE"/>
+            <enum name="GL_ONE_MINUS_CONSTANT_ALPHA_EXT"/>
+            <enum name="GL_ONE_MINUS_CONSTANT_COLOR_EXT"/>
+            <enum name="GL_ONE_MINUS_DST_ALPHA"/>
+            <enum name="GL_ONE_MINUS_DST_COLOR"/>
+            <enum name="GL_ONE_MINUS_SRC_ALPHA"/>
+            <enum name="GL_SRC_ALPHA"/>
+            <enum name="GL_SRC_ALPHA_SATURATE"/>
+            <enum name="GL_ZERO"/>
+        </group>
+
+        <group name="Boolean">
+            <enum name="GL_FALSE"/>
+            <enum name="GL_TRUE"/>
+        </group>
+
+        <group name="ClearBufferMask">
+            <enum name="GL_ACCUM_BUFFER_BIT"/>
+            <enum name="GL_COLOR_BUFFER_BIT"/>
+            <enum name="GL_COVERAGE_BUFFER_BIT_NV"/>
+            <enum name="GL_DEPTH_BUFFER_BIT"/>
+            <enum name="GL_STENCIL_BUFFER_BIT"/>
+        </group>
+
+        <group name="ClientAttribMask">
+            <enum name="GL_CLIENT_ALL_ATTRIB_BITS"/>
+            <enum name="GL_CLIENT_PIXEL_STORE_BIT"/>
+            <enum name="GL_CLIENT_VERTEX_ARRAY_BIT"/>
+        </group>
+
+        <group name="ClipPlaneName">
+            <enum name="GL_CLIP_DISTANCE0"/>
+            <enum name="GL_CLIP_DISTANCE1"/>
+            <enum name="GL_CLIP_DISTANCE2"/>
+            <enum name="GL_CLIP_DISTANCE3"/>
+            <enum name="GL_CLIP_DISTANCE4"/>
+            <enum name="GL_CLIP_DISTANCE5"/>
+            <enum name="GL_CLIP_DISTANCE6"/>
+            <enum name="GL_CLIP_DISTANCE7"/>
+            <enum name="GL_CLIP_PLANE0"/>
+            <enum name="GL_CLIP_PLANE1"/>
+            <enum name="GL_CLIP_PLANE2"/>
+            <enum name="GL_CLIP_PLANE3"/>
+            <enum name="GL_CLIP_PLANE4"/>
+            <enum name="GL_CLIP_PLANE5"/>
+        </group>
+
+        <group name="ColorMaterialFace">
+            <enum name="GL_BACK"/>
+            <enum name="GL_FRONT"/>
+            <enum name="GL_FRONT_AND_BACK"/>
+        </group>
+
+        <group name="ColorMaterialParameter">
+            <enum name="GL_AMBIENT"/>
+            <enum name="GL_AMBIENT_AND_DIFFUSE"/>
+            <enum name="GL_DIFFUSE"/>
+            <enum name="GL_EMISSION"/>
+            <enum name="GL_SPECULAR"/>
+        </group>
+
+        <group name="ColorPointerType">
+            <enum name="GL_BYTE"/>
+            <enum name="GL_DOUBLE"/>
+            <enum name="GL_FLOAT"/>
+            <enum name="GL_INT"/>
+            <enum name="GL_SHORT"/>
+            <enum name="GL_UNSIGNED_BYTE"/>
+            <enum name="GL_UNSIGNED_INT"/>
+            <enum name="GL_UNSIGNED_SHORT"/>
+        </group>
+
+        <group name="ColorTableParameterPNameSGI">
+            <enum name="GL_COLOR_TABLE_BIAS"/>
+            <enum name="GL_COLOR_TABLE_BIAS_SGI"/>
+            <enum name="GL_COLOR_TABLE_SCALE"/>
+            <enum name="GL_COLOR_TABLE_SCALE_SGI"/>
+        </group>
+
+        <group name="ColorTableTargetSGI">
+            <enum name="GL_COLOR_TABLE"/>
+            <enum name="GL_COLOR_TABLE_SGI"/>
+            <enum name="GL_POST_COLOR_MATRIX_COLOR_TABLE"/>
+            <enum name="GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI"/>
+            <enum name="GL_POST_CONVOLUTION_COLOR_TABLE"/>
+            <enum name="GL_POST_CONVOLUTION_COLOR_TABLE_SGI"/>
+            <enum name="GL_PROXY_COLOR_TABLE"/>
+            <enum name="GL_PROXY_COLOR_TABLE_SGI"/>
+            <enum name="GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE"/>
+            <enum name="GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI"/>
+            <enum name="GL_PROXY_POST_CONVOLUTION_COLOR_TABLE"/>
+            <enum name="GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI"/>
+            <enum name="GL_PROXY_TEXTURE_COLOR_TABLE_SGI"/>
+            <enum name="GL_TEXTURE_COLOR_TABLE_SGI"/>
+        </group>
+
+        <group name="ContextFlagMask">
+            <enum name="GL_CONTEXT_FLAG_DEBUG_BIT"/>
+            <enum name="GL_CONTEXT_FLAG_DEBUG_BIT_KHR"/>
+            <enum name="GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT"/>
+            <enum name="GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB"/>
+        </group>
+
+        <group name="ContextProfileMask">
+            <enum name="GL_CONTEXT_COMPATIBILITY_PROFILE_BIT"/>
+            <enum name="GL_CONTEXT_CORE_PROFILE_BIT"/>
+        </group>
+
+        <group name="ConvolutionBorderModeEXT">
+            <enum name="GL_REDUCE"/>
+            <enum name="GL_REDUCE_EXT"/>
+        </group>
+
+        <group name="ConvolutionParameterEXT">
+            <enum name="GL_CONVOLUTION_BORDER_MODE"/>
+            <enum name="GL_CONVOLUTION_BORDER_MODE_EXT"/>
+            <enum name="GL_CONVOLUTION_FILTER_BIAS"/>
+            <enum name="GL_CONVOLUTION_FILTER_BIAS_EXT"/>
+            <enum name="GL_CONVOLUTION_FILTER_SCALE"/>
+            <enum name="GL_CONVOLUTION_FILTER_SCALE_EXT"/>
+        </group>
+
+        <group name="ConvolutionTargetEXT">
+            <enum name="GL_CONVOLUTION_1D"/>
+            <enum name="GL_CONVOLUTION_1D_EXT"/>
+            <enum name="GL_CONVOLUTION_2D"/>
+            <enum name="GL_CONVOLUTION_2D_EXT"/>
+        </group>
+
+        <group name="CullFaceMode">
+            <enum name="GL_BACK"/>
+            <enum name="GL_FRONT"/>
+            <enum name="GL_FRONT_AND_BACK"/>
+        </group>
+
+        <group name="DataType" comment="See enums block below"/>
+
+        <group name="DepthFunction">
+            <enum name="GL_ALWAYS"/>
+            <enum name="GL_EQUAL"/>
+            <enum name="GL_GEQUAL"/>
+            <enum name="GL_GREATER"/>
+            <enum name="GL_LEQUAL"/>
+            <enum name="GL_LESS"/>
+            <enum name="GL_NEVER"/>
+            <enum name="GL_NOTEQUAL"/>
+        </group>
+
+        <group name="DrawBufferMode">
+            <enum name="GL_AUX0"/>
+            <enum name="GL_AUX1"/>
+            <enum name="GL_AUX2"/>
+            <enum name="GL_AUX3"/>
+            <enum name="GL_BACK"/>
+            <enum name="GL_BACK_LEFT"/>
+            <enum name="GL_BACK_RIGHT"/>
+            <enum name="GL_FRONT"/>
+            <enum name="GL_FRONT_AND_BACK"/>
+            <enum name="GL_FRONT_LEFT"/>
+            <enum name="GL_FRONT_RIGHT"/>
+            <enum name="GL_LEFT"/>
+            <enum name="GL_NONE"/>
+            <enum name="GL_NONE_OES"/>
+            <enum name="GL_RIGHT"/>
+        </group>
+
+        <group name="EnableCap">
+            <enum name="GL_ALPHA_TEST"/>
+            <enum name="GL_ASYNC_DRAW_PIXELS_SGIX"/>
+            <enum name="GL_ASYNC_HISTOGRAM_SGIX"/>
+            <enum name="GL_ASYNC_READ_PIXELS_SGIX"/>
+            <enum name="GL_ASYNC_TEX_IMAGE_SGIX"/>
+            <enum name="GL_AUTO_NORMAL"/>
+            <enum name="GL_BLEND"/>
+            <enum name="GL_CALLIGRAPHIC_FRAGMENT_SGIX"/>
+            <enum name="GL_CLIP_PLANE0"/>
+            <enum name="GL_CLIP_PLANE1"/>
+            <enum name="GL_CLIP_PLANE2"/>
+            <enum name="GL_CLIP_PLANE3"/>
+            <enum name="GL_CLIP_PLANE4"/>
+            <enum name="GL_CLIP_PLANE5"/>
+            <enum name="GL_COLOR_ARRAY"/>
+            <enum name="GL_COLOR_LOGIC_OP"/>
+            <enum name="GL_COLOR_MATERIAL"/>
+            <enum name="GL_COLOR_TABLE_SGI"/>
+            <enum name="GL_CONVOLUTION_1D_EXT"/>
+            <enum name="GL_CONVOLUTION_2D_EXT"/>
+            <enum name="GL_CULL_FACE"/>
+            <enum name="GL_DEPTH_TEST"/>
+            <enum name="GL_DITHER"/>
+            <enum name="GL_EDGE_FLAG_ARRAY"/>
+            <enum name="GL_FOG"/>
+            <enum name="GL_FOG_OFFSET_SGIX"/>
+            <enum name="GL_FRAGMENT_COLOR_MATERIAL_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT0_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT1_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT2_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT3_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT4_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT5_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT6_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT7_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHTING_SGIX"/>
+            <enum name="GL_FRAMEZOOM_SGIX"/>
+            <enum name="GL_HISTOGRAM_EXT"/>
+            <enum name="GL_INDEX_ARRAY"/>
+            <enum name="GL_INDEX_LOGIC_OP"/>
+            <enum name="GL_INTERLACE_SGIX"/>
+            <enum name="GL_IR_INSTRUMENT1_SGIX"/>
+            <enum name="GL_LIGHT0"/>
+            <enum name="GL_LIGHT1"/>
+            <enum name="GL_LIGHT2"/>
+            <enum name="GL_LIGHT3"/>
+            <enum name="GL_LIGHT4"/>
+            <enum name="GL_LIGHT5"/>
+            <enum name="GL_LIGHT6"/>
+            <enum name="GL_LIGHT7"/>
+            <enum name="GL_LIGHTING"/>
+            <enum name="GL_LINE_SMOOTH"/>
+            <enum name="GL_LINE_STIPPLE"/>
+            <enum name="GL_MAP1_COLOR_4"/>
+            <enum name="GL_MAP1_INDEX"/>
+            <enum name="GL_MAP1_NORMAL"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_1"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_2"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_3"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_4"/>
+            <enum name="GL_MAP1_VERTEX_3"/>
+            <enum name="GL_MAP1_VERTEX_4"/>
+            <enum name="GL_MAP2_COLOR_4"/>
+            <enum name="GL_MAP2_INDEX"/>
+            <enum name="GL_MAP2_NORMAL"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_1"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_2"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_3"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_4"/>
+            <enum name="GL_MAP2_VERTEX_3"/>
+            <enum name="GL_MAP2_VERTEX_4"/>
+            <enum name="GL_MINMAX_EXT"/>
+            <enum name="GL_MULTISAMPLE_SGIS"/>
+            <enum name="GL_NORMALIZE"/>
+            <enum name="GL_NORMAL_ARRAY"/>
+            <enum name="GL_PIXEL_TEXTURE_SGIS"/>
+            <enum name="GL_PIXEL_TEX_GEN_SGIX"/>
+            <enum name="GL_POINT_SMOOTH"/>
+            <enum name="GL_POLYGON_OFFSET_FILL"/>
+            <enum name="GL_POLYGON_OFFSET_LINE"/>
+            <enum name="GL_POLYGON_OFFSET_POINT"/>
+            <enum name="GL_POLYGON_SMOOTH"/>
+            <enum name="GL_POLYGON_STIPPLE"/>
+            <enum name="GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI"/>
+            <enum name="GL_POST_CONVOLUTION_COLOR_TABLE_SGI"/>
+            <enum name="GL_REFERENCE_PLANE_SGIX"/>
+            <enum name="GL_RESCALE_NORMAL_EXT"/>
+            <enum name="GL_SAMPLE_ALPHA_TO_MASK_SGIS"/>
+            <enum name="GL_SAMPLE_ALPHA_TO_ONE_SGIS"/>
+            <enum name="GL_SAMPLE_MASK_SGIS"/>
+            <enum name="GL_SCISSOR_TEST"/>
+            <enum name="GL_SEPARABLE_2D_EXT"/>
+            <enum name="GL_SHARED_TEXTURE_PALETTE_EXT"/>
+            <enum name="GL_SPRITE_SGIX"/>
+            <enum name="GL_STENCIL_TEST"/>
+            <enum name="GL_TEXTURE_1D"/>
+            <enum name="GL_TEXTURE_2D"/>
+            <enum name="GL_TEXTURE_3D_EXT"/>
+            <enum name="GL_TEXTURE_4D_SGIS"/>
+            <enum name="GL_TEXTURE_COLOR_TABLE_SGI"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY"/>
+            <enum name="GL_TEXTURE_GEN_Q"/>
+            <enum name="GL_TEXTURE_GEN_R"/>
+            <enum name="GL_TEXTURE_GEN_S"/>
+            <enum name="GL_TEXTURE_GEN_T"/>
+            <enum name="GL_VERTEX_ARRAY"/>
+        </group>
+
+        <group name="ErrorCode">
+            <enum name="GL_INVALID_ENUM"/>
+            <enum name="GL_INVALID_FRAMEBUFFER_OPERATION"/>
+            <enum name="GL_INVALID_FRAMEBUFFER_OPERATION_EXT"/>
+            <enum name="GL_INVALID_FRAMEBUFFER_OPERATION_OES"/>
+            <enum name="GL_INVALID_OPERATION"/>
+            <enum name="GL_INVALID_VALUE"/>
+            <enum name="GL_NO_ERROR"/>
+            <enum name="GL_OUT_OF_MEMORY"/>
+            <enum name="GL_STACK_OVERFLOW"/>
+            <enum name="GL_STACK_UNDERFLOW"/>
+            <enum name="GL_TABLE_TOO_LARGE"/>
+            <enum name="GL_TABLE_TOO_LARGE_EXT"/>
+            <enum name="GL_TEXTURE_TOO_LARGE_EXT"/>
+        </group>
+
+        <group name="FeedbackType">
+            <enum name="GL_2D"/>
+            <enum name="GL_3D"/>
+            <enum name="GL_3D_COLOR"/>
+            <enum name="GL_3D_COLOR_TEXTURE"/>
+            <enum name="GL_4D_COLOR_TEXTURE"/>
+        </group>
+
+        <group name="FeedBackToken">
+            <enum name="GL_BITMAP_TOKEN"/>
+            <enum name="GL_COPY_PIXEL_TOKEN"/>
+            <enum name="GL_DRAW_PIXEL_TOKEN"/>
+            <enum name="GL_LINE_RESET_TOKEN"/>
+            <enum name="GL_LINE_TOKEN"/>
+            <enum name="GL_PASS_THROUGH_TOKEN"/>
+            <enum name="GL_POINT_TOKEN"/>
+            <enum name="GL_POLYGON_TOKEN"/>
+        </group>
+
+        <group name="FfdMaskSGIX" comment="See enums section below. Was SGIXFfdMask"/>
+
+        <group name="FfdTargetSGIX">
+            <enum name="GL_GEOMETRY_DEFORMATION_SGIX"/>
+            <enum name="GL_TEXTURE_DEFORMATION_SGIX"/>
+        </group>
+
+        <group name="FogCoordinatePointerType">
+            <enum name="GL_FLOAT"/>
+            <enum name="GL_DOUBLE"/>
+        </group>
+
+        <group name="FogMode">
+            <enum name="GL_EXP"/>
+            <enum name="GL_EXP2"/>
+            <enum name="GL_FOG_FUNC_SGIS"/>
+            <enum name="GL_LINEAR"/>
+        </group>
+
+        <group name="FogParameter">
+            <enum name="GL_FOG_COLOR"/>
+            <enum name="GL_FOG_DENSITY"/>
+            <enum name="GL_FOG_END"/>
+            <enum name="GL_FOG_INDEX"/>
+            <enum name="GL_FOG_MODE"/>
+            <enum name="GL_FOG_OFFSET_VALUE_SGIX"/>
+            <enum name="GL_FOG_START"/>
+        </group>
+
+        <group name="FogPointerTypeEXT">
+            <enum name="GL_FLOAT"/>
+            <enum name="GL_DOUBLE"/>
+        </group>
+
+        <group name="FogPointerTypeIBM">
+            <enum name="GL_FLOAT"/>
+            <enum name="GL_DOUBLE"/>
+        </group>
+
+        <group name="FragmentLightModelParameterSGIX">
+            <enum name="GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX"/>
+        </group>
+
+        <group name="FrontFaceDirection">
+            <enum name="GL_CCW"/>
+            <enum name="GL_CW"/>
+        </group>
+
+        <group name="GetColorTableParameterPNameSGI">
+            <enum name="GL_COLOR_TABLE_ALPHA_SIZE_SGI"/>
+            <enum name="GL_COLOR_TABLE_BIAS_SGI"/>
+            <enum name="GL_COLOR_TABLE_BLUE_SIZE_SGI"/>
+            <enum name="GL_COLOR_TABLE_FORMAT_SGI"/>
+            <enum name="GL_COLOR_TABLE_GREEN_SIZE_SGI"/>
+            <enum name="GL_COLOR_TABLE_INTENSITY_SIZE_SGI"/>
+            <enum name="GL_COLOR_TABLE_LUMINANCE_SIZE_SGI"/>
+            <enum name="GL_COLOR_TABLE_RED_SIZE_SGI"/>
+            <enum name="GL_COLOR_TABLE_SCALE_SGI"/>
+            <enum name="GL_COLOR_TABLE_WIDTH_SGI"/>
+        </group>
+
+        <group name="GetConvolutionParameter">
+            <enum name="GL_CONVOLUTION_BORDER_MODE_EXT"/>
+            <enum name="GL_CONVOLUTION_FILTER_BIAS_EXT"/>
+            <enum name="GL_CONVOLUTION_FILTER_SCALE_EXT"/>
+            <enum name="GL_CONVOLUTION_FORMAT_EXT"/>
+            <enum name="GL_CONVOLUTION_HEIGHT_EXT"/>
+            <enum name="GL_CONVOLUTION_WIDTH_EXT"/>
+            <enum name="GL_MAX_CONVOLUTION_HEIGHT_EXT"/>
+            <enum name="GL_MAX_CONVOLUTION_WIDTH_EXT"/>
+        </group>
+
+        <group name="GetHistogramParameterPNameEXT">
+            <enum name="GL_HISTOGRAM_ALPHA_SIZE_EXT"/>
+            <enum name="GL_HISTOGRAM_BLUE_SIZE_EXT"/>
+            <enum name="GL_HISTOGRAM_FORMAT_EXT"/>
+            <enum name="GL_HISTOGRAM_GREEN_SIZE_EXT"/>
+            <enum name="GL_HISTOGRAM_LUMINANCE_SIZE_EXT"/>
+            <enum name="GL_HISTOGRAM_RED_SIZE_EXT"/>
+            <enum name="GL_HISTOGRAM_SINK_EXT"/>
+            <enum name="GL_HISTOGRAM_WIDTH_EXT"/>
+        </group>
+
+        <group name="GetMapQuery">
+            <enum name="GL_COEFF"/>
+            <enum name="GL_DOMAIN"/>
+            <enum name="GL_ORDER"/>
+        </group>
+
+        <group name="GetMinmaxParameterPNameEXT">
+            <enum name="GL_MINMAX_FORMAT"/>
+            <enum name="GL_MINMAX_FORMAT_EXT"/>
+            <enum name="GL_MINMAX_SINK"/>
+            <enum name="GL_MINMAX_SINK_EXT"/>
+        </group>
+
+        <group name="GetPixelMap">
+            <enum name="GL_PIXEL_MAP_A_TO_A"/>
+            <enum name="GL_PIXEL_MAP_B_TO_B"/>
+            <enum name="GL_PIXEL_MAP_G_TO_G"/>
+            <enum name="GL_PIXEL_MAP_I_TO_A"/>
+            <enum name="GL_PIXEL_MAP_I_TO_B"/>
+            <enum name="GL_PIXEL_MAP_I_TO_G"/>
+            <enum name="GL_PIXEL_MAP_I_TO_I"/>
+            <enum name="GL_PIXEL_MAP_I_TO_R"/>
+            <enum name="GL_PIXEL_MAP_R_TO_R"/>
+            <enum name="GL_PIXEL_MAP_S_TO_S"/>
+        </group>
+
+        <group name="GetPName">
+            <enum name="GL_ACCUM_ALPHA_BITS"/>
+            <enum name="GL_ACCUM_BLUE_BITS"/>
+            <enum name="GL_ACCUM_CLEAR_VALUE"/>
+            <enum name="GL_ACCUM_GREEN_BITS"/>
+            <enum name="GL_ACCUM_RED_BITS"/>
+            <enum name="GL_ALIASED_LINE_WIDTH_RANGE"/>
+            <enum name="GL_ALIASED_POINT_SIZE_RANGE"/>
+            <enum name="GL_ALPHA_BIAS"/>
+            <enum name="GL_ALPHA_BITS"/>
+            <enum name="GL_ALPHA_SCALE"/>
+            <enum name="GL_ALPHA_TEST"/>
+            <enum name="GL_ALPHA_TEST_FUNC"/>
+            <enum name="GL_ALPHA_TEST_FUNC_QCOM"/>
+            <enum name="GL_ALPHA_TEST_QCOM"/>
+            <enum name="GL_ALPHA_TEST_REF"/>
+            <enum name="GL_ALPHA_TEST_REF_QCOM"/>
+            <enum name="GL_ASYNC_DRAW_PIXELS_SGIX"/>
+            <enum name="GL_ASYNC_HISTOGRAM_SGIX"/>
+            <enum name="GL_ASYNC_MARKER_SGIX"/>
+            <enum name="GL_ASYNC_READ_PIXELS_SGIX"/>
+            <enum name="GL_ASYNC_TEX_IMAGE_SGIX"/>
+            <enum name="GL_ATTRIB_STACK_DEPTH"/>
+            <enum name="GL_AUTO_NORMAL"/>
+            <enum name="GL_AUX_BUFFERS"/>
+            <enum name="GL_BLEND"/>
+            <enum name="GL_BLEND_COLOR_EXT"/>
+            <enum name="GL_BLEND_DST"/>
+            <enum name="GL_BLEND_EQUATION_EXT"/>
+            <enum name="GL_BLEND_SRC"/>
+            <enum name="GL_BLUE_BIAS"/>
+            <enum name="GL_BLUE_BITS"/>
+            <enum name="GL_BLUE_SCALE"/>
+            <enum name="GL_CALLIGRAPHIC_FRAGMENT_SGIX"/>
+            <enum name="GL_CLIENT_ATTRIB_STACK_DEPTH"/>
+            <enum name="GL_CLIP_PLANE0"/>
+            <enum name="GL_CLIP_PLANE1"/>
+            <enum name="GL_CLIP_PLANE2"/>
+            <enum name="GL_CLIP_PLANE3"/>
+            <enum name="GL_CLIP_PLANE4"/>
+            <enum name="GL_CLIP_PLANE5"/>
+            <enum name="GL_COLOR_ARRAY"/>
+            <enum name="GL_COLOR_ARRAY_COUNT_EXT"/>
+            <enum name="GL_COLOR_ARRAY_SIZE"/>
+            <enum name="GL_COLOR_ARRAY_STRIDE"/>
+            <enum name="GL_COLOR_ARRAY_TYPE"/>
+            <enum name="GL_COLOR_CLEAR_VALUE"/>
+            <enum name="GL_COLOR_LOGIC_OP"/>
+            <enum name="GL_COLOR_MATERIAL"/>
+            <enum name="GL_COLOR_MATERIAL_FACE"/>
+            <enum name="GL_COLOR_MATERIAL_PARAMETER"/>
+            <enum name="GL_COLOR_MATRIX_SGI"/>
+            <enum name="GL_COLOR_MATRIX_STACK_DEPTH_SGI"/>
+            <enum name="GL_COLOR_TABLE_SGI"/>
+            <enum name="GL_COLOR_WRITEMASK"/>
+            <enum name="GL_CONVOLUTION_1D_EXT"/>
+            <enum name="GL_CONVOLUTION_2D_EXT"/>
+            <enum name="GL_CONVOLUTION_HINT_SGIX"/>
+            <enum name="GL_CULL_FACE"/>
+            <enum name="GL_CULL_FACE_MODE"/>
+            <enum name="GL_CURRENT_COLOR"/>
+            <enum name="GL_CURRENT_INDEX"/>
+            <enum name="GL_CURRENT_NORMAL"/>
+            <enum name="GL_CURRENT_RASTER_COLOR"/>
+            <enum name="GL_CURRENT_RASTER_DISTANCE"/>
+            <enum name="GL_CURRENT_RASTER_INDEX"/>
+            <enum name="GL_CURRENT_RASTER_POSITION"/>
+            <enum name="GL_CURRENT_RASTER_POSITION_VALID"/>
+            <enum name="GL_CURRENT_RASTER_TEXTURE_COORDS"/>
+            <enum name="GL_CURRENT_TEXTURE_COORDS"/>
+            <enum name="GL_DEFORMATIONS_MASK_SGIX"/>
+            <enum name="GL_DEPTH_BIAS"/>
+            <enum name="GL_DEPTH_BITS"/>
+            <enum name="GL_DEPTH_CLEAR_VALUE"/>
+            <enum name="GL_DEPTH_FUNC"/>
+            <enum name="GL_DEPTH_RANGE"/>
+            <enum name="GL_DEPTH_SCALE"/>
+            <enum name="GL_DEPTH_TEST"/>
+            <enum name="GL_DEPTH_WRITEMASK"/>
+            <enum name="GL_DETAIL_TEXTURE_2D_BINDING_SGIS"/>
+            <enum name="GL_DISTANCE_ATTENUATION_SGIS"/>
+            <enum name="GL_DITHER"/>
+            <enum name="GL_DOUBLEBUFFER"/>
+            <enum name="GL_DRAW_BUFFER"/>
+            <enum name="GL_DRAW_BUFFER_EXT"/>
+            <enum name="GL_EDGE_FLAG"/>
+            <enum name="GL_EDGE_FLAG_ARRAY"/>
+            <enum name="GL_EDGE_FLAG_ARRAY_COUNT_EXT"/>
+            <enum name="GL_EDGE_FLAG_ARRAY_STRIDE"/>
+            <enum name="GL_FEEDBACK_BUFFER_SIZE"/>
+            <enum name="GL_FEEDBACK_BUFFER_TYPE"/>
+            <enum name="GL_FOG"/>
+            <enum name="GL_FOG_COLOR"/>
+            <enum name="GL_FOG_DENSITY"/>
+            <enum name="GL_FOG_END"/>
+            <enum name="GL_FOG_FUNC_POINTS_SGIS"/>
+            <enum name="GL_FOG_HINT"/>
+            <enum name="GL_FOG_INDEX"/>
+            <enum name="GL_FOG_MODE"/>
+            <enum name="GL_FOG_OFFSET_SGIX"/>
+            <enum name="GL_FOG_OFFSET_VALUE_SGIX"/>
+            <enum name="GL_FOG_START"/>
+            <enum name="GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX"/>
+            <enum name="GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX"/>
+            <enum name="GL_FRAGMENT_COLOR_MATERIAL_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT0_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHTING_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX"/>
+            <enum name="GL_FRAMEZOOM_FACTOR_SGIX"/>
+            <enum name="GL_FRAMEZOOM_SGIX"/>
+            <enum name="GL_FRONT_FACE"/>
+            <enum name="GL_GENERATE_MIPMAP_HINT_SGIS"/>
+            <enum name="GL_GREEN_BIAS"/>
+            <enum name="GL_GREEN_BITS"/>
+            <enum name="GL_GREEN_SCALE"/>
+            <enum name="GL_HISTOGRAM_EXT"/>
+            <enum name="GL_INDEX_ARRAY"/>
+            <enum name="GL_INDEX_ARRAY_COUNT_EXT"/>
+            <enum name="GL_INDEX_ARRAY_STRIDE"/>
+            <enum name="GL_INDEX_ARRAY_TYPE"/>
+            <enum name="GL_INDEX_BITS"/>
+            <enum name="GL_INDEX_CLEAR_VALUE"/>
+            <enum name="GL_INDEX_LOGIC_OP"/>
+            <enum name="GL_INDEX_MODE"/>
+            <enum name="GL_INDEX_OFFSET"/>
+            <enum name="GL_INDEX_SHIFT"/>
+            <enum name="GL_INDEX_WRITEMASK"/>
+            <enum name="GL_INSTRUMENT_MEASUREMENTS_SGIX"/>
+            <enum name="GL_INTERLACE_SGIX"/>
+            <enum name="GL_IR_INSTRUMENT1_SGIX"/>
+            <enum name="GL_LIGHT0"/>
+            <enum name="GL_LIGHT1"/>
+            <enum name="GL_LIGHT2"/>
+            <enum name="GL_LIGHT3"/>
+            <enum name="GL_LIGHT4"/>
+            <enum name="GL_LIGHT5"/>
+            <enum name="GL_LIGHT6"/>
+            <enum name="GL_LIGHT7"/>
+            <enum name="GL_LIGHTING"/>
+            <enum name="GL_LIGHT_ENV_MODE_SGIX"/>
+            <enum name="GL_LIGHT_MODEL_AMBIENT"/>
+            <enum name="GL_LIGHT_MODEL_COLOR_CONTROL"/>
+            <enum name="GL_LIGHT_MODEL_LOCAL_VIEWER"/>
+            <enum name="GL_LIGHT_MODEL_TWO_SIDE"/>
+            <enum name="GL_LINE_SMOOTH"/>
+            <enum name="GL_LINE_SMOOTH_HINT"/>
+            <enum name="GL_LINE_STIPPLE"/>
+            <enum name="GL_LINE_STIPPLE_PATTERN"/>
+            <enum name="GL_LINE_STIPPLE_REPEAT"/>
+            <enum name="GL_LINE_WIDTH"/>
+            <enum name="GL_LINE_WIDTH_GRANULARITY"/>
+            <enum name="GL_LINE_WIDTH_RANGE"/>
+            <enum name="GL_LIST_BASE"/>
+            <enum name="GL_LIST_INDEX"/>
+            <enum name="GL_LIST_MODE"/>
+            <enum name="GL_LOGIC_OP"/>
+            <enum name="GL_LOGIC_OP_MODE"/>
+            <enum name="GL_MAP1_COLOR_4"/>
+            <enum name="GL_MAP1_GRID_DOMAIN"/>
+            <enum name="GL_MAP1_GRID_SEGMENTS"/>
+            <enum name="GL_MAP1_INDEX"/>
+            <enum name="GL_MAP1_NORMAL"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_1"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_2"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_3"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_4"/>
+            <enum name="GL_MAP1_VERTEX_3"/>
+            <enum name="GL_MAP1_VERTEX_4"/>
+            <enum name="GL_MAP2_COLOR_4"/>
+            <enum name="GL_MAP2_GRID_DOMAIN"/>
+            <enum name="GL_MAP2_GRID_SEGMENTS"/>
+            <enum name="GL_MAP2_INDEX"/>
+            <enum name="GL_MAP2_NORMAL"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_1"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_2"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_3"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_4"/>
+            <enum name="GL_MAP2_VERTEX_3"/>
+            <enum name="GL_MAP2_VERTEX_4"/>
+            <enum name="GL_MAP_COLOR"/>
+            <enum name="GL_MAP_STENCIL"/>
+            <enum name="GL_MATRIX_MODE"/>
+            <enum name="GL_MAX_3D_TEXTURE_SIZE_EXT"/>
+            <enum name="GL_MAX_4D_TEXTURE_SIZE_SGIS"/>
+            <enum name="GL_MAX_ACTIVE_LIGHTS_SGIX"/>
+            <enum name="GL_MAX_ASYNC_DRAW_PIXELS_SGIX"/>
+            <enum name="GL_MAX_ASYNC_HISTOGRAM_SGIX"/>
+            <enum name="GL_MAX_ASYNC_READ_PIXELS_SGIX"/>
+            <enum name="GL_MAX_ASYNC_TEX_IMAGE_SGIX"/>
+            <enum name="GL_MAX_ATTRIB_STACK_DEPTH"/>
+            <enum name="GL_MAX_CLIENT_ATTRIB_STACK_DEPTH"/>
+            <enum name="GL_MAX_CLIPMAP_DEPTH_SGIX"/>
+            <enum name="GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX"/>
+            <enum name="GL_MAX_CLIP_DISTANCES"/>
+            <enum name="GL_MAX_CLIP_PLANES"/>
+            <enum name="GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI"/>
+            <enum name="GL_MAX_EVAL_ORDER"/>
+            <enum name="GL_MAX_FOG_FUNC_POINTS_SGIS"/>
+            <enum name="GL_MAX_FRAGMENT_LIGHTS_SGIX"/>
+            <enum name="GL_MAX_FRAMEZOOM_FACTOR_SGIX"/>
+            <enum name="GL_MAX_LIGHTS"/>
+            <enum name="GL_MAX_LIST_NESTING"/>
+            <enum name="GL_MAX_MODELVIEW_STACK_DEPTH"/>
+            <enum name="GL_MAX_NAME_STACK_DEPTH"/>
+            <enum name="GL_MAX_PIXEL_MAP_TABLE"/>
+            <enum name="GL_MAX_PROJECTION_STACK_DEPTH"/>
+            <enum name="GL_MAX_TEXTURE_SIZE"/>
+            <enum name="GL_MAX_TEXTURE_STACK_DEPTH"/>
+            <enum name="GL_MAX_VIEWPORT_DIMS"/>
+            <enum name="GL_MINMAX_EXT"/>
+            <enum name="GL_MODELVIEW0_MATRIX_EXT"/>
+            <enum name="GL_MODELVIEW0_STACK_DEPTH_EXT"/>
+            <enum name="GL_MODELVIEW_MATRIX"/>
+            <enum name="GL_MODELVIEW_STACK_DEPTH"/>
+            <enum name="GL_MULTISAMPLE_SGIS"/>
+            <enum name="GL_NAME_STACK_DEPTH"/>
+            <enum name="GL_NORMALIZE"/>
+            <enum name="GL_NORMAL_ARRAY"/>
+            <enum name="GL_NORMAL_ARRAY_COUNT_EXT"/>
+            <enum name="GL_NORMAL_ARRAY_STRIDE"/>
+            <enum name="GL_NORMAL_ARRAY_TYPE"/>
+            <enum name="GL_PACK_ALIGNMENT"/>
+            <enum name="GL_PACK_CMYK_HINT_EXT"/>
+            <enum name="GL_PACK_IMAGE_DEPTH_SGIS"/>
+            <enum name="GL_PACK_IMAGE_HEIGHT_EXT"/>
+            <enum name="GL_PACK_LSB_FIRST"/>
+            <enum name="GL_PACK_RESAMPLE_SGIX"/>
+            <enum name="GL_PACK_ROW_LENGTH"/>
+            <enum name="GL_PACK_SKIP_IMAGES_EXT"/>
+            <enum name="GL_PACK_SKIP_PIXELS"/>
+            <enum name="GL_PACK_SKIP_ROWS"/>
+            <enum name="GL_PACK_SKIP_VOLUMES_SGIS"/>
+            <enum name="GL_PACK_SUBSAMPLE_RATE_SGIX"/>
+            <enum name="GL_PACK_SWAP_BYTES"/>
+            <enum name="GL_PERSPECTIVE_CORRECTION_HINT"/>
+            <enum name="GL_PIXEL_MAP_A_TO_A_SIZE"/>
+            <enum name="GL_PIXEL_MAP_B_TO_B_SIZE"/>
+            <enum name="GL_PIXEL_MAP_G_TO_G_SIZE"/>
+            <enum name="GL_PIXEL_MAP_I_TO_A_SIZE"/>
+            <enum name="GL_PIXEL_MAP_I_TO_B_SIZE"/>
+            <enum name="GL_PIXEL_MAP_I_TO_G_SIZE"/>
+            <enum name="GL_PIXEL_MAP_I_TO_I_SIZE"/>
+            <enum name="GL_PIXEL_MAP_I_TO_R_SIZE"/>
+            <enum name="GL_PIXEL_MAP_R_TO_R_SIZE"/>
+            <enum name="GL_PIXEL_MAP_S_TO_S_SIZE"/>
+            <enum name="GL_PIXEL_TEXTURE_SGIS"/>
+            <enum name="GL_PIXEL_TEX_GEN_MODE_SGIX"/>
+            <enum name="GL_PIXEL_TEX_GEN_SGIX"/>
+            <enum name="GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX"/>
+            <enum name="GL_PIXEL_TILE_CACHE_INCREMENT_SGIX"/>
+            <enum name="GL_PIXEL_TILE_CACHE_SIZE_SGIX"/>
+            <enum name="GL_PIXEL_TILE_GRID_DEPTH_SGIX"/>
+            <enum name="GL_PIXEL_TILE_GRID_HEIGHT_SGIX"/>
+            <enum name="GL_PIXEL_TILE_GRID_WIDTH_SGIX"/>
+            <enum name="GL_PIXEL_TILE_HEIGHT_SGIX"/>
+            <enum name="GL_PIXEL_TILE_WIDTH_SGIX"/>
+            <enum name="GL_POINT_FADE_THRESHOLD_SIZE_SGIS"/>
+            <enum name="GL_POINT_SIZE"/>
+            <enum name="GL_POINT_SIZE_GRANULARITY"/>
+            <enum name="GL_POINT_SIZE_MAX_SGIS"/>
+            <enum name="GL_POINT_SIZE_MIN_SGIS"/>
+            <enum name="GL_POINT_SIZE_RANGE"/>
+            <enum name="GL_POINT_SMOOTH"/>
+            <enum name="GL_POINT_SMOOTH_HINT"/>
+            <enum name="GL_POLYGON_MODE"/>
+            <enum name="GL_POLYGON_OFFSET_BIAS_EXT"/>
+            <enum name="GL_POLYGON_OFFSET_FACTOR"/>
+            <enum name="GL_POLYGON_OFFSET_FILL"/>
+            <enum name="GL_POLYGON_OFFSET_LINE"/>
+            <enum name="GL_POLYGON_OFFSET_POINT"/>
+            <enum name="GL_POLYGON_OFFSET_UNITS"/>
+            <enum name="GL_POLYGON_SMOOTH"/>
+            <enum name="GL_POLYGON_SMOOTH_HINT"/>
+            <enum name="GL_POLYGON_STIPPLE"/>
+            <enum name="GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI"/>
+            <enum name="GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI"/>
+            <enum name="GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI"/>
+            <enum name="GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI"/>
+            <enum name="GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI"/>
+            <enum name="GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI"/>
+            <enum name="GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI"/>
+            <enum name="GL_POST_COLOR_MATRIX_RED_BIAS_SGI"/>
+            <enum name="GL_POST_COLOR_MATRIX_RED_SCALE_SGI"/>
+            <enum name="GL_POST_CONVOLUTION_ALPHA_BIAS_EXT"/>
+            <enum name="GL_POST_CONVOLUTION_ALPHA_SCALE_EXT"/>
+            <enum name="GL_POST_CONVOLUTION_BLUE_BIAS_EXT"/>
+            <enum name="GL_POST_CONVOLUTION_BLUE_SCALE_EXT"/>
+            <enum name="GL_POST_CONVOLUTION_COLOR_TABLE_SGI"/>
+            <enum name="GL_POST_CONVOLUTION_GREEN_BIAS_EXT"/>
+            <enum name="GL_POST_CONVOLUTION_GREEN_SCALE_EXT"/>
+            <enum name="GL_POST_CONVOLUTION_RED_BIAS_EXT"/>
+            <enum name="GL_POST_CONVOLUTION_RED_SCALE_EXT"/>
+            <enum name="GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX"/>
+            <enum name="GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX"/>
+            <enum name="GL_PRIMITIVE_BOUNDING_BOX_EXT"/>
+            <enum name="GL_PROJECTION_MATRIX"/>
+            <enum name="GL_PROJECTION_STACK_DEPTH"/>
+            <enum name="GL_READ_BUFFER"/>
+            <enum name="GL_READ_BUFFER_EXT"/>
+            <enum name="GL_READ_BUFFER_NV"/>
+            <enum name="GL_RED_BIAS"/>
+            <enum name="GL_RED_BITS"/>
+            <enum name="GL_RED_SCALE"/>
+            <enum name="GL_REFERENCE_PLANE_EQUATION_SGIX"/>
+            <enum name="GL_REFERENCE_PLANE_SGIX"/>
+            <enum name="GL_RENDER_MODE"/>
+            <enum name="GL_RESCALE_NORMAL_EXT"/>
+            <enum name="GL_RGBA_MODE"/>
+            <enum name="GL_SAMPLES_SGIS"/>
+            <enum name="GL_SAMPLE_ALPHA_TO_MASK_SGIS"/>
+            <enum name="GL_SAMPLE_ALPHA_TO_ONE_SGIS"/>
+            <enum name="GL_SAMPLE_BUFFERS_SGIS"/>
+            <enum name="GL_SAMPLE_MASK_INVERT_SGIS"/>
+            <enum name="GL_SAMPLE_MASK_SGIS"/>
+            <enum name="GL_SAMPLE_MASK_VALUE_SGIS"/>
+            <enum name="GL_SAMPLE_PATTERN_SGIS"/>
+            <enum name="GL_SCISSOR_BOX"/>
+            <enum name="GL_SCISSOR_TEST"/>
+            <enum name="GL_SELECTION_BUFFER_SIZE"/>
+            <enum name="GL_SEPARABLE_2D_EXT"/>
+            <enum name="GL_SHADE_MODEL"/>
+            <enum name="GL_SHARED_TEXTURE_PALETTE_EXT"/>
+            <enum name="GL_SMOOTH_LINE_WIDTH_GRANULARITY"/>
+            <enum name="GL_SMOOTH_LINE_WIDTH_RANGE"/>
+            <enum name="GL_SMOOTH_POINT_SIZE_GRANULARITY"/>
+            <enum name="GL_SMOOTH_POINT_SIZE_RANGE"/>
+            <enum name="GL_SPRITE_AXIS_SGIX"/>
+            <enum name="GL_SPRITE_MODE_SGIX"/>
+            <enum name="GL_SPRITE_SGIX"/>
+            <enum name="GL_SPRITE_TRANSLATION_SGIX"/>
+            <enum name="GL_STENCIL_BITS"/>
+            <enum name="GL_STENCIL_CLEAR_VALUE"/>
+            <enum name="GL_STENCIL_FAIL"/>
+            <enum name="GL_STENCIL_FUNC"/>
+            <enum name="GL_STENCIL_PASS_DEPTH_FAIL"/>
+            <enum name="GL_STENCIL_PASS_DEPTH_PASS"/>
+            <enum name="GL_STENCIL_REF"/>
+            <enum name="GL_STENCIL_TEST"/>
+            <enum name="GL_STENCIL_VALUE_MASK"/>
+            <enum name="GL_STENCIL_WRITEMASK"/>
+            <enum name="GL_STEREO"/>
+            <enum name="GL_SUBPIXEL_BITS"/>
+            <enum name="GL_TEXTURE_1D"/>
+            <enum name="GL_TEXTURE_2D"/>
+            <enum name="GL_TEXTURE_3D_BINDING_EXT"/>
+            <enum name="GL_TEXTURE_3D_EXT"/>
+            <enum name="GL_TEXTURE_4D_BINDING_SGIS"/>
+            <enum name="GL_TEXTURE_4D_SGIS"/>
+            <enum name="GL_TEXTURE_BINDING_1D"/>
+            <enum name="GL_TEXTURE_BINDING_2D"/>
+            <enum name="GL_TEXTURE_BINDING_3D"/>
+            <enum name="GL_TEXTURE_COLOR_TABLE_SGI"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_COUNT_EXT"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_SIZE"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_STRIDE"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_TYPE"/>
+            <enum name="GL_TEXTURE_GEN_Q"/>
+            <enum name="GL_TEXTURE_GEN_R"/>
+            <enum name="GL_TEXTURE_GEN_S"/>
+            <enum name="GL_TEXTURE_GEN_T"/>
+            <enum name="GL_TEXTURE_MATRIX"/>
+            <enum name="GL_TEXTURE_STACK_DEPTH"/>
+            <enum name="GL_UNPACK_ALIGNMENT"/>
+            <enum name="GL_UNPACK_CMYK_HINT_EXT"/>
+            <enum name="GL_UNPACK_IMAGE_DEPTH_SGIS"/>
+            <enum name="GL_UNPACK_IMAGE_HEIGHT_EXT"/>
+            <enum name="GL_UNPACK_LSB_FIRST"/>
+            <enum name="GL_UNPACK_RESAMPLE_SGIX"/>
+            <enum name="GL_UNPACK_ROW_LENGTH"/>
+            <enum name="GL_UNPACK_SKIP_IMAGES_EXT"/>
+            <enum name="GL_UNPACK_SKIP_PIXELS"/>
+            <enum name="GL_UNPACK_SKIP_ROWS"/>
+            <enum name="GL_UNPACK_SKIP_VOLUMES_SGIS"/>
+            <enum name="GL_UNPACK_SUBSAMPLE_RATE_SGIX"/>
+            <enum name="GL_UNPACK_SWAP_BYTES"/>
+            <enum name="GL_VERTEX_ARRAY"/>
+            <enum name="GL_VERTEX_ARRAY_COUNT_EXT"/>
+            <enum name="GL_VERTEX_ARRAY_SIZE"/>
+            <enum name="GL_VERTEX_ARRAY_STRIDE"/>
+            <enum name="GL_VERTEX_ARRAY_TYPE"/>
+            <enum name="GL_VERTEX_PRECLIP_HINT_SGIX"/>
+            <enum name="GL_VERTEX_PRECLIP_SGIX"/>
+            <enum name="GL_VIEWPORT"/>
+            <enum name="GL_ZOOM_X"/>
+            <enum name="GL_ZOOM_Y"/>
+        </group>
+
+        <group name="GetPointervPName">
+            <enum name="GL_COLOR_ARRAY_POINTER"/>
+            <enum name="GL_COLOR_ARRAY_POINTER_EXT"/>
+            <enum name="GL_EDGE_FLAG_ARRAY_POINTER"/>
+            <enum name="GL_EDGE_FLAG_ARRAY_POINTER_EXT"/>
+            <enum name="GL_FEEDBACK_BUFFER_POINTER"/>
+            <enum name="GL_INDEX_ARRAY_POINTER"/>
+            <enum name="GL_INDEX_ARRAY_POINTER_EXT"/>
+            <enum name="GL_INSTRUMENT_BUFFER_POINTER_SGIX"/>
+            <enum name="GL_NORMAL_ARRAY_POINTER"/>
+            <enum name="GL_NORMAL_ARRAY_POINTER_EXT"/>
+            <enum name="GL_SELECTION_BUFFER_POINTER"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_POINTER"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_POINTER_EXT"/>
+            <enum name="GL_VERTEX_ARRAY_POINTER"/>
+            <enum name="GL_VERTEX_ARRAY_POINTER_EXT"/>
+        </group>
+
+        <group name="GetTextureParameter">
+            <enum name="GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS"/>
+            <enum name="GL_DETAIL_TEXTURE_LEVEL_SGIS"/>
+            <enum name="GL_DETAIL_TEXTURE_MODE_SGIS"/>
+            <enum name="GL_DUAL_TEXTURE_SELECT_SGIS"/>
+            <enum name="GL_GENERATE_MIPMAP_SGIS"/>
+            <enum name="GL_POST_TEXTURE_FILTER_BIAS_SGIX"/>
+            <enum name="GL_POST_TEXTURE_FILTER_SCALE_SGIX"/>
+            <enum name="GL_QUAD_TEXTURE_SELECT_SGIS"/>
+            <enum name="GL_SHADOW_AMBIENT_SGIX"/>
+            <enum name="GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS"/>
+            <enum name="GL_TEXTURE_4DSIZE_SGIS"/>
+            <enum name="GL_TEXTURE_ALPHA_SIZE"/>
+            <enum name="GL_TEXTURE_BASE_LEVEL_SGIS"/>
+            <enum name="GL_TEXTURE_BLUE_SIZE"/>
+            <enum name="GL_TEXTURE_BORDER"/>
+            <enum name="GL_TEXTURE_BORDER_COLOR"/>
+            <enum name="GL_TEXTURE_BORDER_COLOR_NV"/>
+            <enum name="GL_TEXTURE_CLIPMAP_CENTER_SGIX"/>
+            <enum name="GL_TEXTURE_CLIPMAP_DEPTH_SGIX"/>
+            <enum name="GL_TEXTURE_CLIPMAP_FRAME_SGIX"/>
+            <enum name="GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX"/>
+            <enum name="GL_TEXTURE_CLIPMAP_OFFSET_SGIX"/>
+            <enum name="GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX"/>
+            <enum name="GL_TEXTURE_COMPARE_OPERATOR_SGIX"/>
+            <enum name="GL_TEXTURE_COMPARE_SGIX"/>
+            <enum name="GL_TEXTURE_COMPONENTS"/>
+            <enum name="GL_TEXTURE_DEPTH_EXT"/>
+            <enum name="GL_TEXTURE_FILTER4_SIZE_SGIS"/>
+            <enum name="GL_TEXTURE_GEQUAL_R_SGIX"/>
+            <enum name="GL_TEXTURE_GREEN_SIZE"/>
+            <enum name="GL_TEXTURE_HEIGHT"/>
+            <enum name="GL_TEXTURE_INTENSITY_SIZE"/>
+            <enum name="GL_TEXTURE_INTERNAL_FORMAT"/>
+            <enum name="GL_TEXTURE_LEQUAL_R_SGIX"/>
+            <enum name="GL_TEXTURE_LOD_BIAS_R_SGIX"/>
+            <enum name="GL_TEXTURE_LOD_BIAS_S_SGIX"/>
+            <enum name="GL_TEXTURE_LOD_BIAS_T_SGIX"/>
+            <enum name="GL_TEXTURE_LUMINANCE_SIZE"/>
+            <enum name="GL_TEXTURE_MAG_FILTER"/>
+            <enum name="GL_TEXTURE_MAX_CLAMP_R_SGIX"/>
+            <enum name="GL_TEXTURE_MAX_CLAMP_S_SGIX"/>
+            <enum name="GL_TEXTURE_MAX_CLAMP_T_SGIX"/>
+            <enum name="GL_TEXTURE_MAX_LEVEL_SGIS"/>
+            <enum name="GL_TEXTURE_MAX_LOD_SGIS"/>
+            <enum name="GL_TEXTURE_MIN_FILTER"/>
+            <enum name="GL_TEXTURE_MIN_LOD_SGIS"/>
+            <enum name="GL_TEXTURE_PRIORITY"/>
+            <enum name="GL_TEXTURE_RED_SIZE"/>
+            <enum name="GL_TEXTURE_RESIDENT"/>
+            <enum name="GL_TEXTURE_WIDTH"/>
+            <enum name="GL_TEXTURE_WRAP_Q_SGIS"/>
+            <enum name="GL_TEXTURE_WRAP_R_EXT"/>
+            <enum name="GL_TEXTURE_WRAP_S"/>
+            <enum name="GL_TEXTURE_WRAP_T"/>
+        </group>
+
+        <group name="HintMode">
+            <enum name="GL_DONT_CARE"/>
+            <enum name="GL_FASTEST"/>
+            <enum name="GL_NICEST"/>
+        </group>
+
+        <group name="HintTarget">
+            <enum name="GL_ALLOW_DRAW_FRG_HINT_PGI"/>
+            <enum name="GL_ALLOW_DRAW_MEM_HINT_PGI"/>
+            <enum name="GL_ALLOW_DRAW_OBJ_HINT_PGI"/>
+            <enum name="GL_ALLOW_DRAW_WIN_HINT_PGI"/>
+            <enum name="GL_ALWAYS_FAST_HINT_PGI"/>
+            <enum name="GL_ALWAYS_SOFT_HINT_PGI"/>
+            <enum name="GL_BACK_NORMALS_HINT_PGI"/>
+            <enum name="GL_BINNING_CONTROL_HINT_QCOM"/>
+            <enum name="GL_CLIP_FAR_HINT_PGI"/>
+            <enum name="GL_CLIP_NEAR_HINT_PGI"/>
+            <enum name="GL_CLIP_VOLUME_CLIPPING_HINT_EXT"/>
+            <enum name="GL_CONSERVE_MEMORY_HINT_PGI"/>
+            <enum name="GL_CONVOLUTION_HINT_SGIX"/>
+            <enum name="GL_FOG_HINT"/>
+            <enum name="GL_FRAGMENT_SHADER_DERIVATIVE_HINT"/>
+            <enum name="GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB"/>
+            <enum name="GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES"/>
+            <enum name="GL_FULL_STIPPLE_HINT_PGI"/>
+            <enum name="GL_GENERATE_MIPMAP_HINT"/>
+            <enum name="GL_GENERATE_MIPMAP_HINT_SGIS"/>
+            <enum name="GL_LINE_QUALITY_HINT_SGIX"/>
+            <enum name="GL_LINE_SMOOTH_HINT"/>
+            <enum name="GL_MATERIAL_SIDE_HINT_PGI"/>
+            <enum name="GL_MAX_VERTEX_HINT_PGI"/>
+            <enum name="GL_MULTISAMPLE_FILTER_HINT_NV"/>
+            <enum name="GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI"/>
+            <enum name="GL_NATIVE_GRAPHICS_END_HINT_PGI"/>
+            <enum name="GL_PACK_CMYK_HINT_EXT"/>
+            <enum name="GL_PERSPECTIVE_CORRECTION_HINT"/>
+            <enum name="GL_PHONG_HINT_WIN"/>
+            <enum name="GL_POINT_SMOOTH_HINT"/>
+            <enum name="GL_POLYGON_SMOOTH_HINT"/>
+            <enum name="GL_PREFER_DOUBLEBUFFER_HINT_PGI"/>
+            <enum name="GL_PROGRAM_BINARY_RETRIEVABLE_HINT"/>
+            <enum name="GL_RECLAIM_MEMORY_HINT_PGI"/>
+            <enum name="GL_SCALEBIAS_HINT_SGIX"/>
+            <enum name="GL_STRICT_DEPTHFUNC_HINT_PGI"/>
+            <enum name="GL_STRICT_LIGHTING_HINT_PGI"/>
+            <enum name="GL_STRICT_SCISSOR_HINT_PGI"/>
+            <enum name="GL_TEXTURE_COMPRESSION_HINT"/>
+            <enum name="GL_TEXTURE_COMPRESSION_HINT_ARB"/>
+            <enum name="GL_TEXTURE_MULTI_BUFFER_HINT_SGIX"/>
+            <enum name="GL_TEXTURE_STORAGE_HINT_APPLE"/>
+            <enum name="GL_TRANSFORM_HINT_APPLE"/>
+            <enum name="GL_UNPACK_CMYK_HINT_EXT"/>
+            <enum name="GL_VERTEX_ARRAY_STORAGE_HINT_APPLE"/>
+            <enum name="GL_VERTEX_CONSISTENT_HINT_PGI"/>
+            <enum name="GL_VERTEX_DATA_HINT_PGI"/>
+            <enum name="GL_VERTEX_PRECLIP_HINT_SGIX"/>
+            <enum name="GL_VERTEX_PRECLIP_SGIX"/>
+            <enum name="GL_WIDE_LINE_HINT_PGI"/>
+        </group>
+
+        <group name="HistogramTargetEXT">
+            <enum name="GL_HISTOGRAM"/>
+            <enum name="GL_HISTOGRAM_EXT"/>
+            <enum name="GL_PROXY_HISTOGRAM"/>
+            <enum name="GL_PROXY_HISTOGRAM_EXT"/>
+        </group>
+
+        <group name="IndexPointerType">
+            <enum name="GL_DOUBLE"/>
+            <enum name="GL_FLOAT"/>
+            <enum name="GL_INT"/>
+            <enum name="GL_SHORT"/>
+        </group>
+
+        <group name="InterleavedArrayFormat">
+            <enum name="GL_C3F_V3F"/>
+            <enum name="GL_C4F_N3F_V3F"/>
+            <enum name="GL_C4UB_V2F"/>
+            <enum name="GL_C4UB_V3F"/>
+            <enum name="GL_N3F_V3F"/>
+            <enum name="GL_T2F_C3F_V3F"/>
+            <enum name="GL_T2F_C4F_N3F_V3F"/>
+            <enum name="GL_T2F_C4UB_V3F"/>
+            <enum name="GL_T2F_N3F_V3F"/>
+            <enum name="GL_T2F_V3F"/>
+            <enum name="GL_T4F_C4F_N3F_V4F"/>
+            <enum name="GL_T4F_V4F"/>
+            <enum name="GL_V2F"/>
+            <enum name="GL_V3F"/>
+        </group>
+
+        <group name="LightEnvModeSGIX">
+            <enum name="GL_ADD"/>
+            <enum name="GL_MODULATE"/>
+            <enum name="GL_REPLACE"/>
+        </group>
+
+        <group name="LightEnvParameterSGIX">
+            <enum name="GL_LIGHT_ENV_MODE_SGIX"/>
+        </group>
+
+        <group name="LightModelColorControl">
+            <enum name="GL_SEPARATE_SPECULAR_COLOR"/>
+            <enum name="GL_SEPARATE_SPECULAR_COLOR_EXT"/>
+            <enum name="GL_SINGLE_COLOR"/>
+            <enum name="GL_SINGLE_COLOR_EXT"/>
+        </group>
+
+        <group name="LightModelParameter">
+            <enum name="GL_LIGHT_MODEL_AMBIENT"/>
+            <enum name="GL_LIGHT_MODEL_COLOR_CONTROL"/>
+            <enum name="GL_LIGHT_MODEL_COLOR_CONTROL_EXT"/>
+            <enum name="GL_LIGHT_MODEL_LOCAL_VIEWER"/>
+            <enum name="GL_LIGHT_MODEL_TWO_SIDE"/>
+        </group>
+
+        <group name="LightName">
+            <enum name="GL_FRAGMENT_LIGHT0_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT1_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT2_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT3_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT4_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT5_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT6_SGIX"/>
+            <enum name="GL_FRAGMENT_LIGHT7_SGIX"/>
+            <enum name="GL_LIGHT0"/>
+            <enum name="GL_LIGHT1"/>
+            <enum name="GL_LIGHT2"/>
+            <enum name="GL_LIGHT3"/>
+            <enum name="GL_LIGHT4"/>
+            <enum name="GL_LIGHT5"/>
+            <enum name="GL_LIGHT6"/>
+            <enum name="GL_LIGHT7"/>
+        </group>
+
+        <group name="LightParameter">
+            <enum name="GL_AMBIENT"/>
+            <enum name="GL_CONSTANT_ATTENUATION"/>
+            <enum name="GL_DIFFUSE"/>
+            <enum name="GL_LINEAR_ATTENUATION"/>
+            <enum name="GL_POSITION"/>
+            <enum name="GL_QUADRATIC_ATTENUATION"/>
+            <enum name="GL_SPECULAR"/>
+            <enum name="GL_SPOT_CUTOFF"/>
+            <enum name="GL_SPOT_DIRECTION"/>
+            <enum name="GL_SPOT_EXPONENT"/>
+        </group>
+
+        <group name="ListMode">
+            <enum name="GL_COMPILE"/>
+            <enum name="GL_COMPILE_AND_EXECUTE"/>
+        </group>
+
+        <group name="ListNameType">
+            <enum name="GL_2_BYTES"/>
+            <enum name="GL_3_BYTES"/>
+            <enum name="GL_4_BYTES"/>
+            <enum name="GL_BYTE"/>
+            <enum name="GL_FLOAT"/>
+            <enum name="GL_INT"/>
+            <enum name="GL_SHORT"/>
+            <enum name="GL_UNSIGNED_BYTE"/>
+            <enum name="GL_UNSIGNED_INT"/>
+            <enum name="GL_UNSIGNED_SHORT"/>
+        </group>
+
+        <group name="ListParameterName">
+            <enum name="GL_LIST_PRIORITY_SGIX"/>
+        </group>
+
+        <group name="LogicOp">
+            <enum name="GL_AND"/>
+            <enum name="GL_AND_INVERTED"/>
+            <enum name="GL_AND_REVERSE"/>
+            <enum name="GL_CLEAR"/>
+            <enum name="GL_COPY"/>
+            <enum name="GL_COPY_INVERTED"/>
+            <enum name="GL_EQUIV"/>
+            <enum name="GL_INVERT"/>
+            <enum name="GL_NAND"/>
+            <enum name="GL_NOOP"/>
+            <enum name="GL_NOR"/>
+            <enum name="GL_OR"/>
+            <enum name="GL_OR_INVERTED"/>
+            <enum name="GL_OR_REVERSE"/>
+            <enum name="GL_SET"/>
+            <enum name="GL_XOR"/>
+        </group>
+
+        <group name="MapBufferUsageMask">
+            <enum name="GL_CLIENT_STORAGE_BIT"/>
+            <enum name="GL_DYNAMIC_STORAGE_BIT"/>
+            <enum name="GL_MAP_COHERENT_BIT"/>
+            <enum name="GL_MAP_FLUSH_EXPLICIT_BIT"/>
+            <enum name="GL_MAP_FLUSH_EXPLICIT_BIT_EXT"/>
+            <enum name="GL_MAP_INVALIDATE_BUFFER_BIT"/>
+            <enum name="GL_MAP_INVALIDATE_BUFFER_BIT_EXT"/>
+            <enum name="GL_MAP_INVALIDATE_RANGE_BIT"/>
+            <enum name="GL_MAP_INVALIDATE_RANGE_BIT_EXT"/>
+            <enum name="GL_MAP_PERSISTENT_BIT"/>
+            <enum name="GL_MAP_READ_BIT"/>
+            <enum name="GL_MAP_READ_BIT_EXT"/>
+            <enum name="GL_MAP_UNSYNCHRONIZED_BIT"/>
+            <enum name="GL_MAP_UNSYNCHRONIZED_BIT_EXT"/>
+            <enum name="GL_MAP_WRITE_BIT"/>
+            <enum name="GL_MAP_WRITE_BIT_EXT"/>
+        </group>
+
+        <group name="MapTarget">
+            <enum name="GL_GEOMETRY_DEFORMATION_SGIX"/>
+            <enum name="GL_MAP1_COLOR_4"/>
+            <enum name="GL_MAP1_INDEX"/>
+            <enum name="GL_MAP1_NORMAL"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_1"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_2"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_3"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_4"/>
+            <enum name="GL_MAP1_VERTEX_3"/>
+            <enum name="GL_MAP1_VERTEX_4"/>
+            <enum name="GL_MAP2_COLOR_4"/>
+            <enum name="GL_MAP2_INDEX"/>
+            <enum name="GL_MAP2_NORMAL"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_1"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_2"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_3"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_4"/>
+            <enum name="GL_MAP2_VERTEX_3"/>
+            <enum name="GL_MAP2_VERTEX_4"/>
+            <enum name="GL_TEXTURE_DEFORMATION_SGIX"/>
+        </group>
+
+        <group name="MapTextureFormatINTEL">
+            <enum name="GL_LAYOUT_DEFAULT_INTEL"/>
+            <enum name="GL_LAYOUT_LINEAR_CPU_CACHED_INTEL"/>
+            <enum name="GL_LAYOUT_LINEAR_INTEL"/>
+        </group>
+
+        <group name="MaterialFace">
+            <enum name="GL_BACK"/>
+            <enum name="GL_FRONT"/>
+            <enum name="GL_FRONT_AND_BACK"/>
+        </group>
+
+        <group name="MaterialParameter">
+            <enum name="GL_AMBIENT"/>
+            <enum name="GL_AMBIENT_AND_DIFFUSE"/>
+            <enum name="GL_COLOR_INDEXES"/>
+            <enum name="GL_DIFFUSE"/>
+            <enum name="GL_EMISSION"/>
+            <enum name="GL_SHININESS"/>
+            <enum name="GL_SPECULAR"/>
+        </group>
+
+        <group name="MatrixMode">
+            <enum name="GL_MODELVIEW"/>
+            <enum name="GL_MODELVIEW0_EXT"/>
+            <enum name="GL_PROJECTION"/>
+            <enum name="GL_TEXTURE"/>
+        </group>
+
+        <group name="MemoryBarrierMask">
+            <enum name="GL_ALL_BARRIER_BITS"/>
+            <enum name="GL_ALL_BARRIER_BITS_EXT"/>
+            <enum name="GL_ATOMIC_COUNTER_BARRIER_BIT"/>
+            <enum name="GL_ATOMIC_COUNTER_BARRIER_BIT_EXT"/>
+            <enum name="GL_BUFFER_UPDATE_BARRIER_BIT"/>
+            <enum name="GL_BUFFER_UPDATE_BARRIER_BIT_EXT"/>
+            <enum name="GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT"/>
+            <enum name="GL_COMMAND_BARRIER_BIT"/>
+            <enum name="GL_COMMAND_BARRIER_BIT_EXT"/>
+            <enum name="GL_ELEMENT_ARRAY_BARRIER_BIT"/>
+            <enum name="GL_ELEMENT_ARRAY_BARRIER_BIT_EXT"/>
+            <enum name="GL_FRAMEBUFFER_BARRIER_BIT"/>
+            <enum name="GL_FRAMEBUFFER_BARRIER_BIT_EXT"/>
+            <enum name="GL_PIXEL_BUFFER_BARRIER_BIT"/>
+            <enum name="GL_PIXEL_BUFFER_BARRIER_BIT_EXT"/>
+            <enum name="GL_QUERY_BUFFER_BARRIER_BIT"/>
+            <enum name="GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV"/>
+            <enum name="GL_SHADER_IMAGE_ACCESS_BARRIER_BIT"/>
+            <enum name="GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT"/>
+            <enum name="GL_SHADER_STORAGE_BARRIER_BIT"/>
+            <enum name="GL_TEXTURE_FETCH_BARRIER_BIT"/>
+            <enum name="GL_TEXTURE_FETCH_BARRIER_BIT_EXT"/>
+            <enum name="GL_TEXTURE_UPDATE_BARRIER_BIT"/>
+            <enum name="GL_TEXTURE_UPDATE_BARRIER_BIT_EXT"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BARRIER_BIT"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT"/>
+            <enum name="GL_UNIFORM_BARRIER_BIT"/>
+            <enum name="GL_UNIFORM_BARRIER_BIT_EXT"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT"/>
+        </group>
+
+        <group name="MeshMode1">
+            <enum name="GL_LINE"/>
+            <enum name="GL_POINT"/>
+        </group>
+
+        <group name="MeshMode2">
+            <enum name="GL_FILL"/>
+            <enum name="GL_LINE"/>
+            <enum name="GL_POINT"/>
+        </group>
+
+        <group name="MinmaxTargetEXT">
+            <enum name="GL_MINMAX"/>
+            <enum name="GL_MINMAX_EXT"/>
+        </group>
+
+        <group name="NormalPointerType">
+            <enum name="GL_BYTE"/>
+            <enum name="GL_DOUBLE"/>
+            <enum name="GL_FLOAT"/>
+            <enum name="GL_INT"/>
+            <enum name="GL_SHORT"/>
+        </group>
+
+        <group name="PixelCopyType">
+            <enum name="GL_COLOR"/>
+            <enum name="GL_COLOR_EXT"/>
+            <enum name="GL_DEPTH"/>
+            <enum name="GL_DEPTH_EXT"/>
+            <enum name="GL_STENCIL"/>
+            <enum name="GL_STENCIL_EXT"/>
+        </group>
+
+        <group name="PixelFormat">
+            <enum name="GL_ABGR_EXT"/>
+            <enum name="GL_ALPHA"/>
+            <enum name="GL_BLUE"/>
+            <enum name="GL_CMYKA_EXT"/>
+            <enum name="GL_CMYK_EXT"/>
+            <enum name="GL_COLOR_INDEX"/>
+            <enum name="GL_DEPTH_COMPONENT"/>
+            <enum name="GL_GREEN"/>
+            <enum name="GL_LUMINANCE"/>
+            <enum name="GL_LUMINANCE_ALPHA"/>
+            <enum name="GL_RED"/>
+            <enum name="GL_RED_EXT"/>
+            <enum name="GL_RGB"/>
+            <enum name="GL_RGBA"/>
+            <enum name="GL_STENCIL_INDEX"/>
+            <enum name="GL_UNSIGNED_INT"/>
+            <enum name="GL_UNSIGNED_SHORT"/>
+            <enum name="GL_YCRCB_422_SGIX"/>
+            <enum name="GL_YCRCB_444_SGIX"/>
+        </group>
+
+        <group name="InternalFormat" comment="Was PixelInternalFormat">
+            <enum name="GL_ALPHA12"/>
+            <enum name="GL_ALPHA16"/>
+            <enum name="GL_ALPHA16_ICC_SGIX"/>
+            <enum name="GL_ALPHA4"/>
+            <enum name="GL_ALPHA8"/>
+            <enum name="GL_ALPHA_ICC_SGIX"/>
+            <enum name="GL_DEPTH_COMPONENT16_SGIX"/>
+            <enum name="GL_DEPTH_COMPONENT24_SGIX"/>
+            <enum name="GL_DEPTH_COMPONENT32_SGIX"/>
+            <enum name="GL_DUAL_ALPHA12_SGIS"/>
+            <enum name="GL_DUAL_ALPHA16_SGIS"/>
+            <enum name="GL_DUAL_ALPHA4_SGIS"/>
+            <enum name="GL_DUAL_ALPHA8_SGIS"/>
+            <enum name="GL_DUAL_INTENSITY12_SGIS"/>
+            <enum name="GL_DUAL_INTENSITY16_SGIS"/>
+            <enum name="GL_DUAL_INTENSITY4_SGIS"/>
+            <enum name="GL_DUAL_INTENSITY8_SGIS"/>
+            <enum name="GL_DUAL_LUMINANCE12_SGIS"/>
+            <enum name="GL_DUAL_LUMINANCE16_SGIS"/>
+            <enum name="GL_DUAL_LUMINANCE4_SGIS"/>
+            <enum name="GL_DUAL_LUMINANCE8_SGIS"/>
+            <enum name="GL_DUAL_LUMINANCE_ALPHA4_SGIS"/>
+            <enum name="GL_DUAL_LUMINANCE_ALPHA8_SGIS"/>
+            <enum name="GL_INTENSITY"/>
+            <enum name="GL_INTENSITY12"/>
+            <enum name="GL_INTENSITY16"/>
+            <enum name="GL_INTENSITY16_ICC_SGIX"/>
+            <enum name="GL_INTENSITY4"/>
+            <enum name="GL_INTENSITY8"/>
+            <enum name="GL_INTENSITY_ICC_SGIX"/>
+            <enum name="GL_LUMINANCE12"/>
+            <enum name="GL_LUMINANCE12_ALPHA12"/>
+            <enum name="GL_LUMINANCE12_ALPHA4"/>
+            <enum name="GL_LUMINANCE16"/>
+            <enum name="GL_LUMINANCE16_ALPHA16"/>
+            <enum name="GL_LUMINANCE16_ALPHA8_ICC_SGIX"/>
+            <enum name="GL_LUMINANCE16_ICC_SGIX"/>
+            <enum name="GL_LUMINANCE4"/>
+            <enum name="GL_LUMINANCE4_ALPHA4"/>
+            <enum name="GL_LUMINANCE6_ALPHA2"/>
+            <enum name="GL_LUMINANCE8"/>
+            <enum name="GL_LUMINANCE8_ALPHA8"/>
+            <enum name="GL_LUMINANCE_ALPHA_ICC_SGIX"/>
+            <enum name="GL_LUMINANCE_ICC_SGIX"/>
+            <enum name="GL_QUAD_ALPHA4_SGIS"/>
+            <enum name="GL_QUAD_ALPHA8_SGIS"/>
+            <enum name="GL_QUAD_INTENSITY4_SGIS"/>
+            <enum name="GL_QUAD_INTENSITY8_SGIS"/>
+            <enum name="GL_QUAD_LUMINANCE4_SGIS"/>
+            <enum name="GL_QUAD_LUMINANCE8_SGIS"/>
+            <enum name="GL_R3_G3_B2"/>
+            <enum name="GL_R5_G6_B5_A8_ICC_SGIX"/>
+            <enum name="GL_R5_G6_B5_ICC_SGIX"/>
+            <enum name="GL_RGB10"/>
+            <enum name="GL_RGB10_A2"/>
+            <enum name="GL_RGB12"/>
+            <enum name="GL_RGB16"/>
+            <enum name="GL_RGB2_EXT"/>
+            <enum name="GL_RGB4"/>
+            <enum name="GL_RGB5"/>
+            <enum name="GL_RGB5_A1"/>
+            <enum name="GL_RGB8"/>
+            <enum name="GL_RGBA12"/>
+            <enum name="GL_RGBA16"/>
+            <enum name="GL_RGBA2"/>
+            <enum name="GL_RGBA4"/>
+            <enum name="GL_RGBA8"/>
+            <enum name="GL_RGBA_ICC_SGIX"/>
+            <enum name="GL_RGB_ICC_SGIX"/>
+        </group>
+
+        <group name="PixelMap">
+            <enum name="GL_PIXEL_MAP_A_TO_A"/>
+            <enum name="GL_PIXEL_MAP_B_TO_B"/>
+            <enum name="GL_PIXEL_MAP_G_TO_G"/>
+            <enum name="GL_PIXEL_MAP_I_TO_A"/>
+            <enum name="GL_PIXEL_MAP_I_TO_B"/>
+            <enum name="GL_PIXEL_MAP_I_TO_G"/>
+            <enum name="GL_PIXEL_MAP_I_TO_I"/>
+            <enum name="GL_PIXEL_MAP_I_TO_R"/>
+            <enum name="GL_PIXEL_MAP_R_TO_R"/>
+            <enum name="GL_PIXEL_MAP_S_TO_S"/>
+        </group>
+
+        <group name="PixelStoreParameter">
+            <enum name="GL_PACK_ALIGNMENT"/>
+            <enum name="GL_PACK_IMAGE_DEPTH_SGIS"/>
+            <enum name="GL_PACK_IMAGE_HEIGHT"/>
+            <enum name="GL_PACK_IMAGE_HEIGHT_EXT"/>
+            <enum name="GL_PACK_LSB_FIRST"/>
+            <enum name="GL_PACK_RESAMPLE_OML"/>
+            <enum name="GL_PACK_RESAMPLE_SGIX"/>
+            <enum name="GL_PACK_ROW_LENGTH"/>
+            <enum name="GL_PACK_SKIP_IMAGES"/>
+            <enum name="GL_PACK_SKIP_IMAGES_EXT"/>
+            <enum name="GL_PACK_SKIP_PIXELS"/>
+            <enum name="GL_PACK_SKIP_ROWS"/>
+            <enum name="GL_PACK_SKIP_VOLUMES_SGIS"/>
+            <enum name="GL_PACK_SUBSAMPLE_RATE_SGIX"/>
+            <enum name="GL_PACK_SWAP_BYTES"/>
+            <enum name="GL_PIXEL_TILE_CACHE_SIZE_SGIX"/>
+            <enum name="GL_PIXEL_TILE_GRID_DEPTH_SGIX"/>
+            <enum name="GL_PIXEL_TILE_GRID_HEIGHT_SGIX"/>
+            <enum name="GL_PIXEL_TILE_GRID_WIDTH_SGIX"/>
+            <enum name="GL_PIXEL_TILE_HEIGHT_SGIX"/>
+            <enum name="GL_PIXEL_TILE_WIDTH_SGIX"/>
+            <enum name="GL_UNPACK_ALIGNMENT"/>
+            <enum name="GL_UNPACK_IMAGE_DEPTH_SGIS"/>
+            <enum name="GL_UNPACK_IMAGE_HEIGHT"/>
+            <enum name="GL_UNPACK_IMAGE_HEIGHT_EXT"/>
+            <enum name="GL_UNPACK_LSB_FIRST"/>
+            <enum name="GL_UNPACK_RESAMPLE_OML"/>
+            <enum name="GL_UNPACK_RESAMPLE_SGIX"/>
+            <enum name="GL_UNPACK_ROW_LENGTH"/>
+            <enum name="GL_UNPACK_ROW_LENGTH_EXT"/>
+            <enum name="GL_UNPACK_SKIP_IMAGES"/>
+            <enum name="GL_UNPACK_SKIP_IMAGES_EXT"/>
+            <enum name="GL_UNPACK_SKIP_PIXELS"/>
+            <enum name="GL_UNPACK_SKIP_PIXELS_EXT"/>
+            <enum name="GL_UNPACK_SKIP_ROWS"/>
+            <enum name="GL_UNPACK_SKIP_ROWS_EXT"/>
+            <enum name="GL_UNPACK_SKIP_VOLUMES_SGIS"/>
+            <enum name="GL_UNPACK_SUBSAMPLE_RATE_SGIX"/>
+            <enum name="GL_UNPACK_SWAP_BYTES"/>
+        </group>
+
+        <group name="PixelStoreResampleMode">
+            <enum name="GL_RESAMPLE_DECIMATE_SGIX"/>
+            <enum name="GL_RESAMPLE_REPLICATE_SGIX"/>
+            <enum name="GL_RESAMPLE_ZERO_FILL_SGIX"/>
+        </group>
+
+        <group name="PixelStoreSubsampleRate">
+            <enum name="GL_PIXEL_SUBSAMPLE_2424_SGIX"/>
+            <enum name="GL_PIXEL_SUBSAMPLE_4242_SGIX"/>
+            <enum name="GL_PIXEL_SUBSAMPLE_4444_SGIX"/>
+        </group>
+
+        <group name="PixelTexGenMode">
+            <enum name="GL_LUMINANCE"/>
+            <enum name="GL_LUMINANCE_ALPHA"/>
+            <enum name="GL_NONE"/>
+            <enum name="GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX"/>
+            <enum name="GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX"/>
+            <enum name="GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX"/>
+            <enum name="GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX"/>
+            <enum name="GL_RGB"/>
+            <enum name="GL_RGBA"/>
+        </group>
+
+        <group name="PixelTexGenParameterNameSGIS">
+            <enum name="GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS"/>
+            <enum name="GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS"/>
+        </group>
+
+        <group name="PixelTransferParameter">
+            <enum name="GL_ALPHA_BIAS"/>
+            <enum name="GL_ALPHA_SCALE"/>
+            <enum name="GL_BLUE_BIAS"/>
+            <enum name="GL_BLUE_SCALE"/>
+            <enum name="GL_DEPTH_BIAS"/>
+            <enum name="GL_DEPTH_SCALE"/>
+            <enum name="GL_GREEN_BIAS"/>
+            <enum name="GL_GREEN_SCALE"/>
+            <enum name="GL_INDEX_OFFSET"/>
+            <enum name="GL_INDEX_SHIFT"/>
+            <enum name="GL_MAP_COLOR"/>
+            <enum name="GL_MAP_STENCIL"/>
+            <enum name="GL_POST_COLOR_MATRIX_ALPHA_BIAS"/>
+            <enum name="GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI"/>
+            <enum name="GL_POST_COLOR_MATRIX_ALPHA_SCALE"/>
+            <enum name="GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI"/>
+            <enum name="GL_POST_COLOR_MATRIX_BLUE_BIAS"/>
+            <enum name="GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI"/>
+            <enum name="GL_POST_COLOR_MATRIX_BLUE_SCALE"/>
+            <enum name="GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI"/>
+            <enum name="GL_POST_COLOR_MATRIX_GREEN_BIAS"/>
+            <enum name="GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI"/>
+            <enum name="GL_POST_COLOR_MATRIX_GREEN_SCALE"/>
+            <enum name="GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI"/>
+            <enum name="GL_POST_COLOR_MATRIX_RED_BIAS"/>
+            <enum name="GL_POST_COLOR_MATRIX_RED_BIAS_SGI"/>
+            <enum name="GL_POST_COLOR_MATRIX_RED_SCALE"/>
+            <enum name="GL_POST_COLOR_MATRIX_RED_SCALE_SGI"/>
+            <enum name="GL_POST_CONVOLUTION_ALPHA_BIAS"/>
+            <enum name="GL_POST_CONVOLUTION_ALPHA_BIAS_EXT"/>
+            <enum name="GL_POST_CONVOLUTION_ALPHA_SCALE"/>
+            <enum name="GL_POST_CONVOLUTION_ALPHA_SCALE_EXT"/>
+            <enum name="GL_POST_CONVOLUTION_BLUE_BIAS"/>
+            <enum name="GL_POST_CONVOLUTION_BLUE_BIAS_EXT"/>
+            <enum name="GL_POST_CONVOLUTION_BLUE_SCALE"/>
+            <enum name="GL_POST_CONVOLUTION_BLUE_SCALE_EXT"/>
+            <enum name="GL_POST_CONVOLUTION_GREEN_BIAS"/>
+            <enum name="GL_POST_CONVOLUTION_GREEN_BIAS_EXT"/>
+            <enum name="GL_POST_CONVOLUTION_GREEN_SCALE"/>
+            <enum name="GL_POST_CONVOLUTION_GREEN_SCALE_EXT"/>
+            <enum name="GL_POST_CONVOLUTION_RED_BIAS"/>
+            <enum name="GL_POST_CONVOLUTION_RED_BIAS_EXT"/>
+            <enum name="GL_POST_CONVOLUTION_RED_SCALE"/>
+            <enum name="GL_POST_CONVOLUTION_RED_SCALE_EXT"/>
+            <enum name="GL_RED_BIAS"/>
+            <enum name="GL_RED_SCALE"/>
+        </group>
+
+        <group name="PixelType">
+            <enum name="GL_BITMAP"/>
+            <enum name="GL_BYTE"/>
+            <enum name="GL_FLOAT"/>
+            <enum name="GL_INT"/>
+            <enum name="GL_SHORT"/>
+            <enum name="GL_UNSIGNED_BYTE"/>
+            <enum name="GL_UNSIGNED_BYTE_3_3_2"/>
+            <enum name="GL_UNSIGNED_BYTE_3_3_2_EXT"/>
+            <enum name="GL_UNSIGNED_INT"/>
+            <enum name="GL_UNSIGNED_INT_10_10_10_2"/>
+            <enum name="GL_UNSIGNED_INT_10_10_10_2_EXT"/>
+            <enum name="GL_UNSIGNED_INT_8_8_8_8"/>
+            <enum name="GL_UNSIGNED_INT_8_8_8_8_EXT"/>
+            <enum name="GL_UNSIGNED_SHORT"/>
+            <enum name="GL_UNSIGNED_SHORT_4_4_4_4"/>
+            <enum name="GL_UNSIGNED_SHORT_4_4_4_4_EXT"/>
+            <enum name="GL_UNSIGNED_SHORT_5_5_5_1"/>
+            <enum name="GL_UNSIGNED_SHORT_5_5_5_1_EXT"/>
+        </group>
+
+        <group name="PointParameterNameSGIS">
+            <enum name="GL_DISTANCE_ATTENUATION_EXT"/>
+            <enum name="GL_DISTANCE_ATTENUATION_SGIS"/>
+            <enum name="GL_POINT_DISTANCE_ATTENUATION"/>
+            <enum name="GL_POINT_DISTANCE_ATTENUATION_ARB"/>
+            <enum name="GL_POINT_FADE_THRESHOLD_SIZE"/>
+            <enum name="GL_POINT_FADE_THRESHOLD_SIZE_ARB"/>
+            <enum name="GL_POINT_FADE_THRESHOLD_SIZE_EXT"/>
+            <enum name="GL_POINT_FADE_THRESHOLD_SIZE_SGIS"/>
+            <enum name="GL_POINT_SIZE_MAX"/>
+            <enum name="GL_POINT_SIZE_MAX_ARB"/>
+            <enum name="GL_POINT_SIZE_MAX_EXT"/>
+            <enum name="GL_POINT_SIZE_MAX_SGIS"/>
+            <enum name="GL_POINT_SIZE_MIN"/>
+            <enum name="GL_POINT_SIZE_MIN_ARB"/>
+            <enum name="GL_POINT_SIZE_MIN_EXT"/>
+            <enum name="GL_POINT_SIZE_MIN_SGIS"/>
+        </group>
+
+        <group name="PolygonMode">
+            <enum name="GL_FILL"/>
+            <enum name="GL_LINE"/>
+            <enum name="GL_POINT"/>
+        </group>
+
+        <group name="PrimitiveType">
+            <enum name="GL_LINES"/>
+            <enum name="GL_LINES_ADJACENCY"/>
+            <enum name="GL_LINES_ADJACENCY_ARB"/>
+            <enum name="GL_LINES_ADJACENCY_EXT"/>
+            <enum name="GL_LINE_LOOP"/>
+            <enum name="GL_LINE_STRIP"/>
+            <enum name="GL_LINE_STRIP_ADJACENCY"/>
+            <enum name="GL_LINE_STRIP_ADJACENCY_ARB"/>
+            <enum name="GL_LINE_STRIP_ADJACENCY_EXT"/>
+            <enum name="GL_PATCHES"/>
+            <enum name="GL_PATCHES_EXT"/>
+            <enum name="GL_POINTS"/>
+            <enum name="GL_POLYGON"/>
+            <enum name="GL_QUADS"/>
+            <enum name="GL_QUADS_EXT"/>
+            <enum name="GL_QUAD_STRIP"/>
+            <enum name="GL_TRIANGLES"/>
+            <enum name="GL_TRIANGLES_ADJACENCY"/>
+            <enum name="GL_TRIANGLES_ADJACENCY_ARB"/>
+            <enum name="GL_TRIANGLES_ADJACENCY_EXT"/>
+            <enum name="GL_TRIANGLE_FAN"/>
+            <enum name="GL_TRIANGLE_STRIP"/>
+            <enum name="GL_TRIANGLE_STRIP_ADJACENCY"/>
+            <enum name="GL_TRIANGLE_STRIP_ADJACENCY_ARB"/>
+            <enum name="GL_TRIANGLE_STRIP_ADJACENCY_EXT"/>
+        </group>
+
+        <group name="OcclusionQueryEventMaskAMD">
+            <enum name="GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD"/>
+            <enum name="GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD"/>
+            <enum name="GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD"/>
+            <enum name="GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD"/>
+            <enum name="GL_QUERY_ALL_EVENT_BITS_AMD"/>
+        </group>
+
+        <group name="ReadBufferMode">
+            <enum name="GL_AUX0"/>
+            <enum name="GL_AUX1"/>
+            <enum name="GL_AUX2"/>
+            <enum name="GL_AUX3"/>
+            <enum name="GL_BACK"/>
+            <enum name="GL_BACK_LEFT"/>
+            <enum name="GL_BACK_RIGHT"/>
+            <enum name="GL_FRONT"/>
+            <enum name="GL_FRONT_LEFT"/>
+            <enum name="GL_FRONT_RIGHT"/>
+            <enum name="GL_LEFT"/>
+            <enum name="GL_RIGHT"/>
+        </group>
+
+        <group name="RenderingMode">
+            <enum name="GL_FEEDBACK"/>
+            <enum name="GL_RENDER"/>
+            <enum name="GL_SELECT"/>
+        </group>
+
+        <group name="SamplePatternSGIS">
+            <enum name="GL_1PASS_EXT"/>
+            <enum name="GL_1PASS_SGIS"/>
+            <enum name="GL_2PASS_0_EXT"/>
+            <enum name="GL_2PASS_0_SGIS"/>
+            <enum name="GL_2PASS_1_EXT"/>
+            <enum name="GL_2PASS_1_SGIS"/>
+            <enum name="GL_4PASS_0_EXT"/>
+            <enum name="GL_4PASS_0_SGIS"/>
+            <enum name="GL_4PASS_1_EXT"/>
+            <enum name="GL_4PASS_1_SGIS"/>
+            <enum name="GL_4PASS_2_EXT"/>
+            <enum name="GL_4PASS_2_SGIS"/>
+            <enum name="GL_4PASS_3_EXT"/>
+            <enum name="GL_4PASS_3_SGIS"/>
+        </group>
+
+        <group name="SeparableTargetEXT">
+            <enum name="GL_SEPARABLE_2D"/>
+            <enum name="GL_SEPARABLE_2D_EXT"/>
+        </group>
+
+        <group name="ShadingModel">
+            <enum name="GL_FLAT"/>
+            <enum name="GL_SMOOTH"/>
+        </group>
+
+        <group name="StencilFunction">
+            <enum name="GL_ALWAYS"/>
+            <enum name="GL_EQUAL"/>
+            <enum name="GL_GEQUAL"/>
+            <enum name="GL_GREATER"/>
+            <enum name="GL_LEQUAL"/>
+            <enum name="GL_LESS"/>
+            <enum name="GL_NEVER"/>
+            <enum name="GL_NOTEQUAL"/>
+        </group>
+
+        <group name="StencilOp">
+            <enum name="GL_DECR"/>
+            <enum name="GL_INCR"/>
+            <enum name="GL_INVERT"/>
+            <enum name="GL_KEEP"/>
+            <enum name="GL_REPLACE"/>
+            <enum name="GL_ZERO"/>
+        </group>
+
+        <group name="StringName">
+            <enum name="GL_EXTENSIONS"/>
+            <enum name="GL_RENDERER"/>
+            <enum name="GL_VENDOR"/>
+            <enum name="GL_VERSION"/>
+        </group>
+
+        <group name="TexCoordPointerType">
+            <enum name="GL_DOUBLE"/>
+            <enum name="GL_FLOAT"/>
+            <enum name="GL_INT"/>
+            <enum name="GL_SHORT"/>
+        </group>
+
+        <group name="TextureCoordName">
+            <enum name="GL_S"/>
+            <enum name="GL_T"/>
+            <enum name="GL_R"/>
+            <enum name="GL_Q"/>
+        </group>
+
+        <group name="TextureEnvMode">
+            <enum name="GL_ADD"/>
+            <enum name="GL_BLEND"/>
+            <enum name="GL_DECAL"/>
+            <enum name="GL_MODULATE"/>
+            <enum name="GL_REPLACE_EXT"/>
+            <enum name="GL_TEXTURE_ENV_BIAS_SGIX"/>
+        </group>
+
+        <group name="TextureEnvParameter">
+            <enum name="GL_TEXTURE_ENV_COLOR"/>
+            <enum name="GL_TEXTURE_ENV_MODE"/>
+        </group>
+
+        <group name="TextureEnvTarget">
+            <enum name="GL_TEXTURE_ENV"/>
+        </group>
+
+        <group name="TextureFilterFuncSGIS">
+            <enum name="GL_FILTER4_SGIS"/>
+        </group>
+
+        <group name="TextureGenMode">
+            <enum name="GL_EYE_DISTANCE_TO_LINE_SGIS"/>
+            <enum name="GL_EYE_DISTANCE_TO_POINT_SGIS"/>
+            <enum name="GL_EYE_LINEAR"/>
+            <enum name="GL_OBJECT_DISTANCE_TO_LINE_SGIS"/>
+            <enum name="GL_OBJECT_DISTANCE_TO_POINT_SGIS"/>
+            <enum name="GL_OBJECT_LINEAR"/>
+            <enum name="GL_SPHERE_MAP"/>
+        </group>
+
+        <group name="TextureGenParameter">
+            <enum name="GL_EYE_LINE_SGIS"/>
+            <enum name="GL_EYE_PLANE"/>
+            <enum name="GL_EYE_POINT_SGIS"/>
+            <enum name="GL_OBJECT_LINE_SGIS"/>
+            <enum name="GL_OBJECT_PLANE"/>
+            <enum name="GL_OBJECT_POINT_SGIS"/>
+            <enum name="GL_TEXTURE_GEN_MODE"/>
+        </group>
+
+        <group name="TextureMagFilter">
+            <enum name="GL_FILTER4_SGIS"/>
+            <enum name="GL_LINEAR"/>
+            <enum name="GL_LINEAR_DETAIL_ALPHA_SGIS"/>
+            <enum name="GL_LINEAR_DETAIL_COLOR_SGIS"/>
+            <enum name="GL_LINEAR_DETAIL_SGIS"/>
+            <enum name="GL_LINEAR_SHARPEN_ALPHA_SGIS"/>
+            <enum name="GL_LINEAR_SHARPEN_COLOR_SGIS"/>
+            <enum name="GL_LINEAR_SHARPEN_SGIS"/>
+            <enum name="GL_NEAREST"/>
+            <enum name="GL_PIXEL_TEX_GEN_Q_CEILING_SGIX"/>
+            <enum name="GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX"/>
+            <enum name="GL_PIXEL_TEX_GEN_Q_ROUND_SGIX"/>
+        </group>
+
+        <group name="TextureMinFilter">
+            <enum name="GL_FILTER4_SGIS"/>
+            <enum name="GL_LINEAR"/>
+            <enum name="GL_LINEAR_CLIPMAP_LINEAR_SGIX"/>
+            <enum name="GL_LINEAR_CLIPMAP_NEAREST_SGIX"/>
+            <enum name="GL_LINEAR_MIPMAP_LINEAR"/>
+            <enum name="GL_LINEAR_MIPMAP_NEAREST"/>
+            <enum name="GL_NEAREST"/>
+            <enum name="GL_NEAREST_CLIPMAP_LINEAR_SGIX"/>
+            <enum name="GL_NEAREST_CLIPMAP_NEAREST_SGIX"/>
+            <enum name="GL_NEAREST_MIPMAP_LINEAR"/>
+            <enum name="GL_NEAREST_MIPMAP_NEAREST"/>
+            <enum name="GL_PIXEL_TEX_GEN_Q_CEILING_SGIX"/>
+            <enum name="GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX"/>
+            <enum name="GL_PIXEL_TEX_GEN_Q_ROUND_SGIX"/>
+        </group>
+
+        <group name="TextureParameterName">
+            <enum name="GL_DETAIL_TEXTURE_LEVEL_SGIS"/>
+            <enum name="GL_DETAIL_TEXTURE_MODE_SGIS"/>
+            <enum name="GL_DUAL_TEXTURE_SELECT_SGIS"/>
+            <enum name="GL_GENERATE_MIPMAP"/>
+            <enum name="GL_GENERATE_MIPMAP_SGIS"/>
+            <enum name="GL_POST_TEXTURE_FILTER_BIAS_SGIX"/>
+            <enum name="GL_POST_TEXTURE_FILTER_SCALE_SGIX"/>
+            <enum name="GL_QUAD_TEXTURE_SELECT_SGIS"/>
+            <enum name="GL_SHADOW_AMBIENT_SGIX"/>
+            <enum name="GL_TEXTURE_BORDER_COLOR"/>
+            <enum name="GL_TEXTURE_CLIPMAP_CENTER_SGIX"/>
+            <enum name="GL_TEXTURE_CLIPMAP_DEPTH_SGIX"/>
+            <enum name="GL_TEXTURE_CLIPMAP_FRAME_SGIX"/>
+            <enum name="GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX"/>
+            <enum name="GL_TEXTURE_CLIPMAP_OFFSET_SGIX"/>
+            <enum name="GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX"/>
+            <enum name="GL_TEXTURE_COMPARE_SGIX"/>
+            <enum name="GL_TEXTURE_LOD_BIAS_R_SGIX"/>
+            <enum name="GL_TEXTURE_LOD_BIAS_S_SGIX"/>
+            <enum name="GL_TEXTURE_LOD_BIAS_T_SGIX"/>
+            <enum name="GL_TEXTURE_MAG_FILTER"/>
+            <enum name="GL_TEXTURE_MAX_CLAMP_R_SGIX"/>
+            <enum name="GL_TEXTURE_MAX_CLAMP_S_SGIX"/>
+            <enum name="GL_TEXTURE_MAX_CLAMP_T_SGIX"/>
+            <enum name="GL_TEXTURE_MIN_FILTER"/>
+            <enum name="GL_TEXTURE_PRIORITY"/>
+            <enum name="GL_TEXTURE_PRIORITY_EXT"/>
+            <enum name="GL_TEXTURE_WRAP_Q_SGIS"/>
+            <enum name="GL_TEXTURE_WRAP_R"/>
+            <enum name="GL_TEXTURE_WRAP_R_EXT"/>
+            <enum name="GL_TEXTURE_WRAP_R_OES"/>
+            <enum name="GL_TEXTURE_WRAP_S"/>
+            <enum name="GL_TEXTURE_WRAP_T"/>
+        </group>
+
+        <group name="TextureTarget">
+            <enum name="GL_DETAIL_TEXTURE_2D_SGIS"/>
+            <enum name="GL_PROXY_TEXTURE_1D"/>
+            <enum name="GL_PROXY_TEXTURE_1D_EXT"/>
+            <enum name="GL_PROXY_TEXTURE_2D"/>
+            <enum name="GL_PROXY_TEXTURE_2D_EXT"/>
+            <enum name="GL_PROXY_TEXTURE_3D"/>
+            <enum name="GL_PROXY_TEXTURE_3D_EXT"/>
+            <enum name="GL_PROXY_TEXTURE_4D_SGIS"/>
+            <enum name="GL_TEXTURE_1D"/>
+            <enum name="GL_TEXTURE_2D"/>
+            <enum name="GL_TEXTURE_3D"/>
+            <enum name="GL_TEXTURE_3D_EXT"/>
+            <enum name="GL_TEXTURE_3D_OES"/>
+            <enum name="GL_TEXTURE_4D_SGIS"/>
+            <enum name="GL_TEXTURE_BASE_LEVEL"/>
+            <enum name="GL_TEXTURE_BASE_LEVEL_SGIS"/>
+            <enum name="GL_TEXTURE_MAX_LEVEL"/>
+            <enum name="GL_TEXTURE_MAX_LEVEL_SGIS"/>
+            <enum name="GL_TEXTURE_MAX_LOD"/>
+            <enum name="GL_TEXTURE_MAX_LOD_SGIS"/>
+            <enum name="GL_TEXTURE_MIN_LOD"/>
+            <enum name="GL_TEXTURE_MIN_LOD_SGIS"/>
+        </group>
+
+        <group name="TextureWrapMode">
+            <enum name="GL_CLAMP"/>
+            <enum name="GL_CLAMP_TO_BORDER"/>
+            <enum name="GL_CLAMP_TO_BORDER_ARB"/>
+            <enum name="GL_CLAMP_TO_BORDER_NV"/>
+            <enum name="GL_CLAMP_TO_BORDER_SGIS"/>
+            <enum name="GL_CLAMP_TO_EDGE"/>
+            <enum name="GL_CLAMP_TO_EDGE_SGIS"/>
+            <enum name="GL_REPEAT"/>
+        </group>
+
+        <group name="UseProgramStageMask">
+            <enum name="GL_VERTEX_SHADER_BIT"/>
+            <enum name="GL_VERTEX_SHADER_BIT_EXT"/>
+            <enum name="GL_FRAGMENT_SHADER_BIT"/>
+            <enum name="GL_FRAGMENT_SHADER_BIT_EXT"/>
+            <enum name="GL_GEOMETRY_SHADER_BIT"/>
+            <enum name="GL_GEOMETRY_SHADER_BIT_EXT"/>
+            <enum name="GL_TESS_CONTROL_SHADER_BIT"/>
+            <enum name="GL_TESS_CONTROL_SHADER_BIT_EXT"/>
+            <enum name="GL_TESS_EVALUATION_SHADER_BIT"/>
+            <enum name="GL_TESS_EVALUATION_SHADER_BIT_EXT"/>
+            <enum name="GL_COMPUTE_SHADER_BIT"/>
+            <enum name="GL_ALL_SHADER_BITS"/>
+            <enum name="GL_ALL_SHADER_BITS_EXT"/>
+        </group>
+
+        <group name="VertexPointerType">
+            <enum name="GL_DOUBLE"/>
+            <enum name="GL_FLOAT"/>
+            <enum name="GL_INT"/>
+            <enum name="GL_SHORT"/>
+        </group>
+    </groups>
+
+    <!-- SECTION: GL enumerant (token) definitions. -->
+
+    <!-- Bitmasks each have their own namespace, although bits are
+         sometimes reused for other purposes -->
+
+    <enums namespace="GL" group="AttribMask" type="bitmask">
+        <enum value="0x00000001" name="GL_CURRENT_BIT"/>
+        <enum value="0x00000002" name="GL_POINT_BIT"/>
+        <enum value="0x00000004" name="GL_LINE_BIT"/>
+        <enum value="0x00000008" name="GL_POLYGON_BIT"/>
+        <enum value="0x00000010" name="GL_POLYGON_STIPPLE_BIT"/>
+        <enum value="0x00000020" name="GL_PIXEL_MODE_BIT"/>
+        <enum value="0x00000040" name="GL_LIGHTING_BIT"/>
+        <enum value="0x00000080" name="GL_FOG_BIT"/>
+        <enum value="0x00000100" name="GL_DEPTH_BUFFER_BIT"/>
+        <enum value="0x00000200" name="GL_ACCUM_BUFFER_BIT"/>
+        <enum value="0x00000400" name="GL_STENCIL_BUFFER_BIT"/>
+        <enum value="0x00000800" name="GL_VIEWPORT_BIT"/>
+        <enum value="0x00001000" name="GL_TRANSFORM_BIT"/>
+        <enum value="0x00002000" name="GL_ENABLE_BIT"/>
+        <enum value="0x00004000" name="GL_COLOR_BUFFER_BIT"/>
+        <enum value="0x00008000" name="GL_HINT_BIT"/>
+        <enum value="0x00010000" name="GL_EVAL_BIT"/>
+        <enum value="0x00020000" name="GL_LIST_BIT"/>
+        <enum value="0x00040000" name="GL_TEXTURE_BIT"/>
+        <enum value="0x00080000" name="GL_SCISSOR_BIT"/>
+        <enum value="0x20000000" name="GL_MULTISAMPLE_BIT"/>
+        <enum value="0x20000000" name="GL_MULTISAMPLE_BIT_ARB"/>
+        <enum value="0x20000000" name="GL_MULTISAMPLE_BIT_EXT"/>
+        <enum value="0x20000000" name="GL_MULTISAMPLE_BIT_3DFX"/>
+        <enum value="0xFFFFFFFF" name="GL_ALL_ATTRIB_BITS" comment="Guaranteed to mark all attribute groups at once"/>
+    </enums>
+
+    <enums namespace="GL" group="ClearBufferMask" type="bitmask" comment="GL_{DEPTH,ACCUM,STENCIL,COLOR}_BUFFER_BIT also lie in this namespace">
+        <enum value="0x00008000" name="GL_COVERAGE_BUFFER_BIT_NV" comment="Collides with AttribMask bit GL_HINT_BIT. OK since this token is for OpenGL ES 2, which doesn't have attribute groups."/>
+            <!-- Also used: 0x00004700 for bits reused from AttribMask above -->
+    </enums>
+
+    <enums namespace="GL" group="ClientAttribMask" type="bitmask">
+        <enum value="0x00000001" name="GL_CLIENT_PIXEL_STORE_BIT"/>
+        <enum value="0x00000002" name="GL_CLIENT_VERTEX_ARRAY_BIT"/>
+        <enum value="0xFFFFFFFF" name="GL_CLIENT_ALL_ATTRIB_BITS"/>
+    </enums>
+
+    <enums namespace="GL" group="ContextFlagMask" type="bitmask" comment="Should be shared with WGL/GLX, but aren't since the FORWARD_COMPATIBLE and DEBUG values are swapped vs. WGL/GLX.">
+        <enum value="0x00000001" name="GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT"/>
+        <enum value="0x00000002" name="GL_CONTEXT_FLAG_DEBUG_BIT"/>
+        <enum value="0x00000002" name="GL_CONTEXT_FLAG_DEBUG_BIT_KHR"/>
+        <enum value="0x00000004" name="GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB"/>
+    </enums>
+
+    <enums namespace="GL" group="ContextProfileMask" type="bitmask">
+        <enum value="0x00000001" name="GL_CONTEXT_CORE_PROFILE_BIT"/>
+        <enum value="0x00000002" name="GL_CONTEXT_COMPATIBILITY_PROFILE_BIT"/>
+    </enums>
+
+    <enums namespace="GL" group="MapBufferUsageMask" type="bitmask">
+        <enum value="0x0001" name="GL_MAP_READ_BIT"/>
+        <enum value="0x0001" name="GL_MAP_READ_BIT_EXT"/>
+        <enum value="0x0002" name="GL_MAP_WRITE_BIT"/>
+        <enum value="0x0002" name="GL_MAP_WRITE_BIT_EXT"/>
+        <enum value="0x0004" name="GL_MAP_INVALIDATE_RANGE_BIT"/>
+        <enum value="0x0004" name="GL_MAP_INVALIDATE_RANGE_BIT_EXT"/>
+        <enum value="0x0008" name="GL_MAP_INVALIDATE_BUFFER_BIT"/>
+        <enum value="0x0008" name="GL_MAP_INVALIDATE_BUFFER_BIT_EXT"/>
+        <enum value="0x0010" name="GL_MAP_FLUSH_EXPLICIT_BIT"/>
+        <enum value="0x0010" name="GL_MAP_FLUSH_EXPLICIT_BIT_EXT"/>
+        <enum value="0x0020" name="GL_MAP_UNSYNCHRONIZED_BIT"/>
+        <enum value="0x0020" name="GL_MAP_UNSYNCHRONIZED_BIT_EXT"/>
+        <enum value="0x0040" name="GL_MAP_PERSISTENT_BIT"/>
+        <enum value="0x0080" name="GL_MAP_COHERENT_BIT"/>
+        <enum value="0x0100" name="GL_DYNAMIC_STORAGE_BIT"/>
+        <enum value="0x0200" name="GL_CLIENT_STORAGE_BIT"/>
+    </enums>
+
+    <enums namespace="GL" group="MemoryBarrierMask" type="bitmask">
+        <enum value="0x00000001" name="GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT"/>
+        <enum value="0x00000001" name="GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT"/>
+        <enum value="0x00000002" name="GL_ELEMENT_ARRAY_BARRIER_BIT"/>
+        <enum value="0x00000002" name="GL_ELEMENT_ARRAY_BARRIER_BIT_EXT"/>
+        <enum value="0x00000004" name="GL_UNIFORM_BARRIER_BIT"/>
+        <enum value="0x00000004" name="GL_UNIFORM_BARRIER_BIT_EXT"/>
+        <enum value="0x00000008" name="GL_TEXTURE_FETCH_BARRIER_BIT"/>
+        <enum value="0x00000008" name="GL_TEXTURE_FETCH_BARRIER_BIT_EXT"/>
+        <enum value="0x00000010" name="GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV"/>
+        <enum value="0x00000020" name="GL_SHADER_IMAGE_ACCESS_BARRIER_BIT"/>
+        <enum value="0x00000020" name="GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT"/>
+        <enum value="0x00000040" name="GL_COMMAND_BARRIER_BIT"/>
+        <enum value="0x00000040" name="GL_COMMAND_BARRIER_BIT_EXT"/>
+        <enum value="0x00000080" name="GL_PIXEL_BUFFER_BARRIER_BIT"/>
+        <enum value="0x00000080" name="GL_PIXEL_BUFFER_BARRIER_BIT_EXT"/>
+        <enum value="0x00000100" name="GL_TEXTURE_UPDATE_BARRIER_BIT"/>
+        <enum value="0x00000100" name="GL_TEXTURE_UPDATE_BARRIER_BIT_EXT"/>
+        <enum value="0x00000200" name="GL_BUFFER_UPDATE_BARRIER_BIT"/>
+        <enum value="0x00000200" name="GL_BUFFER_UPDATE_BARRIER_BIT_EXT"/>
+        <enum value="0x00000400" name="GL_FRAMEBUFFER_BARRIER_BIT"/>
+        <enum value="0x00000400" name="GL_FRAMEBUFFER_BARRIER_BIT_EXT"/>
+        <enum value="0x00000800" name="GL_TRANSFORM_FEEDBACK_BARRIER_BIT"/>
+        <enum value="0x00000800" name="GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT"/>
+        <enum value="0x00001000" name="GL_ATOMIC_COUNTER_BARRIER_BIT"/>
+        <enum value="0x00001000" name="GL_ATOMIC_COUNTER_BARRIER_BIT_EXT"/>
+        <enum value="0x00002000" name="GL_SHADER_STORAGE_BARRIER_BIT"/>
+        <enum value="0x00004000" name="GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT"/>
+        <enum value="0x00008000" name="GL_QUERY_BUFFER_BARRIER_BIT"/>
+        <enum value="0xFFFFFFFF" name="GL_ALL_BARRIER_BITS"/>
+        <enum value="0xFFFFFFFF" name="GL_ALL_BARRIER_BITS_EXT"/>
+    </enums>
+
+    <enums namespace="OcclusionQueryEventMaskAMD">
+        <enum value="0x00000001" name="GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD"/>
+        <enum value="0x00000002" name="GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD"/>
+        <enum value="0x00000004" name="GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD"/>
+        <enum value="0x00000008" name="GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD"/>
+        <enum value="0xFFFFFFFF" name="GL_QUERY_ALL_EVENT_BITS_AMD"/>
+    </enums>
+
+    <enums namespace="GL" group="SyncObjectMask" type="bitmask">
+        <enum value="0x00000001" name="GL_SYNC_FLUSH_COMMANDS_BIT"/>
+        <enum value="0x00000001" name="GL_SYNC_FLUSH_COMMANDS_BIT_APPLE"/>
+    </enums>
+
+    <enums namespace="GL" group="UseProgramStageMask" type="bitmask">
+        <enum value="0x00000001" name="GL_VERTEX_SHADER_BIT"/>
+        <enum value="0x00000001" name="GL_VERTEX_SHADER_BIT_EXT"/>
+        <enum value="0x00000002" name="GL_FRAGMENT_SHADER_BIT"/>
+        <enum value="0x00000002" name="GL_FRAGMENT_SHADER_BIT_EXT"/>
+        <enum value="0x00000004" name="GL_GEOMETRY_SHADER_BIT"/>
+        <enum value="0x00000004" name="GL_GEOMETRY_SHADER_BIT_EXT"/>                             
+        <enum value="0x00000008" name="GL_TESS_CONTROL_SHADER_BIT"/>
+        <enum value="0x00000008" name="GL_TESS_CONTROL_SHADER_BIT_EXT"/>
+        <enum value="0x00000010" name="GL_TESS_EVALUATION_SHADER_BIT"/>
+        <enum value="0x00000010" name="GL_TESS_EVALUATION_SHADER_BIT_EXT"/>
+        <enum value="0x00000020" name="GL_COMPUTE_SHADER_BIT"/>
+        <enum value="0xFFFFFFFF" name="GL_ALL_SHADER_BITS"/>
+        <enum value="0xFFFFFFFF" name="GL_ALL_SHADER_BITS_EXT"/>
+    </enums>
+
+    <!-- Bitmasks defined by vendor extensions -->
+
+    <enums namespace="GL" group="TextureStorageMaskAMD" type="bitmask">
+        <enum value="0x00000001" name="GL_TEXTURE_STORAGE_SPARSE_BIT_AMD"/>
+    </enums>
+
+    <enums namespace="GL" group="FragmentShaderDestMaskATI" type="bitmask">
+        <enum value="0x00000001" name="GL_RED_BIT_ATI"/>
+        <enum value="0x00000002" name="GL_GREEN_BIT_ATI"/>
+        <enum value="0x00000004" name="GL_BLUE_BIT_ATI"/>
+    </enums>
+
+    <enums namespace="GL" group="FragmentShaderDestModMaskATI" type="bitmask">
+        <enum value="0x00000001" name="GL_2X_BIT_ATI"/>
+        <enum value="0x00000002" name="GL_4X_BIT_ATI"/>
+        <enum value="0x00000004" name="GL_8X_BIT_ATI"/>
+        <enum value="0x00000008" name="GL_HALF_BIT_ATI"/>
+        <enum value="0x00000010" name="GL_QUARTER_BIT_ATI"/>
+        <enum value="0x00000020" name="GL_EIGHTH_BIT_ATI"/>
+        <enum value="0x00000040" name="GL_SATURATE_BIT_ATI"/>
+    </enums>
+
+    <enums namespace="GL" group="FragmentShaderColorModMaskATI" type="bitmask">
+            <!-- Also used: 0x00000001 for GL_2X_BIT_ATI reused from FragmentShaderDestModMaskAT above -->
+        <enum value="0x00000002" name="GL_COMP_BIT_ATI"/>
+        <enum value="0x00000004" name="GL_NEGATE_BIT_ATI"/>
+        <enum value="0x00000008" name="GL_BIAS_BIT_ATI"/>
+    </enums>
+
+    <enums namespace="GL" group="TraceMaskMESA" type="bitmask">
+        <enum value="0x0001" name="GL_TRACE_OPERATIONS_BIT_MESA"/>
+        <enum value="0x0002" name="GL_TRACE_PRIMITIVES_BIT_MESA"/>
+        <enum value="0x0004" name="GL_TRACE_ARRAYS_BIT_MESA"/>
+        <enum value="0x0008" name="GL_TRACE_TEXTURES_BIT_MESA"/>
+        <enum value="0x0010" name="GL_TRACE_PIXELS_BIT_MESA"/>
+        <enum value="0x0020" name="GL_TRACE_ERRORS_BIT_MESA"/>
+        <enum value="0xFFFF" name="GL_TRACE_ALL_BITS_MESA"/>
+    </enums>
+
+    <enums namespace="GL" group="PathRenderingMaskNV" type="bitmask">
+        <enum value="0x01" name="GL_BOLD_BIT_NV"/>
+        <enum value="0x02" name="GL_ITALIC_BIT_NV"/>
+        <enum value="0x01" name="GL_GLYPH_WIDTH_BIT_NV"/>
+        <enum value="0x02" name="GL_GLYPH_HEIGHT_BIT_NV"/>
+        <enum value="0x04" name="GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV"/>
+        <enum value="0x08" name="GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV"/>
+        <enum value="0x10" name="GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV"/>
+        <enum value="0x20" name="GL_GLYPH_VERTICAL_BEARING_X_BIT_NV"/>
+        <enum value="0x40" name="GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV"/>
+        <enum value="0x80" name="GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV"/>
+        <enum value="0x100" name="GL_GLYPH_HAS_KERNING_BIT_NV"/>
+        <enum value="0x00010000" name="GL_FONT_X_MIN_BOUNDS_BIT_NV"/>
+        <enum value="0x00020000" name="GL_FONT_Y_MIN_BOUNDS_BIT_NV"/>
+        <enum value="0x00040000" name="GL_FONT_X_MAX_BOUNDS_BIT_NV"/>
+        <enum value="0x00080000" name="GL_FONT_Y_MAX_BOUNDS_BIT_NV"/>
+        <enum value="0x00100000" name="GL_FONT_UNITS_PER_EM_BIT_NV"/>
+        <enum value="0x00200000" name="GL_FONT_ASCENDER_BIT_NV"/>
+        <enum value="0x00400000" name="GL_FONT_DESCENDER_BIT_NV"/>
+        <enum value="0x00800000" name="GL_FONT_HEIGHT_BIT_NV"/>
+        <enum value="0x01000000" name="GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV"/>
+        <enum value="0x02000000" name="GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV"/>
+        <enum value="0x04000000" name="GL_FONT_UNDERLINE_POSITION_BIT_NV"/>
+        <enum value="0x08000000" name="GL_FONT_UNDERLINE_THICKNESS_BIT_NV"/>
+        <enum value="0x10000000" name="GL_FONT_HAS_KERNING_BIT_NV"/>
+    </enums>
+
+    <enums namespace="GL" group="PerformanceQueryCapsMaskINTEL" type="bitmask">
+        <enum value="0x00000000" name="GL_PERFQUERY_SINGLE_CONTEXT_INTEL"/>
+        <enum value="0x00000001" name="GL_PERFQUERY_GLOBAL_CONTEXT_INTEL"/>
+    </enums>
+
+    <enums namespace="GL" group="VertexHintsMaskPGI" type="bitmask">
+        <enum value="0x00000004" name="GL_VERTEX23_BIT_PGI"/>
+        <enum value="0x00000008" name="GL_VERTEX4_BIT_PGI"/>
+        <enum value="0x00010000" name="GL_COLOR3_BIT_PGI"/>
+        <enum value="0x00020000" name="GL_COLOR4_BIT_PGI"/>
+        <enum value="0x00040000" name="GL_EDGEFLAG_BIT_PGI"/>
+        <enum value="0x00080000" name="GL_INDEX_BIT_PGI"/>
+        <enum value="0x00100000" name="GL_MAT_AMBIENT_BIT_PGI"/>
+        <enum value="0x00200000" name="GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI"/>
+        <enum value="0x00400000" name="GL_MAT_DIFFUSE_BIT_PGI"/>
+        <enum value="0x00800000" name="GL_MAT_EMISSION_BIT_PGI"/>
+        <enum value="0x01000000" name="GL_MAT_COLOR_INDEXES_BIT_PGI"/>
+        <enum value="0x02000000" name="GL_MAT_SHININESS_BIT_PGI"/>
+        <enum value="0x04000000" name="GL_MAT_SPECULAR_BIT_PGI"/>
+        <enum value="0x08000000" name="GL_NORMAL_BIT_PGI"/>
+        <enum value="0x10000000" name="GL_TEXCOORD1_BIT_PGI"/>
+        <enum value="0x20000000" name="GL_TEXCOORD2_BIT_PGI"/>
+        <enum value="0x40000000" name="GL_TEXCOORD3_BIT_PGI"/>
+        <enum value="0x80000000" name="GL_TEXCOORD4_BIT_PGI"/>
+    </enums>
+
+    <enums namespace="GL" group="BufferBitQCOM" type="bitmask">
+        <enum value="0x00000001" name="GL_COLOR_BUFFER_BIT0_QCOM"/>
+        <enum value="0x00000002" name="GL_COLOR_BUFFER_BIT1_QCOM"/>
+        <enum value="0x00000004" name="GL_COLOR_BUFFER_BIT2_QCOM"/>
+        <enum value="0x00000008" name="GL_COLOR_BUFFER_BIT3_QCOM"/>
+        <enum value="0x00000010" name="GL_COLOR_BUFFER_BIT4_QCOM"/>
+        <enum value="0x00000020" name="GL_COLOR_BUFFER_BIT5_QCOM"/>
+        <enum value="0x00000040" name="GL_COLOR_BUFFER_BIT6_QCOM"/>
+        <enum value="0x00000080" name="GL_COLOR_BUFFER_BIT7_QCOM"/>
+        <enum value="0x00000100" name="GL_DEPTH_BUFFER_BIT0_QCOM"/>
+        <enum value="0x00000200" name="GL_DEPTH_BUFFER_BIT1_QCOM"/>
+        <enum value="0x00000400" name="GL_DEPTH_BUFFER_BIT2_QCOM"/>
+        <enum value="0x00000800" name="GL_DEPTH_BUFFER_BIT3_QCOM"/>
+        <enum value="0x00001000" name="GL_DEPTH_BUFFER_BIT4_QCOM"/>
+        <enum value="0x00002000" name="GL_DEPTH_BUFFER_BIT5_QCOM"/>
+        <enum value="0x00004000" name="GL_DEPTH_BUFFER_BIT6_QCOM"/>
+        <enum value="0x00008000" name="GL_DEPTH_BUFFER_BIT7_QCOM"/>
+        <enum value="0x00010000" name="GL_STENCIL_BUFFER_BIT0_QCOM"/>
+        <enum value="0x00020000" name="GL_STENCIL_BUFFER_BIT1_QCOM"/>
+        <enum value="0x00040000" name="GL_STENCIL_BUFFER_BIT2_QCOM"/>
+        <enum value="0x00080000" name="GL_STENCIL_BUFFER_BIT3_QCOM"/>
+        <enum value="0x00100000" name="GL_STENCIL_BUFFER_BIT4_QCOM"/>
+        <enum value="0x00200000" name="GL_STENCIL_BUFFER_BIT5_QCOM"/>
+        <enum value="0x00400000" name="GL_STENCIL_BUFFER_BIT6_QCOM"/>
+        <enum value="0x00800000" name="GL_STENCIL_BUFFER_BIT7_QCOM"/>
+        <enum value="0x01000000" name="GL_MULTISAMPLE_BUFFER_BIT0_QCOM"/>
+        <enum value="0x02000000" name="GL_MULTISAMPLE_BUFFER_BIT1_QCOM"/>
+        <enum value="0x04000000" name="GL_MULTISAMPLE_BUFFER_BIT2_QCOM"/>
+        <enum value="0x08000000" name="GL_MULTISAMPLE_BUFFER_BIT3_QCOM"/>
+        <enum value="0x10000000" name="GL_MULTISAMPLE_BUFFER_BIT4_QCOM"/>
+        <enum value="0x20000000" name="GL_MULTISAMPLE_BUFFER_BIT5_QCOM"/>
+        <enum value="0x40000000" name="GL_MULTISAMPLE_BUFFER_BIT6_QCOM"/>
+        <enum value="0x80000000" name="GL_MULTISAMPLE_BUFFER_BIT7_QCOM"/>
+    </enums>
+
+    <enums namespace="GL" group="FfdMaskSGIX" type="bitmask">
+        <enum value="0x00000001" name="GL_TEXTURE_DEFORMATION_BIT_SGIX"/>
+        <enum value="0x00000002" name="GL_GEOMETRY_DEFORMATION_BIT_SGIX"/>
+    </enums>
+
+    <!-- Non-bitmask enums with their own namespace. Generally small numbers
+         used for indexed access. -->
+
+    <enums namespace="GL" group="TriangleListSUN" vendor="SUN">
+        <enum value="0x0001" name="GL_RESTART_SUN"/>
+        <enum value="0x0002" name="GL_REPLACE_MIDDLE_SUN"/>
+        <enum value="0x0003" name="GL_REPLACE_OLDEST_SUN"/>
+    </enums>
+
+    <enums namespace="GL" group="MapTextureFormatINTEL" vendor="INTEL" comment="Texture memory layouts for INTEL_map_texture">
+        <enum value="0" name="GL_LAYOUT_DEFAULT_INTEL"/>
+        <enum value="1" name="GL_LAYOUT_LINEAR_INTEL"/>
+        <enum value="2" name="GL_LAYOUT_LINEAR_CPU_CACHED_INTEL"/>
+    </enums>
+
+    <enums namespace="GL" group="TransformFeedbackTokenNV" vendor="NV" comment="For NV_transform_feedback. No clue why small negative values are used">
+        <enum value="-2" name="GL_NEXT_BUFFER_NV"/>
+        <enum value="-3" name="GL_SKIP_COMPONENTS4_NV"/>
+        <enum value="-4" name="GL_SKIP_COMPONENTS3_NV"/>
+        <enum value="-5" name="GL_SKIP_COMPONENTS2_NV"/>
+        <enum value="-6" name="GL_SKIP_COMPONENTS1_NV"/>
+    </enums>
+
+    <enums namespace="GL" group="PathRenderingTokenNV" vendor="NV">
+        <enum value="0x00" name="GL_CLOSE_PATH_NV"/>
+        <enum value="0x02" name="GL_MOVE_TO_NV"/>
+        <enum value="0x03" name="GL_RELATIVE_MOVE_TO_NV"/>
+        <enum value="0x04" name="GL_LINE_TO_NV"/>
+        <enum value="0x05" name="GL_RELATIVE_LINE_TO_NV"/>
+        <enum value="0x06" name="GL_HORIZONTAL_LINE_TO_NV"/>
+        <enum value="0x07" name="GL_RELATIVE_HORIZONTAL_LINE_TO_NV"/>
+        <enum value="0x08" name="GL_VERTICAL_LINE_TO_NV"/>
+        <enum value="0x09" name="GL_RELATIVE_VERTICAL_LINE_TO_NV"/>
+        <enum value="0x0A" name="GL_QUADRATIC_CURVE_TO_NV"/>
+        <enum value="0x0B" name="GL_RELATIVE_QUADRATIC_CURVE_TO_NV"/>
+        <enum value="0x0C" name="GL_CUBIC_CURVE_TO_NV"/>
+        <enum value="0x0D" name="GL_RELATIVE_CUBIC_CURVE_TO_NV"/>
+        <enum value="0x0E" name="GL_SMOOTH_QUADRATIC_CURVE_TO_NV"/>
+        <enum value="0x0F" name="GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV"/>
+        <enum value="0x10" name="GL_SMOOTH_CUBIC_CURVE_TO_NV"/>
+        <enum value="0x11" name="GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV"/>
+        <enum value="0x12" name="GL_SMALL_CCW_ARC_TO_NV"/>
+        <enum value="0x13" name="GL_RELATIVE_SMALL_CCW_ARC_TO_NV"/>
+        <enum value="0x14" name="GL_SMALL_CW_ARC_TO_NV"/>
+        <enum value="0x15" name="GL_RELATIVE_SMALL_CW_ARC_TO_NV"/>
+        <enum value="0x16" name="GL_LARGE_CCW_ARC_TO_NV"/>
+        <enum value="0x17" name="GL_RELATIVE_LARGE_CCW_ARC_TO_NV"/>
+        <enum value="0x18" name="GL_LARGE_CW_ARC_TO_NV"/>
+        <enum value="0x19" name="GL_RELATIVE_LARGE_CW_ARC_TO_NV"/>
+        <enum value="0xF0" name="GL_RESTART_PATH_NV"/>
+        <enum value="0xF2" name="GL_DUP_FIRST_CUBIC_CURVE_TO_NV"/>
+        <enum value="0xF4" name="GL_DUP_LAST_CUBIC_CURVE_TO_NV"/>
+        <enum value="0xF6" name="GL_RECT_NV"/>
+        <enum value="0xF8" name="GL_CIRCULAR_CCW_ARC_TO_NV"/>
+        <enum value="0xFA" name="GL_CIRCULAR_CW_ARC_TO_NV"/>
+        <enum value="0xFC" name="GL_CIRCULAR_TANGENT_ARC_TO_NV"/>
+        <enum value="0xFE" name="GL_ARC_TO_NV"/>
+        <enum value="0xFF" name="GL_RELATIVE_ARC_TO_NV"/>
+    </enums>
+
+    <!-- The default ("API") enum namespace starts here. While some
+         assigned values may overlap, and different parts of the
+         namespace are reserved for different purposes, it is a single
+         namespace. The "class" attribute indicates some of the reserved
+         purposes but is by no means complete (and cannot be, since many
+         tokens are reused for different purposes in different
+         extensions and API versions). -->
+
+    <enums namespace="GL" group="SpecialNumbers" vendor="ARB" comment="Tokens whose numeric value is intrinsically meaningful">
+        <enum value="0" name="GL_FALSE"/>
+        <enum value="0" name="GL_NO_ERROR"/>
+        <enum value="0" name="GL_ZERO"/>
+        <enum value="0" name="GL_NONE"/>
+        <enum value="0" name="GL_NONE_OES"/>
+        <enum value="1" name="GL_TRUE"/>
+        <enum value="1" name="GL_ONE"/>
+        <enum value="0xFFFFFFFF" name="GL_INVALID_INDEX" type="u" comment="Tagged as uint"/>
+        <enum value="0xFFFFFFFFFFFFFFFF" name="GL_TIMEOUT_IGNORED" type="ull" comment="Tagged as uint64"/>
+        <enum value="0xFFFFFFFFFFFFFFFF" name="GL_TIMEOUT_IGNORED_APPLE" type="ull" comment="Tagged as uint64"/>
+        <enum value="1" name="GL_VERSION_ES_CL_1_0" comment="Not an API enum. API definition macro for ES 1.0/1.1 headers"/>
+        <enum value="1" name="GL_VERSION_ES_CM_1_1" comment="Not an API enum. API definition macro for ES 1.0/1.1 headers"/>
+        <enum value="1" name="GL_VERSION_ES_CL_1_1" comment="Not an API enum. API definition macro for ES 1.0/1.1 headers"/>
+    </enums>
+
+    <enums namespace="GL" start="0x0000" end="0x7FFF" vendor="ARB" comment="Mostly OpenGL 1.0/1.1 enum assignments. Unused ranges should generally remain unused.">
+        <enum value="0x0000" name="GL_POINTS"/>
+        <enum value="0x0001" name="GL_LINES"/>
+        <enum value="0x0002" name="GL_LINE_LOOP"/>
+        <enum value="0x0003" name="GL_LINE_STRIP"/>
+        <enum value="0x0004" name="GL_TRIANGLES"/>
+        <enum value="0x0005" name="GL_TRIANGLE_STRIP"/>
+        <enum value="0x0006" name="GL_TRIANGLE_FAN"/>
+        <enum value="0x0007" name="GL_QUADS"/>
+        <enum value="0x0007" name="GL_QUADS_EXT"/>                                           
+        <enum value="0x0008" name="GL_QUAD_STRIP"/>
+        <enum value="0x0009" name="GL_POLYGON"/>
+        <enum value="0x000A" name="GL_LINES_ADJACENCY"/>
+        <enum value="0x000A" name="GL_LINES_ADJACENCY_ARB"/>
+        <enum value="0x000A" name="GL_LINES_ADJACENCY_EXT"/>
+        <enum value="0x000B" name="GL_LINE_STRIP_ADJACENCY"/>
+        <enum value="0x000B" name="GL_LINE_STRIP_ADJACENCY_ARB"/>
+        <enum value="0x000B" name="GL_LINE_STRIP_ADJACENCY_EXT"/>
+        <enum value="0x000C" name="GL_TRIANGLES_ADJACENCY"/>
+        <enum value="0x000C" name="GL_TRIANGLES_ADJACENCY_ARB"/>
+        <enum value="0x000C" name="GL_TRIANGLES_ADJACENCY_EXT"/>
+        <enum value="0x000D" name="GL_TRIANGLE_STRIP_ADJACENCY"/>
+        <enum value="0x000D" name="GL_TRIANGLE_STRIP_ADJACENCY_ARB"/>
+        <enum value="0x000D" name="GL_TRIANGLE_STRIP_ADJACENCY_EXT"/>
+        <enum value="0x000E" name="GL_PATCHES"/>
+        <enum value="0x000E" name="GL_PATCHES_EXT"/>                                         
+            <unused start="0x000F" end="0x00FF" comment="Unused for PrimitiveType"/>
+        <enum value="0x0100" name="GL_ACCUM"/>
+        <enum value="0x0101" name="GL_LOAD"/>
+        <enum value="0x0102" name="GL_RETURN"/>
+        <enum value="0x0103" name="GL_MULT"/>
+        <enum value="0x0104" name="GL_ADD"/>
+            <unused start="0x0105" end="0x01FF" comment="Unused for AccumOp"/>
+        <enum value="0x0200" name="GL_NEVER"/>
+        <enum value="0x0201" name="GL_LESS"/>
+        <enum value="0x0202" name="GL_EQUAL"/>
+        <enum value="0x0203" name="GL_LEQUAL"/>
+        <enum value="0x0204" name="GL_GREATER"/>
+        <enum value="0x0205" name="GL_NOTEQUAL"/>
+        <enum value="0x0206" name="GL_GEQUAL"/>
+        <enum value="0x0207" name="GL_ALWAYS"/>
+            <unused start="0x0208" end="0x02FF" comment="Unused for AlphaFunction"/>
+        <enum value="0x0300" name="GL_SRC_COLOR"/>
+        <enum value="0x0301" name="GL_ONE_MINUS_SRC_COLOR"/>
+        <enum value="0x0302" name="GL_SRC_ALPHA"/>
+        <enum value="0x0303" name="GL_ONE_MINUS_SRC_ALPHA"/>
+        <enum value="0x0304" name="GL_DST_ALPHA"/>
+        <enum value="0x0305" name="GL_ONE_MINUS_DST_ALPHA"/>
+        <enum value="0x0306" name="GL_DST_COLOR"/>
+        <enum value="0x0307" name="GL_ONE_MINUS_DST_COLOR"/>
+        <enum value="0x0308" name="GL_SRC_ALPHA_SATURATE"/>
+            <unused start="0x0309" end="0x03FF" comment="Unused for BlendingFactor"/>
+        <enum value="0x0400" name="GL_FRONT_LEFT"/>
+        <enum value="0x0401" name="GL_FRONT_RIGHT"/>
+        <enum value="0x0402" name="GL_BACK_LEFT"/>
+        <enum value="0x0403" name="GL_BACK_RIGHT"/>
+        <enum value="0x0404" name="GL_FRONT"/>
+        <enum value="0x0405" name="GL_BACK"/>
+        <enum value="0x0406" name="GL_LEFT"/>
+        <enum value="0x0407" name="GL_RIGHT"/>
+        <enum value="0x0408" name="GL_FRONT_AND_BACK"/>
+        <enum value="0x0409" name="GL_AUX0"/>
+        <enum value="0x040A" name="GL_AUX1"/>
+        <enum value="0x040B" name="GL_AUX2"/>
+        <enum value="0x040C" name="GL_AUX3"/>
+            <unused start="0x040D" end="0x04FF" comment="Unused for DrawBufferMode"/>
+        <enum value="0x0500" name="GL_INVALID_ENUM"/>
+        <enum value="0x0501" name="GL_INVALID_VALUE"/>
+        <enum value="0x0502" name="GL_INVALID_OPERATION"/>
+        <enum value="0x0503" name="GL_STACK_OVERFLOW"/>
+        <enum value="0x0503" name="GL_STACK_OVERFLOW_KHR"/>
+        <enum value="0x0504" name="GL_STACK_UNDERFLOW"/>
+        <enum value="0x0504" name="GL_STACK_UNDERFLOW_KHR"/>
+        <enum value="0x0505" name="GL_OUT_OF_MEMORY"/>
+        <enum value="0x0506" name="GL_INVALID_FRAMEBUFFER_OPERATION"/>
+        <enum value="0x0506" name="GL_INVALID_FRAMEBUFFER_OPERATION_EXT"/>
+        <enum value="0x0506" name="GL_INVALID_FRAMEBUFFER_OPERATION_OES"/>
+            <unused start="0x0507" end="0x05FF" comment="Unused for ErrorCode"/>
+        <enum value="0x0600" name="GL_2D"/>
+        <enum value="0x0601" name="GL_3D"/>
+        <enum value="0x0602" name="GL_3D_COLOR"/>
+        <enum value="0x0603" name="GL_3D_COLOR_TEXTURE"/>
+        <enum value="0x0604" name="GL_4D_COLOR_TEXTURE"/>
+            <unused start="0x0605" end="0x06FF" comment="Unused for FeedbackType"/>
+        <enum value="0x0700" name="GL_PASS_THROUGH_TOKEN"/>
+        <enum value="0x0701" name="GL_POINT_TOKEN"/>
+        <enum value="0x0702" name="GL_LINE_TOKEN"/>
+        <enum value="0x0703" name="GL_POLYGON_TOKEN"/>
+        <enum value="0x0704" name="GL_BITMAP_TOKEN"/>
+        <enum value="0x0705" name="GL_DRAW_PIXEL_TOKEN"/>
+        <enum value="0x0706" name="GL_COPY_PIXEL_TOKEN"/>
+        <enum value="0x0707" name="GL_LINE_RESET_TOKEN"/>
+            <unused start="0x0708" end="0x07FF" comment="Unused for FeedbackToken"/>
+        <enum value="0x0800" name="GL_EXP"/>
+        <enum value="0x0801" name="GL_EXP2"/>
+            <unused start="0x0802" end="0x08FF" comment="Unused for FogMode"/>
+        <enum value="0x0900" name="GL_CW"/>
+        <enum value="0x0901" name="GL_CCW"/>
+            <unused start="0x0902" end="0x09FF" comment="Unused for FrontFaceDirection"/>
+        <enum value="0x0A00" name="GL_COEFF"/>
+        <enum value="0x0A01" name="GL_ORDER"/>
+        <enum value="0x0A02" name="GL_DOMAIN"/>
+            <unused start="0x0A03" end="0x0AFF" comment="Unused for GetMapQuery"/>
+        <enum value="0x0B00" name="GL_CURRENT_COLOR"/>
+        <enum value="0x0B01" name="GL_CURRENT_INDEX"/>
+        <enum value="0x0B02" name="GL_CURRENT_NORMAL"/>
+        <enum value="0x0B03" name="GL_CURRENT_TEXTURE_COORDS"/>
+        <enum value="0x0B04" name="GL_CURRENT_RASTER_COLOR"/>
+        <enum value="0x0B05" name="GL_CURRENT_RASTER_INDEX"/>
+        <enum value="0x0B06" name="GL_CURRENT_RASTER_TEXTURE_COORDS"/>
+        <enum value="0x0B07" name="GL_CURRENT_RASTER_POSITION"/>
+        <enum value="0x0B08" name="GL_CURRENT_RASTER_POSITION_VALID"/>
+        <enum value="0x0B09" name="GL_CURRENT_RASTER_DISTANCE"/>
+
+        <enum value="0x0B10" name="GL_POINT_SMOOTH"/>
+        <enum value="0x0B11" name="GL_POINT_SIZE"/>
+        <enum value="0x0B12" name="GL_POINT_SIZE_RANGE"/>
+        <enum value="0x0B12" name="GL_SMOOTH_POINT_SIZE_RANGE" alias="GL_POINT_SIZE_RANGE"/>
+        <enum value="0x0B13" name="GL_POINT_SIZE_GRANULARITY"/>
+        <enum value="0x0B13" name="GL_SMOOTH_POINT_SIZE_GRANULARITY" alias="GL_POINT_SIZE_GRANULARITY"/>
+
+        <enum value="0x0B20" name="GL_LINE_SMOOTH"/>
+        <enum value="0x0B21" name="GL_LINE_WIDTH"/>
+        <enum value="0x0B22" name="GL_LINE_WIDTH_RANGE"/>
+        <enum value="0x0B22" name="GL_SMOOTH_LINE_WIDTH_RANGE" alias="GL_LINE_WIDTH_RANGE"/>
+        <enum value="0x0B23" name="GL_LINE_WIDTH_GRANULARITY"/>
+        <enum value="0x0B23" name="GL_SMOOTH_LINE_WIDTH_GRANULARITY" alias="GL_LINE_WIDTH_GRANULARITY"/>
+        <enum value="0x0B24" name="GL_LINE_STIPPLE"/>
+        <enum value="0x0B25" name="GL_LINE_STIPPLE_PATTERN"/>
+        <enum value="0x0B26" name="GL_LINE_STIPPLE_REPEAT"/>
+
+        <enum value="0x0B30" name="GL_LIST_MODE"/>
+        <enum value="0x0B31" name="GL_MAX_LIST_NESTING"/>
+        <enum value="0x0B32" name="GL_LIST_BASE"/>
+        <enum value="0x0B33" name="GL_LIST_INDEX"/>
+
+        <enum value="0x0B40" name="GL_POLYGON_MODE"/>
+        <enum value="0x0B41" name="GL_POLYGON_SMOOTH"/>
+        <enum value="0x0B42" name="GL_POLYGON_STIPPLE"/>
+        <enum value="0x0B43" name="GL_EDGE_FLAG"/>
+        <enum value="0x0B44" name="GL_CULL_FACE"/>
+        <enum value="0x0B45" name="GL_CULL_FACE_MODE"/>
+        <enum value="0x0B46" name="GL_FRONT_FACE"/>
+
+        <enum value="0x0B50" name="GL_LIGHTING"/>
+        <enum value="0x0B51" name="GL_LIGHT_MODEL_LOCAL_VIEWER"/>
+        <enum value="0x0B52" name="GL_LIGHT_MODEL_TWO_SIDE"/>
+        <enum value="0x0B53" name="GL_LIGHT_MODEL_AMBIENT"/>
+        <enum value="0x0B54" name="GL_SHADE_MODEL"/>
+        <enum value="0x0B55" name="GL_COLOR_MATERIAL_FACE"/>
+        <enum value="0x0B56" name="GL_COLOR_MATERIAL_PARAMETER"/>
+        <enum value="0x0B57" name="GL_COLOR_MATERIAL"/>
+
+        <enum value="0x0B60" name="GL_FOG"/>
+        <enum value="0x0B61" name="GL_FOG_INDEX"/>
+        <enum value="0x0B62" name="GL_FOG_DENSITY"/>
+        <enum value="0x0B63" name="GL_FOG_START"/>
+        <enum value="0x0B64" name="GL_FOG_END"/>
+        <enum value="0x0B65" name="GL_FOG_MODE"/>
+        <enum value="0x0B66" name="GL_FOG_COLOR"/>
+
+        <enum value="0x0B70" name="GL_DEPTH_RANGE"/>
+        <enum value="0x0B71" name="GL_DEPTH_TEST"/>
+        <enum value="0x0B72" name="GL_DEPTH_WRITEMASK"/>
+        <enum value="0x0B73" name="GL_DEPTH_CLEAR_VALUE"/>
+        <enum value="0x0B74" name="GL_DEPTH_FUNC"/>
+
+        <enum value="0x0B80" name="GL_ACCUM_CLEAR_VALUE"/>
+
+        <enum value="0x0B90" name="GL_STENCIL_TEST"/>
+        <enum value="0x0B91" name="GL_STENCIL_CLEAR_VALUE"/>
+        <enum value="0x0B92" name="GL_STENCIL_FUNC"/>
+        <enum value="0x0B93" name="GL_STENCIL_VALUE_MASK"/>
+        <enum value="0x0B94" name="GL_STENCIL_FAIL"/>
+        <enum value="0x0B95" name="GL_STENCIL_PASS_DEPTH_FAIL"/>
+        <enum value="0x0B96" name="GL_STENCIL_PASS_DEPTH_PASS"/>
+        <enum value="0x0B97" name="GL_STENCIL_REF"/>
+        <enum value="0x0B98" name="GL_STENCIL_WRITEMASK"/>
+
+        <enum value="0x0BA0" name="GL_MATRIX_MODE"/>
+        <enum value="0x0BA1" name="GL_NORMALIZE"/>
+        <enum value="0x0BA2" name="GL_VIEWPORT"/>
+        <enum value="0x0BA3" name="GL_MODELVIEW_STACK_DEPTH"/>
+        <enum value="0x0BA3" name="GL_MODELVIEW0_STACK_DEPTH_EXT"/>
+        <enum value="0x0BA4" name="GL_PROJECTION_STACK_DEPTH"/>
+        <enum value="0x0BA5" name="GL_TEXTURE_STACK_DEPTH"/>
+        <enum value="0x0BA6" name="GL_MODELVIEW_MATRIX"/>
+        <enum value="0x0BA6" name="GL_MODELVIEW0_MATRIX_EXT"/>
+        <enum value="0x0BA7" name="GL_PROJECTION_MATRIX"/>
+        <enum value="0x0BA8" name="GL_TEXTURE_MATRIX"/>
+
+        <enum value="0x0BB0" name="GL_ATTRIB_STACK_DEPTH"/>
+        <enum value="0x0BB1" name="GL_CLIENT_ATTRIB_STACK_DEPTH"/>
+
+        <enum value="0x0BC0" name="GL_ALPHA_TEST"/>
+        <enum value="0x0BC0" name="GL_ALPHA_TEST_QCOM"/>
+        <enum value="0x0BC1" name="GL_ALPHA_TEST_FUNC"/>
+        <enum value="0x0BC1" name="GL_ALPHA_TEST_FUNC_QCOM"/>
+        <enum value="0x0BC2" name="GL_ALPHA_TEST_REF"/>
+        <enum value="0x0BC2" name="GL_ALPHA_TEST_REF_QCOM"/>
+
+        <enum value="0x0BD0" name="GL_DITHER"/>
+
+        <enum value="0x0BE0" name="GL_BLEND_DST"/>
+        <enum value="0x0BE1" name="GL_BLEND_SRC"/>
+        <enum value="0x0BE2" name="GL_BLEND"/>
+
+        <enum value="0x0BF0" name="GL_LOGIC_OP_MODE"/>
+        <enum value="0x0BF1" name="GL_INDEX_LOGIC_OP"/>
+        <enum value="0x0BF1" name="GL_LOGIC_OP"/>
+        <enum value="0x0BF2" name="GL_COLOR_LOGIC_OP"/>
+
+        <enum value="0x0C00" name="GL_AUX_BUFFERS"/>
+        <enum value="0x0C01" name="GL_DRAW_BUFFER"/>
+        <enum value="0x0C01" name="GL_DRAW_BUFFER_EXT"/>
+        <enum value="0x0C02" name="GL_READ_BUFFER"/>
+        <enum value="0x0C02" name="GL_READ_BUFFER_EXT"/>
+        <enum value="0x0C02" name="GL_READ_BUFFER_NV"/>
+
+        <enum value="0x0C10" name="GL_SCISSOR_BOX"/>
+        <enum value="0x0C11" name="GL_SCISSOR_TEST"/>
+
+        <enum value="0x0C20" name="GL_INDEX_CLEAR_VALUE"/>
+        <enum value="0x0C21" name="GL_INDEX_WRITEMASK"/>
+        <enum value="0x0C22" name="GL_COLOR_CLEAR_VALUE"/>
+        <enum value="0x0C23" name="GL_COLOR_WRITEMASK"/>
+
+        <enum value="0x0C30" name="GL_INDEX_MODE"/>
+        <enum value="0x0C31" name="GL_RGBA_MODE"/>
+        <enum value="0x0C32" name="GL_DOUBLEBUFFER"/>
+        <enum value="0x0C33" name="GL_STEREO"/>
+
+        <enum value="0x0C40" name="GL_RENDER_MODE"/>
+
+        <enum value="0x0C50" name="GL_PERSPECTIVE_CORRECTION_HINT"/>
+        <enum value="0x0C51" name="GL_POINT_SMOOTH_HINT"/>
+        <enum value="0x0C52" name="GL_LINE_SMOOTH_HINT"/>
+        <enum value="0x0C53" name="GL_POLYGON_SMOOTH_HINT"/>
+        <enum value="0x0C54" name="GL_FOG_HINT"/>
+
+        <enum value="0x0C60" name="GL_TEXTURE_GEN_S"/>
+        <enum value="0x0C61" name="GL_TEXTURE_GEN_T"/>
+        <enum value="0x0C62" name="GL_TEXTURE_GEN_R"/>
+        <enum value="0x0C63" name="GL_TEXTURE_GEN_Q"/>
+
+        <enum value="0x0C70" name="GL_PIXEL_MAP_I_TO_I"/>
+        <enum value="0x0C71" name="GL_PIXEL_MAP_S_TO_S"/>
+        <enum value="0x0C72" name="GL_PIXEL_MAP_I_TO_R"/>
+        <enum value="0x0C73" name="GL_PIXEL_MAP_I_TO_G"/>
+        <enum value="0x0C74" name="GL_PIXEL_MAP_I_TO_B"/>
+        <enum value="0x0C75" name="GL_PIXEL_MAP_I_TO_A"/>
+        <enum value="0x0C76" name="GL_PIXEL_MAP_R_TO_R"/>
+        <enum value="0x0C77" name="GL_PIXEL_MAP_G_TO_G"/>
+        <enum value="0x0C78" name="GL_PIXEL_MAP_B_TO_B"/>
+        <enum value="0x0C79" name="GL_PIXEL_MAP_A_TO_A"/>
+
+        <enum value="0x0CB0" name="GL_PIXEL_MAP_I_TO_I_SIZE"/>
+        <enum value="0x0CB1" name="GL_PIXEL_MAP_S_TO_S_SIZE"/>
+        <enum value="0x0CB2" name="GL_PIXEL_MAP_I_TO_R_SIZE"/>
+        <enum value="0x0CB3" name="GL_PIXEL_MAP_I_TO_G_SIZE"/>
+        <enum value="0x0CB4" name="GL_PIXEL_MAP_I_TO_B_SIZE"/>
+        <enum value="0x0CB5" name="GL_PIXEL_MAP_I_TO_A_SIZE"/>
+        <enum value="0x0CB6" name="GL_PIXEL_MAP_R_TO_R_SIZE"/>
+        <enum value="0x0CB7" name="GL_PIXEL_MAP_G_TO_G_SIZE"/>
+        <enum value="0x0CB8" name="GL_PIXEL_MAP_B_TO_B_SIZE"/>
+        <enum value="0x0CB9" name="GL_PIXEL_MAP_A_TO_A_SIZE"/>
+
+        <enum value="0x0CF0" name="GL_UNPACK_SWAP_BYTES"/>
+        <enum value="0x0CF1" name="GL_UNPACK_LSB_FIRST"/>
+        <enum value="0x0CF2" name="GL_UNPACK_ROW_LENGTH"/>
+        <enum value="0x0CF2" name="GL_UNPACK_ROW_LENGTH_EXT"/>
+        <enum value="0x0CF3" name="GL_UNPACK_SKIP_ROWS"/>
+        <enum value="0x0CF3" name="GL_UNPACK_SKIP_ROWS_EXT"/>
+        <enum value="0x0CF4" name="GL_UNPACK_SKIP_PIXELS"/>
+        <enum value="0x0CF4" name="GL_UNPACK_SKIP_PIXELS_EXT"/>
+        <enum value="0x0CF5" name="GL_UNPACK_ALIGNMENT"/>
+
+        <enum value="0x0D00" name="GL_PACK_SWAP_BYTES"/>
+        <enum value="0x0D01" name="GL_PACK_LSB_FIRST"/>
+        <enum value="0x0D02" name="GL_PACK_ROW_LENGTH"/>
+        <enum value="0x0D03" name="GL_PACK_SKIP_ROWS"/>
+        <enum value="0x0D04" name="GL_PACK_SKIP_PIXELS"/>
+        <enum value="0x0D05" name="GL_PACK_ALIGNMENT"/>
+
+        <enum value="0x0D10" name="GL_MAP_COLOR"/>
+        <enum value="0x0D11" name="GL_MAP_STENCIL"/>
+        <enum value="0x0D12" name="GL_INDEX_SHIFT"/>
+        <enum value="0x0D13" name="GL_INDEX_OFFSET"/>
+        <enum value="0x0D14" name="GL_RED_SCALE"/>
+        <enum value="0x0D15" name="GL_RED_BIAS"/>
+        <enum value="0x0D16" name="GL_ZOOM_X"/>
+        <enum value="0x0D17" name="GL_ZOOM_Y"/>
+        <enum value="0x0D18" name="GL_GREEN_SCALE"/>
+        <enum value="0x0D19" name="GL_GREEN_BIAS"/>
+        <enum value="0x0D1A" name="GL_BLUE_SCALE"/>
+        <enum value="0x0D1B" name="GL_BLUE_BIAS"/>
+        <enum value="0x0D1C" name="GL_ALPHA_SCALE"/>
+        <enum value="0x0D1D" name="GL_ALPHA_BIAS"/>
+        <enum value="0x0D1E" name="GL_DEPTH_SCALE"/>
+        <enum value="0x0D1F" name="GL_DEPTH_BIAS"/>
+
+        <enum value="0x0D30" name="GL_MAX_EVAL_ORDER"/>
+        <enum value="0x0D31" name="GL_MAX_LIGHTS"/>
+        <enum value="0x0D32" name="GL_MAX_CLIP_PLANES"/>
+        <enum value="0x0D32" name="GL_MAX_CLIP_PLANES_IMG"/>
+        <enum value="0x0D32" name="GL_MAX_CLIP_DISTANCES" alias="GL_MAX_CLIP_PLANES"/>
+        <enum value="0x0D33" name="GL_MAX_TEXTURE_SIZE"/>
+        <enum value="0x0D34" name="GL_MAX_PIXEL_MAP_TABLE"/>
+        <enum value="0x0D35" name="GL_MAX_ATTRIB_STACK_DEPTH"/>
+        <enum value="0x0D36" name="GL_MAX_MODELVIEW_STACK_DEPTH"/>
+        <enum value="0x0D37" name="GL_MAX_NAME_STACK_DEPTH"/>
+        <enum value="0x0D38" name="GL_MAX_PROJECTION_STACK_DEPTH"/>
+        <enum value="0x0D39" name="GL_MAX_TEXTURE_STACK_DEPTH"/>
+        <enum value="0x0D3A" name="GL_MAX_VIEWPORT_DIMS"/>
+        <enum value="0x0D3B" name="GL_MAX_CLIENT_ATTRIB_STACK_DEPTH"/>
+
+        <enum value="0x0D50" name="GL_SUBPIXEL_BITS"/>
+        <enum value="0x0D51" name="GL_INDEX_BITS"/>
+        <enum value="0x0D52" name="GL_RED_BITS"/>
+        <enum value="0x0D53" name="GL_GREEN_BITS"/>
+        <enum value="0x0D54" name="GL_BLUE_BITS"/>
+        <enum value="0x0D55" name="GL_ALPHA_BITS"/>
+        <enum value="0x0D56" name="GL_DEPTH_BITS"/>
+        <enum value="0x0D57" name="GL_STENCIL_BITS"/>
+        <enum value="0x0D58" name="GL_ACCUM_RED_BITS"/>
+        <enum value="0x0D59" name="GL_ACCUM_GREEN_BITS"/>
+        <enum value="0x0D5A" name="GL_ACCUM_BLUE_BITS"/>
+        <enum value="0x0D5B" name="GL_ACCUM_ALPHA_BITS"/>
+
+        <enum value="0x0D70" name="GL_NAME_STACK_DEPTH"/>
+
+        <enum value="0x0D80" name="GL_AUTO_NORMAL"/>
+
+        <enum value="0x0D90" name="GL_MAP1_COLOR_4"/>
+        <enum value="0x0D91" name="GL_MAP1_INDEX"/>
+        <enum value="0x0D92" name="GL_MAP1_NORMAL"/>
+        <enum value="0x0D93" name="GL_MAP1_TEXTURE_COORD_1"/>
+        <enum value="0x0D94" name="GL_MAP1_TEXTURE_COORD_2"/>
+        <enum value="0x0D95" name="GL_MAP1_TEXTURE_COORD_3"/>
+        <enum value="0x0D96" name="GL_MAP1_TEXTURE_COORD_4"/>
+        <enum value="0x0D97" name="GL_MAP1_VERTEX_3"/>
+        <enum value="0x0D98" name="GL_MAP1_VERTEX_4"/>
+
+        <enum value="0x0DB0" name="GL_MAP2_COLOR_4"/>
+        <enum value="0x0DB1" name="GL_MAP2_INDEX"/>
+        <enum value="0x0DB2" name="GL_MAP2_NORMAL"/>
+        <enum value="0x0DB3" name="GL_MAP2_TEXTURE_COORD_1"/>
+        <enum value="0x0DB4" name="GL_MAP2_TEXTURE_COORD_2"/>
+        <enum value="0x0DB5" name="GL_MAP2_TEXTURE_COORD_3"/>
+        <enum value="0x0DB6" name="GL_MAP2_TEXTURE_COORD_4"/>
+        <enum value="0x0DB7" name="GL_MAP2_VERTEX_3"/>
+        <enum value="0x0DB8" name="GL_MAP2_VERTEX_4"/>
+
+        <enum value="0x0DD0" name="GL_MAP1_GRID_DOMAIN"/>
+        <enum value="0x0DD1" name="GL_MAP1_GRID_SEGMENTS"/>
+        <enum value="0x0DD2" name="GL_MAP2_GRID_DOMAIN"/>
+        <enum value="0x0DD3" name="GL_MAP2_GRID_SEGMENTS"/>
+
+        <enum value="0x0DE0" name="GL_TEXTURE_1D"/>
+        <enum value="0x0DE1" name="GL_TEXTURE_2D"/>
+
+        <enum value="0x0DF0" name="GL_FEEDBACK_BUFFER_POINTER"/>
+        <enum value="0x0DF1" name="GL_FEEDBACK_BUFFER_SIZE"/>
+        <enum value="0x0DF2" name="GL_FEEDBACK_BUFFER_TYPE"/>
+        <enum value="0x0DF3" name="GL_SELECTION_BUFFER_POINTER"/>
+        <enum value="0x0DF4" name="GL_SELECTION_BUFFER_SIZE"/>
+            <unused start="0x0DF5" end="0xFFFF" comment="Unused for GetPName"/>
+        <enum value="0x1000" name="GL_TEXTURE_WIDTH"/>
+        <enum value="0x1001" name="GL_TEXTURE_HEIGHT"/>
+        <enum value="0x1003" name="GL_TEXTURE_INTERNAL_FORMAT"/>
+        <enum value="0x1003" name="GL_TEXTURE_COMPONENTS"/>
+        <enum value="0x1004" name="GL_TEXTURE_BORDER_COLOR"/>
+        <enum value="0x1004" name="GL_TEXTURE_BORDER_COLOR_EXT"/>
+        <enum value="0x1004" name="GL_TEXTURE_BORDER_COLOR_NV"/>
+        <enum value="0x1005" name="GL_TEXTURE_BORDER"/>
+            <unused start="0x1006" end="0x10FF" comment="Unused for GetTextureParameter"/>
+        <enum value="0x1100" name="GL_DONT_CARE"/>
+        <enum value="0x1101" name="GL_FASTEST"/>
+        <enum value="0x1102" name="GL_NICEST"/>
+            <unused start="0x1103" end="0x11FF" comment="Unused for HintMode"/>
+        <enum value="0x1200" name="GL_AMBIENT"/>
+        <enum value="0x1201" name="GL_DIFFUSE"/>
+        <enum value="0x1202" name="GL_SPECULAR"/>
+        <enum value="0x1203" name="GL_POSITION"/>
+        <enum value="0x1204" name="GL_SPOT_DIRECTION"/>
+        <enum value="0x1205" name="GL_SPOT_EXPONENT"/>
+        <enum value="0x1206" name="GL_SPOT_CUTOFF"/>
+        <enum value="0x1207" name="GL_CONSTANT_ATTENUATION"/>
+        <enum value="0x1208" name="GL_LINEAR_ATTENUATION"/>
+        <enum value="0x1209" name="GL_QUADRATIC_ATTENUATION"/>
+            <unused start="0x1210" end="0x12FF" comment="Unused for LightParameter"/>
+        <enum value="0x1300" name="GL_COMPILE"/>
+        <enum value="0x1301" name="GL_COMPILE_AND_EXECUTE"/>
+            <unused start="0x1302" end="0x13FF" comment="Unused for ListMode"/>
+        <enum value="0x1400" name="GL_BYTE"/>
+        <enum value="0x1401" name="GL_UNSIGNED_BYTE"/>
+        <enum value="0x1402" name="GL_SHORT"/>
+        <enum value="0x1403" name="GL_UNSIGNED_SHORT"/>
+        <enum value="0x1404" name="GL_INT"/>
+        <enum value="0x1405" name="GL_UNSIGNED_INT"/>
+        <enum value="0x1406" name="GL_FLOAT"/>
+        <enum value="0x1407" name="GL_2_BYTES"/>
+        <enum value="0x1408" name="GL_3_BYTES"/>
+        <enum value="0x1409" name="GL_4_BYTES"/>
+        <enum value="0x140A" name="GL_DOUBLE"/>
+        <enum value="0x140A" name="GL_DOUBLE_EXT"/>
+        <enum value="0x140B" name="GL_HALF_FLOAT"/>
+        <enum value="0x140B" name="GL_HALF_FLOAT_ARB"/>
+        <enum value="0x140B" name="GL_HALF_FLOAT_NV"/>
+        <enum value="0x140B" name="GL_HALF_APPLE"/>
+        <enum value="0x140C" name="GL_FIXED"/>
+        <enum value="0x140C" name="GL_FIXED_OES"/>
+            <unused start="0x140D" comment="Leave gap to preserve even/odd int/uint token values"/>
+        <enum value="0x140E" name="GL_INT64_NV"/>
+        <enum value="0x140F" name="GL_UNSIGNED_INT64_ARB"/>
+        <enum value="0x140F" name="GL_UNSIGNED_INT64_NV"/>
+            <unused start="0x1410" end="0x14FF" comment="Unused for DataType"/>
+        <enum value="0x1500" name="GL_CLEAR"/>
+        <enum value="0x1501" name="GL_AND"/>
+        <enum value="0x1502" name="GL_AND_REVERSE"/>
+        <enum value="0x1503" name="GL_COPY"/>
+        <enum value="0x1504" name="GL_AND_INVERTED"/>
+        <enum value="0x1505" name="GL_NOOP"/>
+        <enum value="0x1506" name="GL_XOR"/>
+        <enum value="0x1506" name="GL_XOR_NV"/>
+        <enum value="0x1507" name="GL_OR"/>
+        <enum value="0x1508" name="GL_NOR"/>
+        <enum value="0x1509" name="GL_EQUIV"/>
+        <enum value="0x150A" name="GL_INVERT"/>
+        <enum value="0x150B" name="GL_OR_REVERSE"/>
+        <enum value="0x150C" name="GL_COPY_INVERTED"/>
+        <enum value="0x150D" name="GL_OR_INVERTED"/>
+        <enum value="0x150E" name="GL_NAND"/>
+        <enum value="0x150F" name="GL_SET"/>
+            <unused start="0x1510" end="0x15FF" comment="Unused for LogicOp"/>
+        <enum value="0x1600" name="GL_EMISSION"/>
+        <enum value="0x1601" name="GL_SHININESS"/>
+        <enum value="0x1602" name="GL_AMBIENT_AND_DIFFUSE"/>
+        <enum value="0x1603" name="GL_COLOR_INDEXES"/>
+            <unused start="0x1604" end="0x16FF" comment="Unused for MaterialParameter"/>
+        <enum value="0x1700" name="GL_MODELVIEW"/>
+        <enum value="0x1700" name="GL_MODELVIEW0_ARB"/>
+        <enum value="0x1700" name="GL_MODELVIEW0_EXT"/>
+        <enum value="0x1701" name="GL_PROJECTION"/>
+        <enum value="0x1702" name="GL_TEXTURE"/>
+            <unused start="0x1703" end="0x17FF" comment="Unused for MatrixMode"/>
+        <enum value="0x1800" name="GL_COLOR"/>
+        <enum value="0x1800" name="GL_COLOR_EXT"/>
+        <enum value="0x1801" name="GL_DEPTH"/>
+        <enum value="0x1801" name="GL_DEPTH_EXT"/>
+        <enum value="0x1802" name="GL_STENCIL"/>
+        <enum value="0x1802" name="GL_STENCIL_EXT"/>
+            <unused start="0x1803" end="0x18FF" comment="Unused for PixelCopyType"/>
+        <enum value="0x1900" name="GL_COLOR_INDEX"/>
+        <enum value="0x1901" name="GL_STENCIL_INDEX"/>
+        <enum value="0x1901" name="GL_STENCIL_INDEX_OES"/>
+        <enum value="0x1902" name="GL_DEPTH_COMPONENT"/>
+        <enum value="0x1903" name="GL_RED"/>
+        <enum value="0x1903" name="GL_RED_EXT"/>
+        <enum value="0x1903" name="GL_RED_NV"/>
+        <enum value="0x1904" name="GL_GREEN"/>
+        <enum value="0x1904" name="GL_GREEN_NV"/>
+        <enum value="0x1905" name="GL_BLUE"/>
+        <enum value="0x1905" name="GL_BLUE_NV"/>
+        <enum value="0x1906" name="GL_ALPHA"/>
+        <enum value="0x1907" name="GL_RGB"/>
+        <enum value="0x1908" name="GL_RGBA"/>
+        <enum value="0x1909" name="GL_LUMINANCE"/>
+        <enum value="0x190A" name="GL_LUMINANCE_ALPHA"/>
+            <unused start="0x1910" end="0x19FF" comment="Unused for PixelFormat"/>
+        <enum value="0x1A00" name="GL_BITMAP"/>
+            <unused start="0x1A01" end="0x1AFF" comment="Unused for PixelType"/>
+        <enum value="0x1B00" name="GL_POINT"/>
+        <enum value="0x1B01" name="GL_LINE"/>
+        <enum value="0x1B02" name="GL_FILL"/>
+            <unused start="0x1B03" end="0x1BFF" comment="Unused for PolygonMode"/>
+        <enum value="0x1C00" name="GL_RENDER"/>
+        <enum value="0x1C01" name="GL_FEEDBACK"/>
+        <enum value="0x1C02" name="GL_SELECT"/>
+            <unused start="0x1C03" end="0x1CFF" comment="Unused for RenderingMode"/>
+        <enum value="0x1D00" name="GL_FLAT"/>
+        <enum value="0x1D01" name="GL_SMOOTH"/>
+            <unused start="0x1D02" end="0x1DFF" comment="Unused for ShadingModel"/>
+        <enum value="0x1E00" name="GL_KEEP"/>
+        <enum value="0x1E01" name="GL_REPLACE"/>
+        <enum value="0x1E02" name="GL_INCR"/>
+        <enum value="0x1E03" name="GL_DECR"/>
+            <unused start="0x1E04" end="0x1EFF" comment="Unused for StencilOp"/>
+        <enum value="0x1F00" name="GL_VENDOR"/>
+        <enum value="0x1F01" name="GL_RENDERER"/>
+        <enum value="0x1F02" name="GL_VERSION"/>
+        <enum value="0x1F03" name="GL_EXTENSIONS"/>
+            <unused start="0x1F04" end="0x1FFF" comment="Unused for StringName"/>
+        <enum value="0x2000" name="GL_S"/>
+        <enum value="0x2001" name="GL_T"/>
+        <enum value="0x2002" name="GL_R"/>
+        <enum value="0x2003" name="GL_Q"/>
+            <unused start="0x2004" end="0x20FF" comment="Unused for TextureCoordName"/>
+        <enum value="0x2100" name="GL_MODULATE"/>
+        <enum value="0x2101" name="GL_DECAL"/>
+            <unused start="0x2102" end="0x21FF" comment="Unused for TextureEnvMode"/>
+        <enum value="0x2200" name="GL_TEXTURE_ENV_MODE"/>
+        <enum value="0x2201" name="GL_TEXTURE_ENV_COLOR"/>
+            <unused start="0x2202" end="0x22FF" comment="Unused for TextureEnvParameter"/>
+        <enum value="0x2300" name="GL_TEXTURE_ENV"/>
+            <unused start="0x2301" end="0x23FF" comment="Unused for TextureEnvTarget"/>
+        <enum value="0x2400" name="GL_EYE_LINEAR"/>
+        <enum value="0x2401" name="GL_OBJECT_LINEAR"/>
+        <enum value="0x2402" name="GL_SPHERE_MAP"/>
+            <unused start="0x2403" end="0x24FF" comment="Unused for TextureGenMode"/>
+        <enum value="0x2500" name="GL_TEXTURE_GEN_MODE"/>
+        <enum value="0x2500" name="GL_TEXTURE_GEN_MODE_OES"/>
+        <enum value="0x2501" name="GL_OBJECT_PLANE"/>
+        <enum value="0x2502" name="GL_EYE_PLANE"/>
+            <unused start="0x2503" end="0x25FF" comment="Unused for TextureGenParameter"/>
+        <enum value="0x2600" name="GL_NEAREST"/>
+        <enum value="0x2601" name="GL_LINEAR"/>
+            <unused start="0x2602" end="0x26FF" comment="Unused for TextureMagFilter"/>
+        <enum value="0x2700" name="GL_NEAREST_MIPMAP_NEAREST"/>
+        <enum value="0x2701" name="GL_LINEAR_MIPMAP_NEAREST"/>
+        <enum value="0x2702" name="GL_NEAREST_MIPMAP_LINEAR"/>
+        <enum value="0x2703" name="GL_LINEAR_MIPMAP_LINEAR"/>
+            <unused start="0x2704" end="0x27FF" comment="Unused for TextureMinFilter"/>
+        <enum value="0x2800" name="GL_TEXTURE_MAG_FILTER"/>
+        <enum value="0x2801" name="GL_TEXTURE_MIN_FILTER"/>
+        <enum value="0x2802" name="GL_TEXTURE_WRAP_S"/>
+        <enum value="0x2803" name="GL_TEXTURE_WRAP_T"/>
+            <unused start="0x2804" end="0x28FF" comment="Unused for TextureParameterName"/>
+        <enum value="0x2900" name="GL_CLAMP"/>
+        <enum value="0x2901" name="GL_REPEAT"/>
+            <unused start="0x2902" end="0x29FF" comment="Unused for TextureWrapMode"/>
+        <enum value="0x2A00" name="GL_POLYGON_OFFSET_UNITS"/>
+        <enum value="0x2A01" name="GL_POLYGON_OFFSET_POINT"/>
+        <enum value="0x2A02" name="GL_POLYGON_OFFSET_LINE"/>
+            <unused start="0x2A03" end="0x2A09" comment="Unused for PolygonOffset"/>
+        <enum value="0x2A10" name="GL_R3_G3_B2"/>
+            <unused start="0x2A11" end="0x2A1F" comment="Unused for InternalFormat"/>
+        <enum value="0x2A20" name="GL_V2F"/>
+        <enum value="0x2A21" name="GL_V3F"/>
+        <enum value="0x2A22" name="GL_C4UB_V2F"/>
+        <enum value="0x2A23" name="GL_C4UB_V3F"/>
+        <enum value="0x2A24" name="GL_C3F_V3F"/>
+        <enum value="0x2A25" name="GL_N3F_V3F"/>
+        <enum value="0x2A26" name="GL_C4F_N3F_V3F"/>
+        <enum value="0x2A27" name="GL_T2F_V3F"/>
+        <enum value="0x2A28" name="GL_T4F_V4F"/>
+        <enum value="0x2A29" name="GL_T2F_C4UB_V3F"/>
+        <enum value="0x2A2A" name="GL_T2F_C3F_V3F"/>
+        <enum value="0x2A2B" name="GL_T2F_N3F_V3F"/>
+        <enum value="0x2A2C" name="GL_T2F_C4F_N3F_V3F"/>
+        <enum value="0x2A2D" name="GL_T4F_C4F_N3F_V4F"/>
+            <unused start="0x2A2E" end="0x2FFF" comment="Unused for InterleavedArrayFormat"/>
+        <enum value="0x3000" name="GL_CLIP_PLANE0"/>
+        <enum value="0x3000" name="GL_CLIP_PLANE0_IMG"/>
+        <enum value="0x3000" name="GL_CLIP_DISTANCE0" alias="GL_CLIP_PLANE0"/>
+        <enum value="0x3001" name="GL_CLIP_PLANE1"/>
+        <enum value="0x3001" name="GL_CLIP_PLANE1_IMG"/>
+        <enum value="0x3001" name="GL_CLIP_DISTANCE1" alias="GL_CLIP_PLANE1"/>
+        <enum value="0x3002" name="GL_CLIP_PLANE2"/>
+        <enum value="0x3002" name="GL_CLIP_PLANE2_IMG"/>
+        <enum value="0x3002" name="GL_CLIP_DISTANCE2" alias="GL_CLIP_PLANE2"/>
+        <enum value="0x3003" name="GL_CLIP_PLANE3"/>
+        <enum value="0x3003" name="GL_CLIP_PLANE3_IMG"/>
+        <enum value="0x3003" name="GL_CLIP_DISTANCE3" alias="GL_CLIP_PLANE3"/>
+        <enum value="0x3004" name="GL_CLIP_PLANE4"/>
+        <enum value="0x3004" name="GL_CLIP_PLANE4_IMG"/>
+        <enum value="0x3004" name="GL_CLIP_DISTANCE4" alias="GL_CLIP_PLANE4"/>
+        <enum value="0x3005" name="GL_CLIP_PLANE5"/>
+        <enum value="0x3005" name="GL_CLIP_PLANE5_IMG"/>
+        <enum value="0x3005" name="GL_CLIP_DISTANCE5" alias="GL_CLIP_PLANE5"/>
+        <enum value="0x3006" name="GL_CLIP_DISTANCE6"/>
+        <enum value="0x3007" name="GL_CLIP_DISTANCE7"/>
+            <unused start="0x3008" end="0x3FFF" comment="Unused for ClipPlaneName"/>
+        <enum value="0x4000" name="GL_LIGHT0"/>
+        <enum value="0x4001" name="GL_LIGHT1"/>
+        <enum value="0x4002" name="GL_LIGHT2"/>
+        <enum value="0x4003" name="GL_LIGHT3"/>
+        <enum value="0x4004" name="GL_LIGHT4"/>
+        <enum value="0x4005" name="GL_LIGHT5"/>
+        <enum value="0x4006" name="GL_LIGHT6"/>
+        <enum value="0x4007" name="GL_LIGHT7"/>
+            <unused start="0x4008" end="0x4FFF" comment="Unused for LightName"/>
+            <unused start="0x5000" end="0x5FFF" comment="Unused. Do not use."/>
+            <unused start="0x6000" end="0x6FFF" comment="Experimental (internal/test only) range. DO NOT SHIP VALUES IN THIS RANGE."/>
+            <unused start="0x7000" end="0x7FFF" comment="Unused. Do not use."/>
+    </enums>
+
+    <enums namespace="GL" start="0x8000" end="0x80BF" vendor="SGI" comment="The primary GL enumerant space begins here. All modern                     enum allocations are in this range. These enums are                     mostly assigned the default class since it's a great                     deal of not very useful work to be more specific"/>
+
+    <enums namespace="GL" vendor="ARB">
+        <enum value="0x8000" name="GL_ABGR_EXT"/>
+        <enum value="0x8001" name="GL_CONSTANT_COLOR"/>
+        <enum value="0x8001" name="GL_CONSTANT_COLOR_EXT"/>
+        <enum value="0x8002" name="GL_ONE_MINUS_CONSTANT_COLOR"/>
+        <enum value="0x8002" name="GL_ONE_MINUS_CONSTANT_COLOR_EXT"/>
+        <enum value="0x8003" name="GL_CONSTANT_ALPHA"/>
+        <enum value="0x8003" name="GL_CONSTANT_ALPHA_EXT"/>
+        <enum value="0x8004" name="GL_ONE_MINUS_CONSTANT_ALPHA"/>
+        <enum value="0x8004" name="GL_ONE_MINUS_CONSTANT_ALPHA_EXT"/>
+        <enum value="0x8005" name="GL_BLEND_COLOR"/>
+        <enum value="0x8005" name="GL_BLEND_COLOR_EXT"/>
+        <enum value="0x8006" name="GL_FUNC_ADD"/>
+        <enum value="0x8006" name="GL_FUNC_ADD_EXT"/>
+        <enum value="0x8006" name="GL_FUNC_ADD_OES"/>
+        <enum value="0x8007" name="GL_MIN"/>
+        <enum value="0x8007" name="GL_MIN_EXT"/>
+        <enum value="0x8008" name="GL_MAX"/>
+        <enum value="0x8008" name="GL_MAX_EXT"/>
+        <enum value="0x8009" name="GL_BLEND_EQUATION"/>
+        <enum value="0x8009" name="GL_BLEND_EQUATION_EXT"/>
+        <enum value="0x8009" name="GL_BLEND_EQUATION_OES"/>
+        <enum value="0x8009" name="GL_BLEND_EQUATION_RGB"/>
+        <enum value="0x8009" name="GL_BLEND_EQUATION_RGB_EXT"/>
+        <enum value="0x8009" name="GL_BLEND_EQUATION_RGB_OES"/>
+        <enum value="0x800A" name="GL_FUNC_SUBTRACT"/>
+        <enum value="0x800A" name="GL_FUNC_SUBTRACT_EXT"/>
+        <enum value="0x800A" name="GL_FUNC_SUBTRACT_OES"/>
+        <enum value="0x800B" name="GL_FUNC_REVERSE_SUBTRACT"/>
+        <enum value="0x800B" name="GL_FUNC_REVERSE_SUBTRACT_EXT"/>
+        <enum value="0x800B" name="GL_FUNC_REVERSE_SUBTRACT_OES"/>
+        <enum value="0x800C" name="GL_CMYK_EXT"/>
+        <enum value="0x800D" name="GL_CMYKA_EXT"/>
+        <enum value="0x800E" name="GL_PACK_CMYK_HINT_EXT"/>
+        <enum value="0x800F" name="GL_UNPACK_CMYK_HINT_EXT"/>
+        <enum value="0x8010" name="GL_CONVOLUTION_1D"/>
+        <enum value="0x8010" name="GL_CONVOLUTION_1D_EXT"/>
+        <enum value="0x8011" name="GL_CONVOLUTION_2D"/>
+        <enum value="0x8011" name="GL_CONVOLUTION_2D_EXT"/>
+        <enum value="0x8012" name="GL_SEPARABLE_2D"/>
+        <enum value="0x8012" name="GL_SEPARABLE_2D_EXT"/>
+        <enum value="0x8013" name="GL_CONVOLUTION_BORDER_MODE"/>
+        <enum value="0x8013" name="GL_CONVOLUTION_BORDER_MODE_EXT"/>
+        <enum value="0x8014" name="GL_CONVOLUTION_FILTER_SCALE"/>
+        <enum value="0x8014" name="GL_CONVOLUTION_FILTER_SCALE_EXT"/>
+        <enum value="0x8015" name="GL_CONVOLUTION_FILTER_BIAS"/>
+        <enum value="0x8015" name="GL_CONVOLUTION_FILTER_BIAS_EXT"/>
+        <enum value="0x8016" name="GL_REDUCE"/>
+        <enum value="0x8016" name="GL_REDUCE_EXT"/>
+        <enum value="0x8017" name="GL_CONVOLUTION_FORMAT"/>
+        <enum value="0x8017" name="GL_CONVOLUTION_FORMAT_EXT"/>
+        <enum value="0x8018" name="GL_CONVOLUTION_WIDTH"/>
+        <enum value="0x8018" name="GL_CONVOLUTION_WIDTH_EXT"/>
+        <enum value="0x8019" name="GL_CONVOLUTION_HEIGHT"/>
+        <enum value="0x8019" name="GL_CONVOLUTION_HEIGHT_EXT"/>
+        <enum value="0x801A" name="GL_MAX_CONVOLUTION_WIDTH"/>
+        <enum value="0x801A" name="GL_MAX_CONVOLUTION_WIDTH_EXT"/>
+        <enum value="0x801B" name="GL_MAX_CONVOLUTION_HEIGHT"/>
+        <enum value="0x801B" name="GL_MAX_CONVOLUTION_HEIGHT_EXT"/>
+        <enum value="0x801C" name="GL_POST_CONVOLUTION_RED_SCALE"/>
+        <enum value="0x801C" name="GL_POST_CONVOLUTION_RED_SCALE_EXT"/>
+        <enum value="0x801D" name="GL_POST_CONVOLUTION_GREEN_SCALE"/>
+        <enum value="0x801D" name="GL_POST_CONVOLUTION_GREEN_SCALE_EXT"/>
+        <enum value="0x801E" name="GL_POST_CONVOLUTION_BLUE_SCALE"/>
+        <enum value="0x801E" name="GL_POST_CONVOLUTION_BLUE_SCALE_EXT"/>
+        <enum value="0x801F" name="GL_POST_CONVOLUTION_ALPHA_SCALE"/>
+        <enum value="0x801F" name="GL_POST_CONVOLUTION_ALPHA_SCALE_EXT"/>
+        <enum value="0x8020" name="GL_POST_CONVOLUTION_RED_BIAS"/>
+        <enum value="0x8020" name="GL_POST_CONVOLUTION_RED_BIAS_EXT"/>
+        <enum value="0x8021" name="GL_POST_CONVOLUTION_GREEN_BIAS"/>
+        <enum value="0x8021" name="GL_POST_CONVOLUTION_GREEN_BIAS_EXT"/>
+        <enum value="0x8022" name="GL_POST_CONVOLUTION_BLUE_BIAS"/>
+        <enum value="0x8022" name="GL_POST_CONVOLUTION_BLUE_BIAS_EXT"/>
+        <enum value="0x8023" name="GL_POST_CONVOLUTION_ALPHA_BIAS"/>
+        <enum value="0x8023" name="GL_POST_CONVOLUTION_ALPHA_BIAS_EXT"/>
+        <enum value="0x8024" name="GL_HISTOGRAM"/>
+        <enum value="0x8024" name="GL_HISTOGRAM_EXT"/>
+        <enum value="0x8025" name="GL_PROXY_HISTOGRAM"/>
+        <enum value="0x8025" name="GL_PROXY_HISTOGRAM_EXT"/>
+        <enum value="0x8026" name="GL_HISTOGRAM_WIDTH"/>
+        <enum value="0x8026" name="GL_HISTOGRAM_WIDTH_EXT"/>
+        <enum value="0x8027" name="GL_HISTOGRAM_FORMAT"/>
+        <enum value="0x8027" name="GL_HISTOGRAM_FORMAT_EXT"/>
+        <enum value="0x8028" name="GL_HISTOGRAM_RED_SIZE"/>
+        <enum value="0x8028" name="GL_HISTOGRAM_RED_SIZE_EXT"/>
+        <enum value="0x8029" name="GL_HISTOGRAM_GREEN_SIZE"/>
+        <enum value="0x8029" name="GL_HISTOGRAM_GREEN_SIZE_EXT"/>
+        <enum value="0x802A" name="GL_HISTOGRAM_BLUE_SIZE"/>
+        <enum value="0x802A" name="GL_HISTOGRAM_BLUE_SIZE_EXT"/>
+        <enum value="0x802B" name="GL_HISTOGRAM_ALPHA_SIZE"/>
+        <enum value="0x802B" name="GL_HISTOGRAM_ALPHA_SIZE_EXT"/>
+        <enum value="0x802C" name="GL_HISTOGRAM_LUMINANCE_SIZE"/>
+        <enum value="0x802C" name="GL_HISTOGRAM_LUMINANCE_SIZE_EXT"/>
+        <enum value="0x802D" name="GL_HISTOGRAM_SINK"/>
+        <enum value="0x802D" name="GL_HISTOGRAM_SINK_EXT"/>
+        <enum value="0x802E" name="GL_MINMAX"/>
+        <enum value="0x802E" name="GL_MINMAX_EXT"/>
+        <enum value="0x802F" name="GL_MINMAX_FORMAT"/>
+        <enum value="0x802F" name="GL_MINMAX_FORMAT_EXT"/>
+        <enum value="0x8030" name="GL_MINMAX_SINK"/>
+        <enum value="0x8030" name="GL_MINMAX_SINK_EXT"/>
+        <enum value="0x8031" name="GL_TABLE_TOO_LARGE_EXT"/>
+        <enum value="0x8031" name="GL_TABLE_TOO_LARGE"/>
+        <enum value="0x8032" name="GL_UNSIGNED_BYTE_3_3_2"/>
+        <enum value="0x8032" name="GL_UNSIGNED_BYTE_3_3_2_EXT"/>
+        <enum value="0x8033" name="GL_UNSIGNED_SHORT_4_4_4_4"/>
+        <enum value="0x8033" name="GL_UNSIGNED_SHORT_4_4_4_4_EXT"/>
+        <enum value="0x8034" name="GL_UNSIGNED_SHORT_5_5_5_1"/>
+        <enum value="0x8034" name="GL_UNSIGNED_SHORT_5_5_5_1_EXT"/>
+        <enum value="0x8035" name="GL_UNSIGNED_INT_8_8_8_8"/>
+        <enum value="0x8035" name="GL_UNSIGNED_INT_8_8_8_8_EXT"/>
+        <enum value="0x8036" name="GL_UNSIGNED_INT_10_10_10_2"/>
+        <enum value="0x8036" name="GL_UNSIGNED_INT_10_10_10_2_EXT"/>
+        <enum value="0x8037" name="GL_POLYGON_OFFSET_EXT"/>
+        <enum value="0x8037" name="GL_POLYGON_OFFSET_FILL"/>
+        <enum value="0x8038" name="GL_POLYGON_OFFSET_FACTOR"/>
+        <enum value="0x8038" name="GL_POLYGON_OFFSET_FACTOR_EXT"/>
+        <enum value="0x8039" name="GL_POLYGON_OFFSET_BIAS_EXT"/>
+        <enum value="0x803A" name="GL_RESCALE_NORMAL"/>
+        <enum value="0x803A" name="GL_RESCALE_NORMAL_EXT"/>
+        <enum value="0x803B" name="GL_ALPHA4"/>
+        <enum value="0x803B" name="GL_ALPHA4_EXT"/>
+        <enum value="0x803C" name="GL_ALPHA8"/>
+        <enum value="0x803C" name="GL_ALPHA8_EXT"/>
+        <enum value="0x803C" name="GL_ALPHA8_OES"/>
+        <enum value="0x803D" name="GL_ALPHA12"/>
+        <enum value="0x803D" name="GL_ALPHA12_EXT"/>
+        <enum value="0x803E" name="GL_ALPHA16"/>
+        <enum value="0x803E" name="GL_ALPHA16_EXT"/>
+        <enum value="0x803F" name="GL_LUMINANCE4"/>
+        <enum value="0x803F" name="GL_LUMINANCE4_EXT"/>
+        <enum value="0x8040" name="GL_LUMINANCE8"/>
+        <enum value="0x8040" name="GL_LUMINANCE8_EXT"/>
+        <enum value="0x8040" name="GL_LUMINANCE8_OES"/>
+        <enum value="0x8041" name="GL_LUMINANCE12"/>
+        <enum value="0x8041" name="GL_LUMINANCE12_EXT"/>
+        <enum value="0x8042" name="GL_LUMINANCE16"/>
+        <enum value="0x8042" name="GL_LUMINANCE16_EXT"/>
+        <enum value="0x8043" name="GL_LUMINANCE4_ALPHA4"/>
+        <enum value="0x8043" name="GL_LUMINANCE4_ALPHA4_EXT"/>
+        <enum value="0x8043" name="GL_LUMINANCE4_ALPHA4_OES"/>
+        <enum value="0x8044" name="GL_LUMINANCE6_ALPHA2"/>
+        <enum value="0x8044" name="GL_LUMINANCE6_ALPHA2_EXT"/>
+        <enum value="0x8045" name="GL_LUMINANCE8_ALPHA8"/>
+        <enum value="0x8045" name="GL_LUMINANCE8_ALPHA8_EXT"/>
+        <enum value="0x8045" name="GL_LUMINANCE8_ALPHA8_OES"/>
+        <enum value="0x8046" name="GL_LUMINANCE12_ALPHA4"/>
+        <enum value="0x8046" name="GL_LUMINANCE12_ALPHA4_EXT"/>
+        <enum value="0x8047" name="GL_LUMINANCE12_ALPHA12"/>
+        <enum value="0x8047" name="GL_LUMINANCE12_ALPHA12_EXT"/>
+        <enum value="0x8048" name="GL_LUMINANCE16_ALPHA16"/>
+        <enum value="0x8048" name="GL_LUMINANCE16_ALPHA16_EXT"/>
+        <enum value="0x8049" name="GL_INTENSITY"/>
+        <enum value="0x8049" name="GL_INTENSITY_EXT"/>
+        <enum value="0x804A" name="GL_INTENSITY4"/>
+        <enum value="0x804A" name="GL_INTENSITY4_EXT"/>
+        <enum value="0x804B" name="GL_INTENSITY8"/>
+        <enum value="0x804B" name="GL_INTENSITY8_EXT"/>
+        <enum value="0x804C" name="GL_INTENSITY12"/>
+        <enum value="0x804C" name="GL_INTENSITY12_EXT"/>
+        <enum value="0x804D" name="GL_INTENSITY16"/>
+        <enum value="0x804D" name="GL_INTENSITY16_EXT"/>
+        <enum value="0x804E" name="GL_RGB2_EXT"/>
+        <enum value="0x804F" name="GL_RGB4"/>
+        <enum value="0x804F" name="GL_RGB4_EXT"/>
+        <enum value="0x8050" name="GL_RGB5"/>
+        <enum value="0x8050" name="GL_RGB5_EXT"/>
+        <enum value="0x8051" name="GL_RGB8"/>
+        <enum value="0x8051" name="GL_RGB8_EXT"/>
+        <enum value="0x8051" name="GL_RGB8_OES"/>
+        <enum value="0x8052" name="GL_RGB10"/>
+        <enum value="0x8052" name="GL_RGB10_EXT"/>
+        <enum value="0x8053" name="GL_RGB12"/>
+        <enum value="0x8053" name="GL_RGB12_EXT"/>
+        <enum value="0x8054" name="GL_RGB16"/>
+        <enum value="0x8054" name="GL_RGB16_EXT"/>
+        <enum value="0x8055" name="GL_RGBA2"/>
+        <enum value="0x8055" name="GL_RGBA2_EXT"/>
+        <enum value="0x8056" name="GL_RGBA4"/>
+        <enum value="0x8056" name="GL_RGBA4_EXT"/>
+        <enum value="0x8056" name="GL_RGBA4_OES"/>
+        <enum value="0x8057" name="GL_RGB5_A1"/>
+        <enum value="0x8057" name="GL_RGB5_A1_EXT"/>
+        <enum value="0x8057" name="GL_RGB5_A1_OES"/>
+        <enum value="0x8058" name="GL_RGBA8"/>
+        <enum value="0x8058" name="GL_RGBA8_EXT"/>
+        <enum value="0x8058" name="GL_RGBA8_OES"/>
+        <enum value="0x8059" name="GL_RGB10_A2"/>
+        <enum value="0x8059" name="GL_RGB10_A2_EXT"/>
+        <enum value="0x805A" name="GL_RGBA12"/>
+        <enum value="0x805A" name="GL_RGBA12_EXT"/>
+        <enum value="0x805B" name="GL_RGBA16"/>
+        <enum value="0x805B" name="GL_RGBA16_EXT"/>
+        <enum value="0x805C" name="GL_TEXTURE_RED_SIZE"/>
+        <enum value="0x805C" name="GL_TEXTURE_RED_SIZE_EXT"/>
+        <enum value="0x805D" name="GL_TEXTURE_GREEN_SIZE"/>
+        <enum value="0x805D" name="GL_TEXTURE_GREEN_SIZE_EXT"/>
+        <enum value="0x805E" name="GL_TEXTURE_BLUE_SIZE"/>
+        <enum value="0x805E" name="GL_TEXTURE_BLUE_SIZE_EXT"/>
+        <enum value="0x805F" name="GL_TEXTURE_ALPHA_SIZE"/>
+        <enum value="0x805F" name="GL_TEXTURE_ALPHA_SIZE_EXT"/>
+        <enum value="0x8060" name="GL_TEXTURE_LUMINANCE_SIZE"/>
+        <enum value="0x8060" name="GL_TEXTURE_LUMINANCE_SIZE_EXT"/>
+        <enum value="0x8061" name="GL_TEXTURE_INTENSITY_SIZE"/>
+        <enum value="0x8061" name="GL_TEXTURE_INTENSITY_SIZE_EXT"/>
+        <enum value="0x8062" name="GL_REPLACE_EXT"/>
+        <enum value="0x8063" name="GL_PROXY_TEXTURE_1D"/>
+        <enum value="0x8063" name="GL_PROXY_TEXTURE_1D_EXT"/>
+        <enum value="0x8064" name="GL_PROXY_TEXTURE_2D"/>
+        <enum value="0x8064" name="GL_PROXY_TEXTURE_2D_EXT"/>
+        <enum value="0x8065" name="GL_TEXTURE_TOO_LARGE_EXT"/>
+        <enum value="0x8066" name="GL_TEXTURE_PRIORITY"/>
+        <enum value="0x8066" name="GL_TEXTURE_PRIORITY_EXT"/>
+        <enum value="0x8067" name="GL_TEXTURE_RESIDENT"/>
+        <enum value="0x8067" name="GL_TEXTURE_RESIDENT_EXT"/>
+        <enum value="0x8068" name="GL_TEXTURE_1D_BINDING_EXT"/>
+        <enum value="0x8068" name="GL_TEXTURE_BINDING_1D"/>
+        <enum value="0x8069" name="GL_TEXTURE_2D_BINDING_EXT"/>
+        <enum value="0x8069" name="GL_TEXTURE_BINDING_2D"/>
+        <enum value="0x806A" name="GL_TEXTURE_3D_BINDING_EXT"/>
+        <enum value="0x806A" name="GL_TEXTURE_3D_BINDING_OES"/>
+        <enum value="0x806A" name="GL_TEXTURE_BINDING_3D"/>
+        <enum value="0x806A" name="GL_TEXTURE_BINDING_3D_OES"/>
+        <enum value="0x806B" name="GL_PACK_SKIP_IMAGES"/>
+        <enum value="0x806B" name="GL_PACK_SKIP_IMAGES_EXT"/>
+        <enum value="0x806C" name="GL_PACK_IMAGE_HEIGHT"/>
+        <enum value="0x806C" name="GL_PACK_IMAGE_HEIGHT_EXT"/>
+        <enum value="0x806D" name="GL_UNPACK_SKIP_IMAGES"/>
+        <enum value="0x806D" name="GL_UNPACK_SKIP_IMAGES_EXT"/>
+        <enum value="0x806E" name="GL_UNPACK_IMAGE_HEIGHT"/>
+        <enum value="0x806E" name="GL_UNPACK_IMAGE_HEIGHT_EXT"/>
+        <enum value="0x806F" name="GL_TEXTURE_3D"/>
+        <enum value="0x806F" name="GL_TEXTURE_3D_EXT"/>
+        <enum value="0x806F" name="GL_TEXTURE_3D_OES"/>
+        <enum value="0x8070" name="GL_PROXY_TEXTURE_3D"/>
+        <enum value="0x8070" name="GL_PROXY_TEXTURE_3D_EXT"/>
+        <enum value="0x8071" name="GL_TEXTURE_DEPTH"/>
+        <enum value="0x8071" name="GL_TEXTURE_DEPTH_EXT"/>
+        <enum value="0x8072" name="GL_TEXTURE_WRAP_R"/>
+        <enum value="0x8072" name="GL_TEXTURE_WRAP_R_EXT"/>
+        <enum value="0x8072" name="GL_TEXTURE_WRAP_R_OES"/>
+        <enum value="0x8073" name="GL_MAX_3D_TEXTURE_SIZE"/>
+        <enum value="0x8073" name="GL_MAX_3D_TEXTURE_SIZE_EXT"/>
+        <enum value="0x8073" name="GL_MAX_3D_TEXTURE_SIZE_OES"/>
+        <enum value="0x8074" name="GL_VERTEX_ARRAY"/>
+        <enum value="0x8074" name="GL_VERTEX_ARRAY_EXT"/>
+        <enum value="0x8074" name="GL_VERTEX_ARRAY_KHR"/>
+        <enum value="0x8075" name="GL_NORMAL_ARRAY"/>
+        <enum value="0x8075" name="GL_NORMAL_ARRAY_EXT"/>
+        <enum value="0x8076" name="GL_COLOR_ARRAY"/>
+        <enum value="0x8076" name="GL_COLOR_ARRAY_EXT"/>
+        <enum value="0x8077" name="GL_INDEX_ARRAY"/>
+        <enum value="0x8077" name="GL_INDEX_ARRAY_EXT"/>
+        <enum value="0x8078" name="GL_TEXTURE_COORD_ARRAY"/>
+        <enum value="0x8078" name="GL_TEXTURE_COORD_ARRAY_EXT"/>
+        <enum value="0x8079" name="GL_EDGE_FLAG_ARRAY"/>
+        <enum value="0x8079" name="GL_EDGE_FLAG_ARRAY_EXT"/>
+        <enum value="0x807A" name="GL_VERTEX_ARRAY_SIZE"/>
+        <enum value="0x807A" name="GL_VERTEX_ARRAY_SIZE_EXT"/>
+        <enum value="0x807B" name="GL_VERTEX_ARRAY_TYPE"/>
+        <enum value="0x807B" name="GL_VERTEX_ARRAY_TYPE_EXT"/>
+        <enum value="0x807C" name="GL_VERTEX_ARRAY_STRIDE"/>
+        <enum value="0x807C" name="GL_VERTEX_ARRAY_STRIDE_EXT"/>
+        <enum value="0x807D" name="GL_VERTEX_ARRAY_COUNT_EXT"/>
+        <enum value="0x807E" name="GL_NORMAL_ARRAY_TYPE"/>
+        <enum value="0x807E" name="GL_NORMAL_ARRAY_TYPE_EXT"/>
+        <enum value="0x807F" name="GL_NORMAL_ARRAY_STRIDE"/>
+        <enum value="0x807F" name="GL_NORMAL_ARRAY_STRIDE_EXT"/>
+        <enum value="0x8080" name="GL_NORMAL_ARRAY_COUNT_EXT"/>
+        <enum value="0x8081" name="GL_COLOR_ARRAY_SIZE"/>
+        <enum value="0x8081" name="GL_COLOR_ARRAY_SIZE_EXT"/>
+        <enum value="0x8082" name="GL_COLOR_ARRAY_TYPE"/>
+        <enum value="0x8082" name="GL_COLOR_ARRAY_TYPE_EXT"/>
+        <enum value="0x8083" name="GL_COLOR_ARRAY_STRIDE"/>
+        <enum value="0x8083" name="GL_COLOR_ARRAY_STRIDE_EXT"/>
+        <enum value="0x8084" name="GL_COLOR_ARRAY_COUNT_EXT"/>
+        <enum value="0x8085" name="GL_INDEX_ARRAY_TYPE"/>
+        <enum value="0x8085" name="GL_INDEX_ARRAY_TYPE_EXT"/>
+        <enum value="0x8086" name="GL_INDEX_ARRAY_STRIDE"/>
+        <enum value="0x8086" name="GL_INDEX_ARRAY_STRIDE_EXT"/>
+        <enum value="0x8087" name="GL_INDEX_ARRAY_COUNT_EXT"/>
+        <enum value="0x8088" name="GL_TEXTURE_COORD_ARRAY_SIZE"/>
+        <enum value="0x8088" name="GL_TEXTURE_COORD_ARRAY_SIZE_EXT"/>
+        <enum value="0x8089" name="GL_TEXTURE_COORD_ARRAY_TYPE"/>
+        <enum value="0x8089" name="GL_TEXTURE_COORD_ARRAY_TYPE_EXT"/>
+        <enum value="0x808A" name="GL_TEXTURE_COORD_ARRAY_STRIDE"/>
+        <enum value="0x808A" name="GL_TEXTURE_COORD_ARRAY_STRIDE_EXT"/>
+        <enum value="0x808B" name="GL_TEXTURE_COORD_ARRAY_COUNT_EXT"/>
+        <enum value="0x808C" name="GL_EDGE_FLAG_ARRAY_STRIDE"/>
+        <enum value="0x808C" name="GL_EDGE_FLAG_ARRAY_STRIDE_EXT"/>
+        <enum value="0x808D" name="GL_EDGE_FLAG_ARRAY_COUNT_EXT"/>
+        <enum value="0x808E" name="GL_VERTEX_ARRAY_POINTER"/>
+        <enum value="0x808E" name="GL_VERTEX_ARRAY_POINTER_EXT"/>
+        <enum value="0x808F" name="GL_NORMAL_ARRAY_POINTER"/>
+        <enum value="0x808F" name="GL_NORMAL_ARRAY_POINTER_EXT"/>
+        <enum value="0x8090" name="GL_COLOR_ARRAY_POINTER"/>
+        <enum value="0x8090" name="GL_COLOR_ARRAY_POINTER_EXT"/>
+        <enum value="0x8091" name="GL_INDEX_ARRAY_POINTER"/>
+        <enum value="0x8091" name="GL_INDEX_ARRAY_POINTER_EXT"/>
+        <enum value="0x8092" name="GL_TEXTURE_COORD_ARRAY_POINTER"/>
+        <enum value="0x8092" name="GL_TEXTURE_COORD_ARRAY_POINTER_EXT"/>
+        <enum value="0x8093" name="GL_EDGE_FLAG_ARRAY_POINTER"/>
+        <enum value="0x8093" name="GL_EDGE_FLAG_ARRAY_POINTER_EXT"/>
+        <enum value="0x8094" name="GL_INTERLACE_SGIX"/>
+        <enum value="0x8095" name="GL_DETAIL_TEXTURE_2D_SGIS"/>
+        <enum value="0x8096" name="GL_DETAIL_TEXTURE_2D_BINDING_SGIS"/>
+        <enum value="0x8097" name="GL_LINEAR_DETAIL_SGIS"/>
+        <enum value="0x8098" name="GL_LINEAR_DETAIL_ALPHA_SGIS"/>
+        <enum value="0x8099" name="GL_LINEAR_DETAIL_COLOR_SGIS"/>
+        <enum value="0x809A" name="GL_DETAIL_TEXTURE_LEVEL_SGIS"/>
+        <enum value="0x809B" name="GL_DETAIL_TEXTURE_MODE_SGIS"/>
+        <enum value="0x809C" name="GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS"/>
+        <enum value="0x809D" name="GL_MULTISAMPLE"/>
+        <enum value="0x809D" name="GL_MULTISAMPLE_ARB"/>
+        <enum value="0x809D" name="GL_MULTISAMPLE_EXT"/>
+        <enum value="0x809D" name="GL_MULTISAMPLE_SGIS"/>
+        <enum value="0x809E" name="GL_SAMPLE_ALPHA_TO_COVERAGE"/>
+        <enum value="0x809E" name="GL_SAMPLE_ALPHA_TO_COVERAGE_ARB"/>
+        <enum value="0x809E" name="GL_SAMPLE_ALPHA_TO_MASK_EXT"/>
+        <enum value="0x809E" name="GL_SAMPLE_ALPHA_TO_MASK_SGIS"/>
+        <enum value="0x809F" name="GL_SAMPLE_ALPHA_TO_ONE"/>
+        <enum value="0x809F" name="GL_SAMPLE_ALPHA_TO_ONE_ARB"/>
+        <enum value="0x809F" name="GL_SAMPLE_ALPHA_TO_ONE_EXT"/>
+        <enum value="0x809F" name="GL_SAMPLE_ALPHA_TO_ONE_SGIS"/>
+        <enum value="0x80A0" name="GL_SAMPLE_COVERAGE"/>
+        <enum value="0x80A0" name="GL_SAMPLE_COVERAGE_ARB"/>
+        <enum value="0x80A0" name="GL_SAMPLE_MASK_EXT"/>
+        <enum value="0x80A0" name="GL_SAMPLE_MASK_SGIS"/>
+        <enum value="0x80A1" name="GL_1PASS_EXT"/>
+        <enum value="0x80A1" name="GL_1PASS_SGIS"/>
+        <enum value="0x80A2" name="GL_2PASS_0_EXT"/>
+        <enum value="0x80A2" name="GL_2PASS_0_SGIS"/>
+        <enum value="0x80A3" name="GL_2PASS_1_EXT"/>
+        <enum value="0x80A3" name="GL_2PASS_1_SGIS"/>
+        <enum value="0x80A4" name="GL_4PASS_0_EXT"/>
+        <enum value="0x80A4" name="GL_4PASS_0_SGIS"/>
+        <enum value="0x80A5" name="GL_4PASS_1_EXT"/>
+        <enum value="0x80A5" name="GL_4PASS_1_SGIS"/>
+        <enum value="0x80A6" name="GL_4PASS_2_EXT"/>
+        <enum value="0x80A6" name="GL_4PASS_2_SGIS"/>
+        <enum value="0x80A7" name="GL_4PASS_3_EXT"/>
+        <enum value="0x80A7" name="GL_4PASS_3_SGIS"/>
+        <enum value="0x80A8" name="GL_SAMPLE_BUFFERS"/>
+        <enum value="0x80A8" name="GL_SAMPLE_BUFFERS_ARB"/>
+        <enum value="0x80A8" name="GL_SAMPLE_BUFFERS_EXT"/>
+        <enum value="0x80A8" name="GL_SAMPLE_BUFFERS_SGIS"/>
+        <enum value="0x80A9" name="GL_SAMPLES"/>
+        <enum value="0x80A9" name="GL_SAMPLES_ARB"/>
+        <enum value="0x80A9" name="GL_SAMPLES_EXT"/>
+        <enum value="0x80A9" name="GL_SAMPLES_SGIS"/>
+        <enum value="0x80AA" name="GL_SAMPLE_COVERAGE_VALUE"/>
+        <enum value="0x80AA" name="GL_SAMPLE_COVERAGE_VALUE_ARB"/>
+        <enum value="0x80AA" name="GL_SAMPLE_MASK_VALUE_EXT"/>
+        <enum value="0x80AA" name="GL_SAMPLE_MASK_VALUE_SGIS"/>
+        <enum value="0x80AB" name="GL_SAMPLE_COVERAGE_INVERT"/>
+        <enum value="0x80AB" name="GL_SAMPLE_COVERAGE_INVERT_ARB"/>
+        <enum value="0x80AB" name="GL_SAMPLE_MASK_INVERT_EXT"/>
+        <enum value="0x80AB" name="GL_SAMPLE_MASK_INVERT_SGIS"/>
+        <enum value="0x80AC" name="GL_SAMPLE_PATTERN_EXT"/>
+        <enum value="0x80AC" name="GL_SAMPLE_PATTERN_SGIS"/>
+        <enum value="0x80AD" name="GL_LINEAR_SHARPEN_SGIS"/>
+        <enum value="0x80AE" name="GL_LINEAR_SHARPEN_ALPHA_SGIS"/>
+        <enum value="0x80AF" name="GL_LINEAR_SHARPEN_COLOR_SGIS"/>
+        <enum value="0x80B0" name="GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS"/>
+        <enum value="0x80B1" name="GL_COLOR_MATRIX"/>
+        <enum value="0x80B1" name="GL_COLOR_MATRIX_SGI"/>
+        <enum value="0x80B2" name="GL_COLOR_MATRIX_STACK_DEPTH"/>
+        <enum value="0x80B2" name="GL_COLOR_MATRIX_STACK_DEPTH_SGI"/>
+        <enum value="0x80B3" name="GL_MAX_COLOR_MATRIX_STACK_DEPTH"/>
+        <enum value="0x80B3" name="GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI"/>
+        <enum value="0x80B4" name="GL_POST_COLOR_MATRIX_RED_SCALE"/>
+        <enum value="0x80B4" name="GL_POST_COLOR_MATRIX_RED_SCALE_SGI"/>
+        <enum value="0x80B5" name="GL_POST_COLOR_MATRIX_GREEN_SCALE"/>
+        <enum value="0x80B5" name="GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI"/>
+        <enum value="0x80B6" name="GL_POST_COLOR_MATRIX_BLUE_SCALE"/>
+        <enum value="0x80B6" name="GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI"/>
+        <enum value="0x80B7" name="GL_POST_COLOR_MATRIX_ALPHA_SCALE"/>
+        <enum value="0x80B7" name="GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI"/>
+        <enum value="0x80B8" name="GL_POST_COLOR_MATRIX_RED_BIAS"/>
+        <enum value="0x80B8" name="GL_POST_COLOR_MATRIX_RED_BIAS_SGI"/>
+        <enum value="0x80B9" name="GL_POST_COLOR_MATRIX_GREEN_BIAS"/>
+        <enum value="0x80B9" name="GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI"/>
+        <enum value="0x80BA" name="GL_POST_COLOR_MATRIX_BLUE_BIAS"/>
+        <enum value="0x80BA" name="GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI"/>
+        <enum value="0x80BB" name="GL_POST_COLOR_MATRIX_ALPHA_BIAS"/>
+        <enum value="0x80BB" name="GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI"/>
+        <enum value="0x80BC" name="GL_TEXTURE_COLOR_TABLE_SGI"/>
+        <enum value="0x80BD" name="GL_PROXY_TEXTURE_COLOR_TABLE_SGI"/>
+        <enum value="0x80BE" name="GL_TEXTURE_ENV_BIAS_SGIX"/>
+        <enum value="0x80BF" name="GL_SHADOW_AMBIENT_SGIX"/>
+        <enum value="0x80BF" name="GL_TEXTURE_COMPARE_FAIL_VALUE_ARB"/>
+    </enums>
+
+    <enums namespace="GL" start="0x80C0" end="0x80CF" vendor="ZiiLabs">
+            <unused start="0x80C0" end="0x80C7"/>
+        <enum value="0x80C8" name="GL_BLEND_DST_RGB"/>
+        <enum value="0x80C8" name="GL_BLEND_DST_RGB_EXT"/>
+        <enum value="0x80C8" name="GL_BLEND_DST_RGB_OES"/>
+        <enum value="0x80C9" name="GL_BLEND_SRC_RGB"/>
+        <enum value="0x80C9" name="GL_BLEND_SRC_RGB_EXT"/>
+        <enum value="0x80C9" name="GL_BLEND_SRC_RGB_OES"/>
+        <enum value="0x80CA" name="GL_BLEND_DST_ALPHA"/>
+        <enum value="0x80CA" name="GL_BLEND_DST_ALPHA_EXT"/>
+        <enum value="0x80CA" name="GL_BLEND_DST_ALPHA_OES"/>
+        <enum value="0x80CB" name="GL_BLEND_SRC_ALPHA"/>
+        <enum value="0x80CB" name="GL_BLEND_SRC_ALPHA_EXT"/>
+        <enum value="0x80CB" name="GL_BLEND_SRC_ALPHA_OES"/>
+        <enum value="0x80CC" name="GL_422_EXT"/>
+        <enum value="0x80CD" name="GL_422_REV_EXT"/>
+        <enum value="0x80CE" name="GL_422_AVERAGE_EXT"/>
+        <enum value="0x80CF" name="GL_422_REV_AVERAGE_EXT"/>
+    </enums>
+
+    <enums namespace="GL" start="0x80D0" end="0x80DF" vendor="SGI">
+        <enum value="0x80D0" name="GL_COLOR_TABLE"/>
+        <enum value="0x80D0" name="GL_COLOR_TABLE_SGI"/>
+        <enum value="0x80D1" name="GL_POST_CONVOLUTION_COLOR_TABLE"/>
+        <enum value="0x80D1" name="GL_POST_CONVOLUTION_COLOR_TABLE_SGI"/>
+        <enum value="0x80D2" name="GL_POST_COLOR_MATRIX_COLOR_TABLE"/>
+        <enum value="0x80D2" name="GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI"/>
+        <enum value="0x80D3" name="GL_PROXY_COLOR_TABLE"/>
+        <enum value="0x80D3" name="GL_PROXY_COLOR_TABLE_SGI"/>
+        <enum value="0x80D4" name="GL_PROXY_POST_CONVOLUTION_COLOR_TABLE"/>
+        <enum value="0x80D4" name="GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI"/>
+        <enum value="0x80D5" name="GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE"/>
+        <enum value="0x80D5" name="GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI"/>
+        <enum value="0x80D6" name="GL_COLOR_TABLE_SCALE"/>
+        <enum value="0x80D6" name="GL_COLOR_TABLE_SCALE_SGI"/>
+        <enum value="0x80D7" name="GL_COLOR_TABLE_BIAS"/>
+        <enum value="0x80D7" name="GL_COLOR_TABLE_BIAS_SGI"/>
+        <enum value="0x80D8" name="GL_COLOR_TABLE_FORMAT"/>
+        <enum value="0x80D8" name="GL_COLOR_TABLE_FORMAT_SGI"/>
+        <enum value="0x80D9" name="GL_COLOR_TABLE_WIDTH"/>
+        <enum value="0x80D9" name="GL_COLOR_TABLE_WIDTH_SGI"/>
+        <enum value="0x80DA" name="GL_COLOR_TABLE_RED_SIZE"/>
+        <enum value="0x80DA" name="GL_COLOR_TABLE_RED_SIZE_SGI"/>
+        <enum value="0x80DB" name="GL_COLOR_TABLE_GREEN_SIZE"/>
+        <enum value="0x80DB" name="GL_COLOR_TABLE_GREEN_SIZE_SGI"/>
+        <enum value="0x80DC" name="GL_COLOR_TABLE_BLUE_SIZE"/>
+        <enum value="0x80DC" name="GL_COLOR_TABLE_BLUE_SIZE_SGI"/>
+        <enum value="0x80DD" name="GL_COLOR_TABLE_ALPHA_SIZE"/>
+        <enum value="0x80DD" name="GL_COLOR_TABLE_ALPHA_SIZE_SGI"/>
+        <enum value="0x80DE" name="GL_COLOR_TABLE_LUMINANCE_SIZE"/>
+        <enum value="0x80DE" name="GL_COLOR_TABLE_LUMINANCE_SIZE_SGI"/>
+        <enum value="0x80DF" name="GL_COLOR_TABLE_INTENSITY_SIZE"/>
+        <enum value="0x80DF" name="GL_COLOR_TABLE_INTENSITY_SIZE_SGI"/>
+    </enums>
+
+    <enums namespace="GL" start="0x80E0" end="0x810F" vendor="MS">
+        <enum value="0x80E0" name="GL_BGR"/>
+        <enum value="0x80E0" name="GL_BGR_EXT"/>
+        <enum value="0x80E1" name="GL_BGRA"/>
+        <enum value="0x80E1" name="GL_BGRA_EXT"/>
+        <enum value="0x80E1" name="GL_BGRA_IMG"/>
+        <enum value="0x80E2" name="GL_COLOR_INDEX1_EXT"/>
+        <enum value="0x80E3" name="GL_COLOR_INDEX2_EXT"/>
+        <enum value="0x80E4" name="GL_COLOR_INDEX4_EXT"/>
+        <enum value="0x80E5" name="GL_COLOR_INDEX8_EXT"/>
+        <enum value="0x80E6" name="GL_COLOR_INDEX12_EXT"/>
+        <enum value="0x80E7" name="GL_COLOR_INDEX16_EXT"/>
+        <enum value="0x80E8" name="GL_MAX_ELEMENTS_VERTICES"/>
+        <enum value="0x80E8" name="GL_MAX_ELEMENTS_VERTICES_EXT"/>
+        <enum value="0x80E9" name="GL_MAX_ELEMENTS_INDICES"/>
+        <enum value="0x80E9" name="GL_MAX_ELEMENTS_INDICES_EXT"/>
+        <enum value="0x80EA" name="GL_PHONG_WIN"/>
+        <enum value="0x80EB" name="GL_PHONG_HINT_WIN"/>
+        <enum value="0x80EC" name="GL_FOG_SPECULAR_TEXTURE_WIN"/>
+        <enum value="0x80ED" name="GL_TEXTURE_INDEX_SIZE_EXT"/>
+        <enum value="0x80EE" name="GL_PARAMETER_BUFFER_ARB"/>
+        <enum value="0x80EF" name="GL_PARAMETER_BUFFER_BINDING_ARB"/>
+        <enum value="0x80F0" name="GL_CLIP_VOLUME_CLIPPING_HINT_EXT"/>
+            <unused start="0x80F1" end="0x810F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8110" end="0x814F" vendor="SGI">
+        <enum value="0x8110" name="GL_DUAL_ALPHA4_SGIS"/>
+        <enum value="0x8111" name="GL_DUAL_ALPHA8_SGIS"/>
+        <enum value="0x8112" name="GL_DUAL_ALPHA12_SGIS"/>
+        <enum value="0x8113" name="GL_DUAL_ALPHA16_SGIS"/>
+        <enum value="0x8114" name="GL_DUAL_LUMINANCE4_SGIS"/>
+        <enum value="0x8115" name="GL_DUAL_LUMINANCE8_SGIS"/>
+        <enum value="0x8116" name="GL_DUAL_LUMINANCE12_SGIS"/>
+        <enum value="0x8117" name="GL_DUAL_LUMINANCE16_SGIS"/>
+        <enum value="0x8118" name="GL_DUAL_INTENSITY4_SGIS"/>
+        <enum value="0x8119" name="GL_DUAL_INTENSITY8_SGIS"/>
+        <enum value="0x811A" name="GL_DUAL_INTENSITY12_SGIS"/>
+        <enum value="0x811B" name="GL_DUAL_INTENSITY16_SGIS"/>
+        <enum value="0x811C" name="GL_DUAL_LUMINANCE_ALPHA4_SGIS"/>
+        <enum value="0x811D" name="GL_DUAL_LUMINANCE_ALPHA8_SGIS"/>
+        <enum value="0x811E" name="GL_QUAD_ALPHA4_SGIS"/>
+        <enum value="0x811F" name="GL_QUAD_ALPHA8_SGIS"/>
+        <enum value="0x8120" name="GL_QUAD_LUMINANCE4_SGIS"/>
+        <enum value="0x8121" name="GL_QUAD_LUMINANCE8_SGIS"/>
+        <enum value="0x8122" name="GL_QUAD_INTENSITY4_SGIS"/>
+        <enum value="0x8123" name="GL_QUAD_INTENSITY8_SGIS"/>
+        <enum value="0x8124" name="GL_DUAL_TEXTURE_SELECT_SGIS"/>
+        <enum value="0x8125" name="GL_QUAD_TEXTURE_SELECT_SGIS"/>
+        <enum value="0x8126" name="GL_POINT_SIZE_MIN"/>
+        <enum value="0x8126" name="GL_POINT_SIZE_MIN_ARB"/>
+        <enum value="0x8126" name="GL_POINT_SIZE_MIN_EXT"/>
+        <enum value="0x8126" name="GL_POINT_SIZE_MIN_SGIS"/>
+        <enum value="0x8127" name="GL_POINT_SIZE_MAX"/>
+        <enum value="0x8127" name="GL_POINT_SIZE_MAX_ARB"/>
+        <enum value="0x8127" name="GL_POINT_SIZE_MAX_EXT"/>
+        <enum value="0x8127" name="GL_POINT_SIZE_MAX_SGIS"/>
+        <enum value="0x8128" name="GL_POINT_FADE_THRESHOLD_SIZE"/>
+        <enum value="0x8128" name="GL_POINT_FADE_THRESHOLD_SIZE_ARB"/>
+        <enum value="0x8128" name="GL_POINT_FADE_THRESHOLD_SIZE_EXT"/>
+        <enum value="0x8128" name="GL_POINT_FADE_THRESHOLD_SIZE_SGIS"/>
+        <enum value="0x8129" name="GL_DISTANCE_ATTENUATION_EXT"/>
+        <enum value="0x8129" name="GL_DISTANCE_ATTENUATION_SGIS"/>
+        <enum value="0x8129" name="GL_POINT_DISTANCE_ATTENUATION"/>
+        <enum value="0x8129" name="GL_POINT_DISTANCE_ATTENUATION_ARB"/>
+        <enum value="0x812A" name="GL_FOG_FUNC_SGIS"/>
+        <enum value="0x812B" name="GL_FOG_FUNC_POINTS_SGIS"/>
+        <enum value="0x812C" name="GL_MAX_FOG_FUNC_POINTS_SGIS"/>
+        <enum value="0x812D" name="GL_CLAMP_TO_BORDER"/>
+        <enum value="0x812D" name="GL_CLAMP_TO_BORDER_ARB"/>
+        <enum value="0x812D" name="GL_CLAMP_TO_BORDER_EXT"/>
+        <enum value="0x812D" name="GL_CLAMP_TO_BORDER_NV"/>
+        <enum value="0x812D" name="GL_CLAMP_TO_BORDER_SGIS"/>
+        <enum value="0x812E" name="GL_TEXTURE_MULTI_BUFFER_HINT_SGIX"/>
+        <enum value="0x812F" name="GL_CLAMP_TO_EDGE"/>
+        <enum value="0x812F" name="GL_CLAMP_TO_EDGE_SGIS"/>
+        <enum value="0x8130" name="GL_PACK_SKIP_VOLUMES_SGIS"/>
+        <enum value="0x8131" name="GL_PACK_IMAGE_DEPTH_SGIS"/>
+        <enum value="0x8132" name="GL_UNPACK_SKIP_VOLUMES_SGIS"/>
+        <enum value="0x8133" name="GL_UNPACK_IMAGE_DEPTH_SGIS"/>
+        <enum value="0x8134" name="GL_TEXTURE_4D_SGIS"/>
+        <enum value="0x8135" name="GL_PROXY_TEXTURE_4D_SGIS"/>
+        <enum value="0x8136" name="GL_TEXTURE_4DSIZE_SGIS"/>
+        <enum value="0x8137" name="GL_TEXTURE_WRAP_Q_SGIS"/>
+        <enum value="0x8138" name="GL_MAX_4D_TEXTURE_SIZE_SGIS"/>
+        <enum value="0x8139" name="GL_PIXEL_TEX_GEN_SGIX"/>
+        <enum value="0x813A" name="GL_TEXTURE_MIN_LOD"/>
+        <enum value="0x813A" name="GL_TEXTURE_MIN_LOD_SGIS"/>
+        <enum value="0x813B" name="GL_TEXTURE_MAX_LOD"/>
+        <enum value="0x813B" name="GL_TEXTURE_MAX_LOD_SGIS"/>
+        <enum value="0x813C" name="GL_TEXTURE_BASE_LEVEL"/>
+        <enum value="0x813C" name="GL_TEXTURE_BASE_LEVEL_SGIS"/>
+        <enum value="0x813D" name="GL_TEXTURE_MAX_LEVEL"/>
+        <enum value="0x813D" name="GL_TEXTURE_MAX_LEVEL_APPLE"/>
+        <enum value="0x813D" name="GL_TEXTURE_MAX_LEVEL_SGIS"/>
+        <enum value="0x813E" name="GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX"/>
+        <enum value="0x813F" name="GL_PIXEL_TILE_CACHE_INCREMENT_SGIX"/>
+        <enum value="0x8140" name="GL_PIXEL_TILE_WIDTH_SGIX"/>
+        <enum value="0x8141" name="GL_PIXEL_TILE_HEIGHT_SGIX"/>
+        <enum value="0x8142" name="GL_PIXEL_TILE_GRID_WIDTH_SGIX"/>
+        <enum value="0x8143" name="GL_PIXEL_TILE_GRID_HEIGHT_SGIX"/>
+        <enum value="0x8144" name="GL_PIXEL_TILE_GRID_DEPTH_SGIX"/>
+        <enum value="0x8145" name="GL_PIXEL_TILE_CACHE_SIZE_SGIX"/>
+        <enum value="0x8146" name="GL_FILTER4_SGIS"/>
+        <enum value="0x8147" name="GL_TEXTURE_FILTER4_SIZE_SGIS"/>
+        <enum value="0x8148" name="GL_SPRITE_SGIX"/>
+        <enum value="0x8149" name="GL_SPRITE_MODE_SGIX"/>
+        <enum value="0x814A" name="GL_SPRITE_AXIS_SGIX"/>
+        <enum value="0x814B" name="GL_SPRITE_TRANSLATION_SGIX"/>
+        <enum value="0x814C" name="GL_SPRITE_AXIAL_SGIX"/>
+        <enum value="0x814D" name="GL_SPRITE_OBJECT_ALIGNED_SGIX"/>
+        <enum value="0x814E" name="GL_SPRITE_EYE_ALIGNED_SGIX"/>
+        <enum value="0x814F" name="GL_TEXTURE_4D_BINDING_SGIS"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8150" end="0x816F" vendor="HP">
+        <enum value="0x8150" name="GL_IGNORE_BORDER_HP"/>
+        <enum value="0x8151" name="GL_CONSTANT_BORDER"/>
+        <enum value="0x8151" name="GL_CONSTANT_BORDER_HP"/>
+            <unused start="0x8152" comment="GL_WRAP_BORDER = 0x8152 was proposed, but not actually promoted to core"/>
+        <enum value="0x8153" name="GL_REPLICATE_BORDER"/>
+        <enum value="0x8153" name="GL_REPLICATE_BORDER_HP"/>
+        <enum value="0x8154" name="GL_CONVOLUTION_BORDER_COLOR"/>
+        <enum value="0x8154" name="GL_CONVOLUTION_BORDER_COLOR_HP"/>
+        <enum value="0x8155" name="GL_IMAGE_SCALE_X_HP"/>
+        <enum value="0x8156" name="GL_IMAGE_SCALE_Y_HP"/>
+        <enum value="0x8157" name="GL_IMAGE_TRANSLATE_X_HP"/>
+        <enum value="0x8158" name="GL_IMAGE_TRANSLATE_Y_HP"/>
+        <enum value="0x8159" name="GL_IMAGE_ROTATE_ANGLE_HP"/>
+        <enum value="0x815A" name="GL_IMAGE_ROTATE_ORIGIN_X_HP"/>
+        <enum value="0x815B" name="GL_IMAGE_ROTATE_ORIGIN_Y_HP"/>
+        <enum value="0x815C" name="GL_IMAGE_MAG_FILTER_HP"/>
+        <enum value="0x815D" name="GL_IMAGE_MIN_FILTER_HP"/>
+        <enum value="0x815E" name="GL_IMAGE_CUBIC_WEIGHT_HP"/>
+        <enum value="0x815F" name="GL_CUBIC_HP"/>
+        <enum value="0x8160" name="GL_AVERAGE_HP"/>
+        <enum value="0x8161" name="GL_IMAGE_TRANSFORM_2D_HP"/>
+        <enum value="0x8162" name="GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP"/>
+        <enum value="0x8163" name="GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP"/>
+            <unused start="0x8164"/>
+        <enum value="0x8165" name="GL_OCCLUSION_TEST_HP"/>
+        <enum value="0x8166" name="GL_OCCLUSION_TEST_RESULT_HP"/>
+        <enum value="0x8167" name="GL_TEXTURE_LIGHTING_MODE_HP"/>
+        <enum value="0x8168" name="GL_TEXTURE_POST_SPECULAR_HP"/>
+        <enum value="0x8169" name="GL_TEXTURE_PRE_SPECULAR_HP"/>
+            <unused start="0x816A" end="0x816F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8170" end="0x81CF" vendor="SGI">
+        <enum value="0x8170" name="GL_LINEAR_CLIPMAP_LINEAR_SGIX"/>
+        <enum value="0x8171" name="GL_TEXTURE_CLIPMAP_CENTER_SGIX"/>
+        <enum value="0x8172" name="GL_TEXTURE_CLIPMAP_FRAME_SGIX"/>
+        <enum value="0x8173" name="GL_TEXTURE_CLIPMAP_OFFSET_SGIX"/>
+        <enum value="0x8174" name="GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX"/>
+        <enum value="0x8175" name="GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX"/>
+        <enum value="0x8176" name="GL_TEXTURE_CLIPMAP_DEPTH_SGIX"/>
+        <enum value="0x8177" name="GL_MAX_CLIPMAP_DEPTH_SGIX"/>
+        <enum value="0x8178" name="GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX"/>
+        <enum value="0x8179" name="GL_POST_TEXTURE_FILTER_BIAS_SGIX"/>
+        <enum value="0x817A" name="GL_POST_TEXTURE_FILTER_SCALE_SGIX"/>
+        <enum value="0x817B" name="GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX"/>
+        <enum value="0x817C" name="GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX"/>
+        <enum value="0x817D" name="GL_REFERENCE_PLANE_SGIX"/>
+        <enum value="0x817E" name="GL_REFERENCE_PLANE_EQUATION_SGIX"/>
+        <enum value="0x817F" name="GL_IR_INSTRUMENT1_SGIX"/>
+        <enum value="0x8180" name="GL_INSTRUMENT_BUFFER_POINTER_SGIX"/>
+        <enum value="0x8181" name="GL_INSTRUMENT_MEASUREMENTS_SGIX"/>
+        <enum value="0x8182" name="GL_LIST_PRIORITY_SGIX"/>
+        <enum value="0x8183" name="GL_CALLIGRAPHIC_FRAGMENT_SGIX"/>
+        <enum value="0x8184" name="GL_PIXEL_TEX_GEN_Q_CEILING_SGIX"/>
+        <enum value="0x8185" name="GL_PIXEL_TEX_GEN_Q_ROUND_SGIX"/>
+        <enum value="0x8186" name="GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX"/>
+        <enum value="0x8187" name="GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX"/>
+        <enum value="0x8188" name="GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX"/>
+        <enum value="0x8189" name="GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX"/>
+        <enum value="0x818A" name="GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX"/>
+        <enum value="0x818B" name="GL_FRAMEZOOM_SGIX"/>
+        <enum value="0x818C" name="GL_FRAMEZOOM_FACTOR_SGIX"/>
+        <enum value="0x818D" name="GL_MAX_FRAMEZOOM_FACTOR_SGIX"/>
+        <enum value="0x818E" name="GL_TEXTURE_LOD_BIAS_S_SGIX"/>
+        <enum value="0x818F" name="GL_TEXTURE_LOD_BIAS_T_SGIX"/>
+        <enum value="0x8190" name="GL_TEXTURE_LOD_BIAS_R_SGIX"/>
+        <enum value="0x8191" name="GL_GENERATE_MIPMAP"/>
+        <enum value="0x8191" name="GL_GENERATE_MIPMAP_SGIS"/>
+        <enum value="0x8192" name="GL_GENERATE_MIPMAP_HINT"/>
+        <enum value="0x8192" name="GL_GENERATE_MIPMAP_HINT_SGIS"/>
+            <unused start="0x8193" end="0x8193" comment="Incomplete extension SGIX_spotlight_cutoff"/>
+            <!-- <enum value="0x8193" name="GL_SPOT_CUTOFF_DELTA_SGIX"/> -->
+        <enum value="0x8194" name="GL_GEOMETRY_DEFORMATION_SGIX"/>
+        <enum value="0x8195" name="GL_TEXTURE_DEFORMATION_SGIX"/>
+        <enum value="0x8196" name="GL_DEFORMATIONS_MASK_SGIX"/>
+        <enum value="0x8197" name="GL_MAX_DEFORMATION_ORDER_SGIX"/>
+        <enum value="0x8198" name="GL_FOG_OFFSET_SGIX"/>
+        <enum value="0x8199" name="GL_FOG_OFFSET_VALUE_SGIX"/>
+        <enum value="0x819A" name="GL_TEXTURE_COMPARE_SGIX"/>
+        <enum value="0x819B" name="GL_TEXTURE_COMPARE_OPERATOR_SGIX"/>
+        <enum value="0x819C" name="GL_TEXTURE_LEQUAL_R_SGIX"/>
+        <enum value="0x819D" name="GL_TEXTURE_GEQUAL_R_SGIX"/>
+            <unused start="0x819E" end="0x81A4" comment="Private (internal) extension SGIX_igloo_interface"/>
+            <!-- <enum value="0x819E" name="GL_IGLOO_FULLSCREEN_SGIX"/> -->
+            <!-- <enum value="0x819F" name="GL_IGLOO_VIEWPORT_OFFSET_SGIX"/> -->
+            <!-- <enum value="0x81A0" name="GL_IGLOO_SWAPTMESH_SGIX"/> -->
+            <!-- <enum value="0x81A1" name="GL_IGLOO_COLORNORMAL_SGIX"/> -->
+            <!-- <enum value="0x81A2" name="GL_IGLOO_IRISGL_MODE_SGIX"/> -->
+            <!-- <enum value="0x81A3" name="GL_IGLOO_LMC_COLOR_SGIX"/> -->
+            <!-- <enum value="0x81A4" name="GL_IGLOO_TMESHMODE_SGIX"/> -->
+        <enum value="0x81A5" name="GL_DEPTH_COMPONENT16"/>
+        <enum value="0x81A5" name="GL_DEPTH_COMPONENT16_ARB"/>
+        <enum value="0x81A5" name="GL_DEPTH_COMPONENT16_OES"/>
+        <enum value="0x81A5" name="GL_DEPTH_COMPONENT16_SGIX"/>
+        <enum value="0x81A6" name="GL_DEPTH_COMPONENT24"/>
+        <enum value="0x81A6" name="GL_DEPTH_COMPONENT24_ARB"/>
+        <enum value="0x81A6" name="GL_DEPTH_COMPONENT24_OES"/>
+        <enum value="0x81A6" name="GL_DEPTH_COMPONENT24_SGIX"/>
+        <enum value="0x81A7" name="GL_DEPTH_COMPONENT32"/>
+        <enum value="0x81A7" name="GL_DEPTH_COMPONENT32_ARB"/>
+        <enum value="0x81A7" name="GL_DEPTH_COMPONENT32_OES"/>
+        <enum value="0x81A7" name="GL_DEPTH_COMPONENT32_SGIX"/>
+        <enum value="0x81A8" name="GL_ARRAY_ELEMENT_LOCK_FIRST_EXT"/>
+        <enum value="0x81A9" name="GL_ARRAY_ELEMENT_LOCK_COUNT_EXT"/>
+        <enum value="0x81AA" name="GL_CULL_VERTEX_EXT"/>
+        <enum value="0x81AB" name="GL_CULL_VERTEX_EYE_POSITION_EXT"/>
+        <enum value="0x81AC" name="GL_CULL_VERTEX_OBJECT_POSITION_EXT"/>
+        <enum value="0x81AD" name="GL_IUI_V2F_EXT"/>
+        <enum value="0x81AE" name="GL_IUI_V3F_EXT"/>
+        <enum value="0x81AF" name="GL_IUI_N3F_V2F_EXT"/>
+        <enum value="0x81B0" name="GL_IUI_N3F_V3F_EXT"/>
+        <enum value="0x81B1" name="GL_T2F_IUI_V2F_EXT"/>
+        <enum value="0x81B2" name="GL_T2F_IUI_V3F_EXT"/>
+        <enum value="0x81B3" name="GL_T2F_IUI_N3F_V2F_EXT"/>
+        <enum value="0x81B4" name="GL_T2F_IUI_N3F_V3F_EXT"/>
+        <enum value="0x81B5" name="GL_INDEX_TEST_EXT"/>
+        <enum value="0x81B6" name="GL_INDEX_TEST_FUNC_EXT"/>
+        <enum value="0x81B7" name="GL_INDEX_TEST_REF_EXT"/>
+        <enum value="0x81B8" name="GL_INDEX_MATERIAL_EXT"/>
+        <enum value="0x81B9" name="GL_INDEX_MATERIAL_PARAMETER_EXT"/>
+        <enum value="0x81BA" name="GL_INDEX_MATERIAL_FACE_EXT"/>
+        <enum value="0x81BB" name="GL_YCRCB_422_SGIX"/>
+        <enum value="0x81BC" name="GL_YCRCB_444_SGIX"/>
+            <unused start="0x81BD" end="0x81C3" comment="Incomplete extension SGI_complex_type"/>
+            <!-- <enum value="0x81BD" name="GL_COMPLEX_UNSIGNED_BYTE_SGI"/> -->
+            <!-- <enum value="0x81BE" name="GL_COMPLEX_BYTE_SGI"/> -->
+            <!-- <enum value="0x81BF" name="GL_COMPLEX_UNSIGNED_SHORT_SGI"/> -->
+            <!-- <enum value="0x81C0" name="GL_COMPLEX_SHORT_SGI"/> -->
+            <!-- <enum value="0x81C1" name="GL_COMPLEX_UNSIGNED_INT_SGI"/> -->
+            <!-- <enum value="0x81C2" name="GL_COMPLEX_INT_SGI"/> -->
+            <!-- <enum value="0x81C3" name="GL_COMPLEX_FLOAT_SGI"/> -->
+            <unused start="0x81C4" end="0x81CA" comment="Incomplete extension SGI_fft"/>
+            <!-- <enum value="0x81C4" name="GL_PIXEL_TRANSFORM_OPERATOR_SGI"/> -->
+            <!-- <enum value="0x81C5" name="GL_CONVOLUTION_SGI"/> -->
+            <!-- <enum value="0x81C6" name="GL_FFT_1D_SGI"/> -->
+            <!-- <enum value="0x81C7" name="GL_PIXEL_TRANSFORM_SGI"/> -->
+            <!-- <enum value="0x81C8" name="GL_MAX_FFT_WIDTH_SGI"/> -->
+            <!-- <enum value="0x81C9" name="GL_SORT_SGI"/> -->
+            <!-- <enum value="0x81CA" name="GL_TRANSPOSE_SGI"/> -->
+            <unused start="0x81CB" end="0x81CF" comment="Incomplete extension SGIX_nurbs_eval"/>
+            <!-- <enum value="0x81CB" name="GL_MAP1_VERTEX_3_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81CC" name="GL_MAP1_VERTEX_4_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81CD" name="GL_MAP1_INDEX_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81CE" name="GL_MAP1_COLOR_4_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81CF" name="GL_MAP1_NORMAL_NURBS_SGIX"/> -->
+    </enums>
+
+    <enums namespace="GL" start="0x81D0" end="0x81DF" vendor="SUN">
+            <unused start="0x81D0" end="0x81D1"/>
+            <unused start="0x81D2" end="0x81D3" comment="No extension spec SUNX_surface_hint"/>
+            <!-- <enum value="0x81D2" name="GL_SURFACE_SIZE_HINT_SUNX"/> -->
+            <!-- <enum value="0x81D3" name="GL_LARGE_SUNX"/> -->
+        <enum value="0x81D4" name="GL_WRAP_BORDER_SUN"/>
+        <enum value="0x81D5" name="GL_UNPACK_CONSTANT_DATA_SUNX"/>
+        <enum value="0x81D6" name="GL_TEXTURE_CONSTANT_DATA_SUNX"/>
+        <enum value="0x81D7" name="GL_TRIANGLE_LIST_SUN"/>
+        <enum value="0x81D8" name="GL_REPLACEMENT_CODE_SUN"/>
+        <enum value="0x81D9" name="GL_GLOBAL_ALPHA_SUN"/>
+        <enum value="0x81DA" name="GL_GLOBAL_ALPHA_FACTOR_SUN"/>
+            <unused start="0x81DB" end="0x81DF"/>
+    </enums>
+
+    <enums namespace="GL" start="0x81E0" end="0x81FF" vendor="SGI">
+            <unused start="0x81E0" end="0x81EE" comment="Incomplete extension SGIX_nurbs_eval"/>
+            <!-- <enum value="0x81E0" name="GL_MAP1_TEXTURE_COORD_1_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81E1" name="GL_MAP1_TEXTURE_COORD_2_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81E2" name="GL_MAP1_TEXTURE_COORD_3_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81E3" name="GL_MAP1_TEXTURE_COORD_4_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81E4" name="GL_MAP2_VERTEX_3_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81E5" name="GL_MAP2_VERTEX_4_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81E6" name="GL_MAP2_INDEX_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81E7" name="GL_MAP2_COLOR_4_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81E8" name="GL_MAP2_NORMAL_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81E9" name="GL_MAP2_TEXTURE_COORD_1_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81EA" name="GL_MAP2_TEXTURE_COORD_2_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81EB" name="GL_MAP2_TEXTURE_COORD_3_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81EC" name="GL_MAP2_TEXTURE_COORD_4_NURBS_SGIX"/> -->
+            <!-- <enum value="0x81ED" name="GL_NURBS_KNOT_COUNT_SGIX"/> -->
+            <!-- <enum value="0x81EE" name="GL_NURBS_KNOT_VECTOR_SGIX"/> -->
+        <enum value="0x81EF" name="GL_TEXTURE_COLOR_WRITEMASK_SGIS"/>
+        <enum value="0x81F0" name="GL_EYE_DISTANCE_TO_POINT_SGIS"/>
+        <enum value="0x81F1" name="GL_OBJECT_DISTANCE_TO_POINT_SGIS"/>
+        <enum value="0x81F2" name="GL_EYE_DISTANCE_TO_LINE_SGIS"/>
+        <enum value="0x81F3" name="GL_OBJECT_DISTANCE_TO_LINE_SGIS"/>
+        <enum value="0x81F4" name="GL_EYE_POINT_SGIS"/>
+        <enum value="0x81F5" name="GL_OBJECT_POINT_SGIS"/>
+        <enum value="0x81F6" name="GL_EYE_LINE_SGIS"/>
+        <enum value="0x81F7" name="GL_OBJECT_LINE_SGIS"/>
+        <enum value="0x81F8" name="GL_LIGHT_MODEL_COLOR_CONTROL"/>
+        <enum value="0x81F8" name="GL_LIGHT_MODEL_COLOR_CONTROL_EXT"/>
+        <enum value="0x81F9" name="GL_SINGLE_COLOR"/>
+        <enum value="0x81F9" name="GL_SINGLE_COLOR_EXT"/>
+        <enum value="0x81FA" name="GL_SEPARATE_SPECULAR_COLOR"/>
+        <enum value="0x81FA" name="GL_SEPARATE_SPECULAR_COLOR_EXT"/>
+        <enum value="0x81FB" name="GL_SHARED_TEXTURE_PALETTE_EXT"/>
+            <unused start="0x81FC" end="0x81FD" comment="Incomplete extension SGIX_fog_scale"/>
+            <!-- <enum value="0x81FC" name="GL_FOG_SCALE_SGIX"/> -->
+            <!-- <enum value="0x81FD" name="GL_FOG_SCALE_VALUE_SGIX"/> -->
+            <unused start="0x81FE" end="0x81FF" comment="Incomplete extension SGIX_fog_blend"/>
+            <!-- <enum value="0x81FE" name="GL_FOG_BLEND_ALPHA_SGIX"/> -->
+            <!-- <enum value="0x81FF" name="GL_FOG_BLEND_COLOR_SGIX"/> -->
+    </enums>
+
+    <enums namespace="GL" start="0x8200" end="0x820F" vendor="AMD" comment="Range released by MS 2002/9/16">
+        <enum value="0x8200" name="GL_TEXT_FRAGMENT_SHADER_ATI"/>
+            <unused start="0x8201" end="0x820F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8210" end="0x823F" vendor="ARB">
+        <enum value="0x8210" name="GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING"/>
+        <enum value="0x8210" name="GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT"/>
+        <enum value="0x8211" name="GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"/>
+        <enum value="0x8211" name="GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT"/>
+        <enum value="0x8212" name="GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE"/>
+        <enum value="0x8213" name="GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE"/>
+        <enum value="0x8214" name="GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE"/>
+        <enum value="0x8215" name="GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE"/>
+        <enum value="0x8216" name="GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE"/>
+        <enum value="0x8217" name="GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE"/>
+        <enum value="0x8218" name="GL_FRAMEBUFFER_DEFAULT"/>
+        <enum value="0x8219" name="GL_FRAMEBUFFER_UNDEFINED"/>
+        <enum value="0x8219" name="GL_FRAMEBUFFER_UNDEFINED_OES"/>
+        <enum value="0x821A" name="GL_DEPTH_STENCIL_ATTACHMENT"/>
+        <enum value="0x821B" name="GL_MAJOR_VERSION"/>
+        <enum value="0x821C" name="GL_MINOR_VERSION"/>
+        <enum value="0x821D" name="GL_NUM_EXTENSIONS"/>
+        <enum value="0x821E" name="GL_CONTEXT_FLAGS"/>
+        <enum value="0x821F" name="GL_BUFFER_IMMUTABLE_STORAGE"/>
+        <enum value="0x8220" name="GL_BUFFER_STORAGE_FLAGS"/>
+        <enum value="0x8221" name="GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED" comment="Proposed for Bug 10364"/>
+        <enum value="0x8222" name="GL_INDEX"/>
+            <unused start="0x8223" comment="GL_DEPTH_BUFFER = 0x8223 not actually used in the API"/>
+            <unused start="0x8224" comment="GL_STENCIL_BUFFER = 0x8224 not actually used in the API"/>
+        <enum value="0x8225" name="GL_COMPRESSED_RED"/>
+        <enum value="0x8226" name="GL_COMPRESSED_RG"/>
+        <enum value="0x8227" name="GL_RG"/>
+        <enum value="0x8227" name="GL_RG_EXT"/>
+        <enum value="0x8228" name="GL_RG_INTEGER"/>
+        <enum value="0x8229" name="GL_R8"/>
+        <enum value="0x8229" name="GL_R8_EXT"/>
+        <enum value="0x822A" name="GL_R16"/>
+        <enum value="0x822B" name="GL_RG8"/>
+        <enum value="0x822B" name="GL_RG8_EXT"/>
+        <enum value="0x822C" name="GL_RG16"/>
+        <enum value="0x822D" name="GL_R16F"/>
+        <enum value="0x822D" name="GL_R16F_EXT"/>
+        <enum value="0x822E" name="GL_R32F"/>
+        <enum value="0x822E" name="GL_R32F_EXT"/>
+        <enum value="0x822F" name="GL_RG16F"/>
+        <enum value="0x822F" name="GL_RG16F_EXT"/>
+        <enum value="0x8230" name="GL_RG32F"/>
+        <enum value="0x8230" name="GL_RG32F_EXT"/>
+        <enum value="0x8231" name="GL_R8I"/>
+        <enum value="0x8232" name="GL_R8UI"/>
+        <enum value="0x8233" name="GL_R16I"/>
+        <enum value="0x8234" name="GL_R16UI"/>
+        <enum value="0x8235" name="GL_R32I"/>
+        <enum value="0x8236" name="GL_R32UI"/>
+        <enum value="0x8237" name="GL_RG8I"/>
+        <enum value="0x8238" name="GL_RG8UI"/>
+        <enum value="0x8239" name="GL_RG16I"/>
+        <enum value="0x823A" name="GL_RG16UI"/>
+        <enum value="0x823B" name="GL_RG32I"/>
+        <enum value="0x823C" name="GL_RG32UI"/>
+            <unused start="0x823D" end="0x823F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8240" end="0x82AF" vendor="ARB" comment="Range released by MS on 2002/9/16">
+        <enum value="0x8240" name="GL_SYNC_CL_EVENT_ARB"/>
+        <enum value="0x8241" name="GL_SYNC_CL_EVENT_COMPLETE_ARB"/>
+        <enum value="0x8242" name="GL_DEBUG_OUTPUT_SYNCHRONOUS"/>
+        <enum value="0x8242" name="GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB"/>
+        <enum value="0x8242" name="GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR"/>
+        <enum value="0x8243" name="GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH"/>
+        <enum value="0x8243" name="GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB"/>
+        <enum value="0x8243" name="GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR"/>
+        <enum value="0x8244" name="GL_DEBUG_CALLBACK_FUNCTION"/>
+        <enum value="0x8244" name="GL_DEBUG_CALLBACK_FUNCTION_ARB"/>
+        <enum value="0x8244" name="GL_DEBUG_CALLBACK_FUNCTION_KHR"/>
+        <enum value="0x8245" name="GL_DEBUG_CALLBACK_USER_PARAM"/>
+        <enum value="0x8245" name="GL_DEBUG_CALLBACK_USER_PARAM_ARB"/>
+        <enum value="0x8245" name="GL_DEBUG_CALLBACK_USER_PARAM_KHR"/>
+        <enum value="0x8246" name="GL_DEBUG_SOURCE_API"/>
+        <enum value="0x8246" name="GL_DEBUG_SOURCE_API_ARB"/>
+        <enum value="0x8246" name="GL_DEBUG_SOURCE_API_KHR"/>
+        <enum value="0x8247" name="GL_DEBUG_SOURCE_WINDOW_SYSTEM"/>
+        <enum value="0x8247" name="GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB"/>
+        <enum value="0x8247" name="GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR"/>
+        <enum value="0x8248" name="GL_DEBUG_SOURCE_SHADER_COMPILER"/>
+        <enum value="0x8248" name="GL_DEBUG_SOURCE_SHADER_COMPILER_ARB"/>
+        <enum value="0x8248" name="GL_DEBUG_SOURCE_SHADER_COMPILER_KHR"/>
+        <enum value="0x8249" name="GL_DEBUG_SOURCE_THIRD_PARTY"/>
+        <enum value="0x8249" name="GL_DEBUG_SOURCE_THIRD_PARTY_ARB"/>
+        <enum value="0x8249" name="GL_DEBUG_SOURCE_THIRD_PARTY_KHR"/>
+        <enum value="0x824A" name="GL_DEBUG_SOURCE_APPLICATION"/>
+        <enum value="0x824A" name="GL_DEBUG_SOURCE_APPLICATION_ARB"/>
+        <enum value="0x824A" name="GL_DEBUG_SOURCE_APPLICATION_KHR"/>
+        <enum value="0x824B" name="GL_DEBUG_SOURCE_OTHER"/>
+        <enum value="0x824B" name="GL_DEBUG_SOURCE_OTHER_ARB"/>
+        <enum value="0x824B" name="GL_DEBUG_SOURCE_OTHER_KHR"/>
+        <enum value="0x824C" name="GL_DEBUG_TYPE_ERROR"/>
+        <enum value="0x824C" name="GL_DEBUG_TYPE_ERROR_ARB"/>
+        <enum value="0x824C" name="GL_DEBUG_TYPE_ERROR_KHR"/>
+        <enum value="0x824D" name="GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR"/>
+        <enum value="0x824D" name="GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB"/>
+        <enum value="0x824D" name="GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR"/>
+        <enum value="0x824E" name="GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR"/>
+        <enum value="0x824E" name="GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB"/>
+        <enum value="0x824E" name="GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR"/>
+        <enum value="0x824F" name="GL_DEBUG_TYPE_PORTABILITY"/>
+        <enum value="0x824F" name="GL_DEBUG_TYPE_PORTABILITY_ARB"/>
+        <enum value="0x824F" name="GL_DEBUG_TYPE_PORTABILITY_KHR"/>
+        <enum value="0x8250" name="GL_DEBUG_TYPE_PERFORMANCE"/>
+        <enum value="0x8250" name="GL_DEBUG_TYPE_PERFORMANCE_ARB"/>
+        <enum value="0x8250" name="GL_DEBUG_TYPE_PERFORMANCE_KHR"/>
+        <enum value="0x8251" name="GL_DEBUG_TYPE_OTHER"/>
+        <enum value="0x8251" name="GL_DEBUG_TYPE_OTHER_ARB"/>
+        <enum value="0x8251" name="GL_DEBUG_TYPE_OTHER_KHR"/>
+        <enum value="0x8252" name="GL_LOSE_CONTEXT_ON_RESET_ARB"/>
+        <enum value="0x8252" name="GL_LOSE_CONTEXT_ON_RESET_EXT"/>
+        <enum value="0x8253" name="GL_GUILTY_CONTEXT_RESET_ARB"/>
+        <enum value="0x8253" name="GL_GUILTY_CONTEXT_RESET_EXT"/>
+        <enum value="0x8254" name="GL_INNOCENT_CONTEXT_RESET_ARB"/>
+        <enum value="0x8254" name="GL_INNOCENT_CONTEXT_RESET_EXT"/>
+        <enum value="0x8255" name="GL_UNKNOWN_CONTEXT_RESET_ARB"/>
+        <enum value="0x8255" name="GL_UNKNOWN_CONTEXT_RESET_EXT"/>
+        <enum value="0x8256" name="GL_RESET_NOTIFICATION_STRATEGY_ARB"/>
+        <enum value="0x8256" name="GL_RESET_NOTIFICATION_STRATEGY_EXT"/>
+        <enum value="0x8257" name="GL_PROGRAM_BINARY_RETRIEVABLE_HINT"/>
+        <enum value="0x8258" name="GL_PROGRAM_SEPARABLE"/>
+        <enum value="0x8258" name="GL_PROGRAM_SEPARABLE_EXT"/>
+        <enum value="0x8259" name="GL_ACTIVE_PROGRAM"/>
+        <enum value="0x8259" api="gles2" name="GL_ACTIVE_PROGRAM_EXT" comment="For the OpenGL ES version of EXT_separate_shader_objects"/>
+        <enum value="0x825A" name="GL_PROGRAM_PIPELINE_BINDING"/>
+        <enum value="0x825A" name="GL_PROGRAM_PIPELINE_BINDING_EXT"/>
+        <enum value="0x825B" name="GL_MAX_VIEWPORTS"/>
+        <enum value="0x825C" name="GL_VIEWPORT_SUBPIXEL_BITS"/>
+        <enum value="0x825D" name="GL_VIEWPORT_BOUNDS_RANGE"/>
+        <enum value="0x825E" name="GL_LAYER_PROVOKING_VERTEX"/>
+        <enum value="0x825E" name="GL_LAYER_PROVOKING_VERTEX_EXT"/>
+        <enum value="0x825F" name="GL_VIEWPORT_INDEX_PROVOKING_VERTEX"/>
+        <enum value="0x8260" name="GL_UNDEFINED_VERTEX"/>
+        <enum value="0x8260" name="GL_UNDEFINED_VERTEX_EXT"/>                                
+        <enum value="0x8261" name="GL_NO_RESET_NOTIFICATION_ARB"/>
+        <enum value="0x8261" name="GL_NO_RESET_NOTIFICATION_EXT"/>
+        <enum value="0x8262" name="GL_MAX_COMPUTE_SHARED_MEMORY_SIZE"/>
+        <enum value="0x8263" name="GL_MAX_COMPUTE_UNIFORM_COMPONENTS"/>
+        <enum value="0x8264" name="GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS"/>
+        <enum value="0x8265" name="GL_MAX_COMPUTE_ATOMIC_COUNTERS"/>
+        <enum value="0x8266" name="GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS"/>
+        <enum value="0x8267" name="GL_COMPUTE_WORK_GROUP_SIZE"/>
+        <enum value="0x8268" name="GL_DEBUG_TYPE_MARKER"/>
+        <enum value="0x8268" name="GL_DEBUG_TYPE_MARKER_KHR"/>
+        <enum value="0x8269" name="GL_DEBUG_TYPE_PUSH_GROUP"/>
+        <enum value="0x8269" name="GL_DEBUG_TYPE_PUSH_GROUP_KHR"/>
+        <enum value="0x826A" name="GL_DEBUG_TYPE_POP_GROUP"/>
+        <enum value="0x826A" name="GL_DEBUG_TYPE_POP_GROUP_KHR"/>
+        <enum value="0x826B" name="GL_DEBUG_SEVERITY_NOTIFICATION"/>
+        <enum value="0x826B" name="GL_DEBUG_SEVERITY_NOTIFICATION_KHR"/>
+        <enum value="0x826C" name="GL_MAX_DEBUG_GROUP_STACK_DEPTH"/>
+        <enum value="0x826C" name="GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR"/>
+        <enum value="0x826D" name="GL_DEBUG_GROUP_STACK_DEPTH"/>
+        <enum value="0x826D" name="GL_DEBUG_GROUP_STACK_DEPTH_KHR"/>
+        <enum value="0x826E" name="GL_MAX_UNIFORM_LOCATIONS"/>
+        <enum value="0x826F" name="GL_INTERNALFORMAT_SUPPORTED"/>
+        <enum value="0x8270" name="GL_INTERNALFORMAT_PREFERRED"/>
+        <enum value="0x8271" name="GL_INTERNALFORMAT_RED_SIZE"/>
+        <enum value="0x8272" name="GL_INTERNALFORMAT_GREEN_SIZE"/>
+        <enum value="0x8273" name="GL_INTERNALFORMAT_BLUE_SIZE"/>
+        <enum value="0x8274" name="GL_INTERNALFORMAT_ALPHA_SIZE"/>
+        <enum value="0x8275" name="GL_INTERNALFORMAT_DEPTH_SIZE"/>
+        <enum value="0x8276" name="GL_INTERNALFORMAT_STENCIL_SIZE"/>
+        <enum value="0x8277" name="GL_INTERNALFORMAT_SHARED_SIZE"/>
+        <enum value="0x8278" name="GL_INTERNALFORMAT_RED_TYPE"/>
+        <enum value="0x8279" name="GL_INTERNALFORMAT_GREEN_TYPE"/>
+        <enum value="0x827A" name="GL_INTERNALFORMAT_BLUE_TYPE"/>
+        <enum value="0x827B" name="GL_INTERNALFORMAT_ALPHA_TYPE"/>
+        <enum value="0x827C" name="GL_INTERNALFORMAT_DEPTH_TYPE"/>
+        <enum value="0x827D" name="GL_INTERNALFORMAT_STENCIL_TYPE"/>
+        <enum value="0x827E" name="GL_MAX_WIDTH"/>
+        <enum value="0x827F" name="GL_MAX_HEIGHT"/>
+        <enum value="0x8280" name="GL_MAX_DEPTH"/>
+        <enum value="0x8281" name="GL_MAX_LAYERS"/>
+        <enum value="0x8282" name="GL_MAX_COMBINED_DIMENSIONS"/>
+        <enum value="0x8283" name="GL_COLOR_COMPONENTS"/>
+        <enum value="0x8284" name="GL_DEPTH_COMPONENTS"/>
+        <enum value="0x8285" name="GL_STENCIL_COMPONENTS"/>
+        <enum value="0x8286" name="GL_COLOR_RENDERABLE"/>
+        <enum value="0x8287" name="GL_DEPTH_RENDERABLE"/>
+        <enum value="0x8288" name="GL_STENCIL_RENDERABLE"/>
+        <enum value="0x8289" name="GL_FRAMEBUFFER_RENDERABLE"/>
+        <enum value="0x828A" name="GL_FRAMEBUFFER_RENDERABLE_LAYERED"/>
+        <enum value="0x828B" name="GL_FRAMEBUFFER_BLEND"/>
+        <enum value="0x828C" name="GL_READ_PIXELS"/>
+        <enum value="0x828D" name="GL_READ_PIXELS_FORMAT"/>
+        <enum value="0x828E" name="GL_READ_PIXELS_TYPE"/>
+        <enum value="0x828F" name="GL_TEXTURE_IMAGE_FORMAT"/>
+        <enum value="0x8290" name="GL_TEXTURE_IMAGE_TYPE"/>
+        <enum value="0x8291" name="GL_GET_TEXTURE_IMAGE_FORMAT"/>
+        <enum value="0x8292" name="GL_GET_TEXTURE_IMAGE_TYPE"/>
+        <enum value="0x8293" name="GL_MIPMAP"/>
+        <enum value="0x8294" name="GL_MANUAL_GENERATE_MIPMAP"/>
+        <enum value="0x8295" name="GL_AUTO_GENERATE_MIPMAP" comment="Should be deprecated"/>
+        <enum value="0x8296" name="GL_COLOR_ENCODING"/>
+        <enum value="0x8297" name="GL_SRGB_READ"/>
+        <enum value="0x8298" name="GL_SRGB_WRITE"/>
+        <enum value="0x8299" name="GL_SRGB_DECODE_ARB"/>
+        <enum value="0x829A" name="GL_FILTER"/>
+        <enum value="0x829B" name="GL_VERTEX_TEXTURE"/>
+        <enum value="0x829C" name="GL_TESS_CONTROL_TEXTURE"/>
+        <enum value="0x829D" name="GL_TESS_EVALUATION_TEXTURE"/>
+        <enum value="0x829E" name="GL_GEOMETRY_TEXTURE"/>
+        <enum value="0x829F" name="GL_FRAGMENT_TEXTURE"/>
+        <enum value="0x82A0" name="GL_COMPUTE_TEXTURE"/>
+        <enum value="0x82A1" name="GL_TEXTURE_SHADOW"/>
+        <enum value="0x82A2" name="GL_TEXTURE_GATHER"/>
+        <enum value="0x82A3" name="GL_TEXTURE_GATHER_SHADOW"/>
+        <enum value="0x82A4" name="GL_SHADER_IMAGE_LOAD"/>
+        <enum value="0x82A5" name="GL_SHADER_IMAGE_STORE"/>
+        <enum value="0x82A6" name="GL_SHADER_IMAGE_ATOMIC"/>
+        <enum value="0x82A7" name="GL_IMAGE_TEXEL_SIZE"/>
+        <enum value="0x82A8" name="GL_IMAGE_COMPATIBILITY_CLASS"/>
+        <enum value="0x82A9" name="GL_IMAGE_PIXEL_FORMAT"/>
+        <enum value="0x82AA" name="GL_IMAGE_PIXEL_TYPE"/>
+            <unused start="0x82AB"/>
+        <enum value="0x82AC" name="GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST"/>
+        <enum value="0x82AD" name="GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST"/>
+        <enum value="0x82AE" name="GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE"/>
+        <enum value="0x82AF" name="GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE"/>
+    </enums>
+
+    <enums namespace="GL" start="0x82B0" end="0x830F" vendor="ARB" comment="Range reclaimed from ADD on 2012/05/10">
+            <unused start="0x82B0"/>
+        <enum value="0x82B1" name="GL_TEXTURE_COMPRESSED_BLOCK_WIDTH"/>
+        <enum value="0x82B2" name="GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT"/>
+        <enum value="0x82B3" name="GL_TEXTURE_COMPRESSED_BLOCK_SIZE"/>
+        <enum value="0x82B4" name="GL_CLEAR_BUFFER"/>
+        <enum value="0x82B5" name="GL_TEXTURE_VIEW"/>
+        <enum value="0x82B6" name="GL_VIEW_COMPATIBILITY_CLASS"/>
+        <enum value="0x82B7" name="GL_FULL_SUPPORT"/>
+        <enum value="0x82B8" name="GL_CAVEAT_SUPPORT"/>
+        <enum value="0x82B9" name="GL_IMAGE_CLASS_4_X_32"/>
+        <enum value="0x82BA" name="GL_IMAGE_CLASS_2_X_32"/>
+        <enum value="0x82BB" name="GL_IMAGE_CLASS_1_X_32"/>
+        <enum value="0x82BC" name="GL_IMAGE_CLASS_4_X_16"/>
+        <enum value="0x82BD" name="GL_IMAGE_CLASS_2_X_16"/>
+        <enum value="0x82BE" name="GL_IMAGE_CLASS_1_X_16"/>
+        <enum value="0x82BF" name="GL_IMAGE_CLASS_4_X_8"/>
+        <enum value="0x82C0" name="GL_IMAGE_CLASS_2_X_8"/>
+        <enum value="0x82C1" name="GL_IMAGE_CLASS_1_X_8"/>
+        <enum value="0x82C2" name="GL_IMAGE_CLASS_11_11_10"/>
+        <enum value="0x82C3" name="GL_IMAGE_CLASS_10_10_10_2"/>
+        <enum value="0x82C4" name="GL_VIEW_CLASS_128_BITS"/>
+        <enum value="0x82C5" name="GL_VIEW_CLASS_96_BITS"/>
+        <enum value="0x82C6" name="GL_VIEW_CLASS_64_BITS"/>
+        <enum value="0x82C7" name="GL_VIEW_CLASS_48_BITS"/>
+        <enum value="0x82C8" name="GL_VIEW_CLASS_32_BITS"/>
+        <enum value="0x82C9" name="GL_VIEW_CLASS_24_BITS"/>
+        <enum value="0x82CA" name="GL_VIEW_CLASS_16_BITS"/>
+        <enum value="0x82CB" name="GL_VIEW_CLASS_8_BITS"/>
+        <enum value="0x82CC" name="GL_VIEW_CLASS_S3TC_DXT1_RGB"/>
+        <enum value="0x82CD" name="GL_VIEW_CLASS_S3TC_DXT1_RGBA"/>
+        <enum value="0x82CE" name="GL_VIEW_CLASS_S3TC_DXT3_RGBA"/>
+        <enum value="0x82CF" name="GL_VIEW_CLASS_S3TC_DXT5_RGBA"/>
+        <enum value="0x82D0" name="GL_VIEW_CLASS_RGTC1_RED"/>
+        <enum value="0x82D1" name="GL_VIEW_CLASS_RGTC2_RG"/>
+        <enum value="0x82D2" name="GL_VIEW_CLASS_BPTC_UNORM"/>
+        <enum value="0x82D3" name="GL_VIEW_CLASS_BPTC_FLOAT"/>
+        <enum value="0x82D4" name="GL_VERTEX_ATTRIB_BINDING"/>
+        <enum value="0x82D5" name="GL_VERTEX_ATTRIB_RELATIVE_OFFSET"/>
+        <enum value="0x82D6" name="GL_VERTEX_BINDING_DIVISOR"/>
+        <enum value="0x82D7" name="GL_VERTEX_BINDING_OFFSET"/>
+        <enum value="0x82D8" name="GL_VERTEX_BINDING_STRIDE"/>
+        <enum value="0x82D9" name="GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET"/>
+        <enum value="0x82DA" name="GL_MAX_VERTEX_ATTRIB_BINDINGS"/>
+        <enum value="0x82DB" name="GL_TEXTURE_VIEW_MIN_LEVEL"/>
+        <enum value="0x82DB" name="GL_TEXTURE_VIEW_MIN_LEVEL_EXT"/>                          
+        <enum value="0x82DC" name="GL_TEXTURE_VIEW_NUM_LEVELS"/>
+        <enum value="0x82DC" name="GL_TEXTURE_VIEW_NUM_LEVELS_EXT"/>                         
+        <enum value="0x82DD" name="GL_TEXTURE_VIEW_MIN_LAYER"/>
+        <enum value="0x82DD" name="GL_TEXTURE_VIEW_MIN_LAYER_EXT"/>                          
+        <enum value="0x82DE" name="GL_TEXTURE_VIEW_NUM_LAYERS"/>
+        <enum value="0x82DE" name="GL_TEXTURE_VIEW_NUM_LAYERS_EXT"/>                         
+        <enum value="0x82DF" name="GL_TEXTURE_IMMUTABLE_LEVELS"/>
+        <enum value="0x82E0" name="GL_BUFFER"/>
+        <enum value="0x82E0" name="GL_BUFFER_KHR"/>
+        <enum value="0x82E1" name="GL_SHADER"/>
+        <enum value="0x82E1" name="GL_SHADER_KHR"/>
+        <enum value="0x82E2" name="GL_PROGRAM"/>
+        <enum value="0x82E2" name="GL_PROGRAM_KHR"/>
+        <enum value="0x82E3" name="GL_QUERY"/>
+        <enum value="0x82E3" name="GL_QUERY_KHR"/>
+        <enum value="0x82E4" name="GL_PROGRAM_PIPELINE"/>
+        <enum value="0x82E5" name="GL_MAX_VERTEX_ATTRIB_STRIDE"/>
+        <enum value="0x82E6" name="GL_SAMPLER"/>
+        <enum value="0x82E6" name="GL_SAMPLER_KHR"/>
+        <enum value="0x82E7" name="GL_DISPLAY_LIST"/>
+        <enum value="0x82E8" name="GL_MAX_LABEL_LENGTH"/>
+        <enum value="0x82E8" name="GL_MAX_LABEL_LENGTH_KHR"/>
+        <enum value="0x82E9" name="GL_NUM_SHADING_LANGUAGE_VERSIONS"/>
+            <unused start="0x82E9" end="0x830F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8310" end="0x832F" vendor="SGI">
+        <enum value="0x8310" name="GL_DEPTH_PASS_INSTRUMENT_SGIX"/>
+        <enum value="0x8311" name="GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX"/>
+        <enum value="0x8312" name="GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX"/>
+        <enum value="0x8313" name="GL_FRAGMENTS_INSTRUMENT_SGIX"/>
+        <enum value="0x8314" name="GL_FRAGMENTS_INSTRUMENT_COUNTERS_SGIX"/>
+        <enum value="0x8315" name="GL_FRAGMENTS_INSTRUMENT_MAX_SGIX"/>
+        <enum value="0x8316" name="GL_CONVOLUTION_HINT_SGIX"/>
+            <unused start="0x8317" comment="Incomplete extension SGIX_color_matrix_accuracy"/>
+            <!-- <enum value="0x8317" name="GL_COLOR_MATRIX_HINT"/> -->
+        <enum value="0x8318" name="GL_YCRCB_SGIX"/>
+        <enum value="0x8319" name="GL_YCRCBA_SGIX"/>
+        <enum value="0x831A" name="GL_UNPACK_COMPRESSED_SIZE_SGIX"/>
+        <enum value="0x831B" name="GL_PACK_MAX_COMPRESSED_SIZE_SGIX"/>
+        <enum value="0x831C" name="GL_PACK_COMPRESSED_SIZE_SGIX"/>
+        <enum value="0x831D" name="GL_SLIM8U_SGIX"/>
+        <enum value="0x831E" name="GL_SLIM10U_SGIX"/>
+        <enum value="0x831F" name="GL_SLIM12S_SGIX"/>
+        <enum value="0x8320" name="GL_ALPHA_MIN_SGIX"/>
+        <enum value="0x8321" name="GL_ALPHA_MAX_SGIX"/>
+        <enum value="0x8322" name="GL_SCALEBIAS_HINT_SGIX"/>
+            <unused start="0x8323" end="0x8328" comment="Incomplete extension SGIX_fog_layers"/>
+            <!-- <enum value="0x8323" name="GL_FOG_TYPE_SGIX"/> -->
+            <!-- <enum value="0x8324" name="GL_UNIFORM_SGIX"/> -->
+            <!-- <enum value="0x8325" name="GL_LAYERED_SGIX"/> -->
+            <!-- <enum value="0x8326" name="GL_FOG_GROUND_PLANE_SGIX"/> -->
+            <!-- <enum value="0x8327" name="GL_FOG_LAYERS_POINTS_SGIX"/> -->
+            <!-- <enum value="0x8328" name="GL_MAX_FOG_LAYERS_POINTS_SGIX"/> -->
+        <enum value="0x8329" name="GL_ASYNC_MARKER_SGIX"/>
+            <unused start="0x832A" comment="Incomplete extension SGIX_texture_phase"/>
+            <!-- <enum value="0x832A" name="GL_PHASE_SGIX"/> -->
+        <enum value="0x832B" name="GL_PIXEL_TEX_GEN_MODE_SGIX"/>
+        <enum value="0x832C" name="GL_ASYNC_HISTOGRAM_SGIX"/>
+        <enum value="0x832D" name="GL_MAX_ASYNC_HISTOGRAM_SGIX"/>
+            <unused start="0x832E" end="0x832F" comment="Incomplete extension SGIX_texture_mipmap_anisotropic"/>
+            <!-- <enum value="0x832E" name="GL_TEXTURE_MIPMAP_ANISOTROPY_SGIX"/> -->
+            <!-- <enum value="0x832F" name="GL_MAX_MIPMAP_ANISOTROPY_SGIX"/> -->
+    </enums>
+
+    <enums namespace="GL" start="0x8330" end="0x833F" vendor="SUN">
+        <enum value="0x8330" name="GL_PIXEL_TRANSFORM_2D_EXT"/>
+        <enum value="0x8331" name="GL_PIXEL_MAG_FILTER_EXT"/>
+        <enum value="0x8332" name="GL_PIXEL_MIN_FILTER_EXT"/>
+        <enum value="0x8333" name="GL_PIXEL_CUBIC_WEIGHT_EXT"/>
+        <enum value="0x8334" name="GL_CUBIC_EXT"/>
+        <enum value="0x8335" name="GL_AVERAGE_EXT"/>
+        <enum value="0x8336" name="GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT"/>
+        <enum value="0x8337" name="GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT"/>
+        <enum value="0x8338" name="GL_PIXEL_TRANSFORM_2D_MATRIX_EXT"/>
+            <unused start="0x8339" end="0x833F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8340" end="0x836F" vendor="SGI">
+            <unused start="0x8340" end="0x8348" comment="Incomplete extension SGIX_cube_map"/>
+            <!-- <enum value="0x8340" name="GL_ENV_MAP_SGIX"/> -->
+            <!-- <enum value="0x8341" name="GL_CUBE_MAP_SGIX"/> -->
+            <!-- <enum value="0x8342" name="GL_CUBE_MAP_ZP_SGIX"/> -->
+            <!-- <enum value="0x8343" name="GL_CUBE_MAP_ZN_SGIX"/> -->
+            <!-- <enum value="0x8344" name="GL_CUBE_MAP_XN_SGIX"/> -->
+            <!-- <enum value="0x8345" name="GL_CUBE_MAP_XP_SGIX"/> -->
+            <!-- <enum value="0x8346" name="GL_CUBE_MAP_YN_SGIX"/> -->
+            <!-- <enum value="0x8347" name="GL_CUBE_MAP_YP_SGIX"/> -->
+            <!-- <enum value="0x8348" name="GL_CUBE_MAP_BINDING_SGIX"/> -->
+        <enum value="0x8349" name="GL_FRAGMENT_MATERIAL_EXT"/>
+        <enum value="0x834A" name="GL_FRAGMENT_NORMAL_EXT"/>
+            <!-- Unfortunately, there was a collision promoting to EXT
+                 from SGIX. Use fog_coord's value of 0x8452 instead of
+                 the old assigned FRAGMENT_DEPTH_EXT (0x834B). -->
+        <enum value="0x834C" name="GL_FRAGMENT_COLOR_EXT"/>
+        <enum value="0x834D" name="GL_ATTENUATION_EXT"/>
+        <enum value="0x834E" name="GL_SHADOW_ATTENUATION_EXT"/>
+        <enum value="0x834F" name="GL_TEXTURE_APPLICATION_MODE_EXT"/>
+        <enum value="0x8350" name="GL_TEXTURE_LIGHT_EXT"/>
+        <enum value="0x8351" name="GL_TEXTURE_MATERIAL_FACE_EXT"/>
+        <enum value="0x8352" name="GL_TEXTURE_MATERIAL_PARAMETER_EXT"/>
+        <enum value="0x8353" name="GL_PIXEL_TEXTURE_SGIS"/>
+        <enum value="0x8354" name="GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS"/>
+        <enum value="0x8355" name="GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS"/>
+        <enum value="0x8356" name="GL_PIXEL_GROUP_COLOR_SGIS"/>
+            <unused start="0x8357" end="0x8359" comment="Incomplete extension SGIX_pixel_texture_bits"/>
+            <!-- <enum value="0x8357" name="GL_COLOR_TO_TEXTURE_COORD_SGIX"/> -->
+            <!-- <enum value="0x8358" name="GL_COLOR_BIT_PATTERN_SGIX"/> -->
+            <!-- <enum value="0x8359" name="GL_COLOR_VALUE_SGIX"/> -->
+            <unused start="0x835A" comment="Incomplete extension SGIX_pixel_texture_lod"/>
+            <!-- <enum value="0x835A" name="GL_PIXEL_TEX_GEN_LAMBDA_SOURCE_SGIX"/> -->
+        <enum value="0x835B" name="GL_LINE_QUALITY_HINT_SGIX"/>
+        <enum value="0x835C" name="GL_ASYNC_TEX_IMAGE_SGIX"/>
+        <enum value="0x835D" name="GL_ASYNC_DRAW_PIXELS_SGIX"/>
+        <enum value="0x835E" name="GL_ASYNC_READ_PIXELS_SGIX"/>
+        <enum value="0x835F" name="GL_MAX_ASYNC_TEX_IMAGE_SGIX"/>
+        <enum value="0x8360" name="GL_MAX_ASYNC_DRAW_PIXELS_SGIX"/>
+        <enum value="0x8361" name="GL_MAX_ASYNC_READ_PIXELS_SGIX"/>
+        <enum value="0x8362" name="GL_UNSIGNED_BYTE_2_3_3_REV"/>
+        <enum value="0x8362" name="GL_UNSIGNED_BYTE_2_3_3_REV_EXT"/>
+        <enum value="0x8363" name="GL_UNSIGNED_SHORT_5_6_5"/>
+        <enum value="0x8363" name="GL_UNSIGNED_SHORT_5_6_5_EXT"/>
+        <enum value="0x8364" name="GL_UNSIGNED_SHORT_5_6_5_REV"/>
+        <enum value="0x8364" name="GL_UNSIGNED_SHORT_5_6_5_REV_EXT"/>
+        <enum value="0x8365" name="GL_UNSIGNED_SHORT_4_4_4_4_REV"/>
+        <enum value="0x8365" name="GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT"/>
+        <enum value="0x8365" name="GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG"/>
+        <enum value="0x8366" name="GL_UNSIGNED_SHORT_1_5_5_5_REV"/>
+        <enum value="0x8366" name="GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT"/>
+        <enum value="0x8367" name="GL_UNSIGNED_INT_8_8_8_8_REV"/>
+        <enum value="0x8367" name="GL_UNSIGNED_INT_8_8_8_8_REV_EXT"/>
+        <enum value="0x8368" name="GL_UNSIGNED_INT_2_10_10_10_REV"/>
+        <enum value="0x8368" name="GL_UNSIGNED_INT_2_10_10_10_REV_EXT"/>
+        <enum value="0x8369" name="GL_TEXTURE_MAX_CLAMP_S_SGIX"/>
+        <enum value="0x836A" name="GL_TEXTURE_MAX_CLAMP_T_SGIX"/>
+        <enum value="0x836B" name="GL_TEXTURE_MAX_CLAMP_R_SGIX"/>
+            <unused start="0x836C" end="0x836E" comment="Incomplete extension SGIX_fog_texture"/>
+            <!-- <enum value="0x836C" name="GL_FRAGMENT_FOG_SGIX"/> -->
+            <!-- <enum value="0x836D" name="GL_TEXTURE_FOG_SGIX"/> -->
+            <!-- <enum value="0x836E" name="GL_FOG_PATCHY_FACTOR_SGIX"/> -->
+            <unused start="0x836F" comment="Incomplete extension SGIX_fog_factor_to_alpha"/>
+            <!-- <enum value="0x836F" name="GL_FOG_FACTOR_TO_ALPHA_SGIX"/> -->
+    </enums>
+
+    <enums namespace="GL" start="0x8370" end="0x837F" vendor="HP">
+            <!-- NOTE: IBM is using values in this range, because of a
+                 bobble when an employee left DEC for IBM at the same
+                 time as they were assigned the range. their registry
+                 became inconsistent. It's unknown whether HP has any
+                 conflicts. They have never reported using any values in
+                 this range. Lesson: assigned ranges belong to vendors,
+                 not engineers! -->
+        <enum value="0x8370" name="GL_MIRRORED_REPEAT"/>
+        <enum value="0x8370" name="GL_MIRRORED_REPEAT_ARB"/>
+        <enum value="0x8370" name="GL_MIRRORED_REPEAT_IBM"/>
+        <enum value="0x8370" name="GL_MIRRORED_REPEAT_OES"/>
+            <unused start="0x8371" end="0x837F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8380" end="0x839F" vendor="IBM"/>
+
+    <enums namespace="GL" start="0x83A0" end="0x83BF" vendor="S3">
+        <enum value="0x83A0" name="GL_RGB_S3TC"/>
+        <enum value="0x83A1" name="GL_RGB4_S3TC"/>
+        <enum value="0x83A2" name="GL_RGBA_S3TC"/>
+        <enum value="0x83A3" name="GL_RGBA4_S3TC"/>
+        <enum value="0x83A4" name="GL_RGBA_DXT5_S3TC"/>
+        <enum value="0x83A5" name="GL_RGBA4_DXT5_S3TC"/>
+            <unused start="0x83A6" end="0x83BF"/>
+    </enums>
+
+    <enums namespace="GL" start="0x83C0" end="0x83EF" vendor="SGI" comment="Most of this could be reclaimed">
+            <unused start="0x83C0" end="0x83CA" comment="Withdrawn extension SGIS_multitexture"/>
+            <!-- <enum value="0x83C0" name="GL_SELECTED_TEXTURE_SGIS"/> -->
+            <!-- <enum value="0x83C1" name="GL_SELECTED_TEXTURE_COORD_SET_SGIS"/> -->
+            <!-- <enum value="0x83C2" name="GL_SELECTED_TEXTURE_TRANSFORM_SGIS"/> -->
+            <!-- <enum value="0x83C3" name="GL_MAX_TEXTURES_SGIS"/> -->
+            <!-- <enum value="0x83C4" name="GL_MAX_TEXTURE_COORD_SETS_SGIS"/> -->
+            <!-- <enum value="0x83C5" name="GL_TEXTURE_COORD_SET_INTERLEAVE_FACTOR_SGIS"/> -->
+            <!-- <enum value="0x83C6" name="GL_TEXTURE_ENV_COORD_SET_SGIS"/> -->
+            <!-- <enum value="0x83C7" name="GL_TEXTURE0_SGIS"/> -->
+            <!-- <enum value="0x83C8" name="GL_TEXTURE1_SGIS"/> -->
+            <!-- <enum value="0x83C9" name="GL_TEXTURE2_SGIS"/> -->
+            <!-- <enum value="0x83CA" name="GL_TEXTURE3_SGIS"/> -->
+            <unused start="0x83CB" end="0x83E5"/>
+            <unused start="0x83E6" end="0x83E9" comment="Incomplete extension SGIX_bali_g_instruments"/>
+            <!-- <enum value="0x83E6" name="GL_BALI_NUM_TRIS_CULLED_INSTRUMENT_SGIX"/> -->
+            <!-- <enum value="0x83E7" name="GL_BALI_NUM_PRIMS_CLIPPED_INSTRUMENT_SGIX"/> -->
+            <!-- <enum value="0x83E8" name="GL_BALI_NUM_PRIMS_REJECT_INSTRUMENT_SGIX"/> -->
+            <!-- <enum value="0x83E9" name="GL_BALI_NUM_PRIMS_CLIP_RESULT_INSTRUMENT_SGIX"/> -->
+            <unused start="0x83EA" end="0x83EC" comment="Incomplete extension SGIX_bali_r_instruments"/>
+            <!-- <enum value="0x83EA" name="GL_BALI_FRAGMENTS_GENERATED_INSTRUMENT_SGIX"/> -->
+            <!-- <enum value="0x83EB" name="GL_BALI_DEPTH_PASS_INSTRUMENT_SGIX"/> -->
+            <!-- <enum value="0x83EC" name="GL_BALI_R_CHIP_COUNT_SGIX"/> -->
+            <unused start="0x83ED" comment="Incomplete extension SGIX_occlusion_instrument"/>
+            <!-- <enum value="0x83ED" name="GL_OCCLUSION_INSTRUMENT_SGIX"/> -->
+        <enum value="0x83EE" name="GL_VERTEX_PRECLIP_SGIX"/>
+        <enum value="0x83EF" name="GL_VERTEX_PRECLIP_HINT_SGIX"/>
+    </enums>
+
+    <enums namespace="GL" start="0x83F0" end="0x83FF" vendor="INTEL">
+            <!-- This block was reclaimed from NTP, who never shipped
+                 it, and reassigned to Intel. -->
+        <enum value="0x83F0" name="GL_COMPRESSED_RGB_S3TC_DXT1_EXT"/>
+        <enum value="0x83F1" name="GL_COMPRESSED_RGBA_S3TC_DXT1_EXT"/>
+        <enum value="0x83F2" name="GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE"/>
+        <enum value="0x83F2" name="GL_COMPRESSED_RGBA_S3TC_DXT3_EXT"/>
+        <enum value="0x83F3" name="GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE"/>
+        <enum value="0x83F3" name="GL_COMPRESSED_RGBA_S3TC_DXT5_EXT"/>
+        <enum value="0x83F4" name="GL_PARALLEL_ARRAYS_INTEL"/>
+        <enum value="0x83F5" name="GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL"/>
+        <enum value="0x83F6" name="GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL"/>
+        <enum value="0x83F7" name="GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL"/>
+        <enum value="0x83F8" name="GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL"/>
+        <enum value="0x83F9" name="GL_PERFQUERY_DONOT_FLUSH_INTEL"/>
+        <enum value="0x83FA" name="GL_PERFQUERY_FLUSH_INTEL"/>
+        <enum value="0x83FB" name="GL_PERFQUERY_WAIT_INTEL"/>
+            <unused start="0x83FC" end="0x83FE"/>
+        <enum value="0x83FF" name="GL_TEXTURE_MEMORY_LAYOUT_INTEL"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8400" end="0x846F" vendor="SGI">
+        <enum value="0x8400" name="GL_FRAGMENT_LIGHTING_SGIX"/>
+        <enum value="0x8401" name="GL_FRAGMENT_COLOR_MATERIAL_SGIX"/>
+        <enum value="0x8402" name="GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX"/>
+        <enum value="0x8403" name="GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX"/>
+        <enum value="0x8404" name="GL_MAX_FRAGMENT_LIGHTS_SGIX"/>
+        <enum value="0x8405" name="GL_MAX_ACTIVE_LIGHTS_SGIX"/>
+        <enum value="0x8406" name="GL_CURRENT_RASTER_NORMAL_SGIX"/>
+        <enum value="0x8407" name="GL_LIGHT_ENV_MODE_SGIX"/>
+        <enum value="0x8408" name="GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX"/>
+        <enum value="0x8409" name="GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX"/>
+        <enum value="0x840A" name="GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX"/>
+        <enum value="0x840B" name="GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX"/>
+        <enum value="0x840C" name="GL_FRAGMENT_LIGHT0_SGIX"/>
+        <enum value="0x840D" name="GL_FRAGMENT_LIGHT1_SGIX"/>
+        <enum value="0x840E" name="GL_FRAGMENT_LIGHT2_SGIX"/>
+        <enum value="0x840F" name="GL_FRAGMENT_LIGHT3_SGIX"/>
+        <enum value="0x8410" name="GL_FRAGMENT_LIGHT4_SGIX"/>
+        <enum value="0x8411" name="GL_FRAGMENT_LIGHT5_SGIX"/>
+        <enum value="0x8412" name="GL_FRAGMENT_LIGHT6_SGIX"/>
+        <enum value="0x8413" name="GL_FRAGMENT_LIGHT7_SGIX"/>
+            <unused start="0x8414" end="0x842B"/>
+        <enum value="0x842C" name="GL_PACK_RESAMPLE_SGIX"/>
+        <enum value="0x842D" name="GL_UNPACK_RESAMPLE_SGIX"/>
+        <enum value="0x842E" name="GL_RESAMPLE_REPLICATE_SGIX"/>
+        <enum value="0x842F" name="GL_RESAMPLE_ZERO_FILL_SGIX"/>
+        <enum value="0x8430" name="GL_RESAMPLE_DECIMATE_SGIX"/>
+            <unused start="0x8431" end="0x8435"/>
+            <!-- Incomplete extension SGIX_fragment_lighting -->
+            <!-- <enum value="0x8436"      name="GL_EYE_SPACE_SGIX"/> -->
+            <!-- <enum value="0x8437"      name="GL_TANGENT_SPACE_SGIX"/> -->
+            <!-- <enum value="0x8438"      name="GL_OBJECT_SPACE_SGIX"/> -->
+            <!-- <enum value="0x8439"      name="GL_TANGENT_ARRAY_SGIX"/> -->
+            <!-- <enum value="0x843A"      name="GL_BINORMAL_ARRAY_SGIX"/> -->
+            <!-- <enum value="0x843B"      name="GL_CURRENT_TANGENT_SGIX"/> -->
+            <!-- <enum value="0x843C"      name="GL_CURRENT_BINORMAL_SGIX"/> -->
+            <!-- <enum value="0x843D"      name="GL_FRAGMENT_LIGHT_SPACE_SGIX"/> -->
+            <!-- <enum value="0x843E"      name="GL_TANGENT_ARRAY_TYPE_SGIX"/> -->
+            <!-- <enum value="0x843F"      name="GL_TANGENT_ARRAY_STRIDE_SGIX"/> -->
+            <!-- <enum value="0x8440"      name="GL_TANGENT_ARRAY_COUNT_SGIX"/> -->
+            <!-- <enum value="0x8441"      name="GL_BINORMAL_ARRAY_TYPE_SGIX"/> -->
+            <!-- <enum value="0x8442"      name="GL_BINORMAL_ARRAY_STRIDE_SGIX"/> -->
+            <!-- <enum value="0x8443"      name="GL_BINORMAL_ARRAY_COUNT_SGIX"/> -->
+            <!-- <enum value="0x8444"      name="GL_TANGENT_ARRAY_POINTER_SGIX"/> -->
+            <!-- <enum value="0x8445"      name="GL_BINORMAL_ARRAY_POINTER_SGIX"/> -->
+            <!-- <enum value="0x8446"      name="GL_MAP1_TANGENT_SGIX"/> -->
+            <!-- <enum value="0x8447"      name="GL_MAP2_TANGENT_SGIX"/> -->
+            <!-- <enum value="0x8448"      name="GL_MAP1_BINORMAL_SGIX"/> -->
+            <!-- <enum value="0x8449"      name="GL_MAP2_BINORMAL_SGIX"/> -->
+        <enum value="0x8439" name="GL_TANGENT_ARRAY_EXT"/>
+        <enum value="0x843A" name="GL_BINORMAL_ARRAY_EXT"/>
+        <enum value="0x843B" name="GL_CURRENT_TANGENT_EXT"/>
+        <enum value="0x843C" name="GL_CURRENT_BINORMAL_EXT"/>
+                     <unused start="0x844D"/>
+        <enum value="0x843E" name="GL_TANGENT_ARRAY_TYPE_EXT"/>
+        <enum value="0x843F" name="GL_TANGENT_ARRAY_STRIDE_EXT"/>
+        <enum value="0x8440" name="GL_BINORMAL_ARRAY_TYPE_EXT"/>
+        <enum value="0x8441" name="GL_BINORMAL_ARRAY_STRIDE_EXT"/>
+        <enum value="0x8442" name="GL_TANGENT_ARRAY_POINTER_EXT"/>
+        <enum value="0x8443" name="GL_BINORMAL_ARRAY_POINTER_EXT"/>
+        <enum value="0x8444" name="GL_MAP1_TANGENT_EXT"/>
+        <enum value="0x8445" name="GL_MAP2_TANGENT_EXT"/>
+        <enum value="0x8446" name="GL_MAP1_BINORMAL_EXT"/>
+        <enum value="0x8447" name="GL_MAP2_BINORMAL_EXT"/>
+            <unused start="0x8448" end="0x8449" comment="Incomplete extension SGIX_fragment_lighting"/>
+            <unused start="0x844A" end="0x844C" comment="Incomplete extension SGIX_bali_timer_instruments"/>
+            <!-- <enum value="0x844A" name="GL_BALI_GEOM_TIMER_INSTRUMENT_SGIX"/> -->
+            <!-- <enum value="0x844B" name="GL_BALI_RASTER_TIMER_INSTRUMENT_SGIX"/> -->
+            <!-- <enum value="0x844C" name="GL_BALI_INSTRUMENT_TIME_UNIT_SGIX"/> -->
+        <enum value="0x844D" name="GL_NEAREST_CLIPMAP_NEAREST_SGIX"/>
+        <enum value="0x844E" name="GL_NEAREST_CLIPMAP_LINEAR_SGIX"/>
+        <enum value="0x844F" name="GL_LINEAR_CLIPMAP_NEAREST_SGIX"/>
+            <!-- 0x8450-0x845F range brokered for Id Software -->
+        <enum value="0x8450" name="GL_FOG_COORDINATE_SOURCE"/>
+        <enum value="0x8450" name="GL_FOG_COORDINATE_SOURCE_EXT"/>
+        <enum value="0x8450" name="GL_FOG_COORD_SRC" alias="GL_FOG_COORDINATE_SOURCE"/>
+        <enum value="0x8451" name="GL_FOG_COORDINATE"/>
+        <enum value="0x8451" name="GL_FOG_COORD" alias="GL_FOG_COORDINATE"/>
+        <enum value="0x8451" name="GL_FOG_COORDINATE_EXT"/>
+        <enum value="0x8452" name="GL_FRAGMENT_DEPTH"/>
+        <enum value="0x8452" name="GL_FRAGMENT_DEPTH_EXT"/>
+        <enum value="0x8453" name="GL_CURRENT_FOG_COORDINATE"/>
+        <enum value="0x8453" name="GL_CURRENT_FOG_COORD" alias="GL_CURRENT_FOG_COORDINATE"/>
+        <enum value="0x8453" name="GL_CURRENT_FOG_COORDINATE_EXT"/>
+        <enum value="0x8454" name="GL_FOG_COORDINATE_ARRAY_TYPE"/>
+        <enum value="0x8454" name="GL_FOG_COORDINATE_ARRAY_TYPE_EXT"/>
+        <enum value="0x8454" name="GL_FOG_COORD_ARRAY_TYPE" alias="GL_FOG_COORDINATE_ARRAY_TYPE"/>
+        <enum value="0x8455" name="GL_FOG_COORDINATE_ARRAY_STRIDE"/>
+        <enum value="0x8455" name="GL_FOG_COORDINATE_ARRAY_STRIDE_EXT"/>
+        <enum value="0x8455" name="GL_FOG_COORD_ARRAY_STRIDE" alias="GL_FOG_COORDINATE_ARRAY_STRIDE"/>
+        <enum value="0x8456" name="GL_FOG_COORDINATE_ARRAY_POINTER"/>
+        <enum value="0x8456" name="GL_FOG_COORDINATE_ARRAY_POINTER_EXT"/>
+        <enum value="0x8456" name="GL_FOG_COORD_ARRAY_POINTER" alias="GL_FOG_COORDINATE_ARRAY_POINTER"/>
+        <enum value="0x8457" name="GL_FOG_COORDINATE_ARRAY"/>
+        <enum value="0x8457" name="GL_FOG_COORDINATE_ARRAY_EXT"/>
+        <enum value="0x8457" name="GL_FOG_COORD_ARRAY" alias="GL_FOG_COORDINATE_ARRAY"/>
+        <enum value="0x8458" name="GL_COLOR_SUM"/>
+        <enum value="0x8458" name="GL_COLOR_SUM_ARB"/>
+        <enum value="0x8458" name="GL_COLOR_SUM_EXT"/>
+        <enum value="0x8459" name="GL_CURRENT_SECONDARY_COLOR"/>
+        <enum value="0x8459" name="GL_CURRENT_SECONDARY_COLOR_EXT"/>
+        <enum value="0x845A" name="GL_SECONDARY_COLOR_ARRAY_SIZE"/>
+        <enum value="0x845A" name="GL_SECONDARY_COLOR_ARRAY_SIZE_EXT"/>
+        <enum value="0x845B" name="GL_SECONDARY_COLOR_ARRAY_TYPE"/>
+        <enum value="0x845B" name="GL_SECONDARY_COLOR_ARRAY_TYPE_EXT"/>
+        <enum value="0x845C" name="GL_SECONDARY_COLOR_ARRAY_STRIDE"/>
+        <enum value="0x845C" name="GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT"/>
+        <enum value="0x845D" name="GL_SECONDARY_COLOR_ARRAY_POINTER"/>
+        <enum value="0x845D" name="GL_SECONDARY_COLOR_ARRAY_POINTER_EXT"/>
+        <enum value="0x845E" name="GL_SECONDARY_COLOR_ARRAY"/>
+        <enum value="0x845E" name="GL_SECONDARY_COLOR_ARRAY_EXT"/>
+        <enum value="0x845F" name="GL_CURRENT_RASTER_SECONDARY_COLOR"/>
+            <unused start="0x8460" end="0x846B" comment="Incomplete extension SGIX_icc_texture"/>
+            <!-- <enum value="0x8460" name="GL_RGB_ICC_SGIX"/> -->
+            <!-- <enum value="0x8461" name="GL_RGBA_ICC_SGIX"/> -->
+            <!-- <enum value="0x8462" name="GL_ALPHA_ICC_SGIX"/> -->
+            <!-- <enum value="0x8463" name="GL_LUMINANCE_ICC_SGIX"/> -->
+            <!-- <enum value="0x8464" name="GL_INTENSITY_ICC_SGIX"/> -->
+            <!-- <enum value="0x8465" name="GL_LUMINANCE_ALPHA_ICC_SGIX"/> -->
+            <!-- <enum value="0x8466" name="GL_R5_G6_B5_ICC_SGIX"/> -->
+            <!-- <enum value="0x8467" name="GL_R5_G6_B5_A8_ICC_SGIX"/> -->
+            <!-- <enum value="0x8468" name="GL_ALPHA16_ICC_SGIX"/> -->
+            <!-- <enum value="0x8469" name="GL_LUMINANCE16_ICC_SGIX"/> -->
+            <!-- <enum value="0x846A" name="GL_INTENSITY16_ICC_SGIX"/> -->
+            <!-- <enum value="0x846B" name="GL_LUMINANCE16_ALPHA8_ICC_SGIX"/> -->
+            <unused start="0x846C"/>
+        <enum value="0x846D" name="GL_ALIASED_POINT_SIZE_RANGE"/>
+        <enum value="0x846E" name="GL_ALIASED_LINE_WIDTH_RANGE"/>
+            <unused start="0x846F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8470" end="0x848F" vendor="AMD"/>
+
+    <enums namespace="GL" start="0x8490" end="0x849F" vendor="REND">
+        <enum value="0x8490" name="GL_SCREEN_COORDINATES_REND"/>
+        <enum value="0x8491" name="GL_INVERTED_SCREEN_W_REND"/>
+            <unused start="0x8492" end="0x849F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x84A0" end="0x84BF" vendor="AMD"/>
+
+    <enums namespace="GL" start="0x84C0" end="0x84EF" vendor="ARB">
+        <enum value="0x84C0" name="GL_TEXTURE0"/>
+        <enum value="0x84C0" name="GL_TEXTURE0_ARB"/>
+        <enum value="0x84C1" name="GL_TEXTURE1"/>
+        <enum value="0x84C1" name="GL_TEXTURE1_ARB"/>
+        <enum value="0x84C2" name="GL_TEXTURE2"/>
+        <enum value="0x84C2" name="GL_TEXTURE2_ARB"/>
+        <enum value="0x84C3" name="GL_TEXTURE3"/>
+        <enum value="0x84C3" name="GL_TEXTURE3_ARB"/>
+        <enum value="0x84C4" name="GL_TEXTURE4"/>
+        <enum value="0x84C4" name="GL_TEXTURE4_ARB"/>
+        <enum value="0x84C5" name="GL_TEXTURE5"/>
+        <enum value="0x84C5" name="GL_TEXTURE5_ARB"/>
+        <enum value="0x84C6" name="GL_TEXTURE6"/>
+        <enum value="0x84C6" name="GL_TEXTURE6_ARB"/>
+        <enum value="0x84C7" name="GL_TEXTURE7"/>
+        <enum value="0x84C7" name="GL_TEXTURE7_ARB"/>
+        <enum value="0x84C8" name="GL_TEXTURE8"/>
+        <enum value="0x84C8" name="GL_TEXTURE8_ARB"/>
+        <enum value="0x84C9" name="GL_TEXTURE9"/>
+        <enum value="0x84C9" name="GL_TEXTURE9_ARB"/>
+        <enum value="0x84CA" name="GL_TEXTURE10"/>
+        <enum value="0x84CA" name="GL_TEXTURE10_ARB"/>
+        <enum value="0x84CB" name="GL_TEXTURE11"/>
+        <enum value="0x84CB" name="GL_TEXTURE11_ARB"/>
+        <enum value="0x84CC" name="GL_TEXTURE12"/>
+        <enum value="0x84CC" name="GL_TEXTURE12_ARB"/>
+        <enum value="0x84CD" name="GL_TEXTURE13"/>
+        <enum value="0x84CD" name="GL_TEXTURE13_ARB"/>
+        <enum value="0x84CE" name="GL_TEXTURE14"/>
+        <enum value="0x84CE" name="GL_TEXTURE14_ARB"/>
+        <enum value="0x84CF" name="GL_TEXTURE15"/>
+        <enum value="0x84CF" name="GL_TEXTURE15_ARB"/>
+        <enum value="0x84D0" name="GL_TEXTURE16"/>
+        <enum value="0x84D0" name="GL_TEXTURE16_ARB"/>
+        <enum value="0x84D1" name="GL_TEXTURE17"/>
+        <enum value="0x84D1" name="GL_TEXTURE17_ARB"/>
+        <enum value="0x84D2" name="GL_TEXTURE18"/>
+        <enum value="0x84D2" name="GL_TEXTURE18_ARB"/>
+        <enum value="0x84D3" name="GL_TEXTURE19"/>
+        <enum value="0x84D3" name="GL_TEXTURE19_ARB"/>
+        <enum value="0x84D4" name="GL_TEXTURE20"/>
+        <enum value="0x84D4" name="GL_TEXTURE20_ARB"/>
+        <enum value="0x84D5" name="GL_TEXTURE21"/>
+        <enum value="0x84D5" name="GL_TEXTURE21_ARB"/>
+        <enum value="0x84D6" name="GL_TEXTURE22"/>
+        <enum value="0x84D6" name="GL_TEXTURE22_ARB"/>
+        <enum value="0x84D7" name="GL_TEXTURE23"/>
+        <enum value="0x84D7" name="GL_TEXTURE23_ARB"/>
+        <enum value="0x84D8" name="GL_TEXTURE24"/>
+        <enum value="0x84D8" name="GL_TEXTURE24_ARB"/>
+        <enum value="0x84D9" name="GL_TEXTURE25"/>
+        <enum value="0x84D9" name="GL_TEXTURE25_ARB"/>
+        <enum value="0x84DA" name="GL_TEXTURE26"/>
+        <enum value="0x84DA" name="GL_TEXTURE26_ARB"/>
+        <enum value="0x84DB" name="GL_TEXTURE27"/>
+        <enum value="0x84DB" name="GL_TEXTURE27_ARB"/>
+        <enum value="0x84DC" name="GL_TEXTURE28"/>
+        <enum value="0x84DC" name="GL_TEXTURE28_ARB"/>
+        <enum value="0x84DD" name="GL_TEXTURE29"/>
+        <enum value="0x84DD" name="GL_TEXTURE29_ARB"/>
+        <enum value="0x84DE" name="GL_TEXTURE30"/>
+        <enum value="0x84DE" name="GL_TEXTURE30_ARB"/>
+        <enum value="0x84DF" name="GL_TEXTURE31"/>
+        <enum value="0x84DF" name="GL_TEXTURE31_ARB"/>
+        <enum value="0x84E0" name="GL_ACTIVE_TEXTURE"/>
+        <enum value="0x84E0" name="GL_ACTIVE_TEXTURE_ARB"/>
+        <enum value="0x84E1" name="GL_CLIENT_ACTIVE_TEXTURE"/>
+        <enum value="0x84E1" name="GL_CLIENT_ACTIVE_TEXTURE_ARB"/>
+        <enum value="0x84E2" name="GL_MAX_TEXTURE_UNITS"/>
+        <enum value="0x84E2" name="GL_MAX_TEXTURE_UNITS_ARB"/>
+        <enum value="0x84E3" name="GL_TRANSPOSE_MODELVIEW_MATRIX"/>
+        <enum value="0x84E3" name="GL_TRANSPOSE_MODELVIEW_MATRIX_ARB"/>
+        <enum value="0x84E4" name="GL_TRANSPOSE_PROJECTION_MATRIX"/>
+        <enum value="0x84E4" name="GL_TRANSPOSE_PROJECTION_MATRIX_ARB"/>
+        <enum value="0x84E5" name="GL_TRANSPOSE_TEXTURE_MATRIX"/>
+        <enum value="0x84E5" name="GL_TRANSPOSE_TEXTURE_MATRIX_ARB"/>
+        <enum value="0x84E6" name="GL_TRANSPOSE_COLOR_MATRIX"/>
+        <enum value="0x84E6" name="GL_TRANSPOSE_COLOR_MATRIX_ARB"/>
+        <enum value="0x84E7" name="GL_SUBTRACT"/>
+        <enum value="0x84E7" name="GL_SUBTRACT_ARB"/>
+        <enum value="0x84E8" name="GL_MAX_RENDERBUFFER_SIZE"/>
+        <enum value="0x84E8" name="GL_MAX_RENDERBUFFER_SIZE_EXT"/>
+        <enum value="0x84E8" name="GL_MAX_RENDERBUFFER_SIZE_OES"/>
+        <enum value="0x84E9" name="GL_COMPRESSED_ALPHA"/>
+        <enum value="0x84E9" name="GL_COMPRESSED_ALPHA_ARB"/>
+        <enum value="0x84EA" name="GL_COMPRESSED_LUMINANCE"/>
+        <enum value="0x84EA" name="GL_COMPRESSED_LUMINANCE_ARB"/>
+        <enum value="0x84EB" name="GL_COMPRESSED_LUMINANCE_ALPHA"/>
+        <enum value="0x84EB" name="GL_COMPRESSED_LUMINANCE_ALPHA_ARB"/>
+        <enum value="0x84EC" name="GL_COMPRESSED_INTENSITY"/>
+        <enum value="0x84EC" name="GL_COMPRESSED_INTENSITY_ARB"/>
+        <enum value="0x84ED" name="GL_COMPRESSED_RGB"/>
+        <enum value="0x84ED" name="GL_COMPRESSED_RGB_ARB"/>
+        <enum value="0x84EE" name="GL_COMPRESSED_RGBA"/>
+        <enum value="0x84EE" name="GL_COMPRESSED_RGBA_ARB"/>
+        <enum value="0x84EF" name="GL_TEXTURE_COMPRESSION_HINT"/>
+        <enum value="0x84EF" name="GL_TEXTURE_COMPRESSION_HINT_ARB"/>
+    </enums>
+
+    <enums namespace="GL" start="0x84F0" end="0x855F" vendor="NV">
+        <enum value="0x84F0" name="GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER"/>
+        <enum value="0x84F1" name="GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER"/>
+        <enum value="0x84F2" name="GL_ALL_COMPLETED_NV"/>
+        <enum value="0x84F3" name="GL_FENCE_STATUS_NV"/>
+        <enum value="0x84F4" name="GL_FENCE_CONDITION_NV"/>
+        <enum value="0x84F5" name="GL_TEXTURE_RECTANGLE"/>
+        <enum value="0x84F5" name="GL_TEXTURE_RECTANGLE_ARB"/>
+        <enum value="0x84F5" name="GL_TEXTURE_RECTANGLE_NV"/>
+        <enum value="0x84F6" name="GL_TEXTURE_BINDING_RECTANGLE"/>
+        <enum value="0x84F6" name="GL_TEXTURE_BINDING_RECTANGLE_ARB"/>
+        <enum value="0x84F6" name="GL_TEXTURE_BINDING_RECTANGLE_NV"/>
+        <enum value="0x84F7" name="GL_PROXY_TEXTURE_RECTANGLE"/>
+        <enum value="0x84F7" name="GL_PROXY_TEXTURE_RECTANGLE_ARB"/>
+        <enum value="0x84F7" name="GL_PROXY_TEXTURE_RECTANGLE_NV"/>
+        <enum value="0x84F8" name="GL_MAX_RECTANGLE_TEXTURE_SIZE"/>
+        <enum value="0x84F8" name="GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB"/>
+        <enum value="0x84F8" name="GL_MAX_RECTANGLE_TEXTURE_SIZE_NV"/>
+        <enum value="0x84F9" name="GL_DEPTH_STENCIL"/>
+        <enum value="0x84F9" name="GL_DEPTH_STENCIL_EXT"/>
+        <enum value="0x84F9" name="GL_DEPTH_STENCIL_NV"/>
+        <enum value="0x84F9" name="GL_DEPTH_STENCIL_OES"/>
+        <enum value="0x84FA" name="GL_UNSIGNED_INT_24_8"/>
+        <enum value="0x84FA" name="GL_UNSIGNED_INT_24_8_EXT"/>
+        <enum value="0x84FA" name="GL_UNSIGNED_INT_24_8_NV"/>
+        <enum value="0x84FA" name="GL_UNSIGNED_INT_24_8_OES"/>
+            <unused start="0x84FB" end="0x84FC"/>
+        <enum value="0x84FD" name="GL_MAX_TEXTURE_LOD_BIAS"/>
+        <enum value="0x84FD" name="GL_MAX_TEXTURE_LOD_BIAS_EXT"/>
+        <enum value="0x84FE" name="GL_TEXTURE_MAX_ANISOTROPY_EXT"/>
+        <enum value="0x84FF" name="GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT"/>
+        <enum value="0x8500" name="GL_TEXTURE_FILTER_CONTROL"/>
+        <enum value="0x8500" name="GL_TEXTURE_FILTER_CONTROL_EXT"/>
+        <enum value="0x8501" name="GL_TEXTURE_LOD_BIAS"/>
+        <enum value="0x8501" name="GL_TEXTURE_LOD_BIAS_EXT"/>
+        <enum value="0x8502" name="GL_MODELVIEW1_STACK_DEPTH_EXT"/>
+        <enum value="0x8503" name="GL_COMBINE4_NV"/>
+        <enum value="0x8504" name="GL_MAX_SHININESS_NV"/>
+        <enum value="0x8505" name="GL_MAX_SPOT_EXPONENT_NV"/>
+        <enum value="0x8506" name="GL_MODELVIEW1_MATRIX_EXT"/>
+        <enum value="0x8507" name="GL_INCR_WRAP"/>
+        <enum value="0x8507" name="GL_INCR_WRAP_EXT"/>
+        <enum value="0x8507" name="GL_INCR_WRAP_OES"/>
+        <enum value="0x8508" name="GL_DECR_WRAP"/>
+        <enum value="0x8508" name="GL_DECR_WRAP_EXT"/>
+        <enum value="0x8508" name="GL_DECR_WRAP_OES"/>
+        <enum value="0x8509" name="GL_VERTEX_WEIGHTING_EXT"/>
+        <enum value="0x850A" name="GL_MODELVIEW1_ARB"/>
+        <enum value="0x850A" name="GL_MODELVIEW1_EXT"/>
+        <enum value="0x850B" name="GL_CURRENT_VERTEX_WEIGHT_EXT"/>
+        <enum value="0x850C" name="GL_VERTEX_WEIGHT_ARRAY_EXT"/>
+        <enum value="0x850D" name="GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT"/>
+        <enum value="0x850E" name="GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT"/>
+        <enum value="0x850F" name="GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT"/>
+        <enum value="0x8510" name="GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT"/>
+        <enum value="0x8511" name="GL_NORMAL_MAP"/>
+        <enum value="0x8511" name="GL_NORMAL_MAP_ARB"/>
+        <enum value="0x8511" name="GL_NORMAL_MAP_EXT"/>
+        <enum value="0x8511" name="GL_NORMAL_MAP_NV"/>
+        <enum value="0x8511" name="GL_NORMAL_MAP_OES"/>
+        <enum value="0x8512" name="GL_REFLECTION_MAP"/>
+        <enum value="0x8512" name="GL_REFLECTION_MAP_ARB"/>
+        <enum value="0x8512" name="GL_REFLECTION_MAP_EXT"/>
+        <enum value="0x8512" name="GL_REFLECTION_MAP_NV"/>
+        <enum value="0x8512" name="GL_REFLECTION_MAP_OES"/>
+        <enum value="0x8513" name="GL_TEXTURE_CUBE_MAP"/>
+        <enum value="0x8513" name="GL_TEXTURE_CUBE_MAP_ARB"/>
+        <enum value="0x8513" name="GL_TEXTURE_CUBE_MAP_EXT"/>
+        <enum value="0x8513" name="GL_TEXTURE_CUBE_MAP_OES"/>
+        <enum value="0x8514" name="GL_TEXTURE_BINDING_CUBE_MAP"/>
+        <enum value="0x8514" name="GL_TEXTURE_BINDING_CUBE_MAP_ARB"/>
+        <enum value="0x8514" name="GL_TEXTURE_BINDING_CUBE_MAP_EXT"/>
+        <enum value="0x8514" name="GL_TEXTURE_BINDING_CUBE_MAP_OES"/>
+        <enum value="0x8515" name="GL_TEXTURE_CUBE_MAP_POSITIVE_X"/>
+        <enum value="0x8515" name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB"/>
+        <enum value="0x8515" name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT"/>
+        <enum value="0x8515" name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES"/>
+        <enum value="0x8516" name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X"/>
+        <enum value="0x8516" name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB"/>
+        <enum value="0x8516" name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT"/>
+        <enum value="0x8516" name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES"/>
+        <enum value="0x8517" name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y"/>
+        <enum value="0x8517" name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB"/>
+        <enum value="0x8517" name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT"/>
+        <enum value="0x8517" name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES"/>
+        <enum value="0x8518" name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y"/>
+        <enum value="0x8518" name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB"/>
+        <enum value="0x8518" name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT"/>
+        <enum value="0x8518" name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES"/>
+        <enum value="0x8519" name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z"/>
+        <enum value="0x8519" name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB"/>
+        <enum value="0x8519" name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT"/>
+        <enum value="0x8519" name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES"/>
+        <enum value="0x851A" name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z"/>
+        <enum value="0x851A" name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB"/>
+        <enum value="0x851A" name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT"/>
+        <enum value="0x851A" name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES"/>
+        <enum value="0x851B" name="GL_PROXY_TEXTURE_CUBE_MAP"/>
+        <enum value="0x851B" name="GL_PROXY_TEXTURE_CUBE_MAP_ARB"/>
+        <enum value="0x851B" name="GL_PROXY_TEXTURE_CUBE_MAP_EXT"/>
+        <enum value="0x851C" name="GL_MAX_CUBE_MAP_TEXTURE_SIZE"/>
+        <enum value="0x851C" name="GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB"/>
+        <enum value="0x851C" name="GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT"/>
+        <enum value="0x851C" name="GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES"/>
+        <enum value="0x851D" name="GL_VERTEX_ARRAY_RANGE_APPLE"/>
+        <enum value="0x851D" name="GL_VERTEX_ARRAY_RANGE_NV"/>
+        <enum value="0x851E" name="GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE"/>
+        <enum value="0x851E" name="GL_VERTEX_ARRAY_RANGE_LENGTH_NV"/>
+        <enum value="0x851F" name="GL_VERTEX_ARRAY_RANGE_VALID_NV"/>
+        <enum value="0x851F" name="GL_VERTEX_ARRAY_STORAGE_HINT_APPLE"/>
+        <enum value="0x8520" name="GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV"/>
+        <enum value="0x8521" name="GL_VERTEX_ARRAY_RANGE_POINTER_APPLE"/>
+        <enum value="0x8521" name="GL_VERTEX_ARRAY_RANGE_POINTER_NV"/>
+        <enum value="0x8522" name="GL_REGISTER_COMBINERS_NV"/>
+        <enum value="0x8523" name="GL_VARIABLE_A_NV"/>
+        <enum value="0x8524" name="GL_VARIABLE_B_NV"/>
+        <enum value="0x8525" name="GL_VARIABLE_C_NV"/>
+        <enum value="0x8526" name="GL_VARIABLE_D_NV"/>
+        <enum value="0x8527" name="GL_VARIABLE_E_NV"/>
+        <enum value="0x8528" name="GL_VARIABLE_F_NV"/>
+        <enum value="0x8529" name="GL_VARIABLE_G_NV"/>
+        <enum value="0x852A" name="GL_CONSTANT_COLOR0_NV"/>
+        <enum value="0x852B" name="GL_CONSTANT_COLOR1_NV"/>
+        <enum value="0x852C" name="GL_PRIMARY_COLOR_NV"/>
+        <enum value="0x852D" name="GL_SECONDARY_COLOR_NV"/>
+        <enum value="0x852E" name="GL_SPARE0_NV"/>
+        <enum value="0x852F" name="GL_SPARE1_NV"/>
+        <enum value="0x8530" name="GL_DISCARD_NV"/>
+        <enum value="0x8531" name="GL_E_TIMES_F_NV"/>
+        <enum value="0x8532" name="GL_SPARE0_PLUS_SECONDARY_COLOR_NV"/>
+        <enum value="0x8533" name="GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV"/>
+        <enum value="0x8534" name="GL_MULTISAMPLE_FILTER_HINT_NV"/>
+        <enum value="0x8535" name="GL_PER_STAGE_CONSTANTS_NV"/>
+        <enum value="0x8536" name="GL_UNSIGNED_IDENTITY_NV"/>
+        <enum value="0x8537" name="GL_UNSIGNED_INVERT_NV"/>
+        <enum value="0x8538" name="GL_EXPAND_NORMAL_NV"/>
+        <enum value="0x8539" name="GL_EXPAND_NEGATE_NV"/>
+        <enum value="0x853A" name="GL_HALF_BIAS_NORMAL_NV"/>
+        <enum value="0x853B" name="GL_HALF_BIAS_NEGATE_NV"/>
+        <enum value="0x853C" name="GL_SIGNED_IDENTITY_NV"/>
+        <enum value="0x853D" name="GL_SIGNED_NEGATE_NV"/>
+        <enum value="0x853E" name="GL_SCALE_BY_TWO_NV"/>
+        <enum value="0x853F" name="GL_SCALE_BY_FOUR_NV"/>
+        <enum value="0x8540" name="GL_SCALE_BY_ONE_HALF_NV"/>
+        <enum value="0x8541" name="GL_BIAS_BY_NEGATIVE_ONE_HALF_NV"/>
+        <enum value="0x8542" name="GL_COMBINER_INPUT_NV"/>
+        <enum value="0x8543" name="GL_COMBINER_MAPPING_NV"/>
+        <enum value="0x8544" name="GL_COMBINER_COMPONENT_USAGE_NV"/>
+        <enum value="0x8545" name="GL_COMBINER_AB_DOT_PRODUCT_NV"/>
+        <enum value="0x8546" name="GL_COMBINER_CD_DOT_PRODUCT_NV"/>
+        <enum value="0x8547" name="GL_COMBINER_MUX_SUM_NV"/>
+        <enum value="0x8548" name="GL_COMBINER_SCALE_NV"/>
+        <enum value="0x8549" name="GL_COMBINER_BIAS_NV"/>
+        <enum value="0x854A" name="GL_COMBINER_AB_OUTPUT_NV"/>
+        <enum value="0x854B" name="GL_COMBINER_CD_OUTPUT_NV"/>
+        <enum value="0x854C" name="GL_COMBINER_SUM_OUTPUT_NV"/>
+        <enum value="0x854D" name="GL_MAX_GENERAL_COMBINERS_NV"/>
+        <enum value="0x854E" name="GL_NUM_GENERAL_COMBINERS_NV"/>
+        <enum value="0x854F" name="GL_COLOR_SUM_CLAMP_NV"/>
+        <enum value="0x8550" name="GL_COMBINER0_NV"/>
+        <enum value="0x8551" name="GL_COMBINER1_NV"/>
+        <enum value="0x8552" name="GL_COMBINER2_NV"/>
+        <enum value="0x8553" name="GL_COMBINER3_NV"/>
+        <enum value="0x8554" name="GL_COMBINER4_NV"/>
+        <enum value="0x8555" name="GL_COMBINER5_NV"/>
+        <enum value="0x8556" name="GL_COMBINER6_NV"/>
+        <enum value="0x8557" name="GL_COMBINER7_NV"/>
+        <enum value="0x8558" name="GL_PRIMITIVE_RESTART_NV"/>
+        <enum value="0x8559" name="GL_PRIMITIVE_RESTART_INDEX_NV"/>
+        <enum value="0x855A" name="GL_FOG_DISTANCE_MODE_NV"/>
+        <enum value="0x855B" name="GL_EYE_RADIAL_NV"/>
+        <enum value="0x855C" name="GL_EYE_PLANE_ABSOLUTE_NV"/>
+        <enum value="0x855D" name="GL_EMBOSS_LIGHT_NV"/>
+        <enum value="0x855E" name="GL_EMBOSS_CONSTANT_NV"/>
+        <enum value="0x855F" name="GL_EMBOSS_MAP_NV"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8560" end="0x856F" vendor="ZiiLabs">
+        <enum value="0x8560" name="GL_RED_MIN_CLAMP_INGR"/>
+        <enum value="0x8561" name="GL_GREEN_MIN_CLAMP_INGR"/>
+        <enum value="0x8562" name="GL_BLUE_MIN_CLAMP_INGR"/>
+        <enum value="0x8563" name="GL_ALPHA_MIN_CLAMP_INGR"/>
+        <enum value="0x8564" name="GL_RED_MAX_CLAMP_INGR"/>
+        <enum value="0x8565" name="GL_GREEN_MAX_CLAMP_INGR"/>
+        <enum value="0x8566" name="GL_BLUE_MAX_CLAMP_INGR"/>
+        <enum value="0x8567" name="GL_ALPHA_MAX_CLAMP_INGR"/>
+        <enum value="0x8568" name="GL_INTERLACE_READ_INGR"/>
+            <unused start="0x8569" end="0x856F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8570" end="0x859F" group="RegisterCombinerPname" vendor="AMD/NV">
+        <enum value="0x8570" name="GL_COMBINE"/>
+        <enum value="0x8570" name="GL_COMBINE_ARB"/>
+        <enum value="0x8570" name="GL_COMBINE_EXT"/>
+        <enum value="0x8571" name="GL_COMBINE_RGB"/>
+        <enum value="0x8571" name="GL_COMBINE_RGB_ARB"/>
+        <enum value="0x8571" name="GL_COMBINE_RGB_EXT"/>
+        <enum value="0x8572" name="GL_COMBINE_ALPHA"/>
+        <enum value="0x8572" name="GL_COMBINE_ALPHA_ARB"/>
+        <enum value="0x8572" name="GL_COMBINE_ALPHA_EXT"/>
+        <enum value="0x8573" name="GL_RGB_SCALE"/>
+        <enum value="0x8573" name="GL_RGB_SCALE_ARB"/>
+        <enum value="0x8573" name="GL_RGB_SCALE_EXT"/>
+        <enum value="0x8574" name="GL_ADD_SIGNED"/>
+        <enum value="0x8574" name="GL_ADD_SIGNED_ARB"/>
+        <enum value="0x8574" name="GL_ADD_SIGNED_EXT"/>
+        <enum value="0x8575" name="GL_INTERPOLATE"/>
+        <enum value="0x8575" name="GL_INTERPOLATE_ARB"/>
+        <enum value="0x8575" name="GL_INTERPOLATE_EXT"/>
+        <enum value="0x8576" name="GL_CONSTANT"/>
+        <enum value="0x8576" name="GL_CONSTANT_ARB"/>
+        <enum value="0x8576" name="GL_CONSTANT_EXT"/>
+        <enum value="0x8577" name="GL_PRIMARY_COLOR"/>
+        <enum value="0x8577" name="GL_PRIMARY_COLOR_ARB"/>
+        <enum value="0x8577" name="GL_PRIMARY_COLOR_EXT"/>
+        <enum value="0x8578" name="GL_PREVIOUS"/>
+        <enum value="0x8578" name="GL_PREVIOUS_ARB"/>
+        <enum value="0x8578" name="GL_PREVIOUS_EXT"/>
+            <unused start="0x8579" end="0x857F" comment="Additional combiner enums only"/>
+        <enum value="0x8580" name="GL_SOURCE0_RGB"/>
+        <enum value="0x8580" name="GL_SOURCE0_RGB_ARB"/>
+        <enum value="0x8580" name="GL_SOURCE0_RGB_EXT"/>
+        <enum value="0x8580" name="GL_SRC0_RGB" alias="GL_SOURCE0_RGB"/>
+        <enum value="0x8581" name="GL_SOURCE1_RGB"/>
+        <enum value="0x8581" name="GL_SOURCE1_RGB_ARB"/>
+        <enum value="0x8581" name="GL_SOURCE1_RGB_EXT"/>
+        <enum value="0x8581" name="GL_SRC1_RGB" alias="GL_SOURCE1_RGB"/>
+        <enum value="0x8582" name="GL_SOURCE2_RGB"/>
+        <enum value="0x8582" name="GL_SOURCE2_RGB_ARB"/>
+        <enum value="0x8582" name="GL_SOURCE2_RGB_EXT"/>
+        <enum value="0x8582" name="GL_SRC2_RGB" alias="GL_SOURCE2_RGB"/>
+        <enum value="0x8583" name="GL_SOURCE3_RGB_NV"/>
+            <unused start="0x8584" end="0x8587" comment="Additional combiner enums only"/>
+        <enum value="0x8588" name="GL_SOURCE0_ALPHA"/>
+        <enum value="0x8588" name="GL_SOURCE0_ALPHA_ARB"/>
+        <enum value="0x8588" name="GL_SOURCE0_ALPHA_EXT"/>
+        <enum value="0x8588" name="GL_SRC0_ALPHA" alias="GL_SOURCE0_ALPHA"/>
+        <enum value="0x8589" name="GL_SOURCE1_ALPHA"/>
+        <enum value="0x8589" name="GL_SOURCE1_ALPHA_ARB"/>
+        <enum value="0x8589" name="GL_SOURCE1_ALPHA_EXT"/>
+        <enum value="0x8589" name="GL_SRC1_ALPHA" alias="GL_SOURCE1_ALPHA"/>
+        <enum value="0x858A" name="GL_SOURCE2_ALPHA"/>
+        <enum value="0x858A" name="GL_SOURCE2_ALPHA_ARB"/>
+        <enum value="0x858A" name="GL_SOURCE2_ALPHA_EXT"/>
+        <enum value="0x858A" name="GL_SRC2_ALPHA" alias="GL_SOURCE2_ALPHA"/>
+        <enum value="0x858B" name="GL_SOURCE3_ALPHA_NV"/>
+            <unused start="0x858C" end="0x858F" comment="Additional combiner enums only"/>
+        <enum value="0x8590" name="GL_OPERAND0_RGB"/>
+        <enum value="0x8590" name="GL_OPERAND0_RGB_ARB"/>
+        <enum value="0x8590" name="GL_OPERAND0_RGB_EXT"/>
+        <enum value="0x8591" name="GL_OPERAND1_RGB"/>
+        <enum value="0x8591" name="GL_OPERAND1_RGB_ARB"/>
+        <enum value="0x8591" name="GL_OPERAND1_RGB_EXT"/>
+        <enum value="0x8592" name="GL_OPERAND2_RGB"/>
+        <enum value="0x8592" name="GL_OPERAND2_RGB_ARB"/>
+        <enum value="0x8592" name="GL_OPERAND2_RGB_EXT"/>
+        <enum value="0x8593" name="GL_OPERAND3_RGB_NV"/>
+            <unused start="0x8594" end="0x8597" comment="Additional combiner enums only"/>
+        <enum value="0x8598" name="GL_OPERAND0_ALPHA"/>
+        <enum value="0x8598" name="GL_OPERAND0_ALPHA_ARB"/>
+        <enum value="0x8598" name="GL_OPERAND0_ALPHA_EXT"/>
+        <enum value="0x8599" name="GL_OPERAND1_ALPHA"/>
+        <enum value="0x8599" name="GL_OPERAND1_ALPHA_ARB"/>
+        <enum value="0x8599" name="GL_OPERAND1_ALPHA_EXT"/>
+        <enum value="0x859A" name="GL_OPERAND2_ALPHA"/>
+        <enum value="0x859A" name="GL_OPERAND2_ALPHA_ARB"/>
+        <enum value="0x859A" name="GL_OPERAND2_ALPHA_EXT"/>
+        <enum value="0x859B" name="GL_OPERAND3_ALPHA_NV"/>
+            <unused start="0x859C" end="0x859F" comment="Additional combiner enums only"/>
+    </enums>
+
+    <enums namespace="GL" start="0x85A0" end="0x85AF" vendor="SGI">
+        <enum value="0x85A0" name="GL_PACK_SUBSAMPLE_RATE_SGIX"/>
+        <enum value="0x85A1" name="GL_UNPACK_SUBSAMPLE_RATE_SGIX"/>
+        <enum value="0x85A2" name="GL_PIXEL_SUBSAMPLE_4444_SGIX"/>
+        <enum value="0x85A3" name="GL_PIXEL_SUBSAMPLE_2424_SGIX"/>
+        <enum value="0x85A4" name="GL_PIXEL_SUBSAMPLE_4242_SGIX"/>
+            <unused start="0x85A5" end="0x85AD" comment="Incomplete extension SGIS_color_range"/>
+            <!-- <enum value="0x85A5" name="GL_EXTENDED_RANGE_SGIS"/> -->
+            <!-- <enum value="0x85A6" name="GL_MIN_RED_SGIS"/> -->
+            <!-- <enum value="0x85A7" name="GL_MAX_RED_SGIS"/> -->
+            <!-- <enum value="0x85A8" name="GL_MIN_GREEN_SGIS"/> -->
+            <!-- <enum value="0x85A9" name="GL_MAX_GREEN_SGIS"/> -->
+            <!-- <enum value="0x85AA" name="GL_MIN_BLUE_SGIS"/> -->
+            <!-- <enum value="0x85AB" name="GL_MAX_BLUE_SGIS"/> -->
+            <!-- <enum value="0x85AC" name="GL_MIN_ALPHA_SGIS"/> -->
+            <!-- <enum value="0x85AD" name="GL_MAX_ALPHA_SGIS"/> -->
+        <enum value="0x85AE" name="GL_PERTURB_EXT"/>
+        <enum value="0x85AF" name="GL_TEXTURE_NORMAL_EXT"/>
+    </enums>
+
+    <enums namespace="GL" start="0x85B0" end="0x85BF" vendor="APPLE">
+        <enum value="0x85B0" name="GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE"/>
+        <enum value="0x85B1" name="GL_TRANSFORM_HINT_APPLE"/>
+        <enum value="0x85B2" name="GL_UNPACK_CLIENT_STORAGE_APPLE"/>
+        <enum value="0x85B3" name="GL_BUFFER_OBJECT_APPLE"/>
+        <enum value="0x85B4" name="GL_STORAGE_CLIENT_APPLE"/>
+        <enum value="0x85B5" name="GL_VERTEX_ARRAY_BINDING"/>
+        <enum value="0x85B5" name="GL_VERTEX_ARRAY_BINDING_APPLE"/>
+        <enum value="0x85B5" name="GL_VERTEX_ARRAY_BINDING_OES"/>
+            <unused start="0x85B6" comment="Unknown extension (Khronos bug 632)"/>
+            <!-- <enum value="0x85B6" name="GL_TEXTURE_MINIMIZE_STORAGE_APPLE"/> -->
+        <enum value="0x85B7" name="GL_TEXTURE_RANGE_LENGTH_APPLE"/>
+        <enum value="0x85B8" name="GL_TEXTURE_RANGE_POINTER_APPLE"/>
+        <enum value="0x85B9" name="GL_YCBCR_422_APPLE"/>
+        <enum value="0x85BA" name="GL_UNSIGNED_SHORT_8_8_APPLE"/>
+        <enum value="0x85BA" name="GL_UNSIGNED_SHORT_8_8_MESA"/>
+        <enum value="0x85BB" name="GL_UNSIGNED_SHORT_8_8_REV_APPLE"/>
+        <enum value="0x85BB" name="GL_UNSIGNED_SHORT_8_8_REV_MESA"/>
+        <enum value="0x85BC" name="GL_TEXTURE_STORAGE_HINT_APPLE"/>
+        <enum value="0x85BD" name="GL_STORAGE_PRIVATE_APPLE"/>
+        <enum value="0x85BE" name="GL_STORAGE_CACHED_APPLE"/>
+        <enum value="0x85BF" name="GL_STORAGE_SHARED_APPLE"/>
+    </enums>
+
+    <enums namespace="GL" start="0x85C0" end="0x85CF" vendor="SUN">
+        <enum value="0x85C0" name="GL_REPLACEMENT_CODE_ARRAY_SUN"/>
+        <enum value="0x85C1" name="GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN"/>
+        <enum value="0x85C2" name="GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN"/>
+        <enum value="0x85C3" name="GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN"/>
+        <enum value="0x85C4" name="GL_R1UI_V3F_SUN"/>
+        <enum value="0x85C5" name="GL_R1UI_C4UB_V3F_SUN"/>
+        <enum value="0x85C6" name="GL_R1UI_C3F_V3F_SUN"/>
+        <enum value="0x85C7" name="GL_R1UI_N3F_V3F_SUN"/>
+        <enum value="0x85C8" name="GL_R1UI_C4F_N3F_V3F_SUN"/>
+        <enum value="0x85C9" name="GL_R1UI_T2F_V3F_SUN"/>
+        <enum value="0x85CA" name="GL_R1UI_T2F_N3F_V3F_SUN"/>
+        <enum value="0x85CB" name="GL_R1UI_T2F_C4F_N3F_V3F_SUN"/>
+        <enum value="0x85CC" name="GL_SLICE_ACCUM_SUN"/>
+            <unused start="0x85CD" end="0x85CF"/>
+    </enums>
+
+    <enums namespace="GL" start="0x85D0" end="0x85DF" vendor="ZiiLabs" comment="3Dlabs private extension for Autodesk">
+            <unused start="0x85D0" end="0x85D1" comment="Unknown 3Dlabs private extension for Autodesk (but we know the enum values)"/>
+            <!-- <enum value="0x85D0" name="GL_FACET_NORMAL_AUTODESK"/> -->
+            <!-- <enum value="0x85D1" name="GL_FACET_NORMAL_ARRAY_AUTODESK"/> -->
+            <unused start="0x85D2" end="0x85DF"/>
+    </enums>
+
+    <enums namespace="GL" start="0x85E0" end="0x85FF" vendor="SGI">
+            <unused start="0x85E0" end="0x85FB" comment="Incomplete extension SGIX_texture_range"/>
+            <!-- <enum value="0x85E0" name="GL_RGB_SIGNED_SGIX"/> -->
+            <!-- <enum value="0x85E1" name="GL_RGBA_SIGNED_SGIX"/> -->
+            <!-- <enum value="0x85E2" name="GL_ALPHA_SIGNED_SGIX"/> -->
+            <!-- <enum value="0x85E3" name="GL_LUMINANCE_SIGNED_SGIX"/> -->
+            <!-- <enum value="0x85E4" name="GL_INTENSITY_SIGNED_SGIX"/> -->
+            <!-- <enum value="0x85E5" name="GL_LUMINANCE_ALPHA_SIGNED_SGIX"/> -->
+            <!-- <enum value="0x85E6" name="GL_RGB16_SIGNED_SGIX"/> -->
+            <!-- <enum value="0x85E7" name="GL_RGBA16_SIGNED_SGIX"/> -->
+            <!-- <enum value="0x85E8" name="GL_ALPHA16_SIGNED_SGIX"/> -->
+            <!-- <enum value="0x85E9" name="GL_LUMINANCE16_SIGNED_SGIX"/> -->
+            <!-- <enum value="0x85EA" name="GL_INTENSITY16_SIGNED_SGIX"/> -->
+            <!-- <enum value="0x85EB" name="GL_LUMINANCE16_ALPHA16_SIGNED_SGIX"/> -->
+            <!-- <enum value="0x85EC" name="GL_RGB_EXTENDED_RANGE_SGIX"/> -->
+            <!-- <enum value="0x85ED" name="GL_RGBA_EXTENDED_RANGE_SGIX"/> -->
+            <!-- <enum value="0x85EE" name="GL_ALPHA_EXTENDED_RANGE_SGIX"/> -->
+            <!-- <enum value="0x85EF" name="GL_LUMINANCE_EXTENDED_RANGE_SGIX"/> -->
+            <!-- <enum value="0x85F0" name="GL_INTENSITY_EXTENDED_RANGE_SGIX"/> -->
+            <!-- <enum value="0x85F1" name="GL_LUMINANCE_ALPHA_EXTENDED_RANGE_SGIX"/> -->
+            <!-- <enum value="0x85F2" name="GL_RGB16_EXTENDED_RANGE_SGIX"/> -->
+            <!-- <enum value="0x85F3" name="GL_RGBA16_EXTENDED_RANGE_SGIX"/> -->
+            <!-- <enum value="0x85F4" name="GL_ALPHA16_EXTENDED_RANGE_SGIX"/> -->
+            <!-- <enum value="0x85F5" name="GL_LUMINANCE16_EXTENDED_RANGE_SGIX"/> -->
+            <!-- <enum value="0x85F6" name="GL_INTENSITY16_EXTENDED_RANGE_SGIX"/> -->
+            <!-- <enum value="0x85F7" name="GL_LUMINANCE16_ALPHA16_EXTENDED_RANGE_SGIX"/> -->
+            <!-- <enum value="0x85F8" name="GL_MIN_LUMINANCE_SGIS"/> -->
+            <!-- <enum value="0x85F9" name="GL_MAX_LUMINANCE_SGIS"/> -->
+            <!-- <enum value="0x85FA" name="GL_MIN_INTENSITY_SGIS"/> -->
+            <!-- <enum value="0x85FB" name="GL_MAX_INTENSITY_SGIS"/> -->
+            <unused start="0x85FC" end="0x85FF"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8600" end="0x861F" vendor="SUN">
+            <unused start="0x8600" end="0x8613"/>
+        <enum value="0x8614" name="GL_QUAD_MESH_SUN"/>
+        <enum value="0x8615" name="GL_TRIANGLE_MESH_SUN"/>
+            <unused start="0x8614" end="0x861F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8620" end="0x867F" vendor="NV">
+        <enum value="0x8620" name="GL_VERTEX_PROGRAM_ARB"/>
+        <enum value="0x8620" name="GL_VERTEX_PROGRAM_NV"/>
+        <enum value="0x8621" name="GL_VERTEX_STATE_PROGRAM_NV"/>
+        <enum value="0x8622" name="GL_VERTEX_ATTRIB_ARRAY_ENABLED"/>
+        <enum value="0x8622" name="GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB"/>
+        <enum value="0x8623" name="GL_ATTRIB_ARRAY_SIZE_NV"/>
+        <enum value="0x8623" name="GL_VERTEX_ATTRIB_ARRAY_SIZE"/>
+        <enum value="0x8623" name="GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB"/>
+        <enum value="0x8624" name="GL_ATTRIB_ARRAY_STRIDE_NV"/>
+        <enum value="0x8624" name="GL_VERTEX_ATTRIB_ARRAY_STRIDE"/>
+        <enum value="0x8624" name="GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB"/>
+        <enum value="0x8625" name="GL_ATTRIB_ARRAY_TYPE_NV"/>
+        <enum value="0x8625" name="GL_VERTEX_ATTRIB_ARRAY_TYPE"/>
+        <enum value="0x8625" name="GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB"/>
+        <enum value="0x8626" name="GL_CURRENT_ATTRIB_NV"/>
+        <enum value="0x8626" name="GL_CURRENT_VERTEX_ATTRIB"/>
+        <enum value="0x8626" name="GL_CURRENT_VERTEX_ATTRIB_ARB"/>
+        <enum value="0x8627" name="GL_PROGRAM_LENGTH_ARB"/>
+        <enum value="0x8627" name="GL_PROGRAM_LENGTH_NV"/>
+        <enum value="0x8628" name="GL_PROGRAM_STRING_ARB"/>
+        <enum value="0x8628" name="GL_PROGRAM_STRING_NV"/>
+        <enum value="0x8629" name="GL_MODELVIEW_PROJECTION_NV"/>
+        <enum value="0x862A" name="GL_IDENTITY_NV"/>
+        <enum value="0x862B" name="GL_INVERSE_NV"/>
+        <enum value="0x862C" name="GL_TRANSPOSE_NV"/>
+        <enum value="0x862D" name="GL_INVERSE_TRANSPOSE_NV"/>
+        <enum value="0x862E" name="GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB"/>
+        <enum value="0x862E" name="GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV"/>
+        <enum value="0x862F" name="GL_MAX_PROGRAM_MATRICES_ARB"/>
+        <enum value="0x862F" name="GL_MAX_TRACK_MATRICES_NV"/>
+        <enum value="0x8630" name="GL_MATRIX0_NV"/>
+        <enum value="0x8631" name="GL_MATRIX1_NV"/>
+        <enum value="0x8632" name="GL_MATRIX2_NV"/>
+        <enum value="0x8633" name="GL_MATRIX3_NV"/>
+        <enum value="0x8634" name="GL_MATRIX4_NV"/>
+        <enum value="0x8635" name="GL_MATRIX5_NV"/>
+        <enum value="0x8636" name="GL_MATRIX6_NV"/>
+        <enum value="0x8637" name="GL_MATRIX7_NV"/>
+            <unused start="0x8638" end="0x863F" comment="Reserved for MATRIX{8-15}_NV"/>
+            <!-- <enum value="0x8638" name="GL_MATRIX8_NV"/> -->
+            <!-- <enum value="0x8639" name="GL_MATRIX9_NV"/> -->
+            <!-- <enum value="0x863A" name="GL_MATRIX10_NV"/> -->
+            <!-- <enum value="0x863B" name="GL_MATRIX11_NV"/> -->
+            <!-- <enum value="0x863C" name="GL_MATRIX12_NV"/> -->
+            <!-- <enum value="0x863D" name="GL_MATRIX13_NV"/> -->
+            <!-- <enum value="0x863E" name="GL_MATRIX14_NV"/> -->
+            <!-- <enum value="0x863F" name="GL_MATRIX15_NV"/> -->
+        <enum value="0x8640" name="GL_CURRENT_MATRIX_STACK_DEPTH_ARB"/>
+        <enum value="0x8640" name="GL_CURRENT_MATRIX_STACK_DEPTH_NV"/>
+        <enum value="0x8641" name="GL_CURRENT_MATRIX_ARB"/>
+        <enum value="0x8641" name="GL_CURRENT_MATRIX_NV"/>
+        <enum value="0x8642" name="GL_VERTEX_PROGRAM_POINT_SIZE"/>
+        <enum value="0x8642" name="GL_VERTEX_PROGRAM_POINT_SIZE_ARB"/>
+        <enum value="0x8642" name="GL_VERTEX_PROGRAM_POINT_SIZE_NV"/>
+        <enum value="0x8642" name="GL_PROGRAM_POINT_SIZE" alias="GL_VERTEX_PROGRAM_POINT_SIZE"/>
+        <enum value="0x8642" name="GL_PROGRAM_POINT_SIZE_ARB"/>
+        <enum value="0x8642" name="GL_PROGRAM_POINT_SIZE_EXT"/>
+        <enum value="0x8643" name="GL_VERTEX_PROGRAM_TWO_SIDE"/>
+        <enum value="0x8643" name="GL_VERTEX_PROGRAM_TWO_SIDE_ARB"/>
+        <enum value="0x8643" name="GL_VERTEX_PROGRAM_TWO_SIDE_NV"/>
+        <enum value="0x8644" name="GL_PROGRAM_PARAMETER_NV"/>
+        <enum value="0x8645" name="GL_ATTRIB_ARRAY_POINTER_NV"/>
+        <enum value="0x8645" name="GL_VERTEX_ATTRIB_ARRAY_POINTER"/>
+        <enum value="0x8645" name="GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB"/>
+        <enum value="0x8646" name="GL_PROGRAM_TARGET_NV"/>
+        <enum value="0x8647" name="GL_PROGRAM_RESIDENT_NV"/>
+        <enum value="0x8648" name="GL_TRACK_MATRIX_NV"/>
+        <enum value="0x8649" name="GL_TRACK_MATRIX_TRANSFORM_NV"/>
+        <enum value="0x864A" name="GL_VERTEX_PROGRAM_BINDING_NV"/>
+        <enum value="0x864B" name="GL_PROGRAM_ERROR_POSITION_ARB"/>
+        <enum value="0x864B" name="GL_PROGRAM_ERROR_POSITION_NV"/>
+        <enum value="0x864C" name="GL_OFFSET_TEXTURE_RECTANGLE_NV"/>
+        <enum value="0x864D" name="GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV"/>
+        <enum value="0x864E" name="GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV"/>
+        <enum value="0x864F" name="GL_DEPTH_CLAMP"/>
+        <enum value="0x864F" name="GL_DEPTH_CLAMP_NV"/>
+        <enum value="0x8650" name="GL_VERTEX_ATTRIB_ARRAY0_NV"/>
+        <enum value="0x8651" name="GL_VERTEX_ATTRIB_ARRAY1_NV"/>
+        <enum value="0x8652" name="GL_VERTEX_ATTRIB_ARRAY2_NV"/>
+        <enum value="0x8653" name="GL_VERTEX_ATTRIB_ARRAY3_NV"/>
+        <enum value="0x8654" name="GL_VERTEX_ATTRIB_ARRAY4_NV"/>
+        <enum value="0x8655" name="GL_VERTEX_ATTRIB_ARRAY5_NV"/>
+        <enum value="0x8656" name="GL_VERTEX_ATTRIB_ARRAY6_NV"/>
+        <enum value="0x8657" name="GL_VERTEX_ATTRIB_ARRAY7_NV"/>
+        <enum value="0x8658" name="GL_VERTEX_ATTRIB_ARRAY8_NV"/>
+        <enum value="0x8659" name="GL_VERTEX_ATTRIB_ARRAY9_NV"/>
+        <enum value="0x865A" name="GL_VERTEX_ATTRIB_ARRAY10_NV"/>
+        <enum value="0x865B" name="GL_VERTEX_ATTRIB_ARRAY11_NV"/>
+        <enum value="0x865C" name="GL_VERTEX_ATTRIB_ARRAY12_NV"/>
+        <enum value="0x865D" name="GL_VERTEX_ATTRIB_ARRAY13_NV"/>
+        <enum value="0x865E" name="GL_VERTEX_ATTRIB_ARRAY14_NV"/>
+        <enum value="0x865F" name="GL_VERTEX_ATTRIB_ARRAY15_NV"/>
+        <enum value="0x8660" name="GL_MAP1_VERTEX_ATTRIB0_4_NV"/>
+        <enum value="0x8661" name="GL_MAP1_VERTEX_ATTRIB1_4_NV"/>
+        <enum value="0x8662" name="GL_MAP1_VERTEX_ATTRIB2_4_NV"/>
+        <enum value="0x8663" name="GL_MAP1_VERTEX_ATTRIB3_4_NV"/>
+        <enum value="0x8664" name="GL_MAP1_VERTEX_ATTRIB4_4_NV"/>
+        <enum value="0x8665" name="GL_MAP1_VERTEX_ATTRIB5_4_NV"/>
+        <enum value="0x8666" name="GL_MAP1_VERTEX_ATTRIB6_4_NV"/>
+        <enum value="0x8667" name="GL_MAP1_VERTEX_ATTRIB7_4_NV"/>
+        <enum value="0x8668" name="GL_MAP1_VERTEX_ATTRIB8_4_NV"/>
+        <enum value="0x8669" name="GL_MAP1_VERTEX_ATTRIB9_4_NV"/>
+        <enum value="0x866A" name="GL_MAP1_VERTEX_ATTRIB10_4_NV"/>
+        <enum value="0x866B" name="GL_MAP1_VERTEX_ATTRIB11_4_NV"/>
+        <enum value="0x866C" name="GL_MAP1_VERTEX_ATTRIB12_4_NV"/>
+        <enum value="0x866D" name="GL_MAP1_VERTEX_ATTRIB13_4_NV"/>
+        <enum value="0x866E" name="GL_MAP1_VERTEX_ATTRIB14_4_NV"/>
+        <enum value="0x866F" name="GL_MAP1_VERTEX_ATTRIB15_4_NV"/>
+        <enum value="0x8670" name="GL_MAP2_VERTEX_ATTRIB0_4_NV"/>
+        <enum value="0x8671" name="GL_MAP2_VERTEX_ATTRIB1_4_NV"/>
+        <enum value="0x8672" name="GL_MAP2_VERTEX_ATTRIB2_4_NV"/>
+        <enum value="0x8673" name="GL_MAP2_VERTEX_ATTRIB3_4_NV"/>
+        <enum value="0x8674" name="GL_MAP2_VERTEX_ATTRIB4_4_NV"/>
+        <enum value="0x8675" name="GL_MAP2_VERTEX_ATTRIB5_4_NV"/>
+        <enum value="0x8676" name="GL_MAP2_VERTEX_ATTRIB6_4_NV"/>
+        <enum value="0x8677" name="GL_MAP2_VERTEX_ATTRIB7_4_NV"/>
+        <enum value="0x8677" name="GL_PROGRAM_BINDING_ARB" comment="NOT an alias. Accidental reuse of GL_MAP2_VERTEX_ATTRIB7_4_NV"/>
+        <enum value="0x8678" name="GL_MAP2_VERTEX_ATTRIB8_4_NV"/>
+        <enum value="0x8679" name="GL_MAP2_VERTEX_ATTRIB9_4_NV"/>
+        <enum value="0x867A" name="GL_MAP2_VERTEX_ATTRIB10_4_NV"/>
+        <enum value="0x867B" name="GL_MAP2_VERTEX_ATTRIB11_4_NV"/>
+        <enum value="0x867C" name="GL_MAP2_VERTEX_ATTRIB12_4_NV"/>
+        <enum value="0x867D" name="GL_MAP2_VERTEX_ATTRIB13_4_NV"/>
+        <enum value="0x867E" name="GL_MAP2_VERTEX_ATTRIB14_4_NV"/>
+        <enum value="0x867F" name="GL_MAP2_VERTEX_ATTRIB15_4_NV"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8680" end="0x869F" vendor="Pixelfusion"/>
+
+    <enums namespace="GL" start="0x86A0" end="0x86AF" vendor="ARB">
+        <enum value="0x86A0" name="GL_TEXTURE_COMPRESSED_IMAGE_SIZE"/>
+        <enum value="0x86A0" name="GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB"/>
+        <enum value="0x86A1" name="GL_TEXTURE_COMPRESSED"/>
+        <enum value="0x86A1" name="GL_TEXTURE_COMPRESSED_ARB"/>
+        <enum value="0x86A2" name="GL_NUM_COMPRESSED_TEXTURE_FORMATS"/>
+        <enum value="0x86A2" name="GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB"/>
+        <enum value="0x86A3" name="GL_COMPRESSED_TEXTURE_FORMATS"/>
+        <enum value="0x86A3" name="GL_COMPRESSED_TEXTURE_FORMATS_ARB"/>
+        <enum value="0x86A4" name="GL_MAX_VERTEX_UNITS_ARB"/>
+        <enum value="0x86A4" name="GL_MAX_VERTEX_UNITS_OES"/>
+        <enum value="0x86A5" name="GL_ACTIVE_VERTEX_UNITS_ARB"/>
+        <enum value="0x86A6" name="GL_WEIGHT_SUM_UNITY_ARB"/>
+        <enum value="0x86A7" name="GL_VERTEX_BLEND_ARB"/>
+        <enum value="0x86A8" name="GL_CURRENT_WEIGHT_ARB"/>
+        <enum value="0x86A9" name="GL_WEIGHT_ARRAY_TYPE_ARB"/>
+        <enum value="0x86A9" name="GL_WEIGHT_ARRAY_TYPE_OES"/>
+        <enum value="0x86AA" name="GL_WEIGHT_ARRAY_STRIDE_ARB"/>
+        <enum value="0x86AA" name="GL_WEIGHT_ARRAY_STRIDE_OES"/>
+        <enum value="0x86AB" name="GL_WEIGHT_ARRAY_SIZE_ARB"/>
+        <enum value="0x86AB" name="GL_WEIGHT_ARRAY_SIZE_OES"/>
+        <enum value="0x86AC" name="GL_WEIGHT_ARRAY_POINTER_ARB"/>
+        <enum value="0x86AC" name="GL_WEIGHT_ARRAY_POINTER_OES"/>
+        <enum value="0x86AD" name="GL_WEIGHT_ARRAY_ARB"/>
+        <enum value="0x86AD" name="GL_WEIGHT_ARRAY_OES"/>
+        <enum value="0x86AE" name="GL_DOT3_RGB"/>
+        <enum value="0x86AE" name="GL_DOT3_RGB_ARB"/>
+        <enum value="0x86AF" name="GL_DOT3_RGBA"/>
+        <enum value="0x86AF" name="GL_DOT3_RGBA_ARB"/>
+        <enum value="0x86AF" name="GL_DOT3_RGBA_IMG"/>
+    </enums>
+
+    <enums namespace="GL" start="0x86B0" end="0x86BF" vendor="3DFX">
+        <enum value="0x86B0" name="GL_COMPRESSED_RGB_FXT1_3DFX"/>
+        <enum value="0x86B1" name="GL_COMPRESSED_RGBA_FXT1_3DFX"/>
+        <enum value="0x86B2" name="GL_MULTISAMPLE_3DFX"/>
+        <enum value="0x86B3" name="GL_SAMPLE_BUFFERS_3DFX"/>
+        <enum value="0x86B4" name="GL_SAMPLES_3DFX"/>
+            <unused start="0x86B5" end="0x86BF"/>
+    </enums>
+
+    <enums namespace="GL" start="0x86C0" end="0x871F" vendor="NV">
+        <enum value="0x86C0" name="GL_EVAL_2D_NV"/>
+        <enum value="0x86C1" name="GL_EVAL_TRIANGULAR_2D_NV"/>
+        <enum value="0x86C2" name="GL_MAP_TESSELLATION_NV"/>
+        <enum value="0x86C3" name="GL_MAP_ATTRIB_U_ORDER_NV"/>
+        <enum value="0x86C4" name="GL_MAP_ATTRIB_V_ORDER_NV"/>
+        <enum value="0x86C5" name="GL_EVAL_FRACTIONAL_TESSELLATION_NV"/>
+        <enum value="0x86C6" name="GL_EVAL_VERTEX_ATTRIB0_NV"/>
+        <enum value="0x86C7" name="GL_EVAL_VERTEX_ATTRIB1_NV"/>
+        <enum value="0x86C8" name="GL_EVAL_VERTEX_ATTRIB2_NV"/>
+        <enum value="0x86C9" name="GL_EVAL_VERTEX_ATTRIB3_NV"/>
+        <enum value="0x86CA" name="GL_EVAL_VERTEX_ATTRIB4_NV"/>
+        <enum value="0x86CB" name="GL_EVAL_VERTEX_ATTRIB5_NV"/>
+        <enum value="0x86CC" name="GL_EVAL_VERTEX_ATTRIB6_NV"/>
+        <enum value="0x86CD" name="GL_EVAL_VERTEX_ATTRIB7_NV"/>
+        <enum value="0x86CE" name="GL_EVAL_VERTEX_ATTRIB8_NV"/>
+        <enum value="0x86CF" name="GL_EVAL_VERTEX_ATTRIB9_NV"/>
+        <enum value="0x86D0" name="GL_EVAL_VERTEX_ATTRIB10_NV"/>
+        <enum value="0x86D1" name="GL_EVAL_VERTEX_ATTRIB11_NV"/>
+        <enum value="0x86D2" name="GL_EVAL_VERTEX_ATTRIB12_NV"/>
+        <enum value="0x86D3" name="GL_EVAL_VERTEX_ATTRIB13_NV"/>
+        <enum value="0x86D4" name="GL_EVAL_VERTEX_ATTRIB14_NV"/>
+        <enum value="0x86D5" name="GL_EVAL_VERTEX_ATTRIB15_NV"/>
+        <enum value="0x86D6" name="GL_MAX_MAP_TESSELLATION_NV"/>
+        <enum value="0x86D7" name="GL_MAX_RATIONAL_EVAL_ORDER_NV"/>
+        <enum value="0x86D8" name="GL_MAX_PROGRAM_PATCH_ATTRIBS_NV"/>
+        <enum value="0x86D9" name="GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV"/>
+        <enum value="0x86DA" name="GL_UNSIGNED_INT_S8_S8_8_8_NV"/>
+        <enum value="0x86DB" name="GL_UNSIGNED_INT_8_8_S8_S8_REV_NV"/>
+        <enum value="0x86DC" name="GL_DSDT_MAG_INTENSITY_NV"/>
+        <enum value="0x86DD" name="GL_SHADER_CONSISTENT_NV"/>
+        <enum value="0x86DE" name="GL_TEXTURE_SHADER_NV"/>
+        <enum value="0x86DF" name="GL_SHADER_OPERATION_NV"/>
+        <enum value="0x86E0" name="GL_CULL_MODES_NV"/>
+        <enum value="0x86E1" name="GL_OFFSET_TEXTURE_MATRIX_NV"/>
+        <enum value="0x86E1" name="GL_OFFSET_TEXTURE_2D_MATRIX_NV" alias="GL_OFFSET_TEXTURE_MATRIX_NV"/>
+        <enum value="0x86E2" name="GL_OFFSET_TEXTURE_SCALE_NV"/>
+        <enum value="0x86E2" name="GL_OFFSET_TEXTURE_2D_SCALE_NV" alias="GL_OFFSET_TEXTURE_SCALE_NV"/>
+        <enum value="0x86E3" name="GL_OFFSET_TEXTURE_BIAS_NV"/>
+        <enum value="0x86E3" name="GL_OFFSET_TEXTURE_2D_BIAS_NV" alias="GL_OFFSET_TEXTURE_BIAS_NV"/>
+        <enum value="0x86E4" name="GL_PREVIOUS_TEXTURE_INPUT_NV"/>
+        <enum value="0x86E5" name="GL_CONST_EYE_NV"/>
+        <enum value="0x86E6" name="GL_PASS_THROUGH_NV"/>
+        <enum value="0x86E7" name="GL_CULL_FRAGMENT_NV"/>
+        <enum value="0x86E8" name="GL_OFFSET_TEXTURE_2D_NV"/>
+        <enum value="0x86E9" name="GL_DEPENDENT_AR_TEXTURE_2D_NV"/>
+        <enum value="0x86EA" name="GL_DEPENDENT_GB_TEXTURE_2D_NV"/>
+        <enum value="0x86EB" name="GL_SURFACE_STATE_NV"/>
+        <enum value="0x86EC" name="GL_DOT_PRODUCT_NV"/>
+        <enum value="0x86ED" name="GL_DOT_PRODUCT_DEPTH_REPLACE_NV"/>
+        <enum value="0x86EE" name="GL_DOT_PRODUCT_TEXTURE_2D_NV"/>
+        <enum value="0x86EF" name="GL_DOT_PRODUCT_TEXTURE_3D_NV"/>
+        <enum value="0x86F0" name="GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV"/>
+        <enum value="0x86F1" name="GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV"/>
+        <enum value="0x86F2" name="GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV"/>
+        <enum value="0x86F3" name="GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV"/>
+        <enum value="0x86F4" name="GL_HILO_NV"/>
+        <enum value="0x86F5" name="GL_DSDT_NV"/>
+        <enum value="0x86F6" name="GL_DSDT_MAG_NV"/>
+        <enum value="0x86F7" name="GL_DSDT_MAG_VIB_NV"/>
+        <enum value="0x86F8" name="GL_HILO16_NV"/>
+        <enum value="0x86F9" name="GL_SIGNED_HILO_NV"/>
+        <enum value="0x86FA" name="GL_SIGNED_HILO16_NV"/>
+        <enum value="0x86FB" name="GL_SIGNED_RGBA_NV"/>
+        <enum value="0x86FC" name="GL_SIGNED_RGBA8_NV"/>
+        <enum value="0x86FD" name="GL_SURFACE_REGISTERED_NV"/>
+        <enum value="0x86FE" name="GL_SIGNED_RGB_NV"/>
+        <enum value="0x86FF" name="GL_SIGNED_RGB8_NV"/>
+        <enum value="0x8700" name="GL_SURFACE_MAPPED_NV"/>
+        <enum value="0x8701" name="GL_SIGNED_LUMINANCE_NV"/>
+        <enum value="0x8702" name="GL_SIGNED_LUMINANCE8_NV"/>
+        <enum value="0x8703" name="GL_SIGNED_LUMINANCE_ALPHA_NV"/>
+        <enum value="0x8704" name="GL_SIGNED_LUMINANCE8_ALPHA8_NV"/>
+        <enum value="0x8705" name="GL_SIGNED_ALPHA_NV"/>
+        <enum value="0x8706" name="GL_SIGNED_ALPHA8_NV"/>
+        <enum value="0x8707" name="GL_SIGNED_INTENSITY_NV"/>
+        <enum value="0x8708" name="GL_SIGNED_INTENSITY8_NV"/>
+        <enum value="0x8709" name="GL_DSDT8_NV"/>
+        <enum value="0x870A" name="GL_DSDT8_MAG8_NV"/>
+        <enum value="0x870B" name="GL_DSDT8_MAG8_INTENSITY8_NV"/>
+        <enum value="0x870C" name="GL_SIGNED_RGB_UNSIGNED_ALPHA_NV"/>
+        <enum value="0x870D" name="GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV"/>
+        <enum value="0x870E" name="GL_HI_SCALE_NV"/>
+        <enum value="0x870F" name="GL_LO_SCALE_NV"/>
+        <enum value="0x8710" name="GL_DS_SCALE_NV"/>
+        <enum value="0x8711" name="GL_DT_SCALE_NV"/>
+        <enum value="0x8712" name="GL_MAGNITUDE_SCALE_NV"/>
+        <enum value="0x8713" name="GL_VIBRANCE_SCALE_NV"/>
+        <enum value="0x8714" name="GL_HI_BIAS_NV"/>
+        <enum value="0x8715" name="GL_LO_BIAS_NV"/>
+        <enum value="0x8716" name="GL_DS_BIAS_NV"/>
+        <enum value="0x8717" name="GL_DT_BIAS_NV"/>
+        <enum value="0x8718" name="GL_MAGNITUDE_BIAS_NV"/>
+        <enum value="0x8719" name="GL_VIBRANCE_BIAS_NV"/>
+        <enum value="0x871A" name="GL_TEXTURE_BORDER_VALUES_NV"/>
+        <enum value="0x871B" name="GL_TEXTURE_HI_SIZE_NV"/>
+        <enum value="0x871C" name="GL_TEXTURE_LO_SIZE_NV"/>
+        <enum value="0x871D" name="GL_TEXTURE_DS_SIZE_NV"/>
+        <enum value="0x871E" name="GL_TEXTURE_DT_SIZE_NV"/>
+        <enum value="0x871F" name="GL_TEXTURE_MAG_SIZE_NV"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8720" end="0x873F" vendor="ARB">
+            <unused start="0x8720" end="0x8721" comment="MODELVIEW0/1 already exist"/>
+        <enum value="0x8722" name="GL_MODELVIEW2_ARB"/>
+        <enum value="0x8723" name="GL_MODELVIEW3_ARB"/>
+        <enum value="0x8724" name="GL_MODELVIEW4_ARB"/>
+        <enum value="0x8725" name="GL_MODELVIEW5_ARB"/>
+        <enum value="0x8726" name="GL_MODELVIEW6_ARB"/>
+        <enum value="0x8727" name="GL_MODELVIEW7_ARB"/>
+        <enum value="0x8728" name="GL_MODELVIEW8_ARB"/>
+        <enum value="0x8729" name="GL_MODELVIEW9_ARB"/>
+        <enum value="0x872A" name="GL_MODELVIEW10_ARB"/>
+        <enum value="0x872B" name="GL_MODELVIEW11_ARB"/>
+        <enum value="0x872C" name="GL_MODELVIEW12_ARB"/>
+        <enum value="0x872D" name="GL_MODELVIEW13_ARB"/>
+        <enum value="0x872E" name="GL_MODELVIEW14_ARB"/>
+        <enum value="0x872F" name="GL_MODELVIEW15_ARB"/>
+        <enum value="0x8730" name="GL_MODELVIEW16_ARB"/>
+        <enum value="0x8731" name="GL_MODELVIEW17_ARB"/>
+        <enum value="0x8732" name="GL_MODELVIEW18_ARB"/>
+        <enum value="0x8733" name="GL_MODELVIEW19_ARB"/>
+        <enum value="0x8734" name="GL_MODELVIEW20_ARB"/>
+        <enum value="0x8735" name="GL_MODELVIEW21_ARB"/>
+        <enum value="0x8736" name="GL_MODELVIEW22_ARB"/>
+        <enum value="0x8737" name="GL_MODELVIEW23_ARB"/>
+        <enum value="0x8738" name="GL_MODELVIEW24_ARB"/>
+        <enum value="0x8739" name="GL_MODELVIEW25_ARB"/>
+        <enum value="0x873A" name="GL_MODELVIEW26_ARB"/>
+        <enum value="0x873B" name="GL_MODELVIEW27_ARB"/>
+        <enum value="0x873C" name="GL_MODELVIEW28_ARB"/>
+        <enum value="0x873D" name="GL_MODELVIEW29_ARB"/>
+        <enum value="0x873E" name="GL_MODELVIEW30_ARB"/>
+        <enum value="0x873F" name="GL_MODELVIEW31_ARB"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8740" end="0x874F" vendor="AMD">
+        <enum value="0x8740" name="GL_DOT3_RGB_EXT"/>
+        <enum value="0x8740" name="GL_Z400_BINARY_AMD" comment="NOT an alias. Accidental reuse of GL_DOT3_RGB_EXT"/>
+        <enum value="0x8741" name="GL_DOT3_RGBA_EXT"/>
+        <enum value="0x8741" name="GL_PROGRAM_BINARY_LENGTH_OES" comment="NOT an alias. Accidental reuse of GL_DOT3_RGBA_EXT"/>
+        <enum value="0x8741" name="GL_PROGRAM_BINARY_LENGTH"/>
+        <enum value="0x8742" name="GL_MIRROR_CLAMP_ATI"/>
+        <enum value="0x8742" name="GL_MIRROR_CLAMP_EXT"/>
+        <enum value="0x8743" name="GL_MIRROR_CLAMP_TO_EDGE"/>
+        <enum value="0x8743" name="GL_MIRROR_CLAMP_TO_EDGE_ATI"/>
+        <enum value="0x8743" name="GL_MIRROR_CLAMP_TO_EDGE_EXT"/>
+        <enum value="0x8744" name="GL_MODULATE_ADD_ATI"/>
+        <enum value="0x8745" name="GL_MODULATE_SIGNED_ADD_ATI"/>
+        <enum value="0x8746" name="GL_MODULATE_SUBTRACT_ATI"/>
+            <unused start="0x8747" end="0x8749"/>
+        <enum value="0x874A" name="GL_SET_AMD"/>
+        <enum value="0x874B" name="GL_REPLACE_VALUE_AMD"/>
+        <enum value="0x874C" name="GL_STENCIL_OP_VALUE_AMD"/>
+        <enum value="0x874D" name="GL_STENCIL_BACK_OP_VALUE_AMD"/>
+        <enum value="0x874E" name="GL_VERTEX_ATTRIB_ARRAY_LONG"/>
+        <enum value="0x874F" name="GL_OCCLUSION_QUERY_EVENT_MASK_AMD"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8750" end="0x875F" vendor="MESA">
+        <enum value="0x8750" name="GL_DEPTH_STENCIL_MESA"/>
+        <enum value="0x8751" name="GL_UNSIGNED_INT_24_8_MESA"/>
+        <enum value="0x8752" name="GL_UNSIGNED_INT_8_24_REV_MESA"/>
+        <enum value="0x8753" name="GL_UNSIGNED_SHORT_15_1_MESA"/>
+        <enum value="0x8754" name="GL_UNSIGNED_SHORT_1_15_REV_MESA"/>
+        <enum value="0x8755" name="GL_TRACE_MASK_MESA"/>
+        <enum value="0x8756" name="GL_TRACE_NAME_MESA"/>
+        <enum value="0x8757" name="GL_YCBCR_MESA"/>
+        <enum value="0x8758" name="GL_PACK_INVERT_MESA"/>
+        <enum value="0x8759" name="GL_DEBUG_OBJECT_MESA" comment="NOT an alias. Accidental reuse of GL_TEXTURE_1D_STACK_MESAX"/>
+        <enum value="0x8759" name="GL_TEXTURE_1D_STACK_MESAX"/>
+        <enum value="0x875A" name="GL_DEBUG_PRINT_MESA" comment="NOT an alias. Accidental reuse of GL_TEXTURE_2D_STACK_MESAX"/>
+        <enum value="0x875A" name="GL_TEXTURE_2D_STACK_MESAX"/>
+        <enum value="0x875B" name="GL_DEBUG_ASSERT_MESA" comment="NOT an alias. Accidental reuse of GL_PROXY_TEXTURE_1D_STACK_MESAX"/>
+        <enum value="0x875B" name="GL_PROXY_TEXTURE_1D_STACK_MESAX"/>
+        <enum value="0x875C" name="GL_PROXY_TEXTURE_2D_STACK_MESAX"/>
+        <enum value="0x875D" name="GL_TEXTURE_1D_STACK_BINDING_MESAX"/>
+        <enum value="0x875E" name="GL_TEXTURE_2D_STACK_BINDING_MESAX"/>
+            <unused start="0x875F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8760" end="0x883F" vendor="AMD">
+        <enum value="0x8760" name="GL_STATIC_ATI"/>
+        <enum value="0x8761" name="GL_DYNAMIC_ATI"/>
+        <enum value="0x8762" name="GL_PRESERVE_ATI"/>
+        <enum value="0x8763" name="GL_DISCARD_ATI"/>
+        <enum value="0x8764" name="GL_BUFFER_SIZE"/>
+        <enum value="0x8764" name="GL_BUFFER_SIZE_ARB"/>
+        <enum value="0x8764" name="GL_OBJECT_BUFFER_SIZE_ATI"/>
+        <enum value="0x8765" name="GL_BUFFER_USAGE"/>
+        <enum value="0x8765" name="GL_BUFFER_USAGE_ARB"/>
+        <enum value="0x8765" name="GL_OBJECT_BUFFER_USAGE_ATI"/>
+        <enum value="0x8766" name="GL_ARRAY_OBJECT_BUFFER_ATI"/>
+        <enum value="0x8767" name="GL_ARRAY_OBJECT_OFFSET_ATI"/>
+        <enum value="0x8768" name="GL_ELEMENT_ARRAY_ATI"/>
+        <enum value="0x8769" name="GL_ELEMENT_ARRAY_TYPE_ATI"/>
+        <enum value="0x876A" name="GL_ELEMENT_ARRAY_POINTER_ATI"/>
+        <enum value="0x876B" name="GL_MAX_VERTEX_STREAMS_ATI"/>
+        <enum value="0x876C" name="GL_VERTEX_STREAM0_ATI"/>
+        <enum value="0x876D" name="GL_VERTEX_STREAM1_ATI"/>
+        <enum value="0x876E" name="GL_VERTEX_STREAM2_ATI"/>
+        <enum value="0x876F" name="GL_VERTEX_STREAM3_ATI"/>
+        <enum value="0x8770" name="GL_VERTEX_STREAM4_ATI"/>
+        <enum value="0x8771" name="GL_VERTEX_STREAM5_ATI"/>
+        <enum value="0x8772" name="GL_VERTEX_STREAM6_ATI"/>
+        <enum value="0x8773" name="GL_VERTEX_STREAM7_ATI"/>
+        <enum value="0x8774" name="GL_VERTEX_SOURCE_ATI"/>
+        <enum value="0x8775" name="GL_BUMP_ROT_MATRIX_ATI"/>
+        <enum value="0x8776" name="GL_BUMP_ROT_MATRIX_SIZE_ATI"/>
+        <enum value="0x8777" name="GL_BUMP_NUM_TEX_UNITS_ATI"/>
+        <enum value="0x8778" name="GL_BUMP_TEX_UNITS_ATI"/>
+        <enum value="0x8779" name="GL_DUDV_ATI"/>
+        <enum value="0x877A" name="GL_DU8DV8_ATI"/>
+        <enum value="0x877B" name="GL_BUMP_ENVMAP_ATI"/>
+        <enum value="0x877C" name="GL_BUMP_TARGET_ATI"/>
+            <unused start="0x877D" end="0x877F"/>
+        <enum value="0x8780" name="GL_VERTEX_SHADER_EXT"/>
+        <enum value="0x8781" name="GL_VERTEX_SHADER_BINDING_EXT"/>
+        <enum value="0x8782" name="GL_OP_INDEX_EXT"/>
+        <enum value="0x8783" name="GL_OP_NEGATE_EXT"/>
+        <enum value="0x8784" name="GL_OP_DOT3_EXT"/>
+        <enum value="0x8785" name="GL_OP_DOT4_EXT"/>
+        <enum value="0x8786" name="GL_OP_MUL_EXT"/>
+        <enum value="0x8787" name="GL_OP_ADD_EXT"/>
+        <enum value="0x8788" name="GL_OP_MADD_EXT"/>
+        <enum value="0x8789" name="GL_OP_FRAC_EXT"/>
+        <enum value="0x878A" name="GL_OP_MAX_EXT"/>
+        <enum value="0x878B" name="GL_OP_MIN_EXT"/>
+        <enum value="0x878C" name="GL_OP_SET_GE_EXT"/>
+        <enum value="0x878D" name="GL_OP_SET_LT_EXT"/>
+        <enum value="0x878E" name="GL_OP_CLAMP_EXT"/>
+        <enum value="0x878F" name="GL_OP_FLOOR_EXT"/>
+        <enum value="0x8790" name="GL_OP_ROUND_EXT"/>
+        <enum value="0x8791" name="GL_OP_EXP_BASE_2_EXT"/>
+        <enum value="0x8792" name="GL_OP_LOG_BASE_2_EXT"/>
+        <enum value="0x8793" name="GL_OP_POWER_EXT"/>
+        <enum value="0x8794" name="GL_OP_RECIP_EXT"/>
+        <enum value="0x8795" name="GL_OP_RECIP_SQRT_EXT"/>
+        <enum value="0x8796" name="GL_OP_SUB_EXT"/>
+        <enum value="0x8797" name="GL_OP_CROSS_PRODUCT_EXT"/>
+        <enum value="0x8798" name="GL_OP_MULTIPLY_MATRIX_EXT"/>
+        <enum value="0x8799" name="GL_OP_MOV_EXT"/>
+        <enum value="0x879A" name="GL_OUTPUT_VERTEX_EXT"/>
+        <enum value="0x879B" name="GL_OUTPUT_COLOR0_EXT"/>
+        <enum value="0x879C" name="GL_OUTPUT_COLOR1_EXT"/>
+        <enum value="0x879D" name="GL_OUTPUT_TEXTURE_COORD0_EXT"/>
+        <enum value="0x879E" name="GL_OUTPUT_TEXTURE_COORD1_EXT"/>
+        <enum value="0x879F" name="GL_OUTPUT_TEXTURE_COORD2_EXT"/>
+        <enum value="0x87A0" name="GL_OUTPUT_TEXTURE_COORD3_EXT"/>
+        <enum value="0x87A1" name="GL_OUTPUT_TEXTURE_COORD4_EXT"/>
+        <enum value="0x87A2" name="GL_OUTPUT_TEXTURE_COORD5_EXT"/>
+        <enum value="0x87A3" name="GL_OUTPUT_TEXTURE_COORD6_EXT"/>
+        <enum value="0x87A4" name="GL_OUTPUT_TEXTURE_COORD7_EXT"/>
+        <enum value="0x87A5" name="GL_OUTPUT_TEXTURE_COORD8_EXT"/>
+        <enum value="0x87A6" name="GL_OUTPUT_TEXTURE_COORD9_EXT"/>
+        <enum value="0x87A7" name="GL_OUTPUT_TEXTURE_COORD10_EXT"/>
+        <enum value="0x87A8" name="GL_OUTPUT_TEXTURE_COORD11_EXT"/>
+        <enum value="0x87A9" name="GL_OUTPUT_TEXTURE_COORD12_EXT"/>
+        <enum value="0x87AA" name="GL_OUTPUT_TEXTURE_COORD13_EXT"/>
+        <enum value="0x87AB" name="GL_OUTPUT_TEXTURE_COORD14_EXT"/>
+        <enum value="0x87AC" name="GL_OUTPUT_TEXTURE_COORD15_EXT"/>
+        <enum value="0x87AD" name="GL_OUTPUT_TEXTURE_COORD16_EXT"/>
+        <enum value="0x87AE" name="GL_OUTPUT_TEXTURE_COORD17_EXT"/>
+        <enum value="0x87AF" name="GL_OUTPUT_TEXTURE_COORD18_EXT"/>
+        <enum value="0x87B0" name="GL_OUTPUT_TEXTURE_COORD19_EXT"/>
+        <enum value="0x87B1" name="GL_OUTPUT_TEXTURE_COORD20_EXT"/>
+        <enum value="0x87B2" name="GL_OUTPUT_TEXTURE_COORD21_EXT"/>
+        <enum value="0x87B3" name="GL_OUTPUT_TEXTURE_COORD22_EXT"/>
+        <enum value="0x87B4" name="GL_OUTPUT_TEXTURE_COORD23_EXT"/>
+        <enum value="0x87B5" name="GL_OUTPUT_TEXTURE_COORD24_EXT"/>
+        <enum value="0x87B6" name="GL_OUTPUT_TEXTURE_COORD25_EXT"/>
+        <enum value="0x87B7" name="GL_OUTPUT_TEXTURE_COORD26_EXT"/>
+        <enum value="0x87B8" name="GL_OUTPUT_TEXTURE_COORD27_EXT"/>
+        <enum value="0x87B9" name="GL_OUTPUT_TEXTURE_COORD28_EXT"/>
+        <enum value="0x87BA" name="GL_OUTPUT_TEXTURE_COORD29_EXT"/>
+        <enum value="0x87BB" name="GL_OUTPUT_TEXTURE_COORD30_EXT"/>
+        <enum value="0x87BC" name="GL_OUTPUT_TEXTURE_COORD31_EXT"/>
+        <enum value="0x87BD" name="GL_OUTPUT_FOG_EXT"/>
+        <enum value="0x87BE" name="GL_SCALAR_EXT"/>
+        <enum value="0x87BF" name="GL_VECTOR_EXT"/>
+        <enum value="0x87C0" name="GL_MATRIX_EXT"/>
+        <enum value="0x87C1" name="GL_VARIANT_EXT"/>
+        <enum value="0x87C2" name="GL_INVARIANT_EXT"/>
+        <enum value="0x87C3" name="GL_LOCAL_CONSTANT_EXT"/>
+        <enum value="0x87C4" name="GL_LOCAL_EXT"/>
+        <enum value="0x87C5" name="GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT"/>
+        <enum value="0x87C6" name="GL_MAX_VERTEX_SHADER_VARIANTS_EXT"/>
+        <enum value="0x87C7" name="GL_MAX_VERTEX_SHADER_INVARIANTS_EXT"/>
+        <enum value="0x87C8" name="GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT"/>
+        <enum value="0x87C9" name="GL_MAX_VERTEX_SHADER_LOCALS_EXT"/>
+        <enum value="0x87CA" name="GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT"/>
+        <enum value="0x87CB" name="GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT"/>
+        <enum value="0x87CC" name="GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT"/>
+        <enum value="0x87CD" name="GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT"/>
+        <enum value="0x87CE" name="GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT"/>
+        <enum value="0x87CF" name="GL_VERTEX_SHADER_INSTRUCTIONS_EXT"/>
+        <enum value="0x87D0" name="GL_VERTEX_SHADER_VARIANTS_EXT"/>
+        <enum value="0x87D1" name="GL_VERTEX_SHADER_INVARIANTS_EXT"/>
+        <enum value="0x87D2" name="GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT"/>
+        <enum value="0x87D3" name="GL_VERTEX_SHADER_LOCALS_EXT"/>
+        <enum value="0x87D4" name="GL_VERTEX_SHADER_OPTIMIZED_EXT"/>
+        <enum value="0x87D5" name="GL_X_EXT"/>
+        <enum value="0x87D6" name="GL_Y_EXT"/>
+        <enum value="0x87D7" name="GL_Z_EXT"/>
+        <enum value="0x87D8" name="GL_W_EXT"/>
+        <enum value="0x87D9" name="GL_NEGATIVE_X_EXT"/>
+        <enum value="0x87DA" name="GL_NEGATIVE_Y_EXT"/>
+        <enum value="0x87DB" name="GL_NEGATIVE_Z_EXT"/>
+        <enum value="0x87DC" name="GL_NEGATIVE_W_EXT"/>
+        <enum value="0x87DD" name="GL_ZERO_EXT"/>
+        <enum value="0x87DE" name="GL_ONE_EXT"/>
+        <enum value="0x87DF" name="GL_NEGATIVE_ONE_EXT"/>
+        <enum value="0x87E0" name="GL_NORMALIZED_RANGE_EXT"/>
+        <enum value="0x87E1" name="GL_FULL_RANGE_EXT"/>
+        <enum value="0x87E2" name="GL_CURRENT_VERTEX_EXT"/>
+        <enum value="0x87E3" name="GL_MVP_MATRIX_EXT"/>
+        <enum value="0x87E4" name="GL_VARIANT_VALUE_EXT"/>
+        <enum value="0x87E5" name="GL_VARIANT_DATATYPE_EXT"/>
+        <enum value="0x87E6" name="GL_VARIANT_ARRAY_STRIDE_EXT"/>
+        <enum value="0x87E7" name="GL_VARIANT_ARRAY_TYPE_EXT"/>
+        <enum value="0x87E8" name="GL_VARIANT_ARRAY_EXT"/>
+        <enum value="0x87E9" name="GL_VARIANT_ARRAY_POINTER_EXT"/>
+        <enum value="0x87EA" name="GL_INVARIANT_VALUE_EXT"/>
+        <enum value="0x87EB" name="GL_INVARIANT_DATATYPE_EXT"/>
+        <enum value="0x87EC" name="GL_LOCAL_CONSTANT_VALUE_EXT"/>
+        <enum value="0x87ED" name="GL_LOCAL_CONSTANT_DATATYPE_EXT"/>
+        <enum value="0x87EE" name="GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD"/>
+        <enum value="0x87F0" name="GL_PN_TRIANGLES_ATI"/>
+        <enum value="0x87F1" name="GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI"/>
+        <enum value="0x87F2" name="GL_PN_TRIANGLES_POINT_MODE_ATI"/>
+        <enum value="0x87F3" name="GL_PN_TRIANGLES_NORMAL_MODE_ATI"/>
+        <enum value="0x87F4" name="GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI"/>
+        <enum value="0x87F5" name="GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI"/>
+        <enum value="0x87F6" name="GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI"/>
+        <enum value="0x87F7" name="GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI"/>
+        <enum value="0x87F8" name="GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI"/>
+        <enum value="0x87F9" name="GL_3DC_X_AMD"/>
+        <enum value="0x87FA" name="GL_3DC_XY_AMD"/>
+        <enum value="0x87FB" name="GL_VBO_FREE_MEMORY_ATI"/>
+        <enum value="0x87FC" name="GL_TEXTURE_FREE_MEMORY_ATI"/>
+        <enum value="0x87FD" name="GL_RENDERBUFFER_FREE_MEMORY_ATI"/>
+        <enum value="0x87FE" name="GL_NUM_PROGRAM_BINARY_FORMATS"/>
+        <enum value="0x87FE" name="GL_NUM_PROGRAM_BINARY_FORMATS_OES"/>
+        <enum value="0x87FF" name="GL_PROGRAM_BINARY_FORMATS"/>
+        <enum value="0x87FF" name="GL_PROGRAM_BINARY_FORMATS_OES"/>
+        <enum value="0x8800" name="GL_STENCIL_BACK_FUNC"/>
+        <enum value="0x8800" name="GL_STENCIL_BACK_FUNC_ATI"/>
+        <enum value="0x8801" name="GL_STENCIL_BACK_FAIL"/>
+        <enum value="0x8801" name="GL_STENCIL_BACK_FAIL_ATI"/>
+        <enum value="0x8802" name="GL_STENCIL_BACK_PASS_DEPTH_FAIL"/>
+        <enum value="0x8802" name="GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI"/>
+        <enum value="0x8803" name="GL_STENCIL_BACK_PASS_DEPTH_PASS"/>
+        <enum value="0x8803" name="GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI"/>
+        <enum value="0x8804" name="GL_FRAGMENT_PROGRAM_ARB"/>
+        <enum value="0x8805" name="GL_PROGRAM_ALU_INSTRUCTIONS_ARB"/>
+        <enum value="0x8806" name="GL_PROGRAM_TEX_INSTRUCTIONS_ARB"/>
+        <enum value="0x8807" name="GL_PROGRAM_TEX_INDIRECTIONS_ARB"/>
+        <enum value="0x8808" name="GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB"/>
+        <enum value="0x8809" name="GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB"/>
+        <enum value="0x880A" name="GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB"/>
+        <enum value="0x880B" name="GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB"/>
+        <enum value="0x880C" name="GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB"/>
+        <enum value="0x880D" name="GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB"/>
+        <enum value="0x880E" name="GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB"/>
+        <enum value="0x880F" name="GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB"/>
+        <enum value="0x8810" name="GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB"/>
+            <unused start="0x8811" end="0x8813"/>
+        <enum value="0x8814" name="GL_RGBA32F"/>
+        <enum value="0x8814" name="GL_RGBA32F_ARB"/>
+        <enum value="0x8814" name="GL_RGBA32F_EXT"/>
+        <enum value="0x8814" name="GL_RGBA_FLOAT32_APPLE"/>
+        <enum value="0x8814" name="GL_RGBA_FLOAT32_ATI"/>
+        <enum value="0x8815" name="GL_RGB32F"/>
+        <enum value="0x8815" name="GL_RGB32F_ARB"/>
+        <enum value="0x8815" name="GL_RGB32F_EXT"/>
+        <enum value="0x8815" name="GL_RGB_FLOAT32_APPLE"/>
+        <enum value="0x8815" name="GL_RGB_FLOAT32_ATI"/>
+        <enum value="0x8816" name="GL_ALPHA32F_ARB"/>
+        <enum value="0x8816" name="GL_ALPHA32F_EXT"/>
+        <enum value="0x8816" name="GL_ALPHA_FLOAT32_APPLE"/>
+        <enum value="0x8816" name="GL_ALPHA_FLOAT32_ATI"/>
+        <enum value="0x8817" name="GL_INTENSITY32F_ARB"/>
+        <enum value="0x8817" name="GL_INTENSITY_FLOAT32_APPLE"/>
+        <enum value="0x8817" name="GL_INTENSITY_FLOAT32_ATI"/>
+        <enum value="0x8818" name="GL_LUMINANCE32F_ARB"/>
+        <enum value="0x8818" name="GL_LUMINANCE32F_EXT"/>
+        <enum value="0x8818" name="GL_LUMINANCE_FLOAT32_APPLE"/>
+        <enum value="0x8818" name="GL_LUMINANCE_FLOAT32_ATI"/>
+        <enum value="0x8819" name="GL_LUMINANCE_ALPHA32F_ARB"/>
+        <enum value="0x8819" name="GL_LUMINANCE_ALPHA32F_EXT"/>
+        <enum value="0x8819" name="GL_LUMINANCE_ALPHA_FLOAT32_APPLE"/>
+        <enum value="0x8819" name="GL_LUMINANCE_ALPHA_FLOAT32_ATI"/>
+        <enum value="0x881A" name="GL_RGBA16F"/>
+        <enum value="0x881A" name="GL_RGBA16F_ARB"/>
+        <enum value="0x881A" name="GL_RGBA16F_EXT"/>
+        <enum value="0x881A" name="GL_RGBA_FLOAT16_APPLE"/>
+        <enum value="0x881A" name="GL_RGBA_FLOAT16_ATI"/>
+        <enum value="0x881B" name="GL_RGB16F"/>
+        <enum value="0x881B" name="GL_RGB16F_ARB"/>
+        <enum value="0x881B" name="GL_RGB16F_EXT"/>
+        <enum value="0x881B" name="GL_RGB_FLOAT16_APPLE"/>
+        <enum value="0x881B" name="GL_RGB_FLOAT16_ATI"/>
+        <enum value="0x881C" name="GL_ALPHA16F_ARB"/>
+        <enum value="0x881C" name="GL_ALPHA16F_EXT"/>
+        <enum value="0x881C" name="GL_ALPHA_FLOAT16_APPLE"/>
+        <enum value="0x881C" name="GL_ALPHA_FLOAT16_ATI"/>
+        <enum value="0x881D" name="GL_INTENSITY16F_ARB"/>
+        <enum value="0x881D" name="GL_INTENSITY_FLOAT16_APPLE"/>
+        <enum value="0x881D" name="GL_INTENSITY_FLOAT16_ATI"/>
+        <enum value="0x881E" name="GL_LUMINANCE16F_ARB"/>
+        <enum value="0x881E" name="GL_LUMINANCE16F_EXT"/>
+        <enum value="0x881E" name="GL_LUMINANCE_FLOAT16_APPLE"/>
+        <enum value="0x881E" name="GL_LUMINANCE_FLOAT16_ATI"/>
+        <enum value="0x881F" name="GL_LUMINANCE_ALPHA16F_ARB"/>
+        <enum value="0x881F" name="GL_LUMINANCE_ALPHA16F_EXT"/>
+        <enum value="0x881F" name="GL_LUMINANCE_ALPHA_FLOAT16_APPLE"/>
+        <enum value="0x881F" name="GL_LUMINANCE_ALPHA_FLOAT16_ATI"/>
+            <!-- RGBA_FLOAT_MODE_ARB equivalent to TYPE_RGBA_FLOAT_ATI -->
+        <enum value="0x8820" name="GL_RGBA_FLOAT_MODE_ARB"/>
+        <enum value="0x8820" name="GL_RGBA_FLOAT_MODE_ATI"/>
+            <unused start="0x8821" end="0x8822"/>
+        <enum value="0x8823" name="GL_WRITEONLY_RENDERING_QCOM"/>
+        <enum value="0x8824" name="GL_MAX_DRAW_BUFFERS"/>
+        <enum value="0x8824" name="GL_MAX_DRAW_BUFFERS_ARB"/>
+        <enum value="0x8824" name="GL_MAX_DRAW_BUFFERS_ATI"/>
+        <enum value="0x8824" name="GL_MAX_DRAW_BUFFERS_EXT"/>
+        <enum value="0x8824" name="GL_MAX_DRAW_BUFFERS_NV"/>
+        <enum value="0x8825" name="GL_DRAW_BUFFER0"/>
+        <enum value="0x8825" name="GL_DRAW_BUFFER0_ARB"/>
+        <enum value="0x8825" name="GL_DRAW_BUFFER0_ATI"/>
+        <enum value="0x8825" name="GL_DRAW_BUFFER0_EXT"/>
+        <enum value="0x8825" name="GL_DRAW_BUFFER0_NV"/>
+        <enum value="0x8826" name="GL_DRAW_BUFFER1"/>
+        <enum value="0x8826" name="GL_DRAW_BUFFER1_ARB"/>
+        <enum value="0x8826" name="GL_DRAW_BUFFER1_ATI"/>
+        <enum value="0x8826" name="GL_DRAW_BUFFER1_EXT"/>
+        <enum value="0x8826" name="GL_DRAW_BUFFER1_NV"/>
+        <enum value="0x8827" name="GL_DRAW_BUFFER2"/>
+        <enum value="0x8827" name="GL_DRAW_BUFFER2_ARB"/>
+        <enum value="0x8827" name="GL_DRAW_BUFFER2_ATI"/>
+        <enum value="0x8827" name="GL_DRAW_BUFFER2_EXT"/>
+        <enum value="0x8827" name="GL_DRAW_BUFFER2_NV"/>
+        <enum value="0x8828" name="GL_DRAW_BUFFER3"/>
+        <enum value="0x8828" name="GL_DRAW_BUFFER3_ARB"/>
+        <enum value="0x8828" name="GL_DRAW_BUFFER3_ATI"/>
+        <enum value="0x8828" name="GL_DRAW_BUFFER3_EXT"/>
+        <enum value="0x8828" name="GL_DRAW_BUFFER3_NV"/>
+        <enum value="0x8829" name="GL_DRAW_BUFFER4"/>
+        <enum value="0x8829" name="GL_DRAW_BUFFER4_ARB"/>
+        <enum value="0x8829" name="GL_DRAW_BUFFER4_ATI"/>
+        <enum value="0x8829" name="GL_DRAW_BUFFER4_EXT"/>
+        <enum value="0x8829" name="GL_DRAW_BUFFER4_NV"/>
+        <enum value="0x882A" name="GL_DRAW_BUFFER5"/>
+        <enum value="0x882A" name="GL_DRAW_BUFFER5_ARB"/>
+        <enum value="0x882A" name="GL_DRAW_BUFFER5_ATI"/>
+        <enum value="0x882A" name="GL_DRAW_BUFFER5_EXT"/>
+        <enum value="0x882A" name="GL_DRAW_BUFFER5_NV"/>
+        <enum value="0x882B" name="GL_DRAW_BUFFER6"/>
+        <enum value="0x882B" name="GL_DRAW_BUFFER6_ARB"/>
+        <enum value="0x882B" name="GL_DRAW_BUFFER6_ATI"/>
+        <enum value="0x882B" name="GL_DRAW_BUFFER6_EXT"/>
+        <enum value="0x882B" name="GL_DRAW_BUFFER6_NV"/>
+        <enum value="0x882C" name="GL_DRAW_BUFFER7"/>
+        <enum value="0x882C" name="GL_DRAW_BUFFER7_ARB"/>
+        <enum value="0x882C" name="GL_DRAW_BUFFER7_ATI"/>
+        <enum value="0x882C" name="GL_DRAW_BUFFER7_EXT"/>
+        <enum value="0x882C" name="GL_DRAW_BUFFER7_NV"/>
+        <enum value="0x882D" name="GL_DRAW_BUFFER8"/>
+        <enum value="0x882D" name="GL_DRAW_BUFFER8_ARB"/>
+        <enum value="0x882D" name="GL_DRAW_BUFFER8_ATI"/>
+        <enum value="0x882D" name="GL_DRAW_BUFFER8_EXT"/>
+        <enum value="0x882D" name="GL_DRAW_BUFFER8_NV"/>
+        <enum value="0x882E" name="GL_DRAW_BUFFER9"/>
+        <enum value="0x882E" name="GL_DRAW_BUFFER9_ARB"/>
+        <enum value="0x882E" name="GL_DRAW_BUFFER9_ATI"/>
+        <enum value="0x882E" name="GL_DRAW_BUFFER9_EXT"/>
+        <enum value="0x882E" name="GL_DRAW_BUFFER9_NV"/>
+        <enum value="0x882F" name="GL_DRAW_BUFFER10"/>
+        <enum value="0x882F" name="GL_DRAW_BUFFER10_ARB"/>
+        <enum value="0x882F" name="GL_DRAW_BUFFER10_ATI"/>
+        <enum value="0x882F" name="GL_DRAW_BUFFER10_EXT"/>
+        <enum value="0x882F" name="GL_DRAW_BUFFER10_NV"/>
+        <enum value="0x8830" name="GL_DRAW_BUFFER11"/>
+        <enum value="0x8830" name="GL_DRAW_BUFFER11_ARB"/>
+        <enum value="0x8830" name="GL_DRAW_BUFFER11_ATI"/>
+        <enum value="0x8830" name="GL_DRAW_BUFFER11_EXT"/>
+        <enum value="0x8830" name="GL_DRAW_BUFFER11_NV"/>
+        <enum value="0x8831" name="GL_DRAW_BUFFER12"/>
+        <enum value="0x8831" name="GL_DRAW_BUFFER12_ARB"/>
+        <enum value="0x8831" name="GL_DRAW_BUFFER12_ATI"/>
+        <enum value="0x8831" name="GL_DRAW_BUFFER12_EXT"/>
+        <enum value="0x8831" name="GL_DRAW_BUFFER12_NV"/>
+        <enum value="0x8832" name="GL_DRAW_BUFFER13"/>
+        <enum value="0x8832" name="GL_DRAW_BUFFER13_ARB"/>
+        <enum value="0x8832" name="GL_DRAW_BUFFER13_ATI"/>
+        <enum value="0x8832" name="GL_DRAW_BUFFER13_EXT"/>
+        <enum value="0x8832" name="GL_DRAW_BUFFER13_NV"/>
+        <enum value="0x8833" name="GL_DRAW_BUFFER14"/>
+        <enum value="0x8833" name="GL_DRAW_BUFFER14_ARB"/>
+        <enum value="0x8833" name="GL_DRAW_BUFFER14_ATI"/>
+        <enum value="0x8833" name="GL_DRAW_BUFFER14_EXT"/>
+        <enum value="0x8833" name="GL_DRAW_BUFFER14_NV"/>
+        <enum value="0x8834" name="GL_DRAW_BUFFER15"/>
+        <enum value="0x8834" name="GL_DRAW_BUFFER15_ARB"/>
+        <enum value="0x8834" name="GL_DRAW_BUFFER15_ATI"/>
+        <enum value="0x8834" name="GL_DRAW_BUFFER15_EXT"/>
+        <enum value="0x8834" name="GL_DRAW_BUFFER15_NV"/>
+        <enum value="0x8835" name="GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI"/>
+            <unused start="0x8836"/>
+        <enum value="0x8837" name="GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI" comment="Defined by Mesa but not ATI"/>
+            <unused start="0x8838" end="0x883C"/>
+        <enum value="0x883D" name="GL_BLEND_EQUATION_ALPHA"/>
+        <enum value="0x883D" name="GL_BLEND_EQUATION_ALPHA_EXT"/>
+        <enum value="0x883D" name="GL_BLEND_EQUATION_ALPHA_OES"/>
+            <unused start="0x883E"/>
+        <enum value="0x883F" name="GL_SUBSAMPLE_DISTANCE_AMD"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8840" end="0x884F" vendor="ARB">
+        <enum value="0x8840" name="GL_MATRIX_PALETTE_ARB"/>
+        <enum value="0x8840" name="GL_MATRIX_PALETTE_OES"/>
+        <enum value="0x8841" name="GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB"/>
+        <enum value="0x8842" name="GL_MAX_PALETTE_MATRICES_ARB"/>
+        <enum value="0x8842" name="GL_MAX_PALETTE_MATRICES_OES"/>
+        <enum value="0x8843" name="GL_CURRENT_PALETTE_MATRIX_ARB"/>
+        <enum value="0x8843" name="GL_CURRENT_PALETTE_MATRIX_OES"/>
+        <enum value="0x8844" name="GL_MATRIX_INDEX_ARRAY_ARB"/>
+        <enum value="0x8844" name="GL_MATRIX_INDEX_ARRAY_OES"/>
+        <enum value="0x8845" name="GL_CURRENT_MATRIX_INDEX_ARB"/>
+        <enum value="0x8846" name="GL_MATRIX_INDEX_ARRAY_SIZE_ARB"/>
+        <enum value="0x8846" name="GL_MATRIX_INDEX_ARRAY_SIZE_OES"/>
+        <enum value="0x8847" name="GL_MATRIX_INDEX_ARRAY_TYPE_ARB"/>
+        <enum value="0x8847" name="GL_MATRIX_INDEX_ARRAY_TYPE_OES"/>
+        <enum value="0x8848" name="GL_MATRIX_INDEX_ARRAY_STRIDE_ARB"/>
+        <enum value="0x8848" name="GL_MATRIX_INDEX_ARRAY_STRIDE_OES"/>
+        <enum value="0x8849" name="GL_MATRIX_INDEX_ARRAY_POINTER_ARB"/>
+        <enum value="0x8849" name="GL_MATRIX_INDEX_ARRAY_POINTER_OES"/>
+        <enum value="0x884A" name="GL_TEXTURE_DEPTH_SIZE"/>
+        <enum value="0x884A" name="GL_TEXTURE_DEPTH_SIZE_ARB"/>
+        <enum value="0x884B" name="GL_DEPTH_TEXTURE_MODE"/>
+        <enum value="0x884B" name="GL_DEPTH_TEXTURE_MODE_ARB"/>
+        <enum value="0x884C" name="GL_TEXTURE_COMPARE_MODE"/>
+        <enum value="0x884C" name="GL_TEXTURE_COMPARE_MODE_ARB"/>
+        <enum value="0x884C" name="GL_TEXTURE_COMPARE_MODE_EXT"/>
+        <enum value="0x884D" name="GL_TEXTURE_COMPARE_FUNC"/>
+        <enum value="0x884D" name="GL_TEXTURE_COMPARE_FUNC_ARB"/>
+        <enum value="0x884D" name="GL_TEXTURE_COMPARE_FUNC_EXT"/>
+        <enum value="0x884E" name="GL_COMPARE_R_TO_TEXTURE"/>
+        <enum value="0x884E" name="GL_COMPARE_R_TO_TEXTURE_ARB"/>
+        <enum value="0x884E" name="GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT"/>
+        <enum value="0x884E" name="GL_COMPARE_REF_TO_TEXTURE" alias="GL_COMPARE_R_TO_TEXTURE"/>
+        <enum value="0x884E" name="GL_COMPARE_REF_TO_TEXTURE_EXT"/>
+        <enum value="0x884F" name="GL_TEXTURE_CUBE_MAP_SEAMLESS"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8850" end="0x891F" vendor="NV">
+        <enum value="0x8850" name="GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV"/>
+        <enum value="0x8851" name="GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV"/>
+        <enum value="0x8852" name="GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV"/>
+        <enum value="0x8853" name="GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV"/>
+        <enum value="0x8854" name="GL_OFFSET_HILO_TEXTURE_2D_NV"/>
+        <enum value="0x8855" name="GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV"/>
+        <enum value="0x8856" name="GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV"/>
+        <enum value="0x8857" name="GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV"/>
+        <enum value="0x8858" name="GL_DEPENDENT_HILO_TEXTURE_2D_NV"/>
+        <enum value="0x8859" name="GL_DEPENDENT_RGB_TEXTURE_3D_NV"/>
+        <enum value="0x885A" name="GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV"/>
+        <enum value="0x885B" name="GL_DOT_PRODUCT_PASS_THROUGH_NV"/>
+        <enum value="0x885C" name="GL_DOT_PRODUCT_TEXTURE_1D_NV"/>
+        <enum value="0x885D" name="GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV"/>
+        <enum value="0x885E" name="GL_HILO8_NV"/>
+        <enum value="0x885F" name="GL_SIGNED_HILO8_NV"/>
+        <enum value="0x8860" name="GL_FORCE_BLUE_TO_ONE_NV"/>
+        <enum value="0x8861" name="GL_POINT_SPRITE"/>
+        <enum value="0x8861" name="GL_POINT_SPRITE_ARB"/>
+        <enum value="0x8861" name="GL_POINT_SPRITE_NV"/>
+        <enum value="0x8861" name="GL_POINT_SPRITE_OES"/>
+        <enum value="0x8862" name="GL_COORD_REPLACE"/>
+        <enum value="0x8862" name="GL_COORD_REPLACE_ARB"/>
+        <enum value="0x8862" name="GL_COORD_REPLACE_NV"/>
+        <enum value="0x8862" name="GL_COORD_REPLACE_OES"/>
+        <enum value="0x8863" name="GL_POINT_SPRITE_R_MODE_NV"/>
+        <enum value="0x8864" name="GL_PIXEL_COUNTER_BITS_NV"/>
+        <enum value="0x8864" name="GL_QUERY_COUNTER_BITS"/>
+        <enum value="0x8864" name="GL_QUERY_COUNTER_BITS_ARB"/>
+        <enum value="0x8864" name="GL_QUERY_COUNTER_BITS_EXT"/>
+        <enum value="0x8865" name="GL_CURRENT_OCCLUSION_QUERY_ID_NV"/>
+        <enum value="0x8865" name="GL_CURRENT_QUERY"/>
+        <enum value="0x8865" name="GL_CURRENT_QUERY_ARB"/>
+        <enum value="0x8865" name="GL_CURRENT_QUERY_EXT"/>
+        <enum value="0x8866" name="GL_PIXEL_COUNT_NV"/>
+        <enum value="0x8866" name="GL_QUERY_RESULT"/>
+        <enum value="0x8866" name="GL_QUERY_RESULT_ARB"/>
+        <enum value="0x8866" name="GL_QUERY_RESULT_EXT"/>
+        <enum value="0x8867" name="GL_PIXEL_COUNT_AVAILABLE_NV"/>
+        <enum value="0x8867" name="GL_QUERY_RESULT_AVAILABLE"/>
+        <enum value="0x8867" name="GL_QUERY_RESULT_AVAILABLE_ARB"/>
+        <enum value="0x8867" name="GL_QUERY_RESULT_AVAILABLE_EXT"/>
+        <enum value="0x8868" name="GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV"/>
+        <enum value="0x8869" name="GL_MAX_VERTEX_ATTRIBS"/>
+        <enum value="0x8869" name="GL_MAX_VERTEX_ATTRIBS_ARB"/>
+        <enum value="0x886A" name="GL_VERTEX_ATTRIB_ARRAY_NORMALIZED"/>
+        <enum value="0x886A" name="GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB"/>
+            <unused start="0x886B"/>
+        <enum value="0x886C" name="GL_MAX_TESS_CONTROL_INPUT_COMPONENTS"/>
+        <enum value="0x886C" name="GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT"/>               
+        <enum value="0x886D" name="GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS"/>
+        <enum value="0x886D" name="GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT"/>            
+        <enum value="0x886E" name="GL_DEPTH_STENCIL_TO_RGBA_NV"/>
+        <enum value="0x886F" name="GL_DEPTH_STENCIL_TO_BGRA_NV"/>
+        <enum value="0x8870" name="GL_FRAGMENT_PROGRAM_NV"/>
+        <enum value="0x8871" name="GL_MAX_TEXTURE_COORDS"/>
+        <enum value="0x8871" name="GL_MAX_TEXTURE_COORDS_ARB"/>
+        <enum value="0x8871" name="GL_MAX_TEXTURE_COORDS_NV"/>
+        <enum value="0x8872" name="GL_MAX_TEXTURE_IMAGE_UNITS"/>
+        <enum value="0x8872" name="GL_MAX_TEXTURE_IMAGE_UNITS_ARB"/>
+        <enum value="0x8872" name="GL_MAX_TEXTURE_IMAGE_UNITS_NV"/>
+        <enum value="0x8873" name="GL_FRAGMENT_PROGRAM_BINDING_NV"/>
+        <enum value="0x8874" name="GL_PROGRAM_ERROR_STRING_ARB"/>
+        <enum value="0x8874" name="GL_PROGRAM_ERROR_STRING_NV"/>
+        <enum value="0x8875" name="GL_PROGRAM_FORMAT_ASCII_ARB"/>
+        <enum value="0x8876" name="GL_PROGRAM_FORMAT_ARB"/>
+            <unused start="0x8877" comment="Should have been assigned to PROGRAM_BINDING_ARB"/>
+        <enum value="0x8878" name="GL_WRITE_PIXEL_DATA_RANGE_NV"/>
+        <enum value="0x8879" name="GL_READ_PIXEL_DATA_RANGE_NV"/>
+        <enum value="0x887A" name="GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV"/>
+        <enum value="0x887B" name="GL_READ_PIXEL_DATA_RANGE_LENGTH_NV"/>
+        <enum value="0x887C" name="GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV"/>
+        <enum value="0x887D" name="GL_READ_PIXEL_DATA_RANGE_POINTER_NV"/>
+            <unused start="0x887E"/>
+        <enum value="0x887F" name="GL_GEOMETRY_SHADER_INVOCATIONS"/>
+        <enum value="0x887F" name="GL_GEOMETRY_SHADER_INVOCATIONS_EXT"/>                     
+        <enum value="0x8880" name="GL_FLOAT_R_NV"/>
+        <enum value="0x8881" name="GL_FLOAT_RG_NV"/>
+        <enum value="0x8882" name="GL_FLOAT_RGB_NV"/>
+        <enum value="0x8883" name="GL_FLOAT_RGBA_NV"/>
+        <enum value="0x8884" name="GL_FLOAT_R16_NV"/>
+        <enum value="0x8885" name="GL_FLOAT_R32_NV"/>
+        <enum value="0x8886" name="GL_FLOAT_RG16_NV"/>
+        <enum value="0x8887" name="GL_FLOAT_RG32_NV"/>
+        <enum value="0x8888" name="GL_FLOAT_RGB16_NV"/>
+        <enum value="0x8889" name="GL_FLOAT_RGB32_NV"/>
+        <enum value="0x888A" name="GL_FLOAT_RGBA16_NV"/>
+        <enum value="0x888B" name="GL_FLOAT_RGBA32_NV"/>
+        <enum value="0x888C" name="GL_TEXTURE_FLOAT_COMPONENTS_NV"/>
+        <enum value="0x888D" name="GL_FLOAT_CLEAR_COLOR_VALUE_NV"/>
+        <enum value="0x888E" name="GL_FLOAT_RGBA_MODE_NV"/>
+        <enum value="0x888F" name="GL_TEXTURE_UNSIGNED_REMAP_MODE_NV"/>
+        <enum value="0x8890" name="GL_DEPTH_BOUNDS_TEST_EXT"/>
+        <enum value="0x8891" name="GL_DEPTH_BOUNDS_EXT"/>
+        <enum value="0x8892" name="GL_ARRAY_BUFFER"/>
+        <enum value="0x8892" name="GL_ARRAY_BUFFER_ARB"/>
+        <enum value="0x8893" name="GL_ELEMENT_ARRAY_BUFFER"/>
+        <enum value="0x8893" name="GL_ELEMENT_ARRAY_BUFFER_ARB"/>
+        <enum value="0x8894" name="GL_ARRAY_BUFFER_BINDING"/>
+        <enum value="0x8894" name="GL_ARRAY_BUFFER_BINDING_ARB"/>
+        <enum value="0x8895" name="GL_ELEMENT_ARRAY_BUFFER_BINDING"/>
+        <enum value="0x8895" name="GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB"/>
+        <enum value="0x8896" name="GL_VERTEX_ARRAY_BUFFER_BINDING"/>
+        <enum value="0x8896" name="GL_VERTEX_ARRAY_BUFFER_BINDING_ARB"/>
+        <enum value="0x8897" name="GL_NORMAL_ARRAY_BUFFER_BINDING"/>
+        <enum value="0x8897" name="GL_NORMAL_ARRAY_BUFFER_BINDING_ARB"/>
+        <enum value="0x8898" name="GL_COLOR_ARRAY_BUFFER_BINDING"/>
+        <enum value="0x8898" name="GL_COLOR_ARRAY_BUFFER_BINDING_ARB"/>
+        <enum value="0x8899" name="GL_INDEX_ARRAY_BUFFER_BINDING"/>
+        <enum value="0x8899" name="GL_INDEX_ARRAY_BUFFER_BINDING_ARB"/>
+        <enum value="0x889A" name="GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING"/>
+        <enum value="0x889A" name="GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB"/>
+        <enum value="0x889B" name="GL_EDGE_FLAG_ARRAY_BUFFER_BINDING"/>
+        <enum value="0x889B" name="GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB"/>
+        <enum value="0x889C" name="GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING"/>
+        <enum value="0x889C" name="GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB"/>
+        <enum value="0x889D" name="GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB"/>
+        <enum value="0x889D" name="GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING"/>
+        <enum value="0x889D" name="GL_FOG_COORD_ARRAY_BUFFER_BINDING" alias="GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING"/>
+        <enum value="0x889E" name="GL_WEIGHT_ARRAY_BUFFER_BINDING"/>
+        <enum value="0x889E" name="GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB"/>
+        <enum value="0x889E" name="GL_WEIGHT_ARRAY_BUFFER_BINDING_OES"/>
+        <enum value="0x889F" name="GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING"/>
+        <enum value="0x889F" name="GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB"/>
+        <enum value="0x88A0" name="GL_PROGRAM_INSTRUCTIONS_ARB"/>
+        <enum value="0x88A1" name="GL_MAX_PROGRAM_INSTRUCTIONS_ARB"/>
+        <enum value="0x88A2" name="GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB"/>
+        <enum value="0x88A3" name="GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB"/>
+        <enum value="0x88A4" name="GL_PROGRAM_TEMPORARIES_ARB"/>
+        <enum value="0x88A5" name="GL_MAX_PROGRAM_TEMPORARIES_ARB"/>
+        <enum value="0x88A6" name="GL_PROGRAM_NATIVE_TEMPORARIES_ARB"/>
+        <enum value="0x88A7" name="GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB"/>
+        <enum value="0x88A8" name="GL_PROGRAM_PARAMETERS_ARB"/>
+        <enum value="0x88A9" name="GL_MAX_PROGRAM_PARAMETERS_ARB"/>
+        <enum value="0x88AA" name="GL_PROGRAM_NATIVE_PARAMETERS_ARB"/>
+        <enum value="0x88AB" name="GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB"/>
+        <enum value="0x88AC" name="GL_PROGRAM_ATTRIBS_ARB"/>
+        <enum value="0x88AD" name="GL_MAX_PROGRAM_ATTRIBS_ARB"/>
+        <enum value="0x88AE" name="GL_PROGRAM_NATIVE_ATTRIBS_ARB"/>
+        <enum value="0x88AF" name="GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB"/>
+        <enum value="0x88B0" name="GL_PROGRAM_ADDRESS_REGISTERS_ARB"/>
+        <enum value="0x88B1" name="GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB"/>
+        <enum value="0x88B2" name="GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB"/>
+        <enum value="0x88B3" name="GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB"/>
+        <enum value="0x88B4" name="GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB"/>
+        <enum value="0x88B5" name="GL_MAX_PROGRAM_ENV_PARAMETERS_ARB"/>
+        <enum value="0x88B6" name="GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB"/>
+        <enum value="0x88B7" name="GL_TRANSPOSE_CURRENT_MATRIX_ARB"/>
+        <enum value="0x88B8" name="GL_READ_ONLY"/>
+        <enum value="0x88B8" name="GL_READ_ONLY_ARB"/>
+        <enum value="0x88B9" name="GL_WRITE_ONLY"/>
+        <enum value="0x88B9" name="GL_WRITE_ONLY_ARB"/>
+        <enum value="0x88B9" name="GL_WRITE_ONLY_OES"/>
+        <enum value="0x88BA" name="GL_READ_WRITE"/>
+        <enum value="0x88BA" name="GL_READ_WRITE_ARB"/>
+        <enum value="0x88BB" name="GL_BUFFER_ACCESS"/>
+        <enum value="0x88BB" name="GL_BUFFER_ACCESS_ARB"/>
+        <enum value="0x88BB" name="GL_BUFFER_ACCESS_OES"/>
+        <enum value="0x88BC" name="GL_BUFFER_MAPPED"/>
+        <enum value="0x88BC" name="GL_BUFFER_MAPPED_ARB"/>
+        <enum value="0x88BC" name="GL_BUFFER_MAPPED_OES"/>
+        <enum value="0x88BD" name="GL_BUFFER_MAP_POINTER"/>
+        <enum value="0x88BD" name="GL_BUFFER_MAP_POINTER_ARB"/>
+        <enum value="0x88BD" name="GL_BUFFER_MAP_POINTER_OES"/>
+        <enum value="0x88BE" name="GL_WRITE_DISCARD_NV"/>
+        <enum value="0x88BF" name="GL_TIME_ELAPSED"/>
+        <enum value="0x88BF" name="GL_TIME_ELAPSED_EXT"/>
+        <enum value="0x88C0" name="GL_MATRIX0_ARB"/>
+        <enum value="0x88C1" name="GL_MATRIX1_ARB"/>
+        <enum value="0x88C2" name="GL_MATRIX2_ARB"/>
+        <enum value="0x88C3" name="GL_MATRIX3_ARB"/>
+        <enum value="0x88C4" name="GL_MATRIX4_ARB"/>
+        <enum value="0x88C5" name="GL_MATRIX5_ARB"/>
+        <enum value="0x88C6" name="GL_MATRIX6_ARB"/>
+        <enum value="0x88C7" name="GL_MATRIX7_ARB"/>
+        <enum value="0x88C8" name="GL_MATRIX8_ARB"/>
+        <enum value="0x88C9" name="GL_MATRIX9_ARB"/>
+        <enum value="0x88CA" name="GL_MATRIX10_ARB"/>
+        <enum value="0x88CB" name="GL_MATRIX11_ARB"/>
+        <enum value="0x88CC" name="GL_MATRIX12_ARB"/>
+        <enum value="0x88CD" name="GL_MATRIX13_ARB"/>
+        <enum value="0x88CE" name="GL_MATRIX14_ARB"/>
+        <enum value="0x88CF" name="GL_MATRIX15_ARB"/>
+        <enum value="0x88D0" name="GL_MATRIX16_ARB"/>
+        <enum value="0x88D1" name="GL_MATRIX17_ARB"/>
+        <enum value="0x88D2" name="GL_MATRIX18_ARB"/>
+        <enum value="0x88D3" name="GL_MATRIX19_ARB"/>
+        <enum value="0x88D4" name="GL_MATRIX20_ARB"/>
+        <enum value="0x88D5" name="GL_MATRIX21_ARB"/>
+        <enum value="0x88D6" name="GL_MATRIX22_ARB"/>
+        <enum value="0x88D7" name="GL_MATRIX23_ARB"/>
+        <enum value="0x88D8" name="GL_MATRIX24_ARB"/>
+        <enum value="0x88D9" name="GL_MATRIX25_ARB"/>
+        <enum value="0x88DA" name="GL_MATRIX26_ARB"/>
+        <enum value="0x88DB" name="GL_MATRIX27_ARB"/>
+        <enum value="0x88DC" name="GL_MATRIX28_ARB"/>
+        <enum value="0x88DD" name="GL_MATRIX29_ARB"/>
+        <enum value="0x88DE" name="GL_MATRIX30_ARB"/>
+        <enum value="0x88DF" name="GL_MATRIX31_ARB"/>
+        <enum value="0x88E0" name="GL_STREAM_DRAW"/>
+        <enum value="0x88E0" name="GL_STREAM_DRAW_ARB"/>
+        <enum value="0x88E1" name="GL_STREAM_READ"/>
+        <enum value="0x88E1" name="GL_STREAM_READ_ARB"/>
+        <enum value="0x88E2" name="GL_STREAM_COPY"/>
+        <enum value="0x88E2" name="GL_STREAM_COPY_ARB"/>
+            <unused start="0x88E3" comment="To extend ARB_vbo"/>
+        <enum value="0x88E4" name="GL_STATIC_DRAW"/>
+        <enum value="0x88E4" name="GL_STATIC_DRAW_ARB"/>
+        <enum value="0x88E5" name="GL_STATIC_READ"/>
+        <enum value="0x88E5" name="GL_STATIC_READ_ARB"/>
+        <enum value="0x88E6" name="GL_STATIC_COPY"/>
+        <enum value="0x88E6" name="GL_STATIC_COPY_ARB"/>
+            <unused start="0x88E7" comment="To extend ARB_vbo"/>
+        <enum value="0x88E8" name="GL_DYNAMIC_DRAW"/>
+        <enum value="0x88E8" name="GL_DYNAMIC_DRAW_ARB"/>
+        <enum value="0x88E9" name="GL_DYNAMIC_READ"/>
+        <enum value="0x88E9" name="GL_DYNAMIC_READ_ARB"/>
+        <enum value="0x88EA" name="GL_DYNAMIC_COPY"/>
+        <enum value="0x88EA" name="GL_DYNAMIC_COPY_ARB"/>
+        <enum value="0x88EB" name="GL_PIXEL_PACK_BUFFER"/>
+        <enum value="0x88EB" name="GL_PIXEL_PACK_BUFFER_ARB"/>
+        <enum value="0x88EB" name="GL_PIXEL_PACK_BUFFER_EXT"/>
+        <enum value="0x88EC" name="GL_PIXEL_UNPACK_BUFFER"/>
+        <enum value="0x88EC" name="GL_PIXEL_UNPACK_BUFFER_ARB"/>
+        <enum value="0x88EC" name="GL_PIXEL_UNPACK_BUFFER_EXT"/>
+        <enum value="0x88ED" name="GL_PIXEL_PACK_BUFFER_BINDING"/>
+        <enum value="0x88ED" name="GL_PIXEL_PACK_BUFFER_BINDING_ARB"/>
+        <enum value="0x88ED" name="GL_PIXEL_PACK_BUFFER_BINDING_EXT"/>
+        <enum value="0x88EE" name="GL_ETC1_SRGB8_NV"/>
+        <enum value="0x88EF" name="GL_PIXEL_UNPACK_BUFFER_BINDING"/>
+        <enum value="0x88EF" name="GL_PIXEL_UNPACK_BUFFER_BINDING_ARB"/>
+        <enum value="0x88EF" name="GL_PIXEL_UNPACK_BUFFER_BINDING_EXT"/>
+        <enum value="0x88F0" name="GL_DEPTH24_STENCIL8"/>
+        <enum value="0x88F0" name="GL_DEPTH24_STENCIL8_EXT"/>
+        <enum value="0x88F0" name="GL_DEPTH24_STENCIL8_OES"/>
+        <enum value="0x88F1" name="GL_TEXTURE_STENCIL_SIZE"/>
+        <enum value="0x88F1" name="GL_TEXTURE_STENCIL_SIZE_EXT"/>
+        <enum value="0x88F2" name="GL_STENCIL_TAG_BITS_EXT"/>
+        <enum value="0x88F3" name="GL_STENCIL_CLEAR_TAG_VALUE_EXT"/>
+        <enum value="0x88F4" name="GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV"/>
+        <enum value="0x88F5" name="GL_MAX_PROGRAM_CALL_DEPTH_NV"/>
+        <enum value="0x88F6" name="GL_MAX_PROGRAM_IF_DEPTH_NV"/>
+        <enum value="0x88F7" name="GL_MAX_PROGRAM_LOOP_DEPTH_NV"/>
+        <enum value="0x88F8" name="GL_MAX_PROGRAM_LOOP_COUNT_NV"/>
+        <enum value="0x88F9" name="GL_SRC1_COLOR"/>
+        <enum value="0x88FA" name="GL_ONE_MINUS_SRC1_COLOR"/>
+        <enum value="0x88FB" name="GL_ONE_MINUS_SRC1_ALPHA"/>
+        <enum value="0x88FC" name="GL_MAX_DUAL_SOURCE_DRAW_BUFFERS"/>
+        <enum value="0x88FD" name="GL_VERTEX_ATTRIB_ARRAY_INTEGER"/>
+        <enum value="0x88FD" name="GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT"/>
+        <enum value="0x88FD" name="GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV"/>
+        <enum value="0x88FE" name="GL_VERTEX_ATTRIB_ARRAY_DIVISOR"/>
+        <enum value="0x88FE" name="GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE"/>
+        <enum value="0x88FE" name="GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB"/>
+        <enum value="0x88FE" name="GL_VERTEX_ATTRIB_ARRAY_DIVISOR_EXT"/>
+        <enum value="0x88FE" name="GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV"/>
+        <enum value="0x88FF" name="GL_MAX_ARRAY_TEXTURE_LAYERS"/>
+        <enum value="0x88FF" name="GL_MAX_ARRAY_TEXTURE_LAYERS_EXT"/>
+        <enum value="0x8904" name="GL_MIN_PROGRAM_TEXEL_OFFSET"/>
+        <enum value="0x8904" name="GL_MIN_PROGRAM_TEXEL_OFFSET_EXT"/>
+        <enum value="0x8904" name="GL_MIN_PROGRAM_TEXEL_OFFSET_NV"/>
+        <enum value="0x8905" name="GL_MAX_PROGRAM_TEXEL_OFFSET"/>
+        <enum value="0x8905" name="GL_MAX_PROGRAM_TEXEL_OFFSET_EXT"/>
+        <enum value="0x8905" name="GL_MAX_PROGRAM_TEXEL_OFFSET_NV"/>
+        <enum value="0x8906" name="GL_PROGRAM_ATTRIB_COMPONENTS_NV"/>
+        <enum value="0x8907" name="GL_PROGRAM_RESULT_COMPONENTS_NV"/>
+        <enum value="0x8908" name="GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV"/>
+        <enum value="0x8909" name="GL_MAX_PROGRAM_RESULT_COMPONENTS_NV"/>
+        <enum value="0x8910" name="GL_STENCIL_TEST_TWO_SIDE_EXT"/>
+        <enum value="0x8911" name="GL_ACTIVE_STENCIL_FACE_EXT"/>
+        <enum value="0x8912" name="GL_MIRROR_CLAMP_TO_BORDER_EXT"/>
+            <unused start="0x8913"/>
+        <enum value="0x8914" name="GL_SAMPLES_PASSED"/>
+        <enum value="0x8914" name="GL_SAMPLES_PASSED_ARB"/>
+            <unused start="0x8915"/>
+        <enum value="0x8916" name="GL_GEOMETRY_VERTICES_OUT"/>
+        <enum value="0x8916" name="GL_GEOMETRY_LINKED_VERTICES_OUT_EXT"/>                           
+        <enum value="0x8917" name="GL_GEOMETRY_INPUT_TYPE"/>
+        <enum value="0x8917" name="GL_GEOMETRY_LINKED_INPUT_TYPE_EXT"/>                             
+        <enum value="0x8918" name="GL_GEOMETRY_OUTPUT_TYPE"/>
+        <enum value="0x8918" name="GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT"/>                            
+        <enum value="0x8919" name="GL_SAMPLER_BINDING"/>
+        <enum value="0x891A" name="GL_CLAMP_VERTEX_COLOR"/>
+        <enum value="0x891A" name="GL_CLAMP_VERTEX_COLOR_ARB"/>
+        <enum value="0x891B" name="GL_CLAMP_FRAGMENT_COLOR"/>
+        <enum value="0x891B" name="GL_CLAMP_FRAGMENT_COLOR_ARB"/>
+        <enum value="0x891C" name="GL_CLAMP_READ_COLOR"/>
+        <enum value="0x891C" name="GL_CLAMP_READ_COLOR_ARB"/>
+        <enum value="0x891D" name="GL_FIXED_ONLY"/>
+        <enum value="0x891D" name="GL_FIXED_ONLY_ARB"/>
+        <enum value="0x891E" name="GL_TESS_CONTROL_PROGRAM_NV"/>
+        <enum value="0x891F" name="GL_TESS_EVALUATION_PROGRAM_NV"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8920" end="0x897F" vendor="AMD">
+        <enum value="0x8920" name="GL_FRAGMENT_SHADER_ATI"/>
+        <enum value="0x8921" name="GL_REG_0_ATI"/>
+        <enum value="0x8922" name="GL_REG_1_ATI"/>
+        <enum value="0x8923" name="GL_REG_2_ATI"/>
+        <enum value="0x8924" name="GL_REG_3_ATI"/>
+        <enum value="0x8925" name="GL_REG_4_ATI"/>
+        <enum value="0x8926" name="GL_REG_5_ATI"/>
+        <enum value="0x8927" name="GL_REG_6_ATI"/>
+        <enum value="0x8928" name="GL_REG_7_ATI"/>
+        <enum value="0x8929" name="GL_REG_8_ATI"/>
+        <enum value="0x892A" name="GL_REG_9_ATI"/>
+        <enum value="0x892B" name="GL_REG_10_ATI"/>
+        <enum value="0x892C" name="GL_REG_11_ATI"/>
+        <enum value="0x892D" name="GL_REG_12_ATI"/>
+        <enum value="0x892E" name="GL_REG_13_ATI"/>
+        <enum value="0x892F" name="GL_REG_14_ATI"/>
+        <enum value="0x8930" name="GL_REG_15_ATI"/>
+        <enum value="0x8931" name="GL_REG_16_ATI"/>
+        <enum value="0x8932" name="GL_REG_17_ATI"/>
+        <enum value="0x8933" name="GL_REG_18_ATI"/>
+        <enum value="0x8934" name="GL_REG_19_ATI"/>
+        <enum value="0x8935" name="GL_REG_20_ATI"/>
+        <enum value="0x8936" name="GL_REG_21_ATI"/>
+        <enum value="0x8937" name="GL_REG_22_ATI"/>
+        <enum value="0x8938" name="GL_REG_23_ATI"/>
+        <enum value="0x8939" name="GL_REG_24_ATI"/>
+        <enum value="0x893A" name="GL_REG_25_ATI"/>
+        <enum value="0x893B" name="GL_REG_26_ATI"/>
+        <enum value="0x893C" name="GL_REG_27_ATI"/>
+        <enum value="0x893D" name="GL_REG_28_ATI"/>
+        <enum value="0x893E" name="GL_REG_29_ATI"/>
+        <enum value="0x893F" name="GL_REG_30_ATI"/>
+        <enum value="0x8940" name="GL_REG_31_ATI"/>
+        <enum value="0x8941" name="GL_CON_0_ATI"/>
+        <enum value="0x8942" name="GL_CON_1_ATI"/>
+        <enum value="0x8943" name="GL_CON_2_ATI"/>
+        <enum value="0x8944" name="GL_CON_3_ATI"/>
+        <enum value="0x8945" name="GL_CON_4_ATI"/>
+        <enum value="0x8946" name="GL_CON_5_ATI"/>
+        <enum value="0x8947" name="GL_CON_6_ATI"/>
+        <enum value="0x8948" name="GL_CON_7_ATI"/>
+        <enum value="0x8949" name="GL_CON_8_ATI"/>
+        <enum value="0x894A" name="GL_CON_9_ATI"/>
+        <enum value="0x894B" name="GL_CON_10_ATI"/>
+        <enum value="0x894C" name="GL_CON_11_ATI"/>
+        <enum value="0x894D" name="GL_CON_12_ATI"/>
+        <enum value="0x894E" name="GL_CON_13_ATI"/>
+        <enum value="0x894F" name="GL_CON_14_ATI"/>
+        <enum value="0x8950" name="GL_CON_15_ATI"/>
+        <enum value="0x8951" name="GL_CON_16_ATI"/>
+        <enum value="0x8952" name="GL_CON_17_ATI"/>
+        <enum value="0x8953" name="GL_CON_18_ATI"/>
+        <enum value="0x8954" name="GL_CON_19_ATI"/>
+        <enum value="0x8955" name="GL_CON_20_ATI"/>
+        <enum value="0x8956" name="GL_CON_21_ATI"/>
+        <enum value="0x8957" name="GL_CON_22_ATI"/>
+        <enum value="0x8958" name="GL_CON_23_ATI"/>
+        <enum value="0x8959" name="GL_CON_24_ATI"/>
+        <enum value="0x895A" name="GL_CON_25_ATI"/>
+        <enum value="0x895B" name="GL_CON_26_ATI"/>
+        <enum value="0x895C" name="GL_CON_27_ATI"/>
+        <enum value="0x895D" name="GL_CON_28_ATI"/>
+        <enum value="0x895E" name="GL_CON_29_ATI"/>
+        <enum value="0x895F" name="GL_CON_30_ATI"/>
+        <enum value="0x8960" name="GL_CON_31_ATI"/>
+        <enum value="0x8961" name="GL_MOV_ATI"/>
+        <enum value="0x8963" name="GL_ADD_ATI"/>
+        <enum value="0x8964" name="GL_MUL_ATI"/>
+        <enum value="0x8965" name="GL_SUB_ATI"/>
+        <enum value="0x8966" name="GL_DOT3_ATI"/>
+        <enum value="0x8967" name="GL_DOT4_ATI"/>
+        <enum value="0x8968" name="GL_MAD_ATI"/>
+        <enum value="0x8969" name="GL_LERP_ATI"/>
+        <enum value="0x896A" name="GL_CND_ATI"/>
+        <enum value="0x896B" name="GL_CND0_ATI"/>
+        <enum value="0x896C" name="GL_DOT2_ADD_ATI"/>
+        <enum value="0x896D" name="GL_SECONDARY_INTERPOLATOR_ATI"/>
+        <enum value="0x896E" name="GL_NUM_FRAGMENT_REGISTERS_ATI"/>
+        <enum value="0x896F" name="GL_NUM_FRAGMENT_CONSTANTS_ATI"/>
+        <enum value="0x8970" name="GL_NUM_PASSES_ATI"/>
+        <enum value="0x8971" name="GL_NUM_INSTRUCTIONS_PER_PASS_ATI"/>
+        <enum value="0x8972" name="GL_NUM_INSTRUCTIONS_TOTAL_ATI"/>
+        <enum value="0x8973" name="GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI"/>
+        <enum value="0x8974" name="GL_NUM_LOOPBACK_COMPONENTS_ATI"/>
+        <enum value="0x8975" name="GL_COLOR_ALPHA_PAIRING_ATI"/>
+        <enum value="0x8976" name="GL_SWIZZLE_STR_ATI"/>
+        <enum value="0x8977" name="GL_SWIZZLE_STQ_ATI"/>
+        <enum value="0x8978" name="GL_SWIZZLE_STR_DR_ATI"/>
+        <enum value="0x8979" name="GL_SWIZZLE_STQ_DQ_ATI"/>
+        <enum value="0x897A" name="GL_SWIZZLE_STRQ_ATI"/>
+        <enum value="0x897B" name="GL_SWIZZLE_STRQ_DQ_ATI"/>
+            <unused start="0x897C" end="0x897F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8980" end="0x898F" vendor="OML">
+        <enum value="0x8980" name="GL_INTERLACE_OML"/>
+        <enum value="0x8981" name="GL_INTERLACE_READ_OML"/>
+        <enum value="0x8982" name="GL_FORMAT_SUBSAMPLE_24_24_OML"/>
+        <enum value="0x8983" name="GL_FORMAT_SUBSAMPLE_244_244_OML"/>
+        <enum value="0x8984" name="GL_PACK_RESAMPLE_OML"/>
+        <enum value="0x8985" name="GL_UNPACK_RESAMPLE_OML"/>
+        <enum value="0x8986" name="GL_RESAMPLE_REPLICATE_OML"/>
+        <enum value="0x8987" name="GL_RESAMPLE_ZERO_FILL_OML"/>
+        <enum value="0x8988" name="GL_RESAMPLE_AVERAGE_OML"/>
+        <enum value="0x8989" name="GL_RESAMPLE_DECIMATE_OML"/>
+        <enum value="0x898A" name="GL_POINT_SIZE_ARRAY_TYPE_OES"/>
+        <enum value="0x898B" name="GL_POINT_SIZE_ARRAY_STRIDE_OES"/>
+        <enum value="0x898C" name="GL_POINT_SIZE_ARRAY_POINTER_OES"/>
+        <enum value="0x898D" name="GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES"/>
+        <enum value="0x898E" name="GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES"/>
+        <enum value="0x898F" name="GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8990" end="0x899F" vendor="ZiiLabs"/>
+
+    <enums namespace="GL" start="0x89A0" end="0x89FF" vendor="Matrox"/>
+
+    <enums namespace="GL" start="0x8A00" end="0x8A7F" vendor="APPLE">
+        <enum value="0x8A00" name="GL_VERTEX_ATTRIB_MAP1_APPLE"/>
+        <enum value="0x8A01" name="GL_VERTEX_ATTRIB_MAP2_APPLE"/>
+        <enum value="0x8A02" name="GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE"/>
+        <enum value="0x8A03" name="GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE"/>
+        <enum value="0x8A04" name="GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE"/>
+        <enum value="0x8A05" name="GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE"/>
+        <enum value="0x8A06" name="GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE"/>
+        <enum value="0x8A07" name="GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE"/>
+        <enum value="0x8A08" name="GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE"/>
+        <enum value="0x8A09" name="GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE"/>
+        <enum value="0x8A0A" name="GL_DRAW_PIXELS_APPLE"/>
+        <enum value="0x8A0B" name="GL_FENCE_APPLE"/>
+        <enum value="0x8A0C" name="GL_ELEMENT_ARRAY_APPLE"/>
+        <enum value="0x8A0D" name="GL_ELEMENT_ARRAY_TYPE_APPLE"/>
+        <enum value="0x8A0E" name="GL_ELEMENT_ARRAY_POINTER_APPLE"/>
+        <enum value="0x8A0F" name="GL_COLOR_FLOAT_APPLE"/>
+            <unused start="0x8A10" comment="Unknown extension (Khronos bug 632)"/>
+            <!-- <enum value="0x8A10" name="GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE"/> -->
+        <enum value="0x8A11" name="GL_UNIFORM_BUFFER"/>
+        <enum value="0x8A12" name="GL_BUFFER_SERIALIZED_MODIFY_APPLE"/>
+        <enum value="0x8A13" name="GL_BUFFER_FLUSHING_UNMAP_APPLE"/>
+        <enum value="0x8A14" name="GL_AUX_DEPTH_STENCIL_APPLE"/>
+        <enum value="0x8A15" name="GL_PACK_ROW_BYTES_APPLE"/>
+        <enum value="0x8A16" name="GL_UNPACK_ROW_BYTES_APPLE"/>
+            <unused start="0x8A17" end="0x8A18"/>
+        <enum value="0x8A19" name="GL_RELEASED_APPLE"/>
+        <enum value="0x8A1A" name="GL_VOLATILE_APPLE"/>
+        <enum value="0x8A1B" name="GL_RETAINED_APPLE"/>
+        <enum value="0x8A1C" name="GL_UNDEFINED_APPLE"/>
+        <enum value="0x8A1D" name="GL_PURGEABLE_APPLE"/>
+            <unused start="0x8A1E"/>
+        <enum value="0x8A1F" name="GL_RGB_422_APPLE"/>
+            <unused start="0x8A20" end="0x8A27"/>
+        <enum value="0x8A28" name="GL_UNIFORM_BUFFER_BINDING"/>
+        <enum value="0x8A29" name="GL_UNIFORM_BUFFER_START"/>
+        <enum value="0x8A2A" name="GL_UNIFORM_BUFFER_SIZE"/>
+        <enum value="0x8A2B" name="GL_MAX_VERTEX_UNIFORM_BLOCKS"/>
+        <enum value="0x8A2C" name="GL_MAX_GEOMETRY_UNIFORM_BLOCKS"/>
+        <enum value="0x8A2C" name="GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT"/>                     
+        <enum value="0x8A2D" name="GL_MAX_FRAGMENT_UNIFORM_BLOCKS"/>
+        <enum value="0x8A2E" name="GL_MAX_COMBINED_UNIFORM_BLOCKS"/>
+        <enum value="0x8A2F" name="GL_MAX_UNIFORM_BUFFER_BINDINGS"/>
+        <enum value="0x8A30" name="GL_MAX_UNIFORM_BLOCK_SIZE"/>
+        <enum value="0x8A31" name="GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS"/>
+        <enum value="0x8A32" name="GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS"/>
+        <enum value="0x8A32" name="GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT"/>
+        <enum value="0x8A33" name="GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS"/>
+        <enum value="0x8A34" name="GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT"/>
+        <enum value="0x8A35" name="GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH"/>
+        <enum value="0x8A36" name="GL_ACTIVE_UNIFORM_BLOCKS"/>
+        <enum value="0x8A37" name="GL_UNIFORM_TYPE"/>
+        <enum value="0x8A38" name="GL_UNIFORM_SIZE"/>
+        <enum value="0x8A39" name="GL_UNIFORM_NAME_LENGTH"/>
+        <enum value="0x8A3A" name="GL_UNIFORM_BLOCK_INDEX"/>
+        <enum value="0x8A3B" name="GL_UNIFORM_OFFSET"/>
+        <enum value="0x8A3C" name="GL_UNIFORM_ARRAY_STRIDE"/>
+        <enum value="0x8A3D" name="GL_UNIFORM_MATRIX_STRIDE"/>
+        <enum value="0x8A3E" name="GL_UNIFORM_IS_ROW_MAJOR"/>
+        <enum value="0x8A3F" name="GL_UNIFORM_BLOCK_BINDING"/>
+        <enum value="0x8A40" name="GL_UNIFORM_BLOCK_DATA_SIZE"/>
+        <enum value="0x8A41" name="GL_UNIFORM_BLOCK_NAME_LENGTH"/>
+        <enum value="0x8A42" name="GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS"/>
+        <enum value="0x8A43" name="GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"/>
+        <enum value="0x8A44" name="GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER"/>
+        <enum value="0x8A45" name="GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER"/>
+        <enum value="0x8A46" name="GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER"/>
+            <unused start="0x8A47"/>
+        <enum value="0x8A48" name="GL_TEXTURE_SRGB_DECODE_EXT"/>
+        <enum value="0x8A49" name="GL_DECODE_EXT"/>
+        <enum value="0x8A4A" name="GL_SKIP_DECODE_EXT"/>
+            <unused start="0x8A4B" end="0x8A4E"/>
+        <enum value="0x8A4F" name="GL_PROGRAM_PIPELINE_OBJECT_EXT"/>
+            <unused start="0x8A50"/>
+        <enum value="0x8A51" name="GL_RGB_RAW_422_APPLE"/>
+        <enum value="0x8A52" name="GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT"/>
+        <enum value="0x8A53" name="GL_SYNC_OBJECT_APPLE"/>
+        <enum value="0x8A54" name="GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT"/>
+        <enum value="0x8A55" name="GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT"/>
+        <enum value="0x8A56" name="GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT"/>
+        <enum value="0x8A57" name="GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT"/>
+            <unused start="0x8A58" end="0x8A7F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8A80" end="0x8AEF" vendor="Matrox"/>
+
+    <enums namespace="GL" start="0x8AF0" end="0x8B2F" vendor="Chromium" comment="For Brian Paul"/>
+
+    <enums namespace="GL" start="0x8B30" end="0x8B3F" group="ShaderType" vendor="ARB">
+        <enum value="0x8B30" name="GL_FRAGMENT_SHADER"/>
+        <enum value="0x8B30" name="GL_FRAGMENT_SHADER_ARB"/>
+        <enum value="0x8B31" name="GL_VERTEX_SHADER"/>
+        <enum value="0x8B31" name="GL_VERTEX_SHADER_ARB"/>
+            <unused start="0x8B32" end="0x8B3F" comment="For shader types"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8B40" end="0x8B47" group="ContainerType" vendor="ARB">
+        <enum value="0x8B40" name="GL_PROGRAM_OBJECT_ARB"/>
+        <enum value="0x8B40" name="GL_PROGRAM_OBJECT_EXT"/>
+            <unused start="0x8B41" end="0x8B47" comment="For container types"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8B48" end="0x8B4F" vendor="ARB">
+        <enum value="0x8B48" name="GL_SHADER_OBJECT_ARB"/>
+        <enum value="0x8B48" name="GL_SHADER_OBJECT_EXT"/>
+        <enum value="0x8B49" name="GL_MAX_FRAGMENT_UNIFORM_COMPONENTS"/>
+        <enum value="0x8B49" name="GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB"/>
+        <enum value="0x8B4A" name="GL_MAX_VERTEX_UNIFORM_COMPONENTS"/>
+        <enum value="0x8B4A" name="GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB"/>
+        <enum value="0x8B4B" name="GL_MAX_VARYING_FLOATS"/>
+        <enum value="0x8B4B" name="GL_MAX_VARYING_COMPONENTS" alias="MAX_VARYING_FLOATS"/>
+        <enum value="0x8B4B" name="GL_MAX_VARYING_COMPONENTS_EXT"/>
+        <enum value="0x8B4B" name="GL_MAX_VARYING_FLOATS_ARB"/>
+        <enum value="0x8B4C" name="GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS"/>
+        <enum value="0x8B4C" name="GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB"/>
+        <enum value="0x8B4D" name="GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS"/>
+        <enum value="0x8B4D" name="GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB"/>
+        <enum value="0x8B4E" name="GL_OBJECT_TYPE_ARB"/>
+        <enum value="0x8B4F" name="GL_SHADER_TYPE"/>
+        <enum value="0x8B4F" name="GL_OBJECT_SUBTYPE_ARB"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8B50" end="0x8B7F" group="AttributeType" vendor="ARB">
+        <enum value="0x8B50" name="GL_FLOAT_VEC2"/>
+        <enum value="0x8B50" name="GL_FLOAT_VEC2_ARB"/>
+        <enum value="0x8B51" name="GL_FLOAT_VEC3"/>
+        <enum value="0x8B51" name="GL_FLOAT_VEC3_ARB"/>
+        <enum value="0x8B52" name="GL_FLOAT_VEC4"/>
+        <enum value="0x8B52" name="GL_FLOAT_VEC4_ARB"/>
+        <enum value="0x8B53" name="GL_INT_VEC2"/>
+        <enum value="0x8B53" name="GL_INT_VEC2_ARB"/>
+        <enum value="0x8B54" name="GL_INT_VEC3"/>
+        <enum value="0x8B54" name="GL_INT_VEC3_ARB"/>
+        <enum value="0x8B55" name="GL_INT_VEC4"/>
+        <enum value="0x8B55" name="GL_INT_VEC4_ARB"/>
+        <enum value="0x8B56" name="GL_BOOL"/>
+        <enum value="0x8B56" name="GL_BOOL_ARB"/>
+        <enum value="0x8B57" name="GL_BOOL_VEC2"/>
+        <enum value="0x8B57" name="GL_BOOL_VEC2_ARB"/>
+        <enum value="0x8B58" name="GL_BOOL_VEC3"/>
+        <enum value="0x8B58" name="GL_BOOL_VEC3_ARB"/>
+        <enum value="0x8B59" name="GL_BOOL_VEC4"/>
+        <enum value="0x8B59" name="GL_BOOL_VEC4_ARB"/>
+        <enum value="0x8B5A" name="GL_FLOAT_MAT2"/>
+        <enum value="0x8B5A" name="GL_FLOAT_MAT2_ARB"/>
+        <enum value="0x8B5B" name="GL_FLOAT_MAT3"/>
+        <enum value="0x8B5B" name="GL_FLOAT_MAT3_ARB"/>
+        <enum value="0x8B5C" name="GL_FLOAT_MAT4"/>
+        <enum value="0x8B5C" name="GL_FLOAT_MAT4_ARB"/>
+        <enum value="0x8B5D" name="GL_SAMPLER_1D"/>
+        <enum value="0x8B5D" name="GL_SAMPLER_1D_ARB"/>
+        <enum value="0x8B5E" name="GL_SAMPLER_2D"/>
+        <enum value="0x8B5E" name="GL_SAMPLER_2D_ARB"/>
+        <enum value="0x8B5F" name="GL_SAMPLER_3D"/>
+        <enum value="0x8B5F" name="GL_SAMPLER_3D_ARB"/>
+        <enum value="0x8B5F" name="GL_SAMPLER_3D_OES"/>
+        <enum value="0x8B60" name="GL_SAMPLER_CUBE"/>
+        <enum value="0x8B60" name="GL_SAMPLER_CUBE_ARB"/>
+        <enum value="0x8B61" name="GL_SAMPLER_1D_SHADOW"/>
+        <enum value="0x8B61" name="GL_SAMPLER_1D_SHADOW_ARB"/>
+        <enum value="0x8B62" name="GL_SAMPLER_2D_SHADOW"/>
+        <enum value="0x8B62" name="GL_SAMPLER_2D_SHADOW_ARB"/>
+        <enum value="0x8B62" name="GL_SAMPLER_2D_SHADOW_EXT"/>
+        <enum value="0x8B63" name="GL_SAMPLER_2D_RECT"/>
+        <enum value="0x8B63" name="GL_SAMPLER_2D_RECT_ARB"/>
+        <enum value="0x8B64" name="GL_SAMPLER_2D_RECT_SHADOW"/>
+        <enum value="0x8B64" name="GL_SAMPLER_2D_RECT_SHADOW_ARB"/>
+        <enum value="0x8B65" name="GL_FLOAT_MAT2x3"/>
+        <enum value="0x8B65" name="GL_FLOAT_MAT2x3_NV"/>
+        <enum value="0x8B66" name="GL_FLOAT_MAT2x4"/>
+        <enum value="0x8B66" name="GL_FLOAT_MAT2x4_NV"/>
+        <enum value="0x8B67" name="GL_FLOAT_MAT3x2"/>
+        <enum value="0x8B67" name="GL_FLOAT_MAT3x2_NV"/>
+        <enum value="0x8B68" name="GL_FLOAT_MAT3x4"/>
+        <enum value="0x8B68" name="GL_FLOAT_MAT3x4_NV"/>
+        <enum value="0x8B69" name="GL_FLOAT_MAT4x2"/>
+        <enum value="0x8B69" name="GL_FLOAT_MAT4x2_NV"/>
+        <enum value="0x8B6A" name="GL_FLOAT_MAT4x3"/>
+        <enum value="0x8B6A" name="GL_FLOAT_MAT4x3_NV"/>
+            <unused start="0x8B6B" end="0x8B7F" comment="For attribute types"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8B80" end="0x8B8F" vendor="ARB">
+        <enum value="0x8B80" name="GL_DELETE_STATUS"/>
+        <enum value="0x8B80" name="GL_OBJECT_DELETE_STATUS_ARB"/>
+        <enum value="0x8B81" name="GL_COMPILE_STATUS"/>
+        <enum value="0x8B81" name="GL_OBJECT_COMPILE_STATUS_ARB"/>
+        <enum value="0x8B82" name="GL_LINK_STATUS"/>
+        <enum value="0x8B82" name="GL_OBJECT_LINK_STATUS_ARB"/>
+        <enum value="0x8B83" name="GL_VALIDATE_STATUS"/>
+        <enum value="0x8B83" name="GL_OBJECT_VALIDATE_STATUS_ARB"/>
+        <enum value="0x8B84" name="GL_INFO_LOG_LENGTH"/>
+        <enum value="0x8B84" name="GL_OBJECT_INFO_LOG_LENGTH_ARB"/>
+        <enum value="0x8B85" name="GL_ATTACHED_SHADERS"/>
+        <enum value="0x8B85" name="GL_OBJECT_ATTACHED_OBJECTS_ARB"/>
+        <enum value="0x8B86" name="GL_ACTIVE_UNIFORMS"/>
+        <enum value="0x8B86" name="GL_OBJECT_ACTIVE_UNIFORMS_ARB"/>
+        <enum value="0x8B87" name="GL_ACTIVE_UNIFORM_MAX_LENGTH"/>
+        <enum value="0x8B87" name="GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB"/>
+        <enum value="0x8B88" name="GL_SHADER_SOURCE_LENGTH"/>
+        <enum value="0x8B88" name="GL_OBJECT_SHADER_SOURCE_LENGTH_ARB"/>
+        <enum value="0x8B89" name="GL_ACTIVE_ATTRIBUTES"/>
+        <enum value="0x8B89" name="GL_OBJECT_ACTIVE_ATTRIBUTES_ARB"/>
+        <enum value="0x8B8A" name="GL_ACTIVE_ATTRIBUTE_MAX_LENGTH"/>
+        <enum value="0x8B8A" name="GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB"/>
+        <enum value="0x8B8B" name="GL_FRAGMENT_SHADER_DERIVATIVE_HINT"/>
+        <enum value="0x8B8B" name="GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB"/>
+        <enum value="0x8B8B" name="GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES"/>
+        <enum value="0x8B8C" name="GL_SHADING_LANGUAGE_VERSION"/>
+        <enum value="0x8B8C" name="GL_SHADING_LANGUAGE_VERSION_ARB"/>
+        <enum value="0x8B8D" name="GL_CURRENT_PROGRAM"/>
+        <enum value="0x8B8D" api="gl" name="GL_ACTIVE_PROGRAM_EXT" alias="GL_CURRENT_PROGRAM" comment="For the OpenGL version of EXT_separate_shader_objects"/>
+            <unused start="0x8B8E" end="0x8B8F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8B90" end="0x8B9F" vendor="OES">
+        <enum value="0x8B90" name="GL_PALETTE4_RGB8_OES"/>
+        <enum value="0x8B91" name="GL_PALETTE4_RGBA8_OES"/>
+        <enum value="0x8B92" name="GL_PALETTE4_R5_G6_B5_OES"/>
+        <enum value="0x8B93" name="GL_PALETTE4_RGBA4_OES"/>
+        <enum value="0x8B94" name="GL_PALETTE4_RGB5_A1_OES"/>
+        <enum value="0x8B95" name="GL_PALETTE8_RGB8_OES"/>
+        <enum value="0x8B96" name="GL_PALETTE8_RGBA8_OES"/>
+        <enum value="0x8B97" name="GL_PALETTE8_R5_G6_B5_OES"/>
+        <enum value="0x8B98" name="GL_PALETTE8_RGBA4_OES"/>
+        <enum value="0x8B99" name="GL_PALETTE8_RGB5_A1_OES"/>
+        <enum value="0x8B9A" name="GL_IMPLEMENTATION_COLOR_READ_TYPE"/>
+        <enum value="0x8B9A" name="GL_IMPLEMENTATION_COLOR_READ_TYPE_OES"/>
+        <enum value="0x8B9B" name="GL_IMPLEMENTATION_COLOR_READ_FORMAT"/>
+        <enum value="0x8B9B" name="GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES"/>
+        <enum value="0x8B9C" name="GL_POINT_SIZE_ARRAY_OES"/>
+        <enum value="0x8B9D" name="GL_TEXTURE_CROP_RECT_OES"/>
+        <enum value="0x8B9E" name="GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES"/>
+        <enum value="0x8B9F" name="GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8BA0" end="0x8BAF" vendor="Seaweed"/>
+
+    <enums namespace="GL" start="0x8BB0" end="0x8BBF" vendor="MESA">
+        <enum value="0x8BB0" name="GL_FRAGMENT_PROGRAM_POSITION_MESA"/>
+        <enum value="0x8BB1" name="GL_FRAGMENT_PROGRAM_CALLBACK_MESA"/>
+        <enum value="0x8BB2" name="GL_FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA"/>
+        <enum value="0x8BB3" name="GL_FRAGMENT_PROGRAM_CALLBACK_DATA_MESA"/>
+        <enum value="0x8BB4" name="GL_VERTEX_PROGRAM_POSITION_MESA"/>
+        <enum value="0x8BB5" name="GL_VERTEX_PROGRAM_CALLBACK_MESA"/>
+        <enum value="0x8BB6" name="GL_VERTEX_PROGRAM_CALLBACK_FUNC_MESA"/>
+        <enum value="0x8BB7" name="GL_VERTEX_PROGRAM_CALLBACK_DATA_MESA"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8BC0" end="0x8BFF" vendor="AMD">
+        <enum value="0x8BC0" name="GL_COUNTER_TYPE_AMD"/>
+        <enum value="0x8BC1" name="GL_COUNTER_RANGE_AMD"/>
+        <enum value="0x8BC2" name="GL_UNSIGNED_INT64_AMD"/>
+        <enum value="0x8BC3" name="GL_PERCENTAGE_AMD"/>
+        <enum value="0x8BC4" name="GL_PERFMON_RESULT_AVAILABLE_AMD"/>
+        <enum value="0x8BC5" name="GL_PERFMON_RESULT_SIZE_AMD"/>
+        <enum value="0x8BC6" name="GL_PERFMON_RESULT_AMD"/>
+            <unused start="0x8BC7" end="0x8BD1"/>
+        <enum value="0x8BD2" name="GL_TEXTURE_WIDTH_QCOM"/>
+        <enum value="0x8BD3" name="GL_TEXTURE_HEIGHT_QCOM"/>
+        <enum value="0x8BD4" name="GL_TEXTURE_DEPTH_QCOM"/>
+        <enum value="0x8BD5" name="GL_TEXTURE_INTERNAL_FORMAT_QCOM"/>
+        <enum value="0x8BD6" name="GL_TEXTURE_FORMAT_QCOM"/>
+        <enum value="0x8BD7" name="GL_TEXTURE_TYPE_QCOM"/>
+        <enum value="0x8BD8" name="GL_TEXTURE_IMAGE_VALID_QCOM"/>
+        <enum value="0x8BD9" name="GL_TEXTURE_NUM_LEVELS_QCOM"/>
+        <enum value="0x8BDA" name="GL_TEXTURE_TARGET_QCOM"/>
+        <enum value="0x8BDB" name="GL_TEXTURE_OBJECT_VALID_QCOM"/>
+        <enum value="0x8BDC" name="GL_STATE_RESTORE"/>
+            <unused start="0x8BDD" end="0x8BFF"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8C00" end="0x8C0F" vendor="IMG">
+        <enum value="0x8C00" name="GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG"/>
+        <enum value="0x8C01" name="GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG"/>
+        <enum value="0x8C02" name="GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG"/>
+        <enum value="0x8C03" name="GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG"/>
+        <enum value="0x8C04" name="GL_MODULATE_COLOR_IMG"/>
+        <enum value="0x8C05" name="GL_RECIP_ADD_SIGNED_ALPHA_IMG"/>
+        <enum value="0x8C06" name="GL_TEXTURE_ALPHA_MODULATE_IMG"/>
+        <enum value="0x8C07" name="GL_FACTOR_ALPHA_MODULATE_IMG"/>
+        <enum value="0x8C08" name="GL_FRAGMENT_ALPHA_MODULATE_IMG"/>
+        <enum value="0x8C09" name="GL_ADD_BLEND_IMG"/>
+        <enum value="0x8C0A" name="GL_SGX_BINARY_IMG"/>
+            <unused start="0x8C0B" end="0x8C0F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8C10" end="0x8C8F" vendor="NV" comment="For Pat Brown">
+        <enum value="0x8C10" name="GL_TEXTURE_RED_TYPE"/>
+        <enum value="0x8C10" name="GL_TEXTURE_RED_TYPE_ARB"/>
+        <enum value="0x8C11" name="GL_TEXTURE_GREEN_TYPE"/>
+        <enum value="0x8C11" name="GL_TEXTURE_GREEN_TYPE_ARB"/>
+        <enum value="0x8C12" name="GL_TEXTURE_BLUE_TYPE"/>
+        <enum value="0x8C12" name="GL_TEXTURE_BLUE_TYPE_ARB"/>
+        <enum value="0x8C13" name="GL_TEXTURE_ALPHA_TYPE"/>
+        <enum value="0x8C13" name="GL_TEXTURE_ALPHA_TYPE_ARB"/>
+        <enum value="0x8C14" name="GL_TEXTURE_LUMINANCE_TYPE"/>
+        <enum value="0x8C14" name="GL_TEXTURE_LUMINANCE_TYPE_ARB"/>
+        <enum value="0x8C15" name="GL_TEXTURE_INTENSITY_TYPE"/>
+        <enum value="0x8C15" name="GL_TEXTURE_INTENSITY_TYPE_ARB"/>
+        <enum value="0x8C16" name="GL_TEXTURE_DEPTH_TYPE"/>
+        <enum value="0x8C16" name="GL_TEXTURE_DEPTH_TYPE_ARB"/>
+        <enum value="0x8C17" name="GL_UNSIGNED_NORMALIZED"/>
+        <enum value="0x8C17" name="GL_UNSIGNED_NORMALIZED_ARB"/>
+        <enum value="0x8C17" name="GL_UNSIGNED_NORMALIZED_EXT"/>
+        <enum value="0x8C18" name="GL_TEXTURE_1D_ARRAY"/>
+        <enum value="0x8C18" name="GL_TEXTURE_1D_ARRAY_EXT"/>
+        <enum value="0x8C19" name="GL_PROXY_TEXTURE_1D_ARRAY"/>
+        <enum value="0x8C19" name="GL_PROXY_TEXTURE_1D_ARRAY_EXT"/>
+        <enum value="0x8C1A" name="GL_TEXTURE_2D_ARRAY"/>
+        <enum value="0x8C1A" name="GL_TEXTURE_2D_ARRAY_EXT"/>
+        <enum value="0x8C1B" name="GL_PROXY_TEXTURE_2D_ARRAY"/>
+        <enum value="0x8C1B" name="GL_PROXY_TEXTURE_2D_ARRAY_EXT"/>
+        <enum value="0x8C1C" name="GL_TEXTURE_BINDING_1D_ARRAY"/>
+        <enum value="0x8C1C" name="GL_TEXTURE_BINDING_1D_ARRAY_EXT"/>
+        <enum value="0x8C1D" name="GL_TEXTURE_BINDING_2D_ARRAY"/>
+        <enum value="0x8C1D" name="GL_TEXTURE_BINDING_2D_ARRAY_EXT"/>
+            <unused start="0x8C1E" end="0x8C25"/>
+        <enum value="0x8C26" name="GL_GEOMETRY_PROGRAM_NV"/>
+        <enum value="0x8C27" name="GL_MAX_PROGRAM_OUTPUT_VERTICES_NV"/>
+        <enum value="0x8C28" name="GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV"/>
+        <enum value="0x8C29" name="GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS"/>
+        <enum value="0x8C29" name="GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB"/>
+        <enum value="0x8C29" name="GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT"/>
+        <enum value="0x8C2A" name="GL_TEXTURE_BUFFER"/>
+        <enum value="0x8C2A" name="GL_TEXTURE_BUFFER_ARB"/>
+        <enum value="0x8C2A" name="GL_TEXTURE_BUFFER_EXT"/>
+        <enum value="0x8C2A" name="GL_TEXTURE_BUFFER_BINDING" comment="Equivalent to GL_TEXTURE_BUFFER_ARB query, but named more consistently"/>
+        <enum value="0x8C2A" name="GL_TEXTURE_BUFFER_BINDING_EXT"/>                          
+        <enum value="0x8C2B" name="GL_MAX_TEXTURE_BUFFER_SIZE"/>
+        <enum value="0x8C2B" name="GL_MAX_TEXTURE_BUFFER_SIZE_ARB"/>
+        <enum value="0x8C2B" name="GL_MAX_TEXTURE_BUFFER_SIZE_EXT"/>
+        <enum value="0x8C2C" name="GL_TEXTURE_BINDING_BUFFER"/>
+        <enum value="0x8C2C" name="GL_TEXTURE_BINDING_BUFFER_ARB"/>
+        <enum value="0x8C2C" name="GL_TEXTURE_BINDING_BUFFER_EXT"/>
+        <enum value="0x8C2D" name="GL_TEXTURE_BUFFER_DATA_STORE_BINDING"/>
+        <enum value="0x8C2D" name="GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB"/>
+        <enum value="0x8C2D" name="GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT"/>
+        <enum value="0x8C2E" name="GL_TEXTURE_BUFFER_FORMAT_ARB"/>
+        <enum value="0x8C2E" name="GL_TEXTURE_BUFFER_FORMAT_EXT"/>
+        <enum value="0x8C2F" name="GL_ANY_SAMPLES_PASSED"/>
+        <enum value="0x8C2F" name="GL_ANY_SAMPLES_PASSED_EXT"/>
+            <unused start="0x8C30" end="0x8C35"/>
+        <enum value="0x8C36" name="GL_SAMPLE_SHADING"/>
+        <enum value="0x8C36" name="GL_SAMPLE_SHADING_ARB"/>
+        <enum value="0x8C36" name="GL_SAMPLE_SHADING_OES"/>
+        <enum value="0x8C37" name="GL_MIN_SAMPLE_SHADING_VALUE"/>
+        <enum value="0x8C37" name="GL_MIN_SAMPLE_SHADING_VALUE_ARB"/>
+        <enum value="0x8C37" name="GL_MIN_SAMPLE_SHADING_VALUE_OES"/>
+            <unused start="0x8C38" end="0x8C39"/>
+        <enum value="0x8C3A" name="GL_R11F_G11F_B10F"/>
+        <enum value="0x8C3A" name="GL_R11F_G11F_B10F_EXT"/>
+        <enum value="0x8C3B" name="GL_UNSIGNED_INT_10F_11F_11F_REV"/>
+        <enum value="0x8C3B" name="GL_UNSIGNED_INT_10F_11F_11F_REV_EXT"/>
+        <enum value="0x8C3C" name="GL_RGBA_SIGNED_COMPONENTS_EXT"/>
+        <enum value="0x8C3D" name="GL_RGB9_E5"/>
+        <enum value="0x8C3D" name="GL_RGB9_E5_EXT"/>
+        <enum value="0x8C3E" name="GL_UNSIGNED_INT_5_9_9_9_REV"/>
+        <enum value="0x8C3E" name="GL_UNSIGNED_INT_5_9_9_9_REV_EXT"/>
+        <enum value="0x8C3F" name="GL_TEXTURE_SHARED_SIZE"/>
+        <enum value="0x8C3F" name="GL_TEXTURE_SHARED_SIZE_EXT"/>
+        <enum value="0x8C40" name="GL_SRGB"/>
+        <enum value="0x8C40" name="GL_SRGB_EXT"/>
+        <enum value="0x8C41" name="GL_SRGB8"/>
+        <enum value="0x8C41" name="GL_SRGB8_EXT"/>
+        <enum value="0x8C41" name="GL_SRGB8_NV"/>
+        <enum value="0x8C42" name="GL_SRGB_ALPHA"/>
+        <enum value="0x8C42" name="GL_SRGB_ALPHA_EXT"/>
+        <enum value="0x8C43" name="GL_SRGB8_ALPHA8"/>
+        <enum value="0x8C43" name="GL_SRGB8_ALPHA8_EXT"/>
+        <enum value="0x8C44" name="GL_SLUMINANCE_ALPHA"/>
+        <enum value="0x8C44" name="GL_SLUMINANCE_ALPHA_EXT"/>
+        <enum value="0x8C44" name="GL_SLUMINANCE_ALPHA_NV"/>
+        <enum value="0x8C45" name="GL_SLUMINANCE8_ALPHA8"/>
+        <enum value="0x8C45" name="GL_SLUMINANCE8_ALPHA8_EXT"/>
+        <enum value="0x8C45" name="GL_SLUMINANCE8_ALPHA8_NV"/>
+        <enum value="0x8C46" name="GL_SLUMINANCE"/>
+        <enum value="0x8C46" name="GL_SLUMINANCE_EXT"/>
+        <enum value="0x8C46" name="GL_SLUMINANCE_NV"/>
+        <enum value="0x8C47" name="GL_SLUMINANCE8"/>
+        <enum value="0x8C47" name="GL_SLUMINANCE8_EXT"/>
+        <enum value="0x8C47" name="GL_SLUMINANCE8_NV"/>
+        <enum value="0x8C48" name="GL_COMPRESSED_SRGB"/>
+        <enum value="0x8C48" name="GL_COMPRESSED_SRGB_EXT"/>
+        <enum value="0x8C49" name="GL_COMPRESSED_SRGB_ALPHA"/>
+        <enum value="0x8C49" name="GL_COMPRESSED_SRGB_ALPHA_EXT"/>
+        <enum value="0x8C4A" name="GL_COMPRESSED_SLUMINANCE"/>
+        <enum value="0x8C4A" name="GL_COMPRESSED_SLUMINANCE_EXT"/>
+        <enum value="0x8C4B" name="GL_COMPRESSED_SLUMINANCE_ALPHA"/>
+        <enum value="0x8C4B" name="GL_COMPRESSED_SLUMINANCE_ALPHA_EXT"/>
+        <enum value="0x8C4C" name="GL_COMPRESSED_SRGB_S3TC_DXT1_EXT"/>
+        <enum value="0x8C4C" name="GL_COMPRESSED_SRGB_S3TC_DXT1_NV"/>
+        <enum value="0x8C4D" name="GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT"/>
+        <enum value="0x8C4D" name="GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV"/>
+        <enum value="0x8C4E" name="GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT"/>
+        <enum value="0x8C4E" name="GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV"/>
+        <enum value="0x8C4F" name="GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT"/>
+        <enum value="0x8C4F" name="GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV"/>
+            <unused start="0x8C50" end="0x8C6F"/>
+        <enum value="0x8C70" name="GL_COMPRESSED_LUMINANCE_LATC1_EXT"/>
+        <enum value="0x8C71" name="GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT"/>
+        <enum value="0x8C72" name="GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT"/>
+        <enum value="0x8C73" name="GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT"/>
+        <enum value="0x8C74" name="GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV"/>
+        <enum value="0x8C75" name="GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV"/>
+        <enum value="0x8C76" name="GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH"/>
+        <enum value="0x8C76" name="GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT"/>
+        <enum value="0x8C77" name="GL_BACK_PRIMARY_COLOR_NV"/>
+        <enum value="0x8C78" name="GL_BACK_SECONDARY_COLOR_NV"/>
+        <enum value="0x8C79" name="GL_TEXTURE_COORD_NV"/>
+        <enum value="0x8C7A" name="GL_CLIP_DISTANCE_NV"/>
+        <enum value="0x8C7B" name="GL_VERTEX_ID_NV"/>
+        <enum value="0x8C7C" name="GL_PRIMITIVE_ID_NV"/>
+        <enum value="0x8C7D" name="GL_GENERIC_ATTRIB_NV"/>
+        <enum value="0x8C7E" name="GL_TRANSFORM_FEEDBACK_ATTRIBS_NV"/>
+        <enum value="0x8C7F" name="GL_TRANSFORM_FEEDBACK_BUFFER_MODE"/>
+        <enum value="0x8C7F" name="GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT"/>
+        <enum value="0x8C7F" name="GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV"/>
+        <enum value="0x8C80" name="GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS"/>
+        <enum value="0x8C80" name="GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT"/>
+        <enum value="0x8C80" name="GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV"/>
+        <enum value="0x8C81" name="GL_ACTIVE_VARYINGS_NV"/>
+        <enum value="0x8C82" name="GL_ACTIVE_VARYING_MAX_LENGTH_NV"/>
+        <enum value="0x8C83" name="GL_TRANSFORM_FEEDBACK_VARYINGS"/>
+        <enum value="0x8C83" name="GL_TRANSFORM_FEEDBACK_VARYINGS_EXT"/>
+        <enum value="0x8C83" name="GL_TRANSFORM_FEEDBACK_VARYINGS_NV"/>
+        <enum value="0x8C84" name="GL_TRANSFORM_FEEDBACK_BUFFER_START"/>
+        <enum value="0x8C84" name="GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT"/>
+        <enum value="0x8C84" name="GL_TRANSFORM_FEEDBACK_BUFFER_START_NV"/>
+        <enum value="0x8C85" name="GL_TRANSFORM_FEEDBACK_BUFFER_SIZE"/>
+        <enum value="0x8C85" name="GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT"/>
+        <enum value="0x8C85" name="GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV"/>
+        <enum value="0x8C86" name="GL_TRANSFORM_FEEDBACK_RECORD_NV"/>
+        <enum value="0x8C87" name="GL_PRIMITIVES_GENERATED"/>
+        <enum value="0x8C87" name="GL_PRIMITIVES_GENERATED_EXT"/>
+        <enum value="0x8C87" name="GL_PRIMITIVES_GENERATED_NV"/>
+        <enum value="0x8C88" name="GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN"/>
+        <enum value="0x8C88" name="GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT"/>
+        <enum value="0x8C88" name="GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV"/>
+        <enum value="0x8C89" name="GL_RASTERIZER_DISCARD"/>
+        <enum value="0x8C89" name="GL_RASTERIZER_DISCARD_EXT"/>
+        <enum value="0x8C89" name="GL_RASTERIZER_DISCARD_NV"/>
+        <enum value="0x8C8A" name="GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS"/>
+        <enum value="0x8C8A" name="GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT"/>
+        <enum value="0x8C8A" name="GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV"/>
+        <enum value="0x8C8B" name="GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS"/>
+        <enum value="0x8C8B" name="GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT"/>
+        <enum value="0x8C8B" name="GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV"/>
+        <enum value="0x8C8C" name="GL_INTERLEAVED_ATTRIBS"/>
+        <enum value="0x8C8C" name="GL_INTERLEAVED_ATTRIBS_EXT"/>
+        <enum value="0x8C8C" name="GL_INTERLEAVED_ATTRIBS_NV"/>
+        <enum value="0x8C8D" name="GL_SEPARATE_ATTRIBS"/>
+        <enum value="0x8C8D" name="GL_SEPARATE_ATTRIBS_EXT"/>
+        <enum value="0x8C8D" name="GL_SEPARATE_ATTRIBS_NV"/>
+        <enum value="0x8C8E" name="GL_TRANSFORM_FEEDBACK_BUFFER"/>
+        <enum value="0x8C8E" name="GL_TRANSFORM_FEEDBACK_BUFFER_EXT"/>
+        <enum value="0x8C8E" name="GL_TRANSFORM_FEEDBACK_BUFFER_NV"/>
+        <enum value="0x8C8F" name="GL_TRANSFORM_FEEDBACK_BUFFER_BINDING"/>
+        <enum value="0x8C8F" name="GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT"/>
+        <enum value="0x8C8F" name="GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8C90" end="0x8C9F" vendor="QCOM" comment="For Affie Munshi, OpenGL ES extensions">
+            <!-- Reassigned from ATI to QCOM at time of
+                 mobile/desktop split (bug 5874) -->
+            <unused start="0x8C90" end="0x8C91"/>
+        <enum value="0x8C92" name="GL_ATC_RGB_AMD"/>
+        <enum value="0x8C93" name="GL_ATC_RGBA_EXPLICIT_ALPHA_AMD"/>
+            <unused start="0x8C94" end="0x8C9F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8CA0" end="0x8CAF" vendor="ARB">
+        <enum value="0x8CA0" name="GL_POINT_SPRITE_COORD_ORIGIN"/>
+        <enum value="0x8CA1" name="GL_LOWER_LEFT"/>
+        <enum value="0x8CA2" name="GL_UPPER_LEFT"/>
+        <enum value="0x8CA3" name="GL_STENCIL_BACK_REF"/>
+        <enum value="0x8CA4" name="GL_STENCIL_BACK_VALUE_MASK"/>
+        <enum value="0x8CA5" name="GL_STENCIL_BACK_WRITEMASK"/>
+        <enum value="0x8CA6" name="GL_DRAW_FRAMEBUFFER_BINDING"/>
+        <enum value="0x8CA6" name="GL_DRAW_FRAMEBUFFER_BINDING_ANGLE"/>
+        <enum value="0x8CA6" name="GL_DRAW_FRAMEBUFFER_BINDING_APPLE"/>
+        <enum value="0x8CA6" name="GL_DRAW_FRAMEBUFFER_BINDING_EXT"/>
+        <enum value="0x8CA6" name="GL_DRAW_FRAMEBUFFER_BINDING_NV"/>
+        <enum value="0x8CA6" name="GL_FRAMEBUFFER_BINDING"/>
+        <enum value="0x8CA6" name="GL_FRAMEBUFFER_BINDING_ANGLE"/>
+        <enum value="0x8CA6" name="GL_FRAMEBUFFER_BINDING_EXT"/>
+        <enum value="0x8CA6" name="GL_FRAMEBUFFER_BINDING_OES"/>
+        <enum value="0x8CA7" name="GL_RENDERBUFFER_BINDING"/>
+        <enum value="0x8CA7" name="GL_RENDERBUFFER_BINDING_ANGLE"/>
+        <enum value="0x8CA7" name="GL_RENDERBUFFER_BINDING_EXT"/>
+        <enum value="0x8CA7" name="GL_RENDERBUFFER_BINDING_OES"/>
+        <enum value="0x8CA8" name="GL_READ_FRAMEBUFFER"/>
+        <enum value="0x8CA8" name="GL_READ_FRAMEBUFFER_ANGLE"/>
+        <enum value="0x8CA8" name="GL_READ_FRAMEBUFFER_APPLE"/>
+        <enum value="0x8CA8" name="GL_READ_FRAMEBUFFER_EXT"/>
+        <enum value="0x8CA8" name="GL_READ_FRAMEBUFFER_NV"/>
+        <enum value="0x8CA9" name="GL_DRAW_FRAMEBUFFER"/>
+        <enum value="0x8CA9" name="GL_DRAW_FRAMEBUFFER_ANGLE"/>
+        <enum value="0x8CA9" name="GL_DRAW_FRAMEBUFFER_APPLE"/>
+        <enum value="0x8CA9" name="GL_DRAW_FRAMEBUFFER_EXT"/>
+        <enum value="0x8CA9" name="GL_DRAW_FRAMEBUFFER_NV"/>
+        <enum value="0x8CAA" name="GL_READ_FRAMEBUFFER_BINDING"/>
+        <enum value="0x8CAA" name="GL_READ_FRAMEBUFFER_BINDING_ANGLE"/>
+        <enum value="0x8CAA" name="GL_READ_FRAMEBUFFER_BINDING_APPLE"/>
+        <enum value="0x8CAA" name="GL_READ_FRAMEBUFFER_BINDING_EXT"/>
+        <enum value="0x8CAA" name="GL_READ_FRAMEBUFFER_BINDING_NV"/>
+        <enum value="0x8CAB" name="GL_RENDERBUFFER_COVERAGE_SAMPLES_NV"/>
+        <enum value="0x8CAB" name="GL_RENDERBUFFER_SAMPLES"/>
+        <enum value="0x8CAB" name="GL_RENDERBUFFER_SAMPLES_ANGLE"/>
+        <enum value="0x8CAB" name="GL_RENDERBUFFER_SAMPLES_APPLE"/>
+        <enum value="0x8CAB" name="GL_RENDERBUFFER_SAMPLES_EXT"/>
+        <enum value="0x8CAB" name="GL_RENDERBUFFER_SAMPLES_NV"/>
+        <enum value="0x8CAC" name="GL_DEPTH_COMPONENT32F"/>
+        <enum value="0x8CAD" name="GL_DEPTH32F_STENCIL8"/>
+            <unused start="0x8CAE" end="0x8CAF"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8CB0" end="0x8CCF" vendor="ZiiLabs" comment="For Barthold Lichtenbelt 2004/12/1"/>
+
+    <enums namespace="GL" start="0x8CD0" end="0x8D5F" vendor="ARB" comment="Framebuffer object specification + headroom">
+        <enum value="0x8CD0" name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE"/>
+        <enum value="0x8CD0" name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT"/>
+        <enum value="0x8CD0" name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES"/>
+        <enum value="0x8CD1" name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME"/>
+        <enum value="0x8CD1" name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT"/>
+        <enum value="0x8CD1" name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES"/>
+        <enum value="0x8CD2" name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL"/>
+        <enum value="0x8CD2" name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT"/>
+        <enum value="0x8CD2" name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES"/>
+        <enum value="0x8CD3" name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE"/>
+        <enum value="0x8CD3" name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT"/>
+        <enum value="0x8CD3" name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES"/>
+        <enum value="0x8CD4" name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT"/>
+        <enum value="0x8CD4" name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES"/>
+        <enum value="0x8CD4" name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER"/>
+        <enum value="0x8CD4" name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT"/>
+        <enum value="0x8CD5" name="GL_FRAMEBUFFER_COMPLETE"/>
+        <enum value="0x8CD5" name="GL_FRAMEBUFFER_COMPLETE_EXT"/>
+        <enum value="0x8CD5" name="GL_FRAMEBUFFER_COMPLETE_OES"/>
+        <enum value="0x8CD6" name="GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"/>
+        <enum value="0x8CD6" name="GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT"/>
+        <enum value="0x8CD6" name="GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES"/>
+        <enum value="0x8CD7" name="GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"/>
+        <enum value="0x8CD7" name="GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT"/>
+        <enum value="0x8CD7" name="GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES"/>
+            <unused start="0x8CD8" comment="Removed 2005/09/26 in revision #117 of the FBO extension spec"/>
+            <!-- <enum value="0x8CD8" name="GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT"/> -->
+        <enum value="0x8CD9" name="GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS"/>
+        <enum value="0x8CD9" name="GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT"/>
+        <enum value="0x8CD9" name="GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES"/>
+        <enum value="0x8CDA" name="GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT"/>
+        <enum value="0x8CDA" name="GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES"/>
+        <enum value="0x8CDB" name="GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER"/>
+        <enum value="0x8CDB" name="GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT"/>
+        <enum value="0x8CDB" name="GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES"/>
+        <enum value="0x8CDC" name="GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER"/>
+        <enum value="0x8CDC" name="GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT"/>
+        <enum value="0x8CDC" name="GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES"/>
+        <enum value="0x8CDD" name="GL_FRAMEBUFFER_UNSUPPORTED"/>
+        <enum value="0x8CDD" name="GL_FRAMEBUFFER_UNSUPPORTED_EXT"/>
+        <enum value="0x8CDD" name="GL_FRAMEBUFFER_UNSUPPORTED_OES"/>
+            <unused start="0x8CDE" comment="Removed 2005/05/31 in revision #113 of the FBO extension spec"/>
+            <!-- <enum value="0x8CDE" name="GL_FRAMEBUFFER_STATUS_ERROR_EXT"/> -->
+        <enum value="0x8CDF" name="GL_MAX_COLOR_ATTACHMENTS"/>
+        <enum value="0x8CDF" name="GL_MAX_COLOR_ATTACHMENTS_EXT"/>
+        <enum value="0x8CDF" name="GL_MAX_COLOR_ATTACHMENTS_NV"/>
+        <enum value="0x8CE0" name="GL_COLOR_ATTACHMENT0"/>
+        <enum value="0x8CE0" name="GL_COLOR_ATTACHMENT0_EXT"/>
+        <enum value="0x8CE0" name="GL_COLOR_ATTACHMENT0_NV"/>
+        <enum value="0x8CE0" name="GL_COLOR_ATTACHMENT0_OES"/>
+        <enum value="0x8CE1" name="GL_COLOR_ATTACHMENT1"/>
+        <enum value="0x8CE1" name="GL_COLOR_ATTACHMENT1_EXT"/>
+        <enum value="0x8CE1" name="GL_COLOR_ATTACHMENT1_NV"/>
+        <enum value="0x8CE2" name="GL_COLOR_ATTACHMENT2"/>
+        <enum value="0x8CE2" name="GL_COLOR_ATTACHMENT2_EXT"/>
+        <enum value="0x8CE2" name="GL_COLOR_ATTACHMENT2_NV"/>
+        <enum value="0x8CE3" name="GL_COLOR_ATTACHMENT3"/>
+        <enum value="0x8CE3" name="GL_COLOR_ATTACHMENT3_EXT"/>
+        <enum value="0x8CE3" name="GL_COLOR_ATTACHMENT3_NV"/>
+        <enum value="0x8CE4" name="GL_COLOR_ATTACHMENT4"/>
+        <enum value="0x8CE4" name="GL_COLOR_ATTACHMENT4_EXT"/>
+        <enum value="0x8CE4" name="GL_COLOR_ATTACHMENT4_NV"/>
+        <enum value="0x8CE5" name="GL_COLOR_ATTACHMENT5"/>
+        <enum value="0x8CE5" name="GL_COLOR_ATTACHMENT5_EXT"/>
+        <enum value="0x8CE5" name="GL_COLOR_ATTACHMENT5_NV"/>
+        <enum value="0x8CE6" name="GL_COLOR_ATTACHMENT6"/>
+        <enum value="0x8CE6" name="GL_COLOR_ATTACHMENT6_EXT"/>
+        <enum value="0x8CE6" name="GL_COLOR_ATTACHMENT6_NV"/>
+        <enum value="0x8CE7" name="GL_COLOR_ATTACHMENT7"/>
+        <enum value="0x8CE7" name="GL_COLOR_ATTACHMENT7_EXT"/>
+        <enum value="0x8CE7" name="GL_COLOR_ATTACHMENT7_NV"/>
+        <enum value="0x8CE8" name="GL_COLOR_ATTACHMENT8"/>
+        <enum value="0x8CE8" name="GL_COLOR_ATTACHMENT8_EXT"/>
+        <enum value="0x8CE8" name="GL_COLOR_ATTACHMENT8_NV"/>
+        <enum value="0x8CE9" name="GL_COLOR_ATTACHMENT9"/>
+        <enum value="0x8CE9" name="GL_COLOR_ATTACHMENT9_EXT"/>
+        <enum value="0x8CE9" name="GL_COLOR_ATTACHMENT9_NV"/>
+        <enum value="0x8CEA" name="GL_COLOR_ATTACHMENT10"/>
+        <enum value="0x8CEA" name="GL_COLOR_ATTACHMENT10_EXT"/>
+        <enum value="0x8CEA" name="GL_COLOR_ATTACHMENT10_NV"/>
+        <enum value="0x8CEB" name="GL_COLOR_ATTACHMENT11"/>
+        <enum value="0x8CEB" name="GL_COLOR_ATTACHMENT11_EXT"/>
+        <enum value="0x8CEB" name="GL_COLOR_ATTACHMENT11_NV"/>
+        <enum value="0x8CEC" name="GL_COLOR_ATTACHMENT12"/>
+        <enum value="0x8CEC" name="GL_COLOR_ATTACHMENT12_EXT"/>
+        <enum value="0x8CEC" name="GL_COLOR_ATTACHMENT12_NV"/>
+        <enum value="0x8CED" name="GL_COLOR_ATTACHMENT13"/>
+        <enum value="0x8CED" name="GL_COLOR_ATTACHMENT13_EXT"/>
+        <enum value="0x8CED" name="GL_COLOR_ATTACHMENT13_NV"/>
+        <enum value="0x8CEE" name="GL_COLOR_ATTACHMENT14"/>
+        <enum value="0x8CEE" name="GL_COLOR_ATTACHMENT14_EXT"/>
+        <enum value="0x8CEE" name="GL_COLOR_ATTACHMENT14_NV"/>
+        <enum value="0x8CEF" name="GL_COLOR_ATTACHMENT15"/>
+        <enum value="0x8CEF" name="GL_COLOR_ATTACHMENT15_EXT"/>
+        <enum value="0x8CEF" name="GL_COLOR_ATTACHMENT15_NV"/>
+            <unused start="0x8CF0" end="0x8CFF" comment="For color attachments 16-31"/>
+        <enum value="0x8D00" name="GL_DEPTH_ATTACHMENT"/>
+        <enum value="0x8D00" name="GL_DEPTH_ATTACHMENT_EXT"/>
+        <enum value="0x8D00" name="GL_DEPTH_ATTACHMENT_OES"/>
+            <unused start="0x8D01" end="0x8D1F" comment="For depth attachments 16-31"/>
+        <enum value="0x8D20" name="GL_STENCIL_ATTACHMENT"/>
+        <enum value="0x8D20" name="GL_STENCIL_ATTACHMENT_EXT"/>
+        <enum value="0x8D20" name="GL_STENCIL_ATTACHMENT_OES"/>
+            <unused start="0x8D21" end="0x8D3F" comment="For stencil attachments 16-31"/>
+        <enum value="0x8D40" name="GL_FRAMEBUFFER"/>
+        <enum value="0x8D40" name="GL_FRAMEBUFFER_EXT"/>
+        <enum value="0x8D40" name="GL_FRAMEBUFFER_OES"/>
+        <enum value="0x8D41" name="GL_RENDERBUFFER"/>
+        <enum value="0x8D41" name="GL_RENDERBUFFER_EXT"/>
+        <enum value="0x8D41" name="GL_RENDERBUFFER_OES"/>
+        <enum value="0x8D42" name="GL_RENDERBUFFER_WIDTH"/>
+        <enum value="0x8D42" name="GL_RENDERBUFFER_WIDTH_EXT"/>
+        <enum value="0x8D42" name="GL_RENDERBUFFER_WIDTH_OES"/>
+        <enum value="0x8D43" name="GL_RENDERBUFFER_HEIGHT"/>
+        <enum value="0x8D43" name="GL_RENDERBUFFER_HEIGHT_EXT"/>
+        <enum value="0x8D43" name="GL_RENDERBUFFER_HEIGHT_OES"/>
+        <enum value="0x8D44" name="GL_RENDERBUFFER_INTERNAL_FORMAT"/>
+        <enum value="0x8D44" name="GL_RENDERBUFFER_INTERNAL_FORMAT_EXT"/>
+        <enum value="0x8D44" name="GL_RENDERBUFFER_INTERNAL_FORMAT_OES"/>
+            <unused start="0x8D45" comment="Was for GL_STENCIL_INDEX_EXT, but now use core STENCIL_INDEX instead"/>
+        <enum value="0x8D46" name="GL_STENCIL_INDEX1"/>
+        <enum value="0x8D46" name="GL_STENCIL_INDEX1_EXT"/>
+        <enum value="0x8D46" name="GL_STENCIL_INDEX1_OES"/>
+        <enum value="0x8D47" name="GL_STENCIL_INDEX4"/>
+        <enum value="0x8D47" name="GL_STENCIL_INDEX4_EXT"/>
+        <enum value="0x8D47" name="GL_STENCIL_INDEX4_OES"/>
+        <enum value="0x8D48" name="GL_STENCIL_INDEX8"/>
+        <enum value="0x8D48" name="GL_STENCIL_INDEX8_EXT"/>
+        <enum value="0x8D48" name="GL_STENCIL_INDEX8_OES"/>
+        <enum value="0x8D49" name="GL_STENCIL_INDEX16"/>
+        <enum value="0x8D49" name="GL_STENCIL_INDEX16_EXT"/>
+            <unused start="0x8D4A" end="0x8D4F" comment="For additional stencil formats"/>
+        <enum value="0x8D50" name="GL_RENDERBUFFER_RED_SIZE"/>
+        <enum value="0x8D50" name="GL_RENDERBUFFER_RED_SIZE_EXT"/>
+        <enum value="0x8D50" name="GL_RENDERBUFFER_RED_SIZE_OES"/>
+        <enum value="0x8D51" name="GL_RENDERBUFFER_GREEN_SIZE"/>
+        <enum value="0x8D51" name="GL_RENDERBUFFER_GREEN_SIZE_EXT"/>
+        <enum value="0x8D51" name="GL_RENDERBUFFER_GREEN_SIZE_OES"/>
+        <enum value="0x8D52" name="GL_RENDERBUFFER_BLUE_SIZE"/>
+        <enum value="0x8D52" name="GL_RENDERBUFFER_BLUE_SIZE_EXT"/>
+        <enum value="0x8D52" name="GL_RENDERBUFFER_BLUE_SIZE_OES"/>
+        <enum value="0x8D53" name="GL_RENDERBUFFER_ALPHA_SIZE"/>
+        <enum value="0x8D53" name="GL_RENDERBUFFER_ALPHA_SIZE_EXT"/>
+        <enum value="0x8D53" name="GL_RENDERBUFFER_ALPHA_SIZE_OES"/>
+        <enum value="0x8D54" name="GL_RENDERBUFFER_DEPTH_SIZE"/>
+        <enum value="0x8D54" name="GL_RENDERBUFFER_DEPTH_SIZE_EXT"/>
+        <enum value="0x8D54" name="GL_RENDERBUFFER_DEPTH_SIZE_OES"/>
+        <enum value="0x8D55" name="GL_RENDERBUFFER_STENCIL_SIZE"/>
+        <enum value="0x8D55" name="GL_RENDERBUFFER_STENCIL_SIZE_EXT"/>
+        <enum value="0x8D55" name="GL_RENDERBUFFER_STENCIL_SIZE_OES"/>
+        <enum value="0x8D56" name="GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"/>
+        <enum value="0x8D56" name="GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE"/>
+        <enum value="0x8D56" name="GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE"/>
+        <enum value="0x8D56" name="GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT"/>
+        <enum value="0x8D56" name="GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV"/>
+        <enum value="0x8D57" name="GL_MAX_SAMPLES"/>
+        <enum value="0x8D57" name="GL_MAX_SAMPLES_ANGLE"/>
+        <enum value="0x8D57" name="GL_MAX_SAMPLES_APPLE"/>
+        <enum value="0x8D57" name="GL_MAX_SAMPLES_EXT"/>
+        <enum value="0x8D57" name="GL_MAX_SAMPLES_NV"/>
+            <unused start="0x8D58" end="0x8D5F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8D60" end="0x8D6F" vendor="OES">
+        <enum value="0x8D60" name="GL_TEXTURE_GEN_STR_OES"/>
+        <enum value="0x8D61" name="GL_HALF_FLOAT_OES"/>
+        <enum value="0x8D62" name="GL_RGB565_OES"/>
+        <enum value="0x8D62" name="GL_RGB565"/>
+            <unused start="0x8D63" comment="Was GL_TEXTURE_IMMUTABLE_LEVELS in draft ES 3.0 spec"/>
+        <enum value="0x8D64" name="GL_ETC1_RGB8_OES"/>
+        <enum value="0x8D65" name="GL_TEXTURE_EXTERNAL_OES"/>
+        <enum value="0x8D66" name="GL_SAMPLER_EXTERNAL_OES"/>
+        <enum value="0x8D67" name="GL_TEXTURE_BINDING_EXTERNAL_OES"/>
+        <enum value="0x8D68" name="GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES"/>
+        <enum value="0x8D69" name="GL_PRIMITIVE_RESTART_FIXED_INDEX"/>
+        <enum value="0x8D6A" name="GL_ANY_SAMPLES_PASSED_CONSERVATIVE"/>
+        <enum value="0x8D6A" name="GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT"/>
+        <enum value="0x8D6B" name="GL_MAX_ELEMENT_INDEX"/>
+        <enum value="0x8D6C" name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT"/>
+            <unused start="0x8D6D" end="0x8D6F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8D70" end="0x8DEF" vendor="NV" comment="For Pat Brown 2005/10/13">
+        <enum value="0x8D70" name="GL_RGBA32UI"/>
+        <enum value="0x8D70" name="GL_RGBA32UI_EXT"/>
+        <enum value="0x8D71" name="GL_RGB32UI"/>
+        <enum value="0x8D71" name="GL_RGB32UI_EXT"/>
+        <enum value="0x8D72" name="GL_ALPHA32UI_EXT"/>
+        <enum value="0x8D73" name="GL_INTENSITY32UI_EXT"/>
+        <enum value="0x8D74" name="GL_LUMINANCE32UI_EXT"/>
+        <enum value="0x8D75" name="GL_LUMINANCE_ALPHA32UI_EXT"/>
+        <enum value="0x8D76" name="GL_RGBA16UI"/>
+        <enum value="0x8D76" name="GL_RGBA16UI_EXT"/>
+        <enum value="0x8D77" name="GL_RGB16UI"/>
+        <enum value="0x8D77" name="GL_RGB16UI_EXT"/>
+        <enum value="0x8D78" name="GL_ALPHA16UI_EXT"/>
+        <enum value="0x8D79" name="GL_INTENSITY16UI_EXT"/>
+        <enum value="0x8D7A" name="GL_LUMINANCE16UI_EXT"/>
+        <enum value="0x8D7B" name="GL_LUMINANCE_ALPHA16UI_EXT"/>
+        <enum value="0x8D7C" name="GL_RGBA8UI"/>
+        <enum value="0x8D7C" name="GL_RGBA8UI_EXT"/>
+        <enum value="0x8D7D" name="GL_RGB8UI"/>
+        <enum value="0x8D7D" name="GL_RGB8UI_EXT"/>
+        <enum value="0x8D7E" name="GL_ALPHA8UI_EXT"/>
+        <enum value="0x8D7F" name="GL_INTENSITY8UI_EXT"/>
+        <enum value="0x8D80" name="GL_LUMINANCE8UI_EXT"/>
+        <enum value="0x8D81" name="GL_LUMINANCE_ALPHA8UI_EXT"/>
+        <enum value="0x8D82" name="GL_RGBA32I"/>
+        <enum value="0x8D82" name="GL_RGBA32I_EXT"/>
+        <enum value="0x8D83" name="GL_RGB32I"/>
+        <enum value="0x8D83" name="GL_RGB32I_EXT"/>
+        <enum value="0x8D84" name="GL_ALPHA32I_EXT"/>
+        <enum value="0x8D85" name="GL_INTENSITY32I_EXT"/>
+        <enum value="0x8D86" name="GL_LUMINANCE32I_EXT"/>
+        <enum value="0x8D87" name="GL_LUMINANCE_ALPHA32I_EXT"/>
+        <enum value="0x8D88" name="GL_RGBA16I"/>
+        <enum value="0x8D88" name="GL_RGBA16I_EXT"/>
+        <enum value="0x8D89" name="GL_RGB16I"/>
+        <enum value="0x8D89" name="GL_RGB16I_EXT"/>
+        <enum value="0x8D8A" name="GL_ALPHA16I_EXT"/>
+        <enum value="0x8D8B" name="GL_INTENSITY16I_EXT"/>
+        <enum value="0x8D8C" name="GL_LUMINANCE16I_EXT"/>
+        <enum value="0x8D8D" name="GL_LUMINANCE_ALPHA16I_EXT"/>
+        <enum value="0x8D8E" name="GL_RGBA8I"/>
+        <enum value="0x8D8E" name="GL_RGBA8I_EXT"/>
+        <enum value="0x8D8F" name="GL_RGB8I"/>
+        <enum value="0x8D8F" name="GL_RGB8I_EXT"/>
+        <enum value="0x8D90" name="GL_ALPHA8I_EXT"/>
+        <enum value="0x8D91" name="GL_INTENSITY8I_EXT"/>
+        <enum value="0x8D92" name="GL_LUMINANCE8I_EXT"/>
+        <enum value="0x8D93" name="GL_LUMINANCE_ALPHA8I_EXT"/>
+        <enum value="0x8D94" name="GL_RED_INTEGER"/>
+        <enum value="0x8D94" name="GL_RED_INTEGER_EXT"/>
+        <enum value="0x8D95" name="GL_GREEN_INTEGER"/>
+        <enum value="0x8D95" name="GL_GREEN_INTEGER_EXT"/>
+        <enum value="0x8D96" name="GL_BLUE_INTEGER"/>
+        <enum value="0x8D96" name="GL_BLUE_INTEGER_EXT"/>
+        <enum value="0x8D97" name="GL_ALPHA_INTEGER"/>
+        <enum value="0x8D97" name="GL_ALPHA_INTEGER_EXT"/>
+        <enum value="0x8D98" name="GL_RGB_INTEGER"/>
+        <enum value="0x8D98" name="GL_RGB_INTEGER_EXT"/>
+        <enum value="0x8D99" name="GL_RGBA_INTEGER"/>
+        <enum value="0x8D99" name="GL_RGBA_INTEGER_EXT"/>
+        <enum value="0x8D9A" name="GL_BGR_INTEGER"/>
+        <enum value="0x8D9A" name="GL_BGR_INTEGER_EXT"/>
+        <enum value="0x8D9B" name="GL_BGRA_INTEGER"/>
+        <enum value="0x8D9B" name="GL_BGRA_INTEGER_EXT"/>
+        <enum value="0x8D9C" name="GL_LUMINANCE_INTEGER_EXT"/>
+        <enum value="0x8D9D" name="GL_LUMINANCE_ALPHA_INTEGER_EXT"/>
+        <enum value="0x8D9E" name="GL_RGBA_INTEGER_MODE_EXT"/>
+        <enum value="0x8D9F" name="GL_INT_2_10_10_10_REV"/>
+        <enum value="0x8DA0" name="GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV"/>
+        <enum value="0x8DA1" name="GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV"/>
+        <enum value="0x8DA2" name="GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV"/>
+        <enum value="0x8DA3" name="GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV"/>
+        <enum value="0x8DA4" name="GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV"/>
+        <enum value="0x8DA5" name="GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV"/>
+        <enum value="0x8DA6" name="GL_MAX_PROGRAM_GENERIC_RESULTS_NV"/>
+        <enum value="0x8DA7" name="GL_FRAMEBUFFER_ATTACHMENT_LAYERED"/>
+        <enum value="0x8DA7" name="GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB"/>
+        <enum value="0x8DA7" name="GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT"/>
+        <enum value="0x8DA8" name="GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS"/>
+        <enum value="0x8DA8" name="GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB"/>
+        <enum value="0x8DA8" name="GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT"/>
+        <enum value="0x8DA9" name="GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB"/>
+        <enum value="0x8DA9" name="GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT"/>
+            <!-- Also see the odd namespace "NVTransformFeedbackToken" above -->
+        <enum value="0x8DAA" name="GL_LAYER_NV"/>
+        <enum value="0x8DAB" name="GL_DEPTH_COMPONENT32F_NV"/>
+        <enum value="0x8DAC" name="GL_DEPTH32F_STENCIL8_NV"/>
+        <enum value="0x8DAD" name="GL_FLOAT_32_UNSIGNED_INT_24_8_REV"/>
+        <enum value="0x8DAD" name="GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV"/>
+        <enum value="0x8DAE" name="GL_SHADER_INCLUDE_ARB"/>
+        <enum value="0x8DAF" name="GL_DEPTH_BUFFER_FLOAT_MODE_NV"/>
+            <unused start="0x8DB0" end="0x8DB8"/>
+        <enum value="0x8DB9" name="GL_FRAMEBUFFER_SRGB"/>
+        <enum value="0x8DB9" name="GL_FRAMEBUFFER_SRGB_EXT"/>
+        <enum value="0x8DBA" name="GL_FRAMEBUFFER_SRGB_CAPABLE_EXT"/>
+        <enum value="0x8DBB" name="GL_COMPRESSED_RED_RGTC1"/>
+        <enum value="0x8DBB" name="GL_COMPRESSED_RED_RGTC1_EXT"/>
+        <enum value="0x8DBC" name="GL_COMPRESSED_SIGNED_RED_RGTC1"/>
+        <enum value="0x8DBC" name="GL_COMPRESSED_SIGNED_RED_RGTC1_EXT"/>
+        <enum value="0x8DBD" name="GL_COMPRESSED_RED_GREEN_RGTC2_EXT"/>
+        <enum value="0x8DBD" name="GL_COMPRESSED_RG_RGTC2"/>
+        <enum value="0x8DBE" name="GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT"/>
+        <enum value="0x8DBE" name="GL_COMPRESSED_SIGNED_RG_RGTC2"/>
+        <enum value="0x8DC0" name="GL_SAMPLER_1D_ARRAY"/>
+        <enum value="0x8DC0" name="GL_SAMPLER_1D_ARRAY_EXT"/>
+        <enum value="0x8DC1" name="GL_SAMPLER_2D_ARRAY"/>
+        <enum value="0x8DC1" name="GL_SAMPLER_2D_ARRAY_EXT"/>
+        <enum value="0x8DC2" name="GL_SAMPLER_BUFFER"/>
+        <enum value="0x8DC2" name="GL_SAMPLER_BUFFER_EXT"/>
+        <enum value="0x8DC3" name="GL_SAMPLER_1D_ARRAY_SHADOW"/>
+        <enum value="0x8DC3" name="GL_SAMPLER_1D_ARRAY_SHADOW_EXT"/>
+        <enum value="0x8DC4" name="GL_SAMPLER_2D_ARRAY_SHADOW"/>
+        <enum value="0x8DC4" name="GL_SAMPLER_2D_ARRAY_SHADOW_EXT"/>
+        <enum value="0x8DC4" name="GL_SAMPLER_2D_ARRAY_SHADOW_NV"/>
+        <enum value="0x8DC5" name="GL_SAMPLER_CUBE_SHADOW"/>
+        <enum value="0x8DC5" name="GL_SAMPLER_CUBE_SHADOW_EXT"/>
+        <enum value="0x8DC5" name="GL_SAMPLER_CUBE_SHADOW_NV"/>
+        <enum value="0x8DC6" name="GL_UNSIGNED_INT_VEC2"/>
+        <enum value="0x8DC6" name="GL_UNSIGNED_INT_VEC2_EXT"/>
+        <enum value="0x8DC7" name="GL_UNSIGNED_INT_VEC3"/>
+        <enum value="0x8DC7" name="GL_UNSIGNED_INT_VEC3_EXT"/>
+        <enum value="0x8DC8" name="GL_UNSIGNED_INT_VEC4"/>
+        <enum value="0x8DC8" name="GL_UNSIGNED_INT_VEC4_EXT"/>
+        <enum value="0x8DC9" name="GL_INT_SAMPLER_1D"/>
+        <enum value="0x8DC9" name="GL_INT_SAMPLER_1D_EXT"/>
+        <enum value="0x8DCA" name="GL_INT_SAMPLER_2D"/>
+        <enum value="0x8DCA" name="GL_INT_SAMPLER_2D_EXT"/>
+        <enum value="0x8DCB" name="GL_INT_SAMPLER_3D"/>
+        <enum value="0x8DCB" name="GL_INT_SAMPLER_3D_EXT"/>
+        <enum value="0x8DCC" name="GL_INT_SAMPLER_CUBE"/>
+        <enum value="0x8DCC" name="GL_INT_SAMPLER_CUBE_EXT"/>
+        <enum value="0x8DCD" name="GL_INT_SAMPLER_2D_RECT"/>
+        <enum value="0x8DCD" name="GL_INT_SAMPLER_2D_RECT_EXT"/>
+        <enum value="0x8DCE" name="GL_INT_SAMPLER_1D_ARRAY"/>
+        <enum value="0x8DCE" name="GL_INT_SAMPLER_1D_ARRAY_EXT"/>
+        <enum value="0x8DCF" name="GL_INT_SAMPLER_2D_ARRAY"/>
+        <enum value="0x8DCF" name="GL_INT_SAMPLER_2D_ARRAY_EXT"/>
+        <enum value="0x8DD0" name="GL_INT_SAMPLER_BUFFER"/>
+        <enum value="0x8DD0" name="GL_INT_SAMPLER_BUFFER_EXT"/>
+        <enum value="0x8DD1" name="GL_UNSIGNED_INT_SAMPLER_1D"/>
+        <enum value="0x8DD1" name="GL_UNSIGNED_INT_SAMPLER_1D_EXT"/>
+        <enum value="0x8DD2" name="GL_UNSIGNED_INT_SAMPLER_2D"/>
+        <enum value="0x8DD2" name="GL_UNSIGNED_INT_SAMPLER_2D_EXT"/>
+        <enum value="0x8DD3" name="GL_UNSIGNED_INT_SAMPLER_3D"/>
+        <enum value="0x8DD3" name="GL_UNSIGNED_INT_SAMPLER_3D_EXT"/>
+        <enum value="0x8DD4" name="GL_UNSIGNED_INT_SAMPLER_CUBE"/>
+        <enum value="0x8DD4" name="GL_UNSIGNED_INT_SAMPLER_CUBE_EXT"/>
+        <enum value="0x8DD5" name="GL_UNSIGNED_INT_SAMPLER_2D_RECT"/>
+        <enum value="0x8DD5" name="GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT"/>
+        <enum value="0x8DD6" name="GL_UNSIGNED_INT_SAMPLER_1D_ARRAY"/>
+        <enum value="0x8DD6" name="GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT"/>
+        <enum value="0x8DD7" name="GL_UNSIGNED_INT_SAMPLER_2D_ARRAY"/>
+        <enum value="0x8DD7" name="GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT"/>
+        <enum value="0x8DD8" name="GL_UNSIGNED_INT_SAMPLER_BUFFER"/>
+        <enum value="0x8DD8" name="GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT"/>
+        <enum value="0x8DD9" name="GL_GEOMETRY_SHADER"/>
+        <enum value="0x8DD9" name="GL_GEOMETRY_SHADER_ARB"/>
+        <enum value="0x8DD9" name="GL_GEOMETRY_SHADER_EXT"/>
+        <enum value="0x8DDA" name="GL_GEOMETRY_VERTICES_OUT_ARB"/>
+        <enum value="0x8DDA" name="GL_GEOMETRY_VERTICES_OUT_EXT"/>
+        <enum value="0x8DDB" name="GL_GEOMETRY_INPUT_TYPE_ARB"/>
+        <enum value="0x8DDB" name="GL_GEOMETRY_INPUT_TYPE_EXT"/>
+        <enum value="0x8DDC" name="GL_GEOMETRY_OUTPUT_TYPE_ARB"/>
+        <enum value="0x8DDC" name="GL_GEOMETRY_OUTPUT_TYPE_EXT"/>
+        <enum value="0x8DDD" name="GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB"/>
+        <enum value="0x8DDD" name="GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT"/>
+        <enum value="0x8DDE" name="GL_MAX_VERTEX_VARYING_COMPONENTS_ARB"/>
+        <enum value="0x8DDE" name="GL_MAX_VERTEX_VARYING_COMPONENTS_EXT"/>
+        <enum value="0x8DDF" name="GL_MAX_GEOMETRY_UNIFORM_COMPONENTS"/>
+        <enum value="0x8DDF" name="GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB"/>
+        <enum value="0x8DDF" name="GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT"/>
+        <enum value="0x8DE0" name="GL_MAX_GEOMETRY_OUTPUT_VERTICES"/>
+        <enum value="0x8DE0" name="GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB"/>
+        <enum value="0x8DE0" name="GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT"/>
+        <enum value="0x8DE1" name="GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS"/>
+        <enum value="0x8DE1" name="GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB"/>
+        <enum value="0x8DE1" name="GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT"/>
+        <enum value="0x8DE2" name="GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT"/>
+        <enum value="0x8DE3" name="GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT"/>
+        <enum value="0x8DE4" name="GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT"/>
+        <enum value="0x8DE5" name="GL_ACTIVE_SUBROUTINES"/>
+        <enum value="0x8DE6" name="GL_ACTIVE_SUBROUTINE_UNIFORMS"/>
+        <enum value="0x8DE7" name="GL_MAX_SUBROUTINES"/>
+        <enum value="0x8DE8" name="GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS"/>
+        <enum value="0x8DE9" name="GL_NAMED_STRING_LENGTH_ARB"/>
+        <enum value="0x8DEA" name="GL_NAMED_STRING_TYPE_ARB"/>
+            <unused start="0x8DEB" end="0x8DEC"/>
+        <enum value="0x8DED" name="GL_MAX_BINDABLE_UNIFORM_SIZE_EXT"/>
+        <enum value="0x8DEE" name="GL_UNIFORM_BUFFER_EXT"/>
+        <enum value="0x8DEF" name="GL_UNIFORM_BUFFER_BINDING_EXT"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8DF0" end="0x8E0F" vendor="OES">
+        <enum value="0x8DF0" name="GL_LOW_FLOAT"/>
+        <enum value="0x8DF1" name="GL_MEDIUM_FLOAT"/>
+        <enum value="0x8DF2" name="GL_HIGH_FLOAT"/>
+        <enum value="0x8DF3" name="GL_LOW_INT"/>
+        <enum value="0x8DF4" name="GL_MEDIUM_INT"/>
+        <enum value="0x8DF5" name="GL_HIGH_INT"/>
+        <enum value="0x8DF6" name="GL_UNSIGNED_INT_10_10_10_2_OES"/>
+        <enum value="0x8DF7" name="GL_INT_10_10_10_2_OES"/>
+        <enum value="0x8DF8" name="GL_SHADER_BINARY_FORMATS"/>
+        <enum value="0x8DF9" name="GL_NUM_SHADER_BINARY_FORMATS"/>
+        <enum value="0x8DFA" name="GL_SHADER_COMPILER"/>
+        <enum value="0x8DFB" name="GL_MAX_VERTEX_UNIFORM_VECTORS"/>
+        <enum value="0x8DFC" name="GL_MAX_VARYING_VECTORS"/>
+        <enum value="0x8DFD" name="GL_MAX_FRAGMENT_UNIFORM_VECTORS"/>
+            <unused start="0x8DFE" end="0x8E0F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8E10" end="0x8E8F" vendor="NV" comment="For Michael Gold 2006/08/07">
+        <enum value="0x8E10" name="GL_RENDERBUFFER_COLOR_SAMPLES_NV"/>
+        <enum value="0x8E11" name="GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV"/>
+        <enum value="0x8E12" name="GL_MULTISAMPLE_COVERAGE_MODES_NV"/>
+        <enum value="0x8E13" name="GL_QUERY_WAIT"/>
+        <enum value="0x8E13" name="GL_QUERY_WAIT_NV"/>
+        <enum value="0x8E14" name="GL_QUERY_NO_WAIT"/>
+        <enum value="0x8E14" name="GL_QUERY_NO_WAIT_NV"/>
+        <enum value="0x8E15" name="GL_QUERY_BY_REGION_WAIT"/>
+        <enum value="0x8E15" name="GL_QUERY_BY_REGION_WAIT_NV"/>
+        <enum value="0x8E16" name="GL_QUERY_BY_REGION_NO_WAIT"/>
+        <enum value="0x8E16" name="GL_QUERY_BY_REGION_NO_WAIT_NV"/>
+            <unused start="0x8E17" end="0x8E1D"/>
+        <enum value="0x8E1E" name="GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS"/>
+        <enum value="0x8E1E" name="GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT"/>    
+        <enum value="0x8E1F" name="GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS"/>
+        <enum value="0x8E1F" name="GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT"/> 
+        <enum value="0x8E20" name="GL_COLOR_SAMPLES_NV"/>
+            <unused start="0x8E21"/>
+        <enum value="0x8E22" name="GL_TRANSFORM_FEEDBACK"/>
+        <enum value="0x8E22" name="GL_TRANSFORM_FEEDBACK_NV"/>
+        <enum value="0x8E23" name="GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED"/>
+        <enum value="0x8E23" name="GL_TRANSFORM_FEEDBACK_PAUSED" alias="GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED"/>
+        <enum value="0x8E23" name="GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV"/>
+        <enum value="0x8E24" name="GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE"/>
+        <enum value="0x8E24" name="GL_TRANSFORM_FEEDBACK_ACTIVE" alias="GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE"/>
+        <enum value="0x8E24" name="GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV"/>
+        <enum value="0x8E25" name="GL_TRANSFORM_FEEDBACK_BINDING"/>
+        <enum value="0x8E25" name="GL_TRANSFORM_FEEDBACK_BINDING_NV"/>
+        <enum value="0x8E26" name="GL_FRAME_NV"/>
+        <enum value="0x8E27" name="GL_FIELDS_NV"/>
+        <enum value="0x8E28" name="GL_CURRENT_TIME_NV"/>
+        <enum value="0x8E28" name="GL_TIMESTAMP"/>
+        <enum value="0x8E28" name="GL_TIMESTAMP_EXT"/>
+        <enum value="0x8E29" name="GL_NUM_FILL_STREAMS_NV"/>
+        <enum value="0x8E2A" name="GL_PRESENT_TIME_NV"/>
+        <enum value="0x8E2B" name="GL_PRESENT_DURATION_NV"/>
+        <enum value="0x8E2C" name="GL_DEPTH_COMPONENT16_NONLINEAR_NV"/>
+        <enum value="0x8E2D" name="GL_PROGRAM_MATRIX_EXT"/>
+        <enum value="0x8E2E" name="GL_TRANSPOSE_PROGRAM_MATRIX_EXT"/>
+        <enum value="0x8E2F" name="GL_PROGRAM_MATRIX_STACK_DEPTH_EXT"/>
+            <unused start="0x8E30" end="0x8E41"/>
+        <enum value="0x8E42" name="GL_TEXTURE_SWIZZLE_R"/>
+        <enum value="0x8E42" name="GL_TEXTURE_SWIZZLE_R_EXT"/>
+        <enum value="0x8E43" name="GL_TEXTURE_SWIZZLE_G"/>
+        <enum value="0x8E43" name="GL_TEXTURE_SWIZZLE_G_EXT"/>
+        <enum value="0x8E44" name="GL_TEXTURE_SWIZZLE_B"/>
+        <enum value="0x8E44" name="GL_TEXTURE_SWIZZLE_B_EXT"/>
+        <enum value="0x8E45" name="GL_TEXTURE_SWIZZLE_A"/>
+        <enum value="0x8E45" name="GL_TEXTURE_SWIZZLE_A_EXT"/>
+        <enum value="0x8E46" name="GL_TEXTURE_SWIZZLE_RGBA"/>
+        <enum value="0x8E46" name="GL_TEXTURE_SWIZZLE_RGBA_EXT"/>
+        <enum value="0x8E47" name="GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS"/>
+        <enum value="0x8E48" name="GL_ACTIVE_SUBROUTINE_MAX_LENGTH"/>
+        <enum value="0x8E49" name="GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH"/>
+        <enum value="0x8E4A" name="GL_NUM_COMPATIBLE_SUBROUTINES"/>
+        <enum value="0x8E4B" name="GL_COMPATIBLE_SUBROUTINES"/>
+        <enum value="0x8E4C" name="GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION"/>
+        <enum value="0x8E4C" name="GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT"/>
+        <enum value="0x8E4D" name="GL_FIRST_VERTEX_CONVENTION"/>
+        <enum value="0x8E4D" name="GL_FIRST_VERTEX_CONVENTION_EXT"/>
+        <enum value="0x8E4E" name="GL_LAST_VERTEX_CONVENTION"/>
+        <enum value="0x8E4E" name="GL_LAST_VERTEX_CONVENTION_EXT"/>
+        <enum value="0x8E4F" name="GL_PROVOKING_VERTEX"/>
+        <enum value="0x8E4F" name="GL_PROVOKING_VERTEX_EXT"/>
+        <enum value="0x8E50" name="GL_SAMPLE_POSITION"/>
+        <enum value="0x8E50" name="GL_SAMPLE_POSITION_NV"/>
+        <enum value="0x8E51" name="GL_SAMPLE_MASK"/>
+        <enum value="0x8E51" name="GL_SAMPLE_MASK_NV"/>
+        <enum value="0x8E52" name="GL_SAMPLE_MASK_VALUE"/>
+        <enum value="0x8E52" name="GL_SAMPLE_MASK_VALUE_NV"/>
+        <enum value="0x8E53" name="GL_TEXTURE_BINDING_RENDERBUFFER_NV"/>
+        <enum value="0x8E54" name="GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV"/>
+        <enum value="0x8E55" name="GL_TEXTURE_RENDERBUFFER_NV"/>
+        <enum value="0x8E56" name="GL_SAMPLER_RENDERBUFFER_NV"/>
+        <enum value="0x8E57" name="GL_INT_SAMPLER_RENDERBUFFER_NV"/>
+        <enum value="0x8E58" name="GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV"/>
+        <enum value="0x8E59" name="GL_MAX_SAMPLE_MASK_WORDS"/>
+        <enum value="0x8E59" name="GL_MAX_SAMPLE_MASK_WORDS_NV"/>
+        <enum value="0x8E5A" name="GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV"/>
+        <enum value="0x8E5A" name="GL_MAX_GEOMETRY_SHADER_INVOCATIONS"/>
+        <enum value="0x8E5A" name="GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT"/>                 
+        <enum value="0x8E5B" name="GL_MIN_FRAGMENT_INTERPOLATION_OFFSET"/>
+        <enum value="0x8E5B" name="GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES"/>
+        <enum value="0x8E5B" name="GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV"/>
+        <enum value="0x8E5C" name="GL_MAX_FRAGMENT_INTERPOLATION_OFFSET"/>
+        <enum value="0x8E5C" name="GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES"/>
+        <enum value="0x8E5C" name="GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV"/>
+        <enum value="0x8E5D" name="GL_FRAGMENT_INTERPOLATION_OFFSET_BITS"/>
+        <enum value="0x8E5D" name="GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES"/>
+        <enum value="0x8E5D" name="GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV"/>
+        <enum value="0x8E5E" name="GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET"/>
+        <enum value="0x8E5E" name="GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB"/>
+        <enum value="0x8E5E" name="GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV"/>
+        <enum value="0x8E5F" name="GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET"/>
+        <enum value="0x8E5F" name="GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB"/>
+        <enum value="0x8E5F" name="GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV"/>
+            <unused start="0x8E60" end="0x8E6F"/>
+        <enum value="0x8E70" name="GL_MAX_TRANSFORM_FEEDBACK_BUFFERS"/>
+        <enum value="0x8E71" name="GL_MAX_VERTEX_STREAMS"/>
+        <enum value="0x8E72" name="GL_PATCH_VERTICES"/>
+        <enum value="0x8E72" name="GL_PATCH_VERTICES_EXT"/>
+        <enum value="0x8E73" name="GL_PATCH_DEFAULT_INNER_LEVEL"/>
+        <enum value="0x8E73" name="GL_PATCH_DEFAULT_INNER_LEVEL_EXT"/>
+        <enum value="0x8E74" name="GL_PATCH_DEFAULT_OUTER_LEVEL"/>
+        <enum value="0x8E74" name="GL_PATCH_DEFAULT_OUTER_LEVEL_EXT"/>
+        <enum value="0x8E75" name="GL_TESS_CONTROL_OUTPUT_VERTICES"/>
+        <enum value="0x8E75" name="GL_TESS_CONTROL_OUTPUT_VERTICES_EXT"/>
+        <enum value="0x8E76" name="GL_TESS_GEN_MODE"/>
+        <enum value="0x8E76" name="GL_TESS_GEN_MODE_EXT"/>
+        <enum value="0x8E77" name="GL_TESS_GEN_SPACING"/>
+        <enum value="0x8E77" name="GL_TESS_GEN_SPACING_EXT"/>
+        <enum value="0x8E78" name="GL_TESS_GEN_VERTEX_ORDER"/>
+        <enum value="0x8E78" name="GL_TESS_GEN_VERTEX_ORDER_EXT"/>
+        <enum value="0x8E79" name="GL_TESS_GEN_POINT_MODE"/>
+        <enum value="0x8E79" name="GL_TESS_GEN_POINT_MODE_EXT"/>
+        <enum value="0x8E7A" name="GL_ISOLINES"/>
+        <enum value="0x8E7A" name="GL_ISOLINES_EXT"/>
+        <enum value="0x8E7B" name="GL_FRACTIONAL_ODD"/>
+        <enum value="0x8E7B" name="GL_FRACTIONAL_ODD_EXT"/>
+        <enum value="0x8E7C" name="GL_FRACTIONAL_EVEN"/>
+        <enum value="0x8E7C" name="GL_FRACTIONAL_EVEN_EXT"/>
+        <enum value="0x8E7D" name="GL_MAX_PATCH_VERTICES"/>
+        <enum value="0x8E7D" name="GL_MAX_PATCH_VERTICES_EXT"/>
+        <enum value="0x8E7E" name="GL_MAX_TESS_GEN_LEVEL"/>
+        <enum value="0x8E7E" name="GL_MAX_TESS_GEN_LEVEL_EXT"/>
+        <enum value="0x8E7F" name="GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS"/>
+        <enum value="0x8E7F" name="GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT"/>
+        <enum value="0x8E80" name="GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS"/>
+        <enum value="0x8E80" name="GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT"/>
+        <enum value="0x8E81" name="GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS"/>
+        <enum value="0x8E81" name="GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT"/>
+        <enum value="0x8E82" name="GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS"/>
+        <enum value="0x8E82" name="GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT"/>
+        <enum value="0x8E83" name="GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS"/>
+        <enum value="0x8E83" name="GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT"/>
+        <enum value="0x8E84" name="GL_MAX_TESS_PATCH_COMPONENTS"/>
+        <enum value="0x8E84" name="GL_MAX_TESS_PATCH_COMPONENTS_EXT"/>
+        <enum value="0x8E85" name="GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS"/>
+        <enum value="0x8E85" name="GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT"/>
+        <enum value="0x8E86" name="GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS"/>
+        <enum value="0x8E86" name="GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT"/>
+        <enum value="0x8E87" name="GL_TESS_EVALUATION_SHADER"/>
+        <enum value="0x8E87" name="GL_TESS_EVALUATION_SHADER_EXT"/>
+        <enum value="0x8E88" name="GL_TESS_CONTROL_SHADER"/>
+        <enum value="0x8E88" name="GL_TESS_CONTROL_SHADER_EXT"/>
+        <enum value="0x8E89" name="GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS"/>
+        <enum value="0x8E89" name="GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT"/>
+        <enum value="0x8E8A" name="GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS"/>
+        <enum value="0x8E8A" name="GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT"/>
+            <unused start="0x8E8B"/>
+        <enum value="0x8E8C" name="GL_COMPRESSED_RGBA_BPTC_UNORM"/>
+        <enum value="0x8E8C" name="GL_COMPRESSED_RGBA_BPTC_UNORM_ARB"/>
+        <enum value="0x8E8D" name="GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM"/>
+        <enum value="0x8E8D" name="GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB"/>
+        <enum value="0x8E8E" name="GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT"/>
+        <enum value="0x8E8E" name="GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB"/>
+        <enum value="0x8E8F" name="GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT"/>
+        <enum value="0x8E8F" name="GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8E90" end="0x8E9F" vendor="QNX" comment="For QNX_texture_tiling, QNX_complex_polygon, QNX_stippled_lines (Khronos bug 696)">
+            <unused start="0x8E90" end="0x8E9F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8EA0" end="0x8EAF" vendor="IMG"/>
+
+    <enums namespace="GL" start="0x8EB0" end="0x8EBF" vendor="OES" comment="For Affie Munshi 2007/07/20"/>
+
+    <enums namespace="GL" start="0x8EC0" end="0x8ECF" vendor="Vincent"/>
+
+    <enums namespace="GL" start="0x8ED0" end="0x8F4F" vendor="NV" comment="For Pat Brown, Khronos bug 3191">
+        <enum value="0x8ED0" name="GL_COVERAGE_COMPONENT_NV"/>
+        <enum value="0x8ED1" name="GL_COVERAGE_COMPONENT4_NV"/>
+        <enum value="0x8ED2" name="GL_COVERAGE_ATTACHMENT_NV"/>
+        <enum value="0x8ED3" name="GL_COVERAGE_BUFFERS_NV"/>
+        <enum value="0x8ED4" name="GL_COVERAGE_SAMPLES_NV"/>
+        <enum value="0x8ED5" name="GL_COVERAGE_ALL_FRAGMENTS_NV"/>
+        <enum value="0x8ED6" name="GL_COVERAGE_EDGE_FRAGMENTS_NV"/>
+        <enum value="0x8ED7" name="GL_COVERAGE_AUTOMATIC_NV"/>
+            <unused start="0x8ED8" end="0x8F1C"/>
+        <enum value="0x8F1D" name="GL_BUFFER_GPU_ADDRESS_NV"/>
+        <enum value="0x8F1E" name="GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV"/>
+        <enum value="0x8F1F" name="GL_ELEMENT_ARRAY_UNIFIED_NV"/>
+        <enum value="0x8F20" name="GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV"/>
+        <enum value="0x8F21" name="GL_VERTEX_ARRAY_ADDRESS_NV"/>
+        <enum value="0x8F22" name="GL_NORMAL_ARRAY_ADDRESS_NV"/>
+        <enum value="0x8F23" name="GL_COLOR_ARRAY_ADDRESS_NV"/>
+        <enum value="0x8F24" name="GL_INDEX_ARRAY_ADDRESS_NV"/>
+        <enum value="0x8F25" name="GL_TEXTURE_COORD_ARRAY_ADDRESS_NV"/>
+        <enum value="0x8F26" name="GL_EDGE_FLAG_ARRAY_ADDRESS_NV"/>
+        <enum value="0x8F27" name="GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV"/>
+        <enum value="0x8F28" name="GL_FOG_COORD_ARRAY_ADDRESS_NV"/>
+        <enum value="0x8F29" name="GL_ELEMENT_ARRAY_ADDRESS_NV"/>
+        <enum value="0x8F2A" name="GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV"/>
+        <enum value="0x8F2B" name="GL_VERTEX_ARRAY_LENGTH_NV"/>
+        <enum value="0x8F2C" name="GL_NORMAL_ARRAY_LENGTH_NV"/>
+        <enum value="0x8F2D" name="GL_COLOR_ARRAY_LENGTH_NV"/>
+        <enum value="0x8F2E" name="GL_INDEX_ARRAY_LENGTH_NV"/>
+        <enum value="0x8F2F" name="GL_TEXTURE_COORD_ARRAY_LENGTH_NV"/>
+        <enum value="0x8F30" name="GL_EDGE_FLAG_ARRAY_LENGTH_NV"/>
+        <enum value="0x8F31" name="GL_SECONDARY_COLOR_ARRAY_LENGTH_NV"/>
+        <enum value="0x8F32" name="GL_FOG_COORD_ARRAY_LENGTH_NV"/>
+        <enum value="0x8F33" name="GL_ELEMENT_ARRAY_LENGTH_NV"/>
+        <enum value="0x8F34" name="GL_GPU_ADDRESS_NV"/>
+        <enum value="0x8F35" name="GL_MAX_SHADER_BUFFER_ADDRESS_NV"/>
+        <enum value="0x8F36" name="GL_COPY_READ_BUFFER"/>
+        <enum value="0x8F36" name="GL_COPY_READ_BUFFER_NV"/>
+        <enum value="0x8F36" name="GL_COPY_READ_BUFFER_BINDING" alias="GL_COPY_READ_BUFFER"/>
+        <enum value="0x8F37" name="GL_COPY_WRITE_BUFFER"/>
+        <enum value="0x8F37" name="GL_COPY_WRITE_BUFFER_NV"/>
+        <enum value="0x8F37" name="GL_COPY_WRITE_BUFFER_BINDING" alias="GL_COPY_WRITE_BUFFER"/>
+        <enum value="0x8F38" name="GL_MAX_IMAGE_UNITS"/>
+        <enum value="0x8F38" name="GL_MAX_IMAGE_UNITS_EXT"/>
+        <enum value="0x8F39" name="GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS"/>
+        <enum value="0x8F39" name="GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT"/>
+        <enum value="0x8F39" name="GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES" alias="GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS"/>
+        <enum value="0x8F3A" name="GL_IMAGE_BINDING_NAME"/>
+        <enum value="0x8F3A" name="GL_IMAGE_BINDING_NAME_EXT"/>
+        <enum value="0x8F3B" name="GL_IMAGE_BINDING_LEVEL"/>
+        <enum value="0x8F3B" name="GL_IMAGE_BINDING_LEVEL_EXT"/>
+        <enum value="0x8F3C" name="GL_IMAGE_BINDING_LAYERED"/>
+        <enum value="0x8F3C" name="GL_IMAGE_BINDING_LAYERED_EXT"/>
+        <enum value="0x8F3D" name="GL_IMAGE_BINDING_LAYER"/>
+        <enum value="0x8F3D" name="GL_IMAGE_BINDING_LAYER_EXT"/>
+        <enum value="0x8F3E" name="GL_IMAGE_BINDING_ACCESS"/>
+        <enum value="0x8F3E" name="GL_IMAGE_BINDING_ACCESS_EXT"/>
+        <enum value="0x8F3F" name="GL_DRAW_INDIRECT_BUFFER"/>
+        <enum value="0x8F40" name="GL_DRAW_INDIRECT_UNIFIED_NV"/>
+        <enum value="0x8F41" name="GL_DRAW_INDIRECT_ADDRESS_NV"/>
+        <enum value="0x8F42" name="GL_DRAW_INDIRECT_LENGTH_NV"/>
+        <enum value="0x8F43" name="GL_DRAW_INDIRECT_BUFFER_BINDING"/>
+        <enum value="0x8F44" name="GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV"/>
+        <enum value="0x8F45" name="GL_MAX_PROGRAM_SUBROUTINE_NUM_NV"/>
+        <enum value="0x8F46" name="GL_DOUBLE_MAT2"/>
+        <enum value="0x8F46" name="GL_DOUBLE_MAT2_EXT"/>
+        <enum value="0x8F47" name="GL_DOUBLE_MAT3"/>
+        <enum value="0x8F47" name="GL_DOUBLE_MAT3_EXT"/>
+        <enum value="0x8F48" name="GL_DOUBLE_MAT4"/>
+        <enum value="0x8F48" name="GL_DOUBLE_MAT4_EXT"/>
+        <enum value="0x8F49" name="GL_DOUBLE_MAT2x3"/>
+        <enum value="0x8F49" name="GL_DOUBLE_MAT2x3_EXT"/>
+        <enum value="0x8F4A" name="GL_DOUBLE_MAT2x4"/>
+        <enum value="0x8F4A" name="GL_DOUBLE_MAT2x4_EXT"/>
+        <enum value="0x8F4B" name="GL_DOUBLE_MAT3x2"/>
+        <enum value="0x8F4B" name="GL_DOUBLE_MAT3x2_EXT"/>
+        <enum value="0x8F4C" name="GL_DOUBLE_MAT3x4"/>
+        <enum value="0x8F4C" name="GL_DOUBLE_MAT3x4_EXT"/>
+        <enum value="0x8F4D" name="GL_DOUBLE_MAT4x2"/>
+        <enum value="0x8F4D" name="GL_DOUBLE_MAT4x2_EXT"/>
+        <enum value="0x8F4E" name="GL_DOUBLE_MAT4x3"/>
+        <enum value="0x8F4E" name="GL_DOUBLE_MAT4x3_EXT"/>
+        <enum value="0x8F4F" name="GL_VERTEX_BINDING_BUFFER"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8F50" end="0x8F5F" vendor="ZiiLabs" comment="For Jon Kennedy, Khronos public bug 75"/>
+
+    <enums namespace="GL" start="0x8F60" end="0x8F6F" vendor="ARM" comment="For Remi Pedersen, Khronos bug 3745">
+        <enum value="0x8F60" name="GL_MALI_SHADER_BINARY_ARM"/>
+        <enum value="0x8F61" name="GL_MALI_PROGRAM_BINARY_ARM"/>
+            <unused start="0x8F62"/>
+        <enum value="0x8F63" name="GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT"/>
+        <enum value="0x8F64" name="GL_SHADER_PIXEL_LOCAL_STORAGE_EXT"/>
+        <enum value="0x8F65" name="GL_FETCH_PER_SAMPLE_ARM"/>
+        <enum value="0x8F66" name="GL_FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM"/>
+        <enum value="0x8F67" name="GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE_EXT"/>
+            <unused start="0x8F68" end="0x8F6F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8F70" end="0x8F7F" vendor="HI" comment="For Mark Callow, Khronos bug 4055. Shared with EGL."/>
+
+    <enums namespace="GL" start="0x8F80" end="0x8F8F" vendor="Zebra" comment="For Mike Weiblen, public bug 910"/>
+
+    <enums namespace="GL" start="0x8F90" end="0x8F9F" vendor="ARB">
+        <enum value="0x8F90" name="GL_RED_SNORM"/>
+        <enum value="0x8F91" name="GL_RG_SNORM"/>
+        <enum value="0x8F92" name="GL_RGB_SNORM"/>
+        <enum value="0x8F93" name="GL_RGBA_SNORM"/>
+        <enum value="0x8F94" name="GL_R8_SNORM"/>
+        <enum value="0x8F95" name="GL_RG8_SNORM"/>
+        <enum value="0x8F96" name="GL_RGB8_SNORM"/>
+        <enum value="0x8F97" name="GL_RGBA8_SNORM"/>
+        <enum value="0x8F98" name="GL_R16_SNORM"/>
+        <enum value="0x8F99" name="GL_RG16_SNORM"/>
+        <enum value="0x8F9A" name="GL_RGB16_SNORM"/>
+        <enum value="0x8F9B" name="GL_RGBA16_SNORM"/>
+        <enum value="0x8F9C" name="GL_SIGNED_NORMALIZED"/>
+        <enum value="0x8F9D" name="GL_PRIMITIVE_RESTART"/>
+        <enum value="0x8F9E" name="GL_PRIMITIVE_RESTART_INDEX"/>
+        <enum value="0x8F9F" name="GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8FA0" end="0x8FBF" vendor="QCOM" comment="For Maurice Ribble, bug 4512">
+        <enum value="0x8FA0" name="GL_PERFMON_GLOBAL_MODE_QCOM"/>
+            <unused start="0x8FA1" end="0x8FAF"/>
+        <enum value="0x8FB0" name="GL_BINNING_CONTROL_HINT_QCOM"/>
+        <enum value="0x8FB1" name="GL_CPU_OPTIMIZED_QCOM"/>
+        <enum value="0x8FB2" name="GL_GPU_OPTIMIZED_QCOM"/>
+        <enum value="0x8FB3" name="GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM"/>
+            <unused start="0x8FB4" end="0x8FBA"/>
+        <enum value="0x8FBB" name="GL_GPU_DISJOINT_EXT"/>
+            <unused start="0x8FBC" end="0x8FBF"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8FC0" end="0x8FDF" vendor="VIV" comment="For Frido Garritsen, bug 4526">
+        <enum value="0x8FC4" name="GL_SHADER_BINARY_VIV"/>
+    </enums>
+
+    <enums namespace="GL" start="0x8FE0" end="0x8FFF" vendor="NV" comment="For Pat Brown, bug 4935">
+        <enum value="0x8FE0" name="GL_INT8_NV"/>
+        <enum value="0x8FE1" name="GL_INT8_VEC2_NV"/>
+        <enum value="0x8FE2" name="GL_INT8_VEC3_NV"/>
+        <enum value="0x8FE3" name="GL_INT8_VEC4_NV"/>
+        <enum value="0x8FE4" name="GL_INT16_NV"/>
+        <enum value="0x8FE5" name="GL_INT16_VEC2_NV"/>
+        <enum value="0x8FE6" name="GL_INT16_VEC3_NV"/>
+        <enum value="0x8FE7" name="GL_INT16_VEC4_NV"/>
+        <enum value="0x8FE9" name="GL_INT64_VEC2_NV"/>
+        <enum value="0x8FEA" name="GL_INT64_VEC3_NV"/>
+        <enum value="0x8FEB" name="GL_INT64_VEC4_NV"/>
+        <enum value="0x8FEC" name="GL_UNSIGNED_INT8_NV"/>
+        <enum value="0x8FED" name="GL_UNSIGNED_INT8_VEC2_NV"/>
+        <enum value="0x8FEE" name="GL_UNSIGNED_INT8_VEC3_NV"/>
+        <enum value="0x8FEF" name="GL_UNSIGNED_INT8_VEC4_NV"/>
+        <enum value="0x8FF0" name="GL_UNSIGNED_INT16_NV"/>
+        <enum value="0x8FF1" name="GL_UNSIGNED_INT16_VEC2_NV"/>
+        <enum value="0x8FF2" name="GL_UNSIGNED_INT16_VEC3_NV"/>
+        <enum value="0x8FF3" name="GL_UNSIGNED_INT16_VEC4_NV"/>
+        <enum value="0x8FF5" name="GL_UNSIGNED_INT64_VEC2_NV"/>
+        <enum value="0x8FF6" name="GL_UNSIGNED_INT64_VEC3_NV"/>
+        <enum value="0x8FF7" name="GL_UNSIGNED_INT64_VEC4_NV"/>
+        <enum value="0x8FF8" name="GL_FLOAT16_NV"/>
+        <enum value="0x8FF9" name="GL_FLOAT16_VEC2_NV"/>
+        <enum value="0x8FFA" name="GL_FLOAT16_VEC3_NV"/>
+        <enum value="0x8FFB" name="GL_FLOAT16_VEC4_NV"/>
+        <enum value="0x8FFC" name="GL_DOUBLE_VEC2"/>
+        <enum value="0x8FFC" name="GL_DOUBLE_VEC2_EXT"/>
+        <enum value="0x8FFD" name="GL_DOUBLE_VEC3"/>
+        <enum value="0x8FFD" name="GL_DOUBLE_VEC3_EXT"/>
+        <enum value="0x8FFE" name="GL_DOUBLE_VEC4"/>
+        <enum value="0x8FFE" name="GL_DOUBLE_VEC4_EXT"/>
+            <unused start="0x8FFF"/>
+    </enums>
+
+    <enums namespace="GL" start="0x9000" end="0x901F" vendor="AMD" comment="For Bill Licea-Kane">
+        <enum value="0x9001" name="GL_SAMPLER_BUFFER_AMD"/>
+        <enum value="0x9002" name="GL_INT_SAMPLER_BUFFER_AMD"/>
+        <enum value="0x9003" name="GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD"/>
+        <enum value="0x9004" name="GL_TESSELLATION_MODE_AMD"/>
+        <enum value="0x9005" name="GL_TESSELLATION_FACTOR_AMD"/>
+        <enum value="0x9006" name="GL_DISCRETE_AMD"/>
+        <enum value="0x9007" name="GL_CONTINUOUS_AMD"/>
+            <unused start="0x9008"/>
+        <enum value="0x9009" name="GL_TEXTURE_CUBE_MAP_ARRAY"/>
+        <enum value="0x9009" name="GL_TEXTURE_CUBE_MAP_ARRAY_ARB"/>
+        <enum value="0x9009" name="GL_TEXTURE_CUBE_MAP_ARRAY_EXT"/>
+        <enum value="0x900A" name="GL_TEXTURE_BINDING_CUBE_MAP_ARRAY"/>
+        <enum value="0x900A" name="GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB"/>
+        <enum value="0x900A" name="GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT"/>
+        <enum value="0x900B" name="GL_PROXY_TEXTURE_CUBE_MAP_ARRAY"/>
+        <enum value="0x900B" name="GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB"/>
+        <enum value="0x900C" name="GL_SAMPLER_CUBE_MAP_ARRAY"/>
+        <enum value="0x900C" name="GL_SAMPLER_CUBE_MAP_ARRAY_ARB"/>
+        <enum value="0x900C" name="GL_SAMPLER_CUBE_MAP_ARRAY_EXT"/>
+        <enum value="0x900D" name="GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW"/>
+        <enum value="0x900D" name="GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB"/>
+        <enum value="0x900D" name="GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT"/>
+        <enum value="0x900E" name="GL_INT_SAMPLER_CUBE_MAP_ARRAY"/>
+        <enum value="0x900E" name="GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB"/>
+        <enum value="0x900E" name="GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT"/>
+        <enum value="0x900F" name="GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY"/>
+        <enum value="0x900F" name="GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB"/>
+        <enum value="0x900F" name="GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT"/>
+        <enum value="0x9010" name="GL_ALPHA_SNORM"/>
+        <enum value="0x9011" name="GL_LUMINANCE_SNORM"/>
+        <enum value="0x9012" name="GL_LUMINANCE_ALPHA_SNORM"/>
+        <enum value="0x9013" name="GL_INTENSITY_SNORM"/>
+        <enum value="0x9014" name="GL_ALPHA8_SNORM"/>
+        <enum value="0x9015" name="GL_LUMINANCE8_SNORM"/>
+        <enum value="0x9016" name="GL_LUMINANCE8_ALPHA8_SNORM"/>
+        <enum value="0x9017" name="GL_INTENSITY8_SNORM"/>
+        <enum value="0x9018" name="GL_ALPHA16_SNORM"/>
+        <enum value="0x9019" name="GL_LUMINANCE16_SNORM"/>
+        <enum value="0x901A" name="GL_LUMINANCE16_ALPHA16_SNORM"/>
+        <enum value="0x901B" name="GL_INTENSITY16_SNORM"/>
+        <enum value="0x901C" name="GL_FACTOR_MIN_AMD"/>
+        <enum value="0x901D" name="GL_FACTOR_MAX_AMD"/>
+        <enum value="0x901E" name="GL_DEPTH_CLAMP_NEAR_AMD"/>
+        <enum value="0x901F" name="GL_DEPTH_CLAMP_FAR_AMD"/>
+    </enums>
+
+    <enums namespace="GL" start="0x9020" end="0x90FF" vendor="NV" comment="For Pat Brown, bug 4935">
+        <enum value="0x9020" name="GL_VIDEO_BUFFER_NV"/>
+        <enum value="0x9021" name="GL_VIDEO_BUFFER_BINDING_NV"/>
+        <enum value="0x9022" name="GL_FIELD_UPPER_NV"/>
+        <enum value="0x9023" name="GL_FIELD_LOWER_NV"/>
+        <enum value="0x9024" name="GL_NUM_VIDEO_CAPTURE_STREAMS_NV"/>
+        <enum value="0x9025" name="GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV"/>
+        <enum value="0x9026" name="GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV"/>
+        <enum value="0x9027" name="GL_LAST_VIDEO_CAPTURE_STATUS_NV"/>
+        <enum value="0x9028" name="GL_VIDEO_BUFFER_PITCH_NV"/>
+        <enum value="0x9029" name="GL_VIDEO_COLOR_CONVERSION_MATRIX_NV"/>
+        <enum value="0x902A" name="GL_VIDEO_COLOR_CONVERSION_MAX_NV"/>
+        <enum value="0x902B" name="GL_VIDEO_COLOR_CONVERSION_MIN_NV"/>
+        <enum value="0x902C" name="GL_VIDEO_COLOR_CONVERSION_OFFSET_NV"/>
+        <enum value="0x902D" name="GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV"/>
+        <enum value="0x902E" name="GL_PARTIAL_SUCCESS_NV"/>
+        <enum value="0x902F" name="GL_SUCCESS_NV"/>
+        <enum value="0x9030" name="GL_FAILURE_NV"/>
+        <enum value="0x9031" name="GL_YCBYCR8_422_NV"/>
+        <enum value="0x9032" name="GL_YCBAYCR8A_4224_NV"/>
+        <enum value="0x9033" name="GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV"/>
+        <enum value="0x9034" name="GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV"/>
+        <enum value="0x9035" name="GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV"/>
+        <enum value="0x9036" name="GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV"/>
+        <enum value="0x9037" name="GL_Z4Y12Z4CB12Z4CR12_444_NV"/>
+        <enum value="0x9038" name="GL_VIDEO_CAPTURE_FRAME_WIDTH_NV"/>
+        <enum value="0x9039" name="GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV"/>
+        <enum value="0x903A" name="GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV"/>
+        <enum value="0x903B" name="GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV"/>
+        <enum value="0x903C" name="GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV"/>
+            <unused start="0x903D" end="0x9044"/>
+        <enum value="0x9045" name="GL_TEXTURE_COVERAGE_SAMPLES_NV"/>
+        <enum value="0x9046" name="GL_TEXTURE_COLOR_SAMPLES_NV"/>
+        <enum value="0x9047" name="GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX"/>
+        <enum value="0x9048" name="GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX"/>
+        <enum value="0x9049" name="GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX"/>
+        <enum value="0x904A" name="GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX"/>
+        <enum value="0x904B" name="GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX"/>
+        <enum value="0x904C" name="GL_IMAGE_1D"/>
+        <enum value="0x904C" name="GL_IMAGE_1D_EXT"/>
+        <enum value="0x904D" name="GL_IMAGE_2D"/>
+        <enum value="0x904D" name="GL_IMAGE_2D_EXT"/>
+        <enum value="0x904E" name="GL_IMAGE_3D"/>
+        <enum value="0x904E" name="GL_IMAGE_3D_EXT"/>
+        <enum value="0x904F" name="GL_IMAGE_2D_RECT"/>
+        <enum value="0x904F" name="GL_IMAGE_2D_RECT_EXT"/>
+        <enum value="0x9050" name="GL_IMAGE_CUBE"/>
+        <enum value="0x9050" name="GL_IMAGE_CUBE_EXT"/>
+        <enum value="0x9051" name="GL_IMAGE_BUFFER"/>
+        <enum value="0x9051" name="GL_IMAGE_BUFFER_EXT"/>
+        <enum value="0x9052" name="GL_IMAGE_1D_ARRAY"/>
+        <enum value="0x9052" name="GL_IMAGE_1D_ARRAY_EXT"/>
+        <enum value="0x9053" name="GL_IMAGE_2D_ARRAY"/>
+        <enum value="0x9053" name="GL_IMAGE_2D_ARRAY_EXT"/>
+        <enum value="0x9054" name="GL_IMAGE_CUBE_MAP_ARRAY"/>
+        <enum value="0x9054" name="GL_IMAGE_CUBE_MAP_ARRAY_EXT"/>
+        <enum value="0x9055" name="GL_IMAGE_2D_MULTISAMPLE"/>
+        <enum value="0x9055" name="GL_IMAGE_2D_MULTISAMPLE_EXT"/>
+        <enum value="0x9056" name="GL_IMAGE_2D_MULTISAMPLE_ARRAY"/>
+        <enum value="0x9056" name="GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT"/>
+        <enum value="0x9057" name="GL_INT_IMAGE_1D"/>
+        <enum value="0x9057" name="GL_INT_IMAGE_1D_EXT"/>
+        <enum value="0x9058" name="GL_INT_IMAGE_2D"/>
+        <enum value="0x9058" name="GL_INT_IMAGE_2D_EXT"/>
+        <enum value="0x9059" name="GL_INT_IMAGE_3D"/>
+        <enum value="0x9059" name="GL_INT_IMAGE_3D_EXT"/>
+        <enum value="0x905A" name="GL_INT_IMAGE_2D_RECT"/>
+        <enum value="0x905A" name="GL_INT_IMAGE_2D_RECT_EXT"/>
+        <enum value="0x905B" name="GL_INT_IMAGE_CUBE"/>
+        <enum value="0x905B" name="GL_INT_IMAGE_CUBE_EXT"/>
+        <enum value="0x905C" name="GL_INT_IMAGE_BUFFER"/>
+        <enum value="0x905C" name="GL_INT_IMAGE_BUFFER_EXT"/>
+        <enum value="0x905D" name="GL_INT_IMAGE_1D_ARRAY"/>
+        <enum value="0x905D" name="GL_INT_IMAGE_1D_ARRAY_EXT"/>
+        <enum value="0x905E" name="GL_INT_IMAGE_2D_ARRAY"/>
+        <enum value="0x905E" name="GL_INT_IMAGE_2D_ARRAY_EXT"/>
+        <enum value="0x905F" name="GL_INT_IMAGE_CUBE_MAP_ARRAY"/>
+        <enum value="0x905F" name="GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT"/>
+        <enum value="0x9060" name="GL_INT_IMAGE_2D_MULTISAMPLE"/>
+        <enum value="0x9060" name="GL_INT_IMAGE_2D_MULTISAMPLE_EXT"/>
+        <enum value="0x9061" name="GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY"/>
+        <enum value="0x9061" name="GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT"/>
+        <enum value="0x9062" name="GL_UNSIGNED_INT_IMAGE_1D"/>
+        <enum value="0x9062" name="GL_UNSIGNED_INT_IMAGE_1D_EXT"/>
+        <enum value="0x9063" name="GL_UNSIGNED_INT_IMAGE_2D"/>
+        <enum value="0x9063" name="GL_UNSIGNED_INT_IMAGE_2D_EXT"/>
+        <enum value="0x9064" name="GL_UNSIGNED_INT_IMAGE_3D"/>
+        <enum value="0x9064" name="GL_UNSIGNED_INT_IMAGE_3D_EXT"/>
+        <enum value="0x9065" name="GL_UNSIGNED_INT_IMAGE_2D_RECT"/>
+        <enum value="0x9065" name="GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT"/>
+        <enum value="0x9066" name="GL_UNSIGNED_INT_IMAGE_CUBE"/>
+        <enum value="0x9066" name="GL_UNSIGNED_INT_IMAGE_CUBE_EXT"/>
+        <enum value="0x9067" name="GL_UNSIGNED_INT_IMAGE_BUFFER"/>
+        <enum value="0x9067" name="GL_UNSIGNED_INT_IMAGE_BUFFER_EXT"/>
+        <enum value="0x9068" name="GL_UNSIGNED_INT_IMAGE_1D_ARRAY"/>
+        <enum value="0x9068" name="GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT"/>
+        <enum value="0x9069" name="GL_UNSIGNED_INT_IMAGE_2D_ARRAY"/>
+        <enum value="0x9069" name="GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT"/>
+        <enum value="0x906A" name="GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY"/>
+        <enum value="0x906A" name="GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT"/>
+        <enum value="0x906B" name="GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE"/>
+        <enum value="0x906B" name="GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT"/>
+        <enum value="0x906C" name="GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY"/>
+        <enum value="0x906C" name="GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT"/>
+        <enum value="0x906D" name="GL_MAX_IMAGE_SAMPLES"/>
+        <enum value="0x906D" name="GL_MAX_IMAGE_SAMPLES_EXT"/>
+        <enum value="0x906E" name="GL_IMAGE_BINDING_FORMAT"/>
+        <enum value="0x906E" name="GL_IMAGE_BINDING_FORMAT_EXT"/>
+        <enum value="0x906F" name="GL_RGB10_A2UI"/>
+        <enum value="0x9070" name="GL_PATH_FORMAT_SVG_NV"/>
+        <enum value="0x9071" name="GL_PATH_FORMAT_PS_NV"/>
+        <enum value="0x9072" name="GL_STANDARD_FONT_NAME_NV"/>
+        <enum value="0x9073" name="GL_SYSTEM_FONT_NAME_NV"/>
+        <enum value="0x9074" name="GL_FILE_NAME_NV"/>
+        <enum value="0x9075" name="GL_PATH_STROKE_WIDTH_NV"/>
+        <enum value="0x9076" name="GL_PATH_END_CAPS_NV"/>
+        <enum value="0x9077" name="GL_PATH_INITIAL_END_CAP_NV"/>
+        <enum value="0x9078" name="GL_PATH_TERMINAL_END_CAP_NV"/>
+        <enum value="0x9079" name="GL_PATH_JOIN_STYLE_NV"/>
+        <enum value="0x907A" name="GL_PATH_MITER_LIMIT_NV"/>
+        <enum value="0x907B" name="GL_PATH_DASH_CAPS_NV"/>
+        <enum value="0x907C" name="GL_PATH_INITIAL_DASH_CAP_NV"/>
+        <enum value="0x907D" name="GL_PATH_TERMINAL_DASH_CAP_NV"/>
+        <enum value="0x907E" name="GL_PATH_DASH_OFFSET_NV"/>
+        <enum value="0x907F" name="GL_PATH_CLIENT_LENGTH_NV"/>
+        <enum value="0x9080" name="GL_PATH_FILL_MODE_NV"/>
+        <enum value="0x9081" name="GL_PATH_FILL_MASK_NV"/>
+        <enum value="0x9082" name="GL_PATH_FILL_COVER_MODE_NV"/>
+        <enum value="0x9083" name="GL_PATH_STROKE_COVER_MODE_NV"/>
+        <enum value="0x9084" name="GL_PATH_STROKE_MASK_NV"/>
+            <!-- <enum value="0x9085" name="GL_PATH_SAMPLE_QUALITY_NV"          comment="Removed from extension"/> -->
+            <!-- <enum value="0x9086" name="GL_PATH_STROKE_BOUND_NV"            comment="Removed from extension"/> -->
+            <!-- <enum value="0x9087" name="GL_PATH_STROKE_OVERSAMPLE_COUNT_NV" comment="Removed from extension"/> -->
+        <enum value="0x9088" name="GL_COUNT_UP_NV"/>
+        <enum value="0x9089" name="GL_COUNT_DOWN_NV"/>
+        <enum value="0x908A" name="GL_PATH_OBJECT_BOUNDING_BOX_NV"/>
+        <enum value="0x908B" name="GL_CONVEX_HULL_NV"/>
+            <!-- <enum value="0x908C" name="GL_MULTI_HULLS_NV"                  comment="Removed from extension"/> -->
+        <enum value="0x908D" name="GL_BOUNDING_BOX_NV"/>
+        <enum value="0x908E" name="GL_TRANSLATE_X_NV"/>
+        <enum value="0x908F" name="GL_TRANSLATE_Y_NV"/>
+        <enum value="0x9090" name="GL_TRANSLATE_2D_NV"/>
+        <enum value="0x9091" name="GL_TRANSLATE_3D_NV"/>
+        <enum value="0x9092" name="GL_AFFINE_2D_NV"/>
+            <!-- <enum value="0x9093" name="GL_PROJECTIVE_2D_NV"                comment="Removed from extension"/> -->
+        <enum value="0x9094" name="GL_AFFINE_3D_NV"/>
+            <!-- <enum value="0x9095" name="GL_PROJECTIVE_3D_NV"                comment="Removed from extension"/> -->
+        <enum value="0x9096" name="GL_TRANSPOSE_AFFINE_2D_NV"/>
+            <!-- <enum value="0x9097" name="GL_TRANSPOSE_PROJECTIVE_2D_NV"      comment="Removed from extension"/> -->
+        <enum value="0x9098" name="GL_TRANSPOSE_AFFINE_3D_NV"/>
+            <!-- <enum value="0x9099" name="GL_TRANSPOSE_PROJECTIVE_3D_NV"      comment="Removed from extension"/> -->
+        <enum value="0x909A" name="GL_UTF8_NV"/>
+        <enum value="0x909B" name="GL_UTF16_NV"/>
+        <enum value="0x909C" name="GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV"/>
+        <enum value="0x909D" name="GL_PATH_COMMAND_COUNT_NV"/>
+        <enum value="0x909E" name="GL_PATH_COORD_COUNT_NV"/>
+        <enum value="0x909F" name="GL_PATH_DASH_ARRAY_COUNT_NV"/>
+        <enum value="0x90A0" name="GL_PATH_COMPUTED_LENGTH_NV"/>
+        <enum value="0x90A1" name="GL_PATH_FILL_BOUNDING_BOX_NV"/>
+        <enum value="0x90A2" name="GL_PATH_STROKE_BOUNDING_BOX_NV"/>
+        <enum value="0x90A3" name="GL_SQUARE_NV"/>
+        <enum value="0x90A4" name="GL_ROUND_NV"/>
+        <enum value="0x90A5" name="GL_TRIANGULAR_NV"/>
+        <enum value="0x90A6" name="GL_BEVEL_NV"/>
+        <enum value="0x90A7" name="GL_MITER_REVERT_NV"/>
+        <enum value="0x90A8" name="GL_MITER_TRUNCATE_NV"/>
+        <enum value="0x90A9" name="GL_SKIP_MISSING_GLYPH_NV"/>
+        <enum value="0x90AA" name="GL_USE_MISSING_GLYPH_NV"/>
+        <enum value="0x90AB" name="GL_PATH_ERROR_POSITION_NV"/>
+        <enum value="0x90AC" name="GL_PATH_FOG_GEN_MODE_NV"/>
+        <enum value="0x90AD" name="GL_ACCUM_ADJACENT_PAIRS_NV"/>
+        <enum value="0x90AE" name="GL_ADJACENT_PAIRS_NV"/>
+        <enum value="0x90AF" name="GL_FIRST_TO_REST_NV"/>
+        <enum value="0x90B0" name="GL_PATH_GEN_MODE_NV"/>
+        <enum value="0x90B1" name="GL_PATH_GEN_COEFF_NV"/>
+        <enum value="0x90B2" name="GL_PATH_GEN_COLOR_FORMAT_NV"/>
+        <enum value="0x90B3" name="GL_PATH_GEN_COMPONENTS_NV"/>
+        <enum value="0x90B4" name="GL_PATH_DASH_OFFSET_RESET_NV"/>
+        <enum value="0x90B5" name="GL_MOVE_TO_RESETS_NV"/>
+        <enum value="0x90B6" name="GL_MOVE_TO_CONTINUES_NV"/>
+        <enum value="0x90B7" name="GL_PATH_STENCIL_FUNC_NV"/>
+        <enum value="0x90B8" name="GL_PATH_STENCIL_REF_NV"/>
+        <enum value="0x90B9" name="GL_PATH_STENCIL_VALUE_MASK_NV"/>
+        <enum value="0x90BA" name="GL_SCALED_RESOLVE_FASTEST_EXT"/>
+        <enum value="0x90BB" name="GL_SCALED_RESOLVE_NICEST_EXT"/>
+        <enum value="0x90BC" name="GL_MIN_MAP_BUFFER_ALIGNMENT"/>
+        <enum value="0x90BD" name="GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV"/>
+        <enum value="0x90BE" name="GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV"/>
+        <enum value="0x90BF" name="GL_PATH_COVER_DEPTH_FUNC_NV"/>
+            <unused start="0x90C0" end="0x90C6"/>
+        <enum value="0x90C7" name="GL_IMAGE_FORMAT_COMPATIBILITY_TYPE"/>
+        <enum value="0x90C8" name="GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE"/>
+        <enum value="0x90C9" name="GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS"/>
+        <enum value="0x90CA" name="GL_MAX_VERTEX_IMAGE_UNIFORMS"/>
+        <enum value="0x90CB" name="GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS"/>
+        <enum value="0x90CB" name="GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT"/>
+        <enum value="0x90CC" name="GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS"/>
+        <enum value="0x90CC" name="GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT"/>
+        <enum value="0x90CD" name="GL_MAX_GEOMETRY_IMAGE_UNIFORMS"/>
+        <enum value="0x90CD" name="GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT"/>
+        <enum value="0x90CE" name="GL_MAX_FRAGMENT_IMAGE_UNIFORMS"/>
+        <enum value="0x90CF" name="GL_MAX_COMBINED_IMAGE_UNIFORMS"/>
+        <enum value="0x90D0" name="GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV"/>
+        <enum value="0x90D1" name="GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV"/>
+        <enum value="0x90D2" name="GL_SHADER_STORAGE_BUFFER"/>
+        <enum value="0x90D3" name="GL_SHADER_STORAGE_BUFFER_BINDING"/>
+        <enum value="0x90D4" name="GL_SHADER_STORAGE_BUFFER_START"/>
+        <enum value="0x90D5" name="GL_SHADER_STORAGE_BUFFER_SIZE"/>
+        <enum value="0x90D6" name="GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS"/>
+        <enum value="0x90D7" name="GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS"/>
+        <enum value="0x90D7" name="GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT"/>
+        <enum value="0x90D8" name="GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS"/>
+        <enum value="0x90D8" name="GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT"/>
+        <enum value="0x90D9" name="GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS"/>
+        <enum value="0x90D9" name="GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT"/>
+        <enum value="0x90DA" name="GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS"/>
+        <enum value="0x90DB" name="GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS"/>
+        <enum value="0x90DC" name="GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS"/>
+        <enum value="0x90DD" name="GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS"/>
+        <enum value="0x90DE" name="GL_MAX_SHADER_STORAGE_BLOCK_SIZE"/>
+        <enum value="0x90DF" name="GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT"/>
+            <unused start="0x90E0"/>
+        <enum value="0x90E1" name="GL_SYNC_X11_FENCE_EXT"/>
+            <unused start="0x90E2" end="0x90E9"/>
+        <enum value="0x90EA" name="GL_DEPTH_STENCIL_TEXTURE_MODE"/>
+        <enum value="0x90EB" name="GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS"/>
+        <enum value="0x90EB" name="GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB" alias="GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS"/>
+        <enum value="0x90EC" name="GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER"/>
+        <enum value="0x90ED" name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER"/>
+        <enum value="0x90EE" name="GL_DISPATCH_INDIRECT_BUFFER"/>
+        <enum value="0x90EF" name="GL_DISPATCH_INDIRECT_BUFFER_BINDING"/>
+        <enum value="0x90F0" name="GL_COLOR_ATTACHMENT_EXT"/>
+        <enum value="0x90F1" name="GL_MULTIVIEW_EXT"/>
+        <enum value="0x90F2" name="GL_MAX_MULTIVIEW_BUFFERS_EXT"/>
+        <enum value="0x90F3" name="GL_CONTEXT_ROBUST_ACCESS_EXT"/>
+            <unused start="0x90F4" end="0x90FA"/>
+        <enum value="0x90FB" name="GL_COMPUTE_PROGRAM_NV"/>
+        <enum value="0x90FC" name="GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV"/>
+            <unused start="0x90FD" end="0x90FF"/>
+    </enums>
+
+    <enums namespace="GL" start="0x9100" end="0x912F" vendor="ARB">
+        <enum value="0x9100" name="GL_TEXTURE_2D_MULTISAMPLE"/>
+        <enum value="0x9101" name="GL_PROXY_TEXTURE_2D_MULTISAMPLE"/>
+        <enum value="0x9102" name="GL_TEXTURE_2D_MULTISAMPLE_ARRAY"/>
+        <enum value="0x9102" name="GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES"/>
+        <enum value="0x9103" name="GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY"/>
+        <enum value="0x9104" name="GL_TEXTURE_BINDING_2D_MULTISAMPLE"/>
+        <enum value="0x9105" name="GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY"/>
+        <enum value="0x9105" name="GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES"/>
+        <enum value="0x9106" name="GL_TEXTURE_SAMPLES"/>
+        <enum value="0x9107" name="GL_TEXTURE_FIXED_SAMPLE_LOCATIONS"/>
+        <enum value="0x9108" name="GL_SAMPLER_2D_MULTISAMPLE"/>
+        <enum value="0x9109" name="GL_INT_SAMPLER_2D_MULTISAMPLE"/>
+        <enum value="0x910A" name="GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE"/>
+        <enum value="0x910B" name="GL_SAMPLER_2D_MULTISAMPLE_ARRAY"/>
+        <enum value="0x910B" name="GL_SAMPLER_2D_MULTISAMPLE_ARRAY_OES"/>
+        <enum value="0x910C" name="GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY"/>
+        <enum value="0x910C" name="GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES"/>
+        <enum value="0x910D" name="GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY"/>
+        <enum value="0x910D" name="GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES"/>
+        <enum value="0x910E" name="GL_MAX_COLOR_TEXTURE_SAMPLES"/>
+        <enum value="0x910F" name="GL_MAX_DEPTH_TEXTURE_SAMPLES"/>
+        <enum value="0x9110" name="GL_MAX_INTEGER_SAMPLES"/>
+        <enum value="0x9111" name="GL_MAX_SERVER_WAIT_TIMEOUT"/>
+        <enum value="0x9111" name="GL_MAX_SERVER_WAIT_TIMEOUT_APPLE"/>
+        <enum value="0x9112" name="GL_OBJECT_TYPE"/>
+        <enum value="0x9112" name="GL_OBJECT_TYPE_APPLE"/>
+        <enum value="0x9113" name="GL_SYNC_CONDITION"/>
+        <enum value="0x9113" name="GL_SYNC_CONDITION_APPLE"/>
+        <enum value="0x9114" name="GL_SYNC_STATUS"/>
+        <enum value="0x9114" name="GL_SYNC_STATUS_APPLE"/>
+        <enum value="0x9115" name="GL_SYNC_FLAGS"/>
+        <enum value="0x9115" name="GL_SYNC_FLAGS_APPLE"/>
+        <enum value="0x9116" name="GL_SYNC_FENCE"/>
+        <enum value="0x9116" name="GL_SYNC_FENCE_APPLE"/>
+        <enum value="0x9117" name="GL_SYNC_GPU_COMMANDS_COMPLETE"/>
+        <enum value="0x9117" name="GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE"/>
+        <enum value="0x9118" name="GL_UNSIGNALED"/>
+        <enum value="0x9118" name="GL_UNSIGNALED_APPLE"/>
+        <enum value="0x9119" name="GL_SIGNALED"/>
+        <enum value="0x9119" name="GL_SIGNALED_APPLE"/>
+        <enum value="0x911A" name="GL_ALREADY_SIGNALED"/>
+        <enum value="0x911A" name="GL_ALREADY_SIGNALED_APPLE"/>
+        <enum value="0x911B" name="GL_TIMEOUT_EXPIRED"/>
+        <enum value="0x911B" name="GL_TIMEOUT_EXPIRED_APPLE"/>
+        <enum value="0x911C" name="GL_CONDITION_SATISFIED"/>
+        <enum value="0x911C" name="GL_CONDITION_SATISFIED_APPLE"/>
+        <enum value="0x911D" name="GL_WAIT_FAILED"/>
+        <enum value="0x911D" name="GL_WAIT_FAILED_APPLE"/>
+        <enum value="0x911F" name="GL_BUFFER_ACCESS_FLAGS"/>
+        <enum value="0x9120" name="GL_BUFFER_MAP_LENGTH"/>
+        <enum value="0x9121" name="GL_BUFFER_MAP_OFFSET"/>
+        <enum value="0x9122" name="GL_MAX_VERTEX_OUTPUT_COMPONENTS"/>
+        <enum value="0x9123" name="GL_MAX_GEOMETRY_INPUT_COMPONENTS"/>
+        <enum value="0x9123" name="GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT"/>
+        <enum value="0x9124" name="GL_MAX_GEOMETRY_OUTPUT_COMPONENTS"/>
+        <enum value="0x9124" name="GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT"/>
+        <enum value="0x9125" name="GL_MAX_FRAGMENT_INPUT_COMPONENTS"/>
+        <enum value="0x9126" name="GL_CONTEXT_PROFILE_MASK"/>
+        <enum value="0x9127" name="GL_UNPACK_COMPRESSED_BLOCK_WIDTH"/>
+        <enum value="0x9128" name="GL_UNPACK_COMPRESSED_BLOCK_HEIGHT"/>
+        <enum value="0x9129" name="GL_UNPACK_COMPRESSED_BLOCK_DEPTH"/>
+        <enum value="0x912A" name="GL_UNPACK_COMPRESSED_BLOCK_SIZE"/>
+        <enum value="0x912B" name="GL_PACK_COMPRESSED_BLOCK_WIDTH"/>
+        <enum value="0x912C" name="GL_PACK_COMPRESSED_BLOCK_HEIGHT"/>
+        <enum value="0x912D" name="GL_PACK_COMPRESSED_BLOCK_DEPTH"/>
+        <enum value="0x912E" name="GL_PACK_COMPRESSED_BLOCK_SIZE"/>
+        <enum value="0x912F" name="GL_TEXTURE_IMMUTABLE_FORMAT"/>
+        <enum value="0x912F" name="GL_TEXTURE_IMMUTABLE_FORMAT_EXT"/>
+    </enums>
+
+    <enums namespace="GL" start="0x9130" end="0x913F" vendor="IMG" comment="Khronos bug 882">
+        <enum value="0x9130" name="GL_SGX_PROGRAM_BINARY_IMG"/>
+            <unused start="0x9131" end="0x9132"/>
+        <enum value="0x9133" name="GL_RENDERBUFFER_SAMPLES_IMG"/>
+        <enum value="0x9134" name="GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG"/>
+        <enum value="0x9135" name="GL_MAX_SAMPLES_IMG"/>
+        <enum value="0x9136" name="GL_TEXTURE_SAMPLES_IMG"/>
+        <enum value="0x9137" name="GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG"/>
+        <enum value="0x9138" name="GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG"/>
+            <unused start="0x9139" end="0x913F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x9140" end="0x923F" vendor="AMD" comment="Khronos bugs 5899, 6004">
+            <unused start="0x9140" end="0x9142"/>
+        <enum value="0x9143" name="GL_MAX_DEBUG_MESSAGE_LENGTH"/>
+        <enum value="0x9143" name="GL_MAX_DEBUG_MESSAGE_LENGTH_AMD"/>
+        <enum value="0x9143" name="GL_MAX_DEBUG_MESSAGE_LENGTH_ARB"/>
+        <enum value="0x9143" name="GL_MAX_DEBUG_MESSAGE_LENGTH_KHR"/>
+        <enum value="0x9144" name="GL_MAX_DEBUG_LOGGED_MESSAGES"/>
+        <enum value="0x9144" name="GL_MAX_DEBUG_LOGGED_MESSAGES_AMD"/>
+        <enum value="0x9144" name="GL_MAX_DEBUG_LOGGED_MESSAGES_ARB"/>
+        <enum value="0x9144" name="GL_MAX_DEBUG_LOGGED_MESSAGES_KHR"/>
+        <enum value="0x9145" name="GL_DEBUG_LOGGED_MESSAGES"/>
+        <enum value="0x9145" name="GL_DEBUG_LOGGED_MESSAGES_AMD"/>
+        <enum value="0x9145" name="GL_DEBUG_LOGGED_MESSAGES_ARB"/>
+        <enum value="0x9145" name="GL_DEBUG_LOGGED_MESSAGES_KHR"/>
+        <enum value="0x9146" name="GL_DEBUG_SEVERITY_HIGH"/>
+        <enum value="0x9146" name="GL_DEBUG_SEVERITY_HIGH_AMD"/>
+        <enum value="0x9146" name="GL_DEBUG_SEVERITY_HIGH_ARB"/>
+        <enum value="0x9146" name="GL_DEBUG_SEVERITY_HIGH_KHR"/>
+        <enum value="0x9147" name="GL_DEBUG_SEVERITY_MEDIUM"/>
+        <enum value="0x9147" name="GL_DEBUG_SEVERITY_MEDIUM_AMD"/>
+        <enum value="0x9147" name="GL_DEBUG_SEVERITY_MEDIUM_ARB"/>
+        <enum value="0x9147" name="GL_DEBUG_SEVERITY_MEDIUM_KHR"/>
+        <enum value="0x9148" name="GL_DEBUG_SEVERITY_LOW"/>
+        <enum value="0x9148" name="GL_DEBUG_SEVERITY_LOW_AMD"/>
+        <enum value="0x9148" name="GL_DEBUG_SEVERITY_LOW_ARB"/>
+        <enum value="0x9148" name="GL_DEBUG_SEVERITY_LOW_KHR"/>
+        <enum value="0x9149" name="GL_DEBUG_CATEGORY_API_ERROR_AMD"/>
+        <enum value="0x914A" name="GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD"/>
+        <enum value="0x914B" name="GL_DEBUG_CATEGORY_DEPRECATION_AMD"/>
+        <enum value="0x914C" name="GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD"/>
+        <enum value="0x914D" name="GL_DEBUG_CATEGORY_PERFORMANCE_AMD"/>
+        <enum value="0x914E" name="GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD"/>
+        <enum value="0x914F" name="GL_DEBUG_CATEGORY_APPLICATION_AMD"/>
+        <enum value="0x9150" name="GL_DEBUG_CATEGORY_OTHER_AMD"/>
+        <enum value="0x9151" name="GL_BUFFER_OBJECT_EXT"/>
+        <enum value="0x9151" name="GL_DATA_BUFFER_AMD"/>
+        <enum value="0x9152" name="GL_PERFORMANCE_MONITOR_AMD"/>
+        <enum value="0x9153" name="GL_QUERY_OBJECT_AMD"/>
+        <enum value="0x9153" name="GL_QUERY_OBJECT_EXT"/>
+        <enum value="0x9154" name="GL_VERTEX_ARRAY_OBJECT_AMD"/>
+        <enum value="0x9154" name="GL_VERTEX_ARRAY_OBJECT_EXT"/>
+        <enum value="0x9155" name="GL_SAMPLER_OBJECT_AMD"/>
+            <unused start="0x9156" end="0x915F"/>
+        <enum value="0x9160" name="GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD"/>
+            <unused start="0x9161"/>
+        <enum value="0x9192" name="GL_QUERY_BUFFER"/>
+        <enum value="0x9192" name="GL_QUERY_BUFFER_AMD"/>
+        <enum value="0x9193" name="GL_QUERY_BUFFER_BINDING"/>
+        <enum value="0x9193" name="GL_QUERY_BUFFER_BINDING_AMD"/>
+        <enum value="0x9194" name="GL_QUERY_RESULT_NO_WAIT"/>
+        <enum value="0x9194" name="GL_QUERY_RESULT_NO_WAIT_AMD"/>
+        <enum value="0x9195" name="GL_VIRTUAL_PAGE_SIZE_X_ARB"/>
+        <enum value="0x9195" name="GL_VIRTUAL_PAGE_SIZE_X_AMD"/>
+        <enum value="0x9196" name="GL_VIRTUAL_PAGE_SIZE_Y_ARB"/>
+        <enum value="0x9196" name="GL_VIRTUAL_PAGE_SIZE_Y_AMD"/>
+        <enum value="0x9197" name="GL_VIRTUAL_PAGE_SIZE_Z_ARB"/>
+        <enum value="0x9197" name="GL_VIRTUAL_PAGE_SIZE_Z_AMD"/>
+        <enum value="0x9198" name="GL_MAX_SPARSE_TEXTURE_SIZE_ARB"/>
+        <enum value="0x9198" name="GL_MAX_SPARSE_TEXTURE_SIZE_AMD"/>
+        <enum value="0x9199" name="GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB"/>
+        <enum value="0x9199" name="GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD"/>
+        <enum value="0x919A" name="GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB"/>
+        <enum value="0x919A" name="GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS"/>
+        <enum value="0x919B" name="GL_MIN_SPARSE_LEVEL_ARB"/>
+        <enum value="0x919B" name="GL_MIN_SPARSE_LEVEL_AMD"/>
+        <enum value="0x919C" name="GL_MIN_LOD_WARNING_AMD"/>
+        <enum value="0x919D" name="GL_TEXTURE_BUFFER_OFFSET"/>
+        <enum value="0x919D" name="GL_TEXTURE_BUFFER_OFFSET_EXT"/>
+        <enum value="0x919E" name="GL_TEXTURE_BUFFER_SIZE"/>
+        <enum value="0x919E" name="GL_TEXTURE_BUFFER_SIZE_EXT"/>
+        <enum value="0x919F" name="GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT"/>
+        <enum value="0x919F" name="GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT"/>
+        <enum value="0x91A0" name="GL_STREAM_RASTERIZATION_AMD"/>
+            <unused start="0x91A1" end="0x91A3"/>
+        <enum value="0x91A4" name="GL_VERTEX_ELEMENT_SWIZZLE_AMD"/>
+        <enum value="0x91A5" name="GL_VERTEX_ID_SWIZZLE_AMD"/>
+        <enum value="0x91A6" name="GL_TEXTURE_SPARSE_ARB"/>
+        <enum value="0x91A7" name="GL_VIRTUAL_PAGE_SIZE_INDEX_ARB"/>
+        <enum value="0x91A8" name="GL_NUM_VIRTUAL_PAGE_SIZES_ARB"/>
+        <enum value="0x91A9" name="GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB"/>
+            <unused start="0x91AA" end="0x91B8"/>
+        <enum value="0x91B9" name="GL_COMPUTE_SHADER"/>
+            <unused start="0x91BA"/>
+        <enum value="0x91BB" name="GL_MAX_COMPUTE_UNIFORM_BLOCKS"/>
+        <enum value="0x91BC" name="GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS"/>
+        <enum value="0x91BD" name="GL_MAX_COMPUTE_IMAGE_UNIFORMS"/>
+        <enum value="0x91BE" name="GL_MAX_COMPUTE_WORK_GROUP_COUNT"/>
+        <enum value="0x91BF" name="GL_MAX_COMPUTE_WORK_GROUP_SIZE"/>
+        <enum value="0x91BF" name="GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB" alias="GL_MAX_COMPUTE_WORK_GROUP_SIZE"/>
+            <unused start="0x91C0" end="0x923F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x9240" end="0x924F" vendor="WEBGL" comment="Khronos bug 6473,6884">
+        <enum value="0x9240" name="GL_UNPACK_FLIP_Y_WEBGL"/>
+        <enum value="0x9241" name="GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL"/>
+        <enum value="0x9242" name="GL_CONTEXT_LOST_WEBGL"/>
+        <enum value="0x9243" name="GL_UNPACK_COLORSPACE_CONVERSION_WEBGL"/>
+        <enum value="0x9244" name="GL_BROWSER_DEFAULT_WEBGL"/>
+            <unused start="0x9245" end="0x924F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x9250" end="0x925F" vendor="DMP" comment="For Eisaku Ohbuchi via email">
+        <enum value="0x9250" name="GL_SHADER_BINARY_DMP"/>
+            <unused start="0x9251" end="0x925F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x9260" end="0x926F" vendor="FJ" comment="Khronos bug 7486">
+        <enum value="0x9260" name="GL_GCCSO_SHADER_BINARY_FJ"/>
+            <unused start="0x9261" end="0x926F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x9270" end="0x927F" vendor="OES" comment="Khronos bug 7625">
+        <enum value="0x9270" name="GL_COMPRESSED_R11_EAC"/>
+        <enum value="0x9270" name="GL_COMPRESSED_R11_EAC_OES"/>
+        <enum value="0x9271" name="GL_COMPRESSED_SIGNED_R11_EAC"/>
+        <enum value="0x9271" name="GL_COMPRESSED_SIGNED_R11_EAC_OES"/>
+        <enum value="0x9272" name="GL_COMPRESSED_RG11_EAC"/>
+        <enum value="0x9272" name="GL_COMPRESSED_RG11_EAC_OES"/>
+        <enum value="0x9273" name="GL_COMPRESSED_SIGNED_RG11_EAC"/>
+        <enum value="0x9273" name="GL_COMPRESSED_SIGNED_RG11_EAC_OES"/>
+        <enum value="0x9274" name="GL_COMPRESSED_RGB8_ETC2"/>
+        <enum value="0x9274" name="GL_COMPRESSED_RGB8_ETC2_OES"/>
+        <enum value="0x9275" name="GL_COMPRESSED_SRGB8_ETC2"/>
+        <enum value="0x9275" name="GL_COMPRESSED_SRGB8_ETC2_OES"/>
+        <enum value="0x9276" name="GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2"/>
+        <enum value="0x9276" name="GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2_OES"/>
+        <enum value="0x9277" name="GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2"/>
+        <enum value="0x9277" name="GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2_OES"/>
+        <enum value="0x9278" name="GL_COMPRESSED_RGBA8_ETC2_EAC"/>
+        <enum value="0x9278" name="GL_COMPRESSED_RGBA8_ETC2_EAC_OES"/>
+        <enum value="0x9279" name="GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"/>
+        <enum value="0x9279" name="GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC_OES"/>
+            <unused start="0x927A" end="0x927F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x9280" end="0x937F" vendor="NV" comment="Khronos bug 7658">
+        <enum value="0x9280" name="GL_BLEND_PREMULTIPLIED_SRC_NV"/>
+        <enum value="0x9281" name="GL_BLEND_OVERLAP_NV"/>
+        <enum value="0x9282" name="GL_UNCORRELATED_NV"/>
+        <enum value="0x9283" name="GL_DISJOINT_NV"/>
+        <enum value="0x9284" name="GL_CONJOINT_NV"/>
+        <enum value="0x9285" name="GL_BLEND_ADVANCED_COHERENT_KHR"/>
+        <enum value="0x9285" name="GL_BLEND_ADVANCED_COHERENT_NV"/>
+        <enum value="0x9286" name="GL_SRC_NV"/>
+        <enum value="0x9287" name="GL_DST_NV"/>
+        <enum value="0x9288" name="GL_SRC_OVER_NV"/>
+        <enum value="0x9289" name="GL_DST_OVER_NV"/>
+        <enum value="0x928A" name="GL_SRC_IN_NV"/>
+        <enum value="0x928B" name="GL_DST_IN_NV"/>
+        <enum value="0x928C" name="GL_SRC_OUT_NV"/>
+        <enum value="0x928D" name="GL_DST_OUT_NV"/>
+        <enum value="0x928E" name="GL_SRC_ATOP_NV"/>
+        <enum value="0x928F" name="GL_DST_ATOP_NV"/>
+            <unused start="0x9290"/>
+        <enum value="0x9291" name="GL_PLUS_NV"/>
+        <enum value="0x9292" name="GL_PLUS_DARKER_NV"/>
+            <unused start="0x9293"/>
+        <enum value="0x9294" name="GL_MULTIPLY_KHR"/>
+        <enum value="0x9294" name="GL_MULTIPLY_NV"/>
+        <enum value="0x9295" name="GL_SCREEN_KHR"/>
+        <enum value="0x9295" name="GL_SCREEN_NV"/>
+        <enum value="0x9296" name="GL_OVERLAY_KHR"/>
+        <enum value="0x9296" name="GL_OVERLAY_NV"/>
+        <enum value="0x9297" name="GL_DARKEN_KHR"/>
+        <enum value="0x9297" name="GL_DARKEN_NV"/>
+        <enum value="0x9298" name="GL_LIGHTEN_KHR"/>
+        <enum value="0x9298" name="GL_LIGHTEN_NV"/>
+        <enum value="0x9299" name="GL_COLORDODGE_KHR"/>
+        <enum value="0x9299" name="GL_COLORDODGE_NV"/>
+        <enum value="0x929A" name="GL_COLORBURN_KHR"/>
+        <enum value="0x929A" name="GL_COLORBURN_NV"/>
+        <enum value="0x929B" name="GL_HARDLIGHT_KHR"/>
+        <enum value="0x929B" name="GL_HARDLIGHT_NV"/>
+        <enum value="0x929C" name="GL_SOFTLIGHT_KHR"/>
+        <enum value="0x929C" name="GL_SOFTLIGHT_NV"/>
+            <unused start="0x929D"/>
+        <enum value="0x929E" name="GL_DIFFERENCE_KHR"/>
+        <enum value="0x929E" name="GL_DIFFERENCE_NV"/>
+        <enum value="0x929F" name="GL_MINUS_NV"/>
+        <enum value="0x92A0" name="GL_EXCLUSION_KHR"/>
+        <enum value="0x92A0" name="GL_EXCLUSION_NV"/>
+        <enum value="0x92A1" name="GL_CONTRAST_NV"/>
+            <unused start="0x92A2"/>
+        <enum value="0x92A3" name="GL_INVERT_RGB_NV"/>
+        <enum value="0x92A4" name="GL_LINEARDODGE_NV"/>
+        <enum value="0x92A5" name="GL_LINEARBURN_NV"/>
+        <enum value="0x92A6" name="GL_VIVIDLIGHT_NV"/>
+        <enum value="0x92A7" name="GL_LINEARLIGHT_NV"/>
+        <enum value="0x92A8" name="GL_PINLIGHT_NV"/>
+        <enum value="0x92A9" name="GL_HARDMIX_NV"/>
+            <unused start="0x92AA" end="0x92AC"/>
+        <enum value="0x92AD" name="GL_HSL_HUE_KHR"/>
+        <enum value="0x92AD" name="GL_HSL_HUE_NV"/>
+        <enum value="0x92AE" name="GL_HSL_SATURATION_KHR"/>
+        <enum value="0x92AE" name="GL_HSL_SATURATION_NV"/>
+        <enum value="0x92AF" name="GL_HSL_COLOR_KHR"/>
+        <enum value="0x92AF" name="GL_HSL_COLOR_NV"/>
+        <enum value="0x92B0" name="GL_HSL_LUMINOSITY_KHR"/>
+        <enum value="0x92B0" name="GL_HSL_LUMINOSITY_NV"/>
+        <enum value="0x92B1" name="GL_PLUS_CLAMPED_NV"/>
+        <enum value="0x92B2" name="GL_PLUS_CLAMPED_ALPHA_NV"/>
+        <enum value="0x92B3" name="GL_MINUS_CLAMPED_NV"/>
+        <enum value="0x92B4" name="GL_INVERT_OVG_NV"/>
+            <unused start="0x92B5" end="0x92BD"/>
+        <enum value="0x92BE" name="GL_PRIMITIVE_BOUNDING_BOX_EXT"/>
+            <unused start="0x92BF"/>
+        <enum value="0x92C0" name="GL_ATOMIC_COUNTER_BUFFER"/>
+        <enum value="0x92C1" name="GL_ATOMIC_COUNTER_BUFFER_BINDING"/>
+        <enum value="0x92C2" name="GL_ATOMIC_COUNTER_BUFFER_START"/>
+        <enum value="0x92C3" name="GL_ATOMIC_COUNTER_BUFFER_SIZE"/>
+        <enum value="0x92C4" name="GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE"/>
+        <enum value="0x92C5" name="GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS"/>
+        <enum value="0x92C6" name="GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES"/>
+        <enum value="0x92C7" name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER"/>
+        <enum value="0x92C8" name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER"/>
+        <enum value="0x92C9" name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER"/>
+        <enum value="0x92CA" name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER"/>
+        <enum value="0x92CB" name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER"/>
+        <enum value="0x92CC" name="GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS"/>
+        <enum value="0x92CD" name="GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS"/>
+        <enum value="0x92CD" name="GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT"/>
+        <enum value="0x92CE" name="GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS"/>
+        <enum value="0x92CE" name="GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT"/>
+        <enum value="0x92CF" name="GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS"/>
+        <enum value="0x92CF" name="GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT"/>
+        <enum value="0x92D0" name="GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS"/>
+        <enum value="0x92D1" name="GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS"/>
+        <enum value="0x92D2" name="GL_MAX_VERTEX_ATOMIC_COUNTERS"/>
+        <enum value="0x92D3" name="GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS"/>
+        <enum value="0x92D3" name="GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT"/>
+        <enum value="0x92D4" name="GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS"/>
+        <enum value="0x92D4" name="GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT"/>
+        <enum value="0x92D5" name="GL_MAX_GEOMETRY_ATOMIC_COUNTERS"/>
+        <enum value="0x92D5" name="GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT"/>
+        <enum value="0x92D6" name="GL_MAX_FRAGMENT_ATOMIC_COUNTERS"/>
+        <enum value="0x92D7" name="GL_MAX_COMBINED_ATOMIC_COUNTERS"/>
+        <enum value="0x92D8" name="GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE"/>
+        <enum value="0x92D9" name="GL_ACTIVE_ATOMIC_COUNTER_BUFFERS"/>
+        <enum value="0x92DA" name="GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX"/>
+        <enum value="0x92DB" name="GL_UNSIGNED_INT_ATOMIC_COUNTER"/>
+        <enum value="0x92DC" name="GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS"/>
+            <unused start="0x92DC" end="0x92DF"/>
+        <enum value="0x92E0" name="GL_DEBUG_OUTPUT"/>
+        <enum value="0x92E0" name="GL_DEBUG_OUTPUT_KHR"/>
+        <enum value="0x92E1" name="GL_UNIFORM"/>
+        <enum value="0x92E2" name="GL_UNIFORM_BLOCK"/>
+        <enum value="0x92E3" name="GL_PROGRAM_INPUT"/>
+        <enum value="0x92E4" name="GL_PROGRAM_OUTPUT"/>
+        <enum value="0x92E5" name="GL_BUFFER_VARIABLE"/>
+        <enum value="0x92E6" name="GL_SHADER_STORAGE_BLOCK"/>
+        <enum value="0x92E7" name="GL_IS_PER_PATCH"/>
+        <enum value="0x92E7" name="GL_IS_PER_PATCH_EXT"/>
+        <enum value="0x92E8" name="GL_VERTEX_SUBROUTINE"/>
+        <enum value="0x92E9" name="GL_TESS_CONTROL_SUBROUTINE"/>
+        <enum value="0x92EA" name="GL_TESS_EVALUATION_SUBROUTINE"/>
+        <enum value="0x92EB" name="GL_GEOMETRY_SUBROUTINE"/>
+        <enum value="0x92EC" name="GL_FRAGMENT_SUBROUTINE"/>
+        <enum value="0x92ED" name="GL_COMPUTE_SUBROUTINE"/>
+        <enum value="0x92EE" name="GL_VERTEX_SUBROUTINE_UNIFORM"/>
+        <enum value="0x92EF" name="GL_TESS_CONTROL_SUBROUTINE_UNIFORM"/>
+        <enum value="0x92F0" name="GL_TESS_EVALUATION_SUBROUTINE_UNIFORM"/>
+        <enum value="0x92F1" name="GL_GEOMETRY_SUBROUTINE_UNIFORM"/>
+        <enum value="0x92F2" name="GL_FRAGMENT_SUBROUTINE_UNIFORM"/>
+        <enum value="0x92F3" name="GL_COMPUTE_SUBROUTINE_UNIFORM"/>
+        <enum value="0x92F4" name="GL_TRANSFORM_FEEDBACK_VARYING"/>
+        <enum value="0x92F5" name="GL_ACTIVE_RESOURCES"/>
+        <enum value="0x92F6" name="GL_MAX_NAME_LENGTH"/>
+        <enum value="0x92F7" name="GL_MAX_NUM_ACTIVE_VARIABLES"/>
+        <enum value="0x92F8" name="GL_MAX_NUM_COMPATIBLE_SUBROUTINES"/>
+        <enum value="0x92F9" name="GL_NAME_LENGTH"/>
+        <enum value="0x92FA" name="GL_TYPE"/>
+        <enum value="0x92FB" name="GL_ARRAY_SIZE"/>
+        <enum value="0x92FC" name="GL_OFFSET"/>
+        <enum value="0x92FD" name="GL_BLOCK_INDEX"/>
+        <enum value="0x92FE" name="GL_ARRAY_STRIDE"/>
+        <enum value="0x92FF" name="GL_MATRIX_STRIDE"/>
+        <enum value="0x9300" name="GL_IS_ROW_MAJOR"/>
+        <enum value="0x9301" name="GL_ATOMIC_COUNTER_BUFFER_INDEX"/>
+        <enum value="0x9302" name="GL_BUFFER_BINDING"/>
+        <enum value="0x9303" name="GL_BUFFER_DATA_SIZE"/>
+        <enum value="0x9304" name="GL_NUM_ACTIVE_VARIABLES"/>
+        <enum value="0x9305" name="GL_ACTIVE_VARIABLES"/>
+        <enum value="0x9306" name="GL_REFERENCED_BY_VERTEX_SHADER"/>
+        <enum value="0x9307" name="GL_REFERENCED_BY_TESS_CONTROL_SHADER"/>
+        <enum value="0x9307" name="GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT"/>
+        <enum value="0x9308" name="GL_REFERENCED_BY_TESS_EVALUATION_SHADER"/>
+        <enum value="0x9308" name="GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT"/>
+        <enum value="0x9309" name="GL_REFERENCED_BY_GEOMETRY_SHADER"/>
+        <enum value="0x9309" name="GL_REFERENCED_BY_GEOMETRY_SHADER_EXT"/>
+        <enum value="0x930A" name="GL_REFERENCED_BY_FRAGMENT_SHADER"/>
+        <enum value="0x930B" name="GL_REFERENCED_BY_COMPUTE_SHADER"/>
+        <enum value="0x930C" name="GL_TOP_LEVEL_ARRAY_SIZE"/>
+        <enum value="0x930D" name="GL_TOP_LEVEL_ARRAY_STRIDE"/>
+        <enum value="0x930E" name="GL_LOCATION"/>
+        <enum value="0x930F" name="GL_LOCATION_INDEX"/>
+        <enum value="0x9310" name="GL_FRAMEBUFFER_DEFAULT_WIDTH"/>
+        <enum value="0x9311" name="GL_FRAMEBUFFER_DEFAULT_HEIGHT"/>
+        <enum value="0x9312" name="GL_FRAMEBUFFER_DEFAULT_LAYERS"/>
+        <enum value="0x9312" name="GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT"/>
+        <enum value="0x9313" name="GL_FRAMEBUFFER_DEFAULT_SAMPLES"/>
+        <enum value="0x9314" name="GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS"/>
+        <enum value="0x9315" name="GL_MAX_FRAMEBUFFER_WIDTH"/>
+        <enum value="0x9316" name="GL_MAX_FRAMEBUFFER_HEIGHT"/>
+        <enum value="0x9317" name="GL_MAX_FRAMEBUFFER_LAYERS"/>
+        <enum value="0x9317" name="GL_MAX_FRAMEBUFFER_LAYERS_EXT"/>
+        <enum value="0x9318" name="GL_MAX_FRAMEBUFFER_SAMPLES"/>
+            <unused start="0x9319" end="0x9338"/>
+        <enum value="0x9339" name="GL_WARP_SIZE_NV"/>
+        <enum value="0x933A" name="GL_WARPS_PER_SM_NV"/>
+        <enum value="0x933B" name="GL_SM_COUNT_NV"/>
+            <unused start="0x933C" end="0x9343"/>
+        <enum value="0x9344" name="GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB"/>
+        <enum value="0x9345" name="GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB"/>
+            <unused start="0x9346" end="0x9349"/>
+        <enum value="0x934A" name="GL_LOCATION_COMPONENT"/>
+        <enum value="0x934B" name="GL_TRANSFORM_FEEDBACK_BUFFER_INDEX"/>
+        <enum value="0x934C" name="GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE"/>
+            <unused start="0x934D" end="0x9364"/>
+        <enum value="0x9365" name="GL_CLEAR_TEXTURE"/>
+            <unused start="0x9366" end="0x937F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x9380" end="0x939F" vendor="ARB">
+        <enum value="0x9380" name="GL_NUM_SAMPLE_COUNTS"/>
+            <unused start="0x9381" end="0x939F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x93A0" end="0x93AF" vendor="ANGLE" comment="Khronos bug 8100">
+        <enum value="0x93A0" name="GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE"/>
+        <enum value="0x93A1" name="GL_BGRA8_EXT"/>
+        <enum value="0x93A2" name="GL_TEXTURE_USAGE_ANGLE"/>
+        <enum value="0x93A3" name="GL_FRAMEBUFFER_ATTACHMENT_ANGLE"/>
+        <enum value="0x93A4" name="GL_PACK_REVERSE_ROW_ORDER_ANGLE"/>
+            <unused start="0x93A5"/>
+        <enum value="0x93A6" name="GL_PROGRAM_BINARY_ANGLE"/>
+            <unused start="0x93A7" end="0x93AF"/>
+    </enums>
+
+    <enums namespace="GL" start="0x93B0" end="0x93EF" vendor="OES" comment="Khronos bug 8853">
+        <enum value="0x93B0" name="GL_COMPRESSED_RGBA_ASTC_4x4_KHR"/>
+        <enum value="0x93B1" name="GL_COMPRESSED_RGBA_ASTC_5x4_KHR"/>
+        <enum value="0x93B2" name="GL_COMPRESSED_RGBA_ASTC_5x5_KHR"/>
+        <enum value="0x93B3" name="GL_COMPRESSED_RGBA_ASTC_6x5_KHR"/>
+        <enum value="0x93B4" name="GL_COMPRESSED_RGBA_ASTC_6x6_KHR"/>
+        <enum value="0x93B5" name="GL_COMPRESSED_RGBA_ASTC_8x5_KHR"/>
+        <enum value="0x93B6" name="GL_COMPRESSED_RGBA_ASTC_8x6_KHR"/>
+        <enum value="0x93B7" name="GL_COMPRESSED_RGBA_ASTC_8x8_KHR"/>
+        <enum value="0x93B8" name="GL_COMPRESSED_RGBA_ASTC_10x5_KHR"/>
+        <enum value="0x93B9" name="GL_COMPRESSED_RGBA_ASTC_10x6_KHR"/>
+        <enum value="0x93BA" name="GL_COMPRESSED_RGBA_ASTC_10x8_KHR"/>
+        <enum value="0x93BB" name="GL_COMPRESSED_RGBA_ASTC_10x10_KHR"/>
+        <enum value="0x93BC" name="GL_COMPRESSED_RGBA_ASTC_12x10_KHR"/>
+        <enum value="0x93BD" name="GL_COMPRESSED_RGBA_ASTC_12x12_KHR"/>
+            <unused start="0x93BE" end="0x93BF"/>
+        <enum value="0x93C0" name="GL_COMPRESSED_RGBA_ASTC_3x3x3_OES"/>
+        <enum value="0x93C1" name="GL_COMPRESSED_RGBA_ASTC_4x3x3_OES"/>
+        <enum value="0x93C2" name="GL_COMPRESSED_RGBA_ASTC_4x4x3_OES"/>
+        <enum value="0x93C3" name="GL_COMPRESSED_RGBA_ASTC_4x4x4_OES"/>
+        <enum value="0x93C4" name="GL_COMPRESSED_RGBA_ASTC_5x4x4_OES"/>
+        <enum value="0x93C5" name="GL_COMPRESSED_RGBA_ASTC_5x5x4_OES"/>
+        <enum value="0x93C6" name="GL_COMPRESSED_RGBA_ASTC_5x5x5_OES"/>
+        <enum value="0x93C7" name="GL_COMPRESSED_RGBA_ASTC_6x5x5_OES"/>
+        <enum value="0x93C8" name="GL_COMPRESSED_RGBA_ASTC_6x6x5_OES"/>
+        <enum value="0x93C9" name="GL_COMPRESSED_RGBA_ASTC_6x6x6_OES"/>
+            <unused start="0x93CA" end="0x93CF"/>
+        <enum value="0x93D0" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR"/>
+        <enum value="0x93D1" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR"/>
+        <enum value="0x93D2" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR"/>
+        <enum value="0x93D3" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR"/>
+        <enum value="0x93D4" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR"/>
+        <enum value="0x93D5" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR"/>
+        <enum value="0x93D6" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR"/>
+        <enum value="0x93D7" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR"/>
+        <enum value="0x93D8" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR"/>
+        <enum value="0x93D9" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR"/>
+        <enum value="0x93DA" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR"/>
+        <enum value="0x93DB" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR"/>
+        <enum value="0x93DC" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR"/>
+        <enum value="0x93DD" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"/>
+            <unused start="0x93DE" end="0x93DF"/>
+        <enum value="0x93E0" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES"/>
+        <enum value="0x93E1" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES"/>
+        <enum value="0x93E2" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES"/>
+        <enum value="0x93E3" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES"/>
+        <enum value="0x93E4" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES"/>
+        <enum value="0x93E5" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES"/>
+        <enum value="0x93E6" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES"/>
+        <enum value="0x93E7" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES"/>
+        <enum value="0x93E8" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES"/>
+        <enum value="0x93E9" name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES"/>
+            <unused start="0x93EA" end="0x93EF"/>
+    </enums>
+
+    <enums namespace="GL" start="0x93F0" end="0x94EF" vendor="APPLE" comment="Khronos bug 10233">
+        <enum value="0x93F0" name="GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG"/>
+        <enum value="0x93F1" name="GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG"/>
+            <unused start="0x93F2" end="0x94EF"/>
+    </enums>
+
+    <enums namespace="GL" start="0x94F0" end="0x950F" vendor="INTEL" comment="Khronos bug 11345">
+        <enum value="0x94F0" name="GL_PERFQUERY_COUNTER_EVENT_INTEL"/>
+        <enum value="0x94F1" name="GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL"/>
+        <enum value="0x94F2" name="GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL"/>
+        <enum value="0x94F3" name="GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL"/>
+        <enum value="0x94F4" name="GL_PERFQUERY_COUNTER_RAW_INTEL"/>
+        <enum value="0x94F5" name="GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL"/>
+            <unused start="0x94F6" end="0x94F7"/>
+        <enum value="0x94F8" name="GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL"/>
+        <enum value="0x94F9" name="GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL"/>
+        <enum value="0x94FA" name="GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL"/>
+        <enum value="0x94FB" name="GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL"/>
+        <enum value="0x94FC" name="GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL"/>
+        <enum value="0x94FD" name="GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL"/>
+        <enum value="0x94FE" name="GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL"/>
+        <enum value="0x94FF" name="GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL"/>
+        <enum value="0x9500" name="GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL"/>
+            <unused start="0x9501" end="0x950F"/>
+    </enums>
+
+    <enums namespace="GL" start="0x9510" end="0x952F" vendor="Broadcom" comment="Khronos bug 12203">
+            <unused start="0x9510" end="0x952F"/>
+    </enums>
+
+<!-- Enums reservable for future use. To reserve a new range, allocate one
+     or more multiples of 16 starting at the lowest available point in this
+     block and note it in a new <enums> block immediately above.
+
+     Please remember that new enumerant allocations must be obtained by
+     request to the Khronos API registrar (see comments at the top of this
+     file) File requests in the Khronos Bugzilla, OpenGL project, Registry
+     component. -->
+
+    <enums namespace="GL" start="0x9530" end="99999" vendor="ARB" comment="RESERVED FOR FUTURE ALLOCATIONS BY KHRONOS">
+        <unused start="0x9530" end="99999"/>
+    </enums>
+
+<!-- Historical large block allocations, all unused except (in older days) by IBM -->
+    <enums namespace="GL" start="100000" end="100999" vendor="ARB" comment="GLU enums"/>
+    <enums namespace="GL" start="101000" end="101999" vendor="ARB" comment="Conformance test enums"/>
+    <enums namespace="GL" start="102000" end="102999" vendor="ARB" comment="Unused, unlikely to ever be used"/>
+
+    <enums namespace="GL" start="103000" end="103999" vendor="IBM" comment="IBM is out of the graphics hardware business. Most of this range will remain unused.">
+        <enum value="0x19262" name="GL_RASTER_POSITION_UNCLIPPED_IBM"/>
+        <enum value="103050" name="GL_CULL_VERTEX_IBM"/>
+        <enum value="103060" name="GL_ALL_STATIC_DATA_IBM"/>
+        <enum value="103061" name="GL_STATIC_VERTEX_ARRAY_IBM"/>
+        <enum value="103070" name="GL_VERTEX_ARRAY_LIST_IBM"/>
+        <enum value="103071" name="GL_NORMAL_ARRAY_LIST_IBM"/>
+        <enum value="103072" name="GL_COLOR_ARRAY_LIST_IBM"/>
+        <enum value="103073" name="GL_INDEX_ARRAY_LIST_IBM"/>
+        <enum value="103074" name="GL_TEXTURE_COORD_ARRAY_LIST_IBM"/>
+        <enum value="103075" name="GL_EDGE_FLAG_ARRAY_LIST_IBM"/>
+        <enum value="103076" name="GL_FOG_COORDINATE_ARRAY_LIST_IBM"/>
+        <enum value="103077" name="GL_SECONDARY_COLOR_ARRAY_LIST_IBM"/>
+        <enum value="103080" name="GL_VERTEX_ARRAY_LIST_STRIDE_IBM"/>
+        <enum value="103081" name="GL_NORMAL_ARRAY_LIST_STRIDE_IBM"/>
+        <enum value="103082" name="GL_COLOR_ARRAY_LIST_STRIDE_IBM"/>
+        <enum value="103083" name="GL_INDEX_ARRAY_LIST_STRIDE_IBM"/>
+        <enum value="103084" name="GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM"/>
+        <enum value="103085" name="GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM"/>
+        <enum value="103086" name="GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM"/>
+        <enum value="103087" name="GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM"/>
+    </enums>
+
+    <enums namespace="GL" start="104000" end="104999" vendor="NEC" comment="NEC may be out of the graphics hardware business?"/>
+    <enums namespace="GL" start="105000" end="105999" vendor="Compaq" comment="Compaq was acquired by HP"/>
+    <enums namespace="GL" start="106000" end="106999" vendor="KPC" comment="Kubota Pacific is out of business"/>
+    <enums namespace="GL" start="107000" end="107999" vendor="PGI" comment="Portland Graphics was acquired by Template Graphics, which is out of business">
+            <!-- lots of <unused> areas here which won't be computed yet -->
+        <enum value="0x1A1F8" name="GL_PREFER_DOUBLEBUFFER_HINT_PGI"/>
+        <enum value="0x1A1FD" name="GL_CONSERVE_MEMORY_HINT_PGI"/>
+        <enum value="0x1A1FE" name="GL_RECLAIM_MEMORY_HINT_PGI"/>
+        <enum value="0x1A202" name="GL_NATIVE_GRAPHICS_HANDLE_PGI"/>
+        <enum value="0x1A203" name="GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI"/>
+        <enum value="0x1A204" name="GL_NATIVE_GRAPHICS_END_HINT_PGI"/>
+        <enum value="0x1A20C" name="GL_ALWAYS_FAST_HINT_PGI"/>
+        <enum value="0x1A20D" name="GL_ALWAYS_SOFT_HINT_PGI"/>
+        <enum value="0x1A20E" name="GL_ALLOW_DRAW_OBJ_HINT_PGI"/>
+        <enum value="0x1A20F" name="GL_ALLOW_DRAW_WIN_HINT_PGI"/>
+        <enum value="0x1A210" name="GL_ALLOW_DRAW_FRG_HINT_PGI"/>
+        <enum value="0x1A211" name="GL_ALLOW_DRAW_MEM_HINT_PGI"/>
+        <enum value="0x1A216" name="GL_STRICT_DEPTHFUNC_HINT_PGI"/>
+        <enum value="0x1A217" name="GL_STRICT_LIGHTING_HINT_PGI"/>
+        <enum value="0x1A218" name="GL_STRICT_SCISSOR_HINT_PGI"/>
+        <enum value="0x1A219" name="GL_FULL_STIPPLE_HINT_PGI"/>
+        <enum value="0x1A220" name="GL_CLIP_NEAR_HINT_PGI"/>
+        <enum value="0x1A221" name="GL_CLIP_FAR_HINT_PGI"/>
+        <enum value="0x1A222" name="GL_WIDE_LINE_HINT_PGI"/>
+        <enum value="0x1A223" name="GL_BACK_NORMALS_HINT_PGI"/>
+        <enum value="0x1A22A" name="GL_VERTEX_DATA_HINT_PGI"/>
+        <enum value="0x1A22B" name="GL_VERTEX_CONSISTENT_HINT_PGI"/>
+        <enum value="0x1A22C" name="GL_MATERIAL_SIDE_HINT_PGI"/>
+        <enum value="0x1A22D" name="GL_MAX_VERTEX_HINT_PGI"/>
+    </enums>
+
+    <enums namespace="GL" start="108000" end="108999" vendor="ES" comment="Evans and Sutherland is out of the graphics hardware business"/>
+
+    <!-- SECTION: GL command definitions. -->
+    <commands namespace="GL">
+        <command>
+            <proto>void <name>glAccum</name></proto>
+            <param group="AccumOp"><ptype>GLenum</ptype> <name>op</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>value</name></param>
+            <glx type="render" opcode="137"/>
+        </command>
+        <command>
+            <proto>void <name>glAccumxOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>op</name></param>
+            <param><ptype>GLfixed</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glActiveProgramEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+        </command>
+        <command>
+            <proto>void <name>glActiveShaderProgram</name></proto>
+            <param><ptype>GLuint</ptype> <name>pipeline</name></param>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+        </command>
+        <command>
+            <proto>void <name>glActiveShaderProgramEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>pipeline</name></param>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+        </command>
+        <command>
+            <proto>void <name>glActiveStencilFaceEXT</name></proto>
+            <param group="StencilFaceDirection"><ptype>GLenum</ptype> <name>face</name></param>
+            <glx type="render" opcode="4220"/>
+        </command>
+        <command>
+            <proto>void <name>glActiveTexture</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texture</name></param>
+            <glx type="render" opcode="197"/>
+        </command>
+        <command>
+            <proto>void <name>glActiveTextureARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texture</name></param>
+            <alias name="glActiveTexture"/>
+            <glx type="render" opcode="197"/>
+        </command>
+        <command>
+            <proto>void <name>glActiveVaryingNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param len="COMPSIZE(name)">const <ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glAlphaFragmentOp1ATI</name></proto>
+            <param group="FragmentOpATI"><ptype>GLenum</ptype> <name>op</name></param>
+            <param><ptype>GLuint</ptype> <name>dst</name></param>
+            <param><ptype>GLuint</ptype> <name>dstMod</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1Rep</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1Mod</name></param>
+        </command>
+        <command>
+            <proto>void <name>glAlphaFragmentOp2ATI</name></proto>
+            <param group="FragmentOpATI"><ptype>GLenum</ptype> <name>op</name></param>
+            <param><ptype>GLuint</ptype> <name>dst</name></param>
+            <param><ptype>GLuint</ptype> <name>dstMod</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1Rep</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1Mod</name></param>
+            <param><ptype>GLuint</ptype> <name>arg2</name></param>
+            <param><ptype>GLuint</ptype> <name>arg2Rep</name></param>
+            <param><ptype>GLuint</ptype> <name>arg2Mod</name></param>
+        </command>
+        <command>
+            <proto>void <name>glAlphaFragmentOp3ATI</name></proto>
+            <param group="FragmentOpATI"><ptype>GLenum</ptype> <name>op</name></param>
+            <param><ptype>GLuint</ptype> <name>dst</name></param>
+            <param><ptype>GLuint</ptype> <name>dstMod</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1Rep</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1Mod</name></param>
+            <param><ptype>GLuint</ptype> <name>arg2</name></param>
+            <param><ptype>GLuint</ptype> <name>arg2Rep</name></param>
+            <param><ptype>GLuint</ptype> <name>arg2Mod</name></param>
+            <param><ptype>GLuint</ptype> <name>arg3</name></param>
+            <param><ptype>GLuint</ptype> <name>arg3Rep</name></param>
+            <param><ptype>GLuint</ptype> <name>arg3Mod</name></param>
+        </command>
+        <command>
+            <proto>void <name>glAlphaFunc</name></proto>
+            <param group="AlphaFunction"><ptype>GLenum</ptype> <name>func</name></param>
+            <param><ptype>GLfloat</ptype> <name>ref</name></param>
+            <glx type="render" opcode="159"/>
+        </command>
+        <command>
+            <proto>void <name>glAlphaFuncQCOM</name></proto>
+            <param><ptype>GLenum</ptype> <name>func</name></param>
+            <param><ptype>GLclampf</ptype> <name>ref</name></param>
+        </command>
+        <command>
+            <proto>void <name>glAlphaFuncx</name></proto>
+            <param><ptype>GLenum</ptype> <name>func</name></param>
+            <param><ptype>GLfixed</ptype> <name>ref</name></param>
+        </command>
+        <command>
+            <proto>void <name>glAlphaFuncxOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>func</name></param>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>ref</name></param>
+        </command>
+        <command>
+            <proto>void <name>glApplyTextureEXT</name></proto>
+            <param group="LightTextureModeEXT"><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glAreProgramsResidentNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>programs</name></param>
+            <param group="Boolean" len="n"><ptype>GLboolean</ptype> *<name>residences</name></param>
+            <glx type="vendor" opcode="1293"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glAreTexturesResident</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="Texture" len="n">const <ptype>GLuint</ptype> *<name>textures</name></param>
+            <param group="Boolean" len="n"><ptype>GLboolean</ptype> *<name>residences</name></param>
+            <glx type="single" opcode="143"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glAreTexturesResidentEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="Texture" len="n">const <ptype>GLuint</ptype> *<name>textures</name></param>
+            <param group="Boolean" len="n"><ptype>GLboolean</ptype> *<name>residences</name></param>
+            <glx type="vendor" opcode="11"/>
+        </command>
+        <command>
+            <proto>void <name>glArrayElement</name></proto>
+            <param><ptype>GLint</ptype> <name>i</name></param>
+        </command>
+        <command>
+            <proto>void <name>glArrayElementEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>i</name></param>
+            <alias name="glArrayElement"/>
+        </command>
+        <command>
+            <proto>void <name>glArrayObjectATI</name></proto>
+            <param group="EnableCap"><ptype>GLenum</ptype> <name>array</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="ScalarType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLuint</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glAsyncMarkerSGIX</name></proto>
+            <param><ptype>GLuint</ptype> <name>marker</name></param>
+        </command>
+        <command>
+            <proto>void <name>glAttachObjectARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>containerObj</name></param>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>obj</name></param>
+            <alias name="glAttachShader"/>
+        </command>
+        <command>
+            <proto>void <name>glAttachShader</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>shader</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBegin</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <glx type="render" opcode="4"/>
+        </command>
+        <command>
+            <proto>void <name>glBeginConditionalRender</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="TypeEnum"><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBeginConditionalRenderNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="TypeEnum"><ptype>GLenum</ptype> <name>mode</name></param>
+            <alias name="glBeginConditionalRender"/>
+            <glx type="render" opcode="348"/>
+        </command>
+        <command>
+            <proto>void <name>glBeginConditionalRenderNVX</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBeginFragmentShaderATI</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glBeginOcclusionQueryNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBeginPerfMonitorAMD</name></proto>
+            <param><ptype>GLuint</ptype> <name>monitor</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBeginPerfQueryINTEL</name></proto>
+            <param><ptype>GLuint</ptype> <name>queryHandle</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBeginQuery</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <glx type="render" opcode="231"/>
+        </command>
+        <command>
+            <proto>void <name>glBeginQueryARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <alias name="glBeginQuery"/>
+        </command>
+        <command>
+            <proto>void <name>glBeginQueryEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBeginQueryIndexed</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBeginTransformFeedback</name></proto>
+            <param><ptype>GLenum</ptype> <name>primitiveMode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBeginTransformFeedbackEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>primitiveMode</name></param>
+            <alias name="glBeginTransformFeedback"/>
+        </command>
+        <command>
+            <proto>void <name>glBeginTransformFeedbackNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>primitiveMode</name></param>
+            <alias name="glBeginTransformFeedback"/>
+        </command>
+        <command>
+            <proto>void <name>glBeginVertexShaderEXT</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glBeginVideoCaptureNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_capture_slot</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindAttribLocation</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param>const <ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindAttribLocationARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>programObj</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param>const <ptype>GLcharARB</ptype> *<name>name</name></param>
+            <alias name="glBindAttribLocation"/>
+        </command>
+        <command>
+            <proto>void <name>glBindBuffer</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindBufferARB</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <alias name="glBindBuffer"/>
+        </command>
+        <command>
+            <proto>void <name>glBindBufferBase</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindBufferBaseEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <alias name="glBindBufferBase"/>
+        </command>
+        <command>
+            <proto>void <name>glBindBufferBaseNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <alias name="glBindBufferBase"/>
+        </command>
+        <command>
+            <proto>void <name>glBindBufferOffsetEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindBufferOffsetNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+            <alias name="glBindBufferOffsetEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glBindBufferRange</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>size</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindBufferRangeEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>size</name></param>
+            <alias name="glBindBufferRange"/>
+        </command>
+        <command>
+            <proto>void <name>glBindBufferRangeNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>size</name></param>
+            <alias name="glBindBufferRange"/>
+        </command>
+        <command>
+            <proto>void <name>glBindBuffersBase</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>buffers</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindBuffersRange</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>buffers</name></param>
+            <param len="count">const <ptype>GLintptr</ptype> *<name>offsets</name></param>
+            <param len="count">const <ptype>GLsizeiptr</ptype> *<name>sizes</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindFragDataLocation</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>color</name></param>
+            <param len="COMPSIZE(name)">const <ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindFragDataLocationEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>color</name></param>
+            <param len="COMPSIZE(name)">const <ptype>GLchar</ptype> *<name>name</name></param>
+            <alias name="glBindFragDataLocation"/>
+        </command>
+        <command>
+            <proto>void <name>glBindFragDataLocationIndexed</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>colorNumber</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param>const <ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindFragmentShaderATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindFramebuffer</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <glx type="render" opcode="236"/>
+        </command>
+        <command>
+            <proto>void <name>glBindFramebufferEXT</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <glx type="render" opcode="4319"/>
+        </command>
+        <command>
+            <proto>void <name>glBindFramebufferOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>framebuffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindImageTexture</name></proto>
+            <param><ptype>GLuint</ptype> <name>unit</name></param>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>layered</name></param>
+            <param><ptype>GLint</ptype> <name>layer</name></param>
+            <param><ptype>GLenum</ptype> <name>access</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindImageTextureEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>layered</name></param>
+            <param><ptype>GLint</ptype> <name>layer</name></param>
+            <param><ptype>GLenum</ptype> <name>access</name></param>
+            <param><ptype>GLint</ptype> <name>format</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindImageTextures</name></proto>
+            <param><ptype>GLuint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>textures</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glBindLightParameterEXT</name></proto>
+            <param group="LightName"><ptype>GLenum</ptype> <name>light</name></param>
+            <param group="LightParameter"><ptype>GLenum</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glBindMaterialParameterEXT</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="MaterialParameter"><ptype>GLenum</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindMultiTextureEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glBindParameterEXT</name></proto>
+            <param group="VertexShaderParameterEXT"><ptype>GLenum</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindProgramARB</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <glx type="render" opcode="4180"/>
+        </command>
+        <command>
+            <proto>void <name>glBindProgramNV</name></proto>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <alias name="glBindProgramARB"/>
+            <glx type="render" opcode="4180"/>
+        </command>
+        <command>
+            <proto>void <name>glBindProgramPipeline</name></proto>
+            <param><ptype>GLuint</ptype> <name>pipeline</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindProgramPipelineEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>pipeline</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindRenderbuffer</name></proto>
+            <param group="RenderbufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+            <glx type="render" opcode="235"/>
+        </command>
+        <command>
+            <proto>void <name>glBindRenderbufferEXT</name></proto>
+            <param group="RenderbufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+            <glx type="render" opcode="4316"/>
+        </command>
+        <command>
+            <proto>void <name>glBindRenderbufferOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindSampler</name></proto>
+            <param><ptype>GLuint</ptype> <name>unit</name></param>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindSamplers</name></proto>
+            <param><ptype>GLuint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>samplers</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glBindTexGenParameterEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>unit</name></param>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindTexture</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <glx type="render" opcode="4117"/>
+        </command>
+        <command>
+            <proto>void <name>glBindTextureEXT</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <alias name="glBindTexture"/>
+            <glx type="render" opcode="4117"/>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glBindTextureUnitParameterEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>unit</name></param>
+            <param group="VertexShaderTextureUnitParameter"><ptype>GLenum</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindTextures</name></proto>
+            <param><ptype>GLuint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>textures</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindTransformFeedback</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindTransformFeedbackNV</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindVertexArray</name></proto>
+            <param><ptype>GLuint</ptype> <name>array</name></param>
+            <glx type="render" opcode="350"/>
+        </command>
+        <command>
+            <proto>void <name>glBindVertexArrayAPPLE</name></proto>
+            <param><ptype>GLuint</ptype> <name>array</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindVertexArrayOES</name></proto>
+            <param><ptype>GLuint</ptype> <name>array</name></param>
+            <alias name="glBindVertexArray"/>
+        </command>
+        <command>
+            <proto>void <name>glBindVertexBuffer</name></proto>
+            <param><ptype>GLuint</ptype> <name>bindingindex</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindVertexBuffers</name></proto>
+            <param><ptype>GLuint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>buffers</name></param>
+            <param len="count">const <ptype>GLintptr</ptype> *<name>offsets</name></param>
+            <param len="count">const <ptype>GLsizei</ptype> *<name>strides</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindVertexShaderEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindVideoCaptureStreamBufferNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_capture_slot</name></param>
+            <param><ptype>GLuint</ptype> <name>stream</name></param>
+            <param><ptype>GLenum</ptype> <name>frame_region</name></param>
+            <param group="BufferOffsetARB"><ptype>GLintptrARB</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBindVideoCaptureStreamTextureNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_capture_slot</name></param>
+            <param><ptype>GLuint</ptype> <name>stream</name></param>
+            <param><ptype>GLenum</ptype> <name>frame_region</name></param>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBinormal3bEXT</name></proto>
+            <param><ptype>GLbyte</ptype> <name>bx</name></param>
+            <param><ptype>GLbyte</ptype> <name>by</name></param>
+            <param><ptype>GLbyte</ptype> <name>bz</name></param>
+            <vecequiv name="glBinormal3bvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glBinormal3bvEXT</name></proto>
+            <param len="3">const <ptype>GLbyte</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBinormal3dEXT</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>bx</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>by</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>bz</name></param>
+            <vecequiv name="glBinormal3dvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glBinormal3dvEXT</name></proto>
+            <param group="CoordD" len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBinormal3fEXT</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>bx</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>by</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>bz</name></param>
+            <vecequiv name="glBinormal3fvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glBinormal3fvEXT</name></proto>
+            <param group="CoordF" len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBinormal3iEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>bx</name></param>
+            <param><ptype>GLint</ptype> <name>by</name></param>
+            <param><ptype>GLint</ptype> <name>bz</name></param>
+            <vecequiv name="glBinormal3ivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glBinormal3ivEXT</name></proto>
+            <param len="3">const <ptype>GLint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBinormal3sEXT</name></proto>
+            <param><ptype>GLshort</ptype> <name>bx</name></param>
+            <param><ptype>GLshort</ptype> <name>by</name></param>
+            <param><ptype>GLshort</ptype> <name>bz</name></param>
+            <vecequiv name="glBinormal3svEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glBinormal3svEXT</name></proto>
+            <param len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBinormalPointerEXT</name></proto>
+            <param group="BinormalPointerTypeEXT"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBitmap</name></proto>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>xorig</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>yorig</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>xmove</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>ymove</name></param>
+            <param len="COMPSIZE(width,height)">const <ptype>GLubyte</ptype> *<name>bitmap</name></param>
+            <glx type="render" opcode="5"/>
+            <glx type="render" opcode="311" name="glBitmapPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glBitmapxOES</name></proto>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLfixed</ptype> <name>xorig</name></param>
+            <param><ptype>GLfixed</ptype> <name>yorig</name></param>
+            <param><ptype>GLfixed</ptype> <name>xmove</name></param>
+            <param><ptype>GLfixed</ptype> <name>ymove</name></param>
+            <param len="COMPSIZE(width,height)">const <ptype>GLubyte</ptype> *<name>bitmap</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBlendBarrierNV</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glBlendBarrierKHR</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glBlendColor</name></proto>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>red</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>green</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>blue</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>alpha</name></param>
+            <glx type="render" opcode="4096"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendColorEXT</name></proto>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>red</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>green</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>blue</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>alpha</name></param>
+            <alias name="glBlendColor"/>
+            <glx type="render" opcode="4096"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendColorxOES</name></proto>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>red</name></param>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>green</name></param>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>blue</name></param>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>alpha</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBlendEquation</name></proto>
+            <param group="BlendEquationMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <glx type="render" opcode="4097"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendEquationEXT</name></proto>
+            <param group="BlendEquationModeEXT"><ptype>GLenum</ptype> <name>mode</name></param>
+            <alias name="glBlendEquation"/>
+            <glx type="render" opcode="4097"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendEquationIndexedAMD</name></proto>
+            <param><ptype>GLuint</ptype> <name>buf</name></param>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+            <alias name="glBlendEquationi"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendEquationOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBlendEquationSeparate</name></proto>
+            <param group="BlendEquationModeEXT"><ptype>GLenum</ptype> <name>modeRGB</name></param>
+            <param group="BlendEquationModeEXT"><ptype>GLenum</ptype> <name>modeAlpha</name></param>
+            <glx type="render" opcode="4228"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendEquationSeparateEXT</name></proto>
+            <param group="BlendEquationModeEXT"><ptype>GLenum</ptype> <name>modeRGB</name></param>
+            <param group="BlendEquationModeEXT"><ptype>GLenum</ptype> <name>modeAlpha</name></param>
+            <alias name="glBlendEquationSeparate"/>
+            <glx type="render" opcode="4228"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendEquationSeparateIndexedAMD</name></proto>
+            <param><ptype>GLuint</ptype> <name>buf</name></param>
+            <param><ptype>GLenum</ptype> <name>modeRGB</name></param>
+            <param><ptype>GLenum</ptype> <name>modeAlpha</name></param>
+            <alias name="glBlendEquationSeparatei"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendEquationSeparateOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>modeRGB</name></param>
+            <param><ptype>GLenum</ptype> <name>modeAlpha</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBlendEquationSeparatei</name></proto>
+            <param><ptype>GLuint</ptype> <name>buf</name></param>
+            <param><ptype>GLenum</ptype> <name>modeRGB</name></param>
+            <param><ptype>GLenum</ptype> <name>modeAlpha</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBlendEquationSeparateiARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>buf</name></param>
+            <param><ptype>GLenum</ptype> <name>modeRGB</name></param>
+            <param><ptype>GLenum</ptype> <name>modeAlpha</name></param>
+            <alias name="glBlendEquationSeparatei"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendEquationSeparateiEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>buf</name></param>
+            <param><ptype>GLenum</ptype> <name>modeRGB</name></param>
+            <param><ptype>GLenum</ptype> <name>modeAlpha</name></param>
+            <alias name="glBlendEquationSeparatei"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendEquationi</name></proto>
+            <param><ptype>GLuint</ptype> <name>buf</name></param>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBlendEquationiEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>buf</name></param>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+            <alias name="glBlendEquationi"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendEquationiARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>buf</name></param>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+            <alias name="glBlendEquationi"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendFunc</name></proto>
+            <param group="BlendingFactorSrc"><ptype>GLenum</ptype> <name>sfactor</name></param>
+            <param group="BlendingFactorDest"><ptype>GLenum</ptype> <name>dfactor</name></param>
+            <glx type="render" opcode="160"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendFuncIndexedAMD</name></proto>
+            <param><ptype>GLuint</ptype> <name>buf</name></param>
+            <param><ptype>GLenum</ptype> <name>src</name></param>
+            <param><ptype>GLenum</ptype> <name>dst</name></param>
+            <alias name="glBlendFunci"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendFuncSeparate</name></proto>
+            <param group="BlendFuncSeparateParameterEXT"><ptype>GLenum</ptype> <name>sfactorRGB</name></param>
+            <param group="BlendFuncSeparateParameterEXT"><ptype>GLenum</ptype> <name>dfactorRGB</name></param>
+            <param group="BlendFuncSeparateParameterEXT"><ptype>GLenum</ptype> <name>sfactorAlpha</name></param>
+            <param group="BlendFuncSeparateParameterEXT"><ptype>GLenum</ptype> <name>dfactorAlpha</name></param>
+            <glx type="render" opcode="4134"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendFuncSeparateEXT</name></proto>
+            <param group="BlendFuncSeparateParameterEXT"><ptype>GLenum</ptype> <name>sfactorRGB</name></param>
+            <param group="BlendFuncSeparateParameterEXT"><ptype>GLenum</ptype> <name>dfactorRGB</name></param>
+            <param group="BlendFuncSeparateParameterEXT"><ptype>GLenum</ptype> <name>sfactorAlpha</name></param>
+            <param group="BlendFuncSeparateParameterEXT"><ptype>GLenum</ptype> <name>dfactorAlpha</name></param>
+            <alias name="glBlendFuncSeparate"/>
+            <glx type="render" opcode="4134"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendFuncSeparateINGR</name></proto>
+            <param group="BlendFuncSeparateParameterEXT"><ptype>GLenum</ptype> <name>sfactorRGB</name></param>
+            <param group="BlendFuncSeparateParameterEXT"><ptype>GLenum</ptype> <name>dfactorRGB</name></param>
+            <param group="BlendFuncSeparateParameterEXT"><ptype>GLenum</ptype> <name>sfactorAlpha</name></param>
+            <param group="BlendFuncSeparateParameterEXT"><ptype>GLenum</ptype> <name>dfactorAlpha</name></param>
+            <alias name="glBlendFuncSeparate"/>
+            <glx type="render" opcode="4134"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendFuncSeparateIndexedAMD</name></proto>
+            <param><ptype>GLuint</ptype> <name>buf</name></param>
+            <param><ptype>GLenum</ptype> <name>srcRGB</name></param>
+            <param><ptype>GLenum</ptype> <name>dstRGB</name></param>
+            <param><ptype>GLenum</ptype> <name>srcAlpha</name></param>
+            <param><ptype>GLenum</ptype> <name>dstAlpha</name></param>
+            <alias name="glBlendFuncSeparatei"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendFuncSeparateOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>srcRGB</name></param>
+            <param><ptype>GLenum</ptype> <name>dstRGB</name></param>
+            <param><ptype>GLenum</ptype> <name>srcAlpha</name></param>
+            <param><ptype>GLenum</ptype> <name>dstAlpha</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBlendFuncSeparatei</name></proto>
+            <param><ptype>GLuint</ptype> <name>buf</name></param>
+            <param><ptype>GLenum</ptype> <name>srcRGB</name></param>
+            <param><ptype>GLenum</ptype> <name>dstRGB</name></param>
+            <param><ptype>GLenum</ptype> <name>srcAlpha</name></param>
+            <param><ptype>GLenum</ptype> <name>dstAlpha</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBlendFuncSeparateiARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>buf</name></param>
+            <param><ptype>GLenum</ptype> <name>srcRGB</name></param>
+            <param><ptype>GLenum</ptype> <name>dstRGB</name></param>
+            <param><ptype>GLenum</ptype> <name>srcAlpha</name></param>
+            <param><ptype>GLenum</ptype> <name>dstAlpha</name></param>
+            <alias name="glBlendFuncSeparatei"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendFuncSeparateiEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>buf</name></param>
+            <param><ptype>GLenum</ptype> <name>srcRGB</name></param>
+            <param><ptype>GLenum</ptype> <name>dstRGB</name></param>
+            <param><ptype>GLenum</ptype> <name>srcAlpha</name></param>
+            <param><ptype>GLenum</ptype> <name>dstAlpha</name></param>
+            <alias name="glBlendFuncSeparatei"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendFunci</name></proto>
+            <param><ptype>GLuint</ptype> <name>buf</name></param>
+            <param><ptype>GLenum</ptype> <name>src</name></param>
+            <param><ptype>GLenum</ptype> <name>dst</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBlendFunciARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>buf</name></param>
+            <param><ptype>GLenum</ptype> <name>src</name></param>
+            <param><ptype>GLenum</ptype> <name>dst</name></param>
+            <alias name="glBlendFunci"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendFunciEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>buf</name></param>
+            <param><ptype>GLenum</ptype> <name>src</name></param>
+            <param><ptype>GLenum</ptype> <name>dst</name></param>
+            <alias name="glBlendFunci"/>
+        </command>
+        <command>
+            <proto>void <name>glBlendParameteriNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBlitFramebuffer</name></proto>
+            <param><ptype>GLint</ptype> <name>srcX0</name></param>
+            <param><ptype>GLint</ptype> <name>srcY0</name></param>
+            <param><ptype>GLint</ptype> <name>srcX1</name></param>
+            <param><ptype>GLint</ptype> <name>srcY1</name></param>
+            <param><ptype>GLint</ptype> <name>dstX0</name></param>
+            <param><ptype>GLint</ptype> <name>dstY0</name></param>
+            <param><ptype>GLint</ptype> <name>dstX1</name></param>
+            <param><ptype>GLint</ptype> <name>dstY1</name></param>
+            <param group="ClearBufferMask"><ptype>GLbitfield</ptype> <name>mask</name></param>
+            <param><ptype>GLenum</ptype> <name>filter</name></param>
+            <glx type="render" opcode="4330"/>
+        </command>
+        <command>
+            <proto>void <name>glBlitFramebufferANGLE</name></proto>
+            <param><ptype>GLint</ptype> <name>srcX0</name></param>
+            <param><ptype>GLint</ptype> <name>srcY0</name></param>
+            <param><ptype>GLint</ptype> <name>srcX1</name></param>
+            <param><ptype>GLint</ptype> <name>srcY1</name></param>
+            <param><ptype>GLint</ptype> <name>dstX0</name></param>
+            <param><ptype>GLint</ptype> <name>dstY0</name></param>
+            <param><ptype>GLint</ptype> <name>dstX1</name></param>
+            <param><ptype>GLint</ptype> <name>dstY1</name></param>
+            <param><ptype>GLbitfield</ptype> <name>mask</name></param>
+            <param><ptype>GLenum</ptype> <name>filter</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBlitFramebufferEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>srcX0</name></param>
+            <param><ptype>GLint</ptype> <name>srcY0</name></param>
+            <param><ptype>GLint</ptype> <name>srcX1</name></param>
+            <param><ptype>GLint</ptype> <name>srcY1</name></param>
+            <param><ptype>GLint</ptype> <name>dstX0</name></param>
+            <param><ptype>GLint</ptype> <name>dstY0</name></param>
+            <param><ptype>GLint</ptype> <name>dstX1</name></param>
+            <param><ptype>GLint</ptype> <name>dstY1</name></param>
+            <param group="ClearBufferMask"><ptype>GLbitfield</ptype> <name>mask</name></param>
+            <param><ptype>GLenum</ptype> <name>filter</name></param>
+            <alias name="glBlitFramebuffer"/>
+            <glx type="render" opcode="4330"/>
+        </command>
+        <command>
+            <proto>void <name>glBlitFramebufferNV</name></proto>
+            <param><ptype>GLint</ptype> <name>srcX0</name></param>
+            <param><ptype>GLint</ptype> <name>srcY0</name></param>
+            <param><ptype>GLint</ptype> <name>srcX1</name></param>
+            <param><ptype>GLint</ptype> <name>srcY1</name></param>
+            <param><ptype>GLint</ptype> <name>dstX0</name></param>
+            <param><ptype>GLint</ptype> <name>dstY0</name></param>
+            <param><ptype>GLint</ptype> <name>dstX1</name></param>
+            <param><ptype>GLint</ptype> <name>dstY1</name></param>
+            <param><ptype>GLbitfield</ptype> <name>mask</name></param>
+            <param><ptype>GLenum</ptype> <name>filter</name></param>
+            <alias name="glBlitFramebuffer"/>
+        </command>
+        <command>
+            <proto>void <name>glBufferAddressRangeNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>address</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>length</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBufferData</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>size</name></param>
+            <param len="size">const void *<name>data</name></param>
+            <param group="BufferUsageARB"><ptype>GLenum</ptype> <name>usage</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBufferDataARB</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="BufferSizeARB"><ptype>GLsizeiptrARB</ptype> <name>size</name></param>
+            <param len="size">const void *<name>data</name></param>
+            <param group="BufferUsageARB"><ptype>GLenum</ptype> <name>usage</name></param>
+            <alias name="glBufferData"/>
+        </command>
+        <command>
+            <proto>void <name>glBufferParameteriAPPLE</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBufferStorage</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizeiptr</ptype> <name>size</name></param>
+            <param len="size">const void *<name>data</name></param>
+            <param><ptype>GLbitfield</ptype> <name>flags</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBufferSubData</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>size</name></param>
+            <param len="size">const void *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glBufferSubDataARB</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="BufferOffsetARB"><ptype>GLintptrARB</ptype> <name>offset</name></param>
+            <param group="BufferSizeARB"><ptype>GLsizeiptrARB</ptype> <name>size</name></param>
+            <param len="size">const void *<name>data</name></param>
+            <alias name="glBufferSubData"/>
+        </command>
+        <command>
+            <proto>void <name>glCallList</name></proto>
+            <param group="List"><ptype>GLuint</ptype> <name>list</name></param>
+            <glx type="render" opcode="1"/>
+        </command>
+        <command>
+            <proto>void <name>glCallLists</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="ListNameType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(n,type)">const void *<name>lists</name></param>
+            <glx type="render" opcode="2"/>
+        </command>
+        <command>
+            <proto><ptype>GLenum</ptype> <name>glCheckFramebufferStatus</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <glx type="vendor" opcode="1427"/>
+        </command>
+        <command>
+            <proto><ptype>GLenum</ptype> <name>glCheckFramebufferStatusEXT</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <alias name="glCheckFramebufferStatus"/>
+            <glx type="vendor" opcode="1427"/>
+        </command>
+        <command>
+            <proto><ptype>GLenum</ptype> <name>glCheckFramebufferStatusOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+        </command>
+        <command>
+            <proto group="FramebufferStatus"><ptype>GLenum</ptype> <name>glCheckNamedFramebufferStatusEXT</name></proto>
+            <param group="Framebuffer"><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClampColor</name></proto>
+            <param group="ClampColorTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ClampColorModeARB"><ptype>GLenum</ptype> <name>clamp</name></param>
+            <glx type="render" opcode="234"/>
+        </command>
+        <command>
+            <proto>void <name>glClampColorARB</name></proto>
+            <param group="ClampColorTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ClampColorModeARB"><ptype>GLenum</ptype> <name>clamp</name></param>
+            <alias name="glClampColor"/>
+            <glx type="render" opcode="234"/>
+        </command>
+        <command>
+            <proto>void <name>glClear</name></proto>
+            <param group="ClearBufferMask"><ptype>GLbitfield</ptype> <name>mask</name></param>
+            <glx type="render" opcode="127"/>
+        </command>
+        <command>
+            <proto>void <name>glClearAccum</name></proto>
+            <param><ptype>GLfloat</ptype> <name>red</name></param>
+            <param><ptype>GLfloat</ptype> <name>green</name></param>
+            <param><ptype>GLfloat</ptype> <name>blue</name></param>
+            <param><ptype>GLfloat</ptype> <name>alpha</name></param>
+            <glx type="render" opcode="128"/>
+        </command>
+        <command>
+            <proto>void <name>glClearAccumxOES</name></proto>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>red</name></param>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>green</name></param>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>blue</name></param>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>alpha</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClearBufferData</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type)">const void *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClearBufferSubData</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type)">const void *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClearBufferfi</name></proto>
+            <param><ptype>GLenum</ptype> <name>buffer</name></param>
+            <param group="DrawBufferName"><ptype>GLint</ptype> <name>drawbuffer</name></param>
+            <param><ptype>GLfloat</ptype> <name>depth</name></param>
+            <param><ptype>GLint</ptype> <name>stencil</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClearBufferfv</name></proto>
+            <param><ptype>GLenum</ptype> <name>buffer</name></param>
+            <param group="DrawBufferName"><ptype>GLint</ptype> <name>drawbuffer</name></param>
+            <param len="COMPSIZE(buffer)">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClearBufferiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>buffer</name></param>
+            <param group="DrawBufferName"><ptype>GLint</ptype> <name>drawbuffer</name></param>
+            <param len="COMPSIZE(buffer)">const <ptype>GLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClearBufferuiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>buffer</name></param>
+            <param group="DrawBufferName"><ptype>GLint</ptype> <name>drawbuffer</name></param>
+            <param len="COMPSIZE(buffer)">const <ptype>GLuint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClearColor</name></proto>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>red</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>green</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>blue</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>alpha</name></param>
+            <glx type="render" opcode="130"/>
+        </command>
+        <command>
+            <proto>void <name>glClearColorIiEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>red</name></param>
+            <param><ptype>GLint</ptype> <name>green</name></param>
+            <param><ptype>GLint</ptype> <name>blue</name></param>
+            <param><ptype>GLint</ptype> <name>alpha</name></param>
+            <glx type="render" opcode="4292"/>
+        </command>
+        <command>
+            <proto>void <name>glClearColorIuiEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>red</name></param>
+            <param><ptype>GLuint</ptype> <name>green</name></param>
+            <param><ptype>GLuint</ptype> <name>blue</name></param>
+            <param><ptype>GLuint</ptype> <name>alpha</name></param>
+            <glx type="render" opcode="4293"/>
+        </command>
+        <command>
+            <proto>void <name>glClearColorx</name></proto>
+            <param><ptype>GLfixed</ptype> <name>red</name></param>
+            <param><ptype>GLfixed</ptype> <name>green</name></param>
+            <param><ptype>GLfixed</ptype> <name>blue</name></param>
+            <param><ptype>GLfixed</ptype> <name>alpha</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClearColorxOES</name></proto>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>red</name></param>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>green</name></param>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>blue</name></param>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>alpha</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClearDepth</name></proto>
+            <param><ptype>GLdouble</ptype> <name>depth</name></param>
+            <glx type="render" opcode="132"/>
+        </command>
+        <command>
+            <proto>void <name>glClearDepthdNV</name></proto>
+            <param><ptype>GLdouble</ptype> <name>depth</name></param>
+            <glx type="render" opcode="4284"/>
+        </command>
+        <command>
+            <proto>void <name>glClearDepthf</name></proto>
+            <param><ptype>GLfloat</ptype> <name>d</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClearDepthfOES</name></proto>
+            <param group="ClampedFloat32"><ptype>GLclampf</ptype> <name>depth</name></param>
+            <glx type="render" opcode="4308"/>
+            <alias name="glClearDepthf"/>
+        </command>
+        <command>
+            <proto>void <name>glClearDepthx</name></proto>
+            <param><ptype>GLfixed</ptype> <name>depth</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClearDepthxOES</name></proto>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>depth</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClearIndex</name></proto>
+            <param group="MaskedColorIndexValueF"><ptype>GLfloat</ptype> <name>c</name></param>
+            <glx type="render" opcode="129"/>
+        </command>
+        <command>
+            <proto>void <name>glClearNamedBufferDataEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type)">const void *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClearNamedBufferSubDataEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>offset</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>size</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type)">const void *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClearStencil</name></proto>
+            <param group="StencilValue"><ptype>GLint</ptype> <name>s</name></param>
+            <glx type="render" opcode="131"/>
+        </command>
+        <command>
+            <proto>void <name>glClearTexImage</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type)">const void *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClearTexSubImage</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type)">const void *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClientActiveTexture</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texture</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClientActiveTextureARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texture</name></param>
+            <alias name="glClientActiveTexture"/>
+        </command>
+        <command>
+            <proto>void <name>glClientActiveVertexStreamATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClientAttribDefaultEXT</name></proto>
+            <param group="ClientAttribMask"><ptype>GLbitfield</ptype> <name>mask</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLenum</ptype> <name>glClientWaitSync</name></proto>
+            <param group="sync"><ptype>GLsync</ptype> <name>sync</name></param>
+            <param><ptype>GLbitfield</ptype> <name>flags</name></param>
+            <param><ptype>GLuint64</ptype> <name>timeout</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLenum</ptype> <name>glClientWaitSyncAPPLE</name></proto>
+            <param><ptype>GLsync</ptype> <name>sync</name></param>
+            <param><ptype>GLbitfield</ptype> <name>flags</name></param>
+            <param><ptype>GLuint64</ptype> <name>timeout</name></param>
+            <alias name="glClientWaitSync"/>
+        </command>
+        <command>
+            <proto>void <name>glClipPlane</name></proto>
+            <param group="ClipPlaneName"><ptype>GLenum</ptype> <name>plane</name></param>
+            <param len="4">const <ptype>GLdouble</ptype> *<name>equation</name></param>
+            <glx type="render" opcode="77"/>
+        </command>
+        <command>
+            <proto>void <name>glClipPlanef</name></proto>
+            <param><ptype>GLenum</ptype> <name>p</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>eqn</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClipPlanefIMG</name></proto>
+            <param><ptype>GLenum</ptype> <name>p</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>eqn</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClipPlanefOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>plane</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>equation</name></param>
+            <glx type="render" opcode="4312"/>
+        </command>
+        <command>
+            <proto>void <name>glClipPlanex</name></proto>
+            <param><ptype>GLenum</ptype> <name>plane</name></param>
+            <param len="4">const <ptype>GLfixed</ptype> *<name>equation</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClipPlanexIMG</name></proto>
+            <param><ptype>GLenum</ptype> <name>p</name></param>
+            <param len="4">const <ptype>GLfixed</ptype> *<name>eqn</name></param>
+        </command>
+        <command>
+            <proto>void <name>glClipPlanexOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>plane</name></param>
+            <param len="4">const <ptype>GLfixed</ptype> *<name>equation</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColor3b</name></proto>
+            <param group="ColorB"><ptype>GLbyte</ptype> <name>red</name></param>
+            <param group="ColorB"><ptype>GLbyte</ptype> <name>green</name></param>
+            <param group="ColorB"><ptype>GLbyte</ptype> <name>blue</name></param>
+            <vecequiv name="glColor3bv"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3bv</name></proto>
+            <param group="ColorB" len="3">const <ptype>GLbyte</ptype> *<name>v</name></param>
+            <glx type="render" opcode="6"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3d</name></proto>
+            <param group="ColorD"><ptype>GLdouble</ptype> <name>red</name></param>
+            <param group="ColorD"><ptype>GLdouble</ptype> <name>green</name></param>
+            <param group="ColorD"><ptype>GLdouble</ptype> <name>blue</name></param>
+            <vecequiv name="glColor3dv"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3dv</name></proto>
+            <param group="ColorD" len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="7"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3f</name></proto>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>red</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>green</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>blue</name></param>
+            <vecequiv name="glColor3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3fVertex3fSUN</name></proto>
+            <param><ptype>GLfloat</ptype> <name>r</name></param>
+            <param><ptype>GLfloat</ptype> <name>g</name></param>
+            <param><ptype>GLfloat</ptype> <name>b</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColor3fVertex3fvSUN</name></proto>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>c</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColor3fv</name></proto>
+            <param group="ColorF" len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="8"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3hNV</name></proto>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>red</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>green</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>blue</name></param>
+            <vecequiv name="glColor3hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3hvNV</name></proto>
+            <param group="Half16NV" len="3">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4244"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3i</name></proto>
+            <param group="ColorI"><ptype>GLint</ptype> <name>red</name></param>
+            <param group="ColorI"><ptype>GLint</ptype> <name>green</name></param>
+            <param group="ColorI"><ptype>GLint</ptype> <name>blue</name></param>
+            <vecequiv name="glColor3iv"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3iv</name></proto>
+            <param group="ColorI" len="3">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="9"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3s</name></proto>
+            <param group="ColorS"><ptype>GLshort</ptype> <name>red</name></param>
+            <param group="ColorS"><ptype>GLshort</ptype> <name>green</name></param>
+            <param group="ColorS"><ptype>GLshort</ptype> <name>blue</name></param>
+            <vecequiv name="glColor3sv"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3sv</name></proto>
+            <param group="ColorS" len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="10"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3ub</name></proto>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>red</name></param>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>green</name></param>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>blue</name></param>
+            <vecequiv name="glColor3ubv"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3ubv</name></proto>
+            <param group="ColorUB" len="3">const <ptype>GLubyte</ptype> *<name>v</name></param>
+            <glx type="render" opcode="11"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3ui</name></proto>
+            <param group="ColorUI"><ptype>GLuint</ptype> <name>red</name></param>
+            <param group="ColorUI"><ptype>GLuint</ptype> <name>green</name></param>
+            <param group="ColorUI"><ptype>GLuint</ptype> <name>blue</name></param>
+            <vecequiv name="glColor3uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3uiv</name></proto>
+            <param group="ColorUI" len="3">const <ptype>GLuint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="12"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3us</name></proto>
+            <param group="ColorUS"><ptype>GLushort</ptype> <name>red</name></param>
+            <param group="ColorUS"><ptype>GLushort</ptype> <name>green</name></param>
+            <param group="ColorUS"><ptype>GLushort</ptype> <name>blue</name></param>
+            <vecequiv name="glColor3usv"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3usv</name></proto>
+            <param group="ColorUS" len="3">const <ptype>GLushort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="13"/>
+        </command>
+        <command>
+            <proto>void <name>glColor3xOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>red</name></param>
+            <param><ptype>GLfixed</ptype> <name>green</name></param>
+            <param><ptype>GLfixed</ptype> <name>blue</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColor3xvOES</name></proto>
+            <param len="3">const <ptype>GLfixed</ptype> *<name>components</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColor4b</name></proto>
+            <param group="ColorB"><ptype>GLbyte</ptype> <name>red</name></param>
+            <param group="ColorB"><ptype>GLbyte</ptype> <name>green</name></param>
+            <param group="ColorB"><ptype>GLbyte</ptype> <name>blue</name></param>
+            <param group="ColorB"><ptype>GLbyte</ptype> <name>alpha</name></param>
+            <vecequiv name="glColor4bv"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4bv</name></proto>
+            <param group="ColorB" len="4">const <ptype>GLbyte</ptype> *<name>v</name></param>
+            <glx type="render" opcode="14"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4d</name></proto>
+            <param group="ColorD"><ptype>GLdouble</ptype> <name>red</name></param>
+            <param group="ColorD"><ptype>GLdouble</ptype> <name>green</name></param>
+            <param group="ColorD"><ptype>GLdouble</ptype> <name>blue</name></param>
+            <param group="ColorD"><ptype>GLdouble</ptype> <name>alpha</name></param>
+            <vecequiv name="glColor4dv"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4dv</name></proto>
+            <param group="ColorD" len="4">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="15"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4f</name></proto>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>red</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>green</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>blue</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>alpha</name></param>
+            <vecequiv name="glColor4fv"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4fNormal3fVertex3fSUN</name></proto>
+            <param><ptype>GLfloat</ptype> <name>r</name></param>
+            <param><ptype>GLfloat</ptype> <name>g</name></param>
+            <param><ptype>GLfloat</ptype> <name>b</name></param>
+            <param><ptype>GLfloat</ptype> <name>a</name></param>
+            <param><ptype>GLfloat</ptype> <name>nx</name></param>
+            <param><ptype>GLfloat</ptype> <name>ny</name></param>
+            <param><ptype>GLfloat</ptype> <name>nz</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColor4fNormal3fVertex3fvSUN</name></proto>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>c</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>n</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColor4fv</name></proto>
+            <param group="ColorF" len="4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="16"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4hNV</name></proto>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>red</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>green</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>blue</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>alpha</name></param>
+            <vecequiv name="glColor4hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4hvNV</name></proto>
+            <param group="Half16NV" len="4">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4245"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4i</name></proto>
+            <param group="ColorI"><ptype>GLint</ptype> <name>red</name></param>
+            <param group="ColorI"><ptype>GLint</ptype> <name>green</name></param>
+            <param group="ColorI"><ptype>GLint</ptype> <name>blue</name></param>
+            <param group="ColorI"><ptype>GLint</ptype> <name>alpha</name></param>
+            <vecequiv name="glColor4iv"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4iv</name></proto>
+            <param group="ColorI" len="4">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="17"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4s</name></proto>
+            <param group="ColorS"><ptype>GLshort</ptype> <name>red</name></param>
+            <param group="ColorS"><ptype>GLshort</ptype> <name>green</name></param>
+            <param group="ColorS"><ptype>GLshort</ptype> <name>blue</name></param>
+            <param group="ColorS"><ptype>GLshort</ptype> <name>alpha</name></param>
+            <vecequiv name="glColor4sv"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4sv</name></proto>
+            <param group="ColorS" len="4">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="18"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4ub</name></proto>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>red</name></param>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>green</name></param>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>blue</name></param>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>alpha</name></param>
+            <vecequiv name="glColor4ubv"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4ubVertex2fSUN</name></proto>
+            <param><ptype>GLubyte</ptype> <name>r</name></param>
+            <param><ptype>GLubyte</ptype> <name>g</name></param>
+            <param><ptype>GLubyte</ptype> <name>b</name></param>
+            <param><ptype>GLubyte</ptype> <name>a</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColor4ubVertex2fvSUN</name></proto>
+            <param len="4">const <ptype>GLubyte</ptype> *<name>c</name></param>
+            <param len="2">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColor4ubVertex3fSUN</name></proto>
+            <param><ptype>GLubyte</ptype> <name>r</name></param>
+            <param><ptype>GLubyte</ptype> <name>g</name></param>
+            <param><ptype>GLubyte</ptype> <name>b</name></param>
+            <param><ptype>GLubyte</ptype> <name>a</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColor4ubVertex3fvSUN</name></proto>
+            <param len="4">const <ptype>GLubyte</ptype> *<name>c</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColor4ubv</name></proto>
+            <param group="ColorUB" len="4">const <ptype>GLubyte</ptype> *<name>v</name></param>
+            <glx type="render" opcode="19"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4ui</name></proto>
+            <param group="ColorUI"><ptype>GLuint</ptype> <name>red</name></param>
+            <param group="ColorUI"><ptype>GLuint</ptype> <name>green</name></param>
+            <param group="ColorUI"><ptype>GLuint</ptype> <name>blue</name></param>
+            <param group="ColorUI"><ptype>GLuint</ptype> <name>alpha</name></param>
+            <vecequiv name="glColor4uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4uiv</name></proto>
+            <param group="ColorUI" len="4">const <ptype>GLuint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="20"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4us</name></proto>
+            <param group="ColorUS"><ptype>GLushort</ptype> <name>red</name></param>
+            <param group="ColorUS"><ptype>GLushort</ptype> <name>green</name></param>
+            <param group="ColorUS"><ptype>GLushort</ptype> <name>blue</name></param>
+            <param group="ColorUS"><ptype>GLushort</ptype> <name>alpha</name></param>
+            <vecequiv name="glColor4usv"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4usv</name></proto>
+            <param group="ColorUS" len="4">const <ptype>GLushort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="21"/>
+        </command>
+        <command>
+            <proto>void <name>glColor4x</name></proto>
+            <param><ptype>GLfixed</ptype> <name>red</name></param>
+            <param><ptype>GLfixed</ptype> <name>green</name></param>
+            <param><ptype>GLfixed</ptype> <name>blue</name></param>
+            <param><ptype>GLfixed</ptype> <name>alpha</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColor4xOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>red</name></param>
+            <param><ptype>GLfixed</ptype> <name>green</name></param>
+            <param><ptype>GLfixed</ptype> <name>blue</name></param>
+            <param><ptype>GLfixed</ptype> <name>alpha</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColor4xvOES</name></proto>
+            <param len="4">const <ptype>GLfixed</ptype> *<name>components</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColorFormatNV</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColorFragmentOp1ATI</name></proto>
+            <param group="FragmentOpATI"><ptype>GLenum</ptype> <name>op</name></param>
+            <param><ptype>GLuint</ptype> <name>dst</name></param>
+            <param><ptype>GLuint</ptype> <name>dstMask</name></param>
+            <param><ptype>GLuint</ptype> <name>dstMod</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1Rep</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1Mod</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColorFragmentOp2ATI</name></proto>
+            <param group="FragmentOpATI"><ptype>GLenum</ptype> <name>op</name></param>
+            <param><ptype>GLuint</ptype> <name>dst</name></param>
+            <param><ptype>GLuint</ptype> <name>dstMask</name></param>
+            <param><ptype>GLuint</ptype> <name>dstMod</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1Rep</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1Mod</name></param>
+            <param><ptype>GLuint</ptype> <name>arg2</name></param>
+            <param><ptype>GLuint</ptype> <name>arg2Rep</name></param>
+            <param><ptype>GLuint</ptype> <name>arg2Mod</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColorFragmentOp3ATI</name></proto>
+            <param group="FragmentOpATI"><ptype>GLenum</ptype> <name>op</name></param>
+            <param><ptype>GLuint</ptype> <name>dst</name></param>
+            <param><ptype>GLuint</ptype> <name>dstMask</name></param>
+            <param><ptype>GLuint</ptype> <name>dstMod</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1Rep</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1Mod</name></param>
+            <param><ptype>GLuint</ptype> <name>arg2</name></param>
+            <param><ptype>GLuint</ptype> <name>arg2Rep</name></param>
+            <param><ptype>GLuint</ptype> <name>arg2Mod</name></param>
+            <param><ptype>GLuint</ptype> <name>arg3</name></param>
+            <param><ptype>GLuint</ptype> <name>arg3Rep</name></param>
+            <param><ptype>GLuint</ptype> <name>arg3Mod</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColorMask</name></proto>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>red</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>green</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>blue</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>alpha</name></param>
+            <glx type="render" opcode="134"/>
+        </command>
+        <command>
+            <proto>void <name>glColorMaskIndexedEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>r</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>g</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>b</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>a</name></param>
+            <alias name="glColorMaski"/>
+        </command>
+        <command>
+            <proto>void <name>glColorMaski</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>r</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>g</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>b</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>a</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColorMaskiEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>r</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>g</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>b</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>a</name></param>
+            <alias name="glColorMaski"/>
+        </command>
+        <command>
+            <proto>void <name>glColorMaterial</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="ColorMaterialParameter"><ptype>GLenum</ptype> <name>mode</name></param>
+            <glx type="render" opcode="78"/>
+        </command>
+        <command>
+            <proto>void <name>glColorP3ui</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>color</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColorP3uiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>color</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColorP4ui</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>color</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColorP4uiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>color</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColorPointer</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="ColorPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(size,type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColorPointerEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="ColorPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="COMPSIZE(size,type,stride,count)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColorPointerListIBM</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="ColorPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLint</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(size,type,stride)">const void **<name>pointer</name></param>
+            <param><ptype>GLint</ptype> <name>ptrstride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColorPointervINTEL</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="VertexPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="4">const void **<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glColorSubTable</name></proto>
+            <param group="ColorTableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>start</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,count)">const void *<name>data</name></param>
+            <glx type="render" opcode="195"/>
+            <glx type="render" opcode="312" name="glColorSubTablePBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glColorSubTableEXT</name></proto>
+            <param group="ColorTableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>start</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,count)">const void *<name>data</name></param>
+            <alias name="glColorSubTable"/>
+        </command>
+        <command>
+            <proto>void <name>glColorTable</name></proto>
+            <param group="ColorTableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width)">const void *<name>table</name></param>
+            <glx type="render" opcode="2053"/>
+            <glx type="render" opcode="313" name="glColorTablePBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glColorTableEXT</name></proto>
+            <param group="ColorTableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalFormat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width)">const void *<name>table</name></param>
+            <alias name="glColorTable"/>
+        </command>
+        <command>
+            <proto>void <name>glColorTableParameterfv</name></proto>
+            <param group="ColorTableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ColorTableParameterPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="render" opcode="2054"/>
+        </command>
+        <command>
+            <proto>void <name>glColorTableParameterfvSGI</name></proto>
+            <param group="ColorTableTargetSGI"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ColorTableParameterPNameSGI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <alias name="glColorTableParameterfv"/>
+            <glx type="render" opcode="2054"/>
+        </command>
+        <command>
+            <proto>void <name>glColorTableParameteriv</name></proto>
+            <param group="ColorTableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ColorTableParameterPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="render" opcode="2055"/>
+        </command>
+        <command>
+            <proto>void <name>glColorTableParameterivSGI</name></proto>
+            <param group="ColorTableTargetSGI"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ColorTableParameterPNameSGI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glColorTableParameteriv"/>
+            <glx type="render" opcode="2055"/>
+        </command>
+        <command>
+            <proto>void <name>glColorTableSGI</name></proto>
+            <param group="ColorTableTargetSGI"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width)">const void *<name>table</name></param>
+            <alias name="glColorTable"/>
+            <glx type="render" opcode="2053"/>
+        </command>
+        <command>
+            <proto>void <name>glCombinerInputNV</name></proto>
+            <param group="CombinerStageNV"><ptype>GLenum</ptype> <name>stage</name></param>
+            <param group="CombinerPortionNV"><ptype>GLenum</ptype> <name>portion</name></param>
+            <param group="CombinerVariableNV"><ptype>GLenum</ptype> <name>variable</name></param>
+            <param group="CombinerRegisterNV"><ptype>GLenum</ptype> <name>input</name></param>
+            <param group="CombinerMappingNV"><ptype>GLenum</ptype> <name>mapping</name></param>
+            <param group="CombinerComponentUsageNV"><ptype>GLenum</ptype> <name>componentUsage</name></param>
+            <glx type="render" opcode="4140"/>
+        </command>
+        <command>
+            <proto>void <name>glCombinerOutputNV</name></proto>
+            <param group="CombinerStageNV"><ptype>GLenum</ptype> <name>stage</name></param>
+            <param group="CombinerPortionNV"><ptype>GLenum</ptype> <name>portion</name></param>
+            <param group="CombinerRegisterNV"><ptype>GLenum</ptype> <name>abOutput</name></param>
+            <param group="CombinerRegisterNV"><ptype>GLenum</ptype> <name>cdOutput</name></param>
+            <param group="CombinerRegisterNV"><ptype>GLenum</ptype> <name>sumOutput</name></param>
+            <param group="CombinerScaleNV"><ptype>GLenum</ptype> <name>scale</name></param>
+            <param group="CombinerBiasNV"><ptype>GLenum</ptype> <name>bias</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>abDotProduct</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>cdDotProduct</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>muxSum</name></param>
+            <glx type="render" opcode="4141"/>
+        </command>
+        <command>
+            <proto>void <name>glCombinerParameterfNV</name></proto>
+            <param group="CombinerParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfloat</ptype> <name>param</name></param>
+            <glx type="render" opcode="4136"/>
+        </command>
+        <command>
+            <proto>void <name>glCombinerParameterfvNV</name></proto>
+            <param group="CombinerParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="render" opcode="4137"/>
+        </command>
+        <command>
+            <proto>void <name>glCombinerParameteriNV</name></proto>
+            <param group="CombinerParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>param</name></param>
+            <glx type="render" opcode="4138"/>
+        </command>
+        <command>
+            <proto>void <name>glCombinerParameterivNV</name></proto>
+            <param group="CombinerParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="render" opcode="4139"/>
+        </command>
+        <command>
+            <proto>void <name>glCombinerStageParameterfvNV</name></proto>
+            <param group="CombinerStageNV"><ptype>GLenum</ptype> <name>stage</name></param>
+            <param group="CombinerParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCompileShader</name></proto>
+            <param><ptype>GLuint</ptype> <name>shader</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCompileShaderARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>shaderObj</name></param>
+            <alias name="glCompileShader"/>
+        </command>
+        <command>
+            <proto>void <name>glCompileShaderIncludeARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>shader</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLchar</ptype> *const*<name>path</name></param>
+            <param len="count">const <ptype>GLint</ptype> *<name>length</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCompressedMultiTexImage1DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param len="imageSize">const void *<name>bits</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCompressedMultiTexImage2DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param len="imageSize">const void *<name>bits</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCompressedMultiTexImage3DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param len="imageSize">const void *<name>bits</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCompressedMultiTexSubImage1DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param len="imageSize">const void *<name>bits</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCompressedMultiTexSubImage2DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param len="imageSize">const void *<name>bits</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCompressedMultiTexSubImage3DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param len="imageSize">const void *<name>bits</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTexImage1D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param group="CompressedTextureARB" len="imageSize">const void *<name>data</name></param>
+            <glx type="render" opcode="214"/>
+            <glx type="render" opcode="314" name="glCompressedTexImage1DPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTexImage1DARB</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param group="CompressedTextureARB" len="imageSize">const void *<name>data</name></param>
+            <alias name="glCompressedTexImage1D"/>
+            <glx type="render" opcode="214"/>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTexImage2D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param group="CompressedTextureARB" len="imageSize">const void *<name>data</name></param>
+            <glx type="render" opcode="215"/>
+            <glx type="render" opcode="315" name="glCompressedTexImage2DPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTexImage2DARB</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param group="CompressedTextureARB" len="imageSize">const void *<name>data</name></param>
+            <alias name="glCompressedTexImage2D"/>
+            <glx type="render" opcode="215"/>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTexImage3D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param group="CompressedTextureARB" len="imageSize">const void *<name>data</name></param>
+            <glx type="render" opcode="216"/>
+            <glx type="render" opcode="316" name="glCompressedTexImage3DPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTexImage3DARB</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param group="CompressedTextureARB" len="imageSize">const void *<name>data</name></param>
+            <alias name="glCompressedTexImage3D"/>
+            <glx type="render" opcode="216"/>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTexImage3DOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param><ptype>GLint</ptype> <name>border</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param len="imageSize">const void *<name>data</name></param>
+            <alias name="glCompressedTexImage3D"/>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTexSubImage1D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param group="CompressedTextureARB" len="imageSize">const void *<name>data</name></param>
+            <glx type="render" opcode="217"/>
+            <glx type="render" opcode="317" name="glCompressedTexSubImage1DPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTexSubImage1DARB</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param group="CompressedTextureARB" len="imageSize">const void *<name>data</name></param>
+            <alias name="glCompressedTexSubImage1D"/>
+            <glx type="render" opcode="217"/>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTexSubImage2D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param group="CompressedTextureARB" len="imageSize">const void *<name>data</name></param>
+            <glx type="render" opcode="218"/>
+            <glx type="render" opcode="318" name="glCompressedTexSubImage2DPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTexSubImage2DARB</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param group="CompressedTextureARB" len="imageSize">const void *<name>data</name></param>
+            <alias name="glCompressedTexSubImage2D"/>
+            <glx type="render" opcode="218"/>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTexSubImage3D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param group="CompressedTextureARB" len="imageSize">const void *<name>data</name></param>
+            <glx type="render" opcode="219"/>
+            <glx type="render" opcode="319" name="glCompressedTexSubImage3DPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTexSubImage3DARB</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param group="CompressedTextureARB" len="imageSize">const void *<name>data</name></param>
+            <alias name="glCompressedTexSubImage3D"/>
+            <glx type="render" opcode="219"/>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTexSubImage3DOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param len="imageSize">const void *<name>data</name></param>
+            <alias name="glCompressedTexSubImage3D"/>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTextureImage1DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param len="imageSize">const void *<name>bits</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTextureImage2DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param len="imageSize">const void *<name>bits</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTextureImage3DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param len="imageSize">const void *<name>bits</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTextureSubImage1DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param len="imageSize">const void *<name>bits</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTextureSubImage2DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param len="imageSize">const void *<name>bits</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCompressedTextureSubImage3DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>imageSize</name></param>
+            <param len="imageSize">const void *<name>bits</name></param>
+        </command>
+        <command>
+            <proto>void <name>glConvolutionFilter1D</name></proto>
+            <param group="ConvolutionTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width)">const void *<name>image</name></param>
+            <glx type="render" opcode="4101"/>
+            <glx type="render" opcode="320" name="glConvolutionFilter1DPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glConvolutionFilter1DEXT</name></proto>
+            <param group="ConvolutionTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width)">const void *<name>image</name></param>
+            <alias name="glConvolutionFilter1D"/>
+            <glx type="render" opcode="4101"/>
+        </command>
+        <command>
+            <proto>void <name>glConvolutionFilter2D</name></proto>
+            <param group="ConvolutionTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height)">const void *<name>image</name></param>
+            <glx type="render" opcode="4102"/>
+            <glx type="render" opcode="321" name="glConvolutionFilter2DPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glConvolutionFilter2DEXT</name></proto>
+            <param group="ConvolutionTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height)">const void *<name>image</name></param>
+            <alias name="glConvolutionFilter2D"/>
+            <glx type="render" opcode="4102"/>
+        </command>
+        <command>
+            <proto>void <name>glConvolutionParameterf</name></proto>
+            <param group="ConvolutionTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ConvolutionParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>params</name></param>
+            <glx type="render" opcode="4103"/>
+        </command>
+        <command>
+            <proto>void <name>glConvolutionParameterfEXT</name></proto>
+            <param group="ConvolutionTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ConvolutionParameterEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>params</name></param>
+            <alias name="glConvolutionParameterf"/>
+            <glx type="render" opcode="4103"/>
+        </command>
+        <command>
+            <proto>void <name>glConvolutionParameterfv</name></proto>
+            <param group="ConvolutionTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ConvolutionParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="render" opcode="4104"/>
+        </command>
+        <command>
+            <proto>void <name>glConvolutionParameterfvEXT</name></proto>
+            <param group="ConvolutionTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ConvolutionParameterEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <alias name="glConvolutionParameterfv"/>
+            <glx type="render" opcode="4104"/>
+        </command>
+        <command>
+            <proto>void <name>glConvolutionParameteri</name></proto>
+            <param group="ConvolutionTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ConvolutionParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>params</name></param>
+            <glx type="render" opcode="4105"/>
+        </command>
+        <command>
+            <proto>void <name>glConvolutionParameteriEXT</name></proto>
+            <param group="ConvolutionTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ConvolutionParameterEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>params</name></param>
+            <alias name="glConvolutionParameteri"/>
+            <glx type="render" opcode="4105"/>
+        </command>
+        <command>
+            <proto>void <name>glConvolutionParameteriv</name></proto>
+            <param group="ConvolutionTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ConvolutionParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="render" opcode="4106"/>
+        </command>
+        <command>
+            <proto>void <name>glConvolutionParameterivEXT</name></proto>
+            <param group="ConvolutionTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ConvolutionParameterEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glConvolutionParameteriv"/>
+            <glx type="render" opcode="4106"/>
+        </command>
+        <command>
+            <proto>void <name>glConvolutionParameterxOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glConvolutionParameterxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCopyBufferSubData</name></proto>
+            <param><ptype>GLenum</ptype> <name>readTarget</name></param>
+            <param><ptype>GLenum</ptype> <name>writeTarget</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>readOffset</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>writeOffset</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>size</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCopyBufferSubDataNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>readTarget</name></param>
+            <param><ptype>GLenum</ptype> <name>writeTarget</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>readOffset</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>writeOffset</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>size</name></param>
+            <alias name="glCopyBufferSubData"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyColorSubTable</name></proto>
+            <param group="ColorTableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>start</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <glx type="render" opcode="196"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyColorSubTableEXT</name></proto>
+            <param group="ColorTableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>start</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <alias name="glCopyColorSubTable"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyColorTable</name></proto>
+            <param group="ColorTableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <glx type="render" opcode="2056"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyColorTableSGI</name></proto>
+            <param group="ColorTableTargetSGI"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <alias name="glCopyColorTable"/>
+            <glx type="render" opcode="2056"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyConvolutionFilter1D</name></proto>
+            <param group="ConvolutionTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <glx type="render" opcode="4107"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyConvolutionFilter1DEXT</name></proto>
+            <param group="ConvolutionTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <alias name="glCopyConvolutionFilter1D"/>
+            <glx type="render" opcode="4107"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyConvolutionFilter2D</name></proto>
+            <param group="ConvolutionTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <glx type="render" opcode="4108"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyConvolutionFilter2DEXT</name></proto>
+            <param group="ConvolutionTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <alias name="glCopyConvolutionFilter2D"/>
+            <glx type="render" opcode="4108"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyImageSubData</name></proto>
+            <param><ptype>GLuint</ptype> <name>srcName</name></param>
+            <param><ptype>GLenum</ptype> <name>srcTarget</name></param>
+            <param><ptype>GLint</ptype> <name>srcLevel</name></param>
+            <param><ptype>GLint</ptype> <name>srcX</name></param>
+            <param><ptype>GLint</ptype> <name>srcY</name></param>
+            <param><ptype>GLint</ptype> <name>srcZ</name></param>
+            <param><ptype>GLuint</ptype> <name>dstName</name></param>
+            <param><ptype>GLenum</ptype> <name>dstTarget</name></param>
+            <param><ptype>GLint</ptype> <name>dstLevel</name></param>
+            <param><ptype>GLint</ptype> <name>dstX</name></param>
+            <param><ptype>GLint</ptype> <name>dstY</name></param>
+            <param><ptype>GLint</ptype> <name>dstZ</name></param>
+            <param><ptype>GLsizei</ptype> <name>srcWidth</name></param>
+            <param><ptype>GLsizei</ptype> <name>srcHeight</name></param>
+            <param><ptype>GLsizei</ptype> <name>srcDepth</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCopyImageSubDataEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>srcName</name></param>
+            <param><ptype>GLenum</ptype> <name>srcTarget</name></param>
+            <param><ptype>GLint</ptype> <name>srcLevel</name></param>
+            <param><ptype>GLint</ptype> <name>srcX</name></param>
+            <param><ptype>GLint</ptype> <name>srcY</name></param>
+            <param><ptype>GLint</ptype> <name>srcZ</name></param>
+            <param><ptype>GLuint</ptype> <name>dstName</name></param>
+            <param><ptype>GLenum</ptype> <name>dstTarget</name></param>
+            <param><ptype>GLint</ptype> <name>dstLevel</name></param>
+            <param><ptype>GLint</ptype> <name>dstX</name></param>
+            <param><ptype>GLint</ptype> <name>dstY</name></param>
+            <param><ptype>GLint</ptype> <name>dstZ</name></param>
+            <param><ptype>GLsizei</ptype> <name>srcWidth</name></param>
+            <param><ptype>GLsizei</ptype> <name>srcHeight</name></param>
+            <param><ptype>GLsizei</ptype> <name>srcDepth</name></param>
+            <alias name="glCopyImageSubData"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyImageSubDataNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>srcName</name></param>
+            <param><ptype>GLenum</ptype> <name>srcTarget</name></param>
+            <param><ptype>GLint</ptype> <name>srcLevel</name></param>
+            <param><ptype>GLint</ptype> <name>srcX</name></param>
+            <param><ptype>GLint</ptype> <name>srcY</name></param>
+            <param><ptype>GLint</ptype> <name>srcZ</name></param>
+            <param><ptype>GLuint</ptype> <name>dstName</name></param>
+            <param><ptype>GLenum</ptype> <name>dstTarget</name></param>
+            <param><ptype>GLint</ptype> <name>dstLevel</name></param>
+            <param><ptype>GLint</ptype> <name>dstX</name></param>
+            <param><ptype>GLint</ptype> <name>dstY</name></param>
+            <param><ptype>GLint</ptype> <name>dstZ</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <glx type="render" opcode="4291"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyMultiTexImage1DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCopyMultiTexImage2DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCopyMultiTexSubImage1DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCopyMultiTexSubImage2DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCopyMultiTexSubImage3DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCopyPathNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>resultPath</name></param>
+            <param group="Path"><ptype>GLuint</ptype> <name>srcPath</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCopyPixels</name></proto>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="PixelCopyType"><ptype>GLenum</ptype> <name>type</name></param>
+            <glx type="render" opcode="172"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyTexImage1D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <glx type="render" opcode="4119"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyTexImage1DEXT</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <alias name="glCopyTexImage1D"/>
+            <glx type="render" opcode="4119"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyTexImage2D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <glx type="render" opcode="4120"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyTexImage2DEXT</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <alias name="glCopyTexImage2D"/>
+            <glx type="render" opcode="4120"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyTexSubImage1D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <glx type="render" opcode="4121"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyTexSubImage1DEXT</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <alias name="glCopyTexSubImage1D"/>
+            <glx type="render" opcode="4121"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyTexSubImage2D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <glx type="render" opcode="4122"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyTexSubImage2DEXT</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <alias name="glCopyTexSubImage2D"/>
+            <glx type="render" opcode="4122"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyTexSubImage3D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <glx type="render" opcode="4123"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyTexSubImage3DEXT</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <alias name="glCopyTexSubImage3D"/>
+            <glx type="render" opcode="4123"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyTexSubImage3DOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <alias name="glCopyTexSubImage3D"/>
+        </command>
+        <command>
+            <proto>void <name>glCopyTextureImage1DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCopyTextureImage2DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCopyTextureLevelsAPPLE</name></proto>
+            <param><ptype>GLuint</ptype> <name>destinationTexture</name></param>
+            <param><ptype>GLuint</ptype> <name>sourceTexture</name></param>
+            <param><ptype>GLint</ptype> <name>sourceBaseLevel</name></param>
+            <param><ptype>GLsizei</ptype> <name>sourceLevelCount</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCopyTextureSubImage1DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCopyTextureSubImage2DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCopyTextureSubImage3DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCoverFillPathInstancedNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>numPaths</name></param>
+            <param group="PathElementType"><ptype>GLenum</ptype> <name>pathNameType</name></param>
+            <param group="PathElement" len="COMPSIZE(numPaths,pathNameType,paths)">const void *<name>paths</name></param>
+            <param group="Path"><ptype>GLuint</ptype> <name>pathBase</name></param>
+            <param group="PathCoverMode"><ptype>GLenum</ptype> <name>coverMode</name></param>
+            <param group="PathTransformType"><ptype>GLenum</ptype> <name>transformType</name></param>
+            <param len="COMPSIZE(numPaths,transformType)">const <ptype>GLfloat</ptype> *<name>transformValues</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCoverFillPathNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param group="PathCoverMode"><ptype>GLenum</ptype> <name>coverMode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCoverStrokePathInstancedNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>numPaths</name></param>
+            <param group="PathElementType"><ptype>GLenum</ptype> <name>pathNameType</name></param>
+            <param group="PathElement" len="COMPSIZE(numPaths,pathNameType,paths)">const void *<name>paths</name></param>
+            <param group="Path"><ptype>GLuint</ptype> <name>pathBase</name></param>
+            <param group="PathCoverMode"><ptype>GLenum</ptype> <name>coverMode</name></param>
+            <param group="PathTransformType"><ptype>GLenum</ptype> <name>transformType</name></param>
+            <param len="COMPSIZE(numPaths,transformType)">const <ptype>GLfloat</ptype> *<name>transformValues</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCoverStrokePathNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param group="PathCoverMode"><ptype>GLenum</ptype> <name>coverMode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCoverageMaskNV</name></proto>
+            <param><ptype>GLboolean</ptype> <name>mask</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCoverageOperationNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>operation</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCreatePerfQueryINTEL</name></proto>
+            <param><ptype>GLuint</ptype> <name>queryId</name></param>
+            <param><ptype>GLuint</ptype> *<name>queryHandle</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glCreateProgram</name></proto>
+        </command>
+        <command>
+            <proto group="handleARB"><ptype>GLhandleARB</ptype> <name>glCreateProgramObjectARB</name></proto>
+            <alias name="glCreateProgram"/>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glCreateShader</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+        </command>
+        <command>
+            <proto group="handleARB"><ptype>GLhandleARB</ptype> <name>glCreateShaderObjectARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>shaderType</name></param>
+            <alias name="glCreateShader"/>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glCreateShaderProgramEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param>const <ptype>GLchar</ptype> *<name>string</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glCreateShaderProgramv</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLchar</ptype> *const*<name>strings</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glCreateShaderProgramvEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLchar</ptype> **<name>strings</name></param>
+        </command>
+        <command>
+            <proto group="sync"><ptype>GLsync</ptype> <name>glCreateSyncFromCLeventARB</name></proto>
+            <param group="cl_context"><ptype>struct _cl_context</ptype> *<name>context</name></param>
+            <param group="cl_event"><ptype>struct _cl_event</ptype> *<name>event</name></param>
+            <param><ptype>GLbitfield</ptype> <name>flags</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCullFace</name></proto>
+            <param group="CullFaceMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <glx type="render" opcode="79"/>
+        </command>
+        <command>
+            <proto>void <name>glCullParameterdvEXT</name></proto>
+            <param group="CullParameterEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="4"><ptype>GLdouble</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCullParameterfvEXT</name></proto>
+            <param group="CullParameterEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="4"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glCurrentPaletteMatrixARB</name></proto>
+            <param><ptype>GLint</ptype> <name>index</name></param>
+            <glx type="render" opcode="4329"/>
+        </command>
+        <command>
+            <proto>void <name>glCurrentPaletteMatrixOES</name></proto>
+            <param><ptype>GLuint</ptype> <name>matrixpaletteindex</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDebugMessageCallback</name></proto>
+            <param><ptype>GLDEBUGPROC</ptype> <name>callback</name></param>
+            <param>const void *<name>userParam</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDebugMessageCallbackAMD</name></proto>
+            <param><ptype>GLDEBUGPROCAMD</ptype> <name>callback</name></param>
+            <param>void *<name>userParam</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDebugMessageCallbackARB</name></proto>
+            <param><ptype>GLDEBUGPROCARB</ptype> <name>callback</name></param>
+            <param len="COMPSIZE(callback)">const void *<name>userParam</name></param>
+            <alias name="glDebugMessageCallback"/>
+        </command>
+        <command>
+            <proto>void <name>glDebugMessageCallbackKHR</name></proto>
+            <param><ptype>GLDEBUGPROCKHR</ptype> <name>callback</name></param>
+            <param>const void *<name>userParam</name></param>
+            <alias name="glDebugMessageCallback"/>
+        </command>
+        <command>
+            <proto>void <name>glDebugMessageControl</name></proto>
+            <param><ptype>GLenum</ptype> <name>source</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLenum</ptype> <name>severity</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>ids</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>enabled</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDebugMessageControlARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>source</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLenum</ptype> <name>severity</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>ids</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>enabled</name></param>
+            <alias name="glDebugMessageControl"/>
+        </command>
+        <command>
+            <proto>void <name>glDebugMessageControlKHR</name></proto>
+            <param><ptype>GLenum</ptype> <name>source</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLenum</ptype> <name>severity</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param>const <ptype>GLuint</ptype> *<name>ids</name></param>
+            <param><ptype>GLboolean</ptype> <name>enabled</name></param>
+            <alias name="glDebugMessageControl"/>
+        </command>
+        <command>
+            <proto>void <name>glDebugMessageEnableAMD</name></proto>
+            <param><ptype>GLenum</ptype> <name>category</name></param>
+            <param><ptype>GLenum</ptype> <name>severity</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>ids</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>enabled</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDebugMessageInsert</name></proto>
+            <param><ptype>GLenum</ptype> <name>source</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLenum</ptype> <name>severity</name></param>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param len="COMPSIZE(buf,length)">const <ptype>GLchar</ptype> *<name>buf</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDebugMessageInsertAMD</name></proto>
+            <param><ptype>GLenum</ptype> <name>category</name></param>
+            <param><ptype>GLenum</ptype> <name>severity</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param len="length">const <ptype>GLchar</ptype> *<name>buf</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDebugMessageInsertARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>source</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLenum</ptype> <name>severity</name></param>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param len="length">const <ptype>GLchar</ptype> *<name>buf</name></param>
+            <alias name="glDebugMessageInsert"/>
+        </command>
+        <command>
+            <proto>void <name>glDebugMessageInsertKHR</name></proto>
+            <param><ptype>GLenum</ptype> <name>source</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLenum</ptype> <name>severity</name></param>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param>const <ptype>GLchar</ptype> *<name>buf</name></param>
+            <alias name="glDebugMessageInsert"/>
+        </command>
+        <command>
+            <proto>void <name>glDeformSGIX</name></proto>
+            <param group="FfdMaskSGIX"><ptype>GLbitfield</ptype> <name>mask</name></param>
+            <glx type="render" opcode="2075"/>
+        </command>
+        <command>
+            <proto>void <name>glDeformationMap3dSGIX</name></proto>
+            <param group="FfdTargetSGIX"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>u1</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>u2</name></param>
+            <param><ptype>GLint</ptype> <name>ustride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>uorder</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>v1</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>v2</name></param>
+            <param><ptype>GLint</ptype> <name>vstride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>vorder</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>w1</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>w2</name></param>
+            <param><ptype>GLint</ptype> <name>wstride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>worder</name></param>
+            <param group="CoordD" len="COMPSIZE(target,ustride,uorder,vstride,vorder,wstride,worder)">const <ptype>GLdouble</ptype> *<name>points</name></param>
+            <glx type="render" opcode="2073"/>
+        </command>
+        <command>
+            <proto>void <name>glDeformationMap3fSGIX</name></proto>
+            <param group="FfdTargetSGIX"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>u1</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>u2</name></param>
+            <param><ptype>GLint</ptype> <name>ustride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>uorder</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>v1</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>v2</name></param>
+            <param><ptype>GLint</ptype> <name>vstride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>vorder</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>w1</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>w2</name></param>
+            <param><ptype>GLint</ptype> <name>wstride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>worder</name></param>
+            <param group="CoordF" len="COMPSIZE(target,ustride,uorder,vstride,vorder,wstride,worder)">const <ptype>GLfloat</ptype> *<name>points</name></param>
+            <glx type="render" opcode="2074"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteAsyncMarkersSGIX</name></proto>
+            <param><ptype>GLuint</ptype> <name>marker</name></param>
+            <param><ptype>GLsizei</ptype> <name>range</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeleteBuffers</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>buffers</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeleteBuffersARB</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>buffers</name></param>
+            <alias name="glDeleteBuffers"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteFencesAPPLE</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="FenceNV" len="n">const <ptype>GLuint</ptype> *<name>fences</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeleteFencesNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="FenceNV" len="n">const <ptype>GLuint</ptype> *<name>fences</name></param>
+            <glx type="vendor" opcode="1276"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteFragmentShaderATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeleteFramebuffers</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>framebuffers</name></param>
+            <glx type="render" opcode="4320"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteFramebuffersEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>framebuffers</name></param>
+            <alias name="glDeleteFramebuffers"/>
+            <glx type="render" opcode="4320"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteFramebuffersOES</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>framebuffers</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeleteLists</name></proto>
+            <param group="List"><ptype>GLuint</ptype> <name>list</name></param>
+            <param><ptype>GLsizei</ptype> <name>range</name></param>
+            <glx type="single" opcode="103"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteNamedStringARB</name></proto>
+            <param><ptype>GLint</ptype> <name>namelen</name></param>
+            <param len="namelen">const <ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeleteNamesAMD</name></proto>
+            <param><ptype>GLenum</ptype> <name>identifier</name></param>
+            <param><ptype>GLuint</ptype> <name>num</name></param>
+            <param len="num">const <ptype>GLuint</ptype> *<name>names</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeleteObjectARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>obj</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeleteOcclusionQueriesNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>ids</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeletePathsNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param><ptype>GLsizei</ptype> <name>range</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeletePerfMonitorsAMD</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>monitors</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeletePerfQueryINTEL</name></proto>
+            <param><ptype>GLuint</ptype> <name>queryHandle</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeleteProgram</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <glx type="single" opcode="202"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteProgramPipelines</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>pipelines</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeleteProgramPipelinesEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>pipelines</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeleteProgramsARB</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>programs</name></param>
+            <glx type="vendor" opcode="1294"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteProgramsNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>programs</name></param>
+            <alias name="glDeleteProgramsARB"/>
+            <glx type="vendor" opcode="1294"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteQueries</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>ids</name></param>
+            <glx type="single" opcode="161"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteQueriesARB</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>ids</name></param>
+            <alias name="glDeleteQueries"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteQueriesEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>ids</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeleteRenderbuffers</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>renderbuffers</name></param>
+            <glx type="render" opcode="4317"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteRenderbuffersEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>renderbuffers</name></param>
+            <alias name="glDeleteRenderbuffers"/>
+            <glx type="render" opcode="4317"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteRenderbuffersOES</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>renderbuffers</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeleteSamplers</name></proto>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>samplers</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeleteShader</name></proto>
+            <param><ptype>GLuint</ptype> <name>shader</name></param>
+            <glx type="single" opcode="195"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteSync</name></proto>
+            <param group="sync"><ptype>GLsync</ptype> <name>sync</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeleteSyncAPPLE</name></proto>
+            <param><ptype>GLsync</ptype> <name>sync</name></param>
+            <alias name="glDeleteSync"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteTextures</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="Texture" len="n">const <ptype>GLuint</ptype> *<name>textures</name></param>
+            <glx type="single" opcode="144"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteTexturesEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="Texture" len="n">const <ptype>GLuint</ptype> *<name>textures</name></param>
+            <glx type="vendor" opcode="12"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteTransformFeedbacks</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>ids</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDeleteTransformFeedbacksNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>ids</name></param>
+            <alias name="glDeleteTransformFeedbacks"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteVertexArrays</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>arrays</name></param>
+            <glx type="render" opcode="351"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteVertexArraysAPPLE</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>arrays</name></param>
+            <alias name="glDeleteVertexArrays"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteVertexArraysOES</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>arrays</name></param>
+            <alias name="glDeleteVertexArrays"/>
+        </command>
+        <command>
+            <proto>void <name>glDeleteVertexShaderEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDepthBoundsEXT</name></proto>
+            <param group="ClampedFloat64"><ptype>GLclampd</ptype> <name>zmin</name></param>
+            <param group="ClampedFloat64"><ptype>GLclampd</ptype> <name>zmax</name></param>
+            <glx type="render" opcode="4229"/>
+        </command>
+        <command>
+            <proto>void <name>glDepthBoundsdNV</name></proto>
+            <param><ptype>GLdouble</ptype> <name>zmin</name></param>
+            <param><ptype>GLdouble</ptype> <name>zmax</name></param>
+            <glx type="render" opcode="4285"/>
+        </command>
+        <command>
+            <proto>void <name>glDepthFunc</name></proto>
+            <param group="DepthFunction"><ptype>GLenum</ptype> <name>func</name></param>
+            <glx type="render" opcode="164"/>
+        </command>
+        <command>
+            <proto>void <name>glDepthMask</name></proto>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>flag</name></param>
+            <glx type="render" opcode="135"/>
+        </command>
+        <command>
+            <proto>void <name>glDepthRange</name></proto>
+            <param><ptype>GLdouble</ptype> <name>near</name></param>
+            <param><ptype>GLdouble</ptype> <name>far</name></param>
+            <glx type="render" opcode="174"/>
+        </command>
+        <command>
+            <proto>void <name>glDepthRangeArrayv</name></proto>
+            <param><ptype>GLuint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="COMPSIZE(count)">const <ptype>GLdouble</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDepthRangeIndexed</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>n</name></param>
+            <param><ptype>GLdouble</ptype> <name>f</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDepthRangedNV</name></proto>
+            <param><ptype>GLdouble</ptype> <name>zNear</name></param>
+            <param><ptype>GLdouble</ptype> <name>zFar</name></param>
+            <glx type="render" opcode="4283"/>
+        </command>
+        <command>
+            <proto>void <name>glDepthRangef</name></proto>
+            <param><ptype>GLfloat</ptype> <name>n</name></param>
+            <param><ptype>GLfloat</ptype> <name>f</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDepthRangefOES</name></proto>
+            <param group="ClampedFloat32"><ptype>GLclampf</ptype> <name>n</name></param>
+            <param group="ClampedFloat32"><ptype>GLclampf</ptype> <name>f</name></param>
+            <glx type="render" opcode="4309"/>
+            <alias name="glDepthRangef"/>
+        </command>
+        <command>
+            <proto>void <name>glDepthRangex</name></proto>
+            <param><ptype>GLfixed</ptype> <name>n</name></param>
+            <param><ptype>GLfixed</ptype> <name>f</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDepthRangexOES</name></proto>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>n</name></param>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>f</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDetachObjectARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>containerObj</name></param>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>attachedObj</name></param>
+            <alias name="glDetachShader"/>
+        </command>
+        <command>
+            <proto>void <name>glDetachShader</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>shader</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDetailTexFuncSGIS</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n*2">const <ptype>GLfloat</ptype> *<name>points</name></param>
+            <glx type="render" opcode="2051"/>
+        </command>
+        <command>
+            <proto>void <name>glDisable</name></proto>
+            <param group="EnableCap"><ptype>GLenum</ptype> <name>cap</name></param>
+            <glx type="render" opcode="138"/>
+        </command>
+        <command>
+            <proto>void <name>glDisableClientState</name></proto>
+            <param group="EnableCap"><ptype>GLenum</ptype> <name>array</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDisableClientStateIndexedEXT</name></proto>
+            <param group="EnableCap"><ptype>GLenum</ptype> <name>array</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDisableClientStateiEXT</name></proto>
+            <param group="EnableCap"><ptype>GLenum</ptype> <name>array</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDisableDriverControlQCOM</name></proto>
+            <param><ptype>GLuint</ptype> <name>driverControl</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDisableIndexedEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <alias name="glDisablei"/>
+        </command>
+        <command>
+            <proto>void <name>glDisableVariantClientStateEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDisableVertexArrayAttribEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDisableVertexArrayEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param group="EnableCap"><ptype>GLenum</ptype> <name>array</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDisableVertexAttribAPPLE</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDisableVertexAttribArray</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDisableVertexAttribArrayARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <alias name="glDisableVertexAttribArray"/>
+        </command>
+        <command>
+            <proto>void <name>glDisablei</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDisableiEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <alias name="glDisablei"/>
+        </command>
+        <command>
+            <proto>void <name>glDiscardFramebufferEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>numAttachments</name></param>
+            <param len="numAttachments">const <ptype>GLenum</ptype> *<name>attachments</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDispatchCompute</name></proto>
+            <param><ptype>GLuint</ptype> <name>num_groups_x</name></param>
+            <param><ptype>GLuint</ptype> <name>num_groups_y</name></param>
+            <param><ptype>GLuint</ptype> <name>num_groups_z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDispatchComputeGroupSizeARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>num_groups_x</name></param>
+            <param><ptype>GLuint</ptype> <name>num_groups_y</name></param>
+            <param><ptype>GLuint</ptype> <name>num_groups_z</name></param>
+            <param><ptype>GLuint</ptype> <name>group_size_x</name></param>
+            <param><ptype>GLuint</ptype> <name>group_size_y</name></param>
+            <param><ptype>GLuint</ptype> <name>group_size_z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDispatchComputeIndirect</name></proto>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>indirect</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawArrays</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <glx type="render" opcode="193"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawArraysEXT</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <alias name="glDrawArrays"/>
+            <glx type="render" opcode="4116"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawArraysIndirect</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param>const void *<name>indirect</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawArraysInstanced</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param><ptype>GLsizei</ptype> <name>instancecount</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawArraysInstancedANGLE</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param><ptype>GLsizei</ptype> <name>primcount</name></param>
+            <alias name="glDrawArraysInstanced"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawArraysInstancedARB</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param><ptype>GLsizei</ptype> <name>primcount</name></param>
+            <alias name="glDrawArraysInstanced"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawArraysInstancedBaseInstance</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param><ptype>GLsizei</ptype> <name>instancecount</name></param>
+            <param><ptype>GLuint</ptype> <name>baseinstance</name></param>
+        </command>
+        <command comment="primcount should be renamed to instanceCount for OpenGL ES">
+            <proto>void <name>glDrawArraysInstancedEXT</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLint</ptype> <name>start</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param><ptype>GLsizei</ptype> <name>primcount</name></param>
+            <alias name="glDrawArraysInstanced"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawArraysInstancedNV</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param><ptype>GLsizei</ptype> <name>primcount</name></param>
+            <alias name="glDrawArraysInstanced"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawBuffer</name></proto>
+            <param group="DrawBufferMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <glx type="render" opcode="126"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawBuffers</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="DrawBufferModeATI" len="n">const <ptype>GLenum</ptype> *<name>bufs</name></param>
+            <glx type="render" opcode="233"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawBuffersARB</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="DrawBufferModeATI" len="n">const <ptype>GLenum</ptype> *<name>bufs</name></param>
+            <alias name="glDrawBuffers"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawBuffersATI</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="DrawBufferModeATI" len="n">const <ptype>GLenum</ptype> *<name>bufs</name></param>
+            <alias name="glDrawBuffers"/>
+            <glx type="render" opcode="233"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawBuffersEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param>const <ptype>GLenum</ptype> *<name>bufs</name></param>
+            <alias name="glDrawBuffers"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawBuffersIndexedEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLenum</ptype> *<name>location</name></param>
+            <param len="n">const <ptype>GLint</ptype> *<name>indices</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawBuffersNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLenum</ptype> *<name>bufs</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawElementArrayAPPLE</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawElementArrayATI</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawElements</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="DrawElementsType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(count,type)">const void *<name>indices</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawElementsBaseVertex</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="DrawElementsType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(count,type)">const void *<name>indices</name></param>
+            <param><ptype>GLint</ptype> <name>basevertex</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawElementsIndirect</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param>const void *<name>indirect</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawElementsInstanced</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="DrawElementsType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(count,type)">const void *<name>indices</name></param>
+            <param><ptype>GLsizei</ptype> <name>instancecount</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawElementsInstancedANGLE</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(count,type)">const void *<name>indices</name></param>
+            <param><ptype>GLsizei</ptype> <name>primcount</name></param>
+            <alias name="glDrawElementsInstanced"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawElementsInstancedARB</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="DrawElementsType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(count,type)">const void *<name>indices</name></param>
+            <param><ptype>GLsizei</ptype> <name>primcount</name></param>
+            <alias name="glDrawElementsInstanced"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawElementsInstancedBaseInstance</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="count">const void *<name>indices</name></param>
+            <param><ptype>GLsizei</ptype> <name>instancecount</name></param>
+            <param><ptype>GLuint</ptype> <name>baseinstance</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawElementsInstancedBaseVertex</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="DrawElementsType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(count,type)">const void *<name>indices</name></param>
+            <param><ptype>GLsizei</ptype> <name>instancecount</name></param>
+            <param><ptype>GLint</ptype> <name>basevertex</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawElementsInstancedBaseVertexBaseInstance</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="count">const void *<name>indices</name></param>
+            <param><ptype>GLsizei</ptype> <name>instancecount</name></param>
+            <param><ptype>GLint</ptype> <name>basevertex</name></param>
+            <param><ptype>GLuint</ptype> <name>baseinstance</name></param>
+        </command>
+        <command comment="primcount should be renamed to instanceCount for OpenGL ES">
+            <proto>void <name>glDrawElementsInstancedEXT</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="DrawElementsType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(count,type)">const void *<name>indices</name></param>
+            <param><ptype>GLsizei</ptype> <name>primcount</name></param>
+            <alias name="glDrawElementsInstanced"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawElementsInstancedNV</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(count,type)">const void *<name>indices</name></param>
+            <param><ptype>GLsizei</ptype> <name>primcount</name></param>
+            <alias name="glDrawElementsInstanced"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawMeshArraysSUN</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawPixels</name></proto>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height)">const void *<name>pixels</name></param>
+            <glx type="render" opcode="173"/>
+            <glx type="render" opcode="322" name="glDrawPixelsPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawRangeElementArrayAPPLE</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLuint</ptype> <name>start</name></param>
+            <param><ptype>GLuint</ptype> <name>end</name></param>
+            <param><ptype>GLint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawRangeElementArrayATI</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLuint</ptype> <name>start</name></param>
+            <param><ptype>GLuint</ptype> <name>end</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawRangeElements</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLuint</ptype> <name>start</name></param>
+            <param><ptype>GLuint</ptype> <name>end</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="DrawElementsType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(count,type)">const void *<name>indices</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawRangeElementsBaseVertex</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLuint</ptype> <name>start</name></param>
+            <param><ptype>GLuint</ptype> <name>end</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="DrawElementsType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(count,type)">const void *<name>indices</name></param>
+            <param><ptype>GLint</ptype> <name>basevertex</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawRangeElementsEXT</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLuint</ptype> <name>start</name></param>
+            <param><ptype>GLuint</ptype> <name>end</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="DrawElementsType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(count,type)">const void *<name>indices</name></param>
+            <alias name="glDrawRangeElements"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawTexfOES</name></proto>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <param><ptype>GLfloat</ptype> <name>width</name></param>
+            <param><ptype>GLfloat</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawTexfvOES</name></proto>
+            <param>const <ptype>GLfloat</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawTexiOES</name></proto>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLint</ptype> <name>z</name></param>
+            <param><ptype>GLint</ptype> <name>width</name></param>
+            <param><ptype>GLint</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawTexivOES</name></proto>
+            <param>const <ptype>GLint</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawTexsOES</name></proto>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+            <param><ptype>GLshort</ptype> <name>y</name></param>
+            <param><ptype>GLshort</ptype> <name>z</name></param>
+            <param><ptype>GLshort</ptype> <name>width</name></param>
+            <param><ptype>GLshort</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawTexsvOES</name></proto>
+            <param>const <ptype>GLshort</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawTextureNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+            <param><ptype>GLfloat</ptype> <name>x0</name></param>
+            <param><ptype>GLfloat</ptype> <name>y0</name></param>
+            <param><ptype>GLfloat</ptype> <name>x1</name></param>
+            <param><ptype>GLfloat</ptype> <name>y1</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <param><ptype>GLfloat</ptype> <name>s0</name></param>
+            <param><ptype>GLfloat</ptype> <name>t0</name></param>
+            <param><ptype>GLfloat</ptype> <name>s1</name></param>
+            <param><ptype>GLfloat</ptype> <name>t1</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawTexxOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>x</name></param>
+            <param><ptype>GLfixed</ptype> <name>y</name></param>
+            <param><ptype>GLfixed</ptype> <name>z</name></param>
+            <param><ptype>GLfixed</ptype> <name>width</name></param>
+            <param><ptype>GLfixed</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawTexxvOES</name></proto>
+            <param>const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawTransformFeedback</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawTransformFeedbackInstanced</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLsizei</ptype> <name>instancecount</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawTransformFeedbackNV</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <alias name="glDrawTransformFeedback"/>
+        </command>
+        <command>
+            <proto>void <name>glDrawTransformFeedbackStream</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLuint</ptype> <name>stream</name></param>
+        </command>
+        <command>
+            <proto>void <name>glDrawTransformFeedbackStreamInstanced</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLuint</ptype> <name>stream</name></param>
+            <param><ptype>GLsizei</ptype> <name>instancecount</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEGLImageTargetRenderbufferStorageOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLeglImageOES</ptype> <name>image</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEGLImageTargetTexture2DOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLeglImageOES</ptype> <name>image</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEdgeFlag</name></proto>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>flag</name></param>
+            <vecequiv name="glEdgeFlagv"/>
+        </command>
+        <command>
+            <proto>void <name>glEdgeFlagFormatNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEdgeFlagPointer</name></proto>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEdgeFlagPointerEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean" len="COMPSIZE(stride,count)">const <ptype>GLboolean</ptype> *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEdgeFlagPointerListIBM</name></proto>
+            <param><ptype>GLint</ptype> <name>stride</name></param>
+            <param group="BooleanPointer" len="COMPSIZE(stride)">const <ptype>GLboolean</ptype> **<name>pointer</name></param>
+            <param><ptype>GLint</ptype> <name>ptrstride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEdgeFlagv</name></proto>
+            <param group="Boolean" len="1">const <ptype>GLboolean</ptype> *<name>flag</name></param>
+            <glx type="render" opcode="22"/>
+        </command>
+        <command>
+            <proto>void <name>glElementPointerAPPLE</name></proto>
+            <param group="ElementPointerTypeATI"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(type)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glElementPointerATI</name></proto>
+            <param group="ElementPointerTypeATI"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(type)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEnable</name></proto>
+            <param group="EnableCap"><ptype>GLenum</ptype> <name>cap</name></param>
+            <glx type="render" opcode="139"/>
+        </command>
+        <command>
+            <proto>void <name>glEnableClientState</name></proto>
+            <param group="EnableCap"><ptype>GLenum</ptype> <name>array</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEnableClientStateIndexedEXT</name></proto>
+            <param group="EnableCap"><ptype>GLenum</ptype> <name>array</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEnableClientStateiEXT</name></proto>
+            <param group="EnableCap"><ptype>GLenum</ptype> <name>array</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEnableDriverControlQCOM</name></proto>
+            <param><ptype>GLuint</ptype> <name>driverControl</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEnableIndexedEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <alias name="glEnablei"/>
+        </command>
+        <command>
+            <proto>void <name>glEnableVariantClientStateEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEnableVertexArrayAttribEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEnableVertexArrayEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param group="EnableCap"><ptype>GLenum</ptype> <name>array</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEnableVertexAttribAPPLE</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEnableVertexAttribArray</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEnableVertexAttribArrayARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <alias name="glEnableVertexAttribArray"/>
+        </command>
+        <command>
+            <proto>void <name>glEnablei</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEnableiEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <alias name="glEnablei"/>
+        </command>
+        <command>
+            <proto>void <name>glEnd</name></proto>
+            <glx type="render" opcode="23"/>
+        </command>
+        <command>
+            <proto>void <name>glEndConditionalRender</name></proto>
+            <glx type="render" opcode="349"/>
+        </command>
+        <command>
+            <proto>void <name>glEndConditionalRenderNV</name></proto>
+            <alias name="glEndConditionalRender"/>
+        </command>
+        <command>
+            <proto>void <name>glEndConditionalRenderNVX</name></proto>
+            <alias name="glEndConditionalRender"/>
+        </command>
+        <command>
+            <proto>void <name>glEndFragmentShaderATI</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glEndList</name></proto>
+            <glx type="single" opcode="102"/>
+        </command>
+        <command>
+            <proto>void <name>glEndOcclusionQueryNV</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glEndPerfMonitorAMD</name></proto>
+            <param><ptype>GLuint</ptype> <name>monitor</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEndPerfQueryINTEL</name></proto>
+            <param><ptype>GLuint</ptype> <name>queryHandle</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEndQuery</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <glx type="render" opcode="232"/>
+        </command>
+        <command>
+            <proto>void <name>glEndQueryARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <alias name="glEndQuery"/>
+        </command>
+        <command>
+            <proto>void <name>glEndQueryEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEndQueryIndexed</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEndTilingQCOM</name></proto>
+            <param><ptype>GLbitfield</ptype> <name>preserveMask</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEndTransformFeedback</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glEndTransformFeedbackEXT</name></proto>
+            <alias name="glEndTransformFeedback"/>
+        </command>
+        <command>
+            <proto>void <name>glEndTransformFeedbackNV</name></proto>
+            <alias name="glEndTransformFeedback"/>
+        </command>
+        <command>
+            <proto>void <name>glEndVertexShaderEXT</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glEndVideoCaptureNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_capture_slot</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEvalCoord1d</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>u</name></param>
+            <vecequiv name="glEvalCoord1dv"/>
+        </command>
+        <command>
+            <proto>void <name>glEvalCoord1dv</name></proto>
+            <param group="CoordD" len="1">const <ptype>GLdouble</ptype> *<name>u</name></param>
+            <glx type="render" opcode="151"/>
+        </command>
+        <command>
+            <proto>void <name>glEvalCoord1f</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>u</name></param>
+            <vecequiv name="glEvalCoord1fv"/>
+        </command>
+        <command>
+            <proto>void <name>glEvalCoord1fv</name></proto>
+            <param group="CoordF" len="1">const <ptype>GLfloat</ptype> *<name>u</name></param>
+            <glx type="render" opcode="152"/>
+        </command>
+        <command>
+            <proto>void <name>glEvalCoord1xOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>u</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEvalCoord1xvOES</name></proto>
+            <param len="1">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEvalCoord2d</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>u</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>v</name></param>
+            <vecequiv name="glEvalCoord2dv"/>
+        </command>
+        <command>
+            <proto>void <name>glEvalCoord2dv</name></proto>
+            <param group="CoordD" len="2">const <ptype>GLdouble</ptype> *<name>u</name></param>
+            <glx type="render" opcode="153"/>
+        </command>
+        <command>
+            <proto>void <name>glEvalCoord2f</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>u</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>v</name></param>
+            <vecequiv name="glEvalCoord2fv"/>
+        </command>
+        <command>
+            <proto>void <name>glEvalCoord2fv</name></proto>
+            <param group="CoordF" len="2">const <ptype>GLfloat</ptype> *<name>u</name></param>
+            <glx type="render" opcode="154"/>
+        </command>
+        <command>
+            <proto>void <name>glEvalCoord2xOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>u</name></param>
+            <param><ptype>GLfixed</ptype> <name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEvalCoord2xvOES</name></proto>
+            <param len="2">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEvalMapsNV</name></proto>
+            <param group="EvalTargetNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="EvalMapsModeNV"><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glEvalMesh1</name></proto>
+            <param group="MeshMode1"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>i1</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>i2</name></param>
+            <glx type="render" opcode="155"/>
+        </command>
+        <command>
+            <proto>void <name>glEvalMesh2</name></proto>
+            <param group="MeshMode2"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>i1</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>i2</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>j1</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>j2</name></param>
+            <glx type="render" opcode="157"/>
+        </command>
+        <command>
+            <proto>void <name>glEvalPoint1</name></proto>
+            <param><ptype>GLint</ptype> <name>i</name></param>
+            <glx type="render" opcode="156"/>
+        </command>
+        <command>
+            <proto>void <name>glEvalPoint2</name></proto>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>i</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>j</name></param>
+            <glx type="render" opcode="158"/>
+        </command>
+        <command>
+            <proto>void <name>glExecuteProgramNV</name></proto>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="render" opcode="4181"/>
+        </command>
+        <command>
+            <proto>void <name>glExtGetBufferPointervQCOM</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param>void **<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glExtGetBuffersQCOM</name></proto>
+            <param len="maxBuffers"><ptype>GLuint</ptype> *<name>buffers</name></param>
+            <param><ptype>GLint</ptype> <name>maxBuffers</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>numBuffers</name></param>
+        </command>
+        <command>
+            <proto>void <name>glExtGetFramebuffersQCOM</name></proto>
+            <param len="maxFramebuffers"><ptype>GLuint</ptype> *<name>framebuffers</name></param>
+            <param><ptype>GLint</ptype> <name>maxFramebuffers</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>numFramebuffers</name></param>
+        </command>
+        <command>
+            <proto>void <name>glExtGetProgramBinarySourceQCOM</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLenum</ptype> <name>shadertype</name></param>
+            <param><ptype>GLchar</ptype> *<name>source</name></param>
+            <param><ptype>GLint</ptype> *<name>length</name></param>
+        </command>
+        <command>
+            <proto>void <name>glExtGetProgramsQCOM</name></proto>
+            <param len="maxPrograms"><ptype>GLuint</ptype> *<name>programs</name></param>
+            <param><ptype>GLint</ptype> <name>maxPrograms</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>numPrograms</name></param>
+        </command>
+        <command>
+            <proto>void <name>glExtGetRenderbuffersQCOM</name></proto>
+            <param len="maxRenderbuffers"><ptype>GLuint</ptype> *<name>renderbuffers</name></param>
+            <param><ptype>GLint</ptype> <name>maxRenderbuffers</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>numRenderbuffers</name></param>
+        </command>
+        <command>
+            <proto>void <name>glExtGetShadersQCOM</name></proto>
+            <param len="maxShaders"><ptype>GLuint</ptype> *<name>shaders</name></param>
+            <param><ptype>GLint</ptype> <name>maxShaders</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>numShaders</name></param>
+        </command>
+        <command>
+            <proto>void <name>glExtGetTexLevelParameterivQCOM</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>face</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glExtGetTexSubImageQCOM</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param>void *<name>texels</name></param>
+        </command>
+        <command>
+            <proto>void <name>glExtGetTexturesQCOM</name></proto>
+            <param><ptype>GLuint</ptype> *<name>textures</name></param>
+            <param><ptype>GLint</ptype> <name>maxTextures</name></param>
+            <param><ptype>GLint</ptype> *<name>numTextures</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLboolean</ptype> <name>glExtIsProgramBinaryQCOM</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+        </command>
+        <command>
+            <proto>void <name>glExtTexObjectStateOverrideiQCOM</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glExtractComponentEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>res</name></param>
+            <param><ptype>GLuint</ptype> <name>src</name></param>
+            <param><ptype>GLuint</ptype> <name>num</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFeedbackBuffer</name></proto>
+            <param><ptype>GLsizei</ptype> <name>size</name></param>
+            <param group="FeedbackType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param group="FeedbackElement" len="size"><ptype>GLfloat</ptype> *<name>buffer</name></param>
+            <glx type="single" opcode="105"/>
+        </command>
+        <command>
+            <proto>void <name>glFeedbackBufferxOES</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="n">const <ptype>GLfixed</ptype> *<name>buffer</name></param>
+        </command>
+        <command>
+            <proto group="sync"><ptype>GLsync</ptype> <name>glFenceSync</name></proto>
+            <param><ptype>GLenum</ptype> <name>condition</name></param>
+            <param><ptype>GLbitfield</ptype> <name>flags</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLsync</ptype> <name>glFenceSyncAPPLE</name></proto>
+            <param><ptype>GLenum</ptype> <name>condition</name></param>
+            <param><ptype>GLbitfield</ptype> <name>flags</name></param>
+            <alias name="glFenceSync"/>
+        </command>
+        <command>
+            <proto>void <name>glFinalCombinerInputNV</name></proto>
+            <param group="CombinerVariableNV"><ptype>GLenum</ptype> <name>variable</name></param>
+            <param group="CombinerRegisterNV"><ptype>GLenum</ptype> <name>input</name></param>
+            <param group="CombinerMappingNV"><ptype>GLenum</ptype> <name>mapping</name></param>
+            <param group="CombinerComponentUsageNV"><ptype>GLenum</ptype> <name>componentUsage</name></param>
+            <glx type="render" opcode="4142"/>
+        </command>
+        <command>
+            <proto>void <name>glFinish</name></proto>
+            <glx type="single" opcode="108"/>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glFinishAsyncSGIX</name></proto>
+            <param len="1"><ptype>GLuint</ptype> *<name>markerp</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFinishFenceAPPLE</name></proto>
+            <param group="FenceNV"><ptype>GLuint</ptype> <name>fence</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFinishFenceNV</name></proto>
+            <param group="FenceNV"><ptype>GLuint</ptype> <name>fence</name></param>
+            <glx type="vendor" opcode="1312"/>
+        </command>
+        <command>
+            <proto>void <name>glFinishObjectAPPLE</name></proto>
+            <param group="ObjectTypeAPPLE"><ptype>GLenum</ptype> <name>object</name></param>
+            <param><ptype>GLint</ptype> <name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFinishTextureSUNX</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glFlush</name></proto>
+            <glx type="single" opcode="142"/>
+        </command>
+        <command>
+            <proto>void <name>glFlushMappedBufferRange</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>length</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFlushMappedBufferRangeAPPLE</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>size</name></param>
+            <alias name="glFlushMappedBufferRange"/>
+        </command>
+        <command>
+            <proto>void <name>glFlushMappedBufferRangeEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param><ptype>GLsizeiptr</ptype> <name>length</name></param>
+            <alias name="glFlushMappedBufferRange"/>
+        </command>
+        <command>
+            <proto>void <name>glFlushMappedNamedBufferRangeEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param><ptype>GLsizeiptr</ptype> <name>length</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFlushPixelDataRangeNV</name></proto>
+            <param group="PixelDataRangeTargetNV"><ptype>GLenum</ptype> <name>target</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFlushRasterSGIX</name></proto>
+            <glx type="vendor" opcode="4105"/>
+        </command>
+        <command>
+            <proto>void <name>glFlushStaticDataIBM</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFlushVertexArrayRangeAPPLE</name></proto>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param len="length">void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFlushVertexArrayRangeNV</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glFogCoordFormatNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFogCoordPointer</name></proto>
+            <param group="FogPointerTypeEXT"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFogCoordPointerEXT</name></proto>
+            <param group="FogPointerTypeEXT"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(type,stride)">const void *<name>pointer</name></param>
+            <alias name="glFogCoordPointer"/>
+        </command>
+        <command>
+            <proto>void <name>glFogCoordPointerListIBM</name></proto>
+            <param group="FogPointerTypeIBM"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLint</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(type,stride)">const void **<name>pointer</name></param>
+            <param><ptype>GLint</ptype> <name>ptrstride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFogCoordd</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>coord</name></param>
+            <vecequiv name="glFogCoorddv"/>
+        </command>
+        <command>
+            <proto>void <name>glFogCoorddEXT</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>coord</name></param>
+            <alias name="glFogCoordd"/>
+            <vecequiv name="glFogCoorddvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glFogCoorddv</name></proto>
+            <param group="CoordD" len="1">const <ptype>GLdouble</ptype> *<name>coord</name></param>
+            <glx type="render" opcode="4125"/>
+        </command>
+        <command>
+            <proto>void <name>glFogCoorddvEXT</name></proto>
+            <param group="CoordD" len="1">const <ptype>GLdouble</ptype> *<name>coord</name></param>
+            <alias name="glFogCoorddv"/>
+            <glx type="render" opcode="4125"/>
+        </command>
+        <command>
+            <proto>void <name>glFogCoordf</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>coord</name></param>
+            <vecequiv name="glFogCoordfv"/>
+        </command>
+        <command>
+            <proto>void <name>glFogCoordfEXT</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>coord</name></param>
+            <alias name="glFogCoordf"/>
+            <vecequiv name="glFogCoordfvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glFogCoordfv</name></proto>
+            <param group="CoordF" len="1">const <ptype>GLfloat</ptype> *<name>coord</name></param>
+            <glx type="render" opcode="4124"/>
+        </command>
+        <command>
+            <proto>void <name>glFogCoordfvEXT</name></proto>
+            <param group="CoordF" len="1">const <ptype>GLfloat</ptype> *<name>coord</name></param>
+            <alias name="glFogCoordfv"/>
+            <glx type="render" opcode="4124"/>
+        </command>
+        <command>
+            <proto>void <name>glFogCoordhNV</name></proto>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>fog</name></param>
+            <vecequiv name="glFogCoordhvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glFogCoordhvNV</name></proto>
+            <param group="Half16NV" len="1">const <ptype>GLhalfNV</ptype> *<name>fog</name></param>
+            <glx type="render" opcode="4254"/>
+        </command>
+        <command>
+            <proto>void <name>glFogFuncSGIS</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n*2">const <ptype>GLfloat</ptype> *<name>points</name></param>
+            <glx type="render" opcode="2067"/>
+        </command>
+        <command>
+            <proto>void <name>glFogf</name></proto>
+            <param group="FogParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <glx type="render" opcode="80"/>
+        </command>
+        <command>
+            <proto>void <name>glFogfv</name></proto>
+            <param group="FogParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="render" opcode="81"/>
+        </command>
+        <command>
+            <proto>void <name>glFogi</name></proto>
+            <param group="FogParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+            <glx type="render" opcode="82"/>
+        </command>
+        <command>
+            <proto>void <name>glFogiv</name></proto>
+            <param group="FogParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="render" opcode="83"/>
+        </command>
+        <command>
+            <proto>void <name>glFogx</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFogxOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFogxv</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfixed</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFogxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfixed</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFragmentColorMaterialSGIX</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="MaterialParameter"><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFragmentLightModelfSGIX</name></proto>
+            <param group="FragmentLightModelParameterSGIX"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFragmentLightModelfvSGIX</name></proto>
+            <param group="FragmentLightModelParameterSGIX"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFragmentLightModeliSGIX</name></proto>
+            <param group="FragmentLightModelParameterSGIX"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFragmentLightModelivSGIX</name></proto>
+            <param group="FragmentLightModelParameterSGIX"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFragmentLightfSGIX</name></proto>
+            <param group="FragmentLightNameSGIX"><ptype>GLenum</ptype> <name>light</name></param>
+            <param group="FragmentLightParameterSGIX"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFragmentLightfvSGIX</name></proto>
+            <param group="FragmentLightNameSGIX"><ptype>GLenum</ptype> <name>light</name></param>
+            <param group="FragmentLightParameterSGIX"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFragmentLightiSGIX</name></proto>
+            <param group="FragmentLightNameSGIX"><ptype>GLenum</ptype> <name>light</name></param>
+            <param group="FragmentLightParameterSGIX"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFragmentLightivSGIX</name></proto>
+            <param group="FragmentLightNameSGIX"><ptype>GLenum</ptype> <name>light</name></param>
+            <param group="FragmentLightParameterSGIX"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFragmentMaterialfSGIX</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="MaterialParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFragmentMaterialfvSGIX</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="MaterialParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFragmentMaterialiSGIX</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="MaterialParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFragmentMaterialivSGIX</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="MaterialParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFrameTerminatorGREMEDY</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glFrameZoomSGIX</name></proto>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>factor</name></param>
+            <glx type="render" opcode="2072"/>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferDrawBufferEXT</name></proto>
+            <param group="Framebuffer"><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <param group="DrawBufferMode"><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferDrawBuffersEXT</name></proto>
+            <param group="Framebuffer"><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="DrawBufferMode" len="n">const <ptype>GLenum</ptype> *<name>bufs</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferParameteri</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferReadBufferEXT</name></proto>
+            <param group="Framebuffer"><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <param group="ReadBufferMode"><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferRenderbuffer</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="RenderbufferTarget"><ptype>GLenum</ptype> <name>renderbuffertarget</name></param>
+            <param><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+            <glx type="render" opcode="4324"/>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferRenderbufferEXT</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="RenderbufferTarget"><ptype>GLenum</ptype> <name>renderbuffertarget</name></param>
+            <param><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+            <alias name="glFramebufferRenderbuffer"/>
+            <glx type="render" opcode="4324"/>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferRenderbufferOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param><ptype>GLenum</ptype> <name>renderbuffertarget</name></param>
+            <param><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTexture</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTexture1D</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param><ptype>GLenum</ptype> <name>textarget</name></param>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <glx type="render" opcode="4321"/>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTexture1DEXT</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param><ptype>GLenum</ptype> <name>textarget</name></param>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <alias name="glFramebufferTexture1D"/>
+            <glx type="render" opcode="4321"/>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTexture2D</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param><ptype>GLenum</ptype> <name>textarget</name></param>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <glx type="render" opcode="4322"/>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTexture2DEXT</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param><ptype>GLenum</ptype> <name>textarget</name></param>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <alias name="glFramebufferTexture2D"/>
+            <glx type="render" opcode="4322"/>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTexture2DMultisampleEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param><ptype>GLenum</ptype> <name>textarget</name></param>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTexture2DMultisampleIMG</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param><ptype>GLenum</ptype> <name>textarget</name></param>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTexture2DOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param><ptype>GLenum</ptype> <name>textarget</name></param>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTexture3D</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param><ptype>GLenum</ptype> <name>textarget</name></param>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLint</ptype> <name>zoffset</name></param>
+            <glx type="render" opcode="4323"/>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTexture3DEXT</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param><ptype>GLenum</ptype> <name>textarget</name></param>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLint</ptype> <name>zoffset</name></param>
+            <alias name="glFramebufferTexture3D"/>
+            <glx type="render" opcode="4323"/>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTexture3DOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param><ptype>GLenum</ptype> <name>textarget</name></param>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLint</ptype> <name>zoffset</name></param>
+            <alias name="glFramebufferTexture3D"/>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTextureARB</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <alias name="glFramebufferTexture"/>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTextureEXT</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <alias name="glFramebufferTextureARB"/>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTextureFaceARB</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>face</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTextureFaceEXT</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>face</name></param>
+            <alias name="glFramebufferTextureFaceARB"/>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTextureLayer</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>layer</name></param>
+            <glx type="render" opcode="237"/>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTextureLayerARB</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>layer</name></param>
+            <alias name="glFramebufferTextureLayer"/>
+        </command>
+        <command>
+            <proto>void <name>glFramebufferTextureLayerEXT</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>layer</name></param>
+            <alias name="glFramebufferTextureLayer"/>
+        </command>
+        <command>
+            <proto>void <name>glFreeObjectBufferATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFrontFace</name></proto>
+            <param group="FrontFaceDirection"><ptype>GLenum</ptype> <name>mode</name></param>
+            <glx type="render" opcode="84"/>
+        </command>
+        <command>
+            <proto>void <name>glFrustum</name></proto>
+            <param><ptype>GLdouble</ptype> <name>left</name></param>
+            <param><ptype>GLdouble</ptype> <name>right</name></param>
+            <param><ptype>GLdouble</ptype> <name>bottom</name></param>
+            <param><ptype>GLdouble</ptype> <name>top</name></param>
+            <param><ptype>GLdouble</ptype> <name>zNear</name></param>
+            <param><ptype>GLdouble</ptype> <name>zFar</name></param>
+            <glx type="render" opcode="175"/>
+        </command>
+        <command>
+            <proto>void <name>glFrustumf</name></proto>
+            <param><ptype>GLfloat</ptype> <name>l</name></param>
+            <param><ptype>GLfloat</ptype> <name>r</name></param>
+            <param><ptype>GLfloat</ptype> <name>b</name></param>
+            <param><ptype>GLfloat</ptype> <name>t</name></param>
+            <param><ptype>GLfloat</ptype> <name>n</name></param>
+            <param><ptype>GLfloat</ptype> <name>f</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFrustumfOES</name></proto>
+            <param><ptype>GLfloat</ptype> <name>l</name></param>
+            <param><ptype>GLfloat</ptype> <name>r</name></param>
+            <param><ptype>GLfloat</ptype> <name>b</name></param>
+            <param><ptype>GLfloat</ptype> <name>t</name></param>
+            <param><ptype>GLfloat</ptype> <name>n</name></param>
+            <param><ptype>GLfloat</ptype> <name>f</name></param>
+            <glx type="render" opcode="4310"/>
+        </command>
+        <command>
+            <proto>void <name>glFrustumx</name></proto>
+            <param><ptype>GLfixed</ptype> <name>l</name></param>
+            <param><ptype>GLfixed</ptype> <name>r</name></param>
+            <param><ptype>GLfixed</ptype> <name>b</name></param>
+            <param><ptype>GLfixed</ptype> <name>t</name></param>
+            <param><ptype>GLfixed</ptype> <name>n</name></param>
+            <param><ptype>GLfixed</ptype> <name>f</name></param>
+        </command>
+        <command>
+            <proto>void <name>glFrustumxOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>l</name></param>
+            <param><ptype>GLfixed</ptype> <name>r</name></param>
+            <param><ptype>GLfixed</ptype> <name>b</name></param>
+            <param><ptype>GLfixed</ptype> <name>t</name></param>
+            <param><ptype>GLfixed</ptype> <name>n</name></param>
+            <param><ptype>GLfixed</ptype> <name>f</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glGenAsyncMarkersSGIX</name></proto>
+            <param><ptype>GLsizei</ptype> <name>range</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGenBuffers</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>buffers</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGenBuffersARB</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>buffers</name></param>
+            <alias name="glGenBuffers"/>
+        </command>
+        <command>
+            <proto>void <name>glGenFencesAPPLE</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="FenceNV" len="n"><ptype>GLuint</ptype> *<name>fences</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGenFencesNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="FenceNV" len="n"><ptype>GLuint</ptype> *<name>fences</name></param>
+            <glx type="vendor" opcode="1277"/>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glGenFragmentShadersATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>range</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGenFramebuffers</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>framebuffers</name></param>
+            <glx type="vendor" opcode="1426"/>
+        </command>
+        <command>
+            <proto>void <name>glGenFramebuffersEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>framebuffers</name></param>
+            <alias name="glGenFramebuffers"/>
+            <glx type="vendor" opcode="1426"/>
+        </command>
+        <command>
+            <proto>void <name>glGenFramebuffersOES</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>framebuffers</name></param>
+        </command>
+        <command>
+            <proto group="List"><ptype>GLuint</ptype> <name>glGenLists</name></proto>
+            <param><ptype>GLsizei</ptype> <name>range</name></param>
+            <glx type="single" opcode="104"/>
+        </command>
+        <command>
+            <proto>void <name>glGenNamesAMD</name></proto>
+            <param><ptype>GLenum</ptype> <name>identifier</name></param>
+            <param><ptype>GLuint</ptype> <name>num</name></param>
+            <param len="num"><ptype>GLuint</ptype> *<name>names</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGenOcclusionQueriesNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>ids</name></param>
+        </command>
+        <command>
+            <proto group="Path"><ptype>GLuint</ptype> <name>glGenPathsNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>range</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGenPerfMonitorsAMD</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>monitors</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGenProgramPipelines</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>pipelines</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGenProgramPipelinesEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>pipelines</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGenProgramsARB</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>programs</name></param>
+            <glx type="vendor" opcode="1295"/>
+        </command>
+        <command>
+            <proto>void <name>glGenProgramsNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>programs</name></param>
+            <alias name="glGenProgramsARB"/>
+            <glx type="vendor" opcode="1295"/>
+        </command>
+        <command>
+            <proto>void <name>glGenQueries</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>ids</name></param>
+            <glx type="single" opcode="162"/>
+        </command>
+        <command>
+            <proto>void <name>glGenQueriesARB</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>ids</name></param>
+            <alias name="glGenQueries"/>
+        </command>
+        <command>
+            <proto>void <name>glGenQueriesEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>ids</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGenRenderbuffers</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>renderbuffers</name></param>
+            <glx type="vendor" opcode="1423"/>
+        </command>
+        <command>
+            <proto>void <name>glGenRenderbuffersEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>renderbuffers</name></param>
+            <alias name="glGenRenderbuffers"/>
+            <glx type="vendor" opcode="1423"/>
+        </command>
+        <command>
+            <proto>void <name>glGenRenderbuffersOES</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>renderbuffers</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGenSamplers</name></proto>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count"><ptype>GLuint</ptype> *<name>samplers</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glGenSymbolsEXT</name></proto>
+            <param group="DataTypeEXT"><ptype>GLenum</ptype> <name>datatype</name></param>
+            <param group="VertexShaderStorageTypeEXT"><ptype>GLenum</ptype> <name>storagetype</name></param>
+            <param group="ParameterRangeEXT"><ptype>GLenum</ptype> <name>range</name></param>
+            <param><ptype>GLuint</ptype> <name>components</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGenTextures</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="Texture" len="n"><ptype>GLuint</ptype> *<name>textures</name></param>
+            <glx type="single" opcode="145"/>
+        </command>
+        <command>
+            <proto>void <name>glGenTexturesEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="Texture" len="n"><ptype>GLuint</ptype> *<name>textures</name></param>
+            <glx type="vendor" opcode="13"/>
+        </command>
+        <command>
+            <proto>void <name>glGenTransformFeedbacks</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>ids</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGenTransformFeedbacksNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>ids</name></param>
+            <alias name="glGenTransformFeedbacks"/>
+        </command>
+        <command>
+            <proto>void <name>glGenVertexArrays</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>arrays</name></param>
+            <glx type="single" opcode="206"/>
+        </command>
+        <command>
+            <proto>void <name>glGenVertexArraysAPPLE</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>arrays</name></param>
+            <alias name="glGenVertexArrays"/>
+        </command>
+        <command>
+            <proto>void <name>glGenVertexArraysOES</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n"><ptype>GLuint</ptype> *<name>arrays</name></param>
+            <alias name="glGenVertexArrays"/>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glGenVertexShadersEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>range</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGenerateMipmap</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <glx type="render" opcode="4325"/>
+        </command>
+        <command>
+            <proto>void <name>glGenerateMipmapEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <alias name="glGenerateMipmap"/>
+            <glx type="render" opcode="4325"/>
+        </command>
+        <command>
+            <proto>void <name>glGenerateMipmapOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGenerateMultiTexMipmapEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGenerateTextureMipmapEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetActiveAtomicCounterBufferiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>bufferIndex</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetActiveAttrib</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>size</name></param>
+            <param len="1"><ptype>GLenum</ptype> *<name>type</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetActiveAttribARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>programObj</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>maxLength</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>size</name></param>
+            <param len="1"><ptype>GLenum</ptype> *<name>type</name></param>
+            <param len="maxLength"><ptype>GLcharARB</ptype> *<name>name</name></param>
+            <alias name="glGetActiveAttrib"/>
+        </command>
+        <command>
+            <proto>void <name>glGetActiveSubroutineName</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLenum</ptype> <name>shadertype</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufsize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufsize"><ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetActiveSubroutineUniformName</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLenum</ptype> <name>shadertype</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufsize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufsize"><ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetActiveSubroutineUniformiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLenum</ptype> <name>shadertype</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>values</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetActiveUniform</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>size</name></param>
+            <param len="1"><ptype>GLenum</ptype> *<name>type</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetActiveUniformARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>programObj</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>maxLength</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>size</name></param>
+            <param len="1"><ptype>GLenum</ptype> *<name>type</name></param>
+            <param len="maxLength"><ptype>GLcharARB</ptype> *<name>name</name></param>
+            <alias name="glGetActiveUniform"/>
+        </command>
+        <command>
+            <proto>void <name>glGetActiveUniformBlockName</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>uniformBlockIndex</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>uniformBlockName</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetActiveUniformBlockiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>uniformBlockIndex</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetActiveUniformName</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>uniformIndex</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>uniformName</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetActiveUniformsiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLsizei</ptype> <name>uniformCount</name></param>
+            <param len="COMPSIZE(uniformCount)">const <ptype>GLuint</ptype> *<name>uniformIndices</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetActiveVaryingNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>size</name></param>
+            <param len="1"><ptype>GLenum</ptype> *<name>type</name></param>
+            <param len="COMPSIZE(program,index,bufSize)"><ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetArrayObjectfvATI</name></proto>
+            <param group="EnableCap"><ptype>GLenum</ptype> <name>array</name></param>
+            <param group="ArrayObjectPNameATI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetArrayObjectivATI</name></proto>
+            <param group="EnableCap"><ptype>GLenum</ptype> <name>array</name></param>
+            <param group="ArrayObjectPNameATI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command comment="Could be an alias of glGetAttachedShaders except that GLhandleARB is different on MacOS X">
+            <proto>void <name>glGetAttachedObjectsARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>containerObj</name></param>
+            <param><ptype>GLsizei</ptype> <name>maxCount</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>count</name></param>
+            <param group="handleARB" len="maxCount"><ptype>GLhandleARB</ptype> *<name>obj</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetAttachedShaders</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLsizei</ptype> <name>maxCount</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>count</name></param>
+            <param len="maxCount"><ptype>GLuint</ptype> *<name>shaders</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glGetAttribLocation</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param>const <ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glGetAttribLocationARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>programObj</name></param>
+            <param>const <ptype>GLcharARB</ptype> *<name>name</name></param>
+            <alias name="glGetAttribLocation"/>
+        </command>
+        <command>
+            <proto>void <name>glGetBooleanIndexedvEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="Boolean" len="COMPSIZE(target)"><ptype>GLboolean</ptype> *<name>data</name></param>
+            <alias name="glGetBooleani_v"/>
+        </command>
+        <command>
+            <proto>void <name>glGetBooleani_v</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="Boolean" len="COMPSIZE(target)"><ptype>GLboolean</ptype> *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetBooleanv</name></proto>
+            <param group="GetPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="Boolean" len="COMPSIZE(pname)"><ptype>GLboolean</ptype> *<name>data</name></param>
+            <glx type="single" opcode="112"/>
+        </command>
+        <command>
+            <proto>void <name>glGetBufferParameteri64v</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="BufferPNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint64</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetBufferParameteriv</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="BufferPNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetBufferParameterivARB</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="BufferPNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glGetBufferParameteriv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetBufferParameterui64vNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLuint64EXT</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetBufferPointerv</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="BufferPointerNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1">void **<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetBufferPointervARB</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="BufferPointerNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1">void **<name>params</name></param>
+            <alias name="glGetBufferPointerv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetBufferPointervOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param>void **<name>params</name></param>
+            <alias name="glGetBufferPointerv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetBufferSubData</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>size</name></param>
+            <param len="size">void *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetBufferSubDataARB</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="BufferOffsetARB"><ptype>GLintptrARB</ptype> <name>offset</name></param>
+            <param group="BufferSizeARB"><ptype>GLsizeiptrARB</ptype> <name>size</name></param>
+            <param len="size">void *<name>data</name></param>
+            <alias name="glGetBufferSubData"/>
+        </command>
+        <command>
+            <proto>void <name>glGetClipPlane</name></proto>
+            <param group="ClipPlaneName"><ptype>GLenum</ptype> <name>plane</name></param>
+            <param len="4"><ptype>GLdouble</ptype> *<name>equation</name></param>
+            <glx type="single" opcode="113"/>
+        </command>
+        <command>
+            <proto>void <name>glGetClipPlanef</name></proto>
+            <param><ptype>GLenum</ptype> <name>plane</name></param>
+            <param len="4"><ptype>GLfloat</ptype> *<name>equation</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetClipPlanefOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>plane</name></param>
+            <param len="4"><ptype>GLfloat</ptype> *<name>equation</name></param>
+            <glx type="vendor" opcode="1421"/>
+        </command>
+        <command>
+            <proto>void <name>glGetClipPlanex</name></proto>
+            <param><ptype>GLenum</ptype> <name>plane</name></param>
+            <param len="4"><ptype>GLfixed</ptype> *<name>equation</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetClipPlanexOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>plane</name></param>
+            <param len="4"><ptype>GLfixed</ptype> *<name>equation</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetColorTable</name></proto>
+            <param group="ColorTableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(target,format,type)">void *<name>table</name></param>
+            <glx type="single" opcode="147"/>
+            <glx type="render" opcode="334" name="glGetColorTablePBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glGetColorTableEXT</name></proto>
+            <param group="ColorTableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(target,format,type)">void *<name>data</name></param>
+            <alias name="glGetColorTable"/>
+        </command>
+        <command>
+            <proto>void <name>glGetColorTableParameterfv</name></proto>
+            <param group="ColorTableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetColorTableParameterPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="single" opcode="148"/>
+        </command>
+        <command>
+            <proto>void <name>glGetColorTableParameterfvEXT</name></proto>
+            <param group="ColorTableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetColorTableParameterPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <alias name="glGetColorTableParameterfv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetColorTableParameterfvSGI</name></proto>
+            <param group="ColorTableTargetSGI"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetColorTableParameterPNameSGI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="4099"/>
+        </command>
+        <command>
+            <proto>void <name>glGetColorTableParameteriv</name></proto>
+            <param group="ColorTableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetColorTableParameterPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="149"/>
+        </command>
+        <command>
+            <proto>void <name>glGetColorTableParameterivEXT</name></proto>
+            <param group="ColorTableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetColorTableParameterPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glGetColorTableParameteriv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetColorTableParameterivSGI</name></proto>
+            <param group="ColorTableTargetSGI"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetColorTableParameterPNameSGI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="4100"/>
+        </command>
+        <command>
+            <proto>void <name>glGetColorTableSGI</name></proto>
+            <param group="ColorTableTargetSGI"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(target,format,type)">void *<name>table</name></param>
+            <glx type="vendor" opcode="4098"/>
+        </command>
+        <command>
+            <proto>void <name>glGetCombinerInputParameterfvNV</name></proto>
+            <param group="CombinerStageNV"><ptype>GLenum</ptype> <name>stage</name></param>
+            <param group="CombinerPortionNV"><ptype>GLenum</ptype> <name>portion</name></param>
+            <param group="CombinerVariableNV"><ptype>GLenum</ptype> <name>variable</name></param>
+            <param group="CombinerParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1270"/>
+        </command>
+        <command>
+            <proto>void <name>glGetCombinerInputParameterivNV</name></proto>
+            <param group="CombinerStageNV"><ptype>GLenum</ptype> <name>stage</name></param>
+            <param group="CombinerPortionNV"><ptype>GLenum</ptype> <name>portion</name></param>
+            <param group="CombinerVariableNV"><ptype>GLenum</ptype> <name>variable</name></param>
+            <param group="CombinerParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1271"/>
+        </command>
+        <command>
+            <proto>void <name>glGetCombinerOutputParameterfvNV</name></proto>
+            <param group="CombinerStageNV"><ptype>GLenum</ptype> <name>stage</name></param>
+            <param group="CombinerPortionNV"><ptype>GLenum</ptype> <name>portion</name></param>
+            <param group="CombinerParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1272"/>
+        </command>
+        <command>
+            <proto>void <name>glGetCombinerOutputParameterivNV</name></proto>
+            <param group="CombinerStageNV"><ptype>GLenum</ptype> <name>stage</name></param>
+            <param group="CombinerPortionNV"><ptype>GLenum</ptype> <name>portion</name></param>
+            <param group="CombinerParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1273"/>
+        </command>
+        <command>
+            <proto>void <name>glGetCombinerStageParameterfvNV</name></proto>
+            <param group="CombinerStageNV"><ptype>GLenum</ptype> <name>stage</name></param>
+            <param group="CombinerParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetCompressedMultiTexImageEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>lod</name></param>
+            <param len="COMPSIZE(target,lod)">void *<name>img</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetCompressedTexImage</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CompressedTextureARB" len="COMPSIZE(target,level)">void *<name>img</name></param>
+            <glx type="single" opcode="160"/>
+            <glx type="render" opcode="335" name="glGetCompressedTexImagePBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glGetCompressedTexImageARB</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CompressedTextureARB" len="COMPSIZE(target,level)">void *<name>img</name></param>
+            <alias name="glGetCompressedTexImage"/>
+            <glx type="single" opcode="160"/>
+        </command>
+        <command>
+            <proto>void <name>glGetCompressedTextureImageEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>lod</name></param>
+            <param len="COMPSIZE(target,lod)">void *<name>img</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetConvolutionFilter</name></proto>
+            <param group="ConvolutionTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(target,format,type)">void *<name>image</name></param>
+            <glx type="single" opcode="150"/>
+            <glx type="render" opcode="336" name="glGetConvolutionFilterPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glGetConvolutionFilterEXT</name></proto>
+            <param group="ConvolutionTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(target,format,type)">void *<name>image</name></param>
+            <glx type="vendor" opcode="1"/>
+        </command>
+        <command>
+            <proto>void <name>glGetConvolutionParameterfv</name></proto>
+            <param group="ConvolutionTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetConvolutionParameterPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="single" opcode="151"/>
+        </command>
+        <command>
+            <proto>void <name>glGetConvolutionParameterfvEXT</name></proto>
+            <param group="ConvolutionTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ConvolutionParameterEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="2"/>
+        </command>
+        <command>
+            <proto>void <name>glGetConvolutionParameteriv</name></proto>
+            <param group="ConvolutionTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetConvolutionParameterPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="152"/>
+        </command>
+        <command>
+            <proto>void <name>glGetConvolutionParameterivEXT</name></proto>
+            <param group="ConvolutionTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ConvolutionParameterEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="3"/>
+        </command>
+        <command>
+            <proto>void <name>glGetConvolutionParameterxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glGetDebugMessageLog</name></proto>
+            <param><ptype>GLuint</ptype> <name>count</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="count"><ptype>GLenum</ptype> *<name>sources</name></param>
+            <param len="count"><ptype>GLenum</ptype> *<name>types</name></param>
+            <param len="count"><ptype>GLuint</ptype> *<name>ids</name></param>
+            <param len="count"><ptype>GLenum</ptype> *<name>severities</name></param>
+            <param len="count"><ptype>GLsizei</ptype> *<name>lengths</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>messageLog</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glGetDebugMessageLogAMD</name></proto>
+            <param><ptype>GLuint</ptype> <name>count</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufsize</name></param>
+            <param len="count"><ptype>GLenum</ptype> *<name>categories</name></param>
+            <param len="count"><ptype>GLuint</ptype> *<name>severities</name></param>
+            <param len="count"><ptype>GLuint</ptype> *<name>ids</name></param>
+            <param len="count"><ptype>GLsizei</ptype> *<name>lengths</name></param>
+            <param len="bufsize"><ptype>GLchar</ptype> *<name>message</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glGetDebugMessageLogARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>count</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="count"><ptype>GLenum</ptype> *<name>sources</name></param>
+            <param len="count"><ptype>GLenum</ptype> *<name>types</name></param>
+            <param len="count"><ptype>GLuint</ptype> *<name>ids</name></param>
+            <param len="count"><ptype>GLenum</ptype> *<name>severities</name></param>
+            <param len="count"><ptype>GLsizei</ptype> *<name>lengths</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>messageLog</name></param>
+            <alias name="glGetDebugMessageLog"/>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glGetDebugMessageLogKHR</name></proto>
+            <param><ptype>GLuint</ptype> <name>count</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="count"><ptype>GLenum</ptype> *<name>sources</name></param>
+            <param len="count"><ptype>GLenum</ptype> *<name>types</name></param>
+            <param len="count"><ptype>GLuint</ptype> *<name>ids</name></param>
+            <param len="count"><ptype>GLenum</ptype> *<name>severities</name></param>
+            <param len="count"><ptype>GLsizei</ptype> *<name>lengths</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>messageLog</name></param>
+            <alias name="glGetDebugMessageLog"/>
+        </command>
+        <command>
+            <proto>void <name>glGetDetailTexFuncSGIS</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param len="COMPSIZE(target)"><ptype>GLfloat</ptype> *<name>points</name></param>
+            <glx type="vendor" opcode="4096"/>
+        </command>
+        <command>
+            <proto>void <name>glGetDoubleIndexedvEXT</name></proto>
+            <param group="TypeEnum"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="COMPSIZE(target)"><ptype>GLdouble</ptype> *<name>data</name></param>
+            <alias name="glGetDoublei_v"/>
+        </command>
+        <command>
+            <proto>void <name>glGetDoublei_v</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="COMPSIZE(target)"><ptype>GLdouble</ptype> *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetDoublei_vEXT</name></proto>
+            <param group="TypeEnum"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="COMPSIZE(target)"><ptype>GLdouble</ptype> *<name>params</name></param>
+            <alias name="glGetDoublei_v"/>
+        </command>
+        <command>
+            <proto>void <name>glGetDoublev</name></proto>
+            <param group="GetPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLdouble</ptype> *<name>data</name></param>
+            <glx type="single" opcode="114"/>
+        </command>
+        <command>
+            <proto>void <name>glGetDriverControlStringQCOM</name></proto>
+            <param><ptype>GLuint</ptype> <name>driverControl</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>driverControlString</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetDriverControlsQCOM</name></proto>
+            <param><ptype>GLint</ptype> *<name>num</name></param>
+            <param><ptype>GLsizei</ptype> <name>size</name></param>
+            <param len="size"><ptype>GLuint</ptype> *<name>driverControls</name></param>
+        </command>
+        <command>
+            <proto group="ErrorCode"><ptype>GLenum</ptype> <name>glGetError</name></proto>
+            <glx type="single" opcode="115"/>
+        </command>
+        <command>
+            <proto>void <name>glGetFenceivNV</name></proto>
+            <param group="FenceNV"><ptype>GLuint</ptype> <name>fence</name></param>
+            <param group="FenceParameterNameNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1280"/>
+        </command>
+        <command>
+            <proto>void <name>glGetFinalCombinerInputParameterfvNV</name></proto>
+            <param group="CombinerVariableNV"><ptype>GLenum</ptype> <name>variable</name></param>
+            <param group="CombinerParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1274"/>
+        </command>
+        <command>
+            <proto>void <name>glGetFinalCombinerInputParameterivNV</name></proto>
+            <param group="CombinerVariableNV"><ptype>GLenum</ptype> <name>variable</name></param>
+            <param group="CombinerParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1275"/>
+        </command>
+        <command>
+            <proto>void <name>glGetFirstPerfQueryIdINTEL</name></proto>
+            <param><ptype>GLuint</ptype> *<name>queryId</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetFixedv</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetFixedvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetFloatIndexedvEXT</name></proto>
+            <param group="TypeEnum"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="COMPSIZE(target)"><ptype>GLfloat</ptype> *<name>data</name></param>
+            <alias name="glGetFloati_v"/>
+        </command>
+        <command>
+            <proto>void <name>glGetFloati_v</name></proto>
+            <param group="TypeEnum"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="COMPSIZE(target)"><ptype>GLfloat</ptype> *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetFloati_vEXT</name></proto>
+            <param group="TypeEnum"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="COMPSIZE(target)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <alias name="glGetFloati_v"/>
+        </command>
+        <command>
+            <proto>void <name>glGetFloatv</name></proto>
+            <param group="GetPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>data</name></param>
+            <glx type="single" opcode="116"/>
+        </command>
+        <command>
+            <proto>void <name>glGetFogFuncSGIS</name></proto>
+            <param len="COMPSIZE()"><ptype>GLfloat</ptype> *<name>points</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glGetFragDataIndex</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param>const <ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glGetFragDataLocation</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param len="COMPSIZE(name)">const <ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glGetFragDataLocationEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param len="COMPSIZE(name)">const <ptype>GLchar</ptype> *<name>name</name></param>
+            <alias name="glGetFragDataLocation"/>
+        </command>
+        <command>
+            <proto>void <name>glGetFragmentLightfvSGIX</name></proto>
+            <param group="FragmentLightNameSGIX"><ptype>GLenum</ptype> <name>light</name></param>
+            <param group="FragmentLightParameterSGIX"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetFragmentLightivSGIX</name></proto>
+            <param group="FragmentLightNameSGIX"><ptype>GLenum</ptype> <name>light</name></param>
+            <param group="FragmentLightParameterSGIX"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetFragmentMaterialfvSGIX</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="MaterialParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetFragmentMaterialivSGIX</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="MaterialParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetFramebufferAttachmentParameteriv</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1428"/>
+        </command>
+        <command>
+            <proto>void <name>glGetFramebufferAttachmentParameterivEXT</name></proto>
+            <param group="FramebufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glGetFramebufferAttachmentParameteriv"/>
+            <glx type="vendor" opcode="1428"/>
+        </command>
+        <command>
+            <proto>void <name>glGetFramebufferAttachmentParameterivOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetFramebufferParameteriv</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetFramebufferParameterivEXT</name></proto>
+            <param group="Framebuffer"><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <param group="GetFramebufferParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLenum</ptype> <name>glGetGraphicsResetStatusARB</name></proto>
+        </command>
+        <command>
+            <proto><ptype>GLenum</ptype> <name>glGetGraphicsResetStatusEXT</name></proto>
+        </command>
+        <command>
+            <proto group="handleARB"><ptype>GLhandleARB</ptype> <name>glGetHandleARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetHistogram</name></proto>
+            <param group="HistogramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>reset</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(target,format,type)">void *<name>values</name></param>
+            <glx type="single" opcode="154"/>
+            <glx type="render" opcode="337" name="glGetHistogramPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glGetHistogramEXT</name></proto>
+            <param group="HistogramTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>reset</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(target,format,type)">void *<name>values</name></param>
+            <glx type="vendor" opcode="5"/>
+        </command>
+        <command>
+            <proto>void <name>glGetHistogramParameterfv</name></proto>
+            <param group="HistogramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetHistogramParameterPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="single" opcode="155"/>
+        </command>
+        <command>
+            <proto>void <name>glGetHistogramParameterfvEXT</name></proto>
+            <param group="HistogramTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetHistogramParameterPNameEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="6"/>
+        </command>
+        <command>
+            <proto>void <name>glGetHistogramParameteriv</name></proto>
+            <param group="HistogramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetHistogramParameterPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="156"/>
+        </command>
+        <command>
+            <proto>void <name>glGetHistogramParameterivEXT</name></proto>
+            <param group="HistogramTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetHistogramParameterPNameEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="7"/>
+        </command>
+        <command>
+            <proto>void <name>glGetHistogramParameterxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint64</ptype> <name>glGetImageHandleARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLboolean</ptype> <name>layered</name></param>
+            <param><ptype>GLint</ptype> <name>layer</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint64</ptype> <name>glGetImageHandleNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>layered</name></param>
+            <param><ptype>GLint</ptype> <name>layer</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetImageTransformParameterfvHP</name></proto>
+            <param group="ImageTransformTargetHP"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ImageTransformPNameHP"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetImageTransformParameterivHP</name></proto>
+            <param group="ImageTransformTargetHP"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ImageTransformPNameHP"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetInfoLogARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>obj</name></param>
+            <param><ptype>GLsizei</ptype> <name>maxLength</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="maxLength"><ptype>GLcharARB</ptype> *<name>infoLog</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glGetInstrumentsSGIX</name></proto>
+            <glx type="vendor" opcode="4102"/>
+        </command>
+        <command>
+            <proto>void <name>glGetInteger64i_v</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="COMPSIZE(target)"><ptype>GLint64</ptype> *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetInteger64v</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint64</ptype> *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetInteger64vAPPLE</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint64</ptype> *<name>params</name></param>
+            <alias name="glGetInteger64v"/>
+        </command>
+        <command>
+            <proto>void <name>glGetIntegerIndexedvEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="COMPSIZE(target)"><ptype>GLint</ptype> *<name>data</name></param>
+            <alias name="glGetIntegeri_v"/>
+        </command>
+        <command>
+            <proto>void <name>glGetIntegeri_v</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="COMPSIZE(target)"><ptype>GLint</ptype> *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetIntegeri_vEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetIntegerui64i_vNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>value</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="COMPSIZE(value)"><ptype>GLuint64EXT</ptype> *<name>result</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetIntegerui64vNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>value</name></param>
+            <param len="COMPSIZE(value)"><ptype>GLuint64EXT</ptype> *<name>result</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetIntegerv</name></proto>
+            <param group="GetPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>data</name></param>
+            <glx type="single" opcode="117"/>
+        </command>
+        <command>
+            <proto>void <name>glGetInternalformati64v</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize"><ptype>GLint64</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetInternalformativ</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetInvariantBooleanvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="GetVariantValueEXT"><ptype>GLenum</ptype> <name>value</name></param>
+            <param group="Boolean" len="COMPSIZE(id)"><ptype>GLboolean</ptype> *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetInvariantFloatvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="GetVariantValueEXT"><ptype>GLenum</ptype> <name>value</name></param>
+            <param len="COMPSIZE(id)"><ptype>GLfloat</ptype> *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetInvariantIntegervEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="GetVariantValueEXT"><ptype>GLenum</ptype> <name>value</name></param>
+            <param len="COMPSIZE(id)"><ptype>GLint</ptype> *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetLightfv</name></proto>
+            <param group="LightName"><ptype>GLenum</ptype> <name>light</name></param>
+            <param group="LightParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="single" opcode="118"/>
+        </command>
+        <command>
+            <proto>void <name>glGetLightiv</name></proto>
+            <param group="LightName"><ptype>GLenum</ptype> <name>light</name></param>
+            <param group="LightParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="119"/>
+        </command>
+        <command>
+            <proto>void <name>glGetLightxOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>light</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetLightxv</name></proto>
+            <param><ptype>GLenum</ptype> <name>light</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetLightxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>light</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetListParameterfvSGIX</name></proto>
+            <param group="List"><ptype>GLuint</ptype> <name>list</name></param>
+            <param group="ListParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetListParameterivSGIX</name></proto>
+            <param group="List"><ptype>GLuint</ptype> <name>list</name></param>
+            <param group="ListParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetLocalConstantBooleanvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="GetVariantValueEXT"><ptype>GLenum</ptype> <name>value</name></param>
+            <param group="Boolean" len="COMPSIZE(id)"><ptype>GLboolean</ptype> *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetLocalConstantFloatvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="GetVariantValueEXT"><ptype>GLenum</ptype> <name>value</name></param>
+            <param len="COMPSIZE(id)"><ptype>GLfloat</ptype> *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetLocalConstantIntegervEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="GetVariantValueEXT"><ptype>GLenum</ptype> <name>value</name></param>
+            <param len="COMPSIZE(id)"><ptype>GLint</ptype> *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMapAttribParameterfvNV</name></proto>
+            <param group="EvalTargetNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="MapAttribParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMapAttribParameterivNV</name></proto>
+            <param group="EvalTargetNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="MapAttribParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMapControlPointsNV</name></proto>
+            <param group="EvalTargetNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="MapTypeNV"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>ustride</name></param>
+            <param><ptype>GLsizei</ptype> <name>vstride</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>packed</name></param>
+            <param len="COMPSIZE(target)">void *<name>points</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMapParameterfvNV</name></proto>
+            <param group="EvalTargetNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="MapParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(target,pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMapParameterivNV</name></proto>
+            <param group="EvalTargetNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="MapParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(target,pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMapdv</name></proto>
+            <param group="MapTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetMapQuery"><ptype>GLenum</ptype> <name>query</name></param>
+            <param len="COMPSIZE(target,query)"><ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="single" opcode="120"/>
+        </command>
+        <command>
+            <proto>void <name>glGetMapfv</name></proto>
+            <param group="MapTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetMapQuery"><ptype>GLenum</ptype> <name>query</name></param>
+            <param len="COMPSIZE(target,query)"><ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="single" opcode="121"/>
+        </command>
+        <command>
+            <proto>void <name>glGetMapiv</name></proto>
+            <param group="MapTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetMapQuery"><ptype>GLenum</ptype> <name>query</name></param>
+            <param len="COMPSIZE(target,query)"><ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="single" opcode="122"/>
+        </command>
+        <command>
+            <proto>void <name>glGetMapxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>query</name></param>
+            <param len="COMPSIZE(query)"><ptype>GLfixed</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMaterialfv</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="MaterialParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="single" opcode="123"/>
+        </command>
+        <command>
+            <proto>void <name>glGetMaterialiv</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="MaterialParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="124"/>
+        </command>
+        <command>
+            <proto>void <name>glGetMaterialxOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>face</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMaterialxv</name></proto>
+            <param><ptype>GLenum</ptype> <name>face</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMaterialxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>face</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMinmax</name></proto>
+            <param group="MinmaxTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>reset</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(target,format,type)">void *<name>values</name></param>
+            <glx type="single" opcode="157"/>
+            <glx type="render" opcode="338" name="glGetMinmaxPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glGetMinmaxEXT</name></proto>
+            <param group="MinmaxTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>reset</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(target,format,type)">void *<name>values</name></param>
+            <glx type="vendor" opcode="8"/>
+        </command>
+        <command>
+            <proto>void <name>glGetMinmaxParameterfv</name></proto>
+            <param group="MinmaxTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetMinmaxParameterPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="single" opcode="158"/>
+        </command>
+        <command>
+            <proto>void <name>glGetMinmaxParameterfvEXT</name></proto>
+            <param group="MinmaxTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetMinmaxParameterPNameEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="9"/>
+        </command>
+        <command>
+            <proto>void <name>glGetMinmaxParameteriv</name></proto>
+            <param group="MinmaxTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetMinmaxParameterPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="159"/>
+        </command>
+        <command>
+            <proto>void <name>glGetMinmaxParameterivEXT</name></proto>
+            <param group="MinmaxTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetMinmaxParameterPNameEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="10"/>
+        </command>
+        <command>
+            <proto>void <name>glGetMultiTexEnvfvEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureEnvTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureEnvParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMultiTexEnvivEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureEnvTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureEnvParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMultiTexGendvEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLdouble</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMultiTexGenfvEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMultiTexGenivEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMultiTexImageEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(target,level,format,type)">void *<name>pixels</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMultiTexLevelParameterfvEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMultiTexLevelParameterivEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMultiTexParameterIivEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMultiTexParameterIuivEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMultiTexParameterfvEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMultiTexParameterivEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMultisamplefv</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>val</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetMultisamplefvNV</name></proto>
+            <param group="GetMultisamplePNameNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2"><ptype>GLfloat</ptype> *<name>val</name></param>
+            <alias name="glGetMultisamplefv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetNamedBufferParameterivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="VertexBufferObjectParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetNamedBufferParameterui64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="VertexBufferObjectParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLuint64EXT</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetNamedBufferPointervEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="VertexBufferObjectParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1">void **<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetNamedBufferSubDataEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param><ptype>GLsizeiptr</ptype> <name>size</name></param>
+            <param len="COMPSIZE(size)">void *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetNamedFramebufferAttachmentParameterivEXT</name></proto>
+            <param group="Framebuffer"><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="FramebufferAttachmentParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetNamedFramebufferParameterivEXT</name></proto>
+            <param group="Framebuffer"><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <param group="GetFramebufferParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetNamedProgramLocalParameterIivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetNamedProgramLocalParameterIuivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4"><ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetNamedProgramLocalParameterdvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4"><ptype>GLdouble</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetNamedProgramLocalParameterfvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetNamedProgramStringEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ProgramStringProperty"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(program,pname)">void *<name>string</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetNamedProgramivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ProgramProperty"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetNamedRenderbufferParameterivEXT</name></proto>
+            <param group="Renderbuffer"><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+            <param group="RenderbufferParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetNamedStringARB</name></proto>
+            <param><ptype>GLint</ptype> <name>namelen</name></param>
+            <param len="namelen">const <ptype>GLchar</ptype> *<name>name</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>stringlen</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>string</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetNamedStringivARB</name></proto>
+            <param><ptype>GLint</ptype> <name>namelen</name></param>
+            <param len="namelen">const <ptype>GLchar</ptype> *<name>name</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetNextPerfQueryIdINTEL</name></proto>
+            <param><ptype>GLuint</ptype> <name>queryId</name></param>
+            <param><ptype>GLuint</ptype> *<name>nextQueryId</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetObjectBufferfvATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="ArrayObjectPNameATI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetObjectBufferivATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="ArrayObjectPNameATI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetObjectLabel</name></proto>
+            <param><ptype>GLenum</ptype> <name>identifier</name></param>
+            <param><ptype>GLuint</ptype> <name>name</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>label</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetObjectLabelEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>object</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>label</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetObjectLabelKHR</name></proto>
+            <param><ptype>GLenum</ptype> <name>identifier</name></param>
+            <param><ptype>GLuint</ptype> <name>name</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>label</name></param>
+            <alias name="glGetObjectLabel"/>
+        </command>
+        <command>
+            <proto>void <name>glGetObjectParameterfvARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>obj</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetObjectParameterivAPPLE</name></proto>
+            <param><ptype>GLenum</ptype> <name>objectType</name></param>
+            <param><ptype>GLuint</ptype> <name>name</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetObjectParameterivARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>obj</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetObjectPtrLabel</name></proto>
+            <param>const void *<name>ptr</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>label</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetObjectPtrLabelKHR</name></proto>
+            <param>const void *<name>ptr</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>label</name></param>
+            <alias name="glGetObjectPtrLabel"/>
+        </command>
+        <command>
+            <proto>void <name>glGetOcclusionQueryivNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="OcclusionQueryParameterNameNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetOcclusionQueryuivNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="OcclusionQueryParameterNameNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPathColorGenfvNV</name></proto>
+            <param group="PathColor"><ptype>GLenum</ptype> <name>color</name></param>
+            <param group="PathGenMode"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPathColorGenivNV</name></proto>
+            <param group="PathColor"><ptype>GLenum</ptype> <name>color</name></param>
+            <param group="PathGenMode"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPathCommandsNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param group="PathCommand" len="COMPSIZE(path)"><ptype>GLubyte</ptype> *<name>commands</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPathCoordsNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param len="COMPSIZE(path)"><ptype>GLfloat</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPathDashArrayNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param len="COMPSIZE(path)"><ptype>GLfloat</ptype> *<name>dashArray</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLfloat</ptype> <name>glGetPathLengthNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param><ptype>GLsizei</ptype> <name>startSegment</name></param>
+            <param><ptype>GLsizei</ptype> <name>numSegments</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPathMetricRangeNV</name></proto>
+            <param group="PathMetricMask"><ptype>GLbitfield</ptype> <name>metricQueryMask</name></param>
+            <param group="Path"><ptype>GLuint</ptype> <name>firstPathName</name></param>
+            <param><ptype>GLsizei</ptype> <name>numPaths</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(metricQueryMask,numPaths,stride)"><ptype>GLfloat</ptype> *<name>metrics</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPathMetricsNV</name></proto>
+            <param group="PathMetricMask"><ptype>GLbitfield</ptype> <name>metricQueryMask</name></param>
+            <param><ptype>GLsizei</ptype> <name>numPaths</name></param>
+            <param group="PathElementType"><ptype>GLenum</ptype> <name>pathNameType</name></param>
+            <param group="PathElement" len="COMPSIZE(numPaths,pathNameType,paths)">const void *<name>paths</name></param>
+            <param group="Path"><ptype>GLuint</ptype> <name>pathBase</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(metricQueryMask,numPaths,stride)"><ptype>GLfloat</ptype> *<name>metrics</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPathParameterfvNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param group="PathParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="4"><ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPathParameterivNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param group="PathParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="4"><ptype>GLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPathSpacingNV</name></proto>
+            <param group="PathListMode"><ptype>GLenum</ptype> <name>pathListMode</name></param>
+            <param><ptype>GLsizei</ptype> <name>numPaths</name></param>
+            <param group="PathElementType"><ptype>GLenum</ptype> <name>pathNameType</name></param>
+            <param group="PathElement" len="COMPSIZE(numPaths,pathNameType,paths)">const void *<name>paths</name></param>
+            <param group="Path"><ptype>GLuint</ptype> <name>pathBase</name></param>
+            <param><ptype>GLfloat</ptype> <name>advanceScale</name></param>
+            <param><ptype>GLfloat</ptype> <name>kerningScale</name></param>
+            <param group="PathTransformType"><ptype>GLenum</ptype> <name>transformType</name></param>
+            <param len="COMPSIZE(pathListMode,numPaths)"><ptype>GLfloat</ptype> *<name>returnedSpacing</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPathTexGenfvNV</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texCoordSet</name></param>
+            <param group="PathGenMode"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPathTexGenivNV</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texCoordSet</name></param>
+            <param group="PathGenMode"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPerfCounterInfoINTEL</name></proto>
+            <param><ptype>GLuint</ptype> <name>queryId</name></param>
+            <param><ptype>GLuint</ptype> <name>counterId</name></param>
+            <param><ptype>GLuint</ptype> <name>counterNameLength</name></param>
+            <param><ptype>GLchar</ptype> *<name>counterName</name></param>
+            <param><ptype>GLuint</ptype> <name>counterDescLength</name></param>
+            <param><ptype>GLchar</ptype> *<name>counterDesc</name></param>
+            <param><ptype>GLuint</ptype> *<name>counterOffset</name></param>
+            <param><ptype>GLuint</ptype> *<name>counterDataSize</name></param>
+            <param><ptype>GLuint</ptype> *<name>counterTypeEnum</name></param>
+            <param><ptype>GLuint</ptype> *<name>counterDataTypeEnum</name></param>
+            <param><ptype>GLuint64</ptype> *<name>rawCounterMaxValue</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPerfMonitorCounterDataAMD</name></proto>
+            <param><ptype>GLuint</ptype> <name>monitor</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLsizei</ptype> <name>dataSize</name></param>
+            <param len="dataSize"><ptype>GLuint</ptype> *<name>data</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>bytesWritten</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPerfMonitorCounterInfoAMD</name></proto>
+            <param><ptype>GLuint</ptype> <name>group</name></param>
+            <param><ptype>GLuint</ptype> <name>counter</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">void *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPerfMonitorCounterStringAMD</name></proto>
+            <param><ptype>GLuint</ptype> <name>group</name></param>
+            <param><ptype>GLuint</ptype> <name>counter</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>counterString</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPerfMonitorCountersAMD</name></proto>
+            <param><ptype>GLuint</ptype> <name>group</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>numCounters</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>maxActiveCounters</name></param>
+            <param><ptype>GLsizei</ptype> <name>counterSize</name></param>
+            <param len="counterSize"><ptype>GLuint</ptype> *<name>counters</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPerfMonitorGroupStringAMD</name></proto>
+            <param><ptype>GLuint</ptype> <name>group</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>groupString</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPerfMonitorGroupsAMD</name></proto>
+            <param len="1"><ptype>GLint</ptype> *<name>numGroups</name></param>
+            <param><ptype>GLsizei</ptype> <name>groupsSize</name></param>
+            <param len="groupsSize"><ptype>GLuint</ptype> *<name>groups</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPerfQueryDataINTEL</name></proto>
+            <param><ptype>GLuint</ptype> <name>queryHandle</name></param>
+            <param><ptype>GLuint</ptype> <name>flags</name></param>
+            <param><ptype>GLsizei</ptype> <name>dataSize</name></param>
+            <param><ptype>GLvoid</ptype> *<name>data</name></param>
+            <param><ptype>GLuint</ptype> *<name>bytesWritten</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPerfQueryIdByNameINTEL</name></proto>
+            <param><ptype>GLchar</ptype> *<name>queryName</name></param>
+            <param><ptype>GLuint</ptype> *<name>queryId</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPerfQueryInfoINTEL</name></proto>
+            <param><ptype>GLuint</ptype> <name>queryId</name></param>
+            <param><ptype>GLuint</ptype> <name>queryNameLength</name></param>
+            <param><ptype>GLchar</ptype> *<name>queryName</name></param>
+            <param><ptype>GLuint</ptype> *<name>dataSize</name></param>
+            <param><ptype>GLuint</ptype> *<name>noCounters</name></param>
+            <param><ptype>GLuint</ptype> *<name>noInstances</name></param>
+            <param><ptype>GLuint</ptype> *<name>capsMask</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPixelMapfv</name></proto>
+            <param group="PixelMap"><ptype>GLenum</ptype> <name>map</name></param>
+            <param len="COMPSIZE(map)"><ptype>GLfloat</ptype> *<name>values</name></param>
+            <glx type="single" opcode="125"/>
+            <glx type="render" opcode="339" name="glGetPixelMapfvPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glGetPixelMapuiv</name></proto>
+            <param group="PixelMap"><ptype>GLenum</ptype> <name>map</name></param>
+            <param len="COMPSIZE(map)"><ptype>GLuint</ptype> *<name>values</name></param>
+            <glx type="single" opcode="126"/>
+            <glx type="render" opcode="340" name="glGetPixelMapuivPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glGetPixelMapusv</name></proto>
+            <param group="PixelMap"><ptype>GLenum</ptype> <name>map</name></param>
+            <param len="COMPSIZE(map)"><ptype>GLushort</ptype> *<name>values</name></param>
+            <glx type="single" opcode="127"/>
+            <glx type="render" opcode="341" name="glGetPixelMapusvPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glGetPixelMapxv</name></proto>
+            <param><ptype>GLenum</ptype> <name>map</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param len="size"><ptype>GLfixed</ptype> *<name>values</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPixelTexGenParameterfvSGIS</name></proto>
+            <param group="PixelTexGenParameterNameSGIS"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPixelTexGenParameterivSGIS</name></proto>
+            <param group="PixelTexGenParameterNameSGIS"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPixelTransformParameterfvEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="2051"/>
+        </command>
+        <command>
+            <proto>void <name>glGetPixelTransformParameterivEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="2052"/>
+        </command>
+        <command>
+            <proto>void <name>glGetPointerIndexedvEXT</name></proto>
+            <param group="TypeEnum"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">void **<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPointeri_vEXT</name></proto>
+            <param group="TypeEnum"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">void **<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetPointerv</name></proto>
+            <param group="GetPointervPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1">void **<name>params</name></param>
+            <glx type="single" opcode="208"/>
+        </command>
+        <command>
+            <proto>void <name>glGetPointervEXT</name></proto>
+            <param group="GetPointervPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1">void **<name>params</name></param>
+            <alias name="glGetPointerv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetPointervKHR</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param>void **<name>params</name></param>
+            <alias name="glGetPointerv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetPolygonStipple</name></proto>
+            <param len="COMPSIZE()"><ptype>GLubyte</ptype> *<name>mask</name></param>
+            <glx type="single" opcode="128"/>
+            <glx type="render" opcode="342" name="glGetPolygonStipplePBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramBinary</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="1"><ptype>GLenum</ptype> *<name>binaryFormat</name></param>
+            <param len="bufSize">void *<name>binary</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramBinaryOES</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="1"><ptype>GLenum</ptype> *<name>binaryFormat</name></param>
+            <param len="bufSize">void *<name>binary</name></param>
+            <alias name="glGetProgramBinary"/>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramEnvParameterIivNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramEnvParameterIuivNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4"><ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramEnvParameterdvARB</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4"><ptype>GLdouble</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramEnvParameterfvARB</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramInfoLog</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>infoLog</name></param>
+            <glx type="single" opcode="201"/>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramInterfaceiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLenum</ptype> <name>programInterface</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramLocalParameterIivNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramLocalParameterIuivNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4"><ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramLocalParameterdvARB</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4"><ptype>GLdouble</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramLocalParameterfvARB</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramNamedParameterdvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLsizei</ptype> <name>len</name></param>
+            <param len="1">const <ptype>GLubyte</ptype> *<name>name</name></param>
+            <param len="4"><ptype>GLdouble</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1311"/>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramNamedParameterfvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLsizei</ptype> <name>len</name></param>
+            <param len="1">const <ptype>GLubyte</ptype> *<name>name</name></param>
+            <param len="4"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1310"/>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramParameterdvNV</name></proto>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="4"><ptype>GLdouble</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1297"/>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramParameterfvNV</name></proto>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="4"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1296"/>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramPipelineInfoLog</name></proto>
+            <param><ptype>GLuint</ptype> <name>pipeline</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>infoLog</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramPipelineInfoLogEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>pipeline</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>infoLog</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramPipelineiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>pipeline</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramPipelineivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>pipeline</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glGetProgramResourceIndex</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLenum</ptype> <name>programInterface</name></param>
+            <param len="COMPSIZE(name)">const <ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glGetProgramResourceLocation</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLenum</ptype> <name>programInterface</name></param>
+            <param len="COMPSIZE(name)">const <ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glGetProgramResourceLocationIndex</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLenum</ptype> <name>programInterface</name></param>
+            <param len="COMPSIZE(name)">const <ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramResourceName</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLenum</ptype> <name>programInterface</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramResourceiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLenum</ptype> <name>programInterface</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>propCount</name></param>
+            <param len="propCount">const <ptype>GLenum</ptype> *<name>props</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramStageiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLenum</ptype> <name>shadertype</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>values</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramStringARB</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ProgramStringPropertyARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(target,pname)">void *<name>string</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramStringNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="ProgramCharacterNV" len="COMPSIZE(id,pname)"><ptype>GLubyte</ptype> *<name>program</name></param>
+            <glx type="vendor" opcode="1299"/>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramSubroutineParameteruivNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="COMPSIZE(target)"><ptype>GLuint</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="199"/>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramivARB</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ProgramPropertyARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetProgramivNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="4"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1298"/>
+        </command>
+        <command>
+            <proto>void <name>glGetQueryIndexediv</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetQueryObjecti64v</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint64</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetQueryObjecti64vEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint64</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1328"/>
+            <alias name="glGetQueryObjecti64v"/>
+        </command>
+        <command>
+            <proto>void <name>glGetQueryObjectiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="165"/>
+        </command>
+        <command>
+            <proto>void <name>glGetQueryObjectivARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glGetQueryObjectiv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetQueryObjectivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glGetQueryObjectiv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetQueryObjectui64v</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLuint64</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetQueryObjectui64vEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLuint64</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1329"/>
+            <alias name="glGetQueryObjectui64v"/>
+        </command>
+        <command>
+            <proto>void <name>glGetQueryObjectuiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLuint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="166"/>
+        </command>
+        <command>
+            <proto>void <name>glGetQueryObjectuivARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLuint</ptype> *<name>params</name></param>
+            <alias name="glGetQueryObjectuiv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetQueryObjectuivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetQueryiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="164"/>
+        </command>
+        <command>
+            <proto>void <name>glGetQueryivARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glGetQueryiv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetQueryivEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetRenderbufferParameteriv</name></proto>
+            <param group="RenderbufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1424"/>
+        </command>
+        <command>
+            <proto>void <name>glGetRenderbufferParameterivEXT</name></proto>
+            <param group="RenderbufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glGetRenderbufferParameteriv"/>
+            <glx type="vendor" opcode="1424"/>
+        </command>
+        <command>
+            <proto>void <name>glGetRenderbufferParameterivOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetSamplerParameterIiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetSamplerParameterIivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glGetSamplerParameterIiv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetSamplerParameterIuiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetSamplerParameterIuivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLuint</ptype> *<name>params</name></param>
+            <alias name="glGetSamplerParameterIuiv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetSamplerParameterfv</name></proto>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetSamplerParameteriv</name></proto>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetSeparableFilter</name></proto>
+            <param group="SeparableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(target,format,type)">void *<name>row</name></param>
+            <param len="COMPSIZE(target,format,type)">void *<name>column</name></param>
+            <param len="COMPSIZE(target,format,type)">void *<name>span</name></param>
+            <glx type="single" opcode="153"/>
+            <glx type="render" opcode="343" name="glGetSeparableFilterPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glGetSeparableFilterEXT</name></proto>
+            <param group="SeparableTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(target,format,type)">void *<name>row</name></param>
+            <param len="COMPSIZE(target,format,type)">void *<name>column</name></param>
+            <param len="COMPSIZE(target,format,type)">void *<name>span</name></param>
+            <glx type="vendor" opcode="4"/>
+        </command>
+        <command>
+            <proto>void <name>glGetShaderInfoLog</name></proto>
+            <param><ptype>GLuint</ptype> <name>shader</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>infoLog</name></param>
+            <glx type="single" opcode="200"/>
+        </command>
+        <command>
+            <proto>void <name>glGetShaderPrecisionFormat</name></proto>
+            <param><ptype>GLenum</ptype> <name>shadertype</name></param>
+            <param><ptype>GLenum</ptype> <name>precisiontype</name></param>
+            <param len="2"><ptype>GLint</ptype> *<name>range</name></param>
+            <param len="2"><ptype>GLint</ptype> *<name>precision</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetShaderSource</name></proto>
+            <param><ptype>GLuint</ptype> <name>shader</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>source</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetShaderSourceARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>obj</name></param>
+            <param><ptype>GLsizei</ptype> <name>maxLength</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="maxLength"><ptype>GLcharARB</ptype> *<name>source</name></param>
+            <alias name="glGetShaderSource"/>
+        </command>
+        <command>
+            <proto>void <name>glGetShaderiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>shader</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="198"/>
+        </command>
+        <command>
+            <proto>void <name>glGetSharpenTexFuncSGIS</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param len="COMPSIZE(target)"><ptype>GLfloat</ptype> *<name>points</name></param>
+            <glx type="vendor" opcode="4097"/>
+        </command>
+        <command>
+            <proto group="String">const <ptype>GLubyte</ptype> *<name>glGetString</name></proto>
+            <param group="StringName"><ptype>GLenum</ptype> <name>name</name></param>
+            <glx type="single" opcode="129"/>
+        </command>
+        <command>
+            <proto group="String">const <ptype>GLubyte</ptype> *<name>glGetStringi</name></proto>
+            <param><ptype>GLenum</ptype> <name>name</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glGetSubroutineIndex</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLenum</ptype> <name>shadertype</name></param>
+            <param>const <ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glGetSubroutineUniformLocation</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLenum</ptype> <name>shadertype</name></param>
+            <param>const <ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetSynciv</name></proto>
+            <param group="sync"><ptype>GLsync</ptype> <name>sync</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLint</ptype> *<name>values</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetSyncivAPPLE</name></proto>
+            <param><ptype>GLsync</ptype> <name>sync</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLint</ptype> *<name>values</name></param>
+            <alias name="glGetSynciv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTexBumpParameterfvATI</name></proto>
+            <param group="GetTexBumpParameterATI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTexBumpParameterivATI</name></proto>
+            <param group="GetTexBumpParameterATI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTexEnvfv</name></proto>
+            <param group="TextureEnvTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureEnvParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="single" opcode="130"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTexEnviv</name></proto>
+            <param group="TextureEnvTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureEnvParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="131"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTexEnvxv</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTexEnvxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTexFilterFuncSGIS</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureFilterSGIS"><ptype>GLenum</ptype> <name>filter</name></param>
+            <param len="COMPSIZE(target,filter)"><ptype>GLfloat</ptype> *<name>weights</name></param>
+            <glx type="vendor" opcode="4101"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTexGendv</name></proto>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLdouble</ptype> *<name>params</name></param>
+            <glx type="single" opcode="132"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTexGenfv</name></proto>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="single" opcode="133"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTexGenfvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>coord</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTexGeniv</name></proto>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="134"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTexGenivOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>coord</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTexGenxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>coord</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTexImage</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(target,level,format,type)">void *<name>pixels</name></param>
+            <glx type="single" opcode="135"/>
+            <glx type="render" opcode="344" name="glGetTexImagePBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTexLevelParameterfv</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="single" opcode="138"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTexLevelParameteriv</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="139"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTexLevelParameterxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTexParameterIiv</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="203"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTexParameterIivEXT</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glGetTexParameterIiv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTexParameterIuiv</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLuint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="204"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTexParameterIuivEXT</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLuint</ptype> *<name>params</name></param>
+            <alias name="glGetTexParameterIuiv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTexParameterPointervAPPLE</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1">void **<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTexParameterfv</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="single" opcode="136"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTexParameteriv</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="single" opcode="137"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTexParameterxv</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTexParameterxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint64</ptype> <name>glGetTextureHandleARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint64</ptype> <name>glGetTextureHandleNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTextureImageEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(target,level,format,type)">void *<name>pixels</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTextureLevelParameterfvEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTextureLevelParameterivEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTextureParameterIivEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTextureParameterIuivEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTextureParameterfvEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTextureParameterivEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="GetTextureParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint64</ptype> <name>glGetTextureSamplerHandleARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint64</ptype> <name>glGetTextureSamplerHandleNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTrackMatrixivNV</name></proto>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>address</name></param>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1300"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTransformFeedbackVarying</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>size</name></param>
+            <param len="1"><ptype>GLenum</ptype> *<name>type</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTransformFeedbackVaryingEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>size</name></param>
+            <param len="1"><ptype>GLenum</ptype> *<name>type</name></param>
+            <param len="bufSize"><ptype>GLchar</ptype> *<name>name</name></param>
+            <alias name="glGetTransformFeedbackVarying"/>
+        </command>
+        <command>
+            <proto>void <name>glGetTransformFeedbackVaryingNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>location</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetTranslatedShaderSourceANGLE</name></proto>
+            <param><ptype>GLuint</ptype> <name>shader</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufsize</name></param>
+            <param len="1"><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param><ptype>GLchar</ptype> *<name>source</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glGetUniformBlockIndex</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param len="COMPSIZE()">const <ptype>GLchar</ptype> *<name>uniformBlockName</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glGetUniformBufferSizeEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetUniformIndices</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLsizei</ptype> <name>uniformCount</name></param>
+            <param len="COMPSIZE(uniformCount)">const <ptype>GLchar</ptype> *const*<name>uniformNames</name></param>
+            <param len="COMPSIZE(uniformCount)"><ptype>GLuint</ptype> *<name>uniformIndices</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glGetUniformLocation</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param>const <ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glGetUniformLocationARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>programObj</name></param>
+            <param>const <ptype>GLcharARB</ptype> *<name>name</name></param>
+            <alias name="glGetUniformLocation"/>
+        </command>
+        <command>
+            <proto group="BufferOffset"><ptype>GLintptr</ptype> <name>glGetUniformOffsetEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetUniformSubroutineuiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>shadertype</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param len="1"><ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetUniformdv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param len="COMPSIZE(location)"><ptype>GLdouble</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetUniformfv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param len="COMPSIZE(location)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetUniformfvARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>programObj</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param len="COMPSIZE(location)"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <alias name="glGetUniformfv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetUniformi64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param len="COMPSIZE(location)"><ptype>GLint64EXT</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetUniformiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param len="COMPSIZE(location)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetUniformivARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>programObj</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param len="COMPSIZE(location)"><ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glGetUniformiv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetUniformui64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param len="COMPSIZE(program,location)"><ptype>GLuint64EXT</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetUniformuiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param len="COMPSIZE(program,location)"><ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetUniformuivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param len="COMPSIZE(program,location)"><ptype>GLuint</ptype> *<name>params</name></param>
+            <alias name="glGetUniformuiv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetVariantArrayObjectfvATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="ArrayObjectPNameATI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVariantArrayObjectivATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="ArrayObjectPNameATI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVariantBooleanvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="GetVariantValueEXT"><ptype>GLenum</ptype> <name>value</name></param>
+            <param group="Boolean" len="COMPSIZE(id)"><ptype>GLboolean</ptype> *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVariantFloatvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="GetVariantValueEXT"><ptype>GLenum</ptype> <name>value</name></param>
+            <param len="COMPSIZE(id)"><ptype>GLfloat</ptype> *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVariantIntegervEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="GetVariantValueEXT"><ptype>GLenum</ptype> <name>value</name></param>
+            <param len="COMPSIZE(id)"><ptype>GLint</ptype> *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVariantPointervEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="GetVariantValueEXT"><ptype>GLenum</ptype> <name>value</name></param>
+            <param len="COMPSIZE(id)">void **<name>data</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glGetVaryingLocationNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param len="COMPSIZE(name)">const <ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexArrayIntegeri_vEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexArrayIntegervEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexArrayPointeri_vEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param>void **<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexArrayPointervEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1">void **<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribArrayObjectfvATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="ArrayObjectPNameATI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribArrayObjectivATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="ArrayObjectPNameATI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribIiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribEnum"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribIivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribEnum"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glGetVertexAttribIiv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribIuiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribEnum"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribIuivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribEnum"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLuint</ptype> *<name>params</name></param>
+            <alias name="glGetVertexAttribIuiv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribLdv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLdouble</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribLdvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLdouble</ptype> *<name>params</name></param>
+            <alias name="glGetVertexAttribLdv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribLi64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint64EXT</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribLui64vARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLuint64EXT</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribLui64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLuint64EXT</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribPointerv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribPointerPropertyARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1">void **<name>pointer</name></param>
+            <glx type="single" opcode="209"/>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribPointervARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribPointerPropertyARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1">void **<name>pointer</name></param>
+            <alias name="glGetVertexAttribPointerv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribPointervNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1">void **<name>pointer</name></param>
+            <alias name="glGetVertexAttribPointerv"/>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribdv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribPropertyARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="4"><ptype>GLdouble</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1301"/>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribdvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribPropertyARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="4"><ptype>GLdouble</ptype> *<name>params</name></param>
+            <alias name="glGetVertexAttribdv"/>
+            <glx type="vendor" opcode="1301"/>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribdvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLdouble</ptype> *<name>params</name></param>
+            <alias name="glGetVertexAttribdv"/>
+            <glx type="vendor" opcode="1301"/>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribfv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribPropertyARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="4"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1302"/>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribfvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribPropertyARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="4"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <alias name="glGetVertexAttribfv"/>
+            <glx type="vendor" opcode="1302"/>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribfvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLfloat</ptype> *<name>params</name></param>
+            <alias name="glGetVertexAttribfv"/>
+            <glx type="vendor" opcode="1302"/>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribPropertyARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="4"><ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="vendor" opcode="1303"/>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribivARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribPropertyARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="4"><ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glGetVertexAttribiv"/>
+            <glx type="vendor" opcode="1303"/>
+        </command>
+        <command>
+            <proto>void <name>glGetVertexAttribivNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glGetVertexAttribiv"/>
+            <glx type="vendor" opcode="1303"/>
+        </command>
+        <command>
+            <proto>void <name>glGetVideoCaptureStreamdvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_capture_slot</name></param>
+            <param><ptype>GLuint</ptype> <name>stream</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLdouble</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVideoCaptureStreamfvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_capture_slot</name></param>
+            <param><ptype>GLuint</ptype> <name>stream</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVideoCaptureStreamivNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_capture_slot</name></param>
+            <param><ptype>GLuint</ptype> <name>stream</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVideoCaptureivNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_capture_slot</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVideoi64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_slot</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint64EXT</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVideoivNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_slot</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVideoui64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_slot</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLuint64EXT</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetVideouivNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_slot</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)"><ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnColorTableARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize">void *<name>table</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnCompressedTexImageARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLint</ptype> <name>lod</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize">void *<name>img</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnConvolutionFilterARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize">void *<name>image</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnHistogramARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>reset</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize">void *<name>values</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnMapdvARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>query</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize"><ptype>GLdouble</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnMapfvARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>query</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize"><ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnMapivARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>query</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize"><ptype>GLint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnMinmaxARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>reset</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize">void *<name>values</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnPixelMapfvARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>map</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize"><ptype>GLfloat</ptype> *<name>values</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnPixelMapuivARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>map</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize"><ptype>GLuint</ptype> *<name>values</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnPixelMapusvARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>map</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize"><ptype>GLushort</ptype> *<name>values</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnPolygonStippleARB</name></proto>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize"><ptype>GLubyte</ptype> *<name>pattern</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnSeparableFilterARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>rowBufSize</name></param>
+            <param len="rowBufSize">void *<name>row</name></param>
+            <param><ptype>GLsizei</ptype> <name>columnBufSize</name></param>
+            <param len="columnBufSize">void *<name>column</name></param>
+            <param len="0">void *<name>span</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnTexImageARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize">void *<name>img</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnUniformdvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize"><ptype>GLdouble</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnUniformfvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnUniformfvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize"><ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnUniformivARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnUniformivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize"><ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGetnUniformuivARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize"><ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGlobalAlphaFactorbSUN</name></proto>
+            <param><ptype>GLbyte</ptype> <name>factor</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGlobalAlphaFactordSUN</name></proto>
+            <param><ptype>GLdouble</ptype> <name>factor</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGlobalAlphaFactorfSUN</name></proto>
+            <param><ptype>GLfloat</ptype> <name>factor</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGlobalAlphaFactoriSUN</name></proto>
+            <param><ptype>GLint</ptype> <name>factor</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGlobalAlphaFactorsSUN</name></proto>
+            <param><ptype>GLshort</ptype> <name>factor</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGlobalAlphaFactorubSUN</name></proto>
+            <param><ptype>GLubyte</ptype> <name>factor</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGlobalAlphaFactoruiSUN</name></proto>
+            <param><ptype>GLuint</ptype> <name>factor</name></param>
+        </command>
+        <command>
+            <proto>void <name>glGlobalAlphaFactorusSUN</name></proto>
+            <param><ptype>GLushort</ptype> <name>factor</name></param>
+        </command>
+        <command>
+            <proto>void <name>glHint</name></proto>
+            <param group="HintTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="HintMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <glx type="render" opcode="85"/>
+        </command>
+        <command>
+            <proto>void <name>glHintPGI</name></proto>
+            <param group="HintTargetPGI"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLint</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glHistogram</name></proto>
+            <param group="HistogramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>sink</name></param>
+            <glx type="render" opcode="4110"/>
+        </command>
+        <command>
+            <proto>void <name>glHistogramEXT</name></proto>
+            <param group="HistogramTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>sink</name></param>
+            <alias name="glHistogram"/>
+            <glx type="render" opcode="4110"/>
+        </command>
+        <command>
+            <proto>void <name>glIglooInterfaceSGIX</name></proto>
+            <param group="IglooFunctionSelectSGIX"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="IglooParameterSGIX" len="COMPSIZE(pname)">const void *<name>params</name></param>
+            <glx type="render" opcode="200"/>
+        </command>
+        <command>
+            <proto>void <name>glImageTransformParameterfHP</name></proto>
+            <param group="ImageTransformTargetHP"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ImageTransformPNameHP"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfloat</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glImageTransformParameterfvHP</name></proto>
+            <param group="ImageTransformTargetHP"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ImageTransformPNameHP"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glImageTransformParameteriHP</name></proto>
+            <param group="ImageTransformTargetHP"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ImageTransformPNameHP"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glImageTransformParameterivHP</name></proto>
+            <param group="ImageTransformTargetHP"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ImageTransformPNameHP"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto group="sync"><ptype>GLsync</ptype> <name>glImportSyncEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>external_sync_type</name></param>
+            <param><ptype>GLintptr</ptype> <name>external_sync</name></param>
+            <param><ptype>GLbitfield</ptype> <name>flags</name></param>
+        </command>
+        <command>
+            <proto>void <name>glIndexFormatNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glIndexFuncEXT</name></proto>
+            <param group="IndexFunctionEXT"><ptype>GLenum</ptype> <name>func</name></param>
+            <param group="ClampedFloat32"><ptype>GLclampf</ptype> <name>ref</name></param>
+        </command>
+        <command>
+            <proto>void <name>glIndexMask</name></proto>
+            <param group="MaskedColorIndexValueI"><ptype>GLuint</ptype> <name>mask</name></param>
+            <glx type="render" opcode="136"/>
+        </command>
+        <command>
+            <proto>void <name>glIndexMaterialEXT</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="IndexMaterialParameterEXT"><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glIndexPointer</name></proto>
+            <param group="IndexPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glIndexPointerEXT</name></proto>
+            <param group="IndexPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="COMPSIZE(type,stride,count)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glIndexPointerListIBM</name></proto>
+            <param group="IndexPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLint</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(type,stride)">const void **<name>pointer</name></param>
+            <param><ptype>GLint</ptype> <name>ptrstride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glIndexd</name></proto>
+            <param group="ColorIndexValueD"><ptype>GLdouble</ptype> <name>c</name></param>
+            <vecequiv name="glIndexdv"/>
+        </command>
+        <command>
+            <proto>void <name>glIndexdv</name></proto>
+            <param group="ColorIndexValueD" len="1">const <ptype>GLdouble</ptype> *<name>c</name></param>
+            <glx type="render" opcode="24"/>
+        </command>
+        <command>
+            <proto>void <name>glIndexf</name></proto>
+            <param group="ColorIndexValueF"><ptype>GLfloat</ptype> <name>c</name></param>
+            <vecequiv name="glIndexfv"/>
+        </command>
+        <command>
+            <proto>void <name>glIndexfv</name></proto>
+            <param group="ColorIndexValueF" len="1">const <ptype>GLfloat</ptype> *<name>c</name></param>
+            <glx type="render" opcode="25"/>
+        </command>
+        <command>
+            <proto>void <name>glIndexi</name></proto>
+            <param group="ColorIndexValueI"><ptype>GLint</ptype> <name>c</name></param>
+            <vecequiv name="glIndexiv"/>
+        </command>
+        <command>
+            <proto>void <name>glIndexiv</name></proto>
+            <param group="ColorIndexValueI" len="1">const <ptype>GLint</ptype> *<name>c</name></param>
+            <glx type="render" opcode="26"/>
+        </command>
+        <command>
+            <proto>void <name>glIndexs</name></proto>
+            <param group="ColorIndexValueS"><ptype>GLshort</ptype> <name>c</name></param>
+            <vecequiv name="glIndexsv"/>
+        </command>
+        <command>
+            <proto>void <name>glIndexsv</name></proto>
+            <param group="ColorIndexValueS" len="1">const <ptype>GLshort</ptype> *<name>c</name></param>
+            <glx type="render" opcode="27"/>
+        </command>
+        <command>
+            <proto>void <name>glIndexub</name></proto>
+            <param group="ColorIndexValueUB"><ptype>GLubyte</ptype> <name>c</name></param>
+            <vecequiv name="glIndexubv"/>
+        </command>
+        <command>
+            <proto>void <name>glIndexubv</name></proto>
+            <param group="ColorIndexValueUB" len="1">const <ptype>GLubyte</ptype> *<name>c</name></param>
+            <glx type="render" opcode="194"/>
+        </command>
+        <command>
+            <proto>void <name>glIndexxOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>component</name></param>
+        </command>
+        <command>
+            <proto>void <name>glIndexxvOES</name></proto>
+            <param len="1">const <ptype>GLfixed</ptype> *<name>component</name></param>
+        </command>
+        <command>
+            <proto>void <name>glInitNames</name></proto>
+            <glx type="render" opcode="121"/>
+        </command>
+        <command>
+            <proto>void <name>glInsertComponentEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>res</name></param>
+            <param><ptype>GLuint</ptype> <name>src</name></param>
+            <param><ptype>GLuint</ptype> <name>num</name></param>
+        </command>
+        <command>
+            <proto>void <name>glInsertEventMarkerEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param>const <ptype>GLchar</ptype> *<name>marker</name></param>
+        </command>
+        <command>
+            <proto>void <name>glInstrumentsBufferSGIX</name></proto>
+            <param><ptype>GLsizei</ptype> <name>size</name></param>
+            <param len="size"><ptype>GLint</ptype> *<name>buffer</name></param>
+            <glx type="vendor" opcode="4103"/>
+        </command>
+        <command>
+            <proto>void <name>glInterleavedArrays</name></proto>
+            <param group="InterleavedArrayFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(format,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glInterpolatePathsNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>resultPath</name></param>
+            <param group="Path"><ptype>GLuint</ptype> <name>pathA</name></param>
+            <param group="Path"><ptype>GLuint</ptype> <name>pathB</name></param>
+            <param><ptype>GLfloat</ptype> <name>weight</name></param>
+        </command>
+        <command>
+            <proto>void <name>glInvalidateBufferData</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glInvalidateBufferSubData</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>length</name></param>
+        </command>
+        <command>
+            <proto>void <name>glInvalidateFramebuffer</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>numAttachments</name></param>
+            <param len="numAttachments">const <ptype>GLenum</ptype> *<name>attachments</name></param>
+        </command>
+        <command>
+            <proto>void <name>glInvalidateSubFramebuffer</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>numAttachments</name></param>
+            <param len="numAttachments">const <ptype>GLenum</ptype> *<name>attachments</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glInvalidateTexImage</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+        </command>
+        <command>
+            <proto>void <name>glInvalidateTexSubImage</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsAsyncMarkerSGIX</name></proto>
+            <param><ptype>GLuint</ptype> <name>marker</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsBuffer</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsBufferARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <alias name="glIsBuffer"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsBufferResidentNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsEnabled</name></proto>
+            <param group="EnableCap"><ptype>GLenum</ptype> <name>cap</name></param>
+            <glx type="single" opcode="140"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsEnabledIndexedEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <alias name="glIsEnabledi"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsEnabledi</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsEnablediEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <alias name="glIsEnabledi"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsFenceAPPLE</name></proto>
+            <param group="FenceNV"><ptype>GLuint</ptype> <name>fence</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsFenceNV</name></proto>
+            <param group="FenceNV"><ptype>GLuint</ptype> <name>fence</name></param>
+            <glx type="vendor" opcode="1278"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsFramebuffer</name></proto>
+            <param><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <glx type="vendor" opcode="1425"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsFramebufferEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <alias name="glIsFramebuffer"/>
+            <glx type="vendor" opcode="1425"/>
+        </command>
+        <command>
+            <proto><ptype>GLboolean</ptype> <name>glIsFramebufferOES</name></proto>
+            <param><ptype>GLuint</ptype> <name>framebuffer</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLboolean</ptype> <name>glIsImageHandleResidentARB</name></proto>
+            <param><ptype>GLuint64</ptype> <name>handle</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsImageHandleResidentNV</name></proto>
+            <param><ptype>GLuint64</ptype> <name>handle</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsList</name></proto>
+            <param group="List"><ptype>GLuint</ptype> <name>list</name></param>
+            <glx type="single" opcode="141"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsNameAMD</name></proto>
+            <param><ptype>GLenum</ptype> <name>identifier</name></param>
+            <param><ptype>GLuint</ptype> <name>name</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsNamedBufferResidentNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsNamedStringARB</name></proto>
+            <param><ptype>GLint</ptype> <name>namelen</name></param>
+            <param len="namelen">const <ptype>GLchar</ptype> *<name>name</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsObjectBufferATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsOcclusionQueryNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsPathNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsPointInFillPathNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param group="MaskedStencilValue"><ptype>GLuint</ptype> <name>mask</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsPointInStrokePathNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsProgram</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <glx type="single" opcode="197"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsProgramARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <glx type="vendor" opcode="1304"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsProgramNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <alias name="glIsProgramARB"/>
+            <glx type="vendor" opcode="1304"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsProgramPipeline</name></proto>
+            <param><ptype>GLuint</ptype> <name>pipeline</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLboolean</ptype> <name>glIsProgramPipelineEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>pipeline</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsQuery</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <glx type="single" opcode="163"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsQueryARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <alias name="glIsQuery"/>
+        </command>
+        <command>
+            <proto><ptype>GLboolean</ptype> <name>glIsQueryEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsRenderbuffer</name></proto>
+            <param><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+            <glx type="vendor" opcode="1422"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsRenderbufferEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+            <alias name="glIsRenderbuffer"/>
+            <glx type="vendor" opcode="1422"/>
+        </command>
+        <command>
+            <proto><ptype>GLboolean</ptype> <name>glIsRenderbufferOES</name></proto>
+            <param><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsSampler</name></proto>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsShader</name></proto>
+            <param><ptype>GLuint</ptype> <name>shader</name></param>
+            <glx type="single" opcode="196"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsSync</name></proto>
+            <param group="sync"><ptype>GLsync</ptype> <name>sync</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLboolean</ptype> <name>glIsSyncAPPLE</name></proto>
+            <param><ptype>GLsync</ptype> <name>sync</name></param>
+            <alias name="glIsSync"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsTexture</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <glx type="single" opcode="146"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsTextureEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <glx type="vendor" opcode="14"/>
+        </command>
+        <command>
+            <proto><ptype>GLboolean</ptype> <name>glIsTextureHandleResidentARB</name></proto>
+            <param><ptype>GLuint64</ptype> <name>handle</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsTextureHandleResidentNV</name></proto>
+            <param><ptype>GLuint64</ptype> <name>handle</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsTransformFeedback</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsTransformFeedbackNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <alias name="glIsTransformFeedback"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsVariantEnabledEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="VariantCapEXT"><ptype>GLenum</ptype> <name>cap</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsVertexArray</name></proto>
+            <param><ptype>GLuint</ptype> <name>array</name></param>
+            <glx type="single" opcode="207"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsVertexArrayAPPLE</name></proto>
+            <param><ptype>GLuint</ptype> <name>array</name></param>
+            <alias name="glIsVertexArray"/>
+        </command>
+        <command>
+            <proto><ptype>GLboolean</ptype> <name>glIsVertexArrayOES</name></proto>
+            <param><ptype>GLuint</ptype> <name>array</name></param>
+            <alias name="glIsVertexArray"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glIsVertexAttribEnabledAPPLE</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLabelObjectEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>object</name></param>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param>const <ptype>GLchar</ptype> *<name>label</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLightEnviSGIX</name></proto>
+            <param group="LightEnvParameterSGIX"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLightModelf</name></proto>
+            <param group="LightModelParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfloat</ptype> <name>param</name></param>
+            <glx type="render" opcode="90"/>
+        </command>
+        <command>
+            <proto>void <name>glLightModelfv</name></proto>
+            <param group="LightModelParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="render" opcode="91"/>
+        </command>
+        <command>
+            <proto>void <name>glLightModeli</name></proto>
+            <param group="LightModelParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>param</name></param>
+            <glx type="render" opcode="92"/>
+        </command>
+        <command>
+            <proto>void <name>glLightModeliv</name></proto>
+            <param group="LightModelParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="render" opcode="93"/>
+        </command>
+        <command>
+            <proto>void <name>glLightModelx</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLightModelxOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLightModelxv</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfixed</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLightModelxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfixed</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLightf</name></proto>
+            <param group="LightName"><ptype>GLenum</ptype> <name>light</name></param>
+            <param group="LightParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <glx type="render" opcode="86"/>
+        </command>
+        <command>
+            <proto>void <name>glLightfv</name></proto>
+            <param group="LightName"><ptype>GLenum</ptype> <name>light</name></param>
+            <param group="LightParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="render" opcode="87"/>
+        </command>
+        <command>
+            <proto>void <name>glLighti</name></proto>
+            <param group="LightName"><ptype>GLenum</ptype> <name>light</name></param>
+            <param group="LightParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+            <glx type="render" opcode="88"/>
+        </command>
+        <command>
+            <proto>void <name>glLightiv</name></proto>
+            <param group="LightName"><ptype>GLenum</ptype> <name>light</name></param>
+            <param group="LightParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="render" opcode="89"/>
+        </command>
+        <command>
+            <proto>void <name>glLightx</name></proto>
+            <param><ptype>GLenum</ptype> <name>light</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLightxOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>light</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLightxv</name></proto>
+            <param><ptype>GLenum</ptype> <name>light</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLightxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>light</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLineStipple</name></proto>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>factor</name></param>
+            <param group="LineStipple"><ptype>GLushort</ptype> <name>pattern</name></param>
+            <glx type="render" opcode="94"/>
+        </command>
+        <command>
+            <proto>void <name>glLineWidth</name></proto>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>width</name></param>
+            <glx type="render" opcode="95"/>
+        </command>
+        <command>
+            <proto>void <name>glLineWidthx</name></proto>
+            <param><ptype>GLfixed</ptype> <name>width</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLineWidthxOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>width</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLinkProgram</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLinkProgramARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>programObj</name></param>
+            <alias name="glLinkProgram"/>
+        </command>
+        <command>
+            <proto>void <name>glListBase</name></proto>
+            <param group="List"><ptype>GLuint</ptype> <name>base</name></param>
+            <glx type="render" opcode="3"/>
+        </command>
+        <command>
+            <proto>void <name>glListParameterfSGIX</name></proto>
+            <param group="List"><ptype>GLuint</ptype> <name>list</name></param>
+            <param group="ListParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <glx type="render" opcode="2078"/>
+        </command>
+        <command>
+            <proto>void <name>glListParameterfvSGIX</name></proto>
+            <param group="List"><ptype>GLuint</ptype> <name>list</name></param>
+            <param group="ListParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="render" opcode="2079"/>
+        </command>
+        <command>
+            <proto>void <name>glListParameteriSGIX</name></proto>
+            <param group="List"><ptype>GLuint</ptype> <name>list</name></param>
+            <param group="ListParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+            <glx type="render" opcode="2080"/>
+        </command>
+        <command>
+            <proto>void <name>glListParameterivSGIX</name></proto>
+            <param group="List"><ptype>GLuint</ptype> <name>list</name></param>
+            <param group="ListParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="render" opcode="2081"/>
+        </command>
+        <command>
+            <proto>void <name>glLoadIdentity</name></proto>
+            <glx type="render" opcode="176"/>
+        </command>
+        <command>
+            <proto>void <name>glLoadIdentityDeformationMapSGIX</name></proto>
+            <param group="FfdMaskSGIX"><ptype>GLbitfield</ptype> <name>mask</name></param>
+            <glx type="render" opcode="2076"/>
+        </command>
+        <command>
+            <proto>void <name>glLoadMatrixd</name></proto>
+            <param len="16">const <ptype>GLdouble</ptype> *<name>m</name></param>
+            <glx type="render" opcode="178"/>
+        </command>
+        <command>
+            <proto>void <name>glLoadMatrixf</name></proto>
+            <param len="16">const <ptype>GLfloat</ptype> *<name>m</name></param>
+            <glx type="render" opcode="177"/>
+        </command>
+        <command>
+            <proto>void <name>glLoadMatrixx</name></proto>
+            <param len="16">const <ptype>GLfixed</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLoadMatrixxOES</name></proto>
+            <param len="16">const <ptype>GLfixed</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLoadName</name></proto>
+            <param group="SelectName"><ptype>GLuint</ptype> <name>name</name></param>
+            <glx type="render" opcode="122"/>
+        </command>
+        <command>
+            <proto>void <name>glLoadPaletteFromModelViewMatrixOES</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glLoadProgramNV</name></proto>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLsizei</ptype> <name>len</name></param>
+            <param len="len">const <ptype>GLubyte</ptype> *<name>program</name></param>
+            <glx type="render" opcode="4183"/>
+        </command>
+        <command>
+            <proto>void <name>glLoadTransposeMatrixd</name></proto>
+            <param len="16">const <ptype>GLdouble</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLoadTransposeMatrixdARB</name></proto>
+            <param len="16">const <ptype>GLdouble</ptype> *<name>m</name></param>
+            <alias name="glLoadTransposeMatrixd"/>
+        </command>
+        <command>
+            <proto>void <name>glLoadTransposeMatrixf</name></proto>
+            <param len="16">const <ptype>GLfloat</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLoadTransposeMatrixfARB</name></proto>
+            <param len="16">const <ptype>GLfloat</ptype> *<name>m</name></param>
+            <alias name="glLoadTransposeMatrixf"/>
+        </command>
+        <command>
+            <proto>void <name>glLoadTransposeMatrixxOES</name></proto>
+            <param len="16">const <ptype>GLfixed</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLockArraysEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+        </command>
+        <command>
+            <proto>void <name>glLogicOp</name></proto>
+            <param group="LogicOp"><ptype>GLenum</ptype> <name>opcode</name></param>
+            <glx type="render" opcode="161"/>
+        </command>
+        <command>
+            <proto>void <name>glMakeBufferNonResidentNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMakeBufferResidentNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>access</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMakeImageHandleNonResidentARB</name></proto>
+            <param><ptype>GLuint64</ptype> <name>handle</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMakeImageHandleNonResidentNV</name></proto>
+            <param><ptype>GLuint64</ptype> <name>handle</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMakeImageHandleResidentARB</name></proto>
+            <param><ptype>GLuint64</ptype> <name>handle</name></param>
+            <param><ptype>GLenum</ptype> <name>access</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMakeImageHandleResidentNV</name></proto>
+            <param><ptype>GLuint64</ptype> <name>handle</name></param>
+            <param><ptype>GLenum</ptype> <name>access</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMakeNamedBufferNonResidentNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMakeNamedBufferResidentNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLenum</ptype> <name>access</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMakeTextureHandleNonResidentARB</name></proto>
+            <param><ptype>GLuint64</ptype> <name>handle</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMakeTextureHandleNonResidentNV</name></proto>
+            <param><ptype>GLuint64</ptype> <name>handle</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMakeTextureHandleResidentARB</name></proto>
+            <param><ptype>GLuint64</ptype> <name>handle</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMakeTextureHandleResidentNV</name></proto>
+            <param><ptype>GLuint64</ptype> <name>handle</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMap1d</name></proto>
+            <param group="MapTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>u1</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>u2</name></param>
+            <param><ptype>GLint</ptype> <name>stride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>order</name></param>
+            <param group="CoordD" len="COMPSIZE(target,stride,order)">const <ptype>GLdouble</ptype> *<name>points</name></param>
+            <glx type="render" opcode="143"/>
+        </command>
+        <command>
+            <proto>void <name>glMap1f</name></proto>
+            <param group="MapTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>u1</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>u2</name></param>
+            <param><ptype>GLint</ptype> <name>stride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>order</name></param>
+            <param group="CoordF" len="COMPSIZE(target,stride,order)">const <ptype>GLfloat</ptype> *<name>points</name></param>
+            <glx type="render" opcode="144"/>
+        </command>
+        <command>
+            <proto>void <name>glMap1xOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLfixed</ptype> <name>u1</name></param>
+            <param><ptype>GLfixed</ptype> <name>u2</name></param>
+            <param><ptype>GLint</ptype> <name>stride</name></param>
+            <param><ptype>GLint</ptype> <name>order</name></param>
+            <param><ptype>GLfixed</ptype> <name>points</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMap2d</name></proto>
+            <param group="MapTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>u1</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>u2</name></param>
+            <param><ptype>GLint</ptype> <name>ustride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>uorder</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>v1</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>v2</name></param>
+            <param><ptype>GLint</ptype> <name>vstride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>vorder</name></param>
+            <param group="CoordD" len="COMPSIZE(target,ustride,uorder,vstride,vorder)">const <ptype>GLdouble</ptype> *<name>points</name></param>
+            <glx type="render" opcode="145"/>
+        </command>
+        <command>
+            <proto>void <name>glMap2f</name></proto>
+            <param group="MapTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>u1</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>u2</name></param>
+            <param><ptype>GLint</ptype> <name>ustride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>uorder</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>v1</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>v2</name></param>
+            <param><ptype>GLint</ptype> <name>vstride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>vorder</name></param>
+            <param group="CoordF" len="COMPSIZE(target,ustride,uorder,vstride,vorder)">const <ptype>GLfloat</ptype> *<name>points</name></param>
+            <glx type="render" opcode="146"/>
+        </command>
+        <command>
+            <proto>void <name>glMap2xOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLfixed</ptype> <name>u1</name></param>
+            <param><ptype>GLfixed</ptype> <name>u2</name></param>
+            <param><ptype>GLint</ptype> <name>ustride</name></param>
+            <param><ptype>GLint</ptype> <name>uorder</name></param>
+            <param><ptype>GLfixed</ptype> <name>v1</name></param>
+            <param><ptype>GLfixed</ptype> <name>v2</name></param>
+            <param><ptype>GLint</ptype> <name>vstride</name></param>
+            <param><ptype>GLint</ptype> <name>vorder</name></param>
+            <param><ptype>GLfixed</ptype> <name>points</name></param>
+        </command>
+        <command>
+            <proto>void *<name>glMapBuffer</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="BufferAccessARB"><ptype>GLenum</ptype> <name>access</name></param>
+        </command>
+        <command>
+            <proto>void *<name>glMapBufferARB</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="BufferAccessARB"><ptype>GLenum</ptype> <name>access</name></param>
+            <alias name="glMapBuffer"/>
+        </command>
+        <command>
+            <proto>void *<name>glMapBufferOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>access</name></param>
+            <alias name="glMapBuffer"/>
+        </command>
+        <command>
+            <proto>void *<name>glMapBufferRange</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>length</name></param>
+            <param group="BufferAccessMask"><ptype>GLbitfield</ptype> <name>access</name></param>
+            <glx type="single" opcode="205"/>
+        </command>
+        <command>
+            <proto>void *<name>glMapBufferRangeEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param><ptype>GLsizeiptr</ptype> <name>length</name></param>
+            <param><ptype>GLbitfield</ptype> <name>access</name></param>
+            <alias name="glMapBufferRange"/>
+        </command>
+        <command>
+            <proto>void <name>glMapControlPointsNV</name></proto>
+            <param group="EvalTargetNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="MapTypeNV"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>ustride</name></param>
+            <param><ptype>GLsizei</ptype> <name>vstride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>uorder</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>vorder</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>packed</name></param>
+            <param len="COMPSIZE(target,uorder,vorder)">const void *<name>points</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMapGrid1d</name></proto>
+            <param><ptype>GLint</ptype> <name>un</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>u1</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>u2</name></param>
+            <glx type="render" opcode="147"/>
+        </command>
+        <command>
+            <proto>void <name>glMapGrid1f</name></proto>
+            <param><ptype>GLint</ptype> <name>un</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>u1</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>u2</name></param>
+            <glx type="render" opcode="148"/>
+        </command>
+        <command>
+            <proto>void <name>glMapGrid1xOES</name></proto>
+            <param><ptype>GLint</ptype> <name>n</name></param>
+            <param><ptype>GLfixed</ptype> <name>u1</name></param>
+            <param><ptype>GLfixed</ptype> <name>u2</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMapGrid2d</name></proto>
+            <param><ptype>GLint</ptype> <name>un</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>u1</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>u2</name></param>
+            <param><ptype>GLint</ptype> <name>vn</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>v1</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>v2</name></param>
+            <glx type="render" opcode="149"/>
+        </command>
+        <command>
+            <proto>void <name>glMapGrid2f</name></proto>
+            <param><ptype>GLint</ptype> <name>un</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>u1</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>u2</name></param>
+            <param><ptype>GLint</ptype> <name>vn</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>v1</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>v2</name></param>
+            <glx type="render" opcode="150"/>
+        </command>
+        <command>
+            <proto>void <name>glMapGrid2xOES</name></proto>
+            <param><ptype>GLint</ptype> <name>n</name></param>
+            <param><ptype>GLfixed</ptype> <name>u1</name></param>
+            <param><ptype>GLfixed</ptype> <name>u2</name></param>
+            <param><ptype>GLfixed</ptype> <name>v1</name></param>
+            <param><ptype>GLfixed</ptype> <name>v2</name></param>
+        </command>
+        <command>
+            <proto>void *<name>glMapNamedBufferEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="VertexBufferObjectAccess"><ptype>GLenum</ptype> <name>access</name></param>
+        </command>
+        <command>
+            <proto>void *<name>glMapNamedBufferRangeEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param><ptype>GLsizeiptr</ptype> <name>length</name></param>
+            <param group="BufferAccessMask"><ptype>GLbitfield</ptype> <name>access</name></param>
+        </command>
+        <command>
+            <proto>void *<name>glMapObjectBufferATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMapParameterfvNV</name></proto>
+            <param group="EvalTargetNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="MapParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(target,pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMapParameterivNV</name></proto>
+            <param group="EvalTargetNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="MapParameterNV"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(target,pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void *<name>glMapTexture2DINTEL</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLbitfield</ptype> <name>access</name></param>
+            <param len="1"><ptype>GLint</ptype> *<name>stride</name></param>
+            <param len="1"><ptype>GLenum</ptype> *<name>layout</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMapVertexAttrib1dAPPLE</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>size</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>u1</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>u2</name></param>
+            <param><ptype>GLint</ptype> <name>stride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>order</name></param>
+            <param group="CoordD" len="COMPSIZE(size,stride,order)">const <ptype>GLdouble</ptype> *<name>points</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMapVertexAttrib1fAPPLE</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>size</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>u1</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>u2</name></param>
+            <param><ptype>GLint</ptype> <name>stride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>order</name></param>
+            <param group="CoordF" len="COMPSIZE(size,stride,order)">const <ptype>GLfloat</ptype> *<name>points</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMapVertexAttrib2dAPPLE</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>size</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>u1</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>u2</name></param>
+            <param><ptype>GLint</ptype> <name>ustride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>uorder</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>v1</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>v2</name></param>
+            <param><ptype>GLint</ptype> <name>vstride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>vorder</name></param>
+            <param group="CoordD" len="COMPSIZE(size,ustride,uorder,vstride,vorder)">const <ptype>GLdouble</ptype> *<name>points</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMapVertexAttrib2fAPPLE</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>size</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>u1</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>u2</name></param>
+            <param><ptype>GLint</ptype> <name>ustride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>uorder</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>v1</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>v2</name></param>
+            <param><ptype>GLint</ptype> <name>vstride</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>vorder</name></param>
+            <param group="CoordF" len="COMPSIZE(size,ustride,uorder,vstride,vorder)">const <ptype>GLfloat</ptype> *<name>points</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMaterialf</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="MaterialParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <glx type="render" opcode="96"/>
+        </command>
+        <command>
+            <proto>void <name>glMaterialfv</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="MaterialParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="render" opcode="97"/>
+        </command>
+        <command>
+            <proto>void <name>glMateriali</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="MaterialParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+            <glx type="render" opcode="98"/>
+        </command>
+        <command>
+            <proto>void <name>glMaterialiv</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="MaterialParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="render" opcode="99"/>
+        </command>
+        <command>
+            <proto>void <name>glMaterialx</name></proto>
+            <param><ptype>GLenum</ptype> <name>face</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMaterialxOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>face</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMaterialxv</name></proto>
+            <param><ptype>GLenum</ptype> <name>face</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfixed</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMaterialxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>face</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfixed</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixFrustumEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLdouble</ptype> <name>left</name></param>
+            <param><ptype>GLdouble</ptype> <name>right</name></param>
+            <param><ptype>GLdouble</ptype> <name>bottom</name></param>
+            <param><ptype>GLdouble</ptype> <name>top</name></param>
+            <param><ptype>GLdouble</ptype> <name>zNear</name></param>
+            <param><ptype>GLdouble</ptype> <name>zFar</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixIndexPointerARB</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="MatrixIndexPointerTypeARB"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(size,type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixIndexPointerOES</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(size,type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixIndexubvARB</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param len="size">const <ptype>GLubyte</ptype> *<name>indices</name></param>
+            <glx type="render" opcode="4326"/>
+        </command>
+        <command>
+            <proto>void <name>glMatrixIndexuivARB</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param len="size">const <ptype>GLuint</ptype> *<name>indices</name></param>
+            <glx type="render" opcode="4328"/>
+        </command>
+        <command>
+            <proto>void <name>glMatrixIndexusvARB</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param len="size">const <ptype>GLushort</ptype> *<name>indices</name></param>
+            <glx type="render" opcode="4327"/>
+        </command>
+        <command>
+            <proto>void <name>glMatrixLoadIdentityEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixLoadTransposedEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param len="16">const <ptype>GLdouble</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixLoadTransposefEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param len="16">const <ptype>GLfloat</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixLoaddEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param len="16">const <ptype>GLdouble</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixLoadfEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param len="16">const <ptype>GLfloat</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixMode</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <glx type="render" opcode="179"/>
+        </command>
+        <command>
+            <proto>void <name>glMatrixMultTransposedEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param len="16">const <ptype>GLdouble</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixMultTransposefEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param len="16">const <ptype>GLfloat</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixMultdEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param len="16">const <ptype>GLdouble</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixMultfEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param len="16">const <ptype>GLfloat</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixOrthoEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLdouble</ptype> <name>left</name></param>
+            <param><ptype>GLdouble</ptype> <name>right</name></param>
+            <param><ptype>GLdouble</ptype> <name>bottom</name></param>
+            <param><ptype>GLdouble</ptype> <name>top</name></param>
+            <param><ptype>GLdouble</ptype> <name>zNear</name></param>
+            <param><ptype>GLdouble</ptype> <name>zFar</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixPopEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixPushEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixRotatedEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLdouble</ptype> <name>angle</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixRotatefEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLfloat</ptype> <name>angle</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixScaledEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixScalefEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixTranslatedEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMatrixTranslatefEXT</name></proto>
+            <param group="MatrixMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMemoryBarrier</name></proto>
+            <param><ptype>GLbitfield</ptype> <name>barriers</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMemoryBarrierByRegion</name></proto>
+            <param><ptype>GLbitfield</ptype> <name>barriers</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMemoryBarrierEXT</name></proto>
+            <param><ptype>GLbitfield</ptype> <name>barriers</name></param>
+            <alias name="glMemoryBarrier"/>
+        </command>
+        <command>
+            <proto>void <name>glMinSampleShading</name></proto>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMinSampleShadingARB</name></proto>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>value</name></param>
+            <alias name="glMinSampleShading"/>
+        </command>
+        <command>
+            <proto>void <name>glMinSampleShadingOES</name></proto>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>value</name></param>
+            <alias name="glMinSampleShading"/>
+        </command>
+        <command>
+            <proto>void <name>glMinmax</name></proto>
+            <param group="MinmaxTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>sink</name></param>
+            <glx type="render" opcode="4111"/>
+        </command>
+        <command>
+            <proto>void <name>glMinmaxEXT</name></proto>
+            <param group="MinmaxTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>sink</name></param>
+            <alias name="glMinmax"/>
+            <glx type="render" opcode="4111"/>
+        </command>
+        <command>
+            <proto>void <name>glMultMatrixd</name></proto>
+            <param len="16">const <ptype>GLdouble</ptype> *<name>m</name></param>
+            <glx type="render" opcode="181"/>
+        </command>
+        <command>
+            <proto>void <name>glMultMatrixf</name></proto>
+            <param len="16">const <ptype>GLfloat</ptype> *<name>m</name></param>
+            <glx type="render" opcode="180"/>
+        </command>
+        <command>
+            <proto>void <name>glMultMatrixx</name></proto>
+            <param len="16">const <ptype>GLfixed</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultMatrixxOES</name></proto>
+            <param len="16">const <ptype>GLfixed</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultTransposeMatrixd</name></proto>
+            <param len="16">const <ptype>GLdouble</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultTransposeMatrixdARB</name></proto>
+            <param len="16">const <ptype>GLdouble</ptype> *<name>m</name></param>
+            <alias name="glMultTransposeMatrixd"/>
+        </command>
+        <command>
+            <proto>void <name>glMultTransposeMatrixf</name></proto>
+            <param len="16">const <ptype>GLfloat</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultTransposeMatrixfARB</name></proto>
+            <param len="16">const <ptype>GLfloat</ptype> *<name>m</name></param>
+            <alias name="glMultTransposeMatrixf"/>
+        </command>
+        <command>
+            <proto>void <name>glMultTransposeMatrixxOES</name></proto>
+            <param len="16">const <ptype>GLfixed</ptype> *<name>m</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiDrawArrays</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param len="COMPSIZE(count)">const <ptype>GLint</ptype> *<name>first</name></param>
+            <param len="COMPSIZE(drawcount)">const <ptype>GLsizei</ptype> *<name>count</name></param>
+            <param><ptype>GLsizei</ptype> <name>drawcount</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiDrawArraysEXT</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param len="COMPSIZE(primcount)">const <ptype>GLint</ptype> *<name>first</name></param>
+            <param len="COMPSIZE(primcount)">const <ptype>GLsizei</ptype> *<name>count</name></param>
+            <param><ptype>GLsizei</ptype> <name>primcount</name></param>
+            <alias name="glMultiDrawArrays"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiDrawArraysIndirect</name></proto>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+            <param len="COMPSIZE(drawcount,stride)">const void *<name>indirect</name></param>
+            <param><ptype>GLsizei</ptype> <name>drawcount</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiDrawArraysIndirectAMD</name></proto>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+            <param>const void *<name>indirect</name></param>
+            <param><ptype>GLsizei</ptype> <name>primcount</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <alias name="glMultiDrawArraysIndirect"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiDrawArraysIndirectBindlessNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+            <param>const void *<name>indirect</name></param>
+            <param><ptype>GLsizei</ptype> <name>drawCount</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLint</ptype> <name>vertexBufferCount</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiDrawArraysIndirectCountARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLintptr</ptype> <name>indirect</name></param>
+            <param><ptype>GLintptr</ptype> <name>drawcount</name></param>
+            <param><ptype>GLsizei</ptype> <name>maxdrawcount</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiDrawElementArrayAPPLE</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param len="primcount">const <ptype>GLint</ptype> *<name>first</name></param>
+            <param len="primcount">const <ptype>GLsizei</ptype> *<name>count</name></param>
+            <param><ptype>GLsizei</ptype> <name>primcount</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiDrawElements</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param len="COMPSIZE(drawcount)">const <ptype>GLsizei</ptype> *<name>count</name></param>
+            <param group="DrawElementsType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(drawcount)">const void *const*<name>indices</name></param>
+            <param><ptype>GLsizei</ptype> <name>drawcount</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiDrawElementsBaseVertex</name></proto>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+            <param len="COMPSIZE(drawcount)">const <ptype>GLsizei</ptype> *<name>count</name></param>
+            <param group="DrawElementsType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(drawcount)">const void *const*<name>indices</name></param>
+            <param><ptype>GLsizei</ptype> <name>drawcount</name></param>
+            <param len="COMPSIZE(drawcount)">const <ptype>GLint</ptype> *<name>basevertex</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiDrawElementsEXT</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param len="COMPSIZE(primcount)">const <ptype>GLsizei</ptype> *<name>count</name></param>
+            <param group="DrawElementsType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(primcount)">const void *const*<name>indices</name></param>
+            <param><ptype>GLsizei</ptype> <name>primcount</name></param>
+            <alias name="glMultiDrawElements"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiDrawElementsIndirect</name></proto>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(drawcount,stride)">const void *<name>indirect</name></param>
+            <param><ptype>GLsizei</ptype> <name>drawcount</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiDrawElementsIndirectAMD</name></proto>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param>const void *<name>indirect</name></param>
+            <param><ptype>GLsizei</ptype> <name>primcount</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <alias name="glMultiDrawElementsIndirect"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiDrawElementsIndirectBindlessNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param>const void *<name>indirect</name></param>
+            <param><ptype>GLsizei</ptype> <name>drawCount</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLint</ptype> <name>vertexBufferCount</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiDrawElementsIndirectCountARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLintptr</ptype> <name>indirect</name></param>
+            <param><ptype>GLintptr</ptype> <name>drawcount</name></param>
+            <param><ptype>GLsizei</ptype> <name>maxdrawcount</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiDrawRangeElementArrayAPPLE</name></proto>
+            <param group="PrimitiveType"><ptype>GLenum</ptype> <name>mode</name></param>
+            <param><ptype>GLuint</ptype> <name>start</name></param>
+            <param><ptype>GLuint</ptype> <name>end</name></param>
+            <param len="primcount">const <ptype>GLint</ptype> *<name>first</name></param>
+            <param len="primcount">const <ptype>GLsizei</ptype> *<name>count</name></param>
+            <param><ptype>GLsizei</ptype> <name>primcount</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiModeDrawArraysIBM</name></proto>
+            <param group="PrimitiveType" len="COMPSIZE(primcount)">const <ptype>GLenum</ptype> *<name>mode</name></param>
+            <param len="COMPSIZE(primcount)">const <ptype>GLint</ptype> *<name>first</name></param>
+            <param len="COMPSIZE(primcount)">const <ptype>GLsizei</ptype> *<name>count</name></param>
+            <param><ptype>GLsizei</ptype> <name>primcount</name></param>
+            <param><ptype>GLint</ptype> <name>modestride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiModeDrawElementsIBM</name></proto>
+            <param group="PrimitiveType" len="COMPSIZE(primcount)">const <ptype>GLenum</ptype> *<name>mode</name></param>
+            <param len="COMPSIZE(primcount)">const <ptype>GLsizei</ptype> *<name>count</name></param>
+            <param group="DrawElementsType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(primcount)">const void *const*<name>indices</name></param>
+            <param><ptype>GLsizei</ptype> <name>primcount</name></param>
+            <param><ptype>GLint</ptype> <name>modestride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexBufferEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TypeEnum"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1bOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLbyte</ptype> <name>s</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1bvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param len="1">const <ptype>GLbyte</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1d</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>s</name></param>
+            <vecequiv name="glMultiTexCoord1dv"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1dARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>s</name></param>
+            <vecequiv name="glMultiTexCoord1dv"/>
+            <alias name="glMultiTexCoord1d"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1dv</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD" len="1">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="198"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1dvARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD" len="1">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glMultiTexCoord1dv"/>
+            <glx type="render" opcode="198"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1f</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>s</name></param>
+            <vecequiv name="glMultiTexCoord1fv"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1fARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>s</name></param>
+            <vecequiv name="glMultiTexCoord1fv"/>
+            <alias name="glMultiTexCoord1f"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1fv</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF" len="1">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="199"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1fvARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF" len="1">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glMultiTexCoord1fv"/>
+            <glx type="render" opcode="199"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1hNV</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>s</name></param>
+            <vecequiv name="glMultiTexCoord1hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1hvNV</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Half16NV" len="1">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4250"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1i</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>s</name></param>
+            <vecequiv name="glMultiTexCoord1iv"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1iARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>s</name></param>
+            <vecequiv name="glMultiTexCoord1iv"/>
+            <alias name="glMultiTexCoord1i"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1iv</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordI" len="1">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="200"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1ivARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordI" len="1">const <ptype>GLint</ptype> *<name>v</name></param>
+            <alias name="glMultiTexCoord1iv"/>
+            <glx type="render" opcode="200"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1s</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>s</name></param>
+            <vecequiv name="glMultiTexCoord1sv"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1sARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>s</name></param>
+            <vecequiv name="glMultiTexCoord1sv"/>
+            <alias name="glMultiTexCoord1s"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1sv</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordS" len="1">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="201"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1svARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordS" len="1">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glMultiTexCoord1sv"/>
+            <glx type="render" opcode="201"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1xOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLfixed</ptype> <name>s</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord1xvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param len="1">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2bOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLbyte</ptype> <name>s</name></param>
+            <param><ptype>GLbyte</ptype> <name>t</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2bvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param len="2">const <ptype>GLbyte</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2d</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>s</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>t</name></param>
+            <vecequiv name="glMultiTexCoord2dv"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2dARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>s</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>t</name></param>
+            <vecequiv name="glMultiTexCoord2dv"/>
+            <alias name="glMultiTexCoord2d"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2dv</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD" len="2">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="202"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2dvARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD" len="2">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glMultiTexCoord2dv"/>
+            <glx type="render" opcode="202"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2f</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>s</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>t</name></param>
+            <vecequiv name="glMultiTexCoord2fv"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2fARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>s</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>t</name></param>
+            <vecequiv name="glMultiTexCoord2fv"/>
+            <alias name="glMultiTexCoord2f"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2fv</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF" len="2">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="203"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2fvARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF" len="2">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glMultiTexCoord2fv"/>
+            <glx type="render" opcode="203"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2hNV</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>s</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>t</name></param>
+            <vecequiv name="glMultiTexCoord2hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2hvNV</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Half16NV" len="2">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4251"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2i</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>s</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>t</name></param>
+            <vecequiv name="glMultiTexCoord2iv"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2iARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>s</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>t</name></param>
+            <vecequiv name="glMultiTexCoord2iv"/>
+            <alias name="glMultiTexCoord2i"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2iv</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordI" len="2">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="204"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2ivARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordI" len="2">const <ptype>GLint</ptype> *<name>v</name></param>
+            <alias name="glMultiTexCoord2iv"/>
+            <glx type="render" opcode="204"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2s</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>s</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>t</name></param>
+            <vecequiv name="glMultiTexCoord2sv"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2sARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>s</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>t</name></param>
+            <vecequiv name="glMultiTexCoord2sv"/>
+            <alias name="glMultiTexCoord2s"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2sv</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordS" len="2">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="205"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2svARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordS" len="2">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glMultiTexCoord2sv"/>
+            <glx type="render" opcode="205"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2xOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLfixed</ptype> <name>s</name></param>
+            <param><ptype>GLfixed</ptype> <name>t</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord2xvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param len="2">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3bOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLbyte</ptype> <name>s</name></param>
+            <param><ptype>GLbyte</ptype> <name>t</name></param>
+            <param><ptype>GLbyte</ptype> <name>r</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3bvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param len="3">const <ptype>GLbyte</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3d</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>s</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>t</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>r</name></param>
+            <vecequiv name="glMultiTexCoord3dv"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3dARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>s</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>t</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>r</name></param>
+            <vecequiv name="glMultiTexCoord3dv"/>
+            <alias name="glMultiTexCoord3d"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3dv</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD" len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="206"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3dvARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD" len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glMultiTexCoord3dv"/>
+            <glx type="render" opcode="206"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3f</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>s</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>t</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>r</name></param>
+            <vecequiv name="glMultiTexCoord3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3fARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>s</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>t</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>r</name></param>
+            <vecequiv name="glMultiTexCoord3fv"/>
+            <alias name="glMultiTexCoord3f"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3fv</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF" len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="207"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3fvARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF" len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glMultiTexCoord3fv"/>
+            <glx type="render" opcode="207"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3hNV</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>s</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>t</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>r</name></param>
+            <vecequiv name="glMultiTexCoord3hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3hvNV</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Half16NV" len="3">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4252"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3i</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>s</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>t</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>r</name></param>
+            <vecequiv name="glMultiTexCoord3iv"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3iARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>s</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>t</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>r</name></param>
+            <vecequiv name="glMultiTexCoord3iv"/>
+            <alias name="glMultiTexCoord3i"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3iv</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordI" len="3">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="208"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3ivARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordI" len="3">const <ptype>GLint</ptype> *<name>v</name></param>
+            <alias name="glMultiTexCoord3iv"/>
+            <glx type="render" opcode="208"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3s</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>s</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>t</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>r</name></param>
+            <vecequiv name="glMultiTexCoord3sv"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3sARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>s</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>t</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>r</name></param>
+            <vecequiv name="glMultiTexCoord3sv"/>
+            <alias name="glMultiTexCoord3s"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3sv</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordS" len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="209"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3svARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordS" len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glMultiTexCoord3sv"/>
+            <glx type="render" opcode="209"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3xOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLfixed</ptype> <name>s</name></param>
+            <param><ptype>GLfixed</ptype> <name>t</name></param>
+            <param><ptype>GLfixed</ptype> <name>r</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord3xvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param len="3">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4bOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLbyte</ptype> <name>s</name></param>
+            <param><ptype>GLbyte</ptype> <name>t</name></param>
+            <param><ptype>GLbyte</ptype> <name>r</name></param>
+            <param><ptype>GLbyte</ptype> <name>q</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4bvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param len="4">const <ptype>GLbyte</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4d</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>s</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>t</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>r</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>q</name></param>
+            <vecequiv name="glMultiTexCoord4dv"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4dARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>s</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>t</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>r</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>q</name></param>
+            <vecequiv name="glMultiTexCoord4dv"/>
+            <alias name="glMultiTexCoord4d"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4dv</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD" len="4">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="210"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4dvARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordD" len="4">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glMultiTexCoord4dv"/>
+            <glx type="render" opcode="210"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4f</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>s</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>t</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>r</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>q</name></param>
+            <vecequiv name="glMultiTexCoord4fv"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4fARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>s</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>t</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>r</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>q</name></param>
+            <vecequiv name="glMultiTexCoord4fv"/>
+            <alias name="glMultiTexCoord4f"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4fv</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF" len="4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="211"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4fvARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordF" len="4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glMultiTexCoord4fv"/>
+            <glx type="render" opcode="211"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4hNV</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>s</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>t</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>r</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>q</name></param>
+            <vecequiv name="glMultiTexCoord4hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4hvNV</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="Half16NV" len="4">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4253"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4i</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>s</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>t</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>r</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>q</name></param>
+            <vecequiv name="glMultiTexCoord4iv"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4iARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>s</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>t</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>r</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>q</name></param>
+            <vecequiv name="glMultiTexCoord4iv"/>
+            <alias name="glMultiTexCoord4i"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4iv</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordI" len="4">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="212"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4ivARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordI" len="4">const <ptype>GLint</ptype> *<name>v</name></param>
+            <alias name="glMultiTexCoord4iv"/>
+            <glx type="render" opcode="212"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4s</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>s</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>t</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>r</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>q</name></param>
+            <vecequiv name="glMultiTexCoord4sv"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4sARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>s</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>t</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>r</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>q</name></param>
+            <vecequiv name="glMultiTexCoord4sv"/>
+            <alias name="glMultiTexCoord4s"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4sv</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordS" len="4">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="213"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4svARB</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CoordS" len="4">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glMultiTexCoord4sv"/>
+            <glx type="render" opcode="213"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4x</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLfixed</ptype> <name>s</name></param>
+            <param><ptype>GLfixed</ptype> <name>t</name></param>
+            <param><ptype>GLfixed</ptype> <name>r</name></param>
+            <param><ptype>GLfixed</ptype> <name>q</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4xOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLfixed</ptype> <name>s</name></param>
+            <param><ptype>GLfixed</ptype> <name>t</name></param>
+            <param><ptype>GLfixed</ptype> <name>r</name></param>
+            <param><ptype>GLfixed</ptype> <name>q</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoord4xvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param len="4">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoordP1ui</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoordP1uiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoordP2ui</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoordP2uiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoordP3ui</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoordP3uiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoordP4ui</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoordP4uiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexCoordPointerEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="TexCoordPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(size,type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexEnvfEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureEnvTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureEnvParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <vecequiv name="glMultiTexEnvfvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexEnvfvEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureEnvTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureEnvParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexEnviEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureEnvTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureEnvParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+            <vecequiv name="glMultiTexEnvivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexEnvivEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureEnvTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureEnvParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexGendEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLdouble</ptype> <name>param</name></param>
+            <vecequiv name="glMultiTexGendvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexGendvEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLdouble</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexGenfEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <vecequiv name="glMultiTexGenfvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexGenfvEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexGeniEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+            <vecequiv name="glMultiTexGenivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexGenivEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexImage1DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureComponentCount"><ptype>GLint</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width)">const void *<name>pixels</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexImage2DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureComponentCount"><ptype>GLint</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height)">const void *<name>pixels</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexImage3DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureComponentCount"><ptype>GLint</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height,depth)">const void *<name>pixels</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexParameterIivEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexParameterIuivEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexParameterfEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <vecequiv name="glMultiTexParameterfvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexParameterfvEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexParameteriEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+            <vecequiv name="glMultiTexParameterivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexParameterivEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexRenderbufferEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexSubImage1DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width)">const void *<name>pixels</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexSubImage2DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height)">const void *<name>pixels</name></param>
+        </command>
+        <command>
+            <proto>void <name>glMultiTexSubImage3DEXT</name></proto>
+            <param group="TextureUnit"><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height,depth)">const void *<name>pixels</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedBufferDataEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLsizeiptr</ptype> <name>size</name></param>
+            <param len="COMPSIZE(size)">const void *<name>data</name></param>
+            <param group="VertexBufferObjectUsage"><ptype>GLenum</ptype> <name>usage</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedBufferStorageEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLsizeiptr</ptype> <name>size</name></param>
+            <param len="size">const void *<name>data</name></param>
+            <param><ptype>GLbitfield</ptype> <name>flags</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedBufferSubDataEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param><ptype>GLsizeiptr</ptype> <name>size</name></param>
+            <param len="COMPSIZE(size)">const void *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedCopyBufferSubDataEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>readBuffer</name></param>
+            <param><ptype>GLuint</ptype> <name>writeBuffer</name></param>
+            <param><ptype>GLintptr</ptype> <name>readOffset</name></param>
+            <param><ptype>GLintptr</ptype> <name>writeOffset</name></param>
+            <param><ptype>GLsizeiptr</ptype> <name>size</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedFramebufferParameteriEXT</name></proto>
+            <param group="Framebuffer"><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <param group="FramebufferParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedFramebufferRenderbufferEXT</name></proto>
+            <param group="Framebuffer"><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="RenderbufferTarget"><ptype>GLenum</ptype> <name>renderbuffertarget</name></param>
+            <param group="Renderbuffer"><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedFramebufferTexture1DEXT</name></proto>
+            <param group="Framebuffer"><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>textarget</name></param>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedFramebufferTexture2DEXT</name></proto>
+            <param group="Framebuffer"><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>textarget</name></param>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedFramebufferTexture3DEXT</name></proto>
+            <param group="Framebuffer"><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>textarget</name></param>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>zoffset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedFramebufferTextureEXT</name></proto>
+            <param group="Framebuffer"><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedFramebufferTextureFaceEXT</name></proto>
+            <param group="Framebuffer"><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>face</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedFramebufferTextureLayerEXT</name></proto>
+            <param group="Framebuffer"><ptype>GLuint</ptype> <name>framebuffer</name></param>
+            <param group="FramebufferAttachment"><ptype>GLenum</ptype> <name>attachment</name></param>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>layer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedProgramLocalParameter4dEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <param><ptype>GLdouble</ptype> <name>w</name></param>
+            <vecequiv name="glNamedProgramLocalParameter4dvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glNamedProgramLocalParameter4dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLdouble</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedProgramLocalParameter4fEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <param><ptype>GLfloat</ptype> <name>w</name></param>
+            <vecequiv name="glNamedProgramLocalParameter4fvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glNamedProgramLocalParameter4fvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedProgramLocalParameterI4iEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLint</ptype> <name>z</name></param>
+            <param><ptype>GLint</ptype> <name>w</name></param>
+            <vecequiv name="glNamedProgramLocalParameterI4ivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glNamedProgramLocalParameterI4ivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedProgramLocalParameterI4uiEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>x</name></param>
+            <param><ptype>GLuint</ptype> <name>y</name></param>
+            <param><ptype>GLuint</ptype> <name>z</name></param>
+            <param><ptype>GLuint</ptype> <name>w</name></param>
+            <vecequiv name="glNamedProgramLocalParameterI4uivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glNamedProgramLocalParameterI4uivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedProgramLocalParameters4fvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedProgramLocalParametersI4ivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedProgramLocalParametersI4uivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedProgramStringEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ProgramFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>len</name></param>
+            <param len="len">const void *<name>string</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedRenderbufferStorageEXT</name></proto>
+            <param group="Renderbuffer"><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedRenderbufferStorageMultisampleCoverageEXT</name></proto>
+            <param group="Renderbuffer"><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+            <param><ptype>GLsizei</ptype> <name>coverageSamples</name></param>
+            <param><ptype>GLsizei</ptype> <name>colorSamples</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedRenderbufferStorageMultisampleEXT</name></proto>
+            <param group="Renderbuffer"><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNamedStringARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLint</ptype> <name>namelen</name></param>
+            <param len="namelen">const <ptype>GLchar</ptype> *<name>name</name></param>
+            <param><ptype>GLint</ptype> <name>stringlen</name></param>
+            <param len="stringlen">const <ptype>GLchar</ptype> *<name>string</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNewList</name></proto>
+            <param group="List"><ptype>GLuint</ptype> <name>list</name></param>
+            <param group="ListMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <glx type="single" opcode="101"/>
+        </command>
+        <command>
+            <proto><ptype>GLuint</ptype> <name>glNewObjectBufferATI</name></proto>
+            <param><ptype>GLsizei</ptype> <name>size</name></param>
+            <param len="size">const void *<name>pointer</name></param>
+            <param group="ArrayObjectUsageATI"><ptype>GLenum</ptype> <name>usage</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormal3b</name></proto>
+            <param><ptype>GLbyte</ptype> <name>nx</name></param>
+            <param><ptype>GLbyte</ptype> <name>ny</name></param>
+            <param><ptype>GLbyte</ptype> <name>nz</name></param>
+            <vecequiv name="glNormal3bv"/>
+        </command>
+        <command>
+            <proto>void <name>glNormal3bv</name></proto>
+            <param len="3">const <ptype>GLbyte</ptype> *<name>v</name></param>
+            <glx type="render" opcode="28"/>
+        </command>
+        <command>
+            <proto>void <name>glNormal3d</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>nx</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>ny</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>nz</name></param>
+            <vecequiv name="glNormal3dv"/>
+        </command>
+        <command>
+            <proto>void <name>glNormal3dv</name></proto>
+            <param group="CoordD" len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="29"/>
+        </command>
+        <command>
+            <proto>void <name>glNormal3f</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>nx</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>ny</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>nz</name></param>
+            <vecequiv name="glNormal3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glNormal3fVertex3fSUN</name></proto>
+            <param><ptype>GLfloat</ptype> <name>nx</name></param>
+            <param><ptype>GLfloat</ptype> <name>ny</name></param>
+            <param><ptype>GLfloat</ptype> <name>nz</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormal3fVertex3fvSUN</name></proto>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>n</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormal3fv</name></proto>
+            <param group="CoordF" len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="30"/>
+        </command>
+        <command>
+            <proto>void <name>glNormal3hNV</name></proto>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>nx</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>ny</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>nz</name></param>
+            <vecequiv name="glNormal3hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glNormal3hvNV</name></proto>
+            <param group="Half16NV" len="3">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4243"/>
+        </command>
+        <command>
+            <proto>void <name>glNormal3i</name></proto>
+            <param><ptype>GLint</ptype> <name>nx</name></param>
+            <param><ptype>GLint</ptype> <name>ny</name></param>
+            <param><ptype>GLint</ptype> <name>nz</name></param>
+            <vecequiv name="glNormal3iv"/>
+        </command>
+        <command>
+            <proto>void <name>glNormal3iv</name></proto>
+            <param len="3">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="31"/>
+        </command>
+        <command>
+            <proto>void <name>glNormal3s</name></proto>
+            <param><ptype>GLshort</ptype> <name>nx</name></param>
+            <param><ptype>GLshort</ptype> <name>ny</name></param>
+            <param><ptype>GLshort</ptype> <name>nz</name></param>
+            <vecequiv name="glNormal3sv"/>
+        </command>
+        <command>
+            <proto>void <name>glNormal3sv</name></proto>
+            <param len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="32"/>
+        </command>
+        <command>
+            <proto>void <name>glNormal3x</name></proto>
+            <param><ptype>GLfixed</ptype> <name>nx</name></param>
+            <param><ptype>GLfixed</ptype> <name>ny</name></param>
+            <param><ptype>GLfixed</ptype> <name>nz</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormal3xOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>nx</name></param>
+            <param><ptype>GLfixed</ptype> <name>ny</name></param>
+            <param><ptype>GLfixed</ptype> <name>nz</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormal3xvOES</name></proto>
+            <param len="3">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalFormatNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalP3ui</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalP3uiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalPointer</name></proto>
+            <param group="NormalPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalPointerEXT</name></proto>
+            <param group="NormalPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="COMPSIZE(type,stride,count)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalPointerListIBM</name></proto>
+            <param group="NormalPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLint</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(type,stride)">const void **<name>pointer</name></param>
+            <param><ptype>GLint</ptype> <name>ptrstride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalPointervINTEL</name></proto>
+            <param group="NormalPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="4">const void **<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalStream3bATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLbyte</ptype> <name>nx</name></param>
+            <param><ptype>GLbyte</ptype> <name>ny</name></param>
+            <param><ptype>GLbyte</ptype> <name>nz</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalStream3bvATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="3">const <ptype>GLbyte</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalStream3dATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLdouble</ptype> <name>nx</name></param>
+            <param><ptype>GLdouble</ptype> <name>ny</name></param>
+            <param><ptype>GLdouble</ptype> <name>nz</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalStream3dvATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="3">const <ptype>GLdouble</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalStream3fATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLfloat</ptype> <name>nx</name></param>
+            <param><ptype>GLfloat</ptype> <name>ny</name></param>
+            <param><ptype>GLfloat</ptype> <name>nz</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalStream3fvATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalStream3iATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLint</ptype> <name>nx</name></param>
+            <param><ptype>GLint</ptype> <name>ny</name></param>
+            <param><ptype>GLint</ptype> <name>nz</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalStream3ivATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="3">const <ptype>GLint</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalStream3sATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLshort</ptype> <name>nx</name></param>
+            <param><ptype>GLshort</ptype> <name>ny</name></param>
+            <param><ptype>GLshort</ptype> <name>nz</name></param>
+        </command>
+        <command>
+            <proto>void <name>glNormalStream3svATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="3">const <ptype>GLshort</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glObjectLabel</name></proto>
+            <param><ptype>GLenum</ptype> <name>identifier</name></param>
+            <param><ptype>GLuint</ptype> <name>name</name></param>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param len="COMPSIZE(label,length)">const <ptype>GLchar</ptype> *<name>label</name></param>
+        </command>
+        <command>
+            <proto>void <name>glObjectLabelKHR</name></proto>
+            <param><ptype>GLenum</ptype> <name>identifier</name></param>
+            <param><ptype>GLuint</ptype> <name>name</name></param>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param>const <ptype>GLchar</ptype> *<name>label</name></param>
+            <alias name="glObjectLabel"/>
+        </command>
+        <command>
+            <proto>void <name>glObjectPtrLabel</name></proto>
+            <param>const void *<name>ptr</name></param>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param len="COMPSIZE(label,length)">const <ptype>GLchar</ptype> *<name>label</name></param>
+        </command>
+        <command>
+            <proto>void <name>glObjectPtrLabelKHR</name></proto>
+            <param>const void *<name>ptr</name></param>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param>const <ptype>GLchar</ptype> *<name>label</name></param>
+            <alias name="glObjectPtrLabel"/>
+        </command>
+        <command>
+            <proto><ptype>GLenum</ptype> <name>glObjectPurgeableAPPLE</name></proto>
+            <param><ptype>GLenum</ptype> <name>objectType</name></param>
+            <param><ptype>GLuint</ptype> <name>name</name></param>
+            <param><ptype>GLenum</ptype> <name>option</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLenum</ptype> <name>glObjectUnpurgeableAPPLE</name></proto>
+            <param><ptype>GLenum</ptype> <name>objectType</name></param>
+            <param><ptype>GLuint</ptype> <name>name</name></param>
+            <param><ptype>GLenum</ptype> <name>option</name></param>
+        </command>
+        <command>
+            <proto>void <name>glOrtho</name></proto>
+            <param><ptype>GLdouble</ptype> <name>left</name></param>
+            <param><ptype>GLdouble</ptype> <name>right</name></param>
+            <param><ptype>GLdouble</ptype> <name>bottom</name></param>
+            <param><ptype>GLdouble</ptype> <name>top</name></param>
+            <param><ptype>GLdouble</ptype> <name>zNear</name></param>
+            <param><ptype>GLdouble</ptype> <name>zFar</name></param>
+            <glx type="render" opcode="182"/>
+        </command>
+        <command>
+            <proto>void <name>glOrthof</name></proto>
+            <param><ptype>GLfloat</ptype> <name>l</name></param>
+            <param><ptype>GLfloat</ptype> <name>r</name></param>
+            <param><ptype>GLfloat</ptype> <name>b</name></param>
+            <param><ptype>GLfloat</ptype> <name>t</name></param>
+            <param><ptype>GLfloat</ptype> <name>n</name></param>
+            <param><ptype>GLfloat</ptype> <name>f</name></param>
+        </command>
+        <command>
+            <proto>void <name>glOrthofOES</name></proto>
+            <param><ptype>GLfloat</ptype> <name>l</name></param>
+            <param><ptype>GLfloat</ptype> <name>r</name></param>
+            <param><ptype>GLfloat</ptype> <name>b</name></param>
+            <param><ptype>GLfloat</ptype> <name>t</name></param>
+            <param><ptype>GLfloat</ptype> <name>n</name></param>
+            <param><ptype>GLfloat</ptype> <name>f</name></param>
+            <glx type="render" opcode="4311"/>
+        </command>
+        <command>
+            <proto>void <name>glOrthox</name></proto>
+            <param><ptype>GLfixed</ptype> <name>l</name></param>
+            <param><ptype>GLfixed</ptype> <name>r</name></param>
+            <param><ptype>GLfixed</ptype> <name>b</name></param>
+            <param><ptype>GLfixed</ptype> <name>t</name></param>
+            <param><ptype>GLfixed</ptype> <name>n</name></param>
+            <param><ptype>GLfixed</ptype> <name>f</name></param>
+        </command>
+        <command>
+            <proto>void <name>glOrthoxOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>l</name></param>
+            <param><ptype>GLfixed</ptype> <name>r</name></param>
+            <param><ptype>GLfixed</ptype> <name>b</name></param>
+            <param><ptype>GLfixed</ptype> <name>t</name></param>
+            <param><ptype>GLfixed</ptype> <name>n</name></param>
+            <param><ptype>GLfixed</ptype> <name>f</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPNTrianglesfATI</name></proto>
+            <param group="PNTrianglesPNameATI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfloat</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPNTrianglesiATI</name></proto>
+            <param group="PNTrianglesPNameATI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPassTexCoordATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>dst</name></param>
+            <param><ptype>GLuint</ptype> <name>coord</name></param>
+            <param group="SwizzleOpATI"><ptype>GLenum</ptype> <name>swizzle</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPassThrough</name></proto>
+            <param group="FeedbackElement"><ptype>GLfloat</ptype> <name>token</name></param>
+            <glx type="render" opcode="123"/>
+        </command>
+        <command>
+            <proto>void <name>glPassThroughxOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>token</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPatchParameterfv</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>values</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPatchParameteri</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPatchParameteriEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>value</name></param>
+            <alias name="glPatchParameteri"/>
+        </command>
+        <command>
+            <proto>void <name>glPathColorGenNV</name></proto>
+            <param group="PathColor"><ptype>GLenum</ptype> <name>color</name></param>
+            <param group="PathGenMode"><ptype>GLenum</ptype> <name>genMode</name></param>
+            <param group="PathColorFormat"><ptype>GLenum</ptype> <name>colorFormat</name></param>
+            <param len="COMPSIZE(genMode,colorFormat)">const <ptype>GLfloat</ptype> *<name>coeffs</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathCommandsNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param><ptype>GLsizei</ptype> <name>numCommands</name></param>
+            <param group="PathCommand" len="numCommands">const <ptype>GLubyte</ptype> *<name>commands</name></param>
+            <param><ptype>GLsizei</ptype> <name>numCoords</name></param>
+            <param group="PathCoordType"><ptype>GLenum</ptype> <name>coordType</name></param>
+            <param len="COMPSIZE(numCoords,coordType)">const void *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathCoordsNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param><ptype>GLsizei</ptype> <name>numCoords</name></param>
+            <param group="PathCoordType"><ptype>GLenum</ptype> <name>coordType</name></param>
+            <param len="COMPSIZE(numCoords,coordType)">const void *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathCoverDepthFuncNV</name></proto>
+            <param group="DepthFunction"><ptype>GLenum</ptype> <name>func</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathDashArrayNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param><ptype>GLsizei</ptype> <name>dashCount</name></param>
+            <param len="dashCount">const <ptype>GLfloat</ptype> *<name>dashArray</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathFogGenNV</name></proto>
+            <param group="PathGenMode"><ptype>GLenum</ptype> <name>genMode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathGlyphRangeNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>firstPathName</name></param>
+            <param group="PathFontTarget"><ptype>GLenum</ptype> <name>fontTarget</name></param>
+            <param len="COMPSIZE(fontTarget,fontName)">const void *<name>fontName</name></param>
+            <param group="PathFontStyle"><ptype>GLbitfield</ptype> <name>fontStyle</name></param>
+            <param><ptype>GLuint</ptype> <name>firstGlyph</name></param>
+            <param><ptype>GLsizei</ptype> <name>numGlyphs</name></param>
+            <param group="PathHandleMissingGlyphs"><ptype>GLenum</ptype> <name>handleMissingGlyphs</name></param>
+            <param group="Path"><ptype>GLuint</ptype> <name>pathParameterTemplate</name></param>
+            <param><ptype>GLfloat</ptype> <name>emScale</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathGlyphsNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>firstPathName</name></param>
+            <param group="PathFontTarget"><ptype>GLenum</ptype> <name>fontTarget</name></param>
+            <param len="COMPSIZE(fontTarget,fontName)">const void *<name>fontName</name></param>
+            <param group="PathFontStyle"><ptype>GLbitfield</ptype> <name>fontStyle</name></param>
+            <param><ptype>GLsizei</ptype> <name>numGlyphs</name></param>
+            <param group="PathElementType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(numGlyphs,type,charcodes)">const void *<name>charcodes</name></param>
+            <param group="PathHandleMissingGlyphs"><ptype>GLenum</ptype> <name>handleMissingGlyphs</name></param>
+            <param group="Path"><ptype>GLuint</ptype> <name>pathParameterTemplate</name></param>
+            <param><ptype>GLfloat</ptype> <name>emScale</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathParameterfNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param group="PathParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfloat</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathParameterfvNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param group="PathParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathParameteriNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param group="PathParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathParameterivNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param group="PathParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathStencilDepthOffsetNV</name></proto>
+            <param><ptype>GLfloat</ptype> <name>factor</name></param>
+            <param><ptype>GLfloat</ptype> <name>units</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathStencilFuncNV</name></proto>
+            <param group="StencilFunction"><ptype>GLenum</ptype> <name>func</name></param>
+            <param group="ClampedStencilValue"><ptype>GLint</ptype> <name>ref</name></param>
+            <param group="MaskedStencilValue"><ptype>GLuint</ptype> <name>mask</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathStringNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param group="PathStringFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param len="length">const void *<name>pathString</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathSubCommandsNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param><ptype>GLsizei</ptype> <name>commandStart</name></param>
+            <param><ptype>GLsizei</ptype> <name>commandsToDelete</name></param>
+            <param><ptype>GLsizei</ptype> <name>numCommands</name></param>
+            <param group="PathCommand" len="numCommands">const <ptype>GLubyte</ptype> *<name>commands</name></param>
+            <param><ptype>GLsizei</ptype> <name>numCoords</name></param>
+            <param group="PathCoordType"><ptype>GLenum</ptype> <name>coordType</name></param>
+            <param len="COMPSIZE(numCoords,coordType)">const void *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathSubCoordsNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param><ptype>GLsizei</ptype> <name>coordStart</name></param>
+            <param><ptype>GLsizei</ptype> <name>numCoords</name></param>
+            <param group="PathCoordType"><ptype>GLenum</ptype> <name>coordType</name></param>
+            <param len="COMPSIZE(numCoords,coordType)">const void *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPathTexGenNV</name></proto>
+            <param group="PathColor"><ptype>GLenum</ptype> <name>texCoordSet</name></param>
+            <param group="PathGenMode"><ptype>GLenum</ptype> <name>genMode</name></param>
+            <param><ptype>GLint</ptype> <name>components</name></param>
+            <param len="COMPSIZE(genMode,components)">const <ptype>GLfloat</ptype> *<name>coeffs</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPauseTransformFeedback</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glPauseTransformFeedbackNV</name></proto>
+            <alias name="glPauseTransformFeedback"/>
+        </command>
+        <command>
+            <proto>void <name>glPixelDataRangeNV</name></proto>
+            <param group="PixelDataRangeTargetNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param len="length">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPixelMapfv</name></proto>
+            <param group="PixelMap"><ptype>GLenum</ptype> <name>map</name></param>
+            <param group="CheckedInt32"><ptype>GLsizei</ptype> <name>mapsize</name></param>
+            <param len="mapsize">const <ptype>GLfloat</ptype> *<name>values</name></param>
+            <glx type="render" opcode="168"/>
+            <glx type="render" opcode="323" name="glPixelMapfvPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glPixelMapuiv</name></proto>
+            <param group="PixelMap"><ptype>GLenum</ptype> <name>map</name></param>
+            <param group="CheckedInt32"><ptype>GLsizei</ptype> <name>mapsize</name></param>
+            <param len="mapsize">const <ptype>GLuint</ptype> *<name>values</name></param>
+            <glx type="render" opcode="169"/>
+            <glx type="render" opcode="324" name="glPixelMapuivPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glPixelMapusv</name></proto>
+            <param group="PixelMap"><ptype>GLenum</ptype> <name>map</name></param>
+            <param group="CheckedInt32"><ptype>GLsizei</ptype> <name>mapsize</name></param>
+            <param len="mapsize">const <ptype>GLushort</ptype> *<name>values</name></param>
+            <glx type="render" opcode="170"/>
+            <glx type="render" opcode="325" name="glPixelMapusvPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glPixelMapx</name></proto>
+            <param><ptype>GLenum</ptype> <name>map</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param len="size">const <ptype>GLfixed</ptype> *<name>values</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPixelStoref</name></proto>
+            <param group="PixelStoreParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <glx type="single" opcode="109"/>
+        </command>
+        <command>
+            <proto>void <name>glPixelStorei</name></proto>
+            <param group="PixelStoreParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+            <glx type="single" opcode="110"/>
+        </command>
+        <command>
+            <proto>void <name>glPixelStorex</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPixelTexGenParameterfSGIS</name></proto>
+            <param group="PixelTexGenParameterNameSGIS"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPixelTexGenParameterfvSGIS</name></proto>
+            <param group="PixelTexGenParameterNameSGIS"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPixelTexGenParameteriSGIS</name></proto>
+            <param group="PixelTexGenParameterNameSGIS"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPixelTexGenParameterivSGIS</name></proto>
+            <param group="PixelTexGenParameterNameSGIS"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPixelTexGenSGIX</name></proto>
+            <param group="PixelTexGenModeSGIX"><ptype>GLenum</ptype> <name>mode</name></param>
+            <glx type="render" opcode="2059"/>
+        </command>
+        <command>
+            <proto>void <name>glPixelTransferf</name></proto>
+            <param group="PixelTransferParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <glx type="render" opcode="166"/>
+        </command>
+        <command>
+            <proto>void <name>glPixelTransferi</name></proto>
+            <param group="PixelTransferParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+            <glx type="render" opcode="167"/>
+        </command>
+        <command>
+            <proto>void <name>glPixelTransferxOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPixelTransformParameterfEXT</name></proto>
+            <param group="PixelTransformTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelTransformPNameEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfloat</ptype> <name>param</name></param>
+            <glx type="render" opcode="16385"/>
+        </command>
+        <command>
+            <proto>void <name>glPixelTransformParameterfvEXT</name></proto>
+            <param group="PixelTransformTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelTransformPNameEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPixelTransformParameteriEXT</name></proto>
+            <param group="PixelTransformTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelTransformPNameEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>param</name></param>
+            <glx type="render" opcode="16386"/>
+        </command>
+        <command>
+            <proto>void <name>glPixelTransformParameterivEXT</name></proto>
+            <param group="PixelTransformTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelTransformPNameEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="1">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPixelZoom</name></proto>
+            <param><ptype>GLfloat</ptype> <name>xfactor</name></param>
+            <param><ptype>GLfloat</ptype> <name>yfactor</name></param>
+            <glx type="render" opcode="165"/>
+        </command>
+        <command>
+            <proto>void <name>glPixelZoomxOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>xfactor</name></param>
+            <param><ptype>GLfixed</ptype> <name>yfactor</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glPointAlongPathNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param><ptype>GLsizei</ptype> <name>startSegment</name></param>
+            <param><ptype>GLsizei</ptype> <name>numSegments</name></param>
+            <param><ptype>GLfloat</ptype> <name>distance</name></param>
+            <param len="1"><ptype>GLfloat</ptype> *<name>x</name></param>
+            <param len="1"><ptype>GLfloat</ptype> *<name>y</name></param>
+            <param len="1"><ptype>GLfloat</ptype> *<name>tangentX</name></param>
+            <param len="1"><ptype>GLfloat</ptype> *<name>tangentY</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPointParameterf</name></proto>
+            <param group="PointParameterNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <glx type="render" opcode="2065"/>
+        </command>
+        <command>
+            <proto>void <name>glPointParameterfARB</name></proto>
+            <param group="PointParameterNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <alias name="glPointParameterf"/>
+            <glx type="render" opcode="2065"/>
+        </command>
+        <command>
+            <proto>void <name>glPointParameterfEXT</name></proto>
+            <param group="PointParameterNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <alias name="glPointParameterf"/>
+        </command>
+        <command>
+            <proto>void <name>glPointParameterfSGIS</name></proto>
+            <param group="PointParameterNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <alias name="glPointParameterf"/>
+        </command>
+        <command>
+            <proto>void <name>glPointParameterfv</name></proto>
+            <param group="PointParameterNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="render" opcode="2066"/>
+        </command>
+        <command>
+            <proto>void <name>glPointParameterfvARB</name></proto>
+            <param group="PointParameterNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <alias name="glPointParameterfv"/>
+            <glx type="render" opcode="2066"/>
+        </command>
+        <command>
+            <proto>void <name>glPointParameterfvEXT</name></proto>
+            <param group="PointParameterNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <alias name="glPointParameterfv"/>
+        </command>
+        <command>
+            <proto>void <name>glPointParameterfvSGIS</name></proto>
+            <param group="PointParameterNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <alias name="glPointParameterfv"/>
+        </command>
+        <command>
+            <proto>void <name>glPointParameteri</name></proto>
+            <param group="PointParameterNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>param</name></param>
+            <glx type="render" opcode="4221"/>
+        </command>
+        <command>
+            <proto>void <name>glPointParameteriNV</name></proto>
+            <param group="PointParameterNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>param</name></param>
+            <alias name="glPointParameteri"/>
+            <glx type="render" opcode="4221"/>
+        </command>
+        <command>
+            <proto>void <name>glPointParameteriv</name></proto>
+            <param group="PointParameterNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="render" opcode="4222"/>
+        </command>
+        <command>
+            <proto>void <name>glPointParameterivNV</name></proto>
+            <param group="PointParameterNameARB"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glPointParameteriv"/>
+            <glx type="render" opcode="4222"/>
+        </command>
+        <command>
+            <proto>void <name>glPointParameterx</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPointParameterxOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPointParameterxv</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPointParameterxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPointSize</name></proto>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>size</name></param>
+            <glx type="render" opcode="100"/>
+        </command>
+        <command>
+            <proto>void <name>glPointSizePointerOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPointSizex</name></proto>
+            <param><ptype>GLfixed</ptype> <name>size</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPointSizexOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>size</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glPollAsyncSGIX</name></proto>
+            <param len="1"><ptype>GLuint</ptype> *<name>markerp</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glPollInstrumentsSGIX</name></proto>
+            <param len="1"><ptype>GLint</ptype> *<name>marker_p</name></param>
+            <glx type="vendor" opcode="4104"/>
+        </command>
+        <command>
+            <proto>void <name>glPolygonMode</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="PolygonMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <glx type="render" opcode="101"/>
+        </command>
+        <command>
+            <proto>void <name>glPolygonOffset</name></proto>
+            <param><ptype>GLfloat</ptype> <name>factor</name></param>
+            <param><ptype>GLfloat</ptype> <name>units</name></param>
+            <glx type="render" opcode="192"/>
+        </command>
+        <command>
+            <proto>void <name>glPolygonOffsetEXT</name></proto>
+            <param><ptype>GLfloat</ptype> <name>factor</name></param>
+            <param><ptype>GLfloat</ptype> <name>bias</name></param>
+            <glx type="render" opcode="4098"/>
+        </command>
+        <command>
+            <proto>void <name>glPolygonOffsetx</name></proto>
+            <param><ptype>GLfixed</ptype> <name>factor</name></param>
+            <param><ptype>GLfixed</ptype> <name>units</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPolygonOffsetxOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>factor</name></param>
+            <param><ptype>GLfixed</ptype> <name>units</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPolygonStipple</name></proto>
+            <param len="COMPSIZE()">const <ptype>GLubyte</ptype> *<name>mask</name></param>
+            <glx type="render" opcode="102"/>
+            <glx type="render" opcode="326" name="glPolygonStipplePBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glPopAttrib</name></proto>
+            <glx type="render" opcode="141"/>
+        </command>
+        <command>
+            <proto>void <name>glPopClientAttrib</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glPopDebugGroup</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glPopDebugGroupKHR</name></proto>
+            <alias name="glPopDebugGroup"/>
+        </command>
+        <command>
+            <proto>void <name>glPopGroupMarkerEXT</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glPopMatrix</name></proto>
+            <glx type="render" opcode="183"/>
+        </command>
+        <command>
+            <proto>void <name>glPopName</name></proto>
+            <glx type="render" opcode="124"/>
+        </command>
+        <command>
+            <proto>void <name>glPresentFrameDualFillNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_slot</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>minPresentTime</name></param>
+            <param><ptype>GLuint</ptype> <name>beginPresentTimeId</name></param>
+            <param><ptype>GLuint</ptype> <name>presentDurationId</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLenum</ptype> <name>target0</name></param>
+            <param><ptype>GLuint</ptype> <name>fill0</name></param>
+            <param><ptype>GLenum</ptype> <name>target1</name></param>
+            <param><ptype>GLuint</ptype> <name>fill1</name></param>
+            <param><ptype>GLenum</ptype> <name>target2</name></param>
+            <param><ptype>GLuint</ptype> <name>fill2</name></param>
+            <param><ptype>GLenum</ptype> <name>target3</name></param>
+            <param><ptype>GLuint</ptype> <name>fill3</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPresentFrameKeyedNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_slot</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>minPresentTime</name></param>
+            <param><ptype>GLuint</ptype> <name>beginPresentTimeId</name></param>
+            <param><ptype>GLuint</ptype> <name>presentDurationId</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLenum</ptype> <name>target0</name></param>
+            <param><ptype>GLuint</ptype> <name>fill0</name></param>
+            <param><ptype>GLuint</ptype> <name>key0</name></param>
+            <param><ptype>GLenum</ptype> <name>target1</name></param>
+            <param><ptype>GLuint</ptype> <name>fill1</name></param>
+            <param><ptype>GLuint</ptype> <name>key1</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPrimitiveBoundingBoxEXT</name></proto>
+            <param><ptype>GLfloat</ptype> <name>minX</name></param>
+            <param><ptype>GLfloat</ptype> <name>minY</name></param>
+            <param><ptype>GLfloat</ptype> <name>minZ</name></param>
+            <param><ptype>GLfloat</ptype> <name>minW</name></param>
+            <param><ptype>GLfloat</ptype> <name>maxX</name></param>
+            <param><ptype>GLfloat</ptype> <name>maxY</name></param>
+            <param><ptype>GLfloat</ptype> <name>maxZ</name></param>
+            <param><ptype>GLfloat</ptype> <name>maxW</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPrimitiveRestartIndex</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPrimitiveRestartIndexNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPrimitiveRestartNV</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glPrioritizeTextures</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="Texture" len="n">const <ptype>GLuint</ptype> *<name>textures</name></param>
+            <param len="n">const <ptype>GLfloat</ptype> *<name>priorities</name></param>
+            <glx type="render" opcode="4118"/>
+        </command>
+        <command>
+            <proto>void <name>glPrioritizeTexturesEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="Texture" len="n">const <ptype>GLuint</ptype> *<name>textures</name></param>
+            <param group="ClampedFloat32" len="n">const <ptype>GLclampf</ptype> *<name>priorities</name></param>
+            <alias name="glPrioritizeTextures"/>
+            <glx type="render" opcode="4118"/>
+        </command>
+        <command>
+            <proto>void <name>glPrioritizeTexturesxOES</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>textures</name></param>
+            <param group="ClampedFixed" len="n">const <ptype>GLfixed</ptype> *<name>priorities</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramBinary</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLenum</ptype> <name>binaryFormat</name></param>
+            <param len="length">const void *<name>binary</name></param>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramBinaryOES</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLenum</ptype> <name>binaryFormat</name></param>
+            <param len="length">const void *<name>binary</name></param>
+            <param><ptype>GLint</ptype> <name>length</name></param>
+            <alias name="glProgramBinary"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramBufferParametersIivNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>bindingIndex</name></param>
+            <param><ptype>GLuint</ptype> <name>wordIndex</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramBufferParametersIuivNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>bindingIndex</name></param>
+            <param><ptype>GLuint</ptype> <name>wordIndex</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramBufferParametersfvNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>bindingIndex</name></param>
+            <param><ptype>GLuint</ptype> <name>wordIndex</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramEnvParameter4dARB</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <param><ptype>GLdouble</ptype> <name>w</name></param>
+            <vecequiv name="glProgramEnvParameter4dvARB"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramEnvParameter4dvARB</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLdouble</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramEnvParameter4fARB</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <param><ptype>GLfloat</ptype> <name>w</name></param>
+            <vecequiv name="glProgramEnvParameter4fvARB"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramEnvParameter4fvARB</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramEnvParameterI4iNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLint</ptype> <name>z</name></param>
+            <param><ptype>GLint</ptype> <name>w</name></param>
+            <vecequiv name="glProgramEnvParameterI4ivNV"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramEnvParameterI4ivNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramEnvParameterI4uiNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>x</name></param>
+            <param><ptype>GLuint</ptype> <name>y</name></param>
+            <param><ptype>GLuint</ptype> <name>z</name></param>
+            <param><ptype>GLuint</ptype> <name>w</name></param>
+            <vecequiv name="glProgramEnvParameterI4uivNV"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramEnvParameterI4uivNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramEnvParameters4fvEXT</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="render" opcode="4281"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramEnvParametersI4ivNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramEnvParametersI4uivNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramLocalParameter4dARB</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <param><ptype>GLdouble</ptype> <name>w</name></param>
+            <vecequiv name="glProgramLocalParameter4dvARB"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramLocalParameter4dvARB</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLdouble</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramLocalParameter4fARB</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <param><ptype>GLfloat</ptype> <name>w</name></param>
+            <vecequiv name="glProgramLocalParameter4fvARB"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramLocalParameter4fvARB</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramLocalParameterI4iNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLint</ptype> <name>z</name></param>
+            <param><ptype>GLint</ptype> <name>w</name></param>
+            <vecequiv name="glProgramLocalParameterI4ivNV"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramLocalParameterI4ivNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramLocalParameterI4uiNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>x</name></param>
+            <param><ptype>GLuint</ptype> <name>y</name></param>
+            <param><ptype>GLuint</ptype> <name>z</name></param>
+            <param><ptype>GLuint</ptype> <name>w</name></param>
+            <vecequiv name="glProgramLocalParameterI4uivNV"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramLocalParameterI4uivNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramLocalParameters4fvEXT</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="render" opcode="4282"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramLocalParametersI4ivNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramLocalParametersI4uivNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramNamedParameter4dNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLsizei</ptype> <name>len</name></param>
+            <param len="1">const <ptype>GLubyte</ptype> *<name>name</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <param><ptype>GLdouble</ptype> <name>w</name></param>
+            <vecequiv name="glProgramNamedParameter4dvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramNamedParameter4dvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLsizei</ptype> <name>len</name></param>
+            <param len="1">const <ptype>GLubyte</ptype> *<name>name</name></param>
+            <param len="4">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4219"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramNamedParameter4fNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLsizei</ptype> <name>len</name></param>
+            <param len="1">const <ptype>GLubyte</ptype> *<name>name</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <param><ptype>GLfloat</ptype> <name>w</name></param>
+            <vecequiv name="glProgramNamedParameter4fvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramNamedParameter4fvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLsizei</ptype> <name>len</name></param>
+            <param len="1">const <ptype>GLubyte</ptype> *<name>name</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4218"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramParameter4dNV</name></proto>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <param><ptype>GLdouble</ptype> <name>w</name></param>
+            <vecequiv name="glProgramParameter4dvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramParameter4dvNV</name></proto>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4185"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramParameter4fNV</name></proto>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <param><ptype>GLfloat</ptype> <name>w</name></param>
+            <vecequiv name="glProgramParameter4fvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramParameter4fvNV</name></proto>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4184"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramParameteri</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramParameterPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramParameteriARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramParameterPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>value</name></param>
+            <alias name="glProgramParameteri"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramParameteriEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param group="ProgramParameterPName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>value</name></param>
+            <alias name="glProgramParameteri"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramParameters4dvNV</name></proto>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4187"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramParameters4fvNV</name></proto>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4186"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramStringARB</name></proto>
+            <param group="ProgramTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="ProgramFormatARB"><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLsizei</ptype> <name>len</name></param>
+            <param len="len">const void *<name>string</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramSubroutineParametersuivNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1d</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLdouble</ptype> <name>v0</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1dEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="1">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1f</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLfloat</ptype> <name>v0</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1fEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLfloat</ptype> <name>v0</name></param>
+            <alias name="glProgramUniform1f"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="1">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1fvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glProgramUniform1fv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1i</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint</ptype> <name>v0</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1i64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>x</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1i64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1iEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint</ptype> <name>v0</name></param>
+            <alias name="glProgramUniform1i"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1iv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="1">const <ptype>GLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1ivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLint</ptype> *<name>value</name></param>
+            <alias name="glProgramUniform1iv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1ui</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>v0</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1ui64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>x</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1ui64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1uiEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>v0</name></param>
+            <alias name="glProgramUniform1ui"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1uiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform1uivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>value</name></param>
+            <alias name="glProgramUniform1uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2d</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLdouble</ptype> <name>v0</name></param>
+            <param><ptype>GLdouble</ptype> <name>v1</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2dEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="2">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2f</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLfloat</ptype> <name>v0</name></param>
+            <param><ptype>GLfloat</ptype> <name>v1</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2fEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLfloat</ptype> <name>v0</name></param>
+            <param><ptype>GLfloat</ptype> <name>v1</name></param>
+            <alias name="glProgramUniform2f"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="2">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2fvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*2">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glProgramUniform2fv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2i</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint</ptype> <name>v0</name></param>
+            <param><ptype>GLint</ptype> <name>v1</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2i64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2i64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*2">const <ptype>GLint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2iEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint</ptype> <name>v0</name></param>
+            <param><ptype>GLint</ptype> <name>v1</name></param>
+            <alias name="glProgramUniform2i"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2iv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="2">const <ptype>GLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2ivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*2">const <ptype>GLint</ptype> *<name>value</name></param>
+            <alias name="glProgramUniform2iv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2ui</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>v0</name></param>
+            <param><ptype>GLuint</ptype> <name>v1</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2ui64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2ui64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*2">const <ptype>GLuint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2uiEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>v0</name></param>
+            <param><ptype>GLuint</ptype> <name>v1</name></param>
+            <alias name="glProgramUniform2ui"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2uiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="2">const <ptype>GLuint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform2uivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*2">const <ptype>GLuint</ptype> *<name>value</name></param>
+            <alias name="glProgramUniform2uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3d</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLdouble</ptype> <name>v0</name></param>
+            <param><ptype>GLdouble</ptype> <name>v1</name></param>
+            <param><ptype>GLdouble</ptype> <name>v2</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3dEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="3">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3f</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLfloat</ptype> <name>v0</name></param>
+            <param><ptype>GLfloat</ptype> <name>v1</name></param>
+            <param><ptype>GLfloat</ptype> <name>v2</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3fEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLfloat</ptype> <name>v0</name></param>
+            <param><ptype>GLfloat</ptype> <name>v1</name></param>
+            <param><ptype>GLfloat</ptype> <name>v2</name></param>
+            <alias name="glProgramUniform3f"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3fvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*3">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glProgramUniform3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3i</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint</ptype> <name>v0</name></param>
+            <param><ptype>GLint</ptype> <name>v1</name></param>
+            <param><ptype>GLint</ptype> <name>v2</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3i64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>y</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3i64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*3">const <ptype>GLint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3iEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint</ptype> <name>v0</name></param>
+            <param><ptype>GLint</ptype> <name>v1</name></param>
+            <param><ptype>GLint</ptype> <name>v2</name></param>
+            <alias name="glProgramUniform3i"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3iv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="3">const <ptype>GLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3ivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*3">const <ptype>GLint</ptype> *<name>value</name></param>
+            <alias name="glProgramUniform3iv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3ui</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>v0</name></param>
+            <param><ptype>GLuint</ptype> <name>v1</name></param>
+            <param><ptype>GLuint</ptype> <name>v2</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3ui64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>y</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3ui64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*3">const <ptype>GLuint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3uiEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>v0</name></param>
+            <param><ptype>GLuint</ptype> <name>v1</name></param>
+            <param><ptype>GLuint</ptype> <name>v2</name></param>
+            <alias name="glProgramUniform3ui"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3uiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="3">const <ptype>GLuint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform3uivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*3">const <ptype>GLuint</ptype> *<name>value</name></param>
+            <alias name="glProgramUniform3uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4d</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLdouble</ptype> <name>v0</name></param>
+            <param><ptype>GLdouble</ptype> <name>v1</name></param>
+            <param><ptype>GLdouble</ptype> <name>v2</name></param>
+            <param><ptype>GLdouble</ptype> <name>v3</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4dEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <param><ptype>GLdouble</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="4">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4f</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLfloat</ptype> <name>v0</name></param>
+            <param><ptype>GLfloat</ptype> <name>v1</name></param>
+            <param><ptype>GLfloat</ptype> <name>v2</name></param>
+            <param><ptype>GLfloat</ptype> <name>v3</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4fEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLfloat</ptype> <name>v0</name></param>
+            <param><ptype>GLfloat</ptype> <name>v1</name></param>
+            <param><ptype>GLfloat</ptype> <name>v2</name></param>
+            <param><ptype>GLfloat</ptype> <name>v3</name></param>
+            <alias name="glProgramUniform4f"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4fvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glProgramUniform4fv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4i</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint</ptype> <name>v0</name></param>
+            <param><ptype>GLint</ptype> <name>v1</name></param>
+            <param><ptype>GLint</ptype> <name>v2</name></param>
+            <param><ptype>GLint</ptype> <name>v3</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4i64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>y</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>z</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4i64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4iEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint</ptype> <name>v0</name></param>
+            <param><ptype>GLint</ptype> <name>v1</name></param>
+            <param><ptype>GLint</ptype> <name>v2</name></param>
+            <param><ptype>GLint</ptype> <name>v3</name></param>
+            <alias name="glProgramUniform4i"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4iv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="4">const <ptype>GLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4ivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLint</ptype> *<name>value</name></param>
+            <alias name="glProgramUniform4iv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4ui</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>v0</name></param>
+            <param><ptype>GLuint</ptype> <name>v1</name></param>
+            <param><ptype>GLuint</ptype> <name>v2</name></param>
+            <param><ptype>GLuint</ptype> <name>v3</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4ui64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>y</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>z</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4ui64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLuint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4uiEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>v0</name></param>
+            <param><ptype>GLuint</ptype> <name>v1</name></param>
+            <param><ptype>GLuint</ptype> <name>v2</name></param>
+            <param><ptype>GLuint</ptype> <name>v3</name></param>
+            <alias name="glProgramUniform4ui"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4uiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="4">const <ptype>GLuint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniform4uivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLuint</ptype> *<name>value</name></param>
+            <alias name="glProgramUniform4uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformHandleui64ARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint64</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformHandleui64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint64</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformHandleui64vARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint64</ptype> *<name>values</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformHandleui64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint64</ptype> *<name>values</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix2dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="2">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix2dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix2fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="2">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix2fvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count*4">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glProgramUniformMatrix2fv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix2x3dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix2x3dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix2x3fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix2x3fvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count*6">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glProgramUniformMatrix2x3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix2x4dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix2x4dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix2x4fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix2x4fvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count*8">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glProgramUniformMatrix2x4fv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix3dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="3">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix3dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix3fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix3fvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count*9">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glProgramUniformMatrix3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix3x2dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix3x2dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix3x2fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix3x2fvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count*6">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glProgramUniformMatrix3x2fv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix3x4dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix3x4dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix3x4fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix3x4fvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count*12">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glProgramUniformMatrix3x4fv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix4dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="4">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix4dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix4fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix4fvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count*16">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glProgramUniformMatrix4fv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix4x2dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix4x2dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix4x2fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix4x2fvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count*8">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glProgramUniformMatrix4x2fv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix4x3dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix4x3dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix4x3fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformMatrix4x3fvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count*12">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glProgramUniformMatrix4x3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformui64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramUniformui64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProgramVertexLimitNV</name></proto>
+            <param group="ProgramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLint</ptype> <name>limit</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProvokingVertex</name></proto>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glProvokingVertexEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+            <alias name="glProvokingVertex"/>
+        </command>
+        <command>
+            <proto>void <name>glPushAttrib</name></proto>
+            <param group="AttribMask"><ptype>GLbitfield</ptype> <name>mask</name></param>
+            <glx type="render" opcode="142"/>
+        </command>
+        <command>
+            <proto>void <name>glPushClientAttrib</name></proto>
+            <param group="ClientAttribMask"><ptype>GLbitfield</ptype> <name>mask</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPushClientAttribDefaultEXT</name></proto>
+            <param group="ClientAttribMask"><ptype>GLbitfield</ptype> <name>mask</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPushDebugGroup</name></proto>
+            <param><ptype>GLenum</ptype> <name>source</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param len="COMPSIZE(message,length)">const <ptype>GLchar</ptype> *<name>message</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPushDebugGroupKHR</name></proto>
+            <param><ptype>GLenum</ptype> <name>source</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param>const <ptype>GLchar</ptype> *<name>message</name></param>
+            <alias name="glPushDebugGroup"/>
+        </command>
+        <command>
+            <proto>void <name>glPushGroupMarkerEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param>const <ptype>GLchar</ptype> *<name>marker</name></param>
+        </command>
+        <command>
+            <proto>void <name>glPushMatrix</name></proto>
+            <glx type="render" opcode="184"/>
+        </command>
+        <command>
+            <proto>void <name>glPushName</name></proto>
+            <param group="SelectName"><ptype>GLuint</ptype> <name>name</name></param>
+            <glx type="render" opcode="125"/>
+        </command>
+        <command>
+            <proto>void <name>glQueryCounter</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+        </command>
+        <command>
+            <proto>void <name>glQueryCounterEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <alias name="glQueryCounter"/>
+        </command>
+        <command>
+            <proto><ptype>GLbitfield</ptype> <name>glQueryMatrixxOES</name></proto>
+            <param len="16"><ptype>GLfixed</ptype> *<name>mantissa</name></param>
+            <param len="16"><ptype>GLint</ptype> *<name>exponent</name></param>
+        </command>
+        <command>
+            <proto>void <name>glQueryObjectParameteruiAMD</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="OcclusionQueryEventMaskAMD"><ptype>GLuint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos2d</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>x</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>y</name></param>
+            <vecequiv name="glRasterPos2dv"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos2dv</name></proto>
+            <param group="CoordD" len="2">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="33"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos2f</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>x</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>y</name></param>
+            <vecequiv name="glRasterPos2fv"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos2fv</name></proto>
+            <param group="CoordF" len="2">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="34"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos2i</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>y</name></param>
+            <vecequiv name="glRasterPos2iv"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos2iv</name></proto>
+            <param group="CoordI" len="2">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="35"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos2s</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>x</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>y</name></param>
+            <vecequiv name="glRasterPos2sv"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos2sv</name></proto>
+            <param group="CoordS" len="2">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="36"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos2xOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>x</name></param>
+            <param><ptype>GLfixed</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos2xvOES</name></proto>
+            <param len="2">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos3d</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>x</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>y</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>z</name></param>
+            <vecequiv name="glRasterPos3dv"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos3dv</name></proto>
+            <param group="CoordD" len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="37"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos3f</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>x</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>y</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>z</name></param>
+            <vecequiv name="glRasterPos3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos3fv</name></proto>
+            <param group="CoordF" len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="38"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos3i</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>y</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>z</name></param>
+            <vecequiv name="glRasterPos3iv"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos3iv</name></proto>
+            <param group="CoordI" len="3">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="39"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos3s</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>x</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>y</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>z</name></param>
+            <vecequiv name="glRasterPos3sv"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos3sv</name></proto>
+            <param group="CoordS" len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="40"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos3xOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>x</name></param>
+            <param><ptype>GLfixed</ptype> <name>y</name></param>
+            <param><ptype>GLfixed</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos3xvOES</name></proto>
+            <param len="3">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos4d</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>x</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>y</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>z</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>w</name></param>
+            <vecequiv name="glRasterPos4dv"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos4dv</name></proto>
+            <param group="CoordD" len="4">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="41"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos4f</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>x</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>y</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>z</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>w</name></param>
+            <vecequiv name="glRasterPos4fv"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos4fv</name></proto>
+            <param group="CoordF" len="4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="42"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos4i</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>y</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>z</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>w</name></param>
+            <vecequiv name="glRasterPos4iv"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos4iv</name></proto>
+            <param group="CoordI" len="4">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="43"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos4s</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>x</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>y</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>z</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>w</name></param>
+            <vecequiv name="glRasterPos4sv"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos4sv</name></proto>
+            <param group="CoordS" len="4">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="44"/>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos4xOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>x</name></param>
+            <param><ptype>GLfixed</ptype> <name>y</name></param>
+            <param><ptype>GLfixed</ptype> <name>z</name></param>
+            <param><ptype>GLfixed</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glRasterPos4xvOES</name></proto>
+            <param len="4">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReadBuffer</name></proto>
+            <param group="ReadBufferMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <glx type="render" opcode="171"/>
+        </command>
+        <command>
+            <proto>void <name>glReadBufferIndexedEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>src</name></param>
+            <param><ptype>GLint</ptype> <name>index</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReadBufferNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReadInstrumentsSGIX</name></proto>
+            <param><ptype>GLint</ptype> <name>marker</name></param>
+            <glx type="render" opcode="2077"/>
+        </command>
+        <command>
+            <proto>void <name>glReadPixels</name></proto>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height)">void *<name>pixels</name></param>
+            <glx type="single" opcode="111"/>
+            <glx type="render" opcode="345" name="glReadPixelsPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glReadnPixelsARB</name></proto>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize">void *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReadnPixelsEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param len="bufSize">void *<name>data</name></param>
+        </command>
+        <command>
+            <proto>void <name>glRectd</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>x1</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>y1</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>x2</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>y2</name></param>
+            <vecequiv name="glRectdv"/>
+        </command>
+        <command>
+            <proto>void <name>glRectdv</name></proto>
+            <param group="CoordD" len="2">const <ptype>GLdouble</ptype> *<name>v1</name></param>
+            <param group="CoordD" len="2">const <ptype>GLdouble</ptype> *<name>v2</name></param>
+            <glx type="render" opcode="45"/>
+        </command>
+        <command>
+            <proto>void <name>glRectf</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>x1</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>y1</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>x2</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>y2</name></param>
+            <vecequiv name="glRectfv"/>
+        </command>
+        <command>
+            <proto>void <name>glRectfv</name></proto>
+            <param group="CoordF" len="2">const <ptype>GLfloat</ptype> *<name>v1</name></param>
+            <param group="CoordF" len="2">const <ptype>GLfloat</ptype> *<name>v2</name></param>
+            <glx type="render" opcode="46"/>
+        </command>
+        <command>
+            <proto>void <name>glRecti</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>x1</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>y1</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>x2</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>y2</name></param>
+            <vecequiv name="glRectiv"/>
+        </command>
+        <command>
+            <proto>void <name>glRectiv</name></proto>
+            <param group="CoordI" len="2">const <ptype>GLint</ptype> *<name>v1</name></param>
+            <param group="CoordI" len="2">const <ptype>GLint</ptype> *<name>v2</name></param>
+            <glx type="render" opcode="47"/>
+        </command>
+        <command>
+            <proto>void <name>glRects</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>x1</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>y1</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>x2</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>y2</name></param>
+            <vecequiv name="glRectsv"/>
+        </command>
+        <command>
+            <proto>void <name>glRectsv</name></proto>
+            <param group="CoordS" len="2">const <ptype>GLshort</ptype> *<name>v1</name></param>
+            <param group="CoordS" len="2">const <ptype>GLshort</ptype> *<name>v2</name></param>
+            <glx type="render" opcode="48"/>
+        </command>
+        <command>
+            <proto>void <name>glRectxOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>x1</name></param>
+            <param><ptype>GLfixed</ptype> <name>y1</name></param>
+            <param><ptype>GLfixed</ptype> <name>x2</name></param>
+            <param><ptype>GLfixed</ptype> <name>y2</name></param>
+        </command>
+        <command>
+            <proto>void <name>glRectxvOES</name></proto>
+            <param len="2">const <ptype>GLfixed</ptype> *<name>v1</name></param>
+            <param len="2">const <ptype>GLfixed</ptype> *<name>v2</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReferencePlaneSGIX</name></proto>
+            <param len="4">const <ptype>GLdouble</ptype> *<name>equation</name></param>
+            <glx type="render" opcode="2071"/>
+        </command>
+        <command>
+            <proto>void <name>glReleaseShaderCompiler</name></proto>
+        </command>
+        <command>
+            <proto><ptype>GLint</ptype> <name>glRenderMode</name></proto>
+            <param group="RenderingMode"><ptype>GLenum</ptype> <name>mode</name></param>
+            <glx type="single" opcode="107"/>
+        </command>
+        <command>
+            <proto>void <name>glRenderbufferStorage</name></proto>
+            <param group="RenderbufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <glx type="render" opcode="4318"/>
+        </command>
+        <command>
+            <proto>void <name>glRenderbufferStorageEXT</name></proto>
+            <param group="RenderbufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <alias name="glRenderbufferStorage"/>
+            <glx type="render" opcode="4318"/>
+        </command>
+        <command>
+            <proto>void <name>glRenderbufferStorageMultisample</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <glx type="render" opcode="4331"/>
+        </command>
+        <command>
+            <proto>void <name>glRenderbufferStorageMultisampleANGLE</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glRenderbufferStorageMultisampleAPPLE</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glRenderbufferStorageMultisampleCoverageNV</name></proto>
+            <param group="RenderbufferTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>coverageSamples</name></param>
+            <param><ptype>GLsizei</ptype> <name>colorSamples</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glRenderbufferStorageMultisampleEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <alias name="glRenderbufferStorageMultisample"/>
+            <glx type="render" opcode="4331"/>
+        </command>
+        <command>
+            <proto>void <name>glRenderbufferStorageMultisampleIMG</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glRenderbufferStorageMultisampleNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <alias name="glRenderbufferStorageMultisample"/>
+        </command>
+        <command>
+            <proto>void <name>glRenderbufferStorageOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodePointerSUN</name></proto>
+            <param group="ReplacementCodeTypeSUN"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(type,stride)">const void **<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeubSUN</name></proto>
+            <param><ptype>GLubyte</ptype> <name>code</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeubvSUN</name></proto>
+            <param len="COMPSIZE()">const <ptype>GLubyte</ptype> *<name>code</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiColor3fVertex3fSUN</name></proto>
+            <param group="ReplacementCodeSUN"><ptype>GLuint</ptype> <name>rc</name></param>
+            <param><ptype>GLfloat</ptype> <name>r</name></param>
+            <param><ptype>GLfloat</ptype> <name>g</name></param>
+            <param><ptype>GLfloat</ptype> <name>b</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiColor3fVertex3fvSUN</name></proto>
+            <param group="ReplacementCodeSUN" len="1">const <ptype>GLuint</ptype> *<name>rc</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>c</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiColor4fNormal3fVertex3fSUN</name></proto>
+            <param group="ReplacementCodeSUN"><ptype>GLuint</ptype> <name>rc</name></param>
+            <param><ptype>GLfloat</ptype> <name>r</name></param>
+            <param><ptype>GLfloat</ptype> <name>g</name></param>
+            <param><ptype>GLfloat</ptype> <name>b</name></param>
+            <param><ptype>GLfloat</ptype> <name>a</name></param>
+            <param><ptype>GLfloat</ptype> <name>nx</name></param>
+            <param><ptype>GLfloat</ptype> <name>ny</name></param>
+            <param><ptype>GLfloat</ptype> <name>nz</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiColor4fNormal3fVertex3fvSUN</name></proto>
+            <param group="ReplacementCodeSUN" len="1">const <ptype>GLuint</ptype> *<name>rc</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>c</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>n</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiColor4ubVertex3fSUN</name></proto>
+            <param group="ReplacementCodeSUN"><ptype>GLuint</ptype> <name>rc</name></param>
+            <param><ptype>GLubyte</ptype> <name>r</name></param>
+            <param><ptype>GLubyte</ptype> <name>g</name></param>
+            <param><ptype>GLubyte</ptype> <name>b</name></param>
+            <param><ptype>GLubyte</ptype> <name>a</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiColor4ubVertex3fvSUN</name></proto>
+            <param group="ReplacementCodeSUN" len="1">const <ptype>GLuint</ptype> *<name>rc</name></param>
+            <param len="4">const <ptype>GLubyte</ptype> *<name>c</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiNormal3fVertex3fSUN</name></proto>
+            <param group="ReplacementCodeSUN"><ptype>GLuint</ptype> <name>rc</name></param>
+            <param><ptype>GLfloat</ptype> <name>nx</name></param>
+            <param><ptype>GLfloat</ptype> <name>ny</name></param>
+            <param><ptype>GLfloat</ptype> <name>nz</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiNormal3fVertex3fvSUN</name></proto>
+            <param group="ReplacementCodeSUN" len="1">const <ptype>GLuint</ptype> *<name>rc</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>n</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiSUN</name></proto>
+            <param><ptype>GLuint</ptype> <name>code</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN</name></proto>
+            <param group="ReplacementCodeSUN"><ptype>GLuint</ptype> <name>rc</name></param>
+            <param><ptype>GLfloat</ptype> <name>s</name></param>
+            <param><ptype>GLfloat</ptype> <name>t</name></param>
+            <param><ptype>GLfloat</ptype> <name>r</name></param>
+            <param><ptype>GLfloat</ptype> <name>g</name></param>
+            <param><ptype>GLfloat</ptype> <name>b</name></param>
+            <param><ptype>GLfloat</ptype> <name>a</name></param>
+            <param><ptype>GLfloat</ptype> <name>nx</name></param>
+            <param><ptype>GLfloat</ptype> <name>ny</name></param>
+            <param><ptype>GLfloat</ptype> <name>nz</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN</name></proto>
+            <param group="ReplacementCodeSUN" len="1">const <ptype>GLuint</ptype> *<name>rc</name></param>
+            <param len="2">const <ptype>GLfloat</ptype> *<name>tc</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>c</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>n</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN</name></proto>
+            <param group="ReplacementCodeSUN"><ptype>GLuint</ptype> <name>rc</name></param>
+            <param><ptype>GLfloat</ptype> <name>s</name></param>
+            <param><ptype>GLfloat</ptype> <name>t</name></param>
+            <param><ptype>GLfloat</ptype> <name>nx</name></param>
+            <param><ptype>GLfloat</ptype> <name>ny</name></param>
+            <param><ptype>GLfloat</ptype> <name>nz</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN</name></proto>
+            <param group="ReplacementCodeSUN" len="1">const <ptype>GLuint</ptype> *<name>rc</name></param>
+            <param len="2">const <ptype>GLfloat</ptype> *<name>tc</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>n</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiTexCoord2fVertex3fSUN</name></proto>
+            <param group="ReplacementCodeSUN"><ptype>GLuint</ptype> <name>rc</name></param>
+            <param><ptype>GLfloat</ptype> <name>s</name></param>
+            <param><ptype>GLfloat</ptype> <name>t</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiTexCoord2fVertex3fvSUN</name></proto>
+            <param group="ReplacementCodeSUN" len="1">const <ptype>GLuint</ptype> *<name>rc</name></param>
+            <param len="2">const <ptype>GLfloat</ptype> *<name>tc</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiVertex3fSUN</name></proto>
+            <param group="ReplacementCodeSUN"><ptype>GLuint</ptype> <name>rc</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuiVertex3fvSUN</name></proto>
+            <param group="ReplacementCodeSUN" len="1">const <ptype>GLuint</ptype> *<name>rc</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeuivSUN</name></proto>
+            <param len="COMPSIZE()">const <ptype>GLuint</ptype> *<name>code</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeusSUN</name></proto>
+            <param><ptype>GLushort</ptype> <name>code</name></param>
+        </command>
+        <command>
+            <proto>void <name>glReplacementCodeusvSUN</name></proto>
+            <param len="COMPSIZE()">const <ptype>GLushort</ptype> *<name>code</name></param>
+        </command>
+        <command>
+            <proto>void <name>glRequestResidentProgramsNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLuint</ptype> *<name>programs</name></param>
+            <glx type="render" opcode="4182"/>
+        </command>
+        <command>
+            <proto>void <name>glResetHistogram</name></proto>
+            <param group="HistogramTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <glx type="render" opcode="4112"/>
+        </command>
+        <command>
+            <proto>void <name>glResetHistogramEXT</name></proto>
+            <param group="HistogramTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <alias name="glResetHistogram"/>
+            <glx type="render" opcode="4112"/>
+        </command>
+        <command>
+            <proto>void <name>glResetMinmax</name></proto>
+            <param group="MinmaxTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <glx type="render" opcode="4113"/>
+        </command>
+        <command>
+            <proto>void <name>glResetMinmaxEXT</name></proto>
+            <param group="MinmaxTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <alias name="glResetMinmax"/>
+            <glx type="render" opcode="4113"/>
+        </command>
+        <command>
+            <proto>void <name>glResizeBuffersMESA</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glResolveMultisampleFramebufferAPPLE</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glResumeTransformFeedback</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glResumeTransformFeedbackNV</name></proto>
+            <alias name="glResumeTransformFeedback"/>
+        </command>
+        <command>
+            <proto>void <name>glRotated</name></proto>
+            <param><ptype>GLdouble</ptype> <name>angle</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <glx type="render" opcode="185"/>
+        </command>
+        <command>
+            <proto>void <name>glRotatef</name></proto>
+            <param><ptype>GLfloat</ptype> <name>angle</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <glx type="render" opcode="186"/>
+        </command>
+        <command>
+            <proto>void <name>glRotatex</name></proto>
+            <param><ptype>GLfixed</ptype> <name>angle</name></param>
+            <param><ptype>GLfixed</ptype> <name>x</name></param>
+            <param><ptype>GLfixed</ptype> <name>y</name></param>
+            <param><ptype>GLfixed</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glRotatexOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>angle</name></param>
+            <param><ptype>GLfixed</ptype> <name>x</name></param>
+            <param><ptype>GLfixed</ptype> <name>y</name></param>
+            <param><ptype>GLfixed</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSampleCoverage</name></proto>
+            <param><ptype>GLfloat</ptype> <name>value</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>invert</name></param>
+            <glx type="render" opcode="229"/>
+        </command>
+        <command>
+            <proto>void <name>glSampleCoverageARB</name></proto>
+            <param><ptype>GLfloat</ptype> <name>value</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>invert</name></param>
+            <alias name="glSampleCoverage"/>
+        </command>
+        <command>
+            <proto>void <name>glSampleCoverageOES</name></proto>
+            <param group="ClampedFixed"><ptype>GLfixed</ptype> <name>value</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>invert</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSampleCoveragex</name></proto>
+            <param><ptype>GLclampx</ptype> <name>value</name></param>
+            <param><ptype>GLboolean</ptype> <name>invert</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSampleCoveragexOES</name></proto>
+            <param><ptype>GLclampx</ptype> <name>value</name></param>
+            <param><ptype>GLboolean</ptype> <name>invert</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSampleMapATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>dst</name></param>
+            <param><ptype>GLuint</ptype> <name>interp</name></param>
+            <param group="SwizzleOpATI"><ptype>GLenum</ptype> <name>swizzle</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSampleMaskEXT</name></proto>
+            <param group="ClampedFloat32"><ptype>GLclampf</ptype> <name>value</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>invert</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSampleMaskIndexedNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="SampleMaskNV"><ptype>GLbitfield</ptype> <name>mask</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSampleMaskSGIS</name></proto>
+            <param group="ClampedFloat32"><ptype>GLclampf</ptype> <name>value</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>invert</name></param>
+            <alias name="glSampleMaskEXT"/>
+            <glx type="render" opcode="2048"/>
+        </command>
+        <command>
+            <proto>void <name>glSampleMaski</name></proto>
+            <param><ptype>GLuint</ptype> <name>maskNumber</name></param>
+            <param><ptype>GLbitfield</ptype> <name>mask</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSamplePatternEXT</name></proto>
+            <param group="SamplePatternEXT"><ptype>GLenum</ptype> <name>pattern</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSamplePatternSGIS</name></proto>
+            <param group="SamplePatternSGIS"><ptype>GLenum</ptype> <name>pattern</name></param>
+            <alias name="glSamplePatternEXT"/>
+            <glx type="render" opcode="2049"/>
+        </command>
+        <command>
+            <proto>void <name>glSamplerParameterIiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSamplerParameterIivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>param</name></param>
+            <alias name="glSamplerParameterIiv"/>
+        </command>
+        <command>
+            <proto>void <name>glSamplerParameterIuiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLuint</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSamplerParameterIuivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLuint</ptype> *<name>param</name></param>
+            <alias name="glSamplerParameterIuiv"/>
+        </command>
+        <command>
+            <proto>void <name>glSamplerParameterf</name></proto>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfloat</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSamplerParameterfv</name></proto>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSamplerParameteri</name></proto>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSamplerParameteriv</name></proto>
+            <param><ptype>GLuint</ptype> <name>sampler</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glScaled</name></proto>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <glx type="render" opcode="187"/>
+        </command>
+        <command>
+            <proto>void <name>glScalef</name></proto>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <glx type="render" opcode="188"/>
+        </command>
+        <command>
+            <proto>void <name>glScalex</name></proto>
+            <param><ptype>GLfixed</ptype> <name>x</name></param>
+            <param><ptype>GLfixed</ptype> <name>y</name></param>
+            <param><ptype>GLfixed</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glScalexOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>x</name></param>
+            <param><ptype>GLfixed</ptype> <name>y</name></param>
+            <param><ptype>GLfixed</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glScissor</name></proto>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <glx type="render" opcode="103"/>
+        </command>
+        <command>
+            <proto>void <name>glScissorArrayv</name></proto>
+            <param><ptype>GLuint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="COMPSIZE(count)">const <ptype>GLint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glScissorIndexed</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>left</name></param>
+            <param><ptype>GLint</ptype> <name>bottom</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glScissorIndexedv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3b</name></proto>
+            <param group="ColorB"><ptype>GLbyte</ptype> <name>red</name></param>
+            <param group="ColorB"><ptype>GLbyte</ptype> <name>green</name></param>
+            <param group="ColorB"><ptype>GLbyte</ptype> <name>blue</name></param>
+            <vecequiv name="glSecondaryColor3bv"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3bEXT</name></proto>
+            <param group="ColorB"><ptype>GLbyte</ptype> <name>red</name></param>
+            <param group="ColorB"><ptype>GLbyte</ptype> <name>green</name></param>
+            <param group="ColorB"><ptype>GLbyte</ptype> <name>blue</name></param>
+            <alias name="glSecondaryColor3b"/>
+            <vecequiv name="glSecondaryColor3bvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3bv</name></proto>
+            <param group="ColorB" len="3">const <ptype>GLbyte</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4126"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3bvEXT</name></proto>
+            <param group="ColorB" len="3">const <ptype>GLbyte</ptype> *<name>v</name></param>
+            <alias name="glSecondaryColor3bv"/>
+            <glx type="render" opcode="4126"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3d</name></proto>
+            <param group="ColorD"><ptype>GLdouble</ptype> <name>red</name></param>
+            <param group="ColorD"><ptype>GLdouble</ptype> <name>green</name></param>
+            <param group="ColorD"><ptype>GLdouble</ptype> <name>blue</name></param>
+            <vecequiv name="glSecondaryColor3dv"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3dEXT</name></proto>
+            <param group="ColorD"><ptype>GLdouble</ptype> <name>red</name></param>
+            <param group="ColorD"><ptype>GLdouble</ptype> <name>green</name></param>
+            <param group="ColorD"><ptype>GLdouble</ptype> <name>blue</name></param>
+            <alias name="glSecondaryColor3d"/>
+            <vecequiv name="glSecondaryColor3dvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3dv</name></proto>
+            <param group="ColorD" len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4130"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3dvEXT</name></proto>
+            <param group="ColorD" len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glSecondaryColor3dv"/>
+            <glx type="render" opcode="4130"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3f</name></proto>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>red</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>green</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>blue</name></param>
+            <vecequiv name="glSecondaryColor3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3fEXT</name></proto>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>red</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>green</name></param>
+            <param group="ColorF"><ptype>GLfloat</ptype> <name>blue</name></param>
+            <alias name="glSecondaryColor3f"/>
+            <vecequiv name="glSecondaryColor3fvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3fv</name></proto>
+            <param group="ColorF" len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4129"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3fvEXT</name></proto>
+            <param group="ColorF" len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glSecondaryColor3fv"/>
+            <glx type="render" opcode="4129"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3hNV</name></proto>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>red</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>green</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>blue</name></param>
+            <vecequiv name="glSecondaryColor3hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3hvNV</name></proto>
+            <param group="Half16NV" len="3">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4255"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3i</name></proto>
+            <param group="ColorI"><ptype>GLint</ptype> <name>red</name></param>
+            <param group="ColorI"><ptype>GLint</ptype> <name>green</name></param>
+            <param group="ColorI"><ptype>GLint</ptype> <name>blue</name></param>
+            <vecequiv name="glSecondaryColor3iv"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3iEXT</name></proto>
+            <param group="ColorI"><ptype>GLint</ptype> <name>red</name></param>
+            <param group="ColorI"><ptype>GLint</ptype> <name>green</name></param>
+            <param group="ColorI"><ptype>GLint</ptype> <name>blue</name></param>
+            <alias name="glSecondaryColor3i"/>
+            <vecequiv name="glSecondaryColor3ivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3iv</name></proto>
+            <param group="ColorI" len="3">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4128"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3ivEXT</name></proto>
+            <param group="ColorI" len="3">const <ptype>GLint</ptype> *<name>v</name></param>
+            <alias name="glSecondaryColor3iv"/>
+            <glx type="render" opcode="4128"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3s</name></proto>
+            <param group="ColorS"><ptype>GLshort</ptype> <name>red</name></param>
+            <param group="ColorS"><ptype>GLshort</ptype> <name>green</name></param>
+            <param group="ColorS"><ptype>GLshort</ptype> <name>blue</name></param>
+            <vecequiv name="glSecondaryColor3sv"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3sEXT</name></proto>
+            <param group="ColorS"><ptype>GLshort</ptype> <name>red</name></param>
+            <param group="ColorS"><ptype>GLshort</ptype> <name>green</name></param>
+            <param group="ColorS"><ptype>GLshort</ptype> <name>blue</name></param>
+            <alias name="glSecondaryColor3s"/>
+            <vecequiv name="glSecondaryColor3svEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3sv</name></proto>
+            <param group="ColorS" len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4127"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3svEXT</name></proto>
+            <param group="ColorS" len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glSecondaryColor3sv"/>
+            <glx type="render" opcode="4127"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3ub</name></proto>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>red</name></param>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>green</name></param>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>blue</name></param>
+            <vecequiv name="glSecondaryColor3ubv"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3ubEXT</name></proto>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>red</name></param>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>green</name></param>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>blue</name></param>
+            <alias name="glSecondaryColor3ub"/>
+            <vecequiv name="glSecondaryColor3ubvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3ubv</name></proto>
+            <param group="ColorUB" len="3">const <ptype>GLubyte</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4131"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3ubvEXT</name></proto>
+            <param group="ColorUB" len="3">const <ptype>GLubyte</ptype> *<name>v</name></param>
+            <alias name="glSecondaryColor3ubv"/>
+            <glx type="render" opcode="4131"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3ui</name></proto>
+            <param group="ColorUI"><ptype>GLuint</ptype> <name>red</name></param>
+            <param group="ColorUI"><ptype>GLuint</ptype> <name>green</name></param>
+            <param group="ColorUI"><ptype>GLuint</ptype> <name>blue</name></param>
+            <vecequiv name="glSecondaryColor3uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3uiEXT</name></proto>
+            <param group="ColorUI"><ptype>GLuint</ptype> <name>red</name></param>
+            <param group="ColorUI"><ptype>GLuint</ptype> <name>green</name></param>
+            <param group="ColorUI"><ptype>GLuint</ptype> <name>blue</name></param>
+            <alias name="glSecondaryColor3ui"/>
+            <vecequiv name="glSecondaryColor3uivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3uiv</name></proto>
+            <param group="ColorUI" len="3">const <ptype>GLuint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4133"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3uivEXT</name></proto>
+            <param group="ColorUI" len="3">const <ptype>GLuint</ptype> *<name>v</name></param>
+            <alias name="glSecondaryColor3uiv"/>
+            <glx type="render" opcode="4133"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3us</name></proto>
+            <param group="ColorUS"><ptype>GLushort</ptype> <name>red</name></param>
+            <param group="ColorUS"><ptype>GLushort</ptype> <name>green</name></param>
+            <param group="ColorUS"><ptype>GLushort</ptype> <name>blue</name></param>
+            <vecequiv name="glSecondaryColor3usv"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3usEXT</name></proto>
+            <param group="ColorUS"><ptype>GLushort</ptype> <name>red</name></param>
+            <param group="ColorUS"><ptype>GLushort</ptype> <name>green</name></param>
+            <param group="ColorUS"><ptype>GLushort</ptype> <name>blue</name></param>
+            <alias name="glSecondaryColor3us"/>
+            <vecequiv name="glSecondaryColor3usvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3usv</name></proto>
+            <param group="ColorUS" len="3">const <ptype>GLushort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4132"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColor3usvEXT</name></proto>
+            <param group="ColorUS" len="3">const <ptype>GLushort</ptype> *<name>v</name></param>
+            <alias name="glSecondaryColor3usv"/>
+            <glx type="render" opcode="4132"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColorFormatNV</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColorP3ui</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>color</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColorP3uiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>color</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColorPointer</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="ColorPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(size,type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColorPointerEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="ColorPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(size,type,stride)">const void *<name>pointer</name></param>
+            <alias name="glSecondaryColorPointer"/>
+        </command>
+        <command>
+            <proto>void <name>glSecondaryColorPointerListIBM</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="SecondaryColorPointerTypeIBM"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLint</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(size,type,stride)">const void **<name>pointer</name></param>
+            <param><ptype>GLint</ptype> <name>ptrstride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSelectBuffer</name></proto>
+            <param><ptype>GLsizei</ptype> <name>size</name></param>
+            <param group="SelectName" len="size"><ptype>GLuint</ptype> *<name>buffer</name></param>
+            <glx type="single" opcode="106"/>
+        </command>
+        <command>
+            <proto>void <name>glSelectPerfMonitorCountersAMD</name></proto>
+            <param><ptype>GLuint</ptype> <name>monitor</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>enable</name></param>
+            <param><ptype>GLuint</ptype> <name>group</name></param>
+            <param><ptype>GLint</ptype> <name>numCounters</name></param>
+            <param len="numCounters"><ptype>GLuint</ptype> *<name>counterList</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSeparableFilter2D</name></proto>
+            <param group="SeparableTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(target,format,type,width)">const void *<name>row</name></param>
+            <param len="COMPSIZE(target,format,type,height)">const void *<name>column</name></param>
+            <glx type="render" opcode="4109"/>
+            <glx type="render" opcode="327" name="glSeparableFilter2DPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glSeparableFilter2DEXT</name></proto>
+            <param group="SeparableTargetEXT"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(target,format,type,width)">const void *<name>row</name></param>
+            <param len="COMPSIZE(target,format,type,height)">const void *<name>column</name></param>
+            <alias name="glSeparableFilter2D"/>
+            <glx type="render" opcode="4109"/>
+        </command>
+        <command>
+            <proto>void <name>glSetFenceAPPLE</name></proto>
+            <param group="FenceNV"><ptype>GLuint</ptype> <name>fence</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSetFenceNV</name></proto>
+            <param group="FenceNV"><ptype>GLuint</ptype> <name>fence</name></param>
+            <param group="FenceConditionNV"><ptype>GLenum</ptype> <name>condition</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSetFragmentShaderConstantATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>dst</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSetInvariantEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="ScalarType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(id,type)">const void *<name>addr</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSetLocalConstantEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="ScalarType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(id,type)">const void *<name>addr</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSetMultisamplefvAMD</name></proto>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLfloat</ptype> *<name>val</name></param>
+        </command>
+        <command>
+            <proto>void <name>glShadeModel</name></proto>
+            <param group="ShadingModel"><ptype>GLenum</ptype> <name>mode</name></param>
+            <glx type="render" opcode="104"/>
+        </command>
+        <command>
+            <proto>void <name>glShaderBinary</name></proto>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>shaders</name></param>
+            <param><ptype>GLenum</ptype> <name>binaryformat</name></param>
+            <param len="length">const void *<name>binary</name></param>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+        </command>
+        <command>
+            <proto>void <name>glShaderOp1EXT</name></proto>
+            <param group="VertexShaderOpEXT"><ptype>GLenum</ptype> <name>op</name></param>
+            <param><ptype>GLuint</ptype> <name>res</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1</name></param>
+        </command>
+        <command>
+            <proto>void <name>glShaderOp2EXT</name></proto>
+            <param group="VertexShaderOpEXT"><ptype>GLenum</ptype> <name>op</name></param>
+            <param><ptype>GLuint</ptype> <name>res</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1</name></param>
+            <param><ptype>GLuint</ptype> <name>arg2</name></param>
+        </command>
+        <command>
+            <proto>void <name>glShaderOp3EXT</name></proto>
+            <param group="VertexShaderOpEXT"><ptype>GLenum</ptype> <name>op</name></param>
+            <param><ptype>GLuint</ptype> <name>res</name></param>
+            <param><ptype>GLuint</ptype> <name>arg1</name></param>
+            <param><ptype>GLuint</ptype> <name>arg2</name></param>
+            <param><ptype>GLuint</ptype> <name>arg3</name></param>
+        </command>
+        <command>
+            <proto>void <name>glShaderSource</name></proto>
+            <param><ptype>GLuint</ptype> <name>shader</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLchar</ptype> *const*<name>string</name></param>
+            <param len="count">const <ptype>GLint</ptype> *<name>length</name></param>
+        </command>
+        <command>
+            <proto>void <name>glShaderSourceARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>shaderObj</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLcharARB</ptype> **<name>string</name></param>
+            <param len="count">const <ptype>GLint</ptype> *<name>length</name></param>
+            <alias name="glShaderSource"/>
+        </command>
+        <command>
+            <proto>void <name>glShaderStorageBlockBinding</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>storageBlockIndex</name></param>
+            <param><ptype>GLuint</ptype> <name>storageBlockBinding</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSharpenTexFuncSGIS</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n*2">const <ptype>GLfloat</ptype> *<name>points</name></param>
+            <glx type="render" opcode="2052"/>
+        </command>
+        <command>
+            <proto>void <name>glSpriteParameterfSGIX</name></proto>
+            <param group="SpriteParameterNameSGIX"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <glx type="render" opcode="2060"/>
+        </command>
+        <command>
+            <proto>void <name>glSpriteParameterfvSGIX</name></proto>
+            <param group="SpriteParameterNameSGIX"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="render" opcode="2061"/>
+        </command>
+        <command>
+            <proto>void <name>glSpriteParameteriSGIX</name></proto>
+            <param group="SpriteParameterNameSGIX"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+            <glx type="render" opcode="2062"/>
+        </command>
+        <command>
+            <proto>void <name>glSpriteParameterivSGIX</name></proto>
+            <param group="SpriteParameterNameSGIX"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="render" opcode="2063"/>
+        </command>
+        <command>
+            <proto>void <name>glStartInstrumentsSGIX</name></proto>
+            <glx type="render" opcode="2069"/>
+        </command>
+        <command>
+            <proto>void <name>glStartTilingQCOM</name></proto>
+            <param><ptype>GLuint</ptype> <name>x</name></param>
+            <param><ptype>GLuint</ptype> <name>y</name></param>
+            <param><ptype>GLuint</ptype> <name>width</name></param>
+            <param><ptype>GLuint</ptype> <name>height</name></param>
+            <param><ptype>GLbitfield</ptype> <name>preserveMask</name></param>
+        </command>
+        <command>
+            <proto>void <name>glStencilClearTagEXT</name></proto>
+            <param><ptype>GLsizei</ptype> <name>stencilTagBits</name></param>
+            <param><ptype>GLuint</ptype> <name>stencilClearTag</name></param>
+            <glx type="render" opcode="4223"/>
+        </command>
+        <command>
+            <proto>void <name>glStencilFillPathInstancedNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>numPaths</name></param>
+            <param group="PathElementType"><ptype>GLenum</ptype> <name>pathNameType</name></param>
+            <param group="PathElement" len="COMPSIZE(numPaths,pathNameType,paths)">const void *<name>paths</name></param>
+            <param group="Path"><ptype>GLuint</ptype> <name>pathBase</name></param>
+            <param group="PathFillMode"><ptype>GLenum</ptype> <name>fillMode</name></param>
+            <param group="MaskedStencilValue"><ptype>GLuint</ptype> <name>mask</name></param>
+            <param group="PathTransformType"><ptype>GLenum</ptype> <name>transformType</name></param>
+            <param len="COMPSIZE(numPaths,transformType)">const <ptype>GLfloat</ptype> *<name>transformValues</name></param>
+        </command>
+        <command>
+            <proto>void <name>glStencilFillPathNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param group="PathFillMode"><ptype>GLenum</ptype> <name>fillMode</name></param>
+            <param group="MaskedStencilValue"><ptype>GLuint</ptype> <name>mask</name></param>
+        </command>
+        <command>
+            <proto>void <name>glStencilFunc</name></proto>
+            <param group="StencilFunction"><ptype>GLenum</ptype> <name>func</name></param>
+            <param group="StencilValue"><ptype>GLint</ptype> <name>ref</name></param>
+            <param group="MaskedStencilValue"><ptype>GLuint</ptype> <name>mask</name></param>
+            <glx type="render" opcode="162"/>
+        </command>
+        <command>
+            <proto>void <name>glStencilFuncSeparate</name></proto>
+            <param group="StencilFaceDirection"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="StencilFunction"><ptype>GLenum</ptype> <name>func</name></param>
+            <param group="StencilValue"><ptype>GLint</ptype> <name>ref</name></param>
+            <param group="MaskedStencilValue"><ptype>GLuint</ptype> <name>mask</name></param>
+        </command>
+        <command>
+            <proto>void <name>glStencilFuncSeparateATI</name></proto>
+            <param group="StencilFunction"><ptype>GLenum</ptype> <name>frontfunc</name></param>
+            <param group="StencilFunction"><ptype>GLenum</ptype> <name>backfunc</name></param>
+            <param group="ClampedStencilValue"><ptype>GLint</ptype> <name>ref</name></param>
+            <param group="MaskedStencilValue"><ptype>GLuint</ptype> <name>mask</name></param>
+        </command>
+        <command>
+            <proto>void <name>glStencilMask</name></proto>
+            <param group="MaskedStencilValue"><ptype>GLuint</ptype> <name>mask</name></param>
+            <glx type="render" opcode="133"/>
+        </command>
+        <command>
+            <proto>void <name>glStencilMaskSeparate</name></proto>
+            <param group="StencilFaceDirection"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="MaskedStencilValue"><ptype>GLuint</ptype> <name>mask</name></param>
+        </command>
+        <command>
+            <proto>void <name>glStencilOp</name></proto>
+            <param group="StencilOp"><ptype>GLenum</ptype> <name>fail</name></param>
+            <param group="StencilOp"><ptype>GLenum</ptype> <name>zfail</name></param>
+            <param group="StencilOp"><ptype>GLenum</ptype> <name>zpass</name></param>
+            <glx type="render" opcode="163"/>
+        </command>
+        <command>
+            <proto>void <name>glStencilOpSeparate</name></proto>
+            <param group="StencilFaceDirection"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="StencilOp"><ptype>GLenum</ptype> <name>sfail</name></param>
+            <param group="StencilOp"><ptype>GLenum</ptype> <name>dpfail</name></param>
+            <param group="StencilOp"><ptype>GLenum</ptype> <name>dppass</name></param>
+        </command>
+        <command>
+            <proto>void <name>glStencilOpSeparateATI</name></proto>
+            <param group="StencilFaceDirection"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="StencilOp"><ptype>GLenum</ptype> <name>sfail</name></param>
+            <param group="StencilOp"><ptype>GLenum</ptype> <name>dpfail</name></param>
+            <param group="StencilOp"><ptype>GLenum</ptype> <name>dppass</name></param>
+            <alias name="glStencilOpSeparate"/>
+        </command>
+        <command>
+            <proto>void <name>glStencilOpValueAMD</name></proto>
+            <param group="StencilFaceDirection"><ptype>GLenum</ptype> <name>face</name></param>
+            <param><ptype>GLuint</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glStencilStrokePathInstancedNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>numPaths</name></param>
+            <param group="PathElementType"><ptype>GLenum</ptype> <name>pathNameType</name></param>
+            <param group="PathElement" len="COMPSIZE(numPaths,pathNameType,paths)">const void *<name>paths</name></param>
+            <param group="Path"><ptype>GLuint</ptype> <name>pathBase</name></param>
+            <param group="StencilValue"><ptype>GLint</ptype> <name>reference</name></param>
+            <param group="MaskedStencilValue"><ptype>GLuint</ptype> <name>mask</name></param>
+            <param group="PathTransformType"><ptype>GLenum</ptype> <name>transformType</name></param>
+            <param len="COMPSIZE(numPaths,transformType)">const <ptype>GLfloat</ptype> *<name>transformValues</name></param>
+        </command>
+        <command>
+            <proto>void <name>glStencilStrokePathNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>path</name></param>
+            <param group="StencilValue"><ptype>GLint</ptype> <name>reference</name></param>
+            <param group="MaskedStencilValue"><ptype>GLuint</ptype> <name>mask</name></param>
+        </command>
+        <command>
+            <proto>void <name>glStopInstrumentsSGIX</name></proto>
+            <param><ptype>GLint</ptype> <name>marker</name></param>
+            <glx type="render" opcode="2070"/>
+        </command>
+        <command>
+            <proto>void <name>glStringMarkerGREMEDY</name></proto>
+            <param><ptype>GLsizei</ptype> <name>len</name></param>
+            <param len="len">const void *<name>string</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSwizzleEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>res</name></param>
+            <param><ptype>GLuint</ptype> <name>in</name></param>
+            <param group="VertexShaderCoordOutEXT"><ptype>GLenum</ptype> <name>outX</name></param>
+            <param group="VertexShaderCoordOutEXT"><ptype>GLenum</ptype> <name>outY</name></param>
+            <param group="VertexShaderCoordOutEXT"><ptype>GLenum</ptype> <name>outZ</name></param>
+            <param group="VertexShaderCoordOutEXT"><ptype>GLenum</ptype> <name>outW</name></param>
+        </command>
+        <command>
+            <proto>void <name>glSyncTextureINTEL</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTagSampleBufferSGIX</name></proto>
+            <glx type="render" opcode="2050"/>
+        </command>
+        <command>
+            <proto>void <name>glTangent3bEXT</name></proto>
+            <param><ptype>GLbyte</ptype> <name>tx</name></param>
+            <param><ptype>GLbyte</ptype> <name>ty</name></param>
+            <param><ptype>GLbyte</ptype> <name>tz</name></param>
+            <vecequiv name="glTangent3bvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glTangent3bvEXT</name></proto>
+            <param len="3">const <ptype>GLbyte</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTangent3dEXT</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>tx</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>ty</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>tz</name></param>
+            <vecequiv name="glTangent3dvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glTangent3dvEXT</name></proto>
+            <param group="CoordD" len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTangent3fEXT</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>tx</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>ty</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>tz</name></param>
+            <vecequiv name="glTangent3fvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glTangent3fvEXT</name></proto>
+            <param group="CoordF" len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTangent3iEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>tx</name></param>
+            <param><ptype>GLint</ptype> <name>ty</name></param>
+            <param><ptype>GLint</ptype> <name>tz</name></param>
+            <vecequiv name="glTangent3ivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glTangent3ivEXT</name></proto>
+            <param len="3">const <ptype>GLint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTangent3sEXT</name></proto>
+            <param><ptype>GLshort</ptype> <name>tx</name></param>
+            <param><ptype>GLshort</ptype> <name>ty</name></param>
+            <param><ptype>GLshort</ptype> <name>tz</name></param>
+            <vecequiv name="glTangent3svEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glTangent3svEXT</name></proto>
+            <param len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTangentPointerEXT</name></proto>
+            <param group="TangentPointerTypeEXT"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTbufferMask3DFX</name></proto>
+            <param><ptype>GLuint</ptype> <name>mask</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTessellationFactorAMD</name></proto>
+            <param><ptype>GLfloat</ptype> <name>factor</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTessellationModeAMD</name></proto>
+            <param><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glTestFenceAPPLE</name></proto>
+            <param group="FenceNV"><ptype>GLuint</ptype> <name>fence</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glTestFenceNV</name></proto>
+            <param group="FenceNV"><ptype>GLuint</ptype> <name>fence</name></param>
+            <glx type="vendor" opcode="1279"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glTestObjectAPPLE</name></proto>
+            <param group="ObjectTypeAPPLE"><ptype>GLenum</ptype> <name>object</name></param>
+            <param><ptype>GLuint</ptype> <name>name</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexBuffer</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexBufferARB</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <alias name="glTexBuffer"/>
+        </command>
+        <command>
+            <proto>void <name>glTexBufferEXT</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <alias name="glTexBuffer"/>
+        </command>
+        <command>
+            <proto>void <name>glTexBufferRange</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>size</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexBufferRangeEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>size</name></param>
+            <alias name="glTexBufferRange"/>
+        </command>
+        <command>
+            <proto>void <name>glTexBumpParameterfvATI</name></proto>
+            <param group="TexBumpParameterATI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexBumpParameterivATI</name></proto>
+            <param group="TexBumpParameterATI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord1bOES</name></proto>
+            <param><ptype>GLbyte</ptype> <name>s</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord1bvOES</name></proto>
+            <param len="1">const <ptype>GLbyte</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord1d</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>s</name></param>
+            <vecequiv name="glTexCoord1dv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord1dv</name></proto>
+            <param group="CoordD" len="1">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="49"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord1f</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>s</name></param>
+            <vecequiv name="glTexCoord1fv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord1fv</name></proto>
+            <param group="CoordF" len="1">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="50"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord1hNV</name></proto>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>s</name></param>
+            <vecequiv name="glTexCoord1hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord1hvNV</name></proto>
+            <param group="Half16NV" len="1">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4246"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord1i</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>s</name></param>
+            <vecequiv name="glTexCoord1iv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord1iv</name></proto>
+            <param group="CoordI" len="1">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="51"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord1s</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>s</name></param>
+            <vecequiv name="glTexCoord1sv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord1sv</name></proto>
+            <param group="CoordS" len="1">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="52"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord1xOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>s</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord1xvOES</name></proto>
+            <param len="1">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2bOES</name></proto>
+            <param><ptype>GLbyte</ptype> <name>s</name></param>
+            <param><ptype>GLbyte</ptype> <name>t</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2bvOES</name></proto>
+            <param len="2">const <ptype>GLbyte</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2d</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>s</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>t</name></param>
+            <vecequiv name="glTexCoord2dv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2dv</name></proto>
+            <param group="CoordD" len="2">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="53"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2f</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>s</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>t</name></param>
+            <vecequiv name="glTexCoord2fv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2fColor3fVertex3fSUN</name></proto>
+            <param><ptype>GLfloat</ptype> <name>s</name></param>
+            <param><ptype>GLfloat</ptype> <name>t</name></param>
+            <param><ptype>GLfloat</ptype> <name>r</name></param>
+            <param><ptype>GLfloat</ptype> <name>g</name></param>
+            <param><ptype>GLfloat</ptype> <name>b</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2fColor3fVertex3fvSUN</name></proto>
+            <param len="2">const <ptype>GLfloat</ptype> *<name>tc</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>c</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2fColor4fNormal3fVertex3fSUN</name></proto>
+            <param><ptype>GLfloat</ptype> <name>s</name></param>
+            <param><ptype>GLfloat</ptype> <name>t</name></param>
+            <param><ptype>GLfloat</ptype> <name>r</name></param>
+            <param><ptype>GLfloat</ptype> <name>g</name></param>
+            <param><ptype>GLfloat</ptype> <name>b</name></param>
+            <param><ptype>GLfloat</ptype> <name>a</name></param>
+            <param><ptype>GLfloat</ptype> <name>nx</name></param>
+            <param><ptype>GLfloat</ptype> <name>ny</name></param>
+            <param><ptype>GLfloat</ptype> <name>nz</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2fColor4fNormal3fVertex3fvSUN</name></proto>
+            <param len="2">const <ptype>GLfloat</ptype> *<name>tc</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>c</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>n</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2fColor4ubVertex3fSUN</name></proto>
+            <param><ptype>GLfloat</ptype> <name>s</name></param>
+            <param><ptype>GLfloat</ptype> <name>t</name></param>
+            <param><ptype>GLubyte</ptype> <name>r</name></param>
+            <param><ptype>GLubyte</ptype> <name>g</name></param>
+            <param><ptype>GLubyte</ptype> <name>b</name></param>
+            <param><ptype>GLubyte</ptype> <name>a</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2fColor4ubVertex3fvSUN</name></proto>
+            <param len="2">const <ptype>GLfloat</ptype> *<name>tc</name></param>
+            <param len="4">const <ptype>GLubyte</ptype> *<name>c</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2fNormal3fVertex3fSUN</name></proto>
+            <param><ptype>GLfloat</ptype> <name>s</name></param>
+            <param><ptype>GLfloat</ptype> <name>t</name></param>
+            <param><ptype>GLfloat</ptype> <name>nx</name></param>
+            <param><ptype>GLfloat</ptype> <name>ny</name></param>
+            <param><ptype>GLfloat</ptype> <name>nz</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2fNormal3fVertex3fvSUN</name></proto>
+            <param len="2">const <ptype>GLfloat</ptype> *<name>tc</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>n</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2fVertex3fSUN</name></proto>
+            <param><ptype>GLfloat</ptype> <name>s</name></param>
+            <param><ptype>GLfloat</ptype> <name>t</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2fVertex3fvSUN</name></proto>
+            <param len="2">const <ptype>GLfloat</ptype> *<name>tc</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2fv</name></proto>
+            <param group="CoordF" len="2">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="54"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2hNV</name></proto>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>s</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>t</name></param>
+            <vecequiv name="glTexCoord2hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2hvNV</name></proto>
+            <param group="Half16NV" len="2">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4247"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2i</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>s</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>t</name></param>
+            <vecequiv name="glTexCoord2iv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2iv</name></proto>
+            <param group="CoordI" len="2">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="55"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2s</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>s</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>t</name></param>
+            <vecequiv name="glTexCoord2sv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2sv</name></proto>
+            <param group="CoordS" len="2">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="56"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2xOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>s</name></param>
+            <param><ptype>GLfixed</ptype> <name>t</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord2xvOES</name></proto>
+            <param len="2">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord3bOES</name></proto>
+            <param><ptype>GLbyte</ptype> <name>s</name></param>
+            <param><ptype>GLbyte</ptype> <name>t</name></param>
+            <param><ptype>GLbyte</ptype> <name>r</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord3bvOES</name></proto>
+            <param len="3">const <ptype>GLbyte</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord3d</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>s</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>t</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>r</name></param>
+            <vecequiv name="glTexCoord3dv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord3dv</name></proto>
+            <param group="CoordD" len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="57"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord3f</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>s</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>t</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>r</name></param>
+            <vecequiv name="glTexCoord3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord3fv</name></proto>
+            <param group="CoordF" len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="58"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord3hNV</name></proto>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>s</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>t</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>r</name></param>
+            <vecequiv name="glTexCoord3hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord3hvNV</name></proto>
+            <param group="Half16NV" len="3">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4248"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord3i</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>s</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>t</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>r</name></param>
+            <vecequiv name="glTexCoord3iv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord3iv</name></proto>
+            <param group="CoordI" len="3">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="59"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord3s</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>s</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>t</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>r</name></param>
+            <vecequiv name="glTexCoord3sv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord3sv</name></proto>
+            <param group="CoordS" len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="60"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord3xOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>s</name></param>
+            <param><ptype>GLfixed</ptype> <name>t</name></param>
+            <param><ptype>GLfixed</ptype> <name>r</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord3xvOES</name></proto>
+            <param len="3">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4bOES</name></proto>
+            <param><ptype>GLbyte</ptype> <name>s</name></param>
+            <param><ptype>GLbyte</ptype> <name>t</name></param>
+            <param><ptype>GLbyte</ptype> <name>r</name></param>
+            <param><ptype>GLbyte</ptype> <name>q</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4bvOES</name></proto>
+            <param len="4">const <ptype>GLbyte</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4d</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>s</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>t</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>r</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>q</name></param>
+            <vecequiv name="glTexCoord4dv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4dv</name></proto>
+            <param group="CoordD" len="4">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="61"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4f</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>s</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>t</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>r</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>q</name></param>
+            <vecequiv name="glTexCoord4fv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4fColor4fNormal3fVertex4fSUN</name></proto>
+            <param><ptype>GLfloat</ptype> <name>s</name></param>
+            <param><ptype>GLfloat</ptype> <name>t</name></param>
+            <param><ptype>GLfloat</ptype> <name>p</name></param>
+            <param><ptype>GLfloat</ptype> <name>q</name></param>
+            <param><ptype>GLfloat</ptype> <name>r</name></param>
+            <param><ptype>GLfloat</ptype> <name>g</name></param>
+            <param><ptype>GLfloat</ptype> <name>b</name></param>
+            <param><ptype>GLfloat</ptype> <name>a</name></param>
+            <param><ptype>GLfloat</ptype> <name>nx</name></param>
+            <param><ptype>GLfloat</ptype> <name>ny</name></param>
+            <param><ptype>GLfloat</ptype> <name>nz</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <param><ptype>GLfloat</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4fColor4fNormal3fVertex4fvSUN</name></proto>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>tc</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>c</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>n</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4fVertex4fSUN</name></proto>
+            <param><ptype>GLfloat</ptype> <name>s</name></param>
+            <param><ptype>GLfloat</ptype> <name>t</name></param>
+            <param><ptype>GLfloat</ptype> <name>p</name></param>
+            <param><ptype>GLfloat</ptype> <name>q</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <param><ptype>GLfloat</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4fVertex4fvSUN</name></proto>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>tc</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4fv</name></proto>
+            <param group="CoordF" len="4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="62"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4hNV</name></proto>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>s</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>t</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>r</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>q</name></param>
+            <vecequiv name="glTexCoord4hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4hvNV</name></proto>
+            <param group="Half16NV" len="4">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4249"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4i</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>s</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>t</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>r</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>q</name></param>
+            <vecequiv name="glTexCoord4iv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4iv</name></proto>
+            <param group="CoordI" len="4">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="63"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4s</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>s</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>t</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>r</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>q</name></param>
+            <vecequiv name="glTexCoord4sv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4sv</name></proto>
+            <param group="CoordS" len="4">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="64"/>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4xOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>s</name></param>
+            <param><ptype>GLfixed</ptype> <name>t</name></param>
+            <param><ptype>GLfixed</ptype> <name>r</name></param>
+            <param><ptype>GLfixed</ptype> <name>q</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoord4xvOES</name></proto>
+            <param len="4">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoordFormatNV</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoordP1ui</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoordP1uiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoordP2ui</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoordP2uiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoordP3ui</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoordP3uiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoordP4ui</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoordP4uiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoordPointer</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="TexCoordPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(size,type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoordPointerEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="TexCoordPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="COMPSIZE(size,type,stride,count)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoordPointerListIBM</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="TexCoordPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLint</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(size,type,stride)">const void **<name>pointer</name></param>
+            <param><ptype>GLint</ptype> <name>ptrstride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexCoordPointervINTEL</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="VertexPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="4">const void **<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexEnvf</name></proto>
+            <param group="TextureEnvTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureEnvParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <glx type="render" opcode="111"/>
+        </command>
+        <command>
+            <proto>void <name>glTexEnvfv</name></proto>
+            <param group="TextureEnvTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureEnvParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="render" opcode="112"/>
+        </command>
+        <command>
+            <proto>void <name>glTexEnvi</name></proto>
+            <param group="TextureEnvTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureEnvParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+            <glx type="render" opcode="113"/>
+        </command>
+        <command>
+            <proto>void <name>glTexEnviv</name></proto>
+            <param group="TextureEnvTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureEnvParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="render" opcode="114"/>
+        </command>
+        <command>
+            <proto>void <name>glTexEnvx</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexEnvxOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexEnvxv</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexEnvxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexFilterFuncSGIS</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureFilterSGIS"><ptype>GLenum</ptype> <name>filter</name></param>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param len="n">const <ptype>GLfloat</ptype> *<name>weights</name></param>
+            <glx type="render" opcode="2064"/>
+        </command>
+        <command>
+            <proto>void <name>glTexGend</name></proto>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLdouble</ptype> <name>param</name></param>
+            <glx type="render" opcode="115"/>
+        </command>
+        <command>
+            <proto>void <name>glTexGendv</name></proto>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLdouble</ptype> *<name>params</name></param>
+            <glx type="render" opcode="116"/>
+        </command>
+        <command>
+            <proto>void <name>glTexGenf</name></proto>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <glx type="render" opcode="117"/>
+        </command>
+        <command>
+            <proto>void <name>glTexGenfOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>coord</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfloat</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexGenfv</name></proto>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="render" opcode="118"/>
+        </command>
+        <command>
+            <proto>void <name>glTexGenfvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>coord</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexGeni</name></proto>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+            <glx type="render" opcode="119"/>
+        </command>
+        <command>
+            <proto>void <name>glTexGeniOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>coord</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexGeniv</name></proto>
+            <param group="TextureCoordName"><ptype>GLenum</ptype> <name>coord</name></param>
+            <param group="TextureGenParameter"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="render" opcode="120"/>
+        </command>
+        <command>
+            <proto>void <name>glTexGenivOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>coord</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexGenxOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>coord</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexGenxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>coord</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexImage1D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureComponentCount"><ptype>GLint</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width)">const void *<name>pixels</name></param>
+            <glx type="render" opcode="109"/>
+            <glx type="render" opcode="328" name="glTexImage1DPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glTexImage2D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureComponentCount"><ptype>GLint</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height)">const void *<name>pixels</name></param>
+            <glx type="render" opcode="110"/>
+            <glx type="render" opcode="329" name="glTexImage2DPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glTexImage2DMultisample</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>fixedsamplelocations</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexImage2DMultisampleCoverageNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>coverageSamples</name></param>
+            <param><ptype>GLsizei</ptype> <name>colorSamples</name></param>
+            <param><ptype>GLint</ptype> <name>internalFormat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>fixedSampleLocations</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexImage3D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureComponentCount"><ptype>GLint</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height,depth)">const void *<name>pixels</name></param>
+            <glx type="render" opcode="4114"/>
+            <glx type="render" opcode="330" name="glTexImage3DPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glTexImage3DEXT</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height,depth)">const void *<name>pixels</name></param>
+            <alias name="glTexImage3D"/>
+            <glx type="render" opcode="4114"/>
+        </command>
+        <command>
+            <proto>void <name>glTexImage3DMultisample</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>fixedsamplelocations</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexImage3DMultisampleCoverageNV</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>coverageSamples</name></param>
+            <param><ptype>GLsizei</ptype> <name>colorSamples</name></param>
+            <param><ptype>GLint</ptype> <name>internalFormat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>fixedSampleLocations</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexImage3DOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param><ptype>GLint</ptype> <name>border</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height,depth)">const void *<name>pixels</name></param>
+            <alias name="glTexImage3D"/>
+        </command>
+        <command>
+            <proto>void <name>glTexImage4DSGIS</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="PixelInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param><ptype>GLsizei</ptype> <name>size4d</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height,depth,size4d)">const void *<name>pixels</name></param>
+            <glx type="render" opcode="2057"/>
+        </command>
+        <command>
+            <proto>void <name>glTexPageCommitmentARB</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param><ptype>GLboolean</ptype> <name>resident</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexParameterIiv</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="render" opcode="346"/>
+        </command>
+        <command>
+            <proto>void <name>glTexParameterIivEXT</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <alias name="glTexParameterIiv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexParameterIuiv</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLuint</ptype> *<name>params</name></param>
+            <glx type="render" opcode="347"/>
+        </command>
+        <command>
+            <proto>void <name>glTexParameterIuivEXT</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLuint</ptype> *<name>params</name></param>
+            <alias name="glTexParameterIuiv"/>
+        </command>
+        <command>
+            <proto>void <name>glTexParameterf</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <glx type="render" opcode="105"/>
+        </command>
+        <command>
+            <proto>void <name>glTexParameterfv</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+            <glx type="render" opcode="106"/>
+        </command>
+        <command>
+            <proto>void <name>glTexParameteri</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+            <glx type="render" opcode="107"/>
+        </command>
+        <command>
+            <proto>void <name>glTexParameteriv</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+            <glx type="render" opcode="108"/>
+        </command>
+        <command>
+            <proto>void <name>glTexParameterx</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexParameterxOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfixed</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexParameterxv</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexParameterxvOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfixed</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexRenderbufferNV</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexStorage1D</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>levels</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexStorage1DEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>levels</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <alias name="glTexStorage1D"/>
+        </command>
+        <command>
+            <proto>void <name>glTexStorage2D</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>levels</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexStorage2DEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>levels</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <alias name="glTexStorage2D"/>
+        </command>
+        <command>
+            <proto>void <name>glTexStorage2DMultisample</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>fixedsamplelocations</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexStorage3D</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>levels</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexStorage3DEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>levels</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <alias name="glTexStorage3D"/>
+        </command>
+        <command>
+            <proto>void <name>glTexStorage3DMultisample</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>fixedsamplelocations</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexStorage3DMultisampleOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>fixedsamplelocations</name></param>
+            <alias name="glTexStorage3DMultisample"/>
+        </command>
+        <command>
+            <proto>void <name>glTexStorageSparseAMD</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>internalFormat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param><ptype>GLsizei</ptype> <name>layers</name></param>
+            <param><ptype>GLbitfield</ptype> <name>flags</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexSubImage1D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width)">const void *<name>pixels</name></param>
+            <glx type="render" opcode="4099"/>
+            <glx type="render" opcode="331" name="glTexSubImage1DPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glTexSubImage1DEXT</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width)">const void *<name>pixels</name></param>
+            <alias name="glTexSubImage1D"/>
+            <glx type="render" opcode="4099"/>
+        </command>
+        <command>
+            <proto>void <name>glTexSubImage2D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height)">const void *<name>pixels</name></param>
+            <glx type="render" opcode="4100"/>
+            <glx type="render" opcode="332" name="glTexSubImage2DPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glTexSubImage2DEXT</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height)">const void *<name>pixels</name></param>
+            <alias name="glTexSubImage2D"/>
+            <glx type="render" opcode="4100"/>
+        </command>
+        <command>
+            <proto>void <name>glTexSubImage3D</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height,depth)">const void *<name>pixels</name></param>
+            <glx type="render" opcode="4115"/>
+            <glx type="render" opcode="333" name="glTexSubImage3DPBO" comment="PBO protocol"/>
+        </command>
+        <command>
+            <proto>void <name>glTexSubImage3DEXT</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height,depth)">const void *<name>pixels</name></param>
+            <alias name="glTexSubImage3D"/>
+            <glx type="render" opcode="4115"/>
+        </command>
+        <command>
+            <proto>void <name>glTexSubImage3DOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param><ptype>GLenum</ptype> <name>format</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height,depth)">const void *<name>pixels</name></param>
+            <alias name="glTexSubImage3D"/>
+        </command>
+        <command>
+            <proto>void <name>glTexSubImage4DSGIS</name></proto>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>woffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param><ptype>GLsizei</ptype> <name>size4d</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height,depth,size4d)">const void *<name>pixels</name></param>
+            <glx type="render" opcode="2058"/>
+        </command>
+        <command>
+            <proto>void <name>glTextureBarrierNV</name></proto>
+            <glx type="render" opcode="4348"/>
+        </command>
+        <command>
+            <proto>void <name>glTextureBufferEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureBufferRangeEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param group="BufferSize"><ptype>GLsizeiptr</ptype> <name>size</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureColorMaskSGIS</name></proto>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>red</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>green</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>blue</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>alpha</name></param>
+            <glx type="render" opcode="2082"/>
+        </command>
+        <command>
+            <proto>void <name>glTextureImage1DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureComponentCount"><ptype>GLint</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width)">const void *<name>pixels</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureImage2DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureComponentCount"><ptype>GLint</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height)">const void *<name>pixels</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureImage2DMultisampleCoverageNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>coverageSamples</name></param>
+            <param><ptype>GLsizei</ptype> <name>colorSamples</name></param>
+            <param><ptype>GLint</ptype> <name>internalFormat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>fixedSampleLocations</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureImage2DMultisampleNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+            <param><ptype>GLint</ptype> <name>internalFormat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>fixedSampleLocations</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureImage3DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="TextureComponentCount"><ptype>GLint</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>border</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height,depth)">const void *<name>pixels</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureImage3DMultisampleCoverageNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>coverageSamples</name></param>
+            <param><ptype>GLsizei</ptype> <name>colorSamples</name></param>
+            <param><ptype>GLint</ptype> <name>internalFormat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>fixedSampleLocations</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureImage3DMultisampleNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+            <param><ptype>GLint</ptype> <name>internalFormat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>fixedSampleLocations</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureLightEXT</name></proto>
+            <param group="LightTexturePNameEXT"><ptype>GLenum</ptype> <name>pname</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureMaterialEXT</name></proto>
+            <param group="MaterialFace"><ptype>GLenum</ptype> <name>face</name></param>
+            <param group="MaterialParameter"><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureNormalEXT</name></proto>
+            <param group="TextureNormalModeEXT"><ptype>GLenum</ptype> <name>mode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTexturePageCommitmentEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+            <param><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param><ptype>GLboolean</ptype> <name>resident</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureParameterIivEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureParameterIuivEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLuint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureParameterfEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32"><ptype>GLfloat</ptype> <name>param</name></param>
+            <vecequiv name="glTextureParameterfvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glTextureParameterfvEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedFloat32" len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureParameteriEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>param</name></param>
+            <vecequiv name="glTextureParameterivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glTextureParameterivEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="TextureParameterName"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param group="CheckedInt32" len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureRangeAPPLE</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param len="length">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureRenderbufferEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>renderbuffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureStorage1DEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>levels</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureStorage2DEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>levels</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureStorage2DMultisampleEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+            <param group="TextureInternalFormat"><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>fixedsamplelocations</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureStorage3DEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>levels</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureStorage3DMultisampleEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>samples</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>fixedsamplelocations</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureStorageSparseAMD</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLenum</ptype> <name>internalFormat</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param><ptype>GLsizei</ptype> <name>layers</name></param>
+            <param><ptype>GLbitfield</ptype> <name>flags</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureSubImage1DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width)">const void *<name>pixels</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureSubImage2DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height)">const void *<name>pixels</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureSubImage3DEXT</name></proto>
+            <param group="Texture"><ptype>GLuint</ptype> <name>texture</name></param>
+            <param group="TextureTarget"><ptype>GLenum</ptype> <name>target</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>level</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>xoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>yoffset</name></param>
+            <param group="CheckedInt32"><ptype>GLint</ptype> <name>zoffset</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <param><ptype>GLsizei</ptype> <name>depth</name></param>
+            <param group="PixelFormat"><ptype>GLenum</ptype> <name>format</name></param>
+            <param group="PixelType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="COMPSIZE(format,type,width,height,depth)">const void *<name>pixels</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureView</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>origtexture</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLuint</ptype> <name>minlevel</name></param>
+            <param><ptype>GLuint</ptype> <name>numlevels</name></param>
+            <param><ptype>GLuint</ptype> <name>minlayer</name></param>
+            <param><ptype>GLuint</ptype> <name>numlayers</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTextureViewEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>origtexture</name></param>
+            <param><ptype>GLenum</ptype> <name>internalformat</name></param>
+            <param><ptype>GLuint</ptype> <name>minlevel</name></param>
+            <param><ptype>GLuint</ptype> <name>numlevels</name></param>
+            <param><ptype>GLuint</ptype> <name>minlayer</name></param>
+            <param><ptype>GLuint</ptype> <name>numlayers</name></param>
+            <alias name="glTextureView"/>
+        </command>
+        <command>
+            <proto>void <name>glTrackMatrixNV</name></proto>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLuint</ptype> <name>address</name></param>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>matrix</name></param>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>transform</name></param>
+            <glx type="render" opcode="4188"/>
+        </command>
+        <command>
+            <proto>void <name>glTransformFeedbackAttribsNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>count</name></param>
+            <param len="COMPSIZE(count)">const <ptype>GLint</ptype> *<name>attribs</name></param>
+            <param><ptype>GLenum</ptype> <name>bufferMode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTransformFeedbackStreamAttribsNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLint</ptype> *<name>attribs</name></param>
+            <param><ptype>GLsizei</ptype> <name>nbuffers</name></param>
+            <param len="nbuffers">const <ptype>GLint</ptype> *<name>bufstreams</name></param>
+            <param><ptype>GLenum</ptype> <name>bufferMode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTransformFeedbackVaryings</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLchar</ptype> *const*<name>varyings</name></param>
+            <param><ptype>GLenum</ptype> <name>bufferMode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTransformFeedbackVaryingsEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLchar</ptype> *const*<name>varyings</name></param>
+            <param><ptype>GLenum</ptype> <name>bufferMode</name></param>
+            <alias name="glTransformFeedbackVaryings"/>
+        </command>
+        <command>
+            <proto>void <name>glTransformFeedbackVaryingsNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLint</ptype> *<name>locations</name></param>
+            <param><ptype>GLenum</ptype> <name>bufferMode</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTransformPathNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>resultPath</name></param>
+            <param group="Path"><ptype>GLuint</ptype> <name>srcPath</name></param>
+            <param group="PathTransformType"><ptype>GLenum</ptype> <name>transformType</name></param>
+            <param len="COMPSIZE(transformType)">const <ptype>GLfloat</ptype> *<name>transformValues</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTranslated</name></proto>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <glx type="render" opcode="189"/>
+        </command>
+        <command>
+            <proto>void <name>glTranslatef</name></proto>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <glx type="render" opcode="190"/>
+        </command>
+        <command>
+            <proto>void <name>glTranslatex</name></proto>
+            <param><ptype>GLfixed</ptype> <name>x</name></param>
+            <param><ptype>GLfixed</ptype> <name>y</name></param>
+            <param><ptype>GLfixed</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glTranslatexOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>x</name></param>
+            <param><ptype>GLfixed</ptype> <name>y</name></param>
+            <param><ptype>GLfixed</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform1d</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform1dv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform1f</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLfloat</ptype> <name>v0</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform1fARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLfloat</ptype> <name>v0</name></param>
+            <alias name="glUniform1f"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform1fv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform1fvARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glUniform1fv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform1i</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint</ptype> <name>v0</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform1i64NV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>x</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform1i64vNV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform1iARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint</ptype> <name>v0</name></param>
+            <alias name="glUniform1i"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform1iv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform1ivARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLint</ptype> *<name>value</name></param>
+            <alias name="glUniform1iv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform1ui</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>v0</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform1ui64NV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>x</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform1ui64vNV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform1uiEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>v0</name></param>
+            <alias name="glUniform1ui"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform1uiv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform1uivEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>value</name></param>
+            <alias name="glUniform1uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform2d</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform2dv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform2f</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLfloat</ptype> <name>v0</name></param>
+            <param><ptype>GLfloat</ptype> <name>v1</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform2fARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLfloat</ptype> <name>v0</name></param>
+            <param><ptype>GLfloat</ptype> <name>v1</name></param>
+            <alias name="glUniform2f"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform2fv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform2fvARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glUniform2fv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform2i</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint</ptype> <name>v0</name></param>
+            <param><ptype>GLint</ptype> <name>v1</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform2i64NV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform2i64vNV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*2">const <ptype>GLint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform2iARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint</ptype> <name>v0</name></param>
+            <param><ptype>GLint</ptype> <name>v1</name></param>
+            <alias name="glUniform2i"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform2iv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform2ivARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLint</ptype> *<name>value</name></param>
+            <alias name="glUniform2iv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform2ui</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>v0</name></param>
+            <param><ptype>GLuint</ptype> <name>v1</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform2ui64NV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform2ui64vNV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*2">const <ptype>GLuint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform2uiEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>v0</name></param>
+            <param><ptype>GLuint</ptype> <name>v1</name></param>
+            <alias name="glUniform2ui"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform2uiv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*2">const <ptype>GLuint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform2uivEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*2">const <ptype>GLuint</ptype> *<name>value</name></param>
+            <alias name="glUniform2uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform3d</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform3dv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform3f</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLfloat</ptype> <name>v0</name></param>
+            <param><ptype>GLfloat</ptype> <name>v1</name></param>
+            <param><ptype>GLfloat</ptype> <name>v2</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform3fARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLfloat</ptype> <name>v0</name></param>
+            <param><ptype>GLfloat</ptype> <name>v1</name></param>
+            <param><ptype>GLfloat</ptype> <name>v2</name></param>
+            <alias name="glUniform3f"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform3fv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform3fvARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glUniform3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform3i</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint</ptype> <name>v0</name></param>
+            <param><ptype>GLint</ptype> <name>v1</name></param>
+            <param><ptype>GLint</ptype> <name>v2</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform3i64NV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>y</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform3i64vNV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*3">const <ptype>GLint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform3iARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint</ptype> <name>v0</name></param>
+            <param><ptype>GLint</ptype> <name>v1</name></param>
+            <param><ptype>GLint</ptype> <name>v2</name></param>
+            <alias name="glUniform3i"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform3iv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform3ivARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLint</ptype> *<name>value</name></param>
+            <alias name="glUniform3iv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform3ui</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>v0</name></param>
+            <param><ptype>GLuint</ptype> <name>v1</name></param>
+            <param><ptype>GLuint</ptype> <name>v2</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform3ui64NV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>y</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform3ui64vNV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*3">const <ptype>GLuint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform3uiEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>v0</name></param>
+            <param><ptype>GLuint</ptype> <name>v1</name></param>
+            <param><ptype>GLuint</ptype> <name>v2</name></param>
+            <alias name="glUniform3ui"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform3uiv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*3">const <ptype>GLuint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform3uivEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*3">const <ptype>GLuint</ptype> *<name>value</name></param>
+            <alias name="glUniform3uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform4d</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <param><ptype>GLdouble</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform4dv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform4f</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLfloat</ptype> <name>v0</name></param>
+            <param><ptype>GLfloat</ptype> <name>v1</name></param>
+            <param><ptype>GLfloat</ptype> <name>v2</name></param>
+            <param><ptype>GLfloat</ptype> <name>v3</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform4fARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLfloat</ptype> <name>v0</name></param>
+            <param><ptype>GLfloat</ptype> <name>v1</name></param>
+            <param><ptype>GLfloat</ptype> <name>v2</name></param>
+            <param><ptype>GLfloat</ptype> <name>v3</name></param>
+            <alias name="glUniform4f"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform4fv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform4fvARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glUniform4fv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform4i</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint</ptype> <name>v0</name></param>
+            <param><ptype>GLint</ptype> <name>v1</name></param>
+            <param><ptype>GLint</ptype> <name>v2</name></param>
+            <param><ptype>GLint</ptype> <name>v3</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform4i64NV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>y</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>z</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform4i64vNV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform4iARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLint</ptype> <name>v0</name></param>
+            <param><ptype>GLint</ptype> <name>v1</name></param>
+            <param><ptype>GLint</ptype> <name>v2</name></param>
+            <param><ptype>GLint</ptype> <name>v3</name></param>
+            <alias name="glUniform4i"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform4iv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform4ivARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLint</ptype> *<name>value</name></param>
+            <alias name="glUniform4iv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform4ui</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>v0</name></param>
+            <param><ptype>GLuint</ptype> <name>v1</name></param>
+            <param><ptype>GLuint</ptype> <name>v2</name></param>
+            <param><ptype>GLuint</ptype> <name>v3</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform4ui64NV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>y</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>z</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform4ui64vNV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLuint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform4uiEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>v0</name></param>
+            <param><ptype>GLuint</ptype> <name>v1</name></param>
+            <param><ptype>GLuint</ptype> <name>v2</name></param>
+            <param><ptype>GLuint</ptype> <name>v3</name></param>
+            <alias name="glUniform4ui"/>
+        </command>
+        <command>
+            <proto>void <name>glUniform4uiv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLuint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniform4uivEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLuint</ptype> *<name>value</name></param>
+            <alias name="glUniform4uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniformBlockBinding</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLuint</ptype> <name>uniformBlockIndex</name></param>
+            <param><ptype>GLuint</ptype> <name>uniformBlockBinding</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformBufferEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformHandleui64ARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint64</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformHandleui64NV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint64</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformHandleui64vARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint64</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformHandleui64vNV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint64</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix2dv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix2fv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix2fvARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glUniformMatrix2fv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix2x3dv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix2x3fv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="6">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <glx type="render" opcode="305"/>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix2x3fvNV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="6">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glUniformMatrix2x3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix2x4dv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix2x4fv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="8">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <glx type="render" opcode="307"/>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix2x4fvNV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="8">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glUniformMatrix2x4fv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix3dv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix3fv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix3fvARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glUniformMatrix3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix3x2dv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix3x2fv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="6">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <glx type="render" opcode="306"/>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix3x2fvNV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="6">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glUniformMatrix3x2fv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix3x4dv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix3x4fv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="12">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <glx type="render" opcode="309"/>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix3x4fvNV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="12">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glUniformMatrix3x4fv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix4dv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix4fv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix4fvARB</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glUniformMatrix4fv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix4x2dv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix4x2fv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="8">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <glx type="render" opcode="308"/>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix4x2fvNV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="8">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glUniformMatrix4x2fv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix4x3dv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix4x3fv</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="12">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <glx type="render" opcode="310"/>
+        </command>
+        <command>
+            <proto>void <name>glUniformMatrix4x3fvNV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>transpose</name></param>
+            <param len="12">const <ptype>GLfloat</ptype> *<name>value</name></param>
+            <alias name="glUniformMatrix4x3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glUniformSubroutinesuiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>shadertype</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint</ptype> *<name>indices</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformui64NV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUniformui64vNV</name></proto>
+            <param><ptype>GLint</ptype> <name>location</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLuint64EXT</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUnlockArraysEXT</name></proto>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glUnmapBuffer</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glUnmapBufferARB</name></proto>
+            <param group="BufferTargetARB"><ptype>GLenum</ptype> <name>target</name></param>
+            <alias name="glUnmapBuffer"/>
+        </command>
+        <command>
+            <proto><ptype>GLboolean</ptype> <name>glUnmapBufferOES</name></proto>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <alias name="glUnmapBuffer"/>
+        </command>
+        <command>
+            <proto group="Boolean"><ptype>GLboolean</ptype> <name>glUnmapNamedBufferEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUnmapObjectBufferATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUnmapTexture2DINTEL</name></proto>
+            <param><ptype>GLuint</ptype> <name>texture</name></param>
+            <param><ptype>GLint</ptype> <name>level</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUpdateObjectBufferATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLuint</ptype> <name>offset</name></param>
+            <param><ptype>GLsizei</ptype> <name>size</name></param>
+            <param len="size">const void *<name>pointer</name></param>
+            <param group="PreserveModeATI"><ptype>GLenum</ptype> <name>preserve</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUseProgram</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUseProgramObjectARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>programObj</name></param>
+            <alias name="glUseProgram"/>
+        </command>
+        <command>
+            <proto>void <name>glUseProgramStages</name></proto>
+            <param><ptype>GLuint</ptype> <name>pipeline</name></param>
+            <param><ptype>GLbitfield</ptype> <name>stages</name></param>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUseProgramStagesEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>pipeline</name></param>
+            <param><ptype>GLbitfield</ptype> <name>stages</name></param>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+        </command>
+        <command>
+            <proto>void <name>glUseShaderProgramEXT</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVDPAUFiniNV</name></proto>
+        </command>
+        <command>
+            <proto>void <name>glVDPAUGetSurfaceivNV</name></proto>
+            <param group="vdpauSurfaceNV"><ptype>GLvdpauSurfaceNV</ptype> <name>surface</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLsizei</ptype> <name>bufSize</name></param>
+            <param><ptype>GLsizei</ptype> *<name>length</name></param>
+            <param len="bufSize"><ptype>GLint</ptype> *<name>values</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVDPAUInitNV</name></proto>
+            <param>const void *<name>vdpDevice</name></param>
+            <param>const void *<name>getProcAddress</name></param>
+        </command>
+        <command>
+            <proto><ptype>GLboolean</ptype> <name>glVDPAUIsSurfaceNV</name></proto>
+            <param group="vdpauSurfaceNV"><ptype>GLvdpauSurfaceNV</ptype> <name>surface</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVDPAUMapSurfacesNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>numSurfaces</name></param>
+            <param group="vdpauSurfaceNV" len="numSurfaces">const <ptype>GLvdpauSurfaceNV</ptype> *<name>surfaces</name></param>
+        </command>
+        <command>
+            <proto group="vdpauSurfaceNV"><ptype>GLvdpauSurfaceNV</ptype> <name>glVDPAURegisterOutputSurfaceNV</name></proto>
+            <param>const void *<name>vdpSurface</name></param>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>numTextureNames</name></param>
+            <param len="numTextureNames">const <ptype>GLuint</ptype> *<name>textureNames</name></param>
+        </command>
+        <command>
+            <proto group="vdpauSurfaceNV"><ptype>GLvdpauSurfaceNV</ptype> <name>glVDPAURegisterVideoSurfaceNV</name></proto>
+            <param>const void *<name>vdpSurface</name></param>
+            <param><ptype>GLenum</ptype> <name>target</name></param>
+            <param><ptype>GLsizei</ptype> <name>numTextureNames</name></param>
+            <param len="numTextureNames">const <ptype>GLuint</ptype> *<name>textureNames</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVDPAUSurfaceAccessNV</name></proto>
+            <param group="vdpauSurfaceNV"><ptype>GLvdpauSurfaceNV</ptype> <name>surface</name></param>
+            <param><ptype>GLenum</ptype> <name>access</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVDPAUUnmapSurfacesNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>numSurface</name></param>
+            <param group="vdpauSurfaceNV" len="numSurface">const <ptype>GLvdpauSurfaceNV</ptype> *<name>surfaces</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVDPAUUnregisterSurfaceNV</name></proto>
+            <param group="vdpauSurfaceNV"><ptype>GLvdpauSurfaceNV</ptype> <name>surface</name></param>
+        </command>
+        <command>
+            <proto>void <name>glValidateProgram</name></proto>
+            <param><ptype>GLuint</ptype> <name>program</name></param>
+        </command>
+        <command>
+            <proto>void <name>glValidateProgramARB</name></proto>
+            <param group="handleARB"><ptype>GLhandleARB</ptype> <name>programObj</name></param>
+            <alias name="glValidateProgram"/>
+        </command>
+        <command>
+            <proto>void <name>glValidateProgramPipeline</name></proto>
+            <param><ptype>GLuint</ptype> <name>pipeline</name></param>
+        </command>
+        <command>
+            <proto>void <name>glValidateProgramPipelineEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>pipeline</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVariantArrayObjectATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="ScalarType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLuint</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVariantPointerEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param group="ScalarType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(id,type,stride)">const void *<name>addr</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVariantbvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param len="COMPSIZE(id)">const <ptype>GLbyte</ptype> *<name>addr</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVariantdvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param len="COMPSIZE(id)">const <ptype>GLdouble</ptype> *<name>addr</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVariantfvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param len="COMPSIZE(id)">const <ptype>GLfloat</ptype> *<name>addr</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVariantivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param len="COMPSIZE(id)">const <ptype>GLint</ptype> *<name>addr</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVariantsvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param len="COMPSIZE(id)">const <ptype>GLshort</ptype> *<name>addr</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVariantubvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param len="COMPSIZE(id)">const <ptype>GLubyte</ptype> *<name>addr</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVariantuivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param len="COMPSIZE(id)">const <ptype>GLuint</ptype> *<name>addr</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVariantusvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>id</name></param>
+            <param len="COMPSIZE(id)">const <ptype>GLushort</ptype> *<name>addr</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertex2bOES</name></proto>
+            <param><ptype>GLbyte</ptype> <name>x</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertex2bvOES</name></proto>
+            <param len="2">const <ptype>GLbyte</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertex2d</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>x</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>y</name></param>
+            <vecequiv name="glVertex2dv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex2dv</name></proto>
+            <param group="CoordD" len="2">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="65"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex2f</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>x</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>y</name></param>
+            <vecequiv name="glVertex2fv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex2fv</name></proto>
+            <param group="CoordF" len="2">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="66"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex2hNV</name></proto>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>x</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>y</name></param>
+            <vecequiv name="glVertex2hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex2hvNV</name></proto>
+            <param group="Half16NV" len="2">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4240"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex2i</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>y</name></param>
+            <vecequiv name="glVertex2iv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex2iv</name></proto>
+            <param group="CoordI" len="2">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="67"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex2s</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>x</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>y</name></param>
+            <vecequiv name="glVertex2sv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex2sv</name></proto>
+            <param group="CoordS" len="2">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="68"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex2xOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>x</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertex2xvOES</name></proto>
+            <param len="2">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertex3bOES</name></proto>
+            <param><ptype>GLbyte</ptype> <name>x</name></param>
+            <param><ptype>GLbyte</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertex3bvOES</name></proto>
+            <param len="3">const <ptype>GLbyte</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertex3d</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>x</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>y</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>z</name></param>
+            <vecequiv name="glVertex3dv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex3dv</name></proto>
+            <param group="CoordD" len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="69"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex3f</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>x</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>y</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>z</name></param>
+            <vecequiv name="glVertex3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex3fv</name></proto>
+            <param group="CoordF" len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="70"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex3hNV</name></proto>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>x</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>y</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>z</name></param>
+            <vecequiv name="glVertex3hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex3hvNV</name></proto>
+            <param group="Half16NV" len="3">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4241"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex3i</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>y</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>z</name></param>
+            <vecequiv name="glVertex3iv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex3iv</name></proto>
+            <param group="CoordI" len="3">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="71"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex3s</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>x</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>y</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>z</name></param>
+            <vecequiv name="glVertex3sv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex3sv</name></proto>
+            <param group="CoordS" len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="72"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex3xOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>x</name></param>
+            <param><ptype>GLfixed</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertex3xvOES</name></proto>
+            <param len="3">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertex4bOES</name></proto>
+            <param><ptype>GLbyte</ptype> <name>x</name></param>
+            <param><ptype>GLbyte</ptype> <name>y</name></param>
+            <param><ptype>GLbyte</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertex4bvOES</name></proto>
+            <param len="4">const <ptype>GLbyte</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertex4d</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>x</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>y</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>z</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>w</name></param>
+            <vecequiv name="glVertex4dv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex4dv</name></proto>
+            <param group="CoordD" len="4">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="73"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex4f</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>x</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>y</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>z</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>w</name></param>
+            <vecequiv name="glVertex4fv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex4fv</name></proto>
+            <param group="CoordF" len="4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="74"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex4hNV</name></proto>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>x</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>y</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>z</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>w</name></param>
+            <vecequiv name="glVertex4hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex4hvNV</name></proto>
+            <param group="Half16NV" len="4">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4242"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex4i</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>y</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>z</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>w</name></param>
+            <vecequiv name="glVertex4iv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex4iv</name></proto>
+            <param group="CoordI" len="4">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="75"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex4s</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>x</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>y</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>z</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>w</name></param>
+            <vecequiv name="glVertex4sv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex4sv</name></proto>
+            <param group="CoordS" len="4">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="76"/>
+        </command>
+        <command>
+            <proto>void <name>glVertex4xOES</name></proto>
+            <param><ptype>GLfixed</ptype> <name>x</name></param>
+            <param><ptype>GLfixed</ptype> <name>y</name></param>
+            <param><ptype>GLfixed</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertex4xvOES</name></proto>
+            <param len="4">const <ptype>GLfixed</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayBindVertexBufferEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>bindingindex</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayColorOffsetEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="ColorPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayEdgeFlagOffsetEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayFogCoordOffsetEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="FogCoordinatePointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayIndexOffsetEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="IndexPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayMultiTexCoordOffsetEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLenum</ptype> <name>texunit</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="TexCoordPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayNormalOffsetEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param group="NormalPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayParameteriAPPLE</name></proto>
+            <param group="VertexArrayPNameAPPLE"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayRangeAPPLE</name></proto>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param len="length">void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayRangeNV</name></proto>
+            <param><ptype>GLsizei</ptype> <name>length</name></param>
+            <param len="COMPSIZE(length)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArraySecondaryColorOffsetEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="ColorPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayTexCoordOffsetEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="TexCoordPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayVertexAttribBindingEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>attribindex</name></param>
+            <param><ptype>GLuint</ptype> <name>bindingindex</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayVertexAttribDivisorEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>divisor</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayVertexAttribFormatEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>attribindex</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>normalized</name></param>
+            <param><ptype>GLuint</ptype> <name>relativeoffset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayVertexAttribIFormatEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>attribindex</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>relativeoffset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayVertexAttribIOffsetEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="VertexAttribEnum"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayVertexAttribLFormatEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>attribindex</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>relativeoffset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayVertexAttribLOffsetEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param group="BufferOffset"><ptype>GLintptr</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayVertexAttribOffsetEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="VertexAttribPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLboolean</ptype> <name>normalized</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayVertexBindingDivisorEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>bindingindex</name></param>
+            <param><ptype>GLuint</ptype> <name>divisor</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexArrayVertexOffsetEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>vaobj</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="VertexPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLintptr</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1d</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <vecequiv name="glVertexAttrib1dv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1dARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <alias name="glVertexAttrib1d"/>
+            <vecequiv name="glVertexAttrib1dvARB"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1dNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <alias name="glVertexAttrib1d"/>
+            <vecequiv name="glVertexAttrib1dvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4197"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1dvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib1dv"/>
+            <glx type="render" opcode="4197"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1dvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib1dv"/>
+            <glx type="render" opcode="4197"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1f</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <vecequiv name="glVertexAttrib1fv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1fARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <alias name="glVertexAttrib1f"/>
+            <vecequiv name="glVertexAttrib1fvARB"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1fNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <alias name="glVertexAttrib1f"/>
+            <vecequiv name="glVertexAttrib1fvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4193"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1fvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib1fv"/>
+            <glx type="render" opcode="4193"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1fvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib1fv"/>
+            <glx type="render" opcode="4193"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1hNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>x</name></param>
+            <vecequiv name="glVertexAttrib1hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1hvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="Half16NV" len="1">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4257"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1s</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+            <vecequiv name="glVertexAttrib1sv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1sARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+            <alias name="glVertexAttrib1s"/>
+            <vecequiv name="glVertexAttrib1svARB"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1sNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+            <alias name="glVertexAttrib1s"/>
+            <vecequiv name="glVertexAttrib1svNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1sv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4189"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1svARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib1sv"/>
+            <glx type="render" opcode="4189"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib1svNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib1sv"/>
+            <glx type="render" opcode="4189"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2d</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <vecequiv name="glVertexAttrib2dv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2dARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <alias name="glVertexAttrib2d"/>
+            <vecequiv name="glVertexAttrib2dvARB"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2dNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <alias name="glVertexAttrib2d"/>
+            <vecequiv name="glVertexAttrib2dvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4198"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2dvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib2dv"/>
+            <glx type="render" opcode="4198"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2dvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib2dv"/>
+            <glx type="render" opcode="4198"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2f</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <vecequiv name="glVertexAttrib2fv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2fARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <alias name="glVertexAttrib2f"/>
+            <vecequiv name="glVertexAttrib2fvARB"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2fNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <alias name="glVertexAttrib2f"/>
+            <vecequiv name="glVertexAttrib2fvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4194"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2fvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib2fv"/>
+            <glx type="render" opcode="4194"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2fvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib2fv"/>
+            <glx type="render" opcode="4194"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2hNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>x</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>y</name></param>
+            <vecequiv name="glVertexAttrib2hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2hvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="Half16NV" len="2">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4258"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2s</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+            <param><ptype>GLshort</ptype> <name>y</name></param>
+            <vecequiv name="glVertexAttrib2sv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2sARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+            <param><ptype>GLshort</ptype> <name>y</name></param>
+            <alias name="glVertexAttrib2s"/>
+            <vecequiv name="glVertexAttrib2svARB"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2sNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+            <param><ptype>GLshort</ptype> <name>y</name></param>
+            <alias name="glVertexAttrib2s"/>
+            <vecequiv name="glVertexAttrib2svNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2sv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4190"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2svARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib2sv"/>
+            <glx type="render" opcode="4190"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib2svNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib2sv"/>
+            <glx type="render" opcode="4190"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3d</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <vecequiv name="glVertexAttrib3dv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3dARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <alias name="glVertexAttrib3d"/>
+            <vecequiv name="glVertexAttrib3dvARB"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3dNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <alias name="glVertexAttrib3d"/>
+            <vecequiv name="glVertexAttrib3dvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4199"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3dvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib3dv"/>
+            <glx type="render" opcode="4199"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3dvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib3dv"/>
+            <glx type="render" opcode="4199"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3f</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <vecequiv name="glVertexAttrib3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3fARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <alias name="glVertexAttrib3f"/>
+            <vecequiv name="glVertexAttrib3fvARB"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3fNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <alias name="glVertexAttrib3f"/>
+            <vecequiv name="glVertexAttrib3fvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4195"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3fvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib3fv"/>
+            <glx type="render" opcode="4195"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3fvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib3fv"/>
+            <glx type="render" opcode="4195"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3hNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>x</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>y</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>z</name></param>
+            <vecequiv name="glVertexAttrib3hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3hvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="Half16NV" len="3">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4259"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3s</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+            <param><ptype>GLshort</ptype> <name>y</name></param>
+            <param><ptype>GLshort</ptype> <name>z</name></param>
+            <vecequiv name="glVertexAttrib3sv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3sARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+            <param><ptype>GLshort</ptype> <name>y</name></param>
+            <param><ptype>GLshort</ptype> <name>z</name></param>
+            <alias name="glVertexAttrib3s"/>
+            <vecequiv name="glVertexAttrib3svARB"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3sNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+            <param><ptype>GLshort</ptype> <name>y</name></param>
+            <param><ptype>GLshort</ptype> <name>z</name></param>
+            <alias name="glVertexAttrib3s"/>
+            <vecequiv name="glVertexAttrib3svNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3sv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4191"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3svARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib3sv"/>
+            <glx type="render" opcode="4191"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib3svNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib3sv"/>
+            <glx type="render" opcode="4191"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4Nbv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLbyte</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4NbvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLbyte</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4Nbv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4Niv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4NivARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLint</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4Niv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4Nsv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLshort</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4NsvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4Nsv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4Nub</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLubyte</ptype> <name>x</name></param>
+            <param><ptype>GLubyte</ptype> <name>y</name></param>
+            <param><ptype>GLubyte</ptype> <name>z</name></param>
+            <param><ptype>GLubyte</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4NubARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLubyte</ptype> <name>x</name></param>
+            <param><ptype>GLubyte</ptype> <name>y</name></param>
+            <param><ptype>GLubyte</ptype> <name>z</name></param>
+            <param><ptype>GLubyte</ptype> <name>w</name></param>
+            <alias name="glVertexAttrib4Nub"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4Nubv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLubyte</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4201"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4NubvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLubyte</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4Nubv"/>
+            <glx type="render" opcode="4201"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4Nuiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLuint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4NuivARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLuint</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4Nuiv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4Nusv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLushort</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4NusvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLushort</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4Nusv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4bv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLbyte</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4bvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLbyte</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4bv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4d</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <param><ptype>GLdouble</ptype> <name>w</name></param>
+            <vecequiv name="glVertexAttrib4dv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4dARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <param><ptype>GLdouble</ptype> <name>w</name></param>
+            <alias name="glVertexAttrib4d"/>
+            <vecequiv name="glVertexAttrib4dvARB"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4dNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <param><ptype>GLdouble</ptype> <name>w</name></param>
+            <alias name="glVertexAttrib4d"/>
+            <vecequiv name="glVertexAttrib4dvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4200"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4dvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4dv"/>
+            <glx type="render" opcode="4200"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4dvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4dv"/>
+            <glx type="render" opcode="4200"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4f</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <param><ptype>GLfloat</ptype> <name>w</name></param>
+            <vecequiv name="glVertexAttrib4fv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4fARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <param><ptype>GLfloat</ptype> <name>w</name></param>
+            <alias name="glVertexAttrib4f"/>
+            <vecequiv name="glVertexAttrib4fvARB"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4fNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <param><ptype>GLfloat</ptype> <name>w</name></param>
+            <alias name="glVertexAttrib4f"/>
+            <vecequiv name="glVertexAttrib4fvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4fv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4196"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4fvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4fv"/>
+            <glx type="render" opcode="4196"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4fvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4fv"/>
+            <glx type="render" opcode="4196"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4hNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>x</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>y</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>z</name></param>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>w</name></param>
+            <vecequiv name="glVertexAttrib4hvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4hvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="Half16NV" len="4">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4260"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4iv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4ivARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLint</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4iv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4s</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+            <param><ptype>GLshort</ptype> <name>y</name></param>
+            <param><ptype>GLshort</ptype> <name>z</name></param>
+            <param><ptype>GLshort</ptype> <name>w</name></param>
+            <vecequiv name="glVertexAttrib4sv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4sARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+            <param><ptype>GLshort</ptype> <name>y</name></param>
+            <param><ptype>GLshort</ptype> <name>z</name></param>
+            <param><ptype>GLshort</ptype> <name>w</name></param>
+            <alias name="glVertexAttrib4s"/>
+            <vecequiv name="glVertexAttrib4svARB"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4sNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+            <param><ptype>GLshort</ptype> <name>y</name></param>
+            <param><ptype>GLshort</ptype> <name>z</name></param>
+            <param><ptype>GLshort</ptype> <name>w</name></param>
+            <alias name="glVertexAttrib4s"/>
+            <vecequiv name="glVertexAttrib4svNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4sv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4192"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4svARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4sv"/>
+            <glx type="render" opcode="4192"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4svNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4sv"/>
+            <glx type="render" opcode="4192"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4ubNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>x</name></param>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>y</name></param>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>z</name></param>
+            <param group="ColorUB"><ptype>GLubyte</ptype> <name>w</name></param>
+            <alias name="glVertexAttrib4Nub"/>
+            <vecequiv name="glVertexAttrib4ubvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4ubv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLubyte</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4ubvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLubyte</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4ubv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4ubvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param group="ColorUB" len="4">const <ptype>GLubyte</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4Nubv"/>
+            <glx type="render" opcode="4201"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4uiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLuint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4uivARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLuint</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4usv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLushort</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttrib4usvARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLushort</ptype> *<name>v</name></param>
+            <alias name="glVertexAttrib4usv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribArrayObjectATI</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="VertexAttribPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>normalized</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLuint</ptype> <name>buffer</name></param>
+            <param><ptype>GLuint</ptype> <name>offset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribBinding</name></proto>
+            <param><ptype>GLuint</ptype> <name>attribindex</name></param>
+            <param><ptype>GLuint</ptype> <name>bindingindex</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribDivisor</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>divisor</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribDivisorANGLE</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>divisor</name></param>
+            <alias name="glVertexAttribDivisor"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribDivisorARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>divisor</name></param>
+            <alias name="glVertexAttribDivisor"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribDivisorEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>divisor</name></param>
+            <alias name="glVertexAttribDivisor"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribDivisorNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>divisor</name></param>
+            <alias name="glVertexAttribDivisor"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribFormat</name></proto>
+            <param><ptype>GLuint</ptype> <name>attribindex</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>normalized</name></param>
+            <param><ptype>GLuint</ptype> <name>relativeoffset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribFormatNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>normalized</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI1i</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <vecequiv name="glVertexAttribI1iv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI1iEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <alias name="glVertexAttribI1i"/>
+            <vecequiv name="glVertexAttribI1ivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI1iv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI1ivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLint</ptype> *<name>v</name></param>
+            <alias name="glVertexAttribI1iv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI1ui</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>x</name></param>
+            <vecequiv name="glVertexAttribI1uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI1uiEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>x</name></param>
+            <alias name="glVertexAttribI1ui"/>
+            <vecequiv name="glVertexAttribI1uivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI1uiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI1uivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>v</name></param>
+            <alias name="glVertexAttribI1uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI2i</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+            <vecequiv name="glVertexAttribI2iv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI2iEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+            <alias name="glVertexAttribI2i"/>
+            <vecequiv name="glVertexAttribI2ivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI2iv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI2ivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLint</ptype> *<name>v</name></param>
+            <alias name="glVertexAttribI2iv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI2ui</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>x</name></param>
+            <param><ptype>GLuint</ptype> <name>y</name></param>
+            <vecequiv name="glVertexAttribI2uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI2uiEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>x</name></param>
+            <param><ptype>GLuint</ptype> <name>y</name></param>
+            <alias name="glVertexAttribI2ui"/>
+            <vecequiv name="glVertexAttribI2uivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI2uiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLuint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI2uivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLuint</ptype> *<name>v</name></param>
+            <alias name="glVertexAttribI2uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI3i</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLint</ptype> <name>z</name></param>
+            <vecequiv name="glVertexAttribI3iv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI3iEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLint</ptype> <name>z</name></param>
+            <alias name="glVertexAttribI3i"/>
+            <vecequiv name="glVertexAttribI3ivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI3iv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI3ivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLint</ptype> *<name>v</name></param>
+            <alias name="glVertexAttribI3iv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI3ui</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>x</name></param>
+            <param><ptype>GLuint</ptype> <name>y</name></param>
+            <param><ptype>GLuint</ptype> <name>z</name></param>
+            <vecequiv name="glVertexAttribI3uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI3uiEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>x</name></param>
+            <param><ptype>GLuint</ptype> <name>y</name></param>
+            <param><ptype>GLuint</ptype> <name>z</name></param>
+            <alias name="glVertexAttribI3ui"/>
+            <vecequiv name="glVertexAttribI3uivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI3uiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLuint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI3uivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLuint</ptype> *<name>v</name></param>
+            <alias name="glVertexAttribI3uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI4bv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLbyte</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI4bvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLbyte</ptype> *<name>v</name></param>
+            <alias name="glVertexAttribI4bv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI4i</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLint</ptype> <name>z</name></param>
+            <param><ptype>GLint</ptype> <name>w</name></param>
+            <vecequiv name="glVertexAttribI4iv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI4iEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLint</ptype> <name>z</name></param>
+            <param><ptype>GLint</ptype> <name>w</name></param>
+            <alias name="glVertexAttribI4i"/>
+            <vecequiv name="glVertexAttribI4ivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI4iv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI4ivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLint</ptype> *<name>v</name></param>
+            <alias name="glVertexAttribI4iv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI4sv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLshort</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI4svEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glVertexAttribI4sv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI4ubv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLubyte</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI4ubvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLubyte</ptype> *<name>v</name></param>
+            <alias name="glVertexAttribI4ubv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI4ui</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>x</name></param>
+            <param><ptype>GLuint</ptype> <name>y</name></param>
+            <param><ptype>GLuint</ptype> <name>z</name></param>
+            <param><ptype>GLuint</ptype> <name>w</name></param>
+            <vecequiv name="glVertexAttribI4uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI4uiEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint</ptype> <name>x</name></param>
+            <param><ptype>GLuint</ptype> <name>y</name></param>
+            <param><ptype>GLuint</ptype> <name>z</name></param>
+            <param><ptype>GLuint</ptype> <name>w</name></param>
+            <alias name="glVertexAttribI4ui"/>
+            <vecequiv name="glVertexAttribI4uivEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI4uiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLuint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI4uivEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLuint</ptype> *<name>v</name></param>
+            <alias name="glVertexAttribI4uiv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI4usv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLushort</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribI4usvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLushort</ptype> *<name>v</name></param>
+            <alias name="glVertexAttribI4usv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribIFormat</name></proto>
+            <param><ptype>GLuint</ptype> <name>attribindex</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>relativeoffset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribIFormatNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribIPointer</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="VertexAttribEnum"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(size,type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribIPointerEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="VertexAttribEnum"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(size,type,stride)">const void *<name>pointer</name></param>
+            <alias name="glVertexAttribIPointer"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL1d</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL1dEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <alias name="glVertexAttribL1d"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL1dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLdouble</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL1dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glVertexAttribL1dv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL1i64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>x</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL1i64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLint64EXT</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL1ui64ARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>x</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL1ui64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>x</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL1ui64vARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param>const <ptype>GLuint64EXT</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL1ui64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="1">const <ptype>GLuint64EXT</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL2d</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL2dEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <alias name="glVertexAttribL2d"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL2dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLdouble</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL2dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glVertexAttribL2dv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL2i64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL2i64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLint64EXT</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL2ui64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL2ui64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="2">const <ptype>GLuint64EXT</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL3d</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL3dEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <alias name="glVertexAttribL3d"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL3dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL3dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glVertexAttribL3dv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL3i64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>y</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL3i64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLint64EXT</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL3ui64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>y</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL3ui64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="3">const <ptype>GLuint64EXT</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL4d</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <param><ptype>GLdouble</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL4dEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <param><ptype>GLdouble</ptype> <name>w</name></param>
+            <alias name="glVertexAttribL4d"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL4dv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLdouble</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL4dvEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glVertexAttribL4dv"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL4i64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>y</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>z</name></param>
+            <param><ptype>GLint64EXT</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL4i64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLint64EXT</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL4ui64NV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>x</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>y</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>z</name></param>
+            <param><ptype>GLuint64EXT</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribL4ui64vNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLuint64EXT</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribLFormat</name></proto>
+            <param><ptype>GLuint</ptype> <name>attribindex</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>relativeoffset</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribLFormatNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribLPointer</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="size">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribLPointerEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="size">const void *<name>pointer</name></param>
+            <alias name="glVertexAttribLPointer"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribP1ui</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>normalized</name></param>
+            <param><ptype>GLuint</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribP1uiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>normalized</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribP2ui</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>normalized</name></param>
+            <param><ptype>GLuint</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribP2uiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>normalized</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribP3ui</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>normalized</name></param>
+            <param><ptype>GLuint</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribP3uiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>normalized</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribP4ui</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>normalized</name></param>
+            <param><ptype>GLuint</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribP4uiv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>normalized</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribParameteriAMD</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribPointer</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="VertexAttribPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>normalized</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(size,type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribPointerARB</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="VertexAttribPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param group="Boolean"><ptype>GLboolean</ptype> <name>normalized</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(size,type,stride)">const void *<name>pointer</name></param>
+            <alias name="glVertexAttribPointer"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribPointerNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLint</ptype> <name>fsize</name></param>
+            <param group="VertexAttribEnumNV"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(fsize,type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs1dvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4210"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs1fvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4206"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs1hvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="Half16NV" len="n">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4261"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs1svNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4202"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs2dvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*2">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4211"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs2fvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*2">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4207"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs2hvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="Half16NV" len="n">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4262"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs2svNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*2">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4203"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs3dvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4212"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs3fvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4208"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs3hvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="Half16NV" len="n">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4263"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs3svNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*3">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4204"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs4dvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4213"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs4fvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4209"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs4hvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>n</name></param>
+            <param group="Half16NV" len="n">const <ptype>GLhalfNV</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4264"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs4svNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="count*4">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4205"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexAttribs4ubvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param group="ColorUB" len="count*4">const <ptype>GLubyte</ptype> *<name>v</name></param>
+            <glx type="render" opcode="4214"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexBindingDivisor</name></proto>
+            <param><ptype>GLuint</ptype> <name>bindingindex</name></param>
+            <param><ptype>GLuint</ptype> <name>divisor</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexBlendARB</name></proto>
+            <param><ptype>GLint</ptype> <name>count</name></param>
+            <glx type="render" opcode="226"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexBlendEnvfATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLfloat</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexBlendEnviATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>pname</name></param>
+            <param><ptype>GLint</ptype> <name>param</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexFormatNV</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexP2ui</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexP2uiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexP3ui</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexP3uiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexP4ui</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLuint</ptype> <name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexP4uiv</name></proto>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="1">const <ptype>GLuint</ptype> *<name>value</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexPointer</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="VertexPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(size,type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexPointerEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="VertexPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="COMPSIZE(size,type,stride,count)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexPointerListIBM</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="VertexPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLint</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(size,type,stride)">const void **<name>pointer</name></param>
+            <param><ptype>GLint</ptype> <name>ptrstride</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexPointervINTEL</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="VertexPointerType"><ptype>GLenum</ptype> <name>type</name></param>
+            <param len="4">const void **<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream1dATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream1dvATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="1">const <ptype>GLdouble</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream1fATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream1fvATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="1">const <ptype>GLfloat</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream1iATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream1ivATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="1">const <ptype>GLint</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream1sATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream1svATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="1">const <ptype>GLshort</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream2dATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream2dvATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="2">const <ptype>GLdouble</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream2fATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream2fvATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="2">const <ptype>GLfloat</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream2iATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream2ivATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="2">const <ptype>GLint</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream2sATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+            <param><ptype>GLshort</ptype> <name>y</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream2svATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="2">const <ptype>GLshort</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream3dATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream3dvATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="3">const <ptype>GLdouble</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream3fATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream3fvATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="3">const <ptype>GLfloat</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream3iATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLint</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream3ivATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="3">const <ptype>GLint</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream3sATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+            <param><ptype>GLshort</ptype> <name>y</name></param>
+            <param><ptype>GLshort</ptype> <name>z</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream3svATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="3">const <ptype>GLshort</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream4dATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLdouble</ptype> <name>x</name></param>
+            <param><ptype>GLdouble</ptype> <name>y</name></param>
+            <param><ptype>GLdouble</ptype> <name>z</name></param>
+            <param><ptype>GLdouble</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream4dvATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="4">const <ptype>GLdouble</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream4fATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>z</name></param>
+            <param><ptype>GLfloat</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream4fvATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream4iATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLint</ptype> <name>x</name></param>
+            <param><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLint</ptype> <name>z</name></param>
+            <param><ptype>GLint</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream4ivATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="4">const <ptype>GLint</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream4sATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param><ptype>GLshort</ptype> <name>x</name></param>
+            <param><ptype>GLshort</ptype> <name>y</name></param>
+            <param><ptype>GLshort</ptype> <name>z</name></param>
+            <param><ptype>GLshort</ptype> <name>w</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexStream4svATI</name></proto>
+            <param group="VertexStreamATI"><ptype>GLenum</ptype> <name>stream</name></param>
+            <param len="4">const <ptype>GLshort</ptype> *<name>coords</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexWeightPointerEXT</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="VertexWeightPointerTypeEXT"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVertexWeightfEXT</name></proto>
+            <param><ptype>GLfloat</ptype> <name>weight</name></param>
+            <vecequiv name="glVertexWeightfvEXT"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexWeightfvEXT</name></proto>
+            <param len="1">const <ptype>GLfloat</ptype> *<name>weight</name></param>
+            <glx type="render" opcode="4135"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexWeighthNV</name></proto>
+            <param group="Half16NV"><ptype>GLhalfNV</ptype> <name>weight</name></param>
+            <vecequiv name="glVertexWeighthvNV"/>
+        </command>
+        <command>
+            <proto>void <name>glVertexWeighthvNV</name></proto>
+            <param group="Half16NV" len="1">const <ptype>GLhalfNV</ptype> *<name>weight</name></param>
+            <glx type="render" opcode="4256"/>
+        </command>
+        <command>
+            <proto><ptype>GLenum</ptype> <name>glVideoCaptureNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_capture_slot</name></param>
+            <param><ptype>GLuint</ptype> *<name>sequence_num</name></param>
+            <param><ptype>GLuint64EXT</ptype> *<name>capture_time</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVideoCaptureStreamParameterdvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_capture_slot</name></param>
+            <param><ptype>GLuint</ptype> <name>stream</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLdouble</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVideoCaptureStreamParameterfvNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_capture_slot</name></param>
+            <param><ptype>GLuint</ptype> <name>stream</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLfloat</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glVideoCaptureStreamParameterivNV</name></proto>
+            <param><ptype>GLuint</ptype> <name>video_capture_slot</name></param>
+            <param><ptype>GLuint</ptype> <name>stream</name></param>
+            <param><ptype>GLenum</ptype> <name>pname</name></param>
+            <param len="COMPSIZE(pname)">const <ptype>GLint</ptype> *<name>params</name></param>
+        </command>
+        <command>
+            <proto>void <name>glViewport</name></proto>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="WinCoord"><ptype>GLint</ptype> <name>y</name></param>
+            <param><ptype>GLsizei</ptype> <name>width</name></param>
+            <param><ptype>GLsizei</ptype> <name>height</name></param>
+            <glx type="render" opcode="191"/>
+        </command>
+        <command>
+            <proto>void <name>glViewportArrayv</name></proto>
+            <param><ptype>GLuint</ptype> <name>first</name></param>
+            <param><ptype>GLsizei</ptype> <name>count</name></param>
+            <param len="COMPSIZE(count)">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glViewportIndexedf</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param><ptype>GLfloat</ptype> <name>x</name></param>
+            <param><ptype>GLfloat</ptype> <name>y</name></param>
+            <param><ptype>GLfloat</ptype> <name>w</name></param>
+            <param><ptype>GLfloat</ptype> <name>h</name></param>
+        </command>
+        <command>
+            <proto>void <name>glViewportIndexedfv</name></proto>
+            <param><ptype>GLuint</ptype> <name>index</name></param>
+            <param len="4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glWaitSync</name></proto>
+            <param group="sync"><ptype>GLsync</ptype> <name>sync</name></param>
+            <param><ptype>GLbitfield</ptype> <name>flags</name></param>
+            <param><ptype>GLuint64</ptype> <name>timeout</name></param>
+        </command>
+        <command>
+            <proto>void <name>glWaitSyncAPPLE</name></proto>
+            <param><ptype>GLsync</ptype> <name>sync</name></param>
+            <param><ptype>GLbitfield</ptype> <name>flags</name></param>
+            <param><ptype>GLuint64</ptype> <name>timeout</name></param>
+            <alias name="glWaitSync"/>
+        </command>
+        <command>
+            <proto>void <name>glWeightPathsNV</name></proto>
+            <param group="Path"><ptype>GLuint</ptype> <name>resultPath</name></param>
+            <param><ptype>GLsizei</ptype> <name>numPaths</name></param>
+            <param group="Path" len="numPaths">const <ptype>GLuint</ptype> *<name>paths</name></param>
+            <param len="numPaths">const <ptype>GLfloat</ptype> *<name>weights</name></param>
+        </command>
+        <command>
+            <proto>void <name>glWeightPointerARB</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param group="WeightPointerTypeARB"><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glWeightPointerOES</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param><ptype>GLenum</ptype> <name>type</name></param>
+            <param><ptype>GLsizei</ptype> <name>stride</name></param>
+            <param len="COMPSIZE(type,stride)">const void *<name>pointer</name></param>
+        </command>
+        <command>
+            <proto>void <name>glWeightbvARB</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param len="size">const <ptype>GLbyte</ptype> *<name>weights</name></param>
+            <glx type="render" opcode="220"/>
+        </command>
+        <command>
+            <proto>void <name>glWeightdvARB</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param len="size">const <ptype>GLdouble</ptype> *<name>weights</name></param>
+            <glx type="render" opcode="228"/>
+        </command>
+        <command>
+            <proto>void <name>glWeightfvARB</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param len="size">const <ptype>GLfloat</ptype> *<name>weights</name></param>
+            <glx type="render" opcode="227"/>
+        </command>
+        <command>
+            <proto>void <name>glWeightivARB</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param len="size">const <ptype>GLint</ptype> *<name>weights</name></param>
+            <glx type="render" opcode="224"/>
+        </command>
+        <command>
+            <proto>void <name>glWeightsvARB</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param len="size">const <ptype>GLshort</ptype> *<name>weights</name></param>
+            <glx type="render" opcode="222"/>
+        </command>
+        <command>
+            <proto>void <name>glWeightubvARB</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param len="size">const <ptype>GLubyte</ptype> *<name>weights</name></param>
+            <glx type="render" opcode="221"/>
+        </command>
+        <command>
+            <proto>void <name>glWeightuivARB</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param len="size">const <ptype>GLuint</ptype> *<name>weights</name></param>
+            <glx type="render" opcode="225"/>
+        </command>
+        <command>
+            <proto>void <name>glWeightusvARB</name></proto>
+            <param><ptype>GLint</ptype> <name>size</name></param>
+            <param len="size">const <ptype>GLushort</ptype> *<name>weights</name></param>
+            <glx type="render" opcode="223"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2d</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>x</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>y</name></param>
+            <vecequiv name="glWindowPos2dv"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2dARB</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>x</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>y</name></param>
+            <alias name="glWindowPos2d"/>
+            <vecequiv name="glWindowPos2dvARB"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2dMESA</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>x</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>y</name></param>
+            <alias name="glWindowPos2d"/>
+            <vecequiv name="glWindowPos2dvMESA"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2dv</name></proto>
+            <param group="CoordD" len="2">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="230"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2dvARB</name></proto>
+            <param group="CoordD" len="2">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glWindowPos2dv"/>
+            <glx type="render" opcode="230"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2dvMESA</name></proto>
+            <param group="CoordD" len="2">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glWindowPos2dv"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2f</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>x</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>y</name></param>
+            <vecequiv name="glWindowPos2fv"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2fARB</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>x</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>y</name></param>
+            <alias name="glWindowPos2f"/>
+            <vecequiv name="glWindowPos2fvARB"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2fMESA</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>x</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>y</name></param>
+            <alias name="glWindowPos2f"/>
+            <vecequiv name="glWindowPos2fvMESA"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2fv</name></proto>
+            <param group="CoordF" len="2">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="230"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2fvARB</name></proto>
+            <param group="CoordF" len="2">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glWindowPos2fv"/>
+            <glx type="render" opcode="230"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2fvMESA</name></proto>
+            <param group="CoordF" len="2">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glWindowPos2fv"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2i</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>y</name></param>
+            <vecequiv name="glWindowPos2iv"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2iARB</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>y</name></param>
+            <alias name="glWindowPos2i"/>
+            <vecequiv name="glWindowPos2ivARB"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2iMESA</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>y</name></param>
+            <alias name="glWindowPos2i"/>
+            <vecequiv name="glWindowPos2ivMESA"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2iv</name></proto>
+            <param group="CoordI" len="2">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="230"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2ivARB</name></proto>
+            <param group="CoordI" len="2">const <ptype>GLint</ptype> *<name>v</name></param>
+            <alias name="glWindowPos2iv"/>
+            <glx type="render" opcode="230"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2ivMESA</name></proto>
+            <param group="CoordI" len="2">const <ptype>GLint</ptype> *<name>v</name></param>
+            <alias name="glWindowPos2iv"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2s</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>x</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>y</name></param>
+            <vecequiv name="glWindowPos2sv"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2sARB</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>x</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>y</name></param>
+            <alias name="glWindowPos2s"/>
+            <vecequiv name="glWindowPos2svARB"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2sMESA</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>x</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>y</name></param>
+            <alias name="glWindowPos2s"/>
+            <vecequiv name="glWindowPos2svMESA"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2sv</name></proto>
+            <param group="CoordS" len="2">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="230"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2svARB</name></proto>
+            <param group="CoordS" len="2">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glWindowPos2sv"/>
+            <glx type="render" opcode="230"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos2svMESA</name></proto>
+            <param group="CoordS" len="2">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glWindowPos2sv"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3d</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>x</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>y</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>z</name></param>
+            <vecequiv name="glWindowPos3dv"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3dARB</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>x</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>y</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>z</name></param>
+            <alias name="glWindowPos3d"/>
+            <vecequiv name="glWindowPos3dvARB"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3dMESA</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>x</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>y</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>z</name></param>
+            <alias name="glWindowPos3d"/>
+            <vecequiv name="glWindowPos3dvMESA"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3dv</name></proto>
+            <param group="CoordD" len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <glx type="render" opcode="230"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3dvARB</name></proto>
+            <param group="CoordD" len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glWindowPos3dv"/>
+            <glx type="render" opcode="230"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3dvMESA</name></proto>
+            <param group="CoordD" len="3">const <ptype>GLdouble</ptype> *<name>v</name></param>
+            <alias name="glWindowPos3dv"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3f</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>x</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>y</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>z</name></param>
+            <vecequiv name="glWindowPos3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3fARB</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>x</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>y</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>z</name></param>
+            <alias name="glWindowPos3f"/>
+            <vecequiv name="glWindowPos3fvARB"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3fMESA</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>x</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>y</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>z</name></param>
+            <alias name="glWindowPos3f"/>
+            <vecequiv name="glWindowPos3fvMESA"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3fv</name></proto>
+            <param group="CoordF" len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <glx type="render" opcode="230"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3fvARB</name></proto>
+            <param group="CoordF" len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glWindowPos3fv"/>
+            <glx type="render" opcode="230"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3fvMESA</name></proto>
+            <param group="CoordF" len="3">const <ptype>GLfloat</ptype> *<name>v</name></param>
+            <alias name="glWindowPos3fv"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3i</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>y</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>z</name></param>
+            <vecequiv name="glWindowPos3iv"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3iARB</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>y</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>z</name></param>
+            <alias name="glWindowPos3i"/>
+            <vecequiv name="glWindowPos3ivARB"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3iMESA</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>y</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>z</name></param>
+            <alias name="glWindowPos3i"/>
+            <vecequiv name="glWindowPos3ivMESA"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3iv</name></proto>
+            <param group="CoordI" len="3">const <ptype>GLint</ptype> *<name>v</name></param>
+            <glx type="render" opcode="230"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3ivARB</name></proto>
+            <param group="CoordI" len="3">const <ptype>GLint</ptype> *<name>v</name></param>
+            <alias name="glWindowPos3iv"/>
+            <glx type="render" opcode="230"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3ivMESA</name></proto>
+            <param group="CoordI" len="3">const <ptype>GLint</ptype> *<name>v</name></param>
+            <alias name="glWindowPos3iv"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3s</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>x</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>y</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>z</name></param>
+            <vecequiv name="glWindowPos3sv"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3sARB</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>x</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>y</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>z</name></param>
+            <alias name="glWindowPos3s"/>
+            <vecequiv name="glWindowPos3svARB"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3sMESA</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>x</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>y</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>z</name></param>
+            <alias name="glWindowPos3s"/>
+            <vecequiv name="glWindowPos3svMESA"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3sv</name></proto>
+            <param group="CoordS" len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <glx type="render" opcode="230"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3svARB</name></proto>
+            <param group="CoordS" len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glWindowPos3sv"/>
+            <glx type="render" opcode="230"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos3svMESA</name></proto>
+            <param group="CoordS" len="3">const <ptype>GLshort</ptype> *<name>v</name></param>
+            <alias name="glWindowPos3sv"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos4dMESA</name></proto>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>x</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>y</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>z</name></param>
+            <param group="CoordD"><ptype>GLdouble</ptype> <name>w</name></param>
+            <vecequiv name="glWindowPos4dvMESA"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos4dvMESA</name></proto>
+            <param group="CoordD" len="4">const <ptype>GLdouble</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos4fMESA</name></proto>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>x</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>y</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>z</name></param>
+            <param group="CoordF"><ptype>GLfloat</ptype> <name>w</name></param>
+            <vecequiv name="glWindowPos4fvMESA"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos4fvMESA</name></proto>
+            <param group="CoordF" len="4">const <ptype>GLfloat</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos4iMESA</name></proto>
+            <param group="CoordI"><ptype>GLint</ptype> <name>x</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>y</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>z</name></param>
+            <param group="CoordI"><ptype>GLint</ptype> <name>w</name></param>
+            <vecequiv name="glWindowPos4ivMESA"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos4ivMESA</name></proto>
+            <param group="CoordI" len="4">const <ptype>GLint</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos4sMESA</name></proto>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>x</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>y</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>z</name></param>
+            <param group="CoordS"><ptype>GLshort</ptype> <name>w</name></param>
+            <vecequiv name="glWindowPos4svMESA"/>
+        </command>
+        <command>
+            <proto>void <name>glWindowPos4svMESA</name></proto>
+            <param group="CoordS" len="4">const <ptype>GLshort</ptype> *<name>v</name></param>
+        </command>
+        <command>
+            <proto>void <name>glWriteMaskEXT</name></proto>
+            <param><ptype>GLuint</ptype> <name>res</name></param>
+            <param><ptype>GLuint</ptype> <name>in</name></param>
+            <param group="VertexShaderWriteMaskEXT"><ptype>GLenum</ptype> <name>outX</name></param>
+            <param group="VertexShaderWriteMaskEXT"><ptype>GLenum</ptype> <name>outY</name></param>
+            <param group="VertexShaderWriteMaskEXT"><ptype>GLenum</ptype> <name>outZ</name></param>
+            <param group="VertexShaderWriteMaskEXT"><ptype>GLenum</ptype> <name>outW</name></param>
+        </command>
+    </commands>
+
+    <!-- SECTION: GL API interface definitions. -->
+    <feature api="gl" name="GL_VERSION_1_0" number="1.0">
+        <require>
+            <type name="GLvoid" comment="No longer used in headers"/>
+            <command name="glCullFace"/>
+            <command name="glFrontFace"/>
+            <command name="glHint"/>
+            <command name="glLineWidth"/>
+            <command name="glPointSize"/>
+            <command name="glPolygonMode"/>
+            <command name="glScissor"/>
+            <command name="glTexParameterf"/>
+            <command name="glTexParameterfv"/>
+            <command name="glTexParameteri"/>
+            <command name="glTexParameteriv"/>
+            <command name="glTexImage1D"/>
+            <command name="glTexImage2D"/>
+            <command name="glDrawBuffer"/>
+            <command name="glClear"/>
+            <command name="glClearColor"/>
+            <command name="glClearStencil"/>
+            <command name="glClearDepth"/>
+            <command name="glStencilMask"/>
+            <command name="glColorMask"/>
+            <command name="glDepthMask"/>
+            <command name="glDisable"/>
+            <command name="glEnable"/>
+            <command name="glFinish"/>
+            <command name="glFlush"/>
+            <command name="glBlendFunc"/>
+            <command name="glLogicOp"/>
+            <command name="glStencilFunc"/>
+            <command name="glStencilOp"/>
+            <command name="glDepthFunc"/>
+            <command name="glPixelStoref"/>
+            <command name="glPixelStorei"/>
+            <command name="glReadBuffer"/>
+            <command name="glReadPixels"/>
+            <command name="glGetBooleanv"/>
+            <command name="glGetDoublev"/>
+            <command name="glGetError"/>
+            <command name="glGetFloatv"/>
+            <command name="glGetIntegerv"/>
+            <command name="glGetString"/>
+            <command name="glGetTexImage"/>
+            <command name="glGetTexParameterfv"/>
+            <command name="glGetTexParameteriv"/>
+            <command name="glGetTexLevelParameterfv"/>
+            <command name="glGetTexLevelParameteriv"/>
+            <command name="glIsEnabled"/>
+            <command name="glDepthRange"/>
+            <command name="glViewport"/>
+            <command name="glNewList"/>
+            <command name="glEndList"/>
+            <command name="glCallList"/>
+            <command name="glCallLists"/>
+            <command name="glDeleteLists"/>
+            <command name="glGenLists"/>
+            <command name="glListBase"/>
+            <command name="glBegin"/>
+            <command name="glBitmap"/>
+            <command name="glColor3b"/>
+            <command name="glColor3bv"/>
+            <command name="glColor3d"/>
+            <command name="glColor3dv"/>
+            <command name="glColor3f"/>
+            <command name="glColor3fv"/>
+            <command name="glColor3i"/>
+            <command name="glColor3iv"/>
+            <command name="glColor3s"/>
+            <command name="glColor3sv"/>
+            <command name="glColor3ub"/>
+            <command name="glColor3ubv"/>
+            <command name="glColor3ui"/>
+            <command name="glColor3uiv"/>
+            <command name="glColor3us"/>
+            <command name="glColor3usv"/>
+            <command name="glColor4b"/>
+            <command name="glColor4bv"/>
+            <command name="glColor4d"/>
+            <command name="glColor4dv"/>
+            <command name="glColor4f"/>
+            <command name="glColor4fv"/>
+            <command name="glColor4i"/>
+            <command name="glColor4iv"/>
+            <command name="glColor4s"/>
+            <command name="glColor4sv"/>
+            <command name="glColor4ub"/>
+            <command name="glColor4ubv"/>
+            <command name="glColor4ui"/>
+            <command name="glColor4uiv"/>
+            <command name="glColor4us"/>
+            <command name="glColor4usv"/>
+            <command name="glEdgeFlag"/>
+            <command name="glEdgeFlagv"/>
+            <command name="glEnd"/>
+            <command name="glIndexd"/>
+            <command name="glIndexdv"/>
+            <command name="glIndexf"/>
+            <command name="glIndexfv"/>
+            <command name="glIndexi"/>
+            <command name="glIndexiv"/>
+            <command name="glIndexs"/>
+            <command name="glIndexsv"/>
+            <command name="glNormal3b"/>
+            <command name="glNormal3bv"/>
+            <command name="glNormal3d"/>
+            <command name="glNormal3dv"/>
+            <command name="glNormal3f"/>
+            <command name="glNormal3fv"/>
+            <command name="glNormal3i"/>
+            <command name="glNormal3iv"/>
+            <command name="glNormal3s"/>
+            <command name="glNormal3sv"/>
+            <command name="glRasterPos2d"/>
+            <command name="glRasterPos2dv"/>
+            <command name="glRasterPos2f"/>
+            <command name="glRasterPos2fv"/>
+            <command name="glRasterPos2i"/>
+            <command name="glRasterPos2iv"/>
+            <command name="glRasterPos2s"/>
+            <command name="glRasterPos2sv"/>
+            <command name="glRasterPos3d"/>
+            <command name="glRasterPos3dv"/>
+            <command name="glRasterPos3f"/>
+            <command name="glRasterPos3fv"/>
+            <command name="glRasterPos3i"/>
+            <command name="glRasterPos3iv"/>
+            <command name="glRasterPos3s"/>
+            <command name="glRasterPos3sv"/>
+            <command name="glRasterPos4d"/>
+            <command name="glRasterPos4dv"/>
+            <command name="glRasterPos4f"/>
+            <command name="glRasterPos4fv"/>
+            <command name="glRasterPos4i"/>
+            <command name="glRasterPos4iv"/>
+            <command name="glRasterPos4s"/>
+            <command name="glRasterPos4sv"/>
+            <command name="glRectd"/>
+            <command name="glRectdv"/>
+            <command name="glRectf"/>
+            <command name="glRectfv"/>
+            <command name="glRecti"/>
+            <command name="glRectiv"/>
+            <command name="glRects"/>
+            <command name="glRectsv"/>
+            <command name="glTexCoord1d"/>
+            <command name="glTexCoord1dv"/>
+            <command name="glTexCoord1f"/>
+            <command name="glTexCoord1fv"/>
+            <command name="glTexCoord1i"/>
+            <command name="glTexCoord1iv"/>
+            <command name="glTexCoord1s"/>
+            <command name="glTexCoord1sv"/>
+            <command name="glTexCoord2d"/>
+            <command name="glTexCoord2dv"/>
+            <command name="glTexCoord2f"/>
+            <command name="glTexCoord2fv"/>
+            <command name="glTexCoord2i"/>
+            <command name="glTexCoord2iv"/>
+            <command name="glTexCoord2s"/>
+            <command name="glTexCoord2sv"/>
+            <command name="glTexCoord3d"/>
+            <command name="glTexCoord3dv"/>
+            <command name="glTexCoord3f"/>
+            <command name="glTexCoord3fv"/>
+            <command name="glTexCoord3i"/>
+            <command name="glTexCoord3iv"/>
+            <command name="glTexCoord3s"/>
+            <command name="glTexCoord3sv"/>
+            <command name="glTexCoord4d"/>
+            <command name="glTexCoord4dv"/>
+            <command name="glTexCoord4f"/>
+            <command name="glTexCoord4fv"/>
+            <command name="glTexCoord4i"/>
+            <command name="glTexCoord4iv"/>
+            <command name="glTexCoord4s"/>
+            <command name="glTexCoord4sv"/>
+            <command name="glVertex2d"/>
+            <command name="glVertex2dv"/>
+            <command name="glVertex2f"/>
+            <command name="glVertex2fv"/>
+            <command name="glVertex2i"/>
+            <command name="glVertex2iv"/>
+            <command name="glVertex2s"/>
+            <command name="glVertex2sv"/>
+            <command name="glVertex3d"/>
+            <command name="glVertex3dv"/>
+            <command name="glVertex3f"/>
+            <command name="glVertex3fv"/>
+            <command name="glVertex3i"/>
+            <command name="glVertex3iv"/>
+            <command name="glVertex3s"/>
+            <command name="glVertex3sv"/>
+            <command name="glVertex4d"/>
+            <command name="glVertex4dv"/>
+            <command name="glVertex4f"/>
+            <command name="glVertex4fv"/>
+            <command name="glVertex4i"/>
+            <command name="glVertex4iv"/>
+            <command name="glVertex4s"/>
+            <command name="glVertex4sv"/>
+            <command name="glClipPlane"/>
+            <command name="glColorMaterial"/>
+            <command name="glFogf"/>
+            <command name="glFogfv"/>
+            <command name="glFogi"/>
+            <command name="glFogiv"/>
+            <command name="glLightf"/>
+            <command name="glLightfv"/>
+            <command name="glLighti"/>
+            <command name="glLightiv"/>
+            <command name="glLightModelf"/>
+            <command name="glLightModelfv"/>
+            <command name="glLightModeli"/>
+            <command name="glLightModeliv"/>
+            <command name="glLineStipple"/>
+            <command name="glMaterialf"/>
+            <command name="glMaterialfv"/>
+            <command name="glMateriali"/>
+            <command name="glMaterialiv"/>
+            <command name="glPolygonStipple"/>
+            <command name="glShadeModel"/>
+            <command name="glTexEnvf"/>
+            <command name="glTexEnvfv"/>
+            <command name="glTexEnvi"/>
+            <command name="glTexEnviv"/>
+            <command name="glTexGend"/>
+            <command name="glTexGendv"/>
+            <command name="glTexGenf"/>
+            <command name="glTexGenfv"/>
+            <command name="glTexGeni"/>
+            <command name="glTexGeniv"/>
+            <command name="glFeedbackBuffer"/>
+            <command name="glSelectBuffer"/>
+            <command name="glRenderMode"/>
+            <command name="glInitNames"/>
+            <command name="glLoadName"/>
+            <command name="glPassThrough"/>
+            <command name="glPopName"/>
+            <command name="glPushName"/>
+            <command name="glClearAccum"/>
+            <command name="glClearIndex"/>
+            <command name="glIndexMask"/>
+            <command name="glAccum"/>
+            <command name="glPopAttrib"/>
+            <command name="glPushAttrib"/>
+            <command name="glMap1d"/>
+            <command name="glMap1f"/>
+            <command name="glMap2d"/>
+            <command name="glMap2f"/>
+            <command name="glMapGrid1d"/>
+            <command name="glMapGrid1f"/>
+            <command name="glMapGrid2d"/>
+            <command name="glMapGrid2f"/>
+            <command name="glEvalCoord1d"/>
+            <command name="glEvalCoord1dv"/>
+            <command name="glEvalCoord1f"/>
+            <command name="glEvalCoord1fv"/>
+            <command name="glEvalCoord2d"/>
+            <command name="glEvalCoord2dv"/>
+            <command name="glEvalCoord2f"/>
+            <command name="glEvalCoord2fv"/>
+            <command name="glEvalMesh1"/>
+            <command name="glEvalPoint1"/>
+            <command name="glEvalMesh2"/>
+            <command name="glEvalPoint2"/>
+            <command name="glAlphaFunc"/>
+            <command name="glPixelZoom"/>
+            <command name="glPixelTransferf"/>
+            <command name="glPixelTransferi"/>
+            <command name="glPixelMapfv"/>
+            <command name="glPixelMapuiv"/>
+            <command name="glPixelMapusv"/>
+            <command name="glCopyPixels"/>
+            <command name="glDrawPixels"/>
+            <command name="glGetClipPlane"/>
+            <command name="glGetLightfv"/>
+            <command name="glGetLightiv"/>
+            <command name="glGetMapdv"/>
+            <command name="glGetMapfv"/>
+            <command name="glGetMapiv"/>
+            <command name="glGetMaterialfv"/>
+            <command name="glGetMaterialiv"/>
+            <command name="glGetPixelMapfv"/>
+            <command name="glGetPixelMapuiv"/>
+            <command name="glGetPixelMapusv"/>
+            <command name="glGetPolygonStipple"/>
+            <command name="glGetTexEnvfv"/>
+            <command name="glGetTexEnviv"/>
+            <command name="glGetTexGendv"/>
+            <command name="glGetTexGenfv"/>
+            <command name="glGetTexGeniv"/>
+            <command name="glIsList"/>
+            <command name="glFrustum"/>
+            <command name="glLoadIdentity"/>
+            <command name="glLoadMatrixf"/>
+            <command name="glLoadMatrixd"/>
+            <command name="glMatrixMode"/>
+            <command name="glMultMatrixf"/>
+            <command name="glMultMatrixd"/>
+            <command name="glOrtho"/>
+            <command name="glPopMatrix"/>
+            <command name="glPushMatrix"/>
+            <command name="glRotated"/>
+            <command name="glRotatef"/>
+            <command name="glScaled"/>
+            <command name="glScalef"/>
+            <command name="glTranslated"/>
+            <command name="glTranslatef"/>
+        </require>
+    </feature>
+    <feature api="gl" name="GL_VERSION_1_1" number="1.1">
+        <require>
+            <type name="GLclampf" comment="No longer used in GL 1.1, but still defined in Mesa gl.h"/>
+            <type name="GLclampd" comment="No longer used in GL 1.1, but still defined in Mesa gl.h"/>
+            <!-- Many of these are really VERSION_1_0 enums -->
+            <enum name="GL_DEPTH_BUFFER_BIT"/>
+            <enum name="GL_STENCIL_BUFFER_BIT"/>
+            <enum name="GL_COLOR_BUFFER_BIT"/>
+            <enum name="GL_FALSE"/>
+            <enum name="GL_TRUE"/>
+            <enum name="GL_POINTS"/>
+            <enum name="GL_LINES"/>
+            <enum name="GL_LINE_LOOP"/>
+            <enum name="GL_LINE_STRIP"/>
+            <enum name="GL_TRIANGLES"/>
+            <enum name="GL_TRIANGLE_STRIP"/>
+            <enum name="GL_TRIANGLE_FAN"/>
+            <enum name="GL_QUADS"/>
+            <enum name="GL_NEVER"/>
+            <enum name="GL_LESS"/>
+            <enum name="GL_EQUAL"/>
+            <enum name="GL_LEQUAL"/>
+            <enum name="GL_GREATER"/>
+            <enum name="GL_NOTEQUAL"/>
+            <enum name="GL_GEQUAL"/>
+            <enum name="GL_ALWAYS"/>
+            <enum name="GL_ZERO"/>
+            <enum name="GL_ONE"/>
+            <enum name="GL_SRC_COLOR"/>
+            <enum name="GL_ONE_MINUS_SRC_COLOR"/>
+            <enum name="GL_SRC_ALPHA"/>
+            <enum name="GL_ONE_MINUS_SRC_ALPHA"/>
+            <enum name="GL_DST_ALPHA"/>
+            <enum name="GL_ONE_MINUS_DST_ALPHA"/>
+            <enum name="GL_DST_COLOR"/>
+            <enum name="GL_ONE_MINUS_DST_COLOR"/>
+            <enum name="GL_SRC_ALPHA_SATURATE"/>
+            <enum name="GL_NONE"/>
+            <enum name="GL_FRONT_LEFT"/>
+            <enum name="GL_FRONT_RIGHT"/>
+            <enum name="GL_BACK_LEFT"/>
+            <enum name="GL_BACK_RIGHT"/>
+            <enum name="GL_FRONT"/>
+            <enum name="GL_BACK"/>
+            <enum name="GL_LEFT"/>
+            <enum name="GL_RIGHT"/>
+            <enum name="GL_FRONT_AND_BACK"/>
+            <enum name="GL_NO_ERROR"/>
+            <enum name="GL_INVALID_ENUM"/>
+            <enum name="GL_INVALID_VALUE"/>
+            <enum name="GL_INVALID_OPERATION"/>
+            <enum name="GL_OUT_OF_MEMORY"/>
+            <enum name="GL_CW"/>
+            <enum name="GL_CCW"/>
+            <enum name="GL_POINT_SIZE"/>
+            <enum name="GL_POINT_SIZE_RANGE"/>
+            <enum name="GL_POINT_SIZE_GRANULARITY"/>
+            <enum name="GL_LINE_SMOOTH"/>
+            <enum name="GL_LINE_WIDTH"/>
+            <enum name="GL_LINE_WIDTH_RANGE"/>
+            <enum name="GL_LINE_WIDTH_GRANULARITY"/>
+            <enum name="GL_POLYGON_MODE"/>
+            <enum name="GL_POLYGON_SMOOTH"/>
+            <enum name="GL_CULL_FACE"/>
+            <enum name="GL_CULL_FACE_MODE"/>
+            <enum name="GL_FRONT_FACE"/>
+            <enum name="GL_DEPTH_RANGE"/>
+            <enum name="GL_DEPTH_TEST"/>
+            <enum name="GL_DEPTH_WRITEMASK"/>
+            <enum name="GL_DEPTH_CLEAR_VALUE"/>
+            <enum name="GL_DEPTH_FUNC"/>
+            <enum name="GL_STENCIL_TEST"/>
+            <enum name="GL_STENCIL_CLEAR_VALUE"/>
+            <enum name="GL_STENCIL_FUNC"/>
+            <enum name="GL_STENCIL_VALUE_MASK"/>
+            <enum name="GL_STENCIL_FAIL"/>
+            <enum name="GL_STENCIL_PASS_DEPTH_FAIL"/>
+            <enum name="GL_STENCIL_PASS_DEPTH_PASS"/>
+            <enum name="GL_STENCIL_REF"/>
+            <enum name="GL_STENCIL_WRITEMASK"/>
+            <enum name="GL_VIEWPORT"/>
+            <enum name="GL_DITHER"/>
+            <enum name="GL_BLEND_DST"/>
+            <enum name="GL_BLEND_SRC"/>
+            <enum name="GL_BLEND"/>
+            <enum name="GL_LOGIC_OP_MODE"/>
+            <enum name="GL_COLOR_LOGIC_OP"/>
+            <enum name="GL_DRAW_BUFFER"/>
+            <enum name="GL_READ_BUFFER"/>
+            <enum name="GL_SCISSOR_BOX"/>
+            <enum name="GL_SCISSOR_TEST"/>
+            <enum name="GL_COLOR_CLEAR_VALUE"/>
+            <enum name="GL_COLOR_WRITEMASK"/>
+            <enum name="GL_DOUBLEBUFFER"/>
+            <enum name="GL_STEREO"/>
+            <enum name="GL_LINE_SMOOTH_HINT"/>
+            <enum name="GL_POLYGON_SMOOTH_HINT"/>
+            <enum name="GL_UNPACK_SWAP_BYTES"/>
+            <enum name="GL_UNPACK_LSB_FIRST"/>
+            <enum name="GL_UNPACK_ROW_LENGTH"/>
+            <enum name="GL_UNPACK_SKIP_ROWS"/>
+            <enum name="GL_UNPACK_SKIP_PIXELS"/>
+            <enum name="GL_UNPACK_ALIGNMENT"/>
+            <enum name="GL_PACK_SWAP_BYTES"/>
+            <enum name="GL_PACK_LSB_FIRST"/>
+            <enum name="GL_PACK_ROW_LENGTH"/>
+            <enum name="GL_PACK_SKIP_ROWS"/>
+            <enum name="GL_PACK_SKIP_PIXELS"/>
+            <enum name="GL_PACK_ALIGNMENT"/>
+            <enum name="GL_MAX_TEXTURE_SIZE"/>
+            <enum name="GL_MAX_VIEWPORT_DIMS"/>
+            <enum name="GL_SUBPIXEL_BITS"/>
+            <enum name="GL_TEXTURE_1D"/>
+            <enum name="GL_TEXTURE_2D"/>
+            <enum name="GL_POLYGON_OFFSET_UNITS"/>
+            <enum name="GL_POLYGON_OFFSET_POINT"/>
+            <enum name="GL_POLYGON_OFFSET_LINE"/>
+            <enum name="GL_POLYGON_OFFSET_FILL"/>
+            <enum name="GL_POLYGON_OFFSET_FACTOR"/>
+            <enum name="GL_TEXTURE_BINDING_1D"/>
+            <enum name="GL_TEXTURE_BINDING_2D"/>
+            <enum name="GL_TEXTURE_WIDTH"/>
+            <enum name="GL_TEXTURE_HEIGHT"/>
+            <enum name="GL_TEXTURE_INTERNAL_FORMAT"/>
+            <enum name="GL_TEXTURE_BORDER_COLOR"/>
+            <enum name="GL_TEXTURE_RED_SIZE"/>
+            <enum name="GL_TEXTURE_GREEN_SIZE"/>
+            <enum name="GL_TEXTURE_BLUE_SIZE"/>
+            <enum name="GL_TEXTURE_ALPHA_SIZE"/>
+            <enum name="GL_DONT_CARE"/>
+            <enum name="GL_FASTEST"/>
+            <enum name="GL_NICEST"/>
+            <enum name="GL_BYTE"/>
+            <enum name="GL_UNSIGNED_BYTE"/>
+            <enum name="GL_SHORT"/>
+            <enum name="GL_UNSIGNED_SHORT"/>
+            <enum name="GL_INT"/>
+            <enum name="GL_UNSIGNED_INT"/>
+            <enum name="GL_FLOAT"/>
+            <enum name="GL_DOUBLE"/>
+            <enum name="GL_STACK_OVERFLOW"/>
+            <enum name="GL_STACK_UNDERFLOW"/>
+            <enum name="GL_CLEAR"/>
+            <enum name="GL_AND"/>
+            <enum name="GL_AND_REVERSE"/>
+            <enum name="GL_COPY"/>
+            <enum name="GL_AND_INVERTED"/>
+            <enum name="GL_NOOP"/>
+            <enum name="GL_XOR"/>
+            <enum name="GL_OR"/>
+            <enum name="GL_NOR"/>
+            <enum name="GL_EQUIV"/>
+            <enum name="GL_INVERT"/>
+            <enum name="GL_OR_REVERSE"/>
+            <enum name="GL_COPY_INVERTED"/>
+            <enum name="GL_OR_INVERTED"/>
+            <enum name="GL_NAND"/>
+            <enum name="GL_SET"/>
+            <enum name="GL_TEXTURE"/>
+            <enum name="GL_COLOR"/>
+            <enum name="GL_DEPTH"/>
+            <enum name="GL_STENCIL"/>
+            <enum name="GL_STENCIL_INDEX"/>
+            <enum name="GL_DEPTH_COMPONENT"/>
+            <enum name="GL_RED"/>
+            <enum name="GL_GREEN"/>
+            <enum name="GL_BLUE"/>
+            <enum name="GL_ALPHA"/>
+            <enum name="GL_RGB"/>
+            <enum name="GL_RGBA"/>
+            <enum name="GL_POINT"/>
+            <enum name="GL_LINE"/>
+            <enum name="GL_FILL"/>
+            <enum name="GL_KEEP"/>
+            <enum name="GL_REPLACE"/>
+            <enum name="GL_INCR"/>
+            <enum name="GL_DECR"/>
+            <enum name="GL_VENDOR"/>
+            <enum name="GL_RENDERER"/>
+            <enum name="GL_VERSION"/>
+            <enum name="GL_EXTENSIONS"/>
+            <enum name="GL_NEAREST"/>
+            <enum name="GL_LINEAR"/>
+            <enum name="GL_NEAREST_MIPMAP_NEAREST"/>
+            <enum name="GL_LINEAR_MIPMAP_NEAREST"/>
+            <enum name="GL_NEAREST_MIPMAP_LINEAR"/>
+            <enum name="GL_LINEAR_MIPMAP_LINEAR"/>
+            <enum name="GL_TEXTURE_MAG_FILTER"/>
+            <enum name="GL_TEXTURE_MIN_FILTER"/>
+            <enum name="GL_TEXTURE_WRAP_S"/>
+            <enum name="GL_TEXTURE_WRAP_T"/>
+            <enum name="GL_PROXY_TEXTURE_1D"/>
+            <enum name="GL_PROXY_TEXTURE_2D"/>
+            <enum name="GL_REPEAT"/>
+            <enum name="GL_R3_G3_B2"/>
+            <enum name="GL_RGB4"/>
+            <enum name="GL_RGB5"/>
+            <enum name="GL_RGB8"/>
+            <enum name="GL_RGB10"/>
+            <enum name="GL_RGB12"/>
+            <enum name="GL_RGB16"/>
+            <enum name="GL_RGBA2"/>
+            <enum name="GL_RGBA4"/>
+            <enum name="GL_RGB5_A1"/>
+            <enum name="GL_RGBA8"/>
+            <enum name="GL_RGB10_A2"/>
+            <enum name="GL_RGBA12"/>
+            <enum name="GL_RGBA16"/>
+            <enum name="GL_CURRENT_BIT"/>
+            <enum name="GL_POINT_BIT"/>
+            <enum name="GL_LINE_BIT"/>
+            <enum name="GL_POLYGON_BIT"/>
+            <enum name="GL_POLYGON_STIPPLE_BIT"/>
+            <enum name="GL_PIXEL_MODE_BIT"/>
+            <enum name="GL_LIGHTING_BIT"/>
+            <enum name="GL_FOG_BIT"/>
+            <enum name="GL_ACCUM_BUFFER_BIT"/>
+            <enum name="GL_VIEWPORT_BIT"/>
+            <enum name="GL_TRANSFORM_BIT"/>
+            <enum name="GL_ENABLE_BIT"/>
+            <enum name="GL_HINT_BIT"/>
+            <enum name="GL_EVAL_BIT"/>
+            <enum name="GL_LIST_BIT"/>
+            <enum name="GL_TEXTURE_BIT"/>
+            <enum name="GL_SCISSOR_BIT"/>
+            <enum name="GL_ALL_ATTRIB_BITS"/>
+            <enum name="GL_CLIENT_PIXEL_STORE_BIT"/>
+            <enum name="GL_CLIENT_VERTEX_ARRAY_BIT"/>
+            <enum name="GL_CLIENT_ALL_ATTRIB_BITS"/>
+            <enum name="GL_QUAD_STRIP"/>
+            <enum name="GL_POLYGON"/>
+            <enum name="GL_ACCUM"/>
+            <enum name="GL_LOAD"/>
+            <enum name="GL_RETURN"/>
+            <enum name="GL_MULT"/>
+            <enum name="GL_ADD"/>
+            <enum name="GL_AUX0"/>
+            <enum name="GL_AUX1"/>
+            <enum name="GL_AUX2"/>
+            <enum name="GL_AUX3"/>
+            <enum name="GL_2D"/>
+            <enum name="GL_3D"/>
+            <enum name="GL_3D_COLOR"/>
+            <enum name="GL_3D_COLOR_TEXTURE"/>
+            <enum name="GL_4D_COLOR_TEXTURE"/>
+            <enum name="GL_PASS_THROUGH_TOKEN"/>
+            <enum name="GL_POINT_TOKEN"/>
+            <enum name="GL_LINE_TOKEN"/>
+            <enum name="GL_POLYGON_TOKEN"/>
+            <enum name="GL_BITMAP_TOKEN"/>
+            <enum name="GL_DRAW_PIXEL_TOKEN"/>
+            <enum name="GL_COPY_PIXEL_TOKEN"/>
+            <enum name="GL_LINE_RESET_TOKEN"/>
+            <enum name="GL_EXP"/>
+            <enum name="GL_EXP2"/>
+            <enum name="GL_COEFF"/>
+            <enum name="GL_ORDER"/>
+            <enum name="GL_DOMAIN"/>
+            <enum name="GL_PIXEL_MAP_I_TO_I"/>
+            <enum name="GL_PIXEL_MAP_S_TO_S"/>
+            <enum name="GL_PIXEL_MAP_I_TO_R"/>
+            <enum name="GL_PIXEL_MAP_I_TO_G"/>
+            <enum name="GL_PIXEL_MAP_I_TO_B"/>
+            <enum name="GL_PIXEL_MAP_I_TO_A"/>
+            <enum name="GL_PIXEL_MAP_R_TO_R"/>
+            <enum name="GL_PIXEL_MAP_G_TO_G"/>
+            <enum name="GL_PIXEL_MAP_B_TO_B"/>
+            <enum name="GL_PIXEL_MAP_A_TO_A"/>
+            <enum name="GL_VERTEX_ARRAY_POINTER"/>
+            <enum name="GL_NORMAL_ARRAY_POINTER"/>
+            <enum name="GL_COLOR_ARRAY_POINTER"/>
+            <enum name="GL_INDEX_ARRAY_POINTER"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_POINTER"/>
+            <enum name="GL_EDGE_FLAG_ARRAY_POINTER"/>
+            <enum name="GL_FEEDBACK_BUFFER_POINTER"/>
+            <enum name="GL_SELECTION_BUFFER_POINTER"/>
+            <enum name="GL_CURRENT_COLOR"/>
+            <enum name="GL_CURRENT_INDEX"/>
+            <enum name="GL_CURRENT_NORMAL"/>
+            <enum name="GL_CURRENT_TEXTURE_COORDS"/>
+            <enum name="GL_CURRENT_RASTER_COLOR"/>
+            <enum name="GL_CURRENT_RASTER_INDEX"/>
+            <enum name="GL_CURRENT_RASTER_TEXTURE_COORDS"/>
+            <enum name="GL_CURRENT_RASTER_POSITION"/>
+            <enum name="GL_CURRENT_RASTER_POSITION_VALID"/>
+            <enum name="GL_CURRENT_RASTER_DISTANCE"/>
+            <enum name="GL_POINT_SMOOTH"/>
+            <enum name="GL_LINE_STIPPLE"/>
+            <enum name="GL_LINE_STIPPLE_PATTERN"/>
+            <enum name="GL_LINE_STIPPLE_REPEAT"/>
+            <enum name="GL_LIST_MODE"/>
+            <enum name="GL_MAX_LIST_NESTING"/>
+            <enum name="GL_LIST_BASE"/>
+            <enum name="GL_LIST_INDEX"/>
+            <enum name="GL_POLYGON_STIPPLE"/>
+            <enum name="GL_EDGE_FLAG"/>
+            <enum name="GL_LIGHTING"/>
+            <enum name="GL_LIGHT_MODEL_LOCAL_VIEWER"/>
+            <enum name="GL_LIGHT_MODEL_TWO_SIDE"/>
+            <enum name="GL_LIGHT_MODEL_AMBIENT"/>
+            <enum name="GL_SHADE_MODEL"/>
+            <enum name="GL_COLOR_MATERIAL_FACE"/>
+            <enum name="GL_COLOR_MATERIAL_PARAMETER"/>
+            <enum name="GL_COLOR_MATERIAL"/>
+            <enum name="GL_FOG"/>
+            <enum name="GL_FOG_INDEX"/>
+            <enum name="GL_FOG_DENSITY"/>
+            <enum name="GL_FOG_START"/>
+            <enum name="GL_FOG_END"/>
+            <enum name="GL_FOG_MODE"/>
+            <enum name="GL_FOG_COLOR"/>
+            <enum name="GL_ACCUM_CLEAR_VALUE"/>
+            <enum name="GL_MATRIX_MODE"/>
+            <enum name="GL_NORMALIZE"/>
+            <enum name="GL_MODELVIEW_STACK_DEPTH"/>
+            <enum name="GL_PROJECTION_STACK_DEPTH"/>
+            <enum name="GL_TEXTURE_STACK_DEPTH"/>
+            <enum name="GL_MODELVIEW_MATRIX"/>
+            <enum name="GL_PROJECTION_MATRIX"/>
+            <enum name="GL_TEXTURE_MATRIX"/>
+            <enum name="GL_ATTRIB_STACK_DEPTH"/>
+            <enum name="GL_CLIENT_ATTRIB_STACK_DEPTH"/>
+            <enum name="GL_ALPHA_TEST"/>
+            <enum name="GL_ALPHA_TEST_FUNC"/>
+            <enum name="GL_ALPHA_TEST_REF"/>
+            <enum name="GL_INDEX_LOGIC_OP"/>
+            <enum name="GL_LOGIC_OP"/>
+            <enum name="GL_AUX_BUFFERS"/>
+            <enum name="GL_INDEX_CLEAR_VALUE"/>
+            <enum name="GL_INDEX_WRITEMASK"/>
+            <enum name="GL_INDEX_MODE"/>
+            <enum name="GL_RGBA_MODE"/>
+            <enum name="GL_RENDER_MODE"/>
+            <enum name="GL_PERSPECTIVE_CORRECTION_HINT"/>
+            <enum name="GL_POINT_SMOOTH_HINT"/>
+            <enum name="GL_FOG_HINT"/>
+            <enum name="GL_TEXTURE_GEN_S"/>
+            <enum name="GL_TEXTURE_GEN_T"/>
+            <enum name="GL_TEXTURE_GEN_R"/>
+            <enum name="GL_TEXTURE_GEN_Q"/>
+            <enum name="GL_PIXEL_MAP_I_TO_I_SIZE"/>
+            <enum name="GL_PIXEL_MAP_S_TO_S_SIZE"/>
+            <enum name="GL_PIXEL_MAP_I_TO_R_SIZE"/>
+            <enum name="GL_PIXEL_MAP_I_TO_G_SIZE"/>
+            <enum name="GL_PIXEL_MAP_I_TO_B_SIZE"/>
+            <enum name="GL_PIXEL_MAP_I_TO_A_SIZE"/>
+            <enum name="GL_PIXEL_MAP_R_TO_R_SIZE"/>
+            <enum name="GL_PIXEL_MAP_G_TO_G_SIZE"/>
+            <enum name="GL_PIXEL_MAP_B_TO_B_SIZE"/>
+            <enum name="GL_PIXEL_MAP_A_TO_A_SIZE"/>
+            <enum name="GL_MAP_COLOR"/>
+            <enum name="GL_MAP_STENCIL"/>
+            <enum name="GL_INDEX_SHIFT"/>
+            <enum name="GL_INDEX_OFFSET"/>
+            <enum name="GL_RED_SCALE"/>
+            <enum name="GL_RED_BIAS"/>
+            <enum name="GL_ZOOM_X"/>
+            <enum name="GL_ZOOM_Y"/>
+            <enum name="GL_GREEN_SCALE"/>
+            <enum name="GL_GREEN_BIAS"/>
+            <enum name="GL_BLUE_SCALE"/>
+            <enum name="GL_BLUE_BIAS"/>
+            <enum name="GL_ALPHA_SCALE"/>
+            <enum name="GL_ALPHA_BIAS"/>
+            <enum name="GL_DEPTH_SCALE"/>
+            <enum name="GL_DEPTH_BIAS"/>
+            <enum name="GL_MAX_EVAL_ORDER"/>
+            <enum name="GL_MAX_LIGHTS"/>
+            <enum name="GL_MAX_CLIP_PLANES"/>
+            <enum name="GL_MAX_PIXEL_MAP_TABLE"/>
+            <enum name="GL_MAX_ATTRIB_STACK_DEPTH"/>
+            <enum name="GL_MAX_MODELVIEW_STACK_DEPTH"/>
+            <enum name="GL_MAX_NAME_STACK_DEPTH"/>
+            <enum name="GL_MAX_PROJECTION_STACK_DEPTH"/>
+            <enum name="GL_MAX_TEXTURE_STACK_DEPTH"/>
+            <enum name="GL_MAX_CLIENT_ATTRIB_STACK_DEPTH"/>
+            <enum name="GL_INDEX_BITS"/>
+            <enum name="GL_RED_BITS"/>
+            <enum name="GL_GREEN_BITS"/>
+            <enum name="GL_BLUE_BITS"/>
+            <enum name="GL_ALPHA_BITS"/>
+            <enum name="GL_DEPTH_BITS"/>
+            <enum name="GL_STENCIL_BITS"/>
+            <enum name="GL_ACCUM_RED_BITS"/>
+            <enum name="GL_ACCUM_GREEN_BITS"/>
+            <enum name="GL_ACCUM_BLUE_BITS"/>
+            <enum name="GL_ACCUM_ALPHA_BITS"/>
+            <enum name="GL_NAME_STACK_DEPTH"/>
+            <enum name="GL_AUTO_NORMAL"/>
+            <enum name="GL_MAP1_COLOR_4"/>
+            <enum name="GL_MAP1_INDEX"/>
+            <enum name="GL_MAP1_NORMAL"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_1"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_2"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_3"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_4"/>
+            <enum name="GL_MAP1_VERTEX_3"/>
+            <enum name="GL_MAP1_VERTEX_4"/>
+            <enum name="GL_MAP2_COLOR_4"/>
+            <enum name="GL_MAP2_INDEX"/>
+            <enum name="GL_MAP2_NORMAL"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_1"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_2"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_3"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_4"/>
+            <enum name="GL_MAP2_VERTEX_3"/>
+            <enum name="GL_MAP2_VERTEX_4"/>
+            <enum name="GL_MAP1_GRID_DOMAIN"/>
+            <enum name="GL_MAP1_GRID_SEGMENTS"/>
+            <enum name="GL_MAP2_GRID_DOMAIN"/>
+            <enum name="GL_MAP2_GRID_SEGMENTS"/>
+            <enum name="GL_FEEDBACK_BUFFER_SIZE"/>
+            <enum name="GL_FEEDBACK_BUFFER_TYPE"/>
+            <enum name="GL_SELECTION_BUFFER_SIZE"/>
+            <enum name="GL_VERTEX_ARRAY"/>
+            <enum name="GL_NORMAL_ARRAY"/>
+            <enum name="GL_COLOR_ARRAY"/>
+            <enum name="GL_INDEX_ARRAY"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY"/>
+            <enum name="GL_EDGE_FLAG_ARRAY"/>
+            <enum name="GL_VERTEX_ARRAY_SIZE"/>
+            <enum name="GL_VERTEX_ARRAY_TYPE"/>
+            <enum name="GL_VERTEX_ARRAY_STRIDE"/>
+            <enum name="GL_NORMAL_ARRAY_TYPE"/>
+            <enum name="GL_NORMAL_ARRAY_STRIDE"/>
+            <enum name="GL_COLOR_ARRAY_SIZE"/>
+            <enum name="GL_COLOR_ARRAY_TYPE"/>
+            <enum name="GL_COLOR_ARRAY_STRIDE"/>
+            <enum name="GL_INDEX_ARRAY_TYPE"/>
+            <enum name="GL_INDEX_ARRAY_STRIDE"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_SIZE"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_TYPE"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_STRIDE"/>
+            <enum name="GL_EDGE_FLAG_ARRAY_STRIDE"/>
+            <enum name="GL_TEXTURE_COMPONENTS"/>
+            <enum name="GL_TEXTURE_BORDER"/>
+            <enum name="GL_TEXTURE_LUMINANCE_SIZE"/>
+            <enum name="GL_TEXTURE_INTENSITY_SIZE"/>
+            <enum name="GL_TEXTURE_PRIORITY"/>
+            <enum name="GL_TEXTURE_RESIDENT"/>
+            <enum name="GL_AMBIENT"/>
+            <enum name="GL_DIFFUSE"/>
+            <enum name="GL_SPECULAR"/>
+            <enum name="GL_POSITION"/>
+            <enum name="GL_SPOT_DIRECTION"/>
+            <enum name="GL_SPOT_EXPONENT"/>
+            <enum name="GL_SPOT_CUTOFF"/>
+            <enum name="GL_CONSTANT_ATTENUATION"/>
+            <enum name="GL_LINEAR_ATTENUATION"/>
+            <enum name="GL_QUADRATIC_ATTENUATION"/>
+            <enum name="GL_COMPILE"/>
+            <enum name="GL_COMPILE_AND_EXECUTE"/>
+            <enum name="GL_2_BYTES"/>
+            <enum name="GL_3_BYTES"/>
+            <enum name="GL_4_BYTES"/>
+            <enum name="GL_EMISSION"/>
+            <enum name="GL_SHININESS"/>
+            <enum name="GL_AMBIENT_AND_DIFFUSE"/>
+            <enum name="GL_COLOR_INDEXES"/>
+            <enum name="GL_MODELVIEW"/>
+            <enum name="GL_PROJECTION"/>
+            <enum name="GL_COLOR_INDEX"/>
+            <enum name="GL_LUMINANCE"/>
+            <enum name="GL_LUMINANCE_ALPHA"/>
+            <enum name="GL_BITMAP"/>
+            <enum name="GL_RENDER"/>
+            <enum name="GL_FEEDBACK"/>
+            <enum name="GL_SELECT"/>
+            <enum name="GL_FLAT"/>
+            <enum name="GL_SMOOTH"/>
+            <enum name="GL_S"/>
+            <enum name="GL_T"/>
+            <enum name="GL_R"/>
+            <enum name="GL_Q"/>
+            <enum name="GL_MODULATE"/>
+            <enum name="GL_DECAL"/>
+            <enum name="GL_TEXTURE_ENV_MODE"/>
+            <enum name="GL_TEXTURE_ENV_COLOR"/>
+            <enum name="GL_TEXTURE_ENV"/>
+            <enum name="GL_EYE_LINEAR"/>
+            <enum name="GL_OBJECT_LINEAR"/>
+            <enum name="GL_SPHERE_MAP"/>
+            <enum name="GL_TEXTURE_GEN_MODE"/>
+            <enum name="GL_OBJECT_PLANE"/>
+            <enum name="GL_EYE_PLANE"/>
+            <enum name="GL_CLAMP"/>
+            <enum name="GL_ALPHA4"/>
+            <enum name="GL_ALPHA8"/>
+            <enum name="GL_ALPHA12"/>
+            <enum name="GL_ALPHA16"/>
+            <enum name="GL_LUMINANCE4"/>
+            <enum name="GL_LUMINANCE8"/>
+            <enum name="GL_LUMINANCE12"/>
+            <enum name="GL_LUMINANCE16"/>
+            <enum name="GL_LUMINANCE4_ALPHA4"/>
+            <enum name="GL_LUMINANCE6_ALPHA2"/>
+            <enum name="GL_LUMINANCE8_ALPHA8"/>
+            <enum name="GL_LUMINANCE12_ALPHA4"/>
+            <enum name="GL_LUMINANCE12_ALPHA12"/>
+            <enum name="GL_LUMINANCE16_ALPHA16"/>
+            <enum name="GL_INTENSITY"/>
+            <enum name="GL_INTENSITY4"/>
+            <enum name="GL_INTENSITY8"/>
+            <enum name="GL_INTENSITY12"/>
+            <enum name="GL_INTENSITY16"/>
+            <enum name="GL_V2F"/>
+            <enum name="GL_V3F"/>
+            <enum name="GL_C4UB_V2F"/>
+            <enum name="GL_C4UB_V3F"/>
+            <enum name="GL_C3F_V3F"/>
+            <enum name="GL_N3F_V3F"/>
+            <enum name="GL_C4F_N3F_V3F"/>
+            <enum name="GL_T2F_V3F"/>
+            <enum name="GL_T4F_V4F"/>
+            <enum name="GL_T2F_C4UB_V3F"/>
+            <enum name="GL_T2F_C3F_V3F"/>
+            <enum name="GL_T2F_N3F_V3F"/>
+            <enum name="GL_T2F_C4F_N3F_V3F"/>
+            <enum name="GL_T4F_C4F_N3F_V4F"/>
+            <enum name="GL_CLIP_PLANE0"/>
+            <enum name="GL_CLIP_PLANE1"/>
+            <enum name="GL_CLIP_PLANE2"/>
+            <enum name="GL_CLIP_PLANE3"/>
+            <enum name="GL_CLIP_PLANE4"/>
+            <enum name="GL_CLIP_PLANE5"/>
+            <enum name="GL_LIGHT0"/>
+            <enum name="GL_LIGHT1"/>
+            <enum name="GL_LIGHT2"/>
+            <enum name="GL_LIGHT3"/>
+            <enum name="GL_LIGHT4"/>
+            <enum name="GL_LIGHT5"/>
+            <enum name="GL_LIGHT6"/>
+            <enum name="GL_LIGHT7"/>
+            <command name="glDrawArrays"/>
+            <command name="glDrawElements"/>
+            <command name="glGetPointerv"/>
+            <command name="glPolygonOffset"/>
+            <command name="glCopyTexImage1D"/>
+            <command name="glCopyTexImage2D"/>
+            <command name="glCopyTexSubImage1D"/>
+            <command name="glCopyTexSubImage2D"/>
+            <command name="glTexSubImage1D"/>
+            <command name="glTexSubImage2D"/>
+            <command name="glBindTexture"/>
+            <command name="glDeleteTextures"/>
+            <command name="glGenTextures"/>
+            <command name="glIsTexture"/>
+            <command name="glArrayElement"/>
+            <command name="glColorPointer"/>
+            <command name="glDisableClientState"/>
+            <command name="glEdgeFlagPointer"/>
+            <command name="glEnableClientState"/>
+            <command name="glIndexPointer"/>
+            <command name="glInterleavedArrays"/>
+            <command name="glNormalPointer"/>
+            <command name="glTexCoordPointer"/>
+            <command name="glVertexPointer"/>
+            <command name="glAreTexturesResident"/>
+            <command name="glPrioritizeTextures"/>
+            <command name="glIndexub"/>
+            <command name="glIndexubv"/>
+            <command name="glPopClientAttrib"/>
+            <command name="glPushClientAttrib"/>
+        </require>
+    </feature>
+    <feature api="gl" name="GL_VERSION_1_2" number="1.2">
+        <require>
+            <enum name="GL_UNSIGNED_BYTE_3_3_2"/>
+            <enum name="GL_UNSIGNED_SHORT_4_4_4_4"/>
+            <enum name="GL_UNSIGNED_SHORT_5_5_5_1"/>
+            <enum name="GL_UNSIGNED_INT_8_8_8_8"/>
+            <enum name="GL_UNSIGNED_INT_10_10_10_2"/>
+            <enum name="GL_TEXTURE_BINDING_3D"/>
+            <enum name="GL_PACK_SKIP_IMAGES"/>
+            <enum name="GL_PACK_IMAGE_HEIGHT"/>
+            <enum name="GL_UNPACK_SKIP_IMAGES"/>
+            <enum name="GL_UNPACK_IMAGE_HEIGHT"/>
+            <enum name="GL_TEXTURE_3D"/>
+            <enum name="GL_PROXY_TEXTURE_3D"/>
+            <enum name="GL_TEXTURE_DEPTH"/>
+            <enum name="GL_TEXTURE_WRAP_R"/>
+            <enum name="GL_MAX_3D_TEXTURE_SIZE"/>
+            <enum name="GL_UNSIGNED_BYTE_2_3_3_REV"/>
+            <enum name="GL_UNSIGNED_SHORT_5_6_5"/>
+            <enum name="GL_UNSIGNED_SHORT_5_6_5_REV"/>
+            <enum name="GL_UNSIGNED_SHORT_4_4_4_4_REV"/>
+            <enum name="GL_UNSIGNED_SHORT_1_5_5_5_REV"/>
+            <enum name="GL_UNSIGNED_INT_8_8_8_8_REV"/>
+            <enum name="GL_UNSIGNED_INT_2_10_10_10_REV"/>
+            <enum name="GL_BGR"/>
+            <enum name="GL_BGRA"/>
+            <enum name="GL_MAX_ELEMENTS_VERTICES"/>
+            <enum name="GL_MAX_ELEMENTS_INDICES"/>
+            <enum name="GL_CLAMP_TO_EDGE"/>
+            <enum name="GL_TEXTURE_MIN_LOD"/>
+            <enum name="GL_TEXTURE_MAX_LOD"/>
+            <enum name="GL_TEXTURE_BASE_LEVEL"/>
+            <enum name="GL_TEXTURE_MAX_LEVEL"/>
+            <enum name="GL_SMOOTH_POINT_SIZE_RANGE"/>
+            <enum name="GL_SMOOTH_POINT_SIZE_GRANULARITY"/>
+            <enum name="GL_SMOOTH_LINE_WIDTH_RANGE"/>
+            <enum name="GL_SMOOTH_LINE_WIDTH_GRANULARITY"/>
+            <enum name="GL_ALIASED_LINE_WIDTH_RANGE"/>
+            <enum name="GL_RESCALE_NORMAL"/>
+            <enum name="GL_LIGHT_MODEL_COLOR_CONTROL"/>
+            <enum name="GL_SINGLE_COLOR"/>
+            <enum name="GL_SEPARATE_SPECULAR_COLOR"/>
+            <enum name="GL_ALIASED_POINT_SIZE_RANGE"/>
+            <command name="glDrawRangeElements"/>
+            <command name="glTexImage3D"/>
+            <command name="glTexSubImage3D"/>
+            <command name="glCopyTexSubImage3D"/>
+          </require>
+    </feature>
+    <feature api="gl" name="GL_VERSION_1_3" number="1.3">
+        <require>
+            <enum name="GL_TEXTURE0"/>
+            <enum name="GL_TEXTURE1"/>
+            <enum name="GL_TEXTURE2"/>
+            <enum name="GL_TEXTURE3"/>
+            <enum name="GL_TEXTURE4"/>
+            <enum name="GL_TEXTURE5"/>
+            <enum name="GL_TEXTURE6"/>
+            <enum name="GL_TEXTURE7"/>
+            <enum name="GL_TEXTURE8"/>
+            <enum name="GL_TEXTURE9"/>
+            <enum name="GL_TEXTURE10"/>
+            <enum name="GL_TEXTURE11"/>
+            <enum name="GL_TEXTURE12"/>
+            <enum name="GL_TEXTURE13"/>
+            <enum name="GL_TEXTURE14"/>
+            <enum name="GL_TEXTURE15"/>
+            <enum name="GL_TEXTURE16"/>
+            <enum name="GL_TEXTURE17"/>
+            <enum name="GL_TEXTURE18"/>
+            <enum name="GL_TEXTURE19"/>
+            <enum name="GL_TEXTURE20"/>
+            <enum name="GL_TEXTURE21"/>
+            <enum name="GL_TEXTURE22"/>
+            <enum name="GL_TEXTURE23"/>
+            <enum name="GL_TEXTURE24"/>
+            <enum name="GL_TEXTURE25"/>
+            <enum name="GL_TEXTURE26"/>
+            <enum name="GL_TEXTURE27"/>
+            <enum name="GL_TEXTURE28"/>
+            <enum name="GL_TEXTURE29"/>
+            <enum name="GL_TEXTURE30"/>
+            <enum name="GL_TEXTURE31"/>
+            <enum name="GL_ACTIVE_TEXTURE"/>
+            <enum name="GL_MULTISAMPLE"/>
+            <enum name="GL_SAMPLE_ALPHA_TO_COVERAGE"/>
+            <enum name="GL_SAMPLE_ALPHA_TO_ONE"/>
+            <enum name="GL_SAMPLE_COVERAGE"/>
+            <enum name="GL_SAMPLE_BUFFERS"/>
+            <enum name="GL_SAMPLES"/>
+            <enum name="GL_SAMPLE_COVERAGE_VALUE"/>
+            <enum name="GL_SAMPLE_COVERAGE_INVERT"/>
+            <enum name="GL_TEXTURE_CUBE_MAP"/>
+            <enum name="GL_TEXTURE_BINDING_CUBE_MAP"/>
+            <enum name="GL_TEXTURE_CUBE_MAP_POSITIVE_X"/>
+            <enum name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X"/>
+            <enum name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y"/>
+            <enum name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y"/>
+            <enum name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z"/>
+            <enum name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z"/>
+            <enum name="GL_PROXY_TEXTURE_CUBE_MAP"/>
+            <enum name="GL_MAX_CUBE_MAP_TEXTURE_SIZE"/>
+            <enum name="GL_COMPRESSED_RGB"/>
+            <enum name="GL_COMPRESSED_RGBA"/>
+            <enum name="GL_TEXTURE_COMPRESSION_HINT"/>
+            <enum name="GL_TEXTURE_COMPRESSED_IMAGE_SIZE"/>
+            <enum name="GL_TEXTURE_COMPRESSED"/>
+            <enum name="GL_NUM_COMPRESSED_TEXTURE_FORMATS"/>
+            <enum name="GL_COMPRESSED_TEXTURE_FORMATS"/>
+            <enum name="GL_CLAMP_TO_BORDER"/>
+            <enum name="GL_CLIENT_ACTIVE_TEXTURE"/>
+            <enum name="GL_MAX_TEXTURE_UNITS"/>
+            <enum name="GL_TRANSPOSE_MODELVIEW_MATRIX"/>
+            <enum name="GL_TRANSPOSE_PROJECTION_MATRIX"/>
+            <enum name="GL_TRANSPOSE_TEXTURE_MATRIX"/>
+            <enum name="GL_TRANSPOSE_COLOR_MATRIX"/>
+            <enum name="GL_MULTISAMPLE_BIT"/>
+            <enum name="GL_NORMAL_MAP"/>
+            <enum name="GL_REFLECTION_MAP"/>
+            <enum name="GL_COMPRESSED_ALPHA"/>
+            <enum name="GL_COMPRESSED_LUMINANCE"/>
+            <enum name="GL_COMPRESSED_LUMINANCE_ALPHA"/>
+            <enum name="GL_COMPRESSED_INTENSITY"/>
+            <enum name="GL_COMBINE"/>
+            <enum name="GL_COMBINE_RGB"/>
+            <enum name="GL_COMBINE_ALPHA"/>
+            <enum name="GL_SOURCE0_RGB"/>
+            <enum name="GL_SOURCE1_RGB"/>
+            <enum name="GL_SOURCE2_RGB"/>
+            <enum name="GL_SOURCE0_ALPHA"/>
+            <enum name="GL_SOURCE1_ALPHA"/>
+            <enum name="GL_SOURCE2_ALPHA"/>
+            <enum name="GL_OPERAND0_RGB"/>
+            <enum name="GL_OPERAND1_RGB"/>
+            <enum name="GL_OPERAND2_RGB"/>
+            <enum name="GL_OPERAND0_ALPHA"/>
+            <enum name="GL_OPERAND1_ALPHA"/>
+            <enum name="GL_OPERAND2_ALPHA"/>
+            <enum name="GL_RGB_SCALE"/>
+            <enum name="GL_ADD_SIGNED"/>
+            <enum name="GL_INTERPOLATE"/>
+            <enum name="GL_SUBTRACT"/>
+            <enum name="GL_CONSTANT"/>
+            <enum name="GL_PRIMARY_COLOR"/>
+            <enum name="GL_PREVIOUS"/>
+            <enum name="GL_DOT3_RGB"/>
+            <enum name="GL_DOT3_RGBA"/>
+            <command name="glActiveTexture"/>
+            <command name="glSampleCoverage"/>
+            <command name="glCompressedTexImage3D"/>
+            <command name="glCompressedTexImage2D"/>
+            <command name="glCompressedTexImage1D"/>
+            <command name="glCompressedTexSubImage3D"/>
+            <command name="glCompressedTexSubImage2D"/>
+            <command name="glCompressedTexSubImage1D"/>
+            <command name="glGetCompressedTexImage"/>
+            <command name="glClientActiveTexture"/>
+            <command name="glMultiTexCoord1d"/>
+            <command name="glMultiTexCoord1dv"/>
+            <command name="glMultiTexCoord1f"/>
+            <command name="glMultiTexCoord1fv"/>
+            <command name="glMultiTexCoord1i"/>
+            <command name="glMultiTexCoord1iv"/>
+            <command name="glMultiTexCoord1s"/>
+            <command name="glMultiTexCoord1sv"/>
+            <command name="glMultiTexCoord2d"/>
+            <command name="glMultiTexCoord2dv"/>
+            <command name="glMultiTexCoord2f"/>
+            <command name="glMultiTexCoord2fv"/>
+            <command name="glMultiTexCoord2i"/>
+            <command name="glMultiTexCoord2iv"/>
+            <command name="glMultiTexCoord2s"/>
+            <command name="glMultiTexCoord2sv"/>
+            <command name="glMultiTexCoord3d"/>
+            <command name="glMultiTexCoord3dv"/>
+            <command name="glMultiTexCoord3f"/>
+            <command name="glMultiTexCoord3fv"/>
+            <command name="glMultiTexCoord3i"/>
+            <command name="glMultiTexCoord3iv"/>
+            <command name="glMultiTexCoord3s"/>
+            <command name="glMultiTexCoord3sv"/>
+            <command name="glMultiTexCoord4d"/>
+            <command name="glMultiTexCoord4dv"/>
+            <command name="glMultiTexCoord4f"/>
+            <command name="glMultiTexCoord4fv"/>
+            <command name="glMultiTexCoord4i"/>
+            <command name="glMultiTexCoord4iv"/>
+            <command name="glMultiTexCoord4s"/>
+            <command name="glMultiTexCoord4sv"/>
+            <command name="glLoadTransposeMatrixf"/>
+            <command name="glLoadTransposeMatrixd"/>
+            <command name="glMultTransposeMatrixf"/>
+            <command name="glMultTransposeMatrixd"/>
+        </require>
+    </feature>
+    <feature api="gl" name="GL_VERSION_1_4" number="1.4">
+        <require>
+            <enum name="GL_BLEND_DST_RGB"/>
+            <enum name="GL_BLEND_SRC_RGB"/>
+            <enum name="GL_BLEND_DST_ALPHA"/>
+            <enum name="GL_BLEND_SRC_ALPHA"/>
+            <enum name="GL_POINT_FADE_THRESHOLD_SIZE"/>
+            <enum name="GL_DEPTH_COMPONENT16"/>
+            <enum name="GL_DEPTH_COMPONENT24"/>
+            <enum name="GL_DEPTH_COMPONENT32"/>
+            <enum name="GL_MIRRORED_REPEAT"/>
+            <enum name="GL_MAX_TEXTURE_LOD_BIAS"/>
+            <enum name="GL_TEXTURE_LOD_BIAS"/>
+            <enum name="GL_INCR_WRAP"/>
+            <enum name="GL_DECR_WRAP"/>
+            <enum name="GL_TEXTURE_DEPTH_SIZE"/>
+            <enum name="GL_TEXTURE_COMPARE_MODE"/>
+            <enum name="GL_TEXTURE_COMPARE_FUNC"/>
+            <enum name="GL_POINT_SIZE_MIN"/>
+            <enum name="GL_POINT_SIZE_MAX"/>
+            <enum name="GL_POINT_DISTANCE_ATTENUATION"/>
+            <enum name="GL_GENERATE_MIPMAP"/>
+            <enum name="GL_GENERATE_MIPMAP_HINT"/>
+            <enum name="GL_FOG_COORDINATE_SOURCE"/>
+            <enum name="GL_FOG_COORDINATE"/>
+            <enum name="GL_FRAGMENT_DEPTH"/>
+            <enum name="GL_CURRENT_FOG_COORDINATE"/>
+            <enum name="GL_FOG_COORDINATE_ARRAY_TYPE"/>
+            <enum name="GL_FOG_COORDINATE_ARRAY_STRIDE"/>
+            <enum name="GL_FOG_COORDINATE_ARRAY_POINTER"/>
+            <enum name="GL_FOG_COORDINATE_ARRAY"/>
+            <enum name="GL_COLOR_SUM"/>
+            <enum name="GL_CURRENT_SECONDARY_COLOR"/>
+            <enum name="GL_SECONDARY_COLOR_ARRAY_SIZE"/>
+            <enum name="GL_SECONDARY_COLOR_ARRAY_TYPE"/>
+            <enum name="GL_SECONDARY_COLOR_ARRAY_STRIDE"/>
+            <enum name="GL_SECONDARY_COLOR_ARRAY_POINTER"/>
+            <enum name="GL_SECONDARY_COLOR_ARRAY"/>
+            <enum name="GL_TEXTURE_FILTER_CONTROL"/>
+            <enum name="GL_DEPTH_TEXTURE_MODE"/>
+            <enum name="GL_COMPARE_R_TO_TEXTURE"/>
+            <command name="glBlendFuncSeparate"/>
+            <command name="glMultiDrawArrays"/>
+            <command name="glMultiDrawElements"/>
+            <command name="glPointParameterf"/>
+            <command name="glPointParameterfv"/>
+            <command name="glPointParameteri"/>
+            <command name="glPointParameteriv"/>
+            <command name="glFogCoordf"/>
+            <command name="glFogCoordfv"/>
+            <command name="glFogCoordd"/>
+            <command name="glFogCoorddv"/>
+            <command name="glFogCoordPointer"/>
+            <command name="glSecondaryColor3b"/>
+            <command name="glSecondaryColor3bv"/>
+            <command name="glSecondaryColor3d"/>
+            <command name="glSecondaryColor3dv"/>
+            <command name="glSecondaryColor3f"/>
+            <command name="glSecondaryColor3fv"/>
+            <command name="glSecondaryColor3i"/>
+            <command name="glSecondaryColor3iv"/>
+            <command name="glSecondaryColor3s"/>
+            <command name="glSecondaryColor3sv"/>
+            <command name="glSecondaryColor3ub"/>
+            <command name="glSecondaryColor3ubv"/>
+            <command name="glSecondaryColor3ui"/>
+            <command name="glSecondaryColor3uiv"/>
+            <command name="glSecondaryColor3us"/>
+            <command name="glSecondaryColor3usv"/>
+            <command name="glSecondaryColorPointer"/>
+            <command name="glWindowPos2d"/>
+            <command name="glWindowPos2dv"/>
+            <command name="glWindowPos2f"/>
+            <command name="glWindowPos2fv"/>
+            <command name="glWindowPos2i"/>
+            <command name="glWindowPos2iv"/>
+            <command name="glWindowPos2s"/>
+            <command name="glWindowPos2sv"/>
+            <command name="glWindowPos3d"/>
+            <command name="glWindowPos3dv"/>
+            <command name="glWindowPos3f"/>
+            <command name="glWindowPos3fv"/>
+            <command name="glWindowPos3i"/>
+            <command name="glWindowPos3iv"/>
+            <command name="glWindowPos3s"/>
+            <command name="glWindowPos3sv"/>
+        </require>
+        <require comment="Promoted from ARB_imaging subset to core">
+            <enum name="GL_FUNC_ADD"/>
+            <enum name="GL_FUNC_SUBTRACT"/>
+            <enum name="GL_FUNC_REVERSE_SUBTRACT"/>
+            <enum name="GL_MIN"/>
+            <enum name="GL_MAX"/>
+            <enum name="GL_CONSTANT_COLOR"/>
+            <enum name="GL_ONE_MINUS_CONSTANT_COLOR"/>
+            <enum name="GL_CONSTANT_ALPHA"/>
+            <enum name="GL_ONE_MINUS_CONSTANT_ALPHA"/>
+            <command name="glBlendColor"/>
+            <command name="glBlendEquation"/>
+        </require>
+    </feature>
+    <feature api="gl" name="GL_VERSION_1_5" number="1.5">
+        <require>
+            <enum name="GL_BUFFER_SIZE"/>
+            <enum name="GL_BUFFER_USAGE"/>
+            <enum name="GL_QUERY_COUNTER_BITS"/>
+            <enum name="GL_CURRENT_QUERY"/>
+            <enum name="GL_QUERY_RESULT"/>
+            <enum name="GL_QUERY_RESULT_AVAILABLE"/>
+            <enum name="GL_ARRAY_BUFFER"/>
+            <enum name="GL_ELEMENT_ARRAY_BUFFER"/>
+            <enum name="GL_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_ELEMENT_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_READ_ONLY"/>
+            <enum name="GL_WRITE_ONLY"/>
+            <enum name="GL_READ_WRITE"/>
+            <enum name="GL_BUFFER_ACCESS"/>
+            <enum name="GL_BUFFER_MAPPED"/>
+            <enum name="GL_BUFFER_MAP_POINTER"/>
+            <enum name="GL_STREAM_DRAW"/>
+            <enum name="GL_STREAM_READ"/>
+            <enum name="GL_STREAM_COPY"/>
+            <enum name="GL_STATIC_DRAW"/>
+            <enum name="GL_STATIC_READ"/>
+            <enum name="GL_STATIC_COPY"/>
+            <enum name="GL_DYNAMIC_DRAW"/>
+            <enum name="GL_DYNAMIC_READ"/>
+            <enum name="GL_DYNAMIC_COPY"/>
+            <enum name="GL_SAMPLES_PASSED"/>
+            <enum name="GL_SRC1_ALPHA"/>
+            <enum name="GL_VERTEX_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_NORMAL_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_COLOR_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_INDEX_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_EDGE_FLAG_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_WEIGHT_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_FOG_COORD_SRC"/>
+            <enum name="GL_FOG_COORD"/>
+            <enum name="GL_CURRENT_FOG_COORD"/>
+            <enum name="GL_FOG_COORD_ARRAY_TYPE"/>
+            <enum name="GL_FOG_COORD_ARRAY_STRIDE"/>
+            <enum name="GL_FOG_COORD_ARRAY_POINTER"/>
+            <enum name="GL_FOG_COORD_ARRAY"/>
+            <enum name="GL_FOG_COORD_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_SRC0_RGB"/>
+            <enum name="GL_SRC1_RGB"/>
+            <enum name="GL_SRC2_RGB"/>
+            <enum name="GL_SRC0_ALPHA"/>
+            <enum name="GL_SRC2_ALPHA"/>
+            <command name="glGenQueries"/>
+            <command name="glDeleteQueries"/>
+            <command name="glIsQuery"/>
+            <command name="glBeginQuery"/>
+            <command name="glEndQuery"/>
+            <command name="glGetQueryiv"/>
+            <command name="glGetQueryObjectiv"/>
+            <command name="glGetQueryObjectuiv"/>
+            <command name="glBindBuffer"/>
+            <command name="glDeleteBuffers"/>
+            <command name="glGenBuffers"/>
+            <command name="glIsBuffer"/>
+            <command name="glBufferData"/>
+            <command name="glBufferSubData"/>
+            <command name="glGetBufferSubData"/>
+            <command name="glMapBuffer"/>
+            <command name="glUnmapBuffer"/>
+            <command name="glGetBufferParameteriv"/>
+            <command name="glGetBufferPointerv"/>
+        </require>
+    </feature>
+    <feature api="gl" name="GL_VERSION_2_0" number="2.0">
+        <require>
+            <enum name="GL_BLEND_EQUATION_RGB"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_ENABLED"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_SIZE"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_STRIDE"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_TYPE"/>
+            <enum name="GL_CURRENT_VERTEX_ATTRIB"/>
+            <enum name="GL_VERTEX_PROGRAM_POINT_SIZE"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_POINTER"/>
+            <enum name="GL_STENCIL_BACK_FUNC"/>
+            <enum name="GL_STENCIL_BACK_FAIL"/>
+            <enum name="GL_STENCIL_BACK_PASS_DEPTH_FAIL"/>
+            <enum name="GL_STENCIL_BACK_PASS_DEPTH_PASS"/>
+            <enum name="GL_MAX_DRAW_BUFFERS"/>
+            <enum name="GL_DRAW_BUFFER0"/>
+            <enum name="GL_DRAW_BUFFER1"/>
+            <enum name="GL_DRAW_BUFFER2"/>
+            <enum name="GL_DRAW_BUFFER3"/>
+            <enum name="GL_DRAW_BUFFER4"/>
+            <enum name="GL_DRAW_BUFFER5"/>
+            <enum name="GL_DRAW_BUFFER6"/>
+            <enum name="GL_DRAW_BUFFER7"/>
+            <enum name="GL_DRAW_BUFFER8"/>
+            <enum name="GL_DRAW_BUFFER9"/>
+            <enum name="GL_DRAW_BUFFER10"/>
+            <enum name="GL_DRAW_BUFFER11"/>
+            <enum name="GL_DRAW_BUFFER12"/>
+            <enum name="GL_DRAW_BUFFER13"/>
+            <enum name="GL_DRAW_BUFFER14"/>
+            <enum name="GL_DRAW_BUFFER15"/>
+            <enum name="GL_BLEND_EQUATION_ALPHA"/>
+            <enum name="GL_MAX_VERTEX_ATTRIBS"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_NORMALIZED"/>
+            <enum name="GL_MAX_TEXTURE_IMAGE_UNITS"/>
+            <enum name="GL_FRAGMENT_SHADER"/>
+            <enum name="GL_VERTEX_SHADER"/>
+            <enum name="GL_MAX_FRAGMENT_UNIFORM_COMPONENTS"/>
+            <enum name="GL_MAX_VERTEX_UNIFORM_COMPONENTS"/>
+            <enum name="GL_MAX_VARYING_FLOATS"/>
+            <enum name="GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS"/>
+            <enum name="GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS"/>
+            <enum name="GL_SHADER_TYPE"/>
+            <enum name="GL_FLOAT_VEC2"/>
+            <enum name="GL_FLOAT_VEC3"/>
+            <enum name="GL_FLOAT_VEC4"/>
+            <enum name="GL_INT_VEC2"/>
+            <enum name="GL_INT_VEC3"/>
+            <enum name="GL_INT_VEC4"/>
+            <enum name="GL_BOOL"/>
+            <enum name="GL_BOOL_VEC2"/>
+            <enum name="GL_BOOL_VEC3"/>
+            <enum name="GL_BOOL_VEC4"/>
+            <enum name="GL_FLOAT_MAT2"/>
+            <enum name="GL_FLOAT_MAT3"/>
+            <enum name="GL_FLOAT_MAT4"/>
+            <enum name="GL_SAMPLER_1D"/>
+            <enum name="GL_SAMPLER_2D"/>
+            <enum name="GL_SAMPLER_3D"/>
+            <enum name="GL_SAMPLER_CUBE"/>
+            <enum name="GL_SAMPLER_1D_SHADOW"/>
+            <enum name="GL_SAMPLER_2D_SHADOW"/>
+            <enum name="GL_DELETE_STATUS"/>
+            <enum name="GL_COMPILE_STATUS"/>
+            <enum name="GL_LINK_STATUS"/>
+            <enum name="GL_VALIDATE_STATUS"/>
+            <enum name="GL_INFO_LOG_LENGTH"/>
+            <enum name="GL_ATTACHED_SHADERS"/>
+            <enum name="GL_ACTIVE_UNIFORMS"/>
+            <enum name="GL_ACTIVE_UNIFORM_MAX_LENGTH"/>
+            <enum name="GL_SHADER_SOURCE_LENGTH"/>
+            <enum name="GL_ACTIVE_ATTRIBUTES"/>
+            <enum name="GL_ACTIVE_ATTRIBUTE_MAX_LENGTH"/>
+            <enum name="GL_FRAGMENT_SHADER_DERIVATIVE_HINT"/>
+            <enum name="GL_SHADING_LANGUAGE_VERSION"/>
+            <enum name="GL_CURRENT_PROGRAM"/>
+            <enum name="GL_POINT_SPRITE_COORD_ORIGIN"/>
+            <enum name="GL_LOWER_LEFT"/>
+            <enum name="GL_UPPER_LEFT"/>
+            <enum name="GL_STENCIL_BACK_REF"/>
+            <enum name="GL_STENCIL_BACK_VALUE_MASK"/>
+            <enum name="GL_STENCIL_BACK_WRITEMASK"/>
+            <enum name="GL_VERTEX_PROGRAM_TWO_SIDE"/>
+            <enum name="GL_POINT_SPRITE"/>
+            <enum name="GL_COORD_REPLACE"/>
+            <enum name="GL_MAX_TEXTURE_COORDS"/>
+            <command name="glBlendEquationSeparate"/>
+            <command name="glDrawBuffers"/>
+            <command name="glStencilOpSeparate"/>
+            <command name="glStencilFuncSeparate"/>
+            <command name="glStencilMaskSeparate"/>
+            <command name="glAttachShader"/>
+            <command name="glBindAttribLocation"/>
+            <command name="glCompileShader"/>
+            <command name="glCreateProgram"/>
+            <command name="glCreateShader"/>
+            <command name="glDeleteProgram"/>
+            <command name="glDeleteShader"/>
+            <command name="glDetachShader"/>
+            <command name="glDisableVertexAttribArray"/>
+            <command name="glEnableVertexAttribArray"/>
+            <command name="glGetActiveAttrib"/>
+            <command name="glGetActiveUniform"/>
+            <command name="glGetAttachedShaders"/>
+            <command name="glGetAttribLocation"/>
+            <command name="glGetProgramiv"/>
+            <command name="glGetProgramInfoLog"/>
+            <command name="glGetShaderiv"/>
+            <command name="glGetShaderInfoLog"/>
+            <command name="glGetShaderSource"/>
+            <command name="glGetUniformLocation"/>
+            <command name="glGetUniformfv"/>
+            <command name="glGetUniformiv"/>
+            <command name="glGetVertexAttribdv"/>
+            <command name="glGetVertexAttribfv"/>
+            <command name="glGetVertexAttribiv"/>
+            <command name="glGetVertexAttribPointerv"/>
+            <command name="glIsProgram"/>
+            <command name="glIsShader"/>
+            <command name="glLinkProgram"/>
+            <command name="glShaderSource"/>
+            <command name="glUseProgram"/>
+            <command name="glUniform1f"/>
+            <command name="glUniform2f"/>
+            <command name="glUniform3f"/>
+            <command name="glUniform4f"/>
+            <command name="glUniform1i"/>
+            <command name="glUniform2i"/>
+            <command name="glUniform3i"/>
+            <command name="glUniform4i"/>
+            <command name="glUniform1fv"/>
+            <command name="glUniform2fv"/>
+            <command name="glUniform3fv"/>
+            <command name="glUniform4fv"/>
+            <command name="glUniform1iv"/>
+            <command name="glUniform2iv"/>
+            <command name="glUniform3iv"/>
+            <command name="glUniform4iv"/>
+            <command name="glUniformMatrix2fv"/>
+            <command name="glUniformMatrix3fv"/>
+            <command name="glUniformMatrix4fv"/>
+            <command name="glValidateProgram"/>
+            <command name="glVertexAttrib1d"/>
+            <command name="glVertexAttrib1dv"/>
+            <command name="glVertexAttrib1f"/>
+            <command name="glVertexAttrib1fv"/>
+            <command name="glVertexAttrib1s"/>
+            <command name="glVertexAttrib1sv"/>
+            <command name="glVertexAttrib2d"/>
+            <command name="glVertexAttrib2dv"/>
+            <command name="glVertexAttrib2f"/>
+            <command name="glVertexAttrib2fv"/>
+            <command name="glVertexAttrib2s"/>
+            <command name="glVertexAttrib2sv"/>
+            <command name="glVertexAttrib3d"/>
+            <command name="glVertexAttrib3dv"/>
+            <command name="glVertexAttrib3f"/>
+            <command name="glVertexAttrib3fv"/>
+            <command name="glVertexAttrib3s"/>
+            <command name="glVertexAttrib3sv"/>
+            <command name="glVertexAttrib4Nbv"/>
+            <command name="glVertexAttrib4Niv"/>
+            <command name="glVertexAttrib4Nsv"/>
+            <command name="glVertexAttrib4Nub"/>
+            <command name="glVertexAttrib4Nubv"/>
+            <command name="glVertexAttrib4Nuiv"/>
+            <command name="glVertexAttrib4Nusv"/>
+            <command name="glVertexAttrib4bv"/>
+            <command name="glVertexAttrib4d"/>
+            <command name="glVertexAttrib4dv"/>
+            <command name="glVertexAttrib4f"/>
+            <command name="glVertexAttrib4fv"/>
+            <command name="glVertexAttrib4iv"/>
+            <command name="glVertexAttrib4s"/>
+            <command name="glVertexAttrib4sv"/>
+            <command name="glVertexAttrib4ubv"/>
+            <command name="glVertexAttrib4uiv"/>
+            <command name="glVertexAttrib4usv"/>
+            <command name="glVertexAttribPointer"/>
+        </require>
+    </feature>
+    <feature api="gl" name="GL_VERSION_2_1" number="2.1">
+        <require>
+            <enum name="GL_PIXEL_PACK_BUFFER"/>
+            <enum name="GL_PIXEL_UNPACK_BUFFER"/>
+            <enum name="GL_PIXEL_PACK_BUFFER_BINDING"/>
+            <enum name="GL_PIXEL_UNPACK_BUFFER_BINDING"/>
+            <enum name="GL_FLOAT_MAT2x3"/>
+            <enum name="GL_FLOAT_MAT2x4"/>
+            <enum name="GL_FLOAT_MAT3x2"/>
+            <enum name="GL_FLOAT_MAT3x4"/>
+            <enum name="GL_FLOAT_MAT4x2"/>
+            <enum name="GL_FLOAT_MAT4x3"/>
+            <enum name="GL_SRGB"/>
+            <enum name="GL_SRGB8"/>
+            <enum name="GL_SRGB_ALPHA"/>
+            <enum name="GL_SRGB8_ALPHA8"/>
+            <enum name="GL_COMPRESSED_SRGB"/>
+            <enum name="GL_COMPRESSED_SRGB_ALPHA"/>
+            <enum name="GL_CURRENT_RASTER_SECONDARY_COLOR"/>
+            <enum name="GL_SLUMINANCE_ALPHA"/>
+            <enum name="GL_SLUMINANCE8_ALPHA8"/>
+            <enum name="GL_SLUMINANCE"/>
+            <enum name="GL_SLUMINANCE8"/>
+            <enum name="GL_COMPRESSED_SLUMINANCE"/>
+            <enum name="GL_COMPRESSED_SLUMINANCE_ALPHA"/>
+            <command name="glUniformMatrix2x3fv"/>
+            <command name="glUniformMatrix3x2fv"/>
+            <command name="glUniformMatrix2x4fv"/>
+            <command name="glUniformMatrix4x2fv"/>
+            <command name="glUniformMatrix3x4fv"/>
+            <command name="glUniformMatrix4x3fv"/>
+        </require>
+    </feature>
+    <feature api="gl" name="GL_VERSION_3_0" number="3.0">
+        <require>
+            <enum name="GL_COMPARE_REF_TO_TEXTURE"/>
+            <enum name="GL_CLIP_DISTANCE0"/>
+            <enum name="GL_CLIP_DISTANCE1"/>
+            <enum name="GL_CLIP_DISTANCE2"/>
+            <enum name="GL_CLIP_DISTANCE3"/>
+            <enum name="GL_CLIP_DISTANCE4"/>
+            <enum name="GL_CLIP_DISTANCE5"/>
+            <enum name="GL_CLIP_DISTANCE6"/>
+            <enum name="GL_CLIP_DISTANCE7"/>
+            <enum name="GL_MAX_CLIP_DISTANCES"/>
+            <enum name="GL_MAJOR_VERSION"/>
+            <enum name="GL_MINOR_VERSION"/>
+            <enum name="GL_NUM_EXTENSIONS"/>
+            <enum name="GL_CONTEXT_FLAGS"/>
+            <enum name="GL_COMPRESSED_RED"/>
+            <enum name="GL_COMPRESSED_RG"/>
+            <enum name="GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT"/>
+            <enum name="GL_RGBA32F"/>
+            <enum name="GL_RGB32F"/>
+            <enum name="GL_RGBA16F"/>
+            <enum name="GL_RGB16F"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_INTEGER"/>
+            <enum name="GL_MAX_ARRAY_TEXTURE_LAYERS"/>
+            <enum name="GL_MIN_PROGRAM_TEXEL_OFFSET"/>
+            <enum name="GL_MAX_PROGRAM_TEXEL_OFFSET"/>
+            <enum name="GL_CLAMP_READ_COLOR"/>
+            <enum name="GL_FIXED_ONLY"/>
+            <enum name="GL_MAX_VARYING_COMPONENTS"/>
+            <enum name="GL_TEXTURE_1D_ARRAY"/>
+            <enum name="GL_PROXY_TEXTURE_1D_ARRAY"/>
+            <enum name="GL_TEXTURE_2D_ARRAY"/>
+            <enum name="GL_PROXY_TEXTURE_2D_ARRAY"/>
+            <enum name="GL_TEXTURE_BINDING_1D_ARRAY"/>
+            <enum name="GL_TEXTURE_BINDING_2D_ARRAY"/>
+            <enum name="GL_R11F_G11F_B10F"/>
+            <enum name="GL_UNSIGNED_INT_10F_11F_11F_REV"/>
+            <enum name="GL_RGB9_E5"/>
+            <enum name="GL_UNSIGNED_INT_5_9_9_9_REV"/>
+            <enum name="GL_TEXTURE_SHARED_SIZE"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_MODE"/>
+            <enum name="GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_VARYINGS"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_START"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_SIZE"/>
+            <enum name="GL_PRIMITIVES_GENERATED"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN"/>
+            <enum name="GL_RASTERIZER_DISCARD"/>
+            <enum name="GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS"/>
+            <enum name="GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS"/>
+            <enum name="GL_INTERLEAVED_ATTRIBS"/>
+            <enum name="GL_SEPARATE_ATTRIBS"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BUFFER"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_BINDING"/>
+            <enum name="GL_RGBA32UI"/>
+            <enum name="GL_RGB32UI"/>
+            <enum name="GL_RGBA16UI"/>
+            <enum name="GL_RGB16UI"/>
+            <enum name="GL_RGBA8UI"/>
+            <enum name="GL_RGB8UI"/>
+            <enum name="GL_RGBA32I"/>
+            <enum name="GL_RGB32I"/>
+            <enum name="GL_RGBA16I"/>
+            <enum name="GL_RGB16I"/>
+            <enum name="GL_RGBA8I"/>
+            <enum name="GL_RGB8I"/>
+            <enum name="GL_RED_INTEGER"/>
+            <enum name="GL_GREEN_INTEGER"/>
+            <enum name="GL_BLUE_INTEGER"/>
+            <enum name="GL_RGB_INTEGER"/>
+            <enum name="GL_RGBA_INTEGER"/>
+            <enum name="GL_BGR_INTEGER"/>
+            <enum name="GL_BGRA_INTEGER"/>
+            <enum name="GL_SAMPLER_1D_ARRAY"/>
+            <enum name="GL_SAMPLER_2D_ARRAY"/>
+            <enum name="GL_SAMPLER_1D_ARRAY_SHADOW"/>
+            <enum name="GL_SAMPLER_2D_ARRAY_SHADOW"/>
+            <enum name="GL_SAMPLER_CUBE_SHADOW"/>
+            <enum name="GL_UNSIGNED_INT_VEC2"/>
+            <enum name="GL_UNSIGNED_INT_VEC3"/>
+            <enum name="GL_UNSIGNED_INT_VEC4"/>
+            <enum name="GL_INT_SAMPLER_1D"/>
+            <enum name="GL_INT_SAMPLER_2D"/>
+            <enum name="GL_INT_SAMPLER_3D"/>
+            <enum name="GL_INT_SAMPLER_CUBE"/>
+            <enum name="GL_INT_SAMPLER_1D_ARRAY"/>
+            <enum name="GL_INT_SAMPLER_2D_ARRAY"/>
+            <enum name="GL_UNSIGNED_INT_SAMPLER_1D"/>
+            <enum name="GL_UNSIGNED_INT_SAMPLER_2D"/>
+            <enum name="GL_UNSIGNED_INT_SAMPLER_3D"/>
+            <enum name="GL_UNSIGNED_INT_SAMPLER_CUBE"/>
+            <enum name="GL_UNSIGNED_INT_SAMPLER_1D_ARRAY"/>
+            <enum name="GL_UNSIGNED_INT_SAMPLER_2D_ARRAY"/>
+            <enum name="GL_QUERY_WAIT"/>
+            <enum name="GL_QUERY_NO_WAIT"/>
+            <enum name="GL_QUERY_BY_REGION_WAIT"/>
+            <enum name="GL_QUERY_BY_REGION_NO_WAIT"/>
+            <enum name="GL_BUFFER_ACCESS_FLAGS"/>
+            <enum name="GL_BUFFER_MAP_LENGTH"/>
+            <enum name="GL_BUFFER_MAP_OFFSET"/>
+            <command name="glColorMaski"/>
+            <command name="glGetBooleani_v"/>
+            <command name="glGetIntegeri_v"/>
+            <command name="glEnablei"/>
+            <command name="glDisablei"/>
+            <command name="glIsEnabledi"/>
+            <command name="glBeginTransformFeedback"/>
+            <command name="glEndTransformFeedback"/>
+            <command name="glBindBufferRange"/>
+            <command name="glBindBufferBase"/>
+            <command name="glTransformFeedbackVaryings"/>
+            <command name="glGetTransformFeedbackVarying"/>
+            <command name="glClampColor"/>
+            <command name="glBeginConditionalRender"/>
+            <command name="glEndConditionalRender"/>
+            <command name="glVertexAttribIPointer"/>
+            <command name="glGetVertexAttribIiv"/>
+            <command name="glGetVertexAttribIuiv"/>
+            <command name="glVertexAttribI1i"/>
+            <command name="glVertexAttribI2i"/>
+            <command name="glVertexAttribI3i"/>
+            <command name="glVertexAttribI4i"/>
+            <command name="glVertexAttribI1ui"/>
+            <command name="glVertexAttribI2ui"/>
+            <command name="glVertexAttribI3ui"/>
+            <command name="glVertexAttribI4ui"/>
+            <command name="glVertexAttribI1iv"/>
+            <command name="glVertexAttribI2iv"/>
+            <command name="glVertexAttribI3iv"/>
+            <command name="glVertexAttribI4iv"/>
+            <command name="glVertexAttribI1uiv"/>
+            <command name="glVertexAttribI2uiv"/>
+            <command name="glVertexAttribI3uiv"/>
+            <command name="glVertexAttribI4uiv"/>
+            <command name="glVertexAttribI4bv"/>
+            <command name="glVertexAttribI4sv"/>
+            <command name="glVertexAttribI4ubv"/>
+            <command name="glVertexAttribI4usv"/>
+            <command name="glGetUniformuiv"/>
+            <command name="glBindFragDataLocation"/>
+            <command name="glGetFragDataLocation"/>
+            <command name="glUniform1ui"/>
+            <command name="glUniform2ui"/>
+            <command name="glUniform3ui"/>
+            <command name="glUniform4ui"/>
+            <command name="glUniform1uiv"/>
+            <command name="glUniform2uiv"/>
+            <command name="glUniform3uiv"/>
+            <command name="glUniform4uiv"/>
+            <command name="glTexParameterIiv"/>
+            <command name="glTexParameterIuiv"/>
+            <command name="glGetTexParameterIiv"/>
+            <command name="glGetTexParameterIuiv"/>
+            <command name="glClearBufferiv"/>
+            <command name="glClearBufferuiv"/>
+            <command name="glClearBufferfv"/>
+            <command name="glClearBufferfi"/>
+            <command name="glGetStringi"/>
+        </require>
+        <require comment="Reuse ARB_depth_buffer_float">
+            <enum name="GL_DEPTH_COMPONENT32F"/>
+            <enum name="GL_DEPTH32F_STENCIL8"/>
+            <enum name="GL_FLOAT_32_UNSIGNED_INT_24_8_REV"/>
+        </require>
+        <require comment="Reuse ARB_framebuffer_object">
+            <enum name="GL_INVALID_FRAMEBUFFER_OPERATION"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE"/>
+            <enum name="GL_FRAMEBUFFER_DEFAULT"/>
+            <enum name="GL_FRAMEBUFFER_UNDEFINED"/>
+            <enum name="GL_DEPTH_STENCIL_ATTACHMENT"/>
+            <enum name="GL_MAX_RENDERBUFFER_SIZE"/>
+            <enum name="GL_DEPTH_STENCIL"/>
+            <enum name="GL_UNSIGNED_INT_24_8"/>
+            <enum name="GL_DEPTH24_STENCIL8"/>
+            <enum name="GL_TEXTURE_STENCIL_SIZE"/>
+            <enum name="GL_TEXTURE_RED_TYPE"/>
+            <enum name="GL_TEXTURE_GREEN_TYPE"/>
+            <enum name="GL_TEXTURE_BLUE_TYPE"/>
+            <enum name="GL_TEXTURE_ALPHA_TYPE"/>
+            <enum name="GL_TEXTURE_DEPTH_TYPE"/>
+            <enum name="GL_UNSIGNED_NORMALIZED"/>
+            <enum name="GL_FRAMEBUFFER_BINDING"/>
+            <enum name="GL_DRAW_FRAMEBUFFER_BINDING"/>
+            <enum name="GL_RENDERBUFFER_BINDING"/>
+            <enum name="GL_READ_FRAMEBUFFER"/>
+            <enum name="GL_DRAW_FRAMEBUFFER"/>
+            <enum name="GL_READ_FRAMEBUFFER_BINDING"/>
+            <enum name="GL_RENDERBUFFER_SAMPLES"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER"/>
+            <enum name="GL_FRAMEBUFFER_COMPLETE"/>
+            <enum name="GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"/>
+            <enum name="GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"/>
+            <enum name="GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER"/>
+            <enum name="GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER"/>
+            <enum name="GL_FRAMEBUFFER_UNSUPPORTED"/>
+            <enum name="GL_MAX_COLOR_ATTACHMENTS"/>
+            <enum name="GL_COLOR_ATTACHMENT0"/>
+            <enum name="GL_COLOR_ATTACHMENT1"/>
+            <enum name="GL_COLOR_ATTACHMENT2"/>
+            <enum name="GL_COLOR_ATTACHMENT3"/>
+            <enum name="GL_COLOR_ATTACHMENT4"/>
+            <enum name="GL_COLOR_ATTACHMENT5"/>
+            <enum name="GL_COLOR_ATTACHMENT6"/>
+            <enum name="GL_COLOR_ATTACHMENT7"/>
+            <enum name="GL_COLOR_ATTACHMENT8"/>
+            <enum name="GL_COLOR_ATTACHMENT9"/>
+            <enum name="GL_COLOR_ATTACHMENT10"/>
+            <enum name="GL_COLOR_ATTACHMENT11"/>
+            <enum name="GL_COLOR_ATTACHMENT12"/>
+            <enum name="GL_COLOR_ATTACHMENT13"/>
+            <enum name="GL_COLOR_ATTACHMENT14"/>
+            <enum name="GL_COLOR_ATTACHMENT15"/>
+            <enum name="GL_DEPTH_ATTACHMENT"/>
+            <enum name="GL_STENCIL_ATTACHMENT"/>
+            <enum name="GL_FRAMEBUFFER"/>
+            <enum name="GL_RENDERBUFFER"/>
+            <enum name="GL_RENDERBUFFER_WIDTH"/>
+            <enum name="GL_RENDERBUFFER_HEIGHT"/>
+            <enum name="GL_RENDERBUFFER_INTERNAL_FORMAT"/>
+            <enum name="GL_STENCIL_INDEX1"/>
+            <enum name="GL_STENCIL_INDEX4"/>
+            <enum name="GL_STENCIL_INDEX8"/>
+            <enum name="GL_STENCIL_INDEX16"/>
+            <enum name="GL_RENDERBUFFER_RED_SIZE"/>
+            <enum name="GL_RENDERBUFFER_GREEN_SIZE"/>
+            <enum name="GL_RENDERBUFFER_BLUE_SIZE"/>
+            <enum name="GL_RENDERBUFFER_ALPHA_SIZE"/>
+            <enum name="GL_RENDERBUFFER_DEPTH_SIZE"/>
+            <enum name="GL_RENDERBUFFER_STENCIL_SIZE"/>
+            <enum name="GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"/>
+            <enum name="GL_MAX_SAMPLES"/>
+            <command name="glIsRenderbuffer"/>
+            <command name="glBindRenderbuffer"/>
+            <command name="glDeleteRenderbuffers"/>
+            <command name="glGenRenderbuffers"/>
+            <command name="glRenderbufferStorage"/>
+            <command name="glGetRenderbufferParameteriv"/>
+            <command name="glIsFramebuffer"/>
+            <command name="glBindFramebuffer"/>
+            <command name="glDeleteFramebuffers"/>
+            <command name="glGenFramebuffers"/>
+            <command name="glCheckFramebufferStatus"/>
+            <command name="glFramebufferTexture1D"/>
+            <command name="glFramebufferTexture2D"/>
+            <command name="glFramebufferTexture3D"/>
+            <command name="glFramebufferRenderbuffer"/>
+            <command name="glGetFramebufferAttachmentParameteriv"/>
+            <command name="glGenerateMipmap"/>
+            <command name="glBlitFramebuffer"/>
+            <command name="glRenderbufferStorageMultisample"/>
+            <command name="glFramebufferTextureLayer"/>
+        </require>
+        <require profile="compatibility" comment="Reuse ARB_framebuffer_object compatibility profile">
+            <enum name="GL_INDEX"/>
+            <enum name="GL_TEXTURE_LUMINANCE_TYPE"/>
+            <enum name="GL_TEXTURE_INTENSITY_TYPE"/>
+        </require>
+        <require comment="Reuse ARB_framebuffer_sRGB">
+            <enum name="GL_FRAMEBUFFER_SRGB"/>
+        </require>
+        <require comment="Reuse ARB_half_float_vertex">
+            <type name="GLhalf"/>
+            <enum name="GL_HALF_FLOAT"/>
+        </require>
+        <require comment="Reuse ARB_map_buffer_range">
+            <enum name="GL_MAP_READ_BIT"/>
+            <enum name="GL_MAP_WRITE_BIT"/>
+            <enum name="GL_MAP_INVALIDATE_RANGE_BIT"/>
+            <enum name="GL_MAP_INVALIDATE_BUFFER_BIT"/>
+            <enum name="GL_MAP_FLUSH_EXPLICIT_BIT"/>
+            <enum name="GL_MAP_UNSYNCHRONIZED_BIT"/>
+            <command name="glMapBufferRange"/>
+            <command name="glFlushMappedBufferRange"/>
+        </require>
+        <require comment="Reuse ARB_texture_compression_rgtc">
+            <enum name="GL_COMPRESSED_RED_RGTC1"/>
+            <enum name="GL_COMPRESSED_SIGNED_RED_RGTC1"/>
+            <enum name="GL_COMPRESSED_RG_RGTC2"/>
+            <enum name="GL_COMPRESSED_SIGNED_RG_RGTC2"/>
+        </require>
+        <require comment="Reuse ARB_texture_rg">
+            <enum name="GL_RG"/>
+            <enum name="GL_RG_INTEGER"/>
+            <enum name="GL_R8"/>
+            <enum name="GL_R16"/>
+            <enum name="GL_RG8"/>
+            <enum name="GL_RG16"/>
+            <enum name="GL_R16F"/>
+            <enum name="GL_R32F"/>
+            <enum name="GL_RG16F"/>
+            <enum name="GL_RG32F"/>
+            <enum name="GL_R8I"/>
+            <enum name="GL_R8UI"/>
+            <enum name="GL_R16I"/>
+            <enum name="GL_R16UI"/>
+            <enum name="GL_R32I"/>
+            <enum name="GL_R32UI"/>
+            <enum name="GL_RG8I"/>
+            <enum name="GL_RG8UI"/>
+            <enum name="GL_RG16I"/>
+            <enum name="GL_RG16UI"/>
+            <enum name="GL_RG32I"/>
+            <enum name="GL_RG32UI"/>
+        </require>
+        <require comment="Reuse ARB_vertex_array_object">
+            <enum name="GL_VERTEX_ARRAY_BINDING"/>
+            <enum name="GL_CLAMP_VERTEX_COLOR"/>
+            <enum name="GL_CLAMP_FRAGMENT_COLOR"/>
+            <enum name="GL_ALPHA_INTEGER"/>
+            <command name="glBindVertexArray"/>
+            <command name="glDeleteVertexArrays"/>
+            <command name="glGenVertexArrays"/>
+            <command name="glIsVertexArray"/>
+        </require>
+    </feature>
+    <feature api="gl" name="GL_VERSION_3_1" number="3.1">
+        <require>
+            <enum name="GL_SAMPLER_2D_RECT"/>
+            <enum name="GL_SAMPLER_2D_RECT_SHADOW"/>
+            <enum name="GL_SAMPLER_BUFFER"/>
+            <enum name="GL_INT_SAMPLER_2D_RECT"/>
+            <enum name="GL_INT_SAMPLER_BUFFER"/>
+            <enum name="GL_UNSIGNED_INT_SAMPLER_2D_RECT"/>
+            <enum name="GL_UNSIGNED_INT_SAMPLER_BUFFER"/>
+            <enum name="GL_TEXTURE_BUFFER"/>
+            <enum name="GL_MAX_TEXTURE_BUFFER_SIZE"/>
+            <enum name="GL_TEXTURE_BINDING_BUFFER"/>
+            <enum name="GL_TEXTURE_BUFFER_DATA_STORE_BINDING"/>
+            <enum name="GL_TEXTURE_RECTANGLE"/>
+            <enum name="GL_TEXTURE_BINDING_RECTANGLE"/>
+            <enum name="GL_PROXY_TEXTURE_RECTANGLE"/>
+            <enum name="GL_MAX_RECTANGLE_TEXTURE_SIZE"/>
+            <enum name="GL_R8_SNORM"/>
+            <enum name="GL_RG8_SNORM"/>
+            <enum name="GL_RGB8_SNORM"/>
+            <enum name="GL_RGBA8_SNORM"/>
+            <enum name="GL_R16_SNORM"/>
+            <enum name="GL_RG16_SNORM"/>
+            <enum name="GL_RGB16_SNORM"/>
+            <enum name="GL_RGBA16_SNORM"/>
+            <enum name="GL_SIGNED_NORMALIZED"/>
+            <enum name="GL_PRIMITIVE_RESTART"/>
+            <enum name="GL_PRIMITIVE_RESTART_INDEX"/>
+            <command name="glDrawArraysInstanced"/>
+            <command name="glDrawElementsInstanced"/>
+            <command name="glTexBuffer"/>
+            <command name="glPrimitiveRestartIndex"/>
+        </require>
+        <require comment="Reuse ARB_copy_buffer">
+            <enum name="GL_COPY_READ_BUFFER"/>
+            <enum name="GL_COPY_WRITE_BUFFER"/>
+            <command name="glCopyBufferSubData"/>
+        </require>
+        <require comment="Reuse ARB_uniform_buffer_object">
+            <enum name="GL_UNIFORM_BUFFER"/>
+            <enum name="GL_UNIFORM_BUFFER_BINDING"/>
+            <enum name="GL_UNIFORM_BUFFER_START"/>
+            <enum name="GL_UNIFORM_BUFFER_SIZE"/>
+            <enum name="GL_MAX_VERTEX_UNIFORM_BLOCKS"/>
+            <enum name="GL_MAX_FRAGMENT_UNIFORM_BLOCKS"/>
+            <enum name="GL_MAX_COMBINED_UNIFORM_BLOCKS"/>
+            <enum name="GL_MAX_UNIFORM_BUFFER_BINDINGS"/>
+            <enum name="GL_MAX_UNIFORM_BLOCK_SIZE"/>
+            <enum name="GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS"/>
+            <enum name="GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS"/>
+            <enum name="GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT"/>
+            <enum name="GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH"/>
+            <enum name="GL_ACTIVE_UNIFORM_BLOCKS"/>
+            <enum name="GL_UNIFORM_TYPE"/>
+            <enum name="GL_UNIFORM_SIZE"/>
+            <enum name="GL_UNIFORM_NAME_LENGTH"/>
+            <enum name="GL_UNIFORM_BLOCK_INDEX"/>
+            <enum name="GL_UNIFORM_OFFSET"/>
+            <enum name="GL_UNIFORM_ARRAY_STRIDE"/>
+            <enum name="GL_UNIFORM_MATRIX_STRIDE"/>
+            <enum name="GL_UNIFORM_IS_ROW_MAJOR"/>
+            <enum name="GL_UNIFORM_BLOCK_BINDING"/>
+            <enum name="GL_UNIFORM_BLOCK_DATA_SIZE"/>
+            <enum name="GL_UNIFORM_BLOCK_NAME_LENGTH"/>
+            <enum name="GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS"/>
+            <enum name="GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"/>
+            <enum name="GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER"/>
+            <enum name="GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER"/>
+            <enum name="GL_INVALID_INDEX"/>
+            <command name="glGetUniformIndices"/>
+            <command name="glGetActiveUniformsiv"/>
+            <command name="glGetActiveUniformName"/>
+            <command name="glGetUniformBlockIndex"/>
+            <command name="glGetActiveUniformBlockiv"/>
+            <command name="glGetActiveUniformBlockName"/>
+            <command name="glUniformBlockBinding"/>
+        </require>
+    </feature>
+    <feature api="gl" name="GL_VERSION_3_2" number="3.2">
+        <require>
+            <enum name="GL_CONTEXT_CORE_PROFILE_BIT"/>
+            <enum name="GL_CONTEXT_COMPATIBILITY_PROFILE_BIT"/>
+            <enum name="GL_LINES_ADJACENCY"/>
+            <enum name="GL_LINE_STRIP_ADJACENCY"/>
+            <enum name="GL_TRIANGLES_ADJACENCY"/>
+            <enum name="GL_TRIANGLE_STRIP_ADJACENCY"/>
+            <enum name="GL_PROGRAM_POINT_SIZE"/>
+            <enum name="GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_LAYERED"/>
+            <enum name="GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS"/>
+            <enum name="GL_GEOMETRY_SHADER"/>
+            <enum name="GL_GEOMETRY_VERTICES_OUT"/>
+            <enum name="GL_GEOMETRY_INPUT_TYPE"/>
+            <enum name="GL_GEOMETRY_OUTPUT_TYPE"/>
+            <enum name="GL_MAX_GEOMETRY_UNIFORM_COMPONENTS"/>
+            <enum name="GL_MAX_GEOMETRY_OUTPUT_VERTICES"/>
+            <enum name="GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS"/>
+            <enum name="GL_MAX_VERTEX_OUTPUT_COMPONENTS"/>
+            <enum name="GL_MAX_GEOMETRY_INPUT_COMPONENTS"/>
+            <enum name="GL_MAX_GEOMETRY_OUTPUT_COMPONENTS"/>
+            <enum name="GL_MAX_FRAGMENT_INPUT_COMPONENTS"/>
+            <enum name="GL_CONTEXT_PROFILE_MASK"/>
+        </require>
+        <require comment="Reuse ARB_depth_clamp">
+            <enum name="GL_DEPTH_CLAMP"/>
+        </require>
+        <require comment="Reuse ARB_draw_elements_base_vertex">
+            <command name="glDrawElementsBaseVertex"/>
+            <command name="glDrawRangeElementsBaseVertex"/>
+            <command name="glDrawElementsInstancedBaseVertex"/>
+            <command name="glMultiDrawElementsBaseVertex"/>
+        </require>
+        <require comment="Reuse ARB_fragment_coord_conventions (none)">
+        </require>
+        <require comment="Reuse ARB_provoking_vertex">
+            <enum name="GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION"/>
+            <enum name="GL_FIRST_VERTEX_CONVENTION"/>
+            <enum name="GL_LAST_VERTEX_CONVENTION"/>
+            <enum name="GL_PROVOKING_VERTEX"/>
+            <command name="glProvokingVertex"/>
+        </require>
+        <require comment="Reuse ARB_seamless_cube_map">
+            <enum name="GL_TEXTURE_CUBE_MAP_SEAMLESS"/>
+        </require>
+        <require comment="Reuse ARB_sync">
+            <enum name="GL_MAX_SERVER_WAIT_TIMEOUT"/>
+            <enum name="GL_OBJECT_TYPE"/>
+            <enum name="GL_SYNC_CONDITION"/>
+            <enum name="GL_SYNC_STATUS"/>
+            <enum name="GL_SYNC_FLAGS"/>
+            <enum name="GL_SYNC_FENCE"/>
+            <enum name="GL_SYNC_GPU_COMMANDS_COMPLETE"/>
+            <enum name="GL_UNSIGNALED"/>
+            <enum name="GL_SIGNALED"/>
+            <enum name="GL_ALREADY_SIGNALED"/>
+            <enum name="GL_TIMEOUT_EXPIRED"/>
+            <enum name="GL_CONDITION_SATISFIED"/>
+            <enum name="GL_WAIT_FAILED"/>
+            <enum name="GL_TIMEOUT_IGNORED"/>
+            <enum name="GL_SYNC_FLUSH_COMMANDS_BIT"/>
+            <command name="glFenceSync"/>
+            <command name="glIsSync"/>
+            <command name="glDeleteSync"/>
+            <command name="glClientWaitSync"/>
+            <command name="glWaitSync"/>
+            <command name="glGetInteger64v"/>
+            <command name="glGetSynciv"/>
+        </require>
+        <require comment="Reuse ARB_texture_multisample">
+            <enum name="GL_SAMPLE_POSITION"/>
+            <enum name="GL_SAMPLE_MASK"/>
+            <enum name="GL_SAMPLE_MASK_VALUE"/>
+            <enum name="GL_MAX_SAMPLE_MASK_WORDS"/>
+            <enum name="GL_TEXTURE_2D_MULTISAMPLE"/>
+            <enum name="GL_PROXY_TEXTURE_2D_MULTISAMPLE"/>
+            <enum name="GL_TEXTURE_2D_MULTISAMPLE_ARRAY"/>
+            <enum name="GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY"/>
+            <enum name="GL_TEXTURE_BINDING_2D_MULTISAMPLE"/>
+            <enum name="GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY"/>
+            <enum name="GL_TEXTURE_SAMPLES"/>
+            <enum name="GL_TEXTURE_FIXED_SAMPLE_LOCATIONS"/>
+            <enum name="GL_SAMPLER_2D_MULTISAMPLE"/>
+            <enum name="GL_INT_SAMPLER_2D_MULTISAMPLE"/>
+            <enum name="GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE"/>
+            <enum name="GL_SAMPLER_2D_MULTISAMPLE_ARRAY"/>
+            <enum name="GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY"/>
+            <enum name="GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY"/>
+            <enum name="GL_MAX_COLOR_TEXTURE_SAMPLES"/>
+            <enum name="GL_MAX_DEPTH_TEXTURE_SAMPLES"/>
+            <enum name="GL_MAX_INTEGER_SAMPLES"/>
+            <!-- /* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */ -->
+            <command name="glGetInteger64i_v"/>
+            <command name="glGetBufferParameteri64v"/>
+            <command name="glFramebufferTexture"/>
+            <command name="glTexImage2DMultisample"/>
+            <command name="glTexImage3DMultisample"/>
+            <command name="glGetMultisamplefv"/>
+            <command name="glSampleMaski"/>
+        </require>
+        <!-- OpenGL 3.2 is where core and compatibility profiles were first
+             introduced, so many, many things were removed from the core
+             profile in this version. A few were reintroduced later (e.g.
+             GetPointerv / STACK_{UNDER,OVER}FLOW by OpenGL 4.3 for debug
+             functionality). -->
+        <remove profile="core" comment="Compatibility-only GL 1.0 features removed from GL 3.2">
+            <command name="glNewList"/>
+            <command name="glEndList"/>
+            <command name="glCallList"/>
+            <command name="glCallLists"/>
+            <command name="glDeleteLists"/>
+            <command name="glGenLists"/>
+            <command name="glListBase"/>
+            <command name="glBegin"/>
+            <command name="glBitmap"/>
+            <command name="glColor3b"/>
+            <command name="glColor3bv"/>
+            <command name="glColor3d"/>
+            <command name="glColor3dv"/>
+            <command name="glColor3f"/>
+            <command name="glColor3fv"/>
+            <command name="glColor3i"/>
+            <command name="glColor3iv"/>
+            <command name="glColor3s"/>
+            <command name="glColor3sv"/>
+            <command name="glColor3ub"/>
+            <command name="glColor3ubv"/>
+            <command name="glColor3ui"/>
+            <command name="glColor3uiv"/>
+            <command name="glColor3us"/>
+            <command name="glColor3usv"/>
+            <command name="glColor4b"/>
+            <command name="glColor4bv"/>
+            <command name="glColor4d"/>
+            <command name="glColor4dv"/>
+            <command name="glColor4f"/>
+            <command name="glColor4fv"/>
+            <command name="glColor4i"/>
+            <command name="glColor4iv"/>
+            <command name="glColor4s"/>
+            <command name="glColor4sv"/>
+            <command name="glColor4ub"/>
+            <command name="glColor4ubv"/>
+            <command name="glColor4ui"/>
+            <command name="glColor4uiv"/>
+            <command name="glColor4us"/>
+            <command name="glColor4usv"/>
+            <command name="glEdgeFlag"/>
+            <command name="glEdgeFlagv"/>
+            <command name="glEnd"/>
+            <command name="glIndexd"/>
+            <command name="glIndexdv"/>
+            <command name="glIndexf"/>
+            <command name="glIndexfv"/>
+            <command name="glIndexi"/>
+            <command name="glIndexiv"/>
+            <command name="glIndexs"/>
+            <command name="glIndexsv"/>
+            <command name="glNormal3b"/>
+            <command name="glNormal3bv"/>
+            <command name="glNormal3d"/>
+            <command name="glNormal3dv"/>
+            <command name="glNormal3f"/>
+            <command name="glNormal3fv"/>
+            <command name="glNormal3i"/>
+            <command name="glNormal3iv"/>
+            <command name="glNormal3s"/>
+            <command name="glNormal3sv"/>
+            <command name="glRasterPos2d"/>
+            <command name="glRasterPos2dv"/>
+            <command name="glRasterPos2f"/>
+            <command name="glRasterPos2fv"/>
+            <command name="glRasterPos2i"/>
+            <command name="glRasterPos2iv"/>
+            <command name="glRasterPos2s"/>
+            <command name="glRasterPos2sv"/>
+            <command name="glRasterPos3d"/>
+            <command name="glRasterPos3dv"/>
+            <command name="glRasterPos3f"/>
+            <command name="glRasterPos3fv"/>
+            <command name="glRasterPos3i"/>
+            <command name="glRasterPos3iv"/>
+            <command name="glRasterPos3s"/>
+            <command name="glRasterPos3sv"/>
+            <command name="glRasterPos4d"/>
+            <command name="glRasterPos4dv"/>
+            <command name="glRasterPos4f"/>
+            <command name="glRasterPos4fv"/>
+            <command name="glRasterPos4i"/>
+            <command name="glRasterPos4iv"/>
+            <command name="glRasterPos4s"/>
+            <command name="glRasterPos4sv"/>
+            <command name="glRectd"/>
+            <command name="glRectdv"/>
+            <command name="glRectf"/>
+            <command name="glRectfv"/>
+            <command name="glRecti"/>
+            <command name="glRectiv"/>
+            <command name="glRects"/>
+            <command name="glRectsv"/>
+            <command name="glTexCoord1d"/>
+            <command name="glTexCoord1dv"/>
+            <command name="glTexCoord1f"/>
+            <command name="glTexCoord1fv"/>
+            <command name="glTexCoord1i"/>
+            <command name="glTexCoord1iv"/>
+            <command name="glTexCoord1s"/>
+            <command name="glTexCoord1sv"/>
+            <command name="glTexCoord2d"/>
+            <command name="glTexCoord2dv"/>
+            <command name="glTexCoord2f"/>
+            <command name="glTexCoord2fv"/>
+            <command name="glTexCoord2i"/>
+            <command name="glTexCoord2iv"/>
+            <command name="glTexCoord2s"/>
+            <command name="glTexCoord2sv"/>
+            <command name="glTexCoord3d"/>
+            <command name="glTexCoord3dv"/>
+            <command name="glTexCoord3f"/>
+            <command name="glTexCoord3fv"/>
+            <command name="glTexCoord3i"/>
+            <command name="glTexCoord3iv"/>
+            <command name="glTexCoord3s"/>
+            <command name="glTexCoord3sv"/>
+            <command name="glTexCoord4d"/>
+            <command name="glTexCoord4dv"/>
+            <command name="glTexCoord4f"/>
+            <command name="glTexCoord4fv"/>
+            <command name="glTexCoord4i"/>
+            <command name="glTexCoord4iv"/>
+            <command name="glTexCoord4s"/>
+            <command name="glTexCoord4sv"/>
+            <command name="glVertex2d"/>
+            <command name="glVertex2dv"/>
+            <command name="glVertex2f"/>
+            <command name="glVertex2fv"/>
+            <command name="glVertex2i"/>
+            <command name="glVertex2iv"/>
+            <command name="glVertex2s"/>
+            <command name="glVertex2sv"/>
+            <command name="glVertex3d"/>
+            <command name="glVertex3dv"/>
+            <command name="glVertex3f"/>
+            <command name="glVertex3fv"/>
+            <command name="glVertex3i"/>
+            <command name="glVertex3iv"/>
+            <command name="glVertex3s"/>
+            <command name="glVertex3sv"/>
+            <command name="glVertex4d"/>
+            <command name="glVertex4dv"/>
+            <command name="glVertex4f"/>
+            <command name="glVertex4fv"/>
+            <command name="glVertex4i"/>
+            <command name="glVertex4iv"/>
+            <command name="glVertex4s"/>
+            <command name="glVertex4sv"/>
+            <command name="glClipPlane"/>
+            <command name="glColorMaterial"/>
+            <command name="glFogf"/>
+            <command name="glFogfv"/>
+            <command name="glFogi"/>
+            <command name="glFogiv"/>
+            <command name="glLightf"/>
+            <command name="glLightfv"/>
+            <command name="glLighti"/>
+            <command name="glLightiv"/>
+            <command name="glLightModelf"/>
+            <command name="glLightModelfv"/>
+            <command name="glLightModeli"/>
+            <command name="glLightModeliv"/>
+            <command name="glLineStipple"/>
+            <command name="glMaterialf"/>
+            <command name="glMaterialfv"/>
+            <command name="glMateriali"/>
+            <command name="glMaterialiv"/>
+            <command name="glPolygonStipple"/>
+            <command name="glShadeModel"/>
+            <command name="glTexEnvf"/>
+            <command name="glTexEnvfv"/>
+            <command name="glTexEnvi"/>
+            <command name="glTexEnviv"/>
+            <command name="glTexGend"/>
+            <command name="glTexGendv"/>
+            <command name="glTexGenf"/>
+            <command name="glTexGenfv"/>
+            <command name="glTexGeni"/>
+            <command name="glTexGeniv"/>
+            <command name="glFeedbackBuffer"/>
+            <command name="glSelectBuffer"/>
+            <command name="glRenderMode"/>
+            <command name="glInitNames"/>
+            <command name="glLoadName"/>
+            <command name="glPassThrough"/>
+            <command name="glPopName"/>
+            <command name="glPushName"/>
+            <command name="glClearAccum"/>
+            <command name="glClearIndex"/>
+            <command name="glIndexMask"/>
+            <command name="glAccum"/>
+            <command name="glPopAttrib"/>
+            <command name="glPushAttrib"/>
+            <command name="glMap1d"/>
+            <command name="glMap1f"/>
+            <command name="glMap2d"/>
+            <command name="glMap2f"/>
+            <command name="glMapGrid1d"/>
+            <command name="glMapGrid1f"/>
+            <command name="glMapGrid2d"/>
+            <command name="glMapGrid2f"/>
+            <command name="glEvalCoord1d"/>
+            <command name="glEvalCoord1dv"/>
+            <command name="glEvalCoord1f"/>
+            <command name="glEvalCoord1fv"/>
+            <command name="glEvalCoord2d"/>
+            <command name="glEvalCoord2dv"/>
+            <command name="glEvalCoord2f"/>
+            <command name="glEvalCoord2fv"/>
+            <command name="glEvalMesh1"/>
+            <command name="glEvalPoint1"/>
+            <command name="glEvalMesh2"/>
+            <command name="glEvalPoint2"/>
+            <command name="glAlphaFunc"/>
+            <command name="glPixelZoom"/>
+            <command name="glPixelTransferf"/>
+            <command name="glPixelTransferi"/>
+            <command name="glPixelMapfv"/>
+            <command name="glPixelMapuiv"/>
+            <command name="glPixelMapusv"/>
+            <command name="glCopyPixels"/>
+            <command name="glDrawPixels"/>
+            <command name="glGetClipPlane"/>
+            <command name="glGetLightfv"/>
+            <command name="glGetLightiv"/>
+            <command name="glGetMapdv"/>
+            <command name="glGetMapfv"/>
+            <command name="glGetMapiv"/>
+            <command name="glGetMaterialfv"/>
+            <command name="glGetMaterialiv"/>
+            <command name="glGetPixelMapfv"/>
+            <command name="glGetPixelMapuiv"/>
+            <command name="glGetPixelMapusv"/>
+            <command name="glGetPolygonStipple"/>
+            <command name="glGetTexEnvfv"/>
+            <command name="glGetTexEnviv"/>
+            <command name="glGetTexGendv"/>
+            <command name="glGetTexGenfv"/>
+            <command name="glGetTexGeniv"/>
+            <command name="glIsList"/>
+            <command name="glFrustum"/>
+            <command name="glLoadIdentity"/>
+            <command name="glLoadMatrixf"/>
+            <command name="glLoadMatrixd"/>
+            <command name="glMatrixMode"/>
+            <command name="glMultMatrixf"/>
+            <command name="glMultMatrixd"/>
+            <command name="glOrtho"/>
+            <command name="glPopMatrix"/>
+            <command name="glPushMatrix"/>
+            <command name="glRotated"/>
+            <command name="glRotatef"/>
+            <command name="glScaled"/>
+            <command name="glScalef"/>
+            <command name="glTranslated"/>
+            <command name="glTranslatef"/>
+        </remove>
+        <remove profile="core" comment="Compatibility-only GL 1.1 features removed from GL 3.2">
+            <enum name="GL_CURRENT_BIT"/>
+            <enum name="GL_POINT_BIT"/>
+            <enum name="GL_LINE_BIT"/>
+            <enum name="GL_POLYGON_BIT"/>
+            <enum name="GL_POLYGON_STIPPLE_BIT"/>
+            <enum name="GL_PIXEL_MODE_BIT"/>
+            <enum name="GL_LIGHTING_BIT"/>
+            <enum name="GL_FOG_BIT"/>
+            <enum name="GL_ACCUM_BUFFER_BIT"/>
+            <enum name="GL_VIEWPORT_BIT"/>
+            <enum name="GL_TRANSFORM_BIT"/>
+            <enum name="GL_ENABLE_BIT"/>
+            <enum name="GL_HINT_BIT"/>
+            <enum name="GL_EVAL_BIT"/>
+            <enum name="GL_LIST_BIT"/>
+            <enum name="GL_TEXTURE_BIT"/>
+            <enum name="GL_SCISSOR_BIT"/>
+            <enum name="GL_ALL_ATTRIB_BITS"/>
+            <enum name="GL_CLIENT_PIXEL_STORE_BIT"/>
+            <enum name="GL_CLIENT_VERTEX_ARRAY_BIT"/>
+            <enum name="GL_CLIENT_ALL_ATTRIB_BITS"/>
+            <enum name="GL_QUAD_STRIP"/>
+            <enum name="GL_QUADS"/>
+            <enum name="GL_POLYGON"/>
+            <enum name="GL_ACCUM"/>
+            <enum name="GL_LOAD"/>
+            <enum name="GL_RETURN"/>
+            <enum name="GL_MULT"/>
+            <enum name="GL_ADD"/>
+            <enum name="GL_STACK_OVERFLOW"/>
+            <enum name="GL_STACK_UNDERFLOW"/>
+            <enum name="GL_AUX0"/>
+            <enum name="GL_AUX1"/>
+            <enum name="GL_AUX2"/>
+            <enum name="GL_AUX3"/>
+            <enum name="GL_2D"/>
+            <enum name="GL_3D"/>
+            <enum name="GL_3D_COLOR"/>
+            <enum name="GL_3D_COLOR_TEXTURE"/>
+            <enum name="GL_4D_COLOR_TEXTURE"/>
+            <enum name="GL_PASS_THROUGH_TOKEN"/>
+            <enum name="GL_POINT_TOKEN"/>
+            <enum name="GL_LINE_TOKEN"/>
+            <enum name="GL_POLYGON_TOKEN"/>
+            <enum name="GL_BITMAP_TOKEN"/>
+            <enum name="GL_DRAW_PIXEL_TOKEN"/>
+            <enum name="GL_COPY_PIXEL_TOKEN"/>
+            <enum name="GL_LINE_RESET_TOKEN"/>
+            <enum name="GL_EXP"/>
+            <enum name="GL_EXP2"/>
+            <enum name="GL_COEFF"/>
+            <enum name="GL_ORDER"/>
+            <enum name="GL_DOMAIN"/>
+            <enum name="GL_PIXEL_MAP_I_TO_I"/>
+            <enum name="GL_PIXEL_MAP_S_TO_S"/>
+            <enum name="GL_PIXEL_MAP_I_TO_R"/>
+            <enum name="GL_PIXEL_MAP_I_TO_G"/>
+            <enum name="GL_PIXEL_MAP_I_TO_B"/>
+            <enum name="GL_PIXEL_MAP_I_TO_A"/>
+            <enum name="GL_PIXEL_MAP_R_TO_R"/>
+            <enum name="GL_PIXEL_MAP_G_TO_G"/>
+            <enum name="GL_PIXEL_MAP_B_TO_B"/>
+            <enum name="GL_PIXEL_MAP_A_TO_A"/>
+            <enum name="GL_VERTEX_ARRAY_POINTER"/>
+            <enum name="GL_NORMAL_ARRAY_POINTER"/>
+            <enum name="GL_COLOR_ARRAY_POINTER"/>
+            <enum name="GL_INDEX_ARRAY_POINTER"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_POINTER"/>
+            <enum name="GL_EDGE_FLAG_ARRAY_POINTER"/>
+            <enum name="GL_FEEDBACK_BUFFER_POINTER"/>
+            <enum name="GL_SELECTION_BUFFER_POINTER"/>
+            <enum name="GL_CURRENT_COLOR"/>
+            <enum name="GL_CURRENT_INDEX"/>
+            <enum name="GL_CURRENT_NORMAL"/>
+            <enum name="GL_CURRENT_TEXTURE_COORDS"/>
+            <enum name="GL_CURRENT_RASTER_COLOR"/>
+            <enum name="GL_CURRENT_RASTER_INDEX"/>
+            <enum name="GL_CURRENT_RASTER_TEXTURE_COORDS"/>
+            <enum name="GL_CURRENT_RASTER_POSITION"/>
+            <enum name="GL_CURRENT_RASTER_POSITION_VALID"/>
+            <enum name="GL_CURRENT_RASTER_DISTANCE"/>
+            <enum name="GL_POINT_SMOOTH"/>
+            <enum name="GL_LINE_STIPPLE"/>
+            <enum name="GL_LINE_STIPPLE_PATTERN"/>
+            <enum name="GL_LINE_STIPPLE_REPEAT"/>
+            <enum name="GL_LIST_MODE"/>
+            <enum name="GL_MAX_LIST_NESTING"/>
+            <enum name="GL_LIST_BASE"/>
+            <enum name="GL_LIST_INDEX"/>
+            <enum name="GL_POLYGON_STIPPLE"/>
+            <enum name="GL_EDGE_FLAG"/>
+            <enum name="GL_LIGHTING"/>
+            <enum name="GL_LIGHT_MODEL_LOCAL_VIEWER"/>
+            <enum name="GL_LIGHT_MODEL_TWO_SIDE"/>
+            <enum name="GL_LIGHT_MODEL_AMBIENT"/>
+            <enum name="GL_SHADE_MODEL"/>
+            <enum name="GL_COLOR_MATERIAL_FACE"/>
+            <enum name="GL_COLOR_MATERIAL_PARAMETER"/>
+            <enum name="GL_COLOR_MATERIAL"/>
+            <enum name="GL_FOG"/>
+            <enum name="GL_FOG_INDEX"/>
+            <enum name="GL_FOG_DENSITY"/>
+            <enum name="GL_FOG_START"/>
+            <enum name="GL_FOG_END"/>
+            <enum name="GL_FOG_MODE"/>
+            <enum name="GL_FOG_COLOR"/>
+            <enum name="GL_ACCUM_CLEAR_VALUE"/>
+            <enum name="GL_MATRIX_MODE"/>
+            <enum name="GL_NORMALIZE"/>
+            <enum name="GL_MODELVIEW_STACK_DEPTH"/>
+            <enum name="GL_PROJECTION_STACK_DEPTH"/>
+            <enum name="GL_TEXTURE_STACK_DEPTH"/>
+            <enum name="GL_MODELVIEW_MATRIX"/>
+            <enum name="GL_PROJECTION_MATRIX"/>
+            <enum name="GL_TEXTURE_MATRIX"/>
+            <enum name="GL_ATTRIB_STACK_DEPTH"/>
+            <enum name="GL_CLIENT_ATTRIB_STACK_DEPTH"/>
+            <enum name="GL_ALPHA_TEST"/>
+            <enum name="GL_ALPHA_TEST_FUNC"/>
+            <enum name="GL_ALPHA_TEST_REF"/>
+            <enum name="GL_INDEX_LOGIC_OP"/>
+            <enum name="GL_LOGIC_OP"/>
+            <enum name="GL_AUX_BUFFERS"/>
+            <enum name="GL_INDEX_CLEAR_VALUE"/>
+            <enum name="GL_INDEX_WRITEMASK"/>
+            <enum name="GL_INDEX_MODE"/>
+            <enum name="GL_RGBA_MODE"/>
+            <enum name="GL_RENDER_MODE"/>
+            <enum name="GL_PERSPECTIVE_CORRECTION_HINT"/>
+            <enum name="GL_POINT_SMOOTH_HINT"/>
+            <enum name="GL_FOG_HINT"/>
+            <enum name="GL_TEXTURE_GEN_S"/>
+            <enum name="GL_TEXTURE_GEN_T"/>
+            <enum name="GL_TEXTURE_GEN_R"/>
+            <enum name="GL_TEXTURE_GEN_Q"/>
+            <enum name="GL_PIXEL_MAP_I_TO_I_SIZE"/>
+            <enum name="GL_PIXEL_MAP_S_TO_S_SIZE"/>
+            <enum name="GL_PIXEL_MAP_I_TO_R_SIZE"/>
+            <enum name="GL_PIXEL_MAP_I_TO_G_SIZE"/>
+            <enum name="GL_PIXEL_MAP_I_TO_B_SIZE"/>
+            <enum name="GL_PIXEL_MAP_I_TO_A_SIZE"/>
+            <enum name="GL_PIXEL_MAP_R_TO_R_SIZE"/>
+            <enum name="GL_PIXEL_MAP_G_TO_G_SIZE"/>
+            <enum name="GL_PIXEL_MAP_B_TO_B_SIZE"/>
+            <enum name="GL_PIXEL_MAP_A_TO_A_SIZE"/>
+            <enum name="GL_MAP_COLOR"/>
+            <enum name="GL_MAP_STENCIL"/>
+            <enum name="GL_INDEX_SHIFT"/>
+            <enum name="GL_INDEX_OFFSET"/>
+            <enum name="GL_RED_SCALE"/>
+            <enum name="GL_RED_BIAS"/>
+            <enum name="GL_ZOOM_X"/>
+            <enum name="GL_ZOOM_Y"/>
+            <enum name="GL_GREEN_SCALE"/>
+            <enum name="GL_GREEN_BIAS"/>
+            <enum name="GL_BLUE_SCALE"/>
+            <enum name="GL_BLUE_BIAS"/>
+            <enum name="GL_ALPHA_SCALE"/>
+            <enum name="GL_ALPHA_BIAS"/>
+            <enum name="GL_DEPTH_SCALE"/>
+            <enum name="GL_DEPTH_BIAS"/>
+            <enum name="GL_MAX_EVAL_ORDER"/>
+            <enum name="GL_MAX_LIGHTS"/>
+            <enum name="GL_MAX_CLIP_PLANES"/>
+            <enum name="GL_MAX_PIXEL_MAP_TABLE"/>
+            <enum name="GL_MAX_ATTRIB_STACK_DEPTH"/>
+            <enum name="GL_MAX_MODELVIEW_STACK_DEPTH"/>
+            <enum name="GL_MAX_NAME_STACK_DEPTH"/>
+            <enum name="GL_MAX_PROJECTION_STACK_DEPTH"/>
+            <enum name="GL_MAX_TEXTURE_STACK_DEPTH"/>
+            <enum name="GL_MAX_CLIENT_ATTRIB_STACK_DEPTH"/>
+            <enum name="GL_INDEX_BITS"/>
+            <enum name="GL_RED_BITS"/>
+            <enum name="GL_GREEN_BITS"/>
+            <enum name="GL_BLUE_BITS"/>
+            <enum name="GL_ALPHA_BITS"/>
+            <enum name="GL_DEPTH_BITS"/>
+            <enum name="GL_STENCIL_BITS"/>
+            <enum name="GL_ACCUM_RED_BITS"/>
+            <enum name="GL_ACCUM_GREEN_BITS"/>
+            <enum name="GL_ACCUM_BLUE_BITS"/>
+            <enum name="GL_ACCUM_ALPHA_BITS"/>
+            <enum name="GL_NAME_STACK_DEPTH"/>
+            <enum name="GL_AUTO_NORMAL"/>
+            <enum name="GL_MAP1_COLOR_4"/>
+            <enum name="GL_MAP1_INDEX"/>
+            <enum name="GL_MAP1_NORMAL"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_1"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_2"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_3"/>
+            <enum name="GL_MAP1_TEXTURE_COORD_4"/>
+            <enum name="GL_MAP1_VERTEX_3"/>
+            <enum name="GL_MAP1_VERTEX_4"/>
+            <enum name="GL_MAP2_COLOR_4"/>
+            <enum name="GL_MAP2_INDEX"/>
+            <enum name="GL_MAP2_NORMAL"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_1"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_2"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_3"/>
+            <enum name="GL_MAP2_TEXTURE_COORD_4"/>
+            <enum name="GL_MAP2_VERTEX_3"/>
+            <enum name="GL_MAP2_VERTEX_4"/>
+            <enum name="GL_MAP1_GRID_DOMAIN"/>
+            <enum name="GL_MAP1_GRID_SEGMENTS"/>
+            <enum name="GL_MAP2_GRID_DOMAIN"/>
+            <enum name="GL_MAP2_GRID_SEGMENTS"/>
+            <enum name="GL_FEEDBACK_BUFFER_SIZE"/>
+            <enum name="GL_FEEDBACK_BUFFER_TYPE"/>
+            <enum name="GL_SELECTION_BUFFER_SIZE"/>
+            <enum name="GL_VERTEX_ARRAY"/>
+            <enum name="GL_NORMAL_ARRAY"/>
+            <enum name="GL_COLOR_ARRAY"/>
+            <enum name="GL_INDEX_ARRAY"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY"/>
+            <enum name="GL_EDGE_FLAG_ARRAY"/>
+            <enum name="GL_VERTEX_ARRAY_SIZE"/>
+            <enum name="GL_VERTEX_ARRAY_TYPE"/>
+            <enum name="GL_VERTEX_ARRAY_STRIDE"/>
+            <enum name="GL_NORMAL_ARRAY_TYPE"/>
+            <enum name="GL_NORMAL_ARRAY_STRIDE"/>
+            <enum name="GL_COLOR_ARRAY_SIZE"/>
+            <enum name="GL_COLOR_ARRAY_TYPE"/>
+            <enum name="GL_COLOR_ARRAY_STRIDE"/>
+            <enum name="GL_INDEX_ARRAY_TYPE"/>
+            <enum name="GL_INDEX_ARRAY_STRIDE"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_SIZE"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_TYPE"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_STRIDE"/>
+            <enum name="GL_EDGE_FLAG_ARRAY_STRIDE"/>
+            <enum name="GL_TEXTURE_COMPONENTS"/>
+            <enum name="GL_TEXTURE_BORDER"/>
+            <enum name="GL_TEXTURE_LUMINANCE_SIZE"/>
+            <enum name="GL_TEXTURE_INTENSITY_SIZE"/>
+            <enum name="GL_TEXTURE_PRIORITY"/>
+            <enum name="GL_TEXTURE_RESIDENT"/>
+            <enum name="GL_AMBIENT"/>
+            <enum name="GL_DIFFUSE"/>
+            <enum name="GL_SPECULAR"/>
+            <enum name="GL_POSITION"/>
+            <enum name="GL_SPOT_DIRECTION"/>
+            <enum name="GL_SPOT_EXPONENT"/>
+            <enum name="GL_SPOT_CUTOFF"/>
+            <enum name="GL_CONSTANT_ATTENUATION"/>
+            <enum name="GL_LINEAR_ATTENUATION"/>
+            <enum name="GL_QUADRATIC_ATTENUATION"/>
+            <enum name="GL_COMPILE"/>
+            <enum name="GL_COMPILE_AND_EXECUTE"/>
+            <enum name="GL_2_BYTES"/>
+            <enum name="GL_3_BYTES"/>
+            <enum name="GL_4_BYTES"/>
+            <enum name="GL_EMISSION"/>
+            <enum name="GL_SHININESS"/>
+            <enum name="GL_AMBIENT_AND_DIFFUSE"/>
+            <enum name="GL_COLOR_INDEXES"/>
+            <enum name="GL_MODELVIEW"/>
+            <enum name="GL_PROJECTION"/>
+            <enum name="GL_COLOR_INDEX"/>
+            <enum name="GL_LUMINANCE"/>
+            <enum name="GL_LUMINANCE_ALPHA"/>
+            <enum name="GL_BITMAP"/>
+            <enum name="GL_RENDER"/>
+            <enum name="GL_FEEDBACK"/>
+            <enum name="GL_SELECT"/>
+            <enum name="GL_FLAT"/>
+            <enum name="GL_SMOOTH"/>
+            <enum name="GL_S"/>
+            <enum name="GL_T"/>
+            <enum name="GL_R"/>
+            <enum name="GL_Q"/>
+            <enum name="GL_MODULATE"/>
+            <enum name="GL_DECAL"/>
+            <enum name="GL_TEXTURE_ENV_MODE"/>
+            <enum name="GL_TEXTURE_ENV_COLOR"/>
+            <enum name="GL_TEXTURE_ENV"/>
+            <enum name="GL_EYE_LINEAR"/>
+            <enum name="GL_OBJECT_LINEAR"/>
+            <enum name="GL_SPHERE_MAP"/>
+            <enum name="GL_TEXTURE_GEN_MODE"/>
+            <enum name="GL_OBJECT_PLANE"/>
+            <enum name="GL_EYE_PLANE"/>
+            <enum name="GL_CLAMP"/>
+            <enum name="GL_ALPHA4"/>
+            <enum name="GL_ALPHA8"/>
+            <enum name="GL_ALPHA12"/>
+            <enum name="GL_ALPHA16"/>
+            <enum name="GL_LUMINANCE4"/>
+            <enum name="GL_LUMINANCE8"/>
+            <enum name="GL_LUMINANCE12"/>
+            <enum name="GL_LUMINANCE16"/>
+            <enum name="GL_LUMINANCE4_ALPHA4"/>
+            <enum name="GL_LUMINANCE6_ALPHA2"/>
+            <enum name="GL_LUMINANCE8_ALPHA8"/>
+            <enum name="GL_LUMINANCE12_ALPHA4"/>
+            <enum name="GL_LUMINANCE12_ALPHA12"/>
+            <enum name="GL_LUMINANCE16_ALPHA16"/>
+            <enum name="GL_INTENSITY"/>
+            <enum name="GL_INTENSITY4"/>
+            <enum name="GL_INTENSITY8"/>
+            <enum name="GL_INTENSITY12"/>
+            <enum name="GL_INTENSITY16"/>
+            <enum name="GL_V2F"/>
+            <enum name="GL_V3F"/>
+            <enum name="GL_C4UB_V2F"/>
+            <enum name="GL_C4UB_V3F"/>
+            <enum name="GL_C3F_V3F"/>
+            <enum name="GL_N3F_V3F"/>
+            <enum name="GL_C4F_N3F_V3F"/>
+            <enum name="GL_T2F_V3F"/>
+            <enum name="GL_T4F_V4F"/>
+            <enum name="GL_T2F_C4UB_V3F"/>
+            <enum name="GL_T2F_C3F_V3F"/>
+            <enum name="GL_T2F_N3F_V3F"/>
+            <enum name="GL_T2F_C4F_N3F_V3F"/>
+            <enum name="GL_T4F_C4F_N3F_V4F"/>
+            <enum name="GL_CLIP_PLANE0"/>
+            <enum name="GL_CLIP_PLANE1"/>
+            <enum name="GL_CLIP_PLANE2"/>
+            <enum name="GL_CLIP_PLANE3"/>
+            <enum name="GL_CLIP_PLANE4"/>
+            <enum name="GL_CLIP_PLANE5"/>
+            <enum name="GL_LIGHT0"/>
+            <enum name="GL_LIGHT1"/>
+            <enum name="GL_LIGHT2"/>
+            <enum name="GL_LIGHT3"/>
+            <enum name="GL_LIGHT4"/>
+            <enum name="GL_LIGHT5"/>
+            <enum name="GL_LIGHT6"/>
+            <enum name="GL_LIGHT7"/>
+            <command name="glArrayElement"/>
+            <command name="glColorPointer"/>
+            <command name="glDisableClientState"/>
+            <command name="glEdgeFlagPointer"/>
+            <command name="glEnableClientState"/>
+            <command name="glIndexPointer"/>
+            <command name="glGetPointerv"/>
+            <command name="glInterleavedArrays"/>
+            <command name="glNormalPointer"/>
+            <command name="glTexCoordPointer"/>
+            <command name="glVertexPointer"/>
+            <command name="glAreTexturesResident"/>
+            <command name="glPrioritizeTextures"/>
+            <command name="glIndexub"/>
+            <command name="glIndexubv"/>
+            <command name="glPopClientAttrib"/>
+            <command name="glPushClientAttrib"/>
+        </remove>
+        <remove profile="core" comment="Compatibility-only GL 1.2 features removed from GL 3.2">
+            <enum name="GL_RESCALE_NORMAL"/>
+            <enum name="GL_LIGHT_MODEL_COLOR_CONTROL"/>
+            <enum name="GL_SINGLE_COLOR"/>
+            <enum name="GL_SEPARATE_SPECULAR_COLOR"/>
+            <enum name="GL_ALIASED_POINT_SIZE_RANGE"/>
+        </remove>
+        <remove profile="core" comment="Compatibility-only GL 1.3 features removed from GL 3.2">
+            <enum name="GL_CLIENT_ACTIVE_TEXTURE"/>
+            <enum name="GL_MAX_TEXTURE_UNITS"/>
+            <enum name="GL_TRANSPOSE_MODELVIEW_MATRIX"/>
+            <enum name="GL_TRANSPOSE_PROJECTION_MATRIX"/>
+            <enum name="GL_TRANSPOSE_TEXTURE_MATRIX"/>
+            <enum name="GL_TRANSPOSE_COLOR_MATRIX"/>
+            <enum name="GL_MULTISAMPLE_BIT"/>
+            <enum name="GL_NORMAL_MAP"/>
+            <enum name="GL_REFLECTION_MAP"/>
+            <enum name="GL_COMPRESSED_ALPHA"/>
+            <enum name="GL_COMPRESSED_LUMINANCE"/>
+            <enum name="GL_COMPRESSED_LUMINANCE_ALPHA"/>
+            <enum name="GL_COMPRESSED_INTENSITY"/>
+            <enum name="GL_COMBINE"/>
+            <enum name="GL_COMBINE_RGB"/>
+            <enum name="GL_COMBINE_ALPHA"/>
+            <enum name="GL_SOURCE0_RGB"/>
+            <enum name="GL_SOURCE1_RGB"/>
+            <enum name="GL_SOURCE2_RGB"/>
+            <enum name="GL_SOURCE0_ALPHA"/>
+            <enum name="GL_SOURCE1_ALPHA"/>
+            <enum name="GL_SOURCE2_ALPHA"/>
+            <enum name="GL_OPERAND0_RGB"/>
+            <enum name="GL_OPERAND1_RGB"/>
+            <enum name="GL_OPERAND2_RGB"/>
+            <enum name="GL_OPERAND0_ALPHA"/>
+            <enum name="GL_OPERAND1_ALPHA"/>
+            <enum name="GL_OPERAND2_ALPHA"/>
+            <enum name="GL_RGB_SCALE"/>
+            <enum name="GL_ADD_SIGNED"/>
+            <enum name="GL_INTERPOLATE"/>
+            <enum name="GL_SUBTRACT"/>
+            <enum name="GL_CONSTANT"/>
+            <enum name="GL_PRIMARY_COLOR"/>
+            <enum name="GL_PREVIOUS"/>
+            <enum name="GL_DOT3_RGB"/>
+            <enum name="GL_DOT3_RGBA"/>
+            <command name="glClientActiveTexture"/>
+            <command name="glMultiTexCoord1d"/>
+            <command name="glMultiTexCoord1dv"/>
+            <command name="glMultiTexCoord1f"/>
+            <command name="glMultiTexCoord1fv"/>
+            <command name="glMultiTexCoord1i"/>
+            <command name="glMultiTexCoord1iv"/>
+            <command name="glMultiTexCoord1s"/>
+            <command name="glMultiTexCoord1sv"/>
+            <command name="glMultiTexCoord2d"/>
+            <command name="glMultiTexCoord2dv"/>
+            <command name="glMultiTexCoord2f"/>
+            <command name="glMultiTexCoord2fv"/>
+            <command name="glMultiTexCoord2i"/>
+            <command name="glMultiTexCoord2iv"/>
+            <command name="glMultiTexCoord2s"/>
+            <command name="glMultiTexCoord2sv"/>
+            <command name="glMultiTexCoord3d"/>
+            <command name="glMultiTexCoord3dv"/>
+            <command name="glMultiTexCoord3f"/>
+            <command name="glMultiTexCoord3fv"/>
+            <command name="glMultiTexCoord3i"/>
+            <command name="glMultiTexCoord3iv"/>
+            <command name="glMultiTexCoord3s"/>
+            <command name="glMultiTexCoord3sv"/>
+            <command name="glMultiTexCoord4d"/>
+            <command name="glMultiTexCoord4dv"/>
+            <command name="glMultiTexCoord4f"/>
+            <command name="glMultiTexCoord4fv"/>
+            <command name="glMultiTexCoord4i"/>
+            <command name="glMultiTexCoord4iv"/>
+            <command name="glMultiTexCoord4s"/>
+            <command name="glMultiTexCoord4sv"/>
+            <command name="glLoadTransposeMatrixf"/>
+            <command name="glLoadTransposeMatrixd"/>
+            <command name="glMultTransposeMatrixf"/>
+            <command name="glMultTransposeMatrixd"/>
+        </remove>
+        <remove profile="core" comment="Compatibility-only GL 1.4 features removed from GL 3.2">
+            <enum name="GL_POINT_SIZE_MIN"/>
+            <enum name="GL_POINT_SIZE_MAX"/>
+            <enum name="GL_POINT_DISTANCE_ATTENUATION"/>
+            <enum name="GL_GENERATE_MIPMAP"/>
+            <enum name="GL_GENERATE_MIPMAP_HINT"/>
+            <enum name="GL_FOG_COORDINATE_SOURCE"/>
+            <enum name="GL_FOG_COORDINATE"/>
+            <enum name="GL_FRAGMENT_DEPTH"/>
+            <enum name="GL_CURRENT_FOG_COORDINATE"/>
+            <enum name="GL_FOG_COORDINATE_ARRAY_TYPE"/>
+            <enum name="GL_FOG_COORDINATE_ARRAY_STRIDE"/>
+            <enum name="GL_FOG_COORDINATE_ARRAY_POINTER"/>
+            <enum name="GL_FOG_COORDINATE_ARRAY"/>
+            <enum name="GL_COLOR_SUM"/>
+            <enum name="GL_CURRENT_SECONDARY_COLOR"/>
+            <enum name="GL_SECONDARY_COLOR_ARRAY_SIZE"/>
+            <enum name="GL_SECONDARY_COLOR_ARRAY_TYPE"/>
+            <enum name="GL_SECONDARY_COLOR_ARRAY_STRIDE"/>
+            <enum name="GL_SECONDARY_COLOR_ARRAY_POINTER"/>
+            <enum name="GL_SECONDARY_COLOR_ARRAY"/>
+            <enum name="GL_TEXTURE_FILTER_CONTROL"/>
+            <enum name="GL_DEPTH_TEXTURE_MODE"/>
+            <enum name="GL_COMPARE_R_TO_TEXTURE"/>
+            <command name="glFogCoordf"/>
+            <command name="glFogCoordfv"/>
+            <command name="glFogCoordd"/>
+            <command name="glFogCoorddv"/>
+            <command name="glFogCoordPointer"/>
+            <command name="glSecondaryColor3b"/>
+            <command name="glSecondaryColor3bv"/>
+            <command name="glSecondaryColor3d"/>
+            <command name="glSecondaryColor3dv"/>
+            <command name="glSecondaryColor3f"/>
+            <command name="glSecondaryColor3fv"/>
+            <command name="glSecondaryColor3i"/>
+            <command name="glSecondaryColor3iv"/>
+            <command name="glSecondaryColor3s"/>
+            <command name="glSecondaryColor3sv"/>
+            <command name="glSecondaryColor3ub"/>
+            <command name="glSecondaryColor3ubv"/>
+            <command name="glSecondaryColor3ui"/>
+            <command name="glSecondaryColor3uiv"/>
+            <command name="glSecondaryColor3us"/>
+            <command name="glSecondaryColor3usv"/>
+            <command name="glSecondaryColorPointer"/>
+            <command name="glWindowPos2d"/>
+            <command name="glWindowPos2dv"/>
+            <command name="glWindowPos2f"/>
+            <command name="glWindowPos2fv"/>
+            <command name="glWindowPos2i"/>
+            <command name="glWindowPos2iv"/>
+            <command name="glWindowPos2s"/>
+            <command name="glWindowPos2sv"/>
+            <command name="glWindowPos3d"/>
+            <command name="glWindowPos3dv"/>
+            <command name="glWindowPos3f"/>
+            <command name="glWindowPos3fv"/>
+            <command name="glWindowPos3i"/>
+            <command name="glWindowPos3iv"/>
+            <command name="glWindowPos3s"/>
+            <command name="glWindowPos3sv"/>
+        </remove>
+        <remove profile="core" comment="Compatibility-only GL 1.5 features removed from GL 3.2">
+            <enum name="GL_VERTEX_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_NORMAL_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_COLOR_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_INDEX_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_EDGE_FLAG_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_WEIGHT_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_FOG_COORD_SRC"/>
+            <enum name="GL_FOG_COORD"/>
+            <enum name="GL_CURRENT_FOG_COORD"/>
+            <enum name="GL_FOG_COORD_ARRAY_TYPE"/>
+            <enum name="GL_FOG_COORD_ARRAY_STRIDE"/>
+            <enum name="GL_FOG_COORD_ARRAY_POINTER"/>
+            <enum name="GL_FOG_COORD_ARRAY"/>
+            <enum name="GL_FOG_COORD_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_SRC0_RGB"/>
+            <enum name="GL_SRC1_RGB"/>
+            <enum name="GL_SRC2_RGB"/>
+            <enum name="GL_SRC0_ALPHA"/>
+            <enum name="GL_SRC2_ALPHA"/>
+        </remove>
+        <remove profile="core" comment="Compatibility-only GL 2.0 features removed from GL 3.2">
+            <enum name="GL_VERTEX_PROGRAM_TWO_SIDE"/>
+            <enum name="GL_POINT_SPRITE"/>
+            <enum name="GL_COORD_REPLACE"/>
+            <enum name="GL_MAX_TEXTURE_COORDS"/>
+        </remove>
+        <remove profile="core" comment="Compatibility-only GL 2.1 features removed from GL 3.2">
+            <enum name="GL_CURRENT_RASTER_SECONDARY_COLOR"/>
+            <enum name="GL_SLUMINANCE_ALPHA"/>
+            <enum name="GL_SLUMINANCE8_ALPHA8"/>
+            <enum name="GL_SLUMINANCE"/>
+            <enum name="GL_SLUMINANCE8"/>
+            <enum name="GL_COMPRESSED_SLUMINANCE"/>
+            <enum name="GL_COMPRESSED_SLUMINANCE_ALPHA"/>
+        </remove>
+        <remove profile="core" comment="Compatibility-only GL 3.0 features removed from GL 3.2">
+            <enum name="GL_CLAMP_VERTEX_COLOR"/>
+            <enum name="GL_CLAMP_FRAGMENT_COLOR"/>
+            <enum name="GL_ALPHA_INTEGER"/>
+            <enum name="GL_TEXTURE_LUMINANCE_TYPE"/>
+            <enum name="GL_TEXTURE_INTENSITY_TYPE"/>
+        </remove>
+        <!-- Deprecated (not removed) in OpenGL 3.2 core;
+             deprecate tag not defined/supported yet
+          <deprecate profile="core">
+            <enum name="GL_MAX_VARYING_FLOATS"/>
+            <enum name="GL_MAX_VARYING_COMPONENTS"/>
+          </deprecate>
+        -->
+    </feature>
+    <feature api="gl" name="GL_VERSION_3_3" number="3.3">
+        <require>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_DIVISOR"/>
+        </require>
+        <require comment="Reuse ARB_blend_func_extended">
+            <enum name="GL_SRC1_COLOR"/>
+            <enum name="GL_ONE_MINUS_SRC1_COLOR"/>
+            <enum name="GL_ONE_MINUS_SRC1_ALPHA"/>
+            <enum name="GL_MAX_DUAL_SOURCE_DRAW_BUFFERS"/>
+            <command name="glBindFragDataLocationIndexed"/>
+            <command name="glGetFragDataIndex"/>
+        </require>
+        <require comment="Reuse ARB_explicit_attrib_location (none)">
+        </require>
+        <require comment="Reuse ARB_occlusion_query2">
+            <enum name="GL_ANY_SAMPLES_PASSED"/>
+        </require>
+        <require comment="Reuse ARB_sampler_objects">
+            <enum name="GL_SAMPLER_BINDING"/>
+            <command name="glGenSamplers"/>
+            <command name="glDeleteSamplers"/>
+            <command name="glIsSampler"/>
+            <command name="glBindSampler"/>
+            <command name="glSamplerParameteri"/>
+            <command name="glSamplerParameteriv"/>
+            <command name="glSamplerParameterf"/>
+            <command name="glSamplerParameterfv"/>
+            <command name="glSamplerParameterIiv"/>
+            <command name="glSamplerParameterIuiv"/>
+            <command name="glGetSamplerParameteriv"/>
+            <command name="glGetSamplerParameterIiv"/>
+            <command name="glGetSamplerParameterfv"/>
+            <command name="glGetSamplerParameterIuiv"/>
+        </require>
+        <require comment="Reuse ARB_shader_bit_encoding (none)">
+        </require>
+        <require comment="Reuse ARB_texture_rgb10_a2ui">
+            <enum name="GL_RGB10_A2UI"/>
+        </require>
+        <require comment="Reuse ARB_texture_swizzle">
+            <enum name="GL_TEXTURE_SWIZZLE_R"/>
+            <enum name="GL_TEXTURE_SWIZZLE_G"/>
+            <enum name="GL_TEXTURE_SWIZZLE_B"/>
+            <enum name="GL_TEXTURE_SWIZZLE_A"/>
+            <enum name="GL_TEXTURE_SWIZZLE_RGBA"/>
+        </require>
+        <require comment="Reuse ARB_timer_query">
+            <enum name="GL_TIME_ELAPSED"/>
+            <enum name="GL_TIMESTAMP"/>
+            <command name="glQueryCounter"/>
+            <command name="glGetQueryObjecti64v"/>
+            <command name="glGetQueryObjectui64v"/>
+        </require>
+        <require comment="Reuse ARB_vertex_type_2_10_10_10_rev">
+            <enum name="GL_INT_2_10_10_10_REV"/>
+            <command name="glVertexAttribDivisor"/>
+            <command name="glVertexAttribP1ui"/>
+            <command name="glVertexAttribP1uiv"/>
+            <command name="glVertexAttribP2ui"/>
+            <command name="glVertexAttribP2uiv"/>
+            <command name="glVertexAttribP3ui"/>
+            <command name="glVertexAttribP3uiv"/>
+            <command name="glVertexAttribP4ui"/>
+            <command name="glVertexAttribP4uiv"/>
+        </require>
+        <require profile="compatibility" comment="Reuse ARB_vertex_type_2_10_10_10_rev compatibility profile">
+            <command name="glVertexP2ui"/>
+            <command name="glVertexP2uiv"/>
+            <command name="glVertexP3ui"/>
+            <command name="glVertexP3uiv"/>
+            <command name="glVertexP4ui"/>
+            <command name="glVertexP4uiv"/>
+            <command name="glTexCoordP1ui"/>
+            <command name="glTexCoordP1uiv"/>
+            <command name="glTexCoordP2ui"/>
+            <command name="glTexCoordP2uiv"/>
+            <command name="glTexCoordP3ui"/>
+            <command name="glTexCoordP3uiv"/>
+            <command name="glTexCoordP4ui"/>
+            <command name="glTexCoordP4uiv"/>
+            <command name="glMultiTexCoordP1ui"/>
+            <command name="glMultiTexCoordP1uiv"/>
+            <command name="glMultiTexCoordP2ui"/>
+            <command name="glMultiTexCoordP2uiv"/>
+            <command name="glMultiTexCoordP3ui"/>
+            <command name="glMultiTexCoordP3uiv"/>
+            <command name="glMultiTexCoordP4ui"/>
+            <command name="glMultiTexCoordP4uiv"/>
+            <command name="glNormalP3ui"/>
+            <command name="glNormalP3uiv"/>
+            <command name="glColorP3ui"/>
+            <command name="glColorP3uiv"/>
+            <command name="glColorP4ui"/>
+            <command name="glColorP4uiv"/>
+            <command name="glSecondaryColorP3ui"/>
+            <command name="glSecondaryColorP3uiv"/>
+        </require>
+    </feature>
+    <feature api="gl" name="GL_VERSION_4_0" number="4.0">
+        <require>
+            <enum name="GL_SAMPLE_SHADING"/>
+            <enum name="GL_MIN_SAMPLE_SHADING_VALUE"/>
+            <enum name="GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET"/>
+            <enum name="GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET"/>
+            <enum name="GL_TEXTURE_CUBE_MAP_ARRAY"/>
+            <enum name="GL_TEXTURE_BINDING_CUBE_MAP_ARRAY"/>
+            <enum name="GL_PROXY_TEXTURE_CUBE_MAP_ARRAY"/>
+            <enum name="GL_SAMPLER_CUBE_MAP_ARRAY"/>
+            <enum name="GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW"/>
+            <enum name="GL_INT_SAMPLER_CUBE_MAP_ARRAY"/>
+            <enum name="GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY"/>
+            <command name="glMinSampleShading"/>
+            <command name="glBlendEquationi"/>
+            <command name="glBlendEquationSeparatei"/>
+            <command name="glBlendFunci"/>
+            <command name="glBlendFuncSeparatei"/>
+        </require>
+        <require comment="Reuse ARB_draw_buffers_blend (none)">
+        </require>
+        <require comment="Reuse ARB_draw_indirect">
+            <enum name="GL_DRAW_INDIRECT_BUFFER"/>
+            <enum name="GL_DRAW_INDIRECT_BUFFER_BINDING"/>
+            <command name="glDrawArraysIndirect"/>
+            <command name="glDrawElementsIndirect"/>
+        </require>
+        <require comment="Reuse ARB_gpu_shader5">
+            <enum name="GL_GEOMETRY_SHADER_INVOCATIONS"/>
+            <enum name="GL_MAX_GEOMETRY_SHADER_INVOCATIONS"/>
+            <enum name="GL_MIN_FRAGMENT_INTERPOLATION_OFFSET"/>
+            <enum name="GL_MAX_FRAGMENT_INTERPOLATION_OFFSET"/>
+            <enum name="GL_FRAGMENT_INTERPOLATION_OFFSET_BITS"/>
+            <enum name="GL_MAX_VERTEX_STREAMS"/>
+        </require>
+        <require comment="Reuse ARB_gpu_shader_fp64">
+            <enum name="GL_DOUBLE_VEC2"/>
+            <enum name="GL_DOUBLE_VEC3"/>
+            <enum name="GL_DOUBLE_VEC4"/>
+            <enum name="GL_DOUBLE_MAT2"/>
+            <enum name="GL_DOUBLE_MAT3"/>
+            <enum name="GL_DOUBLE_MAT4"/>
+            <enum name="GL_DOUBLE_MAT2x3"/>
+            <enum name="GL_DOUBLE_MAT2x4"/>
+            <enum name="GL_DOUBLE_MAT3x2"/>
+            <enum name="GL_DOUBLE_MAT3x4"/>
+            <enum name="GL_DOUBLE_MAT4x2"/>
+            <enum name="GL_DOUBLE_MAT4x3"/>
+            <command name="glUniform1d"/>
+            <command name="glUniform2d"/>
+            <command name="glUniform3d"/>
+            <command name="glUniform4d"/>
+            <command name="glUniform1dv"/>
+            <command name="glUniform2dv"/>
+            <command name="glUniform3dv"/>
+            <command name="glUniform4dv"/>
+            <command name="glUniformMatrix2dv"/>
+            <command name="glUniformMatrix3dv"/>
+            <command name="glUniformMatrix4dv"/>
+            <command name="glUniformMatrix2x3dv"/>
+            <command name="glUniformMatrix2x4dv"/>
+            <command name="glUniformMatrix3x2dv"/>
+            <command name="glUniformMatrix3x4dv"/>
+            <command name="glUniformMatrix4x2dv"/>
+            <command name="glUniformMatrix4x3dv"/>
+            <command name="glGetUniformdv"/>
+        </require>
+        <require comment="Reuse ARB_shader_subroutine">
+            <enum name="GL_ACTIVE_SUBROUTINES"/>
+            <enum name="GL_ACTIVE_SUBROUTINE_UNIFORMS"/>
+            <enum name="GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS"/>
+            <enum name="GL_ACTIVE_SUBROUTINE_MAX_LENGTH"/>
+            <enum name="GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH"/>
+            <enum name="GL_MAX_SUBROUTINES"/>
+            <enum name="GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS"/>
+            <enum name="GL_NUM_COMPATIBLE_SUBROUTINES"/>
+            <enum name="GL_COMPATIBLE_SUBROUTINES"/>
+            <command name="glGetSubroutineUniformLocation"/>
+            <command name="glGetSubroutineIndex"/>
+            <command name="glGetActiveSubroutineUniformiv"/>
+            <command name="glGetActiveSubroutineUniformName"/>
+            <command name="glGetActiveSubroutineName"/>
+            <command name="glUniformSubroutinesuiv"/>
+            <command name="glGetUniformSubroutineuiv"/>
+            <command name="glGetProgramStageiv"/>
+        </require>
+        <require comment="Reuse ARB_tessellation_shader">
+            <enum name="GL_PATCHES"/>
+            <enum name="GL_PATCH_VERTICES"/>
+            <enum name="GL_PATCH_DEFAULT_INNER_LEVEL"/>
+            <enum name="GL_PATCH_DEFAULT_OUTER_LEVEL"/>
+            <enum name="GL_TESS_CONTROL_OUTPUT_VERTICES"/>
+            <enum name="GL_TESS_GEN_MODE"/>
+            <enum name="GL_TESS_GEN_SPACING"/>
+            <enum name="GL_TESS_GEN_VERTEX_ORDER"/>
+            <enum name="GL_TESS_GEN_POINT_MODE"/>
+            <enum name="GL_ISOLINES"/>
+            <enum name="GL_QUADS"/>
+            <enum name="GL_FRACTIONAL_ODD"/>
+            <enum name="GL_FRACTIONAL_EVEN"/>
+            <enum name="GL_MAX_PATCH_VERTICES"/>
+            <enum name="GL_MAX_TESS_GEN_LEVEL"/>
+            <enum name="GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS"/>
+            <enum name="GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS"/>
+            <enum name="GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS"/>
+            <enum name="GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS"/>
+            <enum name="GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS"/>
+            <enum name="GL_MAX_TESS_PATCH_COMPONENTS"/>
+            <enum name="GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS"/>
+            <enum name="GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS"/>
+            <enum name="GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS"/>
+            <enum name="GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS"/>
+            <enum name="GL_MAX_TESS_CONTROL_INPUT_COMPONENTS"/>
+            <enum name="GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS"/>
+            <enum name="GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS"/>
+            <enum name="GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS"/>
+            <enum name="GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER"/>
+            <enum name="GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER"/>
+            <enum name="GL_TESS_EVALUATION_SHADER"/>
+            <enum name="GL_TESS_CONTROL_SHADER"/>
+            <command name="glPatchParameteri"/>
+            <command name="glPatchParameterfv"/>
+        </require>
+        <require comment="Reuse ARB_texture_buffer_object_rgb32 (none)">
+        </require>
+        <require comment="Reuse ARB_texture_cube_map_array (none)">
+        </require>
+        <require comment="Reuse ARB_texture_gather (none)">
+        </require>
+        <require comment="Reuse ARB_texture_query_lod (none)">
+        </require>
+        <require comment="Reuse ARB_transform_feedback2">
+            <enum name="GL_TRANSFORM_FEEDBACK"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BINDING"/>
+            <command name="glBindTransformFeedback"/>
+            <command name="glDeleteTransformFeedbacks"/>
+            <command name="glGenTransformFeedbacks"/>
+            <command name="glIsTransformFeedback"/>
+            <command name="glPauseTransformFeedback"/>
+            <command name="glResumeTransformFeedback"/>
+            <command name="glDrawTransformFeedback"/>
+        </require>
+        <require comment="Reuse ARB_transform_feedback3">
+            <enum name="GL_MAX_TRANSFORM_FEEDBACK_BUFFERS"/>
+            <enum name="GL_MAX_VERTEX_STREAMS"/>
+            <command name="glDrawTransformFeedbackStream"/>
+            <command name="glBeginQueryIndexed"/>
+            <command name="glEndQueryIndexed"/>
+            <command name="glGetQueryIndexediv"/>
+        </require>
+    </feature>
+    <feature api="gl" name="GL_VERSION_4_1" number="4.1">
+        <require comment="Reuse tokens from ARB_ES2_compatibility">
+            <enum name="GL_FIXED"/>
+            <enum name="GL_IMPLEMENTATION_COLOR_READ_TYPE"/>
+            <enum name="GL_IMPLEMENTATION_COLOR_READ_FORMAT"/>
+            <enum name="GL_LOW_FLOAT"/>
+            <enum name="GL_MEDIUM_FLOAT"/>
+            <enum name="GL_HIGH_FLOAT"/>
+            <enum name="GL_LOW_INT"/>
+            <enum name="GL_MEDIUM_INT"/>
+            <enum name="GL_HIGH_INT"/>
+            <enum name="GL_SHADER_COMPILER"/>
+            <enum name="GL_SHADER_BINARY_FORMATS"/>
+            <enum name="GL_NUM_SHADER_BINARY_FORMATS"/>
+            <enum name="GL_MAX_VERTEX_UNIFORM_VECTORS"/>
+            <enum name="GL_MAX_VARYING_VECTORS"/>
+            <enum name="GL_MAX_FRAGMENT_UNIFORM_VECTORS"/>
+            <enum name="GL_RGB565"/>
+        </require>
+        <require comment="Reuse tokens from ARB_get_program_binary">
+            <enum name="GL_PROGRAM_BINARY_RETRIEVABLE_HINT"/>
+            <enum name="GL_PROGRAM_BINARY_LENGTH"/>
+            <enum name="GL_NUM_PROGRAM_BINARY_FORMATS"/>
+            <enum name="GL_PROGRAM_BINARY_FORMATS"/>
+        </require>
+        <require comment="Reuse tokens from ARB_separate_shader_objects">
+            <enum name="GL_VERTEX_SHADER_BIT"/>
+            <enum name="GL_FRAGMENT_SHADER_BIT"/>
+            <enum name="GL_GEOMETRY_SHADER_BIT"/>
+            <enum name="GL_TESS_CONTROL_SHADER_BIT"/>
+            <enum name="GL_TESS_EVALUATION_SHADER_BIT"/>
+            <enum name="GL_ALL_SHADER_BITS"/>
+            <enum name="GL_PROGRAM_SEPARABLE"/>
+            <enum name="GL_ACTIVE_PROGRAM"/>
+            <enum name="GL_PROGRAM_PIPELINE_BINDING"/>
+        </require>
+        <require comment="Reuse tokens from ARB_shader_precision (none)">
+        </require>
+        <require comment="Reuse tokens from ARB_vertex_attrib_64bit - all are in GL 3.0 and 4.0 already">
+        </require>
+        <require comment="Reuse tokens from ARB_viewport_array - some are in GL 1.1 and ARB_provoking_vertex already">
+            <enum name="GL_MAX_VIEWPORTS"/>
+            <enum name="GL_VIEWPORT_SUBPIXEL_BITS"/>
+            <enum name="GL_VIEWPORT_BOUNDS_RANGE"/>
+            <enum name="GL_LAYER_PROVOKING_VERTEX"/>
+            <enum name="GL_VIEWPORT_INDEX_PROVOKING_VERTEX"/>
+            <enum name="GL_UNDEFINED_VERTEX"/>
+        </require>
+        <require comment="Reuse commands from ARB_ES2_compatibility">
+            <command name="glReleaseShaderCompiler"/>
+            <command name="glShaderBinary"/>
+            <command name="glGetShaderPrecisionFormat"/>
+            <command name="glDepthRangef"/>
+            <command name="glClearDepthf"/>
+        </require>
+        <require comment="Reuse commands from ARB_get_program_binary">
+            <command name="glGetProgramBinary"/>
+            <command name="glProgramBinary"/>
+            <command name="glProgramParameteri"/>
+        </require>
+        <require comment="Reuse commands from ARB_separate_shader_objects">
+            <command name="glUseProgramStages"/>
+            <command name="glActiveShaderProgram"/>
+            <command name="glCreateShaderProgramv"/>
+            <command name="glBindProgramPipeline"/>
+            <command name="glDeleteProgramPipelines"/>
+            <command name="glGenProgramPipelines"/>
+            <command name="glIsProgramPipeline"/>
+            <command name="glGetProgramPipelineiv"/>
+            <command name="glProgramUniform1i"/>
+            <command name="glProgramUniform1iv"/>
+            <command name="glProgramUniform1f"/>
+            <command name="glProgramUniform1fv"/>
+            <command name="glProgramUniform1d"/>
+            <command name="glProgramUniform1dv"/>
+            <command name="glProgramUniform1ui"/>
+            <command name="glProgramUniform1uiv"/>
+            <command name="glProgramUniform2i"/>
+            <command name="glProgramUniform2iv"/>
+            <command name="glProgramUniform2f"/>
+            <command name="glProgramUniform2fv"/>
+            <command name="glProgramUniform2d"/>
+            <command name="glProgramUniform2dv"/>
+            <command name="glProgramUniform2ui"/>
+            <command name="glProgramUniform2uiv"/>
+            <command name="glProgramUniform3i"/>
+            <command name="glProgramUniform3iv"/>
+            <command name="glProgramUniform3f"/>
+            <command name="glProgramUniform3fv"/>
+            <command name="glProgramUniform3d"/>
+            <command name="glProgramUniform3dv"/>
+            <command name="glProgramUniform3ui"/>
+            <command name="glProgramUniform3uiv"/>
+            <command name="glProgramUniform4i"/>
+            <command name="glProgramUniform4iv"/>
+            <command name="glProgramUniform4f"/>
+            <command name="glProgramUniform4fv"/>
+            <command name="glProgramUniform4d"/>
+            <command name="glProgramUniform4dv"/>
+            <command name="glProgramUniform4ui"/>
+            <command name="glProgramUniform4uiv"/>
+            <command name="glProgramUniformMatrix2fv"/>
+            <command name="glProgramUniformMatrix3fv"/>
+            <command name="glProgramUniformMatrix4fv"/>
+            <command name="glProgramUniformMatrix2dv"/>
+            <command name="glProgramUniformMatrix3dv"/>
+            <command name="glProgramUniformMatrix4dv"/>
+            <command name="glProgramUniformMatrix2x3fv"/>
+            <command name="glProgramUniformMatrix3x2fv"/>
+            <command name="glProgramUniformMatrix2x4fv"/>
+            <command name="glProgramUniformMatrix4x2fv"/>
+            <command name="glProgramUniformMatrix3x4fv"/>
+            <command name="glProgramUniformMatrix4x3fv"/>
+            <command name="glProgramUniformMatrix2x3dv"/>
+            <command name="glProgramUniformMatrix3x2dv"/>
+            <command name="glProgramUniformMatrix2x4dv"/>
+            <command name="glProgramUniformMatrix4x2dv"/>
+            <command name="glProgramUniformMatrix3x4dv"/>
+            <command name="glProgramUniformMatrix4x3dv"/>
+            <command name="glValidateProgramPipeline"/>
+            <command name="glGetProgramPipelineInfoLog"/>
+        </require>
+        <require comment="Reuse commands from ARB_shader_precision (none)">
+        </require>
+        <require comment="Reuse commands from ARB_vertex_attrib_64bit">
+            <command name="glVertexAttribL1d"/>
+            <command name="glVertexAttribL2d"/>
+            <command name="glVertexAttribL3d"/>
+            <command name="glVertexAttribL4d"/>
+            <command name="glVertexAttribL1dv"/>
+            <command name="glVertexAttribL2dv"/>
+            <command name="glVertexAttribL3dv"/>
+            <command name="glVertexAttribL4dv"/>
+            <command name="glVertexAttribLPointer"/>
+            <command name="glGetVertexAttribLdv"/>
+        </require>
+        <require comment="Reuse commands from ARB_viewport_array">
+            <command name="glViewportArrayv"/>
+            <command name="glViewportIndexedf"/>
+            <command name="glViewportIndexedfv"/>
+            <command name="glScissorArrayv"/>
+            <command name="glScissorIndexed"/>
+            <command name="glScissorIndexedv"/>
+            <command name="glDepthRangeArrayv"/>
+            <command name="glDepthRangeIndexed"/>
+            <command name="glGetFloati_v"/>
+            <command name="glGetDoublei_v"/>
+        </require>
+    </feature>
+    <feature api="gl" name="GL_VERSION_4_2" number="4.2">
+        <require comment="Reuse tokens from ARB_base_instance (none)">
+        </require>
+        <require comment="Reuse tokens from ARB_shading_language_420pack (none)">
+        </require>
+        <require comment="Reuse tokens from ARB_transform_feedback_instanced (none)">
+        </require>
+        <require comment="Reuse tokens from ARB_compressed_texture_pixel_storage">
+            <enum name="GL_UNPACK_COMPRESSED_BLOCK_WIDTH"/>
+            <enum name="GL_UNPACK_COMPRESSED_BLOCK_HEIGHT"/>
+            <enum name="GL_UNPACK_COMPRESSED_BLOCK_DEPTH"/>
+            <enum name="GL_UNPACK_COMPRESSED_BLOCK_SIZE"/>
+            <enum name="GL_PACK_COMPRESSED_BLOCK_WIDTH"/>
+            <enum name="GL_PACK_COMPRESSED_BLOCK_HEIGHT"/>
+            <enum name="GL_PACK_COMPRESSED_BLOCK_DEPTH"/>
+            <enum name="GL_PACK_COMPRESSED_BLOCK_SIZE"/>
+        </require>
+        <require comment="Reuse tokens from ARB_conservative_depth (none)">
+        </require>
+        <require comment="Reuse tokens from ARB_internalformat_query">
+            <enum name="GL_NUM_SAMPLE_COUNTS"/>
+        </require>
+        <require comment="Reuse tokens from ARB_map_buffer_alignment">
+            <enum name="GL_MIN_MAP_BUFFER_ALIGNMENT"/>
+        </require>
+        <require comment="Reuse tokens from ARB_shader_atomic_counters">
+            <enum name="GL_ATOMIC_COUNTER_BUFFER"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_BINDING"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_START"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_SIZE"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER"/>
+            <enum name="GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS"/>
+            <enum name="GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS"/>
+            <enum name="GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS"/>
+            <enum name="GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS"/>
+            <enum name="GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS"/>
+            <enum name="GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS"/>
+            <enum name="GL_MAX_VERTEX_ATOMIC_COUNTERS"/>
+            <enum name="GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS"/>
+            <enum name="GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS"/>
+            <enum name="GL_MAX_GEOMETRY_ATOMIC_COUNTERS"/>
+            <enum name="GL_MAX_FRAGMENT_ATOMIC_COUNTERS"/>
+            <enum name="GL_MAX_COMBINED_ATOMIC_COUNTERS"/>
+            <enum name="GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE"/>
+            <enum name="GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS"/>
+            <enum name="GL_ACTIVE_ATOMIC_COUNTER_BUFFERS"/>
+            <enum name="GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX"/>
+            <enum name="GL_UNSIGNED_INT_ATOMIC_COUNTER"/>
+        </require>
+        <require comment="Reuse tokens from ARB_shader_image_load_store">
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT"/>
+            <enum name="GL_ELEMENT_ARRAY_BARRIER_BIT"/>
+            <enum name="GL_UNIFORM_BARRIER_BIT"/>
+            <enum name="GL_TEXTURE_FETCH_BARRIER_BIT"/>
+            <enum name="GL_SHADER_IMAGE_ACCESS_BARRIER_BIT"/>
+            <enum name="GL_COMMAND_BARRIER_BIT"/>
+            <enum name="GL_PIXEL_BUFFER_BARRIER_BIT"/>
+            <enum name="GL_TEXTURE_UPDATE_BARRIER_BIT"/>
+            <enum name="GL_BUFFER_UPDATE_BARRIER_BIT"/>
+            <enum name="GL_FRAMEBUFFER_BARRIER_BIT"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BARRIER_BIT"/>
+            <enum name="GL_ATOMIC_COUNTER_BARRIER_BIT"/>
+            <enum name="GL_ALL_BARRIER_BITS"/>
+            <enum name="GL_MAX_IMAGE_UNITS"/>
+            <enum name="GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS"/>
+            <enum name="GL_IMAGE_BINDING_NAME"/>
+            <enum name="GL_IMAGE_BINDING_LEVEL"/>
+            <enum name="GL_IMAGE_BINDING_LAYERED"/>
+            <enum name="GL_IMAGE_BINDING_LAYER"/>
+            <enum name="GL_IMAGE_BINDING_ACCESS"/>
+            <enum name="GL_IMAGE_1D"/>
+            <enum name="GL_IMAGE_2D"/>
+            <enum name="GL_IMAGE_3D"/>
+            <enum name="GL_IMAGE_2D_RECT"/>
+            <enum name="GL_IMAGE_CUBE"/>
+            <enum name="GL_IMAGE_BUFFER"/>
+            <enum name="GL_IMAGE_1D_ARRAY"/>
+            <enum name="GL_IMAGE_2D_ARRAY"/>
+            <enum name="GL_IMAGE_CUBE_MAP_ARRAY"/>
+            <enum name="GL_IMAGE_2D_MULTISAMPLE"/>
+            <enum name="GL_IMAGE_2D_MULTISAMPLE_ARRAY"/>
+            <enum name="GL_INT_IMAGE_1D"/>
+            <enum name="GL_INT_IMAGE_2D"/>
+            <enum name="GL_INT_IMAGE_3D"/>
+            <enum name="GL_INT_IMAGE_2D_RECT"/>
+            <enum name="GL_INT_IMAGE_CUBE"/>
+            <enum name="GL_INT_IMAGE_BUFFER"/>
+            <enum name="GL_INT_IMAGE_1D_ARRAY"/>
+            <enum name="GL_INT_IMAGE_2D_ARRAY"/>
+            <enum name="GL_INT_IMAGE_CUBE_MAP_ARRAY"/>
+            <enum name="GL_INT_IMAGE_2D_MULTISAMPLE"/>
+            <enum name="GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY"/>
+            <enum name="GL_UNSIGNED_INT_IMAGE_1D"/>
+            <enum name="GL_UNSIGNED_INT_IMAGE_2D"/>
+            <enum name="GL_UNSIGNED_INT_IMAGE_3D"/>
+            <enum name="GL_UNSIGNED_INT_IMAGE_2D_RECT"/>
+            <enum name="GL_UNSIGNED_INT_IMAGE_CUBE"/>
+            <enum name="GL_UNSIGNED_INT_IMAGE_BUFFER"/>
+            <enum name="GL_UNSIGNED_INT_IMAGE_1D_ARRAY"/>
+            <enum name="GL_UNSIGNED_INT_IMAGE_2D_ARRAY"/>
+            <enum name="GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY"/>
+            <enum name="GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE"/>
+            <enum name="GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY"/>
+            <enum name="GL_MAX_IMAGE_SAMPLES"/>
+            <enum name="GL_IMAGE_BINDING_FORMAT"/>
+            <enum name="GL_IMAGE_FORMAT_COMPATIBILITY_TYPE"/>
+            <enum name="GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE"/>
+            <enum name="GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS"/>
+            <enum name="GL_MAX_VERTEX_IMAGE_UNIFORMS"/>
+            <enum name="GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS"/>
+            <enum name="GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS"/>
+            <enum name="GL_MAX_GEOMETRY_IMAGE_UNIFORMS"/>
+            <enum name="GL_MAX_FRAGMENT_IMAGE_UNIFORMS"/>
+            <enum name="GL_MAX_COMBINED_IMAGE_UNIFORMS"/>
+        </require>
+        <require comment="Reuse tokens from ARB_shading_language_packing (none)">
+        </require>
+        <require comment="Reuse tokens from ARB_texture_compression_bptc">
+            <enum name="GL_COMPRESSED_RGBA_BPTC_UNORM"/>
+            <enum name="GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM"/>
+            <enum name="GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT"/>
+            <enum name="GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT"/>
+        </require>
+        <require comment="Reuse tokens from ARB_texture_storage">
+            <enum name="GL_TEXTURE_IMMUTABLE_FORMAT"/>
+        </require>
+        <require comment="Reuse commands from ARB_base_instance">
+            <command name="glDrawArraysInstancedBaseInstance"/>
+            <command name="glDrawElementsInstancedBaseInstance"/>
+            <command name="glDrawElementsInstancedBaseVertexBaseInstance"/>
+        </require>
+        <require comment="Reuse commands from ARB_compressed_texture_pixel_storage (none)">
+        </require>
+        <require comment="Reuse commands from ARB_conservative_depth (none)">
+        </require>
+        <require comment="Reuse commands from ARB_internalformat_query">
+            <command name="glGetInternalformativ"/>
+        </require>
+        <require comment="Reuse commands from ARB_map_buffer_alignment (none)">
+        </require>
+        <require comment="Reuse commands from ARB_shader_atomic_counters">
+            <command name="glGetActiveAtomicCounterBufferiv"/>
+        </require>
+        <require comment="Reuse commands from ARB_shader_image_load_store">
+            <command name="glBindImageTexture"/>
+            <command name="glMemoryBarrier"/>
+        </require>
+        <require comment="Reuse commands from ARB_shading_language_420pack (none)">
+        </require>
+        <require comment="Reuse commands from ARB_shading_language_packing (none)">
+        </require>
+        <require comment="Reuse commands from ARB_texture_storage">
+            <command name="glTexStorage1D"/>
+            <command name="glTexStorage2D"/>
+            <command name="glTexStorage3D"/>
+        </require>
+        <require comment="Reuse commands from ARB_transform_feedback_instanced">
+            <command name="glDrawTransformFeedbackInstanced"/>
+            <command name="glDrawTransformFeedbackStreamInstanced"/>
+        </require>
+        <!-- Deprecated in OpenGL 4.2 core;
+             deprecate tag not defined/supported yet
+          <deprecate profile="core">
+            <enum name="GL_NUM_COMPRESSED_TEXTURE_FORMATS"/>
+            <enum name="GL_COMPRESSED_TEXTURE_FORMATS"/>
+          </deprecate>
+        -->
+    </feature>
+    <feature api="gl" name="GL_VERSION_4_3" number="4.3">
+        <require>
+            <enum name="GL_NUM_SHADING_LANGUAGE_VERSIONS"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_LONG"/>
+        </require>
+        <require comment="Reuse tokens from ARB_arrays_of_arrays (none, GLSL only)">
+        </require>
+        <require comment="Reuse tokens from ARB_fragment_layer_viewport (none, GLSL only)">
+        </require>
+        <require comment="Reuse tokens from ARB_shader_image_size (none, GLSL only)">
+        </require>
+        <require comment="Reuse tokens from ARB_ES3_compatibility">
+            <enum name="GL_COMPRESSED_RGB8_ETC2"/>
+            <enum name="GL_COMPRESSED_SRGB8_ETC2"/>
+            <enum name="GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2"/>
+            <enum name="GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2"/>
+            <enum name="GL_COMPRESSED_RGBA8_ETC2_EAC"/>
+            <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"/>
+            <enum name="GL_COMPRESSED_R11_EAC"/>
+            <enum name="GL_COMPRESSED_SIGNED_R11_EAC"/>
+            <enum name="GL_COMPRESSED_RG11_EAC"/>
+            <enum name="GL_COMPRESSED_SIGNED_RG11_EAC"/>
+            <enum name="GL_PRIMITIVE_RESTART_FIXED_INDEX"/>
+            <enum name="GL_ANY_SAMPLES_PASSED_CONSERVATIVE"/>
+            <enum name="GL_MAX_ELEMENT_INDEX"/>
+        </require>
+        <require comment="Reuse tokens from ARB_clear_buffer_object (none)">
+        </require>
+        <require comment="Reuse tokens from ARB_compute_shader">
+            <enum name="GL_COMPUTE_SHADER"/>
+            <enum name="GL_MAX_COMPUTE_UNIFORM_BLOCKS"/>
+            <enum name="GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS"/>
+            <enum name="GL_MAX_COMPUTE_IMAGE_UNIFORMS"/>
+            <enum name="GL_MAX_COMPUTE_SHARED_MEMORY_SIZE"/>
+            <enum name="GL_MAX_COMPUTE_UNIFORM_COMPONENTS"/>
+            <enum name="GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS"/>
+            <enum name="GL_MAX_COMPUTE_ATOMIC_COUNTERS"/>
+            <enum name="GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS"/>
+            <enum name="GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS"/>
+            <enum name="GL_MAX_COMPUTE_WORK_GROUP_COUNT"/>
+            <enum name="GL_MAX_COMPUTE_WORK_GROUP_SIZE"/>
+            <enum name="GL_COMPUTE_WORK_GROUP_SIZE"/>
+            <enum name="GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER"/>
+            <enum name="GL_DISPATCH_INDIRECT_BUFFER"/>
+            <enum name="GL_DISPATCH_INDIRECT_BUFFER_BINDING"/>
+        </require>
+        <require comment="Reuse tokens from ARB_copy_image (none)">
+        </require>
+        <require comment="Reuse tokens from KHR_debug">
+            <enum name="GL_DEBUG_OUTPUT_SYNCHRONOUS"/>
+            <enum name="GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH"/>
+            <enum name="GL_DEBUG_CALLBACK_FUNCTION"/>
+            <enum name="GL_DEBUG_CALLBACK_USER_PARAM"/>
+            <enum name="GL_DEBUG_SOURCE_API"/>
+            <enum name="GL_DEBUG_SOURCE_WINDOW_SYSTEM"/>
+            <enum name="GL_DEBUG_SOURCE_SHADER_COMPILER"/>
+            <enum name="GL_DEBUG_SOURCE_THIRD_PARTY"/>
+            <enum name="GL_DEBUG_SOURCE_APPLICATION"/>
+            <enum name="GL_DEBUG_SOURCE_OTHER"/>
+            <enum name="GL_DEBUG_TYPE_ERROR"/>
+            <enum name="GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR"/>
+            <enum name="GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR"/>
+            <enum name="GL_DEBUG_TYPE_PORTABILITY"/>
+            <enum name="GL_DEBUG_TYPE_PERFORMANCE"/>
+            <enum name="GL_DEBUG_TYPE_OTHER"/>
+            <enum name="GL_MAX_DEBUG_MESSAGE_LENGTH"/>
+            <enum name="GL_MAX_DEBUG_LOGGED_MESSAGES"/>
+            <enum name="GL_DEBUG_LOGGED_MESSAGES"/>
+            <enum name="GL_DEBUG_SEVERITY_HIGH"/>
+            <enum name="GL_DEBUG_SEVERITY_MEDIUM"/>
+            <enum name="GL_DEBUG_SEVERITY_LOW"/>
+            <enum name="GL_DEBUG_TYPE_MARKER"/>
+            <enum name="GL_DEBUG_TYPE_PUSH_GROUP"/>
+            <enum name="GL_DEBUG_TYPE_POP_GROUP"/>
+            <enum name="GL_DEBUG_SEVERITY_NOTIFICATION"/>
+            <enum name="GL_MAX_DEBUG_GROUP_STACK_DEPTH"/>
+            <enum name="GL_DEBUG_GROUP_STACK_DEPTH"/>
+            <enum name="GL_BUFFER"/>
+            <enum name="GL_SHADER"/>
+            <enum name="GL_PROGRAM"/>
+            <enum name="GL_VERTEX_ARRAY"/>
+            <enum name="GL_QUERY"/>
+            <enum name="GL_PROGRAM_PIPELINE"/>
+            <enum name="GL_SAMPLER"/>
+            <enum name="GL_MAX_LABEL_LENGTH"/>
+            <enum name="GL_DEBUG_OUTPUT"/>
+            <enum name="GL_CONTEXT_FLAG_DEBUG_BIT"/>
+        </require>
+        <require comment="Reuse tokens from ARB_explicit_uniform_location">
+            <enum name="GL_MAX_UNIFORM_LOCATIONS"/>
+        </require>
+        <require comment="Reuse tokens from ARB_framebuffer_no_attachments">
+            <enum name="GL_FRAMEBUFFER_DEFAULT_WIDTH"/>
+            <enum name="GL_FRAMEBUFFER_DEFAULT_HEIGHT"/>
+            <enum name="GL_FRAMEBUFFER_DEFAULT_LAYERS"/>
+            <enum name="GL_FRAMEBUFFER_DEFAULT_SAMPLES"/>
+            <enum name="GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS"/>
+            <enum name="GL_MAX_FRAMEBUFFER_WIDTH"/>
+            <enum name="GL_MAX_FRAMEBUFFER_HEIGHT"/>
+            <enum name="GL_MAX_FRAMEBUFFER_LAYERS"/>
+            <enum name="GL_MAX_FRAMEBUFFER_SAMPLES"/>
+        </require>
+        <require comment="Reuse tokens from ARB_internalformat_query2">
+            <enum name="GL_INTERNALFORMAT_SUPPORTED"/>
+            <enum name="GL_INTERNALFORMAT_PREFERRED"/>
+            <enum name="GL_INTERNALFORMAT_RED_SIZE"/>
+            <enum name="GL_INTERNALFORMAT_GREEN_SIZE"/>
+            <enum name="GL_INTERNALFORMAT_BLUE_SIZE"/>
+            <enum name="GL_INTERNALFORMAT_ALPHA_SIZE"/>
+            <enum name="GL_INTERNALFORMAT_DEPTH_SIZE"/>
+            <enum name="GL_INTERNALFORMAT_STENCIL_SIZE"/>
+            <enum name="GL_INTERNALFORMAT_SHARED_SIZE"/>
+            <enum name="GL_INTERNALFORMAT_RED_TYPE"/>
+            <enum name="GL_INTERNALFORMAT_GREEN_TYPE"/>
+            <enum name="GL_INTERNALFORMAT_BLUE_TYPE"/>
+            <enum name="GL_INTERNALFORMAT_ALPHA_TYPE"/>
+            <enum name="GL_INTERNALFORMAT_DEPTH_TYPE"/>
+            <enum name="GL_INTERNALFORMAT_STENCIL_TYPE"/>
+            <enum name="GL_MAX_WIDTH"/>
+            <enum name="GL_MAX_HEIGHT"/>
+            <enum name="GL_MAX_DEPTH"/>
+            <enum name="GL_MAX_LAYERS"/>
+            <enum name="GL_MAX_COMBINED_DIMENSIONS"/>
+            <enum name="GL_COLOR_COMPONENTS"/>
+            <enum name="GL_DEPTH_COMPONENTS"/>
+            <enum name="GL_STENCIL_COMPONENTS"/>
+            <enum name="GL_COLOR_RENDERABLE"/>
+            <enum name="GL_DEPTH_RENDERABLE"/>
+            <enum name="GL_STENCIL_RENDERABLE"/>
+            <enum name="GL_FRAMEBUFFER_RENDERABLE"/>
+            <enum name="GL_FRAMEBUFFER_RENDERABLE_LAYERED"/>
+            <enum name="GL_FRAMEBUFFER_BLEND"/>
+            <enum name="GL_READ_PIXELS"/>
+            <enum name="GL_READ_PIXELS_FORMAT"/>
+            <enum name="GL_READ_PIXELS_TYPE"/>
+            <enum name="GL_TEXTURE_IMAGE_FORMAT"/>
+            <enum name="GL_TEXTURE_IMAGE_TYPE"/>
+            <enum name="GL_GET_TEXTURE_IMAGE_FORMAT"/>
+            <enum name="GL_GET_TEXTURE_IMAGE_TYPE"/>
+            <enum name="GL_MIPMAP"/>
+            <enum name="GL_MANUAL_GENERATE_MIPMAP"/>
+            <enum name="GL_AUTO_GENERATE_MIPMAP"/>
+            <enum name="GL_COLOR_ENCODING"/>
+            <enum name="GL_SRGB_READ"/>
+            <enum name="GL_SRGB_WRITE"/>
+            <enum name="GL_FILTER"/>
+            <enum name="GL_VERTEX_TEXTURE"/>
+            <enum name="GL_TESS_CONTROL_TEXTURE"/>
+            <enum name="GL_TESS_EVALUATION_TEXTURE"/>
+            <enum name="GL_GEOMETRY_TEXTURE"/>
+            <enum name="GL_FRAGMENT_TEXTURE"/>
+            <enum name="GL_COMPUTE_TEXTURE"/>
+            <enum name="GL_TEXTURE_SHADOW"/>
+            <enum name="GL_TEXTURE_GATHER"/>
+            <enum name="GL_TEXTURE_GATHER_SHADOW"/>
+            <enum name="GL_SHADER_IMAGE_LOAD"/>
+            <enum name="GL_SHADER_IMAGE_STORE"/>
+            <enum name="GL_SHADER_IMAGE_ATOMIC"/>
+            <enum name="GL_IMAGE_TEXEL_SIZE"/>
+            <enum name="GL_IMAGE_COMPATIBILITY_CLASS"/>
+            <enum name="GL_IMAGE_PIXEL_FORMAT"/>
+            <enum name="GL_IMAGE_PIXEL_TYPE"/>
+            <enum name="GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST"/>
+            <enum name="GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST"/>
+            <enum name="GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE"/>
+            <enum name="GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE"/>
+            <enum name="GL_TEXTURE_COMPRESSED_BLOCK_WIDTH"/>
+            <enum name="GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT"/>
+            <enum name="GL_TEXTURE_COMPRESSED_BLOCK_SIZE"/>
+            <enum name="GL_CLEAR_BUFFER"/>
+            <enum name="GL_TEXTURE_VIEW"/>
+            <enum name="GL_VIEW_COMPATIBILITY_CLASS"/>
+            <enum name="GL_FULL_SUPPORT"/>
+            <enum name="GL_CAVEAT_SUPPORT"/>
+            <enum name="GL_IMAGE_CLASS_4_X_32"/>
+            <enum name="GL_IMAGE_CLASS_2_X_32"/>
+            <enum name="GL_IMAGE_CLASS_1_X_32"/>
+            <enum name="GL_IMAGE_CLASS_4_X_16"/>
+            <enum name="GL_IMAGE_CLASS_2_X_16"/>
+            <enum name="GL_IMAGE_CLASS_1_X_16"/>
+            <enum name="GL_IMAGE_CLASS_4_X_8"/>
+            <enum name="GL_IMAGE_CLASS_2_X_8"/>
+            <enum name="GL_IMAGE_CLASS_1_X_8"/>
+            <enum name="GL_IMAGE_CLASS_11_11_10"/>
+            <enum name="GL_IMAGE_CLASS_10_10_10_2"/>
+            <enum name="GL_VIEW_CLASS_128_BITS"/>
+            <enum name="GL_VIEW_CLASS_96_BITS"/>
+            <enum name="GL_VIEW_CLASS_64_BITS"/>
+            <enum name="GL_VIEW_CLASS_48_BITS"/>
+            <enum name="GL_VIEW_CLASS_32_BITS"/>
+            <enum name="GL_VIEW_CLASS_24_BITS"/>
+            <enum name="GL_VIEW_CLASS_16_BITS"/>
+            <enum name="GL_VIEW_CLASS_8_BITS"/>
+            <enum name="GL_VIEW_CLASS_S3TC_DXT1_RGB"/>
+            <enum name="GL_VIEW_CLASS_S3TC_DXT1_RGBA"/>
+            <enum name="GL_VIEW_CLASS_S3TC_DXT3_RGBA"/>
+            <enum name="GL_VIEW_CLASS_S3TC_DXT5_RGBA"/>
+            <enum name="GL_VIEW_CLASS_RGTC1_RED"/>
+            <enum name="GL_VIEW_CLASS_RGTC2_RG"/>
+            <enum name="GL_VIEW_CLASS_BPTC_UNORM"/>
+            <enum name="GL_VIEW_CLASS_BPTC_FLOAT"/>
+        </require>
+        <require comment="Reuse tokens from ARB_invalidate_subdata (none)">
+        </require>
+        <require comment="Reuse tokens from ARB_multi_draw_indirect (none)">
+        </require>
+        <require comment="Reuse tokens from ARB_program_interface_query">
+            <enum name="GL_UNIFORM"/>
+            <enum name="GL_UNIFORM_BLOCK"/>
+            <enum name="GL_PROGRAM_INPUT"/>
+            <enum name="GL_PROGRAM_OUTPUT"/>
+            <enum name="GL_BUFFER_VARIABLE"/>
+            <enum name="GL_SHADER_STORAGE_BLOCK"/>
+            <enum name="GL_VERTEX_SUBROUTINE"/>
+            <enum name="GL_TESS_CONTROL_SUBROUTINE"/>
+            <enum name="GL_TESS_EVALUATION_SUBROUTINE"/>
+            <enum name="GL_GEOMETRY_SUBROUTINE"/>
+            <enum name="GL_FRAGMENT_SUBROUTINE"/>
+            <enum name="GL_COMPUTE_SUBROUTINE"/>
+            <enum name="GL_VERTEX_SUBROUTINE_UNIFORM"/>
+            <enum name="GL_TESS_CONTROL_SUBROUTINE_UNIFORM"/>
+            <enum name="GL_TESS_EVALUATION_SUBROUTINE_UNIFORM"/>
+            <enum name="GL_GEOMETRY_SUBROUTINE_UNIFORM"/>
+            <enum name="GL_FRAGMENT_SUBROUTINE_UNIFORM"/>
+            <enum name="GL_COMPUTE_SUBROUTINE_UNIFORM"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_VARYING"/>
+            <enum name="GL_ACTIVE_RESOURCES"/>
+            <enum name="GL_MAX_NAME_LENGTH"/>
+            <enum name="GL_MAX_NUM_ACTIVE_VARIABLES"/>
+            <enum name="GL_MAX_NUM_COMPATIBLE_SUBROUTINES"/>
+            <enum name="GL_NAME_LENGTH"/>
+            <enum name="GL_TYPE"/>
+            <enum name="GL_ARRAY_SIZE"/>
+            <enum name="GL_OFFSET"/>
+            <enum name="GL_BLOCK_INDEX"/>
+            <enum name="GL_ARRAY_STRIDE"/>
+            <enum name="GL_MATRIX_STRIDE"/>
+            <enum name="GL_IS_ROW_MAJOR"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_INDEX"/>
+            <enum name="GL_BUFFER_BINDING"/>
+            <enum name="GL_BUFFER_DATA_SIZE"/>
+            <enum name="GL_NUM_ACTIVE_VARIABLES"/>
+            <enum name="GL_ACTIVE_VARIABLES"/>
+            <enum name="GL_REFERENCED_BY_VERTEX_SHADER"/>
+            <enum name="GL_REFERENCED_BY_TESS_CONTROL_SHADER"/>
+            <enum name="GL_REFERENCED_BY_TESS_EVALUATION_SHADER"/>
+            <enum name="GL_REFERENCED_BY_GEOMETRY_SHADER"/>
+            <enum name="GL_REFERENCED_BY_FRAGMENT_SHADER"/>
+            <enum name="GL_REFERENCED_BY_COMPUTE_SHADER"/>
+            <enum name="GL_TOP_LEVEL_ARRAY_SIZE"/>
+            <enum name="GL_TOP_LEVEL_ARRAY_STRIDE"/>
+            <enum name="GL_LOCATION"/>
+            <enum name="GL_LOCATION_INDEX"/>
+            <enum name="GL_IS_PER_PATCH"/>
+        </require>
+        <require comment="Reuse tokens from ARB_robust_buffer_access_behavior (none)">
+        </require>
+        <require comment="Reuse tokens from ARB_shader_storage_buffer_object">
+            <enum name="GL_SHADER_STORAGE_BUFFER"/>
+            <enum name="GL_SHADER_STORAGE_BUFFER_BINDING"/>
+            <enum name="GL_SHADER_STORAGE_BUFFER_START"/>
+            <enum name="GL_SHADER_STORAGE_BUFFER_SIZE"/>
+            <enum name="GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS"/>
+            <enum name="GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS"/>
+            <enum name="GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS"/>
+            <enum name="GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS"/>
+            <enum name="GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS"/>
+            <enum name="GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS"/>
+            <enum name="GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS"/>
+            <enum name="GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS"/>
+            <enum name="GL_MAX_SHADER_STORAGE_BLOCK_SIZE"/>
+            <enum name="GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT"/>
+            <enum name="GL_SHADER_STORAGE_BARRIER_BIT"/>
+            <enum name="GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES"/>
+        </require>
+        <require comment="Reuse tokens from ARB_stencil_texturing">
+            <enum name="GL_DEPTH_STENCIL_TEXTURE_MODE"/>
+        </require>
+        <require comment="Reuse tokens from ARB_texture_buffer_range">
+            <enum name="GL_TEXTURE_BUFFER_OFFSET"/>
+            <enum name="GL_TEXTURE_BUFFER_SIZE"/>
+            <enum name="GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT"/>
+        </require>
+        <require comment="Reuse tokens from ARB_texture_query_levels (none)">
+        </require>
+        <require comment="Reuse tokens from ARB_texture_storage_multisample (none)">
+        </require>
+        <require comment="Reuse tokens from ARB_texture_view">
+            <enum name="GL_TEXTURE_VIEW_MIN_LEVEL"/>
+            <enum name="GL_TEXTURE_VIEW_NUM_LEVELS"/>
+            <enum name="GL_TEXTURE_VIEW_MIN_LAYER"/>
+            <enum name="GL_TEXTURE_VIEW_NUM_LAYERS"/>
+            <enum name="GL_TEXTURE_IMMUTABLE_LEVELS"/>
+        </require>
+        <require comment="Reuse tokens from ARB_vertex_attrib_binding">
+            <enum name="GL_VERTEX_ATTRIB_BINDING"/>
+            <enum name="GL_VERTEX_ATTRIB_RELATIVE_OFFSET"/>
+            <enum name="GL_VERTEX_BINDING_DIVISOR"/>
+            <enum name="GL_VERTEX_BINDING_OFFSET"/>
+            <enum name="GL_VERTEX_BINDING_STRIDE"/>
+            <enum name="GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET"/>
+            <enum name="GL_MAX_VERTEX_ATTRIB_BINDINGS"/>
+            <enum name="GL_VERTEX_BINDING_BUFFER" comment="Added in 2013/10/22 update to the spec"/>
+        </require>
+        <require comment="Reuse commands from ARB_arrays_of_arrays (none, GLSL only)">
+        </require>
+        <require comment="Reuse commands from ARB_clear_buffer_object">
+            <command name="glClearBufferData"/>
+            <command name="glClearBufferSubData"/>
+        </require>
+        <require comment="Reuse commands from ARB_compute_shader">
+            <command name="glDispatchCompute"/>
+            <command name="glDispatchComputeIndirect"/>
+        </require>
+        <require comment="Reuse commands from ARB_copy_image">
+            <command name="glCopyImageSubData"/>
+        </require>
+        <require comment="Reuse commands from ARB_ES3_compatibility (none)">
+        </require>
+        <require comment="Reuse commands from ARB_explicit_uniform_location (none)">
+        </require>
+        <require comment="Reuse commands from ARB_fragment_layer_viewport (none, GLSL only)">
+        </require>
+        <require comment="Reuse commands from ARB_framebuffer_no_attachments">
+            <command name="glFramebufferParameteri"/>
+            <command name="glGetFramebufferParameteriv"/>
+        </require>
+        <require comment="Reuse commands from ARB_internalformat_query2">
+            <command name="glGetInternalformati64v"/>
+        </require>
+        <require comment="Reuse commands from ARB_invalidate_subdata">
+            <command name="glInvalidateTexSubImage"/>
+            <command name="glInvalidateTexImage"/>
+            <command name="glInvalidateBufferSubData"/>
+            <command name="glInvalidateBufferData"/>
+            <command name="glInvalidateFramebuffer"/>
+            <command name="glInvalidateSubFramebuffer"/>
+        </require>
+        <require comment="Reuse commands from ARB_multi_draw_indirect">
+            <command name="glMultiDrawArraysIndirect"/>
+            <command name="glMultiDrawElementsIndirect"/>
+        </require>
+        <require comment="Reuse commands from ARB_program_interface_query">
+            <command name="glGetProgramInterfaceiv"/>
+            <command name="glGetProgramResourceIndex"/>
+            <command name="glGetProgramResourceName"/>
+            <command name="glGetProgramResourceiv"/>
+            <command name="glGetProgramResourceLocation"/>
+            <command name="glGetProgramResourceLocationIndex"/>
+        </require>
+        <require comment="Reuse commands from ARB_robust_buffer_access_behavior (none)">
+        </require>
+        <require comment="Reuse commands from ARB_shader_image_size (none, GLSL only)">
+        </require>
+        <require comment="Reuse commands from ARB_shader_storage_buffer_object">
+            <command name="glShaderStorageBlockBinding"/>
+        </require>
+        <require comment="Reuse commands from ARB_stencil_texturing (none)">
+        </require>
+        <require comment="Reuse commands from ARB_texture_buffer_range">
+            <command name="glTexBufferRange"/>
+        </require>
+        <require comment="Reuse commands from ARB_texture_query_levels (none)">
+        </require>
+        <require comment="Reuse commands from ARB_texture_storage_multisample">
+            <command name="glTexStorage2DMultisample"/>
+            <command name="glTexStorage3DMultisample"/>
+        </require>
+        <require comment="Reuse commands from ARB_texture_view">
+            <command name="glTextureView"/>
+        </require>
+        <require comment="Reuse commands from ARB_vertex_attrib_binding">
+            <command name="glBindVertexBuffer"/>
+            <command name="glVertexAttribFormat"/>
+            <command name="glVertexAttribIFormat"/>
+            <command name="glVertexAttribLFormat"/>
+            <command name="glVertexAttribBinding"/>
+            <command name="glVertexBindingDivisor"/>
+        </require>
+        <require comment="Reuse commands from KHR_debug (includes ARB_debug_output commands promoted to KHR without suffixes)">
+            <command name="glDebugMessageControl"/>
+            <command name="glDebugMessageInsert"/>
+            <command name="glDebugMessageCallback"/>
+            <command name="glGetDebugMessageLog"/>
+            <command name="glPushDebugGroup"/>
+            <command name="glPopDebugGroup"/>
+            <command name="glObjectLabel"/>
+            <command name="glGetObjectLabel"/>
+            <command name="glObjectPtrLabel"/>
+            <command name="glGetObjectPtrLabel"/>
+            <command name="glGetPointerv"/>
+        </require>
+        <require profile="compatibility" comment="KHR_debug functionality not supported in core profile">
+            <enum name="GL_DISPLAY_LIST"/>
+        </require>
+        <require profile="core" comment="Restore functionality removed in GL 3.2 core to GL 4.3. Needed for debug interface.">
+            <enum name="GL_STACK_UNDERFLOW"/>
+            <enum name="GL_STACK_OVERFLOW"/>
+            <command name="glGetPointerv"/>
+        </require>
+        <!-- Deprecated in OpenGL 4.3 core;
+             deprecate tag not defined/supported yet
+          <deprecate profile="core">
+            <enum name="GL_UNPACK_LSB_FIRST"/>
+            <enum name="GL_PACK_LSB_FIRST"/>
+          </deprecate>
+        -->
+    </feature>
+    <feature api="gl" name="GL_VERSION_4_4" number="4.4">
+        <require>
+            <enum name="GL_MAX_VERTEX_ATTRIB_STRIDE"/>
+            <enum name="GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED"/>
+            <enum name="GL_TEXTURE_BUFFER_BINDING"/>
+        </require>
+        <require comment="Reuse GL_ARB_buffer_storage">
+            <enum name="GL_MAP_READ_BIT"/>
+            <enum name="GL_MAP_WRITE_BIT"/>
+            <enum name="GL_MAP_PERSISTENT_BIT"/>
+            <enum name="GL_MAP_COHERENT_BIT"/>
+            <enum name="GL_DYNAMIC_STORAGE_BIT"/>
+            <enum name="GL_CLIENT_STORAGE_BIT"/>
+            <enum name="GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT"/>
+            <enum name="GL_BUFFER_IMMUTABLE_STORAGE"/>
+            <enum name="GL_BUFFER_STORAGE_FLAGS"/>
+            <command name="glBufferStorage"/>
+        </require>
+        <require comment="Reuse GL_ARB_clear_texture">
+            <enum name="GL_CLEAR_TEXTURE"/>
+            <command name="glClearTexImage"/>
+            <command name="glClearTexSubImage"/>
+        </require>
+        <require comment="Reuse GL_ARB_enhanced_layouts">
+            <enum name="GL_LOCATION_COMPONENT"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BUFFER"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_INDEX"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE"/>
+        </require>
+        <require comment="Reuse GL_ARB_multi_bind (none)">
+            <command name="glBindBuffersBase"/>
+            <command name="glBindBuffersRange"/>
+            <command name="glBindTextures"/>
+            <command name="glBindSamplers"/>
+            <command name="glBindImageTextures"/>
+            <command name="glBindVertexBuffers"/>
+        </require>
+        <require comment="Reuse GL_ARB_query_buffer_object">
+            <enum name="GL_QUERY_BUFFER"/>
+            <enum name="GL_QUERY_BUFFER_BARRIER_BIT"/>
+            <enum name="GL_QUERY_BUFFER_BINDING"/>
+            <enum name="GL_QUERY_RESULT_NO_WAIT"/>
+        </require>
+        <require comment="Reuse GL_ARB_texture_mirror_clamp_to_edge">
+            <enum name="GL_MIRROR_CLAMP_TO_EDGE"/>
+        </require>
+        <require comment="Reuse GL_ARB_texture_stencil8">
+            <enum name="GL_STENCIL_INDEX"/>
+            <enum name="GL_STENCIL_INDEX8"/>
+        </require>
+        <require comment="Reuse GL_ARB_vertex_type_10f_11f_11f_rev">
+            <enum name="GL_UNSIGNED_INT_10F_11F_11F_REV"/>
+        </require>
+    </feature>
+
+    <!-- SECTION: OpenGL ES 1.0/1.1 API interface definitions. -->
+    <feature api="gles1" name="GL_VERSION_ES_CM_1_0" number="1.0">
+        <require>
+            <!-- Additional API definition macros - ES 1.0/1.1, common/common-lite all in one header -->
+            <enum name="GL_VERSION_ES_CL_1_0"/>
+            <enum name="GL_VERSION_ES_CM_1_1"/>
+            <enum name="GL_VERSION_ES_CL_1_1"/>
+            <type name="GLvoid" comment="No longer used in headers"/>
+            <enum name="GL_DEPTH_BUFFER_BIT"/>
+            <enum name="GL_STENCIL_BUFFER_BIT"/>
+            <enum name="GL_COLOR_BUFFER_BIT"/>
+            <enum name="GL_FALSE"/>
+            <enum name="GL_TRUE"/>
+            <enum name="GL_POINTS"/>
+            <enum name="GL_LINES"/>
+            <enum name="GL_LINE_LOOP"/>
+            <enum name="GL_LINE_STRIP"/>
+            <enum name="GL_TRIANGLES"/>
+            <enum name="GL_TRIANGLE_STRIP"/>
+            <enum name="GL_TRIANGLE_FAN"/>
+            <enum name="GL_NEVER"/>
+            <enum name="GL_LESS"/>
+            <enum name="GL_EQUAL"/>
+            <enum name="GL_LEQUAL"/>
+            <enum name="GL_GREATER"/>
+            <enum name="GL_NOTEQUAL"/>
+            <enum name="GL_GEQUAL"/>
+            <enum name="GL_ALWAYS"/>
+            <enum name="GL_ZERO"/>
+            <enum name="GL_ONE"/>
+            <enum name="GL_SRC_COLOR"/>
+            <enum name="GL_ONE_MINUS_SRC_COLOR"/>
+            <enum name="GL_SRC_ALPHA"/>
+            <enum name="GL_ONE_MINUS_SRC_ALPHA"/>
+            <enum name="GL_DST_ALPHA"/>
+            <enum name="GL_ONE_MINUS_DST_ALPHA"/>
+            <enum name="GL_DST_COLOR"/>
+            <enum name="GL_ONE_MINUS_DST_COLOR"/>
+            <enum name="GL_SRC_ALPHA_SATURATE"/>
+            <enum name="GL_CLIP_PLANE0"/>
+            <enum name="GL_CLIP_PLANE1"/>
+            <enum name="GL_CLIP_PLANE2"/>
+            <enum name="GL_CLIP_PLANE3"/>
+            <enum name="GL_CLIP_PLANE4"/>
+            <enum name="GL_CLIP_PLANE5"/>
+            <enum name="GL_FRONT"/>
+            <enum name="GL_BACK"/>
+            <enum name="GL_FRONT_AND_BACK"/>
+            <enum name="GL_FOG"/>
+            <enum name="GL_LIGHTING"/>
+            <enum name="GL_TEXTURE_2D"/>
+            <enum name="GL_CULL_FACE"/>
+            <enum name="GL_ALPHA_TEST"/>
+            <enum name="GL_BLEND"/>
+            <enum name="GL_COLOR_LOGIC_OP"/>
+            <enum name="GL_DITHER"/>
+            <enum name="GL_STENCIL_TEST"/>
+            <enum name="GL_DEPTH_TEST"/>
+            <enum name="GL_POINT_SMOOTH"/>
+            <enum name="GL_LINE_SMOOTH"/>
+            <enum name="GL_SCISSOR_TEST"/>
+            <enum name="GL_COLOR_MATERIAL"/>
+            <enum name="GL_NORMALIZE"/>
+            <enum name="GL_RESCALE_NORMAL"/>
+            <enum name="GL_VERTEX_ARRAY"/>
+            <enum name="GL_NORMAL_ARRAY"/>
+            <enum name="GL_COLOR_ARRAY"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY"/>
+            <enum name="GL_MULTISAMPLE"/>
+            <enum name="GL_SAMPLE_ALPHA_TO_COVERAGE"/>
+            <enum name="GL_SAMPLE_ALPHA_TO_ONE"/>
+            <enum name="GL_SAMPLE_COVERAGE"/>
+            <enum name="GL_NO_ERROR"/>
+            <enum name="GL_INVALID_ENUM"/>
+            <enum name="GL_INVALID_VALUE"/>
+            <enum name="GL_INVALID_OPERATION"/>
+            <enum name="GL_STACK_OVERFLOW"/>
+            <enum name="GL_STACK_UNDERFLOW"/>
+            <enum name="GL_OUT_OF_MEMORY"/>
+            <enum name="GL_EXP"/>
+            <enum name="GL_EXP2"/>
+            <enum name="GL_FOG_DENSITY"/>
+            <enum name="GL_FOG_START"/>
+            <enum name="GL_FOG_END"/>
+            <enum name="GL_FOG_MODE"/>
+            <enum name="GL_FOG_COLOR"/>
+            <enum name="GL_CW"/>
+            <enum name="GL_CCW"/>
+            <enum name="GL_CURRENT_COLOR"/>
+            <enum name="GL_CURRENT_NORMAL"/>
+            <enum name="GL_CURRENT_TEXTURE_COORDS"/>
+            <enum name="GL_POINT_SIZE"/>
+            <enum name="GL_POINT_SIZE_MIN"/>
+            <enum name="GL_POINT_SIZE_MAX"/>
+            <enum name="GL_POINT_FADE_THRESHOLD_SIZE"/>
+            <enum name="GL_POINT_DISTANCE_ATTENUATION"/>
+            <enum name="GL_SMOOTH_POINT_SIZE_RANGE"/>
+            <enum name="GL_LINE_WIDTH"/>
+            <enum name="GL_SMOOTH_LINE_WIDTH_RANGE"/>
+            <enum name="GL_ALIASED_POINT_SIZE_RANGE"/>
+            <enum name="GL_ALIASED_LINE_WIDTH_RANGE"/>
+            <enum name="GL_CULL_FACE_MODE"/>
+            <enum name="GL_FRONT_FACE"/>
+            <enum name="GL_SHADE_MODEL"/>
+            <enum name="GL_DEPTH_RANGE"/>
+            <enum name="GL_DEPTH_WRITEMASK"/>
+            <enum name="GL_DEPTH_CLEAR_VALUE"/>
+            <enum name="GL_DEPTH_FUNC"/>
+            <enum name="GL_STENCIL_CLEAR_VALUE"/>
+            <enum name="GL_STENCIL_FUNC"/>
+            <enum name="GL_STENCIL_VALUE_MASK"/>
+            <enum name="GL_STENCIL_FAIL"/>
+            <enum name="GL_STENCIL_PASS_DEPTH_FAIL"/>
+            <enum name="GL_STENCIL_PASS_DEPTH_PASS"/>
+            <enum name="GL_STENCIL_REF"/>
+            <enum name="GL_STENCIL_WRITEMASK"/>
+            <enum name="GL_MATRIX_MODE"/>
+            <enum name="GL_VIEWPORT"/>
+            <enum name="GL_MODELVIEW_STACK_DEPTH"/>
+            <enum name="GL_PROJECTION_STACK_DEPTH"/>
+            <enum name="GL_TEXTURE_STACK_DEPTH"/>
+            <enum name="GL_MODELVIEW_MATRIX"/>
+            <enum name="GL_PROJECTION_MATRIX"/>
+            <enum name="GL_TEXTURE_MATRIX"/>
+            <enum name="GL_ALPHA_TEST_FUNC"/>
+            <enum name="GL_ALPHA_TEST_REF"/>
+            <enum name="GL_BLEND_DST"/>
+            <enum name="GL_BLEND_SRC"/>
+            <enum name="GL_LOGIC_OP_MODE"/>
+            <enum name="GL_SCISSOR_BOX"/>
+            <enum name="GL_COLOR_CLEAR_VALUE"/>
+            <enum name="GL_COLOR_WRITEMASK"/>
+            <enum name="GL_MAX_LIGHTS"/>
+            <enum name="GL_MAX_CLIP_PLANES"/>
+            <enum name="GL_MAX_TEXTURE_SIZE"/>
+            <enum name="GL_MAX_MODELVIEW_STACK_DEPTH"/>
+            <enum name="GL_MAX_PROJECTION_STACK_DEPTH"/>
+            <enum name="GL_MAX_TEXTURE_STACK_DEPTH"/>
+            <enum name="GL_MAX_VIEWPORT_DIMS"/>
+            <enum name="GL_MAX_TEXTURE_UNITS"/>
+            <enum name="GL_SUBPIXEL_BITS"/>
+            <enum name="GL_RED_BITS"/>
+            <enum name="GL_GREEN_BITS"/>
+            <enum name="GL_BLUE_BITS"/>
+            <enum name="GL_ALPHA_BITS"/>
+            <enum name="GL_DEPTH_BITS"/>
+            <enum name="GL_STENCIL_BITS"/>
+            <enum name="GL_POLYGON_OFFSET_UNITS"/>
+            <enum name="GL_POLYGON_OFFSET_FILL"/>
+            <enum name="GL_POLYGON_OFFSET_FACTOR"/>
+            <enum name="GL_TEXTURE_BINDING_2D"/>
+            <enum name="GL_VERTEX_ARRAY_SIZE"/>
+            <enum name="GL_VERTEX_ARRAY_TYPE"/>
+            <enum name="GL_VERTEX_ARRAY_STRIDE"/>
+            <enum name="GL_NORMAL_ARRAY_TYPE"/>
+            <enum name="GL_NORMAL_ARRAY_STRIDE"/>
+            <enum name="GL_COLOR_ARRAY_SIZE"/>
+            <enum name="GL_COLOR_ARRAY_TYPE"/>
+            <enum name="GL_COLOR_ARRAY_STRIDE"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_SIZE"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_TYPE"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_STRIDE"/>
+            <enum name="GL_VERTEX_ARRAY_POINTER"/>
+            <enum name="GL_NORMAL_ARRAY_POINTER"/>
+            <enum name="GL_COLOR_ARRAY_POINTER"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_POINTER"/>
+            <enum name="GL_SAMPLE_BUFFERS"/>
+            <enum name="GL_SAMPLES"/>
+            <enum name="GL_SAMPLE_COVERAGE_VALUE"/>
+            <enum name="GL_SAMPLE_COVERAGE_INVERT"/>
+            <enum name="GL_NUM_COMPRESSED_TEXTURE_FORMATS"/>
+            <enum name="GL_COMPRESSED_TEXTURE_FORMATS"/>
+            <enum name="GL_DONT_CARE"/>
+            <enum name="GL_FASTEST"/>
+            <enum name="GL_NICEST"/>
+            <enum name="GL_PERSPECTIVE_CORRECTION_HINT"/>
+            <enum name="GL_POINT_SMOOTH_HINT"/>
+            <enum name="GL_LINE_SMOOTH_HINT"/>
+            <enum name="GL_FOG_HINT"/>
+            <enum name="GL_GENERATE_MIPMAP_HINT"/>
+            <enum name="GL_LIGHT_MODEL_AMBIENT"/>
+            <enum name="GL_LIGHT_MODEL_TWO_SIDE"/>
+            <enum name="GL_AMBIENT"/>
+            <enum name="GL_DIFFUSE"/>
+            <enum name="GL_SPECULAR"/>
+            <enum name="GL_POSITION"/>
+            <enum name="GL_SPOT_DIRECTION"/>
+            <enum name="GL_SPOT_EXPONENT"/>
+            <enum name="GL_SPOT_CUTOFF"/>
+            <enum name="GL_CONSTANT_ATTENUATION"/>
+            <enum name="GL_LINEAR_ATTENUATION"/>
+            <enum name="GL_QUADRATIC_ATTENUATION"/>
+            <enum name="GL_BYTE"/>
+            <enum name="GL_UNSIGNED_BYTE"/>
+            <enum name="GL_SHORT"/>
+            <enum name="GL_UNSIGNED_SHORT"/>
+            <enum name="GL_FLOAT"/>
+            <enum name="GL_FIXED"/>
+            <enum name="GL_CLEAR"/>
+            <enum name="GL_AND"/>
+            <enum name="GL_AND_REVERSE"/>
+            <enum name="GL_COPY"/>
+            <enum name="GL_AND_INVERTED"/>
+            <enum name="GL_NOOP"/>
+            <enum name="GL_XOR"/>
+            <enum name="GL_OR"/>
+            <enum name="GL_NOR"/>
+            <enum name="GL_EQUIV"/>
+            <enum name="GL_INVERT"/>
+            <enum name="GL_OR_REVERSE"/>
+            <enum name="GL_COPY_INVERTED"/>
+            <enum name="GL_OR_INVERTED"/>
+            <enum name="GL_NAND"/>
+            <enum name="GL_SET"/>
+            <enum name="GL_EMISSION"/>
+            <enum name="GL_SHININESS"/>
+            <enum name="GL_AMBIENT_AND_DIFFUSE"/>
+            <enum name="GL_MODELVIEW"/>
+            <enum name="GL_PROJECTION"/>
+            <enum name="GL_TEXTURE"/>
+            <enum name="GL_ALPHA"/>
+            <enum name="GL_RGB"/>
+            <enum name="GL_RGBA"/>
+            <enum name="GL_LUMINANCE"/>
+            <enum name="GL_LUMINANCE_ALPHA"/>
+            <enum name="GL_UNPACK_ALIGNMENT"/>
+            <enum name="GL_PACK_ALIGNMENT"/>
+            <enum name="GL_UNSIGNED_SHORT_4_4_4_4"/>
+            <enum name="GL_UNSIGNED_SHORT_5_5_5_1"/>
+            <enum name="GL_UNSIGNED_SHORT_5_6_5"/>
+            <enum name="GL_FLAT"/>
+            <enum name="GL_SMOOTH"/>
+            <enum name="GL_KEEP"/>
+            <enum name="GL_REPLACE"/>
+            <enum name="GL_INCR"/>
+            <enum name="GL_DECR"/>
+            <enum name="GL_VENDOR"/>
+            <enum name="GL_RENDERER"/>
+            <enum name="GL_VERSION"/>
+            <enum name="GL_EXTENSIONS"/>
+            <enum name="GL_MODULATE"/>
+            <enum name="GL_DECAL"/>
+            <enum name="GL_ADD"/>
+            <enum name="GL_TEXTURE_ENV_MODE"/>
+            <enum name="GL_TEXTURE_ENV_COLOR"/>
+            <enum name="GL_TEXTURE_ENV"/>
+            <enum name="GL_NEAREST"/>
+            <enum name="GL_LINEAR"/>
+            <enum name="GL_NEAREST_MIPMAP_NEAREST"/>
+            <enum name="GL_LINEAR_MIPMAP_NEAREST"/>
+            <enum name="GL_NEAREST_MIPMAP_LINEAR"/>
+            <enum name="GL_LINEAR_MIPMAP_LINEAR"/>
+            <enum name="GL_TEXTURE_MAG_FILTER"/>
+            <enum name="GL_TEXTURE_MIN_FILTER"/>
+            <enum name="GL_TEXTURE_WRAP_S"/>
+            <enum name="GL_TEXTURE_WRAP_T"/>
+            <enum name="GL_GENERATE_MIPMAP"/>
+            <enum name="GL_TEXTURE0"/>
+            <enum name="GL_TEXTURE1"/>
+            <enum name="GL_TEXTURE2"/>
+            <enum name="GL_TEXTURE3"/>
+            <enum name="GL_TEXTURE4"/>
+            <enum name="GL_TEXTURE5"/>
+            <enum name="GL_TEXTURE6"/>
+            <enum name="GL_TEXTURE7"/>
+            <enum name="GL_TEXTURE8"/>
+            <enum name="GL_TEXTURE9"/>
+            <enum name="GL_TEXTURE10"/>
+            <enum name="GL_TEXTURE11"/>
+            <enum name="GL_TEXTURE12"/>
+            <enum name="GL_TEXTURE13"/>
+            <enum name="GL_TEXTURE14"/>
+            <enum name="GL_TEXTURE15"/>
+            <enum name="GL_TEXTURE16"/>
+            <enum name="GL_TEXTURE17"/>
+            <enum name="GL_TEXTURE18"/>
+            <enum name="GL_TEXTURE19"/>
+            <enum name="GL_TEXTURE20"/>
+            <enum name="GL_TEXTURE21"/>
+            <enum name="GL_TEXTURE22"/>
+            <enum name="GL_TEXTURE23"/>
+            <enum name="GL_TEXTURE24"/>
+            <enum name="GL_TEXTURE25"/>
+            <enum name="GL_TEXTURE26"/>
+            <enum name="GL_TEXTURE27"/>
+            <enum name="GL_TEXTURE28"/>
+            <enum name="GL_TEXTURE29"/>
+            <enum name="GL_TEXTURE30"/>
+            <enum name="GL_TEXTURE31"/>
+            <enum name="GL_ACTIVE_TEXTURE"/>
+            <enum name="GL_CLIENT_ACTIVE_TEXTURE"/>
+            <enum name="GL_REPEAT"/>
+            <enum name="GL_CLAMP_TO_EDGE"/>
+            <enum name="GL_LIGHT0"/>
+            <enum name="GL_LIGHT1"/>
+            <enum name="GL_LIGHT2"/>
+            <enum name="GL_LIGHT3"/>
+            <enum name="GL_LIGHT4"/>
+            <enum name="GL_LIGHT5"/>
+            <enum name="GL_LIGHT6"/>
+            <enum name="GL_LIGHT7"/>
+            <enum name="GL_ARRAY_BUFFER"/>
+            <enum name="GL_ELEMENT_ARRAY_BUFFER"/>
+            <enum name="GL_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_ELEMENT_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_VERTEX_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_NORMAL_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_COLOR_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_STATIC_DRAW"/>
+            <enum name="GL_DYNAMIC_DRAW"/>
+            <enum name="GL_BUFFER_SIZE"/>
+            <enum name="GL_BUFFER_USAGE"/>
+            <enum name="GL_SUBTRACT"/>
+            <enum name="GL_COMBINE"/>
+            <enum name="GL_COMBINE_RGB"/>
+            <enum name="GL_COMBINE_ALPHA"/>
+            <enum name="GL_RGB_SCALE"/>
+            <enum name="GL_ADD_SIGNED"/>
+            <enum name="GL_INTERPOLATE"/>
+            <enum name="GL_CONSTANT"/>
+            <enum name="GL_PRIMARY_COLOR"/>
+            <enum name="GL_PREVIOUS"/>
+            <enum name="GL_OPERAND0_RGB"/>
+            <enum name="GL_OPERAND1_RGB"/>
+            <enum name="GL_OPERAND2_RGB"/>
+            <enum name="GL_OPERAND0_ALPHA"/>
+            <enum name="GL_OPERAND1_ALPHA"/>
+            <enum name="GL_OPERAND2_ALPHA"/>
+            <enum name="GL_ALPHA_SCALE"/>
+            <enum name="GL_SRC0_RGB"/>
+            <enum name="GL_SRC1_RGB"/>
+            <enum name="GL_SRC2_RGB"/>
+            <enum name="GL_SRC0_ALPHA"/>
+            <enum name="GL_SRC1_ALPHA"/>
+            <enum name="GL_SRC2_ALPHA"/>
+            <enum name="GL_DOT3_RGB"/>
+            <enum name="GL_DOT3_RGBA"/>
+        </require>
+        <require profile="common">
+            <command name="glAlphaFunc"/>
+            <command name="glClearColor"/>
+            <command name="glClearDepthf"/>
+            <command name="glClipPlanef"/>
+            <command name="glColor4f"/>
+            <command name="glDepthRangef"/>
+            <command name="glFogf"/>
+            <command name="glFogfv"/>
+            <command name="glFrustumf"/>
+            <command name="glGetClipPlanef"/>
+            <command name="glGetFloatv"/>
+            <command name="glGetLightfv"/>
+            <command name="glGetMaterialfv"/>
+            <command name="glGetTexEnvfv"/>
+            <command name="glGetTexParameterfv"/>
+            <command name="glLightModelf"/>
+            <command name="glLightModelfv"/>
+            <command name="glLightf"/>
+            <command name="glLightfv"/>
+            <command name="glLineWidth"/>
+            <command name="glLoadMatrixf"/>
+            <command name="glMaterialf"/>
+            <command name="glMaterialfv"/>
+            <command name="glMultMatrixf"/>
+            <command name="glMultiTexCoord4f"/>
+            <command name="glNormal3f"/>
+            <command name="glOrthof"/>
+            <command name="glPointParameterf"/>
+            <command name="glPointParameterfv"/>
+            <command name="glPointSize"/>
+            <command name="glPolygonOffset"/>
+            <command name="glRotatef"/>
+            <command name="glScalef"/>
+            <command name="glTexEnvf"/>
+            <command name="glTexEnvfv"/>
+            <command name="glTexParameterf"/>
+            <command name="glTexParameterfv"/>
+            <command name="glTranslatef"/>
+        </require>
+        <require>
+            <command name="glActiveTexture"/>
+            <command name="glAlphaFuncx"/>
+            <command name="glBindBuffer"/>
+            <command name="glBindTexture"/>
+            <command name="glBlendFunc"/>
+            <command name="glBufferData"/>
+            <command name="glBufferSubData"/>
+            <command name="glClear"/>
+            <command name="glClearColorx"/>
+            <command name="glClearDepthx"/>
+            <command name="glClearStencil"/>
+            <command name="glClientActiveTexture"/>
+            <command name="glClipPlanex"/>
+            <command name="glColor4ub"/>
+            <command name="glColor4x"/>
+            <command name="glColorMask"/>
+            <command name="glColorPointer"/>
+            <command name="glCompressedTexImage2D"/>
+            <command name="glCompressedTexSubImage2D"/>
+            <command name="glCopyTexImage2D"/>
+            <command name="glCopyTexSubImage2D"/>
+            <command name="glCullFace"/>
+            <command name="glDeleteBuffers"/>
+            <command name="glDeleteTextures"/>
+            <command name="glDepthFunc"/>
+            <command name="glDepthMask"/>
+            <command name="glDepthRangex"/>
+            <command name="glDisable"/>
+            <command name="glDisableClientState"/>
+            <command name="glDrawArrays"/>
+            <command name="glDrawElements"/>
+            <command name="glEnable"/>
+            <command name="glEnableClientState"/>
+            <command name="glFinish"/>
+            <command name="glFlush"/>
+            <command name="glFogx"/>
+            <command name="glFogxv"/>
+            <command name="glFrontFace"/>
+            <command name="glFrustumx"/>
+            <command name="glGetBooleanv"/>
+            <command name="glGetBufferParameteriv"/>
+            <command name="glGetClipPlanex"/>
+            <command name="glGenBuffers"/>
+            <command name="glGenTextures"/>
+            <command name="glGetError"/>
+            <command name="glGetFixedv"/>
+            <command name="glGetIntegerv"/>
+            <command name="glGetLightxv"/>
+            <command name="glGetMaterialxv"/>
+            <command name="glGetPointerv"/>
+            <command name="glGetString"/>
+            <command name="glGetTexEnviv"/>
+            <command name="glGetTexEnvxv"/>
+            <command name="glGetTexParameteriv"/>
+            <command name="glGetTexParameterxv"/>
+            <command name="glHint"/>
+            <command name="glIsBuffer"/>
+            <command name="glIsEnabled"/>
+            <command name="glIsTexture"/>
+            <command name="glLightModelx"/>
+            <command name="glLightModelxv"/>
+            <command name="glLightx"/>
+            <command name="glLightxv"/>
+            <command name="glLineWidthx"/>
+            <command name="glLoadIdentity"/>
+            <command name="glLoadMatrixx"/>
+            <command name="glLogicOp"/>
+            <command name="glMaterialx"/>
+            <command name="glMaterialxv"/>
+            <command name="glMatrixMode"/>
+            <command name="glMultMatrixx"/>
+            <command name="glMultiTexCoord4x"/>
+            <command name="glNormal3x"/>
+            <command name="glNormalPointer"/>
+            <command name="glOrthox"/>
+            <command name="glPixelStorei"/>
+            <command name="glPointParameterx"/>
+            <command name="glPointParameterxv"/>
+            <command name="glPointSizex"/>
+            <command name="glPolygonOffsetx"/>
+            <command name="glPopMatrix"/>
+            <command name="glPushMatrix"/>
+            <command name="glReadPixels"/>
+            <command name="glRotatex"/>
+            <command name="glSampleCoverage"/>
+            <command name="glSampleCoveragex"/>
+            <command name="glScalex"/>
+            <command name="glScissor"/>
+            <command name="glShadeModel"/>
+            <command name="glStencilFunc"/>
+            <command name="glStencilMask"/>
+            <command name="glStencilOp"/>
+            <command name="glTexCoordPointer"/>
+            <command name="glTexEnvi"/>
+            <command name="glTexEnvx"/>
+            <command name="glTexEnviv"/>
+            <command name="glTexEnvxv"/>
+            <command name="glTexImage2D"/>
+            <command name="glTexParameteri"/>
+            <command name="glTexParameterx"/>
+            <command name="glTexParameteriv"/>
+            <command name="glTexParameterxv"/>
+            <command name="glTexSubImage2D"/>
+            <command name="glTranslatex"/>
+            <command name="glVertexPointer"/>
+            <command name="glViewport"/>
+        </require>
+    </feature>
+    <feature api="gles2" name="GL_ES_VERSION_2_0" number="2.0">
+        <require comment="Not used by the API, for compatibility with old gl2.h">
+            <type name="GLbyte"/>
+            <type name="GLclampf"/>
+            <type name="GLfixed"/>
+            <type name="GLshort"/>
+            <type name="GLushort"/>
+            <type name="GLvoid" comment="No longer used in headers"/>
+        </require>
+        <require comment="Not used by the API; put here so this type doesn't need to be declared in gl2ext.h">
+            <type name="GLsync"/>
+            <type name="GLint64"/>
+            <type name="GLuint64"/>
+        </require>
+        <require>
+            <enum name="GL_DEPTH_BUFFER_BIT"/>
+            <enum name="GL_STENCIL_BUFFER_BIT"/>
+            <enum name="GL_COLOR_BUFFER_BIT"/>
+            <enum name="GL_FALSE"/>
+            <enum name="GL_TRUE"/>
+            <enum name="GL_POINTS"/>
+            <enum name="GL_LINES"/>
+            <enum name="GL_LINE_LOOP"/>
+            <enum name="GL_LINE_STRIP"/>
+            <enum name="GL_TRIANGLES"/>
+            <enum name="GL_TRIANGLE_STRIP"/>
+            <enum name="GL_TRIANGLE_FAN"/>
+            <enum name="GL_ZERO"/>
+            <enum name="GL_ONE"/>
+            <enum name="GL_SRC_COLOR"/>
+            <enum name="GL_ONE_MINUS_SRC_COLOR"/>
+            <enum name="GL_SRC_ALPHA"/>
+            <enum name="GL_ONE_MINUS_SRC_ALPHA"/>
+            <enum name="GL_DST_ALPHA"/>
+            <enum name="GL_ONE_MINUS_DST_ALPHA"/>
+            <enum name="GL_DST_COLOR"/>
+            <enum name="GL_ONE_MINUS_DST_COLOR"/>
+            <enum name="GL_SRC_ALPHA_SATURATE"/>
+            <enum name="GL_FUNC_ADD"/>
+            <enum name="GL_BLEND_EQUATION"/>
+            <enum name="GL_BLEND_EQUATION_RGB"/>
+            <enum name="GL_BLEND_EQUATION_ALPHA"/>
+            <enum name="GL_FUNC_SUBTRACT"/>
+            <enum name="GL_FUNC_REVERSE_SUBTRACT"/>
+            <enum name="GL_BLEND_DST_RGB"/>
+            <enum name="GL_BLEND_SRC_RGB"/>
+            <enum name="GL_BLEND_DST_ALPHA"/>
+            <enum name="GL_BLEND_SRC_ALPHA"/>
+            <enum name="GL_CONSTANT_COLOR"/>
+            <enum name="GL_ONE_MINUS_CONSTANT_COLOR"/>
+            <enum name="GL_CONSTANT_ALPHA"/>
+            <enum name="GL_ONE_MINUS_CONSTANT_ALPHA"/>
+            <enum name="GL_BLEND_COLOR"/>
+            <enum name="GL_ARRAY_BUFFER"/>
+            <enum name="GL_ELEMENT_ARRAY_BUFFER"/>
+            <enum name="GL_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_ELEMENT_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_STREAM_DRAW"/>
+            <enum name="GL_STATIC_DRAW"/>
+            <enum name="GL_DYNAMIC_DRAW"/>
+            <enum name="GL_BUFFER_SIZE"/>
+            <enum name="GL_BUFFER_USAGE"/>
+            <enum name="GL_CURRENT_VERTEX_ATTRIB"/>
+            <enum name="GL_FRONT"/>
+            <enum name="GL_BACK"/>
+            <enum name="GL_FRONT_AND_BACK"/>
+            <enum name="GL_TEXTURE_2D"/>
+            <enum name="GL_CULL_FACE"/>
+            <enum name="GL_BLEND"/>
+            <enum name="GL_DITHER"/>
+            <enum name="GL_STENCIL_TEST"/>
+            <enum name="GL_DEPTH_TEST"/>
+            <enum name="GL_SCISSOR_TEST"/>
+            <enum name="GL_POLYGON_OFFSET_FILL"/>
+            <enum name="GL_SAMPLE_ALPHA_TO_COVERAGE"/>
+            <enum name="GL_SAMPLE_COVERAGE"/>
+            <enum name="GL_NO_ERROR"/>
+            <enum name="GL_INVALID_ENUM"/>
+            <enum name="GL_INVALID_VALUE"/>
+            <enum name="GL_INVALID_OPERATION"/>
+            <enum name="GL_OUT_OF_MEMORY"/>
+            <enum name="GL_CW"/>
+            <enum name="GL_CCW"/>
+            <enum name="GL_LINE_WIDTH"/>
+            <enum name="GL_ALIASED_POINT_SIZE_RANGE"/>
+            <enum name="GL_ALIASED_LINE_WIDTH_RANGE"/>
+            <enum name="GL_CULL_FACE_MODE"/>
+            <enum name="GL_FRONT_FACE"/>
+            <enum name="GL_DEPTH_RANGE"/>
+            <enum name="GL_DEPTH_WRITEMASK"/>
+            <enum name="GL_DEPTH_CLEAR_VALUE"/>
+            <enum name="GL_DEPTH_FUNC"/>
+            <enum name="GL_STENCIL_CLEAR_VALUE"/>
+            <enum name="GL_STENCIL_FUNC"/>
+            <enum name="GL_STENCIL_FAIL"/>
+            <enum name="GL_STENCIL_PASS_DEPTH_FAIL"/>
+            <enum name="GL_STENCIL_PASS_DEPTH_PASS"/>
+            <enum name="GL_STENCIL_REF"/>
+            <enum name="GL_STENCIL_VALUE_MASK"/>
+            <enum name="GL_STENCIL_WRITEMASK"/>
+            <enum name="GL_STENCIL_BACK_FUNC"/>
+            <enum name="GL_STENCIL_BACK_FAIL"/>
+            <enum name="GL_STENCIL_BACK_PASS_DEPTH_FAIL"/>
+            <enum name="GL_STENCIL_BACK_PASS_DEPTH_PASS"/>
+            <enum name="GL_STENCIL_BACK_REF"/>
+            <enum name="GL_STENCIL_BACK_VALUE_MASK"/>
+            <enum name="GL_STENCIL_BACK_WRITEMASK"/>
+            <enum name="GL_VIEWPORT"/>
+            <enum name="GL_SCISSOR_BOX"/>
+            <enum name="GL_COLOR_CLEAR_VALUE"/>
+            <enum name="GL_COLOR_WRITEMASK"/>
+            <enum name="GL_UNPACK_ALIGNMENT"/>
+            <enum name="GL_PACK_ALIGNMENT"/>
+            <enum name="GL_MAX_TEXTURE_SIZE"/>
+            <enum name="GL_MAX_VIEWPORT_DIMS"/>
+            <enum name="GL_SUBPIXEL_BITS"/>
+            <enum name="GL_RED_BITS"/>
+            <enum name="GL_GREEN_BITS"/>
+            <enum name="GL_BLUE_BITS"/>
+            <enum name="GL_ALPHA_BITS"/>
+            <enum name="GL_DEPTH_BITS"/>
+            <enum name="GL_STENCIL_BITS"/>
+            <enum name="GL_POLYGON_OFFSET_UNITS"/>
+            <enum name="GL_POLYGON_OFFSET_FACTOR"/>
+            <enum name="GL_TEXTURE_BINDING_2D"/>
+            <enum name="GL_SAMPLE_BUFFERS"/>
+            <enum name="GL_SAMPLES"/>
+            <enum name="GL_SAMPLE_COVERAGE_VALUE"/>
+            <enum name="GL_SAMPLE_COVERAGE_INVERT"/>
+            <enum name="GL_NUM_COMPRESSED_TEXTURE_FORMATS"/>
+            <enum name="GL_COMPRESSED_TEXTURE_FORMATS"/>
+            <enum name="GL_DONT_CARE"/>
+            <enum name="GL_FASTEST"/>
+            <enum name="GL_NICEST"/>
+            <enum name="GL_GENERATE_MIPMAP_HINT"/>
+            <enum name="GL_BYTE"/>
+            <enum name="GL_UNSIGNED_BYTE"/>
+            <enum name="GL_SHORT"/>
+            <enum name="GL_UNSIGNED_SHORT"/>
+            <enum name="GL_INT"/>
+            <enum name="GL_UNSIGNED_INT"/>
+            <enum name="GL_FLOAT"/>
+            <enum name="GL_FIXED"/>
+            <enum name="GL_DEPTH_COMPONENT"/>
+            <enum name="GL_ALPHA"/>
+            <enum name="GL_RGB"/>
+            <enum name="GL_RGBA"/>
+            <enum name="GL_LUMINANCE"/>
+            <enum name="GL_LUMINANCE_ALPHA"/>
+            <enum name="GL_UNSIGNED_SHORT_4_4_4_4"/>
+            <enum name="GL_UNSIGNED_SHORT_5_5_5_1"/>
+            <enum name="GL_UNSIGNED_SHORT_5_6_5"/>
+            <enum name="GL_FRAGMENT_SHADER"/>
+            <enum name="GL_VERTEX_SHADER"/>
+            <enum name="GL_MAX_VERTEX_ATTRIBS"/>
+            <enum name="GL_MAX_VERTEX_UNIFORM_VECTORS"/>
+            <enum name="GL_MAX_VARYING_VECTORS"/>
+            <enum name="GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS"/>
+            <enum name="GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS"/>
+            <enum name="GL_MAX_TEXTURE_IMAGE_UNITS"/>
+            <enum name="GL_MAX_FRAGMENT_UNIFORM_VECTORS"/>
+            <enum name="GL_SHADER_TYPE"/>
+            <enum name="GL_DELETE_STATUS"/>
+            <enum name="GL_LINK_STATUS"/>
+            <enum name="GL_VALIDATE_STATUS"/>
+            <enum name="GL_ATTACHED_SHADERS"/>
+            <enum name="GL_ACTIVE_UNIFORMS"/>
+            <enum name="GL_ACTIVE_UNIFORM_MAX_LENGTH"/>
+            <enum name="GL_ACTIVE_ATTRIBUTES"/>
+            <enum name="GL_ACTIVE_ATTRIBUTE_MAX_LENGTH"/>
+            <enum name="GL_SHADING_LANGUAGE_VERSION"/>
+            <enum name="GL_CURRENT_PROGRAM"/>
+            <enum name="GL_NEVER"/>
+            <enum name="GL_LESS"/>
+            <enum name="GL_EQUAL"/>
+            <enum name="GL_LEQUAL"/>
+            <enum name="GL_GREATER"/>
+            <enum name="GL_NOTEQUAL"/>
+            <enum name="GL_GEQUAL"/>
+            <enum name="GL_ALWAYS"/>
+            <enum name="GL_KEEP"/>
+            <enum name="GL_REPLACE"/>
+            <enum name="GL_INCR"/>
+            <enum name="GL_DECR"/>
+            <enum name="GL_INVERT"/>
+            <enum name="GL_INCR_WRAP"/>
+            <enum name="GL_DECR_WRAP"/>
+            <enum name="GL_VENDOR"/>
+            <enum name="GL_RENDERER"/>
+            <enum name="GL_VERSION"/>
+            <enum name="GL_EXTENSIONS"/>
+            <enum name="GL_NEAREST"/>
+            <enum name="GL_LINEAR"/>
+            <enum name="GL_NEAREST_MIPMAP_NEAREST"/>
+            <enum name="GL_LINEAR_MIPMAP_NEAREST"/>
+            <enum name="GL_NEAREST_MIPMAP_LINEAR"/>
+            <enum name="GL_LINEAR_MIPMAP_LINEAR"/>
+            <enum name="GL_TEXTURE_MAG_FILTER"/>
+            <enum name="GL_TEXTURE_MIN_FILTER"/>
+            <enum name="GL_TEXTURE_WRAP_S"/>
+            <enum name="GL_TEXTURE_WRAP_T"/>
+            <enum name="GL_TEXTURE"/>
+            <enum name="GL_TEXTURE_CUBE_MAP"/>
+            <enum name="GL_TEXTURE_BINDING_CUBE_MAP"/>
+            <enum name="GL_TEXTURE_CUBE_MAP_POSITIVE_X"/>
+            <enum name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X"/>
+            <enum name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y"/>
+            <enum name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y"/>
+            <enum name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z"/>
+            <enum name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z"/>
+            <enum name="GL_MAX_CUBE_MAP_TEXTURE_SIZE"/>
+            <enum name="GL_TEXTURE0"/>
+            <enum name="GL_TEXTURE1"/>
+            <enum name="GL_TEXTURE2"/>
+            <enum name="GL_TEXTURE3"/>
+            <enum name="GL_TEXTURE4"/>
+            <enum name="GL_TEXTURE5"/>
+            <enum name="GL_TEXTURE6"/>
+            <enum name="GL_TEXTURE7"/>
+            <enum name="GL_TEXTURE8"/>
+            <enum name="GL_TEXTURE9"/>
+            <enum name="GL_TEXTURE10"/>
+            <enum name="GL_TEXTURE11"/>
+            <enum name="GL_TEXTURE12"/>
+            <enum name="GL_TEXTURE13"/>
+            <enum name="GL_TEXTURE14"/>
+            <enum name="GL_TEXTURE15"/>
+            <enum name="GL_TEXTURE16"/>
+            <enum name="GL_TEXTURE17"/>
+            <enum name="GL_TEXTURE18"/>
+            <enum name="GL_TEXTURE19"/>
+            <enum name="GL_TEXTURE20"/>
+            <enum name="GL_TEXTURE21"/>
+            <enum name="GL_TEXTURE22"/>
+            <enum name="GL_TEXTURE23"/>
+            <enum name="GL_TEXTURE24"/>
+            <enum name="GL_TEXTURE25"/>
+            <enum name="GL_TEXTURE26"/>
+            <enum name="GL_TEXTURE27"/>
+            <enum name="GL_TEXTURE28"/>
+            <enum name="GL_TEXTURE29"/>
+            <enum name="GL_TEXTURE30"/>
+            <enum name="GL_TEXTURE31"/>
+            <enum name="GL_ACTIVE_TEXTURE"/>
+            <enum name="GL_REPEAT"/>
+            <enum name="GL_CLAMP_TO_EDGE"/>
+            <enum name="GL_MIRRORED_REPEAT"/>
+            <enum name="GL_FLOAT_VEC2"/>
+            <enum name="GL_FLOAT_VEC3"/>
+            <enum name="GL_FLOAT_VEC4"/>
+            <enum name="GL_INT_VEC2"/>
+            <enum name="GL_INT_VEC3"/>
+            <enum name="GL_INT_VEC4"/>
+            <enum name="GL_BOOL"/>
+            <enum name="GL_BOOL_VEC2"/>
+            <enum name="GL_BOOL_VEC3"/>
+            <enum name="GL_BOOL_VEC4"/>
+            <enum name="GL_FLOAT_MAT2"/>
+            <enum name="GL_FLOAT_MAT3"/>
+            <enum name="GL_FLOAT_MAT4"/>
+            <enum name="GL_SAMPLER_2D"/>
+            <enum name="GL_SAMPLER_CUBE"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_ENABLED"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_SIZE"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_STRIDE"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_TYPE"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_NORMALIZED"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_POINTER"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING"/>
+            <enum name="GL_IMPLEMENTATION_COLOR_READ_TYPE"/>
+            <enum name="GL_IMPLEMENTATION_COLOR_READ_FORMAT"/>
+            <enum name="GL_COMPILE_STATUS"/>
+            <enum name="GL_INFO_LOG_LENGTH"/>
+            <enum name="GL_SHADER_SOURCE_LENGTH"/>
+            <enum name="GL_SHADER_COMPILER"/>
+            <enum name="GL_SHADER_BINARY_FORMATS"/>
+            <enum name="GL_NUM_SHADER_BINARY_FORMATS"/>
+            <enum name="GL_LOW_FLOAT"/>
+            <enum name="GL_MEDIUM_FLOAT"/>
+            <enum name="GL_HIGH_FLOAT"/>
+            <enum name="GL_LOW_INT"/>
+            <enum name="GL_MEDIUM_INT"/>
+            <enum name="GL_HIGH_INT"/>
+            <enum name="GL_FRAMEBUFFER"/>
+            <enum name="GL_RENDERBUFFER"/>
+            <enum name="GL_RGBA4"/>
+            <enum name="GL_RGB5_A1"/>
+            <enum name="GL_RGB565"/>
+            <enum name="GL_DEPTH_COMPONENT16"/>
+            <enum name="GL_STENCIL_INDEX8"/>
+            <enum name="GL_RENDERBUFFER_WIDTH"/>
+            <enum name="GL_RENDERBUFFER_HEIGHT"/>
+            <enum name="GL_RENDERBUFFER_INTERNAL_FORMAT"/>
+            <enum name="GL_RENDERBUFFER_RED_SIZE"/>
+            <enum name="GL_RENDERBUFFER_GREEN_SIZE"/>
+            <enum name="GL_RENDERBUFFER_BLUE_SIZE"/>
+            <enum name="GL_RENDERBUFFER_ALPHA_SIZE"/>
+            <enum name="GL_RENDERBUFFER_DEPTH_SIZE"/>
+            <enum name="GL_RENDERBUFFER_STENCIL_SIZE"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE"/>
+            <enum name="GL_COLOR_ATTACHMENT0"/>
+            <enum name="GL_DEPTH_ATTACHMENT"/>
+            <enum name="GL_STENCIL_ATTACHMENT"/>
+            <enum name="GL_NONE"/>
+            <enum name="GL_FRAMEBUFFER_COMPLETE"/>
+            <enum name="GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"/>
+            <enum name="GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"/>
+            <enum name="GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS"/>
+            <enum name="GL_FRAMEBUFFER_UNSUPPORTED"/>
+            <enum name="GL_FRAMEBUFFER_BINDING"/>
+            <enum name="GL_RENDERBUFFER_BINDING"/>
+            <enum name="GL_MAX_RENDERBUFFER_SIZE"/>
+            <enum name="GL_INVALID_FRAMEBUFFER_OPERATION"/>
+            <command name="glActiveTexture"/>
+            <command name="glAttachShader"/>
+            <command name="glBindAttribLocation"/>
+            <command name="glBindBuffer"/>
+            <command name="glBindFramebuffer"/>
+            <command name="glBindRenderbuffer"/>
+            <command name="glBindTexture"/>
+            <command name="glBlendColor"/>
+            <command name="glBlendEquation"/>
+            <command name="glBlendEquationSeparate"/>
+            <command name="glBlendFunc"/>
+            <command name="glBlendFuncSeparate"/>
+            <command name="glBufferData"/>
+            <command name="glBufferSubData"/>
+            <command name="glCheckFramebufferStatus"/>
+            <command name="glClear"/>
+            <command name="glClearColor"/>
+            <command name="glClearDepthf"/>
+            <command name="glClearStencil"/>
+            <command name="glColorMask"/>
+            <command name="glCompileShader"/>
+            <command name="glCompressedTexImage2D"/>
+            <command name="glCompressedTexSubImage2D"/>
+            <command name="glCopyTexImage2D"/>
+            <command name="glCopyTexSubImage2D"/>
+            <command name="glCreateProgram"/>
+            <command name="glCreateShader"/>
+            <command name="glCullFace"/>
+            <command name="glDeleteBuffers"/>
+            <command name="glDeleteFramebuffers"/>
+            <command name="glDeleteProgram"/>
+            <command name="glDeleteRenderbuffers"/>
+            <command name="glDeleteShader"/>
+            <command name="glDeleteTextures"/>
+            <command name="glDepthFunc"/>
+            <command name="glDepthMask"/>
+            <command name="glDepthRangef"/>
+            <command name="glDetachShader"/>
+            <command name="glDisable"/>
+            <command name="glDisableVertexAttribArray"/>
+            <command name="glDrawArrays"/>
+            <command name="glDrawElements"/>
+            <command name="glEnable"/>
+            <command name="glEnableVertexAttribArray"/>
+            <command name="glFinish"/>
+            <command name="glFlush"/>
+            <command name="glFramebufferRenderbuffer"/>
+            <command name="glFramebufferTexture2D"/>
+            <command name="glFrontFace"/>
+            <command name="glGenBuffers"/>
+            <command name="glGenerateMipmap"/>
+            <command name="glGenFramebuffers"/>
+            <command name="glGenRenderbuffers"/>
+            <command name="glGenTextures"/>
+            <command name="glGetActiveAttrib"/>
+            <command name="glGetActiveUniform"/>
+            <command name="glGetAttachedShaders"/>
+            <command name="glGetAttribLocation"/>
+            <command name="glGetBooleanv"/>
+            <command name="glGetBufferParameteriv"/>
+            <command name="glGetError"/>
+            <command name="glGetFloatv"/>
+            <command name="glGetFramebufferAttachmentParameteriv"/>
+            <command name="glGetIntegerv"/>
+            <command name="glGetProgramiv"/>
+            <command name="glGetProgramInfoLog"/>
+            <command name="glGetRenderbufferParameteriv"/>
+            <command name="glGetShaderiv"/>
+            <command name="glGetShaderInfoLog"/>
+            <command name="glGetShaderPrecisionFormat"/>
+            <command name="glGetShaderSource"/>
+            <command name="glGetString"/>
+            <command name="glGetTexParameterfv"/>
+            <command name="glGetTexParameteriv"/>
+            <command name="glGetUniformfv"/>
+            <command name="glGetUniformiv"/>
+            <command name="glGetUniformLocation"/>
+            <command name="glGetVertexAttribfv"/>
+            <command name="glGetVertexAttribiv"/>
+            <command name="glGetVertexAttribPointerv"/>
+            <command name="glHint"/>
+            <command name="glIsBuffer"/>
+            <command name="glIsEnabled"/>
+            <command name="glIsFramebuffer"/>
+            <command name="glIsProgram"/>
+            <command name="glIsRenderbuffer"/>
+            <command name="glIsShader"/>
+            <command name="glIsTexture"/>
+            <command name="glLineWidth"/>
+            <command name="glLinkProgram"/>
+            <command name="glPixelStorei"/>
+            <command name="glPolygonOffset"/>
+            <command name="glReadPixels"/>
+            <command name="glReleaseShaderCompiler"/>
+            <command name="glRenderbufferStorage"/>
+            <command name="glSampleCoverage"/>
+            <command name="glScissor"/>
+            <command name="glShaderBinary"/>
+            <command name="glShaderSource"/>
+            <command name="glStencilFunc"/>
+            <command name="glStencilFuncSeparate"/>
+            <command name="glStencilMask"/>
+            <command name="glStencilMaskSeparate"/>
+            <command name="glStencilOp"/>
+            <command name="glStencilOpSeparate"/>
+            <command name="glTexImage2D"/>
+            <command name="glTexParameterf"/>
+            <command name="glTexParameterfv"/>
+            <command name="glTexParameteri"/>
+            <command name="glTexParameteriv"/>
+            <command name="glTexSubImage2D"/>
+            <command name="glUniform1f"/>
+            <command name="glUniform1fv"/>
+            <command name="glUniform1i"/>
+            <command name="glUniform1iv"/>
+            <command name="glUniform2f"/>
+            <command name="glUniform2fv"/>
+            <command name="glUniform2i"/>
+            <command name="glUniform2iv"/>
+            <command name="glUniform3f"/>
+            <command name="glUniform3fv"/>
+            <command name="glUniform3i"/>
+            <command name="glUniform3iv"/>
+            <command name="glUniform4f"/>
+            <command name="glUniform4fv"/>
+            <command name="glUniform4i"/>
+            <command name="glUniform4iv"/>
+            <command name="glUniformMatrix2fv"/>
+            <command name="glUniformMatrix3fv"/>
+            <command name="glUniformMatrix4fv"/>
+            <command name="glUseProgram"/>
+            <command name="glValidateProgram"/>
+            <command name="glVertexAttrib1f"/>
+            <command name="glVertexAttrib1fv"/>
+            <command name="glVertexAttrib2f"/>
+            <command name="glVertexAttrib2fv"/>
+            <command name="glVertexAttrib3f"/>
+            <command name="glVertexAttrib3fv"/>
+            <command name="glVertexAttrib4f"/>
+            <command name="glVertexAttrib4fv"/>
+            <command name="glVertexAttribPointer"/>
+            <command name="glViewport"/>
+        </require>
+    </feature>
+    <feature api="gles2" name="GL_ES_VERSION_3_0" number="3.0">
+        <require comment="Not used by the API, for compatibility with old gl2.h">
+            <type name="GLhalf"/>
+        </require>
+        <require>
+            <enum name="GL_READ_BUFFER"/>
+            <enum name="GL_UNPACK_ROW_LENGTH"/>
+            <enum name="GL_UNPACK_SKIP_ROWS"/>
+            <enum name="GL_UNPACK_SKIP_PIXELS"/>
+            <enum name="GL_PACK_ROW_LENGTH"/>
+            <enum name="GL_PACK_SKIP_ROWS"/>
+            <enum name="GL_PACK_SKIP_PIXELS"/>
+            <enum name="GL_COLOR"/>
+            <enum name="GL_DEPTH"/>
+            <enum name="GL_STENCIL"/>
+            <enum name="GL_RED"/>
+            <enum name="GL_RGB8"/>
+            <enum name="GL_RGBA8"/>
+            <enum name="GL_RGB10_A2"/>
+            <enum name="GL_TEXTURE_BINDING_3D"/>
+            <enum name="GL_UNPACK_SKIP_IMAGES"/>
+            <enum name="GL_UNPACK_IMAGE_HEIGHT"/>
+            <enum name="GL_TEXTURE_3D"/>
+            <enum name="GL_TEXTURE_WRAP_R"/>
+            <enum name="GL_MAX_3D_TEXTURE_SIZE"/>
+            <enum name="GL_UNSIGNED_INT_2_10_10_10_REV"/>
+            <enum name="GL_MAX_ELEMENTS_VERTICES"/>
+            <enum name="GL_MAX_ELEMENTS_INDICES"/>
+            <enum name="GL_TEXTURE_MIN_LOD"/>
+            <enum name="GL_TEXTURE_MAX_LOD"/>
+            <enum name="GL_TEXTURE_BASE_LEVEL"/>
+            <enum name="GL_TEXTURE_MAX_LEVEL"/>
+            <enum name="GL_MIN"/>
+            <enum name="GL_MAX"/>
+            <enum name="GL_DEPTH_COMPONENT24"/>
+            <enum name="GL_MAX_TEXTURE_LOD_BIAS"/>
+            <enum name="GL_TEXTURE_COMPARE_MODE"/>
+            <enum name="GL_TEXTURE_COMPARE_FUNC"/>
+            <enum name="GL_CURRENT_QUERY"/>
+            <enum name="GL_QUERY_RESULT"/>
+            <enum name="GL_QUERY_RESULT_AVAILABLE"/>
+            <enum name="GL_BUFFER_MAPPED"/>
+            <enum name="GL_BUFFER_MAP_POINTER"/>
+            <enum name="GL_STREAM_READ"/>
+            <enum name="GL_STREAM_COPY"/>
+            <enum name="GL_STATIC_READ"/>
+            <enum name="GL_STATIC_COPY"/>
+            <enum name="GL_DYNAMIC_READ"/>
+            <enum name="GL_DYNAMIC_COPY"/>
+            <enum name="GL_MAX_DRAW_BUFFERS"/>
+            <enum name="GL_DRAW_BUFFER0"/>
+            <enum name="GL_DRAW_BUFFER1"/>
+            <enum name="GL_DRAW_BUFFER2"/>
+            <enum name="GL_DRAW_BUFFER3"/>
+            <enum name="GL_DRAW_BUFFER4"/>
+            <enum name="GL_DRAW_BUFFER5"/>
+            <enum name="GL_DRAW_BUFFER6"/>
+            <enum name="GL_DRAW_BUFFER7"/>
+            <enum name="GL_DRAW_BUFFER8"/>
+            <enum name="GL_DRAW_BUFFER9"/>
+            <enum name="GL_DRAW_BUFFER10"/>
+            <enum name="GL_DRAW_BUFFER11"/>
+            <enum name="GL_DRAW_BUFFER12"/>
+            <enum name="GL_DRAW_BUFFER13"/>
+            <enum name="GL_DRAW_BUFFER14"/>
+            <enum name="GL_DRAW_BUFFER15"/>
+            <enum name="GL_MAX_FRAGMENT_UNIFORM_COMPONENTS"/>
+            <enum name="GL_MAX_VERTEX_UNIFORM_COMPONENTS"/>
+            <enum name="GL_SAMPLER_3D"/>
+            <enum name="GL_SAMPLER_2D_SHADOW"/>
+            <enum name="GL_FRAGMENT_SHADER_DERIVATIVE_HINT"/>
+            <enum name="GL_PIXEL_PACK_BUFFER"/>
+            <enum name="GL_PIXEL_UNPACK_BUFFER"/>
+            <enum name="GL_PIXEL_PACK_BUFFER_BINDING"/>
+            <enum name="GL_PIXEL_UNPACK_BUFFER_BINDING"/>
+            <enum name="GL_FLOAT_MAT2x3"/>
+            <enum name="GL_FLOAT_MAT2x4"/>
+            <enum name="GL_FLOAT_MAT3x2"/>
+            <enum name="GL_FLOAT_MAT3x4"/>
+            <enum name="GL_FLOAT_MAT4x2"/>
+            <enum name="GL_FLOAT_MAT4x3"/>
+            <enum name="GL_SRGB"/>
+            <enum name="GL_SRGB8"/>
+            <enum name="GL_SRGB8_ALPHA8"/>
+            <enum name="GL_COMPARE_REF_TO_TEXTURE"/>
+            <enum name="GL_MAJOR_VERSION"/>
+            <enum name="GL_MINOR_VERSION"/>
+            <enum name="GL_NUM_EXTENSIONS"/>
+            <enum name="GL_RGBA32F"/>
+            <enum name="GL_RGB32F"/>
+            <enum name="GL_RGBA16F"/>
+            <enum name="GL_RGB16F"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_INTEGER"/>
+            <enum name="GL_MAX_ARRAY_TEXTURE_LAYERS"/>
+            <enum name="GL_MIN_PROGRAM_TEXEL_OFFSET"/>
+            <enum name="GL_MAX_PROGRAM_TEXEL_OFFSET"/>
+            <enum name="GL_MAX_VARYING_COMPONENTS"/>
+            <enum name="GL_TEXTURE_2D_ARRAY"/>
+            <enum name="GL_TEXTURE_BINDING_2D_ARRAY"/>
+            <enum name="GL_R11F_G11F_B10F"/>
+            <enum name="GL_UNSIGNED_INT_10F_11F_11F_REV"/>
+            <enum name="GL_RGB9_E5"/>
+            <enum name="GL_UNSIGNED_INT_5_9_9_9_REV"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_MODE"/>
+            <enum name="GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_VARYINGS"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_START"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_SIZE"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN"/>
+            <enum name="GL_RASTERIZER_DISCARD"/>
+            <enum name="GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS"/>
+            <enum name="GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS"/>
+            <enum name="GL_INTERLEAVED_ATTRIBS"/>
+            <enum name="GL_SEPARATE_ATTRIBS"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BUFFER"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_BINDING"/>
+            <enum name="GL_RGBA32UI"/>
+            <enum name="GL_RGB32UI"/>
+            <enum name="GL_RGBA16UI"/>
+            <enum name="GL_RGB16UI"/>
+            <enum name="GL_RGBA8UI"/>
+            <enum name="GL_RGB8UI"/>
+            <enum name="GL_RGBA32I"/>
+            <enum name="GL_RGB32I"/>
+            <enum name="GL_RGBA16I"/>
+            <enum name="GL_RGB16I"/>
+            <enum name="GL_RGBA8I"/>
+            <enum name="GL_RGB8I"/>
+            <enum name="GL_RED_INTEGER"/>
+            <enum name="GL_RGB_INTEGER"/>
+            <enum name="GL_RGBA_INTEGER"/>
+            <enum name="GL_SAMPLER_2D_ARRAY"/>
+            <enum name="GL_SAMPLER_2D_ARRAY_SHADOW"/>
+            <enum name="GL_SAMPLER_CUBE_SHADOW"/>
+            <enum name="GL_UNSIGNED_INT_VEC2"/>
+            <enum name="GL_UNSIGNED_INT_VEC3"/>
+            <enum name="GL_UNSIGNED_INT_VEC4"/>
+            <enum name="GL_INT_SAMPLER_2D"/>
+            <enum name="GL_INT_SAMPLER_3D"/>
+            <enum name="GL_INT_SAMPLER_CUBE"/>
+            <enum name="GL_INT_SAMPLER_2D_ARRAY"/>
+            <enum name="GL_UNSIGNED_INT_SAMPLER_2D"/>
+            <enum name="GL_UNSIGNED_INT_SAMPLER_3D"/>
+            <enum name="GL_UNSIGNED_INT_SAMPLER_CUBE"/>
+            <enum name="GL_UNSIGNED_INT_SAMPLER_2D_ARRAY"/>
+            <enum name="GL_BUFFER_ACCESS_FLAGS"/>
+            <enum name="GL_BUFFER_MAP_LENGTH"/>
+            <enum name="GL_BUFFER_MAP_OFFSET"/>
+            <enum name="GL_DEPTH_COMPONENT32F"/>
+            <enum name="GL_DEPTH32F_STENCIL8"/>
+            <enum name="GL_FLOAT_32_UNSIGNED_INT_24_8_REV"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE"/>
+            <enum name="GL_FRAMEBUFFER_DEFAULT"/>
+            <enum name="GL_FRAMEBUFFER_UNDEFINED"/>
+            <enum name="GL_DEPTH_STENCIL_ATTACHMENT"/>
+            <enum name="GL_DEPTH_STENCIL"/>
+            <enum name="GL_UNSIGNED_INT_24_8"/>
+            <enum name="GL_DEPTH24_STENCIL8"/>
+            <enum name="GL_UNSIGNED_NORMALIZED"/>
+            <enum name="GL_DRAW_FRAMEBUFFER_BINDING"/>
+            <enum name="GL_READ_FRAMEBUFFER"/>
+            <enum name="GL_DRAW_FRAMEBUFFER"/>
+            <enum name="GL_READ_FRAMEBUFFER_BINDING"/>
+            <enum name="GL_RENDERBUFFER_SAMPLES"/>
+            <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER"/>
+            <enum name="GL_MAX_COLOR_ATTACHMENTS"/>
+            <enum name="GL_COLOR_ATTACHMENT1"/>
+            <enum name="GL_COLOR_ATTACHMENT2"/>
+            <enum name="GL_COLOR_ATTACHMENT3"/>
+            <enum name="GL_COLOR_ATTACHMENT4"/>
+            <enum name="GL_COLOR_ATTACHMENT5"/>
+            <enum name="GL_COLOR_ATTACHMENT6"/>
+            <enum name="GL_COLOR_ATTACHMENT7"/>
+            <enum name="GL_COLOR_ATTACHMENT8"/>
+            <enum name="GL_COLOR_ATTACHMENT9"/>
+            <enum name="GL_COLOR_ATTACHMENT10"/>
+            <enum name="GL_COLOR_ATTACHMENT11"/>
+            <enum name="GL_COLOR_ATTACHMENT12"/>
+            <enum name="GL_COLOR_ATTACHMENT13"/>
+            <enum name="GL_COLOR_ATTACHMENT14"/>
+            <enum name="GL_COLOR_ATTACHMENT15"/>
+            <enum name="GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"/>
+            <enum name="GL_MAX_SAMPLES"/>
+            <enum name="GL_HALF_FLOAT"/>
+            <enum name="GL_MAP_READ_BIT"/>
+            <enum name="GL_MAP_WRITE_BIT"/>
+            <enum name="GL_MAP_INVALIDATE_RANGE_BIT"/>
+            <enum name="GL_MAP_INVALIDATE_BUFFER_BIT"/>
+            <enum name="GL_MAP_FLUSH_EXPLICIT_BIT"/>
+            <enum name="GL_MAP_UNSYNCHRONIZED_BIT"/>
+            <enum name="GL_RG"/>
+            <enum name="GL_RG_INTEGER"/>
+            <enum name="GL_R8"/>
+            <enum name="GL_RG8"/>
+            <enum name="GL_R16F"/>
+            <enum name="GL_R32F"/>
+            <enum name="GL_RG16F"/>
+            <enum name="GL_RG32F"/>
+            <enum name="GL_R8I"/>
+            <enum name="GL_R8UI"/>
+            <enum name="GL_R16I"/>
+            <enum name="GL_R16UI"/>
+            <enum name="GL_R32I"/>
+            <enum name="GL_R32UI"/>
+            <enum name="GL_RG8I"/>
+            <enum name="GL_RG8UI"/>
+            <enum name="GL_RG16I"/>
+            <enum name="GL_RG16UI"/>
+            <enum name="GL_RG32I"/>
+            <enum name="GL_RG32UI"/>
+            <enum name="GL_VERTEX_ARRAY_BINDING"/>
+            <enum name="GL_R8_SNORM"/>
+            <enum name="GL_RG8_SNORM"/>
+            <enum name="GL_RGB8_SNORM"/>
+            <enum name="GL_RGBA8_SNORM"/>
+            <enum name="GL_SIGNED_NORMALIZED"/>
+            <enum name="GL_PRIMITIVE_RESTART_FIXED_INDEX"/>
+            <enum name="GL_COPY_READ_BUFFER"/>
+            <enum name="GL_COPY_WRITE_BUFFER"/>
+            <enum name="GL_COPY_READ_BUFFER_BINDING"/>
+            <enum name="GL_COPY_WRITE_BUFFER_BINDING"/>
+            <enum name="GL_UNIFORM_BUFFER"/>
+            <enum name="GL_UNIFORM_BUFFER_BINDING"/>
+            <enum name="GL_UNIFORM_BUFFER_START"/>
+            <enum name="GL_UNIFORM_BUFFER_SIZE"/>
+            <enum name="GL_MAX_VERTEX_UNIFORM_BLOCKS"/>
+            <enum name="GL_MAX_FRAGMENT_UNIFORM_BLOCKS"/>
+            <enum name="GL_MAX_COMBINED_UNIFORM_BLOCKS"/>
+            <enum name="GL_MAX_UNIFORM_BUFFER_BINDINGS"/>
+            <enum name="GL_MAX_UNIFORM_BLOCK_SIZE"/>
+            <enum name="GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS"/>
+            <enum name="GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS"/>
+            <enum name="GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT"/>
+            <enum name="GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH"/>
+            <enum name="GL_ACTIVE_UNIFORM_BLOCKS"/>
+            <enum name="GL_UNIFORM_TYPE"/>
+            <enum name="GL_UNIFORM_SIZE"/>
+            <enum name="GL_UNIFORM_NAME_LENGTH"/>
+            <enum name="GL_UNIFORM_BLOCK_INDEX"/>
+            <enum name="GL_UNIFORM_OFFSET"/>
+            <enum name="GL_UNIFORM_ARRAY_STRIDE"/>
+            <enum name="GL_UNIFORM_MATRIX_STRIDE"/>
+            <enum name="GL_UNIFORM_IS_ROW_MAJOR"/>
+            <enum name="GL_UNIFORM_BLOCK_BINDING"/>
+            <enum name="GL_UNIFORM_BLOCK_DATA_SIZE"/>
+            <enum name="GL_UNIFORM_BLOCK_NAME_LENGTH"/>
+            <enum name="GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS"/>
+            <enum name="GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"/>
+            <enum name="GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER"/>
+            <enum name="GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER"/>
+            <enum name="GL_INVALID_INDEX"/>
+            <enum name="GL_MAX_VERTEX_OUTPUT_COMPONENTS"/>
+            <enum name="GL_MAX_FRAGMENT_INPUT_COMPONENTS"/>
+            <enum name="GL_MAX_SERVER_WAIT_TIMEOUT"/>
+            <enum name="GL_OBJECT_TYPE"/>
+            <enum name="GL_SYNC_CONDITION"/>
+            <enum name="GL_SYNC_STATUS"/>
+            <enum name="GL_SYNC_FLAGS"/>
+            <enum name="GL_SYNC_FENCE"/>
+            <enum name="GL_SYNC_GPU_COMMANDS_COMPLETE"/>
+            <enum name="GL_UNSIGNALED"/>
+            <enum name="GL_SIGNALED"/>
+            <enum name="GL_ALREADY_SIGNALED"/>
+            <enum name="GL_TIMEOUT_EXPIRED"/>
+            <enum name="GL_CONDITION_SATISFIED"/>
+            <enum name="GL_WAIT_FAILED"/>
+            <enum name="GL_SYNC_FLUSH_COMMANDS_BIT"/>
+            <enum name="GL_TIMEOUT_IGNORED"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_DIVISOR"/>
+            <enum name="GL_ANY_SAMPLES_PASSED"/>
+            <enum name="GL_ANY_SAMPLES_PASSED_CONSERVATIVE"/>
+            <enum name="GL_SAMPLER_BINDING"/>
+            <enum name="GL_RGB10_A2UI"/>
+            <enum name="GL_TEXTURE_SWIZZLE_R"/>
+            <enum name="GL_TEXTURE_SWIZZLE_G"/>
+            <enum name="GL_TEXTURE_SWIZZLE_B"/>
+            <enum name="GL_TEXTURE_SWIZZLE_A"/>
+            <enum name="GL_GREEN"/>
+            <enum name="GL_BLUE"/>
+            <enum name="GL_INT_2_10_10_10_REV"/>
+            <enum name="GL_TRANSFORM_FEEDBACK"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_PAUSED"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_ACTIVE"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BINDING"/>
+            <enum name="GL_PROGRAM_BINARY_RETRIEVABLE_HINT"/>
+            <enum name="GL_PROGRAM_BINARY_LENGTH"/>
+            <enum name="GL_NUM_PROGRAM_BINARY_FORMATS"/>
+            <enum name="GL_PROGRAM_BINARY_FORMATS"/>
+            <enum name="GL_COMPRESSED_R11_EAC"/>
+            <enum name="GL_COMPRESSED_SIGNED_R11_EAC"/>
+            <enum name="GL_COMPRESSED_RG11_EAC"/>
+            <enum name="GL_COMPRESSED_SIGNED_RG11_EAC"/>
+            <enum name="GL_COMPRESSED_RGB8_ETC2"/>
+            <enum name="GL_COMPRESSED_SRGB8_ETC2"/>
+            <enum name="GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2"/>
+            <enum name="GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2"/>
+            <enum name="GL_COMPRESSED_RGBA8_ETC2_EAC"/>
+            <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"/>
+            <enum name="GL_TEXTURE_IMMUTABLE_FORMAT"/>
+            <enum name="GL_MAX_ELEMENT_INDEX"/>
+            <enum name="GL_NUM_SAMPLE_COUNTS"/>
+            <enum name="GL_TEXTURE_IMMUTABLE_LEVELS"/>
+            <command name="glReadBuffer"/>
+            <command name="glDrawRangeElements"/>
+            <command name="glTexImage3D"/>
+            <command name="glTexSubImage3D"/>
+            <command name="glCopyTexSubImage3D"/>
+            <command name="glCompressedTexImage3D"/>
+            <command name="glCompressedTexSubImage3D"/>
+            <command name="glGenQueries"/>
+            <command name="glDeleteQueries"/>
+            <command name="glIsQuery"/>
+            <command name="glBeginQuery"/>
+            <command name="glEndQuery"/>
+            <command name="glGetQueryiv"/>
+            <command name="glGetQueryObjectuiv"/>
+            <command name="glUnmapBuffer"/>
+            <command name="glGetBufferPointerv"/>
+            <command name="glDrawBuffers"/>
+            <command name="glUniformMatrix2x3fv"/>
+            <command name="glUniformMatrix3x2fv"/>
+            <command name="glUniformMatrix2x4fv"/>
+            <command name="glUniformMatrix4x2fv"/>
+            <command name="glUniformMatrix3x4fv"/>
+            <command name="glUniformMatrix4x3fv"/>
+            <command name="glBlitFramebuffer"/>
+            <command name="glRenderbufferStorageMultisample"/>
+            <command name="glFramebufferTextureLayer"/>
+            <command name="glMapBufferRange"/>
+            <command name="glFlushMappedBufferRange"/>
+            <command name="glBindVertexArray"/>
+            <command name="glDeleteVertexArrays"/>
+            <command name="glGenVertexArrays"/>
+            <command name="glIsVertexArray"/>
+            <command name="glGetIntegeri_v"/>
+            <command name="glBeginTransformFeedback"/>
+            <command name="glEndTransformFeedback"/>
+            <command name="glBindBufferRange"/>
+            <command name="glBindBufferBase"/>
+            <command name="glTransformFeedbackVaryings"/>
+            <command name="glGetTransformFeedbackVarying"/>
+            <command name="glVertexAttribIPointer"/>
+            <command name="glGetVertexAttribIiv"/>
+            <command name="glGetVertexAttribIuiv"/>
+            <command name="glVertexAttribI4i"/>
+            <command name="glVertexAttribI4ui"/>
+            <command name="glVertexAttribI4iv"/>
+            <command name="glVertexAttribI4uiv"/>
+            <command name="glGetUniformuiv"/>
+            <command name="glGetFragDataLocation"/>
+            <command name="glUniform1ui"/>
+            <command name="glUniform2ui"/>
+            <command name="glUniform3ui"/>
+            <command name="glUniform4ui"/>
+            <command name="glUniform1uiv"/>
+            <command name="glUniform2uiv"/>
+            <command name="glUniform3uiv"/>
+            <command name="glUniform4uiv"/>
+            <command name="glClearBufferiv"/>
+            <command name="glClearBufferuiv"/>
+            <command name="glClearBufferfv"/>
+            <command name="glClearBufferfi"/>
+            <command name="glGetStringi"/>
+            <command name="glCopyBufferSubData"/>
+            <command name="glGetUniformIndices"/>
+            <command name="glGetActiveUniformsiv"/>
+            <command name="glGetUniformBlockIndex"/>
+            <command name="glGetActiveUniformBlockiv"/>
+            <command name="glGetActiveUniformBlockName"/>
+            <command name="glUniformBlockBinding"/>
+            <command name="glDrawArraysInstanced"/>
+            <command name="glDrawElementsInstanced"/>
+            <command name="glFenceSync"/>
+            <command name="glIsSync"/>
+            <command name="glDeleteSync"/>
+            <command name="glClientWaitSync"/>
+            <command name="glWaitSync"/>
+            <command name="glGetInteger64v"/>
+            <command name="glGetSynciv"/>
+            <command name="glGetInteger64i_v"/>
+            <command name="glGetBufferParameteri64v"/>
+            <command name="glGenSamplers"/>
+            <command name="glDeleteSamplers"/>
+            <command name="glIsSampler"/>
+            <command name="glBindSampler"/>
+            <command name="glSamplerParameteri"/>
+            <command name="glSamplerParameteriv"/>
+            <command name="glSamplerParameterf"/>
+            <command name="glSamplerParameterfv"/>
+            <command name="glGetSamplerParameteriv"/>
+            <command name="glGetSamplerParameterfv"/>
+            <command name="glVertexAttribDivisor"/>
+            <command name="glBindTransformFeedback"/>
+            <command name="glDeleteTransformFeedbacks"/>
+            <command name="glGenTransformFeedbacks"/>
+            <command name="glIsTransformFeedback"/>
+            <command name="glPauseTransformFeedback"/>
+            <command name="glResumeTransformFeedback"/>
+            <command name="glGetProgramBinary"/>
+            <command name="glProgramBinary"/>
+            <command name="glProgramParameteri"/>
+            <command name="glInvalidateFramebuffer"/>
+            <command name="glInvalidateSubFramebuffer"/>
+            <command name="glTexStorage2D"/>
+            <command name="glTexStorage3D"/>
+            <command name="glGetInternalformativ"/>
+        </require>
+    </feature>
+    <feature api="gles2" name="GL_ES_VERSION_3_1" number="3.1">
+        <!-- arrays_of_arrays features -->
+        <require/>
+        <!-- compute_shader features -->
+        <require>
+            <command name="glDispatchCompute"/>
+            <command name="glDispatchComputeIndirect"/>
+            <enum name="GL_COMPUTE_SHADER"/>
+            <enum name="GL_MAX_COMPUTE_UNIFORM_BLOCKS"/>
+            <enum name="GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS"/>
+            <enum name="GL_MAX_COMPUTE_IMAGE_UNIFORMS"/>
+            <enum name="GL_MAX_COMPUTE_SHARED_MEMORY_SIZE"/>
+            <enum name="GL_MAX_COMPUTE_UNIFORM_COMPONENTS"/>
+            <enum name="GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS"/>
+            <enum name="GL_MAX_COMPUTE_ATOMIC_COUNTERS"/>
+            <enum name="GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS"/>
+            <enum name="GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS"/>
+            <enum name="GL_MAX_COMPUTE_WORK_GROUP_COUNT"/>
+            <enum name="GL_MAX_COMPUTE_WORK_GROUP_SIZE"/>
+            <enum name="GL_COMPUTE_WORK_GROUP_SIZE"/>
+            <enum name="GL_DISPATCH_INDIRECT_BUFFER"/>
+            <enum name="GL_DISPATCH_INDIRECT_BUFFER_BINDING"/>
+            <enum name="GL_COMPUTE_SHADER_BIT"/>
+        </require>
+        <!-- draw_indirect features -->
+        <require>
+            <command name="glDrawArraysIndirect"/>
+            <command name="glDrawElementsIndirect"/>
+            <enum name="GL_DRAW_INDIRECT_BUFFER"/>
+            <enum name="GL_DRAW_INDIRECT_BUFFER_BINDING"/>
+        </require>
+        <!-- explicit_uniform_location features -->
+        <require>
+            <enum name="GL_MAX_UNIFORM_LOCATIONS"/>
+        </require>
+        <!-- framebuffer_no_attachments features -->
+        <require>
+            <command name="glFramebufferParameteri"/>
+            <command name="glGetFramebufferParameteriv"/>
+            <enum name="GL_FRAMEBUFFER_DEFAULT_WIDTH"/>
+            <enum name="GL_FRAMEBUFFER_DEFAULT_HEIGHT"/>
+            <enum name="GL_FRAMEBUFFER_DEFAULT_SAMPLES"/>
+            <enum name="GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS"/>
+            <enum name="GL_MAX_FRAMEBUFFER_WIDTH"/>
+            <enum name="GL_MAX_FRAMEBUFFER_HEIGHT"/>
+            <enum name="GL_MAX_FRAMEBUFFER_SAMPLES"/>
+        </require>
+        <!-- program_interface_query features -->
+        <require>
+            <command name="glGetProgramInterfaceiv"/>
+            <command name="glGetProgramResourceIndex"/>
+            <command name="glGetProgramResourceName"/>
+            <command name="glGetProgramResourceiv"/>
+            <command name="glGetProgramResourceLocation"/>
+            <enum name="GL_UNIFORM"/>
+            <enum name="GL_UNIFORM_BLOCK"/>
+            <enum name="GL_PROGRAM_INPUT"/>
+            <enum name="GL_PROGRAM_OUTPUT"/>
+            <enum name="GL_BUFFER_VARIABLE"/>
+            <enum name="GL_SHADER_STORAGE_BLOCK"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_VARYING"/>
+            <enum name="GL_ACTIVE_RESOURCES"/>
+            <enum name="GL_MAX_NAME_LENGTH"/>
+            <enum name="GL_MAX_NUM_ACTIVE_VARIABLES"/>
+            <enum name="GL_NAME_LENGTH"/>
+            <enum name="GL_TYPE"/>
+            <enum name="GL_ARRAY_SIZE"/>
+            <enum name="GL_OFFSET"/>
+            <enum name="GL_BLOCK_INDEX"/>
+            <enum name="GL_ARRAY_STRIDE"/>
+            <enum name="GL_MATRIX_STRIDE"/>
+            <enum name="GL_IS_ROW_MAJOR"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_INDEX"/>
+            <enum name="GL_BUFFER_BINDING"/>
+            <enum name="GL_BUFFER_DATA_SIZE"/>
+            <enum name="GL_NUM_ACTIVE_VARIABLES"/>
+            <enum name="GL_ACTIVE_VARIABLES"/>
+            <enum name="GL_REFERENCED_BY_VERTEX_SHADER"/>
+            <enum name="GL_REFERENCED_BY_FRAGMENT_SHADER"/>
+            <enum name="GL_REFERENCED_BY_COMPUTE_SHADER"/>
+            <enum name="GL_TOP_LEVEL_ARRAY_SIZE"/>
+            <enum name="GL_TOP_LEVEL_ARRAY_STRIDE"/>
+            <enum name="GL_LOCATION"/>
+        </require>
+        <!-- separate_shader_objects features -->
+        <require>
+            <command name="glUseProgramStages"/>
+            <command name="glActiveShaderProgram"/>
+            <command name="glCreateShaderProgramv"/>
+            <command name="glBindProgramPipeline"/>
+            <command name="glDeleteProgramPipelines"/>
+            <command name="glGenProgramPipelines"/>
+            <command name="glIsProgramPipeline"/>
+            <command name="glGetProgramPipelineiv"/>
+            <command name="glProgramUniform1i"/>
+            <command name="glProgramUniform2i"/>
+            <command name="glProgramUniform3i"/>
+            <command name="glProgramUniform4i"/>
+            <command name="glProgramUniform1ui"/>
+            <command name="glProgramUniform2ui"/>
+            <command name="glProgramUniform3ui"/>
+            <command name="glProgramUniform4ui"/>
+            <command name="glProgramUniform1f"/>
+            <command name="glProgramUniform2f"/>
+            <command name="glProgramUniform3f"/>
+            <command name="glProgramUniform4f"/>
+            <command name="glProgramUniform1iv"/>
+            <command name="glProgramUniform2iv"/>
+            <command name="glProgramUniform3iv"/>
+            <command name="glProgramUniform4iv"/>
+            <command name="glProgramUniform1uiv"/>
+            <command name="glProgramUniform2uiv"/>
+            <command name="glProgramUniform3uiv"/>
+            <command name="glProgramUniform4uiv"/>
+            <command name="glProgramUniform1fv"/>
+            <command name="glProgramUniform2fv"/>
+            <command name="glProgramUniform3fv"/>
+            <command name="glProgramUniform4fv"/>
+            <command name="glProgramUniformMatrix2fv"/>
+            <command name="glProgramUniformMatrix3fv"/>
+            <command name="glProgramUniformMatrix4fv"/>
+            <command name="glProgramUniformMatrix2x3fv"/>
+            <command name="glProgramUniformMatrix3x2fv"/>
+            <command name="glProgramUniformMatrix2x4fv"/>
+            <command name="glProgramUniformMatrix4x2fv"/>
+            <command name="glProgramUniformMatrix3x4fv"/>
+            <command name="glProgramUniformMatrix4x3fv"/>
+            <command name="glValidateProgramPipeline"/>
+            <command name="glGetProgramPipelineInfoLog"/>
+            <enum name="GL_VERTEX_SHADER_BIT"/>
+            <enum name="GL_FRAGMENT_SHADER_BIT"/>
+            <enum name="GL_ALL_SHADER_BITS"/>
+            <enum name="GL_PROGRAM_SEPARABLE"/>
+            <enum name="GL_ACTIVE_PROGRAM"/>
+            <enum name="GL_PROGRAM_PIPELINE_BINDING"/>
+        </require>
+        <!-- shader_atomic_counters features -->
+        <require>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_BINDING"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_START"/>
+            <enum name="GL_ATOMIC_COUNTER_BUFFER_SIZE"/>
+            <enum name="GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS"/>
+            <enum name="GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS"/>
+            <enum name="GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS"/>
+            <enum name="GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS"/>
+            <enum name="GL_MAX_VERTEX_ATOMIC_COUNTERS"/>
+            <enum name="GL_MAX_FRAGMENT_ATOMIC_COUNTERS"/>
+            <enum name="GL_MAX_COMPUTE_ATOMIC_COUNTERS"/>
+            <enum name="GL_MAX_COMBINED_ATOMIC_COUNTERS"/>
+            <enum name="GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE"/>
+            <enum name="GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS"/>
+            <enum name="GL_ACTIVE_ATOMIC_COUNTER_BUFFERS"/>
+            <enum name="GL_UNSIGNED_INT_ATOMIC_COUNTER"/>
+        </require>
+        <!-- shader_bitfield_operations features -->
+        <require/>
+        <!-- shader_image_load_store features -->
+        <require>
+            <command name="glBindImageTexture"/>
+            <command name="glGetBooleani_v"/>
+            <command name="glMemoryBarrier"/>
+            <command name="glMemoryBarrierByRegion"/>
+            <enum name="GL_MAX_IMAGE_UNITS"/>
+            <enum name="GL_MAX_VERTEX_IMAGE_UNIFORMS"/>
+            <enum name="GL_MAX_FRAGMENT_IMAGE_UNIFORMS"/>
+            <enum name="GL_MAX_COMPUTE_IMAGE_UNIFORMS"/>
+            <enum name="GL_MAX_COMBINED_IMAGE_UNIFORMS"/>
+            <enum name="GL_IMAGE_BINDING_NAME"/>
+            <enum name="GL_IMAGE_BINDING_LEVEL"/>
+            <enum name="GL_IMAGE_BINDING_LAYERED"/>
+            <enum name="GL_IMAGE_BINDING_LAYER"/>
+            <enum name="GL_IMAGE_BINDING_ACCESS"/>
+            <enum name="GL_IMAGE_BINDING_FORMAT"/>
+            <enum name="GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT"/>
+            <enum name="GL_ELEMENT_ARRAY_BARRIER_BIT"/>
+            <enum name="GL_UNIFORM_BARRIER_BIT"/>
+            <enum name="GL_TEXTURE_FETCH_BARRIER_BIT"/>
+            <enum name="GL_SHADER_IMAGE_ACCESS_BARRIER_BIT"/>
+            <enum name="GL_COMMAND_BARRIER_BIT"/>
+            <enum name="GL_PIXEL_BUFFER_BARRIER_BIT"/>
+            <enum name="GL_TEXTURE_UPDATE_BARRIER_BIT"/>
+            <enum name="GL_BUFFER_UPDATE_BARRIER_BIT"/>
+            <enum name="GL_FRAMEBUFFER_BARRIER_BIT"/>
+            <enum name="GL_TRANSFORM_FEEDBACK_BARRIER_BIT"/>
+            <enum name="GL_ATOMIC_COUNTER_BARRIER_BIT"/>
+            <enum name="GL_ALL_BARRIER_BITS"/>
+            <enum name="GL_IMAGE_2D"/>
+            <enum name="GL_IMAGE_3D"/>
+            <enum name="GL_IMAGE_CUBE"/>
+            <enum name="GL_IMAGE_2D_ARRAY"/>
+            <enum name="GL_INT_IMAGE_2D"/>
+            <enum name="GL_INT_IMAGE_3D"/>
+            <enum name="GL_INT_IMAGE_CUBE"/>
+            <enum name="GL_INT_IMAGE_2D_ARRAY"/>
+            <enum name="GL_UNSIGNED_INT_IMAGE_2D"/>
+            <enum name="GL_UNSIGNED_INT_IMAGE_3D"/>
+            <enum name="GL_UNSIGNED_INT_IMAGE_CUBE"/>
+            <enum name="GL_UNSIGNED_INT_IMAGE_2D_ARRAY"/>
+            <enum name="GL_IMAGE_FORMAT_COMPATIBILITY_TYPE"/>
+            <enum name="GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE"/>
+            <enum name="GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS"/>
+            <enum name="GL_READ_ONLY"/>
+            <enum name="GL_WRITE_ONLY"/>
+            <enum name="GL_READ_WRITE"/>
+        </require>
+        <!-- shader_layout_binding features -->
+        <require/>
+        <!-- shader_storage_buffer_object features -->
+        <require>
+            <enum name="GL_SHADER_STORAGE_BUFFER"/>
+            <enum name="GL_SHADER_STORAGE_BUFFER_BINDING"/>
+            <enum name="GL_SHADER_STORAGE_BUFFER_START"/>
+            <enum name="GL_SHADER_STORAGE_BUFFER_SIZE"/>
+            <enum name="GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS"/>
+            <enum name="GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS"/>
+            <enum name="GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS"/>
+            <enum name="GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS"/>
+            <enum name="GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS"/>
+            <enum name="GL_MAX_SHADER_STORAGE_BLOCK_SIZE"/>
+            <enum name="GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT"/>
+            <enum name="GL_SHADER_STORAGE_BARRIER_BIT"/>
+            <enum name="GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES"/>
+        </require>
+        <!-- stencil_texturing features -->
+        <require>
+            <enum name="GL_DEPTH_STENCIL_TEXTURE_MODE"/>
+            <enum name="GL_STENCIL_INDEX"/>
+        </require>
+        <!-- texture_gather features -->
+        <require>
+            <enum name="GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET"/>
+            <enum name="GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET"/>
+        </require>
+        <!-- texture_storage_multisample features -->
+        <require>
+            <command name="glTexStorage2DMultisample"/>
+            <command name="glGetMultisamplefv"/>
+            <command name="glSampleMaski"/>
+            <command name="glGetTexLevelParameteriv"/>
+            <command name="glGetTexLevelParameterfv"/>
+            <enum name="GL_SAMPLE_POSITION"/>
+            <enum name="GL_SAMPLE_MASK"/>
+            <enum name="GL_SAMPLE_MASK_VALUE"/>
+            <enum name="GL_TEXTURE_2D_MULTISAMPLE"/>
+            <enum name="GL_MAX_SAMPLE_MASK_WORDS"/>
+            <enum name="GL_MAX_COLOR_TEXTURE_SAMPLES"/>
+            <enum name="GL_MAX_DEPTH_TEXTURE_SAMPLES"/>
+            <enum name="GL_MAX_INTEGER_SAMPLES"/>
+            <enum name="GL_TEXTURE_BINDING_2D_MULTISAMPLE"/>
+            <enum name="GL_TEXTURE_SAMPLES"/>
+            <enum name="GL_TEXTURE_FIXED_SAMPLE_LOCATIONS"/>
+            <enum name="GL_TEXTURE_WIDTH"/>
+            <enum name="GL_TEXTURE_HEIGHT"/>
+            <enum name="GL_TEXTURE_DEPTH"/>
+            <enum name="GL_TEXTURE_INTERNAL_FORMAT"/>
+            <enum name="GL_TEXTURE_RED_SIZE"/>
+            <enum name="GL_TEXTURE_GREEN_SIZE"/>
+            <enum name="GL_TEXTURE_BLUE_SIZE"/>
+            <enum name="GL_TEXTURE_ALPHA_SIZE"/>
+            <enum name="GL_TEXTURE_DEPTH_SIZE"/>
+            <enum name="GL_TEXTURE_STENCIL_SIZE"/>
+            <enum name="GL_TEXTURE_SHARED_SIZE"/>
+            <enum name="GL_TEXTURE_RED_TYPE"/>
+            <enum name="GL_TEXTURE_GREEN_TYPE"/>
+            <enum name="GL_TEXTURE_BLUE_TYPE"/>
+            <enum name="GL_TEXTURE_ALPHA_TYPE"/>
+            <enum name="GL_TEXTURE_DEPTH_TYPE"/>
+            <enum name="GL_TEXTURE_COMPRESSED"/>
+            <enum name="GL_SAMPLER_2D_MULTISAMPLE"/>
+            <enum name="GL_INT_SAMPLER_2D_MULTISAMPLE"/>
+            <enum name="GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE"/>
+        </require>
+        <!-- vertex_attrib_binding features -->
+        <require>
+            <command name="glBindVertexBuffer"/>
+            <command name="glVertexAttribFormat"/>
+            <command name="glVertexAttribIFormat"/>
+            <command name="glVertexAttribBinding"/>
+            <command name="glVertexBindingDivisor"/>
+            <enum name="GL_VERTEX_ATTRIB_BINDING"/>
+            <enum name="GL_VERTEX_ATTRIB_RELATIVE_OFFSET"/>
+            <enum name="GL_VERTEX_BINDING_DIVISOR"/>
+            <enum name="GL_VERTEX_BINDING_OFFSET"/>
+            <enum name="GL_VERTEX_BINDING_STRIDE"/>
+            <enum name="GL_VERTEX_BINDING_BUFFER"/>
+            <enum name="GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET"/>
+            <enum name="GL_MAX_VERTEX_ATTRIB_BINDINGS"/>
+            <enum name="GL_MAX_VERTEX_ATTRIB_STRIDE"/>
+        </require>
+    </feature>
+
+    <!-- SECTION: OpenGL / OpenGL ES extension interface definitions -->
+    <extensions>
+        <extension name="GL_3DFX_multisample" supported="gl">
+            <require>
+                <enum name="GL_MULTISAMPLE_3DFX"/>
+                <enum name="GL_SAMPLE_BUFFERS_3DFX"/>
+                <enum name="GL_SAMPLES_3DFX"/>
+                <enum name="GL_MULTISAMPLE_BIT_3DFX"/>
+            </require>
+        </extension>
+        <extension name="GL_3DFX_tbuffer" supported="gl">
+            <require>
+                <command name="glTbufferMask3DFX"/>
+            </require>
+        </extension>
+        <extension name="GL_3DFX_texture_compression_FXT1" supported="gl">
+            <require>
+                <enum name="GL_COMPRESSED_RGB_FXT1_3DFX"/>
+                <enum name="GL_COMPRESSED_RGBA_FXT1_3DFX"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_blend_minmax_factor" supported="gl">
+            <require>
+                <enum name="GL_FACTOR_MIN_AMD"/>
+                <enum name="GL_FACTOR_MAX_AMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_compressed_3DC_texture" supported="gles1|gles2">
+            <require>
+                <enum name="GL_3DC_X_AMD"/>
+                <enum name="GL_3DC_XY_AMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_compressed_ATC_texture" supported="gles1|gles2">
+            <require>
+                <enum name="GL_ATC_RGB_AMD"/>
+                <enum name="GL_ATC_RGBA_EXPLICIT_ALPHA_AMD"/>
+                <enum name="GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_conservative_depth" supported="gl"/>
+        <extension name="GL_AMD_debug_output" supported="gl">
+            <require>
+                <enum name="GL_MAX_DEBUG_MESSAGE_LENGTH_AMD"/>
+                <enum name="GL_MAX_DEBUG_LOGGED_MESSAGES_AMD"/>
+                <enum name="GL_DEBUG_LOGGED_MESSAGES_AMD"/>
+                <enum name="GL_DEBUG_SEVERITY_HIGH_AMD"/>
+                <enum name="GL_DEBUG_SEVERITY_MEDIUM_AMD"/>
+                <enum name="GL_DEBUG_SEVERITY_LOW_AMD"/>
+                <enum name="GL_DEBUG_CATEGORY_API_ERROR_AMD"/>
+                <enum name="GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD"/>
+                <enum name="GL_DEBUG_CATEGORY_DEPRECATION_AMD"/>
+                <enum name="GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD"/>
+                <enum name="GL_DEBUG_CATEGORY_PERFORMANCE_AMD"/>
+                <enum name="GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD"/>
+                <enum name="GL_DEBUG_CATEGORY_APPLICATION_AMD"/>
+                <enum name="GL_DEBUG_CATEGORY_OTHER_AMD"/>
+                <command name="glDebugMessageEnableAMD"/>
+                <command name="glDebugMessageInsertAMD"/>
+                <command name="glDebugMessageCallbackAMD"/>
+                <command name="glGetDebugMessageLogAMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_depth_clamp_separate" supported="gl">
+            <require>
+                <enum name="GL_DEPTH_CLAMP_NEAR_AMD"/>
+                <enum name="GL_DEPTH_CLAMP_FAR_AMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_draw_buffers_blend" supported="gl">
+            <require>
+                <command name="glBlendFuncIndexedAMD"/>
+                <command name="glBlendFuncSeparateIndexedAMD"/>
+                <command name="glBlendEquationIndexedAMD"/>
+                <command name="glBlendEquationSeparateIndexedAMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_gpu_shader_int64" supported="gl">
+            <require>
+                <enum name="GL_INT64_NV"/>
+                <enum name="GL_UNSIGNED_INT64_NV"/>
+                <enum name="GL_INT8_NV"/>
+                <enum name="GL_INT8_VEC2_NV"/>
+                <enum name="GL_INT8_VEC3_NV"/>
+                <enum name="GL_INT8_VEC4_NV"/>
+                <enum name="GL_INT16_NV"/>
+                <enum name="GL_INT16_VEC2_NV"/>
+                <enum name="GL_INT16_VEC3_NV"/>
+                <enum name="GL_INT16_VEC4_NV"/>
+                <enum name="GL_INT64_VEC2_NV"/>
+                <enum name="GL_INT64_VEC3_NV"/>
+                <enum name="GL_INT64_VEC4_NV"/>
+                <enum name="GL_UNSIGNED_INT8_NV"/>
+                <enum name="GL_UNSIGNED_INT8_VEC2_NV"/>
+                <enum name="GL_UNSIGNED_INT8_VEC3_NV"/>
+                <enum name="GL_UNSIGNED_INT8_VEC4_NV"/>
+                <enum name="GL_UNSIGNED_INT16_NV"/>
+                <enum name="GL_UNSIGNED_INT16_VEC2_NV"/>
+                <enum name="GL_UNSIGNED_INT16_VEC3_NV"/>
+                <enum name="GL_UNSIGNED_INT16_VEC4_NV"/>
+                <enum name="GL_UNSIGNED_INT64_VEC2_NV"/>
+                <enum name="GL_UNSIGNED_INT64_VEC3_NV"/>
+                <enum name="GL_UNSIGNED_INT64_VEC4_NV"/>
+                <enum name="GL_FLOAT16_NV"/>
+                <enum name="GL_FLOAT16_VEC2_NV"/>
+                <enum name="GL_FLOAT16_VEC3_NV"/>
+                <enum name="GL_FLOAT16_VEC4_NV"/>
+                <command name="glUniform1i64NV"/>
+                <command name="glUniform2i64NV"/>
+                <command name="glUniform3i64NV"/>
+                <command name="glUniform4i64NV"/>
+                <command name="glUniform1i64vNV"/>
+                <command name="glUniform2i64vNV"/>
+                <command name="glUniform3i64vNV"/>
+                <command name="glUniform4i64vNV"/>
+                <command name="glUniform1ui64NV"/>
+                <command name="glUniform2ui64NV"/>
+                <command name="glUniform3ui64NV"/>
+                <command name="glUniform4ui64NV"/>
+                <command name="glUniform1ui64vNV"/>
+                <command name="glUniform2ui64vNV"/>
+                <command name="glUniform3ui64vNV"/>
+                <command name="glUniform4ui64vNV"/>
+                <command name="glGetUniformi64vNV"/>
+                <command name="glGetUniformui64vNV"/>
+            </require>
+            <require comment="Supported only if GL_EXT_direct_state_access is supported">
+                <command name="glProgramUniform1i64NV"/>
+                <command name="glProgramUniform2i64NV"/>
+                <command name="glProgramUniform3i64NV"/>
+                <command name="glProgramUniform4i64NV"/>
+                <command name="glProgramUniform1i64vNV"/>
+                <command name="glProgramUniform2i64vNV"/>
+                <command name="glProgramUniform3i64vNV"/>
+                <command name="glProgramUniform4i64vNV"/>
+                <command name="glProgramUniform1ui64NV"/>
+                <command name="glProgramUniform2ui64NV"/>
+                <command name="glProgramUniform3ui64NV"/>
+                <command name="glProgramUniform4ui64NV"/>
+                <command name="glProgramUniform1ui64vNV"/>
+                <command name="glProgramUniform2ui64vNV"/>
+                <command name="glProgramUniform3ui64vNV"/>
+                <command name="glProgramUniform4ui64vNV"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_interleaved_elements" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_ELEMENT_SWIZZLE_AMD"/>
+                <enum name="GL_VERTEX_ID_SWIZZLE_AMD"/>
+                <enum name="GL_RED"/>
+                <enum name="GL_GREEN"/>
+                <enum name="GL_BLUE"/>
+                <enum name="GL_ALPHA"/>
+                <enum name="GL_RG8UI"/>
+                <enum name="GL_RG16UI"/>
+                <enum name="GL_RGBA8UI"/>
+                <command name="glVertexAttribParameteriAMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_gcn_shader" supported="gl"/>
+        <extension name="GL_AMD_multi_draw_indirect" supported="gl">
+            <require>
+                <command name="glMultiDrawArraysIndirectAMD"/>
+                <command name="glMultiDrawElementsIndirectAMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_name_gen_delete" supported="gl">
+            <require>
+                <enum name="GL_DATA_BUFFER_AMD"/>
+                <enum name="GL_PERFORMANCE_MONITOR_AMD"/>
+                <enum name="GL_QUERY_OBJECT_AMD"/>
+                <enum name="GL_VERTEX_ARRAY_OBJECT_AMD"/>
+                <enum name="GL_SAMPLER_OBJECT_AMD"/>
+                <command name="glGenNamesAMD"/>
+                <command name="glDeleteNamesAMD"/>
+                <command name="glIsNameAMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_occlusion_query_event" supported="gl">
+            <require>
+                <enum name="GL_OCCLUSION_QUERY_EVENT_MASK_AMD"/>
+                <enum name="GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD"/>
+                <enum name="GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD"/>
+                <enum name="GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD"/>
+                <enum name="GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD"/>
+                <enum name="GL_QUERY_ALL_EVENT_BITS_AMD"/>
+                <command name="glQueryObjectParameteruiAMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_performance_monitor" supported="gl|gles2">
+            <require>
+                <enum name="GL_COUNTER_TYPE_AMD"/>
+                <enum name="GL_COUNTER_RANGE_AMD"/>
+                <enum name="GL_UNSIGNED_INT64_AMD"/>
+                <enum name="GL_PERCENTAGE_AMD"/>
+                <enum name="GL_PERFMON_RESULT_AVAILABLE_AMD"/>
+                <enum name="GL_PERFMON_RESULT_SIZE_AMD"/>
+                <enum name="GL_PERFMON_RESULT_AMD"/>
+                <command name="glGetPerfMonitorGroupsAMD"/>
+                <command name="glGetPerfMonitorCountersAMD"/>
+                <command name="glGetPerfMonitorGroupStringAMD"/>
+                <command name="glGetPerfMonitorCounterStringAMD"/>
+                <command name="glGetPerfMonitorCounterInfoAMD"/>
+                <command name="glGenPerfMonitorsAMD"/>
+                <command name="glDeletePerfMonitorsAMD"/>
+                <command name="glSelectPerfMonitorCountersAMD"/>
+                <command name="glBeginPerfMonitorAMD"/>
+                <command name="glEndPerfMonitorAMD"/>
+                <command name="glGetPerfMonitorCounterDataAMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_pinned_memory" supported="gl">
+            <require>
+                <enum name="GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_program_binary_Z400" supported="gles2">
+            <require>
+                <enum name="GL_Z400_BINARY_AMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_query_buffer_object" supported="gl">
+            <require>
+                <enum name="GL_QUERY_BUFFER_AMD"/>
+                <enum name="GL_QUERY_BUFFER_BINDING_AMD"/>
+                <enum name="GL_QUERY_RESULT_NO_WAIT_AMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_sample_positions" supported="gl">
+            <require>
+                <enum name="GL_SUBSAMPLE_DISTANCE_AMD"/>
+                <command name="glSetMultisamplefvAMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_seamless_cubemap_per_texture" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_CUBE_MAP_SEAMLESS"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_shader_atomic_counter_ops" supported="gl"/>
+        <extension name="GL_AMD_shader_stencil_export" supported="gl"/>
+        <extension name="GL_AMD_shader_trinary_minmax" supported="gl"/>
+        <extension name="GL_AMD_sparse_texture" supported="gl">
+            <require>
+                <enum name="GL_VIRTUAL_PAGE_SIZE_X_AMD"/>
+                <enum name="GL_VIRTUAL_PAGE_SIZE_Y_AMD"/>
+                <enum name="GL_VIRTUAL_PAGE_SIZE_Z_AMD"/>
+                <enum name="GL_MAX_SPARSE_TEXTURE_SIZE_AMD"/>
+                <enum name="GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD"/>
+                <enum name="GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS"/>
+                <enum name="GL_MIN_SPARSE_LEVEL_AMD"/>
+                <enum name="GL_MIN_LOD_WARNING_AMD"/>
+                <enum name="GL_TEXTURE_STORAGE_SPARSE_BIT_AMD"/>
+                <command name="glTexStorageSparseAMD"/>
+                <command name="glTextureStorageSparseAMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_stencil_operation_extended" supported="gl">
+            <require>
+                <enum name="GL_SET_AMD"/>
+                <enum name="GL_REPLACE_VALUE_AMD"/>
+                <enum name="GL_STENCIL_OP_VALUE_AMD"/>
+                <enum name="GL_STENCIL_BACK_OP_VALUE_AMD"/>
+                <command name="glStencilOpValueAMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_texture_texture4" supported="gl"/>
+        <extension name="GL_AMD_transform_feedback3_lines_triangles" supported="gl"/>
+        <extension name="GL_AMD_transform_feedback4" supported="gl">
+            <require>
+                <enum name="GL_STREAM_RASTERIZATION_AMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_vertex_shader_layer" supported="gl"/>
+        <extension name="GL_AMD_vertex_shader_tessellator" supported="gl">
+            <require>
+                <enum name="GL_SAMPLER_BUFFER_AMD"/>
+                <enum name="GL_INT_SAMPLER_BUFFER_AMD"/>
+                <enum name="GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD"/>
+                <enum name="GL_TESSELLATION_MODE_AMD"/>
+                <enum name="GL_TESSELLATION_FACTOR_AMD"/>
+                <enum name="GL_DISCRETE_AMD"/>
+                <enum name="GL_CONTINUOUS_AMD"/>
+                <command name="glTessellationFactorAMD"/>
+                <command name="glTessellationModeAMD"/>
+            </require>
+        </extension>
+        <extension name="GL_AMD_vertex_shader_viewport_index" supported="gl"/>
+        <extension name="GL_ANGLE_depth_texture" supported="gles2">
+            <require>
+                <enum name="GL_DEPTH_COMPONENT"/>
+                <enum name="GL_DEPTH_STENCIL_OES"/>
+                <enum name="GL_UNSIGNED_SHORT"/>
+                <enum name="GL_UNSIGNED_INT"/>
+                <enum name="GL_UNSIGNED_INT_24_8_OES"/>
+                <enum name="GL_DEPTH_COMPONENT16"/>
+                <enum name="GL_DEPTH_COMPONENT32_OES"/>
+                <enum name="GL_DEPTH24_STENCIL8_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_ANGLE_framebuffer_blit" supported="gles2">
+            <require>
+                <enum name="GL_READ_FRAMEBUFFER_ANGLE"/>
+                <enum name="GL_DRAW_FRAMEBUFFER_ANGLE"/>
+                <enum name="GL_DRAW_FRAMEBUFFER_BINDING_ANGLE"/>
+                <enum name="GL_READ_FRAMEBUFFER_BINDING_ANGLE"/>
+                <command name="glBlitFramebufferANGLE"/>
+            </require>
+        </extension>
+        <extension name="GL_ANGLE_framebuffer_multisample" supported="gles2">
+            <require>
+                <enum name="GL_RENDERBUFFER_SAMPLES_ANGLE"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE"/>
+                <enum name="GL_MAX_SAMPLES_ANGLE"/>
+                <command name="glRenderbufferStorageMultisampleANGLE"/>
+            </require>
+        </extension>
+        <extension name="GL_ANGLE_instanced_arrays" supported="gles2">
+            <require>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE"/>
+                <command name="glDrawArraysInstancedANGLE"/>
+                <command name="glDrawElementsInstancedANGLE"/>
+                <command name="glVertexAttribDivisorANGLE"/>
+            </require>
+        </extension>
+        <extension name="GL_ANGLE_pack_reverse_row_order" supported="gles2">
+            <require>
+                <enum name="GL_PACK_REVERSE_ROW_ORDER_ANGLE"/>
+            </require>
+        </extension>
+        <extension name="GL_ANGLE_program_binary" supported="gles2">
+            <require>
+                <enum name="GL_PROGRAM_BINARY_ANGLE"/>
+            </require>
+        </extension>
+        <extension name="GL_ANGLE_texture_compression_dxt3" supported="gles2">
+            <require>
+                <enum name="GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE"/>
+            </require>
+        </extension>
+        <extension name="GL_ANGLE_texture_compression_dxt5" supported="gles2">
+            <require>
+                <enum name="GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE"/>
+            </require>
+        </extension>
+        <extension name="GL_ANGLE_texture_usage" supported="gles2">
+            <require>
+                <enum name="GL_TEXTURE_USAGE_ANGLE"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_ANGLE"/>
+            </require>
+        </extension>
+        <extension name="GL_ANGLE_translated_shader_source" supported="gles2">
+            <require>
+                <enum name="GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE"/>
+                <command name="glGetTranslatedShaderSourceANGLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_aux_depth_stencil" supported="gl">
+            <require>
+                <enum name="GL_AUX_DEPTH_STENCIL_APPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_client_storage" supported="gl">
+            <require>
+                <enum name="GL_UNPACK_CLIENT_STORAGE_APPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_copy_texture_levels" supported="gles1|gles2">
+            <require>
+                <command name="glCopyTextureLevelsAPPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_element_array" supported="gl">
+            <require>
+                <enum name="GL_ELEMENT_ARRAY_APPLE"/>
+                <enum name="GL_ELEMENT_ARRAY_TYPE_APPLE"/>
+                <enum name="GL_ELEMENT_ARRAY_POINTER_APPLE"/>
+                <command name="glElementPointerAPPLE"/>
+                <command name="glDrawElementArrayAPPLE"/>
+                <command name="glDrawRangeElementArrayAPPLE"/>
+                <command name="glMultiDrawElementArrayAPPLE"/>
+                <command name="glMultiDrawRangeElementArrayAPPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_fence" supported="gl">
+            <require>
+                <enum name="GL_DRAW_PIXELS_APPLE"/>
+                <enum name="GL_FENCE_APPLE"/>
+                <command name="glGenFencesAPPLE"/>
+                <command name="glDeleteFencesAPPLE"/>
+                <command name="glSetFenceAPPLE"/>
+                <command name="glIsFenceAPPLE"/>
+                <command name="glTestFenceAPPLE"/>
+                <command name="glFinishFenceAPPLE"/>
+                <command name="glTestObjectAPPLE"/>
+                <command name="glFinishObjectAPPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_float_pixels" supported="gl">
+            <require>
+                <enum name="GL_HALF_APPLE"/>
+                <enum name="GL_RGBA_FLOAT32_APPLE"/>
+                <enum name="GL_RGB_FLOAT32_APPLE"/>
+                <enum name="GL_ALPHA_FLOAT32_APPLE"/>
+                <enum name="GL_INTENSITY_FLOAT32_APPLE"/>
+                <enum name="GL_LUMINANCE_FLOAT32_APPLE"/>
+                <enum name="GL_LUMINANCE_ALPHA_FLOAT32_APPLE"/>
+                <enum name="GL_RGBA_FLOAT16_APPLE"/>
+                <enum name="GL_RGB_FLOAT16_APPLE"/>
+                <enum name="GL_ALPHA_FLOAT16_APPLE"/>
+                <enum name="GL_INTENSITY_FLOAT16_APPLE"/>
+                <enum name="GL_LUMINANCE_FLOAT16_APPLE"/>
+                <enum name="GL_LUMINANCE_ALPHA_FLOAT16_APPLE"/>
+                <enum name="GL_COLOR_FLOAT_APPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_flush_buffer_range" supported="gl">
+            <require>
+                <enum name="GL_BUFFER_SERIALIZED_MODIFY_APPLE"/>
+                <enum name="GL_BUFFER_FLUSHING_UNMAP_APPLE"/>
+                <command name="glBufferParameteriAPPLE"/>
+                <command name="glFlushMappedBufferRangeAPPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_framebuffer_multisample" supported="gles1|gles2">
+            <require>
+                <enum name="GL_RENDERBUFFER_SAMPLES_APPLE"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE"/>
+                <enum name="GL_MAX_SAMPLES_APPLE"/>
+                <enum name="GL_READ_FRAMEBUFFER_APPLE"/>
+                <enum name="GL_DRAW_FRAMEBUFFER_APPLE"/>
+                <enum name="GL_DRAW_FRAMEBUFFER_BINDING_APPLE"/>
+                <enum name="GL_READ_FRAMEBUFFER_BINDING_APPLE"/>
+                <command name="glRenderbufferStorageMultisampleAPPLE"/>
+                <command name="glResolveMultisampleFramebufferAPPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_object_purgeable" supported="gl">
+            <require>
+                <enum name="GL_BUFFER_OBJECT_APPLE"/>
+                <enum name="GL_RELEASED_APPLE"/>
+                <enum name="GL_VOLATILE_APPLE"/>
+                <enum name="GL_RETAINED_APPLE"/>
+                <enum name="GL_UNDEFINED_APPLE"/>
+                <enum name="GL_PURGEABLE_APPLE"/>
+                <command name="glObjectPurgeableAPPLE"/>
+                <command name="glObjectUnpurgeableAPPLE"/>
+                <command name="glGetObjectParameterivAPPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_rgb_422" supported="gl|gles2">
+            <require>
+                <enum name="GL_RGB_422_APPLE"/>
+                <enum name="GL_UNSIGNED_SHORT_8_8_APPLE"/>
+                <enum name="GL_UNSIGNED_SHORT_8_8_REV_APPLE"/>
+            </require>
+            <require comment="Depends on TexStorage* (EXT_texture_storage / ES 3.0 / GL 4.4 / etc.)">
+                <enum name="GL_RGB_RAW_422_APPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_row_bytes" supported="gl">
+            <require>
+                <enum name="GL_PACK_ROW_BYTES_APPLE"/>
+                <enum name="GL_UNPACK_ROW_BYTES_APPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_specular_vector" supported="gl">
+            <require>
+                <enum name="GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_sync" supported="gles1|gles2">
+            <require>
+                <enum name="GL_SYNC_OBJECT_APPLE"/>
+                <enum name="GL_MAX_SERVER_WAIT_TIMEOUT_APPLE"/>
+                <enum name="GL_OBJECT_TYPE_APPLE"/>
+                <enum name="GL_SYNC_CONDITION_APPLE"/>
+                <enum name="GL_SYNC_STATUS_APPLE"/>
+                <enum name="GL_SYNC_FLAGS_APPLE"/>
+                <enum name="GL_SYNC_FENCE_APPLE"/>
+                <enum name="GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE"/>
+                <enum name="GL_UNSIGNALED_APPLE"/>
+                <enum name="GL_SIGNALED_APPLE"/>
+                <enum name="GL_ALREADY_SIGNALED_APPLE"/>
+                <enum name="GL_TIMEOUT_EXPIRED_APPLE"/>
+                <enum name="GL_CONDITION_SATISFIED_APPLE"/>
+                <enum name="GL_WAIT_FAILED_APPLE"/>
+                <enum name="GL_SYNC_FLUSH_COMMANDS_BIT_APPLE"/>
+                <enum name="GL_TIMEOUT_IGNORED_APPLE"/>
+                <command name="glFenceSyncAPPLE"/>
+                <command name="glIsSyncAPPLE"/>
+                <command name="glDeleteSyncAPPLE"/>
+                <command name="glClientWaitSyncAPPLE"/>
+                <command name="glWaitSyncAPPLE"/>
+                <command name="glGetInteger64vAPPLE"/>
+                <command name="glGetSyncivAPPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_texture_2D_limited_npot" supported="gles1"/>
+        <extension name="GL_APPLE_texture_format_BGRA8888" supported="gles1|gles2">
+            <require>
+                <enum name="GL_BGRA_EXT"/>
+            </require>
+            <require comment="Depends on TexStorage* (EXT_texture_storage / ES 3.0 / GL 4.4 / etc.)">
+                <enum name="GL_BGRA8_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_texture_max_level" supported="gles1|gles2">
+            <require>
+                <enum name="GL_TEXTURE_MAX_LEVEL_APPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_texture_range" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_RANGE_LENGTH_APPLE"/>
+                <enum name="GL_TEXTURE_RANGE_POINTER_APPLE"/>
+                <enum name="GL_TEXTURE_STORAGE_HINT_APPLE"/>
+                <enum name="GL_STORAGE_PRIVATE_APPLE"/>
+                <enum name="GL_STORAGE_CACHED_APPLE"/>
+                <enum name="GL_STORAGE_SHARED_APPLE"/>
+                <command name="glTextureRangeAPPLE"/>
+                <command name="glGetTexParameterPointervAPPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_transform_hint" supported="gl">
+            <require>
+                <enum name="GL_TRANSFORM_HINT_APPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_vertex_array_object" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_ARRAY_BINDING_APPLE"/>
+                <command name="glBindVertexArrayAPPLE"/>
+                <command name="glDeleteVertexArraysAPPLE"/>
+                <command name="glGenVertexArraysAPPLE"/>
+                <command name="glIsVertexArrayAPPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_vertex_array_range" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_ARRAY_RANGE_APPLE"/>
+                <enum name="GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE"/>
+                <enum name="GL_VERTEX_ARRAY_STORAGE_HINT_APPLE"/>
+                <enum name="GL_VERTEX_ARRAY_RANGE_POINTER_APPLE"/>
+                <enum name="GL_STORAGE_CLIENT_APPLE"/>
+                <enum name="GL_STORAGE_CACHED_APPLE"/>
+                <enum name="GL_STORAGE_SHARED_APPLE"/>
+                <command name="glVertexArrayRangeAPPLE"/>
+                <command name="glFlushVertexArrayRangeAPPLE"/>
+                <command name="glVertexArrayParameteriAPPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_vertex_program_evaluators" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_ATTRIB_MAP1_APPLE"/>
+                <enum name="GL_VERTEX_ATTRIB_MAP2_APPLE"/>
+                <enum name="GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE"/>
+                <enum name="GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE"/>
+                <enum name="GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE"/>
+                <enum name="GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE"/>
+                <enum name="GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE"/>
+                <enum name="GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE"/>
+                <enum name="GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE"/>
+                <enum name="GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE"/>
+                <command name="glEnableVertexAttribAPPLE"/>
+                <command name="glDisableVertexAttribAPPLE"/>
+                <command name="glIsVertexAttribEnabledAPPLE"/>
+                <command name="glMapVertexAttrib1dAPPLE"/>
+                <command name="glMapVertexAttrib1fAPPLE"/>
+                <command name="glMapVertexAttrib2dAPPLE"/>
+                <command name="glMapVertexAttrib2fAPPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_APPLE_ycbcr_422" supported="gl">
+            <require>
+                <enum name="GL_YCBCR_422_APPLE"/>
+                <enum name="GL_UNSIGNED_SHORT_8_8_APPLE"/>
+                <enum name="GL_UNSIGNED_SHORT_8_8_REV_APPLE"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_ES2_compatibility" supported="gl|glcore">
+            <require>
+                <enum name="GL_FIXED"/>
+                <enum name="GL_IMPLEMENTATION_COLOR_READ_TYPE"/>
+                <enum name="GL_IMPLEMENTATION_COLOR_READ_FORMAT"/>
+                <enum name="GL_LOW_FLOAT"/>
+                <enum name="GL_MEDIUM_FLOAT"/>
+                <enum name="GL_HIGH_FLOAT"/>
+                <enum name="GL_LOW_INT"/>
+                <enum name="GL_MEDIUM_INT"/>
+                <enum name="GL_HIGH_INT"/>
+                <enum name="GL_SHADER_COMPILER"/>
+                <enum name="GL_SHADER_BINARY_FORMATS"/>
+                <enum name="GL_NUM_SHADER_BINARY_FORMATS"/>
+                <enum name="GL_MAX_VERTEX_UNIFORM_VECTORS"/>
+                <enum name="GL_MAX_VARYING_VECTORS"/>
+                <enum name="GL_MAX_FRAGMENT_UNIFORM_VECTORS"/>
+                <enum name="GL_RGB565"/>
+                <command name="glReleaseShaderCompiler"/>
+                <command name="glShaderBinary"/>
+                <command name="glGetShaderPrecisionFormat"/>
+                <command name="glDepthRangef"/>
+                <command name="glClearDepthf"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_ES3_compatibility" supported="gl|glcore">
+            <require>
+                <enum name="GL_COMPRESSED_RGB8_ETC2"/>
+                <enum name="GL_COMPRESSED_SRGB8_ETC2"/>
+                <enum name="GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2"/>
+                <enum name="GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2"/>
+                <enum name="GL_COMPRESSED_RGBA8_ETC2_EAC"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"/>
+                <enum name="GL_COMPRESSED_R11_EAC"/>
+                <enum name="GL_COMPRESSED_SIGNED_R11_EAC"/>
+                <enum name="GL_COMPRESSED_RG11_EAC"/>
+                <enum name="GL_COMPRESSED_SIGNED_RG11_EAC"/>
+                <enum name="GL_PRIMITIVE_RESTART_FIXED_INDEX"/>
+                <enum name="GL_ANY_SAMPLES_PASSED_CONSERVATIVE"/>
+                <enum name="GL_MAX_ELEMENT_INDEX"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_arrays_of_arrays" supported="gl|glcore"/>
+        <extension name="GL_ARB_base_instance" supported="gl|glcore">
+            <require>
+                <command name="glDrawArraysInstancedBaseInstance"/>
+                <command name="glDrawElementsInstancedBaseInstance"/>
+                <command name="glDrawElementsInstancedBaseVertexBaseInstance"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_bindless_texture" supported="gl|glcore">
+            <require>
+                <enum name="GL_UNSIGNED_INT64_ARB"/>
+                <command name="glGetTextureHandleARB"/>
+                <command name="glGetTextureSamplerHandleARB"/>
+                <command name="glMakeTextureHandleResidentARB"/>
+                <command name="glMakeTextureHandleNonResidentARB"/>
+                <command name="glGetImageHandleARB"/>
+                <command name="glMakeImageHandleResidentARB"/>
+                <command name="glMakeImageHandleNonResidentARB"/>
+                <command name="glUniformHandleui64ARB"/>
+                <command name="glUniformHandleui64vARB"/>
+                <command name="glProgramUniformHandleui64ARB"/>
+                <command name="glProgramUniformHandleui64vARB"/>
+                <command name="glIsTextureHandleResidentARB"/>
+                <command name="glIsImageHandleResidentARB"/>
+                <command name="glVertexAttribL1ui64ARB"/>
+                <command name="glVertexAttribL1ui64vARB"/>
+                <command name="glGetVertexAttribLui64vARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_blend_func_extended" supported="gl|glcore">
+            <require>
+                <enum name="GL_SRC1_COLOR"/>
+                <enum name="GL_SRC1_ALPHA"/>
+                <enum name="GL_ONE_MINUS_SRC1_COLOR"/>
+                <enum name="GL_ONE_MINUS_SRC1_ALPHA"/>
+                <enum name="GL_MAX_DUAL_SOURCE_DRAW_BUFFERS"/>
+                <command name="glBindFragDataLocationIndexed"/>
+                <command name="glGetFragDataIndex"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_buffer_storage" supported="gl|glcore">
+            <require>
+                <enum name="GL_MAP_READ_BIT"/>
+                <enum name="GL_MAP_WRITE_BIT"/>
+                <enum name="GL_MAP_PERSISTENT_BIT"/>
+                <enum name="GL_MAP_COHERENT_BIT"/>
+                <enum name="GL_DYNAMIC_STORAGE_BIT"/>
+                <enum name="GL_CLIENT_STORAGE_BIT"/>
+                <enum name="GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT"/>
+                <enum name="GL_BUFFER_IMMUTABLE_STORAGE"/>
+                <enum name="GL_BUFFER_STORAGE_FLAGS"/>
+                <command name="glBufferStorage"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_cl_event" supported="gl|glcore">
+            <require>
+                <enum name="GL_SYNC_CL_EVENT_ARB"/>
+                <enum name="GL_SYNC_CL_EVENT_COMPLETE_ARB"/>
+                <command name="glCreateSyncFromCLeventARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_clear_buffer_object" supported="gl|glcore">
+            <require>
+                <command name="glClearBufferData"/>
+                <command name="glClearBufferSubData"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_clear_texture" supported="gl|glcore">
+            <require>
+                <enum name="GL_CLEAR_TEXTURE"/>
+                <command name="glClearTexImage"/>
+                <command name="glClearTexSubImage"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_color_buffer_float" supported="gl">
+            <require>
+                <enum name="GL_RGBA_FLOAT_MODE_ARB"/>
+                <enum name="GL_CLAMP_VERTEX_COLOR_ARB"/>
+                <enum name="GL_CLAMP_FRAGMENT_COLOR_ARB"/>
+                <enum name="GL_CLAMP_READ_COLOR_ARB"/>
+                <enum name="GL_FIXED_ONLY_ARB"/>
+                <command name="glClampColorARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_compatibility" supported="gl">
+            <require comment="Defines features from OpenGL 3.0 that were removed in OpenGL 3.1 - not enumerated here yet">
+            </require>
+        </extension>
+        <extension name="GL_ARB_compressed_texture_pixel_storage" supported="gl|glcore">
+            <require>
+                <enum name="GL_UNPACK_COMPRESSED_BLOCK_WIDTH"/>
+                <enum name="GL_UNPACK_COMPRESSED_BLOCK_HEIGHT"/>
+                <enum name="GL_UNPACK_COMPRESSED_BLOCK_DEPTH"/>
+                <enum name="GL_UNPACK_COMPRESSED_BLOCK_SIZE"/>
+                <enum name="GL_PACK_COMPRESSED_BLOCK_WIDTH"/>
+                <enum name="GL_PACK_COMPRESSED_BLOCK_HEIGHT"/>
+                <enum name="GL_PACK_COMPRESSED_BLOCK_DEPTH"/>
+                <enum name="GL_PACK_COMPRESSED_BLOCK_SIZE"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_compute_shader" supported="gl|glcore">
+            <require>
+                <enum name="GL_COMPUTE_SHADER"/>
+                <enum name="GL_MAX_COMPUTE_UNIFORM_BLOCKS"/>
+                <enum name="GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS"/>
+                <enum name="GL_MAX_COMPUTE_IMAGE_UNIFORMS"/>
+                <enum name="GL_MAX_COMPUTE_SHARED_MEMORY_SIZE"/>
+                <enum name="GL_MAX_COMPUTE_UNIFORM_COMPONENTS"/>
+                <enum name="GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS"/>
+                <enum name="GL_MAX_COMPUTE_ATOMIC_COUNTERS"/>
+                <enum name="GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS"/>
+                <enum name="GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS"/>
+                <enum name="GL_MAX_COMPUTE_WORK_GROUP_COUNT"/>
+                <enum name="GL_MAX_COMPUTE_WORK_GROUP_SIZE"/>
+                <enum name="GL_COMPUTE_WORK_GROUP_SIZE"/>
+                <enum name="GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER"/>
+                <enum name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER"/>
+                <enum name="GL_DISPATCH_INDIRECT_BUFFER"/>
+                <enum name="GL_DISPATCH_INDIRECT_BUFFER_BINDING"/>
+                <enum name="GL_COMPUTE_SHADER_BIT"/>
+                <command name="glDispatchCompute"/>
+                <command name="glDispatchComputeIndirect"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_compute_variable_group_size" supported="gl|glcore">
+            <require>
+                <enum name="GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB"/>
+                <enum name="GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB"/>
+                <enum name="GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB"/>
+                <enum name="GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB"/>
+                <command name="glDispatchComputeGroupSizeARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_conservative_depth" supported="gl|glcore"/>
+        <extension name="GL_ARB_copy_buffer" supported="gl|glcore">
+            <require>
+                <enum name="GL_COPY_READ_BUFFER_BINDING"/>
+                <enum name="GL_COPY_READ_BUFFER"/>
+                <enum name="GL_COPY_WRITE_BUFFER_BINDING"/>
+                <enum name="GL_COPY_WRITE_BUFFER"/>
+                <command name="glCopyBufferSubData"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_copy_image" supported="gl|glcore">
+            <require>
+                <command name="glCopyImageSubData"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_debug_output" supported="gl|glcore">
+            <require>
+                <enum name="GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB"/>
+                <enum name="GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB"/>
+                <enum name="GL_DEBUG_CALLBACK_FUNCTION_ARB"/>
+                <enum name="GL_DEBUG_CALLBACK_USER_PARAM_ARB"/>
+                <enum name="GL_DEBUG_SOURCE_API_ARB"/>
+                <enum name="GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB"/>
+                <enum name="GL_DEBUG_SOURCE_SHADER_COMPILER_ARB"/>
+                <enum name="GL_DEBUG_SOURCE_THIRD_PARTY_ARB"/>
+                <enum name="GL_DEBUG_SOURCE_APPLICATION_ARB"/>
+                <enum name="GL_DEBUG_SOURCE_OTHER_ARB"/>
+                <enum name="GL_DEBUG_TYPE_ERROR_ARB"/>
+                <enum name="GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB"/>
+                <enum name="GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB"/>
+                <enum name="GL_DEBUG_TYPE_PORTABILITY_ARB"/>
+                <enum name="GL_DEBUG_TYPE_PERFORMANCE_ARB"/>
+                <enum name="GL_DEBUG_TYPE_OTHER_ARB"/>
+                <enum name="GL_MAX_DEBUG_MESSAGE_LENGTH_ARB"/>
+                <enum name="GL_MAX_DEBUG_LOGGED_MESSAGES_ARB"/>
+                <enum name="GL_DEBUG_LOGGED_MESSAGES_ARB"/>
+                <enum name="GL_DEBUG_SEVERITY_HIGH_ARB"/>
+                <enum name="GL_DEBUG_SEVERITY_MEDIUM_ARB"/>
+                <enum name="GL_DEBUG_SEVERITY_LOW_ARB"/>
+                <command name="glDebugMessageControlARB"/>
+                <command name="glDebugMessageInsertARB"/>
+                <command name="glDebugMessageCallbackARB"/>
+                <command name="glGetDebugMessageLogARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_depth_buffer_float" supported="gl|glcore">
+            <require>
+                <enum name="GL_DEPTH_COMPONENT32F"/>
+                <enum name="GL_DEPTH32F_STENCIL8"/>
+                <enum name="GL_FLOAT_32_UNSIGNED_INT_24_8_REV"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_depth_clamp" supported="gl|glcore">
+            <require>
+                <enum name="GL_DEPTH_CLAMP"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_depth_texture" supported="gl">
+            <require>
+                <enum name="GL_DEPTH_COMPONENT16_ARB"/>
+                <enum name="GL_DEPTH_COMPONENT24_ARB"/>
+                <enum name="GL_DEPTH_COMPONENT32_ARB"/>
+                <enum name="GL_TEXTURE_DEPTH_SIZE_ARB"/>
+                <enum name="GL_DEPTH_TEXTURE_MODE_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_draw_buffers" supported="gl">
+            <require>
+                <enum name="GL_MAX_DRAW_BUFFERS_ARB"/>
+                <enum name="GL_DRAW_BUFFER0_ARB"/>
+                <enum name="GL_DRAW_BUFFER1_ARB"/>
+                <enum name="GL_DRAW_BUFFER2_ARB"/>
+                <enum name="GL_DRAW_BUFFER3_ARB"/>
+                <enum name="GL_DRAW_BUFFER4_ARB"/>
+                <enum name="GL_DRAW_BUFFER5_ARB"/>
+                <enum name="GL_DRAW_BUFFER6_ARB"/>
+                <enum name="GL_DRAW_BUFFER7_ARB"/>
+                <enum name="GL_DRAW_BUFFER8_ARB"/>
+                <enum name="GL_DRAW_BUFFER9_ARB"/>
+                <enum name="GL_DRAW_BUFFER10_ARB"/>
+                <enum name="GL_DRAW_BUFFER11_ARB"/>
+                <enum name="GL_DRAW_BUFFER12_ARB"/>
+                <enum name="GL_DRAW_BUFFER13_ARB"/>
+                <enum name="GL_DRAW_BUFFER14_ARB"/>
+                <enum name="GL_DRAW_BUFFER15_ARB"/>
+                <command name="glDrawBuffersARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_draw_buffers_blend" supported="gl|glcore">
+            <require>
+                <command name="glBlendEquationiARB"/>
+                <command name="glBlendEquationSeparateiARB"/>
+                <command name="glBlendFunciARB"/>
+                <command name="glBlendFuncSeparateiARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_draw_elements_base_vertex" supported="gl|glcore">
+            <require>
+                <command name="glDrawElementsBaseVertex"/>
+                <command name="glDrawRangeElementsBaseVertex"/>
+                <command name="glDrawElementsInstancedBaseVertex"/>
+                <command name="glMultiDrawElementsBaseVertex"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_draw_indirect" supported="gl|glcore">
+            <require>
+                <enum name="GL_DRAW_INDIRECT_BUFFER"/>
+                <enum name="GL_DRAW_INDIRECT_BUFFER_BINDING"/>
+                <command name="glDrawArraysIndirect"/>
+                <command name="glDrawElementsIndirect"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_draw_instanced" supported="gl">
+            <require>
+                <command name="glDrawArraysInstancedARB"/>
+                <command name="glDrawElementsInstancedARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_enhanced_layouts" supported="gl|glcore">
+            <require>
+                <enum name="GL_LOCATION_COMPONENT"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_INDEX"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_explicit_attrib_location" supported="gl|glcore"/>
+        <extension name="GL_ARB_explicit_uniform_location" supported="gl|glcore">
+            <require>
+                <enum name="GL_MAX_UNIFORM_LOCATIONS"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_fragment_coord_conventions" supported="gl|glcore"/>
+        <extension name="GL_ARB_fragment_layer_viewport" supported="gl|glcore"/>
+        <extension name="GL_ARB_fragment_program" supported="gl">
+            <require>
+                <enum name="GL_FRAGMENT_PROGRAM_ARB"/>
+                <enum name="GL_PROGRAM_FORMAT_ASCII_ARB"/>
+                <enum name="GL_PROGRAM_LENGTH_ARB"/>
+                <enum name="GL_PROGRAM_FORMAT_ARB"/>
+                <enum name="GL_PROGRAM_BINDING_ARB"/>
+                <enum name="GL_PROGRAM_INSTRUCTIONS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_INSTRUCTIONS_ARB"/>
+                <enum name="GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB"/>
+                <enum name="GL_PROGRAM_TEMPORARIES_ARB"/>
+                <enum name="GL_MAX_PROGRAM_TEMPORARIES_ARB"/>
+                <enum name="GL_PROGRAM_NATIVE_TEMPORARIES_ARB"/>
+                <enum name="GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB"/>
+                <enum name="GL_PROGRAM_PARAMETERS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_PARAMETERS_ARB"/>
+                <enum name="GL_PROGRAM_NATIVE_PARAMETERS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB"/>
+                <enum name="GL_PROGRAM_ATTRIBS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_ATTRIBS_ARB"/>
+                <enum name="GL_PROGRAM_NATIVE_ATTRIBS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_ENV_PARAMETERS_ARB"/>
+                <enum name="GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB"/>
+                <enum name="GL_PROGRAM_ALU_INSTRUCTIONS_ARB"/>
+                <enum name="GL_PROGRAM_TEX_INSTRUCTIONS_ARB"/>
+                <enum name="GL_PROGRAM_TEX_INDIRECTIONS_ARB"/>
+                <enum name="GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB"/>
+                <enum name="GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB"/>
+                <enum name="GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB"/>
+                <enum name="GL_PROGRAM_STRING_ARB"/>
+                <enum name="GL_PROGRAM_ERROR_POSITION_ARB"/>
+                <enum name="GL_CURRENT_MATRIX_ARB"/>
+                <enum name="GL_TRANSPOSE_CURRENT_MATRIX_ARB"/>
+                <enum name="GL_CURRENT_MATRIX_STACK_DEPTH_ARB"/>
+                <enum name="GL_MAX_PROGRAM_MATRICES_ARB"/>
+                <enum name="GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB"/>
+                <enum name="GL_MAX_TEXTURE_COORDS_ARB"/>
+                <enum name="GL_MAX_TEXTURE_IMAGE_UNITS_ARB"/>
+                <enum name="GL_PROGRAM_ERROR_STRING_ARB"/>
+                <enum name="GL_MATRIX0_ARB"/>
+                <enum name="GL_MATRIX1_ARB"/>
+                <enum name="GL_MATRIX2_ARB"/>
+                <enum name="GL_MATRIX3_ARB"/>
+                <enum name="GL_MATRIX4_ARB"/>
+                <enum name="GL_MATRIX5_ARB"/>
+                <enum name="GL_MATRIX6_ARB"/>
+                <enum name="GL_MATRIX7_ARB"/>
+                <enum name="GL_MATRIX8_ARB"/>
+                <enum name="GL_MATRIX9_ARB"/>
+                <enum name="GL_MATRIX10_ARB"/>
+                <enum name="GL_MATRIX11_ARB"/>
+                <enum name="GL_MATRIX12_ARB"/>
+                <enum name="GL_MATRIX13_ARB"/>
+                <enum name="GL_MATRIX14_ARB"/>
+                <enum name="GL_MATRIX15_ARB"/>
+                <enum name="GL_MATRIX16_ARB"/>
+                <enum name="GL_MATRIX17_ARB"/>
+                <enum name="GL_MATRIX18_ARB"/>
+                <enum name="GL_MATRIX19_ARB"/>
+                <enum name="GL_MATRIX20_ARB"/>
+                <enum name="GL_MATRIX21_ARB"/>
+                <enum name="GL_MATRIX22_ARB"/>
+                <enum name="GL_MATRIX23_ARB"/>
+                <enum name="GL_MATRIX24_ARB"/>
+                <enum name="GL_MATRIX25_ARB"/>
+                <enum name="GL_MATRIX26_ARB"/>
+                <enum name="GL_MATRIX27_ARB"/>
+                <enum name="GL_MATRIX28_ARB"/>
+                <enum name="GL_MATRIX29_ARB"/>
+                <enum name="GL_MATRIX30_ARB"/>
+                <enum name="GL_MATRIX31_ARB"/>
+            </require>
+            <require comment="Shared with ARB_vertex_program">
+                <command name="glProgramStringARB"/>
+                <command name="glBindProgramARB"/>
+                <command name="glDeleteProgramsARB"/>
+                <command name="glGenProgramsARB"/>
+                <command name="glProgramEnvParameter4dARB"/>
+                <command name="glProgramEnvParameter4dvARB"/>
+                <command name="glProgramEnvParameter4fARB"/>
+                <command name="glProgramEnvParameter4fvARB"/>
+                <command name="glProgramLocalParameter4dARB"/>
+                <command name="glProgramLocalParameter4dvARB"/>
+                <command name="glProgramLocalParameter4fARB"/>
+                <command name="glProgramLocalParameter4fvARB"/>
+                <command name="glGetProgramEnvParameterdvARB"/>
+                <command name="glGetProgramEnvParameterfvARB"/>
+                <command name="glGetProgramLocalParameterdvARB"/>
+                <command name="glGetProgramLocalParameterfvARB"/>
+                <command name="glGetProgramivARB"/>
+                <command name="glGetProgramStringARB"/>
+                <command name="glIsProgramARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_fragment_program_shadow" supported="gl"/>
+        <extension name="GL_ARB_fragment_shader" supported="gl">
+            <require>
+                <enum name="GL_FRAGMENT_SHADER_ARB"/>
+                <enum name="GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB"/>
+                <enum name="GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_framebuffer_no_attachments" supported="gl|glcore">
+            <require>
+                <enum name="GL_FRAMEBUFFER_DEFAULT_WIDTH"/>
+                <enum name="GL_FRAMEBUFFER_DEFAULT_HEIGHT"/>
+                <enum name="GL_FRAMEBUFFER_DEFAULT_LAYERS"/>
+                <enum name="GL_FRAMEBUFFER_DEFAULT_SAMPLES"/>
+                <enum name="GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS"/>
+                <enum name="GL_MAX_FRAMEBUFFER_WIDTH"/>
+                <enum name="GL_MAX_FRAMEBUFFER_HEIGHT"/>
+                <enum name="GL_MAX_FRAMEBUFFER_LAYERS"/>
+                <enum name="GL_MAX_FRAMEBUFFER_SAMPLES"/>
+                <command name="glFramebufferParameteri"/>
+                <command name="glGetFramebufferParameteriv"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_framebuffer_object" supported="gl|glcore">
+            <require>
+                <enum name="GL_INVALID_FRAMEBUFFER_OPERATION"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE"/>
+                <enum name="GL_FRAMEBUFFER_DEFAULT"/>
+                <enum name="GL_FRAMEBUFFER_UNDEFINED"/>
+                <enum name="GL_DEPTH_STENCIL_ATTACHMENT"/>
+                <enum name="GL_MAX_RENDERBUFFER_SIZE"/>
+                <enum name="GL_DEPTH_STENCIL"/>
+                <enum name="GL_UNSIGNED_INT_24_8"/>
+                <enum name="GL_DEPTH24_STENCIL8"/>
+                <enum name="GL_TEXTURE_STENCIL_SIZE"/>
+                <enum name="GL_TEXTURE_RED_TYPE"/>
+                <enum name="GL_TEXTURE_GREEN_TYPE"/>
+                <enum name="GL_TEXTURE_BLUE_TYPE"/>
+                <enum name="GL_TEXTURE_ALPHA_TYPE"/>
+                <enum name="GL_TEXTURE_DEPTH_TYPE"/>
+                <enum name="GL_UNSIGNED_NORMALIZED"/>
+                <enum name="GL_FRAMEBUFFER_BINDING"/>
+                <enum name="GL_DRAW_FRAMEBUFFER_BINDING"/>
+                <enum name="GL_RENDERBUFFER_BINDING"/>
+                <enum name="GL_READ_FRAMEBUFFER"/>
+                <enum name="GL_DRAW_FRAMEBUFFER"/>
+                <enum name="GL_READ_FRAMEBUFFER_BINDING"/>
+                <enum name="GL_RENDERBUFFER_SAMPLES"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER"/>
+                <enum name="GL_FRAMEBUFFER_COMPLETE"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER"/>
+                <enum name="GL_FRAMEBUFFER_UNSUPPORTED"/>
+                <enum name="GL_MAX_COLOR_ATTACHMENTS"/>
+                <enum name="GL_COLOR_ATTACHMENT0"/>
+                <enum name="GL_COLOR_ATTACHMENT1"/>
+                <enum name="GL_COLOR_ATTACHMENT2"/>
+                <enum name="GL_COLOR_ATTACHMENT3"/>
+                <enum name="GL_COLOR_ATTACHMENT4"/>
+                <enum name="GL_COLOR_ATTACHMENT5"/>
+                <enum name="GL_COLOR_ATTACHMENT6"/>
+                <enum name="GL_COLOR_ATTACHMENT7"/>
+                <enum name="GL_COLOR_ATTACHMENT8"/>
+                <enum name="GL_COLOR_ATTACHMENT9"/>
+                <enum name="GL_COLOR_ATTACHMENT10"/>
+                <enum name="GL_COLOR_ATTACHMENT11"/>
+                <enum name="GL_COLOR_ATTACHMENT12"/>
+                <enum name="GL_COLOR_ATTACHMENT13"/>
+                <enum name="GL_COLOR_ATTACHMENT14"/>
+                <enum name="GL_COLOR_ATTACHMENT15"/>
+                <enum name="GL_DEPTH_ATTACHMENT"/>
+                <enum name="GL_STENCIL_ATTACHMENT"/>
+                <enum name="GL_FRAMEBUFFER"/>
+                <enum name="GL_RENDERBUFFER"/>
+                <enum name="GL_RENDERBUFFER_WIDTH"/>
+                <enum name="GL_RENDERBUFFER_HEIGHT"/>
+                <enum name="GL_RENDERBUFFER_INTERNAL_FORMAT"/>
+                <enum name="GL_STENCIL_INDEX1"/>
+                <enum name="GL_STENCIL_INDEX4"/>
+                <enum name="GL_STENCIL_INDEX8"/>
+                <enum name="GL_STENCIL_INDEX16"/>
+                <enum name="GL_RENDERBUFFER_RED_SIZE"/>
+                <enum name="GL_RENDERBUFFER_GREEN_SIZE"/>
+                <enum name="GL_RENDERBUFFER_BLUE_SIZE"/>
+                <enum name="GL_RENDERBUFFER_ALPHA_SIZE"/>
+                <enum name="GL_RENDERBUFFER_DEPTH_SIZE"/>
+                <enum name="GL_RENDERBUFFER_STENCIL_SIZE"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"/>
+                <enum name="GL_MAX_SAMPLES"/>
+                <command name="glIsRenderbuffer"/>
+                <command name="glBindRenderbuffer"/>
+                <command name="glDeleteRenderbuffers"/>
+                <command name="glGenRenderbuffers"/>
+                <command name="glRenderbufferStorage"/>
+                <command name="glGetRenderbufferParameteriv"/>
+                <command name="glIsFramebuffer"/>
+                <command name="glBindFramebuffer"/>
+                <command name="glDeleteFramebuffers"/>
+                <command name="glGenFramebuffers"/>
+                <command name="glCheckFramebufferStatus"/>
+                <command name="glFramebufferTexture1D"/>
+                <command name="glFramebufferTexture2D"/>
+                <command name="glFramebufferTexture3D"/>
+                <command name="glFramebufferRenderbuffer"/>
+                <command name="glGetFramebufferAttachmentParameteriv"/>
+                <command name="glGenerateMipmap"/>
+                <command name="glBlitFramebuffer"/>
+                <command name="glRenderbufferStorageMultisample"/>
+                <command name="glFramebufferTextureLayer"/>
+            </require>
+            <require api="gl" profile="compatibility">
+                <enum name="GL_INDEX"/>
+                <enum name="GL_TEXTURE_LUMINANCE_TYPE"/>
+                <enum name="GL_TEXTURE_INTENSITY_TYPE"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_framebuffer_sRGB" supported="gl|glcore">
+            <require>
+                <enum name="GL_FRAMEBUFFER_SRGB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_geometry_shader4" supported="gl">
+            <require>
+                <enum name="GL_LINES_ADJACENCY_ARB"/>
+                <enum name="GL_LINE_STRIP_ADJACENCY_ARB"/>
+                <enum name="GL_TRIANGLES_ADJACENCY_ARB"/>
+                <enum name="GL_TRIANGLE_STRIP_ADJACENCY_ARB"/>
+                <enum name="GL_PROGRAM_POINT_SIZE_ARB"/>
+                <enum name="GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB"/>
+                <enum name="GL_GEOMETRY_SHADER_ARB"/>
+                <enum name="GL_GEOMETRY_VERTICES_OUT_ARB"/>
+                <enum name="GL_GEOMETRY_INPUT_TYPE_ARB"/>
+                <enum name="GL_GEOMETRY_OUTPUT_TYPE_ARB"/>
+                <enum name="GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB"/>
+                <enum name="GL_MAX_VERTEX_VARYING_COMPONENTS_ARB"/>
+                <enum name="GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB"/>
+                <enum name="GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB"/>
+                <enum name="GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB"/>
+                <enum name="GL_MAX_VARYING_COMPONENTS"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER"/>
+                <command name="glProgramParameteriARB"/>
+                <command name="glFramebufferTextureARB"/>
+                <command name="glFramebufferTextureLayerARB"/>
+                <command name="glFramebufferTextureFaceARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_get_program_binary" supported="gl|glcore">
+            <require>
+                <enum name="GL_PROGRAM_BINARY_RETRIEVABLE_HINT"/>
+                <enum name="GL_PROGRAM_BINARY_LENGTH"/>
+                <enum name="GL_NUM_PROGRAM_BINARY_FORMATS"/>
+                <enum name="GL_PROGRAM_BINARY_FORMATS"/>
+                <command name="glGetProgramBinary"/>
+                <command name="glProgramBinary"/>
+                <command name="glProgramParameteri"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_gpu_shader5" supported="gl|glcore">
+            <require>
+                <enum name="GL_GEOMETRY_SHADER_INVOCATIONS"/>
+                <enum name="GL_MAX_GEOMETRY_SHADER_INVOCATIONS"/>
+                <enum name="GL_MIN_FRAGMENT_INTERPOLATION_OFFSET"/>
+                <enum name="GL_MAX_FRAGMENT_INTERPOLATION_OFFSET"/>
+                <enum name="GL_FRAGMENT_INTERPOLATION_OFFSET_BITS"/>
+                <enum name="GL_MAX_VERTEX_STREAMS"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_gpu_shader_fp64" supported="gl|glcore">
+            <require>
+                <enum name="GL_DOUBLE"/>
+                <enum name="GL_DOUBLE_VEC2"/>
+                <enum name="GL_DOUBLE_VEC3"/>
+                <enum name="GL_DOUBLE_VEC4"/>
+                <enum name="GL_DOUBLE_MAT2"/>
+                <enum name="GL_DOUBLE_MAT3"/>
+                <enum name="GL_DOUBLE_MAT4"/>
+                <enum name="GL_DOUBLE_MAT2x3"/>
+                <enum name="GL_DOUBLE_MAT2x4"/>
+                <enum name="GL_DOUBLE_MAT3x2"/>
+                <enum name="GL_DOUBLE_MAT3x4"/>
+                <enum name="GL_DOUBLE_MAT4x2"/>
+                <enum name="GL_DOUBLE_MAT4x3"/>
+                <command name="glUniform1d"/>
+                <command name="glUniform2d"/>
+                <command name="glUniform3d"/>
+                <command name="glUniform4d"/>
+                <command name="glUniform1dv"/>
+                <command name="glUniform2dv"/>
+                <command name="glUniform3dv"/>
+                <command name="glUniform4dv"/>
+                <command name="glUniformMatrix2dv"/>
+                <command name="glUniformMatrix3dv"/>
+                <command name="glUniformMatrix4dv"/>
+                <command name="glUniformMatrix2x3dv"/>
+                <command name="glUniformMatrix2x4dv"/>
+                <command name="glUniformMatrix3x2dv"/>
+                <command name="glUniformMatrix3x4dv"/>
+                <command name="glUniformMatrix4x2dv"/>
+                <command name="glUniformMatrix4x3dv"/>
+                <command name="glGetUniformdv"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_half_float_pixel" supported="gl">
+            <require>
+                <type name="GLhalfARB"/>
+                <enum name="GL_HALF_FLOAT_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_half_float_vertex" supported="gl|glcore">
+            <require>
+                <type name="GLhalf"/>
+                <enum name="GL_HALF_FLOAT"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_imaging" supported="gl|glcore" comment="Now treating ARB_imaging as an extension, not a GL API version">
+            <require>
+                <enum name="GL_CONSTANT_COLOR"/>
+                <enum name="GL_ONE_MINUS_CONSTANT_COLOR"/>
+                <enum name="GL_CONSTANT_ALPHA"/>
+                <enum name="GL_ONE_MINUS_CONSTANT_ALPHA"/>
+                <enum name="GL_BLEND_COLOR"/>
+                <enum name="GL_FUNC_ADD"/>
+                <enum name="GL_MIN"/>
+                <enum name="GL_MAX"/>
+                <enum name="GL_BLEND_EQUATION"/>
+                <enum name="GL_FUNC_SUBTRACT"/>
+                <enum name="GL_FUNC_REVERSE_SUBTRACT"/>
+                <command name="glBlendColor"/>
+                <command name="glBlendEquation"/>
+            </require>
+            <require api="gl" profile="compatibility">
+                <enum name="GL_CONVOLUTION_1D"/>
+                <enum name="GL_CONVOLUTION_2D"/>
+                <enum name="GL_SEPARABLE_2D"/>
+                <enum name="GL_CONVOLUTION_BORDER_MODE"/>
+                <enum name="GL_CONVOLUTION_FILTER_SCALE"/>
+                <enum name="GL_CONVOLUTION_FILTER_BIAS"/>
+                <enum name="GL_REDUCE"/>
+                <enum name="GL_CONVOLUTION_FORMAT"/>
+                <enum name="GL_CONVOLUTION_WIDTH"/>
+                <enum name="GL_CONVOLUTION_HEIGHT"/>
+                <enum name="GL_MAX_CONVOLUTION_WIDTH"/>
+                <enum name="GL_MAX_CONVOLUTION_HEIGHT"/>
+                <enum name="GL_POST_CONVOLUTION_RED_SCALE"/>
+                <enum name="GL_POST_CONVOLUTION_GREEN_SCALE"/>
+                <enum name="GL_POST_CONVOLUTION_BLUE_SCALE"/>
+                <enum name="GL_POST_CONVOLUTION_ALPHA_SCALE"/>
+                <enum name="GL_POST_CONVOLUTION_RED_BIAS"/>
+                <enum name="GL_POST_CONVOLUTION_GREEN_BIAS"/>
+                <enum name="GL_POST_CONVOLUTION_BLUE_BIAS"/>
+                <enum name="GL_POST_CONVOLUTION_ALPHA_BIAS"/>
+                <enum name="GL_HISTOGRAM"/>
+                <enum name="GL_PROXY_HISTOGRAM"/>
+                <enum name="GL_HISTOGRAM_WIDTH"/>
+                <enum name="GL_HISTOGRAM_FORMAT"/>
+                <enum name="GL_HISTOGRAM_RED_SIZE"/>
+                <enum name="GL_HISTOGRAM_GREEN_SIZE"/>
+                <enum name="GL_HISTOGRAM_BLUE_SIZE"/>
+                <enum name="GL_HISTOGRAM_ALPHA_SIZE"/>
+                <enum name="GL_HISTOGRAM_LUMINANCE_SIZE"/>
+                <enum name="GL_HISTOGRAM_SINK"/>
+                <enum name="GL_MINMAX"/>
+                <enum name="GL_MINMAX_FORMAT"/>
+                <enum name="GL_MINMAX_SINK"/>
+                <enum name="GL_TABLE_TOO_LARGE"/>
+                <enum name="GL_COLOR_MATRIX"/>
+                <enum name="GL_COLOR_MATRIX_STACK_DEPTH"/>
+                <enum name="GL_MAX_COLOR_MATRIX_STACK_DEPTH"/>
+                <enum name="GL_POST_COLOR_MATRIX_RED_SCALE"/>
+                <enum name="GL_POST_COLOR_MATRIX_GREEN_SCALE"/>
+                <enum name="GL_POST_COLOR_MATRIX_BLUE_SCALE"/>
+                <enum name="GL_POST_COLOR_MATRIX_ALPHA_SCALE"/>
+                <enum name="GL_POST_COLOR_MATRIX_RED_BIAS"/>
+                <enum name="GL_POST_COLOR_MATRIX_GREEN_BIAS"/>
+                <enum name="GL_POST_COLOR_MATRIX_BLUE_BIAS"/>
+                <enum name="GL_POST_COLOR_MATRIX_ALPHA_BIAS"/>
+                <enum name="GL_COLOR_TABLE"/>
+                <enum name="GL_POST_CONVOLUTION_COLOR_TABLE"/>
+                <enum name="GL_POST_COLOR_MATRIX_COLOR_TABLE"/>
+                <enum name="GL_PROXY_COLOR_TABLE"/>
+                <enum name="GL_PROXY_POST_CONVOLUTION_COLOR_TABLE"/>
+                <enum name="GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE"/>
+                <enum name="GL_COLOR_TABLE_SCALE"/>
+                <enum name="GL_COLOR_TABLE_BIAS"/>
+                <enum name="GL_COLOR_TABLE_FORMAT"/>
+                <enum name="GL_COLOR_TABLE_WIDTH"/>
+                <enum name="GL_COLOR_TABLE_RED_SIZE"/>
+                <enum name="GL_COLOR_TABLE_GREEN_SIZE"/>
+                <enum name="GL_COLOR_TABLE_BLUE_SIZE"/>
+                <enum name="GL_COLOR_TABLE_ALPHA_SIZE"/>
+                <enum name="GL_COLOR_TABLE_LUMINANCE_SIZE"/>
+                <enum name="GL_COLOR_TABLE_INTENSITY_SIZE"/>
+                <enum name="GL_CONSTANT_BORDER"/>
+                <enum name="GL_REPLICATE_BORDER"/>
+                <enum name="GL_CONVOLUTION_BORDER_COLOR"/>
+                <command name="glColorTable"/>
+                <command name="glColorTableParameterfv"/>
+                <command name="glColorTableParameteriv"/>
+                <command name="glCopyColorTable"/>
+                <command name="glGetColorTable"/>
+                <command name="glGetColorTableParameterfv"/>
+                <command name="glGetColorTableParameteriv"/>
+                <command name="glColorSubTable"/>
+                <command name="glCopyColorSubTable"/>
+                <command name="glConvolutionFilter1D"/>
+                <command name="glConvolutionFilter2D"/>
+                <command name="glConvolutionParameterf"/>
+                <command name="glConvolutionParameterfv"/>
+                <command name="glConvolutionParameteri"/>
+                <command name="glConvolutionParameteriv"/>
+                <command name="glCopyConvolutionFilter1D"/>
+                <command name="glCopyConvolutionFilter2D"/>
+                <command name="glGetConvolutionFilter"/>
+                <command name="glGetConvolutionParameterfv"/>
+                <command name="glGetConvolutionParameteriv"/>
+                <command name="glGetSeparableFilter"/>
+                <command name="glSeparableFilter2D"/>
+                <command name="glGetHistogram"/>
+                <command name="glGetHistogramParameterfv"/>
+                <command name="glGetHistogramParameteriv"/>
+                <command name="glGetMinmax"/>
+                <command name="glGetMinmaxParameterfv"/>
+                <command name="glGetMinmaxParameteriv"/>
+                <command name="glHistogram"/>
+                <command name="glMinmax"/>
+                <command name="glResetHistogram"/>
+                <command name="glResetMinmax"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_indirect_parameters" supported="gl|glcore">
+            <require>
+                <enum name="GL_PARAMETER_BUFFER_ARB"/>
+                <enum name="GL_PARAMETER_BUFFER_BINDING_ARB"/>
+                <command name="glMultiDrawArraysIndirectCountARB"/>
+                <command name="glMultiDrawElementsIndirectCountARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_instanced_arrays" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB"/>
+                <command name="glVertexAttribDivisorARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_internalformat_query" supported="gl|glcore">
+            <require>
+                <enum name="GL_NUM_SAMPLE_COUNTS"/>
+                <command name="glGetInternalformativ"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_internalformat_query2" supported="gl|glcore">
+            <require>
+                <enum name="GL_IMAGE_FORMAT_COMPATIBILITY_TYPE"/>
+                <enum name="GL_NUM_SAMPLE_COUNTS"/>
+                <enum name="GL_RENDERBUFFER"/>
+                <enum name="GL_SAMPLES"/>
+                <enum name="GL_TEXTURE_1D"/>
+                <enum name="GL_TEXTURE_1D_ARRAY"/>
+                <enum name="GL_TEXTURE_2D"/>
+                <enum name="GL_TEXTURE_2D_ARRAY"/>
+                <enum name="GL_TEXTURE_3D"/>
+                <enum name="GL_TEXTURE_CUBE_MAP"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_ARRAY"/>
+                <enum name="GL_TEXTURE_RECTANGLE"/>
+                <enum name="GL_TEXTURE_BUFFER"/>
+                <enum name="GL_TEXTURE_2D_MULTISAMPLE"/>
+                <enum name="GL_TEXTURE_2D_MULTISAMPLE_ARRAY"/>
+                <enum name="GL_TEXTURE_COMPRESSED"/>
+                <enum name="GL_INTERNALFORMAT_SUPPORTED"/>
+                <enum name="GL_INTERNALFORMAT_PREFERRED"/>
+                <enum name="GL_INTERNALFORMAT_RED_SIZE"/>
+                <enum name="GL_INTERNALFORMAT_GREEN_SIZE"/>
+                <enum name="GL_INTERNALFORMAT_BLUE_SIZE"/>
+                <enum name="GL_INTERNALFORMAT_ALPHA_SIZE"/>
+                <enum name="GL_INTERNALFORMAT_DEPTH_SIZE"/>
+                <enum name="GL_INTERNALFORMAT_STENCIL_SIZE"/>
+                <enum name="GL_INTERNALFORMAT_SHARED_SIZE"/>
+                <enum name="GL_INTERNALFORMAT_RED_TYPE"/>
+                <enum name="GL_INTERNALFORMAT_GREEN_TYPE"/>
+                <enum name="GL_INTERNALFORMAT_BLUE_TYPE"/>
+                <enum name="GL_INTERNALFORMAT_ALPHA_TYPE"/>
+                <enum name="GL_INTERNALFORMAT_DEPTH_TYPE"/>
+                <enum name="GL_INTERNALFORMAT_STENCIL_TYPE"/>
+                <enum name="GL_MAX_WIDTH"/>
+                <enum name="GL_MAX_HEIGHT"/>
+                <enum name="GL_MAX_DEPTH"/>
+                <enum name="GL_MAX_LAYERS"/>
+                <enum name="GL_MAX_COMBINED_DIMENSIONS"/>
+                <enum name="GL_COLOR_COMPONENTS"/>
+                <enum name="GL_DEPTH_COMPONENTS"/>
+                <enum name="GL_STENCIL_COMPONENTS"/>
+                <enum name="GL_COLOR_RENDERABLE"/>
+                <enum name="GL_DEPTH_RENDERABLE"/>
+                <enum name="GL_STENCIL_RENDERABLE"/>
+                <enum name="GL_FRAMEBUFFER_RENDERABLE"/>
+                <enum name="GL_FRAMEBUFFER_RENDERABLE_LAYERED"/>
+                <enum name="GL_FRAMEBUFFER_BLEND"/>
+                <enum name="GL_READ_PIXELS"/>
+                <enum name="GL_READ_PIXELS_FORMAT"/>
+                <enum name="GL_READ_PIXELS_TYPE"/>
+                <enum name="GL_TEXTURE_IMAGE_FORMAT"/>
+                <enum name="GL_TEXTURE_IMAGE_TYPE"/>
+                <enum name="GL_GET_TEXTURE_IMAGE_FORMAT"/>
+                <enum name="GL_GET_TEXTURE_IMAGE_TYPE"/>
+                <enum name="GL_MIPMAP"/>
+                <enum name="GL_MANUAL_GENERATE_MIPMAP"/>
+                <enum name="GL_AUTO_GENERATE_MIPMAP"/>
+                <enum name="GL_COLOR_ENCODING"/>
+                <enum name="GL_SRGB_READ"/>
+                <enum name="GL_SRGB_WRITE"/>
+                <enum name="GL_SRGB_DECODE_ARB"/>
+                <enum name="GL_FILTER"/>
+                <enum name="GL_VERTEX_TEXTURE"/>
+                <enum name="GL_TESS_CONTROL_TEXTURE"/>
+                <enum name="GL_TESS_EVALUATION_TEXTURE"/>
+                <enum name="GL_GEOMETRY_TEXTURE"/>
+                <enum name="GL_FRAGMENT_TEXTURE"/>
+                <enum name="GL_COMPUTE_TEXTURE"/>
+                <enum name="GL_TEXTURE_SHADOW"/>
+                <enum name="GL_TEXTURE_GATHER"/>
+                <enum name="GL_TEXTURE_GATHER_SHADOW"/>
+                <enum name="GL_SHADER_IMAGE_LOAD"/>
+                <enum name="GL_SHADER_IMAGE_STORE"/>
+                <enum name="GL_SHADER_IMAGE_ATOMIC"/>
+                <enum name="GL_IMAGE_TEXEL_SIZE"/>
+                <enum name="GL_IMAGE_COMPATIBILITY_CLASS"/>
+                <enum name="GL_IMAGE_PIXEL_FORMAT"/>
+                <enum name="GL_IMAGE_PIXEL_TYPE"/>
+                <enum name="GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST"/>
+                <enum name="GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST"/>
+                <enum name="GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE"/>
+                <enum name="GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE"/>
+                <enum name="GL_TEXTURE_COMPRESSED_BLOCK_WIDTH"/>
+                <enum name="GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT"/>
+                <enum name="GL_TEXTURE_COMPRESSED_BLOCK_SIZE"/>
+                <enum name="GL_CLEAR_BUFFER"/>
+                <enum name="GL_TEXTURE_VIEW"/>
+                <enum name="GL_VIEW_COMPATIBILITY_CLASS"/>
+                <enum name="GL_FULL_SUPPORT"/>
+                <enum name="GL_CAVEAT_SUPPORT"/>
+                <enum name="GL_IMAGE_CLASS_4_X_32"/>
+                <enum name="GL_IMAGE_CLASS_2_X_32"/>
+                <enum name="GL_IMAGE_CLASS_1_X_32"/>
+                <enum name="GL_IMAGE_CLASS_4_X_16"/>
+                <enum name="GL_IMAGE_CLASS_2_X_16"/>
+                <enum name="GL_IMAGE_CLASS_1_X_16"/>
+                <enum name="GL_IMAGE_CLASS_4_X_8"/>
+                <enum name="GL_IMAGE_CLASS_2_X_8"/>
+                <enum name="GL_IMAGE_CLASS_1_X_8"/>
+                <enum name="GL_IMAGE_CLASS_11_11_10"/>
+                <enum name="GL_IMAGE_CLASS_10_10_10_2"/>
+                <enum name="GL_VIEW_CLASS_128_BITS"/>
+                <enum name="GL_VIEW_CLASS_96_BITS"/>
+                <enum name="GL_VIEW_CLASS_64_BITS"/>
+                <enum name="GL_VIEW_CLASS_48_BITS"/>
+                <enum name="GL_VIEW_CLASS_32_BITS"/>
+                <enum name="GL_VIEW_CLASS_24_BITS"/>
+                <enum name="GL_VIEW_CLASS_16_BITS"/>
+                <enum name="GL_VIEW_CLASS_8_BITS"/>
+                <enum name="GL_VIEW_CLASS_S3TC_DXT1_RGB"/>
+                <enum name="GL_VIEW_CLASS_S3TC_DXT1_RGBA"/>
+                <enum name="GL_VIEW_CLASS_S3TC_DXT3_RGBA"/>
+                <enum name="GL_VIEW_CLASS_S3TC_DXT5_RGBA"/>
+                <enum name="GL_VIEW_CLASS_RGTC1_RED"/>
+                <enum name="GL_VIEW_CLASS_RGTC2_RG"/>
+                <enum name="GL_VIEW_CLASS_BPTC_UNORM"/>
+                <enum name="GL_VIEW_CLASS_BPTC_FLOAT"/>
+                <command name="glGetInternalformati64v"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_invalidate_subdata" supported="gl|glcore">
+            <require>
+                <command name="glInvalidateTexSubImage"/>
+                <command name="glInvalidateTexImage"/>
+                <command name="glInvalidateBufferSubData"/>
+                <command name="glInvalidateBufferData"/>
+                <command name="glInvalidateFramebuffer"/>
+                <command name="glInvalidateSubFramebuffer"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_map_buffer_alignment" supported="gl|glcore">
+            <require>
+                <enum name="GL_MIN_MAP_BUFFER_ALIGNMENT"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_map_buffer_range" supported="gl|glcore">
+            <require>
+                <enum name="GL_MAP_READ_BIT"/>
+                <enum name="GL_MAP_WRITE_BIT"/>
+                <enum name="GL_MAP_INVALIDATE_RANGE_BIT"/>
+                <enum name="GL_MAP_INVALIDATE_BUFFER_BIT"/>
+                <enum name="GL_MAP_FLUSH_EXPLICIT_BIT"/>
+                <enum name="GL_MAP_UNSYNCHRONIZED_BIT"/>
+                <command name="glMapBufferRange"/>
+                <command name="glFlushMappedBufferRange"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_matrix_palette" supported="gl">
+            <require>
+                <enum name="GL_MATRIX_PALETTE_ARB"/>
+                <enum name="GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB"/>
+                <enum name="GL_MAX_PALETTE_MATRICES_ARB"/>
+                <enum name="GL_CURRENT_PALETTE_MATRIX_ARB"/>
+                <enum name="GL_MATRIX_INDEX_ARRAY_ARB"/>
+                <enum name="GL_CURRENT_MATRIX_INDEX_ARB"/>
+                <enum name="GL_MATRIX_INDEX_ARRAY_SIZE_ARB"/>
+                <enum name="GL_MATRIX_INDEX_ARRAY_TYPE_ARB"/>
+                <enum name="GL_MATRIX_INDEX_ARRAY_STRIDE_ARB"/>
+                <enum name="GL_MATRIX_INDEX_ARRAY_POINTER_ARB"/>
+                <command name="glCurrentPaletteMatrixARB"/>
+                <command name="glMatrixIndexubvARB"/>
+                <command name="glMatrixIndexusvARB"/>
+                <command name="glMatrixIndexuivARB"/>
+                <command name="glMatrixIndexPointerARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_multi_bind" supported="gl|glcore">
+            <require>
+                <command name="glBindBuffersBase"/>
+                <command name="glBindBuffersRange"/>
+                <command name="glBindTextures"/>
+                <command name="glBindSamplers"/>
+                <command name="glBindImageTextures"/>
+                <command name="glBindVertexBuffers"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_multi_draw_indirect" supported="gl|glcore">
+            <require>
+                <command name="glMultiDrawArraysIndirect"/>
+                <command name="glMultiDrawElementsIndirect"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_multisample" supported="gl">
+            <require>
+                <enum name="GL_MULTISAMPLE_ARB"/>
+                <enum name="GL_SAMPLE_ALPHA_TO_COVERAGE_ARB"/>
+                <enum name="GL_SAMPLE_ALPHA_TO_ONE_ARB"/>
+                <enum name="GL_SAMPLE_COVERAGE_ARB"/>
+                <enum name="GL_SAMPLE_BUFFERS_ARB"/>
+                <enum name="GL_SAMPLES_ARB"/>
+                <enum name="GL_SAMPLE_COVERAGE_VALUE_ARB"/>
+                <enum name="GL_SAMPLE_COVERAGE_INVERT_ARB"/>
+                <enum name="GL_MULTISAMPLE_BIT_ARB"/>
+                <command name="glSampleCoverageARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_multitexture" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE0_ARB"/>
+                <enum name="GL_TEXTURE1_ARB"/>
+                <enum name="GL_TEXTURE2_ARB"/>
+                <enum name="GL_TEXTURE3_ARB"/>
+                <enum name="GL_TEXTURE4_ARB"/>
+                <enum name="GL_TEXTURE5_ARB"/>
+                <enum name="GL_TEXTURE6_ARB"/>
+                <enum name="GL_TEXTURE7_ARB"/>
+                <enum name="GL_TEXTURE8_ARB"/>
+                <enum name="GL_TEXTURE9_ARB"/>
+                <enum name="GL_TEXTURE10_ARB"/>
+                <enum name="GL_TEXTURE11_ARB"/>
+                <enum name="GL_TEXTURE12_ARB"/>
+                <enum name="GL_TEXTURE13_ARB"/>
+                <enum name="GL_TEXTURE14_ARB"/>
+                <enum name="GL_TEXTURE15_ARB"/>
+                <enum name="GL_TEXTURE16_ARB"/>
+                <enum name="GL_TEXTURE17_ARB"/>
+                <enum name="GL_TEXTURE18_ARB"/>
+                <enum name="GL_TEXTURE19_ARB"/>
+                <enum name="GL_TEXTURE20_ARB"/>
+                <enum name="GL_TEXTURE21_ARB"/>
+                <enum name="GL_TEXTURE22_ARB"/>
+                <enum name="GL_TEXTURE23_ARB"/>
+                <enum name="GL_TEXTURE24_ARB"/>
+                <enum name="GL_TEXTURE25_ARB"/>
+                <enum name="GL_TEXTURE26_ARB"/>
+                <enum name="GL_TEXTURE27_ARB"/>
+                <enum name="GL_TEXTURE28_ARB"/>
+                <enum name="GL_TEXTURE29_ARB"/>
+                <enum name="GL_TEXTURE30_ARB"/>
+                <enum name="GL_TEXTURE31_ARB"/>
+                <enum name="GL_ACTIVE_TEXTURE_ARB"/>
+                <enum name="GL_CLIENT_ACTIVE_TEXTURE_ARB"/>
+                <enum name="GL_MAX_TEXTURE_UNITS_ARB"/>
+                <command name="glActiveTextureARB"/>
+                <command name="glClientActiveTextureARB"/>
+                <command name="glMultiTexCoord1dARB"/>
+                <command name="glMultiTexCoord1dvARB"/>
+                <command name="glMultiTexCoord1fARB"/>
+                <command name="glMultiTexCoord1fvARB"/>
+                <command name="glMultiTexCoord1iARB"/>
+                <command name="glMultiTexCoord1ivARB"/>
+                <command name="glMultiTexCoord1sARB"/>
+                <command name="glMultiTexCoord1svARB"/>
+                <command name="glMultiTexCoord2dARB"/>
+                <command name="glMultiTexCoord2dvARB"/>
+                <command name="glMultiTexCoord2fARB"/>
+                <command name="glMultiTexCoord2fvARB"/>
+                <command name="glMultiTexCoord2iARB"/>
+                <command name="glMultiTexCoord2ivARB"/>
+                <command name="glMultiTexCoord2sARB"/>
+                <command name="glMultiTexCoord2svARB"/>
+                <command name="glMultiTexCoord3dARB"/>
+                <command name="glMultiTexCoord3dvARB"/>
+                <command name="glMultiTexCoord3fARB"/>
+                <command name="glMultiTexCoord3fvARB"/>
+                <command name="glMultiTexCoord3iARB"/>
+                <command name="glMultiTexCoord3ivARB"/>
+                <command name="glMultiTexCoord3sARB"/>
+                <command name="glMultiTexCoord3svARB"/>
+                <command name="glMultiTexCoord4dARB"/>
+                <command name="glMultiTexCoord4dvARB"/>
+                <command name="glMultiTexCoord4fARB"/>
+                <command name="glMultiTexCoord4fvARB"/>
+                <command name="glMultiTexCoord4iARB"/>
+                <command name="glMultiTexCoord4ivARB"/>
+                <command name="glMultiTexCoord4sARB"/>
+                <command name="glMultiTexCoord4svARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_occlusion_query" supported="gl">
+            <require>
+                <enum name="GL_QUERY_COUNTER_BITS_ARB"/>
+                <enum name="GL_CURRENT_QUERY_ARB"/>
+                <enum name="GL_QUERY_RESULT_ARB"/>
+                <enum name="GL_QUERY_RESULT_AVAILABLE_ARB"/>
+                <enum name="GL_SAMPLES_PASSED_ARB"/>
+                <command name="glGenQueriesARB"/>
+                <command name="glDeleteQueriesARB"/>
+                <command name="glIsQueryARB"/>
+                <command name="glBeginQueryARB"/>
+                <command name="glEndQueryARB"/>
+                <command name="glGetQueryivARB"/>
+                <command name="glGetQueryObjectivARB"/>
+                <command name="glGetQueryObjectuivARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_occlusion_query2" supported="gl|glcore">
+            <require>
+                <enum name="GL_ANY_SAMPLES_PASSED"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_pixel_buffer_object" supported="gl">
+            <require>
+                <enum name="GL_PIXEL_PACK_BUFFER_ARB"/>
+                <enum name="GL_PIXEL_UNPACK_BUFFER_ARB"/>
+                <enum name="GL_PIXEL_PACK_BUFFER_BINDING_ARB"/>
+                <enum name="GL_PIXEL_UNPACK_BUFFER_BINDING_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_point_parameters" supported="gl">
+            <require>
+                <enum name="GL_POINT_SIZE_MIN_ARB"/>
+                <enum name="GL_POINT_SIZE_MAX_ARB"/>
+                <enum name="GL_POINT_FADE_THRESHOLD_SIZE_ARB"/>
+                <enum name="GL_POINT_DISTANCE_ATTENUATION_ARB"/>
+                <command name="glPointParameterfARB"/>
+                <command name="glPointParameterfvARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_point_sprite" supported="gl">
+            <require>
+                <enum name="GL_POINT_SPRITE_ARB"/>
+                <enum name="GL_COORD_REPLACE_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_program_interface_query" supported="gl|glcore">
+            <require>
+                <enum name="GL_UNIFORM"/>
+                <enum name="GL_UNIFORM_BLOCK"/>
+                <enum name="GL_PROGRAM_INPUT"/>
+                <enum name="GL_PROGRAM_OUTPUT"/>
+                <enum name="GL_BUFFER_VARIABLE"/>
+                <enum name="GL_SHADER_STORAGE_BLOCK"/>
+                <enum name="GL_ATOMIC_COUNTER_BUFFER"/>
+                <enum name="GL_VERTEX_SUBROUTINE"/>
+                <enum name="GL_TESS_CONTROL_SUBROUTINE"/>
+                <enum name="GL_TESS_EVALUATION_SUBROUTINE"/>
+                <enum name="GL_GEOMETRY_SUBROUTINE"/>
+                <enum name="GL_FRAGMENT_SUBROUTINE"/>
+                <enum name="GL_COMPUTE_SUBROUTINE"/>
+                <enum name="GL_VERTEX_SUBROUTINE_UNIFORM"/>
+                <enum name="GL_TESS_CONTROL_SUBROUTINE_UNIFORM"/>
+                <enum name="GL_TESS_EVALUATION_SUBROUTINE_UNIFORM"/>
+                <enum name="GL_GEOMETRY_SUBROUTINE_UNIFORM"/>
+                <enum name="GL_FRAGMENT_SUBROUTINE_UNIFORM"/>
+                <enum name="GL_COMPUTE_SUBROUTINE_UNIFORM"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_VARYING"/>
+                <enum name="GL_ACTIVE_RESOURCES"/>
+                <enum name="GL_MAX_NAME_LENGTH"/>
+                <enum name="GL_MAX_NUM_ACTIVE_VARIABLES"/>
+                <enum name="GL_MAX_NUM_COMPATIBLE_SUBROUTINES"/>
+                <enum name="GL_NAME_LENGTH"/>
+                <enum name="GL_TYPE"/>
+                <enum name="GL_ARRAY_SIZE"/>
+                <enum name="GL_OFFSET"/>
+                <enum name="GL_BLOCK_INDEX"/>
+                <enum name="GL_ARRAY_STRIDE"/>
+                <enum name="GL_MATRIX_STRIDE"/>
+                <enum name="GL_IS_ROW_MAJOR"/>
+                <enum name="GL_ATOMIC_COUNTER_BUFFER_INDEX"/>
+                <enum name="GL_BUFFER_BINDING"/>
+                <enum name="GL_BUFFER_DATA_SIZE"/>
+                <enum name="GL_NUM_ACTIVE_VARIABLES"/>
+                <enum name="GL_ACTIVE_VARIABLES"/>
+                <enum name="GL_REFERENCED_BY_VERTEX_SHADER"/>
+                <enum name="GL_REFERENCED_BY_TESS_CONTROL_SHADER"/>
+                <enum name="GL_REFERENCED_BY_TESS_EVALUATION_SHADER"/>
+                <enum name="GL_REFERENCED_BY_GEOMETRY_SHADER"/>
+                <enum name="GL_REFERENCED_BY_FRAGMENT_SHADER"/>
+                <enum name="GL_REFERENCED_BY_COMPUTE_SHADER"/>
+                <enum name="GL_TOP_LEVEL_ARRAY_SIZE"/>
+                <enum name="GL_TOP_LEVEL_ARRAY_STRIDE"/>
+                <enum name="GL_LOCATION"/>
+                <enum name="GL_LOCATION_INDEX"/>
+                <enum name="GL_IS_PER_PATCH"/>
+                <enum name="GL_NUM_COMPATIBLE_SUBROUTINES"/>
+                <enum name="GL_COMPATIBLE_SUBROUTINES"/>
+                <command name="glGetProgramInterfaceiv"/>
+                <command name="glGetProgramResourceIndex"/>
+                <command name="glGetProgramResourceName"/>
+                <command name="glGetProgramResourceiv"/>
+                <command name="glGetProgramResourceLocation"/>
+                <command name="glGetProgramResourceLocationIndex"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_provoking_vertex" supported="gl|glcore">
+            <require>
+                <enum name="GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION"/>
+                <enum name="GL_FIRST_VERTEX_CONVENTION"/>
+                <enum name="GL_LAST_VERTEX_CONVENTION"/>
+                <enum name="GL_PROVOKING_VERTEX"/>
+                <command name="glProvokingVertex"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_query_buffer_object" supported="gl|glcore">
+            <require>
+                <enum name="GL_QUERY_BUFFER"/>
+                <enum name="GL_QUERY_BUFFER_BARRIER_BIT"/>
+                <enum name="GL_QUERY_BUFFER_BINDING"/>
+                <enum name="GL_QUERY_RESULT_NO_WAIT"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_robust_buffer_access_behavior" supported="gl|glcore"/>
+        <extension name="GL_ARB_robustness" supported="gl|glcore">
+            <require>
+                <enum name="GL_NO_ERROR"/>
+                <enum name="GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB"/>
+                <enum name="GL_LOSE_CONTEXT_ON_RESET_ARB"/>
+                <enum name="GL_GUILTY_CONTEXT_RESET_ARB"/>
+                <enum name="GL_INNOCENT_CONTEXT_RESET_ARB"/>
+                <enum name="GL_UNKNOWN_CONTEXT_RESET_ARB"/>
+                <enum name="GL_RESET_NOTIFICATION_STRATEGY_ARB"/>
+                <enum name="GL_NO_RESET_NOTIFICATION_ARB"/>
+                <command name="glGetGraphicsResetStatusARB"/>
+                <command name="glGetnTexImageARB"/>
+                <command name="glReadnPixelsARB"/>
+                <command name="glGetnCompressedTexImageARB"/>
+                <command name="glGetnUniformfvARB"/>
+                <command name="glGetnUniformivARB"/>
+                <command name="glGetnUniformuivARB"/>
+                <command name="glGetnUniformdvARB"/>
+            </require>
+            <require api="gl" profile="compatibility">
+                <command name="glGetnMapdvARB"/>
+                <command name="glGetnMapfvARB"/>
+                <command name="glGetnMapivARB"/>
+                <command name="glGetnPixelMapfvARB"/>
+                <command name="glGetnPixelMapuivARB"/>
+                <command name="glGetnPixelMapusvARB"/>
+                <command name="glGetnPolygonStippleARB"/>
+                <command name="glGetnColorTableARB"/>
+                <command name="glGetnConvolutionFilterARB"/>
+                <command name="glGetnSeparableFilterARB"/>
+                <command name="glGetnHistogramARB"/>
+                <command name="glGetnMinmaxARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_robustness_isolation" supported="gl|glcore"/>
+        <extension name="GL_ARB_sample_shading" supported="gl|glcore">
+            <require>
+                <enum name="GL_SAMPLE_SHADING_ARB"/>
+                <enum name="GL_MIN_SAMPLE_SHADING_VALUE_ARB"/>
+                <command name="glMinSampleShadingARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_sampler_objects" supported="gl|glcore">
+            <require>
+                <enum name="GL_SAMPLER_BINDING"/>
+                <command name="glGenSamplers"/>
+                <command name="glDeleteSamplers"/>
+                <command name="glIsSampler"/>
+                <command name="glBindSampler"/>
+                <command name="glSamplerParameteri"/>
+                <command name="glSamplerParameteriv"/>
+                <command name="glSamplerParameterf"/>
+                <command name="glSamplerParameterfv"/>
+                <command name="glSamplerParameterIiv"/>
+                <command name="glSamplerParameterIuiv"/>
+                <command name="glGetSamplerParameteriv"/>
+                <command name="glGetSamplerParameterIiv"/>
+                <command name="glGetSamplerParameterfv"/>
+                <command name="glGetSamplerParameterIuiv"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_seamless_cube_map" supported="gl|glcore">
+            <require>
+                <enum name="GL_TEXTURE_CUBE_MAP_SEAMLESS"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_seamless_cubemap_per_texture" supported="gl|glcore">
+            <require>
+                <enum name="GL_TEXTURE_CUBE_MAP_SEAMLESS"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_separate_shader_objects" supported="gl|glcore">
+            <require>
+                <enum name="GL_VERTEX_SHADER_BIT"/>
+                <enum name="GL_FRAGMENT_SHADER_BIT"/>
+                <enum name="GL_GEOMETRY_SHADER_BIT"/>
+                <enum name="GL_TESS_CONTROL_SHADER_BIT"/>
+                <enum name="GL_TESS_EVALUATION_SHADER_BIT"/>
+                <enum name="GL_ALL_SHADER_BITS"/>
+                <enum name="GL_PROGRAM_SEPARABLE"/>
+                <enum name="GL_ACTIVE_PROGRAM"/>
+                <enum name="GL_PROGRAM_PIPELINE_BINDING"/>
+                <command name="glUseProgramStages"/>
+                <command name="glActiveShaderProgram"/>
+                <command name="glCreateShaderProgramv"/>
+                <command name="glBindProgramPipeline"/>
+                <command name="glDeleteProgramPipelines"/>
+                <command name="glGenProgramPipelines"/>
+                <command name="glIsProgramPipeline"/>
+                <command name="glGetProgramPipelineiv"/>
+                <command name="glProgramUniform1i"/>
+                <command name="glProgramUniform1iv"/>
+                <command name="glProgramUniform1f"/>
+                <command name="glProgramUniform1fv"/>
+                <command name="glProgramUniform1d"/>
+                <command name="glProgramUniform1dv"/>
+                <command name="glProgramUniform1ui"/>
+                <command name="glProgramUniform1uiv"/>
+                <command name="glProgramUniform2i"/>
+                <command name="glProgramUniform2iv"/>
+                <command name="glProgramUniform2f"/>
+                <command name="glProgramUniform2fv"/>
+                <command name="glProgramUniform2d"/>
+                <command name="glProgramUniform2dv"/>
+                <command name="glProgramUniform2ui"/>
+                <command name="glProgramUniform2uiv"/>
+                <command name="glProgramUniform3i"/>
+                <command name="glProgramUniform3iv"/>
+                <command name="glProgramUniform3f"/>
+                <command name="glProgramUniform3fv"/>
+                <command name="glProgramUniform3d"/>
+                <command name="glProgramUniform3dv"/>
+                <command name="glProgramUniform3ui"/>
+                <command name="glProgramUniform3uiv"/>
+                <command name="glProgramUniform4i"/>
+                <command name="glProgramUniform4iv"/>
+                <command name="glProgramUniform4f"/>
+                <command name="glProgramUniform4fv"/>
+                <command name="glProgramUniform4d"/>
+                <command name="glProgramUniform4dv"/>
+                <command name="glProgramUniform4ui"/>
+                <command name="glProgramUniform4uiv"/>
+                <command name="glProgramUniformMatrix2fv"/>
+                <command name="glProgramUniformMatrix3fv"/>
+                <command name="glProgramUniformMatrix4fv"/>
+                <command name="glProgramUniformMatrix2dv"/>
+                <command name="glProgramUniformMatrix3dv"/>
+                <command name="glProgramUniformMatrix4dv"/>
+                <command name="glProgramUniformMatrix2x3fv"/>
+                <command name="glProgramUniformMatrix3x2fv"/>
+                <command name="glProgramUniformMatrix2x4fv"/>
+                <command name="glProgramUniformMatrix4x2fv"/>
+                <command name="glProgramUniformMatrix3x4fv"/>
+                <command name="glProgramUniformMatrix4x3fv"/>
+                <command name="glProgramUniformMatrix2x3dv"/>
+                <command name="glProgramUniformMatrix3x2dv"/>
+                <command name="glProgramUniformMatrix2x4dv"/>
+                <command name="glProgramUniformMatrix4x2dv"/>
+                <command name="glProgramUniformMatrix3x4dv"/>
+                <command name="glProgramUniformMatrix4x3dv"/>
+                <command name="glValidateProgramPipeline"/>
+                <command name="glGetProgramPipelineInfoLog"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_shader_atomic_counters" supported="gl|glcore">
+            <require>
+                <enum name="GL_ATOMIC_COUNTER_BUFFER"/>
+                <enum name="GL_ATOMIC_COUNTER_BUFFER_BINDING"/>
+                <enum name="GL_ATOMIC_COUNTER_BUFFER_START"/>
+                <enum name="GL_ATOMIC_COUNTER_BUFFER_SIZE"/>
+                <enum name="GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE"/>
+                <enum name="GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS"/>
+                <enum name="GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES"/>
+                <enum name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER"/>
+                <enum name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER"/>
+                <enum name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER"/>
+                <enum name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER"/>
+                <enum name="GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER"/>
+                <enum name="GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS"/>
+                <enum name="GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS"/>
+                <enum name="GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS"/>
+                <enum name="GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS"/>
+                <enum name="GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS"/>
+                <enum name="GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS"/>
+                <enum name="GL_MAX_VERTEX_ATOMIC_COUNTERS"/>
+                <enum name="GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS"/>
+                <enum name="GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS"/>
+                <enum name="GL_MAX_GEOMETRY_ATOMIC_COUNTERS"/>
+                <enum name="GL_MAX_FRAGMENT_ATOMIC_COUNTERS"/>
+                <enum name="GL_MAX_COMBINED_ATOMIC_COUNTERS"/>
+                <enum name="GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE"/>
+                <enum name="GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS"/>
+                <enum name="GL_ACTIVE_ATOMIC_COUNTER_BUFFERS"/>
+                <enum name="GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX"/>
+                <enum name="GL_UNSIGNED_INT_ATOMIC_COUNTER"/>
+                <command name="glGetActiveAtomicCounterBufferiv"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_shader_bit_encoding" supported="gl|glcore"/>
+        <extension name="GL_ARB_shader_draw_parameters" supported="gl|glcore"/>
+        <extension name="GL_ARB_shader_group_vote" supported="gl|glcore"/>
+        <extension name="GL_ARB_shader_image_load_store" supported="gl|glcore">
+            <require>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT"/>
+                <enum name="GL_ELEMENT_ARRAY_BARRIER_BIT"/>
+                <enum name="GL_UNIFORM_BARRIER_BIT"/>
+                <enum name="GL_TEXTURE_FETCH_BARRIER_BIT"/>
+                <enum name="GL_SHADER_IMAGE_ACCESS_BARRIER_BIT"/>
+                <enum name="GL_COMMAND_BARRIER_BIT"/>
+                <enum name="GL_PIXEL_BUFFER_BARRIER_BIT"/>
+                <enum name="GL_TEXTURE_UPDATE_BARRIER_BIT"/>
+                <enum name="GL_BUFFER_UPDATE_BARRIER_BIT"/>
+                <enum name="GL_FRAMEBUFFER_BARRIER_BIT"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BARRIER_BIT"/>
+                <enum name="GL_ATOMIC_COUNTER_BARRIER_BIT"/>
+                <enum name="GL_ALL_BARRIER_BITS"/>
+                <enum name="GL_MAX_IMAGE_UNITS"/>
+                <enum name="GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS"/>
+                <enum name="GL_IMAGE_BINDING_NAME"/>
+                <enum name="GL_IMAGE_BINDING_LEVEL"/>
+                <enum name="GL_IMAGE_BINDING_LAYERED"/>
+                <enum name="GL_IMAGE_BINDING_LAYER"/>
+                <enum name="GL_IMAGE_BINDING_ACCESS"/>
+                <enum name="GL_IMAGE_1D"/>
+                <enum name="GL_IMAGE_2D"/>
+                <enum name="GL_IMAGE_3D"/>
+                <enum name="GL_IMAGE_2D_RECT"/>
+                <enum name="GL_IMAGE_CUBE"/>
+                <enum name="GL_IMAGE_BUFFER"/>
+                <enum name="GL_IMAGE_1D_ARRAY"/>
+                <enum name="GL_IMAGE_2D_ARRAY"/>
+                <enum name="GL_IMAGE_CUBE_MAP_ARRAY"/>
+                <enum name="GL_IMAGE_2D_MULTISAMPLE"/>
+                <enum name="GL_IMAGE_2D_MULTISAMPLE_ARRAY"/>
+                <enum name="GL_INT_IMAGE_1D"/>
+                <enum name="GL_INT_IMAGE_2D"/>
+                <enum name="GL_INT_IMAGE_3D"/>
+                <enum name="GL_INT_IMAGE_2D_RECT"/>
+                <enum name="GL_INT_IMAGE_CUBE"/>
+                <enum name="GL_INT_IMAGE_BUFFER"/>
+                <enum name="GL_INT_IMAGE_1D_ARRAY"/>
+                <enum name="GL_INT_IMAGE_2D_ARRAY"/>
+                <enum name="GL_INT_IMAGE_CUBE_MAP_ARRAY"/>
+                <enum name="GL_INT_IMAGE_2D_MULTISAMPLE"/>
+                <enum name="GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_1D"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_2D"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_3D"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_2D_RECT"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_CUBE"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_BUFFER"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_1D_ARRAY"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_2D_ARRAY"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY"/>
+                <enum name="GL_MAX_IMAGE_SAMPLES"/>
+                <enum name="GL_IMAGE_BINDING_FORMAT"/>
+                <enum name="GL_IMAGE_FORMAT_COMPATIBILITY_TYPE"/>
+                <enum name="GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE"/>
+                <enum name="GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS"/>
+                <enum name="GL_MAX_VERTEX_IMAGE_UNIFORMS"/>
+                <enum name="GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS"/>
+                <enum name="GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS"/>
+                <enum name="GL_MAX_GEOMETRY_IMAGE_UNIFORMS"/>
+                <enum name="GL_MAX_FRAGMENT_IMAGE_UNIFORMS"/>
+                <enum name="GL_MAX_COMBINED_IMAGE_UNIFORMS"/>
+                <command name="glBindImageTexture"/>
+                <command name="glMemoryBarrier"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_shader_image_size" supported="gl|glcore"/>
+        <extension name="GL_ARB_shader_objects" supported="gl">
+            <require>
+                <enum name="GL_PROGRAM_OBJECT_ARB"/>
+                <enum name="GL_SHADER_OBJECT_ARB"/>
+                <enum name="GL_OBJECT_TYPE_ARB"/>
+                <enum name="GL_OBJECT_SUBTYPE_ARB"/>
+                <enum name="GL_FLOAT_VEC2_ARB"/>
+                <enum name="GL_FLOAT_VEC3_ARB"/>
+                <enum name="GL_FLOAT_VEC4_ARB"/>
+                <enum name="GL_INT_VEC2_ARB"/>
+                <enum name="GL_INT_VEC3_ARB"/>
+                <enum name="GL_INT_VEC4_ARB"/>
+                <enum name="GL_BOOL_ARB"/>
+                <enum name="GL_BOOL_VEC2_ARB"/>
+                <enum name="GL_BOOL_VEC3_ARB"/>
+                <enum name="GL_BOOL_VEC4_ARB"/>
+                <enum name="GL_FLOAT_MAT2_ARB"/>
+                <enum name="GL_FLOAT_MAT3_ARB"/>
+                <enum name="GL_FLOAT_MAT4_ARB"/>
+                <enum name="GL_SAMPLER_1D_ARB"/>
+                <enum name="GL_SAMPLER_2D_ARB"/>
+                <enum name="GL_SAMPLER_3D_ARB"/>
+                <enum name="GL_SAMPLER_CUBE_ARB"/>
+                <enum name="GL_SAMPLER_1D_SHADOW_ARB"/>
+                <enum name="GL_SAMPLER_2D_SHADOW_ARB"/>
+                <enum name="GL_SAMPLER_2D_RECT_ARB"/>
+                <enum name="GL_SAMPLER_2D_RECT_SHADOW_ARB"/>
+                <enum name="GL_OBJECT_DELETE_STATUS_ARB"/>
+                <enum name="GL_OBJECT_COMPILE_STATUS_ARB"/>
+                <enum name="GL_OBJECT_LINK_STATUS_ARB"/>
+                <enum name="GL_OBJECT_VALIDATE_STATUS_ARB"/>
+                <enum name="GL_OBJECT_INFO_LOG_LENGTH_ARB"/>
+                <enum name="GL_OBJECT_ATTACHED_OBJECTS_ARB"/>
+                <enum name="GL_OBJECT_ACTIVE_UNIFORMS_ARB"/>
+                <enum name="GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB"/>
+                <enum name="GL_OBJECT_SHADER_SOURCE_LENGTH_ARB"/>
+                <command name="glDeleteObjectARB"/>
+                <command name="glGetHandleARB"/>
+                <command name="glDetachObjectARB"/>
+                <command name="glCreateShaderObjectARB"/>
+                <command name="glShaderSourceARB"/>
+                <command name="glCompileShaderARB"/>
+                <command name="glCreateProgramObjectARB"/>
+                <command name="glAttachObjectARB"/>
+                <command name="glLinkProgramARB"/>
+                <command name="glUseProgramObjectARB"/>
+                <command name="glValidateProgramARB"/>
+                <command name="glUniform1fARB"/>
+                <command name="glUniform2fARB"/>
+                <command name="glUniform3fARB"/>
+                <command name="glUniform4fARB"/>
+                <command name="glUniform1iARB"/>
+                <command name="glUniform2iARB"/>
+                <command name="glUniform3iARB"/>
+                <command name="glUniform4iARB"/>
+                <command name="glUniform1fvARB"/>
+                <command name="glUniform2fvARB"/>
+                <command name="glUniform3fvARB"/>
+                <command name="glUniform4fvARB"/>
+                <command name="glUniform1ivARB"/>
+                <command name="glUniform2ivARB"/>
+                <command name="glUniform3ivARB"/>
+                <command name="glUniform4ivARB"/>
+                <command name="glUniformMatrix2fvARB"/>
+                <command name="glUniformMatrix3fvARB"/>
+                <command name="glUniformMatrix4fvARB"/>
+                <command name="glGetObjectParameterfvARB"/>
+                <command name="glGetObjectParameterivARB"/>
+                <command name="glGetInfoLogARB"/>
+                <command name="glGetAttachedObjectsARB"/>
+                <command name="glGetUniformLocationARB"/>
+                <command name="glGetActiveUniformARB"/>
+                <command name="glGetUniformfvARB"/>
+                <command name="glGetUniformivARB"/>
+                <command name="glGetShaderSourceARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_shader_precision" supported="gl|glcore"/>
+        <extension name="GL_ARB_shader_stencil_export" supported="gl|glcore"/>
+        <extension name="GL_ARB_shader_storage_buffer_object" supported="gl|glcore">
+            <require>
+                <enum name="GL_SHADER_STORAGE_BUFFER"/>
+                <enum name="GL_SHADER_STORAGE_BUFFER_BINDING"/>
+                <enum name="GL_SHADER_STORAGE_BUFFER_START"/>
+                <enum name="GL_SHADER_STORAGE_BUFFER_SIZE"/>
+                <enum name="GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS"/>
+                <enum name="GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS"/>
+                <enum name="GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS"/>
+                <enum name="GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS"/>
+                <enum name="GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS"/>
+                <enum name="GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS"/>
+                <enum name="GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS"/>
+                <enum name="GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS"/>
+                <enum name="GL_MAX_SHADER_STORAGE_BLOCK_SIZE"/>
+                <enum name="GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT"/>
+                <enum name="GL_SHADER_STORAGE_BARRIER_BIT"/>
+                <enum name="GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES"/>
+                <enum name="GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS"/>
+                <command name="glShaderStorageBlockBinding"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_shader_subroutine" supported="gl|glcore">
+            <require>
+                <enum name="GL_ACTIVE_SUBROUTINES"/>
+                <enum name="GL_ACTIVE_SUBROUTINE_UNIFORMS"/>
+                <enum name="GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS"/>
+                <enum name="GL_ACTIVE_SUBROUTINE_MAX_LENGTH"/>
+                <enum name="GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH"/>
+                <enum name="GL_MAX_SUBROUTINES"/>
+                <enum name="GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS"/>
+                <enum name="GL_NUM_COMPATIBLE_SUBROUTINES"/>
+                <enum name="GL_COMPATIBLE_SUBROUTINES"/>
+                <enum name="GL_UNIFORM_SIZE"/>
+                <enum name="GL_UNIFORM_NAME_LENGTH"/>
+                <command name="glGetSubroutineUniformLocation"/>
+                <command name="glGetSubroutineIndex"/>
+                <command name="glGetActiveSubroutineUniformiv"/>
+                <command name="glGetActiveSubroutineUniformName"/>
+                <command name="glGetActiveSubroutineName"/>
+                <command name="glUniformSubroutinesuiv"/>
+                <command name="glGetUniformSubroutineuiv"/>
+                <command name="glGetProgramStageiv"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_shader_texture_lod" supported="gl"/>
+        <extension name="GL_ARB_shading_language_100" supported="gl">
+            <require>
+                <enum name="GL_SHADING_LANGUAGE_VERSION_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_shading_language_420pack" supported="gl|glcore"/>
+        <extension name="GL_ARB_shading_language_include" supported="gl|glcore">
+            <require>
+                <enum name="GL_SHADER_INCLUDE_ARB"/>
+                <enum name="GL_NAMED_STRING_LENGTH_ARB"/>
+                <enum name="GL_NAMED_STRING_TYPE_ARB"/>
+                <command name="glNamedStringARB"/>
+                <command name="glDeleteNamedStringARB"/>
+                <command name="glCompileShaderIncludeARB"/>
+                <command name="glIsNamedStringARB"/>
+                <command name="glGetNamedStringARB"/>
+                <command name="glGetNamedStringivARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_shading_language_packing" supported="gl|glcore"/>
+        <extension name="GL_ARB_shadow" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_COMPARE_MODE_ARB"/>
+                <enum name="GL_TEXTURE_COMPARE_FUNC_ARB"/>
+                <enum name="GL_COMPARE_R_TO_TEXTURE_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_shadow_ambient" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_COMPARE_FAIL_VALUE_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_sparse_texture" supported="gl|glcore">
+            <require>
+                <enum name="GL_TEXTURE_SPARSE_ARB"/>
+                <enum name="GL_VIRTUAL_PAGE_SIZE_INDEX_ARB"/>
+                <enum name="GL_MIN_SPARSE_LEVEL_ARB"/>
+                <enum name="GL_NUM_VIRTUAL_PAGE_SIZES_ARB"/>
+                <enum name="GL_VIRTUAL_PAGE_SIZE_X_ARB"/>
+                <enum name="GL_VIRTUAL_PAGE_SIZE_Y_ARB"/>
+                <enum name="GL_VIRTUAL_PAGE_SIZE_Z_ARB"/>
+                <enum name="GL_MAX_SPARSE_TEXTURE_SIZE_ARB"/>
+                <enum name="GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB"/>
+                <enum name="GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB"/>
+                <enum name="GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB"/>
+                <command name="glTexPageCommitmentARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_stencil_texturing" supported="gl|glcore">
+            <require>
+                <enum name="GL_DEPTH_STENCIL_TEXTURE_MODE"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_sync" supported="gl|glcore">
+            <require>
+                <enum name="GL_MAX_SERVER_WAIT_TIMEOUT"/>
+                <enum name="GL_OBJECT_TYPE"/>
+                <enum name="GL_SYNC_CONDITION"/>
+                <enum name="GL_SYNC_STATUS"/>
+                <enum name="GL_SYNC_FLAGS"/>
+                <enum name="GL_SYNC_FENCE"/>
+                <enum name="GL_SYNC_GPU_COMMANDS_COMPLETE"/>
+                <enum name="GL_UNSIGNALED"/>
+                <enum name="GL_SIGNALED"/>
+                <enum name="GL_ALREADY_SIGNALED"/>
+                <enum name="GL_TIMEOUT_EXPIRED"/>
+                <enum name="GL_CONDITION_SATISFIED"/>
+                <enum name="GL_WAIT_FAILED"/>
+                <enum name="GL_SYNC_FLUSH_COMMANDS_BIT"/>
+                <enum name="GL_TIMEOUT_IGNORED"/>
+                <command name="glFenceSync"/>
+                <command name="glIsSync"/>
+                <command name="glDeleteSync"/>
+                <command name="glClientWaitSync"/>
+                <command name="glWaitSync"/>
+                <command name="glGetInteger64v"/>
+                <command name="glGetSynciv"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_tessellation_shader" supported="gl|glcore">
+            <require>
+                <enum name="GL_PATCHES"/>
+                <enum name="GL_PATCH_VERTICES"/>
+                <enum name="GL_PATCH_DEFAULT_INNER_LEVEL"/>
+                <enum name="GL_PATCH_DEFAULT_OUTER_LEVEL"/>
+                <enum name="GL_TESS_CONTROL_OUTPUT_VERTICES"/>
+                <enum name="GL_TESS_GEN_MODE"/>
+                <enum name="GL_TESS_GEN_SPACING"/>
+                <enum name="GL_TESS_GEN_VERTEX_ORDER"/>
+                <enum name="GL_TESS_GEN_POINT_MODE"/>
+                <enum name="GL_TRIANGLES"/>
+                <enum name="GL_ISOLINES"/>
+                <enum name="GL_QUADS"/>
+                <enum name="GL_EQUAL"/>
+                <enum name="GL_FRACTIONAL_ODD"/>
+                <enum name="GL_FRACTIONAL_EVEN"/>
+                <enum name="GL_CCW"/>
+                <enum name="GL_CW"/>
+                <enum name="GL_MAX_PATCH_VERTICES"/>
+                <enum name="GL_MAX_TESS_GEN_LEVEL"/>
+                <enum name="GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS"/>
+                <enum name="GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS"/>
+                <enum name="GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS"/>
+                <enum name="GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS"/>
+                <enum name="GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS"/>
+                <enum name="GL_MAX_TESS_PATCH_COMPONENTS"/>
+                <enum name="GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS"/>
+                <enum name="GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS"/>
+                <enum name="GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS"/>
+                <enum name="GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS"/>
+                <enum name="GL_MAX_TESS_CONTROL_INPUT_COMPONENTS"/>
+                <enum name="GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS"/>
+                <enum name="GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS"/>
+                <enum name="GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS"/>
+                <enum name="GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER"/>
+                <enum name="GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER"/>
+                <enum name="GL_TESS_EVALUATION_SHADER"/>
+                <enum name="GL_TESS_CONTROL_SHADER"/>
+                <command name="glPatchParameteri"/>
+                <command name="glPatchParameterfv"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_border_clamp" supported="gl">
+            <require>
+                <enum name="GL_CLAMP_TO_BORDER_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_buffer_object" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_BUFFER_ARB"/>
+                <enum name="GL_MAX_TEXTURE_BUFFER_SIZE_ARB"/>
+                <enum name="GL_TEXTURE_BINDING_BUFFER_ARB"/>
+                <enum name="GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB"/>
+                <enum name="GL_TEXTURE_BUFFER_FORMAT_ARB"/>
+                <command name="glTexBufferARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_buffer_object_rgb32" supported="gl|glcore">
+            <require>
+                <enum name="GL_RGB32F"/>
+                <enum name="GL_RGB32UI"/>
+                <enum name="GL_RGB32I"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_buffer_range" supported="gl|glcore">
+            <require>
+                <enum name="GL_TEXTURE_BUFFER_OFFSET"/>
+                <enum name="GL_TEXTURE_BUFFER_SIZE"/>
+                <enum name="GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT"/>
+                <command name="glTexBufferRange"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_compression" supported="gl">
+            <require>
+                <enum name="GL_COMPRESSED_ALPHA_ARB"/>
+                <enum name="GL_COMPRESSED_LUMINANCE_ARB"/>
+                <enum name="GL_COMPRESSED_LUMINANCE_ALPHA_ARB"/>
+                <enum name="GL_COMPRESSED_INTENSITY_ARB"/>
+                <enum name="GL_COMPRESSED_RGB_ARB"/>
+                <enum name="GL_COMPRESSED_RGBA_ARB"/>
+                <enum name="GL_TEXTURE_COMPRESSION_HINT_ARB"/>
+                <enum name="GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB"/>
+                <enum name="GL_TEXTURE_COMPRESSED_ARB"/>
+                <enum name="GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB"/>
+                <enum name="GL_COMPRESSED_TEXTURE_FORMATS_ARB"/>
+                <command name="glCompressedTexImage3DARB"/>
+                <command name="glCompressedTexImage2DARB"/>
+                <command name="glCompressedTexImage1DARB"/>
+                <command name="glCompressedTexSubImage3DARB"/>
+                <command name="glCompressedTexSubImage2DARB"/>
+                <command name="glCompressedTexSubImage1DARB"/>
+                <command name="glGetCompressedTexImageARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_compression_bptc" supported="gl|glcore">
+            <require>
+                <enum name="GL_COMPRESSED_RGBA_BPTC_UNORM_ARB"/>
+                <enum name="GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB"/>
+                <enum name="GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB"/>
+                <enum name="GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_compression_rgtc" supported="gl|glcore">
+            <require>
+                <enum name="GL_COMPRESSED_RED_RGTC1"/>
+                <enum name="GL_COMPRESSED_SIGNED_RED_RGTC1"/>
+                <enum name="GL_COMPRESSED_RG_RGTC2"/>
+                <enum name="GL_COMPRESSED_SIGNED_RG_RGTC2"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_cube_map" supported="gl">
+            <require>
+                <enum name="GL_NORMAL_MAP_ARB"/>
+                <enum name="GL_REFLECTION_MAP_ARB"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_ARB"/>
+                <enum name="GL_TEXTURE_BINDING_CUBE_MAP_ARB"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB"/>
+                <enum name="GL_PROXY_TEXTURE_CUBE_MAP_ARB"/>
+                <enum name="GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_cube_map_array" supported="gl|glcore">
+            <require>
+                <enum name="GL_TEXTURE_CUBE_MAP_ARRAY_ARB"/>
+                <enum name="GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB"/>
+                <enum name="GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB"/>
+                <enum name="GL_SAMPLER_CUBE_MAP_ARRAY_ARB"/>
+                <enum name="GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB"/>
+                <enum name="GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB"/>
+                <enum name="GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_env_add" supported="gl"/>
+        <extension name="GL_ARB_texture_env_combine" supported="gl">
+            <require>
+                <enum name="GL_COMBINE_ARB"/>
+                <enum name="GL_COMBINE_RGB_ARB"/>
+                <enum name="GL_COMBINE_ALPHA_ARB"/>
+                <enum name="GL_SOURCE0_RGB_ARB"/>
+                <enum name="GL_SOURCE1_RGB_ARB"/>
+                <enum name="GL_SOURCE2_RGB_ARB"/>
+                <enum name="GL_SOURCE0_ALPHA_ARB"/>
+                <enum name="GL_SOURCE1_ALPHA_ARB"/>
+                <enum name="GL_SOURCE2_ALPHA_ARB"/>
+                <enum name="GL_OPERAND0_RGB_ARB"/>
+                <enum name="GL_OPERAND1_RGB_ARB"/>
+                <enum name="GL_OPERAND2_RGB_ARB"/>
+                <enum name="GL_OPERAND0_ALPHA_ARB"/>
+                <enum name="GL_OPERAND1_ALPHA_ARB"/>
+                <enum name="GL_OPERAND2_ALPHA_ARB"/>
+                <enum name="GL_RGB_SCALE_ARB"/>
+                <enum name="GL_ADD_SIGNED_ARB"/>
+                <enum name="GL_INTERPOLATE_ARB"/>
+                <enum name="GL_SUBTRACT_ARB"/>
+                <enum name="GL_CONSTANT_ARB"/>
+                <enum name="GL_PRIMARY_COLOR_ARB"/>
+                <enum name="GL_PREVIOUS_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_env_crossbar" supported="gl"/>
+        <extension name="GL_ARB_texture_env_dot3" supported="gl">
+            <require>
+                <enum name="GL_DOT3_RGB_ARB"/>
+                <enum name="GL_DOT3_RGBA_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_float" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_RED_TYPE_ARB"/>
+                <enum name="GL_TEXTURE_GREEN_TYPE_ARB"/>
+                <enum name="GL_TEXTURE_BLUE_TYPE_ARB"/>
+                <enum name="GL_TEXTURE_ALPHA_TYPE_ARB"/>
+                <enum name="GL_TEXTURE_LUMINANCE_TYPE_ARB"/>
+                <enum name="GL_TEXTURE_INTENSITY_TYPE_ARB"/>
+                <enum name="GL_TEXTURE_DEPTH_TYPE_ARB"/>
+                <enum name="GL_UNSIGNED_NORMALIZED_ARB"/>
+                <enum name="GL_RGBA32F_ARB"/>
+                <enum name="GL_RGB32F_ARB"/>
+                <enum name="GL_ALPHA32F_ARB"/>
+                <enum name="GL_INTENSITY32F_ARB"/>
+                <enum name="GL_LUMINANCE32F_ARB"/>
+                <enum name="GL_LUMINANCE_ALPHA32F_ARB"/>
+                <enum name="GL_RGBA16F_ARB"/>
+                <enum name="GL_RGB16F_ARB"/>
+                <enum name="GL_ALPHA16F_ARB"/>
+                <enum name="GL_INTENSITY16F_ARB"/>
+                <enum name="GL_LUMINANCE16F_ARB"/>
+                <enum name="GL_LUMINANCE_ALPHA16F_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_gather" supported="gl|glcore">
+            <require>
+                <enum name="GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB"/>
+                <enum name="GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB"/>
+                <enum name="GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_mirror_clamp_to_edge" supported="gl|glcore">
+            <require>
+                <enum name="GL_MIRROR_CLAMP_TO_EDGE"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_mirrored_repeat" supported="gl">
+            <require>
+                <enum name="GL_MIRRORED_REPEAT_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_multisample" supported="gl|glcore">
+            <require>
+                <enum name="GL_SAMPLE_POSITION"/>
+                <enum name="GL_SAMPLE_MASK"/>
+                <enum name="GL_SAMPLE_MASK_VALUE"/>
+                <enum name="GL_MAX_SAMPLE_MASK_WORDS"/>
+                <enum name="GL_TEXTURE_2D_MULTISAMPLE"/>
+                <enum name="GL_PROXY_TEXTURE_2D_MULTISAMPLE"/>
+                <enum name="GL_TEXTURE_2D_MULTISAMPLE_ARRAY"/>
+                <enum name="GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY"/>
+                <enum name="GL_TEXTURE_BINDING_2D_MULTISAMPLE"/>
+                <enum name="GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY"/>
+                <enum name="GL_TEXTURE_SAMPLES"/>
+                <enum name="GL_TEXTURE_FIXED_SAMPLE_LOCATIONS"/>
+                <enum name="GL_SAMPLER_2D_MULTISAMPLE"/>
+                <enum name="GL_INT_SAMPLER_2D_MULTISAMPLE"/>
+                <enum name="GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE"/>
+                <enum name="GL_SAMPLER_2D_MULTISAMPLE_ARRAY"/>
+                <enum name="GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY"/>
+                <enum name="GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY"/>
+                <enum name="GL_MAX_COLOR_TEXTURE_SAMPLES"/>
+                <enum name="GL_MAX_DEPTH_TEXTURE_SAMPLES"/>
+                <enum name="GL_MAX_INTEGER_SAMPLES"/>
+                <command name="glTexImage2DMultisample"/>
+                <command name="glTexImage3DMultisample"/>
+                <command name="glGetMultisamplefv"/>
+                <command name="glSampleMaski"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_non_power_of_two" supported="gl"/>
+        <extension name="GL_ARB_texture_query_levels" supported="gl|glcore"/>
+        <extension name="GL_ARB_texture_query_lod" supported="gl|glcore"/>
+        <extension name="GL_ARB_texture_rectangle" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_RECTANGLE_ARB"/>
+                <enum name="GL_TEXTURE_BINDING_RECTANGLE_ARB"/>
+                <enum name="GL_PROXY_TEXTURE_RECTANGLE_ARB"/>
+                <enum name="GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_rg" supported="gl|glcore">
+            <require>
+                <enum name="GL_RG"/>
+                <enum name="GL_RG_INTEGER"/>
+                <enum name="GL_R8"/>
+                <enum name="GL_R16"/>
+                <enum name="GL_RG8"/>
+                <enum name="GL_RG16"/>
+                <enum name="GL_R16F"/>
+                <enum name="GL_R32F"/>
+                <enum name="GL_RG16F"/>
+                <enum name="GL_RG32F"/>
+                <enum name="GL_R8I"/>
+                <enum name="GL_R8UI"/>
+                <enum name="GL_R16I"/>
+                <enum name="GL_R16UI"/>
+                <enum name="GL_R32I"/>
+                <enum name="GL_R32UI"/>
+                <enum name="GL_RG8I"/>
+                <enum name="GL_RG8UI"/>
+                <enum name="GL_RG16I"/>
+                <enum name="GL_RG16UI"/>
+                <enum name="GL_RG32I"/>
+                <enum name="GL_RG32UI"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_rgb10_a2ui" supported="gl|glcore">
+            <require>
+                <enum name="GL_RGB10_A2UI"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_stencil8" supported="gl|glcore">
+            <require>
+                <enum name="GL_STENCIL_INDEX"/>
+                <enum name="GL_STENCIL_INDEX8"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_storage" supported="gl|glcore">
+            <require>
+                <enum name="GL_TEXTURE_IMMUTABLE_FORMAT"/>
+                <command name="glTexStorage1D"/>
+                <command name="glTexStorage2D"/>
+                <command name="glTexStorage3D"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_storage_multisample" supported="gl|glcore">
+            <require>
+                <command name="glTexStorage2DMultisample"/>
+                <command name="glTexStorage3DMultisample"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_swizzle" supported="gl|glcore">
+            <require>
+                <enum name="GL_TEXTURE_SWIZZLE_R"/>
+                <enum name="GL_TEXTURE_SWIZZLE_G"/>
+                <enum name="GL_TEXTURE_SWIZZLE_B"/>
+                <enum name="GL_TEXTURE_SWIZZLE_A"/>
+                <enum name="GL_TEXTURE_SWIZZLE_RGBA"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_texture_view" supported="gl|glcore">
+            <require>
+                <enum name="GL_TEXTURE_VIEW_MIN_LEVEL"/>
+                <enum name="GL_TEXTURE_VIEW_NUM_LEVELS"/>
+                <enum name="GL_TEXTURE_VIEW_MIN_LAYER"/>
+                <enum name="GL_TEXTURE_VIEW_NUM_LAYERS"/>
+                <enum name="GL_TEXTURE_IMMUTABLE_LEVELS"/>
+                <command name="glTextureView"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_timer_query" supported="gl|glcore">
+            <require>
+                <enum name="GL_TIME_ELAPSED"/>
+                <enum name="GL_TIMESTAMP"/>
+                <command name="glQueryCounter"/>
+                <command name="glGetQueryObjecti64v"/>
+                <command name="glGetQueryObjectui64v"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_transform_feedback2" supported="gl|glcore">
+            <require>
+                <enum name="GL_TRANSFORM_FEEDBACK"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_PAUSED"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_ACTIVE"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BINDING"/>
+                <command name="glBindTransformFeedback"/>
+                <command name="glDeleteTransformFeedbacks"/>
+                <command name="glGenTransformFeedbacks"/>
+                <command name="glIsTransformFeedback"/>
+                <command name="glPauseTransformFeedback"/>
+                <command name="glResumeTransformFeedback"/>
+                <command name="glDrawTransformFeedback"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_transform_feedback3" supported="gl|glcore">
+            <require>
+                <enum name="GL_MAX_TRANSFORM_FEEDBACK_BUFFERS"/>
+                <enum name="GL_MAX_VERTEX_STREAMS"/>
+                <command name="glDrawTransformFeedbackStream"/>
+                <command name="glBeginQueryIndexed"/>
+                <command name="glEndQueryIndexed"/>
+                <command name="glGetQueryIndexediv"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_transform_feedback_instanced" supported="gl|glcore">
+            <require>
+                <command name="glDrawTransformFeedbackInstanced"/>
+                <command name="glDrawTransformFeedbackStreamInstanced"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_transpose_matrix" supported="gl">
+            <require>
+                <enum name="GL_TRANSPOSE_MODELVIEW_MATRIX_ARB"/>
+                <enum name="GL_TRANSPOSE_PROJECTION_MATRIX_ARB"/>
+                <enum name="GL_TRANSPOSE_TEXTURE_MATRIX_ARB"/>
+                <enum name="GL_TRANSPOSE_COLOR_MATRIX_ARB"/>
+                <command name="glLoadTransposeMatrixfARB"/>
+                <command name="glLoadTransposeMatrixdARB"/>
+                <command name="glMultTransposeMatrixfARB"/>
+                <command name="glMultTransposeMatrixdARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_uniform_buffer_object" supported="gl|glcore">
+            <require>
+                <enum name="GL_UNIFORM_BUFFER"/>
+                <enum name="GL_UNIFORM_BUFFER_BINDING"/>
+                <enum name="GL_UNIFORM_BUFFER_START"/>
+                <enum name="GL_UNIFORM_BUFFER_SIZE"/>
+                <enum name="GL_MAX_VERTEX_UNIFORM_BLOCKS"/>
+                <enum name="GL_MAX_GEOMETRY_UNIFORM_BLOCKS"/>
+                <enum name="GL_MAX_FRAGMENT_UNIFORM_BLOCKS"/>
+                <enum name="GL_MAX_COMBINED_UNIFORM_BLOCKS"/>
+                <enum name="GL_MAX_UNIFORM_BUFFER_BINDINGS"/>
+                <enum name="GL_MAX_UNIFORM_BLOCK_SIZE"/>
+                <enum name="GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS"/>
+                <enum name="GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS"/>
+                <enum name="GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS"/>
+                <enum name="GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT"/>
+                <enum name="GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH"/>
+                <enum name="GL_ACTIVE_UNIFORM_BLOCKS"/>
+                <enum name="GL_UNIFORM_TYPE"/>
+                <enum name="GL_UNIFORM_SIZE"/>
+                <enum name="GL_UNIFORM_NAME_LENGTH"/>
+                <enum name="GL_UNIFORM_BLOCK_INDEX"/>
+                <enum name="GL_UNIFORM_OFFSET"/>
+                <enum name="GL_UNIFORM_ARRAY_STRIDE"/>
+                <enum name="GL_UNIFORM_MATRIX_STRIDE"/>
+                <enum name="GL_UNIFORM_IS_ROW_MAJOR"/>
+                <enum name="GL_UNIFORM_BLOCK_BINDING"/>
+                <enum name="GL_UNIFORM_BLOCK_DATA_SIZE"/>
+                <enum name="GL_UNIFORM_BLOCK_NAME_LENGTH"/>
+                <enum name="GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS"/>
+                <enum name="GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"/>
+                <enum name="GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER"/>
+                <enum name="GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER"/>
+                <enum name="GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER"/>
+                <enum name="GL_INVALID_INDEX"/>
+                <command name="glGetUniformIndices"/>
+                <command name="glGetActiveUniformsiv"/>
+                <command name="glGetActiveUniformName"/>
+                <command name="glGetUniformBlockIndex"/>
+                <command name="glGetActiveUniformBlockiv"/>
+                <command name="glGetActiveUniformBlockName"/>
+                <command name="glUniformBlockBinding"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_vertex_array_bgra" supported="gl|glcore">
+            <require>
+                <enum name="GL_BGRA"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_vertex_array_object" supported="gl|glcore">
+            <require>
+                <enum name="GL_VERTEX_ARRAY_BINDING"/>
+                <command name="glBindVertexArray"/>
+                <command name="glDeleteVertexArrays"/>
+                <command name="glGenVertexArrays"/>
+                <command name="glIsVertexArray"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_vertex_attrib_64bit" supported="gl|glcore">
+            <require>
+                <enum name="GL_RGB32I"/>
+                <enum name="GL_DOUBLE_VEC2"/>
+                <enum name="GL_DOUBLE_VEC3"/>
+                <enum name="GL_DOUBLE_VEC4"/>
+                <enum name="GL_DOUBLE_MAT2"/>
+                <enum name="GL_DOUBLE_MAT3"/>
+                <enum name="GL_DOUBLE_MAT4"/>
+                <enum name="GL_DOUBLE_MAT2x3"/>
+                <enum name="GL_DOUBLE_MAT2x4"/>
+                <enum name="GL_DOUBLE_MAT3x2"/>
+                <enum name="GL_DOUBLE_MAT3x4"/>
+                <enum name="GL_DOUBLE_MAT4x2"/>
+                <enum name="GL_DOUBLE_MAT4x3"/>
+                <command name="glVertexAttribL1d"/>
+                <command name="glVertexAttribL2d"/>
+                <command name="glVertexAttribL3d"/>
+                <command name="glVertexAttribL4d"/>
+                <command name="glVertexAttribL1dv"/>
+                <command name="glVertexAttribL2dv"/>
+                <command name="glVertexAttribL3dv"/>
+                <command name="glVertexAttribL4dv"/>
+                <command name="glVertexAttribLPointer"/>
+                <command name="glGetVertexAttribLdv"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_vertex_attrib_binding" supported="gl|glcore">
+            <require>
+                <enum name="GL_VERTEX_ATTRIB_BINDING"/>
+                <enum name="GL_VERTEX_ATTRIB_RELATIVE_OFFSET"/>
+                <enum name="GL_VERTEX_BINDING_DIVISOR"/>
+                <enum name="GL_VERTEX_BINDING_OFFSET"/>
+                <enum name="GL_VERTEX_BINDING_STRIDE"/>
+                <enum name="GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET"/>
+                <enum name="GL_MAX_VERTEX_ATTRIB_BINDINGS"/>
+                <command name="glBindVertexBuffer"/>
+                <command name="glVertexAttribFormat"/>
+                <command name="glVertexAttribIFormat"/>
+                <command name="glVertexAttribLFormat"/>
+                <command name="glVertexAttribBinding"/>
+                <command name="glVertexBindingDivisor"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_vertex_blend" supported="gl">
+            <require>
+                <enum name="GL_MAX_VERTEX_UNITS_ARB"/>
+                <enum name="GL_ACTIVE_VERTEX_UNITS_ARB"/>
+                <enum name="GL_WEIGHT_SUM_UNITY_ARB"/>
+                <enum name="GL_VERTEX_BLEND_ARB"/>
+                <enum name="GL_CURRENT_WEIGHT_ARB"/>
+                <enum name="GL_WEIGHT_ARRAY_TYPE_ARB"/>
+                <enum name="GL_WEIGHT_ARRAY_STRIDE_ARB"/>
+                <enum name="GL_WEIGHT_ARRAY_SIZE_ARB"/>
+                <enum name="GL_WEIGHT_ARRAY_POINTER_ARB"/>
+                <enum name="GL_WEIGHT_ARRAY_ARB"/>
+                <enum name="GL_MODELVIEW0_ARB"/>
+                <enum name="GL_MODELVIEW1_ARB"/>
+                <enum name="GL_MODELVIEW2_ARB"/>
+                <enum name="GL_MODELVIEW3_ARB"/>
+                <enum name="GL_MODELVIEW4_ARB"/>
+                <enum name="GL_MODELVIEW5_ARB"/>
+                <enum name="GL_MODELVIEW6_ARB"/>
+                <enum name="GL_MODELVIEW7_ARB"/>
+                <enum name="GL_MODELVIEW8_ARB"/>
+                <enum name="GL_MODELVIEW9_ARB"/>
+                <enum name="GL_MODELVIEW10_ARB"/>
+                <enum name="GL_MODELVIEW11_ARB"/>
+                <enum name="GL_MODELVIEW12_ARB"/>
+                <enum name="GL_MODELVIEW13_ARB"/>
+                <enum name="GL_MODELVIEW14_ARB"/>
+                <enum name="GL_MODELVIEW15_ARB"/>
+                <enum name="GL_MODELVIEW16_ARB"/>
+                <enum name="GL_MODELVIEW17_ARB"/>
+                <enum name="GL_MODELVIEW18_ARB"/>
+                <enum name="GL_MODELVIEW19_ARB"/>
+                <enum name="GL_MODELVIEW20_ARB"/>
+                <enum name="GL_MODELVIEW21_ARB"/>
+                <enum name="GL_MODELVIEW22_ARB"/>
+                <enum name="GL_MODELVIEW23_ARB"/>
+                <enum name="GL_MODELVIEW24_ARB"/>
+                <enum name="GL_MODELVIEW25_ARB"/>
+                <enum name="GL_MODELVIEW26_ARB"/>
+                <enum name="GL_MODELVIEW27_ARB"/>
+                <enum name="GL_MODELVIEW28_ARB"/>
+                <enum name="GL_MODELVIEW29_ARB"/>
+                <enum name="GL_MODELVIEW30_ARB"/>
+                <enum name="GL_MODELVIEW31_ARB"/>
+                <command name="glWeightbvARB"/>
+                <command name="glWeightsvARB"/>
+                <command name="glWeightivARB"/>
+                <command name="glWeightfvARB"/>
+                <command name="glWeightdvARB"/>
+                <command name="glWeightubvARB"/>
+                <command name="glWeightusvARB"/>
+                <command name="glWeightuivARB"/>
+                <command name="glWeightPointerARB"/>
+                <command name="glVertexBlendARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_vertex_buffer_object" supported="gl">
+            <require>
+                <enum name="GL_BUFFER_SIZE_ARB"/>
+                <enum name="GL_BUFFER_USAGE_ARB"/>
+                <enum name="GL_ARRAY_BUFFER_ARB"/>
+                <enum name="GL_ELEMENT_ARRAY_BUFFER_ARB"/>
+                <enum name="GL_ARRAY_BUFFER_BINDING_ARB"/>
+                <enum name="GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB"/>
+                <enum name="GL_VERTEX_ARRAY_BUFFER_BINDING_ARB"/>
+                <enum name="GL_NORMAL_ARRAY_BUFFER_BINDING_ARB"/>
+                <enum name="GL_COLOR_ARRAY_BUFFER_BINDING_ARB"/>
+                <enum name="GL_INDEX_ARRAY_BUFFER_BINDING_ARB"/>
+                <enum name="GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB"/>
+                <enum name="GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB"/>
+                <enum name="GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB"/>
+                <enum name="GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB"/>
+                <enum name="GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB"/>
+                <enum name="GL_READ_ONLY_ARB"/>
+                <enum name="GL_WRITE_ONLY_ARB"/>
+                <enum name="GL_READ_WRITE_ARB"/>
+                <enum name="GL_BUFFER_ACCESS_ARB"/>
+                <enum name="GL_BUFFER_MAPPED_ARB"/>
+                <enum name="GL_BUFFER_MAP_POINTER_ARB"/>
+                <enum name="GL_STREAM_DRAW_ARB"/>
+                <enum name="GL_STREAM_READ_ARB"/>
+                <enum name="GL_STREAM_COPY_ARB"/>
+                <enum name="GL_STATIC_DRAW_ARB"/>
+                <enum name="GL_STATIC_READ_ARB"/>
+                <enum name="GL_STATIC_COPY_ARB"/>
+                <enum name="GL_DYNAMIC_DRAW_ARB"/>
+                <enum name="GL_DYNAMIC_READ_ARB"/>
+                <enum name="GL_DYNAMIC_COPY_ARB"/>
+                <command name="glBindBufferARB"/>
+                <command name="glDeleteBuffersARB"/>
+                <command name="glGenBuffersARB"/>
+                <command name="glIsBufferARB"/>
+                <command name="glBufferDataARB"/>
+                <command name="glBufferSubDataARB"/>
+                <command name="glGetBufferSubDataARB"/>
+                <command name="glMapBufferARB"/>
+                <command name="glUnmapBufferARB"/>
+                <command name="glGetBufferParameterivARB"/>
+                <command name="glGetBufferPointervARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_vertex_program" supported="gl">
+            <require>
+                <enum name="GL_COLOR_SUM_ARB"/>
+                <enum name="GL_VERTEX_PROGRAM_ARB"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB"/>
+                <enum name="GL_CURRENT_VERTEX_ATTRIB_ARB"/>
+                <enum name="GL_PROGRAM_LENGTH_ARB"/>
+                <enum name="GL_PROGRAM_STRING_ARB"/>
+                <enum name="GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB"/>
+                <enum name="GL_MAX_PROGRAM_MATRICES_ARB"/>
+                <enum name="GL_CURRENT_MATRIX_STACK_DEPTH_ARB"/>
+                <enum name="GL_CURRENT_MATRIX_ARB"/>
+                <enum name="GL_VERTEX_PROGRAM_POINT_SIZE_ARB"/>
+                <enum name="GL_VERTEX_PROGRAM_TWO_SIDE_ARB"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB"/>
+                <enum name="GL_PROGRAM_ERROR_POSITION_ARB"/>
+                <enum name="GL_PROGRAM_BINDING_ARB"/>
+                <enum name="GL_MAX_VERTEX_ATTRIBS_ARB"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB"/>
+                <enum name="GL_PROGRAM_ERROR_STRING_ARB"/>
+                <enum name="GL_PROGRAM_FORMAT_ASCII_ARB"/>
+                <enum name="GL_PROGRAM_FORMAT_ARB"/>
+                <enum name="GL_PROGRAM_INSTRUCTIONS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_INSTRUCTIONS_ARB"/>
+                <enum name="GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB"/>
+                <enum name="GL_PROGRAM_TEMPORARIES_ARB"/>
+                <enum name="GL_MAX_PROGRAM_TEMPORARIES_ARB"/>
+                <enum name="GL_PROGRAM_NATIVE_TEMPORARIES_ARB"/>
+                <enum name="GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB"/>
+                <enum name="GL_PROGRAM_PARAMETERS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_PARAMETERS_ARB"/>
+                <enum name="GL_PROGRAM_NATIVE_PARAMETERS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB"/>
+                <enum name="GL_PROGRAM_ATTRIBS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_ATTRIBS_ARB"/>
+                <enum name="GL_PROGRAM_NATIVE_ATTRIBS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB"/>
+                <enum name="GL_PROGRAM_ADDRESS_REGISTERS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB"/>
+                <enum name="GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB"/>
+                <enum name="GL_MAX_PROGRAM_ENV_PARAMETERS_ARB"/>
+                <enum name="GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB"/>
+                <enum name="GL_TRANSPOSE_CURRENT_MATRIX_ARB"/>
+                <enum name="GL_MATRIX0_ARB"/>
+                <enum name="GL_MATRIX1_ARB"/>
+                <enum name="GL_MATRIX2_ARB"/>
+                <enum name="GL_MATRIX3_ARB"/>
+                <enum name="GL_MATRIX4_ARB"/>
+                <enum name="GL_MATRIX5_ARB"/>
+                <enum name="GL_MATRIX6_ARB"/>
+                <enum name="GL_MATRIX7_ARB"/>
+                <enum name="GL_MATRIX8_ARB"/>
+                <enum name="GL_MATRIX9_ARB"/>
+                <enum name="GL_MATRIX10_ARB"/>
+                <enum name="GL_MATRIX11_ARB"/>
+                <enum name="GL_MATRIX12_ARB"/>
+                <enum name="GL_MATRIX13_ARB"/>
+                <enum name="GL_MATRIX14_ARB"/>
+                <enum name="GL_MATRIX15_ARB"/>
+                <enum name="GL_MATRIX16_ARB"/>
+                <enum name="GL_MATRIX17_ARB"/>
+                <enum name="GL_MATRIX18_ARB"/>
+                <enum name="GL_MATRIX19_ARB"/>
+                <enum name="GL_MATRIX20_ARB"/>
+                <enum name="GL_MATRIX21_ARB"/>
+                <enum name="GL_MATRIX22_ARB"/>
+                <enum name="GL_MATRIX23_ARB"/>
+                <enum name="GL_MATRIX24_ARB"/>
+                <enum name="GL_MATRIX25_ARB"/>
+                <enum name="GL_MATRIX26_ARB"/>
+                <enum name="GL_MATRIX27_ARB"/>
+                <enum name="GL_MATRIX28_ARB"/>
+                <enum name="GL_MATRIX29_ARB"/>
+                <enum name="GL_MATRIX30_ARB"/>
+                <enum name="GL_MATRIX31_ARB"/>
+                <command name="glVertexAttrib1dARB"/>
+                <command name="glVertexAttrib1dvARB"/>
+                <command name="glVertexAttrib1fARB"/>
+                <command name="glVertexAttrib1fvARB"/>
+                <command name="glVertexAttrib1sARB"/>
+                <command name="glVertexAttrib1svARB"/>
+                <command name="glVertexAttrib2dARB"/>
+                <command name="glVertexAttrib2dvARB"/>
+                <command name="glVertexAttrib2fARB"/>
+                <command name="glVertexAttrib2fvARB"/>
+                <command name="glVertexAttrib2sARB"/>
+                <command name="glVertexAttrib2svARB"/>
+                <command name="glVertexAttrib3dARB"/>
+                <command name="glVertexAttrib3dvARB"/>
+                <command name="glVertexAttrib3fARB"/>
+                <command name="glVertexAttrib3fvARB"/>
+                <command name="glVertexAttrib3sARB"/>
+                <command name="glVertexAttrib3svARB"/>
+                <command name="glVertexAttrib4NbvARB"/>
+                <command name="glVertexAttrib4NivARB"/>
+                <command name="glVertexAttrib4NsvARB"/>
+                <command name="glVertexAttrib4NubARB"/>
+                <command name="glVertexAttrib4NubvARB"/>
+                <command name="glVertexAttrib4NuivARB"/>
+                <command name="glVertexAttrib4NusvARB"/>
+                <command name="glVertexAttrib4bvARB"/>
+                <command name="glVertexAttrib4dARB"/>
+                <command name="glVertexAttrib4dvARB"/>
+                <command name="glVertexAttrib4fARB"/>
+                <command name="glVertexAttrib4fvARB"/>
+                <command name="glVertexAttrib4ivARB"/>
+                <command name="glVertexAttrib4sARB"/>
+                <command name="glVertexAttrib4svARB"/>
+                <command name="glVertexAttrib4ubvARB"/>
+                <command name="glVertexAttrib4uivARB"/>
+                <command name="glVertexAttrib4usvARB"/>
+                <command name="glVertexAttribPointerARB"/>
+                <command name="glEnableVertexAttribArrayARB"/>
+                <command name="glDisableVertexAttribArrayARB"/>
+                <command name="glProgramStringARB"/>
+                <command name="glBindProgramARB"/>
+                <command name="glDeleteProgramsARB"/>
+                <command name="glGenProgramsARB"/>
+                <command name="glProgramEnvParameter4dARB"/>
+                <command name="glProgramEnvParameter4dvARB"/>
+                <command name="glProgramEnvParameter4fARB"/>
+                <command name="glProgramEnvParameter4fvARB"/>
+                <command name="glProgramLocalParameter4dARB"/>
+                <command name="glProgramLocalParameter4dvARB"/>
+                <command name="glProgramLocalParameter4fARB"/>
+                <command name="glProgramLocalParameter4fvARB"/>
+                <command name="glGetProgramEnvParameterdvARB"/>
+                <command name="glGetProgramEnvParameterfvARB"/>
+                <command name="glGetProgramLocalParameterdvARB"/>
+                <command name="glGetProgramLocalParameterfvARB"/>
+                <command name="glGetProgramivARB"/>
+                <command name="glGetProgramStringARB"/>
+                <command name="glGetVertexAttribdvARB"/>
+                <command name="glGetVertexAttribfvARB"/>
+                <command name="glGetVertexAttribivARB"/>
+                <command name="glGetVertexAttribPointervARB"/>
+                <command name="glIsProgramARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_vertex_shader" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_SHADER_ARB"/>
+                <enum name="GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB"/>
+                <enum name="GL_MAX_VARYING_FLOATS_ARB"/>
+                <enum name="GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB"/>
+                <enum name="GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB"/>
+                <enum name="GL_OBJECT_ACTIVE_ATTRIBUTES_ARB"/>
+                <enum name="GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB"/>
+                <enum name="GL_MAX_VERTEX_ATTRIBS_ARB"/>
+                <enum name="GL_MAX_TEXTURE_IMAGE_UNITS_ARB"/>
+                <enum name="GL_MAX_TEXTURE_COORDS_ARB"/>
+                <enum name="GL_VERTEX_PROGRAM_POINT_SIZE_ARB"/>
+                <enum name="GL_VERTEX_PROGRAM_TWO_SIDE_ARB"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB"/>
+                <enum name="GL_CURRENT_VERTEX_ATTRIB_ARB"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB"/>
+                <enum name="GL_FLOAT"/>
+                <enum name="GL_FLOAT_VEC2_ARB"/>
+                <enum name="GL_FLOAT_VEC3_ARB"/>
+                <enum name="GL_FLOAT_VEC4_ARB"/>
+                <enum name="GL_FLOAT_MAT2_ARB"/>
+                <enum name="GL_FLOAT_MAT3_ARB"/>
+                <enum name="GL_FLOAT_MAT4_ARB"/>
+                <command name="glVertexAttrib1fARB"/>
+                <command name="glVertexAttrib1sARB"/>
+                <command name="glVertexAttrib1dARB"/>
+                <command name="glVertexAttrib2fARB"/>
+                <command name="glVertexAttrib2sARB"/>
+                <command name="glVertexAttrib2dARB"/>
+                <command name="glVertexAttrib3fARB"/>
+                <command name="glVertexAttrib3sARB"/>
+                <command name="glVertexAttrib3dARB"/>
+                <command name="glVertexAttrib4fARB"/>
+                <command name="glVertexAttrib4sARB"/>
+                <command name="glVertexAttrib4dARB"/>
+                <command name="glVertexAttrib4NubARB"/>
+                <command name="glVertexAttrib1fvARB"/>
+                <command name="glVertexAttrib1svARB"/>
+                <command name="glVertexAttrib1dvARB"/>
+                <command name="glVertexAttrib2fvARB"/>
+                <command name="glVertexAttrib2svARB"/>
+                <command name="glVertexAttrib2dvARB"/>
+                <command name="glVertexAttrib3fvARB"/>
+                <command name="glVertexAttrib3svARB"/>
+                <command name="glVertexAttrib3dvARB"/>
+                <command name="glVertexAttrib4fvARB"/>
+                <command name="glVertexAttrib4svARB"/>
+                <command name="glVertexAttrib4dvARB"/>
+                <command name="glVertexAttrib4ivARB"/>
+                <command name="glVertexAttrib4bvARB"/>
+                <command name="glVertexAttrib4ubvARB"/>
+                <command name="glVertexAttrib4usvARB"/>
+                <command name="glVertexAttrib4uivARB"/>
+                <command name="glVertexAttrib4NbvARB"/>
+                <command name="glVertexAttrib4NsvARB"/>
+                <command name="glVertexAttrib4NivARB"/>
+                <command name="glVertexAttrib4NubvARB"/>
+                <command name="glVertexAttrib4NusvARB"/>
+                <command name="glVertexAttrib4NuivARB"/>
+                <command name="glVertexAttribPointerARB"/>
+                <command name="glEnableVertexAttribArrayARB"/>
+                <command name="glDisableVertexAttribArrayARB"/>
+                <command name="glBindAttribLocationARB"/>
+                <command name="glGetActiveAttribARB"/>
+                <command name="glGetAttribLocationARB"/>
+                <command name="glGetVertexAttribdvARB"/>
+                <command name="glGetVertexAttribfvARB"/>
+                <command name="glGetVertexAttribivARB"/>
+                <command name="glGetVertexAttribPointervARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_vertex_type_10f_11f_11f_rev" supported="gl|glcore">
+            <require>
+                <enum name="GL_UNSIGNED_INT_10F_11F_11F_REV"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_vertex_type_2_10_10_10_rev" supported="gl|glcore">
+            <require>
+                <enum name="GL_UNSIGNED_INT_2_10_10_10_REV"/>
+                <enum name="GL_INT_2_10_10_10_REV"/>
+                <command name="glVertexAttribP1ui"/>
+                <command name="glVertexAttribP1uiv"/>
+                <command name="glVertexAttribP2ui"/>
+                <command name="glVertexAttribP2uiv"/>
+                <command name="glVertexAttribP3ui"/>
+                <command name="glVertexAttribP3uiv"/>
+                <command name="glVertexAttribP4ui"/>
+                <command name="glVertexAttribP4uiv"/>
+            </require>
+            <require api="gl" profile="compatibility">
+                <command name="glVertexP2ui"/>
+                <command name="glVertexP2uiv"/>
+                <command name="glVertexP3ui"/>
+                <command name="glVertexP3uiv"/>
+                <command name="glVertexP4ui"/>
+                <command name="glVertexP4uiv"/>
+                <command name="glTexCoordP1ui"/>
+                <command name="glTexCoordP1uiv"/>
+                <command name="glTexCoordP2ui"/>
+                <command name="glTexCoordP2uiv"/>
+                <command name="glTexCoordP3ui"/>
+                <command name="glTexCoordP3uiv"/>
+                <command name="glTexCoordP4ui"/>
+                <command name="glTexCoordP4uiv"/>
+                <command name="glMultiTexCoordP1ui"/>
+                <command name="glMultiTexCoordP1uiv"/>
+                <command name="glMultiTexCoordP2ui"/>
+                <command name="glMultiTexCoordP2uiv"/>
+                <command name="glMultiTexCoordP3ui"/>
+                <command name="glMultiTexCoordP3uiv"/>
+                <command name="glMultiTexCoordP4ui"/>
+                <command name="glMultiTexCoordP4uiv"/>
+                <command name="glNormalP3ui"/>
+                <command name="glNormalP3uiv"/>
+                <command name="glColorP3ui"/>
+                <command name="glColorP3uiv"/>
+                <command name="glColorP4ui"/>
+                <command name="glColorP4uiv"/>
+                <command name="glSecondaryColorP3ui"/>
+                <command name="glSecondaryColorP3uiv"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_viewport_array" supported="gl|glcore">
+            <require>
+                <enum name="GL_SCISSOR_BOX"/>
+                <enum name="GL_VIEWPORT"/>
+                <enum name="GL_DEPTH_RANGE"/>
+                <enum name="GL_SCISSOR_TEST"/>
+                <enum name="GL_MAX_VIEWPORTS"/>
+                <enum name="GL_VIEWPORT_SUBPIXEL_BITS"/>
+                <enum name="GL_VIEWPORT_BOUNDS_RANGE"/>
+                <enum name="GL_LAYER_PROVOKING_VERTEX"/>
+                <enum name="GL_VIEWPORT_INDEX_PROVOKING_VERTEX"/>
+                <enum name="GL_UNDEFINED_VERTEX"/>
+                <enum name="GL_FIRST_VERTEX_CONVENTION"/>
+                <enum name="GL_LAST_VERTEX_CONVENTION"/>
+                <enum name="GL_PROVOKING_VERTEX"/>
+                <command name="glViewportArrayv"/>
+                <command name="glViewportIndexedf"/>
+                <command name="glViewportIndexedfv"/>
+                <command name="glScissorArrayv"/>
+                <command name="glScissorIndexed"/>
+                <command name="glScissorIndexedv"/>
+                <command name="glDepthRangeArrayv"/>
+                <command name="glDepthRangeIndexed"/>
+                <command name="glGetFloati_v"/>
+                <command name="glGetDoublei_v"/>
+            </require>
+        </extension>
+        <extension name="GL_ARB_window_pos" supported="gl">
+            <require>
+                <command name="glWindowPos2dARB"/>
+                <command name="glWindowPos2dvARB"/>
+                <command name="glWindowPos2fARB"/>
+                <command name="glWindowPos2fvARB"/>
+                <command name="glWindowPos2iARB"/>
+                <command name="glWindowPos2ivARB"/>
+                <command name="glWindowPos2sARB"/>
+                <command name="glWindowPos2svARB"/>
+                <command name="glWindowPos3dARB"/>
+                <command name="glWindowPos3dvARB"/>
+                <command name="glWindowPos3fARB"/>
+                <command name="glWindowPos3fvARB"/>
+                <command name="glWindowPos3iARB"/>
+                <command name="glWindowPos3ivARB"/>
+                <command name="glWindowPos3sARB"/>
+                <command name="glWindowPos3svARB"/>
+            </require>
+        </extension>
+        <extension name="GL_ARM_mali_program_binary" supported="gles2">
+            <require>
+                <enum name="GL_MALI_PROGRAM_BINARY_ARM"/>
+            </require>
+        </extension>
+        <extension name="GL_ARM_mali_shader_binary" supported="gles2">
+            <require>
+                <enum name="GL_MALI_SHADER_BINARY_ARM"/>
+            </require>
+        </extension>
+        <extension name="GL_ARM_rgba8" supported="gles1|gles2"/>
+        <extension name="GL_ARM_shader_framebuffer_fetch" supported="gles2">
+            <require>
+                <enum name="GL_FETCH_PER_SAMPLE_ARM"/>
+                <enum name="GL_FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM"/>
+            </require>
+        </extension>
+        <extension name="GL_ARM_shader_framebuffer_fetch_depth_stencil" supported="gles2"/>
+        <extension name="GL_ATI_draw_buffers" supported="gl">
+            <require>
+                <enum name="GL_MAX_DRAW_BUFFERS_ATI"/>
+                <enum name="GL_DRAW_BUFFER0_ATI"/>
+                <enum name="GL_DRAW_BUFFER1_ATI"/>
+                <enum name="GL_DRAW_BUFFER2_ATI"/>
+                <enum name="GL_DRAW_BUFFER3_ATI"/>
+                <enum name="GL_DRAW_BUFFER4_ATI"/>
+                <enum name="GL_DRAW_BUFFER5_ATI"/>
+                <enum name="GL_DRAW_BUFFER6_ATI"/>
+                <enum name="GL_DRAW_BUFFER7_ATI"/>
+                <enum name="GL_DRAW_BUFFER8_ATI"/>
+                <enum name="GL_DRAW_BUFFER9_ATI"/>
+                <enum name="GL_DRAW_BUFFER10_ATI"/>
+                <enum name="GL_DRAW_BUFFER11_ATI"/>
+                <enum name="GL_DRAW_BUFFER12_ATI"/>
+                <enum name="GL_DRAW_BUFFER13_ATI"/>
+                <enum name="GL_DRAW_BUFFER14_ATI"/>
+                <enum name="GL_DRAW_BUFFER15_ATI"/>
+                <command name="glDrawBuffersATI"/>
+            </require>
+        </extension>
+        <extension name="GL_ATI_element_array" supported="gl">
+            <require>
+                <enum name="GL_ELEMENT_ARRAY_ATI"/>
+                <enum name="GL_ELEMENT_ARRAY_TYPE_ATI"/>
+                <enum name="GL_ELEMENT_ARRAY_POINTER_ATI"/>
+                <command name="glElementPointerATI"/>
+                <command name="glDrawElementArrayATI"/>
+                <command name="glDrawRangeElementArrayATI"/>
+            </require>
+        </extension>
+        <extension name="GL_ATI_envmap_bumpmap" supported="gl">
+            <require>
+                <enum name="GL_BUMP_ROT_MATRIX_ATI"/>
+                <enum name="GL_BUMP_ROT_MATRIX_SIZE_ATI"/>
+                <enum name="GL_BUMP_NUM_TEX_UNITS_ATI"/>
+                <enum name="GL_BUMP_TEX_UNITS_ATI"/>
+                <enum name="GL_DUDV_ATI"/>
+                <enum name="GL_DU8DV8_ATI"/>
+                <enum name="GL_BUMP_ENVMAP_ATI"/>
+                <enum name="GL_BUMP_TARGET_ATI"/>
+                <command name="glTexBumpParameterivATI"/>
+                <command name="glTexBumpParameterfvATI"/>
+                <command name="glGetTexBumpParameterivATI"/>
+                <command name="glGetTexBumpParameterfvATI"/>
+            </require>
+        </extension>
+        <extension name="GL_ATI_fragment_shader" supported="gl">
+            <require>
+                <enum name="GL_FRAGMENT_SHADER_ATI"/>
+                <enum name="GL_REG_0_ATI"/>
+                <enum name="GL_REG_1_ATI"/>
+                <enum name="GL_REG_2_ATI"/>
+                <enum name="GL_REG_3_ATI"/>
+                <enum name="GL_REG_4_ATI"/>
+                <enum name="GL_REG_5_ATI"/>
+                <enum name="GL_REG_6_ATI"/>
+                <enum name="GL_REG_7_ATI"/>
+                <enum name="GL_REG_8_ATI"/>
+                <enum name="GL_REG_9_ATI"/>
+                <enum name="GL_REG_10_ATI"/>
+                <enum name="GL_REG_11_ATI"/>
+                <enum name="GL_REG_12_ATI"/>
+                <enum name="GL_REG_13_ATI"/>
+                <enum name="GL_REG_14_ATI"/>
+                <enum name="GL_REG_15_ATI"/>
+                <enum name="GL_REG_16_ATI"/>
+                <enum name="GL_REG_17_ATI"/>
+                <enum name="GL_REG_18_ATI"/>
+                <enum name="GL_REG_19_ATI"/>
+                <enum name="GL_REG_20_ATI"/>
+                <enum name="GL_REG_21_ATI"/>
+                <enum name="GL_REG_22_ATI"/>
+                <enum name="GL_REG_23_ATI"/>
+                <enum name="GL_REG_24_ATI"/>
+                <enum name="GL_REG_25_ATI"/>
+                <enum name="GL_REG_26_ATI"/>
+                <enum name="GL_REG_27_ATI"/>
+                <enum name="GL_REG_28_ATI"/>
+                <enum name="GL_REG_29_ATI"/>
+                <enum name="GL_REG_30_ATI"/>
+                <enum name="GL_REG_31_ATI"/>
+                <enum name="GL_CON_0_ATI"/>
+                <enum name="GL_CON_1_ATI"/>
+                <enum name="GL_CON_2_ATI"/>
+                <enum name="GL_CON_3_ATI"/>
+                <enum name="GL_CON_4_ATI"/>
+                <enum name="GL_CON_5_ATI"/>
+                <enum name="GL_CON_6_ATI"/>
+                <enum name="GL_CON_7_ATI"/>
+                <enum name="GL_CON_8_ATI"/>
+                <enum name="GL_CON_9_ATI"/>
+                <enum name="GL_CON_10_ATI"/>
+                <enum name="GL_CON_11_ATI"/>
+                <enum name="GL_CON_12_ATI"/>
+                <enum name="GL_CON_13_ATI"/>
+                <enum name="GL_CON_14_ATI"/>
+                <enum name="GL_CON_15_ATI"/>
+                <enum name="GL_CON_16_ATI"/>
+                <enum name="GL_CON_17_ATI"/>
+                <enum name="GL_CON_18_ATI"/>
+                <enum name="GL_CON_19_ATI"/>
+                <enum name="GL_CON_20_ATI"/>
+                <enum name="GL_CON_21_ATI"/>
+                <enum name="GL_CON_22_ATI"/>
+                <enum name="GL_CON_23_ATI"/>
+                <enum name="GL_CON_24_ATI"/>
+                <enum name="GL_CON_25_ATI"/>
+                <enum name="GL_CON_26_ATI"/>
+                <enum name="GL_CON_27_ATI"/>
+                <enum name="GL_CON_28_ATI"/>
+                <enum name="GL_CON_29_ATI"/>
+                <enum name="GL_CON_30_ATI"/>
+                <enum name="GL_CON_31_ATI"/>
+                <enum name="GL_MOV_ATI"/>
+                <enum name="GL_ADD_ATI"/>
+                <enum name="GL_MUL_ATI"/>
+                <enum name="GL_SUB_ATI"/>
+                <enum name="GL_DOT3_ATI"/>
+                <enum name="GL_DOT4_ATI"/>
+                <enum name="GL_MAD_ATI"/>
+                <enum name="GL_LERP_ATI"/>
+                <enum name="GL_CND_ATI"/>
+                <enum name="GL_CND0_ATI"/>
+                <enum name="GL_DOT2_ADD_ATI"/>
+                <enum name="GL_SECONDARY_INTERPOLATOR_ATI"/>
+                <enum name="GL_NUM_FRAGMENT_REGISTERS_ATI"/>
+                <enum name="GL_NUM_FRAGMENT_CONSTANTS_ATI"/>
+                <enum name="GL_NUM_PASSES_ATI"/>
+                <enum name="GL_NUM_INSTRUCTIONS_PER_PASS_ATI"/>
+                <enum name="GL_NUM_INSTRUCTIONS_TOTAL_ATI"/>
+                <enum name="GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI"/>
+                <enum name="GL_NUM_LOOPBACK_COMPONENTS_ATI"/>
+                <enum name="GL_COLOR_ALPHA_PAIRING_ATI"/>
+                <enum name="GL_SWIZZLE_STR_ATI"/>
+                <enum name="GL_SWIZZLE_STQ_ATI"/>
+                <enum name="GL_SWIZZLE_STR_DR_ATI"/>
+                <enum name="GL_SWIZZLE_STQ_DQ_ATI"/>
+                <enum name="GL_SWIZZLE_STRQ_ATI"/>
+                <enum name="GL_SWIZZLE_STRQ_DQ_ATI"/>
+                <enum name="GL_RED_BIT_ATI"/>
+                <enum name="GL_GREEN_BIT_ATI"/>
+                <enum name="GL_BLUE_BIT_ATI"/>
+                <enum name="GL_2X_BIT_ATI"/>
+                <enum name="GL_4X_BIT_ATI"/>
+                <enum name="GL_8X_BIT_ATI"/>
+                <enum name="GL_HALF_BIT_ATI"/>
+                <enum name="GL_QUARTER_BIT_ATI"/>
+                <enum name="GL_EIGHTH_BIT_ATI"/>
+                <enum name="GL_SATURATE_BIT_ATI"/>
+                <enum name="GL_COMP_BIT_ATI"/>
+                <enum name="GL_NEGATE_BIT_ATI"/>
+                <enum name="GL_BIAS_BIT_ATI"/>
+                <command name="glGenFragmentShadersATI"/>
+                <command name="glBindFragmentShaderATI"/>
+                <command name="glDeleteFragmentShaderATI"/>
+                <command name="glBeginFragmentShaderATI"/>
+                <command name="glEndFragmentShaderATI"/>
+                <command name="glPassTexCoordATI"/>
+                <command name="glSampleMapATI"/>
+                <command name="glColorFragmentOp1ATI"/>
+                <command name="glColorFragmentOp2ATI"/>
+                <command name="glColorFragmentOp3ATI"/>
+                <command name="glAlphaFragmentOp1ATI"/>
+                <command name="glAlphaFragmentOp2ATI"/>
+                <command name="glAlphaFragmentOp3ATI"/>
+                <command name="glSetFragmentShaderConstantATI"/>
+            </require>
+        </extension>
+        <extension name="GL_ATI_map_object_buffer" supported="gl">
+            <require>
+                <command name="glMapObjectBufferATI"/>
+                <command name="glUnmapObjectBufferATI"/>
+            </require>
+        </extension>
+        <extension name="GL_ATI_meminfo" supported="gl">
+            <require>
+                <enum name="GL_VBO_FREE_MEMORY_ATI"/>
+                <enum name="GL_TEXTURE_FREE_MEMORY_ATI"/>
+                <enum name="GL_RENDERBUFFER_FREE_MEMORY_ATI"/>
+            </require>
+        </extension>
+        <extension name="GL_ATI_pixel_format_float" supported="gl" comment="WGL extension defining some associated GL enums. ATI does not export this extension.">
+            <require>
+                <enum name="GL_RGBA_FLOAT_MODE_ATI"/>
+                <enum name="GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI"/>
+            </require>
+        </extension>
+        <extension name="GL_ATI_pn_triangles" supported="gl">
+            <require>
+                <enum name="GL_PN_TRIANGLES_ATI"/>
+                <enum name="GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI"/>
+                <enum name="GL_PN_TRIANGLES_POINT_MODE_ATI"/>
+                <enum name="GL_PN_TRIANGLES_NORMAL_MODE_ATI"/>
+                <enum name="GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI"/>
+                <enum name="GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI"/>
+                <enum name="GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI"/>
+                <enum name="GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI"/>
+                <enum name="GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI"/>
+                <command name="glPNTrianglesiATI"/>
+                <command name="glPNTrianglesfATI"/>
+            </require>
+        </extension>
+        <extension name="GL_ATI_separate_stencil" supported="gl">
+            <require>
+                <enum name="GL_STENCIL_BACK_FUNC_ATI"/>
+                <enum name="GL_STENCIL_BACK_FAIL_ATI"/>
+                <enum name="GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI"/>
+                <enum name="GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI"/>
+                <command name="glStencilOpSeparateATI"/>
+                <command name="glStencilFuncSeparateATI"/>
+            </require>
+        </extension>
+        <extension name="GL_ATI_text_fragment_shader" supported="gl">
+            <require>
+                <enum name="GL_TEXT_FRAGMENT_SHADER_ATI"/>
+            </require>
+        </extension>
+        <extension name="GL_ATI_texture_env_combine3" supported="gl">
+            <require>
+                <enum name="GL_MODULATE_ADD_ATI"/>
+                <enum name="GL_MODULATE_SIGNED_ADD_ATI"/>
+                <enum name="GL_MODULATE_SUBTRACT_ATI"/>
+            </require>
+        </extension>
+        <extension name="GL_ATI_texture_float" supported="gl">
+            <require>
+                <enum name="GL_RGBA_FLOAT32_ATI"/>
+                <enum name="GL_RGB_FLOAT32_ATI"/>
+                <enum name="GL_ALPHA_FLOAT32_ATI"/>
+                <enum name="GL_INTENSITY_FLOAT32_ATI"/>
+                <enum name="GL_LUMINANCE_FLOAT32_ATI"/>
+                <enum name="GL_LUMINANCE_ALPHA_FLOAT32_ATI"/>
+                <enum name="GL_RGBA_FLOAT16_ATI"/>
+                <enum name="GL_RGB_FLOAT16_ATI"/>
+                <enum name="GL_ALPHA_FLOAT16_ATI"/>
+                <enum name="GL_INTENSITY_FLOAT16_ATI"/>
+                <enum name="GL_LUMINANCE_FLOAT16_ATI"/>
+                <enum name="GL_LUMINANCE_ALPHA_FLOAT16_ATI"/>
+            </require>
+        </extension>
+        <extension name="GL_ATI_texture_mirror_once" supported="gl">
+            <require>
+                <enum name="GL_MIRROR_CLAMP_ATI"/>
+                <enum name="GL_MIRROR_CLAMP_TO_EDGE_ATI"/>
+            </require>
+        </extension>
+        <extension name="GL_ATI_vertex_array_object" supported="gl">
+            <require>
+                <enum name="GL_STATIC_ATI"/>
+                <enum name="GL_DYNAMIC_ATI"/>
+                <enum name="GL_PRESERVE_ATI"/>
+                <enum name="GL_DISCARD_ATI"/>
+                <enum name="GL_OBJECT_BUFFER_SIZE_ATI"/>
+                <enum name="GL_OBJECT_BUFFER_USAGE_ATI"/>
+                <enum name="GL_ARRAY_OBJECT_BUFFER_ATI"/>
+                <enum name="GL_ARRAY_OBJECT_OFFSET_ATI"/>
+                <command name="glNewObjectBufferATI"/>
+                <command name="glIsObjectBufferATI"/>
+                <command name="glUpdateObjectBufferATI"/>
+                <command name="glGetObjectBufferfvATI"/>
+                <command name="glGetObjectBufferivATI"/>
+                <command name="glFreeObjectBufferATI"/>
+                <command name="glArrayObjectATI"/>
+                <command name="glGetArrayObjectfvATI"/>
+                <command name="glGetArrayObjectivATI"/>
+                <command name="glVariantArrayObjectATI"/>
+                <command name="glGetVariantArrayObjectfvATI"/>
+                <command name="glGetVariantArrayObjectivATI"/>
+            </require>
+        </extension>
+        <extension name="GL_ATI_vertex_attrib_array_object" supported="gl">
+            <require>
+                <command name="glVertexAttribArrayObjectATI"/>
+                <command name="glGetVertexAttribArrayObjectfvATI"/>
+                <command name="glGetVertexAttribArrayObjectivATI"/>
+            </require>
+        </extension>
+        <extension name="GL_ATI_vertex_streams" supported="gl">
+            <require>
+                <enum name="GL_MAX_VERTEX_STREAMS_ATI"/>
+                <enum name="GL_VERTEX_STREAM0_ATI"/>
+                <enum name="GL_VERTEX_STREAM1_ATI"/>
+                <enum name="GL_VERTEX_STREAM2_ATI"/>
+                <enum name="GL_VERTEX_STREAM3_ATI"/>
+                <enum name="GL_VERTEX_STREAM4_ATI"/>
+                <enum name="GL_VERTEX_STREAM5_ATI"/>
+                <enum name="GL_VERTEX_STREAM6_ATI"/>
+                <enum name="GL_VERTEX_STREAM7_ATI"/>
+                <enum name="GL_VERTEX_SOURCE_ATI"/>
+                <command name="glVertexStream1sATI"/>
+                <command name="glVertexStream1svATI"/>
+                <command name="glVertexStream1iATI"/>
+                <command name="glVertexStream1ivATI"/>
+                <command name="glVertexStream1fATI"/>
+                <command name="glVertexStream1fvATI"/>
+                <command name="glVertexStream1dATI"/>
+                <command name="glVertexStream1dvATI"/>
+                <command name="glVertexStream2sATI"/>
+                <command name="glVertexStream2svATI"/>
+                <command name="glVertexStream2iATI"/>
+                <command name="glVertexStream2ivATI"/>
+                <command name="glVertexStream2fATI"/>
+                <command name="glVertexStream2fvATI"/>
+                <command name="glVertexStream2dATI"/>
+                <command name="glVertexStream2dvATI"/>
+                <command name="glVertexStream3sATI"/>
+                <command name="glVertexStream3svATI"/>
+                <command name="glVertexStream3iATI"/>
+                <command name="glVertexStream3ivATI"/>
+                <command name="glVertexStream3fATI"/>
+                <command name="glVertexStream3fvATI"/>
+                <command name="glVertexStream3dATI"/>
+                <command name="glVertexStream3dvATI"/>
+                <command name="glVertexStream4sATI"/>
+                <command name="glVertexStream4svATI"/>
+                <command name="glVertexStream4iATI"/>
+                <command name="glVertexStream4ivATI"/>
+                <command name="glVertexStream4fATI"/>
+                <command name="glVertexStream4fvATI"/>
+                <command name="glVertexStream4dATI"/>
+                <command name="glVertexStream4dvATI"/>
+                <command name="glNormalStream3bATI"/>
+                <command name="glNormalStream3bvATI"/>
+                <command name="glNormalStream3sATI"/>
+                <command name="glNormalStream3svATI"/>
+                <command name="glNormalStream3iATI"/>
+                <command name="glNormalStream3ivATI"/>
+                <command name="glNormalStream3fATI"/>
+                <command name="glNormalStream3fvATI"/>
+                <command name="glNormalStream3dATI"/>
+                <command name="glNormalStream3dvATI"/>
+                <command name="glClientActiveVertexStreamATI"/>
+                <command name="glVertexBlendEnviATI"/>
+                <command name="glVertexBlendEnvfATI"/>
+            </require>
+        </extension>
+        <extension name="GL_DMP_shader_binary" supported="gles2">
+            <require>
+                <enum name="GL_SHADER_BINARY_DMP"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_422_pixels" supported="gl">
+            <require>
+                <enum name="GL_422_EXT"/>
+                <enum name="GL_422_REV_EXT"/>
+                <enum name="GL_422_AVERAGE_EXT"/>
+                <enum name="GL_422_REV_AVERAGE_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_abgr" supported="gl">
+            <require>
+                <enum name="GL_ABGR_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_bgra" supported="gl">
+            <require>
+                <enum name="GL_BGR_EXT"/>
+                <enum name="GL_BGRA_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_bindable_uniform" supported="gl">
+            <require>
+                <enum name="GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT"/>
+                <enum name="GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT"/>
+                <enum name="GL_MAX_BINDABLE_UNIFORM_SIZE_EXT"/>
+                <enum name="GL_UNIFORM_BUFFER_EXT"/>
+                <enum name="GL_UNIFORM_BUFFER_BINDING_EXT"/>
+                <command name="glUniformBufferEXT"/>
+                <command name="glGetUniformBufferSizeEXT"/>
+                <command name="glGetUniformOffsetEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_blend_color" supported="gl">
+            <require>
+                <enum name="GL_CONSTANT_COLOR_EXT"/>
+                <enum name="GL_ONE_MINUS_CONSTANT_COLOR_EXT"/>
+                <enum name="GL_CONSTANT_ALPHA_EXT"/>
+                <enum name="GL_ONE_MINUS_CONSTANT_ALPHA_EXT"/>
+                <enum name="GL_BLEND_COLOR_EXT"/>
+                <command name="glBlendColorEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_blend_equation_separate" supported="gl">
+            <require>
+                <enum name="GL_BLEND_EQUATION_RGB_EXT"/>
+                <enum name="GL_BLEND_EQUATION_ALPHA_EXT"/>
+                <command name="glBlendEquationSeparateEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_blend_func_separate" supported="gl">
+            <require>
+                <enum name="GL_BLEND_DST_RGB_EXT"/>
+                <enum name="GL_BLEND_SRC_RGB_EXT"/>
+                <enum name="GL_BLEND_DST_ALPHA_EXT"/>
+                <enum name="GL_BLEND_SRC_ALPHA_EXT"/>
+                <command name="glBlendFuncSeparateEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_blend_logic_op" supported="gl"/>
+        <extension name="GL_EXT_blend_minmax" supported="gl|gles1|gles2">
+            <require>
+                <enum name="GL_MIN_EXT"/>
+                <enum name="GL_MAX_EXT"/>
+            </require>
+            <require api="gl">
+                <enum name="GL_FUNC_ADD_EXT"/>
+                <enum name="GL_BLEND_EQUATION_EXT"/>
+                <command name="glBlendEquationEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_blend_subtract" supported="gl">
+            <require>
+                <enum name="GL_FUNC_SUBTRACT_EXT"/>
+                <enum name="GL_FUNC_REVERSE_SUBTRACT_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_clip_volume_hint" supported="gl">
+            <require>
+                <enum name="GL_CLIP_VOLUME_CLIPPING_HINT_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_cmyka" supported="gl">
+            <require>
+                <enum name="GL_CMYK_EXT"/>
+                <enum name="GL_CMYKA_EXT"/>
+                <enum name="GL_PACK_CMYK_HINT_EXT"/>
+                <enum name="GL_UNPACK_CMYK_HINT_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_color_buffer_half_float" supported="gles2">
+            <require>
+                <enum name="GL_RGBA16F_EXT"/>
+                <enum name="GL_RGB16F_EXT"/>
+                <enum name="GL_RG16F_EXT"/>
+                <enum name="GL_R16F_EXT"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT"/>
+                <enum name="GL_UNSIGNED_NORMALIZED_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_color_subtable" supported="gl">
+            <require>
+                <command name="glColorSubTableEXT"/>
+                <command name="glCopyColorSubTableEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_compiled_vertex_array" supported="gl">
+            <require>
+                <enum name="GL_ARRAY_ELEMENT_LOCK_FIRST_EXT"/>
+                <enum name="GL_ARRAY_ELEMENT_LOCK_COUNT_EXT"/>
+                <command name="glLockArraysEXT"/>
+                <command name="glUnlockArraysEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_convolution" supported="gl">
+            <require>
+                <enum name="GL_CONVOLUTION_1D_EXT"/>
+                <enum name="GL_CONVOLUTION_2D_EXT"/>
+                <enum name="GL_SEPARABLE_2D_EXT"/>
+                <enum name="GL_CONVOLUTION_BORDER_MODE_EXT"/>
+                <enum name="GL_CONVOLUTION_FILTER_SCALE_EXT"/>
+                <enum name="GL_CONVOLUTION_FILTER_BIAS_EXT"/>
+                <enum name="GL_REDUCE_EXT"/>
+                <enum name="GL_CONVOLUTION_FORMAT_EXT"/>
+                <enum name="GL_CONVOLUTION_WIDTH_EXT"/>
+                <enum name="GL_CONVOLUTION_HEIGHT_EXT"/>
+                <enum name="GL_MAX_CONVOLUTION_WIDTH_EXT"/>
+                <enum name="GL_MAX_CONVOLUTION_HEIGHT_EXT"/>
+                <enum name="GL_POST_CONVOLUTION_RED_SCALE_EXT"/>
+                <enum name="GL_POST_CONVOLUTION_GREEN_SCALE_EXT"/>
+                <enum name="GL_POST_CONVOLUTION_BLUE_SCALE_EXT"/>
+                <enum name="GL_POST_CONVOLUTION_ALPHA_SCALE_EXT"/>
+                <enum name="GL_POST_CONVOLUTION_RED_BIAS_EXT"/>
+                <enum name="GL_POST_CONVOLUTION_GREEN_BIAS_EXT"/>
+                <enum name="GL_POST_CONVOLUTION_BLUE_BIAS_EXT"/>
+                <enum name="GL_POST_CONVOLUTION_ALPHA_BIAS_EXT"/>
+                <command name="glConvolutionFilter1DEXT"/>
+                <command name="glConvolutionFilter2DEXT"/>
+                <command name="glConvolutionParameterfEXT"/>
+                <command name="glConvolutionParameterfvEXT"/>
+                <command name="glConvolutionParameteriEXT"/>
+                <command name="glConvolutionParameterivEXT"/>
+                <command name="glCopyConvolutionFilter1DEXT"/>
+                <command name="glCopyConvolutionFilter2DEXT"/>
+                <command name="glGetConvolutionFilterEXT"/>
+                <command name="glGetConvolutionParameterfvEXT"/>
+                <command name="glGetConvolutionParameterivEXT"/>
+                <command name="glGetSeparableFilterEXT"/>
+                <command name="glSeparableFilter2DEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_coordinate_frame" supported="gl">
+            <require>
+                <enum name="GL_TANGENT_ARRAY_EXT"/>
+                <enum name="GL_BINORMAL_ARRAY_EXT"/>
+                <enum name="GL_CURRENT_TANGENT_EXT"/>
+                <enum name="GL_CURRENT_BINORMAL_EXT"/>
+                <enum name="GL_TANGENT_ARRAY_TYPE_EXT"/>
+                <enum name="GL_TANGENT_ARRAY_STRIDE_EXT"/>
+                <enum name="GL_BINORMAL_ARRAY_TYPE_EXT"/>
+                <enum name="GL_BINORMAL_ARRAY_STRIDE_EXT"/>
+                <enum name="GL_TANGENT_ARRAY_POINTER_EXT"/>
+                <enum name="GL_BINORMAL_ARRAY_POINTER_EXT"/>
+                <enum name="GL_MAP1_TANGENT_EXT"/>
+                <enum name="GL_MAP2_TANGENT_EXT"/>
+                <enum name="GL_MAP1_BINORMAL_EXT"/>
+                <enum name="GL_MAP2_BINORMAL_EXT"/>
+                <command name="glTangent3bEXT"/>
+                <command name="glTangent3bvEXT"/>
+                <command name="glTangent3dEXT"/>
+                <command name="glTangent3dvEXT"/>
+                <command name="glTangent3fEXT"/>
+                <command name="glTangent3fvEXT"/>
+                <command name="glTangent3iEXT"/>
+                <command name="glTangent3ivEXT"/>
+                <command name="glTangent3sEXT"/>
+                <command name="glTangent3svEXT"/>
+                <command name="glBinormal3bEXT"/>
+                <command name="glBinormal3bvEXT"/>
+                <command name="glBinormal3dEXT"/>
+                <command name="glBinormal3dvEXT"/>
+                <command name="glBinormal3fEXT"/>
+                <command name="glBinormal3fvEXT"/>
+                <command name="glBinormal3iEXT"/>
+                <command name="glBinormal3ivEXT"/>
+                <command name="glBinormal3sEXT"/>
+                <command name="glBinormal3svEXT"/>
+                <command name="glTangentPointerEXT"/>
+                <command name="glBinormalPointerEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_copy_image" supported="gles2">
+            <require>
+                <command name="glCopyImageSubDataEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_copy_texture" supported="gl">
+            <require>
+                <command name="glCopyTexImage1DEXT"/>
+                <command name="glCopyTexImage2DEXT"/>
+                <command name="glCopyTexSubImage1DEXT"/>
+                <command name="glCopyTexSubImage2DEXT"/>
+                <command name="glCopyTexSubImage3DEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_cull_vertex" supported="gl">
+            <require>
+                <enum name="GL_CULL_VERTEX_EXT"/>
+                <enum name="GL_CULL_VERTEX_EYE_POSITION_EXT"/>
+                <enum name="GL_CULL_VERTEX_OBJECT_POSITION_EXT"/>
+                <command name="glCullParameterdvEXT"/>
+                <command name="glCullParameterfvEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_debug_label" supported="gl|gles2">
+            <require>
+                <enum name="GL_PROGRAM_PIPELINE_OBJECT_EXT"/>
+                <enum name="GL_PROGRAM_OBJECT_EXT"/>
+                <enum name="GL_SHADER_OBJECT_EXT"/>
+                <enum name="GL_BUFFER_OBJECT_EXT"/>
+                <enum name="GL_QUERY_OBJECT_EXT"/>
+                <enum name="GL_VERTEX_ARRAY_OBJECT_EXT"/>
+                <command name="glLabelObjectEXT"/>
+                <command name="glGetObjectLabelEXT"/>
+            </require>
+            <require comment="Depends on OpenGL ES 3.0">
+                <enum name="GL_SAMPLER"/>
+                <enum name="GL_TRANSFORM_FEEDBACK"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_debug_marker" supported="gl|gles2">
+            <require>
+                <command name="glInsertEventMarkerEXT"/>
+                <command name="glPushGroupMarkerEXT"/>
+                <command name="glPopGroupMarkerEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_depth_bounds_test" supported="gl">
+            <require>
+                <enum name="GL_DEPTH_BOUNDS_TEST_EXT"/>
+                <enum name="GL_DEPTH_BOUNDS_EXT"/>
+                <command name="glDepthBoundsEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_direct_state_access" supported="gl" comment="DSA extension doesn't identify which interfaces are core profile and keeps getting expanded. This is in sync with revision 34, 2010/09/07">
+            <require>
+                <enum name="GL_PROGRAM_MATRIX_EXT"/>
+                <enum name="GL_TRANSPOSE_PROGRAM_MATRIX_EXT"/>
+                <enum name="GL_PROGRAM_MATRIX_STACK_DEPTH_EXT"/>
+            </require>
+            <require comment="OpenGL 1.0: New matrix commands">
+                <command name="glMatrixLoadfEXT"/>
+                <command name="glMatrixLoaddEXT"/>
+                <command name="glMatrixMultfEXT"/>
+                <command name="glMatrixMultdEXT"/>
+                <command name="glMatrixLoadIdentityEXT"/>
+                <command name="glMatrixRotatefEXT"/>
+                <command name="glMatrixRotatedEXT"/>
+                <command name="glMatrixScalefEXT"/>
+                <command name="glMatrixScaledEXT"/>
+                <command name="glMatrixTranslatefEXT"/>
+                <command name="glMatrixTranslatedEXT"/>
+                <command name="glMatrixFrustumEXT"/>
+                <command name="glMatrixOrthoEXT"/>
+                <command name="glMatrixPopEXT"/>
+                <command name="glMatrixPushEXT"/>
+            </require>
+            <require comment="OpenGL 1.1: New client commands">
+                <command name="glClientAttribDefaultEXT"/>
+                <command name="glPushClientAttribDefaultEXT"/>
+            </require>
+            <require comment="OpenGL 1.1: New texture object commands">
+                <command name="glTextureParameterfEXT"/>
+                <command name="glTextureParameterfvEXT"/>
+                <command name="glTextureParameteriEXT"/>
+                <command name="glTextureParameterivEXT"/>
+                <command name="glTextureImage1DEXT"/>
+                <command name="glTextureImage2DEXT"/>
+                <command name="glTextureSubImage1DEXT"/>
+                <command name="glTextureSubImage2DEXT"/>
+                <command name="glCopyTextureImage1DEXT"/>
+                <command name="glCopyTextureImage2DEXT"/>
+                <command name="glCopyTextureSubImage1DEXT"/>
+                <command name="glCopyTextureSubImage2DEXT"/>
+                <command name="glGetTextureImageEXT"/>
+                <command name="glGetTextureParameterfvEXT"/>
+                <command name="glGetTextureParameterivEXT"/>
+                <command name="glGetTextureLevelParameterfvEXT"/>
+                <command name="glGetTextureLevelParameterivEXT"/>
+            </require>
+            <require comment="OpenGL 1.2: New 3D texture object commands">
+                <command name="glTextureImage3DEXT"/>
+                <command name="glTextureSubImage3DEXT"/>
+                <command name="glCopyTextureSubImage3DEXT"/>
+            </require>
+            <require comment="OpenGL 1.2.1: New multitexture commands">
+                <command name="glBindMultiTextureEXT"/>
+                <command name="glMultiTexCoordPointerEXT"/>
+                <command name="glMultiTexEnvfEXT"/>
+                <command name="glMultiTexEnvfvEXT"/>
+                <command name="glMultiTexEnviEXT"/>
+                <command name="glMultiTexEnvivEXT"/>
+                <command name="glMultiTexGendEXT"/>
+                <command name="glMultiTexGendvEXT"/>
+                <command name="glMultiTexGenfEXT"/>
+                <command name="glMultiTexGenfvEXT"/>
+                <command name="glMultiTexGeniEXT"/>
+                <command name="glMultiTexGenivEXT"/>
+                <command name="glGetMultiTexEnvfvEXT"/>
+                <command name="glGetMultiTexEnvivEXT"/>
+                <command name="glGetMultiTexGendvEXT"/>
+                <command name="glGetMultiTexGenfvEXT"/>
+                <command name="glGetMultiTexGenivEXT"/>
+                <command name="glMultiTexParameteriEXT"/>
+                <command name="glMultiTexParameterivEXT"/>
+                <command name="glMultiTexParameterfEXT"/>
+                <command name="glMultiTexParameterfvEXT"/>
+                <command name="glMultiTexImage1DEXT"/>
+                <command name="glMultiTexImage2DEXT"/>
+                <command name="glMultiTexSubImage1DEXT"/>
+                <command name="glMultiTexSubImage2DEXT"/>
+                <command name="glCopyMultiTexImage1DEXT"/>
+                <command name="glCopyMultiTexImage2DEXT"/>
+                <command name="glCopyMultiTexSubImage1DEXT"/>
+                <command name="glCopyMultiTexSubImage2DEXT"/>
+                <command name="glGetMultiTexImageEXT"/>
+                <command name="glGetMultiTexParameterfvEXT"/>
+                <command name="glGetMultiTexParameterivEXT"/>
+                <command name="glGetMultiTexLevelParameterfvEXT"/>
+                <command name="glGetMultiTexLevelParameterivEXT"/>
+                <command name="glMultiTexImage3DEXT"/>
+                <command name="glMultiTexSubImage3DEXT"/>
+                <command name="glCopyMultiTexSubImage3DEXT"/>
+            </require>
+            <require comment="OpenGL 1.2.1: New indexed texture commands">
+                <command name="glEnableClientStateIndexedEXT"/>
+                <command name="glDisableClientStateIndexedEXT"/>
+            </require>
+            <require comment="OpenGL 1.2.1: New indexed generic queries">
+                <command name="glGetFloatIndexedvEXT"/>
+                <command name="glGetDoubleIndexedvEXT"/>
+                <command name="glGetPointerIndexedvEXT"/>
+            </require>
+            <require comment="OpenGL 1.2.1: Extend EXT_draw_buffers2 commands">
+                <command name="glEnableIndexedEXT"/>
+                <command name="glDisableIndexedEXT"/>
+                <command name="glIsEnabledIndexedEXT"/>
+                <command name="glGetIntegerIndexedvEXT"/>
+                <command name="glGetBooleanIndexedvEXT"/>
+            </require>
+            <require comment="OpenGL 1.3: New compressed texture object commands">
+                <command name="glCompressedTextureImage3DEXT"/>
+                <command name="glCompressedTextureImage2DEXT"/>
+                <command name="glCompressedTextureImage1DEXT"/>
+                <command name="glCompressedTextureSubImage3DEXT"/>
+                <command name="glCompressedTextureSubImage2DEXT"/>
+                <command name="glCompressedTextureSubImage1DEXT"/>
+                <command name="glGetCompressedTextureImageEXT"/>
+            </require>
+            <require comment="OpenGL 1.3: New multitexture compressed texture commands">
+                <command name="glCompressedMultiTexImage3DEXT"/>
+                <command name="glCompressedMultiTexImage2DEXT"/>
+                <command name="glCompressedMultiTexImage1DEXT"/>
+                <command name="glCompressedMultiTexSubImage3DEXT"/>
+                <command name="glCompressedMultiTexSubImage2DEXT"/>
+                <command name="glCompressedMultiTexSubImage1DEXT"/>
+                <command name="glGetCompressedMultiTexImageEXT"/>
+            </require>
+            <require comment="OpenGL 1.3: New transpose matrix commands">
+                <command name="glMatrixLoadTransposefEXT"/>
+                <command name="glMatrixLoadTransposedEXT"/>
+                <command name="glMatrixMultTransposefEXT"/>
+                <command name="glMatrixMultTransposedEXT"/>
+            </require>
+            <require comment="OpenGL 1.5: New buffer commands">
+                <command name="glNamedBufferDataEXT"/>
+                <command name="glNamedBufferSubDataEXT"/>
+                <command name="glMapNamedBufferEXT"/>
+                <command name="glUnmapNamedBufferEXT"/>
+                <command name="glGetNamedBufferParameterivEXT"/>
+                <command name="glGetNamedBufferPointervEXT"/>
+                <command name="glGetNamedBufferSubDataEXT"/>
+            </require>
+            <require comment="OpenGL 2.0: New uniform commands">
+                <command name="glProgramUniform1fEXT"/>
+                <command name="glProgramUniform2fEXT"/>
+                <command name="glProgramUniform3fEXT"/>
+                <command name="glProgramUniform4fEXT"/>
+                <command name="glProgramUniform1iEXT"/>
+                <command name="glProgramUniform2iEXT"/>
+                <command name="glProgramUniform3iEXT"/>
+                <command name="glProgramUniform4iEXT"/>
+                <command name="glProgramUniform1fvEXT"/>
+                <command name="glProgramUniform2fvEXT"/>
+                <command name="glProgramUniform3fvEXT"/>
+                <command name="glProgramUniform4fvEXT"/>
+                <command name="glProgramUniform1ivEXT"/>
+                <command name="glProgramUniform2ivEXT"/>
+                <command name="glProgramUniform3ivEXT"/>
+                <command name="glProgramUniform4ivEXT"/>
+                <command name="glProgramUniformMatrix2fvEXT"/>
+                <command name="glProgramUniformMatrix3fvEXT"/>
+                <command name="glProgramUniformMatrix4fvEXT"/>
+            </require>
+            <require comment="OpenGL 2.1: New uniform matrix commands">
+                <command name="glProgramUniformMatrix2x3fvEXT"/>
+                <command name="glProgramUniformMatrix3x2fvEXT"/>
+                <command name="glProgramUniformMatrix2x4fvEXT"/>
+                <command name="glProgramUniformMatrix4x2fvEXT"/>
+                <command name="glProgramUniformMatrix3x4fvEXT"/>
+                <command name="glProgramUniformMatrix4x3fvEXT"/>
+            </require>
+            <require comment="Extend EXT_texture_buffer_object commands">
+                <command name="glTextureBufferEXT"/>
+                <command name="glMultiTexBufferEXT"/>
+            </require>
+            <require comment="Extend EXT_texture_integer commands">
+                <command name="glTextureParameterIivEXT"/>
+                <command name="glTextureParameterIuivEXT"/>
+                <command name="glGetTextureParameterIivEXT"/>
+                <command name="glGetTextureParameterIuivEXT"/>
+                <command name="glMultiTexParameterIivEXT"/>
+                <command name="glMultiTexParameterIuivEXT"/>
+                <command name="glGetMultiTexParameterIivEXT"/>
+                <command name="glGetMultiTexParameterIuivEXT"/>
+            </require>
+            <require comment="Extend EXT_gpu_shader4 commands">
+                <command name="glProgramUniform1uiEXT"/>
+                <command name="glProgramUniform2uiEXT"/>
+                <command name="glProgramUniform3uiEXT"/>
+                <command name="glProgramUniform4uiEXT"/>
+                <command name="glProgramUniform1uivEXT"/>
+                <command name="glProgramUniform2uivEXT"/>
+                <command name="glProgramUniform3uivEXT"/>
+                <command name="glProgramUniform4uivEXT"/>
+            </require>
+            <require comment="Extend EXT_gpu_program_parameters commands">
+                <command name="glNamedProgramLocalParameters4fvEXT"/>
+            </require>
+            <require comment="Extend NV_gpu_program4 commands">
+                <command name="glNamedProgramLocalParameterI4iEXT"/>
+                <command name="glNamedProgramLocalParameterI4ivEXT"/>
+                <command name="glNamedProgramLocalParametersI4ivEXT"/>
+                <command name="glNamedProgramLocalParameterI4uiEXT"/>
+                <command name="glNamedProgramLocalParameterI4uivEXT"/>
+                <command name="glNamedProgramLocalParametersI4uivEXT"/>
+                <command name="glGetNamedProgramLocalParameterIivEXT"/>
+                <command name="glGetNamedProgramLocalParameterIuivEXT"/>
+            </require>
+            <require comment="OpenGL 3.0: New indexed texture commands">
+                <command name="glEnableClientStateiEXT"/>
+                <command name="glDisableClientStateiEXT"/>
+            </require>
+            <require comment="OpenGL 3.0: New indexed generic queries">
+                <command name="glGetFloati_vEXT"/>
+                <command name="glGetDoublei_vEXT"/>
+                <command name="glGetPointeri_vEXT"/>
+            </require>
+            <require comment="Extend GL_ARB_vertex_program commands">
+                <command name="glNamedProgramStringEXT"/>
+                <command name="glNamedProgramLocalParameter4dEXT"/>
+                <command name="glNamedProgramLocalParameter4dvEXT"/>
+                <command name="glNamedProgramLocalParameter4fEXT"/>
+                <command name="glNamedProgramLocalParameter4fvEXT"/>
+                <command name="glGetNamedProgramLocalParameterdvEXT"/>
+                <command name="glGetNamedProgramLocalParameterfvEXT"/>
+                <command name="glGetNamedProgramivEXT"/>
+                <command name="glGetNamedProgramStringEXT"/>
+            </require>
+            <require comment="OpenGL 3.0: New renderbuffer commands">
+                <command name="glNamedRenderbufferStorageEXT"/>
+                <command name="glGetNamedRenderbufferParameterivEXT"/>
+                <command name="glNamedRenderbufferStorageMultisampleEXT"/>
+            </require>
+            <require comment="Extend NV_framebuffer_multisample_coverage">
+                <command name="glNamedRenderbufferStorageMultisampleCoverageEXT"/>
+            </require>
+            <require comment="OpenGL 3.0: New framebuffer commands">
+                <command name="glCheckNamedFramebufferStatusEXT"/>
+                <command name="glNamedFramebufferTexture1DEXT"/>
+                <command name="glNamedFramebufferTexture2DEXT"/>
+                <command name="glNamedFramebufferTexture3DEXT"/>
+                <command name="glNamedFramebufferRenderbufferEXT"/>
+                <command name="glGetNamedFramebufferAttachmentParameterivEXT"/>
+            </require>
+            <require comment="OpenGL 3.0: New texture commands">
+                <command name="glGenerateTextureMipmapEXT"/>
+                <command name="glGenerateMultiTexMipmapEXT"/>
+            </require>
+            <require comment="OpenGL 3.0: New framebuffer commands">
+                <command name="glFramebufferDrawBufferEXT"/>
+                <command name="glFramebufferDrawBuffersEXT"/>
+                <command name="glFramebufferReadBufferEXT"/>
+                <command name="glGetFramebufferParameterivEXT"/>
+            </require>
+            <require comment="OpenGL 3.0: New buffer data copy command">
+                <command name="glNamedCopyBufferSubDataEXT"/>
+            </require>
+            <require comment="Extend EXT_geometry_shader4 or NV_gpu_program4">
+                <command name="glNamedFramebufferTextureEXT"/>
+                <command name="glNamedFramebufferTextureLayerEXT"/>
+                <command name="glNamedFramebufferTextureFaceEXT"/>
+            </require>
+            <require comment="Extend NV_explicit_multisample">
+                <command name="glTextureRenderbufferEXT"/>
+                <command name="glMultiTexRenderbufferEXT"/>
+            </require>
+            <require comment="OpenGL 3.0: New vertex array specification commands for VAO">
+                <command name="glVertexArrayVertexOffsetEXT"/>
+                <command name="glVertexArrayColorOffsetEXT"/>
+                <command name="glVertexArrayEdgeFlagOffsetEXT"/>
+                <command name="glVertexArrayIndexOffsetEXT"/>
+                <command name="glVertexArrayNormalOffsetEXT"/>
+                <command name="glVertexArrayTexCoordOffsetEXT"/>
+                <command name="glVertexArrayMultiTexCoordOffsetEXT"/>
+                <command name="glVertexArrayFogCoordOffsetEXT"/>
+                <command name="glVertexArraySecondaryColorOffsetEXT"/>
+                <command name="glVertexArrayVertexAttribOffsetEXT"/>
+                <command name="glVertexArrayVertexAttribIOffsetEXT"/>
+            </require>
+            <require comment="OpenGL 3.0: New vertex array enable commands for VAO">
+                <command name="glEnableVertexArrayEXT"/>
+                <command name="glDisableVertexArrayEXT"/>
+            </require>
+            <require comment="OpenGL 3.0: New vertex attrib array enable commands for VAO">
+                <command name="glEnableVertexArrayAttribEXT"/>
+                <command name="glDisableVertexArrayAttribEXT"/>
+            </require>
+            <require comment="OpenGL 3.0: New queries for VAO">
+                <command name="glGetVertexArrayIntegervEXT"/>
+                <command name="glGetVertexArrayPointervEXT"/>
+                <command name="glGetVertexArrayIntegeri_vEXT"/>
+                <command name="glGetVertexArrayPointeri_vEXT"/>
+            </require>
+            <require comment="OpenGL 3.0: New buffer commands">
+                <command name="glMapNamedBufferRangeEXT"/>
+                <command name="glFlushMappedNamedBufferRangeEXT"/>
+            </require>
+            <require comment="Extended by GL_ARB_buffer_storage">
+                <command name="glNamedBufferStorageEXT"/>
+            </require>
+            <require comment="Extended by GL_ARB_clear_buffer_object">
+                <command name="glClearNamedBufferDataEXT"/>
+                <command name="glClearNamedBufferSubDataEXT"/>
+            </require>
+            <require comment="Extended by GL_ARB_framebuffer_no_attachments">
+                <command name="glNamedFramebufferParameteriEXT"/>
+                <command name="glGetNamedFramebufferParameterivEXT"/>
+            </require>
+            <require comment="Extended by GL_ARB_gpu_shader_fp64">
+                <command name="glProgramUniform1dEXT"/>
+                <command name="glProgramUniform2dEXT"/>
+                <command name="glProgramUniform3dEXT"/>
+                <command name="glProgramUniform4dEXT"/>
+                <command name="glProgramUniform1dvEXT"/>
+                <command name="glProgramUniform2dvEXT"/>
+                <command name="glProgramUniform3dvEXT"/>
+                <command name="glProgramUniform4dvEXT"/>
+                <command name="glProgramUniformMatrix2dvEXT"/>
+                <command name="glProgramUniformMatrix3dvEXT"/>
+                <command name="glProgramUniformMatrix4dvEXT"/>
+                <command name="glProgramUniformMatrix2x3dvEXT"/>
+                <command name="glProgramUniformMatrix2x4dvEXT"/>
+                <command name="glProgramUniformMatrix3x2dvEXT"/>
+                <command name="glProgramUniformMatrix3x4dvEXT"/>
+                <command name="glProgramUniformMatrix4x2dvEXT"/>
+                <command name="glProgramUniformMatrix4x3dvEXT"/>
+            </require>
+            <require comment="Extended by GL_ARB_texture_buffer_range">
+                <command name="glTextureBufferRangeEXT"/>
+            </require>
+            <require comment="Extended by GL_ARB_texture_storage">
+                <command name="glTextureStorage1DEXT"/>
+                <command name="glTextureStorage2DEXT"/>
+                <command name="glTextureStorage3DEXT"/>
+            </require>
+            <require comment="Extended by GL_ARB_texture_storage_multisample">
+                <command name="glTextureStorage2DMultisampleEXT"/>
+                <command name="glTextureStorage3DMultisampleEXT"/>
+            </require>
+            <require comment="Extended by GL_ARB_vertex_attrib_binding">
+                <command name="glVertexArrayBindVertexBufferEXT"/>
+                <command name="glVertexArrayVertexAttribFormatEXT"/>
+                <command name="glVertexArrayVertexAttribIFormatEXT"/>
+                <command name="glVertexArrayVertexAttribLFormatEXT"/>
+                <command name="glVertexArrayVertexAttribBindingEXT"/>
+                <command name="glVertexArrayVertexBindingDivisorEXT"/>
+            </require>
+            <require comment="Extended by GL_EXT_vertex_attrib_64bit">
+                <command name="glVertexArrayVertexAttribLOffsetEXT"/>
+            </require>
+            <require comment="Extended by GL_ARB_sparse_texture">
+                <command name="glTexturePageCommitmentEXT"/>
+            </require>
+            <require comment="Extended by GL_ARB_instanced_arrays">
+                <command name="glVertexArrayVertexAttribDivisorEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_discard_framebuffer" supported="gles1|gles2">
+            <require>
+                <enum name="GL_COLOR_EXT"/>
+                <enum name="GL_DEPTH_EXT"/>
+                <enum name="GL_STENCIL_EXT"/>
+                <command name="glDiscardFramebufferEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_disjoint_timer_query" supported="gles2">
+            <require>
+                <enum name="GL_QUERY_COUNTER_BITS_EXT"/>
+                <enum name="GL_CURRENT_QUERY_EXT"/>
+                <enum name="GL_QUERY_RESULT_EXT"/>
+                <enum name="GL_QUERY_RESULT_AVAILABLE_EXT"/>
+                <enum name="GL_TIME_ELAPSED_EXT"/>
+                <enum name="GL_TIMESTAMP_EXT"/>
+                <enum name="GL_GPU_DISJOINT_EXT"/>
+                <command name="glGenQueriesEXT"/>
+                <command name="glDeleteQueriesEXT"/>
+                <command name="glIsQueryEXT"/>
+                <command name="glBeginQueryEXT"/>
+                <command name="glEndQueryEXT"/>
+                <command name="glQueryCounterEXT"/>
+                <command name="glGetQueryivEXT"/>
+                <command name="glGetQueryObjectivEXT"/>
+                <command name="glGetQueryObjectuivEXT"/>
+                <command name="glGetQueryObjecti64vEXT"/>
+                <command name="glGetQueryObjectui64vEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_draw_buffers" supported="gles2">
+            <require>
+                <enum name="GL_MAX_COLOR_ATTACHMENTS_EXT"/>
+                <enum name="GL_MAX_DRAW_BUFFERS_EXT"/>
+                <enum name="GL_DRAW_BUFFER0_EXT"/>
+                <enum name="GL_DRAW_BUFFER1_EXT"/>
+                <enum name="GL_DRAW_BUFFER2_EXT"/>
+                <enum name="GL_DRAW_BUFFER3_EXT"/>
+                <enum name="GL_DRAW_BUFFER4_EXT"/>
+                <enum name="GL_DRAW_BUFFER5_EXT"/>
+                <enum name="GL_DRAW_BUFFER6_EXT"/>
+                <enum name="GL_DRAW_BUFFER7_EXT"/>
+                <enum name="GL_DRAW_BUFFER8_EXT"/>
+                <enum name="GL_DRAW_BUFFER9_EXT"/>
+                <enum name="GL_DRAW_BUFFER10_EXT"/>
+                <enum name="GL_DRAW_BUFFER11_EXT"/>
+                <enum name="GL_DRAW_BUFFER12_EXT"/>
+                <enum name="GL_DRAW_BUFFER13_EXT"/>
+                <enum name="GL_DRAW_BUFFER14_EXT"/>
+                <enum name="GL_DRAW_BUFFER15_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT0_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT1_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT2_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT3_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT4_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT5_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT6_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT7_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT8_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT9_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT10_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT11_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT12_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT13_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT14_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT15_EXT"/>
+                <command name="glDrawBuffersEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_draw_buffers2" supported="gl">
+            <require>
+                <command name="glColorMaskIndexedEXT"/>
+                <command name="glGetBooleanIndexedvEXT"/>
+                <command name="glGetIntegerIndexedvEXT"/>
+                <command name="glEnableIndexedEXT"/>
+                <command name="glDisableIndexedEXT"/>
+                <command name="glIsEnabledIndexedEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_draw_buffers_indexed" supported="gles2">
+            <require>
+                <enum name="GL_BLEND_EQUATION_RGB"/>
+                <enum name="GL_BLEND_EQUATION_ALPHA"/>
+                <enum name="GL_BLEND_SRC_RGB"/>
+                <enum name="GL_BLEND_SRC_ALPHA"/>
+                <enum name="GL_BLEND_DST_RGB"/>
+                <enum name="GL_BLEND_DST_ALPHA"/>
+                <enum name="GL_COLOR_WRITEMASK"/>
+                <enum name="GL_BLEND"/>
+                <enum name="GL_FUNC_ADD"/>
+                <enum name="GL_FUNC_SUBTRACT"/>
+                <enum name="GL_FUNC_REVERSE_SUBTRACT"/>
+                <enum name="GL_MIN"/>
+                <enum name="GL_MAX"/>
+                <enum name="GL_ZERO"/>
+                <enum name="GL_ONE"/>
+                <enum name="GL_SRC_COLOR"/>
+                <enum name="GL_ONE_MINUS_SRC_COLOR"/>
+                <enum name="GL_DST_COLOR"/>
+                <enum name="GL_ONE_MINUS_DST_COLOR"/>
+                <enum name="GL_SRC_ALPHA"/>
+                <enum name="GL_ONE_MINUS_SRC_ALPHA"/>
+                <enum name="GL_DST_ALPHA"/>
+                <enum name="GL_ONE_MINUS_DST_ALPHA"/>
+                <enum name="GL_CONSTANT_COLOR"/>
+                <enum name="GL_ONE_MINUS_CONSTANT_COLOR"/>
+                <enum name="GL_CONSTANT_ALPHA"/>
+                <enum name="GL_ONE_MINUS_CONSTANT_ALPHA"/>
+                <enum name="GL_SRC_ALPHA_SATURATE"/>
+                <command name="glEnableiEXT"/>
+                <command name="glDisableiEXT"/>
+                <command name="glBlendEquationiEXT"/>
+                <command name="glBlendEquationSeparateiEXT"/>
+                <command name="glBlendFunciEXT"/>
+                <command name="glBlendFuncSeparateiEXT"/>
+                <command name="glColorMaskiEXT"/>
+                <command name="glIsEnablediEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_draw_instanced" supported="gl|gles2">
+            <require>
+                <command name="glDrawArraysInstancedEXT"/>
+                <command name="glDrawElementsInstancedEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_draw_range_elements" supported="gl">
+            <require>
+                <enum name="GL_MAX_ELEMENTS_VERTICES_EXT"/>
+                <enum name="GL_MAX_ELEMENTS_INDICES_EXT"/>
+                <command name="glDrawRangeElementsEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_fog_coord" supported="gl">
+            <require>
+                <enum name="GL_FOG_COORDINATE_SOURCE_EXT"/>
+                <enum name="GL_FOG_COORDINATE_EXT"/>
+                <enum name="GL_FRAGMENT_DEPTH_EXT"/>
+                <enum name="GL_CURRENT_FOG_COORDINATE_EXT"/>
+                <enum name="GL_FOG_COORDINATE_ARRAY_TYPE_EXT"/>
+                <enum name="GL_FOG_COORDINATE_ARRAY_STRIDE_EXT"/>
+                <enum name="GL_FOG_COORDINATE_ARRAY_POINTER_EXT"/>
+                <enum name="GL_FOG_COORDINATE_ARRAY_EXT"/>
+                <command name="glFogCoordfEXT"/>
+                <command name="glFogCoordfvEXT"/>
+                <command name="glFogCoorddEXT"/>
+                <command name="glFogCoorddvEXT"/>
+                <command name="glFogCoordPointerEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_framebuffer_blit" supported="gl">
+            <require>
+                <enum name="GL_READ_FRAMEBUFFER_EXT"/>
+                <enum name="GL_DRAW_FRAMEBUFFER_EXT"/>
+                <enum name="GL_DRAW_FRAMEBUFFER_BINDING_EXT"/>
+                <enum name="GL_READ_FRAMEBUFFER_BINDING_EXT"/>
+                <command name="glBlitFramebufferEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_framebuffer_multisample" supported="gl">
+            <require>
+                <enum name="GL_RENDERBUFFER_SAMPLES_EXT"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT"/>
+                <enum name="GL_MAX_SAMPLES_EXT"/>
+                <command name="glRenderbufferStorageMultisampleEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_framebuffer_multisample_blit_scaled" supported="gl">
+            <require>
+                <enum name="GL_SCALED_RESOLVE_FASTEST_EXT"/>
+                <enum name="GL_SCALED_RESOLVE_NICEST_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_framebuffer_object" supported="gl">
+            <require>
+                <enum name="GL_INVALID_FRAMEBUFFER_OPERATION_EXT"/>
+                <enum name="GL_MAX_RENDERBUFFER_SIZE_EXT"/>
+                <enum name="GL_FRAMEBUFFER_BINDING_EXT"/>
+                <enum name="GL_RENDERBUFFER_BINDING_EXT"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT"/>
+                <enum name="GL_FRAMEBUFFER_COMPLETE_EXT"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT"/>
+                <enum name="GL_FRAMEBUFFER_UNSUPPORTED_EXT"/>
+                <enum name="GL_MAX_COLOR_ATTACHMENTS_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT0_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT1_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT2_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT3_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT4_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT5_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT6_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT7_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT8_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT9_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT10_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT11_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT12_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT13_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT14_EXT"/>
+                <enum name="GL_COLOR_ATTACHMENT15_EXT"/>
+                <enum name="GL_DEPTH_ATTACHMENT_EXT"/>
+                <enum name="GL_STENCIL_ATTACHMENT_EXT"/>
+                <enum name="GL_FRAMEBUFFER_EXT"/>
+                <enum name="GL_RENDERBUFFER_EXT"/>
+                <enum name="GL_RENDERBUFFER_WIDTH_EXT"/>
+                <enum name="GL_RENDERBUFFER_HEIGHT_EXT"/>
+                <enum name="GL_RENDERBUFFER_INTERNAL_FORMAT_EXT"/>
+                <enum name="GL_STENCIL_INDEX1_EXT"/>
+                <enum name="GL_STENCIL_INDEX4_EXT"/>
+                <enum name="GL_STENCIL_INDEX8_EXT"/>
+                <enum name="GL_STENCIL_INDEX16_EXT"/>
+                <enum name="GL_RENDERBUFFER_RED_SIZE_EXT"/>
+                <enum name="GL_RENDERBUFFER_GREEN_SIZE_EXT"/>
+                <enum name="GL_RENDERBUFFER_BLUE_SIZE_EXT"/>
+                <enum name="GL_RENDERBUFFER_ALPHA_SIZE_EXT"/>
+                <enum name="GL_RENDERBUFFER_DEPTH_SIZE_EXT"/>
+                <enum name="GL_RENDERBUFFER_STENCIL_SIZE_EXT"/>
+                <command name="glIsRenderbufferEXT"/>
+                <command name="glBindRenderbufferEXT"/>
+                <command name="glDeleteRenderbuffersEXT"/>
+                <command name="glGenRenderbuffersEXT"/>
+                <command name="glRenderbufferStorageEXT"/>
+                <command name="glGetRenderbufferParameterivEXT"/>
+                <command name="glIsFramebufferEXT"/>
+                <command name="glBindFramebufferEXT"/>
+                <command name="glDeleteFramebuffersEXT"/>
+                <command name="glGenFramebuffersEXT"/>
+                <command name="glCheckFramebufferStatusEXT"/>
+                <command name="glFramebufferTexture1DEXT"/>
+                <command name="glFramebufferTexture2DEXT"/>
+                <command name="glFramebufferTexture3DEXT"/>
+                <command name="glFramebufferRenderbufferEXT"/>
+                <command name="glGetFramebufferAttachmentParameterivEXT"/>
+                <command name="glGenerateMipmapEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_framebuffer_sRGB" supported="gl">
+            <require>
+                <enum name="GL_FRAMEBUFFER_SRGB_EXT"/>
+                <enum name="GL_FRAMEBUFFER_SRGB_CAPABLE_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_geometry_shader" supported="gles2">
+            <require>
+                <enum name="GL_GEOMETRY_SHADER_EXT"/>
+                <enum name="GL_GEOMETRY_SHADER_BIT_EXT"/>
+                <enum name="GL_GEOMETRY_LINKED_VERTICES_OUT_EXT"/>
+                <enum name="GL_GEOMETRY_LINKED_INPUT_TYPE_EXT"/>
+                <enum name="GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT"/>
+                <enum name="GL_GEOMETRY_SHADER_INVOCATIONS_EXT"/>
+                <enum name="GL_LAYER_PROVOKING_VERTEX_EXT"/>
+                <enum name="GL_LINES_ADJACENCY_EXT"/>
+                <enum name="GL_LINE_STRIP_ADJACENCY_EXT"/>
+                <enum name="GL_TRIANGLES_ADJACENCY_EXT"/>
+                <enum name="GL_TRIANGLE_STRIP_ADJACENCY_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT"/>
+                <enum name="GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT"/>
+                <enum name="GL_FIRST_VERTEX_CONVENTION_EXT"/>
+                <enum name="GL_LAST_VERTEX_CONVENTION_EXT"/>
+                <enum name="GL_UNDEFINED_VERTEX_EXT"/>
+                <enum name="GL_PRIMITIVES_GENERATED_EXT"/>
+                <enum name="GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT"/>
+                <enum name="GL_MAX_FRAMEBUFFER_LAYERS_EXT"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT"/>
+                <enum name="GL_REFERENCED_BY_GEOMETRY_SHADER_EXT"/>
+                <command name="glFramebufferTextureEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_geometry_shader4" supported="gl">
+            <require>
+                <enum name="GL_GEOMETRY_SHADER_EXT"/>
+                <enum name="GL_GEOMETRY_VERTICES_OUT_EXT"/>
+                <enum name="GL_GEOMETRY_INPUT_TYPE_EXT"/>
+                <enum name="GL_GEOMETRY_OUTPUT_TYPE_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_VERTEX_VARYING_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_VARYING_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT"/>
+                <enum name="GL_LINES_ADJACENCY_EXT"/>
+                <enum name="GL_LINE_STRIP_ADJACENCY_EXT"/>
+                <enum name="GL_TRIANGLES_ADJACENCY_EXT"/>
+                <enum name="GL_TRIANGLE_STRIP_ADJACENCY_EXT"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT"/>
+                <enum name="GL_PROGRAM_POINT_SIZE_EXT"/>
+                <command name="glProgramParameteriEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_gpu_program_parameters" supported="gl">
+            <require>
+                <command name="glProgramEnvParameters4fvEXT"/>
+                <command name="glProgramLocalParameters4fvEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_gpu_shader4" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT"/>
+                <enum name="GL_SAMPLER_1D_ARRAY_EXT"/>
+                <enum name="GL_SAMPLER_2D_ARRAY_EXT"/>
+                <enum name="GL_SAMPLER_BUFFER_EXT"/>
+                <enum name="GL_SAMPLER_1D_ARRAY_SHADOW_EXT"/>
+                <enum name="GL_SAMPLER_2D_ARRAY_SHADOW_EXT"/>
+                <enum name="GL_SAMPLER_CUBE_SHADOW_EXT"/>
+                <enum name="GL_UNSIGNED_INT_VEC2_EXT"/>
+                <enum name="GL_UNSIGNED_INT_VEC3_EXT"/>
+                <enum name="GL_UNSIGNED_INT_VEC4_EXT"/>
+                <enum name="GL_INT_SAMPLER_1D_EXT"/>
+                <enum name="GL_INT_SAMPLER_2D_EXT"/>
+                <enum name="GL_INT_SAMPLER_3D_EXT"/>
+                <enum name="GL_INT_SAMPLER_CUBE_EXT"/>
+                <enum name="GL_INT_SAMPLER_2D_RECT_EXT"/>
+                <enum name="GL_INT_SAMPLER_1D_ARRAY_EXT"/>
+                <enum name="GL_INT_SAMPLER_2D_ARRAY_EXT"/>
+                <enum name="GL_INT_SAMPLER_BUFFER_EXT"/>
+                <enum name="GL_UNSIGNED_INT_SAMPLER_1D_EXT"/>
+                <enum name="GL_UNSIGNED_INT_SAMPLER_2D_EXT"/>
+                <enum name="GL_UNSIGNED_INT_SAMPLER_3D_EXT"/>
+                <enum name="GL_UNSIGNED_INT_SAMPLER_CUBE_EXT"/>
+                <enum name="GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT"/>
+                <enum name="GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT"/>
+                <enum name="GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT"/>
+                <enum name="GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT"/>
+                <enum name="GL_MIN_PROGRAM_TEXEL_OFFSET_EXT"/>
+                <enum name="GL_MAX_PROGRAM_TEXEL_OFFSET_EXT"/>
+                <command name="glGetUniformuivEXT"/>
+                <command name="glBindFragDataLocationEXT"/>
+                <command name="glGetFragDataLocationEXT"/>
+                <command name="glUniform1uiEXT"/>
+                <command name="glUniform2uiEXT"/>
+                <command name="glUniform3uiEXT"/>
+                <command name="glUniform4uiEXT"/>
+                <command name="glUniform1uivEXT"/>
+                <command name="glUniform2uivEXT"/>
+                <command name="glUniform3uivEXT"/>
+                <command name="glUniform4uivEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_gpu_shader5" supported="gles2">
+            <require/>
+        </extension>
+        <extension name="GL_EXT_histogram" supported="gl">
+            <require>
+                <enum name="GL_HISTOGRAM_EXT"/>
+                <enum name="GL_PROXY_HISTOGRAM_EXT"/>
+                <enum name="GL_HISTOGRAM_WIDTH_EXT"/>
+                <enum name="GL_HISTOGRAM_FORMAT_EXT"/>
+                <enum name="GL_HISTOGRAM_RED_SIZE_EXT"/>
+                <enum name="GL_HISTOGRAM_GREEN_SIZE_EXT"/>
+                <enum name="GL_HISTOGRAM_BLUE_SIZE_EXT"/>
+                <enum name="GL_HISTOGRAM_ALPHA_SIZE_EXT"/>
+                <enum name="GL_HISTOGRAM_LUMINANCE_SIZE_EXT"/>
+                <enum name="GL_HISTOGRAM_SINK_EXT"/>
+                <enum name="GL_MINMAX_EXT"/>
+                <enum name="GL_MINMAX_FORMAT_EXT"/>
+                <enum name="GL_MINMAX_SINK_EXT"/>
+                <enum name="GL_TABLE_TOO_LARGE_EXT"/>
+                <command name="glGetHistogramEXT"/>
+                <command name="glGetHistogramParameterfvEXT"/>
+                <command name="glGetHistogramParameterivEXT"/>
+                <command name="glGetMinmaxEXT"/>
+                <command name="glGetMinmaxParameterfvEXT"/>
+                <command name="glGetMinmaxParameterivEXT"/>
+                <command name="glHistogramEXT"/>
+                <command name="glMinmaxEXT"/>
+                <command name="glResetHistogramEXT"/>
+                <command name="glResetMinmaxEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_index_array_formats" supported="gl">
+            <require>
+                <enum name="GL_IUI_V2F_EXT"/>
+                <enum name="GL_IUI_V3F_EXT"/>
+                <enum name="GL_IUI_N3F_V2F_EXT"/>
+                <enum name="GL_IUI_N3F_V3F_EXT"/>
+                <enum name="GL_T2F_IUI_V2F_EXT"/>
+                <enum name="GL_T2F_IUI_V3F_EXT"/>
+                <enum name="GL_T2F_IUI_N3F_V2F_EXT"/>
+                <enum name="GL_T2F_IUI_N3F_V3F_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_index_func" supported="gl">
+            <require>
+                <enum name="GL_INDEX_TEST_EXT"/>
+                <enum name="GL_INDEX_TEST_FUNC_EXT"/>
+                <enum name="GL_INDEX_TEST_REF_EXT"/>
+                <command name="glIndexFuncEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_index_material" supported="gl">
+            <require>
+                <enum name="GL_INDEX_MATERIAL_EXT"/>
+                <enum name="GL_INDEX_MATERIAL_PARAMETER_EXT"/>
+                <enum name="GL_INDEX_MATERIAL_FACE_EXT"/>
+                <command name="glIndexMaterialEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_index_texture" supported="gl"/>
+        <extension name="GL_EXT_instanced_arrays" supported="gles2">
+            <require>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_DIVISOR_EXT"/>
+                <command name="glDrawArraysInstancedEXT"/>
+                <command name="glDrawElementsInstancedEXT"/>
+                <command name="glVertexAttribDivisorEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_light_texture" supported="gl">
+            <require>
+                <enum name="GL_FRAGMENT_MATERIAL_EXT"/>
+                <enum name="GL_FRAGMENT_NORMAL_EXT"/>
+                <enum name="GL_FRAGMENT_COLOR_EXT"/>
+                <enum name="GL_ATTENUATION_EXT"/>
+                <enum name="GL_SHADOW_ATTENUATION_EXT"/>
+                <enum name="GL_TEXTURE_APPLICATION_MODE_EXT"/>
+                <enum name="GL_TEXTURE_LIGHT_EXT"/>
+                <enum name="GL_TEXTURE_MATERIAL_FACE_EXT"/>
+                <enum name="GL_TEXTURE_MATERIAL_PARAMETER_EXT"/>
+                <enum name="GL_FRAGMENT_DEPTH_EXT"/>
+                <command name="glApplyTextureEXT"/>
+                <command name="glTextureLightEXT"/>
+                <command name="glTextureMaterialEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_map_buffer_range" supported="gles1|gles2">
+            <require>
+                <enum name="GL_MAP_READ_BIT_EXT"/>
+                <enum name="GL_MAP_WRITE_BIT_EXT"/>
+                <enum name="GL_MAP_INVALIDATE_RANGE_BIT_EXT"/>
+                <enum name="GL_MAP_INVALIDATE_BUFFER_BIT_EXT"/>
+                <enum name="GL_MAP_FLUSH_EXPLICIT_BIT_EXT"/>
+                <enum name="GL_MAP_UNSYNCHRONIZED_BIT_EXT"/>
+                <command name="glMapBufferRangeEXT"/>
+                <command name="glFlushMappedBufferRangeEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_misc_attribute" supported="gl"/>
+        <extension name="GL_EXT_multi_draw_arrays" supported="gl|gles1|gles2">
+            <require>
+                <command name="glMultiDrawArraysEXT"/>
+                <command name="glMultiDrawElementsEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_multisample" supported="gl">
+            <require>
+                <enum name="GL_MULTISAMPLE_EXT"/>
+                <enum name="GL_SAMPLE_ALPHA_TO_MASK_EXT"/>
+                <enum name="GL_SAMPLE_ALPHA_TO_ONE_EXT"/>
+                <enum name="GL_SAMPLE_MASK_EXT"/>
+                <enum name="GL_1PASS_EXT"/>
+                <enum name="GL_2PASS_0_EXT"/>
+                <enum name="GL_2PASS_1_EXT"/>
+                <enum name="GL_4PASS_0_EXT"/>
+                <enum name="GL_4PASS_1_EXT"/>
+                <enum name="GL_4PASS_2_EXT"/>
+                <enum name="GL_4PASS_3_EXT"/>
+                <enum name="GL_SAMPLE_BUFFERS_EXT"/>
+                <enum name="GL_SAMPLES_EXT"/>
+                <enum name="GL_SAMPLE_MASK_VALUE_EXT"/>
+                <enum name="GL_SAMPLE_MASK_INVERT_EXT"/>
+                <enum name="GL_SAMPLE_PATTERN_EXT"/>
+                <enum name="GL_MULTISAMPLE_BIT_EXT"/>
+                <command name="glSampleMaskEXT"/>
+                <command name="glSamplePatternEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_multisampled_render_to_texture" supported="gles1|gles2">
+            <require>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT"/>
+                <enum name="GL_RENDERBUFFER_SAMPLES_EXT"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT"/>
+                <enum name="GL_MAX_SAMPLES_EXT"/>
+                <command name="glRenderbufferStorageMultisampleEXT"/>
+                <command name="glFramebufferTexture2DMultisampleEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_multiview_draw_buffers" supported="gles2">
+            <require>
+                <enum name="GL_COLOR_ATTACHMENT_EXT"/>
+                <enum name="GL_MULTIVIEW_EXT"/>
+                <enum name="GL_DRAW_BUFFER_EXT"/>
+                <enum name="GL_READ_BUFFER_EXT"/>
+                <enum name="GL_MAX_MULTIVIEW_BUFFERS_EXT"/>
+                <command name="glReadBufferIndexedEXT"/>
+                <command name="glDrawBuffersIndexedEXT"/>
+                <command name="glGetIntegeri_vEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_occlusion_query_boolean" supported="gles2">
+            <require>
+                <enum name="GL_ANY_SAMPLES_PASSED_EXT"/>
+                <enum name="GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT"/>
+                <enum name="GL_CURRENT_QUERY_EXT"/>
+                <enum name="GL_QUERY_RESULT_EXT"/>
+                <enum name="GL_QUERY_RESULT_AVAILABLE_EXT"/>
+                <command name="glGenQueriesEXT"/>
+                <command name="glDeleteQueriesEXT"/>
+                <command name="glIsQueryEXT"/>
+                <command name="glBeginQueryEXT"/>
+                <command name="glEndQueryEXT"/>
+                <command name="glGetQueryivEXT"/>
+                <command name="glGetQueryObjectuivEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_packed_depth_stencil" supported="gl">
+            <require>
+                <enum name="GL_DEPTH_STENCIL_EXT"/>
+                <enum name="GL_UNSIGNED_INT_24_8_EXT"/>
+                <enum name="GL_DEPTH24_STENCIL8_EXT"/>
+                <enum name="GL_TEXTURE_STENCIL_SIZE_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_packed_float" supported="gl">
+            <require>
+                <enum name="GL_R11F_G11F_B10F_EXT"/>
+                <enum name="GL_UNSIGNED_INT_10F_11F_11F_REV_EXT"/>
+                <enum name="GL_RGBA_SIGNED_COMPONENTS_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_packed_pixels" supported="gl">
+            <require>
+                <enum name="GL_UNSIGNED_BYTE_3_3_2_EXT"/>
+                <enum name="GL_UNSIGNED_SHORT_4_4_4_4_EXT"/>
+                <enum name="GL_UNSIGNED_SHORT_5_5_5_1_EXT"/>
+                <enum name="GL_UNSIGNED_INT_8_8_8_8_EXT"/>
+                <enum name="GL_UNSIGNED_INT_10_10_10_2_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_paletted_texture" supported="gl">
+            <require>
+                <enum name="GL_COLOR_INDEX1_EXT"/>
+                <enum name="GL_COLOR_INDEX2_EXT"/>
+                <enum name="GL_COLOR_INDEX4_EXT"/>
+                <enum name="GL_COLOR_INDEX8_EXT"/>
+                <enum name="GL_COLOR_INDEX12_EXT"/>
+                <enum name="GL_COLOR_INDEX16_EXT"/>
+                <enum name="GL_TEXTURE_INDEX_SIZE_EXT"/>
+                <command name="glColorTableEXT"/>
+                <command name="glGetColorTableEXT"/>
+                <command name="glGetColorTableParameterivEXT"/>
+                <command name="glGetColorTableParameterfvEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_pixel_buffer_object" supported="gl">
+            <require>
+                <enum name="GL_PIXEL_PACK_BUFFER_EXT"/>
+                <enum name="GL_PIXEL_UNPACK_BUFFER_EXT"/>
+                <enum name="GL_PIXEL_PACK_BUFFER_BINDING_EXT"/>
+                <enum name="GL_PIXEL_UNPACK_BUFFER_BINDING_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_pixel_transform" supported="gl">
+            <require>
+                <enum name="GL_PIXEL_TRANSFORM_2D_EXT"/>
+                <enum name="GL_PIXEL_MAG_FILTER_EXT"/>
+                <enum name="GL_PIXEL_MIN_FILTER_EXT"/>
+                <enum name="GL_PIXEL_CUBIC_WEIGHT_EXT"/>
+                <enum name="GL_CUBIC_EXT"/>
+                <enum name="GL_AVERAGE_EXT"/>
+                <enum name="GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT"/>
+                <enum name="GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT"/>
+                <enum name="GL_PIXEL_TRANSFORM_2D_MATRIX_EXT"/>
+                <command name="glPixelTransformParameteriEXT"/>
+                <command name="glPixelTransformParameterfEXT"/>
+                <command name="glPixelTransformParameterivEXT"/>
+                <command name="glPixelTransformParameterfvEXT"/>
+                <command name="glGetPixelTransformParameterivEXT"/>
+                <command name="glGetPixelTransformParameterfvEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_pixel_transform_color_table" supported="gl"/>
+        <extension name="GL_EXT_point_parameters" supported="gl">
+            <require>
+                <enum name="GL_POINT_SIZE_MIN_EXT"/>
+                <enum name="GL_POINT_SIZE_MAX_EXT"/>
+                <enum name="GL_POINT_FADE_THRESHOLD_SIZE_EXT"/>
+                <enum name="GL_DISTANCE_ATTENUATION_EXT"/>
+                <command name="glPointParameterfEXT"/>
+                <command name="glPointParameterfvEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_polygon_offset" supported="gl">
+            <require>
+                <enum name="GL_POLYGON_OFFSET_EXT"/>
+                <enum name="GL_POLYGON_OFFSET_FACTOR_EXT"/>
+                <enum name="GL_POLYGON_OFFSET_BIAS_EXT"/>
+                <command name="glPolygonOffsetEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_primitive_bounding_box" supported="gles2">
+            <require>
+                <enum name="GL_PRIMITIVE_BOUNDING_BOX_EXT"/>
+                <command name="glPrimitiveBoundingBoxEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_provoking_vertex" supported="gl">
+            <require>
+                <enum name="GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT"/>
+                <enum name="GL_FIRST_VERTEX_CONVENTION_EXT"/>
+                <enum name="GL_LAST_VERTEX_CONVENTION_EXT"/>
+                <enum name="GL_PROVOKING_VERTEX_EXT"/>
+                <command name="glProvokingVertexEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_pvrtc_sRGB" supported="gles2">
+            <require>
+                <enum name="GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT"/>
+                <enum name="GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT"/>
+                <enum name="GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT"/>
+                <enum name="GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT"/>
+                <enum name="GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG"/>
+                <enum name="GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_read_format_bgra" supported="gles1|gles2">
+            <require>
+                <enum name="GL_BGRA_EXT"/>
+                <enum name="GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT"/>
+                <enum name="GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_rescale_normal" supported="gl">
+            <require>
+                <enum name="GL_RESCALE_NORMAL_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_robustness" supported="gles1|gles2">
+            <require>
+                <enum name="GL_NO_ERROR"/>
+                <enum name="GL_GUILTY_CONTEXT_RESET_EXT"/>
+                <enum name="GL_INNOCENT_CONTEXT_RESET_EXT"/>
+                <enum name="GL_UNKNOWN_CONTEXT_RESET_EXT"/>
+                <enum name="GL_CONTEXT_ROBUST_ACCESS_EXT"/>
+                <enum name="GL_RESET_NOTIFICATION_STRATEGY_EXT"/>
+                <enum name="GL_LOSE_CONTEXT_ON_RESET_EXT"/>
+                <enum name="GL_NO_RESET_NOTIFICATION_EXT"/>
+                <command name="glGetGraphicsResetStatusEXT"/>
+                <command name="glReadnPixelsEXT"/>
+                <command name="glGetnUniformfvEXT"/>
+                <command name="glGetnUniformivEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_sRGB" supported="gles1|gles2">
+            <require>
+                <enum name="GL_SRGB_EXT"/>
+                <enum name="GL_SRGB_ALPHA_EXT"/>
+                <enum name="GL_SRGB8_ALPHA8_EXT"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_sRGB_write_control" supported="gles2">
+            <require>
+                <enum name="GL_FRAMEBUFFER_SRGB_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_secondary_color" supported="gl">
+            <require>
+                <enum name="GL_COLOR_SUM_EXT"/>
+                <enum name="GL_CURRENT_SECONDARY_COLOR_EXT"/>
+                <enum name="GL_SECONDARY_COLOR_ARRAY_SIZE_EXT"/>
+                <enum name="GL_SECONDARY_COLOR_ARRAY_TYPE_EXT"/>
+                <enum name="GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT"/>
+                <enum name="GL_SECONDARY_COLOR_ARRAY_POINTER_EXT"/>
+                <enum name="GL_SECONDARY_COLOR_ARRAY_EXT"/>
+                <command name="glSecondaryColor3bEXT"/>
+                <command name="glSecondaryColor3bvEXT"/>
+                <command name="glSecondaryColor3dEXT"/>
+                <command name="glSecondaryColor3dvEXT"/>
+                <command name="glSecondaryColor3fEXT"/>
+                <command name="glSecondaryColor3fvEXT"/>
+                <command name="glSecondaryColor3iEXT"/>
+                <command name="glSecondaryColor3ivEXT"/>
+                <command name="glSecondaryColor3sEXT"/>
+                <command name="glSecondaryColor3svEXT"/>
+                <command name="glSecondaryColor3ubEXT"/>
+                <command name="glSecondaryColor3ubvEXT"/>
+                <command name="glSecondaryColor3uiEXT"/>
+                <command name="glSecondaryColor3uivEXT"/>
+                <command name="glSecondaryColor3usEXT"/>
+                <command name="glSecondaryColor3usvEXT"/>
+                <command name="glSecondaryColorPointerEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_separate_shader_objects" supported="gl|gles2">
+            <require api="gl" comment="The OpenGL version of this extension is completely unrelated to the OpenGL ES version">
+                <enum name="GL_ACTIVE_PROGRAM_EXT"/>
+                <command name="glUseShaderProgramEXT"/>
+                <command name="glActiveProgramEXT"/>
+                <command name="glCreateShaderProgramEXT"/>
+            </require>
+            <require api="gles2" comment="The OpenGL ES version of this extension is completely unrelated to the OpenGL version">
+                <enum name="GL_VERTEX_SHADER_BIT_EXT"/>
+                <enum name="GL_FRAGMENT_SHADER_BIT_EXT"/>
+                <enum name="GL_ALL_SHADER_BITS_EXT"/>
+                <enum name="GL_PROGRAM_SEPARABLE_EXT"/>
+                <enum name="GL_ACTIVE_PROGRAM_EXT"/>
+                <enum name="GL_PROGRAM_PIPELINE_BINDING_EXT"/>
+                <command name="glActiveShaderProgramEXT"/>
+                <command name="glBindProgramPipelineEXT"/>
+                <command name="glCreateShaderProgramvEXT"/>
+                <command name="glDeleteProgramPipelinesEXT"/>
+                <command name="glGenProgramPipelinesEXT"/>
+                <command name="glGetProgramPipelineInfoLogEXT"/>
+                <command name="glGetProgramPipelineivEXT"/>
+                <command name="glIsProgramPipelineEXT"/>
+                <command name="glProgramParameteriEXT"/>
+                <command name="glProgramUniform1fEXT"/>
+                <command name="glProgramUniform1fvEXT"/>
+                <command name="glProgramUniform1iEXT"/>
+                <command name="glProgramUniform1ivEXT"/>
+                <command name="glProgramUniform2fEXT"/>
+                <command name="glProgramUniform2fvEXT"/>
+                <command name="glProgramUniform2iEXT"/>
+                <command name="glProgramUniform2ivEXT"/>
+                <command name="glProgramUniform3fEXT"/>
+                <command name="glProgramUniform3fvEXT"/>
+                <command name="glProgramUniform3iEXT"/>
+                <command name="glProgramUniform3ivEXT"/>
+                <command name="glProgramUniform4fEXT"/>
+                <command name="glProgramUniform4fvEXT"/>
+                <command name="glProgramUniform4iEXT"/>
+                <command name="glProgramUniform4ivEXT"/>
+                <command name="glProgramUniformMatrix2fvEXT"/>
+                <command name="glProgramUniformMatrix3fvEXT"/>
+                <command name="glProgramUniformMatrix4fvEXT"/>
+                <command name="glUseProgramStagesEXT"/>
+                <command name="glValidateProgramPipelineEXT"/>
+            </require>
+            <require api="gles2" comment="Depends on OpenGL ES 3.0 or GL_NV_non_square_matrices">
+                <command name="glProgramUniform1uiEXT"/>
+                <command name="glProgramUniform2uiEXT"/>
+                <command name="glProgramUniform3uiEXT"/>
+                <command name="glProgramUniform4uiEXT"/>
+                <command name="glProgramUniform1uivEXT"/>
+                <command name="glProgramUniform2uivEXT"/>
+                <command name="glProgramUniform3uivEXT"/>
+                <command name="glProgramUniform4uivEXT"/>
+                <command name="glProgramUniformMatrix4fvEXT"/>
+                <command name="glProgramUniformMatrix2x3fvEXT"/>
+                <command name="glProgramUniformMatrix3x2fvEXT"/>
+                <command name="glProgramUniformMatrix2x4fvEXT"/>
+                <command name="glProgramUniformMatrix4x2fvEXT"/>
+                <command name="glProgramUniformMatrix3x4fvEXT"/>
+                <command name="glProgramUniformMatrix4x3fvEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_separate_specular_color" supported="gl">
+            <require>
+                <enum name="GL_LIGHT_MODEL_COLOR_CONTROL_EXT"/>
+                <enum name="GL_SINGLE_COLOR_EXT"/>
+                <enum name="GL_SEPARATE_SPECULAR_COLOR_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_shader_framebuffer_fetch" supported="gles2">
+            <require>
+                <enum name="GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_shader_image_load_store" supported="gl">
+            <require>
+                <enum name="GL_MAX_IMAGE_UNITS_EXT"/>
+                <enum name="GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT"/>
+                <enum name="GL_IMAGE_BINDING_NAME_EXT"/>
+                <enum name="GL_IMAGE_BINDING_LEVEL_EXT"/>
+                <enum name="GL_IMAGE_BINDING_LAYERED_EXT"/>
+                <enum name="GL_IMAGE_BINDING_LAYER_EXT"/>
+                <enum name="GL_IMAGE_BINDING_ACCESS_EXT"/>
+                <enum name="GL_IMAGE_1D_EXT"/>
+                <enum name="GL_IMAGE_2D_EXT"/>
+                <enum name="GL_IMAGE_3D_EXT"/>
+                <enum name="GL_IMAGE_2D_RECT_EXT"/>
+                <enum name="GL_IMAGE_CUBE_EXT"/>
+                <enum name="GL_IMAGE_BUFFER_EXT"/>
+                <enum name="GL_IMAGE_1D_ARRAY_EXT"/>
+                <enum name="GL_IMAGE_2D_ARRAY_EXT"/>
+                <enum name="GL_IMAGE_CUBE_MAP_ARRAY_EXT"/>
+                <enum name="GL_IMAGE_2D_MULTISAMPLE_EXT"/>
+                <enum name="GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT"/>
+                <enum name="GL_INT_IMAGE_1D_EXT"/>
+                <enum name="GL_INT_IMAGE_2D_EXT"/>
+                <enum name="GL_INT_IMAGE_3D_EXT"/>
+                <enum name="GL_INT_IMAGE_2D_RECT_EXT"/>
+                <enum name="GL_INT_IMAGE_CUBE_EXT"/>
+                <enum name="GL_INT_IMAGE_BUFFER_EXT"/>
+                <enum name="GL_INT_IMAGE_1D_ARRAY_EXT"/>
+                <enum name="GL_INT_IMAGE_2D_ARRAY_EXT"/>
+                <enum name="GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT"/>
+                <enum name="GL_INT_IMAGE_2D_MULTISAMPLE_EXT"/>
+                <enum name="GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_1D_EXT"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_2D_EXT"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_3D_EXT"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_CUBE_EXT"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_BUFFER_EXT"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT"/>
+                <enum name="GL_MAX_IMAGE_SAMPLES_EXT"/>
+                <enum name="GL_IMAGE_BINDING_FORMAT_EXT"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT"/>
+                <enum name="GL_ELEMENT_ARRAY_BARRIER_BIT_EXT"/>
+                <enum name="GL_UNIFORM_BARRIER_BIT_EXT"/>
+                <enum name="GL_TEXTURE_FETCH_BARRIER_BIT_EXT"/>
+                <enum name="GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT"/>
+                <enum name="GL_COMMAND_BARRIER_BIT_EXT"/>
+                <enum name="GL_PIXEL_BUFFER_BARRIER_BIT_EXT"/>
+                <enum name="GL_TEXTURE_UPDATE_BARRIER_BIT_EXT"/>
+                <enum name="GL_BUFFER_UPDATE_BARRIER_BIT_EXT"/>
+                <enum name="GL_FRAMEBUFFER_BARRIER_BIT_EXT"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT"/>
+                <enum name="GL_ATOMIC_COUNTER_BARRIER_BIT_EXT"/>
+                <enum name="GL_ALL_BARRIER_BITS_EXT"/>
+                <command name="glBindImageTextureEXT"/>
+                <command name="glMemoryBarrierEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_shader_implicit_conversions" supported="gles2"/>
+        <extension name="GL_EXT_shader_integer_mix" supported="gl|gles2"/>
+        <extension name="GL_EXT_shader_io_blocks" supported="gles2"/>
+        <extension name="GL_EXT_shader_pixel_local_storage" supported="gles2">
+            <require>
+                <enum name="GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT"/>
+                <enum name="GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE_EXT"/>
+                <enum name="GL_SHADER_PIXEL_LOCAL_STORAGE_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_shader_texture_lod" supported="gles2"/>
+        <extension name="GL_EXT_shadow_funcs" supported="gl"/>
+        <extension name="GL_EXT_shadow_samplers" supported="gles2">
+            <require>
+                <enum name="GL_TEXTURE_COMPARE_MODE_EXT"/>
+                <enum name="GL_TEXTURE_COMPARE_FUNC_EXT"/>
+                <enum name="GL_COMPARE_REF_TO_TEXTURE_EXT"/>
+                <enum name="GL_SAMPLER_2D_SHADOW_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_shared_texture_palette" supported="gl">
+            <require>
+                <enum name="GL_SHARED_TEXTURE_PALETTE_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_stencil_clear_tag" supported="gl">
+            <require>
+                <enum name="GL_STENCIL_TAG_BITS_EXT"/>
+                <enum name="GL_STENCIL_CLEAR_TAG_VALUE_EXT"/>
+                <command name="glStencilClearTagEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_stencil_two_side" supported="gl">
+            <require>
+                <enum name="GL_STENCIL_TEST_TWO_SIDE_EXT"/>
+                <enum name="GL_ACTIVE_STENCIL_FACE_EXT"/>
+                <command name="glActiveStencilFaceEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_stencil_wrap" supported="gl">
+            <require>
+                <enum name="GL_INCR_WRAP_EXT"/>
+                <enum name="GL_DECR_WRAP_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_subtexture" supported="gl">
+            <require>
+                <command name="glTexSubImage1DEXT"/>
+                <command name="glTexSubImage2DEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_tessellation_shader" supported="gles2">
+            <require>
+                <enum name="GL_PATCHES_EXT"/>
+                <enum name="GL_PATCH_VERTICES_EXT"/>
+                <enum name="GL_TESS_CONTROL_OUTPUT_VERTICES_EXT"/>
+                <enum name="GL_TESS_GEN_MODE_EXT"/>
+                <enum name="GL_TESS_GEN_SPACING_EXT"/>
+                <enum name="GL_TESS_GEN_VERTEX_ORDER_EXT"/>
+                <enum name="GL_TESS_GEN_POINT_MODE_EXT"/>
+                <enum name="GL_TRIANGLES"/>                         
+                <enum name="GL_ISOLINES_EXT"/>
+                <enum name="GL_QUADS_EXT"/>
+                <enum name="GL_EQUAL"/>
+                <enum name="GL_FRACTIONAL_ODD_EXT"/>
+                <enum name="GL_FRACTIONAL_EVEN_EXT"/>
+                <enum name="GL_CCW"/>
+                <enum name="GL_CW"/>
+                <enum name="GL_MAX_PATCH_VERTICES_EXT"/>
+                <enum name="GL_MAX_TESS_GEN_LEVEL_EXT"/>
+                <enum name="GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT"/>
+                <enum name="GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT"/>
+                <enum name="GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_TESS_PATCH_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT"/>
+                <enum name="GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT"/>
+                <enum name="GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT"/>
+                <enum name="GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT"/>
+                <enum name="GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT"/>
+                <enum name="GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT"/>
+                <enum name="GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT"/>
+                <enum name="GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT"/>
+                <enum name="GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT"/>
+                <enum name="GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT"/>
+                <enum name="GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED"/>
+                <enum name="GL_IS_PER_PATCH_EXT"/>
+                <enum name="GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT"/>
+                <enum name="GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT"/>
+                <enum name="GL_TESS_CONTROL_SHADER_EXT"/>
+                <enum name="GL_TESS_EVALUATION_SHADER_EXT"/>
+                <enum name="GL_TESS_CONTROL_SHADER_BIT_EXT"/>
+                <enum name="GL_TESS_EVALUATION_SHADER_BIT_EXT"/>
+                <command name="glPatchParameteriEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture" supported="gl">
+            <require>
+                <enum name="GL_ALPHA4_EXT"/>
+                <enum name="GL_ALPHA8_EXT"/>
+                <enum name="GL_ALPHA12_EXT"/>
+                <enum name="GL_ALPHA16_EXT"/>
+                <enum name="GL_LUMINANCE4_EXT"/>
+                <enum name="GL_LUMINANCE8_EXT"/>
+                <enum name="GL_LUMINANCE12_EXT"/>
+                <enum name="GL_LUMINANCE16_EXT"/>
+                <enum name="GL_LUMINANCE4_ALPHA4_EXT"/>
+                <enum name="GL_LUMINANCE6_ALPHA2_EXT"/>
+                <enum name="GL_LUMINANCE8_ALPHA8_EXT"/>
+                <enum name="GL_LUMINANCE12_ALPHA4_EXT"/>
+                <enum name="GL_LUMINANCE12_ALPHA12_EXT"/>
+                <enum name="GL_LUMINANCE16_ALPHA16_EXT"/>
+                <enum name="GL_INTENSITY_EXT"/>
+                <enum name="GL_INTENSITY4_EXT"/>
+                <enum name="GL_INTENSITY8_EXT"/>
+                <enum name="GL_INTENSITY12_EXT"/>
+                <enum name="GL_INTENSITY16_EXT"/>
+                <enum name="GL_RGB2_EXT"/>
+                <enum name="GL_RGB4_EXT"/>
+                <enum name="GL_RGB5_EXT"/>
+                <enum name="GL_RGB8_EXT"/>
+                <enum name="GL_RGB10_EXT"/>
+                <enum name="GL_RGB12_EXT"/>
+                <enum name="GL_RGB16_EXT"/>
+                <enum name="GL_RGBA2_EXT"/>
+                <enum name="GL_RGBA4_EXT"/>
+                <enum name="GL_RGB5_A1_EXT"/>
+                <enum name="GL_RGBA8_EXT"/>
+                <enum name="GL_RGB10_A2_EXT"/>
+                <enum name="GL_RGBA12_EXT"/>
+                <enum name="GL_RGBA16_EXT"/>
+                <enum name="GL_TEXTURE_RED_SIZE_EXT"/>
+                <enum name="GL_TEXTURE_GREEN_SIZE_EXT"/>
+                <enum name="GL_TEXTURE_BLUE_SIZE_EXT"/>
+                <enum name="GL_TEXTURE_ALPHA_SIZE_EXT"/>
+                <enum name="GL_TEXTURE_LUMINANCE_SIZE_EXT"/>
+                <enum name="GL_TEXTURE_INTENSITY_SIZE_EXT"/>
+                <enum name="GL_REPLACE_EXT"/>
+                <enum name="GL_PROXY_TEXTURE_1D_EXT"/>
+                <enum name="GL_PROXY_TEXTURE_2D_EXT"/>
+                <enum name="GL_TEXTURE_TOO_LARGE_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture3D" supported="gl">
+            <require>
+                <enum name="GL_PACK_SKIP_IMAGES_EXT"/>
+                <enum name="GL_PACK_IMAGE_HEIGHT_EXT"/>
+                <enum name="GL_UNPACK_SKIP_IMAGES_EXT"/>
+                <enum name="GL_UNPACK_IMAGE_HEIGHT_EXT"/>
+                <enum name="GL_TEXTURE_3D_EXT"/>
+                <enum name="GL_PROXY_TEXTURE_3D_EXT"/>
+                <enum name="GL_TEXTURE_DEPTH_EXT"/>
+                <enum name="GL_TEXTURE_WRAP_R_EXT"/>
+                <enum name="GL_MAX_3D_TEXTURE_SIZE_EXT"/>
+                <command name="glTexImage3DEXT"/>
+                <command name="glTexSubImage3DEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_array" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_1D_ARRAY_EXT"/>
+                <enum name="GL_PROXY_TEXTURE_1D_ARRAY_EXT"/>
+                <enum name="GL_TEXTURE_2D_ARRAY_EXT"/>
+                <enum name="GL_PROXY_TEXTURE_2D_ARRAY_EXT"/>
+                <enum name="GL_TEXTURE_BINDING_1D_ARRAY_EXT"/>
+                <enum name="GL_TEXTURE_BINDING_2D_ARRAY_EXT"/>
+                <enum name="GL_MAX_ARRAY_TEXTURE_LAYERS_EXT"/>
+                <enum name="GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_border_clamp" supported="gles2">
+            <require>
+                <enum name="GL_TEXTURE_BORDER_COLOR_EXT"/>
+                <enum name="GL_CLAMP_TO_BORDER_EXT"/>
+                <command name="glTexParameterIivEXT"/>
+                <command name="glTexParameterIuivEXT"/>
+                <command name="glGetTexParameterIivEXT"/>
+                <command name="glGetTexParameterIuivEXT"/>
+                <command name="glSamplerParameterIivEXT"/>
+                <command name="glSamplerParameterIuivEXT"/>
+                <command name="glGetSamplerParameterIivEXT"/>
+                <command name="glGetSamplerParameterIuivEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_buffer" supported="gles2">
+            <require>
+                <enum name="GL_TEXTURE_BUFFER_EXT"/>
+                <enum name="GL_TEXTURE_BUFFER_BINDING_EXT"/>
+                <enum name="GL_MAX_TEXTURE_BUFFER_SIZE_EXT"/>
+                <enum name="GL_TEXTURE_BINDING_BUFFER_EXT"/>
+                <enum name="GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT"/>
+                <enum name="GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT"/>
+                <enum name="GL_SAMPLER_BUFFER_EXT"/>
+                <enum name="GL_INT_SAMPLER_BUFFER_EXT"/>
+                <enum name="GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT"/>
+                <enum name="GL_IMAGE_BUFFER_EXT"/>
+                <enum name="GL_INT_IMAGE_BUFFER_EXT"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_BUFFER_EXT"/>
+                <enum name="GL_TEXTURE_BUFFER_OFFSET_EXT"/>
+                <enum name="GL_TEXTURE_BUFFER_SIZE_EXT"/>
+                <command name="glTexBufferEXT"/>
+                <command name="glTexBufferRangeEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_buffer_object" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_BUFFER_EXT"/>
+                <enum name="GL_MAX_TEXTURE_BUFFER_SIZE_EXT"/>
+                <enum name="GL_TEXTURE_BINDING_BUFFER_EXT"/>
+                <enum name="GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT"/>
+                <enum name="GL_TEXTURE_BUFFER_FORMAT_EXT"/>
+                <command name="glTexBufferEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_compression_dxt1" supported="gles1|gles2">
+            <require>
+                <enum name="GL_COMPRESSED_RGB_S3TC_DXT1_EXT"/>
+                <enum name="GL_COMPRESSED_RGBA_S3TC_DXT1_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_compression_latc" supported="gl">
+            <require>
+                <enum name="GL_COMPRESSED_LUMINANCE_LATC1_EXT"/>
+                <enum name="GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT"/>
+                <enum name="GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT"/>
+                <enum name="GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_compression_rgtc" supported="gl">
+            <require>
+                <enum name="GL_COMPRESSED_RED_RGTC1_EXT"/>
+                <enum name="GL_COMPRESSED_SIGNED_RED_RGTC1_EXT"/>
+                <enum name="GL_COMPRESSED_RED_GREEN_RGTC2_EXT"/>
+                <enum name="GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_compression_s3tc" supported="gl|gles2">
+            <require>
+                <enum name="GL_COMPRESSED_RGB_S3TC_DXT1_EXT"/>
+                <enum name="GL_COMPRESSED_RGBA_S3TC_DXT1_EXT"/>
+                <enum name="GL_COMPRESSED_RGBA_S3TC_DXT3_EXT"/>
+                <enum name="GL_COMPRESSED_RGBA_S3TC_DXT5_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_cube_map" supported="gl" comment="Replaced by ARB_texture_cube_map, but was apparently shipped anyway?">
+            <require>
+                <enum name="GL_NORMAL_MAP_EXT"/>
+                <enum name="GL_REFLECTION_MAP_EXT"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_EXT"/>
+                <enum name="GL_TEXTURE_BINDING_CUBE_MAP_EXT"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT"/>
+                <enum name="GL_PROXY_TEXTURE_CUBE_MAP_EXT"/>
+                <enum name="GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_cube_map_array" supported="gles2">
+            <require>
+                <enum name="GL_TEXTURE_CUBE_MAP_ARRAY_EXT"/>
+                <enum name="GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT"/>
+                <enum name="GL_SAMPLER_CUBE_MAP_ARRAY_EXT"/>
+                <enum name="GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT"/>
+                <enum name="GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT"/>
+                <enum name="GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT"/>
+                <enum name="GL_IMAGE_CUBE_MAP_ARRAY_EXT"/>
+                <enum name="GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT"/>
+                <enum name="GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_env_add" supported="gl"/>
+        <extension name="GL_EXT_texture_env_combine" supported="gl">
+            <require>
+                <enum name="GL_COMBINE_EXT"/>
+                <enum name="GL_COMBINE_RGB_EXT"/>
+                <enum name="GL_COMBINE_ALPHA_EXT"/>
+                <enum name="GL_RGB_SCALE_EXT"/>
+                <enum name="GL_ADD_SIGNED_EXT"/>
+                <enum name="GL_INTERPOLATE_EXT"/>
+                <enum name="GL_CONSTANT_EXT"/>
+                <enum name="GL_PRIMARY_COLOR_EXT"/>
+                <enum name="GL_PREVIOUS_EXT"/>
+                <enum name="GL_SOURCE0_RGB_EXT"/>
+                <enum name="GL_SOURCE1_RGB_EXT"/>
+                <enum name="GL_SOURCE2_RGB_EXT"/>
+                <enum name="GL_SOURCE0_ALPHA_EXT"/>
+                <enum name="GL_SOURCE1_ALPHA_EXT"/>
+                <enum name="GL_SOURCE2_ALPHA_EXT"/>
+                <enum name="GL_OPERAND0_RGB_EXT"/>
+                <enum name="GL_OPERAND1_RGB_EXT"/>
+                <enum name="GL_OPERAND2_RGB_EXT"/>
+                <enum name="GL_OPERAND0_ALPHA_EXT"/>
+                <enum name="GL_OPERAND1_ALPHA_EXT"/>
+                <enum name="GL_OPERAND2_ALPHA_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_env_dot3" supported="gl">
+            <require>
+                <enum name="GL_DOT3_RGB_EXT"/>
+                <enum name="GL_DOT3_RGBA_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_filter_anisotropic" supported="gl|gles1|gles2">
+            <require>
+                <enum name="GL_TEXTURE_MAX_ANISOTROPY_EXT"/>
+                <enum name="GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_format_BGRA8888" supported="gles1|gles2">
+            <require>
+                <enum name="GL_BGRA_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_integer" supported="gl">
+            <require>
+                <enum name="GL_RGBA32UI_EXT"/>
+                <enum name="GL_RGB32UI_EXT"/>
+                <enum name="GL_ALPHA32UI_EXT"/>
+                <enum name="GL_INTENSITY32UI_EXT"/>
+                <enum name="GL_LUMINANCE32UI_EXT"/>
+                <enum name="GL_LUMINANCE_ALPHA32UI_EXT"/>
+                <enum name="GL_RGBA16UI_EXT"/>
+                <enum name="GL_RGB16UI_EXT"/>
+                <enum name="GL_ALPHA16UI_EXT"/>
+                <enum name="GL_INTENSITY16UI_EXT"/>
+                <enum name="GL_LUMINANCE16UI_EXT"/>
+                <enum name="GL_LUMINANCE_ALPHA16UI_EXT"/>
+                <enum name="GL_RGBA8UI_EXT"/>
+                <enum name="GL_RGB8UI_EXT"/>
+                <enum name="GL_ALPHA8UI_EXT"/>
+                <enum name="GL_INTENSITY8UI_EXT"/>
+                <enum name="GL_LUMINANCE8UI_EXT"/>
+                <enum name="GL_LUMINANCE_ALPHA8UI_EXT"/>
+                <enum name="GL_RGBA32I_EXT"/>
+                <enum name="GL_RGB32I_EXT"/>
+                <enum name="GL_ALPHA32I_EXT"/>
+                <enum name="GL_INTENSITY32I_EXT"/>
+                <enum name="GL_LUMINANCE32I_EXT"/>
+                <enum name="GL_LUMINANCE_ALPHA32I_EXT"/>
+                <enum name="GL_RGBA16I_EXT"/>
+                <enum name="GL_RGB16I_EXT"/>
+                <enum name="GL_ALPHA16I_EXT"/>
+                <enum name="GL_INTENSITY16I_EXT"/>
+                <enum name="GL_LUMINANCE16I_EXT"/>
+                <enum name="GL_LUMINANCE_ALPHA16I_EXT"/>
+                <enum name="GL_RGBA8I_EXT"/>
+                <enum name="GL_RGB8I_EXT"/>
+                <enum name="GL_ALPHA8I_EXT"/>
+                <enum name="GL_INTENSITY8I_EXT"/>
+                <enum name="GL_LUMINANCE8I_EXT"/>
+                <enum name="GL_LUMINANCE_ALPHA8I_EXT"/>
+                <enum name="GL_RED_INTEGER_EXT"/>
+                <enum name="GL_GREEN_INTEGER_EXT"/>
+                <enum name="GL_BLUE_INTEGER_EXT"/>
+                <enum name="GL_ALPHA_INTEGER_EXT"/>
+                <enum name="GL_RGB_INTEGER_EXT"/>
+                <enum name="GL_RGBA_INTEGER_EXT"/>
+                <enum name="GL_BGR_INTEGER_EXT"/>
+                <enum name="GL_BGRA_INTEGER_EXT"/>
+                <enum name="GL_LUMINANCE_INTEGER_EXT"/>
+                <enum name="GL_LUMINANCE_ALPHA_INTEGER_EXT"/>
+                <enum name="GL_RGBA_INTEGER_MODE_EXT"/>
+                <command name="glTexParameterIivEXT"/>
+                <command name="glTexParameterIuivEXT"/>
+                <command name="glGetTexParameterIivEXT"/>
+                <command name="glGetTexParameterIuivEXT"/>
+                <command name="glClearColorIiEXT"/>
+                <command name="glClearColorIuiEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_lod_bias" supported="gl|gles1">
+            <require>
+                <enum name="GL_MAX_TEXTURE_LOD_BIAS_EXT"/>
+                <enum name="GL_TEXTURE_FILTER_CONTROL_EXT"/>
+                <enum name="GL_TEXTURE_LOD_BIAS_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_mirror_clamp" supported="gl">
+            <require>
+                <enum name="GL_MIRROR_CLAMP_EXT"/>
+                <enum name="GL_MIRROR_CLAMP_TO_EDGE_EXT"/>
+                <enum name="GL_MIRROR_CLAMP_TO_BORDER_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_object" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_PRIORITY_EXT"/>
+                <enum name="GL_TEXTURE_RESIDENT_EXT"/>
+                <enum name="GL_TEXTURE_1D_BINDING_EXT"/>
+                <enum name="GL_TEXTURE_2D_BINDING_EXT"/>
+                <enum name="GL_TEXTURE_3D_BINDING_EXT"/>
+                <command name="glAreTexturesResidentEXT"/>
+                <command name="glBindTextureEXT"/>
+                <command name="glDeleteTexturesEXT"/>
+                <command name="glGenTexturesEXT"/>
+                <command name="glIsTextureEXT"/>
+                <command name="glPrioritizeTexturesEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_perturb_normal" supported="gl">
+            <require>
+                <enum name="GL_PERTURB_EXT"/>
+                <enum name="GL_TEXTURE_NORMAL_EXT"/>
+                <command name="glTextureNormalEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_rg" supported="gles2">
+            <require>
+                <enum name="GL_RED_EXT"/>
+                <enum name="GL_RG_EXT"/>
+                <enum name="GL_R8_EXT"/>
+                <enum name="GL_RG8_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_sRGB" supported="gl">
+            <require>
+                <enum name="GL_SRGB_EXT"/>
+                <enum name="GL_SRGB8_EXT"/>
+                <enum name="GL_SRGB_ALPHA_EXT"/>
+                <enum name="GL_SRGB8_ALPHA8_EXT"/>
+                <enum name="GL_SLUMINANCE_ALPHA_EXT"/>
+                <enum name="GL_SLUMINANCE8_ALPHA8_EXT"/>
+                <enum name="GL_SLUMINANCE_EXT"/>
+                <enum name="GL_SLUMINANCE8_EXT"/>
+                <enum name="GL_COMPRESSED_SRGB_EXT"/>
+                <enum name="GL_COMPRESSED_SRGB_ALPHA_EXT"/>
+                <enum name="GL_COMPRESSED_SLUMINANCE_EXT"/>
+                <enum name="GL_COMPRESSED_SLUMINANCE_ALPHA_EXT"/>
+                <enum name="GL_COMPRESSED_SRGB_S3TC_DXT1_EXT"/>
+                <enum name="GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT"/>
+                <enum name="GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT"/>
+                <enum name="GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_sRGB_decode" supported="gl|gles2">
+            <require>
+                <enum name="GL_TEXTURE_SRGB_DECODE_EXT"/>
+                <enum name="GL_DECODE_EXT"/>
+                <enum name="GL_SKIP_DECODE_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_shared_exponent" supported="gl">
+            <require>
+                <enum name="GL_RGB9_E5_EXT"/>
+                <enum name="GL_UNSIGNED_INT_5_9_9_9_REV_EXT"/>
+                <enum name="GL_TEXTURE_SHARED_SIZE_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_snorm" supported="gl">
+            <require>
+                <enum name="GL_ALPHA_SNORM"/>
+                <enum name="GL_LUMINANCE_SNORM"/>
+                <enum name="GL_LUMINANCE_ALPHA_SNORM"/>
+                <enum name="GL_INTENSITY_SNORM"/>
+                <enum name="GL_ALPHA8_SNORM"/>
+                <enum name="GL_LUMINANCE8_SNORM"/>
+                <enum name="GL_LUMINANCE8_ALPHA8_SNORM"/>
+                <enum name="GL_INTENSITY8_SNORM"/>
+                <enum name="GL_ALPHA16_SNORM"/>
+                <enum name="GL_LUMINANCE16_SNORM"/>
+                <enum name="GL_LUMINANCE16_ALPHA16_SNORM"/>
+                <enum name="GL_INTENSITY16_SNORM"/>
+                <enum name="GL_RED_SNORM"/>
+                <enum name="GL_RG_SNORM"/>
+                <enum name="GL_RGB_SNORM"/>
+                <enum name="GL_RGBA_SNORM"/>
+                <enum name="GL_R8_SNORM"/>
+                <enum name="GL_RG8_SNORM"/>
+                <enum name="GL_RGB8_SNORM"/>
+                <enum name="GL_RGBA8_SNORM"/>
+                <enum name="GL_R16_SNORM"/>
+                <enum name="GL_RG16_SNORM"/>
+                <enum name="GL_RGB16_SNORM"/>
+                <enum name="GL_RGBA16_SNORM"/>
+                <enum name="GL_SIGNED_NORMALIZED"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_storage" supported="gles1|gles2">
+            <require comment="Not clear all of these enums should be here for OpenGL ES. Many are only defined if other extensions also requiring them are supported">
+                <enum name="GL_TEXTURE_IMMUTABLE_FORMAT_EXT"/>
+                <enum name="GL_ALPHA8_EXT"/>
+                <enum name="GL_LUMINANCE8_EXT"/>
+                <enum name="GL_LUMINANCE8_ALPHA8_EXT"/>
+                <enum name="GL_RGBA32F_EXT"/>
+                <enum name="GL_RGB32F_EXT"/>
+                <enum name="GL_ALPHA32F_EXT"/>
+                <enum name="GL_LUMINANCE32F_EXT"/>
+                <enum name="GL_LUMINANCE_ALPHA32F_EXT"/>
+                <enum name="GL_RGBA16F_EXT"/>
+                <enum name="GL_RGB16F_EXT"/>
+                <enum name="GL_ALPHA16F_EXT"/>
+                <enum name="GL_LUMINANCE16F_EXT"/>
+                <enum name="GL_LUMINANCE_ALPHA16F_EXT"/>
+                <enum name="GL_RGB10_A2_EXT"/>
+                <enum name="GL_RGB10_EXT"/>
+                <enum name="GL_BGRA8_EXT"/>
+                <enum name="GL_R8_EXT"/>
+                <enum name="GL_RG8_EXT"/>
+                <enum name="GL_R32F_EXT"/>
+                <enum name="GL_RG32F_EXT"/>
+                <enum name="GL_R16F_EXT"/>
+                <enum name="GL_RG16F_EXT"/>
+                <command name="glTexStorage1DEXT"/>
+                <command name="glTexStorage2DEXT"/>
+                <command name="glTexStorage3DEXT"/>
+            </require>
+            <require comment="Supported only if GL_EXT_direct_state_access is supported">
+                <command name="glTextureStorage1DEXT"/>
+                <command name="glTextureStorage2DEXT"/>
+                <command name="glTextureStorage3DEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_swizzle" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_SWIZZLE_R_EXT"/>
+                <enum name="GL_TEXTURE_SWIZZLE_G_EXT"/>
+                <enum name="GL_TEXTURE_SWIZZLE_B_EXT"/>
+                <enum name="GL_TEXTURE_SWIZZLE_A_EXT"/>
+                <enum name="GL_TEXTURE_SWIZZLE_RGBA_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_type_2_10_10_10_REV" supported="gles2">
+            <require>
+                <enum name="GL_UNSIGNED_INT_2_10_10_10_REV_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_texture_view" supported="gles2">
+            <require>
+                <enum name="GL_TEXTURE_VIEW_MIN_LEVEL_EXT"/>
+                <enum name="GL_TEXTURE_VIEW_NUM_LEVELS_EXT"/>
+                <enum name="GL_TEXTURE_VIEW_MIN_LAYER_EXT"/>
+                <enum name="GL_TEXTURE_VIEW_NUM_LAYERS_EXT"/>
+                <enum name="GL_TEXTURE_IMMUTABLE_LEVELS"/>
+                <command name="glTextureViewEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_timer_query" supported="gl">
+            <require>
+                <enum name="GL_TIME_ELAPSED_EXT"/>
+                <command name="glGetQueryObjecti64vEXT"/>
+                <command name="glGetQueryObjectui64vEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_transform_feedback" supported="gl">
+            <require>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_EXT"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT"/>
+                <enum name="GL_INTERLEAVED_ATTRIBS_EXT"/>
+                <enum name="GL_SEPARATE_ATTRIBS_EXT"/>
+                <enum name="GL_PRIMITIVES_GENERATED_EXT"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT"/>
+                <enum name="GL_RASTERIZER_DISCARD_EXT"/>
+                <enum name="GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT"/>
+                <enum name="GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT"/>
+                <enum name="GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_VARYINGS_EXT"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT"/>
+                <command name="glBeginTransformFeedbackEXT"/>
+                <command name="glEndTransformFeedbackEXT"/>
+                <command name="glBindBufferRangeEXT"/>
+                <command name="glBindBufferOffsetEXT"/>
+                <command name="glBindBufferBaseEXT"/>
+                <command name="glTransformFeedbackVaryingsEXT"/>
+                <command name="glGetTransformFeedbackVaryingEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_unpack_subimage" supported="gles2">
+            <require>
+                <enum name="GL_UNPACK_ROW_LENGTH_EXT"/>
+                <enum name="GL_UNPACK_SKIP_ROWS_EXT"/>
+                <enum name="GL_UNPACK_SKIP_PIXELS_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_vertex_array" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_ARRAY_EXT"/>
+                <enum name="GL_NORMAL_ARRAY_EXT"/>
+                <enum name="GL_COLOR_ARRAY_EXT"/>
+                <enum name="GL_INDEX_ARRAY_EXT"/>
+                <enum name="GL_TEXTURE_COORD_ARRAY_EXT"/>
+                <enum name="GL_EDGE_FLAG_ARRAY_EXT"/>
+                <enum name="GL_VERTEX_ARRAY_SIZE_EXT"/>
+                <enum name="GL_VERTEX_ARRAY_TYPE_EXT"/>
+                <enum name="GL_VERTEX_ARRAY_STRIDE_EXT"/>
+                <enum name="GL_VERTEX_ARRAY_COUNT_EXT"/>
+                <enum name="GL_NORMAL_ARRAY_TYPE_EXT"/>
+                <enum name="GL_NORMAL_ARRAY_STRIDE_EXT"/>
+                <enum name="GL_NORMAL_ARRAY_COUNT_EXT"/>
+                <enum name="GL_COLOR_ARRAY_SIZE_EXT"/>
+                <enum name="GL_COLOR_ARRAY_TYPE_EXT"/>
+                <enum name="GL_COLOR_ARRAY_STRIDE_EXT"/>
+                <enum name="GL_COLOR_ARRAY_COUNT_EXT"/>
+                <enum name="GL_INDEX_ARRAY_TYPE_EXT"/>
+                <enum name="GL_INDEX_ARRAY_STRIDE_EXT"/>
+                <enum name="GL_INDEX_ARRAY_COUNT_EXT"/>
+                <enum name="GL_TEXTURE_COORD_ARRAY_SIZE_EXT"/>
+                <enum name="GL_TEXTURE_COORD_ARRAY_TYPE_EXT"/>
+                <enum name="GL_TEXTURE_COORD_ARRAY_STRIDE_EXT"/>
+                <enum name="GL_TEXTURE_COORD_ARRAY_COUNT_EXT"/>
+                <enum name="GL_EDGE_FLAG_ARRAY_STRIDE_EXT"/>
+                <enum name="GL_EDGE_FLAG_ARRAY_COUNT_EXT"/>
+                <enum name="GL_VERTEX_ARRAY_POINTER_EXT"/>
+                <enum name="GL_NORMAL_ARRAY_POINTER_EXT"/>
+                <enum name="GL_COLOR_ARRAY_POINTER_EXT"/>
+                <enum name="GL_INDEX_ARRAY_POINTER_EXT"/>
+                <enum name="GL_TEXTURE_COORD_ARRAY_POINTER_EXT"/>
+                <enum name="GL_EDGE_FLAG_ARRAY_POINTER_EXT"/>
+                <command name="glArrayElementEXT"/>
+                <command name="glColorPointerEXT"/>
+                <command name="glDrawArraysEXT"/>
+                <command name="glEdgeFlagPointerEXT"/>
+                <command name="glGetPointervEXT"/>
+                <command name="glIndexPointerEXT"/>
+                <command name="glNormalPointerEXT"/>
+                <command name="glTexCoordPointerEXT"/>
+                <command name="glVertexPointerEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_vertex_array_bgra" supported="gl">
+            <require>
+                <enum name="GL_BGRA"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_vertex_attrib_64bit" supported="gl">
+            <require>
+                <enum name="GL_DOUBLE"/>
+                <enum name="GL_DOUBLE_VEC2_EXT"/>
+                <enum name="GL_DOUBLE_VEC3_EXT"/>
+                <enum name="GL_DOUBLE_VEC4_EXT"/>
+                <enum name="GL_DOUBLE_MAT2_EXT"/>
+                <enum name="GL_DOUBLE_MAT3_EXT"/>
+                <enum name="GL_DOUBLE_MAT4_EXT"/>
+                <enum name="GL_DOUBLE_MAT2x3_EXT"/>
+                <enum name="GL_DOUBLE_MAT2x4_EXT"/>
+                <enum name="GL_DOUBLE_MAT3x2_EXT"/>
+                <enum name="GL_DOUBLE_MAT3x4_EXT"/>
+                <enum name="GL_DOUBLE_MAT4x2_EXT"/>
+                <enum name="GL_DOUBLE_MAT4x3_EXT"/>
+                <command name="glVertexAttribL1dEXT"/>
+                <command name="glVertexAttribL2dEXT"/>
+                <command name="glVertexAttribL3dEXT"/>
+                <command name="glVertexAttribL4dEXT"/>
+                <command name="glVertexAttribL1dvEXT"/>
+                <command name="glVertexAttribL2dvEXT"/>
+                <command name="glVertexAttribL3dvEXT"/>
+                <command name="glVertexAttribL4dvEXT"/>
+                <command name="glVertexAttribLPointerEXT"/>
+                <command name="glGetVertexAttribLdvEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_vertex_shader" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_SHADER_EXT"/>
+                <enum name="GL_VERTEX_SHADER_BINDING_EXT"/>
+                <enum name="GL_OP_INDEX_EXT"/>
+                <enum name="GL_OP_NEGATE_EXT"/>
+                <enum name="GL_OP_DOT3_EXT"/>
+                <enum name="GL_OP_DOT4_EXT"/>
+                <enum name="GL_OP_MUL_EXT"/>
+                <enum name="GL_OP_ADD_EXT"/>
+                <enum name="GL_OP_MADD_EXT"/>
+                <enum name="GL_OP_FRAC_EXT"/>
+                <enum name="GL_OP_MAX_EXT"/>
+                <enum name="GL_OP_MIN_EXT"/>
+                <enum name="GL_OP_SET_GE_EXT"/>
+                <enum name="GL_OP_SET_LT_EXT"/>
+                <enum name="GL_OP_CLAMP_EXT"/>
+                <enum name="GL_OP_FLOOR_EXT"/>
+                <enum name="GL_OP_ROUND_EXT"/>
+                <enum name="GL_OP_EXP_BASE_2_EXT"/>
+                <enum name="GL_OP_LOG_BASE_2_EXT"/>
+                <enum name="GL_OP_POWER_EXT"/>
+                <enum name="GL_OP_RECIP_EXT"/>
+                <enum name="GL_OP_RECIP_SQRT_EXT"/>
+                <enum name="GL_OP_SUB_EXT"/>
+                <enum name="GL_OP_CROSS_PRODUCT_EXT"/>
+                <enum name="GL_OP_MULTIPLY_MATRIX_EXT"/>
+                <enum name="GL_OP_MOV_EXT"/>
+                <enum name="GL_OUTPUT_VERTEX_EXT"/>
+                <enum name="GL_OUTPUT_COLOR0_EXT"/>
+                <enum name="GL_OUTPUT_COLOR1_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD0_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD1_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD2_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD3_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD4_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD5_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD6_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD7_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD8_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD9_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD10_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD11_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD12_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD13_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD14_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD15_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD16_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD17_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD18_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD19_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD20_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD21_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD22_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD23_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD24_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD25_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD26_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD27_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD28_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD29_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD30_EXT"/>
+                <enum name="GL_OUTPUT_TEXTURE_COORD31_EXT"/>
+                <enum name="GL_OUTPUT_FOG_EXT"/>
+                <enum name="GL_SCALAR_EXT"/>
+                <enum name="GL_VECTOR_EXT"/>
+                <enum name="GL_MATRIX_EXT"/>
+                <enum name="GL_VARIANT_EXT"/>
+                <enum name="GL_INVARIANT_EXT"/>
+                <enum name="GL_LOCAL_CONSTANT_EXT"/>
+                <enum name="GL_LOCAL_EXT"/>
+                <enum name="GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT"/>
+                <enum name="GL_MAX_VERTEX_SHADER_VARIANTS_EXT"/>
+                <enum name="GL_MAX_VERTEX_SHADER_INVARIANTS_EXT"/>
+                <enum name="GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT"/>
+                <enum name="GL_MAX_VERTEX_SHADER_LOCALS_EXT"/>
+                <enum name="GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT"/>
+                <enum name="GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT"/>
+                <enum name="GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT"/>
+                <enum name="GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT"/>
+                <enum name="GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT"/>
+                <enum name="GL_VERTEX_SHADER_INSTRUCTIONS_EXT"/>
+                <enum name="GL_VERTEX_SHADER_VARIANTS_EXT"/>
+                <enum name="GL_VERTEX_SHADER_INVARIANTS_EXT"/>
+                <enum name="GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT"/>
+                <enum name="GL_VERTEX_SHADER_LOCALS_EXT"/>
+                <enum name="GL_VERTEX_SHADER_OPTIMIZED_EXT"/>
+                <enum name="GL_X_EXT"/>
+                <enum name="GL_Y_EXT"/>
+                <enum name="GL_Z_EXT"/>
+                <enum name="GL_W_EXT"/>
+                <enum name="GL_NEGATIVE_X_EXT"/>
+                <enum name="GL_NEGATIVE_Y_EXT"/>
+                <enum name="GL_NEGATIVE_Z_EXT"/>
+                <enum name="GL_NEGATIVE_W_EXT"/>
+                <enum name="GL_ZERO_EXT"/>
+                <enum name="GL_ONE_EXT"/>
+                <enum name="GL_NEGATIVE_ONE_EXT"/>
+                <enum name="GL_NORMALIZED_RANGE_EXT"/>
+                <enum name="GL_FULL_RANGE_EXT"/>
+                <enum name="GL_CURRENT_VERTEX_EXT"/>
+                <enum name="GL_MVP_MATRIX_EXT"/>
+                <enum name="GL_VARIANT_VALUE_EXT"/>
+                <enum name="GL_VARIANT_DATATYPE_EXT"/>
+                <enum name="GL_VARIANT_ARRAY_STRIDE_EXT"/>
+                <enum name="GL_VARIANT_ARRAY_TYPE_EXT"/>
+                <enum name="GL_VARIANT_ARRAY_EXT"/>
+                <enum name="GL_VARIANT_ARRAY_POINTER_EXT"/>
+                <enum name="GL_INVARIANT_VALUE_EXT"/>
+                <enum name="GL_INVARIANT_DATATYPE_EXT"/>
+                <enum name="GL_LOCAL_CONSTANT_VALUE_EXT"/>
+                <enum name="GL_LOCAL_CONSTANT_DATATYPE_EXT"/>
+                <command name="glBeginVertexShaderEXT"/>
+                <command name="glEndVertexShaderEXT"/>
+                <command name="glBindVertexShaderEXT"/>
+                <command name="glGenVertexShadersEXT"/>
+                <command name="glDeleteVertexShaderEXT"/>
+                <command name="glShaderOp1EXT"/>
+                <command name="glShaderOp2EXT"/>
+                <command name="glShaderOp3EXT"/>
+                <command name="glSwizzleEXT"/>
+                <command name="glWriteMaskEXT"/>
+                <command name="glInsertComponentEXT"/>
+                <command name="glExtractComponentEXT"/>
+                <command name="glGenSymbolsEXT"/>
+                <command name="glSetInvariantEXT"/>
+                <command name="glSetLocalConstantEXT"/>
+                <command name="glVariantbvEXT"/>
+                <command name="glVariantsvEXT"/>
+                <command name="glVariantivEXT"/>
+                <command name="glVariantfvEXT"/>
+                <command name="glVariantdvEXT"/>
+                <command name="glVariantubvEXT"/>
+                <command name="glVariantusvEXT"/>
+                <command name="glVariantuivEXT"/>
+                <command name="glVariantPointerEXT"/>
+                <command name="glEnableVariantClientStateEXT"/>
+                <command name="glDisableVariantClientStateEXT"/>
+                <command name="glBindLightParameterEXT"/>
+                <command name="glBindMaterialParameterEXT"/>
+                <command name="glBindTexGenParameterEXT"/>
+                <command name="glBindTextureUnitParameterEXT"/>
+                <command name="glBindParameterEXT"/>
+                <command name="glIsVariantEnabledEXT"/>
+                <command name="glGetVariantBooleanvEXT"/>
+                <command name="glGetVariantIntegervEXT"/>
+                <command name="glGetVariantFloatvEXT"/>
+                <command name="glGetVariantPointervEXT"/>
+                <command name="glGetInvariantBooleanvEXT"/>
+                <command name="glGetInvariantIntegervEXT"/>
+                <command name="glGetInvariantFloatvEXT"/>
+                <command name="glGetLocalConstantBooleanvEXT"/>
+                <command name="glGetLocalConstantIntegervEXT"/>
+                <command name="glGetLocalConstantFloatvEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_vertex_weighting" supported="gl">
+            <require>
+                <enum name="GL_MODELVIEW0_STACK_DEPTH_EXT"/>
+                <enum name="GL_MODELVIEW1_STACK_DEPTH_EXT"/>
+                <enum name="GL_MODELVIEW0_MATRIX_EXT"/>
+                <enum name="GL_MODELVIEW1_MATRIX_EXT"/>
+                <enum name="GL_VERTEX_WEIGHTING_EXT"/>
+                <enum name="GL_MODELVIEW0_EXT"/>
+                <enum name="GL_MODELVIEW1_EXT"/>
+                <enum name="GL_CURRENT_VERTEX_WEIGHT_EXT"/>
+                <enum name="GL_VERTEX_WEIGHT_ARRAY_EXT"/>
+                <enum name="GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT"/>
+                <enum name="GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT"/>
+                <enum name="GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT"/>
+                <enum name="GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT"/>
+                <command name="glVertexWeightfEXT"/>
+                <command name="glVertexWeightfvEXT"/>
+                <command name="glVertexWeightPointerEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_EXT_x11_sync_object" supported="gl">
+            <require>
+                <enum name="GL_SYNC_X11_FENCE_EXT"/>
+                <command name="glImportSyncEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_FJ_shader_binary_GCCSO" supported="gles2">
+            <require>
+                <enum name="GL_GCCSO_SHADER_BINARY_FJ"/>
+            </require>
+        </extension>
+        <extension name="GL_GREMEDY_frame_terminator" supported="gl">
+            <require>
+                <command name="glFrameTerminatorGREMEDY"/>
+            </require>
+        </extension>
+        <extension name="GL_GREMEDY_string_marker" supported="gl">
+            <require>
+                <command name="glStringMarkerGREMEDY"/>
+            </require>
+        </extension>
+        <extension name="GL_HP_convolution_border_modes" supported="gl">
+            <require>
+                <enum name="GL_IGNORE_BORDER_HP"/>
+                <enum name="GL_CONSTANT_BORDER_HP"/>
+                <enum name="GL_REPLICATE_BORDER_HP"/>
+                <enum name="GL_CONVOLUTION_BORDER_COLOR_HP"/>
+            </require>
+        </extension>
+        <extension name="GL_HP_image_transform" supported="gl">
+            <require>
+                <enum name="GL_IMAGE_SCALE_X_HP"/>
+                <enum name="GL_IMAGE_SCALE_Y_HP"/>
+                <enum name="GL_IMAGE_TRANSLATE_X_HP"/>
+                <enum name="GL_IMAGE_TRANSLATE_Y_HP"/>
+                <enum name="GL_IMAGE_ROTATE_ANGLE_HP"/>
+                <enum name="GL_IMAGE_ROTATE_ORIGIN_X_HP"/>
+                <enum name="GL_IMAGE_ROTATE_ORIGIN_Y_HP"/>
+                <enum name="GL_IMAGE_MAG_FILTER_HP"/>
+                <enum name="GL_IMAGE_MIN_FILTER_HP"/>
+                <enum name="GL_IMAGE_CUBIC_WEIGHT_HP"/>
+                <enum name="GL_CUBIC_HP"/>
+                <enum name="GL_AVERAGE_HP"/>
+                <enum name="GL_IMAGE_TRANSFORM_2D_HP"/>
+                <enum name="GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP"/>
+                <enum name="GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP"/>
+                <command name="glImageTransformParameteriHP"/>
+                <command name="glImageTransformParameterfHP"/>
+                <command name="glImageTransformParameterivHP"/>
+                <command name="glImageTransformParameterfvHP"/>
+                <command name="glGetImageTransformParameterivHP"/>
+                <command name="glGetImageTransformParameterfvHP"/>
+            </require>
+        </extension>
+        <extension name="GL_HP_occlusion_test" supported="gl">
+            <require>
+                <enum name="GL_OCCLUSION_TEST_HP"/>
+                <enum name="GL_OCCLUSION_TEST_RESULT_HP"/>
+            </require>
+        </extension>
+        <extension name="GL_HP_texture_lighting" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_LIGHTING_MODE_HP"/>
+                <enum name="GL_TEXTURE_POST_SPECULAR_HP"/>
+                <enum name="GL_TEXTURE_PRE_SPECULAR_HP"/>
+            </require>
+        </extension>
+        <extension name="GL_IBM_cull_vertex" supported="gl">
+            <require>
+                <enum name="GL_CULL_VERTEX_IBM"/>
+            </require>
+        </extension>
+        <extension name="GL_IBM_multimode_draw_arrays" supported="gl">
+            <require>
+                <command name="glMultiModeDrawArraysIBM"/>
+                <command name="glMultiModeDrawElementsIBM"/>
+            </require>
+        </extension>
+        <extension name="GL_IBM_rasterpos_clip" supported="gl">
+            <require>
+                <enum name="GL_RASTER_POSITION_UNCLIPPED_IBM"/>
+            </require>
+        </extension>
+        <extension name="GL_IBM_static_data" supported="gl">
+            <require>
+                <enum name="GL_ALL_STATIC_DATA_IBM"/>
+                <enum name="GL_STATIC_VERTEX_ARRAY_IBM"/>
+                <command name="glFlushStaticDataIBM"/>
+            </require>
+        </extension>
+        <extension name="GL_IBM_texture_mirrored_repeat" supported="gl">
+            <require>
+                <enum name="GL_MIRRORED_REPEAT_IBM"/>
+            </require>
+        </extension>
+        <extension name="GL_IBM_vertex_array_lists" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_ARRAY_LIST_IBM"/>
+                <enum name="GL_NORMAL_ARRAY_LIST_IBM"/>
+                <enum name="GL_COLOR_ARRAY_LIST_IBM"/>
+                <enum name="GL_INDEX_ARRAY_LIST_IBM"/>
+                <enum name="GL_TEXTURE_COORD_ARRAY_LIST_IBM"/>
+                <enum name="GL_EDGE_FLAG_ARRAY_LIST_IBM"/>
+                <enum name="GL_FOG_COORDINATE_ARRAY_LIST_IBM"/>
+                <enum name="GL_SECONDARY_COLOR_ARRAY_LIST_IBM"/>
+                <enum name="GL_VERTEX_ARRAY_LIST_STRIDE_IBM"/>
+                <enum name="GL_NORMAL_ARRAY_LIST_STRIDE_IBM"/>
+                <enum name="GL_COLOR_ARRAY_LIST_STRIDE_IBM"/>
+                <enum name="GL_INDEX_ARRAY_LIST_STRIDE_IBM"/>
+                <enum name="GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM"/>
+                <enum name="GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM"/>
+                <enum name="GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM"/>
+                <enum name="GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM"/>
+                <command name="glColorPointerListIBM"/>
+                <command name="glSecondaryColorPointerListIBM"/>
+                <command name="glEdgeFlagPointerListIBM"/>
+                <command name="glFogCoordPointerListIBM"/>
+                <command name="glIndexPointerListIBM"/>
+                <command name="glNormalPointerListIBM"/>
+                <command name="glTexCoordPointerListIBM"/>
+                <command name="glVertexPointerListIBM"/>
+            </require>
+        </extension>
+        <extension name="GL_IMG_multisampled_render_to_texture" supported="gles1|gles2">
+            <require>
+                <enum name="GL_RENDERBUFFER_SAMPLES_IMG"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG"/>
+                <enum name="GL_MAX_SAMPLES_IMG"/>
+                <enum name="GL_TEXTURE_SAMPLES_IMG"/>
+                <command name="glRenderbufferStorageMultisampleIMG"/>
+                <command name="glFramebufferTexture2DMultisampleIMG"/>
+            </require>
+        </extension>
+        <extension name="GL_IMG_program_binary" supported="gles2">
+            <require>
+                <enum name="GL_SGX_PROGRAM_BINARY_IMG"/>
+            </require>
+        </extension>
+        <extension name="GL_IMG_read_format" supported="gles1|gles2">
+            <require>
+                <enum name="GL_BGRA_IMG"/>
+                <enum name="GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG"/>
+            </require>
+        </extension>
+        <extension name="GL_IMG_shader_binary" supported="gles2">
+            <require>
+                <enum name="GL_SGX_BINARY_IMG"/>
+            </require>
+        </extension>
+        <extension name="GL_IMG_texture_compression_pvrtc" supported="gles1|gles2">
+            <require>
+                <enum name="GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG"/>
+                <enum name="GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG"/>
+                <enum name="GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG"/>
+                <enum name="GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG"/>
+            </require>
+        </extension>
+        <extension name="GL_IMG_texture_compression_pvrtc2" supported="gles2">
+            <require>
+                <enum name="GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG"/>
+                <enum name="GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG"/>
+            </require>
+        </extension>
+        <extension name="GL_IMG_texture_env_enhanced_fixed_function" supported="gles1">
+            <require>
+                <enum name="GL_MODULATE_COLOR_IMG"/>
+                <enum name="GL_RECIP_ADD_SIGNED_ALPHA_IMG"/>
+                <enum name="GL_TEXTURE_ALPHA_MODULATE_IMG"/>
+                <enum name="GL_FACTOR_ALPHA_MODULATE_IMG"/>
+                <enum name="GL_FRAGMENT_ALPHA_MODULATE_IMG"/>
+                <enum name="GL_ADD_BLEND_IMG"/>
+                <enum name="GL_DOT3_RGBA_IMG"/>
+            </require>
+        </extension>
+        <extension name="GL_IMG_user_clip_plane" supported="gles1">
+            <require>
+                <enum name="GL_CLIP_PLANE0_IMG"/>
+                <enum name="GL_CLIP_PLANE1_IMG"/>
+                <enum name="GL_CLIP_PLANE2_IMG"/>
+                <enum name="GL_CLIP_PLANE3_IMG"/>
+                <enum name="GL_CLIP_PLANE4_IMG"/>
+                <enum name="GL_CLIP_PLANE5_IMG"/>
+                <enum name="GL_MAX_CLIP_PLANES_IMG"/>
+                <command name="glClipPlanefIMG"/>
+                <command name="glClipPlanexIMG"/>
+            </require>
+        </extension>
+        <extension name="GL_INGR_blend_func_separate" supported="gl">
+            <require>
+                <command name="glBlendFuncSeparateINGR"/>
+            </require>
+        </extension>
+        <extension name="GL_INGR_color_clamp" supported="gl">
+            <require>
+                <enum name="GL_RED_MIN_CLAMP_INGR"/>
+                <enum name="GL_GREEN_MIN_CLAMP_INGR"/>
+                <enum name="GL_BLUE_MIN_CLAMP_INGR"/>
+                <enum name="GL_ALPHA_MIN_CLAMP_INGR"/>
+                <enum name="GL_RED_MAX_CLAMP_INGR"/>
+                <enum name="GL_GREEN_MAX_CLAMP_INGR"/>
+                <enum name="GL_BLUE_MAX_CLAMP_INGR"/>
+                <enum name="GL_ALPHA_MAX_CLAMP_INGR"/>
+            </require>
+        </extension>
+        <extension name="GL_INGR_interlace_read" supported="gl">
+            <require>
+                <enum name="GL_INTERLACE_READ_INGR"/>
+            </require>
+        </extension>
+        <extension name="GL_INTEL_fragment_shader_ordering" supported="gl"/>
+        <extension name="GL_INTEL_map_texture" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_MEMORY_LAYOUT_INTEL"/>
+                <enum name="GL_LAYOUT_DEFAULT_INTEL"/>
+                <enum name="GL_LAYOUT_LINEAR_INTEL"/>
+                <enum name="GL_LAYOUT_LINEAR_CPU_CACHED_INTEL"/>
+                <command name="glSyncTextureINTEL"/>
+                <command name="glUnmapTexture2DINTEL"/>
+                <command name="glMapTexture2DINTEL"/>
+            </require>
+        </extension>
+        <extension name="GL_INTEL_parallel_arrays" supported="gl">
+            <require>
+                <enum name="GL_PARALLEL_ARRAYS_INTEL"/>
+                <enum name="GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL"/>
+                <enum name="GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL"/>
+                <enum name="GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL"/>
+                <enum name="GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL"/>
+                <command name="glVertexPointervINTEL"/>
+                <command name="glNormalPointervINTEL"/>
+                <command name="glColorPointervINTEL"/>
+                <command name="glTexCoordPointervINTEL"/>
+            </require>
+        </extension>
+        <extension name="GL_INTEL_performance_query" supported="gl|gles2">
+            <require>
+                <enum name="GL_PERFQUERY_SINGLE_CONTEXT_INTEL"/>
+                <enum name="GL_PERFQUERY_GLOBAL_CONTEXT_INTEL"/>
+                <enum name="GL_PERFQUERY_WAIT_INTEL"/>
+                <enum name="GL_PERFQUERY_FLUSH_INTEL"/>
+                <enum name="GL_PERFQUERY_DONOT_FLUSH_INTEL"/>
+                <enum name="GL_PERFQUERY_COUNTER_EVENT_INTEL"/>
+                <enum name="GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL"/>
+                <enum name="GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL"/>
+                <enum name="GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL"/>
+                <enum name="GL_PERFQUERY_COUNTER_RAW_INTEL"/>
+                <enum name="GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL"/>
+                <enum name="GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL"/>
+                <enum name="GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL"/>
+                <enum name="GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL"/>
+                <enum name="GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL"/>
+                <enum name="GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL"/>
+                <enum name="GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL"/>
+                <enum name="GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL"/>
+                <enum name="GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL"/>
+                <enum name="GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL"/>
+                <command name="glBeginPerfQueryINTEL"/>
+                <command name="glCreatePerfQueryINTEL"/>
+                <command name="glDeletePerfQueryINTEL"/>
+                <command name="glEndPerfQueryINTEL"/>
+                <command name="glGetFirstPerfQueryIdINTEL"/>
+                <command name="glGetNextPerfQueryIdINTEL"/>
+                <command name="glGetPerfCounterInfoINTEL"/>
+                <command name="glGetPerfQueryDataINTEL"/>
+                <command name="glGetPerfQueryIdByNameINTEL"/>
+                <command name="glGetPerfQueryInfoINTEL"/>
+            </require>
+        </extension>
+        <extension name="GL_KHR_blend_equation_advanced" supported="gles2">
+            <require>
+                <command name="glBlendBarrierKHR"/>                                         
+                <enum name="GL_BLEND_ADVANCED_COHERENT_KHR"/>                               
+                <enum name="GL_MULTIPLY_KHR"/>                                              
+                <enum name="GL_SCREEN_KHR"/>                                                
+                <enum name="GL_OVERLAY_KHR"/>                                               
+                <enum name="GL_DARKEN_KHR"/>                                                
+                <enum name="GL_LIGHTEN_KHR"/>                                               
+                <enum name="GL_COLORDODGE_KHR"/>                                            
+                <enum name="GL_COLORBURN_KHR"/>                                             
+                <enum name="GL_HARDLIGHT_KHR"/>                                             
+                <enum name="GL_SOFTLIGHT_KHR"/>                                             
+                <enum name="GL_DIFFERENCE_KHR"/>                                            
+                <enum name="GL_EXCLUSION_KHR"/>                                             
+                <enum name="GL_HSL_HUE_KHR"/>                                               
+                <enum name="GL_HSL_SATURATION_KHR"/>                                        
+                <enum name="GL_HSL_COLOR_KHR"/>                                             
+                <enum name="GL_HSL_LUMINOSITY_KHR"/>                                        
+            </require>
+        </extension>
+        <extension name="GL_KHR_debug" supported="gl|glcore|gles2">
+            <require api="gl" comment="KHR extensions *mandate* suffixes for ES, unlike for GL">
+                <enum name="GL_DEBUG_OUTPUT_SYNCHRONOUS"/>
+                <enum name="GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH"/>
+                <enum name="GL_DEBUG_CALLBACK_FUNCTION"/>
+                <enum name="GL_DEBUG_CALLBACK_USER_PARAM"/>
+                <enum name="GL_DEBUG_SOURCE_API"/>
+                <enum name="GL_DEBUG_SOURCE_WINDOW_SYSTEM"/>
+                <enum name="GL_DEBUG_SOURCE_SHADER_COMPILER"/>
+                <enum name="GL_DEBUG_SOURCE_THIRD_PARTY"/>
+                <enum name="GL_DEBUG_SOURCE_APPLICATION"/>
+                <enum name="GL_DEBUG_SOURCE_OTHER"/>
+                <enum name="GL_DEBUG_TYPE_ERROR"/>
+                <enum name="GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR"/>
+                <enum name="GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR"/>
+                <enum name="GL_DEBUG_TYPE_PORTABILITY"/>
+                <enum name="GL_DEBUG_TYPE_PERFORMANCE"/>
+                <enum name="GL_DEBUG_TYPE_OTHER"/>
+                <enum name="GL_DEBUG_TYPE_MARKER"/>
+                <enum name="GL_DEBUG_TYPE_PUSH_GROUP"/>
+                <enum name="GL_DEBUG_TYPE_POP_GROUP"/>
+                <enum name="GL_DEBUG_SEVERITY_NOTIFICATION"/>
+                <enum name="GL_MAX_DEBUG_GROUP_STACK_DEPTH"/>
+                <enum name="GL_DEBUG_GROUP_STACK_DEPTH"/>
+                <enum name="GL_BUFFER"/>
+                <enum name="GL_SHADER"/>
+                <enum name="GL_PROGRAM"/>
+                <enum name="GL_VERTEX_ARRAY"/>
+                <enum name="GL_QUERY"/>
+                <enum name="GL_SAMPLER"/>
+                <enum name="GL_MAX_LABEL_LENGTH"/>
+                <enum name="GL_MAX_DEBUG_MESSAGE_LENGTH"/>
+                <enum name="GL_MAX_DEBUG_LOGGED_MESSAGES"/>
+                <enum name="GL_DEBUG_LOGGED_MESSAGES"/>
+                <enum name="GL_DEBUG_SEVERITY_HIGH"/>
+                <enum name="GL_DEBUG_SEVERITY_MEDIUM"/>
+                <enum name="GL_DEBUG_SEVERITY_LOW"/>
+                <enum name="GL_DEBUG_OUTPUT"/>
+                <enum name="GL_CONTEXT_FLAG_DEBUG_BIT"/>
+                <enum name="GL_STACK_OVERFLOW"/>
+                <enum name="GL_STACK_UNDERFLOW"/>
+                <command name="glDebugMessageControl"/>
+                <command name="glDebugMessageInsert"/>
+                <command name="glDebugMessageCallback"/>
+                <command name="glGetDebugMessageLog"/>
+                <command name="glPushDebugGroup"/>
+                <command name="glPopDebugGroup"/>
+                <command name="glObjectLabel"/>
+                <command name="glGetObjectLabel"/>
+                <command name="glObjectPtrLabel"/>
+                <command name="glGetObjectPtrLabel"/>
+                <command name="glGetPointerv"/>
+            </require>
+            <require api="gles2">
+                <enum name="GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR"/>
+                <enum name="GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR"/>
+                <enum name="GL_DEBUG_CALLBACK_FUNCTION_KHR"/>
+                <enum name="GL_DEBUG_CALLBACK_USER_PARAM_KHR"/>
+                <enum name="GL_DEBUG_SOURCE_API_KHR"/>
+                <enum name="GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR"/>
+                <enum name="GL_DEBUG_SOURCE_SHADER_COMPILER_KHR"/>
+                <enum name="GL_DEBUG_SOURCE_THIRD_PARTY_KHR"/>
+                <enum name="GL_DEBUG_SOURCE_APPLICATION_KHR"/>
+                <enum name="GL_DEBUG_SOURCE_OTHER_KHR"/>
+                <enum name="GL_DEBUG_TYPE_ERROR_KHR"/>
+                <enum name="GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR"/>
+                <enum name="GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR"/>
+                <enum name="GL_DEBUG_TYPE_PORTABILITY_KHR"/>
+                <enum name="GL_DEBUG_TYPE_PERFORMANCE_KHR"/>
+                <enum name="GL_DEBUG_TYPE_OTHER_KHR"/>
+                <enum name="GL_DEBUG_TYPE_MARKER_KHR"/>
+                <enum name="GL_DEBUG_TYPE_PUSH_GROUP_KHR"/>
+                <enum name="GL_DEBUG_TYPE_POP_GROUP_KHR"/>
+                <enum name="GL_DEBUG_SEVERITY_NOTIFICATION_KHR"/>
+                <enum name="GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR"/>
+                <enum name="GL_DEBUG_GROUP_STACK_DEPTH_KHR"/>
+                <enum name="GL_BUFFER_KHR"/>
+                <enum name="GL_SHADER_KHR"/>
+                <enum name="GL_PROGRAM_KHR"/>
+                <enum name="GL_VERTEX_ARRAY_KHR"/>
+                <enum name="GL_QUERY_KHR"/>
+                <enum name="GL_SAMPLER_KHR"/>
+                <enum name="GL_MAX_LABEL_LENGTH_KHR"/>
+                <enum name="GL_MAX_DEBUG_MESSAGE_LENGTH_KHR"/>
+                <enum name="GL_MAX_DEBUG_LOGGED_MESSAGES_KHR"/>
+                <enum name="GL_DEBUG_LOGGED_MESSAGES_KHR"/>
+                <enum name="GL_DEBUG_SEVERITY_HIGH_KHR"/>
+                <enum name="GL_DEBUG_SEVERITY_MEDIUM_KHR"/>
+                <enum name="GL_DEBUG_SEVERITY_LOW_KHR"/>
+                <enum name="GL_DEBUG_OUTPUT_KHR"/>
+                <enum name="GL_CONTEXT_FLAG_DEBUG_BIT_KHR"/>
+                <enum name="GL_STACK_OVERFLOW_KHR"/>
+                <enum name="GL_STACK_UNDERFLOW_KHR"/>
+                <command name="glDebugMessageControlKHR"/>
+                <command name="glDebugMessageInsertKHR"/>
+                <command name="glDebugMessageCallbackKHR"/>
+                <command name="glGetDebugMessageLogKHR"/>
+                <command name="glPushDebugGroupKHR"/>
+                <command name="glPopDebugGroupKHR"/>
+                <command name="glObjectLabelKHR"/>
+                <command name="glGetObjectLabelKHR"/>
+                <command name="glObjectPtrLabelKHR"/>
+                <command name="glGetObjectPtrLabelKHR"/>
+                <command name="glGetPointervKHR"/>
+            </require>
+            <require api="gl" comment="Could benefit from api/profile attributes at enum tag level">
+                <enum name="GL_PROGRAM_PIPELINE"/>
+            </require>
+            <require api="gl" profile="compatibility">
+                <enum name="GL_DISPLAY_LIST"/>
+            </require>
+        </extension>
+        <extension name="GL_KHR_texture_compression_astc_hdr" supported="gl|glcore|gles2">
+            <require>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_4x4_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_5x4_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_5x5_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_6x5_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_6x6_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_8x5_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_8x6_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_8x8_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_10x5_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_10x6_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_10x8_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_10x10_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_12x10_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_12x12_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"/>
+            </require>
+        </extension>
+        <extension name="GL_KHR_texture_compression_astc_ldr" supported="gl|glcore|gles2" comment="API is identical to GL_KHR_texture_compression_astc_hdr extension">
+            <require>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_4x4_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_5x4_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_5x5_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_6x5_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_6x6_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_8x5_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_8x6_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_8x8_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_10x5_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_10x6_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_10x8_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_10x10_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_12x10_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_12x12_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"/>
+            </require>
+        </extension>
+        <extension name="GL_MESAX_texture_stack" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_1D_STACK_MESAX"/>
+                <enum name="GL_TEXTURE_2D_STACK_MESAX"/>
+                <enum name="GL_PROXY_TEXTURE_1D_STACK_MESAX"/>
+                <enum name="GL_PROXY_TEXTURE_2D_STACK_MESAX"/>
+                <enum name="GL_TEXTURE_1D_STACK_BINDING_MESAX"/>
+                <enum name="GL_TEXTURE_2D_STACK_BINDING_MESAX"/>
+            </require>
+        </extension>
+        <extension name="GL_MESA_pack_invert" supported="gl">
+            <require>
+                <enum name="GL_PACK_INVERT_MESA"/>
+            </require>
+        </extension>
+        <extension name="GL_MESA_resize_buffers" supported="gl">
+            <require>
+                <command name="glResizeBuffersMESA"/>
+            </require>
+        </extension>
+        <extension name="GL_MESA_window_pos" supported="gl">
+            <require>
+                <command name="glWindowPos2dMESA"/>
+                <command name="glWindowPos2dvMESA"/>
+                <command name="glWindowPos2fMESA"/>
+                <command name="glWindowPos2fvMESA"/>
+                <command name="glWindowPos2iMESA"/>
+                <command name="glWindowPos2ivMESA"/>
+                <command name="glWindowPos2sMESA"/>
+                <command name="glWindowPos2svMESA"/>
+                <command name="glWindowPos3dMESA"/>
+                <command name="glWindowPos3dvMESA"/>
+                <command name="glWindowPos3fMESA"/>
+                <command name="glWindowPos3fvMESA"/>
+                <command name="glWindowPos3iMESA"/>
+                <command name="glWindowPos3ivMESA"/>
+                <command name="glWindowPos3sMESA"/>
+                <command name="glWindowPos3svMESA"/>
+                <command name="glWindowPos4dMESA"/>
+                <command name="glWindowPos4dvMESA"/>
+                <command name="glWindowPos4fMESA"/>
+                <command name="glWindowPos4fvMESA"/>
+                <command name="glWindowPos4iMESA"/>
+                <command name="glWindowPos4ivMESA"/>
+                <command name="glWindowPos4sMESA"/>
+                <command name="glWindowPos4svMESA"/>
+            </require>
+        </extension>
+        <extension name="GL_MESA_ycbcr_texture" supported="gl">
+            <require>
+                <enum name="GL_UNSIGNED_SHORT_8_8_MESA"/>
+                <enum name="GL_UNSIGNED_SHORT_8_8_REV_MESA"/>
+                <enum name="GL_YCBCR_MESA"/>
+            </require>
+        </extension>
+        <extension name="GL_NVX_conditional_render" supported="gl">
+            <require>
+                <command name="glBeginConditionalRenderNVX"/>
+                <command name="glEndConditionalRenderNVX"/>
+            </require>
+        </extension>
+        <extension name="GL_NVX_gpu_memory_info" supported="gl">
+            <require>
+                <enum name="GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX"/>
+                <enum name="GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX"/>
+                <enum name="GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX"/>
+                <enum name="GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX"/>
+                <enum name="GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_bindless_multi_draw_indirect" supported="gl">
+            <require>
+                <command name="glMultiDrawArraysIndirectBindlessNV"/>
+                <command name="glMultiDrawElementsIndirectBindlessNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_bindless_texture" supported="gl">
+            <require>
+                <command name="glGetTextureHandleNV"/>
+                <command name="glGetTextureSamplerHandleNV"/>
+                <command name="glMakeTextureHandleResidentNV"/>
+                <command name="glMakeTextureHandleNonResidentNV"/>
+                <command name="glGetImageHandleNV"/>
+                <command name="glMakeImageHandleResidentNV"/>
+                <command name="glMakeImageHandleNonResidentNV"/>
+                <command name="glUniformHandleui64NV"/>
+                <command name="glUniformHandleui64vNV"/>
+                <command name="glProgramUniformHandleui64NV"/>
+                <command name="glProgramUniformHandleui64vNV"/>
+                <command name="glIsTextureHandleResidentNV"/>
+                <command name="glIsImageHandleResidentNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_blend_equation_advanced" supported="gl|gles2">
+            <require>
+                <enum name="GL_BLEND_OVERLAP_NV"/>
+                <enum name="GL_BLEND_PREMULTIPLIED_SRC_NV"/>
+                <enum name="GL_BLUE_NV"/>
+                <enum name="GL_COLORBURN_NV"/>
+                <enum name="GL_COLORDODGE_NV"/>
+                <enum name="GL_CONJOINT_NV"/>
+                <enum name="GL_CONTRAST_NV"/>
+                <enum name="GL_DARKEN_NV"/>
+                <enum name="GL_DIFFERENCE_NV"/>
+                <enum name="GL_DISJOINT_NV"/>
+                <enum name="GL_DST_ATOP_NV"/>
+                <enum name="GL_DST_IN_NV"/>
+                <enum name="GL_DST_NV"/>
+                <enum name="GL_DST_OUT_NV"/>
+                <enum name="GL_DST_OVER_NV"/>
+                <enum name="GL_EXCLUSION_NV"/>
+                <enum name="GL_GREEN_NV"/>
+                <enum name="GL_HARDLIGHT_NV"/>
+                <enum name="GL_HARDMIX_NV"/>
+                <enum name="GL_HSL_COLOR_NV"/>
+                <enum name="GL_HSL_HUE_NV"/>
+                <enum name="GL_HSL_LUMINOSITY_NV"/>
+                <enum name="GL_HSL_SATURATION_NV"/>
+                <enum name="GL_INVERT"/>
+                <enum name="GL_INVERT_OVG_NV"/>
+                <enum name="GL_INVERT_RGB_NV"/>
+                <enum name="GL_LIGHTEN_NV"/>
+                <enum name="GL_LINEARBURN_NV"/>
+                <enum name="GL_LINEARDODGE_NV"/>
+                <enum name="GL_LINEARLIGHT_NV"/>
+                <enum name="GL_MINUS_CLAMPED_NV"/>
+                <enum name="GL_MINUS_NV"/>
+                <enum name="GL_MULTIPLY_NV"/>
+                <enum name="GL_OVERLAY_NV"/>
+                <enum name="GL_PINLIGHT_NV"/>
+                <enum name="GL_PLUS_CLAMPED_ALPHA_NV"/>
+                <enum name="GL_PLUS_CLAMPED_NV"/>
+                <enum name="GL_PLUS_DARKER_NV"/>
+                <enum name="GL_PLUS_NV"/>
+                <enum name="GL_RED_NV"/>
+                <enum name="GL_SCREEN_NV"/>
+                <enum name="GL_SOFTLIGHT_NV"/>
+                <enum name="GL_SRC_ATOP_NV"/>
+                <enum name="GL_SRC_IN_NV"/>
+                <enum name="GL_SRC_NV"/>
+                <enum name="GL_SRC_OUT_NV"/>
+                <enum name="GL_SRC_OVER_NV"/>
+                <enum name="GL_UNCORRELATED_NV"/>
+                <enum name="GL_VIVIDLIGHT_NV"/>
+                <enum name="GL_XOR_NV"/>
+                <enum name="GL_ZERO"/>
+                <command name="glBlendParameteriNV"/>
+                <command name="glBlendBarrierNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_blend_equation_advanced_coherent" supported="gl|gles2">
+            <require comment="Otherwise identical to GL_NV_blend_equation_advanced, just different semantic behavior">
+                <enum name="GL_BLEND_ADVANCED_COHERENT_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_blend_square" supported="gl"/>
+        <extension name="GL_NV_compute_program5" supported="gl">
+            <require>
+                <enum name="GL_COMPUTE_PROGRAM_NV"/>
+                <enum name="GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_conditional_render" supported="gl">
+            <require>
+                <enum name="GL_QUERY_WAIT_NV"/>
+                <enum name="GL_QUERY_NO_WAIT_NV"/>
+                <enum name="GL_QUERY_BY_REGION_WAIT_NV"/>
+                <enum name="GL_QUERY_BY_REGION_NO_WAIT_NV"/>
+                <command name="glBeginConditionalRenderNV"/>
+                <command name="glEndConditionalRenderNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_copy_buffer" supported="gles2">
+            <require>
+                <enum name="GL_COPY_READ_BUFFER_NV"/>
+                <enum name="GL_COPY_WRITE_BUFFER_NV"/>
+                <command name="glCopyBufferSubDataNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_copy_depth_to_color" supported="gl">
+            <require>
+                <enum name="GL_DEPTH_STENCIL_TO_RGBA_NV"/>
+                <enum name="GL_DEPTH_STENCIL_TO_BGRA_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_copy_image" supported="gl">
+            <require>
+                <command name="glCopyImageSubDataNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_coverage_sample" supported="gles2">
+            <require>
+                <enum name="GL_COVERAGE_COMPONENT_NV"/>
+                <enum name="GL_COVERAGE_COMPONENT4_NV"/>
+                <enum name="GL_COVERAGE_ATTACHMENT_NV"/>
+                <enum name="GL_COVERAGE_BUFFERS_NV"/>
+                <enum name="GL_COVERAGE_SAMPLES_NV"/>
+                <enum name="GL_COVERAGE_ALL_FRAGMENTS_NV"/>
+                <enum name="GL_COVERAGE_EDGE_FRAGMENTS_NV"/>
+                <enum name="GL_COVERAGE_AUTOMATIC_NV"/>
+                <enum name="GL_COVERAGE_BUFFER_BIT_NV"/>
+                <command name="glCoverageMaskNV"/>
+                <command name="glCoverageOperationNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_deep_texture3D" supported="gl">
+            <require>
+                <enum name="GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV"/>
+                <enum name="GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_depth_buffer_float" supported="gl">
+            <require>
+                <enum name="GL_DEPTH_COMPONENT32F_NV"/>
+                <enum name="GL_DEPTH32F_STENCIL8_NV"/>
+                <enum name="GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV"/>
+                <enum name="GL_DEPTH_BUFFER_FLOAT_MODE_NV"/>
+                <command name="glDepthRangedNV"/>
+                <command name="glClearDepthdNV"/>
+                <command name="glDepthBoundsdNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_depth_clamp" supported="gl">
+            <require>
+                <enum name="GL_DEPTH_CLAMP_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_depth_nonlinear" supported="gles2">
+            <require>
+                <enum name="GL_DEPTH_COMPONENT16_NONLINEAR_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_draw_buffers" supported="gles2">
+            <require>
+                <enum name="GL_MAX_DRAW_BUFFERS_NV"/>
+                <enum name="GL_DRAW_BUFFER0_NV"/>
+                <enum name="GL_DRAW_BUFFER1_NV"/>
+                <enum name="GL_DRAW_BUFFER2_NV"/>
+                <enum name="GL_DRAW_BUFFER3_NV"/>
+                <enum name="GL_DRAW_BUFFER4_NV"/>
+                <enum name="GL_DRAW_BUFFER5_NV"/>
+                <enum name="GL_DRAW_BUFFER6_NV"/>
+                <enum name="GL_DRAW_BUFFER7_NV"/>
+                <enum name="GL_DRAW_BUFFER8_NV"/>
+                <enum name="GL_DRAW_BUFFER9_NV"/>
+                <enum name="GL_DRAW_BUFFER10_NV"/>
+                <enum name="GL_DRAW_BUFFER11_NV"/>
+                <enum name="GL_DRAW_BUFFER12_NV"/>
+                <enum name="GL_DRAW_BUFFER13_NV"/>
+                <enum name="GL_DRAW_BUFFER14_NV"/>
+                <enum name="GL_DRAW_BUFFER15_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT0_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT1_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT2_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT3_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT4_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT5_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT6_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT7_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT8_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT9_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT10_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT11_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT12_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT13_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT14_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT15_NV"/>
+                <command name="glDrawBuffersNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_draw_instanced" supported="gles2">
+            <require>
+                <command name="glDrawArraysInstancedNV"/>
+                <command name="glDrawElementsInstancedNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_draw_texture" supported="gl">
+            <require>
+                <command name="glDrawTextureNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_evaluators" supported="gl">
+            <require>
+                <enum name="GL_EVAL_2D_NV"/>
+                <enum name="GL_EVAL_TRIANGULAR_2D_NV"/>
+                <enum name="GL_MAP_TESSELLATION_NV"/>
+                <enum name="GL_MAP_ATTRIB_U_ORDER_NV"/>
+                <enum name="GL_MAP_ATTRIB_V_ORDER_NV"/>
+                <enum name="GL_EVAL_FRACTIONAL_TESSELLATION_NV"/>
+                <enum name="GL_EVAL_VERTEX_ATTRIB0_NV"/>
+                <enum name="GL_EVAL_VERTEX_ATTRIB1_NV"/>
+                <enum name="GL_EVAL_VERTEX_ATTRIB2_NV"/>
+                <enum name="GL_EVAL_VERTEX_ATTRIB3_NV"/>
+                <enum name="GL_EVAL_VERTEX_ATTRIB4_NV"/>
+                <enum name="GL_EVAL_VERTEX_ATTRIB5_NV"/>
+                <enum name="GL_EVAL_VERTEX_ATTRIB6_NV"/>
+                <enum name="GL_EVAL_VERTEX_ATTRIB7_NV"/>
+                <enum name="GL_EVAL_VERTEX_ATTRIB8_NV"/>
+                <enum name="GL_EVAL_VERTEX_ATTRIB9_NV"/>
+                <enum name="GL_EVAL_VERTEX_ATTRIB10_NV"/>
+                <enum name="GL_EVAL_VERTEX_ATTRIB11_NV"/>
+                <enum name="GL_EVAL_VERTEX_ATTRIB12_NV"/>
+                <enum name="GL_EVAL_VERTEX_ATTRIB13_NV"/>
+                <enum name="GL_EVAL_VERTEX_ATTRIB14_NV"/>
+                <enum name="GL_EVAL_VERTEX_ATTRIB15_NV"/>
+                <enum name="GL_MAX_MAP_TESSELLATION_NV"/>
+                <enum name="GL_MAX_RATIONAL_EVAL_ORDER_NV"/>
+                <command name="glMapControlPointsNV"/>
+                <command name="glMapParameterivNV"/>
+                <command name="glMapParameterfvNV"/>
+                <command name="glGetMapControlPointsNV"/>
+                <command name="glGetMapParameterivNV"/>
+                <command name="glGetMapParameterfvNV"/>
+                <command name="glGetMapAttribParameterivNV"/>
+                <command name="glGetMapAttribParameterfvNV"/>
+                <command name="glEvalMapsNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_explicit_attrib_location" supported="gles2"/>
+        <extension name="GL_NV_explicit_multisample" supported="gl">
+            <require>
+                <enum name="GL_SAMPLE_POSITION_NV"/>
+                <enum name="GL_SAMPLE_MASK_NV"/>
+                <enum name="GL_SAMPLE_MASK_VALUE_NV"/>
+                <enum name="GL_TEXTURE_BINDING_RENDERBUFFER_NV"/>
+                <enum name="GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV"/>
+                <enum name="GL_TEXTURE_RENDERBUFFER_NV"/>
+                <enum name="GL_SAMPLER_RENDERBUFFER_NV"/>
+                <enum name="GL_INT_SAMPLER_RENDERBUFFER_NV"/>
+                <enum name="GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV"/>
+                <enum name="GL_MAX_SAMPLE_MASK_WORDS_NV"/>
+                <command name="glGetMultisamplefvNV"/>
+                <command name="glSampleMaskIndexedNV"/>
+                <command name="glTexRenderbufferNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_fbo_color_attachments" supported="gles2">
+            <require>
+                <enum name="GL_MAX_COLOR_ATTACHMENTS_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT0_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT1_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT2_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT3_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT4_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT5_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT6_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT7_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT8_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT9_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT10_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT11_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT12_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT13_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT14_NV"/>
+                <enum name="GL_COLOR_ATTACHMENT15_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_fence" supported="gl|gles1|gles2">
+            <require>
+                <enum name="GL_ALL_COMPLETED_NV"/>
+                <enum name="GL_FENCE_STATUS_NV"/>
+                <enum name="GL_FENCE_CONDITION_NV"/>
+                <command name="glDeleteFencesNV"/>
+                <command name="glGenFencesNV"/>
+                <command name="glIsFenceNV"/>
+                <command name="glTestFenceNV"/>
+                <command name="glGetFenceivNV"/>
+                <command name="glFinishFenceNV"/>
+                <command name="glSetFenceNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_float_buffer" supported="gl">
+            <require>
+                <enum name="GL_FLOAT_R_NV"/>
+                <enum name="GL_FLOAT_RG_NV"/>
+                <enum name="GL_FLOAT_RGB_NV"/>
+                <enum name="GL_FLOAT_RGBA_NV"/>
+                <enum name="GL_FLOAT_R16_NV"/>
+                <enum name="GL_FLOAT_R32_NV"/>
+                <enum name="GL_FLOAT_RG16_NV"/>
+                <enum name="GL_FLOAT_RG32_NV"/>
+                <enum name="GL_FLOAT_RGB16_NV"/>
+                <enum name="GL_FLOAT_RGB32_NV"/>
+                <enum name="GL_FLOAT_RGBA16_NV"/>
+                <enum name="GL_FLOAT_RGBA32_NV"/>
+                <enum name="GL_TEXTURE_FLOAT_COMPONENTS_NV"/>
+                <enum name="GL_FLOAT_CLEAR_COLOR_VALUE_NV"/>
+                <enum name="GL_FLOAT_RGBA_MODE_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_fog_distance" supported="gl">
+            <require>
+                <enum name="GL_FOG_DISTANCE_MODE_NV"/>
+                <enum name="GL_EYE_RADIAL_NV"/>
+                <enum name="GL_EYE_PLANE_ABSOLUTE_NV"/>
+                <enum name="GL_EYE_PLANE"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_fragment_program" supported="gl">
+            <require>
+                <enum name="GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV"/>
+                <enum name="GL_FRAGMENT_PROGRAM_NV"/>
+                <enum name="GL_MAX_TEXTURE_COORDS_NV"/>
+                <enum name="GL_MAX_TEXTURE_IMAGE_UNITS_NV"/>
+                <enum name="GL_FRAGMENT_PROGRAM_BINDING_NV"/>
+                <enum name="GL_PROGRAM_ERROR_STRING_NV"/>
+            </require>
+            <require comment="Some NV_fragment_program entry points are shared with ARB_vertex_program">
+                <command name="glProgramNamedParameter4fNV"/>
+                <command name="glProgramNamedParameter4fvNV"/>
+                <command name="glProgramNamedParameter4dNV"/>
+                <command name="glProgramNamedParameter4dvNV"/>
+                <command name="glGetProgramNamedParameterfvNV"/>
+                <command name="glGetProgramNamedParameterdvNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_fragment_program2" supported="gl">
+            <require>
+                <enum name="GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV"/>
+                <enum name="GL_MAX_PROGRAM_CALL_DEPTH_NV"/>
+                <enum name="GL_MAX_PROGRAM_IF_DEPTH_NV"/>
+                <enum name="GL_MAX_PROGRAM_LOOP_DEPTH_NV"/>
+                <enum name="GL_MAX_PROGRAM_LOOP_COUNT_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_fragment_program4" supported="gl"/>
+        <extension name="GL_NV_fragment_program_option" supported="gl"/>
+        <extension name="GL_NV_framebuffer_blit" supported="gles2">
+            <require>
+                <enum name="GL_READ_FRAMEBUFFER_NV"/>
+                <enum name="GL_DRAW_FRAMEBUFFER_NV"/>
+                <enum name="GL_DRAW_FRAMEBUFFER_BINDING_NV"/>
+                <enum name="GL_READ_FRAMEBUFFER_BINDING_NV"/>
+                <command name="glBlitFramebufferNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_framebuffer_multisample" supported="gles2">
+            <require>
+                <enum name="GL_RENDERBUFFER_SAMPLES_NV"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV"/>
+                <enum name="GL_MAX_SAMPLES_NV"/>
+                <command name="glRenderbufferStorageMultisampleNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_framebuffer_multisample_coverage" supported="gl">
+            <require>
+                <enum name="GL_RENDERBUFFER_COVERAGE_SAMPLES_NV"/>
+                <enum name="GL_RENDERBUFFER_COLOR_SAMPLES_NV"/>
+                <enum name="GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV"/>
+                <enum name="GL_MULTISAMPLE_COVERAGE_MODES_NV"/>
+                <command name="glRenderbufferStorageMultisampleCoverageNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_generate_mipmap_sRGB" supported="gles2"/>
+        <extension name="GL_NV_geometry_program4" supported="gl">
+            <require>
+                <enum name="GL_LINES_ADJACENCY_EXT"/>
+                <enum name="GL_LINE_STRIP_ADJACENCY_EXT"/>
+                <enum name="GL_TRIANGLES_ADJACENCY_EXT"/>
+                <enum name="GL_TRIANGLE_STRIP_ADJACENCY_EXT"/>
+                <enum name="GL_GEOMETRY_PROGRAM_NV"/>
+                <enum name="GL_MAX_PROGRAM_OUTPUT_VERTICES_NV"/>
+                <enum name="GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV"/>
+                <enum name="GL_GEOMETRY_VERTICES_OUT_EXT"/>
+                <enum name="GL_GEOMETRY_INPUT_TYPE_EXT"/>
+                <enum name="GL_GEOMETRY_OUTPUT_TYPE_EXT"/>
+                <enum name="GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT"/>
+                <enum name="GL_PROGRAM_POINT_SIZE_EXT"/>
+                <command name="glProgramVertexLimitNV"/>
+                <command name="glFramebufferTextureEXT"/>
+                <command name="glFramebufferTextureLayerEXT"/>
+                <command name="glFramebufferTextureFaceEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_geometry_shader4" supported="gl"/>
+        <extension name="GL_NV_gpu_program4" supported="gl">
+            <require>
+                <enum name="GL_MIN_PROGRAM_TEXEL_OFFSET_NV"/>
+                <enum name="GL_MAX_PROGRAM_TEXEL_OFFSET_NV"/>
+                <enum name="GL_PROGRAM_ATTRIB_COMPONENTS_NV"/>
+                <enum name="GL_PROGRAM_RESULT_COMPONENTS_NV"/>
+                <enum name="GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV"/>
+                <enum name="GL_MAX_PROGRAM_RESULT_COMPONENTS_NV"/>
+                <enum name="GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV"/>
+                <enum name="GL_MAX_PROGRAM_GENERIC_RESULTS_NV"/>
+                <command name="glProgramLocalParameterI4iNV"/>
+                <command name="glProgramLocalParameterI4ivNV"/>
+                <command name="glProgramLocalParametersI4ivNV"/>
+                <command name="glProgramLocalParameterI4uiNV"/>
+                <command name="glProgramLocalParameterI4uivNV"/>
+                <command name="glProgramLocalParametersI4uivNV"/>
+                <command name="glProgramEnvParameterI4iNV"/>
+                <command name="glProgramEnvParameterI4ivNV"/>
+                <command name="glProgramEnvParametersI4ivNV"/>
+                <command name="glProgramEnvParameterI4uiNV"/>
+                <command name="glProgramEnvParameterI4uivNV"/>
+                <command name="glProgramEnvParametersI4uivNV"/>
+                <command name="glGetProgramLocalParameterIivNV"/>
+                <command name="glGetProgramLocalParameterIuivNV"/>
+                <command name="glGetProgramEnvParameterIivNV"/>
+                <command name="glGetProgramEnvParameterIuivNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_gpu_program5" supported="gl">
+            <require>
+                <enum name="GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV"/>
+                <enum name="GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV"/>
+                <enum name="GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV"/>
+                <enum name="GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV"/>
+                <enum name="GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV"/>
+                <enum name="GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV"/>
+                <enum name="GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV"/>
+                <enum name="GL_MAX_PROGRAM_SUBROUTINE_NUM_NV"/>
+                <command name="glProgramSubroutineParametersuivNV"/>
+                <command name="glGetProgramSubroutineParameteruivNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_gpu_program5_mem_extended" supported="gl"/>
+        <extension name="GL_NV_gpu_shader5" supported="gl">
+            <require>
+                <enum name="GL_INT64_NV"/>
+                <enum name="GL_UNSIGNED_INT64_NV"/>
+                <enum name="GL_INT8_NV"/>
+                <enum name="GL_INT8_VEC2_NV"/>
+                <enum name="GL_INT8_VEC3_NV"/>
+                <enum name="GL_INT8_VEC4_NV"/>
+                <enum name="GL_INT16_NV"/>
+                <enum name="GL_INT16_VEC2_NV"/>
+                <enum name="GL_INT16_VEC3_NV"/>
+                <enum name="GL_INT16_VEC4_NV"/>
+                <enum name="GL_INT64_VEC2_NV"/>
+                <enum name="GL_INT64_VEC3_NV"/>
+                <enum name="GL_INT64_VEC4_NV"/>
+                <enum name="GL_UNSIGNED_INT8_NV"/>
+                <enum name="GL_UNSIGNED_INT8_VEC2_NV"/>
+                <enum name="GL_UNSIGNED_INT8_VEC3_NV"/>
+                <enum name="GL_UNSIGNED_INT8_VEC4_NV"/>
+                <enum name="GL_UNSIGNED_INT16_NV"/>
+                <enum name="GL_UNSIGNED_INT16_VEC2_NV"/>
+                <enum name="GL_UNSIGNED_INT16_VEC3_NV"/>
+                <enum name="GL_UNSIGNED_INT16_VEC4_NV"/>
+                <enum name="GL_UNSIGNED_INT64_VEC2_NV"/>
+                <enum name="GL_UNSIGNED_INT64_VEC3_NV"/>
+                <enum name="GL_UNSIGNED_INT64_VEC4_NV"/>
+                <enum name="GL_FLOAT16_NV"/>
+                <enum name="GL_FLOAT16_VEC2_NV"/>
+                <enum name="GL_FLOAT16_VEC3_NV"/>
+                <enum name="GL_FLOAT16_VEC4_NV"/>
+                <enum name="GL_PATCHES"/>
+                <command name="glUniform1i64NV"/>
+                <command name="glUniform2i64NV"/>
+                <command name="glUniform3i64NV"/>
+                <command name="glUniform4i64NV"/>
+                <command name="glUniform1i64vNV"/>
+                <command name="glUniform2i64vNV"/>
+                <command name="glUniform3i64vNV"/>
+                <command name="glUniform4i64vNV"/>
+                <command name="glUniform1ui64NV"/>
+                <command name="glUniform2ui64NV"/>
+                <command name="glUniform3ui64NV"/>
+                <command name="glUniform4ui64NV"/>
+                <command name="glUniform1ui64vNV"/>
+                <command name="glUniform2ui64vNV"/>
+                <command name="glUniform3ui64vNV"/>
+                <command name="glUniform4ui64vNV"/>
+                <command name="glGetUniformi64vNV"/>
+            </require>
+            <require comment="Supported only if GL_EXT_direct_state_access is supported">
+                <command name="glProgramUniform1i64NV"/>
+                <command name="glProgramUniform2i64NV"/>
+                <command name="glProgramUniform3i64NV"/>
+                <command name="glProgramUniform4i64NV"/>
+                <command name="glProgramUniform1i64vNV"/>
+                <command name="glProgramUniform2i64vNV"/>
+                <command name="glProgramUniform3i64vNV"/>
+                <command name="glProgramUniform4i64vNV"/>
+                <command name="glProgramUniform1ui64NV"/>
+                <command name="glProgramUniform2ui64NV"/>
+                <command name="glProgramUniform3ui64NV"/>
+                <command name="glProgramUniform4ui64NV"/>
+                <command name="glProgramUniform1ui64vNV"/>
+                <command name="glProgramUniform2ui64vNV"/>
+                <command name="glProgramUniform3ui64vNV"/>
+                <command name="glProgramUniform4ui64vNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_half_float" supported="gl">
+            <require>
+                <enum name="GL_HALF_FLOAT_NV"/>
+                <command name="glVertex2hNV"/>
+                <command name="glVertex2hvNV"/>
+                <command name="glVertex3hNV"/>
+                <command name="glVertex3hvNV"/>
+                <command name="glVertex4hNV"/>
+                <command name="glVertex4hvNV"/>
+                <command name="glNormal3hNV"/>
+                <command name="glNormal3hvNV"/>
+                <command name="glColor3hNV"/>
+                <command name="glColor3hvNV"/>
+                <command name="glColor4hNV"/>
+                <command name="glColor4hvNV"/>
+                <command name="glTexCoord1hNV"/>
+                <command name="glTexCoord1hvNV"/>
+                <command name="glTexCoord2hNV"/>
+                <command name="glTexCoord2hvNV"/>
+                <command name="glTexCoord3hNV"/>
+                <command name="glTexCoord3hvNV"/>
+                <command name="glTexCoord4hNV"/>
+                <command name="glTexCoord4hvNV"/>
+                <command name="glMultiTexCoord1hNV"/>
+                <command name="glMultiTexCoord1hvNV"/>
+                <command name="glMultiTexCoord2hNV"/>
+                <command name="glMultiTexCoord2hvNV"/>
+                <command name="glMultiTexCoord3hNV"/>
+                <command name="glMultiTexCoord3hvNV"/>
+                <command name="glMultiTexCoord4hNV"/>
+                <command name="glMultiTexCoord4hvNV"/>
+                <command name="glFogCoordhNV"/>
+                <command name="glFogCoordhvNV"/>
+                <command name="glSecondaryColor3hNV"/>
+                <command name="glSecondaryColor3hvNV"/>
+                <command name="glVertexWeighthNV"/>
+                <command name="glVertexWeighthvNV"/>
+                <command name="glVertexAttrib1hNV"/>
+                <command name="glVertexAttrib1hvNV"/>
+                <command name="glVertexAttrib2hNV"/>
+                <command name="glVertexAttrib2hvNV"/>
+                <command name="glVertexAttrib3hNV"/>
+                <command name="glVertexAttrib3hvNV"/>
+                <command name="glVertexAttrib4hNV"/>
+                <command name="glVertexAttrib4hvNV"/>
+                <command name="glVertexAttribs1hvNV"/>
+                <command name="glVertexAttribs2hvNV"/>
+                <command name="glVertexAttribs3hvNV"/>
+                <command name="glVertexAttribs4hvNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_instanced_arrays" supported="gles2">
+            <require>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV"/>
+                <command name="glVertexAttribDivisorNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_light_max_exponent" supported="gl">
+            <require>
+                <enum name="GL_MAX_SHININESS_NV"/>
+                <enum name="GL_MAX_SPOT_EXPONENT_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_multisample_coverage" supported="gl">
+            <require>
+                <enum name="GL_SAMPLES_ARB"/>
+                <enum name="GL_COLOR_SAMPLES_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_multisample_filter_hint" supported="gl">
+            <require>
+                <enum name="GL_MULTISAMPLE_FILTER_HINT_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_non_square_matrices" supported="gles2">
+            <require>
+                <enum name="GL_FLOAT_MAT2x3_NV"/>
+                <enum name="GL_FLOAT_MAT2x4_NV"/>
+                <enum name="GL_FLOAT_MAT3x2_NV"/>
+                <enum name="GL_FLOAT_MAT3x4_NV"/>
+                <enum name="GL_FLOAT_MAT4x2_NV"/>
+                <enum name="GL_FLOAT_MAT4x3_NV"/>
+                <command name="glUniformMatrix2x3fvNV"/>
+                <command name="glUniformMatrix3x2fvNV"/>
+                <command name="glUniformMatrix2x4fvNV"/>
+                <command name="glUniformMatrix4x2fvNV"/>
+                <command name="glUniformMatrix3x4fvNV"/>
+                <command name="glUniformMatrix4x3fvNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_occlusion_query" supported="gl">
+            <require>
+                <enum name="GL_PIXEL_COUNTER_BITS_NV"/>
+                <enum name="GL_CURRENT_OCCLUSION_QUERY_ID_NV"/>
+                <enum name="GL_PIXEL_COUNT_NV"/>
+                <enum name="GL_PIXEL_COUNT_AVAILABLE_NV"/>
+                <command name="glGenOcclusionQueriesNV"/>
+                <command name="glDeleteOcclusionQueriesNV"/>
+                <command name="glIsOcclusionQueryNV"/>
+                <command name="glBeginOcclusionQueryNV"/>
+                <command name="glEndOcclusionQueryNV"/>
+                <command name="glGetOcclusionQueryivNV"/>
+                <command name="glGetOcclusionQueryuivNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_packed_depth_stencil" supported="gl">
+            <require>
+                <enum name="GL_DEPTH_STENCIL_NV"/>
+                <enum name="GL_UNSIGNED_INT_24_8_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_parameter_buffer_object" supported="gl">
+            <require>
+                <enum name="GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV"/>
+                <enum name="GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV"/>
+                <enum name="GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV"/>
+                <enum name="GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV"/>
+                <enum name="GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV"/>
+                <command name="glProgramBufferParametersfvNV"/>
+                <command name="glProgramBufferParametersIivNV"/>
+                <command name="glProgramBufferParametersIuivNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_parameter_buffer_object2" supported="gl"/>
+        <extension name="GL_NV_path_rendering" supported="gl">
+            <require>
+                <enum name="GL_PATH_FORMAT_SVG_NV"/>
+                <enum name="GL_PATH_FORMAT_PS_NV"/>
+                <enum name="GL_STANDARD_FONT_NAME_NV"/>
+                <enum name="GL_SYSTEM_FONT_NAME_NV"/>
+                <enum name="GL_FILE_NAME_NV"/>
+                <enum name="GL_PATH_STROKE_WIDTH_NV"/>
+                <enum name="GL_PATH_END_CAPS_NV"/>
+                <enum name="GL_PATH_INITIAL_END_CAP_NV"/>
+                <enum name="GL_PATH_TERMINAL_END_CAP_NV"/>
+                <enum name="GL_PATH_JOIN_STYLE_NV"/>
+                <enum name="GL_PATH_MITER_LIMIT_NV"/>
+                <enum name="GL_PATH_DASH_CAPS_NV"/>
+                <enum name="GL_PATH_INITIAL_DASH_CAP_NV"/>
+                <enum name="GL_PATH_TERMINAL_DASH_CAP_NV"/>
+                <enum name="GL_PATH_DASH_OFFSET_NV"/>
+                <enum name="GL_PATH_CLIENT_LENGTH_NV"/>
+                <enum name="GL_PATH_FILL_MODE_NV"/>
+                <enum name="GL_PATH_FILL_MASK_NV"/>
+                <enum name="GL_PATH_FILL_COVER_MODE_NV"/>
+                <enum name="GL_PATH_STROKE_COVER_MODE_NV"/>
+                <enum name="GL_PATH_STROKE_MASK_NV"/>
+                <enum name="GL_COUNT_UP_NV"/>
+                <enum name="GL_COUNT_DOWN_NV"/>
+                <enum name="GL_PATH_OBJECT_BOUNDING_BOX_NV"/>
+                <enum name="GL_CONVEX_HULL_NV"/>
+                <enum name="GL_BOUNDING_BOX_NV"/>
+                <enum name="GL_TRANSLATE_X_NV"/>
+                <enum name="GL_TRANSLATE_Y_NV"/>
+                <enum name="GL_TRANSLATE_2D_NV"/>
+                <enum name="GL_TRANSLATE_3D_NV"/>
+                <enum name="GL_AFFINE_2D_NV"/>
+                <enum name="GL_AFFINE_3D_NV"/>
+                <enum name="GL_TRANSPOSE_AFFINE_2D_NV"/>
+                <enum name="GL_TRANSPOSE_AFFINE_3D_NV"/>
+                <enum name="GL_UTF8_NV"/>
+                <enum name="GL_UTF16_NV"/>
+                <enum name="GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV"/>
+                <enum name="GL_PATH_COMMAND_COUNT_NV"/>
+                <enum name="GL_PATH_COORD_COUNT_NV"/>
+                <enum name="GL_PATH_DASH_ARRAY_COUNT_NV"/>
+                <enum name="GL_PATH_COMPUTED_LENGTH_NV"/>
+                <enum name="GL_PATH_FILL_BOUNDING_BOX_NV"/>
+                <enum name="GL_PATH_STROKE_BOUNDING_BOX_NV"/>
+                <enum name="GL_SQUARE_NV"/>
+                <enum name="GL_ROUND_NV"/>
+                <enum name="GL_TRIANGULAR_NV"/>
+                <enum name="GL_BEVEL_NV"/>
+                <enum name="GL_MITER_REVERT_NV"/>
+                <enum name="GL_MITER_TRUNCATE_NV"/>
+                <enum name="GL_SKIP_MISSING_GLYPH_NV"/>
+                <enum name="GL_USE_MISSING_GLYPH_NV"/>
+                <enum name="GL_PATH_ERROR_POSITION_NV"/>
+                <enum name="GL_PATH_FOG_GEN_MODE_NV"/>
+                <enum name="GL_ACCUM_ADJACENT_PAIRS_NV"/>
+                <enum name="GL_ADJACENT_PAIRS_NV"/>
+                <enum name="GL_FIRST_TO_REST_NV"/>
+                <enum name="GL_PATH_GEN_MODE_NV"/>
+                <enum name="GL_PATH_GEN_COEFF_NV"/>
+                <enum name="GL_PATH_GEN_COLOR_FORMAT_NV"/>
+                <enum name="GL_PATH_GEN_COMPONENTS_NV"/>
+                <enum name="GL_PATH_STENCIL_FUNC_NV"/>
+                <enum name="GL_PATH_STENCIL_REF_NV"/>
+                <enum name="GL_PATH_STENCIL_VALUE_MASK_NV"/>
+                <enum name="GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV"/>
+                <enum name="GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV"/>
+                <enum name="GL_PATH_COVER_DEPTH_FUNC_NV"/>
+                <enum name="GL_PATH_DASH_OFFSET_RESET_NV"/>
+                <enum name="GL_MOVE_TO_RESETS_NV"/>
+                <enum name="GL_MOVE_TO_CONTINUES_NV"/>
+                <enum name="GL_CLOSE_PATH_NV"/>
+                <enum name="GL_MOVE_TO_NV"/>
+                <enum name="GL_RELATIVE_MOVE_TO_NV"/>
+                <enum name="GL_LINE_TO_NV"/>
+                <enum name="GL_RELATIVE_LINE_TO_NV"/>
+                <enum name="GL_HORIZONTAL_LINE_TO_NV"/>
+                <enum name="GL_RELATIVE_HORIZONTAL_LINE_TO_NV"/>
+                <enum name="GL_VERTICAL_LINE_TO_NV"/>
+                <enum name="GL_RELATIVE_VERTICAL_LINE_TO_NV"/>
+                <enum name="GL_QUADRATIC_CURVE_TO_NV"/>
+                <enum name="GL_RELATIVE_QUADRATIC_CURVE_TO_NV"/>
+                <enum name="GL_CUBIC_CURVE_TO_NV"/>
+                <enum name="GL_RELATIVE_CUBIC_CURVE_TO_NV"/>
+                <enum name="GL_SMOOTH_QUADRATIC_CURVE_TO_NV"/>
+                <enum name="GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV"/>
+                <enum name="GL_SMOOTH_CUBIC_CURVE_TO_NV"/>
+                <enum name="GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV"/>
+                <enum name="GL_SMALL_CCW_ARC_TO_NV"/>
+                <enum name="GL_RELATIVE_SMALL_CCW_ARC_TO_NV"/>
+                <enum name="GL_SMALL_CW_ARC_TO_NV"/>
+                <enum name="GL_RELATIVE_SMALL_CW_ARC_TO_NV"/>
+                <enum name="GL_LARGE_CCW_ARC_TO_NV"/>
+                <enum name="GL_RELATIVE_LARGE_CCW_ARC_TO_NV"/>
+                <enum name="GL_LARGE_CW_ARC_TO_NV"/>
+                <enum name="GL_RELATIVE_LARGE_CW_ARC_TO_NV"/>
+                <enum name="GL_RESTART_PATH_NV"/>
+                <enum name="GL_DUP_FIRST_CUBIC_CURVE_TO_NV"/>
+                <enum name="GL_DUP_LAST_CUBIC_CURVE_TO_NV"/>
+                <enum name="GL_RECT_NV"/>
+                <enum name="GL_CIRCULAR_CCW_ARC_TO_NV"/>
+                <enum name="GL_CIRCULAR_CW_ARC_TO_NV"/>
+                <enum name="GL_CIRCULAR_TANGENT_ARC_TO_NV"/>
+                <enum name="GL_ARC_TO_NV"/>
+                <enum name="GL_RELATIVE_ARC_TO_NV"/>
+                <enum name="GL_BOLD_BIT_NV"/>
+                <enum name="GL_ITALIC_BIT_NV"/>
+                <enum name="GL_GLYPH_WIDTH_BIT_NV"/>
+                <enum name="GL_GLYPH_HEIGHT_BIT_NV"/>
+                <enum name="GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV"/>
+                <enum name="GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV"/>
+                <enum name="GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV"/>
+                <enum name="GL_GLYPH_VERTICAL_BEARING_X_BIT_NV"/>
+                <enum name="GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV"/>
+                <enum name="GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV"/>
+                <enum name="GL_GLYPH_HAS_KERNING_BIT_NV"/>
+                <enum name="GL_FONT_X_MIN_BOUNDS_BIT_NV"/>
+                <enum name="GL_FONT_Y_MIN_BOUNDS_BIT_NV"/>
+                <enum name="GL_FONT_X_MAX_BOUNDS_BIT_NV"/>
+                <enum name="GL_FONT_Y_MAX_BOUNDS_BIT_NV"/>
+                <enum name="GL_FONT_UNITS_PER_EM_BIT_NV"/>
+                <enum name="GL_FONT_ASCENDER_BIT_NV"/>
+                <enum name="GL_FONT_DESCENDER_BIT_NV"/>
+                <enum name="GL_FONT_HEIGHT_BIT_NV"/>
+                <enum name="GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV"/>
+                <enum name="GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV"/>
+                <enum name="GL_FONT_UNDERLINE_POSITION_BIT_NV"/>
+                <enum name="GL_FONT_UNDERLINE_THICKNESS_BIT_NV"/>
+                <enum name="GL_FONT_HAS_KERNING_BIT_NV"/>
+                <enum name="GL_PRIMARY_COLOR"/>
+                <enum name="GL_PRIMARY_COLOR_NV"/>
+                <enum name="GL_SECONDARY_COLOR_NV"/>
+                <command name="glGenPathsNV"/>
+                <command name="glDeletePathsNV"/>
+                <command name="glIsPathNV"/>
+                <command name="glPathCommandsNV"/>
+                <command name="glPathCoordsNV"/>
+                <command name="glPathSubCommandsNV"/>
+                <command name="glPathSubCoordsNV"/>
+                <command name="glPathStringNV"/>
+                <command name="glPathGlyphsNV"/>
+                <command name="glPathGlyphRangeNV"/>
+                <command name="glWeightPathsNV"/>
+                <command name="glCopyPathNV"/>
+                <command name="glInterpolatePathsNV"/>
+                <command name="glTransformPathNV"/>
+                <command name="glPathParameterivNV"/>
+                <command name="glPathParameteriNV"/>
+                <command name="glPathParameterfvNV"/>
+                <command name="glPathParameterfNV"/>
+                <command name="glPathDashArrayNV"/>
+                <command name="glPathStencilFuncNV"/>
+                <command name="glPathStencilDepthOffsetNV"/>
+                <command name="glStencilFillPathNV"/>
+                <command name="glStencilStrokePathNV"/>
+                <command name="glStencilFillPathInstancedNV"/>
+                <command name="glStencilStrokePathInstancedNV"/>
+                <command name="glPathCoverDepthFuncNV"/>
+                <command name="glPathColorGenNV"/>
+                <command name="glPathTexGenNV"/>
+                <command name="glPathFogGenNV"/>
+                <command name="glCoverFillPathNV"/>
+                <command name="glCoverStrokePathNV"/>
+                <command name="glCoverFillPathInstancedNV"/>
+                <command name="glCoverStrokePathInstancedNV"/>
+                <command name="glGetPathParameterivNV"/>
+                <command name="glGetPathParameterfvNV"/>
+                <command name="glGetPathCommandsNV"/>
+                <command name="glGetPathCoordsNV"/>
+                <command name="glGetPathDashArrayNV"/>
+                <command name="glGetPathMetricsNV"/>
+                <command name="glGetPathMetricRangeNV"/>
+                <command name="glGetPathSpacingNV"/>
+                <command name="glGetPathColorGenivNV"/>
+                <command name="glGetPathColorGenfvNV"/>
+                <command name="glGetPathTexGenivNV"/>
+                <command name="glGetPathTexGenfvNV"/>
+                <command name="glIsPointInFillPathNV"/>
+                <command name="glIsPointInStrokePathNV"/>
+                <command name="glGetPathLengthNV"/>
+                <command name="glPointAlongPathNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_pixel_data_range" supported="gl">
+            <require>
+                <enum name="GL_WRITE_PIXEL_DATA_RANGE_NV"/>
+                <enum name="GL_READ_PIXEL_DATA_RANGE_NV"/>
+                <enum name="GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV"/>
+                <enum name="GL_READ_PIXEL_DATA_RANGE_LENGTH_NV"/>
+                <enum name="GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV"/>
+                <enum name="GL_READ_PIXEL_DATA_RANGE_POINTER_NV"/>
+                <command name="glPixelDataRangeNV"/>
+                <command name="glFlushPixelDataRangeNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_point_sprite" supported="gl">
+            <require>
+                <enum name="GL_POINT_SPRITE_NV"/>
+                <enum name="GL_COORD_REPLACE_NV"/>
+                <enum name="GL_POINT_SPRITE_R_MODE_NV"/>
+                <command name="glPointParameteriNV"/>
+                <command name="glPointParameterivNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_present_video" supported="gl">
+            <require>
+                <enum name="GL_FRAME_NV"/>
+                <enum name="GL_FIELDS_NV"/>
+                <enum name="GL_CURRENT_TIME_NV"/>
+                <enum name="GL_NUM_FILL_STREAMS_NV"/>
+                <enum name="GL_PRESENT_TIME_NV"/>
+                <enum name="GL_PRESENT_DURATION_NV"/>
+                <command name="glPresentFrameKeyedNV"/>
+                <command name="glPresentFrameDualFillNV"/>
+                <command name="glGetVideoivNV"/>
+                <command name="glGetVideouivNV"/>
+                <command name="glGetVideoi64vNV"/>
+                <command name="glGetVideoui64vNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_primitive_restart" supported="gl">
+            <require>
+                <enum name="GL_PRIMITIVE_RESTART_NV"/>
+                <enum name="GL_PRIMITIVE_RESTART_INDEX_NV"/>
+                <command name="glPrimitiveRestartNV"/>
+                <command name="glPrimitiveRestartIndexNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_read_buffer" supported="gles2">
+            <require>
+                <enum name="GL_READ_BUFFER_NV"/>
+                <command name="glReadBufferNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_read_buffer_front" supported="gles2"/>
+        <extension name="GL_NV_read_depth" supported="gles2"/>
+        <extension name="GL_NV_read_depth_stencil" supported="gles2"/>
+        <extension name="GL_NV_read_stencil" supported="gles2"/>
+        <extension name="GL_NV_register_combiners" supported="gl">
+            <require>
+                <enum name="GL_REGISTER_COMBINERS_NV"/>
+                <enum name="GL_VARIABLE_A_NV"/>
+                <enum name="GL_VARIABLE_B_NV"/>
+                <enum name="GL_VARIABLE_C_NV"/>
+                <enum name="GL_VARIABLE_D_NV"/>
+                <enum name="GL_VARIABLE_E_NV"/>
+                <enum name="GL_VARIABLE_F_NV"/>
+                <enum name="GL_VARIABLE_G_NV"/>
+                <enum name="GL_CONSTANT_COLOR0_NV"/>
+                <enum name="GL_CONSTANT_COLOR1_NV"/>
+                <enum name="GL_PRIMARY_COLOR_NV"/>
+                <enum name="GL_SECONDARY_COLOR_NV"/>
+                <enum name="GL_SPARE0_NV"/>
+                <enum name="GL_SPARE1_NV"/>
+                <enum name="GL_DISCARD_NV"/>
+                <enum name="GL_E_TIMES_F_NV"/>
+                <enum name="GL_SPARE0_PLUS_SECONDARY_COLOR_NV"/>
+                <enum name="GL_UNSIGNED_IDENTITY_NV"/>
+                <enum name="GL_UNSIGNED_INVERT_NV"/>
+                <enum name="GL_EXPAND_NORMAL_NV"/>
+                <enum name="GL_EXPAND_NEGATE_NV"/>
+                <enum name="GL_HALF_BIAS_NORMAL_NV"/>
+                <enum name="GL_HALF_BIAS_NEGATE_NV"/>
+                <enum name="GL_SIGNED_IDENTITY_NV"/>
+                <enum name="GL_SIGNED_NEGATE_NV"/>
+                <enum name="GL_SCALE_BY_TWO_NV"/>
+                <enum name="GL_SCALE_BY_FOUR_NV"/>
+                <enum name="GL_SCALE_BY_ONE_HALF_NV"/>
+                <enum name="GL_BIAS_BY_NEGATIVE_ONE_HALF_NV"/>
+                <enum name="GL_COMBINER_INPUT_NV"/>
+                <enum name="GL_COMBINER_MAPPING_NV"/>
+                <enum name="GL_COMBINER_COMPONENT_USAGE_NV"/>
+                <enum name="GL_COMBINER_AB_DOT_PRODUCT_NV"/>
+                <enum name="GL_COMBINER_CD_DOT_PRODUCT_NV"/>
+                <enum name="GL_COMBINER_MUX_SUM_NV"/>
+                <enum name="GL_COMBINER_SCALE_NV"/>
+                <enum name="GL_COMBINER_BIAS_NV"/>
+                <enum name="GL_COMBINER_AB_OUTPUT_NV"/>
+                <enum name="GL_COMBINER_CD_OUTPUT_NV"/>
+                <enum name="GL_COMBINER_SUM_OUTPUT_NV"/>
+                <enum name="GL_MAX_GENERAL_COMBINERS_NV"/>
+                <enum name="GL_NUM_GENERAL_COMBINERS_NV"/>
+                <enum name="GL_COLOR_SUM_CLAMP_NV"/>
+                <enum name="GL_COMBINER0_NV"/>
+                <enum name="GL_COMBINER1_NV"/>
+                <enum name="GL_COMBINER2_NV"/>
+                <enum name="GL_COMBINER3_NV"/>
+                <enum name="GL_COMBINER4_NV"/>
+                <enum name="GL_COMBINER5_NV"/>
+                <enum name="GL_COMBINER6_NV"/>
+                <enum name="GL_COMBINER7_NV"/>
+                <enum name="GL_TEXTURE0_ARB"/>
+                <enum name="GL_TEXTURE1_ARB"/>
+                <enum name="GL_ZERO"/>
+                <enum name="GL_NONE"/>
+                <enum name="GL_FOG"/>
+                <command name="glCombinerParameterfvNV"/>
+                <command name="glCombinerParameterfNV"/>
+                <command name="glCombinerParameterivNV"/>
+                <command name="glCombinerParameteriNV"/>
+                <command name="glCombinerInputNV"/>
+                <command name="glCombinerOutputNV"/>
+                <command name="glFinalCombinerInputNV"/>
+                <command name="glGetCombinerInputParameterfvNV"/>
+                <command name="glGetCombinerInputParameterivNV"/>
+                <command name="glGetCombinerOutputParameterfvNV"/>
+                <command name="glGetCombinerOutputParameterivNV"/>
+                <command name="glGetFinalCombinerInputParameterfvNV"/>
+                <command name="glGetFinalCombinerInputParameterivNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_register_combiners2" supported="gl">
+            <require>
+                <enum name="GL_PER_STAGE_CONSTANTS_NV"/>
+                <command name="glCombinerStageParameterfvNV"/>
+                <command name="glGetCombinerStageParameterfvNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_sRGB_formats" supported="gles2">
+            <require>
+                <enum name="GL_SLUMINANCE_NV"/>
+                <enum name="GL_SLUMINANCE_ALPHA_NV"/>
+                <enum name="GL_SRGB8_NV"/>
+                <enum name="GL_SLUMINANCE8_NV"/>
+                <enum name="GL_SLUMINANCE8_ALPHA8_NV"/>
+                <enum name="GL_COMPRESSED_SRGB_S3TC_DXT1_NV"/>
+                <enum name="GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV"/>
+                <enum name="GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV"/>
+                <enum name="GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV"/>
+                <enum name="GL_ETC1_SRGB8_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_shader_atomic_counters" supported="gl"/>
+        <extension name="GL_NV_shader_atomic_float" supported="gl"/>
+        <extension name="GL_NV_shader_buffer_load" supported="gl">
+            <require>
+                <enum name="GL_BUFFER_GPU_ADDRESS_NV"/>
+                <enum name="GL_GPU_ADDRESS_NV"/>
+                <enum name="GL_MAX_SHADER_BUFFER_ADDRESS_NV"/>
+                <command name="glMakeBufferResidentNV"/>
+                <command name="glMakeBufferNonResidentNV"/>
+                <command name="glIsBufferResidentNV"/>
+                <command name="glMakeNamedBufferResidentNV"/>
+                <command name="glMakeNamedBufferNonResidentNV"/>
+                <command name="glIsNamedBufferResidentNV"/>
+                <command name="glGetBufferParameterui64vNV"/>
+                <command name="glGetNamedBufferParameterui64vNV"/>
+                <command name="glGetIntegerui64vNV"/>
+                <command name="glUniformui64NV"/>
+                <command name="glUniformui64vNV"/>
+                <command name="glGetUniformui64vNV"/>
+                <command name="glProgramUniformui64NV"/>
+                <command name="glProgramUniformui64vNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_shader_buffer_store" supported="gl">
+            <require>
+                <enum name="GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV"/>
+                <enum name="GL_READ_WRITE"/>
+                <enum name="GL_WRITE_ONLY"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_shader_storage_buffer_object" supported="gl"/>
+        <extension name="GL_NV_shader_thread_group" supported="gl">
+            <require>
+                <enum name="GL_WARP_SIZE_NV"/>
+                <enum name="GL_WARPS_PER_SM_NV"/>
+                <enum name="GL_SM_COUNT_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_shader_thread_shuffle" supported="gl"/>
+        <extension name="GL_EXT_shader_image_load_formatted" supported="gl"/>
+        <extension name="GL_NV_shadow_samplers_array" supported="gles2">
+            <require>
+                <enum name="GL_SAMPLER_2D_ARRAY_SHADOW_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_shadow_samplers_cube" supported="gles2">
+            <require>
+                <enum name="GL_SAMPLER_CUBE_SHADOW_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_tessellation_program5" supported="gl">
+            <require>
+                <enum name="GL_MAX_PROGRAM_PATCH_ATTRIBS_NV"/>
+                <enum name="GL_TESS_CONTROL_PROGRAM_NV"/>
+                <enum name="GL_TESS_EVALUATION_PROGRAM_NV"/>
+                <enum name="GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV"/>
+                <enum name="GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_texgen_emboss" supported="gl">
+            <require>
+                <enum name="GL_EMBOSS_LIGHT_NV"/>
+                <enum name="GL_EMBOSS_CONSTANT_NV"/>
+                <enum name="GL_EMBOSS_MAP_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_texgen_reflection" supported="gl">
+            <require>
+                <enum name="GL_NORMAL_MAP_NV"/>
+                <enum name="GL_REFLECTION_MAP_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_texture_barrier" supported="gl">
+            <require>
+                <command name="glTextureBarrierNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_texture_border_clamp" supported="gles2">
+            <require>
+                <enum name="GL_TEXTURE_BORDER_COLOR_NV"/>
+                <enum name="GL_CLAMP_TO_BORDER_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_texture_compression_s3tc_update" supported="gles2"/>
+        <extension name="GL_NV_texture_compression_vtc" supported="gl"/>
+        <extension name="GL_NV_texture_env_combine4" supported="gl">
+            <require>
+                <enum name="GL_COMBINE4_NV"/>
+                <enum name="GL_SOURCE3_RGB_NV"/>
+                <enum name="GL_SOURCE3_ALPHA_NV"/>
+                <enum name="GL_OPERAND3_RGB_NV"/>
+                <enum name="GL_OPERAND3_ALPHA_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_texture_expand_normal" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_UNSIGNED_REMAP_MODE_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_texture_multisample" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_COVERAGE_SAMPLES_NV"/>
+                <enum name="GL_TEXTURE_COLOR_SAMPLES_NV"/>
+                <command name="glTexImage2DMultisampleCoverageNV"/>
+                <command name="glTexImage3DMultisampleCoverageNV"/>
+            </require>
+            <require comment="Supported only if GL_EXT_direct_state_access is supported">
+                <command name="glTextureImage2DMultisampleNV"/>
+                <command name="glTextureImage3DMultisampleNV"/>
+                <command name="glTextureImage2DMultisampleCoverageNV"/>
+                <command name="glTextureImage3DMultisampleCoverageNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_texture_npot_2D_mipmap" supported="gles2"/>
+        <extension name="GL_NV_texture_rectangle" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_RECTANGLE_NV"/>
+                <enum name="GL_TEXTURE_BINDING_RECTANGLE_NV"/>
+                <enum name="GL_PROXY_TEXTURE_RECTANGLE_NV"/>
+                <enum name="GL_MAX_RECTANGLE_TEXTURE_SIZE_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_texture_shader" supported="gl">
+            <require>
+                <enum name="GL_OFFSET_TEXTURE_RECTANGLE_NV"/>
+                <enum name="GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV"/>
+                <enum name="GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV"/>
+                <enum name="GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV"/>
+                <enum name="GL_UNSIGNED_INT_S8_S8_8_8_NV"/>
+                <enum name="GL_UNSIGNED_INT_8_8_S8_S8_REV_NV"/>
+                <enum name="GL_DSDT_MAG_INTENSITY_NV"/>
+                <enum name="GL_SHADER_CONSISTENT_NV"/>
+                <enum name="GL_TEXTURE_SHADER_NV"/>
+                <enum name="GL_SHADER_OPERATION_NV"/>
+                <enum name="GL_CULL_MODES_NV"/>
+                <enum name="GL_OFFSET_TEXTURE_MATRIX_NV"/>
+                <enum name="GL_OFFSET_TEXTURE_SCALE_NV"/>
+                <enum name="GL_OFFSET_TEXTURE_BIAS_NV"/>
+                <enum name="GL_OFFSET_TEXTURE_2D_MATRIX_NV"/>
+                <enum name="GL_OFFSET_TEXTURE_2D_SCALE_NV"/>
+                <enum name="GL_OFFSET_TEXTURE_2D_BIAS_NV"/>
+                <enum name="GL_PREVIOUS_TEXTURE_INPUT_NV"/>
+                <enum name="GL_CONST_EYE_NV"/>
+                <enum name="GL_PASS_THROUGH_NV"/>
+                <enum name="GL_CULL_FRAGMENT_NV"/>
+                <enum name="GL_OFFSET_TEXTURE_2D_NV"/>
+                <enum name="GL_DEPENDENT_AR_TEXTURE_2D_NV"/>
+                <enum name="GL_DEPENDENT_GB_TEXTURE_2D_NV"/>
+                <enum name="GL_DOT_PRODUCT_NV"/>
+                <enum name="GL_DOT_PRODUCT_DEPTH_REPLACE_NV"/>
+                <enum name="GL_DOT_PRODUCT_TEXTURE_2D_NV"/>
+                <enum name="GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV"/>
+                <enum name="GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV"/>
+                <enum name="GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV"/>
+                <enum name="GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV"/>
+                <enum name="GL_HILO_NV"/>
+                <enum name="GL_DSDT_NV"/>
+                <enum name="GL_DSDT_MAG_NV"/>
+                <enum name="GL_DSDT_MAG_VIB_NV"/>
+                <enum name="GL_HILO16_NV"/>
+                <enum name="GL_SIGNED_HILO_NV"/>
+                <enum name="GL_SIGNED_HILO16_NV"/>
+                <enum name="GL_SIGNED_RGBA_NV"/>
+                <enum name="GL_SIGNED_RGBA8_NV"/>
+                <enum name="GL_SIGNED_RGB_NV"/>
+                <enum name="GL_SIGNED_RGB8_NV"/>
+                <enum name="GL_SIGNED_LUMINANCE_NV"/>
+                <enum name="GL_SIGNED_LUMINANCE8_NV"/>
+                <enum name="GL_SIGNED_LUMINANCE_ALPHA_NV"/>
+                <enum name="GL_SIGNED_LUMINANCE8_ALPHA8_NV"/>
+                <enum name="GL_SIGNED_ALPHA_NV"/>
+                <enum name="GL_SIGNED_ALPHA8_NV"/>
+                <enum name="GL_SIGNED_INTENSITY_NV"/>
+                <enum name="GL_SIGNED_INTENSITY8_NV"/>
+                <enum name="GL_DSDT8_NV"/>
+                <enum name="GL_DSDT8_MAG8_NV"/>
+                <enum name="GL_DSDT8_MAG8_INTENSITY8_NV"/>
+                <enum name="GL_SIGNED_RGB_UNSIGNED_ALPHA_NV"/>
+                <enum name="GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV"/>
+                <enum name="GL_HI_SCALE_NV"/>
+                <enum name="GL_LO_SCALE_NV"/>
+                <enum name="GL_DS_SCALE_NV"/>
+                <enum name="GL_DT_SCALE_NV"/>
+                <enum name="GL_MAGNITUDE_SCALE_NV"/>
+                <enum name="GL_VIBRANCE_SCALE_NV"/>
+                <enum name="GL_HI_BIAS_NV"/>
+                <enum name="GL_LO_BIAS_NV"/>
+                <enum name="GL_DS_BIAS_NV"/>
+                <enum name="GL_DT_BIAS_NV"/>
+                <enum name="GL_MAGNITUDE_BIAS_NV"/>
+                <enum name="GL_VIBRANCE_BIAS_NV"/>
+                <enum name="GL_TEXTURE_BORDER_VALUES_NV"/>
+                <enum name="GL_TEXTURE_HI_SIZE_NV"/>
+                <enum name="GL_TEXTURE_LO_SIZE_NV"/>
+                <enum name="GL_TEXTURE_DS_SIZE_NV"/>
+                <enum name="GL_TEXTURE_DT_SIZE_NV"/>
+                <enum name="GL_TEXTURE_MAG_SIZE_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_texture_shader2" supported="gl">
+            <require>
+                <enum name="GL_DOT_PRODUCT_TEXTURE_3D_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_texture_shader3" supported="gl">
+            <require>
+                <enum name="GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV"/>
+                <enum name="GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV"/>
+                <enum name="GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV"/>
+                <enum name="GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV"/>
+                <enum name="GL_OFFSET_HILO_TEXTURE_2D_NV"/>
+                <enum name="GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV"/>
+                <enum name="GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV"/>
+                <enum name="GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV"/>
+                <enum name="GL_DEPENDENT_HILO_TEXTURE_2D_NV"/>
+                <enum name="GL_DEPENDENT_RGB_TEXTURE_3D_NV"/>
+                <enum name="GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV"/>
+                <enum name="GL_DOT_PRODUCT_PASS_THROUGH_NV"/>
+                <enum name="GL_DOT_PRODUCT_TEXTURE_1D_NV"/>
+                <enum name="GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV"/>
+                <enum name="GL_HILO8_NV"/>
+                <enum name="GL_SIGNED_HILO8_NV"/>
+                <enum name="GL_FORCE_BLUE_TO_ONE_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_transform_feedback" supported="gl">
+            <require>
+                <enum name="GL_BACK_PRIMARY_COLOR_NV"/>
+                <enum name="GL_BACK_SECONDARY_COLOR_NV"/>
+                <enum name="GL_TEXTURE_COORD_NV"/>
+                <enum name="GL_CLIP_DISTANCE_NV"/>
+                <enum name="GL_VERTEX_ID_NV"/>
+                <enum name="GL_PRIMITIVE_ID_NV"/>
+                <enum name="GL_GENERIC_ATTRIB_NV"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_ATTRIBS_NV"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV"/>
+                <enum name="GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV"/>
+                <enum name="GL_ACTIVE_VARYINGS_NV"/>
+                <enum name="GL_ACTIVE_VARYING_MAX_LENGTH_NV"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_VARYINGS_NV"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_START_NV"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_RECORD_NV"/>
+                <enum name="GL_PRIMITIVES_GENERATED_NV"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV"/>
+                <enum name="GL_RASTERIZER_DISCARD_NV"/>
+                <enum name="GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV"/>
+                <enum name="GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV"/>
+                <enum name="GL_INTERLEAVED_ATTRIBS_NV"/>
+                <enum name="GL_SEPARATE_ATTRIBS_NV"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_NV"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV"/>
+                <enum name="GL_LAYER_NV"/>
+                <command name="glBeginTransformFeedbackNV"/>
+                <command name="glEndTransformFeedbackNV"/>
+                <command name="glTransformFeedbackAttribsNV"/>
+                <command name="glBindBufferRangeNV"/>
+                <command name="glBindBufferOffsetNV"/>
+                <command name="glBindBufferBaseNV"/>
+                <command name="glTransformFeedbackVaryingsNV"/>
+                <command name="glActiveVaryingNV"/>
+                <command name="glGetVaryingLocationNV"/>
+                <command name="glGetActiveVaryingNV"/>
+                <command name="glGetTransformFeedbackVaryingNV"/>
+            </require>
+            <require comment="Extended by GL_ARB_transform_feedback3">
+                <enum name="GL_NEXT_BUFFER_NV"/>
+                <enum name="GL_SKIP_COMPONENTS4_NV"/>
+                <enum name="GL_SKIP_COMPONENTS3_NV"/>
+                <enum name="GL_SKIP_COMPONENTS2_NV"/>
+                <enum name="GL_SKIP_COMPONENTS1_NV"/>
+                <command name="glTransformFeedbackStreamAttribsNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_transform_feedback2" supported="gl">
+            <require>
+                <enum name="GL_TRANSFORM_FEEDBACK_NV"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV"/>
+                <enum name="GL_TRANSFORM_FEEDBACK_BINDING_NV"/>
+                <command name="glBindTransformFeedbackNV"/>
+                <command name="glDeleteTransformFeedbacksNV"/>
+                <command name="glGenTransformFeedbacksNV"/>
+                <command name="glIsTransformFeedbackNV"/>
+                <command name="glPauseTransformFeedbackNV"/>
+                <command name="glResumeTransformFeedbackNV"/>
+                <command name="glDrawTransformFeedbackNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_vdpau_interop" supported="gl">
+            <require>
+                <enum name="GL_SURFACE_STATE_NV"/>
+                <enum name="GL_SURFACE_REGISTERED_NV"/>
+                <enum name="GL_SURFACE_MAPPED_NV"/>
+                <enum name="GL_WRITE_DISCARD_NV"/>
+                <command name="glVDPAUInitNV"/>
+                <command name="glVDPAUFiniNV"/>
+                <command name="glVDPAURegisterVideoSurfaceNV"/>
+                <command name="glVDPAURegisterOutputSurfaceNV"/>
+                <command name="glVDPAUIsSurfaceNV"/>
+                <command name="glVDPAUUnregisterSurfaceNV"/>
+                <command name="glVDPAUGetSurfaceivNV"/>
+                <command name="glVDPAUSurfaceAccessNV"/>
+                <command name="glVDPAUMapSurfacesNV"/>
+                <command name="glVDPAUUnmapSurfacesNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_vertex_array_range" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_ARRAY_RANGE_NV"/>
+                <enum name="GL_VERTEX_ARRAY_RANGE_LENGTH_NV"/>
+                <enum name="GL_VERTEX_ARRAY_RANGE_VALID_NV"/>
+                <enum name="GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV"/>
+                <enum name="GL_VERTEX_ARRAY_RANGE_POINTER_NV"/>
+                <command name="glFlushVertexArrayRangeNV"/>
+                <command name="glVertexArrayRangeNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_vertex_array_range2" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_vertex_attrib_integer_64bit" supported="gl">
+            <require>
+                <enum name="GL_INT64_NV"/>
+                <enum name="GL_UNSIGNED_INT64_NV"/>
+                <command name="glVertexAttribL1i64NV"/>
+                <command name="glVertexAttribL2i64NV"/>
+                <command name="glVertexAttribL3i64NV"/>
+                <command name="glVertexAttribL4i64NV"/>
+                <command name="glVertexAttribL1i64vNV"/>
+                <command name="glVertexAttribL2i64vNV"/>
+                <command name="glVertexAttribL3i64vNV"/>
+                <command name="glVertexAttribL4i64vNV"/>
+                <command name="glVertexAttribL1ui64NV"/>
+                <command name="glVertexAttribL2ui64NV"/>
+                <command name="glVertexAttribL3ui64NV"/>
+                <command name="glVertexAttribL4ui64NV"/>
+                <command name="glVertexAttribL1ui64vNV"/>
+                <command name="glVertexAttribL2ui64vNV"/>
+                <command name="glVertexAttribL3ui64vNV"/>
+                <command name="glVertexAttribL4ui64vNV"/>
+                <command name="glGetVertexAttribLi64vNV"/>
+                <command name="glGetVertexAttribLui64vNV"/>
+                <command name="glVertexAttribLFormatNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_vertex_buffer_unified_memory" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV"/>
+                <enum name="GL_ELEMENT_ARRAY_UNIFIED_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV"/>
+                <enum name="GL_VERTEX_ARRAY_ADDRESS_NV"/>
+                <enum name="GL_NORMAL_ARRAY_ADDRESS_NV"/>
+                <enum name="GL_COLOR_ARRAY_ADDRESS_NV"/>
+                <enum name="GL_INDEX_ARRAY_ADDRESS_NV"/>
+                <enum name="GL_TEXTURE_COORD_ARRAY_ADDRESS_NV"/>
+                <enum name="GL_EDGE_FLAG_ARRAY_ADDRESS_NV"/>
+                <enum name="GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV"/>
+                <enum name="GL_FOG_COORD_ARRAY_ADDRESS_NV"/>
+                <enum name="GL_ELEMENT_ARRAY_ADDRESS_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV"/>
+                <enum name="GL_VERTEX_ARRAY_LENGTH_NV"/>
+                <enum name="GL_NORMAL_ARRAY_LENGTH_NV"/>
+                <enum name="GL_COLOR_ARRAY_LENGTH_NV"/>
+                <enum name="GL_INDEX_ARRAY_LENGTH_NV"/>
+                <enum name="GL_TEXTURE_COORD_ARRAY_LENGTH_NV"/>
+                <enum name="GL_EDGE_FLAG_ARRAY_LENGTH_NV"/>
+                <enum name="GL_SECONDARY_COLOR_ARRAY_LENGTH_NV"/>
+                <enum name="GL_FOG_COORD_ARRAY_LENGTH_NV"/>
+                <enum name="GL_ELEMENT_ARRAY_LENGTH_NV"/>
+                <enum name="GL_DRAW_INDIRECT_UNIFIED_NV"/>
+                <enum name="GL_DRAW_INDIRECT_ADDRESS_NV"/>
+                <enum name="GL_DRAW_INDIRECT_LENGTH_NV"/>
+                <command name="glBufferAddressRangeNV"/>
+                <command name="glVertexFormatNV"/>
+                <command name="glNormalFormatNV"/>
+                <command name="glColorFormatNV"/>
+                <command name="glIndexFormatNV"/>
+                <command name="glTexCoordFormatNV"/>
+                <command name="glEdgeFlagFormatNV"/>
+                <command name="glSecondaryColorFormatNV"/>
+                <command name="glFogCoordFormatNV"/>
+                <command name="glVertexAttribFormatNV"/>
+                <command name="glVertexAttribIFormatNV"/>
+                <command name="glGetIntegerui64i_vNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_vertex_program" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_PROGRAM_NV"/>
+                <enum name="GL_VERTEX_STATE_PROGRAM_NV"/>
+                <enum name="GL_ATTRIB_ARRAY_SIZE_NV"/>
+                <enum name="GL_ATTRIB_ARRAY_STRIDE_NV"/>
+                <enum name="GL_ATTRIB_ARRAY_TYPE_NV"/>
+                <enum name="GL_CURRENT_ATTRIB_NV"/>
+                <enum name="GL_PROGRAM_LENGTH_NV"/>
+                <enum name="GL_PROGRAM_STRING_NV"/>
+                <enum name="GL_MODELVIEW_PROJECTION_NV"/>
+                <enum name="GL_IDENTITY_NV"/>
+                <enum name="GL_INVERSE_NV"/>
+                <enum name="GL_TRANSPOSE_NV"/>
+                <enum name="GL_INVERSE_TRANSPOSE_NV"/>
+                <enum name="GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV"/>
+                <enum name="GL_MAX_TRACK_MATRICES_NV"/>
+                <enum name="GL_MATRIX0_NV"/>
+                <enum name="GL_MATRIX1_NV"/>
+                <enum name="GL_MATRIX2_NV"/>
+                <enum name="GL_MATRIX3_NV"/>
+                <enum name="GL_MATRIX4_NV"/>
+                <enum name="GL_MATRIX5_NV"/>
+                <enum name="GL_MATRIX6_NV"/>
+                <enum name="GL_MATRIX7_NV"/>
+                <enum name="GL_CURRENT_MATRIX_STACK_DEPTH_NV"/>
+                <enum name="GL_CURRENT_MATRIX_NV"/>
+                <enum name="GL_VERTEX_PROGRAM_POINT_SIZE_NV"/>
+                <enum name="GL_VERTEX_PROGRAM_TWO_SIDE_NV"/>
+                <enum name="GL_PROGRAM_PARAMETER_NV"/>
+                <enum name="GL_ATTRIB_ARRAY_POINTER_NV"/>
+                <enum name="GL_PROGRAM_TARGET_NV"/>
+                <enum name="GL_PROGRAM_RESIDENT_NV"/>
+                <enum name="GL_TRACK_MATRIX_NV"/>
+                <enum name="GL_TRACK_MATRIX_TRANSFORM_NV"/>
+                <enum name="GL_VERTEX_PROGRAM_BINDING_NV"/>
+                <enum name="GL_PROGRAM_ERROR_POSITION_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY0_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY1_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY2_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY3_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY4_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY5_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY6_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY7_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY8_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY9_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY10_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY11_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY12_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY13_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY14_NV"/>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY15_NV"/>
+                <enum name="GL_MAP1_VERTEX_ATTRIB0_4_NV"/>
+                <enum name="GL_MAP1_VERTEX_ATTRIB1_4_NV"/>
+                <enum name="GL_MAP1_VERTEX_ATTRIB2_4_NV"/>
+                <enum name="GL_MAP1_VERTEX_ATTRIB3_4_NV"/>
+                <enum name="GL_MAP1_VERTEX_ATTRIB4_4_NV"/>
+                <enum name="GL_MAP1_VERTEX_ATTRIB5_4_NV"/>
+                <enum name="GL_MAP1_VERTEX_ATTRIB6_4_NV"/>
+                <enum name="GL_MAP1_VERTEX_ATTRIB7_4_NV"/>
+                <enum name="GL_MAP1_VERTEX_ATTRIB8_4_NV"/>
+                <enum name="GL_MAP1_VERTEX_ATTRIB9_4_NV"/>
+                <enum name="GL_MAP1_VERTEX_ATTRIB10_4_NV"/>
+                <enum name="GL_MAP1_VERTEX_ATTRIB11_4_NV"/>
+                <enum name="GL_MAP1_VERTEX_ATTRIB12_4_NV"/>
+                <enum name="GL_MAP1_VERTEX_ATTRIB13_4_NV"/>
+                <enum name="GL_MAP1_VERTEX_ATTRIB14_4_NV"/>
+                <enum name="GL_MAP1_VERTEX_ATTRIB15_4_NV"/>
+                <enum name="GL_MAP2_VERTEX_ATTRIB0_4_NV"/>
+                <enum name="GL_MAP2_VERTEX_ATTRIB1_4_NV"/>
+                <enum name="GL_MAP2_VERTEX_ATTRIB2_4_NV"/>
+                <enum name="GL_MAP2_VERTEX_ATTRIB3_4_NV"/>
+                <enum name="GL_MAP2_VERTEX_ATTRIB4_4_NV"/>
+                <enum name="GL_MAP2_VERTEX_ATTRIB5_4_NV"/>
+                <enum name="GL_MAP2_VERTEX_ATTRIB6_4_NV"/>
+                <enum name="GL_MAP2_VERTEX_ATTRIB7_4_NV"/>
+                <enum name="GL_MAP2_VERTEX_ATTRIB8_4_NV"/>
+                <enum name="GL_MAP2_VERTEX_ATTRIB9_4_NV"/>
+                <enum name="GL_MAP2_VERTEX_ATTRIB10_4_NV"/>
+                <enum name="GL_MAP2_VERTEX_ATTRIB11_4_NV"/>
+                <enum name="GL_MAP2_VERTEX_ATTRIB12_4_NV"/>
+                <enum name="GL_MAP2_VERTEX_ATTRIB13_4_NV"/>
+                <enum name="GL_MAP2_VERTEX_ATTRIB14_4_NV"/>
+                <enum name="GL_MAP2_VERTEX_ATTRIB15_4_NV"/>
+                <command name="glAreProgramsResidentNV"/>
+                <command name="glBindProgramNV"/>
+                <command name="glDeleteProgramsNV"/>
+                <command name="glExecuteProgramNV"/>
+                <command name="glGenProgramsNV"/>
+                <command name="glGetProgramParameterdvNV"/>
+                <command name="glGetProgramParameterfvNV"/>
+                <command name="glGetProgramivNV"/>
+                <command name="glGetProgramStringNV"/>
+                <command name="glGetTrackMatrixivNV"/>
+                <command name="glGetVertexAttribdvNV"/>
+                <command name="glGetVertexAttribfvNV"/>
+                <command name="glGetVertexAttribivNV"/>
+                <command name="glGetVertexAttribPointervNV"/>
+                <command name="glIsProgramNV"/>
+                <command name="glLoadProgramNV"/>
+                <command name="glProgramParameter4dNV"/>
+                <command name="glProgramParameter4dvNV"/>
+                <command name="glProgramParameter4fNV"/>
+                <command name="glProgramParameter4fvNV"/>
+                <command name="glProgramParameters4dvNV"/>
+                <command name="glProgramParameters4fvNV"/>
+                <command name="glRequestResidentProgramsNV"/>
+                <command name="glTrackMatrixNV"/>
+                <command name="glVertexAttribPointerNV"/>
+                <command name="glVertexAttrib1dNV"/>
+                <command name="glVertexAttrib1dvNV"/>
+                <command name="glVertexAttrib1fNV"/>
+                <command name="glVertexAttrib1fvNV"/>
+                <command name="glVertexAttrib1sNV"/>
+                <command name="glVertexAttrib1svNV"/>
+                <command name="glVertexAttrib2dNV"/>
+                <command name="glVertexAttrib2dvNV"/>
+                <command name="glVertexAttrib2fNV"/>
+                <command name="glVertexAttrib2fvNV"/>
+                <command name="glVertexAttrib2sNV"/>
+                <command name="glVertexAttrib2svNV"/>
+                <command name="glVertexAttrib3dNV"/>
+                <command name="glVertexAttrib3dvNV"/>
+                <command name="glVertexAttrib3fNV"/>
+                <command name="glVertexAttrib3fvNV"/>
+                <command name="glVertexAttrib3sNV"/>
+                <command name="glVertexAttrib3svNV"/>
+                <command name="glVertexAttrib4dNV"/>
+                <command name="glVertexAttrib4dvNV"/>
+                <command name="glVertexAttrib4fNV"/>
+                <command name="glVertexAttrib4fvNV"/>
+                <command name="glVertexAttrib4sNV"/>
+                <command name="glVertexAttrib4svNV"/>
+                <command name="glVertexAttrib4ubNV"/>
+                <command name="glVertexAttrib4ubvNV"/>
+                <command name="glVertexAttribs1dvNV"/>
+                <command name="glVertexAttribs1fvNV"/>
+                <command name="glVertexAttribs1svNV"/>
+                <command name="glVertexAttribs2dvNV"/>
+                <command name="glVertexAttribs2fvNV"/>
+                <command name="glVertexAttribs2svNV"/>
+                <command name="glVertexAttribs3dvNV"/>
+                <command name="glVertexAttribs3fvNV"/>
+                <command name="glVertexAttribs3svNV"/>
+                <command name="glVertexAttribs4dvNV"/>
+                <command name="glVertexAttribs4fvNV"/>
+                <command name="glVertexAttribs4svNV"/>
+                <command name="glVertexAttribs4ubvNV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_vertex_program1_1" supported="gl"/>
+        <extension name="GL_NV_vertex_program2" supported="gl"/>
+        <extension name="GL_NV_vertex_program2_option" supported="gl">
+            <require>
+                <enum name="GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV"/>
+                <enum name="GL_MAX_PROGRAM_CALL_DEPTH_NV"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_vertex_program3" supported="gl">
+            <require>
+                <enum name="GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_vertex_program4" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV"/>
+                <command name="glVertexAttribI1iEXT"/>
+                <command name="glVertexAttribI2iEXT"/>
+                <command name="glVertexAttribI3iEXT"/>
+                <command name="glVertexAttribI4iEXT"/>
+                <command name="glVertexAttribI1uiEXT"/>
+                <command name="glVertexAttribI2uiEXT"/>
+                <command name="glVertexAttribI3uiEXT"/>
+                <command name="glVertexAttribI4uiEXT"/>
+                <command name="glVertexAttribI1ivEXT"/>
+                <command name="glVertexAttribI2ivEXT"/>
+                <command name="glVertexAttribI3ivEXT"/>
+                <command name="glVertexAttribI4ivEXT"/>
+                <command name="glVertexAttribI1uivEXT"/>
+                <command name="glVertexAttribI2uivEXT"/>
+                <command name="glVertexAttribI3uivEXT"/>
+                <command name="glVertexAttribI4uivEXT"/>
+                <command name="glVertexAttribI4bvEXT"/>
+                <command name="glVertexAttribI4svEXT"/>
+                <command name="glVertexAttribI4ubvEXT"/>
+                <command name="glVertexAttribI4usvEXT"/>
+                <command name="glVertexAttribIPointerEXT"/>
+                <command name="glGetVertexAttribIivEXT"/>
+                <command name="glGetVertexAttribIuivEXT"/>
+            </require>
+        </extension>
+        <extension name="GL_NV_video_capture" supported="gl">
+            <require>
+                <enum name="GL_VIDEO_BUFFER_NV"/>
+                <enum name="GL_VIDEO_BUFFER_BINDING_NV"/>
+                <enum name="GL_FIELD_UPPER_NV"/>
+                <enum name="GL_FIELD_LOWER_NV"/>
+                <enum name="GL_NUM_VIDEO_CAPTURE_STREAMS_NV"/>
+                <enum name="GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV"/>
+                <enum name="GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV"/>
+                <enum name="GL_LAST_VIDEO_CAPTURE_STATUS_NV"/>
+                <enum name="GL_VIDEO_BUFFER_PITCH_NV"/>
+                <enum name="GL_VIDEO_COLOR_CONVERSION_MATRIX_NV"/>
+                <enum name="GL_VIDEO_COLOR_CONVERSION_MAX_NV"/>
+                <enum name="GL_VIDEO_COLOR_CONVERSION_MIN_NV"/>
+                <enum name="GL_VIDEO_COLOR_CONVERSION_OFFSET_NV"/>
+                <enum name="GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV"/>
+                <enum name="GL_PARTIAL_SUCCESS_NV"/>
+                <enum name="GL_SUCCESS_NV"/>
+                <enum name="GL_FAILURE_NV"/>
+                <enum name="GL_YCBYCR8_422_NV"/>
+                <enum name="GL_YCBAYCR8A_4224_NV"/>
+                <enum name="GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV"/>
+                <enum name="GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV"/>
+                <enum name="GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV"/>
+                <enum name="GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV"/>
+                <enum name="GL_Z4Y12Z4CB12Z4CR12_444_NV"/>
+                <enum name="GL_VIDEO_CAPTURE_FRAME_WIDTH_NV"/>
+                <enum name="GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV"/>
+                <enum name="GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV"/>
+                <enum name="GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV"/>
+                <enum name="GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV"/>
+                <command name="glBeginVideoCaptureNV"/>
+                <command name="glBindVideoCaptureStreamBufferNV"/>
+                <command name="glBindVideoCaptureStreamTextureNV"/>
+                <command name="glEndVideoCaptureNV"/>
+                <command name="glGetVideoCaptureivNV"/>
+                <command name="glGetVideoCaptureStreamivNV"/>
+                <command name="glGetVideoCaptureStreamfvNV"/>
+                <command name="glGetVideoCaptureStreamdvNV"/>
+                <command name="glVideoCaptureNV"/>
+                <command name="glVideoCaptureStreamParameterivNV"/>
+                <command name="glVideoCaptureStreamParameterfvNV"/>
+                <command name="glVideoCaptureStreamParameterdvNV"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_EGL_image" supported="gles1|gles2">
+            <require>
+                <type name="GLeglImageOES"/>
+                <command name="glEGLImageTargetTexture2DOES"/>
+                <command name="glEGLImageTargetRenderbufferStorageOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_EGL_image_external" supported="gles1|gles2">
+            <require>
+                <type name="GLeglImageOES"/>
+                <enum name="GL_TEXTURE_EXTERNAL_OES"/>
+                <enum name="GL_TEXTURE_BINDING_EXTERNAL_OES"/>
+                <enum name="GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES"/>
+            </require>
+            <require api="gles2">
+                <enum name="GL_SAMPLER_EXTERNAL_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_blend_equation_separate" supported="gles1">
+            <require>
+                <enum name="GL_BLEND_EQUATION_RGB_OES"/>
+                <enum name="GL_BLEND_EQUATION_ALPHA_OES"/>
+                <command name="glBlendEquationSeparateOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_blend_func_separate" supported="gles1">
+            <require>
+                <enum name="GL_BLEND_DST_RGB_OES"/>
+                <enum name="GL_BLEND_SRC_RGB_OES"/>
+                <enum name="GL_BLEND_DST_ALPHA_OES"/>
+                <enum name="GL_BLEND_SRC_ALPHA_OES"/>
+                <command name="glBlendFuncSeparateOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_blend_subtract" supported="gles1">
+            <require>
+                <enum name="GL_BLEND_EQUATION_OES"/>
+                <enum name="GL_FUNC_ADD_OES"/>
+                <enum name="GL_FUNC_SUBTRACT_OES"/>
+                <enum name="GL_FUNC_REVERSE_SUBTRACT_OES"/>
+                <command name="glBlendEquationOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_byte_coordinates" supported="gl|gles1">
+            <require>
+                <command name="glMultiTexCoord1bOES"/>
+                <command name="glMultiTexCoord1bvOES"/>
+                <command name="glMultiTexCoord2bOES"/>
+                <command name="glMultiTexCoord2bvOES"/>
+                <command name="glMultiTexCoord3bOES"/>
+                <command name="glMultiTexCoord3bvOES"/>
+                <command name="glMultiTexCoord4bOES"/>
+                <command name="glMultiTexCoord4bvOES"/>
+                <command name="glTexCoord1bOES"/>
+                <command name="glTexCoord1bvOES"/>
+                <command name="glTexCoord2bOES"/>
+                <command name="glTexCoord2bvOES"/>
+                <command name="glTexCoord3bOES"/>
+                <command name="glTexCoord3bvOES"/>
+                <command name="glTexCoord4bOES"/>
+                <command name="glTexCoord4bvOES"/>
+                <command name="glVertex2bOES"/>
+                <command name="glVertex2bvOES"/>
+                <command name="glVertex3bOES"/>
+                <command name="glVertex3bvOES"/>
+                <command name="glVertex4bOES"/>
+                <command name="glVertex4bvOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_compressed_ETC1_RGB8_texture" supported="gles1|gles2">
+            <require>
+                <enum name="GL_ETC1_RGB8_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_compressed_paletted_texture" supported="gl|gles1|gles2">
+            <require>
+                <enum name="GL_PALETTE4_RGB8_OES"/>
+                <enum name="GL_PALETTE4_RGBA8_OES"/>
+                <enum name="GL_PALETTE4_R5_G6_B5_OES"/>
+                <enum name="GL_PALETTE4_RGBA4_OES"/>
+                <enum name="GL_PALETTE4_RGB5_A1_OES"/>
+                <enum name="GL_PALETTE8_RGB8_OES"/>
+                <enum name="GL_PALETTE8_RGBA8_OES"/>
+                <enum name="GL_PALETTE8_R5_G6_B5_OES"/>
+                <enum name="GL_PALETTE8_RGBA4_OES"/>
+                <enum name="GL_PALETTE8_RGB5_A1_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_depth24" supported="gles1|gles2">
+            <require>
+                <enum name="GL_DEPTH_COMPONENT24_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_depth32" supported="gles1|gles2">
+            <require>
+                <enum name="GL_DEPTH_COMPONENT32_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_depth_texture" supported="gles2">
+            <require>
+                <enum name="GL_DEPTH_COMPONENT"/>
+                <enum name="GL_UNSIGNED_SHORT"/>
+                <enum name="GL_UNSIGNED_INT"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_draw_texture" supported="gles1">
+            <require>
+                <enum name="GL_TEXTURE_CROP_RECT_OES"/>
+                <command name="glDrawTexsOES"/>
+                <command name="glDrawTexiOES"/>
+                <command name="glDrawTexxOES"/>
+                <command name="glDrawTexsvOES"/>
+                <command name="glDrawTexivOES"/>
+                <command name="glDrawTexxvOES"/>
+                <command name="glDrawTexfOES"/>
+                <command name="glDrawTexfvOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_element_index_uint" supported="gles1|gles2">
+            <require>
+                <enum name="GL_UNSIGNED_INT"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_extended_matrix_palette" supported="gles1"/>
+        <extension name="GL_OES_fbo_render_mipmap" supported="gles1|gles2"/>
+        <extension name="GL_OES_fixed_point" supported="gl|gles1">
+            <require>
+                <enum name="GL_FIXED_OES"/>
+                <command name="glAlphaFuncxOES"/>
+                <command name="glClearColorxOES"/>
+                <command name="glClearDepthxOES"/>
+                <command name="glClipPlanexOES"/>
+                <command name="glColor4xOES"/>
+                <command name="glDepthRangexOES"/>
+                <command name="glFogxOES"/>
+                <command name="glFogxvOES"/>
+                <command name="glFrustumxOES"/>
+                <command name="glGetClipPlanexOES"/>
+                <command name="glGetFixedvOES"/>
+                <command name="glGetTexEnvxvOES"/>
+                <command name="glGetTexParameterxvOES"/>
+                <command name="glLightModelxOES"/>
+                <command name="glLightModelxvOES"/>
+                <command name="glLightxOES"/>
+                <command name="glLightxvOES"/>
+                <command name="glLineWidthxOES"/>
+                <command name="glLoadMatrixxOES"/>
+                <command name="glMaterialxOES"/>
+                <command name="glMaterialxvOES"/>
+                <command name="glMultMatrixxOES"/>
+                <command name="glMultiTexCoord4xOES"/>
+                <command name="glNormal3xOES"/>
+                <command name="glOrthoxOES"/>
+                <command name="glPointParameterxvOES"/>
+                <command name="glPointSizexOES"/>
+                <command name="glPolygonOffsetxOES"/>
+                <command name="glRotatexOES"/>
+                <command name="glSampleCoverageOES"/>
+                <command name="glScalexOES"/>
+                <command name="glTexEnvxOES"/>
+                <command name="glTexEnvxvOES"/>
+                <command name="glTexParameterxOES"/>
+                <command name="glTexParameterxvOES"/>
+                <command name="glTranslatexOES"/>
+            </require>
+            <require api="gles1" comment="Entry points not in the extension spec, but in the Khronos glext.h. Included for backward compatibility.">
+                <command name="glGetLightxvOES"/>
+                <command name="glGetMaterialxvOES"/>
+                <command name="glPointParameterxOES"/>
+                <command name="glSampleCoveragexOES"/>
+            </require>
+            <require api="gl" comment="Entry points in the extension spec, but not the Khronos glext.h. Correspond to GL-only features it's unlikely were ever implemented against ES 1.x.">
+                <command name="glAccumxOES"/>
+                <command name="glBitmapxOES"/>
+                <command name="glBlendColorxOES"/>
+                <command name="glClearAccumxOES"/>
+                <command name="glColor3xOES"/>
+                <command name="glColor3xvOES"/>
+                <command name="glColor4xvOES"/>
+                <command name="glConvolutionParameterxOES"/>
+                <command name="glConvolutionParameterxvOES"/>
+                <command name="glEvalCoord1xOES"/>
+                <command name="glEvalCoord1xvOES"/>
+                <command name="glEvalCoord2xOES"/>
+                <command name="glEvalCoord2xvOES"/>
+                <command name="glFeedbackBufferxOES"/>
+                <command name="glGetConvolutionParameterxvOES"/>
+                <command name="glGetHistogramParameterxvOES"/>
+                <command name="glGetLightxOES"/>
+                <command name="glGetMapxvOES"/>
+                <command name="glGetMaterialxOES"/>
+                <command name="glGetPixelMapxv"/>
+                <command name="glGetTexGenxvOES"/>
+                <command name="glGetTexLevelParameterxvOES"/>
+                <command name="glIndexxOES"/>
+                <command name="glIndexxvOES"/>
+                <command name="glLoadTransposeMatrixxOES"/>
+                <command name="glMap1xOES"/>
+                <command name="glMap2xOES"/>
+                <command name="glMapGrid1xOES"/>
+                <command name="glMapGrid2xOES"/>
+                <command name="glMultTransposeMatrixxOES"/>
+                <command name="glMultiTexCoord1xOES"/>
+                <command name="glMultiTexCoord1xvOES"/>
+                <command name="glMultiTexCoord2xOES"/>
+                <command name="glMultiTexCoord2xvOES"/>
+                <command name="glMultiTexCoord3xOES"/>
+                <command name="glMultiTexCoord3xvOES"/>
+                <command name="glMultiTexCoord4xvOES"/>
+                <command name="glNormal3xvOES"/>
+                <command name="glPassThroughxOES"/>
+                <command name="glPixelMapx"/>
+                <command name="glPixelStorex"/>
+                <command name="glPixelTransferxOES"/>
+                <command name="glPixelZoomxOES"/>
+                <command name="glPrioritizeTexturesxOES"/>
+                <command name="glRasterPos2xOES"/>
+                <command name="glRasterPos2xvOES"/>
+                <command name="glRasterPos3xOES"/>
+                <command name="glRasterPos3xvOES"/>
+                <command name="glRasterPos4xOES"/>
+                <command name="glRasterPos4xvOES"/>
+                <command name="glRectxOES"/>
+                <command name="glRectxvOES"/>
+                <command name="glTexCoord1xOES"/>
+                <command name="glTexCoord1xvOES"/>
+                <command name="glTexCoord2xOES"/>
+                <command name="glTexCoord2xvOES"/>
+                <command name="glTexCoord3xOES"/>
+                <command name="glTexCoord3xvOES"/>
+                <command name="glTexCoord4xOES"/>
+                <command name="glTexCoord4xvOES"/>
+                <command name="glTexGenxOES"/>
+                <command name="glTexGenxvOES"/>
+                <command name="glVertex2xOES"/>
+                <command name="glVertex2xvOES"/>
+                <command name="glVertex3xOES"/>
+                <command name="glVertex3xvOES"/>
+                <command name="glVertex4xOES"/>
+                <command name="glVertex4xvOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_fragment_precision_high" supported="gles2">
+            <require>
+            </require>
+        </extension>
+        <extension name="GL_OES_framebuffer_object" supported="gles1">
+            <require>
+                <enum name="GL_NONE_OES"/>
+                <enum name="GL_FRAMEBUFFER_OES"/>
+                <enum name="GL_RENDERBUFFER_OES"/>
+                <enum name="GL_RGBA4_OES"/>
+                <enum name="GL_RGB5_A1_OES"/>
+                <enum name="GL_RGB565_OES"/>
+                <enum name="GL_DEPTH_COMPONENT16_OES"/>
+                <enum name="GL_RENDERBUFFER_WIDTH_OES"/>
+                <enum name="GL_RENDERBUFFER_HEIGHT_OES"/>
+                <enum name="GL_RENDERBUFFER_INTERNAL_FORMAT_OES"/>
+                <enum name="GL_RENDERBUFFER_RED_SIZE_OES"/>
+                <enum name="GL_RENDERBUFFER_GREEN_SIZE_OES"/>
+                <enum name="GL_RENDERBUFFER_BLUE_SIZE_OES"/>
+                <enum name="GL_RENDERBUFFER_ALPHA_SIZE_OES"/>
+                <enum name="GL_RENDERBUFFER_DEPTH_SIZE_OES"/>
+                <enum name="GL_RENDERBUFFER_STENCIL_SIZE_OES"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES"/>
+                <enum name="GL_COLOR_ATTACHMENT0_OES"/>
+                <enum name="GL_DEPTH_ATTACHMENT_OES"/>
+                <enum name="GL_STENCIL_ATTACHMENT_OES"/>
+                <enum name="GL_FRAMEBUFFER_COMPLETE_OES"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES"/>
+                <enum name="GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES"/>
+                <enum name="GL_FRAMEBUFFER_UNSUPPORTED_OES"/>
+                <enum name="GL_FRAMEBUFFER_BINDING_OES"/>
+                <enum name="GL_RENDERBUFFER_BINDING_OES"/>
+                <enum name="GL_MAX_RENDERBUFFER_SIZE_OES"/>
+                <enum name="GL_INVALID_FRAMEBUFFER_OPERATION_OES"/>
+                <command name="glIsRenderbufferOES"/>
+                <command name="glBindRenderbufferOES"/>
+                <command name="glDeleteRenderbuffersOES"/>
+                <command name="glGenRenderbuffersOES"/>
+                <command name="glRenderbufferStorageOES"/>
+                <command name="glGetRenderbufferParameterivOES"/>
+                <command name="glIsFramebufferOES"/>
+                <command name="glBindFramebufferOES"/>
+                <command name="glDeleteFramebuffersOES"/>
+                <command name="glGenFramebuffersOES"/>
+                <command name="glCheckFramebufferStatusOES"/>
+                <command name="glFramebufferRenderbufferOES"/>
+                <command name="glFramebufferTexture2DOES"/>
+                <command name="glGetFramebufferAttachmentParameterivOES"/>
+                <command name="glGenerateMipmapOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_get_program_binary" supported="gles2">
+            <require>
+                <enum name="GL_PROGRAM_BINARY_LENGTH_OES"/>
+                <enum name="GL_NUM_PROGRAM_BINARY_FORMATS_OES"/>
+                <enum name="GL_PROGRAM_BINARY_FORMATS_OES"/>
+                <command name="glGetProgramBinaryOES"/>
+                <command name="glProgramBinaryOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_mapbuffer" supported="gles1|gles2">
+            <require>
+                <enum name="GL_WRITE_ONLY_OES"/>
+                <enum name="GL_BUFFER_ACCESS_OES"/>
+                <enum name="GL_BUFFER_MAPPED_OES"/>
+                <enum name="GL_BUFFER_MAP_POINTER_OES"/>
+                <command name="glMapBufferOES"/>
+                <command name="glUnmapBufferOES"/>
+                <command name="glGetBufferPointervOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_matrix_get" supported="gles1">
+            <require>
+                <enum name="GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES"/>
+                <enum name="GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES"/>
+                <enum name="GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_matrix_palette" supported="gles1">
+            <require>
+                <enum name="GL_MAX_VERTEX_UNITS_OES"/>
+                <enum name="GL_MAX_PALETTE_MATRICES_OES"/>
+                <enum name="GL_MATRIX_PALETTE_OES"/>
+                <enum name="GL_MATRIX_INDEX_ARRAY_OES"/>
+                <enum name="GL_WEIGHT_ARRAY_OES"/>
+                <enum name="GL_CURRENT_PALETTE_MATRIX_OES"/>
+                <enum name="GL_MATRIX_INDEX_ARRAY_SIZE_OES"/>
+                <enum name="GL_MATRIX_INDEX_ARRAY_TYPE_OES"/>
+                <enum name="GL_MATRIX_INDEX_ARRAY_STRIDE_OES"/>
+                <enum name="GL_MATRIX_INDEX_ARRAY_POINTER_OES"/>
+                <enum name="GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES"/>
+                <enum name="GL_WEIGHT_ARRAY_SIZE_OES"/>
+                <enum name="GL_WEIGHT_ARRAY_TYPE_OES"/>
+                <enum name="GL_WEIGHT_ARRAY_STRIDE_OES"/>
+                <enum name="GL_WEIGHT_ARRAY_POINTER_OES"/>
+                <enum name="GL_WEIGHT_ARRAY_BUFFER_BINDING_OES"/>
+                <command name="glCurrentPaletteMatrixOES"/>
+                <command name="glLoadPaletteFromModelViewMatrixOES"/>
+                <command name="glMatrixIndexPointerOES"/>
+                <command name="glWeightPointerOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_packed_depth_stencil" supported="gles1|gles2">
+            <require>
+                <enum name="GL_DEPTH_STENCIL_OES"/>
+                <enum name="GL_UNSIGNED_INT_24_8_OES"/>
+                <enum name="GL_DEPTH24_STENCIL8_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_point_size_array" supported="gles1">
+            <require>
+                <enum name="GL_POINT_SIZE_ARRAY_OES"/>
+                <enum name="GL_POINT_SIZE_ARRAY_TYPE_OES"/>
+                <enum name="GL_POINT_SIZE_ARRAY_STRIDE_OES"/>
+                <enum name="GL_POINT_SIZE_ARRAY_POINTER_OES"/>
+                <enum name="GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES"/>
+                <command name="glPointSizePointerOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_point_sprite" supported="gles1">
+            <require>
+                <enum name="GL_POINT_SPRITE_OES"/>
+                <enum name="GL_COORD_REPLACE_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_query_matrix" supported="gl|gles1">
+            <require>
+                <command name="glQueryMatrixxOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_read_format" supported="gl|gles1">
+            <require>
+                <enum name="GL_IMPLEMENTATION_COLOR_READ_TYPE_OES"/>
+                <enum name="GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_required_internalformat" supported="gles1|gles2">
+            <require>
+                <enum name="GL_ALPHA8_OES"/>
+                <enum name="GL_DEPTH_COMPONENT16_OES"/>
+                <enum name="GL_DEPTH_COMPONENT24_OES"/>
+                <enum name="GL_DEPTH24_STENCIL8_OES"/>
+                <enum name="GL_DEPTH_COMPONENT32_OES"/>
+                <enum name="GL_LUMINANCE4_ALPHA4_OES"/>
+                <enum name="GL_LUMINANCE8_ALPHA8_OES"/>
+                <enum name="GL_LUMINANCE8_OES"/>
+                <enum name="GL_RGBA4_OES"/>
+                <enum name="GL_RGB5_A1_OES"/>
+                <enum name="GL_RGB565_OES"/>
+                <enum name="GL_RGB8_OES"/>
+                <enum name="GL_RGBA8_OES"/>
+                <enum name="GL_RGB10_EXT"/>
+                <enum name="GL_RGB10_A2_EXT"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_rgb8_rgba8" supported="gles1|gles2">
+            <require>
+                <enum name="GL_RGB8_OES"/>
+                <enum name="GL_RGBA8_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_sample_shading" supported="gles2">
+            <require>
+                <command name="glMinSampleShadingOES"/>                                     
+                <enum name="GL_SAMPLE_SHADING_OES"/>                                        
+                <enum name="GL_MIN_SAMPLE_SHADING_VALUE_OES"/>                              
+            </require>
+        </extension>
+        <extension name="GL_OES_sample_variables" supported="gles2"/>
+        <extension name="GL_OES_shader_image_atomic" supported="gles2"/>
+        <extension name="GL_OES_shader_multisample_interpolation" supported="gles2">
+            <require>
+                <enum name="GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES"/>                     
+                <enum name="GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES"/>                     
+                <enum name="GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES"/>                    
+            </require>
+        </extension>
+        <extension name="GL_OES_single_precision" supported="gl|gles1">
+            <require>
+                <command name="glClearDepthfOES"/>
+                <command name="glClipPlanefOES"/>
+                <command name="glDepthRangefOES"/>
+                <command name="glFrustumfOES"/>
+                <command name="glGetClipPlanefOES"/>
+                <command name="glOrthofOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_standard_derivatives" supported="gles2">
+            <require>
+                <enum name="GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_stencil1" supported="gles1|gles2">
+            <require>
+                <enum name="GL_STENCIL_INDEX1_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_stencil4" supported="gles1|gles2">
+            <require>
+                <enum name="GL_STENCIL_INDEX4_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_stencil8" supported="gles1">
+            <require>
+                <enum name="GL_STENCIL_INDEX8_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_stencil_wrap" supported="gles1">
+            <require>
+                <enum name="GL_INCR_WRAP_OES"/>
+                <enum name="GL_DECR_WRAP_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_surfaceless_context" supported="gles2">
+            <require>
+                <enum name="GL_FRAMEBUFFER_UNDEFINED_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_texture_3D" supported="gles2">
+            <require>
+                <enum name="GL_TEXTURE_WRAP_R_OES"/>
+                <enum name="GL_TEXTURE_3D_OES"/>
+                <enum name="GL_TEXTURE_BINDING_3D_OES"/>
+                <enum name="GL_MAX_3D_TEXTURE_SIZE_OES"/>
+                <enum name="GL_SAMPLER_3D_OES"/>
+                <enum name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES"/>
+                <command name="glTexImage3DOES"/>
+                <command name="glTexSubImage3DOES"/>
+                <command name="glCopyTexSubImage3DOES"/>
+                <command name="glCompressedTexImage3DOES"/>
+                <command name="glCompressedTexSubImage3DOES"/>
+                <command name="glFramebufferTexture3DOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_texture_compression_astc" supported="gles2" comment="API is identical to GL_KHR_texture_compression_astc_hdr extension">
+            <require>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_4x4_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_5x4_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_5x5_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_6x5_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_6x6_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_8x5_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_8x6_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_8x8_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_10x5_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_10x6_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_10x8_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_10x10_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_12x10_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_12x12_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_3x3x3_OES"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_4x3x3_OES"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_4x4x3_OES"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_4x4x4_OES"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_5x4x4_OES"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_5x5x4_OES"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_5x5x5_OES"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_6x5x5_OES"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_6x6x5_OES"/>
+                <enum name="GL_COMPRESSED_RGBA_ASTC_6x6x6_OES"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES"/>
+                <enum name="GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_texture_cube_map" supported="gles1">
+            <require>
+                <enum name="GL_NORMAL_MAP_OES"/>
+                <enum name="GL_REFLECTION_MAP_OES"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_OES"/>
+                <enum name="GL_TEXTURE_BINDING_CUBE_MAP_OES"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES"/>
+                <enum name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES"/>
+                <enum name="GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES"/>
+                <enum name="GL_TEXTURE_GEN_MODE_OES"/>
+                <enum name="GL_TEXTURE_GEN_STR_OES"/>
+                <command name="glTexGenfOES"/>
+                <command name="glTexGenfvOES"/>
+                <command name="glTexGeniOES"/>
+                <command name="glTexGenivOES"/>
+                <command name="glTexGenxOES"/>
+                <command name="glTexGenxvOES"/>
+                <command name="glGetTexGenfvOES"/>
+                <command name="glGetTexGenivOES"/>
+                <command name="glGetTexGenxvOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_texture_env_crossbar" supported="gles1"/>
+        <extension name="GL_OES_texture_float" supported="gles2">
+            <require>
+                <enum name="GL_FLOAT"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_texture_float_linear" supported="gles2"/>
+        <extension name="GL_OES_texture_half_float" supported="gles2">
+            <require>
+                <enum name="GL_HALF_FLOAT_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_texture_half_float_linear" supported="gles2"/>
+        <extension name="GL_OES_texture_mirrored_repeat" supported="gles1">
+            <require>
+                <enum name="GL_MIRRORED_REPEAT_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_texture_npot" supported="gles2"/>
+        <extension name="GL_OES_texture_stencil8" supported="gles2">
+            <require>
+                <enum name="GL_STENCIL_INDEX_OES"/>                                         
+                <enum name="GL_STENCIL_INDEX8_OES"/>                                        
+            </require>
+        </extension>
+        <extension name="GL_OES_texture_storage_multisample_2d_array" supported="gles2">
+            <require>
+                <command name="glTexStorage3DMultisampleOES"/>
+                <enum name="GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES"/>
+                <enum name="GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES"/>
+                <enum name="GL_SAMPLER_2D_MULTISAMPLE_ARRAY_OES"/>
+                <enum name="GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES"/>
+                <enum name="GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_vertex_array_object" supported="gles1|gles2">
+            <require>
+                <enum name="GL_VERTEX_ARRAY_BINDING_OES"/>
+                <command name="glBindVertexArrayOES"/>
+                <command name="glDeleteVertexArraysOES"/>
+                <command name="glGenVertexArraysOES"/>
+                <command name="glIsVertexArrayOES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_vertex_half_float" supported="gles2">
+            <require>
+                <enum name="GL_HALF_FLOAT_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OES_vertex_type_10_10_10_2" supported="gles2">
+            <require>
+                <enum name="GL_UNSIGNED_INT_10_10_10_2_OES"/>
+                <enum name="GL_INT_10_10_10_2_OES"/>
+            </require>
+        </extension>
+        <extension name="GL_OML_interlace" supported="gl">
+            <require>
+                <enum name="GL_INTERLACE_OML"/>
+                <enum name="GL_INTERLACE_READ_OML"/>
+            </require>
+        </extension>
+        <extension name="GL_OML_resample" supported="gl">
+            <require>
+                <enum name="GL_PACK_RESAMPLE_OML"/>
+                <enum name="GL_UNPACK_RESAMPLE_OML"/>
+                <enum name="GL_RESAMPLE_REPLICATE_OML"/>
+                <enum name="GL_RESAMPLE_ZERO_FILL_OML"/>
+                <enum name="GL_RESAMPLE_AVERAGE_OML"/>
+                <enum name="GL_RESAMPLE_DECIMATE_OML"/>
+            </require>
+        </extension>
+        <extension name="GL_OML_subsample" supported="gl">
+            <require>
+                <enum name="GL_FORMAT_SUBSAMPLE_24_24_OML"/>
+                <enum name="GL_FORMAT_SUBSAMPLE_244_244_OML"/>
+            </require>
+        </extension>
+        <extension name="GL_PGI_misc_hints" supported="gl">
+            <require>
+                <enum name="GL_PREFER_DOUBLEBUFFER_HINT_PGI"/>
+                <enum name="GL_CONSERVE_MEMORY_HINT_PGI"/>
+                <enum name="GL_RECLAIM_MEMORY_HINT_PGI"/>
+                <enum name="GL_NATIVE_GRAPHICS_HANDLE_PGI"/>
+                <enum name="GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI"/>
+                <enum name="GL_NATIVE_GRAPHICS_END_HINT_PGI"/>
+                <enum name="GL_ALWAYS_FAST_HINT_PGI"/>
+                <enum name="GL_ALWAYS_SOFT_HINT_PGI"/>
+                <enum name="GL_ALLOW_DRAW_OBJ_HINT_PGI"/>
+                <enum name="GL_ALLOW_DRAW_WIN_HINT_PGI"/>
+                <enum name="GL_ALLOW_DRAW_FRG_HINT_PGI"/>
+                <enum name="GL_ALLOW_DRAW_MEM_HINT_PGI"/>
+                <enum name="GL_STRICT_DEPTHFUNC_HINT_PGI"/>
+                <enum name="GL_STRICT_LIGHTING_HINT_PGI"/>
+                <enum name="GL_STRICT_SCISSOR_HINT_PGI"/>
+                <enum name="GL_FULL_STIPPLE_HINT_PGI"/>
+                <enum name="GL_CLIP_NEAR_HINT_PGI"/>
+                <enum name="GL_CLIP_FAR_HINT_PGI"/>
+                <enum name="GL_WIDE_LINE_HINT_PGI"/>
+                <enum name="GL_BACK_NORMALS_HINT_PGI"/>
+                <command name="glHintPGI"/>
+            </require>
+        </extension>
+        <extension name="GL_PGI_vertex_hints" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_DATA_HINT_PGI"/>
+                <enum name="GL_VERTEX_CONSISTENT_HINT_PGI"/>
+                <enum name="GL_MATERIAL_SIDE_HINT_PGI"/>
+                <enum name="GL_MAX_VERTEX_HINT_PGI"/>
+                <enum name="GL_COLOR3_BIT_PGI"/>
+                <enum name="GL_COLOR4_BIT_PGI"/>
+                <enum name="GL_EDGEFLAG_BIT_PGI"/>
+                <enum name="GL_INDEX_BIT_PGI"/>
+                <enum name="GL_MAT_AMBIENT_BIT_PGI"/>
+                <enum name="GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI"/>
+                <enum name="GL_MAT_DIFFUSE_BIT_PGI"/>
+                <enum name="GL_MAT_EMISSION_BIT_PGI"/>
+                <enum name="GL_MAT_COLOR_INDEXES_BIT_PGI"/>
+                <enum name="GL_MAT_SHININESS_BIT_PGI"/>
+                <enum name="GL_MAT_SPECULAR_BIT_PGI"/>
+                <enum name="GL_NORMAL_BIT_PGI"/>
+                <enum name="GL_TEXCOORD1_BIT_PGI"/>
+                <enum name="GL_TEXCOORD2_BIT_PGI"/>
+                <enum name="GL_TEXCOORD3_BIT_PGI"/>
+                <enum name="GL_TEXCOORD4_BIT_PGI"/>
+                <enum name="GL_VERTEX23_BIT_PGI"/>
+                <enum name="GL_VERTEX4_BIT_PGI"/>
+            </require>
+        </extension>
+        <extension name="GL_QCOM_alpha_test" supported="gles2">
+            <require>
+                <enum name="GL_ALPHA_TEST_QCOM"/>
+                <enum name="GL_ALPHA_TEST_FUNC_QCOM"/>
+                <enum name="GL_ALPHA_TEST_REF_QCOM"/>
+                <command name="glAlphaFuncQCOM"/>
+            </require>
+        </extension>
+        <extension name="GL_QCOM_binning_control" supported="gles2">
+            <require>
+                <enum name="GL_BINNING_CONTROL_HINT_QCOM"/>
+                <enum name="GL_CPU_OPTIMIZED_QCOM"/>
+                <enum name="GL_GPU_OPTIMIZED_QCOM"/>
+                <enum name="GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM"/>
+            </require>
+        </extension>
+        <extension name="GL_QCOM_driver_control" supported="gles1|gles2">
+            <require>
+                <command name="glGetDriverControlsQCOM"/>
+                <command name="glGetDriverControlStringQCOM"/>
+                <command name="glEnableDriverControlQCOM"/>
+                <command name="glDisableDriverControlQCOM"/>
+            </require>
+        </extension>
+        <extension name="GL_QCOM_extended_get" supported="gles1|gles2">
+            <require>
+                <enum name="GL_TEXTURE_WIDTH_QCOM"/>
+                <enum name="GL_TEXTURE_HEIGHT_QCOM"/>
+                <enum name="GL_TEXTURE_DEPTH_QCOM"/>
+                <enum name="GL_TEXTURE_INTERNAL_FORMAT_QCOM"/>
+                <enum name="GL_TEXTURE_FORMAT_QCOM"/>
+                <enum name="GL_TEXTURE_TYPE_QCOM"/>
+                <enum name="GL_TEXTURE_IMAGE_VALID_QCOM"/>
+                <enum name="GL_TEXTURE_NUM_LEVELS_QCOM"/>
+                <enum name="GL_TEXTURE_TARGET_QCOM"/>
+                <enum name="GL_TEXTURE_OBJECT_VALID_QCOM"/>
+                <enum name="GL_STATE_RESTORE"/>
+                <command name="glExtGetTexturesQCOM"/>
+                <command name="glExtGetBuffersQCOM"/>
+                <command name="glExtGetRenderbuffersQCOM"/>
+                <command name="glExtGetFramebuffersQCOM"/>
+                <command name="glExtGetTexLevelParameterivQCOM"/>
+                <command name="glExtTexObjectStateOverrideiQCOM"/>
+                <command name="glExtGetTexSubImageQCOM"/>
+                <command name="glExtGetBufferPointervQCOM"/>
+            </require>
+        </extension>
+        <extension name="GL_QCOM_extended_get2" supported="gles1|gles2">
+            <require>
+                <command name="glExtGetShadersQCOM"/>
+                <command name="glExtGetProgramsQCOM"/>
+                <command name="glExtIsProgramBinaryQCOM"/>
+                <command name="glExtGetProgramBinarySourceQCOM"/>
+            </require>
+        </extension>
+        <extension name="GL_QCOM_perfmon_global_mode" supported="gles1|gles2">
+            <require>
+                <enum name="GL_PERFMON_GLOBAL_MODE_QCOM"/>
+            </require>
+        </extension>
+        <extension name="GL_QCOM_tiled_rendering" supported="gles1|gles2">
+            <require>
+                <enum name="GL_COLOR_BUFFER_BIT0_QCOM"/>
+                <enum name="GL_COLOR_BUFFER_BIT1_QCOM"/>
+                <enum name="GL_COLOR_BUFFER_BIT2_QCOM"/>
+                <enum name="GL_COLOR_BUFFER_BIT3_QCOM"/>
+                <enum name="GL_COLOR_BUFFER_BIT4_QCOM"/>
+                <enum name="GL_COLOR_BUFFER_BIT5_QCOM"/>
+                <enum name="GL_COLOR_BUFFER_BIT6_QCOM"/>
+                <enum name="GL_COLOR_BUFFER_BIT7_QCOM"/>
+                <enum name="GL_DEPTH_BUFFER_BIT0_QCOM"/>
+                <enum name="GL_DEPTH_BUFFER_BIT1_QCOM"/>
+                <enum name="GL_DEPTH_BUFFER_BIT2_QCOM"/>
+                <enum name="GL_DEPTH_BUFFER_BIT3_QCOM"/>
+                <enum name="GL_DEPTH_BUFFER_BIT4_QCOM"/>
+                <enum name="GL_DEPTH_BUFFER_BIT5_QCOM"/>
+                <enum name="GL_DEPTH_BUFFER_BIT6_QCOM"/>
+                <enum name="GL_DEPTH_BUFFER_BIT7_QCOM"/>
+                <enum name="GL_STENCIL_BUFFER_BIT0_QCOM"/>
+                <enum name="GL_STENCIL_BUFFER_BIT1_QCOM"/>
+                <enum name="GL_STENCIL_BUFFER_BIT2_QCOM"/>
+                <enum name="GL_STENCIL_BUFFER_BIT3_QCOM"/>
+                <enum name="GL_STENCIL_BUFFER_BIT4_QCOM"/>
+                <enum name="GL_STENCIL_BUFFER_BIT5_QCOM"/>
+                <enum name="GL_STENCIL_BUFFER_BIT6_QCOM"/>
+                <enum name="GL_STENCIL_BUFFER_BIT7_QCOM"/>
+                <enum name="GL_MULTISAMPLE_BUFFER_BIT0_QCOM"/>
+                <enum name="GL_MULTISAMPLE_BUFFER_BIT1_QCOM"/>
+                <enum name="GL_MULTISAMPLE_BUFFER_BIT2_QCOM"/>
+                <enum name="GL_MULTISAMPLE_BUFFER_BIT3_QCOM"/>
+                <enum name="GL_MULTISAMPLE_BUFFER_BIT4_QCOM"/>
+                <enum name="GL_MULTISAMPLE_BUFFER_BIT5_QCOM"/>
+                <enum name="GL_MULTISAMPLE_BUFFER_BIT6_QCOM"/>
+                <enum name="GL_MULTISAMPLE_BUFFER_BIT7_QCOM"/>
+                <command name="glStartTilingQCOM"/>
+                <command name="glEndTilingQCOM"/>
+            </require>
+        </extension>
+        <extension name="GL_QCOM_writeonly_rendering" supported="gles1|gles2">
+            <require>
+                <enum name="GL_WRITEONLY_RENDERING_QCOM"/>
+            </require>
+        </extension>
+        <extension name="GL_REND_screen_coordinates" supported="gl">
+            <require>
+                <enum name="GL_SCREEN_COORDINATES_REND"/>
+                <enum name="GL_INVERTED_SCREEN_W_REND"/>
+            </require>
+        </extension>
+        <extension name="GL_S3_s3tc" supported="gl">
+            <require>
+                <enum name="GL_RGB_S3TC"/>
+                <enum name="GL_RGB4_S3TC"/>
+                <enum name="GL_RGBA_S3TC"/>
+                <enum name="GL_RGBA4_S3TC"/>
+                <enum name="GL_RGBA_DXT5_S3TC"/>
+                <enum name="GL_RGBA4_DXT5_S3TC"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIS_detail_texture" supported="gl">
+            <require>
+                <enum name="GL_DETAIL_TEXTURE_2D_SGIS"/>
+                <enum name="GL_DETAIL_TEXTURE_2D_BINDING_SGIS"/>
+                <enum name="GL_LINEAR_DETAIL_SGIS"/>
+                <enum name="GL_LINEAR_DETAIL_ALPHA_SGIS"/>
+                <enum name="GL_LINEAR_DETAIL_COLOR_SGIS"/>
+                <enum name="GL_DETAIL_TEXTURE_LEVEL_SGIS"/>
+                <enum name="GL_DETAIL_TEXTURE_MODE_SGIS"/>
+                <enum name="GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS"/>
+                <command name="glDetailTexFuncSGIS"/>
+                <command name="glGetDetailTexFuncSGIS"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIS_fog_function" supported="gl">
+            <require>
+                <enum name="GL_FOG_FUNC_SGIS"/>
+                <enum name="GL_FOG_FUNC_POINTS_SGIS"/>
+                <enum name="GL_MAX_FOG_FUNC_POINTS_SGIS"/>
+                <command name="glFogFuncSGIS"/>
+                <command name="glGetFogFuncSGIS"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIS_generate_mipmap" supported="gl">
+            <require>
+                <enum name="GL_GENERATE_MIPMAP_SGIS"/>
+                <enum name="GL_GENERATE_MIPMAP_HINT_SGIS"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIS_multisample" supported="gl">
+            <require>
+                <enum name="GL_MULTISAMPLE_SGIS"/>
+                <enum name="GL_SAMPLE_ALPHA_TO_MASK_SGIS"/>
+                <enum name="GL_SAMPLE_ALPHA_TO_ONE_SGIS"/>
+                <enum name="GL_SAMPLE_MASK_SGIS"/>
+                <enum name="GL_1PASS_SGIS"/>
+                <enum name="GL_2PASS_0_SGIS"/>
+                <enum name="GL_2PASS_1_SGIS"/>
+                <enum name="GL_4PASS_0_SGIS"/>
+                <enum name="GL_4PASS_1_SGIS"/>
+                <enum name="GL_4PASS_2_SGIS"/>
+                <enum name="GL_4PASS_3_SGIS"/>
+                <enum name="GL_SAMPLE_BUFFERS_SGIS"/>
+                <enum name="GL_SAMPLES_SGIS"/>
+                <enum name="GL_SAMPLE_MASK_VALUE_SGIS"/>
+                <enum name="GL_SAMPLE_MASK_INVERT_SGIS"/>
+                <enum name="GL_SAMPLE_PATTERN_SGIS"/>
+                <command name="glSampleMaskSGIS"/>
+                <command name="glSamplePatternSGIS"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIS_pixel_texture" supported="gl">
+            <require>
+                <enum name="GL_PIXEL_TEXTURE_SGIS"/>
+                <enum name="GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS"/>
+                <enum name="GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS"/>
+                <enum name="GL_PIXEL_GROUP_COLOR_SGIS"/>
+                <command name="glPixelTexGenParameteriSGIS"/>
+                <command name="glPixelTexGenParameterivSGIS"/>
+                <command name="glPixelTexGenParameterfSGIS"/>
+                <command name="glPixelTexGenParameterfvSGIS"/>
+                <command name="glGetPixelTexGenParameterivSGIS"/>
+                <command name="glGetPixelTexGenParameterfvSGIS"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIS_point_line_texgen" supported="gl">
+            <require>
+                <enum name="GL_EYE_DISTANCE_TO_POINT_SGIS"/>
+                <enum name="GL_OBJECT_DISTANCE_TO_POINT_SGIS"/>
+                <enum name="GL_EYE_DISTANCE_TO_LINE_SGIS"/>
+                <enum name="GL_OBJECT_DISTANCE_TO_LINE_SGIS"/>
+                <enum name="GL_EYE_POINT_SGIS"/>
+                <enum name="GL_OBJECT_POINT_SGIS"/>
+                <enum name="GL_EYE_LINE_SGIS"/>
+                <enum name="GL_OBJECT_LINE_SGIS"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIS_point_parameters" supported="gl">
+            <require>
+                <enum name="GL_POINT_SIZE_MIN_SGIS"/>
+                <enum name="GL_POINT_SIZE_MAX_SGIS"/>
+                <enum name="GL_POINT_FADE_THRESHOLD_SIZE_SGIS"/>
+                <enum name="GL_DISTANCE_ATTENUATION_SGIS"/>
+                <command name="glPointParameterfSGIS"/>
+                <command name="glPointParameterfvSGIS"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIS_sharpen_texture" supported="gl">
+            <require>
+                <enum name="GL_LINEAR_SHARPEN_SGIS"/>
+                <enum name="GL_LINEAR_SHARPEN_ALPHA_SGIS"/>
+                <enum name="GL_LINEAR_SHARPEN_COLOR_SGIS"/>
+                <enum name="GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS"/>
+                <command name="glSharpenTexFuncSGIS"/>
+                <command name="glGetSharpenTexFuncSGIS"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIS_texture4D" supported="gl">
+            <require>
+                <enum name="GL_PACK_SKIP_VOLUMES_SGIS"/>
+                <enum name="GL_PACK_IMAGE_DEPTH_SGIS"/>
+                <enum name="GL_UNPACK_SKIP_VOLUMES_SGIS"/>
+                <enum name="GL_UNPACK_IMAGE_DEPTH_SGIS"/>
+                <enum name="GL_TEXTURE_4D_SGIS"/>
+                <enum name="GL_PROXY_TEXTURE_4D_SGIS"/>
+                <enum name="GL_TEXTURE_4DSIZE_SGIS"/>
+                <enum name="GL_TEXTURE_WRAP_Q_SGIS"/>
+                <enum name="GL_MAX_4D_TEXTURE_SIZE_SGIS"/>
+                <enum name="GL_TEXTURE_4D_BINDING_SGIS"/>
+                <command name="glTexImage4DSGIS"/>
+                <command name="glTexSubImage4DSGIS"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIS_texture_border_clamp" supported="gl">
+            <require>
+                <enum name="GL_CLAMP_TO_BORDER_SGIS"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIS_texture_color_mask" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_COLOR_WRITEMASK_SGIS"/>
+                <command name="glTextureColorMaskSGIS"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIS_texture_edge_clamp" supported="gl">
+            <require>
+                <enum name="GL_CLAMP_TO_EDGE_SGIS"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIS_texture_filter4" supported="gl">
+            <require>
+                <enum name="GL_FILTER4_SGIS"/>
+                <enum name="GL_TEXTURE_FILTER4_SIZE_SGIS"/>
+                <command name="glGetTexFilterFuncSGIS"/>
+                <command name="glTexFilterFuncSGIS"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIS_texture_lod" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_MIN_LOD_SGIS"/>
+                <enum name="GL_TEXTURE_MAX_LOD_SGIS"/>
+                <enum name="GL_TEXTURE_BASE_LEVEL_SGIS"/>
+                <enum name="GL_TEXTURE_MAX_LEVEL_SGIS"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIS_texture_select" supported="gl">
+            <require>
+                <enum name="GL_DUAL_ALPHA4_SGIS"/>
+                <enum name="GL_DUAL_ALPHA8_SGIS"/>
+                <enum name="GL_DUAL_ALPHA12_SGIS"/>
+                <enum name="GL_DUAL_ALPHA16_SGIS"/>
+                <enum name="GL_DUAL_LUMINANCE4_SGIS"/>
+                <enum name="GL_DUAL_LUMINANCE8_SGIS"/>
+                <enum name="GL_DUAL_LUMINANCE12_SGIS"/>
+                <enum name="GL_DUAL_LUMINANCE16_SGIS"/>
+                <enum name="GL_DUAL_INTENSITY4_SGIS"/>
+                <enum name="GL_DUAL_INTENSITY8_SGIS"/>
+                <enum name="GL_DUAL_INTENSITY12_SGIS"/>
+                <enum name="GL_DUAL_INTENSITY16_SGIS"/>
+                <enum name="GL_DUAL_LUMINANCE_ALPHA4_SGIS"/>
+                <enum name="GL_DUAL_LUMINANCE_ALPHA8_SGIS"/>
+                <enum name="GL_QUAD_ALPHA4_SGIS"/>
+                <enum name="GL_QUAD_ALPHA8_SGIS"/>
+                <enum name="GL_QUAD_LUMINANCE4_SGIS"/>
+                <enum name="GL_QUAD_LUMINANCE8_SGIS"/>
+                <enum name="GL_QUAD_INTENSITY4_SGIS"/>
+                <enum name="GL_QUAD_INTENSITY8_SGIS"/>
+                <enum name="GL_DUAL_TEXTURE_SELECT_SGIS"/>
+                <enum name="GL_QUAD_TEXTURE_SELECT_SGIS"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_async" supported="gl">
+            <require>
+                <enum name="GL_ASYNC_MARKER_SGIX"/>
+                <command name="glAsyncMarkerSGIX"/>
+                <command name="glFinishAsyncSGIX"/>
+                <command name="glPollAsyncSGIX"/>
+                <command name="glGenAsyncMarkersSGIX"/>
+                <command name="glDeleteAsyncMarkersSGIX"/>
+                <command name="glIsAsyncMarkerSGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_async_histogram" supported="gl">
+            <require>
+                <enum name="GL_ASYNC_HISTOGRAM_SGIX"/>
+                <enum name="GL_MAX_ASYNC_HISTOGRAM_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_async_pixel" supported="gl">
+            <require>
+                <enum name="GL_ASYNC_TEX_IMAGE_SGIX"/>
+                <enum name="GL_ASYNC_DRAW_PIXELS_SGIX"/>
+                <enum name="GL_ASYNC_READ_PIXELS_SGIX"/>
+                <enum name="GL_MAX_ASYNC_TEX_IMAGE_SGIX"/>
+                <enum name="GL_MAX_ASYNC_DRAW_PIXELS_SGIX"/>
+                <enum name="GL_MAX_ASYNC_READ_PIXELS_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_blend_alpha_minmax" supported="gl">
+            <require>
+                <enum name="GL_ALPHA_MIN_SGIX"/>
+                <enum name="GL_ALPHA_MAX_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_calligraphic_fragment" supported="gl">
+            <require>
+                <enum name="GL_CALLIGRAPHIC_FRAGMENT_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_clipmap" supported="gl">
+            <require>
+                <enum name="GL_LINEAR_CLIPMAP_LINEAR_SGIX"/>
+                <enum name="GL_TEXTURE_CLIPMAP_CENTER_SGIX"/>
+                <enum name="GL_TEXTURE_CLIPMAP_FRAME_SGIX"/>
+                <enum name="GL_TEXTURE_CLIPMAP_OFFSET_SGIX"/>
+                <enum name="GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX"/>
+                <enum name="GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX"/>
+                <enum name="GL_TEXTURE_CLIPMAP_DEPTH_SGIX"/>
+                <enum name="GL_MAX_CLIPMAP_DEPTH_SGIX"/>
+                <enum name="GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX"/>
+                <enum name="GL_NEAREST_CLIPMAP_NEAREST_SGIX"/>
+                <enum name="GL_NEAREST_CLIPMAP_LINEAR_SGIX"/>
+                <enum name="GL_LINEAR_CLIPMAP_NEAREST_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_convolution_accuracy" supported="gl">
+            <require>
+                <enum name="GL_CONVOLUTION_HINT_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_depth_pass_instrument" supported="gl"/>
+        <extension name="GL_SGIX_depth_texture" supported="gl">
+            <require>
+                <enum name="GL_DEPTH_COMPONENT16_SGIX"/>
+                <enum name="GL_DEPTH_COMPONENT24_SGIX"/>
+                <enum name="GL_DEPTH_COMPONENT32_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_flush_raster" supported="gl">
+            <require>
+                <command name="glFlushRasterSGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_fog_offset" supported="gl">
+            <require>
+                <enum name="GL_FOG_OFFSET_SGIX"/>
+                <enum name="GL_FOG_OFFSET_VALUE_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_fragment_lighting" supported="gl" comment="Incomplete extension">
+            <require>
+                <enum name="GL_FRAGMENT_LIGHTING_SGIX"/>
+                <enum name="GL_FRAGMENT_COLOR_MATERIAL_SGIX"/>
+                <enum name="GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX"/>
+                <enum name="GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX"/>
+                <enum name="GL_MAX_FRAGMENT_LIGHTS_SGIX"/>
+                <enum name="GL_MAX_ACTIVE_LIGHTS_SGIX"/>
+                <enum name="GL_CURRENT_RASTER_NORMAL_SGIX"/>
+                <enum name="GL_LIGHT_ENV_MODE_SGIX"/>
+                <enum name="GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX"/>
+                <enum name="GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX"/>
+                <enum name="GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX"/>
+                <enum name="GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX"/>
+                <enum name="GL_FRAGMENT_LIGHT0_SGIX"/>
+                <enum name="GL_FRAGMENT_LIGHT1_SGIX"/>
+                <enum name="GL_FRAGMENT_LIGHT2_SGIX"/>
+                <enum name="GL_FRAGMENT_LIGHT3_SGIX"/>
+                <enum name="GL_FRAGMENT_LIGHT4_SGIX"/>
+                <enum name="GL_FRAGMENT_LIGHT5_SGIX"/>
+                <enum name="GL_FRAGMENT_LIGHT6_SGIX"/>
+                <enum name="GL_FRAGMENT_LIGHT7_SGIX"/>
+                <command name="glFragmentColorMaterialSGIX"/>
+                <command name="glFragmentLightfSGIX"/>
+                <command name="glFragmentLightfvSGIX"/>
+                <command name="glFragmentLightiSGIX"/>
+                <command name="glFragmentLightivSGIX"/>
+                <command name="glFragmentLightModelfSGIX"/>
+                <command name="glFragmentLightModelfvSGIX"/>
+                <command name="glFragmentLightModeliSGIX"/>
+                <command name="glFragmentLightModelivSGIX"/>
+                <command name="glFragmentMaterialfSGIX"/>
+                <command name="glFragmentMaterialfvSGIX"/>
+                <command name="glFragmentMaterialiSGIX"/>
+                <command name="glFragmentMaterialivSGIX"/>
+                <command name="glGetFragmentLightfvSGIX"/>
+                <command name="glGetFragmentLightivSGIX"/>
+                <command name="glGetFragmentMaterialfvSGIX"/>
+                <command name="glGetFragmentMaterialivSGIX"/>
+                <command name="glLightEnviSGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_framezoom" supported="gl">
+            <require>
+                <enum name="GL_FRAMEZOOM_SGIX"/>
+                <enum name="GL_FRAMEZOOM_FACTOR_SGIX"/>
+                <enum name="GL_MAX_FRAMEZOOM_FACTOR_SGIX"/>
+                <command name="glFrameZoomSGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_igloo_interface" supported="gl">
+            <require>
+                <command name="glIglooInterfaceSGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_instruments" supported="gl">
+            <require>
+                <enum name="GL_INSTRUMENT_BUFFER_POINTER_SGIX"/>
+                <enum name="GL_INSTRUMENT_MEASUREMENTS_SGIX"/>
+                <command name="glGetInstrumentsSGIX"/>
+                <command name="glInstrumentsBufferSGIX"/>
+                <command name="glPollInstrumentsSGIX"/>
+                <command name="glReadInstrumentsSGIX"/>
+                <command name="glStartInstrumentsSGIX"/>
+                <command name="glStopInstrumentsSGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_interlace" supported="gl">
+            <require>
+                <enum name="GL_INTERLACE_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_ir_instrument1" supported="gl">
+            <require>
+                <enum name="GL_IR_INSTRUMENT1_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_list_priority" supported="gl">
+            <require>
+                <enum name="GL_LIST_PRIORITY_SGIX"/>
+                <command name="glGetListParameterfvSGIX"/>
+                <command name="glGetListParameterivSGIX"/>
+                <command name="glListParameterfSGIX"/>
+                <command name="glListParameterfvSGIX"/>
+                <command name="glListParameteriSGIX"/>
+                <command name="glListParameterivSGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_pixel_texture" supported="gl">
+            <require>
+                <enum name="GL_PIXEL_TEX_GEN_SGIX"/>
+                <enum name="GL_PIXEL_TEX_GEN_MODE_SGIX"/>
+                <command name="glPixelTexGenSGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_pixel_tiles" supported="gl">
+            <require>
+                <enum name="GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX"/>
+                <enum name="GL_PIXEL_TILE_CACHE_INCREMENT_SGIX"/>
+                <enum name="GL_PIXEL_TILE_WIDTH_SGIX"/>
+                <enum name="GL_PIXEL_TILE_HEIGHT_SGIX"/>
+                <enum name="GL_PIXEL_TILE_GRID_WIDTH_SGIX"/>
+                <enum name="GL_PIXEL_TILE_GRID_HEIGHT_SGIX"/>
+                <enum name="GL_PIXEL_TILE_GRID_DEPTH_SGIX"/>
+                <enum name="GL_PIXEL_TILE_CACHE_SIZE_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_polynomial_ffd" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_DEFORMATION_BIT_SGIX"/>
+                <enum name="GL_GEOMETRY_DEFORMATION_BIT_SGIX"/>
+                <enum name="GL_GEOMETRY_DEFORMATION_SGIX"/>
+                <enum name="GL_TEXTURE_DEFORMATION_SGIX"/>
+                <enum name="GL_DEFORMATIONS_MASK_SGIX"/>
+                <enum name="GL_MAX_DEFORMATION_ORDER_SGIX"/>
+                <command name="glDeformationMap3dSGIX"/>
+                <command name="glDeformationMap3fSGIX"/>
+                <command name="glDeformSGIX"/>
+                <command name="glLoadIdentityDeformationMapSGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_reference_plane" supported="gl">
+            <require>
+                <enum name="GL_REFERENCE_PLANE_SGIX"/>
+                <enum name="GL_REFERENCE_PLANE_EQUATION_SGIX"/>
+                <command name="glReferencePlaneSGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_resample" supported="gl">
+            <require>
+                <enum name="GL_PACK_RESAMPLE_SGIX"/>
+                <enum name="GL_UNPACK_RESAMPLE_SGIX"/>
+                <enum name="GL_RESAMPLE_REPLICATE_SGIX"/>
+                <enum name="GL_RESAMPLE_ZERO_FILL_SGIX"/>
+                <enum name="GL_RESAMPLE_DECIMATE_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_scalebias_hint" supported="gl">
+            <require>
+                <enum name="GL_SCALEBIAS_HINT_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_shadow" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_COMPARE_SGIX"/>
+                <enum name="GL_TEXTURE_COMPARE_OPERATOR_SGIX"/>
+                <enum name="GL_TEXTURE_LEQUAL_R_SGIX"/>
+                <enum name="GL_TEXTURE_GEQUAL_R_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_shadow_ambient" supported="gl">
+            <require>
+                <enum name="GL_SHADOW_AMBIENT_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_sprite" supported="gl">
+            <require>
+                <enum name="GL_SPRITE_SGIX"/>
+                <enum name="GL_SPRITE_MODE_SGIX"/>
+                <enum name="GL_SPRITE_AXIS_SGIX"/>
+                <enum name="GL_SPRITE_TRANSLATION_SGIX"/>
+                <enum name="GL_SPRITE_AXIAL_SGIX"/>
+                <enum name="GL_SPRITE_OBJECT_ALIGNED_SGIX"/>
+                <enum name="GL_SPRITE_EYE_ALIGNED_SGIX"/>
+                <command name="glSpriteParameterfSGIX"/>
+                <command name="glSpriteParameterfvSGIX"/>
+                <command name="glSpriteParameteriSGIX"/>
+                <command name="glSpriteParameterivSGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_subsample" supported="gl">
+            <require>
+                <enum name="GL_PACK_SUBSAMPLE_RATE_SGIX"/>
+                <enum name="GL_UNPACK_SUBSAMPLE_RATE_SGIX"/>
+                <enum name="GL_PIXEL_SUBSAMPLE_4444_SGIX"/>
+                <enum name="GL_PIXEL_SUBSAMPLE_2424_SGIX"/>
+                <enum name="GL_PIXEL_SUBSAMPLE_4242_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_tag_sample_buffer" supported="gl">
+            <require>
+                <command name="glTagSampleBufferSGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_texture_add_env" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_ENV_BIAS_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_texture_coordinate_clamp" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_MAX_CLAMP_S_SGIX"/>
+                <enum name="GL_TEXTURE_MAX_CLAMP_T_SGIX"/>
+                <enum name="GL_TEXTURE_MAX_CLAMP_R_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_texture_lod_bias" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_LOD_BIAS_S_SGIX"/>
+                <enum name="GL_TEXTURE_LOD_BIAS_T_SGIX"/>
+                <enum name="GL_TEXTURE_LOD_BIAS_R_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_texture_multi_buffer" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_MULTI_BUFFER_HINT_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_texture_scale_bias" supported="gl">
+            <require>
+                <enum name="GL_POST_TEXTURE_FILTER_BIAS_SGIX"/>
+                <enum name="GL_POST_TEXTURE_FILTER_SCALE_SGIX"/>
+                <enum name="GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX"/>
+                <enum name="GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_vertex_preclip" supported="gl">
+            <require>
+                <enum name="GL_VERTEX_PRECLIP_SGIX"/>
+                <enum name="GL_VERTEX_PRECLIP_HINT_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_ycrcb" supported="gl">
+            <require>
+                <enum name="GL_YCRCB_422_SGIX"/>
+                <enum name="GL_YCRCB_444_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGIX_ycrcb_subsample" supported="gl"/>
+        <extension name="GL_SGIX_ycrcba" supported="gl">
+            <require>
+                <enum name="GL_YCRCB_SGIX"/>
+                <enum name="GL_YCRCBA_SGIX"/>
+            </require>
+        </extension>
+        <extension name="GL_SGI_color_matrix" supported="gl">
+            <require>
+                <enum name="GL_COLOR_MATRIX_SGI"/>
+                <enum name="GL_COLOR_MATRIX_STACK_DEPTH_SGI"/>
+                <enum name="GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI"/>
+                <enum name="GL_POST_COLOR_MATRIX_RED_SCALE_SGI"/>
+                <enum name="GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI"/>
+                <enum name="GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI"/>
+                <enum name="GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI"/>
+                <enum name="GL_POST_COLOR_MATRIX_RED_BIAS_SGI"/>
+                <enum name="GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI"/>
+                <enum name="GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI"/>
+                <enum name="GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI"/>
+            </require>
+        </extension>
+        <extension name="GL_SGI_color_table" supported="gl">
+            <require>
+                <enum name="GL_COLOR_TABLE_SGI"/>
+                <enum name="GL_POST_CONVOLUTION_COLOR_TABLE_SGI"/>
+                <enum name="GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI"/>
+                <enum name="GL_PROXY_COLOR_TABLE_SGI"/>
+                <enum name="GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI"/>
+                <enum name="GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI"/>
+                <enum name="GL_COLOR_TABLE_SCALE_SGI"/>
+                <enum name="GL_COLOR_TABLE_BIAS_SGI"/>
+                <enum name="GL_COLOR_TABLE_FORMAT_SGI"/>
+                <enum name="GL_COLOR_TABLE_WIDTH_SGI"/>
+                <enum name="GL_COLOR_TABLE_RED_SIZE_SGI"/>
+                <enum name="GL_COLOR_TABLE_GREEN_SIZE_SGI"/>
+                <enum name="GL_COLOR_TABLE_BLUE_SIZE_SGI"/>
+                <enum name="GL_COLOR_TABLE_ALPHA_SIZE_SGI"/>
+                <enum name="GL_COLOR_TABLE_LUMINANCE_SIZE_SGI"/>
+                <enum name="GL_COLOR_TABLE_INTENSITY_SIZE_SGI"/>
+                <command name="glColorTableSGI"/>
+                <command name="glColorTableParameterfvSGI"/>
+                <command name="glColorTableParameterivSGI"/>
+                <command name="glCopyColorTableSGI"/>
+                <command name="glGetColorTableSGI"/>
+                <command name="glGetColorTableParameterfvSGI"/>
+                <command name="glGetColorTableParameterivSGI"/>
+            </require>
+        </extension>
+        <extension name="GL_SGI_texture_color_table" supported="gl">
+            <require>
+                <enum name="GL_TEXTURE_COLOR_TABLE_SGI"/>
+                <enum name="GL_PROXY_TEXTURE_COLOR_TABLE_SGI"/>
+            </require>
+        </extension>
+        <extension name="GL_SUNX_constant_data" supported="gl">
+            <require>
+                <enum name="GL_UNPACK_CONSTANT_DATA_SUNX"/>
+                <enum name="GL_TEXTURE_CONSTANT_DATA_SUNX"/>
+                <command name="glFinishTextureSUNX"/>
+            </require>
+        </extension>
+        <extension name="GL_SUN_convolution_border_modes" supported="gl">
+            <require>
+                <enum name="GL_WRAP_BORDER_SUN"/>
+            </require>
+        </extension>
+        <extension name="GL_SUN_global_alpha" supported="gl">
+            <require>
+                <enum name="GL_GLOBAL_ALPHA_SUN"/>
+                <enum name="GL_GLOBAL_ALPHA_FACTOR_SUN"/>
+                <command name="glGlobalAlphaFactorbSUN"/>
+                <command name="glGlobalAlphaFactorsSUN"/>
+                <command name="glGlobalAlphaFactoriSUN"/>
+                <command name="glGlobalAlphaFactorfSUN"/>
+                <command name="glGlobalAlphaFactordSUN"/>
+                <command name="glGlobalAlphaFactorubSUN"/>
+                <command name="glGlobalAlphaFactorusSUN"/>
+                <command name="glGlobalAlphaFactoruiSUN"/>
+            </require>
+        </extension>
+        <extension name="GL_SUN_mesh_array" supported="gl">
+            <require>
+                <enum name="GL_QUAD_MESH_SUN"/>
+                <enum name="GL_TRIANGLE_MESH_SUN"/>
+                <command name="glDrawMeshArraysSUN"/>
+            </require>
+        </extension>
+        <extension name="GL_SUN_slice_accum" supported="gl">
+            <require>
+                <enum name="GL_SLICE_ACCUM_SUN"/>
+            </require>
+        </extension>
+        <extension name="GL_SUN_triangle_list" supported="gl">
+            <require>
+                <enum name="GL_RESTART_SUN"/>
+                <enum name="GL_REPLACE_MIDDLE_SUN"/>
+                <enum name="GL_REPLACE_OLDEST_SUN"/>
+                <enum name="GL_TRIANGLE_LIST_SUN"/>
+                <enum name="GL_REPLACEMENT_CODE_SUN"/>
+                <enum name="GL_REPLACEMENT_CODE_ARRAY_SUN"/>
+                <enum name="GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN"/>
+                <enum name="GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN"/>
+                <enum name="GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN"/>
+                <enum name="GL_R1UI_V3F_SUN"/>
+                <enum name="GL_R1UI_C4UB_V3F_SUN"/>
+                <enum name="GL_R1UI_C3F_V3F_SUN"/>
+                <enum name="GL_R1UI_N3F_V3F_SUN"/>
+                <enum name="GL_R1UI_C4F_N3F_V3F_SUN"/>
+                <enum name="GL_R1UI_T2F_V3F_SUN"/>
+                <enum name="GL_R1UI_T2F_N3F_V3F_SUN"/>
+                <enum name="GL_R1UI_T2F_C4F_N3F_V3F_SUN"/>
+                <command name="glReplacementCodeuiSUN"/>
+                <command name="glReplacementCodeusSUN"/>
+                <command name="glReplacementCodeubSUN"/>
+                <command name="glReplacementCodeuivSUN"/>
+                <command name="glReplacementCodeusvSUN"/>
+                <command name="glReplacementCodeubvSUN"/>
+                <command name="glReplacementCodePointerSUN"/>
+            </require>
+        </extension>
+        <extension name="GL_SUN_vertex" supported="gl">
+            <require>
+                <command name="glColor4ubVertex2fSUN"/>
+                <command name="glColor4ubVertex2fvSUN"/>
+                <command name="glColor4ubVertex3fSUN"/>
+                <command name="glColor4ubVertex3fvSUN"/>
+                <command name="glColor3fVertex3fSUN"/>
+                <command name="glColor3fVertex3fvSUN"/>
+                <command name="glNormal3fVertex3fSUN"/>
+                <command name="glNormal3fVertex3fvSUN"/>
+                <command name="glColor4fNormal3fVertex3fSUN"/>
+                <command name="glColor4fNormal3fVertex3fvSUN"/>
+                <command name="glTexCoord2fVertex3fSUN"/>
+                <command name="glTexCoord2fVertex3fvSUN"/>
+                <command name="glTexCoord4fVertex4fSUN"/>
+                <command name="glTexCoord4fVertex4fvSUN"/>
+                <command name="glTexCoord2fColor4ubVertex3fSUN"/>
+                <command name="glTexCoord2fColor4ubVertex3fvSUN"/>
+                <command name="glTexCoord2fColor3fVertex3fSUN"/>
+                <command name="glTexCoord2fColor3fVertex3fvSUN"/>
+                <command name="glTexCoord2fNormal3fVertex3fSUN"/>
+                <command name="glTexCoord2fNormal3fVertex3fvSUN"/>
+                <command name="glTexCoord2fColor4fNormal3fVertex3fSUN"/>
+                <command name="glTexCoord2fColor4fNormal3fVertex3fvSUN"/>
+                <command name="glTexCoord4fColor4fNormal3fVertex4fSUN"/>
+                <command name="glTexCoord4fColor4fNormal3fVertex4fvSUN"/>
+                <command name="glReplacementCodeuiVertex3fSUN"/>
+                <command name="glReplacementCodeuiVertex3fvSUN"/>
+                <command name="glReplacementCodeuiColor4ubVertex3fSUN"/>
+                <command name="glReplacementCodeuiColor4ubVertex3fvSUN"/>
+                <command name="glReplacementCodeuiColor3fVertex3fSUN"/>
+                <command name="glReplacementCodeuiColor3fVertex3fvSUN"/>
+                <command name="glReplacementCodeuiNormal3fVertex3fSUN"/>
+                <command name="glReplacementCodeuiNormal3fVertex3fvSUN"/>
+                <command name="glReplacementCodeuiColor4fNormal3fVertex3fSUN"/>
+                <command name="glReplacementCodeuiColor4fNormal3fVertex3fvSUN"/>
+                <command name="glReplacementCodeuiTexCoord2fVertex3fSUN"/>
+                <command name="glReplacementCodeuiTexCoord2fVertex3fvSUN"/>
+                <command name="glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN"/>
+                <command name="glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN"/>
+                <command name="glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN"/>
+                <command name="glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN"/>
+            </require>
+        </extension>
+        <extension name="GL_VIV_shader_binary" supported="gles2">
+            <require>
+                <enum name="GL_SHADER_BINARY_VIV"/>
+            </require>
+        </extension>
+        <extension name="GL_WIN_phong_shading" supported="gl">
+            <require>
+                <enum name="GL_PHONG_WIN"/>
+                <enum name="GL_PHONG_HINT_WIN"/>
+            </require>
+        </extension>
+        <extension name="GL_WIN_specular_fog" supported="gl">
+            <require>
+                <enum name="GL_FOG_SPECULAR_TEXTURE_WIN"/>
+            </require>
+        </extension>
+    </extensions>
+</registry>
diff --git a/opengl/tools/glgen2/registry/reg.py b/opengl/tools/glgen2/registry/reg.py
new file mode 100755
index 0000000..1bbe0a0
--- /dev/null
+++ b/opengl/tools/glgen2/registry/reg.py
@@ -0,0 +1,1162 @@
+#!/usr/bin/python3 -i
+#
+# Copyright (c) 2013-2014 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.
+
+import io,os,re,string,sys
+from lxml import etree
+
+def write( *args, **kwargs ):
+    file = kwargs.pop('file',sys.stdout)
+    end = kwargs.pop( 'end','\n')
+    file.write( ' '.join([str(arg) for arg in args]) )
+    file.write( end )
+
+# noneStr - returns string argument, or "" if argument is None.
+# Used in converting lxml Elements into text.
+#   str - string to convert
+def noneStr(str):
+    if (str):
+        return str
+    else:
+        return ""
+
+# matchAPIProfile - returns whether an API and profile
+#   being generated matches an element's profile
+# api - string naming the API to match
+# profile - string naming the profile to match
+# elem - Element which (may) have 'api' and 'profile'
+#   attributes to match to.
+# If a tag is not present in the Element, the corresponding API
+#   or profile always matches.
+# Otherwise, the tag must exactly match the API or profile.
+# Thus, if 'profile' = core:
+#   <remove> with no attribute will match
+#   <remove profile='core'> will match
+#   <remove profile='compatibility'> will not match
+# Possible match conditions:
+#   Requested   Element
+#   Profile     Profile
+#   ---------   --------
+#   None        None        Always matches
+#   'string'    None        Always matches
+#   None        'string'    Does not match. Can't generate multiple APIs
+#                           or profiles, so if an API/profile constraint
+#                           is present, it must be asked for explicitly.
+#   'string'    'string'    Strings must match
+#
+#   ** In the future, we will allow regexes for the attributes,
+#   not just strings, so that api="^(gl|gles2)" will match. Even
+#   this isn't really quite enough, we might prefer something
+#   like "gl(core)|gles1(common-lite)".
+def matchAPIProfile(api, profile, elem):
+    """Match a requested API & profile name to a api & profile attributes of an Element"""
+    match = True
+    # Match 'api', if present
+    if ('api' in elem.attrib):
+        if (api == None):
+            raise UserWarning("No API requested, but 'api' attribute is present with value '" +
+                              elem.get('api') + "'")
+        elif (api != elem.get('api')):
+            # Requested API doesn't match attribute
+            return False
+    if ('profile' in elem.attrib):
+        if (profile == None):
+            raise UserWarning("No profile requested, but 'profile' attribute is present with value '" +
+                elem.get('profile') + "'")
+        elif (profile != elem.get('profile')):
+            # Requested profile doesn't match attribute
+            return False
+    return True
+
+# BaseInfo - base class for information about a registry feature
+# (type/group/enum/command/API/extension).
+#   required - should this feature be defined during header generation
+#     (has it been removed by a profile or version)?
+#   declared - has this feature been defined already?
+#   elem - lxml.etree Element for this feature
+#   resetState() - reset required/declared to initial values. Used
+#     prior to generating a new API interface.
+class BaseInfo:
+    """Represents the state of a registry feature, used during API generation"""
+    def __init__(self, elem):
+        self.required = False
+        self.declared = False
+        self.elem = elem
+    def resetState(self):
+        self.required = False
+        self.declared = False
+
+# TypeInfo - registry information about a type. No additional state
+#   beyond BaseInfo is required.
+class TypeInfo(BaseInfo):
+    """Represents the state of a registry type"""
+    def __init__(self, elem):
+        BaseInfo.__init__(self, elem)
+
+# GroupInfo - registry information about a group of related enums.
+#   enums - dictionary of enum names which are in the group
+class GroupInfo(BaseInfo):
+    """Represents the state of a registry enumerant group"""
+    def __init__(self, elem):
+        BaseInfo.__init__(self, elem)
+        self.enums = {}
+
+# EnumInfo - registry information about an enum
+#   type - numeric type of the value of the <enum> tag
+#     ( '' for GLint, 'u' for GLuint, 'ull' for GLuint64 )
+class EnumInfo(BaseInfo):
+    """Represents the state of a registry enum"""
+    def __init__(self, elem):
+        BaseInfo.__init__(self, elem)
+        self.type = elem.get('type')
+        if (self.type == None):
+            self.type = ''
+
+# CmdInfo - registry information about a command
+#   glxtype - type of GLX protocol { None, 'render', 'single', 'vendor' }
+#   glxopcode - GLX protocol opcode { None, number }
+#   glxequiv - equivalent command at GLX dispatch level { None, string }
+#   vecequiv - equivalent vector form of a command taking multiple scalar args
+#     { None, string }
+class CmdInfo(BaseInfo):
+    """Represents the state of a registry command"""
+    def __init__(self, elem):
+        BaseInfo.__init__(self, elem)
+        self.glxtype = None
+        self.glxopcode = None
+        self.glxequiv = None
+        self.vecequiv = None
+
+# FeatureInfo - registry information about an API <feature>
+# or <extension>
+#   name - feature name string (e.g. 'GL_ARB_multitexture')
+#   number - feature version number (e.g. 1.2). <extension>
+#     features are unversioned and assigned version number 0.
+#   category - category, e.g. VERSION or ARB/KHR/OES/ETC/vendor
+#   emit - has this feature been defined already?
+class FeatureInfo(BaseInfo):
+    """Represents the state of an API feature (version/extension)"""
+    def __init__(self, elem):
+        BaseInfo.__init__(self, elem)
+        self.name = elem.get('name')
+        # Determine element category (vendor). Only works
+        # for <extension> elements.
+        if (elem.tag == 'feature'):
+            self.category = 'VERSION'
+            self.number = elem.get('number')
+        else:
+            self.category = self.name.split('_', 2)[1]
+            self.number = "0"
+        self.emit = False
+
+# Primary sort key for regSortFeatures.
+# Sorts by category of the feature name string:
+#   Core API features (those defined with a <feature> tag)
+#   ARB/KHR/OES (Khronos extensions)
+#   other       (EXT/vendor extensions)
+def regSortCategoryKey(feature):
+    if (feature.elem.tag == 'feature'):
+        return 0
+    elif (feature.category == 'ARB' or
+          feature.category == 'KHR' or
+          feature.category == 'OES'):
+        return 1
+    else:
+        return 2
+
+# Secondary sort key for regSortFeatures.
+# Sorts by extension name.
+def regSortNameKey(feature):
+    return feature.name
+
+# Tertiary sort key for regSortFeatures.
+# Sorts by feature version number. <extension>
+# elements all have version number "0"
+def regSortNumberKey(feature):
+    return feature.number
+
+# regSortFeatures - default sort procedure for features.
+# Sorts by primary key of feature category,
+# then by feature name within the category,
+# then by version number
+def regSortFeatures(featureList):
+    featureList.sort(key = regSortNumberKey)
+    featureList.sort(key = regSortNameKey)
+    featureList.sort(key = regSortCategoryKey)
+
+# GeneratorOptions - base class for options used during header production
+# These options are target language independent, and used by
+# Registry.apiGen() and by base OutputGenerator objects.
+#
+# Members
+#   filename - name of file to generate, or None to write to stdout.
+#   apiname - string matching <api> 'apiname' attribute, e.g. 'gl'.
+#   profile - string specifying API profile , e.g. 'core', or None.
+#   versions - regex matching API versions to process interfaces for.
+#     Normally '.*' or '[0-9]\.[0-9]' to match all defined versions.
+#   emitversions - regex matching API versions to actually emit
+#    interfaces for (though all requested versions are considered
+#    when deciding which interfaces to generate). For GL 4.3 glext.h,
+#     this might be '1\.[2-5]|[2-4]\.[0-9]'.
+#   defaultExtensions - If not None, a string which must in its
+#     entirety match the pattern in the "supported" attribute of
+#     the <extension>. Defaults to None. Usually the same as apiname.
+#   addExtensions - regex matching names of additional extensions
+#     to include. Defaults to None.
+#   removeExtenions - regex matching names of extensions to
+#     remove (after defaultExtensions and addExtensions). Defaults
+#     to None.
+#   sortProcedure - takes a list of FeatureInfo objects and sorts
+#     them in place to a preferred order in the generated output.
+#     Default is core API versions, ARB/KHR/OES extensions, all
+#     other extensions, alphabetically within each group.
+# The regex patterns can be None or empty, in which case they match
+#   nothing.
+class GeneratorOptions:
+    """Represents options during header production from an API registry"""
+    def __init__(self,
+                 filename = None,
+                 apiname = None,
+                 profile = None,
+                 versions = '.*',
+                 emitversions = '.*',
+                 defaultExtensions = None,
+                 addExtensions = None,
+                 removeExtensions = None,
+                 sortProcedure = regSortFeatures):
+        self.filename          = filename
+        self.apiname           = apiname
+        self.profile           = profile
+        self.versions          = self.emptyRegex(versions)
+        self.emitversions      = self.emptyRegex(emitversions)
+        self.defaultExtensions = defaultExtensions
+        self.addExtensions     = self.emptyRegex(addExtensions)
+        self.removeExtensions  = self.emptyRegex(removeExtensions)
+        self.sortProcedure     = sortProcedure
+    #
+    # Substitute a regular expression which matches no version
+    # or extension names for None or the empty string.
+    def emptyRegex(self,pat):
+        if (pat == None or pat == ''):
+            return '_nomatch_^'
+        else:
+            return pat
+
+# CGeneratorOptions - subclass of GeneratorOptions.
+#
+# Adds options used by COutputGenerator objects during C language header
+# generation.
+#
+# Additional members
+#   prefixText - list of strings to prefix generated header with
+#     (usually a copyright statement + calling convention macros).
+#   protectFile - True if multiple inclusion protection should be
+#     generated (based on the filename) around the entire header.
+#   protectFeature - True if #ifndef..#endif protection should be
+#     generated around a feature interface in the header file.
+#   genFuncPointers - True if function pointer typedefs should be
+#     generated
+#   protectProto - True if #ifdef..#endif protection should be
+#     generated around prototype declarations
+#   protectProtoStr - #ifdef symbol to use around prototype
+#     declarations, if protected
+#   apicall - string to use for the function declaration prefix,
+#     such as APICALL on Windows.
+#   apientry - string to use for the calling convention macro,
+#     in typedefs, such as APIENTRY.
+#   apientryp - string to use for the calling convention macro
+#     in function pointer typedefs, such as APIENTRYP.
+class CGeneratorOptions(GeneratorOptions):
+    """Represents options during C header production from an API registry"""
+    def __init__(self,
+                 filename = None,
+                 apiname = None,
+                 profile = None,
+                 versions = '.*',
+                 emitversions = '.*',
+                 defaultExtensions = None,
+                 addExtensions = None,
+                 removeExtensions = None,
+                 sortProcedure = regSortFeatures,
+                 prefixText = "",
+                 genFuncPointers = True,
+                 protectFile = True,
+                 protectFeature = True,
+                 protectProto = True,
+                 protectProtoStr = True,
+                 apicall = '',
+                 apientry = '',
+                 apientryp = ''):
+        GeneratorOptions.__init__(self, filename, apiname, profile,
+                                  versions, emitversions, defaultExtensions,
+                                  addExtensions, removeExtensions, sortProcedure)
+        self.prefixText      = prefixText
+        self.genFuncPointers = genFuncPointers
+        self.protectFile     = protectFile
+        self.protectFeature  = protectFeature
+        self.protectProto    = protectProto
+        self.protectProtoStr = protectProtoStr
+        self.apicall         = apicall
+        self.apientry        = apientry
+        self.apientryp       = apientryp
+
+# OutputGenerator - base class for generating API interfaces.
+# Manages basic logic, logging, and output file control
+# Derived classes actually generate formatted output.
+#
+# ---- methods ----
+# OutputGenerator(errFile, warnFile, diagFile)
+#   errFile, warnFile, diagFile - file handles to write errors,
+#     warnings, diagnostics to. May be None to not write.
+# logMsg(level, *args) - log messages of different categories
+#   level - 'error', 'warn', or 'diag'. 'error' will also
+#     raise a UserWarning exception
+#   *args - print()-style arguments
+# beginFile(genOpts) - start a new interface file
+#   genOpts - GeneratorOptions controlling what's generated and how
+# endFile() - finish an interface file, closing it when done
+# beginFeature(interface, emit) - write interface for a feature
+# and tag generated features as having been done.
+#   interface - element for the <version> / <extension> to generate
+#   emit - actually write to the header only when True
+# endFeature() - finish an interface.
+# genType(typeinfo,name) - generate interface for a type
+#   typeinfo - TypeInfo for a type
+# genEnum(enuminfo, name) - generate interface for an enum
+#   enuminfo - EnumInfo for an enum
+#   name - enum name
+# genCmd(cmdinfo) - generate interface for a command
+#   cmdinfo - CmdInfo for a command
+class OutputGenerator:
+    """Generate specified API interfaces in a specific style, such as a C header"""
+    def __init__(self,
+                 errFile = sys.stderr,
+                 warnFile = sys.stderr,
+                 diagFile = sys.stdout):
+        self.outFile = None
+        self.errFile = errFile
+        self.warnFile = warnFile
+        self.diagFile = diagFile
+        # Internal state
+        self.featureName = None
+        self.genOpts = None
+    #
+    # logMsg - write a message of different categories to different
+    #   destinations.
+    # level -
+    #   'diag' (diagnostic, voluminous)
+    #   'warn' (warning)
+    #   'error' (fatal error - raises exception after logging)
+    # *args - print()-style arguments to direct to corresponding log
+    def logMsg(self, level, *args):
+        """Log a message at the given level. Can be ignored or log to a file"""
+        if (level == 'error'):
+            strfile = io.StringIO()
+            write('ERROR:', *args, file=strfile)
+            if (self.errFile != None):
+                write(strfile.getvalue(), file=self.errFile)
+            raise UserWarning(strfile.getvalue())
+        elif (level == 'warn'):
+            if (self.warnFile != None):
+                write('WARNING:', *args, file=self.warnFile)
+        elif (level == 'diag'):
+            if (self.diagFile != None):
+                write('DIAG:', *args, file=self.diagFile)
+        else:
+            raise UserWarning(
+                '*** FATAL ERROR in Generator.logMsg: unknown level:' + level)
+    #
+    def beginFile(self, genOpts):
+        self.genOpts = genOpts
+        #
+        # Open specified output file. Not done in constructor since a
+        # Generator can be used without writing to a file.
+        if (self.genOpts.filename != None):
+            self.outFile = open(self.genOpts.filename, 'w')
+        else:
+            self.outFile = sys.stdout
+    def endFile(self):
+        self.errFile and self.errFile.flush()
+        self.warnFile and self.warnFile.flush()
+        self.diagFile and self.diagFile.flush()
+        self.outFile.flush()
+        if (self.outFile != sys.stdout and self.outFile != sys.stderr):
+            self.outFile.close()
+        self.genOpts = None
+    #
+    def beginFeature(self, interface, emit):
+        self.emit = emit
+        self.featureName = interface.get('name')
+        # If there's an additional 'protect' attribute in the feature, save it
+        self.featureExtraProtect = interface.get('protect')
+    def endFeature(self):
+        # Derived classes responsible for emitting feature
+        self.featureName = None
+        self.featureExtraProtect = None
+    #
+    # Type generation
+    def genType(self, typeinfo, name):
+        if (self.featureName == None):
+            raise UserWarning('Attempt to generate type', name,
+                    'when not in feature')
+    #
+    # Enumerant generation
+    def genEnum(self, enuminfo, name):
+        if (self.featureName == None):
+            raise UserWarning('Attempt to generate enum', name,
+                    'when not in feature')
+    #
+    # Command generation
+    def genCmd(self, cmd, name):
+        if (self.featureName == None):
+            raise UserWarning('Attempt to generate command', name,
+                    'when not in feature')
+
+# COutputGenerator - subclass of OutputGenerator.
+# Generates C-language API interfaces.
+#
+# ---- methods ----
+# COutputGenerator(errFile, warnFile, diagFile) - args as for
+#   OutputGenerator. Defines additional internal state.
+# makeCDecls(cmd) - return C prototype and function pointer typedef for a
+#     <command> Element, as a list of two strings
+#   cmd - Element for the <command>
+# newline() - print a newline to the output file (utility function)
+# ---- methods overriding base class ----
+# beginFile(genOpts)
+# endFile()
+# beginFeature(interface, emit)
+# endFeature()
+# genType(typeinfo,name) - generate interface for a type
+# genEnum(enuminfo, name)
+# genCmd(cmdinfo)
+class COutputGenerator(OutputGenerator):
+    """Generate specified API interfaces in a specific style, such as a C header"""
+    def __init__(self,
+                 errFile = sys.stderr,
+                 warnFile = sys.stderr,
+                 diagFile = sys.stdout):
+        OutputGenerator.__init__(self, errFile, warnFile, diagFile)
+        # Internal state - accumulators for different inner block text
+        self.typeBody = ''
+        self.enumBody = ''
+        self.cmdBody = ''
+    #
+    # makeCDecls - return C prototype and function pointer typedef for a
+    #   command, as a two-element list of strings.
+    # cmd - Element containing a <command> tag
+    def makeCDecls(self, cmd):
+        """Generate C function pointer typedef for <command> Element"""
+        proto = cmd.find('proto')
+        params = cmd.findall('param')
+        # Begin accumulating prototype and typedef strings
+        pdecl = self.genOpts.apicall
+        tdecl = 'typedef '
+        #
+        # Insert the function return type/name.
+        # For prototypes, add APIENTRY macro before the name
+        # For typedefs, add (APIENTRYP <name>) around the name and
+        #   use the PFNGLCMDNAMEPROC nameng convention.
+        # Done by walking the tree for <proto> element by element.
+        # lxml.etree has elem.text followed by (elem[i], elem[i].tail)
+        #   for each child element and any following text
+        # Leading text
+        pdecl += noneStr(proto.text)
+        tdecl += noneStr(proto.text)
+        # For each child element, if it's a <name> wrap in appropriate
+        # declaration. Otherwise append its contents and tail contents.
+        for elem in proto:
+            text = noneStr(elem.text)
+            tail = noneStr(elem.tail)
+            if (elem.tag == 'name'):
+                pdecl += self.genOpts.apientry + text + tail
+                tdecl += '(' + self.genOpts.apientryp + 'PFN' + text.upper() + 'PROC' + tail + ')'
+            else:
+                pdecl += text + tail
+                tdecl += text + tail
+        # Now add the parameter declaration list, which is identical
+        # for prototypes and typedefs. Concatenate all the text from
+        # a <param> node without the tags. No tree walking required
+        # since all tags are ignored.
+        n = len(params)
+        paramdecl = ' ('
+        if n > 0:
+            for i in range(0,n):
+                paramdecl += ''.join([t for t in params[i].itertext()])
+                if (i < n - 1):
+                    paramdecl += ', '
+        else:
+            paramdecl += 'void'
+        paramdecl += ");\n";
+        return [ pdecl + paramdecl, tdecl + paramdecl ]
+    #
+    def newline(self):
+        write('', file=self.outFile)
+    #
+    def beginFile(self, genOpts):
+        OutputGenerator.beginFile(self, genOpts)
+        # C-specific
+        #
+        # Multiple inclusion protection & C++ wrappers.
+        if (genOpts.protectFile and self.genOpts.filename):
+            headerSym = '__' + re.sub('\.h', '_h_', os.path.basename(self.genOpts.filename))
+            write('#ifndef', headerSym, file=self.outFile)
+            write('#define', headerSym, '1', file=self.outFile)
+            self.newline()
+        write('#ifdef __cplusplus', file=self.outFile)
+        write('extern "C" {', file=self.outFile)
+        write('#endif', file=self.outFile)
+        self.newline()
+        #
+        # User-supplied prefix text, if any (list of strings)
+        if (genOpts.prefixText):
+            for s in genOpts.prefixText:
+                write(s, file=self.outFile)
+        #
+        # Some boilerplate describing what was generated - this
+        # will probably be removed later since the extensions
+        # pattern may be very long.
+        write('/* Generated C header for:', file=self.outFile)
+        write(' * API:', genOpts.apiname, file=self.outFile)
+        if (genOpts.profile):
+            write(' * Profile:', genOpts.profile, file=self.outFile)
+        write(' * Versions considered:', genOpts.versions, file=self.outFile)
+        write(' * Versions emitted:', genOpts.emitversions, file=self.outFile)
+        write(' * Default extensions included:', genOpts.defaultExtensions, file=self.outFile)
+        write(' * Additional extensions included:', genOpts.addExtensions, file=self.outFile)
+        write(' * Extensions removed:', genOpts.removeExtensions, file=self.outFile)
+        write(' */', file=self.outFile)
+    def endFile(self):
+        # C-specific
+        # Finish C++ wrapper and multiple inclusion protection
+        self.newline()
+        write('#ifdef __cplusplus', file=self.outFile)
+        write('}', file=self.outFile)
+        write('#endif', file=self.outFile)
+        if (self.genOpts.protectFile and self.genOpts.filename):
+            self.newline()
+            write('#endif', file=self.outFile)
+        # Finish processing in superclass
+        OutputGenerator.endFile(self)
+    def beginFeature(self, interface, emit):
+        # Start processing in superclass
+        OutputGenerator.beginFeature(self, interface, emit)
+        # C-specific
+        # Accumulate types, enums, function pointer typedefs, end function
+        # prototypes separately for this feature. They're only printed in
+        # endFeature().
+        self.typeBody = ''
+        self.enumBody = ''
+        self.cmdPointerBody = ''
+        self.cmdBody = ''
+    def endFeature(self):
+        # C-specific
+        # Actually write the interface to the output file.
+        if (self.emit):
+            self.newline()
+            if (self.genOpts.protectFeature):
+                write('#ifndef', self.featureName, file=self.outFile)
+            write('#define', self.featureName, '1', file=self.outFile)
+            if (self.typeBody != ''):
+                write(self.typeBody, end='', file=self.outFile)
+            #
+            # Don't add additional protection for derived type declarations,
+            # which may be needed by other features later on.
+            if (self.featureExtraProtect != None):
+                write('#ifdef', self.featureExtraProtect, file=self.outFile)
+            if (self.enumBody != ''):
+                write(self.enumBody, end='', file=self.outFile)
+            if (self.genOpts.genFuncPointers and self.cmdPointerBody != ''):
+                write(self.cmdPointerBody, end='', file=self.outFile)
+            if (self.cmdBody != ''):
+                if (self.genOpts.protectProto):
+                    write('#ifdef', self.genOpts.protectProtoStr, file=self.outFile)
+                write(self.cmdBody, end='', file=self.outFile)
+                if (self.genOpts.protectProto):
+                    write('#endif', file=self.outFile)
+            if (self.featureExtraProtect != None):
+                write('#endif /*', self.featureExtraProtect, '*/', file=self.outFile)
+            if (self.genOpts.protectFeature):
+                write('#endif /*', self.featureName, '*/', file=self.outFile)
+        # Finish processing in superclass
+        OutputGenerator.endFeature(self)
+    #
+    # Type generation
+    def genType(self, typeinfo, name):
+        OutputGenerator.genType(self, typeinfo, name)
+        #
+        # Replace <apientry /> tags with an APIENTRY-style string
+        # (from self.genOpts). Copy other text through unchanged.
+        # If the resulting text is an empty string, don't emit it.
+        typeElem = typeinfo.elem
+        s = noneStr(typeElem.text)
+        for elem in typeElem:
+            if (elem.tag == 'apientry'):
+                s += self.genOpts.apientry + noneStr(elem.tail)
+            else:
+                s += noneStr(elem.text) + noneStr(elem.tail)
+        if (len(s) > 0):
+            self.typeBody += s + "\n"
+    #
+    # Enumerant generation
+    def genEnum(self, enuminfo, name):
+        OutputGenerator.genEnum(self, enuminfo, name)
+        #
+        # EnumInfo.type is a C value suffix (e.g. u, ull)
+        self.enumBody += '#define ' + name.ljust(33) + ' ' + enuminfo.elem.get('value')
+        #
+        # Handle non-integer 'type' fields by using it as the C value suffix
+        t = enuminfo.elem.get('type')
+        if (t != '' and t != 'i'):
+            self.enumBody += enuminfo.type
+        self.enumBody += "\n"
+    #
+    # Command generation
+    def genCmd(self, cmdinfo, name):
+        OutputGenerator.genCmd(self, cmdinfo, name)
+        #
+        decls = self.makeCDecls(cmdinfo.elem)
+        self.cmdBody += decls[0]
+        if (self.genOpts.genFuncPointers):
+            self.cmdPointerBody += decls[1]
+
+# Registry - object representing an API registry, loaded from an XML file
+# Members
+#   tree - ElementTree containing the root <registry>
+#   typedict - dictionary of TypeInfo objects keyed by type name
+#   groupdict - dictionary of GroupInfo objects keyed by group name
+#   enumdict - dictionary of EnumInfo objects keyed by enum name
+#   cmddict - dictionary of CmdInfo objects keyed by command name
+#   apidict - dictionary of <api> Elements keyed by API name
+#   extensions - list of <extension> Elements
+#   extdict - dictionary of <extension> Elements keyed by extension name
+#   gen - OutputGenerator object used to write headers / messages
+#   genOpts - GeneratorOptions object used to control which
+#     fetures to write and how to format them
+#   emitFeatures - True to actually emit features for a version / extension,
+#     or False to just treat them as emitted
+# Public methods
+#   loadElementTree(etree) - load registry from specified ElementTree
+#   loadFile(filename) - load registry from XML file
+#   setGenerator(gen) - OutputGenerator to use
+#   parseTree() - parse the registry once loaded & create dictionaries
+#   dumpReg(maxlen, filehandle) - diagnostic to dump the dictionaries
+#     to specified file handle (default stdout). Truncates type /
+#     enum / command elements to maxlen characters (default 80)
+#   generator(g) - specify the output generator object
+#   apiGen(apiname, genOpts) - generate API headers for the API type
+#     and profile specified in genOpts, but only for the versions and
+#     extensions specified there.
+#   apiReset() - call between calls to apiGen() to reset internal state
+#   validateGroups() - call to verify that each <proto> or <param>
+#     with a 'group' attribute matches an actual existing group.
+# Private methods
+#   addElementInfo(elem,info,infoName,dictionary) - add feature info to dict
+#   lookupElementInfo(fname,dictionary) - lookup feature info in dict
+class Registry:
+    """Represents an API registry loaded from XML"""
+    def __init__(self):
+        self.tree         = None
+        self.typedict     = {}
+        self.groupdict    = {}
+        self.enumdict     = {}
+        self.cmddict      = {}
+        self.apidict      = {}
+        self.extensions   = []
+        self.extdict      = {}
+        # A default output generator, so commands prior to apiGen can report
+        # errors via the generator object.
+        self.gen          = OutputGenerator()
+        self.genOpts      = None
+        self.emitFeatures = False
+    def loadElementTree(self, tree):
+        """Load ElementTree into a Registry object and parse it"""
+        self.tree = tree
+        self.parseTree()
+    def loadFile(self, file):
+        """Load an API registry XML file into a Registry object and parse it"""
+        self.tree = etree.parse(file)
+        self.parseTree()
+    def setGenerator(self, gen):
+        """Specify output generator object. None restores the default generator"""
+        self.gen = gen
+    # addElementInfo - add information about an element to the
+    # corresponding dictionary
+    #   elem - <type>/<group>/<enum>/<command>/<feature>/<extension> Element
+    #   info - corresponding {Type|Group|Enum|Cmd|Feature}Info object
+    #   infoName - 'type' / 'group' / 'enum' / 'command' / 'feature' / 'extension'
+    #   dictionary - self.{type|group|enum|cmd|api|ext}dict
+    # If the Element has an 'api' attribute, the dictionary key is the
+    # tuple (name,api). If not, the key is the name. 'name' is an 
+    # attribute of the Element
+    def addElementInfo(self, elem, info, infoName, dictionary):
+        if ('api' in elem.attrib):
+            key = (elem.get('name'),elem.get('api'))
+        else:
+            key = elem.get('name')
+        if key in dictionary:
+            self.gen.logMsg('warn', '*** Attempt to redefine',
+                            infoName, 'with key:', key)
+        else:
+            dictionary[key] = info
+    #
+    # lookupElementInfo - find a {Type|Enum|Cmd}Info object by name.
+    # If an object qualified by API name exists, use that.
+    #   fname - name of type / enum / command
+    #   dictionary - self.{type|enum|cmd}dict
+    def lookupElementInfo(self, fname, dictionary):
+        key = (fname, self.genOpts.apiname)
+        if (key in dictionary):
+            # self.gen.logMsg('diag', 'Found API-specific element for feature', fname)
+            return dictionary[key]
+        elif (fname in dictionary):
+            # self.gen.logMsg('diag', 'Found generic element for feature', fname)
+            return dictionary[fname]
+        else:
+            return None
+    def parseTree(self):
+        """Parse the registry Element, once created"""
+        # This must be the Element for the root <registry>
+        self.reg = self.tree.getroot()
+        #
+        # Create dictionary of registry types from toplevel <types> tags
+        # and add 'name' attribute to each <type> tag (where missing)
+        # based on its <name> element.
+        #
+        # There's usually one <types> block; more are OK
+        # Required <type> attributes: 'name' or nested <name> tag contents
+        self.typedict = {}
+        for type in self.reg.findall('types/type'):
+            # If the <type> doesn't already have a 'name' attribute, set
+            # it from contents of its <name> tag.
+            if (type.get('name') == None):
+                type.attrib['name'] = type.find('name').text
+            self.addElementInfo(type, TypeInfo(type), 'type', self.typedict)
+        #
+        # Create dictionary of registry groups from toplevel <groups> tags.
+        #
+        # There's usually one <groups> block; more are OK.
+        # Required <group> attributes: 'name'
+        self.groupdict = {}
+        for group in self.reg.findall('groups/group'):
+            self.addElementInfo(group, GroupInfo(group), 'group', self.groupdict)
+        #
+        # Create dictionary of registry enums from toplevel <enums> tags
+        #
+        # There are usually many <enums> tags in different namespaces, but
+        #   these are functional namespaces of the values, while the actual
+        #   enum names all share the dictionary.
+        # Required <enums> attributes: 'name', 'value'
+        self.enumdict = {}
+        for enum in self.reg.findall('enums/enum'):
+            self.addElementInfo(enum, EnumInfo(enum), 'enum', self.enumdict)
+        #
+        # Create dictionary of registry commands from <command> tags
+        # and add 'name' attribute to each <command> tag (where missing)
+        # based on its <proto><name> element.
+        #
+        # There's usually only one <commands> block; more are OK.
+        # Required <command> attributes: 'name' or <proto><name> tag contents
+        self.cmddict = {}
+        for cmd in self.reg.findall('commands/command'):
+            # If the <command> doesn't already have a 'name' attribute, set
+            # it from contents of its <proto><name> tag.
+            if (cmd.get('name') == None):
+                cmd.attrib['name'] = cmd.find('proto/name').text
+            ci = CmdInfo(cmd)
+            self.addElementInfo(cmd, ci, 'command', self.cmddict)
+        #
+        # Create dictionaries of API and extension interfaces
+        #   from toplevel <api> and <extension> tags.
+        #
+        self.apidict = {}
+        for feature in self.reg.findall('feature'):
+            ai = FeatureInfo(feature)
+            self.addElementInfo(feature, ai, 'feature', self.apidict)
+        self.extensions = self.reg.findall('extensions/extension')
+        self.extdict = {}
+        for feature in self.extensions:
+            ei = FeatureInfo(feature)
+            self.addElementInfo(feature, ei, 'extension', self.extdict)
+    def dumpReg(self, maxlen = 40, filehandle = sys.stdout):
+        """Dump all the dictionaries constructed from the Registry object"""
+        write('***************************************', file=filehandle)
+        write('    ** Dumping Registry contents **',     file=filehandle)
+        write('***************************************', file=filehandle)
+        write('// Types', file=filehandle)
+        for name in self.typedict:
+            tobj = self.typedict[name]
+            write('    Type', name, '->', etree.tostring(tobj.elem)[0:maxlen], file=filehandle)
+        write('// Groups', file=filehandle)
+        for name in self.groupdict:
+            gobj = self.groupdict[name]
+            write('    Group', name, '->', etree.tostring(gobj.elem)[0:maxlen], file=filehandle)
+        write('// Enums', file=filehandle)
+        for name in self.enumdict:
+            eobj = self.enumdict[name]
+            write('    Enum', name, '->', etree.tostring(eobj.elem)[0:maxlen], file=filehandle)
+        write('// Commands', file=filehandle)
+        for name in self.cmddict:
+            cobj = self.cmddict[name]
+            write('    Command', name, '->', etree.tostring(cobj.elem)[0:maxlen], file=filehandle)
+        write('// APIs', file=filehandle)
+        for key in self.apidict:
+            write('    API Version ', key, '->',
+                etree.tostring(self.apidict[key].elem)[0:maxlen], file=filehandle)
+        write('// Extensions', file=filehandle)
+        for key in self.extdict:
+            write('    Extension', key, '->',
+                etree.tostring(self.extdict[key].elem)[0:maxlen], file=filehandle)
+        # write('***************************************', file=filehandle)
+        # write('    ** Dumping XML ElementTree **', file=filehandle)
+        # write('***************************************', file=filehandle)
+        # write(etree.tostring(self.tree.getroot(),pretty_print=True), file=filehandle)
+    #
+    # typename - name of type
+    # required - boolean (to tag features as required or not)
+    def markTypeRequired(self, typename, required):
+        """Require (along with its dependencies) or remove (but not its dependencies) a type"""
+        self.gen.logMsg('diag', '*** tagging type:', typename, '-> required =', required)
+        # Get TypeInfo object for <type> tag corresponding to typename
+        type = self.lookupElementInfo(typename, self.typedict)
+        if (type != None):
+            # Tag required type dependencies as required.
+            # This DOES NOT un-tag dependencies in a <remove> tag.
+            # See comments in markRequired() below for the reason.
+            if (required and ('requires' in type.elem.attrib)):
+                depType = type.elem.get('requires')
+                self.gen.logMsg('diag', '*** Generating dependent type',
+                    depType, 'for type', typename)
+                self.markTypeRequired(depType, required)
+            type.required = required
+        else:
+            self.gen.logMsg('warn', '*** type:', typename , 'IS NOT DEFINED')
+    #
+    # features - Element for <require> or <remove> tag
+    # required - boolean (to tag features as required or not)
+    def markRequired(self, features, required):
+        """Require or remove features specified in the Element"""
+        self.gen.logMsg('diag', '*** markRequired (features = <too long to print>, required =', required, ')')
+        # Loop over types, enums, and commands in the tag
+        # @@ It would be possible to respect 'api' and 'profile' attributes
+        #  in individual features, but that's not done yet.
+        for typeElem in features.findall('type'):
+            self.markTypeRequired(typeElem.get('name'), required)
+        for enumElem in features.findall('enum'):
+            name = enumElem.get('name')
+            self.gen.logMsg('diag', '*** tagging enum:', name, '-> required =', required)
+            enum = self.lookupElementInfo(name, self.enumdict)
+            if (enum != None):
+                enum.required = required
+            else:
+                self.gen.logMsg('warn', '*** enum:', name , 'IS NOT DEFINED')
+        for cmdElem in features.findall('command'):
+            name = cmdElem.get('name')
+            self.gen.logMsg('diag', '*** tagging command:', name, '-> required =', required)
+            cmd = self.lookupElementInfo(name, self.cmddict)
+            if (cmd != None):
+                cmd.required = required
+                # Tag all parameter types of this command as required.
+                # This DOES NOT remove types of commands in a <remove>
+                # tag, because many other commands may use the same type.
+                # We could be more clever and reference count types,
+                # instead of using a boolean.
+                if (required):
+                    # Look for <ptype> in entire <command> tree,
+                    # not just immediate children
+                    for ptype in cmd.elem.findall('.//ptype'):
+                        self.gen.logMsg('diag', '*** markRequired: command implicitly requires dependent type', ptype.text)
+                        self.markTypeRequired(ptype.text, required)
+            else:
+                self.gen.logMsg('warn', '*** command:', name, 'IS NOT DEFINED')
+    #
+    # interface - Element for <version> or <extension>, containing
+    #   <require> and <remove> tags
+    # api - string specifying API name being generated
+    # profile - string specifying API profile being generated
+    def requireAndRemoveFeatures(self, interface, api, profile):
+        """Process <recquire> and <remove> tags for a <version> or <extension>"""
+        # <require> marks things that are required by this version/profile
+        for feature in interface.findall('require'):
+            if (matchAPIProfile(api, profile, feature)):
+                self.markRequired(feature,True)
+        # <remove> marks things that are removed by this version/profile
+        for feature in interface.findall('remove'):
+            if (matchAPIProfile(api, profile, feature)):
+                self.markRequired(feature,False)
+    #
+    # generateFeature - generate a single type / enum / command,
+    # and all its dependencies as needed.
+    #   fname - name of feature (<type>/<enum>/<command>
+    #   ftype - type of feature, 'type' | 'enum' | 'command'
+    #   dictionary - of *Info objects - self.{type|enum|cmd}dict
+    #   genProc - bound function pointer for self.gen.gen{Type|Enum|Cmd}
+    def generateFeature(self, fname, ftype, dictionary, genProc):
+        f = self.lookupElementInfo(fname, dictionary)
+        if (f == None):
+            # No such feature. This is an error, but reported earlier
+            self.gen.logMsg('diag', '*** No entry found for feature', fname,
+                            'returning!')
+            return
+        #
+        # If feature isn't required, or has already been declared, return
+        if (not f.required):
+            self.gen.logMsg('diag', '*** Skipping', ftype, fname, '(not required)')
+            return
+        if (f.declared):
+            self.gen.logMsg('diag', '*** Skipping', ftype, fname, '(already declared)')
+            return
+        #
+        # Pull in dependent type declaration(s) of the feature.
+        # For types, there may be one in the 'required' attribute of the element
+        # For commands, there may be many in <ptype> tags within the element
+        # For enums, no dependencies are allowed (though perhasps if you
+        #   have a uint64 enum, it should require GLuint64)
+        if (ftype == 'type'):
+            if ('requires' in f.elem.attrib):
+                depname = f.elem.get('requires')
+                self.gen.logMsg('diag', '*** Generating required dependent type',
+                                depname)
+                self.generateFeature(depname, 'type', self.typedict,
+                                     self.gen.genType)
+        elif (ftype == 'command'):
+            for ptype in f.elem.findall('.//ptype'):
+                depname = ptype.text
+                self.gen.logMsg('diag', '*** Generating required parameter type',
+                                depname)
+                self.generateFeature(depname, 'type', self.typedict,
+                                     self.gen.genType)
+        #
+        # Actually generate the type only if emitting declarations
+        if self.emitFeatures:
+            self.gen.logMsg('diag', '*** Emitting', ftype, 'decl for', fname)
+            genProc(f, fname)
+        else:
+            self.gen.logMsg('diag', '*** Skipping', ftype, fname,
+                            '(not emitting this feature)')
+        # Always mark feature declared, as though actually emitted
+        f.declared = True
+    #
+    # generateRequiredInterface - generate all interfaces required
+    # by an API version or extension
+    #   interface - Element for <version> or <extension>
+    def generateRequiredInterface(self, interface):
+        """Generate required C interface for specified API version/extension"""
+        #
+        # Loop over all features inside all <require> tags.
+        # <remove> tags are ignored (handled in pass 1).
+        for features in interface.findall('require'):
+            for t in features.findall('type'):
+                self.generateFeature(t.get('name'), 'type', self.typedict,
+                                     self.gen.genType)
+            for e in features.findall('enum'):
+                self.generateFeature(e.get('name'), 'enum', self.enumdict,
+                                     self.gen.genEnum)
+            for c in features.findall('command'):
+                self.generateFeature(c.get('name'), 'command', self.cmddict,
+                                     self.gen.genCmd)
+    #
+    # apiGen(genOpts) - generate interface for specified versions
+    #   genOpts - GeneratorOptions object with parameters used
+    #   by the Generator object.
+    def apiGen(self, genOpts):
+        """Generate interfaces for the specified API type and range of versions"""
+        #
+        self.gen.logMsg('diag', '*******************************************')
+        self.gen.logMsg('diag', '  Registry.apiGen file:', genOpts.filename,
+                        'api:', genOpts.apiname,
+                        'profile:', genOpts.profile)
+        self.gen.logMsg('diag', '*******************************************')
+        #
+        self.genOpts = genOpts
+        # Reset required/declared flags for all features
+        self.apiReset()
+        #
+        # Compile regexps used to select versions & extensions
+        regVersions = re.compile(self.genOpts.versions)
+        regEmitVersions = re.compile(self.genOpts.emitversions)
+        regAddExtensions = re.compile(self.genOpts.addExtensions)
+        regRemoveExtensions = re.compile(self.genOpts.removeExtensions)
+        #
+        # Get all matching API versions & add to list of FeatureInfo
+        features = []
+        apiMatch = False
+        for key in self.apidict:
+            fi = self.apidict[key]
+            api = fi.elem.get('api')
+            if (api == self.genOpts.apiname):
+                apiMatch = True
+                if (regVersions.match(fi.number)):
+                    # Matches API & version #s being generated. Mark for
+                    # emission and add to the features[] list .
+                    # @@ Could use 'declared' instead of 'emit'?
+                    fi.emit = (regEmitVersions.match(fi.number) != None)
+                    features.append(fi)
+                    if (not fi.emit):
+                        self.gen.logMsg('diag', '*** NOT tagging feature api =', api,
+                            'name =', fi.name, 'number =', fi.number,
+                            'for emission (does not match emitversions pattern)')
+                else:
+                    self.gen.logMsg('diag', '*** NOT including feature api =', api,
+                        'name =', fi.name, 'number =', fi.number,
+                        '(does not match requested versions)')
+            else:
+                self.gen.logMsg('diag', '*** NOT including feature api =', api,
+                    'name =', fi.name,
+                    '(does not match requested API)')
+        if (not apiMatch):
+            self.gen.logMsg('warn', '*** No matching API versions found!')
+        #
+        # Get all matching extensions & add to the list.
+        # Start with extensions tagged with 'api' pattern matching the API
+        # being generated. Add extensions matching the pattern specified in
+        # regExtensions, then remove extensions matching the pattern
+        # specified in regRemoveExtensions
+        for key in self.extdict:
+            ei = self.extdict[key]
+            extName = ei.name
+            include = False
+            #
+            # Include extension if defaultExtensions is not None and if the
+            # 'supported' attribute matches defaultExtensions. The regexp in
+            # 'supported' must exactly match defaultExtensions, so bracket
+            # it with ^(pat)$.
+            pat = '^(' + ei.elem.get('supported') + ')$'
+            if (self.genOpts.defaultExtensions and
+                     re.match(pat, self.genOpts.defaultExtensions)):
+                self.gen.logMsg('diag', '*** Including extension',
+                    extName, "(defaultExtensions matches the 'supported' attribute)")
+                include = True
+            #
+            # Include additional extensions if the extension name matches
+            # the regexp specified in the generator options. This allows
+            # forcing extensions into an interface even if they're not
+            # tagged appropriately in the registry.
+            if (regAddExtensions.match(extName) != None):
+                self.gen.logMsg('diag', '*** Including extension',
+                    extName, '(matches explicitly requested extensions to add)')
+                include = True
+            # Remove extensions if the name matches the regexp specified
+            # in generator options. This allows forcing removal of
+            # extensions from an interface even if they're tagged that
+            # way in the registry.
+            if (regRemoveExtensions.match(extName) != None):
+                self.gen.logMsg('diag', '*** Removing extension',
+                    extName, '(matches explicitly requested extensions to remove)')
+                include = False
+            #
+            # If the extension is to be included, add it to the
+            # extension features list.
+            if (include):
+                ei.emit = True
+                features.append(ei)
+            else:
+                self.gen.logMsg('diag', '*** NOT including extension',
+                    extName, '(does not match api attribute or explicitly requested extensions)')
+        #
+        # Sort the extension features list, if a sort procedure is defined
+        if (self.genOpts.sortProcedure):
+            self.genOpts.sortProcedure(features)
+        #
+        # Pass 1: loop over requested API versions and extensions tagging
+        #   types/commands/features as required (in an <require> block) or no
+        #   longer required (in an <exclude> block). It is possible to remove
+        #   a feature in one version and restore it later by requiring it in
+        #   a later version.
+        # If a profile other than 'None' is being generated, it must
+        #   match the profile attribute (if any) of the <require> and
+        #   <remove> tags.
+        self.gen.logMsg('diag', '*** PASS 1: TAG FEATURES ********************************************')
+        for f in features:
+            self.gen.logMsg('diag', '*** PASS 1: Tagging required and removed features for',
+                f.name)
+            self.requireAndRemoveFeatures(f.elem, self.genOpts.apiname, self.genOpts.profile)
+        #
+        # Pass 2: loop over specified API versions and extensions printing
+        #   declarations for required things which haven't already been
+        #   generated.
+        self.gen.logMsg('diag', '*** PASS 2: GENERATE INTERFACES FOR FEATURES ************************')
+        self.gen.beginFile(self.genOpts)
+        for f in features:
+            self.gen.logMsg('diag', '*** PASS 2: Generating interface for',
+                f.name)
+            emit = self.emitFeatures = f.emit
+            if (not emit):
+                self.gen.logMsg('diag', '*** PASS 2: NOT declaring feature',
+                    f.elem.get('name'), 'because it is not tagged for emission')
+            # Generate the interface (or just tag its elements as having been
+            # emitted, if they haven't been).
+            self.gen.beginFeature(f.elem, emit)
+            self.generateRequiredInterface(f.elem)
+            self.gen.endFeature()
+        self.gen.endFile()
+    #
+    # apiReset - use between apiGen() calls to reset internal state
+    #
+    def apiReset(self):
+        """Reset type/enum/command dictionaries before generating another API"""
+        for type in self.typedict:
+            self.typedict[type].resetState()
+        for enum in self.enumdict:
+            self.enumdict[enum].resetState()
+        for cmd in self.cmddict:
+            self.cmddict[cmd].resetState()
+        for cmd in self.apidict:
+            self.apidict[cmd].resetState()
+    #
+    # validateGroups - check that group= attributes match actual groups
+    #
+    def validateGroups(self):
+        """Validate group= attributes on <param> and <proto> tags"""
+        # Keep track of group names not in <group> tags
+        badGroup = {}
+        self.gen.logMsg('diag', '*** VALIDATING GROUP ATTRIBUTES ***')
+        for cmd in self.reg.findall('commands/command'):
+            proto = cmd.find('proto')
+            funcname = cmd.find('proto/name').text
+            if ('group' in proto.attrib.keys()):
+                group = proto.get('group')
+                # self.gen.logMsg('diag', '*** Command ', funcname, ' has return group ', group)
+                if (group not in self.groupdict.keys()):
+                    # self.gen.logMsg('diag', '*** Command ', funcname, ' has UNKNOWN return group ', group)
+                    if (group not in badGroup.keys()):
+                        badGroup[group] = 1
+                    else:
+                        badGroup[group] = badGroup[group] +  1
+            for param in cmd.findall('param'):
+                pname = param.find('name')
+                if (pname != None):
+                    pname = pname.text
+                else:
+                    pname = type.get('name')
+                if ('group' in param.attrib.keys()):
+                    group = param.get('group')
+                    if (group not in self.groupdict.keys()):
+                        # self.gen.logMsg('diag', '*** Command ', funcname, ' param ', pname, ' has UNKNOWN group ', group)
+                        if (group not in badGroup.keys()):
+                            badGroup[group] = 1
+                        else:
+                            badGroup[group] = badGroup[group] +  1
+        if (len(badGroup.keys()) > 0):
+            self.gen.logMsg('diag', '*** SUMMARY OF UNRECOGNIZED GROUPS ***')
+            for key in sorted(badGroup.keys()):
+                self.gen.logMsg('diag', '    ', key, ' occurred ', badGroup[key], ' times')
diff --git a/services/batteryservice/Android.mk b/services/batteryservice/Android.mk
index 0a29c36..e4097d7 100644
--- a/services/batteryservice/Android.mk
+++ b/services/batteryservice/Android.mk
@@ -2,16 +2,19 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:= \
-	BatteryProperties.cpp \
-	IBatteryPropertiesListener.cpp \
-	IBatteryPropertiesRegistrar.cpp
+    BatteryProperties.cpp \
+    BatteryProperty.cpp \
+    IBatteryPropertiesListener.cpp \
+    IBatteryPropertiesRegistrar.cpp
 
 LOCAL_STATIC_LIBRARIES := \
-	libutils \
-	libbinder
+    libutils \
+    libbinder
 
 LOCAL_MODULE:= libbatteryservice
 
 LOCAL_MODULE_TAGS := optional
 
+LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
+
 include $(BUILD_STATIC_LIBRARY)
diff --git a/services/batteryservice/BatteryProperties.cpp b/services/batteryservice/BatteryProperties.cpp
index e4a42ed..07cc797 100644
--- a/services/batteryservice/BatteryProperties.cpp
+++ b/services/batteryservice/BatteryProperties.cpp
@@ -33,13 +33,13 @@
     chargerAcOnline = p->readInt32() == 1 ? true : false;
     chargerUsbOnline = p->readInt32() == 1 ? true : false;
     chargerWirelessOnline = p->readInt32() == 1 ? true : false;
+    maxChargingCurrent = p->readInt32();
+    maxChargingVoltage = p->readInt32();
     batteryStatus = p->readInt32();
     batteryHealth = p->readInt32();
     batteryPresent = p->readInt32() == 1 ? true : false;
     batteryLevel = p->readInt32();
     batteryVoltage = p->readInt32();
-    batteryCurrentNow = p->readInt32();
-    batteryChargeCounter = p->readInt32();
     batteryTemperature = p->readInt32();
     batteryTechnology = String8((p->readString16()).string());
     return OK;
@@ -49,13 +49,13 @@
     p->writeInt32(chargerAcOnline ? 1 : 0);
     p->writeInt32(chargerUsbOnline ? 1 : 0);
     p->writeInt32(chargerWirelessOnline ? 1 : 0);
+    p->writeInt32(maxChargingCurrent);
+    p->writeInt32(maxChargingVoltage);
     p->writeInt32(batteryStatus);
     p->writeInt32(batteryHealth);
     p->writeInt32(batteryPresent ? 1 : 0);
     p->writeInt32(batteryLevel);
     p->writeInt32(batteryVoltage);
-    p->writeInt32(batteryCurrentNow);
-    p->writeInt32(batteryChargeCounter);
     p->writeInt32(batteryTemperature);
     p->writeString16(String16(batteryTechnology));
     return OK;
diff --git a/services/batteryservice/BatteryProperty.cpp b/services/batteryservice/BatteryProperty.cpp
new file mode 100644
index 0000000..483d925
--- /dev/null
+++ b/services/batteryservice/BatteryProperty.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <batteryservice/BatteryService.h>
+#include <binder/Parcel.h>
+#include <utils/Errors.h>
+
+namespace android {
+
+/*
+ * Parcel read/write code must be kept in sync with
+ * frameworks/base/core/java/android/os/BatteryProperty.java
+ */
+
+status_t BatteryProperty::readFromParcel(Parcel* p) {
+    valueInt64 = p->readInt64();
+    return OK;
+}
+
+status_t BatteryProperty::writeToParcel(Parcel* p) const {
+    p->writeInt64(valueInt64);
+    return OK;
+}
+
+}; // namespace android
diff --git a/services/batteryservice/IBatteryPropertiesListener.cpp b/services/batteryservice/IBatteryPropertiesListener.cpp
index 19ac7f0..7555f4b 100644
--- a/services/batteryservice/IBatteryPropertiesListener.cpp
+++ b/services/batteryservice/IBatteryPropertiesListener.cpp
@@ -24,7 +24,7 @@
 class BpBatteryPropertiesListener : public BpInterface<IBatteryPropertiesListener>
 {
 public:
-    BpBatteryPropertiesListener(const sp<IBinder>& impl)
+    explicit BpBatteryPropertiesListener(const sp<IBinder>& impl)
         : BpInterface<IBatteryPropertiesListener>(impl)
     {
     }
@@ -35,7 +35,7 @@
         data.writeInterfaceToken(IBatteryPropertiesListener::getInterfaceDescriptor());
         data.writeInt32(1);
         props.writeToParcel(&data);
-        status_t err = remote()->transact(TRANSACT_BATTERYPROPERTIESCHANGED, data, &reply, IBinder::FLAG_ONEWAY);
+        remote()->transact(TRANSACT_BATTERYPROPERTIESCHANGED, data, &reply, IBinder::FLAG_ONEWAY);
     }
 };
 
diff --git a/services/batteryservice/IBatteryPropertiesRegistrar.cpp b/services/batteryservice/IBatteryPropertiesRegistrar.cpp
index 6c2d2a5..1fdda43 100644
--- a/services/batteryservice/IBatteryPropertiesRegistrar.cpp
+++ b/services/batteryservice/IBatteryPropertiesRegistrar.cpp
@@ -28,22 +28,38 @@
 
 class BpBatteryPropertiesRegistrar : public BpInterface<IBatteryPropertiesRegistrar> {
 public:
-    BpBatteryPropertiesRegistrar(const sp<IBinder>& impl)
+    explicit BpBatteryPropertiesRegistrar(const sp<IBinder>& impl)
         : BpInterface<IBatteryPropertiesRegistrar>(impl) {}
 
         void registerListener(const sp<IBatteryPropertiesListener>& listener) {
             Parcel data;
             data.writeInterfaceToken(IBatteryPropertiesRegistrar::getInterfaceDescriptor());
-            data.writeStrongBinder(listener->asBinder());
+            data.writeStrongBinder(IInterface::asBinder(listener));
             remote()->transact(REGISTER_LISTENER, data, NULL);
         }
 
         void unregisterListener(const sp<IBatteryPropertiesListener>& listener) {
             Parcel data;
             data.writeInterfaceToken(IBatteryPropertiesRegistrar::getInterfaceDescriptor());
-            data.writeStrongBinder(listener->asBinder());
+            data.writeStrongBinder(IInterface::asBinder(listener));
             remote()->transact(UNREGISTER_LISTENER, data, NULL);
         }
+
+        status_t getProperty(int id, struct BatteryProperty *val) {
+            Parcel data, reply;
+            data.writeInterfaceToken(IBatteryPropertiesRegistrar::getInterfaceDescriptor());
+            data.writeInt32(id);
+            remote()->transact(GET_PROPERTY, data, &reply);
+            int32_t ret = reply.readExceptionCode();
+            if (ret != 0) {
+                return ret;
+            }
+            ret = reply.readInt32();
+            int parcelpresent = reply.readInt32();
+            if (parcelpresent)
+                val->readFromParcel(&reply);
+            return ret;
+        }
 };
 
 IMPLEMENT_META_INTERFACE(BatteryPropertiesRegistrar, "android.os.IBatteryPropertiesRegistrar");
@@ -69,6 +85,18 @@
             unregisterListener(listener);
             return OK;
         }
+
+        case GET_PROPERTY: {
+            CHECK_INTERFACE(IBatteryPropertiesRegistrar, data, reply);
+            int id = data.readInt32();
+            struct BatteryProperty val;
+            status_t result = getProperty(id, &val);
+            reply->writeNoException();
+            reply->writeInt32(result);
+            reply->writeInt32(1);
+            val.writeToParcel(reply);
+            return OK;
+        }
     }
     return BBinder::onTransact(code, data, reply, flags);
 };
diff --git a/services/connectivitymanager/Android.mk b/services/connectivitymanager/Android.mk
deleted file mode 100644
index e986abc..0000000
--- a/services/connectivitymanager/Android.mk
+++ /dev/null
@@ -1,13 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= ConnectivityManager.cpp
-
-LOCAL_SHARED_LIBRARIES := \
-	libcutils \
-	libutils \
-	libbinder
-
-LOCAL_MODULE:= libconnectivitymanager
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/services/connectivitymanager/ConnectivityManager.cpp b/services/connectivitymanager/ConnectivityManager.cpp
deleted file mode 100644
index 949c2ac..0000000
--- a/services/connectivitymanager/ConnectivityManager.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2013, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <sys/types.h>
-
-#include <utils/Singleton.h>
-
-#include <binder/BinderService.h>
-#include <binder/Parcel.h>
-
-#include "ConnectivityManager.h"
-
-namespace android {
-
-ConnectivityManager::ConnectivityManager() {
-    const sp<IServiceManager> sm(defaultServiceManager());
-    if (sm != NULL) {
-        const String16 name("connectivity");
-        mConnectivityService = sm->getService(name);
-    }
-}
-
-void ConnectivityManager::markSocketAsUserImpl(int fd, uid_t uid) {
-    Parcel data, reply;
-    data.writeInterfaceToken(DESCRIPTOR);
-    // parcelable objects are preceded by a 1 if not null in aidl generated code.
-    // Play nice with the generated Java
-    data.writeInt32(1);
-    data.writeFileDescriptor(fd);
-    data.writeInt32(uid);
-    mConnectivityService->transact(TRANSACTION_markSocketAsUser, data, &reply, 0);
-}
-
-const String16 ConnectivityManager::DESCRIPTOR("android.net.IConnectivityManager");
-
-ANDROID_SINGLETON_STATIC_INSTANCE(ConnectivityManager)
-
-};
diff --git a/services/connectivitymanager/ConnectivityManager.h b/services/connectivitymanager/ConnectivityManager.h
deleted file mode 100644
index 37f5d98..0000000
--- a/services/connectivitymanager/ConnectivityManager.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright (c) 2013, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <utils/Singleton.h>
-
-namespace android {
-
-class ConnectivityManager : public Singleton<ConnectivityManager> {
-    // Keep this in sync with IConnectivityManager.aidl
-    static const int TRANSACTION_markSocketAsUser = IBinder::FIRST_CALL_TRANSACTION;
-    static const String16 DESCRIPTOR;
-
-    friend class Singleton<ConnectivityManager>;
-    sp<IBinder> mConnectivityService;
-
-    ConnectivityManager();
-
-    void markSocketAsUserImpl(int fd, uid_t uid);
-
-public:
-    static void markSocketAsUser(int fd, uid_t uid) {
-        ConnectivityManager::getInstance().markSocketAsUserImpl(fd, uid);
-    }
-};
-
-};
diff --git a/services/inputflinger/Android.mk b/services/inputflinger/Android.mk
new file mode 100644
index 0000000..ed867d8
--- /dev/null
+++ b/services/inputflinger/Android.mk
@@ -0,0 +1,49 @@
+# Copyright (C) 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+    EventHub.cpp \
+    InputApplication.cpp \
+    InputDispatcher.cpp \
+    InputListener.cpp \
+    InputManager.cpp \
+    InputReader.cpp \
+    InputWindow.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+    libbinder \
+    libcrypto \
+    libcutils \
+    libinput \
+    liblog \
+    libutils \
+    libui \
+    libhardware_legacy
+
+
+# TODO: Move inputflinger to its own process and mark it hidden
+#LOCAL_CFLAGS += -fvisibility=hidden
+
+LOCAL_CFLAGS += -Wno-unused-parameter
+
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
+
+LOCAL_MODULE := libinputflinger
+
+include $(BUILD_SHARED_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cpp
new file mode 100644
index 0000000..3958c8b
--- /dev/null
+++ b/services/inputflinger/EventHub.cpp
@@ -0,0 +1,1712 @@
+/*
+ * Copyright (C) 2005 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <assert.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <memory.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/epoll.h>
+#include <sys/limits.h>
+#include <sys/inotify.h>
+#include <sys/ioctl.h>
+#include <sys/utsname.h>
+#include <unistd.h>
+
+#define LOG_TAG "EventHub"
+
+// #define LOG_NDEBUG 0
+
+#include "EventHub.h"
+
+#include <hardware_legacy/power.h>
+
+#include <cutils/properties.h>
+#include <openssl/sha.h>
+#include <utils/Log.h>
+#include <utils/Timers.h>
+#include <utils/threads.h>
+#include <utils/Errors.h>
+
+#include <input/KeyLayoutMap.h>
+#include <input/KeyCharacterMap.h>
+#include <input/VirtualKeyMap.h>
+
+/* this macro is used to tell if "bit" is set in "array"
+ * it selects a byte from the array, and does a boolean AND
+ * operation with a byte that only has the relevant bit set.
+ * eg. to check for the 12th bit, we do (array[1] & 1<<4)
+ */
+#define test_bit(bit, array)    ((array)[(bit)/8] & (1<<((bit)%8)))
+
+/* this macro computes the number of bytes needed to represent a bit array of the specified size */
+#define sizeof_bit_array(bits)  (((bits) + 7) / 8)
+
+#define INDENT "  "
+#define INDENT2 "    "
+#define INDENT3 "      "
+
+namespace android {
+
+static const char *WAKE_LOCK_ID = "KeyEvents";
+static const char *DEVICE_PATH = "/dev/input";
+
+/* return the larger integer */
+static inline int max(int v1, int v2)
+{
+    return (v1 > v2) ? v1 : v2;
+}
+
+static inline const char* toString(bool value) {
+    return value ? "true" : "false";
+}
+
+static String8 sha1(const String8& in) {
+    SHA_CTX ctx;
+    SHA1_Init(&ctx);
+    SHA1_Update(&ctx, reinterpret_cast<const u_char*>(in.string()), in.size());
+    u_char digest[SHA_DIGEST_LENGTH];
+    SHA1_Final(digest, &ctx);
+
+    String8 out;
+    for (size_t i = 0; i < SHA_DIGEST_LENGTH; i++) {
+        out.appendFormat("%02x", digest[i]);
+    }
+    return out;
+}
+
+static void getLinuxRelease(int* major, int* minor) {
+    struct utsname info;
+    if (uname(&info) || sscanf(info.release, "%d.%d", major, minor) <= 0) {
+        *major = 0, *minor = 0;
+        ALOGE("Could not get linux version: %s", strerror(errno));
+    }
+}
+
+// --- Global Functions ---
+
+uint32_t getAbsAxisUsage(int32_t axis, uint32_t deviceClasses) {
+    // Touch devices get dibs on touch-related axes.
+    if (deviceClasses & INPUT_DEVICE_CLASS_TOUCH) {
+        switch (axis) {
+        case ABS_X:
+        case ABS_Y:
+        case ABS_PRESSURE:
+        case ABS_TOOL_WIDTH:
+        case ABS_DISTANCE:
+        case ABS_TILT_X:
+        case ABS_TILT_Y:
+        case ABS_MT_SLOT:
+        case ABS_MT_TOUCH_MAJOR:
+        case ABS_MT_TOUCH_MINOR:
+        case ABS_MT_WIDTH_MAJOR:
+        case ABS_MT_WIDTH_MINOR:
+        case ABS_MT_ORIENTATION:
+        case ABS_MT_POSITION_X:
+        case ABS_MT_POSITION_Y:
+        case ABS_MT_TOOL_TYPE:
+        case ABS_MT_BLOB_ID:
+        case ABS_MT_TRACKING_ID:
+        case ABS_MT_PRESSURE:
+        case ABS_MT_DISTANCE:
+            return INPUT_DEVICE_CLASS_TOUCH;
+        }
+    }
+
+    // External stylus gets the pressure axis
+    if (deviceClasses & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS) {
+        if (axis == ABS_PRESSURE) {
+            return INPUT_DEVICE_CLASS_EXTERNAL_STYLUS;
+        }
+    }
+
+    // Joystick devices get the rest.
+    return deviceClasses & INPUT_DEVICE_CLASS_JOYSTICK;
+}
+
+// --- EventHub::Device ---
+
+EventHub::Device::Device(int fd, int32_t id, const String8& path,
+        const InputDeviceIdentifier& identifier) :
+        next(NULL),
+        fd(fd), id(id), path(path), identifier(identifier),
+        classes(0), configuration(NULL), virtualKeyMap(NULL),
+        ffEffectPlaying(false), ffEffectId(-1), controllerNumber(0),
+        timestampOverrideSec(0), timestampOverrideUsec(0) {
+    memset(keyBitmask, 0, sizeof(keyBitmask));
+    memset(absBitmask, 0, sizeof(absBitmask));
+    memset(relBitmask, 0, sizeof(relBitmask));
+    memset(swBitmask, 0, sizeof(swBitmask));
+    memset(ledBitmask, 0, sizeof(ledBitmask));
+    memset(ffBitmask, 0, sizeof(ffBitmask));
+    memset(propBitmask, 0, sizeof(propBitmask));
+}
+
+EventHub::Device::~Device() {
+    close();
+    delete configuration;
+    delete virtualKeyMap;
+}
+
+void EventHub::Device::close() {
+    if (fd >= 0) {
+        ::close(fd);
+        fd = -1;
+    }
+}
+
+
+// --- EventHub ---
+
+const uint32_t EventHub::EPOLL_ID_INOTIFY;
+const uint32_t EventHub::EPOLL_ID_WAKE;
+const int EventHub::EPOLL_SIZE_HINT;
+const int EventHub::EPOLL_MAX_EVENTS;
+
+EventHub::EventHub(void) :
+        mBuiltInKeyboardId(NO_BUILT_IN_KEYBOARD), mNextDeviceId(1), mControllerNumbers(),
+        mOpeningDevices(0), mClosingDevices(0),
+        mNeedToSendFinishedDeviceScan(false),
+        mNeedToReopenDevices(false), mNeedToScanDevices(true),
+        mPendingEventCount(0), mPendingEventIndex(0), mPendingINotify(false) {
+    acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID);
+
+    mEpollFd = epoll_create(EPOLL_SIZE_HINT);
+    LOG_ALWAYS_FATAL_IF(mEpollFd < 0, "Could not create epoll instance.  errno=%d", errno);
+
+    mINotifyFd = inotify_init();
+    int result = inotify_add_watch(mINotifyFd, DEVICE_PATH, IN_DELETE | IN_CREATE);
+    LOG_ALWAYS_FATAL_IF(result < 0, "Could not register INotify for %s.  errno=%d",
+            DEVICE_PATH, errno);
+
+    struct epoll_event eventItem;
+    memset(&eventItem, 0, sizeof(eventItem));
+    eventItem.events = EPOLLIN;
+    eventItem.data.u32 = EPOLL_ID_INOTIFY;
+    result = epoll_ctl(mEpollFd, EPOLL_CTL_ADD, mINotifyFd, &eventItem);
+    LOG_ALWAYS_FATAL_IF(result != 0, "Could not add INotify to epoll instance.  errno=%d", errno);
+
+    int wakeFds[2];
+    result = pipe(wakeFds);
+    LOG_ALWAYS_FATAL_IF(result != 0, "Could not create wake pipe.  errno=%d", errno);
+
+    mWakeReadPipeFd = wakeFds[0];
+    mWakeWritePipeFd = wakeFds[1];
+
+    result = fcntl(mWakeReadPipeFd, F_SETFL, O_NONBLOCK);
+    LOG_ALWAYS_FATAL_IF(result != 0, "Could not make wake read pipe non-blocking.  errno=%d",
+            errno);
+
+    result = fcntl(mWakeWritePipeFd, F_SETFL, O_NONBLOCK);
+    LOG_ALWAYS_FATAL_IF(result != 0, "Could not make wake write pipe non-blocking.  errno=%d",
+            errno);
+
+    eventItem.data.u32 = EPOLL_ID_WAKE;
+    result = epoll_ctl(mEpollFd, EPOLL_CTL_ADD, mWakeReadPipeFd, &eventItem);
+    LOG_ALWAYS_FATAL_IF(result != 0, "Could not add wake read pipe to epoll instance.  errno=%d",
+            errno);
+
+    int major, minor;
+    getLinuxRelease(&major, &minor);
+    // EPOLLWAKEUP was introduced in kernel 3.5
+    mUsingEpollWakeup = major > 3 || (major == 3 && minor >= 5);
+}
+
+EventHub::~EventHub(void) {
+    closeAllDevicesLocked();
+
+    while (mClosingDevices) {
+        Device* device = mClosingDevices;
+        mClosingDevices = device->next;
+        delete device;
+    }
+
+    ::close(mEpollFd);
+    ::close(mINotifyFd);
+    ::close(mWakeReadPipeFd);
+    ::close(mWakeWritePipeFd);
+
+    release_wake_lock(WAKE_LOCK_ID);
+}
+
+InputDeviceIdentifier EventHub::getDeviceIdentifier(int32_t deviceId) const {
+    AutoMutex _l(mLock);
+    Device* device = getDeviceLocked(deviceId);
+    if (device == NULL) return InputDeviceIdentifier();
+    return device->identifier;
+}
+
+uint32_t EventHub::getDeviceClasses(int32_t deviceId) const {
+    AutoMutex _l(mLock);
+    Device* device = getDeviceLocked(deviceId);
+    if (device == NULL) return 0;
+    return device->classes;
+}
+
+int32_t EventHub::getDeviceControllerNumber(int32_t deviceId) const {
+    AutoMutex _l(mLock);
+    Device* device = getDeviceLocked(deviceId);
+    if (device == NULL) return 0;
+    return device->controllerNumber;
+}
+
+void EventHub::getConfiguration(int32_t deviceId, PropertyMap* outConfiguration) const {
+    AutoMutex _l(mLock);
+    Device* device = getDeviceLocked(deviceId);
+    if (device && device->configuration) {
+        *outConfiguration = *device->configuration;
+    } else {
+        outConfiguration->clear();
+    }
+}
+
+status_t EventHub::getAbsoluteAxisInfo(int32_t deviceId, int axis,
+        RawAbsoluteAxisInfo* outAxisInfo) const {
+    outAxisInfo->clear();
+
+    if (axis >= 0 && axis <= ABS_MAX) {
+        AutoMutex _l(mLock);
+
+        Device* device = getDeviceLocked(deviceId);
+        if (device && !device->isVirtual() && test_bit(axis, device->absBitmask)) {
+            struct input_absinfo info;
+            if(ioctl(device->fd, EVIOCGABS(axis), &info)) {
+                ALOGW("Error reading absolute controller %d for device %s fd %d, errno=%d",
+                     axis, device->identifier.name.string(), device->fd, errno);
+                return -errno;
+            }
+
+            if (info.minimum != info.maximum) {
+                outAxisInfo->valid = true;
+                outAxisInfo->minValue = info.minimum;
+                outAxisInfo->maxValue = info.maximum;
+                outAxisInfo->flat = info.flat;
+                outAxisInfo->fuzz = info.fuzz;
+                outAxisInfo->resolution = info.resolution;
+            }
+            return OK;
+        }
+    }
+    return -1;
+}
+
+bool EventHub::hasRelativeAxis(int32_t deviceId, int axis) const {
+    if (axis >= 0 && axis <= REL_MAX) {
+        AutoMutex _l(mLock);
+
+        Device* device = getDeviceLocked(deviceId);
+        if (device) {
+            return test_bit(axis, device->relBitmask);
+        }
+    }
+    return false;
+}
+
+bool EventHub::hasInputProperty(int32_t deviceId, int property) const {
+    if (property >= 0 && property <= INPUT_PROP_MAX) {
+        AutoMutex _l(mLock);
+
+        Device* device = getDeviceLocked(deviceId);
+        if (device) {
+            return test_bit(property, device->propBitmask);
+        }
+    }
+    return false;
+}
+
+int32_t EventHub::getScanCodeState(int32_t deviceId, int32_t scanCode) const {
+    if (scanCode >= 0 && scanCode <= KEY_MAX) {
+        AutoMutex _l(mLock);
+
+        Device* device = getDeviceLocked(deviceId);
+        if (device && !device->isVirtual() && test_bit(scanCode, device->keyBitmask)) {
+            uint8_t keyState[sizeof_bit_array(KEY_MAX + 1)];
+            memset(keyState, 0, sizeof(keyState));
+            if (ioctl(device->fd, EVIOCGKEY(sizeof(keyState)), keyState) >= 0) {
+                return test_bit(scanCode, keyState) ? AKEY_STATE_DOWN : AKEY_STATE_UP;
+            }
+        }
+    }
+    return AKEY_STATE_UNKNOWN;
+}
+
+int32_t EventHub::getKeyCodeState(int32_t deviceId, int32_t keyCode) const {
+    AutoMutex _l(mLock);
+
+    Device* device = getDeviceLocked(deviceId);
+    if (device && !device->isVirtual() && device->keyMap.haveKeyLayout()) {
+        Vector<int32_t> scanCodes;
+        device->keyMap.keyLayoutMap->findScanCodesForKey(keyCode, &scanCodes);
+        if (scanCodes.size() != 0) {
+            uint8_t keyState[sizeof_bit_array(KEY_MAX + 1)];
+            memset(keyState, 0, sizeof(keyState));
+            if (ioctl(device->fd, EVIOCGKEY(sizeof(keyState)), keyState) >= 0) {
+                for (size_t i = 0; i < scanCodes.size(); i++) {
+                    int32_t sc = scanCodes.itemAt(i);
+                    if (sc >= 0 && sc <= KEY_MAX && test_bit(sc, keyState)) {
+                        return AKEY_STATE_DOWN;
+                    }
+                }
+                return AKEY_STATE_UP;
+            }
+        }
+    }
+    return AKEY_STATE_UNKNOWN;
+}
+
+int32_t EventHub::getSwitchState(int32_t deviceId, int32_t sw) const {
+    if (sw >= 0 && sw <= SW_MAX) {
+        AutoMutex _l(mLock);
+
+        Device* device = getDeviceLocked(deviceId);
+        if (device && !device->isVirtual() && test_bit(sw, device->swBitmask)) {
+            uint8_t swState[sizeof_bit_array(SW_MAX + 1)];
+            memset(swState, 0, sizeof(swState));
+            if (ioctl(device->fd, EVIOCGSW(sizeof(swState)), swState) >= 0) {
+                return test_bit(sw, swState) ? AKEY_STATE_DOWN : AKEY_STATE_UP;
+            }
+        }
+    }
+    return AKEY_STATE_UNKNOWN;
+}
+
+status_t EventHub::getAbsoluteAxisValue(int32_t deviceId, int32_t axis, int32_t* outValue) const {
+    *outValue = 0;
+
+    if (axis >= 0 && axis <= ABS_MAX) {
+        AutoMutex _l(mLock);
+
+        Device* device = getDeviceLocked(deviceId);
+        if (device && !device->isVirtual() && test_bit(axis, device->absBitmask)) {
+            struct input_absinfo info;
+            if(ioctl(device->fd, EVIOCGABS(axis), &info)) {
+                ALOGW("Error reading absolute controller %d for device %s fd %d, errno=%d",
+                     axis, device->identifier.name.string(), device->fd, errno);
+                return -errno;
+            }
+
+            *outValue = info.value;
+            return OK;
+        }
+    }
+    return -1;
+}
+
+bool EventHub::markSupportedKeyCodes(int32_t deviceId, size_t numCodes,
+        const int32_t* keyCodes, uint8_t* outFlags) const {
+    AutoMutex _l(mLock);
+
+    Device* device = getDeviceLocked(deviceId);
+    if (device && device->keyMap.haveKeyLayout()) {
+        Vector<int32_t> scanCodes;
+        for (size_t codeIndex = 0; codeIndex < numCodes; codeIndex++) {
+            scanCodes.clear();
+
+            status_t err = device->keyMap.keyLayoutMap->findScanCodesForKey(
+                    keyCodes[codeIndex], &scanCodes);
+            if (! err) {
+                // check the possible scan codes identified by the layout map against the
+                // map of codes actually emitted by the driver
+                for (size_t sc = 0; sc < scanCodes.size(); sc++) {
+                    if (test_bit(scanCodes[sc], device->keyBitmask)) {
+                        outFlags[codeIndex] = 1;
+                        break;
+                    }
+                }
+            }
+        }
+        return true;
+    }
+    return false;
+}
+
+status_t EventHub::mapKey(int32_t deviceId,
+        int32_t scanCode, int32_t usageCode, int32_t metaState,
+        int32_t* outKeycode, int32_t* outMetaState, uint32_t* outFlags) const {
+    AutoMutex _l(mLock);
+    Device* device = getDeviceLocked(deviceId);
+    status_t status = NAME_NOT_FOUND;
+
+    if (device) {
+        // Check the key character map first.
+        sp<KeyCharacterMap> kcm = device->getKeyCharacterMap();
+        if (kcm != NULL) {
+            if (!kcm->mapKey(scanCode, usageCode, outKeycode)) {
+                *outFlags = 0;
+                status = NO_ERROR;
+            }
+        }
+
+        // Check the key layout next.
+        if (status != NO_ERROR && device->keyMap.haveKeyLayout()) {
+            if (!device->keyMap.keyLayoutMap->mapKey(
+                    scanCode, usageCode, outKeycode, outFlags)) {
+                status = NO_ERROR;
+            }
+        }
+
+        if (status == NO_ERROR) {
+            if (kcm != NULL) {
+                kcm->tryRemapKey(*outKeycode, metaState, outKeycode, outMetaState);
+            } else {
+                *outMetaState = metaState;
+            }
+        }
+    }
+
+    if (status != NO_ERROR) {
+        *outKeycode = 0;
+        *outFlags = 0;
+        *outMetaState = metaState;
+    }
+
+    return status;
+}
+
+status_t EventHub::mapAxis(int32_t deviceId, int32_t scanCode, AxisInfo* outAxisInfo) const {
+    AutoMutex _l(mLock);
+    Device* device = getDeviceLocked(deviceId);
+
+    if (device && device->keyMap.haveKeyLayout()) {
+        status_t err = device->keyMap.keyLayoutMap->mapAxis(scanCode, outAxisInfo);
+        if (err == NO_ERROR) {
+            return NO_ERROR;
+        }
+    }
+
+    return NAME_NOT_FOUND;
+}
+
+void EventHub::setExcludedDevices(const Vector<String8>& devices) {
+    AutoMutex _l(mLock);
+
+    mExcludedDevices = devices;
+}
+
+bool EventHub::hasScanCode(int32_t deviceId, int32_t scanCode) const {
+    AutoMutex _l(mLock);
+    Device* device = getDeviceLocked(deviceId);
+    if (device && scanCode >= 0 && scanCode <= KEY_MAX) {
+        if (test_bit(scanCode, device->keyBitmask)) {
+            return true;
+        }
+    }
+    return false;
+}
+
+bool EventHub::hasLed(int32_t deviceId, int32_t led) const {
+    AutoMutex _l(mLock);
+    Device* device = getDeviceLocked(deviceId);
+    int32_t sc;
+    if (device && mapLed(device, led, &sc) == NO_ERROR) {
+        if (test_bit(sc, device->ledBitmask)) {
+            return true;
+        }
+    }
+    return false;
+}
+
+void EventHub::setLedState(int32_t deviceId, int32_t led, bool on) {
+    AutoMutex _l(mLock);
+    Device* device = getDeviceLocked(deviceId);
+    setLedStateLocked(device, led, on);
+}
+
+void EventHub::setLedStateLocked(Device* device, int32_t led, bool on) {
+    int32_t sc;
+    if (device && !device->isVirtual() && mapLed(device, led, &sc) != NAME_NOT_FOUND) {
+        struct input_event ev;
+        ev.time.tv_sec = 0;
+        ev.time.tv_usec = 0;
+        ev.type = EV_LED;
+        ev.code = sc;
+        ev.value = on ? 1 : 0;
+
+        ssize_t nWrite;
+        do {
+            nWrite = write(device->fd, &ev, sizeof(struct input_event));
+        } while (nWrite == -1 && errno == EINTR);
+    }
+}
+
+void EventHub::getVirtualKeyDefinitions(int32_t deviceId,
+        Vector<VirtualKeyDefinition>& outVirtualKeys) const {
+    outVirtualKeys.clear();
+
+    AutoMutex _l(mLock);
+    Device* device = getDeviceLocked(deviceId);
+    if (device && device->virtualKeyMap) {
+        outVirtualKeys.appendVector(device->virtualKeyMap->getVirtualKeys());
+    }
+}
+
+sp<KeyCharacterMap> EventHub::getKeyCharacterMap(int32_t deviceId) const {
+    AutoMutex _l(mLock);
+    Device* device = getDeviceLocked(deviceId);
+    if (device) {
+        return device->getKeyCharacterMap();
+    }
+    return NULL;
+}
+
+bool EventHub::setKeyboardLayoutOverlay(int32_t deviceId,
+        const sp<KeyCharacterMap>& map) {
+    AutoMutex _l(mLock);
+    Device* device = getDeviceLocked(deviceId);
+    if (device) {
+        if (map != device->overlayKeyMap) {
+            device->overlayKeyMap = map;
+            device->combinedKeyMap = KeyCharacterMap::combine(
+                    device->keyMap.keyCharacterMap, map);
+            return true;
+        }
+    }
+    return false;
+}
+
+static String8 generateDescriptor(InputDeviceIdentifier& identifier) {
+    String8 rawDescriptor;
+    rawDescriptor.appendFormat(":%04x:%04x:", identifier.vendor,
+            identifier.product);
+    // TODO add handling for USB devices to not uniqueify kbs that show up twice
+    if (!identifier.uniqueId.isEmpty()) {
+        rawDescriptor.append("uniqueId:");
+        rawDescriptor.append(identifier.uniqueId);
+    } else if (identifier.nonce != 0) {
+        rawDescriptor.appendFormat("nonce:%04x", identifier.nonce);
+    }
+
+    if (identifier.vendor == 0 && identifier.product == 0) {
+        // If we don't know the vendor and product id, then the device is probably
+        // built-in so we need to rely on other information to uniquely identify
+        // the input device.  Usually we try to avoid relying on the device name or
+        // location but for built-in input device, they are unlikely to ever change.
+        if (!identifier.name.isEmpty()) {
+            rawDescriptor.append("name:");
+            rawDescriptor.append(identifier.name);
+        } else if (!identifier.location.isEmpty()) {
+            rawDescriptor.append("location:");
+            rawDescriptor.append(identifier.location);
+        }
+    }
+    identifier.descriptor = sha1(rawDescriptor);
+    return rawDescriptor;
+}
+
+void EventHub::assignDescriptorLocked(InputDeviceIdentifier& identifier) {
+    // Compute a device descriptor that uniquely identifies the device.
+    // The descriptor is assumed to be a stable identifier.  Its value should not
+    // change between reboots, reconnections, firmware updates or new releases
+    // of Android. In practice we sometimes get devices that cannot be uniquely
+    // identified. In this case we enforce uniqueness between connected devices.
+    // Ideally, we also want the descriptor to be short and relatively opaque.
+
+    identifier.nonce = 0;
+    String8 rawDescriptor = generateDescriptor(identifier);
+    if (identifier.uniqueId.isEmpty()) {
+        // If it didn't have a unique id check for conflicts and enforce
+        // uniqueness if necessary.
+        while(getDeviceByDescriptorLocked(identifier.descriptor) != NULL) {
+            identifier.nonce++;
+            rawDescriptor = generateDescriptor(identifier);
+        }
+    }
+    ALOGV("Created descriptor: raw=%s, cooked=%s", rawDescriptor.string(),
+            identifier.descriptor.string());
+}
+
+void EventHub::vibrate(int32_t deviceId, nsecs_t duration) {
+    AutoMutex _l(mLock);
+    Device* device = getDeviceLocked(deviceId);
+    if (device && !device->isVirtual()) {
+        ff_effect effect;
+        memset(&effect, 0, sizeof(effect));
+        effect.type = FF_RUMBLE;
+        effect.id = device->ffEffectId;
+        effect.u.rumble.strong_magnitude = 0xc000;
+        effect.u.rumble.weak_magnitude = 0xc000;
+        effect.replay.length = (duration + 999999LL) / 1000000LL;
+        effect.replay.delay = 0;
+        if (ioctl(device->fd, EVIOCSFF, &effect)) {
+            ALOGW("Could not upload force feedback effect to device %s due to error %d.",
+                    device->identifier.name.string(), errno);
+            return;
+        }
+        device->ffEffectId = effect.id;
+
+        struct input_event ev;
+        ev.time.tv_sec = 0;
+        ev.time.tv_usec = 0;
+        ev.type = EV_FF;
+        ev.code = device->ffEffectId;
+        ev.value = 1;
+        if (write(device->fd, &ev, sizeof(ev)) != sizeof(ev)) {
+            ALOGW("Could not start force feedback effect on device %s due to error %d.",
+                    device->identifier.name.string(), errno);
+            return;
+        }
+        device->ffEffectPlaying = true;
+    }
+}
+
+void EventHub::cancelVibrate(int32_t deviceId) {
+    AutoMutex _l(mLock);
+    Device* device = getDeviceLocked(deviceId);
+    if (device && !device->isVirtual()) {
+        if (device->ffEffectPlaying) {
+            device->ffEffectPlaying = false;
+
+            struct input_event ev;
+            ev.time.tv_sec = 0;
+            ev.time.tv_usec = 0;
+            ev.type = EV_FF;
+            ev.code = device->ffEffectId;
+            ev.value = 0;
+            if (write(device->fd, &ev, sizeof(ev)) != sizeof(ev)) {
+                ALOGW("Could not stop force feedback effect on device %s due to error %d.",
+                        device->identifier.name.string(), errno);
+                return;
+            }
+        }
+    }
+}
+
+EventHub::Device* EventHub::getDeviceByDescriptorLocked(String8& descriptor) const {
+    size_t size = mDevices.size();
+    for (size_t i = 0; i < size; i++) {
+        Device* device = mDevices.valueAt(i);
+        if (descriptor.compare(device->identifier.descriptor) == 0) {
+            return device;
+        }
+    }
+    return NULL;
+}
+
+EventHub::Device* EventHub::getDeviceLocked(int32_t deviceId) const {
+    if (deviceId == BUILT_IN_KEYBOARD_ID) {
+        deviceId = mBuiltInKeyboardId;
+    }
+    ssize_t index = mDevices.indexOfKey(deviceId);
+    return index >= 0 ? mDevices.valueAt(index) : NULL;
+}
+
+EventHub::Device* EventHub::getDeviceByPathLocked(const char* devicePath) const {
+    for (size_t i = 0; i < mDevices.size(); i++) {
+        Device* device = mDevices.valueAt(i);
+        if (device->path == devicePath) {
+            return device;
+        }
+    }
+    return NULL;
+}
+
+size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSize) {
+    ALOG_ASSERT(bufferSize >= 1);
+
+    AutoMutex _l(mLock);
+
+    struct input_event readBuffer[bufferSize];
+
+    RawEvent* event = buffer;
+    size_t capacity = bufferSize;
+    bool awoken = false;
+    for (;;) {
+        nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);
+
+        // Reopen input devices if needed.
+        if (mNeedToReopenDevices) {
+            mNeedToReopenDevices = false;
+
+            ALOGI("Reopening all input devices due to a configuration change.");
+
+            closeAllDevicesLocked();
+            mNeedToScanDevices = true;
+            break; // return to the caller before we actually rescan
+        }
+
+        // Report any devices that had last been added/removed.
+        while (mClosingDevices) {
+            Device* device = mClosingDevices;
+            ALOGV("Reporting device closed: id=%d, name=%s\n",
+                 device->id, device->path.string());
+            mClosingDevices = device->next;
+            event->when = now;
+            event->deviceId = device->id == mBuiltInKeyboardId ? BUILT_IN_KEYBOARD_ID : device->id;
+            event->type = DEVICE_REMOVED;
+            event += 1;
+            delete device;
+            mNeedToSendFinishedDeviceScan = true;
+            if (--capacity == 0) {
+                break;
+            }
+        }
+
+        if (mNeedToScanDevices) {
+            mNeedToScanDevices = false;
+            scanDevicesLocked();
+            mNeedToSendFinishedDeviceScan = true;
+        }
+
+        while (mOpeningDevices != NULL) {
+            Device* device = mOpeningDevices;
+            ALOGV("Reporting device opened: id=%d, name=%s\n",
+                 device->id, device->path.string());
+            mOpeningDevices = device->next;
+            event->when = now;
+            event->deviceId = device->id == mBuiltInKeyboardId ? 0 : device->id;
+            event->type = DEVICE_ADDED;
+            event += 1;
+            mNeedToSendFinishedDeviceScan = true;
+            if (--capacity == 0) {
+                break;
+            }
+        }
+
+        if (mNeedToSendFinishedDeviceScan) {
+            mNeedToSendFinishedDeviceScan = false;
+            event->when = now;
+            event->type = FINISHED_DEVICE_SCAN;
+            event += 1;
+            if (--capacity == 0) {
+                break;
+            }
+        }
+
+        // Grab the next input event.
+        bool deviceChanged = false;
+        while (mPendingEventIndex < mPendingEventCount) {
+            const struct epoll_event& eventItem = mPendingEventItems[mPendingEventIndex++];
+            if (eventItem.data.u32 == EPOLL_ID_INOTIFY) {
+                if (eventItem.events & EPOLLIN) {
+                    mPendingINotify = true;
+                } else {
+                    ALOGW("Received unexpected epoll event 0x%08x for INotify.", eventItem.events);
+                }
+                continue;
+            }
+
+            if (eventItem.data.u32 == EPOLL_ID_WAKE) {
+                if (eventItem.events & EPOLLIN) {
+                    ALOGV("awoken after wake()");
+                    awoken = true;
+                    char buffer[16];
+                    ssize_t nRead;
+                    do {
+                        nRead = read(mWakeReadPipeFd, buffer, sizeof(buffer));
+                    } while ((nRead == -1 && errno == EINTR) || nRead == sizeof(buffer));
+                } else {
+                    ALOGW("Received unexpected epoll event 0x%08x for wake read pipe.",
+                            eventItem.events);
+                }
+                continue;
+            }
+
+            ssize_t deviceIndex = mDevices.indexOfKey(eventItem.data.u32);
+            if (deviceIndex < 0) {
+                ALOGW("Received unexpected epoll event 0x%08x for unknown device id %d.",
+                        eventItem.events, eventItem.data.u32);
+                continue;
+            }
+
+            Device* device = mDevices.valueAt(deviceIndex);
+            if (eventItem.events & EPOLLIN) {
+                int32_t readSize = read(device->fd, readBuffer,
+                        sizeof(struct input_event) * capacity);
+                if (readSize == 0 || (readSize < 0 && errno == ENODEV)) {
+                    // Device was removed before INotify noticed.
+                    ALOGW("could not get event, removed? (fd: %d size: %" PRId32
+                            " bufferSize: %zu capacity: %zu errno: %d)\n",
+                            device->fd, readSize, bufferSize, capacity, errno);
+                    deviceChanged = true;
+                    closeDeviceLocked(device);
+                } else if (readSize < 0) {
+                    if (errno != EAGAIN && errno != EINTR) {
+                        ALOGW("could not get event (errno=%d)", errno);
+                    }
+                } else if ((readSize % sizeof(struct input_event)) != 0) {
+                    ALOGE("could not get event (wrong size: %d)", readSize);
+                } else {
+                    int32_t deviceId = device->id == mBuiltInKeyboardId ? 0 : device->id;
+
+                    size_t count = size_t(readSize) / sizeof(struct input_event);
+                    for (size_t i = 0; i < count; i++) {
+                        struct input_event& iev = readBuffer[i];
+                        ALOGV("%s got: time=%d.%06d, type=%d, code=%d, value=%d",
+                                device->path.string(),
+                                (int) iev.time.tv_sec, (int) iev.time.tv_usec,
+                                iev.type, iev.code, iev.value);
+
+                        // Some input devices may have a better concept of the time
+                        // when an input event was actually generated than the kernel
+                        // which simply timestamps all events on entry to evdev.
+                        // This is a custom Android extension of the input protocol
+                        // mainly intended for use with uinput based device drivers.
+                        if (iev.type == EV_MSC) {
+                            if (iev.code == MSC_ANDROID_TIME_SEC) {
+                                device->timestampOverrideSec = iev.value;
+                                continue;
+                            } else if (iev.code == MSC_ANDROID_TIME_USEC) {
+                                device->timestampOverrideUsec = iev.value;
+                                continue;
+                            }
+                        }
+                        if (device->timestampOverrideSec || device->timestampOverrideUsec) {
+                            iev.time.tv_sec = device->timestampOverrideSec;
+                            iev.time.tv_usec = device->timestampOverrideUsec;
+                            if (iev.type == EV_SYN && iev.code == SYN_REPORT) {
+                                device->timestampOverrideSec = 0;
+                                device->timestampOverrideUsec = 0;
+                            }
+                            ALOGV("applied override time %d.%06d",
+                                    int(iev.time.tv_sec), int(iev.time.tv_usec));
+                        }
+
+                        // Use the time specified in the event instead of the current time
+                        // so that downstream code can get more accurate estimates of
+                        // event dispatch latency from the time the event is enqueued onto
+                        // the evdev client buffer.
+                        //
+                        // The event's timestamp fortuitously uses the same monotonic clock
+                        // time base as the rest of Android.  The kernel event device driver
+                        // (drivers/input/evdev.c) obtains timestamps using ktime_get_ts().
+                        // The systemTime(SYSTEM_TIME_MONOTONIC) function we use everywhere
+                        // calls clock_gettime(CLOCK_MONOTONIC) which is implemented as a
+                        // system call that also queries ktime_get_ts().
+                        event->when = nsecs_t(iev.time.tv_sec) * 1000000000LL
+                                + nsecs_t(iev.time.tv_usec) * 1000LL;
+                        ALOGV("event time %" PRId64 ", now %" PRId64, event->when, now);
+
+                        // Bug 7291243: Add a guard in case the kernel generates timestamps
+                        // that appear to be far into the future because they were generated
+                        // using the wrong clock source.
+                        //
+                        // This can happen because when the input device is initially opened
+                        // it has a default clock source of CLOCK_REALTIME.  Any input events
+                        // enqueued right after the device is opened will have timestamps
+                        // generated using CLOCK_REALTIME.  We later set the clock source
+                        // to CLOCK_MONOTONIC but it is already too late.
+                        //
+                        // Invalid input event timestamps can result in ANRs, crashes and
+                        // and other issues that are hard to track down.  We must not let them
+                        // propagate through the system.
+                        //
+                        // Log a warning so that we notice the problem and recover gracefully.
+                        if (event->when >= now + 10 * 1000000000LL) {
+                            // Double-check.  Time may have moved on.
+                            nsecs_t time = systemTime(SYSTEM_TIME_MONOTONIC);
+                            if (event->when > time) {
+                                ALOGW("An input event from %s has a timestamp that appears to "
+                                        "have been generated using the wrong clock source "
+                                        "(expected CLOCK_MONOTONIC): "
+                                        "event time %" PRId64 ", current time %" PRId64
+                                        ", call time %" PRId64 ".  "
+                                        "Using current time instead.",
+                                        device->path.string(), event->when, time, now);
+                                event->when = time;
+                            } else {
+                                ALOGV("Event time is ok but failed the fast path and required "
+                                        "an extra call to systemTime: "
+                                        "event time %" PRId64 ", current time %" PRId64
+                                        ", call time %" PRId64 ".",
+                                        event->when, time, now);
+                            }
+                        }
+                        event->deviceId = deviceId;
+                        event->type = iev.type;
+                        event->code = iev.code;
+                        event->value = iev.value;
+                        event += 1;
+                        capacity -= 1;
+                    }
+                    if (capacity == 0) {
+                        // The result buffer is full.  Reset the pending event index
+                        // so we will try to read the device again on the next iteration.
+                        mPendingEventIndex -= 1;
+                        break;
+                    }
+                }
+            } else if (eventItem.events & EPOLLHUP) {
+                ALOGI("Removing device %s due to epoll hang-up event.",
+                        device->identifier.name.string());
+                deviceChanged = true;
+                closeDeviceLocked(device);
+            } else {
+                ALOGW("Received unexpected epoll event 0x%08x for device %s.",
+                        eventItem.events, device->identifier.name.string());
+            }
+        }
+
+        // readNotify() will modify the list of devices so this must be done after
+        // processing all other events to ensure that we read all remaining events
+        // before closing the devices.
+        if (mPendingINotify && mPendingEventIndex >= mPendingEventCount) {
+            mPendingINotify = false;
+            readNotifyLocked();
+            deviceChanged = true;
+        }
+
+        // Report added or removed devices immediately.
+        if (deviceChanged) {
+            continue;
+        }
+
+        // Return now if we have collected any events or if we were explicitly awoken.
+        if (event != buffer || awoken) {
+            break;
+        }
+
+        // Poll for events.  Mind the wake lock dance!
+        // We hold a wake lock at all times except during epoll_wait().  This works due to some
+        // subtle choreography.  When a device driver has pending (unread) events, it acquires
+        // a kernel wake lock.  However, once the last pending event has been read, the device
+        // driver will release the kernel wake lock.  To prevent the system from going to sleep
+        // when this happens, the EventHub holds onto its own user wake lock while the client
+        // is processing events.  Thus the system can only sleep if there are no events
+        // pending or currently being processed.
+        //
+        // The timeout is advisory only.  If the device is asleep, it will not wake just to
+        // service the timeout.
+        mPendingEventIndex = 0;
+
+        mLock.unlock(); // release lock before poll, must be before release_wake_lock
+        release_wake_lock(WAKE_LOCK_ID);
+
+        int pollResult = epoll_wait(mEpollFd, mPendingEventItems, EPOLL_MAX_EVENTS, timeoutMillis);
+
+        acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID);
+        mLock.lock(); // reacquire lock after poll, must be after acquire_wake_lock
+
+        if (pollResult == 0) {
+            // Timed out.
+            mPendingEventCount = 0;
+            break;
+        }
+
+        if (pollResult < 0) {
+            // An error occurred.
+            mPendingEventCount = 0;
+
+            // Sleep after errors to avoid locking up the system.
+            // Hopefully the error is transient.
+            if (errno != EINTR) {
+                ALOGW("poll failed (errno=%d)\n", errno);
+                usleep(100000);
+            }
+        } else {
+            // Some events occurred.
+            mPendingEventCount = size_t(pollResult);
+        }
+    }
+
+    // All done, return the number of events we read.
+    return event - buffer;
+}
+
+void EventHub::wake() {
+    ALOGV("wake() called");
+
+    ssize_t nWrite;
+    do {
+        nWrite = write(mWakeWritePipeFd, "W", 1);
+    } while (nWrite == -1 && errno == EINTR);
+
+    if (nWrite != 1 && errno != EAGAIN) {
+        ALOGW("Could not write wake signal, errno=%d", errno);
+    }
+}
+
+void EventHub::scanDevicesLocked() {
+    status_t res = scanDirLocked(DEVICE_PATH);
+    if(res < 0) {
+        ALOGE("scan dir failed for %s\n", DEVICE_PATH);
+    }
+    if (mDevices.indexOfKey(VIRTUAL_KEYBOARD_ID) < 0) {
+        createVirtualKeyboardLocked();
+    }
+}
+
+// ----------------------------------------------------------------------------
+
+static bool containsNonZeroByte(const uint8_t* array, uint32_t startIndex, uint32_t endIndex) {
+    const uint8_t* end = array + endIndex;
+    array += startIndex;
+    while (array != end) {
+        if (*(array++) != 0) {
+            return true;
+        }
+    }
+    return false;
+}
+
+static const int32_t GAMEPAD_KEYCODES[] = {
+        AKEYCODE_BUTTON_A, AKEYCODE_BUTTON_B, AKEYCODE_BUTTON_C,
+        AKEYCODE_BUTTON_X, AKEYCODE_BUTTON_Y, AKEYCODE_BUTTON_Z,
+        AKEYCODE_BUTTON_L1, AKEYCODE_BUTTON_R1,
+        AKEYCODE_BUTTON_L2, AKEYCODE_BUTTON_R2,
+        AKEYCODE_BUTTON_THUMBL, AKEYCODE_BUTTON_THUMBR,
+        AKEYCODE_BUTTON_START, AKEYCODE_BUTTON_SELECT, AKEYCODE_BUTTON_MODE,
+};
+
+status_t EventHub::openDeviceLocked(const char *devicePath) {
+    char buffer[80];
+
+    ALOGV("Opening device: %s", devicePath);
+
+    int fd = open(devicePath, O_RDWR | O_CLOEXEC);
+    if(fd < 0) {
+        ALOGE("could not open %s, %s\n", devicePath, strerror(errno));
+        return -1;
+    }
+
+    InputDeviceIdentifier identifier;
+
+    // Get device name.
+    if(ioctl(fd, EVIOCGNAME(sizeof(buffer) - 1), &buffer) < 1) {
+        //fprintf(stderr, "could not get device name for %s, %s\n", devicePath, strerror(errno));
+    } else {
+        buffer[sizeof(buffer) - 1] = '\0';
+        identifier.name.setTo(buffer);
+    }
+
+    // Check to see if the device is on our excluded list
+    for (size_t i = 0; i < mExcludedDevices.size(); i++) {
+        const String8& item = mExcludedDevices.itemAt(i);
+        if (identifier.name == item) {
+            ALOGI("ignoring event id %s driver %s\n", devicePath, item.string());
+            close(fd);
+            return -1;
+        }
+    }
+
+    // Get device driver version.
+    int driverVersion;
+    if(ioctl(fd, EVIOCGVERSION, &driverVersion)) {
+        ALOGE("could not get driver version for %s, %s\n", devicePath, strerror(errno));
+        close(fd);
+        return -1;
+    }
+
+    // Get device identifier.
+    struct input_id inputId;
+    if(ioctl(fd, EVIOCGID, &inputId)) {
+        ALOGE("could not get device input id for %s, %s\n", devicePath, strerror(errno));
+        close(fd);
+        return -1;
+    }
+    identifier.bus = inputId.bustype;
+    identifier.product = inputId.product;
+    identifier.vendor = inputId.vendor;
+    identifier.version = inputId.version;
+
+    // Get device physical location.
+    if(ioctl(fd, EVIOCGPHYS(sizeof(buffer) - 1), &buffer) < 1) {
+        //fprintf(stderr, "could not get location for %s, %s\n", devicePath, strerror(errno));
+    } else {
+        buffer[sizeof(buffer) - 1] = '\0';
+        identifier.location.setTo(buffer);
+    }
+
+    // Get device unique id.
+    if(ioctl(fd, EVIOCGUNIQ(sizeof(buffer) - 1), &buffer) < 1) {
+        //fprintf(stderr, "could not get idstring for %s, %s\n", devicePath, strerror(errno));
+    } else {
+        buffer[sizeof(buffer) - 1] = '\0';
+        identifier.uniqueId.setTo(buffer);
+    }
+
+    // Fill in the descriptor.
+    assignDescriptorLocked(identifier);
+
+    // Make file descriptor non-blocking for use with poll().
+    if (fcntl(fd, F_SETFL, O_NONBLOCK)) {
+        ALOGE("Error %d making device file descriptor non-blocking.", errno);
+        close(fd);
+        return -1;
+    }
+
+    // Allocate device.  (The device object takes ownership of the fd at this point.)
+    int32_t deviceId = mNextDeviceId++;
+    Device* device = new Device(fd, deviceId, String8(devicePath), identifier);
+
+    ALOGV("add device %d: %s\n", deviceId, devicePath);
+    ALOGV("  bus:        %04x\n"
+         "  vendor      %04x\n"
+         "  product     %04x\n"
+         "  version     %04x\n",
+        identifier.bus, identifier.vendor, identifier.product, identifier.version);
+    ALOGV("  name:       \"%s\"\n", identifier.name.string());
+    ALOGV("  location:   \"%s\"\n", identifier.location.string());
+    ALOGV("  unique id:  \"%s\"\n", identifier.uniqueId.string());
+    ALOGV("  descriptor: \"%s\"\n", identifier.descriptor.string());
+    ALOGV("  driver:     v%d.%d.%d\n",
+        driverVersion >> 16, (driverVersion >> 8) & 0xff, driverVersion & 0xff);
+
+    // Load the configuration file for the device.
+    loadConfigurationLocked(device);
+
+    // Figure out the kinds of events the device reports.
+    ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(device->keyBitmask)), device->keyBitmask);
+    ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(device->absBitmask)), device->absBitmask);
+    ioctl(fd, EVIOCGBIT(EV_REL, sizeof(device->relBitmask)), device->relBitmask);
+    ioctl(fd, EVIOCGBIT(EV_SW, sizeof(device->swBitmask)), device->swBitmask);
+    ioctl(fd, EVIOCGBIT(EV_LED, sizeof(device->ledBitmask)), device->ledBitmask);
+    ioctl(fd, EVIOCGBIT(EV_FF, sizeof(device->ffBitmask)), device->ffBitmask);
+    ioctl(fd, EVIOCGPROP(sizeof(device->propBitmask)), device->propBitmask);
+
+    // See if this is a keyboard.  Ignore everything in the button range except for
+    // joystick and gamepad buttons which are handled like keyboards for the most part.
+    bool haveKeyboardKeys = containsNonZeroByte(device->keyBitmask, 0, sizeof_bit_array(BTN_MISC))
+            || containsNonZeroByte(device->keyBitmask, sizeof_bit_array(KEY_OK),
+                    sizeof_bit_array(KEY_MAX + 1));
+    bool haveGamepadButtons = containsNonZeroByte(device->keyBitmask, sizeof_bit_array(BTN_MISC),
+                    sizeof_bit_array(BTN_MOUSE))
+            || containsNonZeroByte(device->keyBitmask, sizeof_bit_array(BTN_JOYSTICK),
+                    sizeof_bit_array(BTN_DIGI));
+    if (haveKeyboardKeys || haveGamepadButtons) {
+        device->classes |= INPUT_DEVICE_CLASS_KEYBOARD;
+    }
+
+    // See if this is a cursor device such as a trackball or mouse.
+    if (test_bit(BTN_MOUSE, device->keyBitmask)
+            && test_bit(REL_X, device->relBitmask)
+            && test_bit(REL_Y, device->relBitmask)) {
+        device->classes |= INPUT_DEVICE_CLASS_CURSOR;
+    }
+
+    // See if this is a touch pad.
+    // Is this a new modern multi-touch driver?
+    if (test_bit(ABS_MT_POSITION_X, device->absBitmask)
+            && test_bit(ABS_MT_POSITION_Y, device->absBitmask)) {
+        // Some joysticks such as the PS3 controller report axes that conflict
+        // with the ABS_MT range.  Try to confirm that the device really is
+        // a touch screen.
+        if (test_bit(BTN_TOUCH, device->keyBitmask) || !haveGamepadButtons) {
+            device->classes |= INPUT_DEVICE_CLASS_TOUCH | INPUT_DEVICE_CLASS_TOUCH_MT;
+        }
+    // Is this an old style single-touch driver?
+    } else if (test_bit(BTN_TOUCH, device->keyBitmask)
+            && test_bit(ABS_X, device->absBitmask)
+            && test_bit(ABS_Y, device->absBitmask)) {
+        device->classes |= INPUT_DEVICE_CLASS_TOUCH;
+    // Is this a BT stylus?
+    } else if ((test_bit(ABS_PRESSURE, device->absBitmask) ||
+                test_bit(BTN_TOUCH, device->keyBitmask))
+            && !test_bit(ABS_X, device->absBitmask)
+            && !test_bit(ABS_Y, device->absBitmask)) {
+        device->classes |= INPUT_DEVICE_CLASS_EXTERNAL_STYLUS;
+        // Keyboard will try to claim some of the buttons but we really want to reserve those so we
+        // can fuse it with the touch screen data, so just take them back. Note this means an
+        // external stylus cannot also be a keyboard device.
+        device->classes &= ~INPUT_DEVICE_CLASS_KEYBOARD;
+    }
+
+    // See if this device is a joystick.
+    // Assumes that joysticks always have gamepad buttons in order to distinguish them
+    // from other devices such as accelerometers that also have absolute axes.
+    if (haveGamepadButtons) {
+        uint32_t assumedClasses = device->classes | INPUT_DEVICE_CLASS_JOYSTICK;
+        for (int i = 0; i <= ABS_MAX; i++) {
+            if (test_bit(i, device->absBitmask)
+                    && (getAbsAxisUsage(i, assumedClasses) & INPUT_DEVICE_CLASS_JOYSTICK)) {
+                device->classes = assumedClasses;
+                break;
+            }
+        }
+    }
+
+    // Check whether this device has switches.
+    for (int i = 0; i <= SW_MAX; i++) {
+        if (test_bit(i, device->swBitmask)) {
+            device->classes |= INPUT_DEVICE_CLASS_SWITCH;
+            break;
+        }
+    }
+
+    // Check whether this device supports the vibrator.
+    if (test_bit(FF_RUMBLE, device->ffBitmask)) {
+        device->classes |= INPUT_DEVICE_CLASS_VIBRATOR;
+    }
+
+    // Configure virtual keys.
+    if ((device->classes & INPUT_DEVICE_CLASS_TOUCH)) {
+        // Load the virtual keys for the touch screen, if any.
+        // We do this now so that we can make sure to load the keymap if necessary.
+        status_t status = loadVirtualKeyMapLocked(device);
+        if (!status) {
+            device->classes |= INPUT_DEVICE_CLASS_KEYBOARD;
+        }
+    }
+
+    // Load the key map.
+    // We need to do this for joysticks too because the key layout may specify axes.
+    status_t keyMapStatus = NAME_NOT_FOUND;
+    if (device->classes & (INPUT_DEVICE_CLASS_KEYBOARD | INPUT_DEVICE_CLASS_JOYSTICK)) {
+        // Load the keymap for the device.
+        keyMapStatus = loadKeyMapLocked(device);
+    }
+
+    // Configure the keyboard, gamepad or virtual keyboard.
+    if (device->classes & INPUT_DEVICE_CLASS_KEYBOARD) {
+        // Register the keyboard as a built-in keyboard if it is eligible.
+        if (!keyMapStatus
+                && mBuiltInKeyboardId == NO_BUILT_IN_KEYBOARD
+                && isEligibleBuiltInKeyboard(device->identifier,
+                        device->configuration, &device->keyMap)) {
+            mBuiltInKeyboardId = device->id;
+        }
+
+        // 'Q' key support = cheap test of whether this is an alpha-capable kbd
+        if (hasKeycodeLocked(device, AKEYCODE_Q)) {
+            device->classes |= INPUT_DEVICE_CLASS_ALPHAKEY;
+        }
+
+        // See if this device has a DPAD.
+        if (hasKeycodeLocked(device, AKEYCODE_DPAD_UP) &&
+                hasKeycodeLocked(device, AKEYCODE_DPAD_DOWN) &&
+                hasKeycodeLocked(device, AKEYCODE_DPAD_LEFT) &&
+                hasKeycodeLocked(device, AKEYCODE_DPAD_RIGHT) &&
+                hasKeycodeLocked(device, AKEYCODE_DPAD_CENTER)) {
+            device->classes |= INPUT_DEVICE_CLASS_DPAD;
+        }
+
+        // See if this device has a gamepad.
+        for (size_t i = 0; i < sizeof(GAMEPAD_KEYCODES)/sizeof(GAMEPAD_KEYCODES[0]); i++) {
+            if (hasKeycodeLocked(device, GAMEPAD_KEYCODES[i])) {
+                device->classes |= INPUT_DEVICE_CLASS_GAMEPAD;
+                break;
+            }
+        }
+
+        // Disable kernel key repeat since we handle it ourselves
+        unsigned int repeatRate[] = {0,0};
+        if (ioctl(fd, EVIOCSREP, repeatRate)) {
+            ALOGW("Unable to disable kernel key repeat for %s: %s", devicePath, strerror(errno));
+        }
+    }
+
+    // If the device isn't recognized as something we handle, don't monitor it.
+    if (device->classes == 0) {
+        ALOGV("Dropping device: id=%d, path='%s', name='%s'",
+                deviceId, devicePath, device->identifier.name.string());
+        delete device;
+        return -1;
+    }
+
+    // Determine whether the device has a mic.
+    if (deviceHasMicLocked(device)) {
+        device->classes |= INPUT_DEVICE_CLASS_MIC;
+    }
+
+    // Determine whether the device is external or internal.
+    if (isExternalDeviceLocked(device)) {
+        device->classes |= INPUT_DEVICE_CLASS_EXTERNAL;
+    }
+
+    if (device->classes & (INPUT_DEVICE_CLASS_JOYSTICK | INPUT_DEVICE_CLASS_DPAD)
+            && device->classes & INPUT_DEVICE_CLASS_GAMEPAD) {
+        device->controllerNumber = getNextControllerNumberLocked(device);
+        setLedForController(device);
+    }
+
+    // Register with epoll.
+    struct epoll_event eventItem;
+    memset(&eventItem, 0, sizeof(eventItem));
+    eventItem.events = EPOLLIN;
+    if (mUsingEpollWakeup) {
+        eventItem.events |= EPOLLWAKEUP;
+    }
+    eventItem.data.u32 = deviceId;
+    if (epoll_ctl(mEpollFd, EPOLL_CTL_ADD, fd, &eventItem)) {
+        ALOGE("Could not add device fd to epoll instance.  errno=%d", errno);
+        delete device;
+        return -1;
+    }
+
+    String8 wakeMechanism("EPOLLWAKEUP");
+    if (!mUsingEpollWakeup) {
+#ifndef EVIOCSSUSPENDBLOCK
+        // uapi headers don't include EVIOCSSUSPENDBLOCK, and future kernels
+        // will use an epoll flag instead, so as long as we want to support
+        // this feature, we need to be prepared to define the ioctl ourselves.
+#define EVIOCSSUSPENDBLOCK _IOW('E', 0x91, int)
+#endif
+        if (ioctl(fd, EVIOCSSUSPENDBLOCK, 1)) {
+            wakeMechanism = "<none>";
+        } else {
+            wakeMechanism = "EVIOCSSUSPENDBLOCK";
+        }
+    }
+
+    // Tell the kernel that we want to use the monotonic clock for reporting timestamps
+    // associated with input events.  This is important because the input system
+    // uses the timestamps extensively and assumes they were recorded using the monotonic
+    // clock.
+    //
+    // In older kernel, before Linux 3.4, there was no way to tell the kernel which
+    // clock to use to input event timestamps.  The standard kernel behavior was to
+    // record a real time timestamp, which isn't what we want.  Android kernels therefore
+    // contained a patch to the evdev_event() function in drivers/input/evdev.c to
+    // replace the call to do_gettimeofday() with ktime_get_ts() to cause the monotonic
+    // clock to be used instead of the real time clock.
+    //
+    // As of Linux 3.4, there is a new EVIOCSCLOCKID ioctl to set the desired clock.
+    // Therefore, we no longer require the Android-specific kernel patch described above
+    // as long as we make sure to set select the monotonic clock.  We do that here.
+    int clockId = CLOCK_MONOTONIC;
+    bool usingClockIoctl = !ioctl(fd, EVIOCSCLOCKID, &clockId);
+
+    ALOGI("New device: id=%d, fd=%d, path='%s', name='%s', classes=0x%x, "
+            "configuration='%s', keyLayout='%s', keyCharacterMap='%s', builtinKeyboard=%s, "
+            "wakeMechanism=%s, usingClockIoctl=%s",
+         deviceId, fd, devicePath, device->identifier.name.string(),
+         device->classes,
+         device->configurationFile.string(),
+         device->keyMap.keyLayoutFile.string(),
+         device->keyMap.keyCharacterMapFile.string(),
+         toString(mBuiltInKeyboardId == deviceId),
+         wakeMechanism.string(), toString(usingClockIoctl));
+
+    addDeviceLocked(device);
+    return 0;
+}
+
+void EventHub::createVirtualKeyboardLocked() {
+    InputDeviceIdentifier identifier;
+    identifier.name = "Virtual";
+    identifier.uniqueId = "<virtual>";
+    assignDescriptorLocked(identifier);
+
+    Device* device = new Device(-1, VIRTUAL_KEYBOARD_ID, String8("<virtual>"), identifier);
+    device->classes = INPUT_DEVICE_CLASS_KEYBOARD
+            | INPUT_DEVICE_CLASS_ALPHAKEY
+            | INPUT_DEVICE_CLASS_DPAD
+            | INPUT_DEVICE_CLASS_VIRTUAL;
+    loadKeyMapLocked(device);
+    addDeviceLocked(device);
+}
+
+void EventHub::addDeviceLocked(Device* device) {
+    mDevices.add(device->id, device);
+    device->next = mOpeningDevices;
+    mOpeningDevices = device;
+}
+
+void EventHub::loadConfigurationLocked(Device* device) {
+    device->configurationFile = getInputDeviceConfigurationFilePathByDeviceIdentifier(
+            device->identifier, INPUT_DEVICE_CONFIGURATION_FILE_TYPE_CONFIGURATION);
+    if (device->configurationFile.isEmpty()) {
+        ALOGD("No input device configuration file found for device '%s'.",
+                device->identifier.name.string());
+    } else {
+        status_t status = PropertyMap::load(device->configurationFile,
+                &device->configuration);
+        if (status) {
+            ALOGE("Error loading input device configuration file for device '%s'.  "
+                    "Using default configuration.",
+                    device->identifier.name.string());
+        }
+    }
+}
+
+status_t EventHub::loadVirtualKeyMapLocked(Device* device) {
+    // The virtual key map is supplied by the kernel as a system board property file.
+    String8 path;
+    path.append("/sys/board_properties/virtualkeys.");
+    path.append(device->identifier.name);
+    if (access(path.string(), R_OK)) {
+        return NAME_NOT_FOUND;
+    }
+    return VirtualKeyMap::load(path, &device->virtualKeyMap);
+}
+
+status_t EventHub::loadKeyMapLocked(Device* device) {
+    return device->keyMap.load(device->identifier, device->configuration);
+}
+
+bool EventHub::isExternalDeviceLocked(Device* device) {
+    if (device->configuration) {
+        bool value;
+        if (device->configuration->tryGetProperty(String8("device.internal"), value)) {
+            return !value;
+        }
+    }
+    return device->identifier.bus == BUS_USB || device->identifier.bus == BUS_BLUETOOTH;
+}
+
+bool EventHub::deviceHasMicLocked(Device* device) {
+    if (device->configuration) {
+        bool value;
+        if (device->configuration->tryGetProperty(String8("audio.mic"), value)) {
+            return value;
+        }
+    }
+    return false;
+}
+
+int32_t EventHub::getNextControllerNumberLocked(Device* device) {
+    if (mControllerNumbers.isFull()) {
+        ALOGI("Maximum number of controllers reached, assigning controller number 0 to device %s",
+                device->identifier.name.string());
+        return 0;
+    }
+    // Since the controller number 0 is reserved for non-controllers, translate all numbers up by
+    // one
+    return static_cast<int32_t>(mControllerNumbers.markFirstUnmarkedBit() + 1);
+}
+
+void EventHub::releaseControllerNumberLocked(Device* device) {
+    int32_t num = device->controllerNumber;
+    device->controllerNumber= 0;
+    if (num == 0) {
+        return;
+    }
+    mControllerNumbers.clearBit(static_cast<uint32_t>(num - 1));
+}
+
+void EventHub::setLedForController(Device* device) {
+    for (int i = 0; i < MAX_CONTROLLER_LEDS; i++) {
+        setLedStateLocked(device, ALED_CONTROLLER_1 + i, device->controllerNumber == i + 1);
+    }
+}
+
+bool EventHub::hasKeycodeLocked(Device* device, int keycode) const {
+    if (!device->keyMap.haveKeyLayout()) {
+        return false;
+    }
+    
+    Vector<int32_t> scanCodes;
+    device->keyMap.keyLayoutMap->findScanCodesForKey(keycode, &scanCodes);
+    const size_t N = scanCodes.size();
+    for (size_t i=0; i<N && i<=KEY_MAX; i++) {
+        int32_t sc = scanCodes.itemAt(i);
+        if (sc >= 0 && sc <= KEY_MAX && test_bit(sc, device->keyBitmask)) {
+            return true;
+        }
+    }
+    
+    return false;
+}
+
+status_t EventHub::mapLed(Device* device, int32_t led, int32_t* outScanCode) const {
+    if (!device->keyMap.haveKeyLayout()) {
+        return NAME_NOT_FOUND;
+    }
+
+    int32_t scanCode;
+    if(device->keyMap.keyLayoutMap->findScanCodeForLed(led, &scanCode) != NAME_NOT_FOUND) {
+        if(scanCode >= 0 && scanCode <= LED_MAX && test_bit(scanCode, device->ledBitmask)) {
+            *outScanCode = scanCode;
+            return NO_ERROR;
+        }
+    }
+    return NAME_NOT_FOUND;
+}
+
+status_t EventHub::closeDeviceByPathLocked(const char *devicePath) {
+    Device* device = getDeviceByPathLocked(devicePath);
+    if (device) {
+        closeDeviceLocked(device);
+        return 0;
+    }
+    ALOGV("Remove device: %s not found, device may already have been removed.", devicePath);
+    return -1;
+}
+
+void EventHub::closeAllDevicesLocked() {
+    while (mDevices.size() > 0) {
+        closeDeviceLocked(mDevices.valueAt(mDevices.size() - 1));
+    }
+}
+
+void EventHub::closeDeviceLocked(Device* device) {
+    ALOGI("Removed device: path=%s name=%s id=%d fd=%d classes=0x%x\n",
+         device->path.string(), device->identifier.name.string(), device->id,
+         device->fd, device->classes);
+
+    if (device->id == mBuiltInKeyboardId) {
+        ALOGW("built-in keyboard device %s (id=%d) is closing! the apps will not like this",
+                device->path.string(), mBuiltInKeyboardId);
+        mBuiltInKeyboardId = NO_BUILT_IN_KEYBOARD;
+    }
+
+    if (!device->isVirtual()) {
+        if (epoll_ctl(mEpollFd, EPOLL_CTL_DEL, device->fd, NULL)) {
+            ALOGW("Could not remove device fd from epoll instance.  errno=%d", errno);
+        }
+    }
+
+    releaseControllerNumberLocked(device);
+
+    mDevices.removeItem(device->id);
+    device->close();
+
+    // Unlink for opening devices list if it is present.
+    Device* pred = NULL;
+    bool found = false;
+    for (Device* entry = mOpeningDevices; entry != NULL; ) {
+        if (entry == device) {
+            found = true;
+            break;
+        }
+        pred = entry;
+        entry = entry->next;
+    }
+    if (found) {
+        // Unlink the device from the opening devices list then delete it.
+        // We don't need to tell the client that the device was closed because
+        // it does not even know it was opened in the first place.
+        ALOGI("Device %s was immediately closed after opening.", device->path.string());
+        if (pred) {
+            pred->next = device->next;
+        } else {
+            mOpeningDevices = device->next;
+        }
+        delete device;
+    } else {
+        // Link into closing devices list.
+        // The device will be deleted later after we have informed the client.
+        device->next = mClosingDevices;
+        mClosingDevices = device;
+    }
+}
+
+status_t EventHub::readNotifyLocked() {
+    int res;
+    char devname[PATH_MAX];
+    char *filename;
+    char event_buf[512];
+    int event_size;
+    int event_pos = 0;
+    struct inotify_event *event;
+
+    ALOGV("EventHub::readNotify nfd: %d\n", mINotifyFd);
+    res = read(mINotifyFd, event_buf, sizeof(event_buf));
+    if(res < (int)sizeof(*event)) {
+        if(errno == EINTR)
+            return 0;
+        ALOGW("could not get event, %s\n", strerror(errno));
+        return -1;
+    }
+    //printf("got %d bytes of event information\n", res);
+
+    strcpy(devname, DEVICE_PATH);
+    filename = devname + strlen(devname);
+    *filename++ = '/';
+
+    while(res >= (int)sizeof(*event)) {
+        event = (struct inotify_event *)(event_buf + event_pos);
+        //printf("%d: %08x \"%s\"\n", event->wd, event->mask, event->len ? event->name : "");
+        if(event->len) {
+            strcpy(filename, event->name);
+            if(event->mask & IN_CREATE) {
+                openDeviceLocked(devname);
+            } else {
+                ALOGI("Removing device '%s' due to inotify event\n", devname);
+                closeDeviceByPathLocked(devname);
+            }
+        }
+        event_size = sizeof(*event) + event->len;
+        res -= event_size;
+        event_pos += event_size;
+    }
+    return 0;
+}
+
+status_t EventHub::scanDirLocked(const char *dirname)
+{
+    char devname[PATH_MAX];
+    char *filename;
+    DIR *dir;
+    struct dirent *de;
+    dir = opendir(dirname);
+    if(dir == NULL)
+        return -1;
+    strcpy(devname, dirname);
+    filename = devname + strlen(devname);
+    *filename++ = '/';
+    while((de = readdir(dir))) {
+        if(de->d_name[0] == '.' &&
+           (de->d_name[1] == '\0' ||
+            (de->d_name[1] == '.' && de->d_name[2] == '\0')))
+            continue;
+        strcpy(filename, de->d_name);
+        openDeviceLocked(devname);
+    }
+    closedir(dir);
+    return 0;
+}
+
+void EventHub::requestReopenDevices() {
+    ALOGV("requestReopenDevices() called");
+
+    AutoMutex _l(mLock);
+    mNeedToReopenDevices = true;
+}
+
+void EventHub::dump(String8& dump) {
+    dump.append("Event Hub State:\n");
+
+    { // acquire lock
+        AutoMutex _l(mLock);
+
+        dump.appendFormat(INDENT "BuiltInKeyboardId: %d\n", mBuiltInKeyboardId);
+
+        dump.append(INDENT "Devices:\n");
+
+        for (size_t i = 0; i < mDevices.size(); i++) {
+            const Device* device = mDevices.valueAt(i);
+            if (mBuiltInKeyboardId == device->id) {
+                dump.appendFormat(INDENT2 "%d: %s (aka device 0 - built-in keyboard)\n",
+                        device->id, device->identifier.name.string());
+            } else {
+                dump.appendFormat(INDENT2 "%d: %s\n", device->id,
+                        device->identifier.name.string());
+            }
+            dump.appendFormat(INDENT3 "Classes: 0x%08x\n", device->classes);
+            dump.appendFormat(INDENT3 "Path: %s\n", device->path.string());
+            dump.appendFormat(INDENT3 "Descriptor: %s\n", device->identifier.descriptor.string());
+            dump.appendFormat(INDENT3 "Location: %s\n", device->identifier.location.string());
+            dump.appendFormat(INDENT3 "ControllerNumber: %d\n", device->controllerNumber);
+            dump.appendFormat(INDENT3 "UniqueId: %s\n", device->identifier.uniqueId.string());
+            dump.appendFormat(INDENT3 "Identifier: bus=0x%04x, vendor=0x%04x, "
+                    "product=0x%04x, version=0x%04x\n",
+                    device->identifier.bus, device->identifier.vendor,
+                    device->identifier.product, device->identifier.version);
+            dump.appendFormat(INDENT3 "KeyLayoutFile: %s\n",
+                    device->keyMap.keyLayoutFile.string());
+            dump.appendFormat(INDENT3 "KeyCharacterMapFile: %s\n",
+                    device->keyMap.keyCharacterMapFile.string());
+            dump.appendFormat(INDENT3 "ConfigurationFile: %s\n",
+                    device->configurationFile.string());
+            dump.appendFormat(INDENT3 "HaveKeyboardLayoutOverlay: %s\n",
+                    toString(device->overlayKeyMap != NULL));
+        }
+    } // release lock
+}
+
+void EventHub::monitor() {
+    // Acquire and release the lock to ensure that the event hub has not deadlocked.
+    mLock.lock();
+    mLock.unlock();
+}
+
+
+}; // namespace android
diff --git a/services/inputflinger/EventHub.h b/services/inputflinger/EventHub.h
new file mode 100644
index 0000000..0f94c77
--- /dev/null
+++ b/services/inputflinger/EventHub.h
@@ -0,0 +1,466 @@
+/*
+ * Copyright (C) 2005 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//
+#ifndef _RUNTIME_EVENT_HUB_H
+#define _RUNTIME_EVENT_HUB_H
+
+#include <input/Input.h>
+#include <input/InputDevice.h>
+#include <input/Keyboard.h>
+#include <input/KeyLayoutMap.h>
+#include <input/KeyCharacterMap.h>
+#include <input/VirtualKeyMap.h>
+#include <utils/String8.h>
+#include <utils/threads.h>
+#include <utils/Log.h>
+#include <utils/threads.h>
+#include <utils/List.h>
+#include <utils/Errors.h>
+#include <utils/PropertyMap.h>
+#include <utils/Vector.h>
+#include <utils/KeyedVector.h>
+#include <utils/BitSet.h>
+
+#include <linux/input.h>
+#include <sys/epoll.h>
+
+/* Convenience constants. */
+
+#define BTN_FIRST 0x100  // first button code
+#define BTN_LAST 0x15f   // last button code
+
+/*
+ * These constants are used privately in Android to pass raw timestamps
+ * through evdev from uinput device drivers because there is currently no
+ * other way to transfer this information.  The evdev driver automatically
+ * timestamps all input events with the time they were posted and clobbers
+ * whatever information was passed in.
+ *
+ * For the purposes of this hack, the timestamp is specified in the
+ * CLOCK_MONOTONIC timebase and is split into two EV_MSC events specifying
+ * seconds and microseconds.
+ */
+#define MSC_ANDROID_TIME_SEC 0x6
+#define MSC_ANDROID_TIME_USEC 0x7
+
+namespace android {
+
+enum {
+    // Device id of a special "virtual" keyboard that is always present.
+    VIRTUAL_KEYBOARD_ID = -1,
+    // Device id of the "built-in" keyboard if there is one.
+    BUILT_IN_KEYBOARD_ID = 0,
+};
+
+/*
+ * A raw event as retrieved from the EventHub.
+ */
+struct RawEvent {
+    nsecs_t when;
+    int32_t deviceId;
+    int32_t type;
+    int32_t code;
+    int32_t value;
+};
+
+/* Describes an absolute axis. */
+struct RawAbsoluteAxisInfo {
+    bool valid; // true if the information is valid, false otherwise
+
+    int32_t minValue;  // minimum value
+    int32_t maxValue;  // maximum value
+    int32_t flat;      // center flat position, eg. flat == 8 means center is between -8 and 8
+    int32_t fuzz;      // error tolerance, eg. fuzz == 4 means value is +/- 4 due to noise
+    int32_t resolution; // resolution in units per mm or radians per mm
+
+    inline void clear() {
+        valid = false;
+        minValue = 0;
+        maxValue = 0;
+        flat = 0;
+        fuzz = 0;
+        resolution = 0;
+    }
+};
+
+/*
+ * Input device classes.
+ */
+enum {
+    /* The input device is a keyboard or has buttons. */
+    INPUT_DEVICE_CLASS_KEYBOARD      = 0x00000001,
+
+    /* The input device is an alpha-numeric keyboard (not just a dial pad). */
+    INPUT_DEVICE_CLASS_ALPHAKEY      = 0x00000002,
+
+    /* The input device is a touchscreen or a touchpad (either single-touch or multi-touch). */
+    INPUT_DEVICE_CLASS_TOUCH         = 0x00000004,
+
+    /* The input device is a cursor device such as a trackball or mouse. */
+    INPUT_DEVICE_CLASS_CURSOR        = 0x00000008,
+
+    /* The input device is a multi-touch touchscreen. */
+    INPUT_DEVICE_CLASS_TOUCH_MT      = 0x00000010,
+
+    /* The input device is a directional pad (implies keyboard, has DPAD keys). */
+    INPUT_DEVICE_CLASS_DPAD          = 0x00000020,
+
+    /* The input device is a gamepad (implies keyboard, has BUTTON keys). */
+    INPUT_DEVICE_CLASS_GAMEPAD       = 0x00000040,
+
+    /* The input device has switches. */
+    INPUT_DEVICE_CLASS_SWITCH        = 0x00000080,
+
+    /* The input device is a joystick (implies gamepad, has joystick absolute axes). */
+    INPUT_DEVICE_CLASS_JOYSTICK      = 0x00000100,
+
+    /* The input device has a vibrator (supports FF_RUMBLE). */
+    INPUT_DEVICE_CLASS_VIBRATOR      = 0x00000200,
+
+    /* The input device has a microphone. */
+    INPUT_DEVICE_CLASS_MIC           = 0x00000400,
+
+    /* The input device is an external stylus (has data we want to fuse with touch data). */
+    INPUT_DEVICE_CLASS_EXTERNAL_STYLUS = 0x00000800,
+
+    /* The input device is virtual (not a real device, not part of UI configuration). */
+    INPUT_DEVICE_CLASS_VIRTUAL       = 0x40000000,
+
+    /* The input device is external (not built-in). */
+    INPUT_DEVICE_CLASS_EXTERNAL      = 0x80000000,
+};
+
+/*
+ * Gets the class that owns an axis, in cases where multiple classes might claim
+ * the same axis for different purposes.
+ */
+extern uint32_t getAbsAxisUsage(int32_t axis, uint32_t deviceClasses);
+
+/*
+ * Grand Central Station for events.
+ *
+ * The event hub aggregates input events received across all known input
+ * devices on the system, including devices that may be emulated by the simulator
+ * environment.  In addition, the event hub generates fake input events to indicate
+ * when devices are added or removed.
+ *
+ * The event hub provides a stream of input events (via the getEvent function).
+ * It also supports querying the current actual state of input devices such as identifying
+ * which keys are currently down.  Finally, the event hub keeps track of the capabilities of
+ * individual input devices, such as their class and the set of key codes that they support.
+ */
+class EventHubInterface : public virtual RefBase {
+protected:
+    EventHubInterface() { }
+    virtual ~EventHubInterface() { }
+
+public:
+    // Synthetic raw event type codes produced when devices are added or removed.
+    enum {
+        // Sent when a device is added.
+        DEVICE_ADDED = 0x10000000,
+        // Sent when a device is removed.
+        DEVICE_REMOVED = 0x20000000,
+        // Sent when all added/removed devices from the most recent scan have been reported.
+        // This event is always sent at least once.
+        FINISHED_DEVICE_SCAN = 0x30000000,
+
+        FIRST_SYNTHETIC_EVENT = DEVICE_ADDED,
+    };
+
+    virtual uint32_t getDeviceClasses(int32_t deviceId) const = 0;
+
+    virtual InputDeviceIdentifier getDeviceIdentifier(int32_t deviceId) const = 0;
+
+    virtual int32_t getDeviceControllerNumber(int32_t deviceId) const = 0;
+
+    virtual void getConfiguration(int32_t deviceId, PropertyMap* outConfiguration) const = 0;
+
+    virtual status_t getAbsoluteAxisInfo(int32_t deviceId, int axis,
+            RawAbsoluteAxisInfo* outAxisInfo) const = 0;
+
+    virtual bool hasRelativeAxis(int32_t deviceId, int axis) const = 0;
+
+    virtual bool hasInputProperty(int32_t deviceId, int property) const = 0;
+
+    virtual status_t mapKey(int32_t deviceId,
+            int32_t scanCode, int32_t usageCode, int32_t metaState,
+            int32_t* outKeycode, int32_t *outMetaState, uint32_t* outFlags) const = 0;
+
+    virtual status_t mapAxis(int32_t deviceId, int32_t scanCode,
+            AxisInfo* outAxisInfo) const = 0;
+
+    // Sets devices that are excluded from opening.
+    // This can be used to ignore input devices for sensors.
+    virtual void setExcludedDevices(const Vector<String8>& devices) = 0;
+
+    /*
+     * Wait for events to become available and returns them.
+     * After returning, the EventHub holds onto a wake lock until the next call to getEvent.
+     * This ensures that the device will not go to sleep while the event is being processed.
+     * If the device needs to remain awake longer than that, then the caller is responsible
+     * for taking care of it (say, by poking the power manager user activity timer).
+     *
+     * The timeout is advisory only.  If the device is asleep, it will not wake just to
+     * service the timeout.
+     *
+     * Returns the number of events obtained, or 0 if the timeout expired.
+     */
+    virtual size_t getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSize) = 0;
+
+    /*
+     * Query current input state.
+     */
+    virtual int32_t getScanCodeState(int32_t deviceId, int32_t scanCode) const = 0;
+    virtual int32_t getKeyCodeState(int32_t deviceId, int32_t keyCode) const = 0;
+    virtual int32_t getSwitchState(int32_t deviceId, int32_t sw) const = 0;
+    virtual status_t getAbsoluteAxisValue(int32_t deviceId, int32_t axis,
+            int32_t* outValue) const = 0;
+
+    /*
+     * Examine key input devices for specific framework keycode support
+     */
+    virtual bool markSupportedKeyCodes(int32_t deviceId, size_t numCodes, const int32_t* keyCodes,
+            uint8_t* outFlags) const = 0;
+
+    virtual bool hasScanCode(int32_t deviceId, int32_t scanCode) const = 0;
+
+    /* LED related functions expect Android LED constants, not scan codes or HID usages */
+    virtual bool hasLed(int32_t deviceId, int32_t led) const = 0;
+    virtual void setLedState(int32_t deviceId, int32_t led, bool on) = 0;
+
+    virtual void getVirtualKeyDefinitions(int32_t deviceId,
+            Vector<VirtualKeyDefinition>& outVirtualKeys) const = 0;
+
+    virtual sp<KeyCharacterMap> getKeyCharacterMap(int32_t deviceId) const = 0;
+    virtual bool setKeyboardLayoutOverlay(int32_t deviceId, const sp<KeyCharacterMap>& map) = 0;
+
+    /* Control the vibrator. */
+    virtual void vibrate(int32_t deviceId, nsecs_t duration) = 0;
+    virtual void cancelVibrate(int32_t deviceId) = 0;
+
+    /* Requests the EventHub to reopen all input devices on the next call to getEvents(). */
+    virtual void requestReopenDevices() = 0;
+
+    /* Wakes up getEvents() if it is blocked on a read. */
+    virtual void wake() = 0;
+
+    /* Dump EventHub state to a string. */
+    virtual void dump(String8& dump) = 0;
+
+    /* Called by the heatbeat to ensures that the reader has not deadlocked. */
+    virtual void monitor() = 0;
+};
+
+class EventHub : public EventHubInterface
+{
+public:
+    EventHub();
+
+    virtual uint32_t getDeviceClasses(int32_t deviceId) const;
+
+    virtual InputDeviceIdentifier getDeviceIdentifier(int32_t deviceId) const;
+
+    virtual int32_t getDeviceControllerNumber(int32_t deviceId) const;
+
+    virtual void getConfiguration(int32_t deviceId, PropertyMap* outConfiguration) const;
+
+    virtual status_t getAbsoluteAxisInfo(int32_t deviceId, int axis,
+            RawAbsoluteAxisInfo* outAxisInfo) const;
+
+    virtual bool hasRelativeAxis(int32_t deviceId, int axis) const;
+
+    virtual bool hasInputProperty(int32_t deviceId, int property) const;
+
+    virtual status_t mapKey(int32_t deviceId,
+            int32_t scanCode, int32_t usageCode, int32_t metaState,
+            int32_t* outKeycode, int32_t *outMetaState, uint32_t* outFlags) const;
+
+    virtual status_t mapAxis(int32_t deviceId, int32_t scanCode,
+            AxisInfo* outAxisInfo) const;
+
+    virtual void setExcludedDevices(const Vector<String8>& devices);
+
+    virtual int32_t getScanCodeState(int32_t deviceId, int32_t scanCode) const;
+    virtual int32_t getKeyCodeState(int32_t deviceId, int32_t keyCode) const;
+    virtual int32_t getSwitchState(int32_t deviceId, int32_t sw) const;
+    virtual status_t getAbsoluteAxisValue(int32_t deviceId, int32_t axis, int32_t* outValue) const;
+
+    virtual bool markSupportedKeyCodes(int32_t deviceId, size_t numCodes,
+            const int32_t* keyCodes, uint8_t* outFlags) const;
+
+    virtual size_t getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSize);
+
+    virtual bool hasScanCode(int32_t deviceId, int32_t scanCode) const;
+    virtual bool hasLed(int32_t deviceId, int32_t led) const;
+    virtual void setLedState(int32_t deviceId, int32_t led, bool on);
+
+    virtual void getVirtualKeyDefinitions(int32_t deviceId,
+            Vector<VirtualKeyDefinition>& outVirtualKeys) const;
+
+    virtual sp<KeyCharacterMap> getKeyCharacterMap(int32_t deviceId) const;
+    virtual bool setKeyboardLayoutOverlay(int32_t deviceId, const sp<KeyCharacterMap>& map);
+
+    virtual void vibrate(int32_t deviceId, nsecs_t duration);
+    virtual void cancelVibrate(int32_t deviceId);
+
+    virtual void requestReopenDevices();
+
+    virtual void wake();
+
+    virtual void dump(String8& dump);
+    virtual void monitor();
+
+protected:
+    virtual ~EventHub();
+
+private:
+    struct Device {
+        Device* next;
+
+        int fd; // may be -1 if device is virtual
+        const int32_t id;
+        const String8 path;
+        const InputDeviceIdentifier identifier;
+
+        uint32_t classes;
+
+        uint8_t keyBitmask[(KEY_MAX + 1) / 8];
+        uint8_t absBitmask[(ABS_MAX + 1) / 8];
+        uint8_t relBitmask[(REL_MAX + 1) / 8];
+        uint8_t swBitmask[(SW_MAX + 1) / 8];
+        uint8_t ledBitmask[(LED_MAX + 1) / 8];
+        uint8_t ffBitmask[(FF_MAX + 1) / 8];
+        uint8_t propBitmask[(INPUT_PROP_MAX + 1) / 8];
+
+        String8 configurationFile;
+        PropertyMap* configuration;
+        VirtualKeyMap* virtualKeyMap;
+        KeyMap keyMap;
+
+        sp<KeyCharacterMap> overlayKeyMap;
+        sp<KeyCharacterMap> combinedKeyMap;
+
+        bool ffEffectPlaying;
+        int16_t ffEffectId; // initially -1
+
+        int32_t controllerNumber;
+
+        int32_t timestampOverrideSec;
+        int32_t timestampOverrideUsec;
+
+        Device(int fd, int32_t id, const String8& path, const InputDeviceIdentifier& identifier);
+        ~Device();
+
+        void close();
+
+        inline bool isVirtual() const { return fd < 0; }
+
+        const sp<KeyCharacterMap>& getKeyCharacterMap() const {
+            if (combinedKeyMap != NULL) {
+                return combinedKeyMap;
+            }
+            return keyMap.keyCharacterMap;
+        }
+    };
+
+    status_t openDeviceLocked(const char *devicePath);
+    void createVirtualKeyboardLocked();
+    void addDeviceLocked(Device* device);
+    void assignDescriptorLocked(InputDeviceIdentifier& identifier);
+
+    status_t closeDeviceByPathLocked(const char *devicePath);
+    void closeDeviceLocked(Device* device);
+    void closeAllDevicesLocked();
+
+    status_t scanDirLocked(const char *dirname);
+    void scanDevicesLocked();
+    status_t readNotifyLocked();
+
+    Device* getDeviceByDescriptorLocked(String8& descriptor) const;
+    Device* getDeviceLocked(int32_t deviceId) const;
+    Device* getDeviceByPathLocked(const char* devicePath) const;
+
+    bool hasKeycodeLocked(Device* device, int keycode) const;
+
+    void loadConfigurationLocked(Device* device);
+    status_t loadVirtualKeyMapLocked(Device* device);
+    status_t loadKeyMapLocked(Device* device);
+
+    bool isExternalDeviceLocked(Device* device);
+    bool deviceHasMicLocked(Device* device);
+
+    int32_t getNextControllerNumberLocked(Device* device);
+    void releaseControllerNumberLocked(Device* device);
+    void setLedForController(Device* device);
+
+    status_t mapLed(Device* device, int32_t led, int32_t* outScanCode) const;
+    void setLedStateLocked(Device* device, int32_t led, bool on);
+
+    // Protect all internal state.
+    mutable Mutex mLock;
+
+    // The actual id of the built-in keyboard, or NO_BUILT_IN_KEYBOARD if none.
+    // EventHub remaps the built-in keyboard to id 0 externally as required by the API.
+    enum {
+        // Must not conflict with any other assigned device ids, including
+        // the virtual keyboard id (-1).
+        NO_BUILT_IN_KEYBOARD = -2,
+    };
+    int32_t mBuiltInKeyboardId;
+
+    int32_t mNextDeviceId;
+
+    BitSet32 mControllerNumbers;
+
+    KeyedVector<int32_t, Device*> mDevices;
+
+    Device *mOpeningDevices;
+    Device *mClosingDevices;
+
+    bool mNeedToSendFinishedDeviceScan;
+    bool mNeedToReopenDevices;
+    bool mNeedToScanDevices;
+    Vector<String8> mExcludedDevices;
+
+    int mEpollFd;
+    int mINotifyFd;
+    int mWakeReadPipeFd;
+    int mWakeWritePipeFd;
+
+    // Ids used for epoll notifications not associated with devices.
+    static const uint32_t EPOLL_ID_INOTIFY = 0x80000001;
+    static const uint32_t EPOLL_ID_WAKE = 0x80000002;
+
+    // Epoll FD list size hint.
+    static const int EPOLL_SIZE_HINT = 8;
+
+    // Maximum number of signalled FDs to handle at a time.
+    static const int EPOLL_MAX_EVENTS = 16;
+
+    // The array of pending epoll events and the index of the next event to be handled.
+    struct epoll_event mPendingEventItems[EPOLL_MAX_EVENTS];
+    size_t mPendingEventCount;
+    size_t mPendingEventIndex;
+    bool mPendingINotify;
+
+    bool mUsingEpollWakeup;
+};
+
+}; // namespace android
+
+#endif // _RUNTIME_EVENT_HUB_H
diff --git a/services/inputflinger/InputApplication.cpp b/services/inputflinger/InputApplication.cpp
new file mode 100644
index 0000000..a99e637
--- /dev/null
+++ b/services/inputflinger/InputApplication.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "InputApplication"
+
+#include "InputApplication.h"
+
+#include <cutils/log.h>
+
+namespace android {
+
+// --- InputApplicationHandle ---
+
+InputApplicationHandle::InputApplicationHandle() :
+    mInfo(NULL) {
+}
+
+InputApplicationHandle::~InputApplicationHandle() {
+    delete mInfo;
+}
+
+void InputApplicationHandle::releaseInfo() {
+    if (mInfo) {
+        delete mInfo;
+        mInfo = NULL;
+    }
+}
+
+} // namespace android
diff --git a/services/inputflinger/InputApplication.h b/services/inputflinger/InputApplication.h
new file mode 100644
index 0000000..1f5504c
--- /dev/null
+++ b/services/inputflinger/InputApplication.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _UI_INPUT_APPLICATION_H
+#define _UI_INPUT_APPLICATION_H
+
+#include <input/Input.h>
+
+#include <utils/RefBase.h>
+#include <utils/Timers.h>
+#include <utils/String8.h>
+
+namespace android {
+
+/*
+ * Describes the properties of an application that can receive input.
+ */
+struct InputApplicationInfo {
+    String8 name;
+    nsecs_t dispatchingTimeout;
+};
+
+
+/*
+ * Handle for an application that can receive input.
+ *
+ * Used by the native input dispatcher as a handle for the window manager objects
+ * that describe an application.
+ */
+class InputApplicationHandle : public RefBase {
+public:
+    inline const InputApplicationInfo* getInfo() const {
+        return mInfo;
+    }
+
+    inline String8 getName() const {
+        return mInfo ? mInfo->name : String8("<invalid>");
+    }
+
+    inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const {
+        return mInfo ? mInfo->dispatchingTimeout : defaultValue;
+    }
+
+    /**
+     * Requests that the state of this object be updated to reflect
+     * the most current available information about the application.
+     *
+     * This method should only be called from within the input dispatcher's
+     * critical section.
+     *
+     * Returns true on success, or false if the handle is no longer valid.
+     */
+    virtual bool updateInfo() = 0;
+
+    /**
+     * Releases the storage used by the associated information when it is
+     * no longer needed.
+     */
+    void releaseInfo();
+
+protected:
+    InputApplicationHandle();
+    virtual ~InputApplicationHandle();
+
+    InputApplicationInfo* mInfo;
+};
+
+} // namespace android
+
+#endif // _UI_INPUT_APPLICATION_H
diff --git a/services/inputflinger/InputDispatcher.cpp b/services/inputflinger/InputDispatcher.cpp
new file mode 100644
index 0000000..87c96ce
--- /dev/null
+++ b/services/inputflinger/InputDispatcher.cpp
@@ -0,0 +1,4535 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "InputDispatcher"
+#define ATRACE_TAG ATRACE_TAG_INPUT
+
+//#define LOG_NDEBUG 0
+
+// Log detailed debug messages about each inbound event notification to the dispatcher.
+#define DEBUG_INBOUND_EVENT_DETAILS 0
+
+// Log detailed debug messages about each outbound event processed by the dispatcher.
+#define DEBUG_OUTBOUND_EVENT_DETAILS 0
+
+// Log debug messages about the dispatch cycle.
+#define DEBUG_DISPATCH_CYCLE 0
+
+// Log debug messages about registrations.
+#define DEBUG_REGISTRATION 0
+
+// Log debug messages about input event injection.
+#define DEBUG_INJECTION 0
+
+// Log debug messages about input focus tracking.
+#define DEBUG_FOCUS 0
+
+// Log debug messages about the app switch latency optimization.
+#define DEBUG_APP_SWITCH 0
+
+// Log debug messages about hover events.
+#define DEBUG_HOVER 0
+
+#include "InputDispatcher.h"
+
+#include <utils/Trace.h>
+#include <cutils/log.h>
+#include <powermanager/PowerManager.h>
+#include <ui/Region.h>
+
+#include <stddef.h>
+#include <unistd.h>
+#include <errno.h>
+#include <limits.h>
+#include <time.h>
+
+#define INDENT "  "
+#define INDENT2 "    "
+#define INDENT3 "      "
+#define INDENT4 "        "
+
+namespace android {
+
+// Default input dispatching timeout if there is no focused application or paused window
+// from which to determine an appropriate dispatching timeout.
+const nsecs_t DEFAULT_INPUT_DISPATCHING_TIMEOUT = 5000 * 1000000LL; // 5 sec
+
+// Amount of time to allow for all pending events to be processed when an app switch
+// key is on the way.  This is used to preempt input dispatch and drop input events
+// when an application takes too long to respond and the user has pressed an app switch key.
+const nsecs_t APP_SWITCH_TIMEOUT = 500 * 1000000LL; // 0.5sec
+
+// Amount of time to allow for an event to be dispatched (measured since its eventTime)
+// before considering it stale and dropping it.
+const nsecs_t STALE_EVENT_TIMEOUT = 10000 * 1000000LL; // 10sec
+
+// Amount of time to allow touch events to be streamed out to a connection before requiring
+// that the first event be finished.  This value extends the ANR timeout by the specified
+// amount.  For example, if streaming is allowed to get ahead by one second relative to the
+// queue of waiting unfinished events, then ANRs will similarly be delayed by one second.
+const nsecs_t STREAM_AHEAD_EVENT_TIMEOUT = 500 * 1000000LL; // 0.5sec
+
+// Log a warning when an event takes longer than this to process, even if an ANR does not occur.
+const nsecs_t SLOW_EVENT_PROCESSING_WARNING_TIMEOUT = 2000 * 1000000LL; // 2sec
+
+// Number of recent events to keep for debugging purposes.
+const size_t RECENT_QUEUE_MAX_SIZE = 10;
+
+static inline nsecs_t now() {
+    return systemTime(SYSTEM_TIME_MONOTONIC);
+}
+
+static inline const char* toString(bool value) {
+    return value ? "true" : "false";
+}
+
+static inline int32_t getMotionEventActionPointerIndex(int32_t action) {
+    return (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK)
+            >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
+}
+
+static bool isValidKeyAction(int32_t action) {
+    switch (action) {
+    case AKEY_EVENT_ACTION_DOWN:
+    case AKEY_EVENT_ACTION_UP:
+        return true;
+    default:
+        return false;
+    }
+}
+
+static bool validateKeyEvent(int32_t action) {
+    if (! isValidKeyAction(action)) {
+        ALOGE("Key event has invalid action code 0x%x", action);
+        return false;
+    }
+    return true;
+}
+
+static bool isValidMotionAction(int32_t action, int32_t actionButton, int32_t pointerCount) {
+    switch (action & AMOTION_EVENT_ACTION_MASK) {
+    case AMOTION_EVENT_ACTION_DOWN:
+    case AMOTION_EVENT_ACTION_UP:
+    case AMOTION_EVENT_ACTION_CANCEL:
+    case AMOTION_EVENT_ACTION_MOVE:
+    case AMOTION_EVENT_ACTION_OUTSIDE:
+    case AMOTION_EVENT_ACTION_HOVER_ENTER:
+    case AMOTION_EVENT_ACTION_HOVER_MOVE:
+    case AMOTION_EVENT_ACTION_HOVER_EXIT:
+    case AMOTION_EVENT_ACTION_SCROLL:
+        return true;
+    case AMOTION_EVENT_ACTION_POINTER_DOWN:
+    case AMOTION_EVENT_ACTION_POINTER_UP: {
+        int32_t index = getMotionEventActionPointerIndex(action);
+        return index >= 0 && index < pointerCount;
+    }
+    case AMOTION_EVENT_ACTION_BUTTON_PRESS:
+    case AMOTION_EVENT_ACTION_BUTTON_RELEASE:
+        return actionButton != 0;
+    default:
+        return false;
+    }
+}
+
+static bool validateMotionEvent(int32_t action, int32_t actionButton, size_t pointerCount,
+        const PointerProperties* pointerProperties) {
+    if (! isValidMotionAction(action, actionButton, pointerCount)) {
+        ALOGE("Motion event has invalid action code 0x%x", action);
+        return false;
+    }
+    if (pointerCount < 1 || pointerCount > MAX_POINTERS) {
+        ALOGE("Motion event has invalid pointer count %zu; value must be between 1 and %d.",
+                pointerCount, MAX_POINTERS);
+        return false;
+    }
+    BitSet32 pointerIdBits;
+    for (size_t i = 0; i < pointerCount; i++) {
+        int32_t id = pointerProperties[i].id;
+        if (id < 0 || id > MAX_POINTER_ID) {
+            ALOGE("Motion event has invalid pointer id %d; value must be between 0 and %d",
+                    id, MAX_POINTER_ID);
+            return false;
+        }
+        if (pointerIdBits.hasBit(id)) {
+            ALOGE("Motion event has duplicate pointer id %d", id);
+            return false;
+        }
+        pointerIdBits.markBit(id);
+    }
+    return true;
+}
+
+static bool isMainDisplay(int32_t displayId) {
+    return displayId == ADISPLAY_ID_DEFAULT || displayId == ADISPLAY_ID_NONE;
+}
+
+static void dumpRegion(String8& dump, const Region& region) {
+    if (region.isEmpty()) {
+        dump.append("<empty>");
+        return;
+    }
+
+    bool first = true;
+    Region::const_iterator cur = region.begin();
+    Region::const_iterator const tail = region.end();
+    while (cur != tail) {
+        if (first) {
+            first = false;
+        } else {
+            dump.append("|");
+        }
+        dump.appendFormat("[%d,%d][%d,%d]", cur->left, cur->top, cur->right, cur->bottom);
+        cur++;
+    }
+}
+
+
+// --- InputDispatcher ---
+
+InputDispatcher::InputDispatcher(const sp<InputDispatcherPolicyInterface>& policy) :
+    mPolicy(policy),
+    mPendingEvent(NULL), mLastDropReason(DROP_REASON_NOT_DROPPED),
+    mAppSwitchSawKeyDown(false), mAppSwitchDueTime(LONG_LONG_MAX),
+    mNextUnblockedEvent(NULL),
+    mDispatchEnabled(false), mDispatchFrozen(false), mInputFilterEnabled(false),
+    mInputTargetWaitCause(INPUT_TARGET_WAIT_CAUSE_NONE) {
+    mLooper = new Looper(false);
+
+    mKeyRepeatState.lastKeyEntry = NULL;
+
+    policy->getDispatcherConfiguration(&mConfig);
+}
+
+InputDispatcher::~InputDispatcher() {
+    { // acquire lock
+        AutoMutex _l(mLock);
+
+        resetKeyRepeatLocked();
+        releasePendingEventLocked();
+        drainInboundQueueLocked();
+    }
+
+    while (mConnectionsByFd.size() != 0) {
+        unregisterInputChannel(mConnectionsByFd.valueAt(0)->inputChannel);
+    }
+}
+
+void InputDispatcher::dispatchOnce() {
+    nsecs_t nextWakeupTime = LONG_LONG_MAX;
+    { // acquire lock
+        AutoMutex _l(mLock);
+        mDispatcherIsAliveCondition.broadcast();
+
+        // Run a dispatch loop if there are no pending commands.
+        // The dispatch loop might enqueue commands to run afterwards.
+        if (!haveCommandsLocked()) {
+            dispatchOnceInnerLocked(&nextWakeupTime);
+        }
+
+        // Run all pending commands if there are any.
+        // If any commands were run then force the next poll to wake up immediately.
+        if (runCommandsLockedInterruptible()) {
+            nextWakeupTime = LONG_LONG_MIN;
+        }
+    } // release lock
+
+    // Wait for callback or timeout or wake.  (make sure we round up, not down)
+    nsecs_t currentTime = now();
+    int timeoutMillis = toMillisecondTimeoutDelay(currentTime, nextWakeupTime);
+    mLooper->pollOnce(timeoutMillis);
+}
+
+void InputDispatcher::dispatchOnceInnerLocked(nsecs_t* nextWakeupTime) {
+    nsecs_t currentTime = now();
+
+    // Reset the key repeat timer whenever normal dispatch is suspended while the
+    // device is in a non-interactive state.  This is to ensure that we abort a key
+    // repeat if the device is just coming out of sleep.
+    if (!mDispatchEnabled) {
+        resetKeyRepeatLocked();
+    }
+
+    // If dispatching is frozen, do not process timeouts or try to deliver any new events.
+    if (mDispatchFrozen) {
+#if DEBUG_FOCUS
+        ALOGD("Dispatch frozen.  Waiting some more.");
+#endif
+        return;
+    }
+
+    // Optimize latency of app switches.
+    // Essentially we start a short timeout when an app switch key (HOME / ENDCALL) has
+    // been pressed.  When it expires, we preempt dispatch and drop all other pending events.
+    bool isAppSwitchDue = mAppSwitchDueTime <= currentTime;
+    if (mAppSwitchDueTime < *nextWakeupTime) {
+        *nextWakeupTime = mAppSwitchDueTime;
+    }
+
+    // Ready to start a new event.
+    // If we don't already have a pending event, go grab one.
+    if (! mPendingEvent) {
+        if (mInboundQueue.isEmpty()) {
+            if (isAppSwitchDue) {
+                // The inbound queue is empty so the app switch key we were waiting
+                // for will never arrive.  Stop waiting for it.
+                resetPendingAppSwitchLocked(false);
+                isAppSwitchDue = false;
+            }
+
+            // Synthesize a key repeat if appropriate.
+            if (mKeyRepeatState.lastKeyEntry) {
+                if (currentTime >= mKeyRepeatState.nextRepeatTime) {
+                    mPendingEvent = synthesizeKeyRepeatLocked(currentTime);
+                } else {
+                    if (mKeyRepeatState.nextRepeatTime < *nextWakeupTime) {
+                        *nextWakeupTime = mKeyRepeatState.nextRepeatTime;
+                    }
+                }
+            }
+
+            // Nothing to do if there is no pending event.
+            if (!mPendingEvent) {
+                return;
+            }
+        } else {
+            // Inbound queue has at least one entry.
+            mPendingEvent = mInboundQueue.dequeueAtHead();
+            traceInboundQueueLengthLocked();
+        }
+
+        // Poke user activity for this event.
+        if (mPendingEvent->policyFlags & POLICY_FLAG_PASS_TO_USER) {
+            pokeUserActivityLocked(mPendingEvent);
+        }
+
+        // Get ready to dispatch the event.
+        resetANRTimeoutsLocked();
+    }
+
+    // Now we have an event to dispatch.
+    // All events are eventually dequeued and processed this way, even if we intend to drop them.
+    ALOG_ASSERT(mPendingEvent != NULL);
+    bool done = false;
+    DropReason dropReason = DROP_REASON_NOT_DROPPED;
+    if (!(mPendingEvent->policyFlags & POLICY_FLAG_PASS_TO_USER)) {
+        dropReason = DROP_REASON_POLICY;
+    } else if (!mDispatchEnabled) {
+        dropReason = DROP_REASON_DISABLED;
+    }
+
+    if (mNextUnblockedEvent == mPendingEvent) {
+        mNextUnblockedEvent = NULL;
+    }
+
+    switch (mPendingEvent->type) {
+    case EventEntry::TYPE_CONFIGURATION_CHANGED: {
+        ConfigurationChangedEntry* typedEntry =
+                static_cast<ConfigurationChangedEntry*>(mPendingEvent);
+        done = dispatchConfigurationChangedLocked(currentTime, typedEntry);
+        dropReason = DROP_REASON_NOT_DROPPED; // configuration changes are never dropped
+        break;
+    }
+
+    case EventEntry::TYPE_DEVICE_RESET: {
+        DeviceResetEntry* typedEntry =
+                static_cast<DeviceResetEntry*>(mPendingEvent);
+        done = dispatchDeviceResetLocked(currentTime, typedEntry);
+        dropReason = DROP_REASON_NOT_DROPPED; // device resets are never dropped
+        break;
+    }
+
+    case EventEntry::TYPE_KEY: {
+        KeyEntry* typedEntry = static_cast<KeyEntry*>(mPendingEvent);
+        if (isAppSwitchDue) {
+            if (isAppSwitchKeyEventLocked(typedEntry)) {
+                resetPendingAppSwitchLocked(true);
+                isAppSwitchDue = false;
+            } else if (dropReason == DROP_REASON_NOT_DROPPED) {
+                dropReason = DROP_REASON_APP_SWITCH;
+            }
+        }
+        if (dropReason == DROP_REASON_NOT_DROPPED
+                && isStaleEventLocked(currentTime, typedEntry)) {
+            dropReason = DROP_REASON_STALE;
+        }
+        if (dropReason == DROP_REASON_NOT_DROPPED && mNextUnblockedEvent) {
+            dropReason = DROP_REASON_BLOCKED;
+        }
+        done = dispatchKeyLocked(currentTime, typedEntry, &dropReason, nextWakeupTime);
+        break;
+    }
+
+    case EventEntry::TYPE_MOTION: {
+        MotionEntry* typedEntry = static_cast<MotionEntry*>(mPendingEvent);
+        if (dropReason == DROP_REASON_NOT_DROPPED && isAppSwitchDue) {
+            dropReason = DROP_REASON_APP_SWITCH;
+        }
+        if (dropReason == DROP_REASON_NOT_DROPPED
+                && isStaleEventLocked(currentTime, typedEntry)) {
+            dropReason = DROP_REASON_STALE;
+        }
+        if (dropReason == DROP_REASON_NOT_DROPPED && mNextUnblockedEvent) {
+            dropReason = DROP_REASON_BLOCKED;
+        }
+        done = dispatchMotionLocked(currentTime, typedEntry,
+                &dropReason, nextWakeupTime);
+        break;
+    }
+
+    default:
+        ALOG_ASSERT(false);
+        break;
+    }
+
+    if (done) {
+        if (dropReason != DROP_REASON_NOT_DROPPED) {
+            dropInboundEventLocked(mPendingEvent, dropReason);
+        }
+        mLastDropReason = dropReason;
+
+        releasePendingEventLocked();
+        *nextWakeupTime = LONG_LONG_MIN;  // force next poll to wake up immediately
+    }
+}
+
+bool InputDispatcher::enqueueInboundEventLocked(EventEntry* entry) {
+    bool needWake = mInboundQueue.isEmpty();
+    mInboundQueue.enqueueAtTail(entry);
+    traceInboundQueueLengthLocked();
+
+    switch (entry->type) {
+    case EventEntry::TYPE_KEY: {
+        // Optimize app switch latency.
+        // If the application takes too long to catch up then we drop all events preceding
+        // the app switch key.
+        KeyEntry* keyEntry = static_cast<KeyEntry*>(entry);
+        if (isAppSwitchKeyEventLocked(keyEntry)) {
+            if (keyEntry->action == AKEY_EVENT_ACTION_DOWN) {
+                mAppSwitchSawKeyDown = true;
+            } else if (keyEntry->action == AKEY_EVENT_ACTION_UP) {
+                if (mAppSwitchSawKeyDown) {
+#if DEBUG_APP_SWITCH
+                    ALOGD("App switch is pending!");
+#endif
+                    mAppSwitchDueTime = keyEntry->eventTime + APP_SWITCH_TIMEOUT;
+                    mAppSwitchSawKeyDown = false;
+                    needWake = true;
+                }
+            }
+        }
+        break;
+    }
+
+    case EventEntry::TYPE_MOTION: {
+        // Optimize case where the current application is unresponsive and the user
+        // decides to touch a window in a different application.
+        // If the application takes too long to catch up then we drop all events preceding
+        // the touch into the other window.
+        MotionEntry* motionEntry = static_cast<MotionEntry*>(entry);
+        if (motionEntry->action == AMOTION_EVENT_ACTION_DOWN
+                && (motionEntry->source & AINPUT_SOURCE_CLASS_POINTER)
+                && mInputTargetWaitCause == INPUT_TARGET_WAIT_CAUSE_APPLICATION_NOT_READY
+                && mInputTargetWaitApplicationHandle != NULL) {
+            int32_t displayId = motionEntry->displayId;
+            int32_t x = int32_t(motionEntry->pointerCoords[0].
+                    getAxisValue(AMOTION_EVENT_AXIS_X));
+            int32_t y = int32_t(motionEntry->pointerCoords[0].
+                    getAxisValue(AMOTION_EVENT_AXIS_Y));
+            sp<InputWindowHandle> touchedWindowHandle = findTouchedWindowAtLocked(displayId, x, y);
+            if (touchedWindowHandle != NULL
+                    && touchedWindowHandle->inputApplicationHandle
+                            != mInputTargetWaitApplicationHandle) {
+                // User touched a different application than the one we are waiting on.
+                // Flag the event, and start pruning the input queue.
+                mNextUnblockedEvent = motionEntry;
+                needWake = true;
+            }
+        }
+        break;
+    }
+    }
+
+    return needWake;
+}
+
+void InputDispatcher::addRecentEventLocked(EventEntry* entry) {
+    entry->refCount += 1;
+    mRecentQueue.enqueueAtTail(entry);
+    if (mRecentQueue.count() > RECENT_QUEUE_MAX_SIZE) {
+        mRecentQueue.dequeueAtHead()->release();
+    }
+}
+
+sp<InputWindowHandle> InputDispatcher::findTouchedWindowAtLocked(int32_t displayId,
+        int32_t x, int32_t y) {
+    // Traverse windows from front to back to find touched window.
+    size_t numWindows = mWindowHandles.size();
+    for (size_t i = 0; i < numWindows; i++) {
+        sp<InputWindowHandle> windowHandle = mWindowHandles.itemAt(i);
+        const InputWindowInfo* windowInfo = windowHandle->getInfo();
+        if (windowInfo->displayId == displayId) {
+            int32_t flags = windowInfo->layoutParamsFlags;
+
+            if (windowInfo->visible) {
+                if (!(flags & InputWindowInfo::FLAG_NOT_TOUCHABLE)) {
+                    bool isTouchModal = (flags & (InputWindowInfo::FLAG_NOT_FOCUSABLE
+                            | InputWindowInfo::FLAG_NOT_TOUCH_MODAL)) == 0;
+                    if (isTouchModal || windowInfo->touchableRegionContainsPoint(x, y)) {
+                        // Found window.
+                        return windowHandle;
+                    }
+                }
+            }
+        }
+    }
+    return NULL;
+}
+
+void InputDispatcher::dropInboundEventLocked(EventEntry* entry, DropReason dropReason) {
+    const char* reason;
+    switch (dropReason) {
+    case DROP_REASON_POLICY:
+#if DEBUG_INBOUND_EVENT_DETAILS
+        ALOGD("Dropped event because policy consumed it.");
+#endif
+        reason = "inbound event was dropped because the policy consumed it";
+        break;
+    case DROP_REASON_DISABLED:
+        if (mLastDropReason != DROP_REASON_DISABLED) {
+            ALOGI("Dropped event because input dispatch is disabled.");
+        }
+        reason = "inbound event was dropped because input dispatch is disabled";
+        break;
+    case DROP_REASON_APP_SWITCH:
+        ALOGI("Dropped event because of pending overdue app switch.");
+        reason = "inbound event was dropped because of pending overdue app switch";
+        break;
+    case DROP_REASON_BLOCKED:
+        ALOGI("Dropped event because the current application is not responding and the user "
+                "has started interacting with a different application.");
+        reason = "inbound event was dropped because the current application is not responding "
+                "and the user has started interacting with a different application";
+        break;
+    case DROP_REASON_STALE:
+        ALOGI("Dropped event because it is stale.");
+        reason = "inbound event was dropped because it is stale";
+        break;
+    default:
+        ALOG_ASSERT(false);
+        return;
+    }
+
+    switch (entry->type) {
+    case EventEntry::TYPE_KEY: {
+        CancelationOptions options(CancelationOptions::CANCEL_NON_POINTER_EVENTS, reason);
+        synthesizeCancelationEventsForAllConnectionsLocked(options);
+        break;
+    }
+    case EventEntry::TYPE_MOTION: {
+        MotionEntry* motionEntry = static_cast<MotionEntry*>(entry);
+        if (motionEntry->source & AINPUT_SOURCE_CLASS_POINTER) {
+            CancelationOptions options(CancelationOptions::CANCEL_POINTER_EVENTS, reason);
+            synthesizeCancelationEventsForAllConnectionsLocked(options);
+        } else {
+            CancelationOptions options(CancelationOptions::CANCEL_NON_POINTER_EVENTS, reason);
+            synthesizeCancelationEventsForAllConnectionsLocked(options);
+        }
+        break;
+    }
+    }
+}
+
+bool InputDispatcher::isAppSwitchKeyCode(int32_t keyCode) {
+    return keyCode == AKEYCODE_HOME
+            || keyCode == AKEYCODE_ENDCALL
+            || keyCode == AKEYCODE_APP_SWITCH;
+}
+
+bool InputDispatcher::isAppSwitchKeyEventLocked(KeyEntry* keyEntry) {
+    return ! (keyEntry->flags & AKEY_EVENT_FLAG_CANCELED)
+            && isAppSwitchKeyCode(keyEntry->keyCode)
+            && (keyEntry->policyFlags & POLICY_FLAG_TRUSTED)
+            && (keyEntry->policyFlags & POLICY_FLAG_PASS_TO_USER);
+}
+
+bool InputDispatcher::isAppSwitchPendingLocked() {
+    return mAppSwitchDueTime != LONG_LONG_MAX;
+}
+
+void InputDispatcher::resetPendingAppSwitchLocked(bool handled) {
+    mAppSwitchDueTime = LONG_LONG_MAX;
+
+#if DEBUG_APP_SWITCH
+    if (handled) {
+        ALOGD("App switch has arrived.");
+    } else {
+        ALOGD("App switch was abandoned.");
+    }
+#endif
+}
+
+bool InputDispatcher::isStaleEventLocked(nsecs_t currentTime, EventEntry* entry) {
+    return currentTime - entry->eventTime >= STALE_EVENT_TIMEOUT;
+}
+
+bool InputDispatcher::haveCommandsLocked() const {
+    return !mCommandQueue.isEmpty();
+}
+
+bool InputDispatcher::runCommandsLockedInterruptible() {
+    if (mCommandQueue.isEmpty()) {
+        return false;
+    }
+
+    do {
+        CommandEntry* commandEntry = mCommandQueue.dequeueAtHead();
+
+        Command command = commandEntry->command;
+        (this->*command)(commandEntry); // commands are implicitly 'LockedInterruptible'
+
+        commandEntry->connection.clear();
+        delete commandEntry;
+    } while (! mCommandQueue.isEmpty());
+    return true;
+}
+
+InputDispatcher::CommandEntry* InputDispatcher::postCommandLocked(Command command) {
+    CommandEntry* commandEntry = new CommandEntry(command);
+    mCommandQueue.enqueueAtTail(commandEntry);
+    return commandEntry;
+}
+
+void InputDispatcher::drainInboundQueueLocked() {
+    while (! mInboundQueue.isEmpty()) {
+        EventEntry* entry = mInboundQueue.dequeueAtHead();
+        releaseInboundEventLocked(entry);
+    }
+    traceInboundQueueLengthLocked();
+}
+
+void InputDispatcher::releasePendingEventLocked() {
+    if (mPendingEvent) {
+        resetANRTimeoutsLocked();
+        releaseInboundEventLocked(mPendingEvent);
+        mPendingEvent = NULL;
+    }
+}
+
+void InputDispatcher::releaseInboundEventLocked(EventEntry* entry) {
+    InjectionState* injectionState = entry->injectionState;
+    if (injectionState && injectionState->injectionResult == INPUT_EVENT_INJECTION_PENDING) {
+#if DEBUG_DISPATCH_CYCLE
+        ALOGD("Injected inbound event was dropped.");
+#endif
+        setInjectionResultLocked(entry, INPUT_EVENT_INJECTION_FAILED);
+    }
+    if (entry == mNextUnblockedEvent) {
+        mNextUnblockedEvent = NULL;
+    }
+    addRecentEventLocked(entry);
+    entry->release();
+}
+
+void InputDispatcher::resetKeyRepeatLocked() {
+    if (mKeyRepeatState.lastKeyEntry) {
+        mKeyRepeatState.lastKeyEntry->release();
+        mKeyRepeatState.lastKeyEntry = NULL;
+    }
+}
+
+InputDispatcher::KeyEntry* InputDispatcher::synthesizeKeyRepeatLocked(nsecs_t currentTime) {
+    KeyEntry* entry = mKeyRepeatState.lastKeyEntry;
+
+    // Reuse the repeated key entry if it is otherwise unreferenced.
+    uint32_t policyFlags = entry->policyFlags &
+            (POLICY_FLAG_RAW_MASK | POLICY_FLAG_PASS_TO_USER | POLICY_FLAG_TRUSTED);
+    if (entry->refCount == 1) {
+        entry->recycle();
+        entry->eventTime = currentTime;
+        entry->policyFlags = policyFlags;
+        entry->repeatCount += 1;
+    } else {
+        KeyEntry* newEntry = new KeyEntry(currentTime,
+                entry->deviceId, entry->source, policyFlags,
+                entry->action, entry->flags, entry->keyCode, entry->scanCode,
+                entry->metaState, entry->repeatCount + 1, entry->downTime);
+
+        mKeyRepeatState.lastKeyEntry = newEntry;
+        entry->release();
+
+        entry = newEntry;
+    }
+    entry->syntheticRepeat = true;
+
+    // Increment reference count since we keep a reference to the event in
+    // mKeyRepeatState.lastKeyEntry in addition to the one we return.
+    entry->refCount += 1;
+
+    mKeyRepeatState.nextRepeatTime = currentTime + mConfig.keyRepeatDelay;
+    return entry;
+}
+
+bool InputDispatcher::dispatchConfigurationChangedLocked(
+        nsecs_t currentTime, ConfigurationChangedEntry* entry) {
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+    ALOGD("dispatchConfigurationChanged - eventTime=%lld", entry->eventTime);
+#endif
+
+    // Reset key repeating in case a keyboard device was added or removed or something.
+    resetKeyRepeatLocked();
+
+    // Enqueue a command to run outside the lock to tell the policy that the configuration changed.
+    CommandEntry* commandEntry = postCommandLocked(
+            & InputDispatcher::doNotifyConfigurationChangedInterruptible);
+    commandEntry->eventTime = entry->eventTime;
+    return true;
+}
+
+bool InputDispatcher::dispatchDeviceResetLocked(
+        nsecs_t currentTime, DeviceResetEntry* entry) {
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+    ALOGD("dispatchDeviceReset - eventTime=%lld, deviceId=%d", entry->eventTime, entry->deviceId);
+#endif
+
+    CancelationOptions options(CancelationOptions::CANCEL_ALL_EVENTS,
+            "device was reset");
+    options.deviceId = entry->deviceId;
+    synthesizeCancelationEventsForAllConnectionsLocked(options);
+    return true;
+}
+
+bool InputDispatcher::dispatchKeyLocked(nsecs_t currentTime, KeyEntry* entry,
+        DropReason* dropReason, nsecs_t* nextWakeupTime) {
+    // Preprocessing.
+    if (! entry->dispatchInProgress) {
+        if (entry->repeatCount == 0
+                && entry->action == AKEY_EVENT_ACTION_DOWN
+                && (entry->policyFlags & POLICY_FLAG_TRUSTED)
+                && (!(entry->policyFlags & POLICY_FLAG_DISABLE_KEY_REPEAT))) {
+            if (mKeyRepeatState.lastKeyEntry
+                    && mKeyRepeatState.lastKeyEntry->keyCode == entry->keyCode) {
+                // We have seen two identical key downs in a row which indicates that the device
+                // driver is automatically generating key repeats itself.  We take note of the
+                // repeat here, but we disable our own next key repeat timer since it is clear that
+                // we will not need to synthesize key repeats ourselves.
+                entry->repeatCount = mKeyRepeatState.lastKeyEntry->repeatCount + 1;
+                resetKeyRepeatLocked();
+                mKeyRepeatState.nextRepeatTime = LONG_LONG_MAX; // don't generate repeats ourselves
+            } else {
+                // Not a repeat.  Save key down state in case we do see a repeat later.
+                resetKeyRepeatLocked();
+                mKeyRepeatState.nextRepeatTime = entry->eventTime + mConfig.keyRepeatTimeout;
+            }
+            mKeyRepeatState.lastKeyEntry = entry;
+            entry->refCount += 1;
+        } else if (! entry->syntheticRepeat) {
+            resetKeyRepeatLocked();
+        }
+
+        if (entry->repeatCount == 1) {
+            entry->flags |= AKEY_EVENT_FLAG_LONG_PRESS;
+        } else {
+            entry->flags &= ~AKEY_EVENT_FLAG_LONG_PRESS;
+        }
+
+        entry->dispatchInProgress = true;
+
+        logOutboundKeyDetailsLocked("dispatchKey - ", entry);
+    }
+
+    // Handle case where the policy asked us to try again later last time.
+    if (entry->interceptKeyResult == KeyEntry::INTERCEPT_KEY_RESULT_TRY_AGAIN_LATER) {
+        if (currentTime < entry->interceptKeyWakeupTime) {
+            if (entry->interceptKeyWakeupTime < *nextWakeupTime) {
+                *nextWakeupTime = entry->interceptKeyWakeupTime;
+            }
+            return false; // wait until next wakeup
+        }
+        entry->interceptKeyResult = KeyEntry::INTERCEPT_KEY_RESULT_UNKNOWN;
+        entry->interceptKeyWakeupTime = 0;
+    }
+
+    // Give the policy a chance to intercept the key.
+    if (entry->interceptKeyResult == KeyEntry::INTERCEPT_KEY_RESULT_UNKNOWN) {
+        if (entry->policyFlags & POLICY_FLAG_PASS_TO_USER) {
+            CommandEntry* commandEntry = postCommandLocked(
+                    & InputDispatcher::doInterceptKeyBeforeDispatchingLockedInterruptible);
+            if (mFocusedWindowHandle != NULL) {
+                commandEntry->inputWindowHandle = mFocusedWindowHandle;
+            }
+            commandEntry->keyEntry = entry;
+            entry->refCount += 1;
+            return false; // wait for the command to run
+        } else {
+            entry->interceptKeyResult = KeyEntry::INTERCEPT_KEY_RESULT_CONTINUE;
+        }
+    } else if (entry->interceptKeyResult == KeyEntry::INTERCEPT_KEY_RESULT_SKIP) {
+        if (*dropReason == DROP_REASON_NOT_DROPPED) {
+            *dropReason = DROP_REASON_POLICY;
+        }
+    }
+
+    // Clean up if dropping the event.
+    if (*dropReason != DROP_REASON_NOT_DROPPED) {
+        setInjectionResultLocked(entry, *dropReason == DROP_REASON_POLICY
+                ? INPUT_EVENT_INJECTION_SUCCEEDED : INPUT_EVENT_INJECTION_FAILED);
+        return true;
+    }
+
+    // Identify targets.
+    Vector<InputTarget> inputTargets;
+    int32_t injectionResult = findFocusedWindowTargetsLocked(currentTime,
+            entry, inputTargets, nextWakeupTime);
+    if (injectionResult == INPUT_EVENT_INJECTION_PENDING) {
+        return false;
+    }
+
+    setInjectionResultLocked(entry, injectionResult);
+    if (injectionResult != INPUT_EVENT_INJECTION_SUCCEEDED) {
+        return true;
+    }
+
+    addMonitoringTargetsLocked(inputTargets);
+
+    // Dispatch the key.
+    dispatchEventLocked(currentTime, entry, inputTargets);
+    return true;
+}
+
+void InputDispatcher::logOutboundKeyDetailsLocked(const char* prefix, const KeyEntry* entry) {
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+    ALOGD("%seventTime=%lld, deviceId=%d, source=0x%x, policyFlags=0x%x, "
+            "action=0x%x, flags=0x%x, keyCode=0x%x, scanCode=0x%x, metaState=0x%x, "
+            "repeatCount=%d, downTime=%lld",
+            prefix,
+            entry->eventTime, entry->deviceId, entry->source, entry->policyFlags,
+            entry->action, entry->flags, entry->keyCode, entry->scanCode, entry->metaState,
+            entry->repeatCount, entry->downTime);
+#endif
+}
+
+bool InputDispatcher::dispatchMotionLocked(
+        nsecs_t currentTime, MotionEntry* entry, DropReason* dropReason, nsecs_t* nextWakeupTime) {
+    // Preprocessing.
+    if (! entry->dispatchInProgress) {
+        entry->dispatchInProgress = true;
+
+        logOutboundMotionDetailsLocked("dispatchMotion - ", entry);
+    }
+
+    // Clean up if dropping the event.
+    if (*dropReason != DROP_REASON_NOT_DROPPED) {
+        setInjectionResultLocked(entry, *dropReason == DROP_REASON_POLICY
+                ? INPUT_EVENT_INJECTION_SUCCEEDED : INPUT_EVENT_INJECTION_FAILED);
+        return true;
+    }
+
+    bool isPointerEvent = entry->source & AINPUT_SOURCE_CLASS_POINTER;
+
+    // Identify targets.
+    Vector<InputTarget> inputTargets;
+
+    bool conflictingPointerActions = false;
+    int32_t injectionResult;
+    if (isPointerEvent) {
+        // Pointer event.  (eg. touchscreen)
+        injectionResult = findTouchedWindowTargetsLocked(currentTime,
+                entry, inputTargets, nextWakeupTime, &conflictingPointerActions);
+    } else {
+        // Non touch event.  (eg. trackball)
+        injectionResult = findFocusedWindowTargetsLocked(currentTime,
+                entry, inputTargets, nextWakeupTime);
+    }
+    if (injectionResult == INPUT_EVENT_INJECTION_PENDING) {
+        return false;
+    }
+
+    setInjectionResultLocked(entry, injectionResult);
+    if (injectionResult != INPUT_EVENT_INJECTION_SUCCEEDED) {
+        if (injectionResult != INPUT_EVENT_INJECTION_PERMISSION_DENIED) {
+            CancelationOptions::Mode mode(isPointerEvent ?
+                    CancelationOptions::CANCEL_POINTER_EVENTS :
+                    CancelationOptions::CANCEL_NON_POINTER_EVENTS);
+            CancelationOptions options(mode, "input event injection failed");
+            synthesizeCancelationEventsForMonitorsLocked(options);
+        }
+        return true;
+    }
+
+    // TODO: support sending secondary display events to input monitors
+    if (isMainDisplay(entry->displayId)) {
+        addMonitoringTargetsLocked(inputTargets);
+    }
+
+    // Dispatch the motion.
+    if (conflictingPointerActions) {
+        CancelationOptions options(CancelationOptions::CANCEL_POINTER_EVENTS,
+                "conflicting pointer actions");
+        synthesizeCancelationEventsForAllConnectionsLocked(options);
+    }
+    dispatchEventLocked(currentTime, entry, inputTargets);
+    return true;
+}
+
+
+void InputDispatcher::logOutboundMotionDetailsLocked(const char* prefix, const MotionEntry* entry) {
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+    ALOGD("%seventTime=%lld, deviceId=%d, source=0x%x, policyFlags=0x%x, "
+            "action=0x%x, actionButton=0x%x, flags=0x%x, "
+            "metaState=0x%x, buttonState=0x%x,"
+            "edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, downTime=%lld",
+            prefix,
+            entry->eventTime, entry->deviceId, entry->source, entry->policyFlags,
+            entry->action, entry->actionButton, entry->flags,
+            entry->metaState, entry->buttonState,
+            entry->edgeFlags, entry->xPrecision, entry->yPrecision,
+            entry->downTime);
+
+    for (uint32_t i = 0; i < entry->pointerCount; i++) {
+        ALOGD("  Pointer %d: id=%d, toolType=%d, "
+                "x=%f, y=%f, pressure=%f, size=%f, "
+                "touchMajor=%f, touchMinor=%f, toolMajor=%f, toolMinor=%f, "
+                "orientation=%f",
+                i, entry->pointerProperties[i].id,
+                entry->pointerProperties[i].toolType,
+                entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_X),
+                entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_Y),
+                entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE),
+                entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_SIZE),
+                entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR),
+                entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR),
+                entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR),
+                entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR),
+                entry->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION));
+    }
+#endif
+}
+
+void InputDispatcher::dispatchEventLocked(nsecs_t currentTime,
+        EventEntry* eventEntry, const Vector<InputTarget>& inputTargets) {
+#if DEBUG_DISPATCH_CYCLE
+    ALOGD("dispatchEventToCurrentInputTargets");
+#endif
+
+    ALOG_ASSERT(eventEntry->dispatchInProgress); // should already have been set to true
+
+    pokeUserActivityLocked(eventEntry);
+
+    for (size_t i = 0; i < inputTargets.size(); i++) {
+        const InputTarget& inputTarget = inputTargets.itemAt(i);
+
+        ssize_t connectionIndex = getConnectionIndexLocked(inputTarget.inputChannel);
+        if (connectionIndex >= 0) {
+            sp<Connection> connection = mConnectionsByFd.valueAt(connectionIndex);
+            prepareDispatchCycleLocked(currentTime, connection, eventEntry, &inputTarget);
+        } else {
+#if DEBUG_FOCUS
+            ALOGD("Dropping event delivery to target with channel '%s' because it "
+                    "is no longer registered with the input dispatcher.",
+                    inputTarget.inputChannel->getName().string());
+#endif
+        }
+    }
+}
+
+int32_t InputDispatcher::handleTargetsNotReadyLocked(nsecs_t currentTime,
+        const EventEntry* entry,
+        const sp<InputApplicationHandle>& applicationHandle,
+        const sp<InputWindowHandle>& windowHandle,
+        nsecs_t* nextWakeupTime, const char* reason) {
+    if (applicationHandle == NULL && windowHandle == NULL) {
+        if (mInputTargetWaitCause != INPUT_TARGET_WAIT_CAUSE_SYSTEM_NOT_READY) {
+#if DEBUG_FOCUS
+            ALOGD("Waiting for system to become ready for input.  Reason: %s", reason);
+#endif
+            mInputTargetWaitCause = INPUT_TARGET_WAIT_CAUSE_SYSTEM_NOT_READY;
+            mInputTargetWaitStartTime = currentTime;
+            mInputTargetWaitTimeoutTime = LONG_LONG_MAX;
+            mInputTargetWaitTimeoutExpired = false;
+            mInputTargetWaitApplicationHandle.clear();
+        }
+    } else {
+        if (mInputTargetWaitCause != INPUT_TARGET_WAIT_CAUSE_APPLICATION_NOT_READY) {
+#if DEBUG_FOCUS
+            ALOGD("Waiting for application to become ready for input: %s.  Reason: %s",
+                    getApplicationWindowLabelLocked(applicationHandle, windowHandle).string(),
+                    reason);
+#endif
+            nsecs_t timeout;
+            if (windowHandle != NULL) {
+                timeout = windowHandle->getDispatchingTimeout(DEFAULT_INPUT_DISPATCHING_TIMEOUT);
+            } else if (applicationHandle != NULL) {
+                timeout = applicationHandle->getDispatchingTimeout(
+                        DEFAULT_INPUT_DISPATCHING_TIMEOUT);
+            } else {
+                timeout = DEFAULT_INPUT_DISPATCHING_TIMEOUT;
+            }
+
+            mInputTargetWaitCause = INPUT_TARGET_WAIT_CAUSE_APPLICATION_NOT_READY;
+            mInputTargetWaitStartTime = currentTime;
+            mInputTargetWaitTimeoutTime = currentTime + timeout;
+            mInputTargetWaitTimeoutExpired = false;
+            mInputTargetWaitApplicationHandle.clear();
+
+            if (windowHandle != NULL) {
+                mInputTargetWaitApplicationHandle = windowHandle->inputApplicationHandle;
+            }
+            if (mInputTargetWaitApplicationHandle == NULL && applicationHandle != NULL) {
+                mInputTargetWaitApplicationHandle = applicationHandle;
+            }
+        }
+    }
+
+    if (mInputTargetWaitTimeoutExpired) {
+        return INPUT_EVENT_INJECTION_TIMED_OUT;
+    }
+
+    if (currentTime >= mInputTargetWaitTimeoutTime) {
+        onANRLocked(currentTime, applicationHandle, windowHandle,
+                entry->eventTime, mInputTargetWaitStartTime, reason);
+
+        // Force poll loop to wake up immediately on next iteration once we get the
+        // ANR response back from the policy.
+        *nextWakeupTime = LONG_LONG_MIN;
+        return INPUT_EVENT_INJECTION_PENDING;
+    } else {
+        // Force poll loop to wake up when timeout is due.
+        if (mInputTargetWaitTimeoutTime < *nextWakeupTime) {
+            *nextWakeupTime = mInputTargetWaitTimeoutTime;
+        }
+        return INPUT_EVENT_INJECTION_PENDING;
+    }
+}
+
+void InputDispatcher::resumeAfterTargetsNotReadyTimeoutLocked(nsecs_t newTimeout,
+        const sp<InputChannel>& inputChannel) {
+    if (newTimeout > 0) {
+        // Extend the timeout.
+        mInputTargetWaitTimeoutTime = now() + newTimeout;
+    } else {
+        // Give up.
+        mInputTargetWaitTimeoutExpired = true;
+
+        // Input state will not be realistic.  Mark it out of sync.
+        if (inputChannel.get()) {
+            ssize_t connectionIndex = getConnectionIndexLocked(inputChannel);
+            if (connectionIndex >= 0) {
+                sp<Connection> connection = mConnectionsByFd.valueAt(connectionIndex);
+                sp<InputWindowHandle> windowHandle = connection->inputWindowHandle;
+
+                if (windowHandle != NULL) {
+                    const InputWindowInfo* info = windowHandle->getInfo();
+                    if (info) {
+                        ssize_t stateIndex = mTouchStatesByDisplay.indexOfKey(info->displayId);
+                        if (stateIndex >= 0) {
+                            mTouchStatesByDisplay.editValueAt(stateIndex).removeWindow(
+                                    windowHandle);
+                        }
+                    }
+                }
+
+                if (connection->status == Connection::STATUS_NORMAL) {
+                    CancelationOptions options(CancelationOptions::CANCEL_ALL_EVENTS,
+                            "application not responding");
+                    synthesizeCancelationEventsForConnectionLocked(connection, options);
+                }
+            }
+        }
+    }
+}
+
+nsecs_t InputDispatcher::getTimeSpentWaitingForApplicationLocked(
+        nsecs_t currentTime) {
+    if (mInputTargetWaitCause == INPUT_TARGET_WAIT_CAUSE_APPLICATION_NOT_READY) {
+        return currentTime - mInputTargetWaitStartTime;
+    }
+    return 0;
+}
+
+void InputDispatcher::resetANRTimeoutsLocked() {
+#if DEBUG_FOCUS
+        ALOGD("Resetting ANR timeouts.");
+#endif
+
+    // Reset input target wait timeout.
+    mInputTargetWaitCause = INPUT_TARGET_WAIT_CAUSE_NONE;
+    mInputTargetWaitApplicationHandle.clear();
+}
+
+int32_t InputDispatcher::findFocusedWindowTargetsLocked(nsecs_t currentTime,
+        const EventEntry* entry, Vector<InputTarget>& inputTargets, nsecs_t* nextWakeupTime) {
+    int32_t injectionResult;
+    String8 reason;
+
+    // If there is no currently focused window and no focused application
+    // then drop the event.
+    if (mFocusedWindowHandle == NULL) {
+        if (mFocusedApplicationHandle != NULL) {
+            injectionResult = handleTargetsNotReadyLocked(currentTime, entry,
+                    mFocusedApplicationHandle, NULL, nextWakeupTime,
+                    "Waiting because no window has focus but there is a "
+                    "focused application that may eventually add a window "
+                    "when it finishes starting up.");
+            goto Unresponsive;
+        }
+
+        ALOGI("Dropping event because there is no focused window or focused application.");
+        injectionResult = INPUT_EVENT_INJECTION_FAILED;
+        goto Failed;
+    }
+
+    // Check permissions.
+    if (! checkInjectionPermission(mFocusedWindowHandle, entry->injectionState)) {
+        injectionResult = INPUT_EVENT_INJECTION_PERMISSION_DENIED;
+        goto Failed;
+    }
+
+    // Check whether the window is ready for more input.
+    reason = checkWindowReadyForMoreInputLocked(currentTime,
+            mFocusedWindowHandle, entry, "focused");
+    if (!reason.isEmpty()) {
+        injectionResult = handleTargetsNotReadyLocked(currentTime, entry,
+                mFocusedApplicationHandle, mFocusedWindowHandle, nextWakeupTime, reason.string());
+        goto Unresponsive;
+    }
+
+    // Success!  Output targets.
+    injectionResult = INPUT_EVENT_INJECTION_SUCCEEDED;
+    addWindowTargetLocked(mFocusedWindowHandle,
+            InputTarget::FLAG_FOREGROUND | InputTarget::FLAG_DISPATCH_AS_IS, BitSet32(0),
+            inputTargets);
+
+    // Done.
+Failed:
+Unresponsive:
+    nsecs_t timeSpentWaitingForApplication = getTimeSpentWaitingForApplicationLocked(currentTime);
+    updateDispatchStatisticsLocked(currentTime, entry,
+            injectionResult, timeSpentWaitingForApplication);
+#if DEBUG_FOCUS
+    ALOGD("findFocusedWindow finished: injectionResult=%d, "
+            "timeSpentWaitingForApplication=%0.1fms",
+            injectionResult, timeSpentWaitingForApplication / 1000000.0);
+#endif
+    return injectionResult;
+}
+
+int32_t InputDispatcher::findTouchedWindowTargetsLocked(nsecs_t currentTime,
+        const MotionEntry* entry, Vector<InputTarget>& inputTargets, nsecs_t* nextWakeupTime,
+        bool* outConflictingPointerActions) {
+    enum InjectionPermission {
+        INJECTION_PERMISSION_UNKNOWN,
+        INJECTION_PERMISSION_GRANTED,
+        INJECTION_PERMISSION_DENIED
+    };
+
+    nsecs_t startTime = now();
+
+    // For security reasons, we defer updating the touch state until we are sure that
+    // event injection will be allowed.
+    int32_t displayId = entry->displayId;
+    int32_t action = entry->action;
+    int32_t maskedAction = action & AMOTION_EVENT_ACTION_MASK;
+
+    // Update the touch state as needed based on the properties of the touch event.
+    int32_t injectionResult = INPUT_EVENT_INJECTION_PENDING;
+    InjectionPermission injectionPermission = INJECTION_PERMISSION_UNKNOWN;
+    sp<InputWindowHandle> newHoverWindowHandle;
+
+    // Copy current touch state into mTempTouchState.
+    // This state is always reset at the end of this function, so if we don't find state
+    // for the specified display then our initial state will be empty.
+    const TouchState* oldState = NULL;
+    ssize_t oldStateIndex = mTouchStatesByDisplay.indexOfKey(displayId);
+    if (oldStateIndex >= 0) {
+        oldState = &mTouchStatesByDisplay.valueAt(oldStateIndex);
+        mTempTouchState.copyFrom(*oldState);
+    }
+
+    bool isSplit = mTempTouchState.split;
+    bool switchedDevice = mTempTouchState.deviceId >= 0 && mTempTouchState.displayId >= 0
+            && (mTempTouchState.deviceId != entry->deviceId
+                    || mTempTouchState.source != entry->source
+                    || mTempTouchState.displayId != displayId);
+    bool isHoverAction = (maskedAction == AMOTION_EVENT_ACTION_HOVER_MOVE
+            || maskedAction == AMOTION_EVENT_ACTION_HOVER_ENTER
+            || maskedAction == AMOTION_EVENT_ACTION_HOVER_EXIT);
+    bool newGesture = (maskedAction == AMOTION_EVENT_ACTION_DOWN
+            || maskedAction == AMOTION_EVENT_ACTION_SCROLL
+            || isHoverAction);
+    bool wrongDevice = false;
+    if (newGesture) {
+        bool down = maskedAction == AMOTION_EVENT_ACTION_DOWN;
+        if (switchedDevice && mTempTouchState.down && !down) {
+#if DEBUG_FOCUS
+            ALOGD("Dropping event because a pointer for a different device is already down.");
+#endif
+            injectionResult = INPUT_EVENT_INJECTION_FAILED;
+            switchedDevice = false;
+            wrongDevice = true;
+            goto Failed;
+        }
+        mTempTouchState.reset();
+        mTempTouchState.down = down;
+        mTempTouchState.deviceId = entry->deviceId;
+        mTempTouchState.source = entry->source;
+        mTempTouchState.displayId = displayId;
+        isSplit = false;
+    }
+
+    if (newGesture || (isSplit && maskedAction == AMOTION_EVENT_ACTION_POINTER_DOWN)) {
+        /* Case 1: New splittable pointer going down, or need target for hover or scroll. */
+
+        int32_t pointerIndex = getMotionEventActionPointerIndex(action);
+        int32_t x = int32_t(entry->pointerCoords[pointerIndex].
+                getAxisValue(AMOTION_EVENT_AXIS_X));
+        int32_t y = int32_t(entry->pointerCoords[pointerIndex].
+                getAxisValue(AMOTION_EVENT_AXIS_Y));
+        sp<InputWindowHandle> newTouchedWindowHandle;
+        bool isTouchModal = false;
+
+        // Traverse windows from front to back to find touched window and outside targets.
+        size_t numWindows = mWindowHandles.size();
+        for (size_t i = 0; i < numWindows; i++) {
+            sp<InputWindowHandle> windowHandle = mWindowHandles.itemAt(i);
+            const InputWindowInfo* windowInfo = windowHandle->getInfo();
+            if (windowInfo->displayId != displayId) {
+                continue; // wrong display
+            }
+
+            int32_t flags = windowInfo->layoutParamsFlags;
+            if (windowInfo->visible) {
+                if (! (flags & InputWindowInfo::FLAG_NOT_TOUCHABLE)) {
+                    isTouchModal = (flags & (InputWindowInfo::FLAG_NOT_FOCUSABLE
+                            | InputWindowInfo::FLAG_NOT_TOUCH_MODAL)) == 0;
+                    if (isTouchModal || windowInfo->touchableRegionContainsPoint(x, y)) {
+                        newTouchedWindowHandle = windowHandle;
+                        break; // found touched window, exit window loop
+                    }
+                }
+
+                if (maskedAction == AMOTION_EVENT_ACTION_DOWN
+                        && (flags & InputWindowInfo::FLAG_WATCH_OUTSIDE_TOUCH)) {
+                    int32_t outsideTargetFlags = InputTarget::FLAG_DISPATCH_AS_OUTSIDE;
+                    if (isWindowObscuredAtPointLocked(windowHandle, x, y)) {
+                        outsideTargetFlags |= InputTarget::FLAG_WINDOW_IS_OBSCURED;
+                    }
+
+                    mTempTouchState.addOrUpdateWindow(
+                            windowHandle, outsideTargetFlags, BitSet32(0));
+                }
+            }
+        }
+
+        // Figure out whether splitting will be allowed for this window.
+        if (newTouchedWindowHandle != NULL
+                && newTouchedWindowHandle->getInfo()->supportsSplitTouch()) {
+            // New window supports splitting.
+            isSplit = true;
+        } else if (isSplit) {
+            // New window does not support splitting but we have already split events.
+            // Ignore the new window.
+            newTouchedWindowHandle = NULL;
+        }
+
+        // Handle the case where we did not find a window.
+        if (newTouchedWindowHandle == NULL) {
+            // Try to assign the pointer to the first foreground window we find, if there is one.
+            newTouchedWindowHandle = mTempTouchState.getFirstForegroundWindowHandle();
+            if (newTouchedWindowHandle == NULL) {
+                ALOGI("Dropping event because there is no touchable window at (%d, %d).", x, y);
+                injectionResult = INPUT_EVENT_INJECTION_FAILED;
+                goto Failed;
+            }
+        }
+
+        // Set target flags.
+        int32_t targetFlags = InputTarget::FLAG_FOREGROUND | InputTarget::FLAG_DISPATCH_AS_IS;
+        if (isSplit) {
+            targetFlags |= InputTarget::FLAG_SPLIT;
+        }
+        if (isWindowObscuredAtPointLocked(newTouchedWindowHandle, x, y)) {
+            targetFlags |= InputTarget::FLAG_WINDOW_IS_OBSCURED;
+        }
+
+        // Update hover state.
+        if (isHoverAction) {
+            newHoverWindowHandle = newTouchedWindowHandle;
+        } else if (maskedAction == AMOTION_EVENT_ACTION_SCROLL) {
+            newHoverWindowHandle = mLastHoverWindowHandle;
+        }
+
+        // Update the temporary touch state.
+        BitSet32 pointerIds;
+        if (isSplit) {
+            uint32_t pointerId = entry->pointerProperties[pointerIndex].id;
+            pointerIds.markBit(pointerId);
+        }
+        mTempTouchState.addOrUpdateWindow(newTouchedWindowHandle, targetFlags, pointerIds);
+    } else {
+        /* Case 2: Pointer move, up, cancel or non-splittable pointer down. */
+
+        // If the pointer is not currently down, then ignore the event.
+        if (! mTempTouchState.down) {
+#if DEBUG_FOCUS
+            ALOGD("Dropping event because the pointer is not down or we previously "
+                    "dropped the pointer down event.");
+#endif
+            injectionResult = INPUT_EVENT_INJECTION_FAILED;
+            goto Failed;
+        }
+
+        // Check whether touches should slip outside of the current foreground window.
+        if (maskedAction == AMOTION_EVENT_ACTION_MOVE
+                && entry->pointerCount == 1
+                && mTempTouchState.isSlippery()) {
+            int32_t x = int32_t(entry->pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X));
+            int32_t y = int32_t(entry->pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y));
+
+            sp<InputWindowHandle> oldTouchedWindowHandle =
+                    mTempTouchState.getFirstForegroundWindowHandle();
+            sp<InputWindowHandle> newTouchedWindowHandle =
+                    findTouchedWindowAtLocked(displayId, x, y);
+            if (oldTouchedWindowHandle != newTouchedWindowHandle
+                    && newTouchedWindowHandle != NULL) {
+#if DEBUG_FOCUS
+                ALOGD("Touch is slipping out of window %s into window %s.",
+                        oldTouchedWindowHandle->getName().string(),
+                        newTouchedWindowHandle->getName().string());
+#endif
+                // Make a slippery exit from the old window.
+                mTempTouchState.addOrUpdateWindow(oldTouchedWindowHandle,
+                        InputTarget::FLAG_DISPATCH_AS_SLIPPERY_EXIT, BitSet32(0));
+
+                // Make a slippery entrance into the new window.
+                if (newTouchedWindowHandle->getInfo()->supportsSplitTouch()) {
+                    isSplit = true;
+                }
+
+                int32_t targetFlags = InputTarget::FLAG_FOREGROUND
+                        | InputTarget::FLAG_DISPATCH_AS_SLIPPERY_ENTER;
+                if (isSplit) {
+                    targetFlags |= InputTarget::FLAG_SPLIT;
+                }
+                if (isWindowObscuredAtPointLocked(newTouchedWindowHandle, x, y)) {
+                    targetFlags |= InputTarget::FLAG_WINDOW_IS_OBSCURED;
+                }
+
+                BitSet32 pointerIds;
+                if (isSplit) {
+                    pointerIds.markBit(entry->pointerProperties[0].id);
+                }
+                mTempTouchState.addOrUpdateWindow(newTouchedWindowHandle, targetFlags, pointerIds);
+            }
+        }
+    }
+
+    if (newHoverWindowHandle != mLastHoverWindowHandle) {
+        // Let the previous window know that the hover sequence is over.
+        if (mLastHoverWindowHandle != NULL) {
+#if DEBUG_HOVER
+            ALOGD("Sending hover exit event to window %s.",
+                    mLastHoverWindowHandle->getName().string());
+#endif
+            mTempTouchState.addOrUpdateWindow(mLastHoverWindowHandle,
+                    InputTarget::FLAG_DISPATCH_AS_HOVER_EXIT, BitSet32(0));
+        }
+
+        // Let the new window know that the hover sequence is starting.
+        if (newHoverWindowHandle != NULL) {
+#if DEBUG_HOVER
+            ALOGD("Sending hover enter event to window %s.",
+                    newHoverWindowHandle->getName().string());
+#endif
+            mTempTouchState.addOrUpdateWindow(newHoverWindowHandle,
+                    InputTarget::FLAG_DISPATCH_AS_HOVER_ENTER, BitSet32(0));
+        }
+    }
+
+    // Check permission to inject into all touched foreground windows and ensure there
+    // is at least one touched foreground window.
+    {
+        bool haveForegroundWindow = false;
+        for (size_t i = 0; i < mTempTouchState.windows.size(); i++) {
+            const TouchedWindow& touchedWindow = mTempTouchState.windows[i];
+            if (touchedWindow.targetFlags & InputTarget::FLAG_FOREGROUND) {
+                haveForegroundWindow = true;
+                if (! checkInjectionPermission(touchedWindow.windowHandle,
+                        entry->injectionState)) {
+                    injectionResult = INPUT_EVENT_INJECTION_PERMISSION_DENIED;
+                    injectionPermission = INJECTION_PERMISSION_DENIED;
+                    goto Failed;
+                }
+            }
+        }
+        if (! haveForegroundWindow) {
+#if DEBUG_FOCUS
+            ALOGD("Dropping event because there is no touched foreground window to receive it.");
+#endif
+            injectionResult = INPUT_EVENT_INJECTION_FAILED;
+            goto Failed;
+        }
+
+        // Permission granted to injection into all touched foreground windows.
+        injectionPermission = INJECTION_PERMISSION_GRANTED;
+    }
+
+    // Check whether windows listening for outside touches are owned by the same UID. If it is
+    // set the policy flag that we will not reveal coordinate information to this window.
+    if (maskedAction == AMOTION_EVENT_ACTION_DOWN) {
+        sp<InputWindowHandle> foregroundWindowHandle =
+                mTempTouchState.getFirstForegroundWindowHandle();
+        const int32_t foregroundWindowUid = foregroundWindowHandle->getInfo()->ownerUid;
+        for (size_t i = 0; i < mTempTouchState.windows.size(); i++) {
+            const TouchedWindow& touchedWindow = mTempTouchState.windows[i];
+            if (touchedWindow.targetFlags & InputTarget::FLAG_DISPATCH_AS_OUTSIDE) {
+                sp<InputWindowHandle> inputWindowHandle = touchedWindow.windowHandle;
+                if (inputWindowHandle->getInfo()->ownerUid != foregroundWindowUid) {
+                    mTempTouchState.addOrUpdateWindow(inputWindowHandle,
+                            InputTarget::FLAG_ZERO_COORDS, BitSet32(0));
+                }
+            }
+        }
+    }
+
+    // Ensure all touched foreground windows are ready for new input.
+    for (size_t i = 0; i < mTempTouchState.windows.size(); i++) {
+        const TouchedWindow& touchedWindow = mTempTouchState.windows[i];
+        if (touchedWindow.targetFlags & InputTarget::FLAG_FOREGROUND) {
+            // Check whether the window is ready for more input.
+            String8 reason = checkWindowReadyForMoreInputLocked(currentTime,
+                    touchedWindow.windowHandle, entry, "touched");
+            if (!reason.isEmpty()) {
+                injectionResult = handleTargetsNotReadyLocked(currentTime, entry,
+                        NULL, touchedWindow.windowHandle, nextWakeupTime, reason.string());
+                goto Unresponsive;
+            }
+        }
+    }
+
+    // If this is the first pointer going down and the touched window has a wallpaper
+    // then also add the touched wallpaper windows so they are locked in for the duration
+    // of the touch gesture.
+    // We do not collect wallpapers during HOVER_MOVE or SCROLL because the wallpaper
+    // engine only supports touch events.  We would need to add a mechanism similar
+    // to View.onGenericMotionEvent to enable wallpapers to handle these events.
+    if (maskedAction == AMOTION_EVENT_ACTION_DOWN) {
+        sp<InputWindowHandle> foregroundWindowHandle =
+                mTempTouchState.getFirstForegroundWindowHandle();
+        if (foregroundWindowHandle->getInfo()->hasWallpaper) {
+            for (size_t i = 0; i < mWindowHandles.size(); i++) {
+                sp<InputWindowHandle> windowHandle = mWindowHandles.itemAt(i);
+                const InputWindowInfo* info = windowHandle->getInfo();
+                if (info->displayId == displayId
+                        && windowHandle->getInfo()->layoutParamsType
+                                == InputWindowInfo::TYPE_WALLPAPER) {
+                    mTempTouchState.addOrUpdateWindow(windowHandle,
+                            InputTarget::FLAG_WINDOW_IS_OBSCURED
+                                    | InputTarget::FLAG_DISPATCH_AS_IS,
+                            BitSet32(0));
+                }
+            }
+        }
+    }
+
+    // Success!  Output targets.
+    injectionResult = INPUT_EVENT_INJECTION_SUCCEEDED;
+
+    for (size_t i = 0; i < mTempTouchState.windows.size(); i++) {
+        const TouchedWindow& touchedWindow = mTempTouchState.windows.itemAt(i);
+        addWindowTargetLocked(touchedWindow.windowHandle, touchedWindow.targetFlags,
+                touchedWindow.pointerIds, inputTargets);
+    }
+
+    // Drop the outside or hover touch windows since we will not care about them
+    // in the next iteration.
+    mTempTouchState.filterNonAsIsTouchWindows();
+
+Failed:
+    // Check injection permission once and for all.
+    if (injectionPermission == INJECTION_PERMISSION_UNKNOWN) {
+        if (checkInjectionPermission(NULL, entry->injectionState)) {
+            injectionPermission = INJECTION_PERMISSION_GRANTED;
+        } else {
+            injectionPermission = INJECTION_PERMISSION_DENIED;
+        }
+    }
+
+    // Update final pieces of touch state if the injector had permission.
+    if (injectionPermission == INJECTION_PERMISSION_GRANTED) {
+        if (!wrongDevice) {
+            if (switchedDevice) {
+#if DEBUG_FOCUS
+                ALOGD("Conflicting pointer actions: Switched to a different device.");
+#endif
+                *outConflictingPointerActions = true;
+            }
+
+            if (isHoverAction) {
+                // Started hovering, therefore no longer down.
+                if (oldState && oldState->down) {
+#if DEBUG_FOCUS
+                    ALOGD("Conflicting pointer actions: Hover received while pointer was down.");
+#endif
+                    *outConflictingPointerActions = true;
+                }
+                mTempTouchState.reset();
+                if (maskedAction == AMOTION_EVENT_ACTION_HOVER_ENTER
+                        || maskedAction == AMOTION_EVENT_ACTION_HOVER_MOVE) {
+                    mTempTouchState.deviceId = entry->deviceId;
+                    mTempTouchState.source = entry->source;
+                    mTempTouchState.displayId = displayId;
+                }
+            } else if (maskedAction == AMOTION_EVENT_ACTION_UP
+                    || maskedAction == AMOTION_EVENT_ACTION_CANCEL) {
+                // All pointers up or canceled.
+                mTempTouchState.reset();
+            } else if (maskedAction == AMOTION_EVENT_ACTION_DOWN) {
+                // First pointer went down.
+                if (oldState && oldState->down) {
+#if DEBUG_FOCUS
+                    ALOGD("Conflicting pointer actions: Down received while already down.");
+#endif
+                    *outConflictingPointerActions = true;
+                }
+            } else if (maskedAction == AMOTION_EVENT_ACTION_POINTER_UP) {
+                // One pointer went up.
+                if (isSplit) {
+                    int32_t pointerIndex = getMotionEventActionPointerIndex(action);
+                    uint32_t pointerId = entry->pointerProperties[pointerIndex].id;
+
+                    for (size_t i = 0; i < mTempTouchState.windows.size(); ) {
+                        TouchedWindow& touchedWindow = mTempTouchState.windows.editItemAt(i);
+                        if (touchedWindow.targetFlags & InputTarget::FLAG_SPLIT) {
+                            touchedWindow.pointerIds.clearBit(pointerId);
+                            if (touchedWindow.pointerIds.isEmpty()) {
+                                mTempTouchState.windows.removeAt(i);
+                                continue;
+                            }
+                        }
+                        i += 1;
+                    }
+                }
+            }
+
+            // Save changes unless the action was scroll in which case the temporary touch
+            // state was only valid for this one action.
+            if (maskedAction != AMOTION_EVENT_ACTION_SCROLL) {
+                if (mTempTouchState.displayId >= 0) {
+                    if (oldStateIndex >= 0) {
+                        mTouchStatesByDisplay.editValueAt(oldStateIndex).copyFrom(mTempTouchState);
+                    } else {
+                        mTouchStatesByDisplay.add(displayId, mTempTouchState);
+                    }
+                } else if (oldStateIndex >= 0) {
+                    mTouchStatesByDisplay.removeItemsAt(oldStateIndex);
+                }
+            }
+
+            // Update hover state.
+            mLastHoverWindowHandle = newHoverWindowHandle;
+        }
+    } else {
+#if DEBUG_FOCUS
+        ALOGD("Not updating touch focus because injection was denied.");
+#endif
+    }
+
+Unresponsive:
+    // Reset temporary touch state to ensure we release unnecessary references to input channels.
+    mTempTouchState.reset();
+
+    nsecs_t timeSpentWaitingForApplication = getTimeSpentWaitingForApplicationLocked(currentTime);
+    updateDispatchStatisticsLocked(currentTime, entry,
+            injectionResult, timeSpentWaitingForApplication);
+#if DEBUG_FOCUS
+    ALOGD("findTouchedWindow finished: injectionResult=%d, injectionPermission=%d, "
+            "timeSpentWaitingForApplication=%0.1fms",
+            injectionResult, injectionPermission, timeSpentWaitingForApplication / 1000000.0);
+#endif
+    return injectionResult;
+}
+
+void InputDispatcher::addWindowTargetLocked(const sp<InputWindowHandle>& windowHandle,
+        int32_t targetFlags, BitSet32 pointerIds, Vector<InputTarget>& inputTargets) {
+    inputTargets.push();
+
+    const InputWindowInfo* windowInfo = windowHandle->getInfo();
+    InputTarget& target = inputTargets.editTop();
+    target.inputChannel = windowInfo->inputChannel;
+    target.flags = targetFlags;
+    target.xOffset = - windowInfo->frameLeft;
+    target.yOffset = - windowInfo->frameTop;
+    target.scaleFactor = windowInfo->scaleFactor;
+    target.pointerIds = pointerIds;
+}
+
+void InputDispatcher::addMonitoringTargetsLocked(Vector<InputTarget>& inputTargets) {
+    for (size_t i = 0; i < mMonitoringChannels.size(); i++) {
+        inputTargets.push();
+
+        InputTarget& target = inputTargets.editTop();
+        target.inputChannel = mMonitoringChannels[i];
+        target.flags = InputTarget::FLAG_DISPATCH_AS_IS;
+        target.xOffset = 0;
+        target.yOffset = 0;
+        target.pointerIds.clear();
+        target.scaleFactor = 1.0f;
+    }
+}
+
+bool InputDispatcher::checkInjectionPermission(const sp<InputWindowHandle>& windowHandle,
+        const InjectionState* injectionState) {
+    if (injectionState
+            && (windowHandle == NULL
+                    || windowHandle->getInfo()->ownerUid != injectionState->injectorUid)
+            && !hasInjectionPermission(injectionState->injectorPid, injectionState->injectorUid)) {
+        if (windowHandle != NULL) {
+            ALOGW("Permission denied: injecting event from pid %d uid %d to window %s "
+                    "owned by uid %d",
+                    injectionState->injectorPid, injectionState->injectorUid,
+                    windowHandle->getName().string(),
+                    windowHandle->getInfo()->ownerUid);
+        } else {
+            ALOGW("Permission denied: injecting event from pid %d uid %d",
+                    injectionState->injectorPid, injectionState->injectorUid);
+        }
+        return false;
+    }
+    return true;
+}
+
+bool InputDispatcher::isWindowObscuredAtPointLocked(
+        const sp<InputWindowHandle>& windowHandle, int32_t x, int32_t y) const {
+    int32_t displayId = windowHandle->getInfo()->displayId;
+    size_t numWindows = mWindowHandles.size();
+    for (size_t i = 0; i < numWindows; i++) {
+        sp<InputWindowHandle> otherHandle = mWindowHandles.itemAt(i);
+        if (otherHandle == windowHandle) {
+            break;
+        }
+
+        const InputWindowInfo* otherInfo = otherHandle->getInfo();
+        if (otherInfo->displayId == displayId
+                && otherInfo->visible && !otherInfo->isTrustedOverlay()
+                && otherInfo->frameContainsPoint(x, y)) {
+            return true;
+        }
+    }
+    return false;
+}
+
+String8 InputDispatcher::checkWindowReadyForMoreInputLocked(nsecs_t currentTime,
+        const sp<InputWindowHandle>& windowHandle, const EventEntry* eventEntry,
+        const char* targetType) {
+    // If the window is paused then keep waiting.
+    if (windowHandle->getInfo()->paused) {
+        return String8::format("Waiting because the %s window is paused.", targetType);
+    }
+
+    // If the window's connection is not registered then keep waiting.
+    ssize_t connectionIndex = getConnectionIndexLocked(windowHandle->getInputChannel());
+    if (connectionIndex < 0) {
+        return String8::format("Waiting because the %s window's input channel is not "
+                "registered with the input dispatcher.  The window may be in the process "
+                "of being removed.", targetType);
+    }
+
+    // If the connection is dead then keep waiting.
+    sp<Connection> connection = mConnectionsByFd.valueAt(connectionIndex);
+    if (connection->status != Connection::STATUS_NORMAL) {
+        return String8::format("Waiting because the %s window's input connection is %s."
+                "The window may be in the process of being removed.", targetType,
+                connection->getStatusLabel());
+    }
+
+    // If the connection is backed up then keep waiting.
+    if (connection->inputPublisherBlocked) {
+        return String8::format("Waiting because the %s window's input channel is full.  "
+                "Outbound queue length: %d.  Wait queue length: %d.",
+                targetType, connection->outboundQueue.count(), connection->waitQueue.count());
+    }
+
+    // Ensure that the dispatch queues aren't too far backed up for this event.
+    if (eventEntry->type == EventEntry::TYPE_KEY) {
+        // If the event is a key event, then we must wait for all previous events to
+        // complete before delivering it because previous events may have the
+        // side-effect of transferring focus to a different window and we want to
+        // ensure that the following keys are sent to the new window.
+        //
+        // Suppose the user touches a button in a window then immediately presses "A".
+        // If the button causes a pop-up window to appear then we want to ensure that
+        // the "A" key is delivered to the new pop-up window.  This is because users
+        // often anticipate pending UI changes when typing on a keyboard.
+        // To obtain this behavior, we must serialize key events with respect to all
+        // prior input events.
+        if (!connection->outboundQueue.isEmpty() || !connection->waitQueue.isEmpty()) {
+            return String8::format("Waiting to send key event because the %s window has not "
+                    "finished processing all of the input events that were previously "
+                    "delivered to it.  Outbound queue length: %d.  Wait queue length: %d.",
+                    targetType, connection->outboundQueue.count(), connection->waitQueue.count());
+        }
+    } else {
+        // Touch events can always be sent to a window immediately because the user intended
+        // to touch whatever was visible at the time.  Even if focus changes or a new
+        // window appears moments later, the touch event was meant to be delivered to
+        // whatever window happened to be on screen at the time.
+        //
+        // Generic motion events, such as trackball or joystick events are a little trickier.
+        // Like key events, generic motion events are delivered to the focused window.
+        // Unlike key events, generic motion events don't tend to transfer focus to other
+        // windows and it is not important for them to be serialized.  So we prefer to deliver
+        // generic motion events as soon as possible to improve efficiency and reduce lag
+        // through batching.
+        //
+        // The one case where we pause input event delivery is when the wait queue is piling
+        // up with lots of events because the application is not responding.
+        // This condition ensures that ANRs are detected reliably.
+        if (!connection->waitQueue.isEmpty()
+                && currentTime >= connection->waitQueue.head->deliveryTime
+                        + STREAM_AHEAD_EVENT_TIMEOUT) {
+            return String8::format("Waiting to send non-key event because the %s window has not "
+                    "finished processing certain input events that were delivered to it over "
+                    "%0.1fms ago.  Wait queue length: %d.  Wait queue head age: %0.1fms.",
+                    targetType, STREAM_AHEAD_EVENT_TIMEOUT * 0.000001f,
+                    connection->waitQueue.count(),
+                    (currentTime - connection->waitQueue.head->deliveryTime) * 0.000001f);
+        }
+    }
+    return String8::empty();
+}
+
+String8 InputDispatcher::getApplicationWindowLabelLocked(
+        const sp<InputApplicationHandle>& applicationHandle,
+        const sp<InputWindowHandle>& windowHandle) {
+    if (applicationHandle != NULL) {
+        if (windowHandle != NULL) {
+            String8 label(applicationHandle->getName());
+            label.append(" - ");
+            label.append(windowHandle->getName());
+            return label;
+        } else {
+            return applicationHandle->getName();
+        }
+    } else if (windowHandle != NULL) {
+        return windowHandle->getName();
+    } else {
+        return String8("<unknown application or window>");
+    }
+}
+
+void InputDispatcher::pokeUserActivityLocked(const EventEntry* eventEntry) {
+    if (mFocusedWindowHandle != NULL) {
+        const InputWindowInfo* info = mFocusedWindowHandle->getInfo();
+        if (info->inputFeatures & InputWindowInfo::INPUT_FEATURE_DISABLE_USER_ACTIVITY) {
+#if DEBUG_DISPATCH_CYCLE
+            ALOGD("Not poking user activity: disabled by window '%s'.", info->name.string());
+#endif
+            return;
+        }
+    }
+
+    int32_t eventType = USER_ACTIVITY_EVENT_OTHER;
+    switch (eventEntry->type) {
+    case EventEntry::TYPE_MOTION: {
+        const MotionEntry* motionEntry = static_cast<const MotionEntry*>(eventEntry);
+        if (motionEntry->action == AMOTION_EVENT_ACTION_CANCEL) {
+            return;
+        }
+
+        if (MotionEvent::isTouchEvent(motionEntry->source, motionEntry->action)) {
+            eventType = USER_ACTIVITY_EVENT_TOUCH;
+        }
+        break;
+    }
+    case EventEntry::TYPE_KEY: {
+        const KeyEntry* keyEntry = static_cast<const KeyEntry*>(eventEntry);
+        if (keyEntry->flags & AKEY_EVENT_FLAG_CANCELED) {
+            return;
+        }
+        eventType = USER_ACTIVITY_EVENT_BUTTON;
+        break;
+    }
+    }
+
+    CommandEntry* commandEntry = postCommandLocked(
+            & InputDispatcher::doPokeUserActivityLockedInterruptible);
+    commandEntry->eventTime = eventEntry->eventTime;
+    commandEntry->userActivityEventType = eventType;
+}
+
+void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime,
+        const sp<Connection>& connection, EventEntry* eventEntry, const InputTarget* inputTarget) {
+#if DEBUG_DISPATCH_CYCLE
+    ALOGD("channel '%s' ~ prepareDispatchCycle - flags=0x%08x, "
+            "xOffset=%f, yOffset=%f, scaleFactor=%f, "
+            "pointerIds=0x%x",
+            connection->getInputChannelName(), inputTarget->flags,
+            inputTarget->xOffset, inputTarget->yOffset,
+            inputTarget->scaleFactor, inputTarget->pointerIds.value);
+#endif
+
+    // Skip this event if the connection status is not normal.
+    // We don't want to enqueue additional outbound events if the connection is broken.
+    if (connection->status != Connection::STATUS_NORMAL) {
+#if DEBUG_DISPATCH_CYCLE
+        ALOGD("channel '%s' ~ Dropping event because the channel status is %s",
+                connection->getInputChannelName(), connection->getStatusLabel());
+#endif
+        return;
+    }
+
+    // Split a motion event if needed.
+    if (inputTarget->flags & InputTarget::FLAG_SPLIT) {
+        ALOG_ASSERT(eventEntry->type == EventEntry::TYPE_MOTION);
+
+        MotionEntry* originalMotionEntry = static_cast<MotionEntry*>(eventEntry);
+        if (inputTarget->pointerIds.count() != originalMotionEntry->pointerCount) {
+            MotionEntry* splitMotionEntry = splitMotionEvent(
+                    originalMotionEntry, inputTarget->pointerIds);
+            if (!splitMotionEntry) {
+                return; // split event was dropped
+            }
+#if DEBUG_FOCUS
+            ALOGD("channel '%s' ~ Split motion event.",
+                    connection->getInputChannelName());
+            logOutboundMotionDetailsLocked("  ", splitMotionEntry);
+#endif
+            enqueueDispatchEntriesLocked(currentTime, connection,
+                    splitMotionEntry, inputTarget);
+            splitMotionEntry->release();
+            return;
+        }
+    }
+
+    // Not splitting.  Enqueue dispatch entries for the event as is.
+    enqueueDispatchEntriesLocked(currentTime, connection, eventEntry, inputTarget);
+}
+
+void InputDispatcher::enqueueDispatchEntriesLocked(nsecs_t currentTime,
+        const sp<Connection>& connection, EventEntry* eventEntry, const InputTarget* inputTarget) {
+    bool wasEmpty = connection->outboundQueue.isEmpty();
+
+    // Enqueue dispatch entries for the requested modes.
+    enqueueDispatchEntryLocked(connection, eventEntry, inputTarget,
+            InputTarget::FLAG_DISPATCH_AS_HOVER_EXIT);
+    enqueueDispatchEntryLocked(connection, eventEntry, inputTarget,
+            InputTarget::FLAG_DISPATCH_AS_OUTSIDE);
+    enqueueDispatchEntryLocked(connection, eventEntry, inputTarget,
+            InputTarget::FLAG_DISPATCH_AS_HOVER_ENTER);
+    enqueueDispatchEntryLocked(connection, eventEntry, inputTarget,
+            InputTarget::FLAG_DISPATCH_AS_IS);
+    enqueueDispatchEntryLocked(connection, eventEntry, inputTarget,
+            InputTarget::FLAG_DISPATCH_AS_SLIPPERY_EXIT);
+    enqueueDispatchEntryLocked(connection, eventEntry, inputTarget,
+            InputTarget::FLAG_DISPATCH_AS_SLIPPERY_ENTER);
+
+    // If the outbound queue was previously empty, start the dispatch cycle going.
+    if (wasEmpty && !connection->outboundQueue.isEmpty()) {
+        startDispatchCycleLocked(currentTime, connection);
+    }
+}
+
+void InputDispatcher::enqueueDispatchEntryLocked(
+        const sp<Connection>& connection, EventEntry* eventEntry, const InputTarget* inputTarget,
+        int32_t dispatchMode) {
+    int32_t inputTargetFlags = inputTarget->flags;
+    if (!(inputTargetFlags & dispatchMode)) {
+        return;
+    }
+    inputTargetFlags = (inputTargetFlags & ~InputTarget::FLAG_DISPATCH_MASK) | dispatchMode;
+
+    // This is a new event.
+    // Enqueue a new dispatch entry onto the outbound queue for this connection.
+    DispatchEntry* dispatchEntry = new DispatchEntry(eventEntry, // increments ref
+            inputTargetFlags, inputTarget->xOffset, inputTarget->yOffset,
+            inputTarget->scaleFactor);
+
+    // Apply target flags and update the connection's input state.
+    switch (eventEntry->type) {
+    case EventEntry::TYPE_KEY: {
+        KeyEntry* keyEntry = static_cast<KeyEntry*>(eventEntry);
+        dispatchEntry->resolvedAction = keyEntry->action;
+        dispatchEntry->resolvedFlags = keyEntry->flags;
+
+        if (!connection->inputState.trackKey(keyEntry,
+                dispatchEntry->resolvedAction, dispatchEntry->resolvedFlags)) {
+#if DEBUG_DISPATCH_CYCLE
+            ALOGD("channel '%s' ~ enqueueDispatchEntryLocked: skipping inconsistent key event",
+                    connection->getInputChannelName());
+#endif
+            delete dispatchEntry;
+            return; // skip the inconsistent event
+        }
+        break;
+    }
+
+    case EventEntry::TYPE_MOTION: {
+        MotionEntry* motionEntry = static_cast<MotionEntry*>(eventEntry);
+        if (dispatchMode & InputTarget::FLAG_DISPATCH_AS_OUTSIDE) {
+            dispatchEntry->resolvedAction = AMOTION_EVENT_ACTION_OUTSIDE;
+        } else if (dispatchMode & InputTarget::FLAG_DISPATCH_AS_HOVER_EXIT) {
+            dispatchEntry->resolvedAction = AMOTION_EVENT_ACTION_HOVER_EXIT;
+        } else if (dispatchMode & InputTarget::FLAG_DISPATCH_AS_HOVER_ENTER) {
+            dispatchEntry->resolvedAction = AMOTION_EVENT_ACTION_HOVER_ENTER;
+        } else if (dispatchMode & InputTarget::FLAG_DISPATCH_AS_SLIPPERY_EXIT) {
+            dispatchEntry->resolvedAction = AMOTION_EVENT_ACTION_CANCEL;
+        } else if (dispatchMode & InputTarget::FLAG_DISPATCH_AS_SLIPPERY_ENTER) {
+            dispatchEntry->resolvedAction = AMOTION_EVENT_ACTION_DOWN;
+        } else {
+            dispatchEntry->resolvedAction = motionEntry->action;
+        }
+        if (dispatchEntry->resolvedAction == AMOTION_EVENT_ACTION_HOVER_MOVE
+                && !connection->inputState.isHovering(
+                        motionEntry->deviceId, motionEntry->source, motionEntry->displayId)) {
+#if DEBUG_DISPATCH_CYCLE
+        ALOGD("channel '%s' ~ enqueueDispatchEntryLocked: filling in missing hover enter event",
+                connection->getInputChannelName());
+#endif
+            dispatchEntry->resolvedAction = AMOTION_EVENT_ACTION_HOVER_ENTER;
+        }
+
+        dispatchEntry->resolvedFlags = motionEntry->flags;
+        if (dispatchEntry->targetFlags & InputTarget::FLAG_WINDOW_IS_OBSCURED) {
+            dispatchEntry->resolvedFlags |= AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED;
+        }
+
+        if (!connection->inputState.trackMotion(motionEntry,
+                dispatchEntry->resolvedAction, dispatchEntry->resolvedFlags)) {
+#if DEBUG_DISPATCH_CYCLE
+            ALOGD("channel '%s' ~ enqueueDispatchEntryLocked: skipping inconsistent motion event",
+                    connection->getInputChannelName());
+#endif
+            delete dispatchEntry;
+            return; // skip the inconsistent event
+        }
+        break;
+    }
+    }
+
+    // Remember that we are waiting for this dispatch to complete.
+    if (dispatchEntry->hasForegroundTarget()) {
+        incrementPendingForegroundDispatchesLocked(eventEntry);
+    }
+
+    // Enqueue the dispatch entry.
+    connection->outboundQueue.enqueueAtTail(dispatchEntry);
+    traceOutboundQueueLengthLocked(connection);
+}
+
+void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
+        const sp<Connection>& connection) {
+#if DEBUG_DISPATCH_CYCLE
+    ALOGD("channel '%s' ~ startDispatchCycle",
+            connection->getInputChannelName());
+#endif
+
+    while (connection->status == Connection::STATUS_NORMAL
+            && !connection->outboundQueue.isEmpty()) {
+        DispatchEntry* dispatchEntry = connection->outboundQueue.head;
+        dispatchEntry->deliveryTime = currentTime;
+
+        // Publish the event.
+        status_t status;
+        EventEntry* eventEntry = dispatchEntry->eventEntry;
+        switch (eventEntry->type) {
+        case EventEntry::TYPE_KEY: {
+            KeyEntry* keyEntry = static_cast<KeyEntry*>(eventEntry);
+
+            // Publish the key event.
+            status = connection->inputPublisher.publishKeyEvent(dispatchEntry->seq,
+                    keyEntry->deviceId, keyEntry->source,
+                    dispatchEntry->resolvedAction, dispatchEntry->resolvedFlags,
+                    keyEntry->keyCode, keyEntry->scanCode,
+                    keyEntry->metaState, keyEntry->repeatCount, keyEntry->downTime,
+                    keyEntry->eventTime);
+            break;
+        }
+
+        case EventEntry::TYPE_MOTION: {
+            MotionEntry* motionEntry = static_cast<MotionEntry*>(eventEntry);
+
+            PointerCoords scaledCoords[MAX_POINTERS];
+            const PointerCoords* usingCoords = motionEntry->pointerCoords;
+
+            // Set the X and Y offset depending on the input source.
+            float xOffset, yOffset, scaleFactor;
+            if ((motionEntry->source & AINPUT_SOURCE_CLASS_POINTER)
+                    && !(dispatchEntry->targetFlags & InputTarget::FLAG_ZERO_COORDS)) {
+                scaleFactor = dispatchEntry->scaleFactor;
+                xOffset = dispatchEntry->xOffset * scaleFactor;
+                yOffset = dispatchEntry->yOffset * scaleFactor;
+                if (scaleFactor != 1.0f) {
+                    for (uint32_t i = 0; i < motionEntry->pointerCount; i++) {
+                        scaledCoords[i] = motionEntry->pointerCoords[i];
+                        scaledCoords[i].scale(scaleFactor);
+                    }
+                    usingCoords = scaledCoords;
+                }
+            } else {
+                xOffset = 0.0f;
+                yOffset = 0.0f;
+                scaleFactor = 1.0f;
+
+                // We don't want the dispatch target to know.
+                if (dispatchEntry->targetFlags & InputTarget::FLAG_ZERO_COORDS) {
+                    for (uint32_t i = 0; i < motionEntry->pointerCount; i++) {
+                        scaledCoords[i].clear();
+                    }
+                    usingCoords = scaledCoords;
+                }
+            }
+
+            // Publish the motion event.
+            status = connection->inputPublisher.publishMotionEvent(dispatchEntry->seq,
+                    motionEntry->deviceId, motionEntry->source,
+                    dispatchEntry->resolvedAction, motionEntry->actionButton,
+                    dispatchEntry->resolvedFlags, motionEntry->edgeFlags,
+                    motionEntry->metaState, motionEntry->buttonState,
+                    xOffset, yOffset, motionEntry->xPrecision, motionEntry->yPrecision,
+                    motionEntry->downTime, motionEntry->eventTime,
+                    motionEntry->pointerCount, motionEntry->pointerProperties,
+                    usingCoords);
+            break;
+        }
+
+        default:
+            ALOG_ASSERT(false);
+            return;
+        }
+
+        // Check the result.
+        if (status) {
+            if (status == WOULD_BLOCK) {
+                if (connection->waitQueue.isEmpty()) {
+                    ALOGE("channel '%s' ~ Could not publish event because the pipe is full. "
+                            "This is unexpected because the wait queue is empty, so the pipe "
+                            "should be empty and we shouldn't have any problems writing an "
+                            "event to it, status=%d", connection->getInputChannelName(), status);
+                    abortBrokenDispatchCycleLocked(currentTime, connection, true /*notify*/);
+                } else {
+                    // Pipe is full and we are waiting for the app to finish process some events
+                    // before sending more events to it.
+#if DEBUG_DISPATCH_CYCLE
+                    ALOGD("channel '%s' ~ Could not publish event because the pipe is full, "
+                            "waiting for the application to catch up",
+                            connection->getInputChannelName());
+#endif
+                    connection->inputPublisherBlocked = true;
+                }
+            } else {
+                ALOGE("channel '%s' ~ Could not publish event due to an unexpected error, "
+                        "status=%d", connection->getInputChannelName(), status);
+                abortBrokenDispatchCycleLocked(currentTime, connection, true /*notify*/);
+            }
+            return;
+        }
+
+        // Re-enqueue the event on the wait queue.
+        connection->outboundQueue.dequeue(dispatchEntry);
+        traceOutboundQueueLengthLocked(connection);
+        connection->waitQueue.enqueueAtTail(dispatchEntry);
+        traceWaitQueueLengthLocked(connection);
+    }
+}
+
+void InputDispatcher::finishDispatchCycleLocked(nsecs_t currentTime,
+        const sp<Connection>& connection, uint32_t seq, bool handled) {
+#if DEBUG_DISPATCH_CYCLE
+    ALOGD("channel '%s' ~ finishDispatchCycle - seq=%u, handled=%s",
+            connection->getInputChannelName(), seq, toString(handled));
+#endif
+
+    connection->inputPublisherBlocked = false;
+
+    if (connection->status == Connection::STATUS_BROKEN
+            || connection->status == Connection::STATUS_ZOMBIE) {
+        return;
+    }
+
+    // Notify other system components and prepare to start the next dispatch cycle.
+    onDispatchCycleFinishedLocked(currentTime, connection, seq, handled);
+}
+
+void InputDispatcher::abortBrokenDispatchCycleLocked(nsecs_t currentTime,
+        const sp<Connection>& connection, bool notify) {
+#if DEBUG_DISPATCH_CYCLE
+    ALOGD("channel '%s' ~ abortBrokenDispatchCycle - notify=%s",
+            connection->getInputChannelName(), toString(notify));
+#endif
+
+    // Clear the dispatch queues.
+    drainDispatchQueueLocked(&connection->outboundQueue);
+    traceOutboundQueueLengthLocked(connection);
+    drainDispatchQueueLocked(&connection->waitQueue);
+    traceWaitQueueLengthLocked(connection);
+
+    // The connection appears to be unrecoverably broken.
+    // Ignore already broken or zombie connections.
+    if (connection->status == Connection::STATUS_NORMAL) {
+        connection->status = Connection::STATUS_BROKEN;
+
+        if (notify) {
+            // Notify other system components.
+            onDispatchCycleBrokenLocked(currentTime, connection);
+        }
+    }
+}
+
+void InputDispatcher::drainDispatchQueueLocked(Queue<DispatchEntry>* queue) {
+    while (!queue->isEmpty()) {
+        DispatchEntry* dispatchEntry = queue->dequeueAtHead();
+        releaseDispatchEntryLocked(dispatchEntry);
+    }
+}
+
+void InputDispatcher::releaseDispatchEntryLocked(DispatchEntry* dispatchEntry) {
+    if (dispatchEntry->hasForegroundTarget()) {
+        decrementPendingForegroundDispatchesLocked(dispatchEntry->eventEntry);
+    }
+    delete dispatchEntry;
+}
+
+int InputDispatcher::handleReceiveCallback(int fd, int events, void* data) {
+    InputDispatcher* d = static_cast<InputDispatcher*>(data);
+
+    { // acquire lock
+        AutoMutex _l(d->mLock);
+
+        ssize_t connectionIndex = d->mConnectionsByFd.indexOfKey(fd);
+        if (connectionIndex < 0) {
+            ALOGE("Received spurious receive callback for unknown input channel.  "
+                    "fd=%d, events=0x%x", fd, events);
+            return 0; // remove the callback
+        }
+
+        bool notify;
+        sp<Connection> connection = d->mConnectionsByFd.valueAt(connectionIndex);
+        if (!(events & (ALOOPER_EVENT_ERROR | ALOOPER_EVENT_HANGUP))) {
+            if (!(events & ALOOPER_EVENT_INPUT)) {
+                ALOGW("channel '%s' ~ Received spurious callback for unhandled poll event.  "
+                        "events=0x%x", connection->getInputChannelName(), events);
+                return 1;
+            }
+
+            nsecs_t currentTime = now();
+            bool gotOne = false;
+            status_t status;
+            for (;;) {
+                uint32_t seq;
+                bool handled;
+                status = connection->inputPublisher.receiveFinishedSignal(&seq, &handled);
+                if (status) {
+                    break;
+                }
+                d->finishDispatchCycleLocked(currentTime, connection, seq, handled);
+                gotOne = true;
+            }
+            if (gotOne) {
+                d->runCommandsLockedInterruptible();
+                if (status == WOULD_BLOCK) {
+                    return 1;
+                }
+            }
+
+            notify = status != DEAD_OBJECT || !connection->monitor;
+            if (notify) {
+                ALOGE("channel '%s' ~ Failed to receive finished signal.  status=%d",
+                        connection->getInputChannelName(), status);
+            }
+        } else {
+            // Monitor channels are never explicitly unregistered.
+            // We do it automatically when the remote endpoint is closed so don't warn
+            // about them.
+            notify = !connection->monitor;
+            if (notify) {
+                ALOGW("channel '%s' ~ Consumer closed input channel or an error occurred.  "
+                        "events=0x%x", connection->getInputChannelName(), events);
+            }
+        }
+
+        // Unregister the channel.
+        d->unregisterInputChannelLocked(connection->inputChannel, notify);
+        return 0; // remove the callback
+    } // release lock
+}
+
+void InputDispatcher::synthesizeCancelationEventsForAllConnectionsLocked(
+        const CancelationOptions& options) {
+    for (size_t i = 0; i < mConnectionsByFd.size(); i++) {
+        synthesizeCancelationEventsForConnectionLocked(
+                mConnectionsByFd.valueAt(i), options);
+    }
+}
+
+void InputDispatcher::synthesizeCancelationEventsForMonitorsLocked(
+        const CancelationOptions& options) {
+    for (size_t i = 0; i < mMonitoringChannels.size(); i++) {
+        synthesizeCancelationEventsForInputChannelLocked(mMonitoringChannels[i], options);
+    }
+}
+
+void InputDispatcher::synthesizeCancelationEventsForInputChannelLocked(
+        const sp<InputChannel>& channel, const CancelationOptions& options) {
+    ssize_t index = getConnectionIndexLocked(channel);
+    if (index >= 0) {
+        synthesizeCancelationEventsForConnectionLocked(
+                mConnectionsByFd.valueAt(index), options);
+    }
+}
+
+void InputDispatcher::synthesizeCancelationEventsForConnectionLocked(
+        const sp<Connection>& connection, const CancelationOptions& options) {
+    if (connection->status == Connection::STATUS_BROKEN) {
+        return;
+    }
+
+    nsecs_t currentTime = now();
+
+    Vector<EventEntry*> cancelationEvents;
+    connection->inputState.synthesizeCancelationEvents(currentTime,
+            cancelationEvents, options);
+
+    if (!cancelationEvents.isEmpty()) {
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+        ALOGD("channel '%s' ~ Synthesized %d cancelation events to bring channel back in sync "
+                "with reality: %s, mode=%d.",
+                connection->getInputChannelName(), cancelationEvents.size(),
+                options.reason, options.mode);
+#endif
+        for (size_t i = 0; i < cancelationEvents.size(); i++) {
+            EventEntry* cancelationEventEntry = cancelationEvents.itemAt(i);
+            switch (cancelationEventEntry->type) {
+            case EventEntry::TYPE_KEY:
+                logOutboundKeyDetailsLocked("cancel - ",
+                        static_cast<KeyEntry*>(cancelationEventEntry));
+                break;
+            case EventEntry::TYPE_MOTION:
+                logOutboundMotionDetailsLocked("cancel - ",
+                        static_cast<MotionEntry*>(cancelationEventEntry));
+                break;
+            }
+
+            InputTarget target;
+            sp<InputWindowHandle> windowHandle = getWindowHandleLocked(connection->inputChannel);
+            if (windowHandle != NULL) {
+                const InputWindowInfo* windowInfo = windowHandle->getInfo();
+                target.xOffset = -windowInfo->frameLeft;
+                target.yOffset = -windowInfo->frameTop;
+                target.scaleFactor = windowInfo->scaleFactor;
+            } else {
+                target.xOffset = 0;
+                target.yOffset = 0;
+                target.scaleFactor = 1.0f;
+            }
+            target.inputChannel = connection->inputChannel;
+            target.flags = InputTarget::FLAG_DISPATCH_AS_IS;
+
+            enqueueDispatchEntryLocked(connection, cancelationEventEntry, // increments ref
+                    &target, InputTarget::FLAG_DISPATCH_AS_IS);
+
+            cancelationEventEntry->release();
+        }
+
+        startDispatchCycleLocked(currentTime, connection);
+    }
+}
+
+InputDispatcher::MotionEntry*
+InputDispatcher::splitMotionEvent(const MotionEntry* originalMotionEntry, BitSet32 pointerIds) {
+    ALOG_ASSERT(pointerIds.value != 0);
+
+    uint32_t splitPointerIndexMap[MAX_POINTERS];
+    PointerProperties splitPointerProperties[MAX_POINTERS];
+    PointerCoords splitPointerCoords[MAX_POINTERS];
+
+    uint32_t originalPointerCount = originalMotionEntry->pointerCount;
+    uint32_t splitPointerCount = 0;
+
+    for (uint32_t originalPointerIndex = 0; originalPointerIndex < originalPointerCount;
+            originalPointerIndex++) {
+        const PointerProperties& pointerProperties =
+                originalMotionEntry->pointerProperties[originalPointerIndex];
+        uint32_t pointerId = uint32_t(pointerProperties.id);
+        if (pointerIds.hasBit(pointerId)) {
+            splitPointerIndexMap[splitPointerCount] = originalPointerIndex;
+            splitPointerProperties[splitPointerCount].copyFrom(pointerProperties);
+            splitPointerCoords[splitPointerCount].copyFrom(
+                    originalMotionEntry->pointerCoords[originalPointerIndex]);
+            splitPointerCount += 1;
+        }
+    }
+
+    if (splitPointerCount != pointerIds.count()) {
+        // This is bad.  We are missing some of the pointers that we expected to deliver.
+        // Most likely this indicates that we received an ACTION_MOVE events that has
+        // different pointer ids than we expected based on the previous ACTION_DOWN
+        // or ACTION_POINTER_DOWN events that caused us to decide to split the pointers
+        // in this way.
+        ALOGW("Dropping split motion event because the pointer count is %d but "
+                "we expected there to be %d pointers.  This probably means we received "
+                "a broken sequence of pointer ids from the input device.",
+                splitPointerCount, pointerIds.count());
+        return NULL;
+    }
+
+    int32_t action = originalMotionEntry->action;
+    int32_t maskedAction = action & AMOTION_EVENT_ACTION_MASK;
+    if (maskedAction == AMOTION_EVENT_ACTION_POINTER_DOWN
+            || maskedAction == AMOTION_EVENT_ACTION_POINTER_UP) {
+        int32_t originalPointerIndex = getMotionEventActionPointerIndex(action);
+        const PointerProperties& pointerProperties =
+                originalMotionEntry->pointerProperties[originalPointerIndex];
+        uint32_t pointerId = uint32_t(pointerProperties.id);
+        if (pointerIds.hasBit(pointerId)) {
+            if (pointerIds.count() == 1) {
+                // The first/last pointer went down/up.
+                action = maskedAction == AMOTION_EVENT_ACTION_POINTER_DOWN
+                        ? AMOTION_EVENT_ACTION_DOWN : AMOTION_EVENT_ACTION_UP;
+            } else {
+                // A secondary pointer went down/up.
+                uint32_t splitPointerIndex = 0;
+                while (pointerId != uint32_t(splitPointerProperties[splitPointerIndex].id)) {
+                    splitPointerIndex += 1;
+                }
+                action = maskedAction | (splitPointerIndex
+                        << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT);
+            }
+        } else {
+            // An unrelated pointer changed.
+            action = AMOTION_EVENT_ACTION_MOVE;
+        }
+    }
+
+    MotionEntry* splitMotionEntry = new MotionEntry(
+            originalMotionEntry->eventTime,
+            originalMotionEntry->deviceId,
+            originalMotionEntry->source,
+            originalMotionEntry->policyFlags,
+            action,
+            originalMotionEntry->actionButton,
+            originalMotionEntry->flags,
+            originalMotionEntry->metaState,
+            originalMotionEntry->buttonState,
+            originalMotionEntry->edgeFlags,
+            originalMotionEntry->xPrecision,
+            originalMotionEntry->yPrecision,
+            originalMotionEntry->downTime,
+            originalMotionEntry->displayId,
+            splitPointerCount, splitPointerProperties, splitPointerCoords, 0, 0);
+
+    if (originalMotionEntry->injectionState) {
+        splitMotionEntry->injectionState = originalMotionEntry->injectionState;
+        splitMotionEntry->injectionState->refCount += 1;
+    }
+
+    return splitMotionEntry;
+}
+
+void InputDispatcher::notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) {
+#if DEBUG_INBOUND_EVENT_DETAILS
+    ALOGD("notifyConfigurationChanged - eventTime=%lld", args->eventTime);
+#endif
+
+    bool needWake;
+    { // acquire lock
+        AutoMutex _l(mLock);
+
+        ConfigurationChangedEntry* newEntry = new ConfigurationChangedEntry(args->eventTime);
+        needWake = enqueueInboundEventLocked(newEntry);
+    } // release lock
+
+    if (needWake) {
+        mLooper->wake();
+    }
+}
+
+void InputDispatcher::notifyKey(const NotifyKeyArgs* args) {
+#if DEBUG_INBOUND_EVENT_DETAILS
+    ALOGD("notifyKey - eventTime=%lld, deviceId=%d, source=0x%x, policyFlags=0x%x, action=0x%x, "
+            "flags=0x%x, keyCode=0x%x, scanCode=0x%x, metaState=0x%x, downTime=%lld",
+            args->eventTime, args->deviceId, args->source, args->policyFlags,
+            args->action, args->flags, args->keyCode, args->scanCode,
+            args->metaState, args->downTime);
+#endif
+    if (!validateKeyEvent(args->action)) {
+        return;
+    }
+
+    uint32_t policyFlags = args->policyFlags;
+    int32_t flags = args->flags;
+    int32_t metaState = args->metaState;
+    if ((policyFlags & POLICY_FLAG_VIRTUAL) || (flags & AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY)) {
+        policyFlags |= POLICY_FLAG_VIRTUAL;
+        flags |= AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY;
+    }
+    if (policyFlags & POLICY_FLAG_FUNCTION) {
+        metaState |= AMETA_FUNCTION_ON;
+    }
+
+    policyFlags |= POLICY_FLAG_TRUSTED;
+
+    int32_t keyCode = args->keyCode;
+    if (metaState & AMETA_META_ON && args->action == AKEY_EVENT_ACTION_DOWN) {
+        int32_t newKeyCode = AKEYCODE_UNKNOWN;
+        if (keyCode == AKEYCODE_DEL) {
+            newKeyCode = AKEYCODE_BACK;
+        } else if (keyCode == AKEYCODE_ENTER) {
+            newKeyCode = AKEYCODE_HOME;
+        }
+        if (newKeyCode != AKEYCODE_UNKNOWN) {
+            AutoMutex _l(mLock);
+            struct KeyReplacement replacement = {keyCode, args->deviceId};
+            mReplacedKeys.add(replacement, newKeyCode);
+            keyCode = newKeyCode;
+            metaState &= ~AMETA_META_ON;
+        }
+    } else if (args->action == AKEY_EVENT_ACTION_UP) {
+        // In order to maintain a consistent stream of up and down events, check to see if the key
+        // going up is one we've replaced in a down event and haven't yet replaced in an up event,
+        // even if the modifier was released between the down and the up events.
+        AutoMutex _l(mLock);
+        struct KeyReplacement replacement = {keyCode, args->deviceId};
+        ssize_t index = mReplacedKeys.indexOfKey(replacement);
+        if (index >= 0) {
+            keyCode = mReplacedKeys.valueAt(index);
+            mReplacedKeys.removeItemsAt(index);
+            metaState &= ~AMETA_META_ON;
+        }
+    }
+
+    KeyEvent event;
+    event.initialize(args->deviceId, args->source, args->action,
+            flags, keyCode, args->scanCode, metaState, 0,
+            args->downTime, args->eventTime);
+
+    mPolicy->interceptKeyBeforeQueueing(&event, /*byref*/ policyFlags);
+
+    bool needWake;
+    { // acquire lock
+        mLock.lock();
+
+        if (shouldSendKeyToInputFilterLocked(args)) {
+            mLock.unlock();
+
+            policyFlags |= POLICY_FLAG_FILTERED;
+            if (!mPolicy->filterInputEvent(&event, policyFlags)) {
+                return; // event was consumed by the filter
+            }
+
+            mLock.lock();
+        }
+
+        int32_t repeatCount = 0;
+        KeyEntry* newEntry = new KeyEntry(args->eventTime,
+                args->deviceId, args->source, policyFlags,
+                args->action, flags, keyCode, args->scanCode,
+                metaState, repeatCount, args->downTime);
+
+        needWake = enqueueInboundEventLocked(newEntry);
+        mLock.unlock();
+    } // release lock
+
+    if (needWake) {
+        mLooper->wake();
+    }
+}
+
+bool InputDispatcher::shouldSendKeyToInputFilterLocked(const NotifyKeyArgs* args) {
+    return mInputFilterEnabled;
+}
+
+void InputDispatcher::notifyMotion(const NotifyMotionArgs* args) {
+#if DEBUG_INBOUND_EVENT_DETAILS
+    ALOGD("notifyMotion - eventTime=%lld, deviceId=%d, source=0x%x, policyFlags=0x%x, "
+            "action=0x%x, actionButton=0x%x, flags=0x%x, metaState=0x%x, buttonState=0x%x,"
+            "edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, downTime=%lld",
+            args->eventTime, args->deviceId, args->source, args->policyFlags,
+            args->action, args->actionButton, args->flags, args->metaState, args->buttonState,
+            args->edgeFlags, args->xPrecision, args->yPrecision, args->downTime);
+    for (uint32_t i = 0; i < args->pointerCount; i++) {
+        ALOGD("  Pointer %d: id=%d, toolType=%d, "
+                "x=%f, y=%f, pressure=%f, size=%f, "
+                "touchMajor=%f, touchMinor=%f, toolMajor=%f, toolMinor=%f, "
+                "orientation=%f",
+                i, args->pointerProperties[i].id,
+                args->pointerProperties[i].toolType,
+                args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_X),
+                args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_Y),
+                args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE),
+                args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_SIZE),
+                args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR),
+                args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR),
+                args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR),
+                args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR),
+                args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION));
+    }
+#endif
+    if (!validateMotionEvent(args->action, args->actionButton,
+                args->pointerCount, args->pointerProperties)) {
+        return;
+    }
+
+    uint32_t policyFlags = args->policyFlags;
+    policyFlags |= POLICY_FLAG_TRUSTED;
+    mPolicy->interceptMotionBeforeQueueing(args->eventTime, /*byref*/ policyFlags);
+
+    bool needWake;
+    { // acquire lock
+        mLock.lock();
+
+        if (shouldSendMotionToInputFilterLocked(args)) {
+            mLock.unlock();
+
+            MotionEvent event;
+            event.initialize(args->deviceId, args->source, args->action, args->actionButton,
+                    args->flags, args->edgeFlags, args->metaState, args->buttonState,
+                    0, 0, args->xPrecision, args->yPrecision,
+                    args->downTime, args->eventTime,
+                    args->pointerCount, args->pointerProperties, args->pointerCoords);
+
+            policyFlags |= POLICY_FLAG_FILTERED;
+            if (!mPolicy->filterInputEvent(&event, policyFlags)) {
+                return; // event was consumed by the filter
+            }
+
+            mLock.lock();
+        }
+
+        // Just enqueue a new motion event.
+        MotionEntry* newEntry = new MotionEntry(args->eventTime,
+                args->deviceId, args->source, policyFlags,
+                args->action, args->actionButton, args->flags,
+                args->metaState, args->buttonState,
+                args->edgeFlags, args->xPrecision, args->yPrecision, args->downTime,
+                args->displayId,
+                args->pointerCount, args->pointerProperties, args->pointerCoords, 0, 0);
+
+        needWake = enqueueInboundEventLocked(newEntry);
+        mLock.unlock();
+    } // release lock
+
+    if (needWake) {
+        mLooper->wake();
+    }
+}
+
+bool InputDispatcher::shouldSendMotionToInputFilterLocked(const NotifyMotionArgs* args) {
+    // TODO: support sending secondary display events to input filter
+    return mInputFilterEnabled && isMainDisplay(args->displayId);
+}
+
+void InputDispatcher::notifySwitch(const NotifySwitchArgs* args) {
+#if DEBUG_INBOUND_EVENT_DETAILS
+    ALOGD("notifySwitch - eventTime=%lld, policyFlags=0x%x, switchValues=0x%08x, switchMask=0x%08x",
+            args->eventTime, args->policyFlags,
+            args->switchValues, args->switchMask);
+#endif
+
+    uint32_t policyFlags = args->policyFlags;
+    policyFlags |= POLICY_FLAG_TRUSTED;
+    mPolicy->notifySwitch(args->eventTime,
+            args->switchValues, args->switchMask, policyFlags);
+}
+
+void InputDispatcher::notifyDeviceReset(const NotifyDeviceResetArgs* args) {
+#if DEBUG_INBOUND_EVENT_DETAILS
+    ALOGD("notifyDeviceReset - eventTime=%lld, deviceId=%d",
+            args->eventTime, args->deviceId);
+#endif
+
+    bool needWake;
+    { // acquire lock
+        AutoMutex _l(mLock);
+
+        DeviceResetEntry* newEntry = new DeviceResetEntry(args->eventTime, args->deviceId);
+        needWake = enqueueInboundEventLocked(newEntry);
+    } // release lock
+
+    if (needWake) {
+        mLooper->wake();
+    }
+}
+
+int32_t InputDispatcher::injectInputEvent(const InputEvent* event, int32_t displayId,
+        int32_t injectorPid, int32_t injectorUid, int32_t syncMode, int32_t timeoutMillis,
+        uint32_t policyFlags) {
+#if DEBUG_INBOUND_EVENT_DETAILS
+    ALOGD("injectInputEvent - eventType=%d, injectorPid=%d, injectorUid=%d, "
+            "syncMode=%d, timeoutMillis=%d, policyFlags=0x%08x",
+            event->getType(), injectorPid, injectorUid, syncMode, timeoutMillis, policyFlags);
+#endif
+
+    nsecs_t endTime = now() + milliseconds_to_nanoseconds(timeoutMillis);
+
+    policyFlags |= POLICY_FLAG_INJECTED;
+    if (hasInjectionPermission(injectorPid, injectorUid)) {
+        policyFlags |= POLICY_FLAG_TRUSTED;
+    }
+
+    EventEntry* firstInjectedEntry;
+    EventEntry* lastInjectedEntry;
+    switch (event->getType()) {
+    case AINPUT_EVENT_TYPE_KEY: {
+        const KeyEvent* keyEvent = static_cast<const KeyEvent*>(event);
+        int32_t action = keyEvent->getAction();
+        if (! validateKeyEvent(action)) {
+            return INPUT_EVENT_INJECTION_FAILED;
+        }
+
+        int32_t flags = keyEvent->getFlags();
+        if (flags & AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY) {
+            policyFlags |= POLICY_FLAG_VIRTUAL;
+        }
+
+        if (!(policyFlags & POLICY_FLAG_FILTERED)) {
+            mPolicy->interceptKeyBeforeQueueing(keyEvent, /*byref*/ policyFlags);
+        }
+
+        mLock.lock();
+        firstInjectedEntry = new KeyEntry(keyEvent->getEventTime(),
+                keyEvent->getDeviceId(), keyEvent->getSource(),
+                policyFlags, action, flags,
+                keyEvent->getKeyCode(), keyEvent->getScanCode(), keyEvent->getMetaState(),
+                keyEvent->getRepeatCount(), keyEvent->getDownTime());
+        lastInjectedEntry = firstInjectedEntry;
+        break;
+    }
+
+    case AINPUT_EVENT_TYPE_MOTION: {
+        const MotionEvent* motionEvent = static_cast<const MotionEvent*>(event);
+        int32_t action = motionEvent->getAction();
+        size_t pointerCount = motionEvent->getPointerCount();
+        const PointerProperties* pointerProperties = motionEvent->getPointerProperties();
+        int32_t actionButton = motionEvent->getActionButton();
+        if (! validateMotionEvent(action, actionButton, pointerCount, pointerProperties)) {
+            return INPUT_EVENT_INJECTION_FAILED;
+        }
+
+        if (!(policyFlags & POLICY_FLAG_FILTERED)) {
+            nsecs_t eventTime = motionEvent->getEventTime();
+            mPolicy->interceptMotionBeforeQueueing(eventTime, /*byref*/ policyFlags);
+        }
+
+        mLock.lock();
+        const nsecs_t* sampleEventTimes = motionEvent->getSampleEventTimes();
+        const PointerCoords* samplePointerCoords = motionEvent->getSamplePointerCoords();
+        firstInjectedEntry = new MotionEntry(*sampleEventTimes,
+                motionEvent->getDeviceId(), motionEvent->getSource(), policyFlags,
+                action, actionButton, motionEvent->getFlags(),
+                motionEvent->getMetaState(), motionEvent->getButtonState(),
+                motionEvent->getEdgeFlags(),
+                motionEvent->getXPrecision(), motionEvent->getYPrecision(),
+                motionEvent->getDownTime(), displayId,
+                uint32_t(pointerCount), pointerProperties, samplePointerCoords,
+                motionEvent->getXOffset(), motionEvent->getYOffset());
+        lastInjectedEntry = firstInjectedEntry;
+        for (size_t i = motionEvent->getHistorySize(); i > 0; i--) {
+            sampleEventTimes += 1;
+            samplePointerCoords += pointerCount;
+            MotionEntry* nextInjectedEntry = new MotionEntry(*sampleEventTimes,
+                    motionEvent->getDeviceId(), motionEvent->getSource(), policyFlags,
+                    action, actionButton, motionEvent->getFlags(),
+                    motionEvent->getMetaState(), motionEvent->getButtonState(),
+                    motionEvent->getEdgeFlags(),
+                    motionEvent->getXPrecision(), motionEvent->getYPrecision(),
+                    motionEvent->getDownTime(), displayId,
+                    uint32_t(pointerCount), pointerProperties, samplePointerCoords,
+                    motionEvent->getXOffset(), motionEvent->getYOffset());
+            lastInjectedEntry->next = nextInjectedEntry;
+            lastInjectedEntry = nextInjectedEntry;
+        }
+        break;
+    }
+
+    default:
+        ALOGW("Cannot inject event of type %d", event->getType());
+        return INPUT_EVENT_INJECTION_FAILED;
+    }
+
+    InjectionState* injectionState = new InjectionState(injectorPid, injectorUid);
+    if (syncMode == INPUT_EVENT_INJECTION_SYNC_NONE) {
+        injectionState->injectionIsAsync = true;
+    }
+
+    injectionState->refCount += 1;
+    lastInjectedEntry->injectionState = injectionState;
+
+    bool needWake = false;
+    for (EventEntry* entry = firstInjectedEntry; entry != NULL; ) {
+        EventEntry* nextEntry = entry->next;
+        needWake |= enqueueInboundEventLocked(entry);
+        entry = nextEntry;
+    }
+
+    mLock.unlock();
+
+    if (needWake) {
+        mLooper->wake();
+    }
+
+    int32_t injectionResult;
+    { // acquire lock
+        AutoMutex _l(mLock);
+
+        if (syncMode == INPUT_EVENT_INJECTION_SYNC_NONE) {
+            injectionResult = INPUT_EVENT_INJECTION_SUCCEEDED;
+        } else {
+            for (;;) {
+                injectionResult = injectionState->injectionResult;
+                if (injectionResult != INPUT_EVENT_INJECTION_PENDING) {
+                    break;
+                }
+
+                nsecs_t remainingTimeout = endTime - now();
+                if (remainingTimeout <= 0) {
+#if DEBUG_INJECTION
+                    ALOGD("injectInputEvent - Timed out waiting for injection result "
+                            "to become available.");
+#endif
+                    injectionResult = INPUT_EVENT_INJECTION_TIMED_OUT;
+                    break;
+                }
+
+                mInjectionResultAvailableCondition.waitRelative(mLock, remainingTimeout);
+            }
+
+            if (injectionResult == INPUT_EVENT_INJECTION_SUCCEEDED
+                    && syncMode == INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_FINISHED) {
+                while (injectionState->pendingForegroundDispatches != 0) {
+#if DEBUG_INJECTION
+                    ALOGD("injectInputEvent - Waiting for %d pending foreground dispatches.",
+                            injectionState->pendingForegroundDispatches);
+#endif
+                    nsecs_t remainingTimeout = endTime - now();
+                    if (remainingTimeout <= 0) {
+#if DEBUG_INJECTION
+                    ALOGD("injectInputEvent - Timed out waiting for pending foreground "
+                            "dispatches to finish.");
+#endif
+                        injectionResult = INPUT_EVENT_INJECTION_TIMED_OUT;
+                        break;
+                    }
+
+                    mInjectionSyncFinishedCondition.waitRelative(mLock, remainingTimeout);
+                }
+            }
+        }
+
+        injectionState->release();
+    } // release lock
+
+#if DEBUG_INJECTION
+    ALOGD("injectInputEvent - Finished with result %d.  "
+            "injectorPid=%d, injectorUid=%d",
+            injectionResult, injectorPid, injectorUid);
+#endif
+
+    return injectionResult;
+}
+
+bool InputDispatcher::hasInjectionPermission(int32_t injectorPid, int32_t injectorUid) {
+    return injectorUid == 0
+            || mPolicy->checkInjectEventsPermissionNonReentrant(injectorPid, injectorUid);
+}
+
+void InputDispatcher::setInjectionResultLocked(EventEntry* entry, int32_t injectionResult) {
+    InjectionState* injectionState = entry->injectionState;
+    if (injectionState) {
+#if DEBUG_INJECTION
+        ALOGD("Setting input event injection result to %d.  "
+                "injectorPid=%d, injectorUid=%d",
+                 injectionResult, injectionState->injectorPid, injectionState->injectorUid);
+#endif
+
+        if (injectionState->injectionIsAsync
+                && !(entry->policyFlags & POLICY_FLAG_FILTERED)) {
+            // Log the outcome since the injector did not wait for the injection result.
+            switch (injectionResult) {
+            case INPUT_EVENT_INJECTION_SUCCEEDED:
+                ALOGV("Asynchronous input event injection succeeded.");
+                break;
+            case INPUT_EVENT_INJECTION_FAILED:
+                ALOGW("Asynchronous input event injection failed.");
+                break;
+            case INPUT_EVENT_INJECTION_PERMISSION_DENIED:
+                ALOGW("Asynchronous input event injection permission denied.");
+                break;
+            case INPUT_EVENT_INJECTION_TIMED_OUT:
+                ALOGW("Asynchronous input event injection timed out.");
+                break;
+            }
+        }
+
+        injectionState->injectionResult = injectionResult;
+        mInjectionResultAvailableCondition.broadcast();
+    }
+}
+
+void InputDispatcher::incrementPendingForegroundDispatchesLocked(EventEntry* entry) {
+    InjectionState* injectionState = entry->injectionState;
+    if (injectionState) {
+        injectionState->pendingForegroundDispatches += 1;
+    }
+}
+
+void InputDispatcher::decrementPendingForegroundDispatchesLocked(EventEntry* entry) {
+    InjectionState* injectionState = entry->injectionState;
+    if (injectionState) {
+        injectionState->pendingForegroundDispatches -= 1;
+
+        if (injectionState->pendingForegroundDispatches == 0) {
+            mInjectionSyncFinishedCondition.broadcast();
+        }
+    }
+}
+
+sp<InputWindowHandle> InputDispatcher::getWindowHandleLocked(
+        const sp<InputChannel>& inputChannel) const {
+    size_t numWindows = mWindowHandles.size();
+    for (size_t i = 0; i < numWindows; i++) {
+        const sp<InputWindowHandle>& windowHandle = mWindowHandles.itemAt(i);
+        if (windowHandle->getInputChannel() == inputChannel) {
+            return windowHandle;
+        }
+    }
+    return NULL;
+}
+
+bool InputDispatcher::hasWindowHandleLocked(
+        const sp<InputWindowHandle>& windowHandle) const {
+    size_t numWindows = mWindowHandles.size();
+    for (size_t i = 0; i < numWindows; i++) {
+        if (mWindowHandles.itemAt(i) == windowHandle) {
+            return true;
+        }
+    }
+    return false;
+}
+
+void InputDispatcher::setInputWindows(const Vector<sp<InputWindowHandle> >& inputWindowHandles) {
+#if DEBUG_FOCUS
+    ALOGD("setInputWindows");
+#endif
+    { // acquire lock
+        AutoMutex _l(mLock);
+
+        Vector<sp<InputWindowHandle> > oldWindowHandles = mWindowHandles;
+        mWindowHandles = inputWindowHandles;
+
+        sp<InputWindowHandle> newFocusedWindowHandle;
+        bool foundHoveredWindow = false;
+        for (size_t i = 0; i < mWindowHandles.size(); i++) {
+            const sp<InputWindowHandle>& windowHandle = mWindowHandles.itemAt(i);
+            if (!windowHandle->updateInfo() || windowHandle->getInputChannel() == NULL) {
+                mWindowHandles.removeAt(i--);
+                continue;
+            }
+            if (windowHandle->getInfo()->hasFocus) {
+                newFocusedWindowHandle = windowHandle;
+            }
+            if (windowHandle == mLastHoverWindowHandle) {
+                foundHoveredWindow = true;
+            }
+        }
+
+        if (!foundHoveredWindow) {
+            mLastHoverWindowHandle = NULL;
+        }
+
+        if (mFocusedWindowHandle != newFocusedWindowHandle) {
+            if (mFocusedWindowHandle != NULL) {
+#if DEBUG_FOCUS
+                ALOGD("Focus left window: %s",
+                        mFocusedWindowHandle->getName().string());
+#endif
+                sp<InputChannel> focusedInputChannel = mFocusedWindowHandle->getInputChannel();
+                if (focusedInputChannel != NULL) {
+                    CancelationOptions options(CancelationOptions::CANCEL_NON_POINTER_EVENTS,
+                            "focus left window");
+                    synthesizeCancelationEventsForInputChannelLocked(
+                            focusedInputChannel, options);
+                }
+            }
+            if (newFocusedWindowHandle != NULL) {
+#if DEBUG_FOCUS
+                ALOGD("Focus entered window: %s",
+                        newFocusedWindowHandle->getName().string());
+#endif
+            }
+            mFocusedWindowHandle = newFocusedWindowHandle;
+        }
+
+        for (size_t d = 0; d < mTouchStatesByDisplay.size(); d++) {
+            TouchState& state = mTouchStatesByDisplay.editValueAt(d);
+            for (size_t i = 0; i < state.windows.size(); i++) {
+                TouchedWindow& touchedWindow = state.windows.editItemAt(i);
+                if (!hasWindowHandleLocked(touchedWindow.windowHandle)) {
+#if DEBUG_FOCUS
+                    ALOGD("Touched window was removed: %s",
+                            touchedWindow.windowHandle->getName().string());
+#endif
+                    sp<InputChannel> touchedInputChannel =
+                            touchedWindow.windowHandle->getInputChannel();
+                    if (touchedInputChannel != NULL) {
+                        CancelationOptions options(CancelationOptions::CANCEL_POINTER_EVENTS,
+                                "touched window was removed");
+                        synthesizeCancelationEventsForInputChannelLocked(
+                                touchedInputChannel, options);
+                    }
+                    state.windows.removeAt(i--);
+                }
+            }
+        }
+
+        // Release information for windows that are no longer present.
+        // This ensures that unused input channels are released promptly.
+        // Otherwise, they might stick around until the window handle is destroyed
+        // which might not happen until the next GC.
+        for (size_t i = 0; i < oldWindowHandles.size(); i++) {
+            const sp<InputWindowHandle>& oldWindowHandle = oldWindowHandles.itemAt(i);
+            if (!hasWindowHandleLocked(oldWindowHandle)) {
+#if DEBUG_FOCUS
+                ALOGD("Window went away: %s", oldWindowHandle->getName().string());
+#endif
+                oldWindowHandle->releaseInfo();
+            }
+        }
+    } // release lock
+
+    // Wake up poll loop since it may need to make new input dispatching choices.
+    mLooper->wake();
+}
+
+void InputDispatcher::setFocusedApplication(
+        const sp<InputApplicationHandle>& inputApplicationHandle) {
+#if DEBUG_FOCUS
+    ALOGD("setFocusedApplication");
+#endif
+    { // acquire lock
+        AutoMutex _l(mLock);
+
+        if (inputApplicationHandle != NULL && inputApplicationHandle->updateInfo()) {
+            if (mFocusedApplicationHandle != inputApplicationHandle) {
+                if (mFocusedApplicationHandle != NULL) {
+                    resetANRTimeoutsLocked();
+                    mFocusedApplicationHandle->releaseInfo();
+                }
+                mFocusedApplicationHandle = inputApplicationHandle;
+            }
+        } else if (mFocusedApplicationHandle != NULL) {
+            resetANRTimeoutsLocked();
+            mFocusedApplicationHandle->releaseInfo();
+            mFocusedApplicationHandle.clear();
+        }
+
+#if DEBUG_FOCUS
+        //logDispatchStateLocked();
+#endif
+    } // release lock
+
+    // Wake up poll loop since it may need to make new input dispatching choices.
+    mLooper->wake();
+}
+
+void InputDispatcher::setInputDispatchMode(bool enabled, bool frozen) {
+#if DEBUG_FOCUS
+    ALOGD("setInputDispatchMode: enabled=%d, frozen=%d", enabled, frozen);
+#endif
+
+    bool changed;
+    { // acquire lock
+        AutoMutex _l(mLock);
+
+        if (mDispatchEnabled != enabled || mDispatchFrozen != frozen) {
+            if (mDispatchFrozen && !frozen) {
+                resetANRTimeoutsLocked();
+            }
+
+            if (mDispatchEnabled && !enabled) {
+                resetAndDropEverythingLocked("dispatcher is being disabled");
+            }
+
+            mDispatchEnabled = enabled;
+            mDispatchFrozen = frozen;
+            changed = true;
+        } else {
+            changed = false;
+        }
+
+#if DEBUG_FOCUS
+        //logDispatchStateLocked();
+#endif
+    } // release lock
+
+    if (changed) {
+        // Wake up poll loop since it may need to make new input dispatching choices.
+        mLooper->wake();
+    }
+}
+
+void InputDispatcher::setInputFilterEnabled(bool enabled) {
+#if DEBUG_FOCUS
+    ALOGD("setInputFilterEnabled: enabled=%d", enabled);
+#endif
+
+    { // acquire lock
+        AutoMutex _l(mLock);
+
+        if (mInputFilterEnabled == enabled) {
+            return;
+        }
+
+        mInputFilterEnabled = enabled;
+        resetAndDropEverythingLocked("input filter is being enabled or disabled");
+    } // release lock
+
+    // Wake up poll loop since there might be work to do to drop everything.
+    mLooper->wake();
+}
+
+bool InputDispatcher::transferTouchFocus(const sp<InputChannel>& fromChannel,
+        const sp<InputChannel>& toChannel) {
+#if DEBUG_FOCUS
+    ALOGD("transferTouchFocus: fromChannel=%s, toChannel=%s",
+            fromChannel->getName().string(), toChannel->getName().string());
+#endif
+    { // acquire lock
+        AutoMutex _l(mLock);
+
+        sp<InputWindowHandle> fromWindowHandle = getWindowHandleLocked(fromChannel);
+        sp<InputWindowHandle> toWindowHandle = getWindowHandleLocked(toChannel);
+        if (fromWindowHandle == NULL || toWindowHandle == NULL) {
+#if DEBUG_FOCUS
+            ALOGD("Cannot transfer focus because from or to window not found.");
+#endif
+            return false;
+        }
+        if (fromWindowHandle == toWindowHandle) {
+#if DEBUG_FOCUS
+            ALOGD("Trivial transfer to same window.");
+#endif
+            return true;
+        }
+        if (fromWindowHandle->getInfo()->displayId != toWindowHandle->getInfo()->displayId) {
+#if DEBUG_FOCUS
+            ALOGD("Cannot transfer focus because windows are on different displays.");
+#endif
+            return false;
+        }
+
+        bool found = false;
+        for (size_t d = 0; d < mTouchStatesByDisplay.size(); d++) {
+            TouchState& state = mTouchStatesByDisplay.editValueAt(d);
+            for (size_t i = 0; i < state.windows.size(); i++) {
+                const TouchedWindow& touchedWindow = state.windows[i];
+                if (touchedWindow.windowHandle == fromWindowHandle) {
+                    int32_t oldTargetFlags = touchedWindow.targetFlags;
+                    BitSet32 pointerIds = touchedWindow.pointerIds;
+
+                    state.windows.removeAt(i);
+
+                    int32_t newTargetFlags = oldTargetFlags
+                            & (InputTarget::FLAG_FOREGROUND
+                                    | InputTarget::FLAG_SPLIT | InputTarget::FLAG_DISPATCH_AS_IS);
+                    state.addOrUpdateWindow(toWindowHandle, newTargetFlags, pointerIds);
+
+                    found = true;
+                    goto Found;
+                }
+            }
+        }
+Found:
+
+        if (! found) {
+#if DEBUG_FOCUS
+            ALOGD("Focus transfer failed because from window did not have focus.");
+#endif
+            return false;
+        }
+
+        ssize_t fromConnectionIndex = getConnectionIndexLocked(fromChannel);
+        ssize_t toConnectionIndex = getConnectionIndexLocked(toChannel);
+        if (fromConnectionIndex >= 0 && toConnectionIndex >= 0) {
+            sp<Connection> fromConnection = mConnectionsByFd.valueAt(fromConnectionIndex);
+            sp<Connection> toConnection = mConnectionsByFd.valueAt(toConnectionIndex);
+
+            fromConnection->inputState.copyPointerStateTo(toConnection->inputState);
+            CancelationOptions options(CancelationOptions::CANCEL_POINTER_EVENTS,
+                    "transferring touch focus from this window to another window");
+            synthesizeCancelationEventsForConnectionLocked(fromConnection, options);
+        }
+
+#if DEBUG_FOCUS
+        logDispatchStateLocked();
+#endif
+    } // release lock
+
+    // Wake up poll loop since it may need to make new input dispatching choices.
+    mLooper->wake();
+    return true;
+}
+
+void InputDispatcher::resetAndDropEverythingLocked(const char* reason) {
+#if DEBUG_FOCUS
+    ALOGD("Resetting and dropping all events (%s).", reason);
+#endif
+
+    CancelationOptions options(CancelationOptions::CANCEL_ALL_EVENTS, reason);
+    synthesizeCancelationEventsForAllConnectionsLocked(options);
+
+    resetKeyRepeatLocked();
+    releasePendingEventLocked();
+    drainInboundQueueLocked();
+    resetANRTimeoutsLocked();
+
+    mTouchStatesByDisplay.clear();
+    mLastHoverWindowHandle.clear();
+    mReplacedKeys.clear();
+}
+
+void InputDispatcher::logDispatchStateLocked() {
+    String8 dump;
+    dumpDispatchStateLocked(dump);
+
+    char* text = dump.lockBuffer(dump.size());
+    char* start = text;
+    while (*start != '\0') {
+        char* end = strchr(start, '\n');
+        if (*end == '\n') {
+            *(end++) = '\0';
+        }
+        ALOGD("%s", start);
+        start = end;
+    }
+}
+
+void InputDispatcher::dumpDispatchStateLocked(String8& dump) {
+    dump.appendFormat(INDENT "DispatchEnabled: %d\n", mDispatchEnabled);
+    dump.appendFormat(INDENT "DispatchFrozen: %d\n", mDispatchFrozen);
+
+    if (mFocusedApplicationHandle != NULL) {
+        dump.appendFormat(INDENT "FocusedApplication: name='%s', dispatchingTimeout=%0.3fms\n",
+                mFocusedApplicationHandle->getName().string(),
+                mFocusedApplicationHandle->getDispatchingTimeout(
+                        DEFAULT_INPUT_DISPATCHING_TIMEOUT) / 1000000.0);
+    } else {
+        dump.append(INDENT "FocusedApplication: <null>\n");
+    }
+    dump.appendFormat(INDENT "FocusedWindow: name='%s'\n",
+            mFocusedWindowHandle != NULL ? mFocusedWindowHandle->getName().string() : "<null>");
+
+    if (!mTouchStatesByDisplay.isEmpty()) {
+        dump.appendFormat(INDENT "TouchStatesByDisplay:\n");
+        for (size_t i = 0; i < mTouchStatesByDisplay.size(); i++) {
+            const TouchState& state = mTouchStatesByDisplay.valueAt(i);
+            dump.appendFormat(INDENT2 "%d: down=%s, split=%s, deviceId=%d, source=0x%08x\n",
+                    state.displayId, toString(state.down), toString(state.split),
+                    state.deviceId, state.source);
+            if (!state.windows.isEmpty()) {
+                dump.append(INDENT3 "Windows:\n");
+                for (size_t i = 0; i < state.windows.size(); i++) {
+                    const TouchedWindow& touchedWindow = state.windows[i];
+                    dump.appendFormat(INDENT4 "%zu: name='%s', pointerIds=0x%0x, targetFlags=0x%x\n",
+                            i, touchedWindow.windowHandle->getName().string(),
+                            touchedWindow.pointerIds.value,
+                            touchedWindow.targetFlags);
+                }
+            } else {
+                dump.append(INDENT3 "Windows: <none>\n");
+            }
+        }
+    } else {
+        dump.append(INDENT "TouchStates: <no displays touched>\n");
+    }
+
+    if (!mWindowHandles.isEmpty()) {
+        dump.append(INDENT "Windows:\n");
+        for (size_t i = 0; i < mWindowHandles.size(); i++) {
+            const sp<InputWindowHandle>& windowHandle = mWindowHandles.itemAt(i);
+            const InputWindowInfo* windowInfo = windowHandle->getInfo();
+
+            dump.appendFormat(INDENT2 "%zu: name='%s', displayId=%d, "
+                    "paused=%s, hasFocus=%s, hasWallpaper=%s, "
+                    "visible=%s, canReceiveKeys=%s, flags=0x%08x, type=0x%08x, layer=%d, "
+                    "frame=[%d,%d][%d,%d], scale=%f, "
+                    "touchableRegion=",
+                    i, windowInfo->name.string(), windowInfo->displayId,
+                    toString(windowInfo->paused),
+                    toString(windowInfo->hasFocus),
+                    toString(windowInfo->hasWallpaper),
+                    toString(windowInfo->visible),
+                    toString(windowInfo->canReceiveKeys),
+                    windowInfo->layoutParamsFlags, windowInfo->layoutParamsType,
+                    windowInfo->layer,
+                    windowInfo->frameLeft, windowInfo->frameTop,
+                    windowInfo->frameRight, windowInfo->frameBottom,
+                    windowInfo->scaleFactor);
+            dumpRegion(dump, windowInfo->touchableRegion);
+            dump.appendFormat(", inputFeatures=0x%08x", windowInfo->inputFeatures);
+            dump.appendFormat(", ownerPid=%d, ownerUid=%d, dispatchingTimeout=%0.3fms\n",
+                    windowInfo->ownerPid, windowInfo->ownerUid,
+                    windowInfo->dispatchingTimeout / 1000000.0);
+        }
+    } else {
+        dump.append(INDENT "Windows: <none>\n");
+    }
+
+    if (!mMonitoringChannels.isEmpty()) {
+        dump.append(INDENT "MonitoringChannels:\n");
+        for (size_t i = 0; i < mMonitoringChannels.size(); i++) {
+            const sp<InputChannel>& channel = mMonitoringChannels[i];
+            dump.appendFormat(INDENT2 "%zu: '%s'\n", i, channel->getName().string());
+        }
+    } else {
+        dump.append(INDENT "MonitoringChannels: <none>\n");
+    }
+
+    nsecs_t currentTime = now();
+
+    // Dump recently dispatched or dropped events from oldest to newest.
+    if (!mRecentQueue.isEmpty()) {
+        dump.appendFormat(INDENT "RecentQueue: length=%u\n", mRecentQueue.count());
+        for (EventEntry* entry = mRecentQueue.head; entry; entry = entry->next) {
+            dump.append(INDENT2);
+            entry->appendDescription(dump);
+            dump.appendFormat(", age=%0.1fms\n",
+                    (currentTime - entry->eventTime) * 0.000001f);
+        }
+    } else {
+        dump.append(INDENT "RecentQueue: <empty>\n");
+    }
+
+    // Dump event currently being dispatched.
+    if (mPendingEvent) {
+        dump.append(INDENT "PendingEvent:\n");
+        dump.append(INDENT2);
+        mPendingEvent->appendDescription(dump);
+        dump.appendFormat(", age=%0.1fms\n",
+                (currentTime - mPendingEvent->eventTime) * 0.000001f);
+    } else {
+        dump.append(INDENT "PendingEvent: <none>\n");
+    }
+
+    // Dump inbound events from oldest to newest.
+    if (!mInboundQueue.isEmpty()) {
+        dump.appendFormat(INDENT "InboundQueue: length=%u\n", mInboundQueue.count());
+        for (EventEntry* entry = mInboundQueue.head; entry; entry = entry->next) {
+            dump.append(INDENT2);
+            entry->appendDescription(dump);
+            dump.appendFormat(", age=%0.1fms\n",
+                    (currentTime - entry->eventTime) * 0.000001f);
+        }
+    } else {
+        dump.append(INDENT "InboundQueue: <empty>\n");
+    }
+
+    if (!mReplacedKeys.isEmpty()) {
+        dump.append(INDENT "ReplacedKeys:\n");
+        for (size_t i = 0; i < mReplacedKeys.size(); i++) {
+            const KeyReplacement& replacement = mReplacedKeys.keyAt(i);
+            int32_t newKeyCode = mReplacedKeys.valueAt(i);
+            dump.appendFormat(INDENT2 "%zu: originalKeyCode=%d, deviceId=%d, newKeyCode=%d\n",
+                    i, replacement.keyCode, replacement.deviceId, newKeyCode);
+        }
+    } else {
+        dump.append(INDENT "ReplacedKeys: <empty>\n");
+    }
+
+    if (!mConnectionsByFd.isEmpty()) {
+        dump.append(INDENT "Connections:\n");
+        for (size_t i = 0; i < mConnectionsByFd.size(); i++) {
+            const sp<Connection>& connection = mConnectionsByFd.valueAt(i);
+            dump.appendFormat(INDENT2 "%zu: channelName='%s', windowName='%s', "
+                    "status=%s, monitor=%s, inputPublisherBlocked=%s\n",
+                    i, connection->getInputChannelName(), connection->getWindowName(),
+                    connection->getStatusLabel(), toString(connection->monitor),
+                    toString(connection->inputPublisherBlocked));
+
+            if (!connection->outboundQueue.isEmpty()) {
+                dump.appendFormat(INDENT3 "OutboundQueue: length=%u\n",
+                        connection->outboundQueue.count());
+                for (DispatchEntry* entry = connection->outboundQueue.head; entry;
+                        entry = entry->next) {
+                    dump.append(INDENT4);
+                    entry->eventEntry->appendDescription(dump);
+                    dump.appendFormat(", targetFlags=0x%08x, resolvedAction=%d, age=%0.1fms\n",
+                            entry->targetFlags, entry->resolvedAction,
+                            (currentTime - entry->eventEntry->eventTime) * 0.000001f);
+                }
+            } else {
+                dump.append(INDENT3 "OutboundQueue: <empty>\n");
+            }
+
+            if (!connection->waitQueue.isEmpty()) {
+                dump.appendFormat(INDENT3 "WaitQueue: length=%u\n",
+                        connection->waitQueue.count());
+                for (DispatchEntry* entry = connection->waitQueue.head; entry;
+                        entry = entry->next) {
+                    dump.append(INDENT4);
+                    entry->eventEntry->appendDescription(dump);
+                    dump.appendFormat(", targetFlags=0x%08x, resolvedAction=%d, "
+                            "age=%0.1fms, wait=%0.1fms\n",
+                            entry->targetFlags, entry->resolvedAction,
+                            (currentTime - entry->eventEntry->eventTime) * 0.000001f,
+                            (currentTime - entry->deliveryTime) * 0.000001f);
+                }
+            } else {
+                dump.append(INDENT3 "WaitQueue: <empty>\n");
+            }
+        }
+    } else {
+        dump.append(INDENT "Connections: <none>\n");
+    }
+
+    if (isAppSwitchPendingLocked()) {
+        dump.appendFormat(INDENT "AppSwitch: pending, due in %0.1fms\n",
+                (mAppSwitchDueTime - now()) / 1000000.0);
+    } else {
+        dump.append(INDENT "AppSwitch: not pending\n");
+    }
+
+    dump.append(INDENT "Configuration:\n");
+    dump.appendFormat(INDENT2 "KeyRepeatDelay: %0.1fms\n",
+            mConfig.keyRepeatDelay * 0.000001f);
+    dump.appendFormat(INDENT2 "KeyRepeatTimeout: %0.1fms\n",
+            mConfig.keyRepeatTimeout * 0.000001f);
+}
+
+status_t InputDispatcher::registerInputChannel(const sp<InputChannel>& inputChannel,
+        const sp<InputWindowHandle>& inputWindowHandle, bool monitor) {
+#if DEBUG_REGISTRATION
+    ALOGD("channel '%s' ~ registerInputChannel - monitor=%s", inputChannel->getName().string(),
+            toString(monitor));
+#endif
+
+    { // acquire lock
+        AutoMutex _l(mLock);
+
+        if (getConnectionIndexLocked(inputChannel) >= 0) {
+            ALOGW("Attempted to register already registered input channel '%s'",
+                    inputChannel->getName().string());
+            return BAD_VALUE;
+        }
+
+        sp<Connection> connection = new Connection(inputChannel, inputWindowHandle, monitor);
+
+        int fd = inputChannel->getFd();
+        mConnectionsByFd.add(fd, connection);
+
+        if (monitor) {
+            mMonitoringChannels.push(inputChannel);
+        }
+
+        mLooper->addFd(fd, 0, ALOOPER_EVENT_INPUT, handleReceiveCallback, this);
+    } // release lock
+
+    // Wake the looper because some connections have changed.
+    mLooper->wake();
+    return OK;
+}
+
+status_t InputDispatcher::unregisterInputChannel(const sp<InputChannel>& inputChannel) {
+#if DEBUG_REGISTRATION
+    ALOGD("channel '%s' ~ unregisterInputChannel", inputChannel->getName().string());
+#endif
+
+    { // acquire lock
+        AutoMutex _l(mLock);
+
+        status_t status = unregisterInputChannelLocked(inputChannel, false /*notify*/);
+        if (status) {
+            return status;
+        }
+    } // release lock
+
+    // Wake the poll loop because removing the connection may have changed the current
+    // synchronization state.
+    mLooper->wake();
+    return OK;
+}
+
+status_t InputDispatcher::unregisterInputChannelLocked(const sp<InputChannel>& inputChannel,
+        bool notify) {
+    ssize_t connectionIndex = getConnectionIndexLocked(inputChannel);
+    if (connectionIndex < 0) {
+        ALOGW("Attempted to unregister already unregistered input channel '%s'",
+                inputChannel->getName().string());
+        return BAD_VALUE;
+    }
+
+    sp<Connection> connection = mConnectionsByFd.valueAt(connectionIndex);
+    mConnectionsByFd.removeItemsAt(connectionIndex);
+
+    if (connection->monitor) {
+        removeMonitorChannelLocked(inputChannel);
+    }
+
+    mLooper->removeFd(inputChannel->getFd());
+
+    nsecs_t currentTime = now();
+    abortBrokenDispatchCycleLocked(currentTime, connection, notify);
+
+    connection->status = Connection::STATUS_ZOMBIE;
+    return OK;
+}
+
+void InputDispatcher::removeMonitorChannelLocked(const sp<InputChannel>& inputChannel) {
+    for (size_t i = 0; i < mMonitoringChannels.size(); i++) {
+         if (mMonitoringChannels[i] == inputChannel) {
+             mMonitoringChannels.removeAt(i);
+             break;
+         }
+    }
+}
+
+ssize_t InputDispatcher::getConnectionIndexLocked(const sp<InputChannel>& inputChannel) {
+    ssize_t connectionIndex = mConnectionsByFd.indexOfKey(inputChannel->getFd());
+    if (connectionIndex >= 0) {
+        sp<Connection> connection = mConnectionsByFd.valueAt(connectionIndex);
+        if (connection->inputChannel.get() == inputChannel.get()) {
+            return connectionIndex;
+        }
+    }
+
+    return -1;
+}
+
+void InputDispatcher::onDispatchCycleFinishedLocked(
+        nsecs_t currentTime, const sp<Connection>& connection, uint32_t seq, bool handled) {
+    CommandEntry* commandEntry = postCommandLocked(
+            & InputDispatcher::doDispatchCycleFinishedLockedInterruptible);
+    commandEntry->connection = connection;
+    commandEntry->eventTime = currentTime;
+    commandEntry->seq = seq;
+    commandEntry->handled = handled;
+}
+
+void InputDispatcher::onDispatchCycleBrokenLocked(
+        nsecs_t currentTime, const sp<Connection>& connection) {
+    ALOGE("channel '%s' ~ Channel is unrecoverably broken and will be disposed!",
+            connection->getInputChannelName());
+
+    CommandEntry* commandEntry = postCommandLocked(
+            & InputDispatcher::doNotifyInputChannelBrokenLockedInterruptible);
+    commandEntry->connection = connection;
+}
+
+void InputDispatcher::onANRLocked(
+        nsecs_t currentTime, const sp<InputApplicationHandle>& applicationHandle,
+        const sp<InputWindowHandle>& windowHandle,
+        nsecs_t eventTime, nsecs_t waitStartTime, const char* reason) {
+    float dispatchLatency = (currentTime - eventTime) * 0.000001f;
+    float waitDuration = (currentTime - waitStartTime) * 0.000001f;
+    ALOGI("Application is not responding: %s.  "
+            "It has been %0.1fms since event, %0.1fms since wait started.  Reason: %s",
+            getApplicationWindowLabelLocked(applicationHandle, windowHandle).string(),
+            dispatchLatency, waitDuration, reason);
+
+    // Capture a record of the InputDispatcher state at the time of the ANR.
+    time_t t = time(NULL);
+    struct tm tm;
+    localtime_r(&t, &tm);
+    char timestr[64];
+    strftime(timestr, sizeof(timestr), "%F %T", &tm);
+    mLastANRState.clear();
+    mLastANRState.append(INDENT "ANR:\n");
+    mLastANRState.appendFormat(INDENT2 "Time: %s\n", timestr);
+    mLastANRState.appendFormat(INDENT2 "Window: %s\n",
+            getApplicationWindowLabelLocked(applicationHandle, windowHandle).string());
+    mLastANRState.appendFormat(INDENT2 "DispatchLatency: %0.1fms\n", dispatchLatency);
+    mLastANRState.appendFormat(INDENT2 "WaitDuration: %0.1fms\n", waitDuration);
+    mLastANRState.appendFormat(INDENT2 "Reason: %s\n", reason);
+    dumpDispatchStateLocked(mLastANRState);
+
+    CommandEntry* commandEntry = postCommandLocked(
+            & InputDispatcher::doNotifyANRLockedInterruptible);
+    commandEntry->inputApplicationHandle = applicationHandle;
+    commandEntry->inputWindowHandle = windowHandle;
+    commandEntry->reason = reason;
+}
+
+void InputDispatcher::doNotifyConfigurationChangedInterruptible(
+        CommandEntry* commandEntry) {
+    mLock.unlock();
+
+    mPolicy->notifyConfigurationChanged(commandEntry->eventTime);
+
+    mLock.lock();
+}
+
+void InputDispatcher::doNotifyInputChannelBrokenLockedInterruptible(
+        CommandEntry* commandEntry) {
+    sp<Connection> connection = commandEntry->connection;
+
+    if (connection->status != Connection::STATUS_ZOMBIE) {
+        mLock.unlock();
+
+        mPolicy->notifyInputChannelBroken(connection->inputWindowHandle);
+
+        mLock.lock();
+    }
+}
+
+void InputDispatcher::doNotifyANRLockedInterruptible(
+        CommandEntry* commandEntry) {
+    mLock.unlock();
+
+    nsecs_t newTimeout = mPolicy->notifyANR(
+            commandEntry->inputApplicationHandle, commandEntry->inputWindowHandle,
+            commandEntry->reason);
+
+    mLock.lock();
+
+    resumeAfterTargetsNotReadyTimeoutLocked(newTimeout,
+            commandEntry->inputWindowHandle != NULL
+                    ? commandEntry->inputWindowHandle->getInputChannel() : NULL);
+}
+
+void InputDispatcher::doInterceptKeyBeforeDispatchingLockedInterruptible(
+        CommandEntry* commandEntry) {
+    KeyEntry* entry = commandEntry->keyEntry;
+
+    KeyEvent event;
+    initializeKeyEvent(&event, entry);
+
+    mLock.unlock();
+
+    nsecs_t delay = mPolicy->interceptKeyBeforeDispatching(commandEntry->inputWindowHandle,
+            &event, entry->policyFlags);
+
+    mLock.lock();
+
+    if (delay < 0) {
+        entry->interceptKeyResult = KeyEntry::INTERCEPT_KEY_RESULT_SKIP;
+    } else if (!delay) {
+        entry->interceptKeyResult = KeyEntry::INTERCEPT_KEY_RESULT_CONTINUE;
+    } else {
+        entry->interceptKeyResult = KeyEntry::INTERCEPT_KEY_RESULT_TRY_AGAIN_LATER;
+        entry->interceptKeyWakeupTime = now() + delay;
+    }
+    entry->release();
+}
+
+void InputDispatcher::doDispatchCycleFinishedLockedInterruptible(
+        CommandEntry* commandEntry) {
+    sp<Connection> connection = commandEntry->connection;
+    nsecs_t finishTime = commandEntry->eventTime;
+    uint32_t seq = commandEntry->seq;
+    bool handled = commandEntry->handled;
+
+    // Handle post-event policy actions.
+    DispatchEntry* dispatchEntry = connection->findWaitQueueEntry(seq);
+    if (dispatchEntry) {
+        nsecs_t eventDuration = finishTime - dispatchEntry->deliveryTime;
+        if (eventDuration > SLOW_EVENT_PROCESSING_WARNING_TIMEOUT) {
+            String8 msg;
+            msg.appendFormat("Window '%s' spent %0.1fms processing the last input event: ",
+                    connection->getWindowName(), eventDuration * 0.000001f);
+            dispatchEntry->eventEntry->appendDescription(msg);
+            ALOGI("%s", msg.string());
+        }
+
+        bool restartEvent;
+        if (dispatchEntry->eventEntry->type == EventEntry::TYPE_KEY) {
+            KeyEntry* keyEntry = static_cast<KeyEntry*>(dispatchEntry->eventEntry);
+            restartEvent = afterKeyEventLockedInterruptible(connection,
+                    dispatchEntry, keyEntry, handled);
+        } else if (dispatchEntry->eventEntry->type == EventEntry::TYPE_MOTION) {
+            MotionEntry* motionEntry = static_cast<MotionEntry*>(dispatchEntry->eventEntry);
+            restartEvent = afterMotionEventLockedInterruptible(connection,
+                    dispatchEntry, motionEntry, handled);
+        } else {
+            restartEvent = false;
+        }
+
+        // Dequeue the event and start the next cycle.
+        // Note that because the lock might have been released, it is possible that the
+        // contents of the wait queue to have been drained, so we need to double-check
+        // a few things.
+        if (dispatchEntry == connection->findWaitQueueEntry(seq)) {
+            connection->waitQueue.dequeue(dispatchEntry);
+            traceWaitQueueLengthLocked(connection);
+            if (restartEvent && connection->status == Connection::STATUS_NORMAL) {
+                connection->outboundQueue.enqueueAtHead(dispatchEntry);
+                traceOutboundQueueLengthLocked(connection);
+            } else {
+                releaseDispatchEntryLocked(dispatchEntry);
+            }
+        }
+
+        // Start the next dispatch cycle for this connection.
+        startDispatchCycleLocked(now(), connection);
+    }
+}
+
+bool InputDispatcher::afterKeyEventLockedInterruptible(const sp<Connection>& connection,
+        DispatchEntry* dispatchEntry, KeyEntry* keyEntry, bool handled) {
+    if (!(keyEntry->flags & AKEY_EVENT_FLAG_FALLBACK)) {
+        // Get the fallback key state.
+        // Clear it out after dispatching the UP.
+        int32_t originalKeyCode = keyEntry->keyCode;
+        int32_t fallbackKeyCode = connection->inputState.getFallbackKey(originalKeyCode);
+        if (keyEntry->action == AKEY_EVENT_ACTION_UP) {
+            connection->inputState.removeFallbackKey(originalKeyCode);
+        }
+
+        if (handled || !dispatchEntry->hasForegroundTarget()) {
+            // If the application handles the original key for which we previously
+            // generated a fallback or if the window is not a foreground window,
+            // then cancel the associated fallback key, if any.
+            if (fallbackKeyCode != -1) {
+                // Dispatch the unhandled key to the policy with the cancel flag.
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+                ALOGD("Unhandled key event: Asking policy to cancel fallback action.  "
+                        "keyCode=%d, action=%d, repeatCount=%d, policyFlags=0x%08x",
+                        keyEntry->keyCode, keyEntry->action, keyEntry->repeatCount,
+                        keyEntry->policyFlags);
+#endif
+                KeyEvent event;
+                initializeKeyEvent(&event, keyEntry);
+                event.setFlags(event.getFlags() | AKEY_EVENT_FLAG_CANCELED);
+
+                mLock.unlock();
+
+                mPolicy->dispatchUnhandledKey(connection->inputWindowHandle,
+                        &event, keyEntry->policyFlags, &event);
+
+                mLock.lock();
+
+                // Cancel the fallback key.
+                if (fallbackKeyCode != AKEYCODE_UNKNOWN) {
+                    CancelationOptions options(CancelationOptions::CANCEL_FALLBACK_EVENTS,
+                            "application handled the original non-fallback key "
+                            "or is no longer a foreground target, "
+                            "canceling previously dispatched fallback key");
+                    options.keyCode = fallbackKeyCode;
+                    synthesizeCancelationEventsForConnectionLocked(connection, options);
+                }
+                connection->inputState.removeFallbackKey(originalKeyCode);
+            }
+        } else {
+            // If the application did not handle a non-fallback key, first check
+            // that we are in a good state to perform unhandled key event processing
+            // Then ask the policy what to do with it.
+            bool initialDown = keyEntry->action == AKEY_EVENT_ACTION_DOWN
+                    && keyEntry->repeatCount == 0;
+            if (fallbackKeyCode == -1 && !initialDown) {
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+                ALOGD("Unhandled key event: Skipping unhandled key event processing "
+                        "since this is not an initial down.  "
+                        "keyCode=%d, action=%d, repeatCount=%d, policyFlags=0x%08x",
+                        originalKeyCode, keyEntry->action, keyEntry->repeatCount,
+                        keyEntry->policyFlags);
+#endif
+                return false;
+            }
+
+            // Dispatch the unhandled key to the policy.
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+            ALOGD("Unhandled key event: Asking policy to perform fallback action.  "
+                    "keyCode=%d, action=%d, repeatCount=%d, policyFlags=0x%08x",
+                    keyEntry->keyCode, keyEntry->action, keyEntry->repeatCount,
+                    keyEntry->policyFlags);
+#endif
+            KeyEvent event;
+            initializeKeyEvent(&event, keyEntry);
+
+            mLock.unlock();
+
+            bool fallback = mPolicy->dispatchUnhandledKey(connection->inputWindowHandle,
+                    &event, keyEntry->policyFlags, &event);
+
+            mLock.lock();
+
+            if (connection->status != Connection::STATUS_NORMAL) {
+                connection->inputState.removeFallbackKey(originalKeyCode);
+                return false;
+            }
+
+            // Latch the fallback keycode for this key on an initial down.
+            // The fallback keycode cannot change at any other point in the lifecycle.
+            if (initialDown) {
+                if (fallback) {
+                    fallbackKeyCode = event.getKeyCode();
+                } else {
+                    fallbackKeyCode = AKEYCODE_UNKNOWN;
+                }
+                connection->inputState.setFallbackKey(originalKeyCode, fallbackKeyCode);
+            }
+
+            ALOG_ASSERT(fallbackKeyCode != -1);
+
+            // Cancel the fallback key if the policy decides not to send it anymore.
+            // We will continue to dispatch the key to the policy but we will no
+            // longer dispatch a fallback key to the application.
+            if (fallbackKeyCode != AKEYCODE_UNKNOWN
+                    && (!fallback || fallbackKeyCode != event.getKeyCode())) {
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+                if (fallback) {
+                    ALOGD("Unhandled key event: Policy requested to send key %d"
+                            "as a fallback for %d, but on the DOWN it had requested "
+                            "to send %d instead.  Fallback canceled.",
+                            event.getKeyCode(), originalKeyCode, fallbackKeyCode);
+                } else {
+                    ALOGD("Unhandled key event: Policy did not request fallback for %d, "
+                            "but on the DOWN it had requested to send %d.  "
+                            "Fallback canceled.",
+                            originalKeyCode, fallbackKeyCode);
+                }
+#endif
+
+                CancelationOptions options(CancelationOptions::CANCEL_FALLBACK_EVENTS,
+                        "canceling fallback, policy no longer desires it");
+                options.keyCode = fallbackKeyCode;
+                synthesizeCancelationEventsForConnectionLocked(connection, options);
+
+                fallback = false;
+                fallbackKeyCode = AKEYCODE_UNKNOWN;
+                if (keyEntry->action != AKEY_EVENT_ACTION_UP) {
+                    connection->inputState.setFallbackKey(originalKeyCode,
+                            fallbackKeyCode);
+                }
+            }
+
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+            {
+                String8 msg;
+                const KeyedVector<int32_t, int32_t>& fallbackKeys =
+                        connection->inputState.getFallbackKeys();
+                for (size_t i = 0; i < fallbackKeys.size(); i++) {
+                    msg.appendFormat(", %d->%d", fallbackKeys.keyAt(i),
+                            fallbackKeys.valueAt(i));
+                }
+                ALOGD("Unhandled key event: %d currently tracked fallback keys%s.",
+                        fallbackKeys.size(), msg.string());
+            }
+#endif
+
+            if (fallback) {
+                // Restart the dispatch cycle using the fallback key.
+                keyEntry->eventTime = event.getEventTime();
+                keyEntry->deviceId = event.getDeviceId();
+                keyEntry->source = event.getSource();
+                keyEntry->flags = event.getFlags() | AKEY_EVENT_FLAG_FALLBACK;
+                keyEntry->keyCode = fallbackKeyCode;
+                keyEntry->scanCode = event.getScanCode();
+                keyEntry->metaState = event.getMetaState();
+                keyEntry->repeatCount = event.getRepeatCount();
+                keyEntry->downTime = event.getDownTime();
+                keyEntry->syntheticRepeat = false;
+
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+                ALOGD("Unhandled key event: Dispatching fallback key.  "
+                        "originalKeyCode=%d, fallbackKeyCode=%d, fallbackMetaState=%08x",
+                        originalKeyCode, fallbackKeyCode, keyEntry->metaState);
+#endif
+                return true; // restart the event
+            } else {
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+                ALOGD("Unhandled key event: No fallback key.");
+#endif
+            }
+        }
+    }
+    return false;
+}
+
+bool InputDispatcher::afterMotionEventLockedInterruptible(const sp<Connection>& connection,
+        DispatchEntry* dispatchEntry, MotionEntry* motionEntry, bool handled) {
+    return false;
+}
+
+void InputDispatcher::doPokeUserActivityLockedInterruptible(CommandEntry* commandEntry) {
+    mLock.unlock();
+
+    mPolicy->pokeUserActivity(commandEntry->eventTime, commandEntry->userActivityEventType);
+
+    mLock.lock();
+}
+
+void InputDispatcher::initializeKeyEvent(KeyEvent* event, const KeyEntry* entry) {
+    event->initialize(entry->deviceId, entry->source, entry->action, entry->flags,
+            entry->keyCode, entry->scanCode, entry->metaState, entry->repeatCount,
+            entry->downTime, entry->eventTime);
+}
+
+void InputDispatcher::updateDispatchStatisticsLocked(nsecs_t currentTime, const EventEntry* entry,
+        int32_t injectionResult, nsecs_t timeSpentWaitingForApplication) {
+    // TODO Write some statistics about how long we spend waiting.
+}
+
+void InputDispatcher::traceInboundQueueLengthLocked() {
+    if (ATRACE_ENABLED()) {
+        ATRACE_INT("iq", mInboundQueue.count());
+    }
+}
+
+void InputDispatcher::traceOutboundQueueLengthLocked(const sp<Connection>& connection) {
+    if (ATRACE_ENABLED()) {
+        char counterName[40];
+        snprintf(counterName, sizeof(counterName), "oq:%s", connection->getWindowName());
+        ATRACE_INT(counterName, connection->outboundQueue.count());
+    }
+}
+
+void InputDispatcher::traceWaitQueueLengthLocked(const sp<Connection>& connection) {
+    if (ATRACE_ENABLED()) {
+        char counterName[40];
+        snprintf(counterName, sizeof(counterName), "wq:%s", connection->getWindowName());
+        ATRACE_INT(counterName, connection->waitQueue.count());
+    }
+}
+
+void InputDispatcher::dump(String8& dump) {
+    AutoMutex _l(mLock);
+
+    dump.append("Input Dispatcher State:\n");
+    dumpDispatchStateLocked(dump);
+
+    if (!mLastANRState.isEmpty()) {
+        dump.append("\nInput Dispatcher State at time of last ANR:\n");
+        dump.append(mLastANRState);
+    }
+}
+
+void InputDispatcher::monitor() {
+    // Acquire and release the lock to ensure that the dispatcher has not deadlocked.
+    mLock.lock();
+    mLooper->wake();
+    mDispatcherIsAliveCondition.wait(mLock);
+    mLock.unlock();
+}
+
+
+// --- InputDispatcher::InjectionState ---
+
+InputDispatcher::InjectionState::InjectionState(int32_t injectorPid, int32_t injectorUid) :
+        refCount(1),
+        injectorPid(injectorPid), injectorUid(injectorUid),
+        injectionResult(INPUT_EVENT_INJECTION_PENDING), injectionIsAsync(false),
+        pendingForegroundDispatches(0) {
+}
+
+InputDispatcher::InjectionState::~InjectionState() {
+}
+
+void InputDispatcher::InjectionState::release() {
+    refCount -= 1;
+    if (refCount == 0) {
+        delete this;
+    } else {
+        ALOG_ASSERT(refCount > 0);
+    }
+}
+
+
+// --- InputDispatcher::EventEntry ---
+
+InputDispatcher::EventEntry::EventEntry(int32_t type, nsecs_t eventTime, uint32_t policyFlags) :
+        refCount(1), type(type), eventTime(eventTime), policyFlags(policyFlags),
+        injectionState(NULL), dispatchInProgress(false) {
+}
+
+InputDispatcher::EventEntry::~EventEntry() {
+    releaseInjectionState();
+}
+
+void InputDispatcher::EventEntry::release() {
+    refCount -= 1;
+    if (refCount == 0) {
+        delete this;
+    } else {
+        ALOG_ASSERT(refCount > 0);
+    }
+}
+
+void InputDispatcher::EventEntry::releaseInjectionState() {
+    if (injectionState) {
+        injectionState->release();
+        injectionState = NULL;
+    }
+}
+
+
+// --- InputDispatcher::ConfigurationChangedEntry ---
+
+InputDispatcher::ConfigurationChangedEntry::ConfigurationChangedEntry(nsecs_t eventTime) :
+        EventEntry(TYPE_CONFIGURATION_CHANGED, eventTime, 0) {
+}
+
+InputDispatcher::ConfigurationChangedEntry::~ConfigurationChangedEntry() {
+}
+
+void InputDispatcher::ConfigurationChangedEntry::appendDescription(String8& msg) const {
+    msg.append("ConfigurationChangedEvent(), policyFlags=0x%08x",
+            policyFlags);
+}
+
+
+// --- InputDispatcher::DeviceResetEntry ---
+
+InputDispatcher::DeviceResetEntry::DeviceResetEntry(nsecs_t eventTime, int32_t deviceId) :
+        EventEntry(TYPE_DEVICE_RESET, eventTime, 0),
+        deviceId(deviceId) {
+}
+
+InputDispatcher::DeviceResetEntry::~DeviceResetEntry() {
+}
+
+void InputDispatcher::DeviceResetEntry::appendDescription(String8& msg) const {
+    msg.appendFormat("DeviceResetEvent(deviceId=%d), policyFlags=0x%08x",
+            deviceId, policyFlags);
+}
+
+
+// --- InputDispatcher::KeyEntry ---
+
+InputDispatcher::KeyEntry::KeyEntry(nsecs_t eventTime,
+        int32_t deviceId, uint32_t source, uint32_t policyFlags, int32_t action,
+        int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState,
+        int32_t repeatCount, nsecs_t downTime) :
+        EventEntry(TYPE_KEY, eventTime, policyFlags),
+        deviceId(deviceId), source(source), action(action), flags(flags),
+        keyCode(keyCode), scanCode(scanCode), metaState(metaState),
+        repeatCount(repeatCount), downTime(downTime),
+        syntheticRepeat(false), interceptKeyResult(KeyEntry::INTERCEPT_KEY_RESULT_UNKNOWN),
+        interceptKeyWakeupTime(0) {
+}
+
+InputDispatcher::KeyEntry::~KeyEntry() {
+}
+
+void InputDispatcher::KeyEntry::appendDescription(String8& msg) const {
+    msg.appendFormat("KeyEvent(deviceId=%d, source=0x%08x, action=%d, "
+            "flags=0x%08x, keyCode=%d, scanCode=%d, metaState=0x%08x, "
+            "repeatCount=%d), policyFlags=0x%08x",
+            deviceId, source, action, flags, keyCode, scanCode, metaState,
+            repeatCount, policyFlags);
+}
+
+void InputDispatcher::KeyEntry::recycle() {
+    releaseInjectionState();
+
+    dispatchInProgress = false;
+    syntheticRepeat = false;
+    interceptKeyResult = KeyEntry::INTERCEPT_KEY_RESULT_UNKNOWN;
+    interceptKeyWakeupTime = 0;
+}
+
+
+// --- InputDispatcher::MotionEntry ---
+
+InputDispatcher::MotionEntry::MotionEntry(nsecs_t eventTime, int32_t deviceId,
+        uint32_t source, uint32_t policyFlags, int32_t action, int32_t actionButton,
+        int32_t flags, int32_t metaState, int32_t buttonState, int32_t edgeFlags,
+        float xPrecision, float yPrecision, nsecs_t downTime,
+        int32_t displayId, uint32_t pointerCount,
+        const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
+        float xOffset, float yOffset) :
+        EventEntry(TYPE_MOTION, eventTime, policyFlags),
+        eventTime(eventTime),
+        deviceId(deviceId), source(source), action(action), actionButton(actionButton),
+        flags(flags), metaState(metaState), buttonState(buttonState),
+        edgeFlags(edgeFlags), xPrecision(xPrecision), yPrecision(yPrecision),
+        downTime(downTime), displayId(displayId), pointerCount(pointerCount) {
+    for (uint32_t i = 0; i < pointerCount; i++) {
+        this->pointerProperties[i].copyFrom(pointerProperties[i]);
+        this->pointerCoords[i].copyFrom(pointerCoords[i]);
+        if (xOffset || yOffset) {
+            this->pointerCoords[i].applyOffset(xOffset, yOffset);
+        }
+    }
+}
+
+InputDispatcher::MotionEntry::~MotionEntry() {
+}
+
+void InputDispatcher::MotionEntry::appendDescription(String8& msg) const {
+    msg.appendFormat("MotionEvent(deviceId=%d, source=0x%08x, action=%d, actionButton=0x%08x, "
+            "flags=0x%08x, metaState=0x%08x, buttonState=0x%08x, "
+            "edgeFlags=0x%08x, xPrecision=%.1f, yPrecision=%.1f, displayId=%d, pointers=[",
+            deviceId, source, action, actionButton, flags, metaState, buttonState, edgeFlags,
+            xPrecision, yPrecision, displayId);
+    for (uint32_t i = 0; i < pointerCount; i++) {
+        if (i) {
+            msg.append(", ");
+        }
+        msg.appendFormat("%d: (%.1f, %.1f)", pointerProperties[i].id,
+                pointerCoords[i].getX(), pointerCoords[i].getY());
+    }
+    msg.appendFormat("]), policyFlags=0x%08x", policyFlags);
+}
+
+
+// --- InputDispatcher::DispatchEntry ---
+
+volatile int32_t InputDispatcher::DispatchEntry::sNextSeqAtomic;
+
+InputDispatcher::DispatchEntry::DispatchEntry(EventEntry* eventEntry,
+        int32_t targetFlags, float xOffset, float yOffset, float scaleFactor) :
+        seq(nextSeq()),
+        eventEntry(eventEntry), targetFlags(targetFlags),
+        xOffset(xOffset), yOffset(yOffset), scaleFactor(scaleFactor),
+        deliveryTime(0), resolvedAction(0), resolvedFlags(0) {
+    eventEntry->refCount += 1;
+}
+
+InputDispatcher::DispatchEntry::~DispatchEntry() {
+    eventEntry->release();
+}
+
+uint32_t InputDispatcher::DispatchEntry::nextSeq() {
+    // Sequence number 0 is reserved and will never be returned.
+    uint32_t seq;
+    do {
+        seq = android_atomic_inc(&sNextSeqAtomic);
+    } while (!seq);
+    return seq;
+}
+
+
+// --- InputDispatcher::InputState ---
+
+InputDispatcher::InputState::InputState() {
+}
+
+InputDispatcher::InputState::~InputState() {
+}
+
+bool InputDispatcher::InputState::isNeutral() const {
+    return mKeyMementos.isEmpty() && mMotionMementos.isEmpty();
+}
+
+bool InputDispatcher::InputState::isHovering(int32_t deviceId, uint32_t source,
+        int32_t displayId) const {
+    for (size_t i = 0; i < mMotionMementos.size(); i++) {
+        const MotionMemento& memento = mMotionMementos.itemAt(i);
+        if (memento.deviceId == deviceId
+                && memento.source == source
+                && memento.displayId == displayId
+                && memento.hovering) {
+            return true;
+        }
+    }
+    return false;
+}
+
+bool InputDispatcher::InputState::trackKey(const KeyEntry* entry,
+        int32_t action, int32_t flags) {
+    switch (action) {
+    case AKEY_EVENT_ACTION_UP: {
+        if (entry->flags & AKEY_EVENT_FLAG_FALLBACK) {
+            for (size_t i = 0; i < mFallbackKeys.size(); ) {
+                if (mFallbackKeys.valueAt(i) == entry->keyCode) {
+                    mFallbackKeys.removeItemsAt(i);
+                } else {
+                    i += 1;
+                }
+            }
+        }
+        ssize_t index = findKeyMemento(entry);
+        if (index >= 0) {
+            mKeyMementos.removeAt(index);
+            return true;
+        }
+        /* FIXME: We can't just drop the key up event because that prevents creating
+         * popup windows that are automatically shown when a key is held and then
+         * dismissed when the key is released.  The problem is that the popup will
+         * not have received the original key down, so the key up will be considered
+         * to be inconsistent with its observed state.  We could perhaps handle this
+         * by synthesizing a key down but that will cause other problems.
+         *
+         * So for now, allow inconsistent key up events to be dispatched.
+         *
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+        ALOGD("Dropping inconsistent key up event: deviceId=%d, source=%08x, "
+                "keyCode=%d, scanCode=%d",
+                entry->deviceId, entry->source, entry->keyCode, entry->scanCode);
+#endif
+        return false;
+        */
+        return true;
+    }
+
+    case AKEY_EVENT_ACTION_DOWN: {
+        ssize_t index = findKeyMemento(entry);
+        if (index >= 0) {
+            mKeyMementos.removeAt(index);
+        }
+        addKeyMemento(entry, flags);
+        return true;
+    }
+
+    default:
+        return true;
+    }
+}
+
+bool InputDispatcher::InputState::trackMotion(const MotionEntry* entry,
+        int32_t action, int32_t flags) {
+    int32_t actionMasked = action & AMOTION_EVENT_ACTION_MASK;
+    switch (actionMasked) {
+    case AMOTION_EVENT_ACTION_UP:
+    case AMOTION_EVENT_ACTION_CANCEL: {
+        ssize_t index = findMotionMemento(entry, false /*hovering*/);
+        if (index >= 0) {
+            mMotionMementos.removeAt(index);
+            return true;
+        }
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+        ALOGD("Dropping inconsistent motion up or cancel event: deviceId=%d, source=%08x, "
+                "actionMasked=%d",
+                entry->deviceId, entry->source, actionMasked);
+#endif
+        return false;
+    }
+
+    case AMOTION_EVENT_ACTION_DOWN: {
+        ssize_t index = findMotionMemento(entry, false /*hovering*/);
+        if (index >= 0) {
+            mMotionMementos.removeAt(index);
+        }
+        addMotionMemento(entry, flags, false /*hovering*/);
+        return true;
+    }
+
+    case AMOTION_EVENT_ACTION_POINTER_UP:
+    case AMOTION_EVENT_ACTION_POINTER_DOWN:
+    case AMOTION_EVENT_ACTION_MOVE: {
+        if (entry->source & AINPUT_SOURCE_CLASS_NAVIGATION) {
+            // Trackballs can send MOVE events with a corresponding DOWN or UP. There's no need to
+            // generate cancellation events for these since they're based in relative rather than
+            // absolute units.
+            return true;
+        }
+
+        ssize_t index = findMotionMemento(entry, false /*hovering*/);
+
+        if (entry->source & AINPUT_SOURCE_CLASS_JOYSTICK) {
+            // Joysticks can send MOVE events without a corresponding DOWN or UP. Since all
+            // joystick axes are normalized to [-1, 1] we can trust that 0 means it's neutral. Any
+            // other value and we need to track the motion so we can send cancellation events for
+            // anything generating fallback events (e.g. DPad keys for joystick movements).
+            if (index >= 0) {
+                if (entry->pointerCoords[0].isEmpty()) {
+                    mMotionMementos.removeAt(index);
+                } else {
+                    MotionMemento& memento = mMotionMementos.editItemAt(index);
+                    memento.setPointers(entry);
+                }
+            } else if (!entry->pointerCoords[0].isEmpty()) {
+                addMotionMemento(entry, flags, false /*hovering*/);
+            }
+
+            // Joysticks and trackballs can send MOVE events without corresponding DOWN or UP.
+            return true;
+        }
+        if (index >= 0) {
+            MotionMemento& memento = mMotionMementos.editItemAt(index);
+            memento.setPointers(entry);
+            return true;
+        }
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+        ALOGD("Dropping inconsistent motion pointer up/down or move event: "
+                "deviceId=%d, source=%08x, actionMasked=%d",
+                entry->deviceId, entry->source, actionMasked);
+#endif
+        return false;
+    }
+
+    case AMOTION_EVENT_ACTION_HOVER_EXIT: {
+        ssize_t index = findMotionMemento(entry, true /*hovering*/);
+        if (index >= 0) {
+            mMotionMementos.removeAt(index);
+            return true;
+        }
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+        ALOGD("Dropping inconsistent motion hover exit event: deviceId=%d, source=%08x",
+                entry->deviceId, entry->source);
+#endif
+        return false;
+    }
+
+    case AMOTION_EVENT_ACTION_HOVER_ENTER:
+    case AMOTION_EVENT_ACTION_HOVER_MOVE: {
+        ssize_t index = findMotionMemento(entry, true /*hovering*/);
+        if (index >= 0) {
+            mMotionMementos.removeAt(index);
+        }
+        addMotionMemento(entry, flags, true /*hovering*/);
+        return true;
+    }
+
+    default:
+        return true;
+    }
+}
+
+ssize_t InputDispatcher::InputState::findKeyMemento(const KeyEntry* entry) const {
+    for (size_t i = 0; i < mKeyMementos.size(); i++) {
+        const KeyMemento& memento = mKeyMementos.itemAt(i);
+        if (memento.deviceId == entry->deviceId
+                && memento.source == entry->source
+                && memento.keyCode == entry->keyCode
+                && memento.scanCode == entry->scanCode) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+ssize_t InputDispatcher::InputState::findMotionMemento(const MotionEntry* entry,
+        bool hovering) const {
+    for (size_t i = 0; i < mMotionMementos.size(); i++) {
+        const MotionMemento& memento = mMotionMementos.itemAt(i);
+        if (memento.deviceId == entry->deviceId
+                && memento.source == entry->source
+                && memento.displayId == entry->displayId
+                && memento.hovering == hovering) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+void InputDispatcher::InputState::addKeyMemento(const KeyEntry* entry, int32_t flags) {
+    mKeyMementos.push();
+    KeyMemento& memento = mKeyMementos.editTop();
+    memento.deviceId = entry->deviceId;
+    memento.source = entry->source;
+    memento.keyCode = entry->keyCode;
+    memento.scanCode = entry->scanCode;
+    memento.metaState = entry->metaState;
+    memento.flags = flags;
+    memento.downTime = entry->downTime;
+    memento.policyFlags = entry->policyFlags;
+}
+
+void InputDispatcher::InputState::addMotionMemento(const MotionEntry* entry,
+        int32_t flags, bool hovering) {
+    mMotionMementos.push();
+    MotionMemento& memento = mMotionMementos.editTop();
+    memento.deviceId = entry->deviceId;
+    memento.source = entry->source;
+    memento.flags = flags;
+    memento.xPrecision = entry->xPrecision;
+    memento.yPrecision = entry->yPrecision;
+    memento.downTime = entry->downTime;
+    memento.displayId = entry->displayId;
+    memento.setPointers(entry);
+    memento.hovering = hovering;
+    memento.policyFlags = entry->policyFlags;
+}
+
+void InputDispatcher::InputState::MotionMemento::setPointers(const MotionEntry* entry) {
+    pointerCount = entry->pointerCount;
+    for (uint32_t i = 0; i < entry->pointerCount; i++) {
+        pointerProperties[i].copyFrom(entry->pointerProperties[i]);
+        pointerCoords[i].copyFrom(entry->pointerCoords[i]);
+    }
+}
+
+void InputDispatcher::InputState::synthesizeCancelationEvents(nsecs_t currentTime,
+        Vector<EventEntry*>& outEvents, const CancelationOptions& options) {
+    for (size_t i = 0; i < mKeyMementos.size(); i++) {
+        const KeyMemento& memento = mKeyMementos.itemAt(i);
+        if (shouldCancelKey(memento, options)) {
+            outEvents.push(new KeyEntry(currentTime,
+                    memento.deviceId, memento.source, memento.policyFlags,
+                    AKEY_EVENT_ACTION_UP, memento.flags | AKEY_EVENT_FLAG_CANCELED,
+                    memento.keyCode, memento.scanCode, memento.metaState, 0, memento.downTime));
+        }
+    }
+
+    for (size_t i = 0; i < mMotionMementos.size(); i++) {
+        const MotionMemento& memento = mMotionMementos.itemAt(i);
+        if (shouldCancelMotion(memento, options)) {
+            outEvents.push(new MotionEntry(currentTime,
+                    memento.deviceId, memento.source, memento.policyFlags,
+                    memento.hovering
+                            ? AMOTION_EVENT_ACTION_HOVER_EXIT
+                            : AMOTION_EVENT_ACTION_CANCEL,
+                    memento.flags, 0, 0, 0, 0,
+                    memento.xPrecision, memento.yPrecision, memento.downTime,
+                    memento.displayId,
+                    memento.pointerCount, memento.pointerProperties, memento.pointerCoords,
+                    0, 0));
+        }
+    }
+}
+
+void InputDispatcher::InputState::clear() {
+    mKeyMementos.clear();
+    mMotionMementos.clear();
+    mFallbackKeys.clear();
+}
+
+void InputDispatcher::InputState::copyPointerStateTo(InputState& other) const {
+    for (size_t i = 0; i < mMotionMementos.size(); i++) {
+        const MotionMemento& memento = mMotionMementos.itemAt(i);
+        if (memento.source & AINPUT_SOURCE_CLASS_POINTER) {
+            for (size_t j = 0; j < other.mMotionMementos.size(); ) {
+                const MotionMemento& otherMemento = other.mMotionMementos.itemAt(j);
+                if (memento.deviceId == otherMemento.deviceId
+                        && memento.source == otherMemento.source
+                        && memento.displayId == otherMemento.displayId) {
+                    other.mMotionMementos.removeAt(j);
+                } else {
+                    j += 1;
+                }
+            }
+            other.mMotionMementos.push(memento);
+        }
+    }
+}
+
+int32_t InputDispatcher::InputState::getFallbackKey(int32_t originalKeyCode) {
+    ssize_t index = mFallbackKeys.indexOfKey(originalKeyCode);
+    return index >= 0 ? mFallbackKeys.valueAt(index) : -1;
+}
+
+void InputDispatcher::InputState::setFallbackKey(int32_t originalKeyCode,
+        int32_t fallbackKeyCode) {
+    ssize_t index = mFallbackKeys.indexOfKey(originalKeyCode);
+    if (index >= 0) {
+        mFallbackKeys.replaceValueAt(index, fallbackKeyCode);
+    } else {
+        mFallbackKeys.add(originalKeyCode, fallbackKeyCode);
+    }
+}
+
+void InputDispatcher::InputState::removeFallbackKey(int32_t originalKeyCode) {
+    mFallbackKeys.removeItem(originalKeyCode);
+}
+
+bool InputDispatcher::InputState::shouldCancelKey(const KeyMemento& memento,
+        const CancelationOptions& options) {
+    if (options.keyCode != -1 && memento.keyCode != options.keyCode) {
+        return false;
+    }
+
+    if (options.deviceId != -1 && memento.deviceId != options.deviceId) {
+        return false;
+    }
+
+    switch (options.mode) {
+    case CancelationOptions::CANCEL_ALL_EVENTS:
+    case CancelationOptions::CANCEL_NON_POINTER_EVENTS:
+        return true;
+    case CancelationOptions::CANCEL_FALLBACK_EVENTS:
+        return memento.flags & AKEY_EVENT_FLAG_FALLBACK;
+    default:
+        return false;
+    }
+}
+
+bool InputDispatcher::InputState::shouldCancelMotion(const MotionMemento& memento,
+        const CancelationOptions& options) {
+    if (options.deviceId != -1 && memento.deviceId != options.deviceId) {
+        return false;
+    }
+
+    switch (options.mode) {
+    case CancelationOptions::CANCEL_ALL_EVENTS:
+        return true;
+    case CancelationOptions::CANCEL_POINTER_EVENTS:
+        return memento.source & AINPUT_SOURCE_CLASS_POINTER;
+    case CancelationOptions::CANCEL_NON_POINTER_EVENTS:
+        return !(memento.source & AINPUT_SOURCE_CLASS_POINTER);
+    default:
+        return false;
+    }
+}
+
+
+// --- InputDispatcher::Connection ---
+
+InputDispatcher::Connection::Connection(const sp<InputChannel>& inputChannel,
+        const sp<InputWindowHandle>& inputWindowHandle, bool monitor) :
+        status(STATUS_NORMAL), inputChannel(inputChannel), inputWindowHandle(inputWindowHandle),
+        monitor(monitor),
+        inputPublisher(inputChannel), inputPublisherBlocked(false) {
+}
+
+InputDispatcher::Connection::~Connection() {
+}
+
+const char* InputDispatcher::Connection::getWindowName() const {
+    if (inputWindowHandle != NULL) {
+        return inputWindowHandle->getName().string();
+    }
+    if (monitor) {
+        return "monitor";
+    }
+    return "?";
+}
+
+const char* InputDispatcher::Connection::getStatusLabel() const {
+    switch (status) {
+    case STATUS_NORMAL:
+        return "NORMAL";
+
+    case STATUS_BROKEN:
+        return "BROKEN";
+
+    case STATUS_ZOMBIE:
+        return "ZOMBIE";
+
+    default:
+        return "UNKNOWN";
+    }
+}
+
+InputDispatcher::DispatchEntry* InputDispatcher::Connection::findWaitQueueEntry(uint32_t seq) {
+    for (DispatchEntry* entry = waitQueue.head; entry != NULL; entry = entry->next) {
+        if (entry->seq == seq) {
+            return entry;
+        }
+    }
+    return NULL;
+}
+
+
+// --- InputDispatcher::CommandEntry ---
+
+InputDispatcher::CommandEntry::CommandEntry(Command command) :
+    command(command), eventTime(0), keyEntry(NULL), userActivityEventType(0),
+    seq(0), handled(false) {
+}
+
+InputDispatcher::CommandEntry::~CommandEntry() {
+}
+
+
+// --- InputDispatcher::TouchState ---
+
+InputDispatcher::TouchState::TouchState() :
+    down(false), split(false), deviceId(-1), source(0), displayId(-1) {
+}
+
+InputDispatcher::TouchState::~TouchState() {
+}
+
+void InputDispatcher::TouchState::reset() {
+    down = false;
+    split = false;
+    deviceId = -1;
+    source = 0;
+    displayId = -1;
+    windows.clear();
+}
+
+void InputDispatcher::TouchState::copyFrom(const TouchState& other) {
+    down = other.down;
+    split = other.split;
+    deviceId = other.deviceId;
+    source = other.source;
+    displayId = other.displayId;
+    windows = other.windows;
+}
+
+void InputDispatcher::TouchState::addOrUpdateWindow(const sp<InputWindowHandle>& windowHandle,
+        int32_t targetFlags, BitSet32 pointerIds) {
+    if (targetFlags & InputTarget::FLAG_SPLIT) {
+        split = true;
+    }
+
+    for (size_t i = 0; i < windows.size(); i++) {
+        TouchedWindow& touchedWindow = windows.editItemAt(i);
+        if (touchedWindow.windowHandle == windowHandle) {
+            touchedWindow.targetFlags |= targetFlags;
+            if (targetFlags & InputTarget::FLAG_DISPATCH_AS_SLIPPERY_EXIT) {
+                touchedWindow.targetFlags &= ~InputTarget::FLAG_DISPATCH_AS_IS;
+            }
+            touchedWindow.pointerIds.value |= pointerIds.value;
+            return;
+        }
+    }
+
+    windows.push();
+
+    TouchedWindow& touchedWindow = windows.editTop();
+    touchedWindow.windowHandle = windowHandle;
+    touchedWindow.targetFlags = targetFlags;
+    touchedWindow.pointerIds = pointerIds;
+}
+
+void InputDispatcher::TouchState::removeWindow(const sp<InputWindowHandle>& windowHandle) {
+    for (size_t i = 0; i < windows.size(); i++) {
+        if (windows.itemAt(i).windowHandle == windowHandle) {
+            windows.removeAt(i);
+            return;
+        }
+    }
+}
+
+void InputDispatcher::TouchState::filterNonAsIsTouchWindows() {
+    for (size_t i = 0 ; i < windows.size(); ) {
+        TouchedWindow& window = windows.editItemAt(i);
+        if (window.targetFlags & (InputTarget::FLAG_DISPATCH_AS_IS
+                | InputTarget::FLAG_DISPATCH_AS_SLIPPERY_ENTER)) {
+            window.targetFlags &= ~InputTarget::FLAG_DISPATCH_MASK;
+            window.targetFlags |= InputTarget::FLAG_DISPATCH_AS_IS;
+            i += 1;
+        } else {
+            windows.removeAt(i);
+        }
+    }
+}
+
+sp<InputWindowHandle> InputDispatcher::TouchState::getFirstForegroundWindowHandle() const {
+    for (size_t i = 0; i < windows.size(); i++) {
+        const TouchedWindow& window = windows.itemAt(i);
+        if (window.targetFlags & InputTarget::FLAG_FOREGROUND) {
+            return window.windowHandle;
+        }
+    }
+    return NULL;
+}
+
+bool InputDispatcher::TouchState::isSlippery() const {
+    // Must have exactly one foreground window.
+    bool haveSlipperyForegroundWindow = false;
+    for (size_t i = 0; i < windows.size(); i++) {
+        const TouchedWindow& window = windows.itemAt(i);
+        if (window.targetFlags & InputTarget::FLAG_FOREGROUND) {
+            if (haveSlipperyForegroundWindow
+                    || !(window.windowHandle->getInfo()->layoutParamsFlags
+                            & InputWindowInfo::FLAG_SLIPPERY)) {
+                return false;
+            }
+            haveSlipperyForegroundWindow = true;
+        }
+    }
+    return haveSlipperyForegroundWindow;
+}
+
+
+// --- InputDispatcherThread ---
+
+InputDispatcherThread::InputDispatcherThread(const sp<InputDispatcherInterface>& dispatcher) :
+        Thread(/*canCallJava*/ true), mDispatcher(dispatcher) {
+}
+
+InputDispatcherThread::~InputDispatcherThread() {
+}
+
+bool InputDispatcherThread::threadLoop() {
+    mDispatcher->dispatchOnce();
+    return true;
+}
+
+} // namespace android
diff --git a/services/inputflinger/InputDispatcher.h b/services/inputflinger/InputDispatcher.h
new file mode 100644
index 0000000..98355c6
--- /dev/null
+++ b/services/inputflinger/InputDispatcher.h
@@ -0,0 +1,1148 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _UI_INPUT_DISPATCHER_H
+#define _UI_INPUT_DISPATCHER_H
+
+#include <input/Input.h>
+#include <input/InputTransport.h>
+#include <utils/KeyedVector.h>
+#include <utils/Vector.h>
+#include <utils/threads.h>
+#include <utils/Timers.h>
+#include <utils/RefBase.h>
+#include <utils/String8.h>
+#include <utils/Looper.h>
+#include <utils/BitSet.h>
+#include <cutils/atomic.h>
+
+#include <stddef.h>
+#include <unistd.h>
+#include <limits.h>
+
+#include "InputWindow.h"
+#include "InputApplication.h"
+#include "InputListener.h"
+
+
+namespace android {
+
+/*
+ * Constants used to report the outcome of input event injection.
+ */
+enum {
+    /* (INTERNAL USE ONLY) Specifies that injection is pending and its outcome is unknown. */
+    INPUT_EVENT_INJECTION_PENDING = -1,
+
+    /* Injection succeeded. */
+    INPUT_EVENT_INJECTION_SUCCEEDED = 0,
+
+    /* Injection failed because the injector did not have permission to inject
+     * into the application with input focus. */
+    INPUT_EVENT_INJECTION_PERMISSION_DENIED = 1,
+
+    /* Injection failed because there were no available input targets. */
+    INPUT_EVENT_INJECTION_FAILED = 2,
+
+    /* Injection failed due to a timeout. */
+    INPUT_EVENT_INJECTION_TIMED_OUT = 3
+};
+
+/*
+ * Constants used to determine the input event injection synchronization mode.
+ */
+enum {
+    /* Injection is asynchronous and is assumed always to be successful. */
+    INPUT_EVENT_INJECTION_SYNC_NONE = 0,
+
+    /* Waits for previous events to be dispatched so that the input dispatcher can determine
+     * whether input event injection willbe permitted based on the current input focus.
+     * Does not wait for the input event to finish processing. */
+    INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_RESULT = 1,
+
+    /* Waits for the input event to be completely processed. */
+    INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_FINISHED = 2,
+};
+
+
+/*
+ * An input target specifies how an input event is to be dispatched to a particular window
+ * including the window's input channel, control flags, a timeout, and an X / Y offset to
+ * be added to input event coordinates to compensate for the absolute position of the
+ * window area.
+ */
+struct InputTarget {
+    enum {
+        /* This flag indicates that the event is being delivered to a foreground application. */
+        FLAG_FOREGROUND = 1 << 0,
+
+        /* This flag indicates that the target of a MotionEvent is partly or wholly
+         * obscured by another visible window above it.  The motion event should be
+         * delivered with flag AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED. */
+        FLAG_WINDOW_IS_OBSCURED = 1 << 1,
+
+        /* This flag indicates that a motion event is being split across multiple windows. */
+        FLAG_SPLIT = 1 << 2,
+
+        /* This flag indicates that the pointer coordinates dispatched to the application
+         * will be zeroed out to avoid revealing information to an application. This is
+         * used in conjunction with FLAG_DISPATCH_AS_OUTSIDE to prevent apps not sharing
+         * the same UID from watching all touches. */
+        FLAG_ZERO_COORDS = 1 << 3,
+
+        /* This flag indicates that the event should be sent as is.
+         * Should always be set unless the event is to be transmuted. */
+        FLAG_DISPATCH_AS_IS = 1 << 8,
+
+        /* This flag indicates that a MotionEvent with AMOTION_EVENT_ACTION_DOWN falls outside
+         * of the area of this target and so should instead be delivered as an
+         * AMOTION_EVENT_ACTION_OUTSIDE to this target. */
+        FLAG_DISPATCH_AS_OUTSIDE = 1 << 9,
+
+        /* This flag indicates that a hover sequence is starting in the given window.
+         * The event is transmuted into ACTION_HOVER_ENTER. */
+        FLAG_DISPATCH_AS_HOVER_ENTER = 1 << 10,
+
+        /* This flag indicates that a hover event happened outside of a window which handled
+         * previous hover events, signifying the end of the current hover sequence for that
+         * window.
+         * The event is transmuted into ACTION_HOVER_ENTER. */
+        FLAG_DISPATCH_AS_HOVER_EXIT = 1 << 11,
+
+        /* This flag indicates that the event should be canceled.
+         * It is used to transmute ACTION_MOVE into ACTION_CANCEL when a touch slips
+         * outside of a window. */
+        FLAG_DISPATCH_AS_SLIPPERY_EXIT = 1 << 12,
+
+        /* This flag indicates that the event should be dispatched as an initial down.
+         * It is used to transmute ACTION_MOVE into ACTION_DOWN when a touch slips
+         * into a new window. */
+        FLAG_DISPATCH_AS_SLIPPERY_ENTER = 1 << 13,
+
+        /* Mask for all dispatch modes. */
+        FLAG_DISPATCH_MASK = FLAG_DISPATCH_AS_IS
+                | FLAG_DISPATCH_AS_OUTSIDE
+                | FLAG_DISPATCH_AS_HOVER_ENTER
+                | FLAG_DISPATCH_AS_HOVER_EXIT
+                | FLAG_DISPATCH_AS_SLIPPERY_EXIT
+                | FLAG_DISPATCH_AS_SLIPPERY_ENTER,
+    };
+
+    // The input channel to be targeted.
+    sp<InputChannel> inputChannel;
+
+    // Flags for the input target.
+    int32_t flags;
+
+    // The x and y offset to add to a MotionEvent as it is delivered.
+    // (ignored for KeyEvents)
+    float xOffset, yOffset;
+
+    // Scaling factor to apply to MotionEvent as it is delivered.
+    // (ignored for KeyEvents)
+    float scaleFactor;
+
+    // The subset of pointer ids to include in motion events dispatched to this input target
+    // if FLAG_SPLIT is set.
+    BitSet32 pointerIds;
+};
+
+
+/*
+ * Input dispatcher configuration.
+ *
+ * Specifies various options that modify the behavior of the input dispatcher.
+ * The values provided here are merely defaults. The actual values will come from ViewConfiguration
+ * and are passed into the dispatcher during initialization.
+ */
+struct InputDispatcherConfiguration {
+    // The key repeat initial timeout.
+    nsecs_t keyRepeatTimeout;
+
+    // The key repeat inter-key delay.
+    nsecs_t keyRepeatDelay;
+
+    InputDispatcherConfiguration() :
+            keyRepeatTimeout(500 * 1000000LL),
+            keyRepeatDelay(50 * 1000000LL) { }
+};
+
+
+/*
+ * Input dispatcher policy interface.
+ *
+ * The input reader policy is used by the input reader to interact with the Window Manager
+ * and other system components.
+ *
+ * The actual implementation is partially supported by callbacks into the DVM
+ * via JNI.  This interface is also mocked in the unit tests.
+ */
+class InputDispatcherPolicyInterface : public virtual RefBase {
+protected:
+    InputDispatcherPolicyInterface() { }
+    virtual ~InputDispatcherPolicyInterface() { }
+
+public:
+    /* Notifies the system that a configuration change has occurred. */
+    virtual void notifyConfigurationChanged(nsecs_t when) = 0;
+
+    /* Notifies the system that an application is not responding.
+     * Returns a new timeout to continue waiting, or 0 to abort dispatch. */
+    virtual nsecs_t notifyANR(const sp<InputApplicationHandle>& inputApplicationHandle,
+            const sp<InputWindowHandle>& inputWindowHandle,
+            const String8& reason) = 0;
+
+    /* Notifies the system that an input channel is unrecoverably broken. */
+    virtual void notifyInputChannelBroken(const sp<InputWindowHandle>& inputWindowHandle) = 0;
+
+    /* Gets the input dispatcher configuration. */
+    virtual void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) = 0;
+
+    /* Filters an input event.
+     * Return true to dispatch the event unmodified, false to consume the event.
+     * A filter can also transform and inject events later by passing POLICY_FLAG_FILTERED
+     * to injectInputEvent.
+     */
+    virtual bool filterInputEvent(const InputEvent* inputEvent, uint32_t policyFlags) = 0;
+
+    /* Intercepts a key event immediately before queueing it.
+     * The policy can use this method as an opportunity to perform power management functions
+     * and early event preprocessing such as updating policy flags.
+     *
+     * This method is expected to set the POLICY_FLAG_PASS_TO_USER policy flag if the event
+     * should be dispatched to applications.
+     */
+    virtual void interceptKeyBeforeQueueing(const KeyEvent* keyEvent, uint32_t& policyFlags) = 0;
+
+    /* Intercepts a touch, trackball or other motion event before queueing it.
+     * The policy can use this method as an opportunity to perform power management functions
+     * and early event preprocessing such as updating policy flags.
+     *
+     * This method is expected to set the POLICY_FLAG_PASS_TO_USER policy flag if the event
+     * should be dispatched to applications.
+     */
+    virtual void interceptMotionBeforeQueueing(nsecs_t when, uint32_t& policyFlags) = 0;
+
+    /* Allows the policy a chance to intercept a key before dispatching. */
+    virtual nsecs_t interceptKeyBeforeDispatching(const sp<InputWindowHandle>& inputWindowHandle,
+            const KeyEvent* keyEvent, uint32_t policyFlags) = 0;
+
+    /* Allows the policy a chance to perform default processing for an unhandled key.
+     * Returns an alternate keycode to redispatch as a fallback, or 0 to give up. */
+    virtual bool dispatchUnhandledKey(const sp<InputWindowHandle>& inputWindowHandle,
+            const KeyEvent* keyEvent, uint32_t policyFlags, KeyEvent* outFallbackKeyEvent) = 0;
+
+    /* Notifies the policy about switch events.
+     */
+    virtual void notifySwitch(nsecs_t when,
+            uint32_t switchValues, uint32_t switchMask, uint32_t policyFlags) = 0;
+
+    /* Poke user activity for an event dispatched to a window. */
+    virtual void pokeUserActivity(nsecs_t eventTime, int32_t eventType) = 0;
+
+    /* Checks whether a given application pid/uid has permission to inject input events
+     * into other applications.
+     *
+     * This method is special in that its implementation promises to be non-reentrant and
+     * is safe to call while holding other locks.  (Most other methods make no such guarantees!)
+     */
+    virtual bool checkInjectEventsPermissionNonReentrant(
+            int32_t injectorPid, int32_t injectorUid) = 0;
+};
+
+
+/* Notifies the system about input events generated by the input reader.
+ * The dispatcher is expected to be mostly asynchronous. */
+class InputDispatcherInterface : public virtual RefBase, public InputListenerInterface {
+protected:
+    InputDispatcherInterface() { }
+    virtual ~InputDispatcherInterface() { }
+
+public:
+    /* Dumps the state of the input dispatcher.
+     *
+     * This method may be called on any thread (usually by the input manager). */
+    virtual void dump(String8& dump) = 0;
+
+    /* Called by the heatbeat to ensures that the dispatcher has not deadlocked. */
+    virtual void monitor() = 0;
+
+    /* Runs a single iteration of the dispatch loop.
+     * Nominally processes one queued event, a timeout, or a response from an input consumer.
+     *
+     * This method should only be called on the input dispatcher thread.
+     */
+    virtual void dispatchOnce() = 0;
+
+    /* Injects an input event and optionally waits for sync.
+     * The synchronization mode determines whether the method blocks while waiting for
+     * input injection to proceed.
+     * Returns one of the INPUT_EVENT_INJECTION_XXX constants.
+     *
+     * This method may be called on any thread (usually by the input manager).
+     */
+    virtual int32_t injectInputEvent(const InputEvent* event, int32_t displayId,
+            int32_t injectorPid, int32_t injectorUid, int32_t syncMode, int32_t timeoutMillis,
+            uint32_t policyFlags) = 0;
+
+    /* Sets the list of input windows.
+     *
+     * This method may be called on any thread (usually by the input manager).
+     */
+    virtual void setInputWindows(const Vector<sp<InputWindowHandle> >& inputWindowHandles) = 0;
+
+    /* Sets the focused application.
+     *
+     * This method may be called on any thread (usually by the input manager).
+     */
+    virtual void setFocusedApplication(
+            const sp<InputApplicationHandle>& inputApplicationHandle) = 0;
+
+    /* Sets the input dispatching mode.
+     *
+     * This method may be called on any thread (usually by the input manager).
+     */
+    virtual void setInputDispatchMode(bool enabled, bool frozen) = 0;
+
+    /* Sets whether input event filtering is enabled.
+     * When enabled, incoming input events are sent to the policy's filterInputEvent
+     * method instead of being dispatched.  The filter is expected to use
+     * injectInputEvent to inject the events it would like to have dispatched.
+     * It should include POLICY_FLAG_FILTERED in the policy flags during injection.
+     */
+    virtual void setInputFilterEnabled(bool enabled) = 0;
+
+    /* Transfers touch focus from the window associated with one channel to the
+     * window associated with the other channel.
+     *
+     * Returns true on success.  False if the window did not actually have touch focus.
+     */
+    virtual bool transferTouchFocus(const sp<InputChannel>& fromChannel,
+            const sp<InputChannel>& toChannel) = 0;
+
+    /* Registers or unregister input channels that may be used as targets for input events.
+     * If monitor is true, the channel will receive a copy of all input events.
+     *
+     * These methods may be called on any thread (usually by the input manager).
+     */
+    virtual status_t registerInputChannel(const sp<InputChannel>& inputChannel,
+            const sp<InputWindowHandle>& inputWindowHandle, bool monitor) = 0;
+    virtual status_t unregisterInputChannel(const sp<InputChannel>& inputChannel) = 0;
+};
+
+/* Dispatches events to input targets.  Some functions of the input dispatcher, such as
+ * identifying input targets, are controlled by a separate policy object.
+ *
+ * IMPORTANT INVARIANT:
+ *     Because the policy can potentially block or cause re-entrance into the input dispatcher,
+ *     the input dispatcher never calls into the policy while holding its internal locks.
+ *     The implementation is also carefully designed to recover from scenarios such as an
+ *     input channel becoming unregistered while identifying input targets or processing timeouts.
+ *
+ *     Methods marked 'Locked' must be called with the lock acquired.
+ *
+ *     Methods marked 'LockedInterruptible' must be called with the lock acquired but
+ *     may during the course of their execution release the lock, call into the policy, and
+ *     then reacquire the lock.  The caller is responsible for recovering gracefully.
+ *
+ *     A 'LockedInterruptible' method may called a 'Locked' method, but NOT vice-versa.
+ */
+class InputDispatcher : public InputDispatcherInterface {
+protected:
+    virtual ~InputDispatcher();
+
+public:
+    explicit InputDispatcher(const sp<InputDispatcherPolicyInterface>& policy);
+
+    virtual void dump(String8& dump);
+    virtual void monitor();
+
+    virtual void dispatchOnce();
+
+    virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args);
+    virtual void notifyKey(const NotifyKeyArgs* args);
+    virtual void notifyMotion(const NotifyMotionArgs* args);
+    virtual void notifySwitch(const NotifySwitchArgs* args);
+    virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args);
+
+    virtual int32_t injectInputEvent(const InputEvent* event, int32_t displayId,
+            int32_t injectorPid, int32_t injectorUid, int32_t syncMode, int32_t timeoutMillis,
+            uint32_t policyFlags);
+
+    virtual void setInputWindows(const Vector<sp<InputWindowHandle> >& inputWindowHandles);
+    virtual void setFocusedApplication(const sp<InputApplicationHandle>& inputApplicationHandle);
+    virtual void setInputDispatchMode(bool enabled, bool frozen);
+    virtual void setInputFilterEnabled(bool enabled);
+
+    virtual bool transferTouchFocus(const sp<InputChannel>& fromChannel,
+            const sp<InputChannel>& toChannel);
+
+    virtual status_t registerInputChannel(const sp<InputChannel>& inputChannel,
+            const sp<InputWindowHandle>& inputWindowHandle, bool monitor);
+    virtual status_t unregisterInputChannel(const sp<InputChannel>& inputChannel);
+
+private:
+    template <typename T>
+    struct Link {
+        T* next;
+        T* prev;
+
+    protected:
+        inline Link() : next(NULL), prev(NULL) { }
+    };
+
+    struct InjectionState {
+        mutable int32_t refCount;
+
+        int32_t injectorPid;
+        int32_t injectorUid;
+        int32_t injectionResult;  // initially INPUT_EVENT_INJECTION_PENDING
+        bool injectionIsAsync; // set to true if injection is not waiting for the result
+        int32_t pendingForegroundDispatches; // the number of foreground dispatches in progress
+
+        InjectionState(int32_t injectorPid, int32_t injectorUid);
+        void release();
+
+    private:
+        ~InjectionState();
+    };
+
+    struct EventEntry : Link<EventEntry> {
+        enum {
+            TYPE_CONFIGURATION_CHANGED,
+            TYPE_DEVICE_RESET,
+            TYPE_KEY,
+            TYPE_MOTION
+        };
+
+        mutable int32_t refCount;
+        int32_t type;
+        nsecs_t eventTime;
+        uint32_t policyFlags;
+        InjectionState* injectionState;
+
+        bool dispatchInProgress; // initially false, set to true while dispatching
+
+        inline bool isInjected() const { return injectionState != NULL; }
+
+        void release();
+
+        virtual void appendDescription(String8& msg) const = 0;
+
+    protected:
+        EventEntry(int32_t type, nsecs_t eventTime, uint32_t policyFlags);
+        virtual ~EventEntry();
+        void releaseInjectionState();
+    };
+
+    struct ConfigurationChangedEntry : EventEntry {
+        ConfigurationChangedEntry(nsecs_t eventTime);
+        virtual void appendDescription(String8& msg) const;
+
+    protected:
+        virtual ~ConfigurationChangedEntry();
+    };
+
+    struct DeviceResetEntry : EventEntry {
+        int32_t deviceId;
+
+        DeviceResetEntry(nsecs_t eventTime, int32_t deviceId);
+        virtual void appendDescription(String8& msg) const;
+
+    protected:
+        virtual ~DeviceResetEntry();
+    };
+
+    struct KeyEntry : EventEntry {
+        int32_t deviceId;
+        uint32_t source;
+        int32_t action;
+        int32_t flags;
+        int32_t keyCode;
+        int32_t scanCode;
+        int32_t metaState;
+        int32_t repeatCount;
+        nsecs_t downTime;
+
+        bool syntheticRepeat; // set to true for synthetic key repeats
+
+        enum InterceptKeyResult {
+            INTERCEPT_KEY_RESULT_UNKNOWN,
+            INTERCEPT_KEY_RESULT_SKIP,
+            INTERCEPT_KEY_RESULT_CONTINUE,
+            INTERCEPT_KEY_RESULT_TRY_AGAIN_LATER,
+        };
+        InterceptKeyResult interceptKeyResult; // set based on the interception result
+        nsecs_t interceptKeyWakeupTime; // used with INTERCEPT_KEY_RESULT_TRY_AGAIN_LATER
+
+        KeyEntry(nsecs_t eventTime,
+                int32_t deviceId, uint32_t source, uint32_t policyFlags, int32_t action,
+                int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState,
+                int32_t repeatCount, nsecs_t downTime);
+        virtual void appendDescription(String8& msg) const;
+        void recycle();
+
+    protected:
+        virtual ~KeyEntry();
+    };
+
+    struct MotionEntry : EventEntry {
+        nsecs_t eventTime;
+        int32_t deviceId;
+        uint32_t source;
+        int32_t action;
+        int32_t actionButton;
+        int32_t flags;
+        int32_t metaState;
+        int32_t buttonState;
+        int32_t edgeFlags;
+        float xPrecision;
+        float yPrecision;
+        nsecs_t downTime;
+        int32_t displayId;
+        uint32_t pointerCount;
+        PointerProperties pointerProperties[MAX_POINTERS];
+        PointerCoords pointerCoords[MAX_POINTERS];
+
+        MotionEntry(nsecs_t eventTime,
+                int32_t deviceId, uint32_t source, uint32_t policyFlags,
+                int32_t action, int32_t actionButton, int32_t flags,
+                int32_t metaState, int32_t buttonState, int32_t edgeFlags,
+                float xPrecision, float yPrecision, nsecs_t downTime,
+                int32_t displayId, uint32_t pointerCount,
+                const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
+                float xOffset, float yOffset);
+        virtual void appendDescription(String8& msg) const;
+
+    protected:
+        virtual ~MotionEntry();
+    };
+
+    // Tracks the progress of dispatching a particular event to a particular connection.
+    struct DispatchEntry : Link<DispatchEntry> {
+        const uint32_t seq; // unique sequence number, never 0
+
+        EventEntry* eventEntry; // the event to dispatch
+        int32_t targetFlags;
+        float xOffset;
+        float yOffset;
+        float scaleFactor;
+        nsecs_t deliveryTime; // time when the event was actually delivered
+
+        // Set to the resolved action and flags when the event is enqueued.
+        int32_t resolvedAction;
+        int32_t resolvedFlags;
+
+        DispatchEntry(EventEntry* eventEntry,
+                int32_t targetFlags, float xOffset, float yOffset, float scaleFactor);
+        ~DispatchEntry();
+
+        inline bool hasForegroundTarget() const {
+            return targetFlags & InputTarget::FLAG_FOREGROUND;
+        }
+
+        inline bool isSplit() const {
+            return targetFlags & InputTarget::FLAG_SPLIT;
+        }
+
+    private:
+        static volatile int32_t sNextSeqAtomic;
+
+        static uint32_t nextSeq();
+    };
+
+    // A command entry captures state and behavior for an action to be performed in the
+    // dispatch loop after the initial processing has taken place.  It is essentially
+    // a kind of continuation used to postpone sensitive policy interactions to a point
+    // in the dispatch loop where it is safe to release the lock (generally after finishing
+    // the critical parts of the dispatch cycle).
+    //
+    // The special thing about commands is that they can voluntarily release and reacquire
+    // the dispatcher lock at will.  Initially when the command starts running, the
+    // dispatcher lock is held.  However, if the command needs to call into the policy to
+    // do some work, it can release the lock, do the work, then reacquire the lock again
+    // before returning.
+    //
+    // This mechanism is a bit clunky but it helps to preserve the invariant that the dispatch
+    // never calls into the policy while holding its lock.
+    //
+    // Commands are implicitly 'LockedInterruptible'.
+    struct CommandEntry;
+    typedef void (InputDispatcher::*Command)(CommandEntry* commandEntry);
+
+    class Connection;
+    struct CommandEntry : Link<CommandEntry> {
+        CommandEntry(Command command);
+        ~CommandEntry();
+
+        Command command;
+
+        // parameters for the command (usage varies by command)
+        sp<Connection> connection;
+        nsecs_t eventTime;
+        KeyEntry* keyEntry;
+        sp<InputApplicationHandle> inputApplicationHandle;
+        sp<InputWindowHandle> inputWindowHandle;
+        String8 reason;
+        int32_t userActivityEventType;
+        uint32_t seq;
+        bool handled;
+    };
+
+    // Generic queue implementation.
+    template <typename T>
+    struct Queue {
+        T* head;
+        T* tail;
+        uint32_t entryCount;
+
+        inline Queue() : head(NULL), tail(NULL), entryCount(0) {
+        }
+
+        inline bool isEmpty() const {
+            return !head;
+        }
+
+        inline void enqueueAtTail(T* entry) {
+            entryCount++;
+            entry->prev = tail;
+            if (tail) {
+                tail->next = entry;
+            } else {
+                head = entry;
+            }
+            entry->next = NULL;
+            tail = entry;
+        }
+
+        inline void enqueueAtHead(T* entry) {
+            entryCount++;
+            entry->next = head;
+            if (head) {
+                head->prev = entry;
+            } else {
+                tail = entry;
+            }
+            entry->prev = NULL;
+            head = entry;
+        }
+
+        inline void dequeue(T* entry) {
+            entryCount--;
+            if (entry->prev) {
+                entry->prev->next = entry->next;
+            } else {
+                head = entry->next;
+            }
+            if (entry->next) {
+                entry->next->prev = entry->prev;
+            } else {
+                tail = entry->prev;
+            }
+        }
+
+        inline T* dequeueAtHead() {
+            entryCount--;
+            T* entry = head;
+            head = entry->next;
+            if (head) {
+                head->prev = NULL;
+            } else {
+                tail = NULL;
+            }
+            return entry;
+        }
+
+        uint32_t count() const {
+            return entryCount;
+        }
+    };
+
+    /* Specifies which events are to be canceled and why. */
+    struct CancelationOptions {
+        enum Mode {
+            CANCEL_ALL_EVENTS = 0,
+            CANCEL_POINTER_EVENTS = 1,
+            CANCEL_NON_POINTER_EVENTS = 2,
+            CANCEL_FALLBACK_EVENTS = 3,
+        };
+
+        // The criterion to use to determine which events should be canceled.
+        Mode mode;
+
+        // Descriptive reason for the cancelation.
+        const char* reason;
+
+        // The specific keycode of the key event to cancel, or -1 to cancel any key event.
+        int32_t keyCode;
+
+        // The specific device id of events to cancel, or -1 to cancel events from any device.
+        int32_t deviceId;
+
+        CancelationOptions(Mode mode, const char* reason) :
+                mode(mode), reason(reason), keyCode(-1), deviceId(-1) { }
+    };
+
+    /* Tracks dispatched key and motion event state so that cancelation events can be
+     * synthesized when events are dropped. */
+    class InputState {
+    public:
+        InputState();
+        ~InputState();
+
+        // Returns true if there is no state to be canceled.
+        bool isNeutral() const;
+
+        // Returns true if the specified source is known to have received a hover enter
+        // motion event.
+        bool isHovering(int32_t deviceId, uint32_t source, int32_t displayId) const;
+
+        // Records tracking information for a key event that has just been published.
+        // Returns true if the event should be delivered, false if it is inconsistent
+        // and should be skipped.
+        bool trackKey(const KeyEntry* entry, int32_t action, int32_t flags);
+
+        // Records tracking information for a motion event that has just been published.
+        // Returns true if the event should be delivered, false if it is inconsistent
+        // and should be skipped.
+        bool trackMotion(const MotionEntry* entry, int32_t action, int32_t flags);
+
+        // Synthesizes cancelation events for the current state and resets the tracked state.
+        void synthesizeCancelationEvents(nsecs_t currentTime,
+                Vector<EventEntry*>& outEvents, const CancelationOptions& options);
+
+        // Clears the current state.
+        void clear();
+
+        // Copies pointer-related parts of the input state to another instance.
+        void copyPointerStateTo(InputState& other) const;
+
+        // Gets the fallback key associated with a keycode.
+        // Returns -1 if none.
+        // Returns AKEYCODE_UNKNOWN if we are only dispatching the unhandled key to the policy.
+        int32_t getFallbackKey(int32_t originalKeyCode);
+
+        // Sets the fallback key for a particular keycode.
+        void setFallbackKey(int32_t originalKeyCode, int32_t fallbackKeyCode);
+
+        // Removes the fallback key for a particular keycode.
+        void removeFallbackKey(int32_t originalKeyCode);
+
+        inline const KeyedVector<int32_t, int32_t>& getFallbackKeys() const {
+            return mFallbackKeys;
+        }
+
+    private:
+        struct KeyMemento {
+            int32_t deviceId;
+            uint32_t source;
+            int32_t keyCode;
+            int32_t scanCode;
+            int32_t metaState;
+            int32_t flags;
+            nsecs_t downTime;
+            uint32_t policyFlags;
+        };
+
+        struct MotionMemento {
+            int32_t deviceId;
+            uint32_t source;
+            int32_t flags;
+            float xPrecision;
+            float yPrecision;
+            nsecs_t downTime;
+            int32_t displayId;
+            uint32_t pointerCount;
+            PointerProperties pointerProperties[MAX_POINTERS];
+            PointerCoords pointerCoords[MAX_POINTERS];
+            bool hovering;
+            uint32_t policyFlags;
+
+            void setPointers(const MotionEntry* entry);
+        };
+
+        Vector<KeyMemento> mKeyMementos;
+        Vector<MotionMemento> mMotionMementos;
+        KeyedVector<int32_t, int32_t> mFallbackKeys;
+
+        ssize_t findKeyMemento(const KeyEntry* entry) const;
+        ssize_t findMotionMemento(const MotionEntry* entry, bool hovering) const;
+
+        void addKeyMemento(const KeyEntry* entry, int32_t flags);
+        void addMotionMemento(const MotionEntry* entry, int32_t flags, bool hovering);
+
+        static bool shouldCancelKey(const KeyMemento& memento,
+                const CancelationOptions& options);
+        static bool shouldCancelMotion(const MotionMemento& memento,
+                const CancelationOptions& options);
+    };
+
+    /* Manages the dispatch state associated with a single input channel. */
+    class Connection : public RefBase {
+    protected:
+        virtual ~Connection();
+
+    public:
+        enum Status {
+            // Everything is peachy.
+            STATUS_NORMAL,
+            // An unrecoverable communication error has occurred.
+            STATUS_BROKEN,
+            // The input channel has been unregistered.
+            STATUS_ZOMBIE
+        };
+
+        Status status;
+        sp<InputChannel> inputChannel; // never null
+        sp<InputWindowHandle> inputWindowHandle; // may be null
+        bool monitor;
+        InputPublisher inputPublisher;
+        InputState inputState;
+
+        // True if the socket is full and no further events can be published until
+        // the application consumes some of the input.
+        bool inputPublisherBlocked;
+
+        // Queue of events that need to be published to the connection.
+        Queue<DispatchEntry> outboundQueue;
+
+        // Queue of events that have been published to the connection but that have not
+        // yet received a "finished" response from the application.
+        Queue<DispatchEntry> waitQueue;
+
+        explicit Connection(const sp<InputChannel>& inputChannel,
+                const sp<InputWindowHandle>& inputWindowHandle, bool monitor);
+
+        inline const char* getInputChannelName() const { return inputChannel->getName().string(); }
+
+        const char* getWindowName() const;
+        const char* getStatusLabel() const;
+
+        DispatchEntry* findWaitQueueEntry(uint32_t seq);
+    };
+
+    enum DropReason {
+        DROP_REASON_NOT_DROPPED = 0,
+        DROP_REASON_POLICY = 1,
+        DROP_REASON_APP_SWITCH = 2,
+        DROP_REASON_DISABLED = 3,
+        DROP_REASON_BLOCKED = 4,
+        DROP_REASON_STALE = 5,
+    };
+
+    sp<InputDispatcherPolicyInterface> mPolicy;
+    InputDispatcherConfiguration mConfig;
+
+    Mutex mLock;
+
+    Condition mDispatcherIsAliveCondition;
+
+    sp<Looper> mLooper;
+
+    EventEntry* mPendingEvent;
+    Queue<EventEntry> mInboundQueue;
+    Queue<EventEntry> mRecentQueue;
+    Queue<CommandEntry> mCommandQueue;
+
+    DropReason mLastDropReason;
+
+    void dispatchOnceInnerLocked(nsecs_t* nextWakeupTime);
+
+    // Enqueues an inbound event.  Returns true if mLooper->wake() should be called.
+    bool enqueueInboundEventLocked(EventEntry* entry);
+
+    // Cleans up input state when dropping an inbound event.
+    void dropInboundEventLocked(EventEntry* entry, DropReason dropReason);
+
+    // Adds an event to a queue of recent events for debugging purposes.
+    void addRecentEventLocked(EventEntry* entry);
+
+    // App switch latency optimization.
+    bool mAppSwitchSawKeyDown;
+    nsecs_t mAppSwitchDueTime;
+
+    static bool isAppSwitchKeyCode(int32_t keyCode);
+    bool isAppSwitchKeyEventLocked(KeyEntry* keyEntry);
+    bool isAppSwitchPendingLocked();
+    void resetPendingAppSwitchLocked(bool handled);
+
+    // Stale event latency optimization.
+    static bool isStaleEventLocked(nsecs_t currentTime, EventEntry* entry);
+
+    // Blocked event latency optimization.  Drops old events when the user intends
+    // to transfer focus to a new application.
+    EventEntry* mNextUnblockedEvent;
+
+    sp<InputWindowHandle> findTouchedWindowAtLocked(int32_t displayId, int32_t x, int32_t y);
+
+    // All registered connections mapped by channel file descriptor.
+    KeyedVector<int, sp<Connection> > mConnectionsByFd;
+
+    ssize_t getConnectionIndexLocked(const sp<InputChannel>& inputChannel);
+
+    // Input channels that will receive a copy of all input events.
+    Vector<sp<InputChannel> > mMonitoringChannels;
+
+    // Event injection and synchronization.
+    Condition mInjectionResultAvailableCondition;
+    bool hasInjectionPermission(int32_t injectorPid, int32_t injectorUid);
+    void setInjectionResultLocked(EventEntry* entry, int32_t injectionResult);
+
+    Condition mInjectionSyncFinishedCondition;
+    void incrementPendingForegroundDispatchesLocked(EventEntry* entry);
+    void decrementPendingForegroundDispatchesLocked(EventEntry* entry);
+
+    // Key repeat tracking.
+    struct KeyRepeatState {
+        KeyEntry* lastKeyEntry; // or null if no repeat
+        nsecs_t nextRepeatTime;
+    } mKeyRepeatState;
+
+    void resetKeyRepeatLocked();
+    KeyEntry* synthesizeKeyRepeatLocked(nsecs_t currentTime);
+
+    // Key replacement tracking
+    struct KeyReplacement {
+        int32_t keyCode;
+        int32_t deviceId;
+        bool operator==(const KeyReplacement& rhs) const {
+            return keyCode == rhs.keyCode && deviceId == rhs.deviceId;
+        }
+        bool operator<(const KeyReplacement& rhs) const {
+            return keyCode != rhs.keyCode ? keyCode < rhs.keyCode : deviceId < rhs.deviceId;
+        }
+    };
+    // Maps the key code replaced, device id tuple to the key code it was replaced with
+    KeyedVector<KeyReplacement, int32_t> mReplacedKeys;
+
+    // Deferred command processing.
+    bool haveCommandsLocked() const;
+    bool runCommandsLockedInterruptible();
+    CommandEntry* postCommandLocked(Command command);
+
+    // Input filter processing.
+    bool shouldSendKeyToInputFilterLocked(const NotifyKeyArgs* args);
+    bool shouldSendMotionToInputFilterLocked(const NotifyMotionArgs* args);
+
+    // Inbound event processing.
+    void drainInboundQueueLocked();
+    void releasePendingEventLocked();
+    void releaseInboundEventLocked(EventEntry* entry);
+
+    // Dispatch state.
+    bool mDispatchEnabled;
+    bool mDispatchFrozen;
+    bool mInputFilterEnabled;
+
+    Vector<sp<InputWindowHandle> > mWindowHandles;
+
+    sp<InputWindowHandle> getWindowHandleLocked(const sp<InputChannel>& inputChannel) const;
+    bool hasWindowHandleLocked(const sp<InputWindowHandle>& windowHandle) const;
+
+    // Focus tracking for keys, trackball, etc.
+    sp<InputWindowHandle> mFocusedWindowHandle;
+
+    // Focus tracking for touch.
+    struct TouchedWindow {
+        sp<InputWindowHandle> windowHandle;
+        int32_t targetFlags;
+        BitSet32 pointerIds;        // zero unless target flag FLAG_SPLIT is set
+    };
+    struct TouchState {
+        bool down;
+        bool split;
+        int32_t deviceId; // id of the device that is currently down, others are rejected
+        uint32_t source;  // source of the device that is current down, others are rejected
+        int32_t displayId; // id to the display that currently has a touch, others are rejected
+        Vector<TouchedWindow> windows;
+
+        TouchState();
+        ~TouchState();
+        void reset();
+        void copyFrom(const TouchState& other);
+        void addOrUpdateWindow(const sp<InputWindowHandle>& windowHandle,
+                int32_t targetFlags, BitSet32 pointerIds);
+        void removeWindow(const sp<InputWindowHandle>& windowHandle);
+        void filterNonAsIsTouchWindows();
+        sp<InputWindowHandle> getFirstForegroundWindowHandle() const;
+        bool isSlippery() const;
+    };
+
+    KeyedVector<int32_t, TouchState> mTouchStatesByDisplay;
+    TouchState mTempTouchState;
+
+    // Focused application.
+    sp<InputApplicationHandle> mFocusedApplicationHandle;
+
+    // Dispatcher state at time of last ANR.
+    String8 mLastANRState;
+
+    // Dispatch inbound events.
+    bool dispatchConfigurationChangedLocked(
+            nsecs_t currentTime, ConfigurationChangedEntry* entry);
+    bool dispatchDeviceResetLocked(
+            nsecs_t currentTime, DeviceResetEntry* entry);
+    bool dispatchKeyLocked(
+            nsecs_t currentTime, KeyEntry* entry,
+            DropReason* dropReason, nsecs_t* nextWakeupTime);
+    bool dispatchMotionLocked(
+            nsecs_t currentTime, MotionEntry* entry,
+            DropReason* dropReason, nsecs_t* nextWakeupTime);
+    void dispatchEventLocked(nsecs_t currentTime, EventEntry* entry,
+            const Vector<InputTarget>& inputTargets);
+
+    void logOutboundKeyDetailsLocked(const char* prefix, const KeyEntry* entry);
+    void logOutboundMotionDetailsLocked(const char* prefix, const MotionEntry* entry);
+
+    // Keeping track of ANR timeouts.
+    enum InputTargetWaitCause {
+        INPUT_TARGET_WAIT_CAUSE_NONE,
+        INPUT_TARGET_WAIT_CAUSE_SYSTEM_NOT_READY,
+        INPUT_TARGET_WAIT_CAUSE_APPLICATION_NOT_READY,
+    };
+
+    InputTargetWaitCause mInputTargetWaitCause;
+    nsecs_t mInputTargetWaitStartTime;
+    nsecs_t mInputTargetWaitTimeoutTime;
+    bool mInputTargetWaitTimeoutExpired;
+    sp<InputApplicationHandle> mInputTargetWaitApplicationHandle;
+
+    // Contains the last window which received a hover event.
+    sp<InputWindowHandle> mLastHoverWindowHandle;
+
+    // Finding targets for input events.
+    int32_t handleTargetsNotReadyLocked(nsecs_t currentTime, const EventEntry* entry,
+            const sp<InputApplicationHandle>& applicationHandle,
+            const sp<InputWindowHandle>& windowHandle,
+            nsecs_t* nextWakeupTime, const char* reason);
+    void resumeAfterTargetsNotReadyTimeoutLocked(nsecs_t newTimeout,
+            const sp<InputChannel>& inputChannel);
+    nsecs_t getTimeSpentWaitingForApplicationLocked(nsecs_t currentTime);
+    void resetANRTimeoutsLocked();
+
+    int32_t findFocusedWindowTargetsLocked(nsecs_t currentTime, const EventEntry* entry,
+            Vector<InputTarget>& inputTargets, nsecs_t* nextWakeupTime);
+    int32_t findTouchedWindowTargetsLocked(nsecs_t currentTime, const MotionEntry* entry,
+            Vector<InputTarget>& inputTargets, nsecs_t* nextWakeupTime,
+            bool* outConflictingPointerActions);
+
+    void addWindowTargetLocked(const sp<InputWindowHandle>& windowHandle,
+            int32_t targetFlags, BitSet32 pointerIds, Vector<InputTarget>& inputTargets);
+    void addMonitoringTargetsLocked(Vector<InputTarget>& inputTargets);
+
+    void pokeUserActivityLocked(const EventEntry* eventEntry);
+    bool checkInjectionPermission(const sp<InputWindowHandle>& windowHandle,
+            const InjectionState* injectionState);
+    bool isWindowObscuredAtPointLocked(const sp<InputWindowHandle>& windowHandle,
+            int32_t x, int32_t y) const;
+    String8 getApplicationWindowLabelLocked(const sp<InputApplicationHandle>& applicationHandle,
+            const sp<InputWindowHandle>& windowHandle);
+
+    String8 checkWindowReadyForMoreInputLocked(nsecs_t currentTime,
+            const sp<InputWindowHandle>& windowHandle, const EventEntry* eventEntry,
+            const char* targetType);
+
+    // Manage the dispatch cycle for a single connection.
+    // These methods are deliberately not Interruptible because doing all of the work
+    // with the mutex held makes it easier to ensure that connection invariants are maintained.
+    // If needed, the methods post commands to run later once the critical bits are done.
+    void prepareDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection,
+            EventEntry* eventEntry, const InputTarget* inputTarget);
+    void enqueueDispatchEntriesLocked(nsecs_t currentTime, const sp<Connection>& connection,
+            EventEntry* eventEntry, const InputTarget* inputTarget);
+    void enqueueDispatchEntryLocked(const sp<Connection>& connection,
+            EventEntry* eventEntry, const InputTarget* inputTarget, int32_t dispatchMode);
+    void startDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection);
+    void finishDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection,
+            uint32_t seq, bool handled);
+    void abortBrokenDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection,
+            bool notify);
+    void drainDispatchQueueLocked(Queue<DispatchEntry>* queue);
+    void releaseDispatchEntryLocked(DispatchEntry* dispatchEntry);
+    static int handleReceiveCallback(int fd, int events, void* data);
+
+    void synthesizeCancelationEventsForAllConnectionsLocked(
+            const CancelationOptions& options);
+    void synthesizeCancelationEventsForMonitorsLocked(const CancelationOptions& options);
+    void synthesizeCancelationEventsForInputChannelLocked(const sp<InputChannel>& channel,
+            const CancelationOptions& options);
+    void synthesizeCancelationEventsForConnectionLocked(const sp<Connection>& connection,
+            const CancelationOptions& options);
+
+    // Splitting motion events across windows.
+    MotionEntry* splitMotionEvent(const MotionEntry* originalMotionEntry, BitSet32 pointerIds);
+
+    // Reset and drop everything the dispatcher is doing.
+    void resetAndDropEverythingLocked(const char* reason);
+
+    // Dump state.
+    void dumpDispatchStateLocked(String8& dump);
+    void logDispatchStateLocked();
+
+    // Registration.
+    void removeMonitorChannelLocked(const sp<InputChannel>& inputChannel);
+    status_t unregisterInputChannelLocked(const sp<InputChannel>& inputChannel, bool notify);
+
+    // Add or remove a connection to the mActiveConnections vector.
+    void activateConnectionLocked(Connection* connection);
+    void deactivateConnectionLocked(Connection* connection);
+
+    // Interesting events that we might like to log or tell the framework about.
+    void onDispatchCycleFinishedLocked(
+            nsecs_t currentTime, const sp<Connection>& connection, uint32_t seq, bool handled);
+    void onDispatchCycleBrokenLocked(
+            nsecs_t currentTime, const sp<Connection>& connection);
+    void onANRLocked(
+            nsecs_t currentTime, const sp<InputApplicationHandle>& applicationHandle,
+            const sp<InputWindowHandle>& windowHandle,
+            nsecs_t eventTime, nsecs_t waitStartTime, const char* reason);
+
+    // Outbound policy interactions.
+    void doNotifyConfigurationChangedInterruptible(CommandEntry* commandEntry);
+    void doNotifyInputChannelBrokenLockedInterruptible(CommandEntry* commandEntry);
+    void doNotifyANRLockedInterruptible(CommandEntry* commandEntry);
+    void doInterceptKeyBeforeDispatchingLockedInterruptible(CommandEntry* commandEntry);
+    void doDispatchCycleFinishedLockedInterruptible(CommandEntry* commandEntry);
+    bool afterKeyEventLockedInterruptible(const sp<Connection>& connection,
+            DispatchEntry* dispatchEntry, KeyEntry* keyEntry, bool handled);
+    bool afterMotionEventLockedInterruptible(const sp<Connection>& connection,
+            DispatchEntry* dispatchEntry, MotionEntry* motionEntry, bool handled);
+    void doPokeUserActivityLockedInterruptible(CommandEntry* commandEntry);
+    void initializeKeyEvent(KeyEvent* event, const KeyEntry* entry);
+
+    // Statistics gathering.
+    void updateDispatchStatisticsLocked(nsecs_t currentTime, const EventEntry* entry,
+            int32_t injectionResult, nsecs_t timeSpentWaitingForApplication);
+    void traceInboundQueueLengthLocked();
+    void traceOutboundQueueLengthLocked(const sp<Connection>& connection);
+    void traceWaitQueueLengthLocked(const sp<Connection>& connection);
+};
+
+/* Enqueues and dispatches input events, endlessly. */
+class InputDispatcherThread : public Thread {
+public:
+    explicit InputDispatcherThread(const sp<InputDispatcherInterface>& dispatcher);
+    ~InputDispatcherThread();
+
+private:
+    virtual bool threadLoop();
+
+    sp<InputDispatcherInterface> mDispatcher;
+};
+
+} // namespace android
+
+#endif // _UI_INPUT_DISPATCHER_H
diff --git a/services/inputflinger/InputListener.cpp b/services/inputflinger/InputListener.cpp
new file mode 100644
index 0000000..dded47d
--- /dev/null
+++ b/services/inputflinger/InputListener.cpp
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "InputListener"
+
+//#define LOG_NDEBUG 0
+
+#include "InputListener.h"
+
+#include <cutils/log.h>
+
+namespace android {
+
+// --- NotifyConfigurationChangedArgs ---
+
+NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs(nsecs_t eventTime) :
+        eventTime(eventTime) {
+}
+
+NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs(
+        const NotifyConfigurationChangedArgs& other) :
+        eventTime(other.eventTime) {
+}
+
+void NotifyConfigurationChangedArgs::notify(const sp<InputListenerInterface>& listener) const {
+    listener->notifyConfigurationChanged(this);
+}
+
+
+// --- NotifyKeyArgs ---
+
+NotifyKeyArgs::NotifyKeyArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source,
+        uint32_t policyFlags,
+        int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode,
+        int32_t metaState, nsecs_t downTime) :
+        eventTime(eventTime), deviceId(deviceId), source(source), policyFlags(policyFlags),
+        action(action), flags(flags), keyCode(keyCode), scanCode(scanCode),
+        metaState(metaState), downTime(downTime) {
+}
+
+NotifyKeyArgs::NotifyKeyArgs(const NotifyKeyArgs& other) :
+        eventTime(other.eventTime), deviceId(other.deviceId), source(other.source),
+        policyFlags(other.policyFlags),
+        action(other.action), flags(other.flags),
+        keyCode(other.keyCode), scanCode(other.scanCode),
+        metaState(other.metaState), downTime(other.downTime) {
+}
+
+void NotifyKeyArgs::notify(const sp<InputListenerInterface>& listener) const {
+    listener->notifyKey(this);
+}
+
+
+// --- NotifyMotionArgs ---
+
+NotifyMotionArgs::NotifyMotionArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source,
+        uint32_t policyFlags,
+        int32_t action, int32_t actionButton, int32_t flags, int32_t metaState,
+        int32_t buttonState, int32_t edgeFlags, int32_t displayId, uint32_t pointerCount,
+        const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
+        float xPrecision, float yPrecision, nsecs_t downTime) :
+        eventTime(eventTime), deviceId(deviceId), source(source), policyFlags(policyFlags),
+        action(action), actionButton(actionButton),
+        flags(flags), metaState(metaState), buttonState(buttonState),
+        edgeFlags(edgeFlags), displayId(displayId), pointerCount(pointerCount),
+        xPrecision(xPrecision), yPrecision(yPrecision), downTime(downTime) {
+    for (uint32_t i = 0; i < pointerCount; i++) {
+        this->pointerProperties[i].copyFrom(pointerProperties[i]);
+        this->pointerCoords[i].copyFrom(pointerCoords[i]);
+    }
+}
+
+NotifyMotionArgs::NotifyMotionArgs(const NotifyMotionArgs& other) :
+        eventTime(other.eventTime), deviceId(other.deviceId), source(other.source),
+        policyFlags(other.policyFlags),
+        action(other.action), actionButton(other.actionButton), flags(other.flags),
+        metaState(other.metaState), buttonState(other.buttonState),
+        edgeFlags(other.edgeFlags), displayId(other.displayId), pointerCount(other.pointerCount),
+        xPrecision(other.xPrecision), yPrecision(other.yPrecision), downTime(other.downTime) {
+    for (uint32_t i = 0; i < pointerCount; i++) {
+        pointerProperties[i].copyFrom(other.pointerProperties[i]);
+        pointerCoords[i].copyFrom(other.pointerCoords[i]);
+    }
+}
+
+void NotifyMotionArgs::notify(const sp<InputListenerInterface>& listener) const {
+    listener->notifyMotion(this);
+}
+
+
+// --- NotifySwitchArgs ---
+
+NotifySwitchArgs::NotifySwitchArgs(nsecs_t eventTime, uint32_t policyFlags,
+        uint32_t switchValues, uint32_t switchMask) :
+        eventTime(eventTime), policyFlags(policyFlags),
+        switchValues(switchValues), switchMask(switchMask) {
+}
+
+NotifySwitchArgs::NotifySwitchArgs(const NotifySwitchArgs& other) :
+        eventTime(other.eventTime), policyFlags(other.policyFlags),
+        switchValues(other.switchValues), switchMask(other.switchMask) {
+}
+
+void NotifySwitchArgs::notify(const sp<InputListenerInterface>& listener) const {
+    listener->notifySwitch(this);
+}
+
+
+// --- NotifyDeviceResetArgs ---
+
+NotifyDeviceResetArgs::NotifyDeviceResetArgs(nsecs_t eventTime, int32_t deviceId) :
+        eventTime(eventTime), deviceId(deviceId) {
+}
+
+NotifyDeviceResetArgs::NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other) :
+        eventTime(other.eventTime), deviceId(other.deviceId) {
+}
+
+void NotifyDeviceResetArgs::notify(const sp<InputListenerInterface>& listener) const {
+    listener->notifyDeviceReset(this);
+}
+
+
+// --- QueuedInputListener ---
+
+QueuedInputListener::QueuedInputListener(const sp<InputListenerInterface>& innerListener) :
+        mInnerListener(innerListener) {
+}
+
+QueuedInputListener::~QueuedInputListener() {
+    size_t count = mArgsQueue.size();
+    for (size_t i = 0; i < count; i++) {
+        delete mArgsQueue[i];
+    }
+}
+
+void QueuedInputListener::notifyConfigurationChanged(
+        const NotifyConfigurationChangedArgs* args) {
+    mArgsQueue.push(new NotifyConfigurationChangedArgs(*args));
+}
+
+void QueuedInputListener::notifyKey(const NotifyKeyArgs* args) {
+    mArgsQueue.push(new NotifyKeyArgs(*args));
+}
+
+void QueuedInputListener::notifyMotion(const NotifyMotionArgs* args) {
+    mArgsQueue.push(new NotifyMotionArgs(*args));
+}
+
+void QueuedInputListener::notifySwitch(const NotifySwitchArgs* args) {
+    mArgsQueue.push(new NotifySwitchArgs(*args));
+}
+
+void QueuedInputListener::notifyDeviceReset(const NotifyDeviceResetArgs* args) {
+    mArgsQueue.push(new NotifyDeviceResetArgs(*args));
+}
+
+void QueuedInputListener::flush() {
+    size_t count = mArgsQueue.size();
+    for (size_t i = 0; i < count; i++) {
+        NotifyArgs* args = mArgsQueue[i];
+        args->notify(mInnerListener);
+        delete args;
+    }
+    mArgsQueue.clear();
+}
+
+
+} // namespace android
diff --git a/services/inputflinger/InputListener.h b/services/inputflinger/InputListener.h
new file mode 100644
index 0000000..1ec09ce
--- /dev/null
+++ b/services/inputflinger/InputListener.h
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _UI_INPUT_LISTENER_H
+#define _UI_INPUT_LISTENER_H
+
+#include <input/Input.h>
+#include <utils/RefBase.h>
+#include <utils/Vector.h>
+
+namespace android {
+
+class InputListenerInterface;
+
+
+/* Superclass of all input event argument objects */
+struct NotifyArgs {
+    virtual ~NotifyArgs() { }
+
+    virtual void notify(const sp<InputListenerInterface>& listener) const = 0;
+};
+
+
+/* Describes a configuration change event. */
+struct NotifyConfigurationChangedArgs : public NotifyArgs {
+    nsecs_t eventTime;
+
+    inline NotifyConfigurationChangedArgs() { }
+
+    NotifyConfigurationChangedArgs(nsecs_t eventTime);
+
+    NotifyConfigurationChangedArgs(const NotifyConfigurationChangedArgs& other);
+
+    virtual ~NotifyConfigurationChangedArgs() { }
+
+    virtual void notify(const sp<InputListenerInterface>& listener) const;
+};
+
+
+/* Describes a key event. */
+struct NotifyKeyArgs : public NotifyArgs {
+    nsecs_t eventTime;
+    int32_t deviceId;
+    uint32_t source;
+    uint32_t policyFlags;
+    int32_t action;
+    int32_t flags;
+    int32_t keyCode;
+    int32_t scanCode;
+    int32_t metaState;
+    nsecs_t downTime;
+
+    inline NotifyKeyArgs() { }
+
+    NotifyKeyArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source, uint32_t policyFlags,
+            int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode,
+            int32_t metaState, nsecs_t downTime);
+
+    NotifyKeyArgs(const NotifyKeyArgs& other);
+
+    virtual ~NotifyKeyArgs() { }
+
+    virtual void notify(const sp<InputListenerInterface>& listener) const;
+};
+
+
+/* Describes a motion event. */
+struct NotifyMotionArgs : public NotifyArgs {
+    nsecs_t eventTime;
+    int32_t deviceId;
+    uint32_t source;
+    uint32_t policyFlags;
+    int32_t action;
+    int32_t actionButton;
+    int32_t flags;
+    int32_t metaState;
+    int32_t buttonState;
+    int32_t edgeFlags;
+    int32_t displayId;
+    uint32_t pointerCount;
+    PointerProperties pointerProperties[MAX_POINTERS];
+    PointerCoords pointerCoords[MAX_POINTERS];
+    float xPrecision;
+    float yPrecision;
+    nsecs_t downTime;
+
+    inline NotifyMotionArgs() { }
+
+    NotifyMotionArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source, uint32_t policyFlags,
+            int32_t action, int32_t actionButton, int32_t flags,
+            int32_t metaState, int32_t buttonState,
+            int32_t edgeFlags, int32_t displayId, uint32_t pointerCount,
+            const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
+            float xPrecision, float yPrecision, nsecs_t downTime);
+
+    NotifyMotionArgs(const NotifyMotionArgs& other);
+
+    virtual ~NotifyMotionArgs() { }
+
+    virtual void notify(const sp<InputListenerInterface>& listener) const;
+};
+
+
+/* Describes a switch event. */
+struct NotifySwitchArgs : public NotifyArgs {
+    nsecs_t eventTime;
+    uint32_t policyFlags;
+    uint32_t switchValues;
+    uint32_t switchMask;
+
+    inline NotifySwitchArgs() { }
+
+    NotifySwitchArgs(nsecs_t eventTime, uint32_t policyFlags,
+            uint32_t switchValues, uint32_t switchMask);
+
+    NotifySwitchArgs(const NotifySwitchArgs& other);
+
+    virtual ~NotifySwitchArgs() { }
+
+    virtual void notify(const sp<InputListenerInterface>& listener) const;
+};
+
+
+/* Describes a device reset event, such as when a device is added,
+ * reconfigured, or removed. */
+struct NotifyDeviceResetArgs : public NotifyArgs {
+    nsecs_t eventTime;
+    int32_t deviceId;
+
+    inline NotifyDeviceResetArgs() { }
+
+    NotifyDeviceResetArgs(nsecs_t eventTime, int32_t deviceId);
+
+    NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other);
+
+    virtual ~NotifyDeviceResetArgs() { }
+
+    virtual void notify(const sp<InputListenerInterface>& listener) const;
+};
+
+
+/*
+ * The interface used by the InputReader to notify the InputListener about input events.
+ */
+class InputListenerInterface : public virtual RefBase {
+protected:
+    InputListenerInterface() { }
+    virtual ~InputListenerInterface() { }
+
+public:
+    virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) = 0;
+    virtual void notifyKey(const NotifyKeyArgs* args) = 0;
+    virtual void notifyMotion(const NotifyMotionArgs* args) = 0;
+    virtual void notifySwitch(const NotifySwitchArgs* args) = 0;
+    virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args) = 0;
+};
+
+
+/*
+ * An implementation of the listener interface that queues up and defers dispatch
+ * of decoded events until flushed.
+ */
+class QueuedInputListener : public InputListenerInterface {
+protected:
+    virtual ~QueuedInputListener();
+
+public:
+    QueuedInputListener(const sp<InputListenerInterface>& innerListener);
+
+    virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args);
+    virtual void notifyKey(const NotifyKeyArgs* args);
+    virtual void notifyMotion(const NotifyMotionArgs* args);
+    virtual void notifySwitch(const NotifySwitchArgs* args);
+    virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args);
+
+    void flush();
+
+private:
+    sp<InputListenerInterface> mInnerListener;
+    Vector<NotifyArgs*> mArgsQueue;
+};
+
+} // namespace android
+
+#endif // _UI_INPUT_LISTENER_H
diff --git a/services/inputflinger/InputManager.cpp b/services/inputflinger/InputManager.cpp
new file mode 100644
index 0000000..6a6547b
--- /dev/null
+++ b/services/inputflinger/InputManager.cpp
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "InputManager"
+
+//#define LOG_NDEBUG 0
+
+#include "InputManager.h"
+
+#include <cutils/log.h>
+
+namespace android {
+
+InputManager::InputManager(
+        const sp<EventHubInterface>& eventHub,
+        const sp<InputReaderPolicyInterface>& readerPolicy,
+        const sp<InputDispatcherPolicyInterface>& dispatcherPolicy) {
+    mDispatcher = new InputDispatcher(dispatcherPolicy);
+    mReader = new InputReader(eventHub, readerPolicy, mDispatcher);
+    initialize();
+}
+
+InputManager::InputManager(
+        const sp<InputReaderInterface>& reader,
+        const sp<InputDispatcherInterface>& dispatcher) :
+        mReader(reader),
+        mDispatcher(dispatcher) {
+    initialize();
+}
+
+InputManager::~InputManager() {
+    stop();
+}
+
+void InputManager::initialize() {
+    mReaderThread = new InputReaderThread(mReader);
+    mDispatcherThread = new InputDispatcherThread(mDispatcher);
+}
+
+status_t InputManager::start() {
+    status_t result = mDispatcherThread->run("InputDispatcher", PRIORITY_URGENT_DISPLAY);
+    if (result) {
+        ALOGE("Could not start InputDispatcher thread due to error %d.", result);
+        return result;
+    }
+
+    result = mReaderThread->run("InputReader", PRIORITY_URGENT_DISPLAY);
+    if (result) {
+        ALOGE("Could not start InputReader thread due to error %d.", result);
+
+        mDispatcherThread->requestExit();
+        return result;
+    }
+
+    return OK;
+}
+
+status_t InputManager::stop() {
+    status_t result = mReaderThread->requestExitAndWait();
+    if (result) {
+        ALOGW("Could not stop InputReader thread due to error %d.", result);
+    }
+
+    result = mDispatcherThread->requestExitAndWait();
+    if (result) {
+        ALOGW("Could not stop InputDispatcher thread due to error %d.", result);
+    }
+
+    return OK;
+}
+
+sp<InputReaderInterface> InputManager::getReader() {
+    return mReader;
+}
+
+sp<InputDispatcherInterface> InputManager::getDispatcher() {
+    return mDispatcher;
+}
+
+} // namespace android
diff --git a/services/inputflinger/InputManager.h b/services/inputflinger/InputManager.h
new file mode 100644
index 0000000..a213b2d
--- /dev/null
+++ b/services/inputflinger/InputManager.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _UI_INPUT_MANAGER_H
+#define _UI_INPUT_MANAGER_H
+
+/**
+ * Native input manager.
+ */
+
+#include "EventHub.h"
+#include "InputReader.h"
+#include "InputDispatcher.h"
+
+#include <input/Input.h>
+#include <input/InputTransport.h>
+#include <utils/Errors.h>
+#include <utils/Vector.h>
+#include <utils/Timers.h>
+#include <utils/RefBase.h>
+#include <utils/String8.h>
+
+namespace android {
+
+/*
+ * The input manager is the core of the system event processing.
+ *
+ * The input manager uses two threads.
+ *
+ * 1. The InputReaderThread (called "InputReader") reads and preprocesses raw input events,
+ *    applies policy, and posts messages to a queue managed by the DispatcherThread.
+ * 2. The InputDispatcherThread (called "InputDispatcher") thread waits for new events on the
+ *    queue and asynchronously dispatches them to applications.
+ *
+ * By design, the InputReaderThread class and InputDispatcherThread class do not share any
+ * internal state.  Moreover, all communication is done one way from the InputReaderThread
+ * into the InputDispatcherThread and never the reverse.  Both classes may interact with the
+ * InputDispatchPolicy, however.
+ *
+ * The InputManager class never makes any calls into Java itself.  Instead, the
+ * InputDispatchPolicy is responsible for performing all external interactions with the
+ * system, including calling DVM services.
+ */
+class InputManagerInterface : public virtual RefBase {
+protected:
+    InputManagerInterface() { }
+    virtual ~InputManagerInterface() { }
+
+public:
+    /* Starts the input manager threads. */
+    virtual status_t start() = 0;
+
+    /* Stops the input manager threads and waits for them to exit. */
+    virtual status_t stop() = 0;
+
+    /* Gets the input reader. */
+    virtual sp<InputReaderInterface> getReader() = 0;
+
+    /* Gets the input dispatcher. */
+    virtual sp<InputDispatcherInterface> getDispatcher() = 0;
+};
+
+class InputManager : public InputManagerInterface {
+protected:
+    virtual ~InputManager();
+
+public:
+    InputManager(
+            const sp<EventHubInterface>& eventHub,
+            const sp<InputReaderPolicyInterface>& readerPolicy,
+            const sp<InputDispatcherPolicyInterface>& dispatcherPolicy);
+
+    // (used for testing purposes)
+    InputManager(
+            const sp<InputReaderInterface>& reader,
+            const sp<InputDispatcherInterface>& dispatcher);
+
+    virtual status_t start();
+    virtual status_t stop();
+
+    virtual sp<InputReaderInterface> getReader();
+    virtual sp<InputDispatcherInterface> getDispatcher();
+
+private:
+    sp<InputReaderInterface> mReader;
+    sp<InputReaderThread> mReaderThread;
+
+    sp<InputDispatcherInterface> mDispatcher;
+    sp<InputDispatcherThread> mDispatcherThread;
+
+    void initialize();
+};
+
+} // namespace android
+
+#endif // _UI_INPUT_MANAGER_H
diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp
new file mode 100644
index 0000000..b2cbfe8
--- /dev/null
+++ b/services/inputflinger/InputReader.cpp
@@ -0,0 +1,7070 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "InputReader"
+
+//#define LOG_NDEBUG 0
+
+// Log debug messages for each raw event received from the EventHub.
+#define DEBUG_RAW_EVENTS 0
+
+// Log debug messages about touch screen filtering hacks.
+#define DEBUG_HACKS 0
+
+// Log debug messages about virtual key processing.
+#define DEBUG_VIRTUAL_KEYS 0
+
+// Log debug messages about pointers.
+#define DEBUG_POINTERS 0
+
+// Log debug messages about pointer assignment calculations.
+#define DEBUG_POINTER_ASSIGNMENT 0
+
+// Log debug messages about gesture detection.
+#define DEBUG_GESTURES 0
+
+// Log debug messages about the vibrator.
+#define DEBUG_VIBRATOR 0
+
+// Log debug messages about fusing stylus data.
+#define DEBUG_STYLUS_FUSION 0
+
+#include "InputReader.h"
+
+#include <cutils/log.h>
+#include <input/Keyboard.h>
+#include <input/VirtualKeyMap.h>
+
+#include <inttypes.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <limits.h>
+#include <math.h>
+
+#define INDENT "  "
+#define INDENT2 "    "
+#define INDENT3 "      "
+#define INDENT4 "        "
+#define INDENT5 "          "
+
+namespace android {
+
+// --- Constants ---
+
+// Maximum number of slots supported when using the slot-based Multitouch Protocol B.
+static const size_t MAX_SLOTS = 32;
+
+// Maximum amount of latency to add to touch events while waiting for data from an
+// external stylus.
+static const nsecs_t EXTERNAL_STYLUS_DATA_TIMEOUT = ms2ns(72);
+
+// Maximum amount of time to wait on touch data before pushing out new pressure data.
+static const nsecs_t TOUCH_DATA_TIMEOUT = ms2ns(20);
+
+// Artificial latency on synthetic events created from stylus data without corresponding touch
+// data.
+static const nsecs_t STYLUS_DATA_LATENCY = ms2ns(10);
+
+// --- Static Functions ---
+
+template<typename T>
+inline static T abs(const T& value) {
+    return value < 0 ? - value : value;
+}
+
+template<typename T>
+inline static T min(const T& a, const T& b) {
+    return a < b ? a : b;
+}
+
+template<typename T>
+inline static void swap(T& a, T& b) {
+    T temp = a;
+    a = b;
+    b = temp;
+}
+
+inline static float avg(float x, float y) {
+    return (x + y) / 2;
+}
+
+inline static float distance(float x1, float y1, float x2, float y2) {
+    return hypotf(x1 - x2, y1 - y2);
+}
+
+inline static int32_t signExtendNybble(int32_t value) {
+    return value >= 8 ? value - 16 : value;
+}
+
+static inline const char* toString(bool value) {
+    return value ? "true" : "false";
+}
+
+static int32_t rotateValueUsingRotationMap(int32_t value, int32_t orientation,
+        const int32_t map[][4], size_t mapSize) {
+    if (orientation != DISPLAY_ORIENTATION_0) {
+        for (size_t i = 0; i < mapSize; i++) {
+            if (value == map[i][0]) {
+                return map[i][orientation];
+            }
+        }
+    }
+    return value;
+}
+
+static const int32_t keyCodeRotationMap[][4] = {
+        // key codes enumerated counter-clockwise with the original (unrotated) key first
+        // no rotation,        90 degree rotation,  180 degree rotation, 270 degree rotation
+        { AKEYCODE_DPAD_DOWN,   AKEYCODE_DPAD_RIGHT,  AKEYCODE_DPAD_UP,     AKEYCODE_DPAD_LEFT },
+        { AKEYCODE_DPAD_RIGHT,  AKEYCODE_DPAD_UP,     AKEYCODE_DPAD_LEFT,   AKEYCODE_DPAD_DOWN },
+        { AKEYCODE_DPAD_UP,     AKEYCODE_DPAD_LEFT,   AKEYCODE_DPAD_DOWN,   AKEYCODE_DPAD_RIGHT },
+        { AKEYCODE_DPAD_LEFT,   AKEYCODE_DPAD_DOWN,   AKEYCODE_DPAD_RIGHT,  AKEYCODE_DPAD_UP },
+};
+static const size_t keyCodeRotationMapSize =
+        sizeof(keyCodeRotationMap) / sizeof(keyCodeRotationMap[0]);
+
+static int32_t rotateKeyCode(int32_t keyCode, int32_t orientation) {
+    return rotateValueUsingRotationMap(keyCode, orientation,
+            keyCodeRotationMap, keyCodeRotationMapSize);
+}
+
+static void rotateDelta(int32_t orientation, float* deltaX, float* deltaY) {
+    float temp;
+    switch (orientation) {
+    case DISPLAY_ORIENTATION_90:
+        temp = *deltaX;
+        *deltaX = *deltaY;
+        *deltaY = -temp;
+        break;
+
+    case DISPLAY_ORIENTATION_180:
+        *deltaX = -*deltaX;
+        *deltaY = -*deltaY;
+        break;
+
+    case DISPLAY_ORIENTATION_270:
+        temp = *deltaX;
+        *deltaX = -*deltaY;
+        *deltaY = temp;
+        break;
+    }
+}
+
+static inline bool sourcesMatchMask(uint32_t sources, uint32_t sourceMask) {
+    return (sources & sourceMask & ~ AINPUT_SOURCE_CLASS_MASK) != 0;
+}
+
+// Returns true if the pointer should be reported as being down given the specified
+// button states.  This determines whether the event is reported as a touch event.
+static bool isPointerDown(int32_t buttonState) {
+    return buttonState &
+            (AMOTION_EVENT_BUTTON_PRIMARY | AMOTION_EVENT_BUTTON_SECONDARY
+                    | AMOTION_EVENT_BUTTON_TERTIARY);
+}
+
+static float calculateCommonVector(float a, float b) {
+    if (a > 0 && b > 0) {
+        return a < b ? a : b;
+    } else if (a < 0 && b < 0) {
+        return a > b ? a : b;
+    } else {
+        return 0;
+    }
+}
+
+static void synthesizeButtonKey(InputReaderContext* context, int32_t action,
+        nsecs_t when, int32_t deviceId, uint32_t source,
+        uint32_t policyFlags, int32_t lastButtonState, int32_t currentButtonState,
+        int32_t buttonState, int32_t keyCode) {
+    if (
+            (action == AKEY_EVENT_ACTION_DOWN
+                    && !(lastButtonState & buttonState)
+                    && (currentButtonState & buttonState))
+            || (action == AKEY_EVENT_ACTION_UP
+                    && (lastButtonState & buttonState)
+                    && !(currentButtonState & buttonState))) {
+        NotifyKeyArgs args(when, deviceId, source, policyFlags,
+                action, 0, keyCode, 0, context->getGlobalMetaState(), when);
+        context->getListener()->notifyKey(&args);
+    }
+}
+
+static void synthesizeButtonKeys(InputReaderContext* context, int32_t action,
+        nsecs_t when, int32_t deviceId, uint32_t source,
+        uint32_t policyFlags, int32_t lastButtonState, int32_t currentButtonState) {
+    synthesizeButtonKey(context, action, when, deviceId, source, policyFlags,
+            lastButtonState, currentButtonState,
+            AMOTION_EVENT_BUTTON_BACK, AKEYCODE_BACK);
+    synthesizeButtonKey(context, action, when, deviceId, source, policyFlags,
+            lastButtonState, currentButtonState,
+            AMOTION_EVENT_BUTTON_FORWARD, AKEYCODE_FORWARD);
+}
+
+
+// --- InputReaderConfiguration ---
+
+bool InputReaderConfiguration::getDisplayInfo(bool external, DisplayViewport* outViewport) const {
+    const DisplayViewport& viewport = external ? mExternalDisplay : mInternalDisplay;
+    if (viewport.displayId >= 0) {
+        *outViewport = viewport;
+        return true;
+    }
+    return false;
+}
+
+void InputReaderConfiguration::setDisplayInfo(bool external, const DisplayViewport& viewport) {
+    DisplayViewport& v = external ? mExternalDisplay : mInternalDisplay;
+    v = viewport;
+}
+
+
+// -- TouchAffineTransformation --
+void TouchAffineTransformation::applyTo(float& x, float& y) const {
+    float newX, newY;
+    newX = x * x_scale + y * x_ymix + x_offset;
+    newY = x * y_xmix + y * y_scale + y_offset;
+
+    x = newX;
+    y = newY;
+}
+
+
+// --- InputReader ---
+
+InputReader::InputReader(const sp<EventHubInterface>& eventHub,
+        const sp<InputReaderPolicyInterface>& policy,
+        const sp<InputListenerInterface>& listener) :
+        mContext(this), mEventHub(eventHub), mPolicy(policy),
+        mGlobalMetaState(0), mGeneration(1),
+        mDisableVirtualKeysTimeout(LLONG_MIN), mNextTimeout(LLONG_MAX),
+        mConfigurationChangesToRefresh(0) {
+    mQueuedListener = new QueuedInputListener(listener);
+
+    { // acquire lock
+        AutoMutex _l(mLock);
+
+        refreshConfigurationLocked(0);
+        updateGlobalMetaStateLocked();
+    } // release lock
+}
+
+InputReader::~InputReader() {
+    for (size_t i = 0; i < mDevices.size(); i++) {
+        delete mDevices.valueAt(i);
+    }
+}
+
+void InputReader::loopOnce() {
+    int32_t oldGeneration;
+    int32_t timeoutMillis;
+    bool inputDevicesChanged = false;
+    Vector<InputDeviceInfo> inputDevices;
+    { // acquire lock
+        AutoMutex _l(mLock);
+
+        oldGeneration = mGeneration;
+        timeoutMillis = -1;
+
+        uint32_t changes = mConfigurationChangesToRefresh;
+        if (changes) {
+            mConfigurationChangesToRefresh = 0;
+            timeoutMillis = 0;
+            refreshConfigurationLocked(changes);
+        } else if (mNextTimeout != LLONG_MAX) {
+            nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);
+            timeoutMillis = toMillisecondTimeoutDelay(now, mNextTimeout);
+        }
+    } // release lock
+
+    size_t count = mEventHub->getEvents(timeoutMillis, mEventBuffer, EVENT_BUFFER_SIZE);
+
+    { // acquire lock
+        AutoMutex _l(mLock);
+        mReaderIsAliveCondition.broadcast();
+
+        if (count) {
+            processEventsLocked(mEventBuffer, count);
+        }
+
+        if (mNextTimeout != LLONG_MAX) {
+            nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);
+            if (now >= mNextTimeout) {
+#if DEBUG_RAW_EVENTS
+                ALOGD("Timeout expired, latency=%0.3fms", (now - mNextTimeout) * 0.000001f);
+#endif
+                mNextTimeout = LLONG_MAX;
+                timeoutExpiredLocked(now);
+            }
+        }
+
+        if (oldGeneration != mGeneration) {
+            inputDevicesChanged = true;
+            getInputDevicesLocked(inputDevices);
+        }
+    } // release lock
+
+    // Send out a message that the describes the changed input devices.
+    if (inputDevicesChanged) {
+        mPolicy->notifyInputDevicesChanged(inputDevices);
+    }
+
+    // Flush queued events out to the listener.
+    // This must happen outside of the lock because the listener could potentially call
+    // back into the InputReader's methods, such as getScanCodeState, or become blocked
+    // on another thread similarly waiting to acquire the InputReader lock thereby
+    // resulting in a deadlock.  This situation is actually quite plausible because the
+    // listener is actually the input dispatcher, which calls into the window manager,
+    // which occasionally calls into the input reader.
+    mQueuedListener->flush();
+}
+
+void InputReader::processEventsLocked(const RawEvent* rawEvents, size_t count) {
+    for (const RawEvent* rawEvent = rawEvents; count;) {
+        int32_t type = rawEvent->type;
+        size_t batchSize = 1;
+        if (type < EventHubInterface::FIRST_SYNTHETIC_EVENT) {
+            int32_t deviceId = rawEvent->deviceId;
+            while (batchSize < count) {
+                if (rawEvent[batchSize].type >= EventHubInterface::FIRST_SYNTHETIC_EVENT
+                        || rawEvent[batchSize].deviceId != deviceId) {
+                    break;
+                }
+                batchSize += 1;
+            }
+#if DEBUG_RAW_EVENTS
+            ALOGD("BatchSize: %d Count: %d", batchSize, count);
+#endif
+            processEventsForDeviceLocked(deviceId, rawEvent, batchSize);
+        } else {
+            switch (rawEvent->type) {
+            case EventHubInterface::DEVICE_ADDED:
+                addDeviceLocked(rawEvent->when, rawEvent->deviceId);
+                break;
+            case EventHubInterface::DEVICE_REMOVED:
+                removeDeviceLocked(rawEvent->when, rawEvent->deviceId);
+                break;
+            case EventHubInterface::FINISHED_DEVICE_SCAN:
+                handleConfigurationChangedLocked(rawEvent->when);
+                break;
+            default:
+                ALOG_ASSERT(false); // can't happen
+                break;
+            }
+        }
+        count -= batchSize;
+        rawEvent += batchSize;
+    }
+}
+
+void InputReader::addDeviceLocked(nsecs_t when, int32_t deviceId) {
+    ssize_t deviceIndex = mDevices.indexOfKey(deviceId);
+    if (deviceIndex >= 0) {
+        ALOGW("Ignoring spurious device added event for deviceId %d.", deviceId);
+        return;
+    }
+
+    InputDeviceIdentifier identifier = mEventHub->getDeviceIdentifier(deviceId);
+    uint32_t classes = mEventHub->getDeviceClasses(deviceId);
+    int32_t controllerNumber = mEventHub->getDeviceControllerNumber(deviceId);
+
+    InputDevice* device = createDeviceLocked(deviceId, controllerNumber, identifier, classes);
+    device->configure(when, &mConfig, 0);
+    device->reset(when);
+
+    if (device->isIgnored()) {
+        ALOGI("Device added: id=%d, name='%s' (ignored non-input device)", deviceId,
+                identifier.name.string());
+    } else {
+        ALOGI("Device added: id=%d, name='%s', sources=0x%08x", deviceId,
+                identifier.name.string(), device->getSources());
+    }
+
+    mDevices.add(deviceId, device);
+    bumpGenerationLocked();
+
+    if (device->getClasses() & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS) {
+        notifyExternalStylusPresenceChanged();
+    }
+}
+
+void InputReader::removeDeviceLocked(nsecs_t when, int32_t deviceId) {
+    InputDevice* device = NULL;
+    ssize_t deviceIndex = mDevices.indexOfKey(deviceId);
+    if (deviceIndex < 0) {
+        ALOGW("Ignoring spurious device removed event for deviceId %d.", deviceId);
+        return;
+    }
+
+    device = mDevices.valueAt(deviceIndex);
+    mDevices.removeItemsAt(deviceIndex, 1);
+    bumpGenerationLocked();
+
+    if (device->isIgnored()) {
+        ALOGI("Device removed: id=%d, name='%s' (ignored non-input device)",
+                device->getId(), device->getName().string());
+    } else {
+        ALOGI("Device removed: id=%d, name='%s', sources=0x%08x",
+                device->getId(), device->getName().string(), device->getSources());
+    }
+
+    if (device->getClasses() & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS) {
+        notifyExternalStylusPresenceChanged();
+    }
+
+    device->reset(when);
+    delete device;
+}
+
+InputDevice* InputReader::createDeviceLocked(int32_t deviceId, int32_t controllerNumber,
+        const InputDeviceIdentifier& identifier, uint32_t classes) {
+    InputDevice* device = new InputDevice(&mContext, deviceId, bumpGenerationLocked(),
+            controllerNumber, identifier, classes);
+
+    // External devices.
+    if (classes & INPUT_DEVICE_CLASS_EXTERNAL) {
+        device->setExternal(true);
+    }
+
+    // Devices with mics.
+    if (classes & INPUT_DEVICE_CLASS_MIC) {
+        device->setMic(true);
+    }
+
+    // Switch-like devices.
+    if (classes & INPUT_DEVICE_CLASS_SWITCH) {
+        device->addMapper(new SwitchInputMapper(device));
+    }
+
+    // Vibrator-like devices.
+    if (classes & INPUT_DEVICE_CLASS_VIBRATOR) {
+        device->addMapper(new VibratorInputMapper(device));
+    }
+
+    // Keyboard-like devices.
+    uint32_t keyboardSource = 0;
+    int32_t keyboardType = AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC;
+    if (classes & INPUT_DEVICE_CLASS_KEYBOARD) {
+        keyboardSource |= AINPUT_SOURCE_KEYBOARD;
+    }
+    if (classes & INPUT_DEVICE_CLASS_ALPHAKEY) {
+        keyboardType = AINPUT_KEYBOARD_TYPE_ALPHABETIC;
+    }
+    if (classes & INPUT_DEVICE_CLASS_DPAD) {
+        keyboardSource |= AINPUT_SOURCE_DPAD;
+    }
+    if (classes & INPUT_DEVICE_CLASS_GAMEPAD) {
+        keyboardSource |= AINPUT_SOURCE_GAMEPAD;
+    }
+
+    if (keyboardSource != 0) {
+        device->addMapper(new KeyboardInputMapper(device, keyboardSource, keyboardType));
+    }
+
+    // Cursor-like devices.
+    if (classes & INPUT_DEVICE_CLASS_CURSOR) {
+        device->addMapper(new CursorInputMapper(device));
+    }
+
+    // Touchscreens and touchpad devices.
+    if (classes & INPUT_DEVICE_CLASS_TOUCH_MT) {
+        device->addMapper(new MultiTouchInputMapper(device));
+    } else if (classes & INPUT_DEVICE_CLASS_TOUCH) {
+        device->addMapper(new SingleTouchInputMapper(device));
+    }
+
+    // Joystick-like devices.
+    if (classes & INPUT_DEVICE_CLASS_JOYSTICK) {
+        device->addMapper(new JoystickInputMapper(device));
+    }
+
+    // External stylus-like devices.
+    if (classes & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS) {
+        device->addMapper(new ExternalStylusInputMapper(device));
+    }
+
+    return device;
+}
+
+void InputReader::processEventsForDeviceLocked(int32_t deviceId,
+        const RawEvent* rawEvents, size_t count) {
+    ssize_t deviceIndex = mDevices.indexOfKey(deviceId);
+    if (deviceIndex < 0) {
+        ALOGW("Discarding event for unknown deviceId %d.", deviceId);
+        return;
+    }
+
+    InputDevice* device = mDevices.valueAt(deviceIndex);
+    if (device->isIgnored()) {
+        //ALOGD("Discarding event for ignored deviceId %d.", deviceId);
+        return;
+    }
+
+    device->process(rawEvents, count);
+}
+
+void InputReader::timeoutExpiredLocked(nsecs_t when) {
+    for (size_t i = 0; i < mDevices.size(); i++) {
+        InputDevice* device = mDevices.valueAt(i);
+        if (!device->isIgnored()) {
+            device->timeoutExpired(when);
+        }
+    }
+}
+
+void InputReader::handleConfigurationChangedLocked(nsecs_t when) {
+    // Reset global meta state because it depends on the list of all configured devices.
+    updateGlobalMetaStateLocked();
+
+    // Enqueue configuration changed.
+    NotifyConfigurationChangedArgs args(when);
+    mQueuedListener->notifyConfigurationChanged(&args);
+}
+
+void InputReader::refreshConfigurationLocked(uint32_t changes) {
+    mPolicy->getReaderConfiguration(&mConfig);
+    mEventHub->setExcludedDevices(mConfig.excludedDeviceNames);
+
+    if (changes) {
+        ALOGI("Reconfiguring input devices.  changes=0x%08x", changes);
+        nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);
+
+        if (changes & InputReaderConfiguration::CHANGE_MUST_REOPEN) {
+            mEventHub->requestReopenDevices();
+        } else {
+            for (size_t i = 0; i < mDevices.size(); i++) {
+                InputDevice* device = mDevices.valueAt(i);
+                device->configure(now, &mConfig, changes);
+            }
+        }
+    }
+}
+
+void InputReader::updateGlobalMetaStateLocked() {
+    mGlobalMetaState = 0;
+
+    for (size_t i = 0; i < mDevices.size(); i++) {
+        InputDevice* device = mDevices.valueAt(i);
+        mGlobalMetaState |= device->getMetaState();
+    }
+}
+
+int32_t InputReader::getGlobalMetaStateLocked() {
+    return mGlobalMetaState;
+}
+
+void InputReader::notifyExternalStylusPresenceChanged() {
+    refreshConfigurationLocked(InputReaderConfiguration::CHANGE_EXTERNAL_STYLUS_PRESENCE);
+}
+
+void InputReader::getExternalStylusDevicesLocked(Vector<InputDeviceInfo>& outDevices) {
+    for (size_t i = 0; i < mDevices.size(); i++) {
+        InputDevice* device = mDevices.valueAt(i);
+        if (device->getClasses() & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS && !device->isIgnored()) {
+            outDevices.push();
+            device->getDeviceInfo(&outDevices.editTop());
+        }
+    }
+}
+
+void InputReader::dispatchExternalStylusState(const StylusState& state) {
+    for (size_t i = 0; i < mDevices.size(); i++) {
+        InputDevice* device = mDevices.valueAt(i);
+        device->updateExternalStylusState(state);
+    }
+}
+
+void InputReader::disableVirtualKeysUntilLocked(nsecs_t time) {
+    mDisableVirtualKeysTimeout = time;
+}
+
+bool InputReader::shouldDropVirtualKeyLocked(nsecs_t now,
+        InputDevice* device, int32_t keyCode, int32_t scanCode) {
+    if (now < mDisableVirtualKeysTimeout) {
+        ALOGI("Dropping virtual key from device %s because virtual keys are "
+                "temporarily disabled for the next %0.3fms.  keyCode=%d, scanCode=%d",
+                device->getName().string(),
+                (mDisableVirtualKeysTimeout - now) * 0.000001,
+                keyCode, scanCode);
+        return true;
+    } else {
+        return false;
+    }
+}
+
+void InputReader::fadePointerLocked() {
+    for (size_t i = 0; i < mDevices.size(); i++) {
+        InputDevice* device = mDevices.valueAt(i);
+        device->fadePointer();
+    }
+}
+
+void InputReader::requestTimeoutAtTimeLocked(nsecs_t when) {
+    if (when < mNextTimeout) {
+        mNextTimeout = when;
+        mEventHub->wake();
+    }
+}
+
+int32_t InputReader::bumpGenerationLocked() {
+    return ++mGeneration;
+}
+
+void InputReader::getInputDevices(Vector<InputDeviceInfo>& outInputDevices) {
+    AutoMutex _l(mLock);
+    getInputDevicesLocked(outInputDevices);
+}
+
+void InputReader::getInputDevicesLocked(Vector<InputDeviceInfo>& outInputDevices) {
+    outInputDevices.clear();
+
+    size_t numDevices = mDevices.size();
+    for (size_t i = 0; i < numDevices; i++) {
+        InputDevice* device = mDevices.valueAt(i);
+        if (!device->isIgnored()) {
+            outInputDevices.push();
+            device->getDeviceInfo(&outInputDevices.editTop());
+        }
+    }
+}
+
+int32_t InputReader::getKeyCodeState(int32_t deviceId, uint32_t sourceMask,
+        int32_t keyCode) {
+    AutoMutex _l(mLock);
+
+    return getStateLocked(deviceId, sourceMask, keyCode, &InputDevice::getKeyCodeState);
+}
+
+int32_t InputReader::getScanCodeState(int32_t deviceId, uint32_t sourceMask,
+        int32_t scanCode) {
+    AutoMutex _l(mLock);
+
+    return getStateLocked(deviceId, sourceMask, scanCode, &InputDevice::getScanCodeState);
+}
+
+int32_t InputReader::getSwitchState(int32_t deviceId, uint32_t sourceMask, int32_t switchCode) {
+    AutoMutex _l(mLock);
+
+    return getStateLocked(deviceId, sourceMask, switchCode, &InputDevice::getSwitchState);
+}
+
+int32_t InputReader::getStateLocked(int32_t deviceId, uint32_t sourceMask, int32_t code,
+        GetStateFunc getStateFunc) {
+    int32_t result = AKEY_STATE_UNKNOWN;
+    if (deviceId >= 0) {
+        ssize_t deviceIndex = mDevices.indexOfKey(deviceId);
+        if (deviceIndex >= 0) {
+            InputDevice* device = mDevices.valueAt(deviceIndex);
+            if (! device->isIgnored() && sourcesMatchMask(device->getSources(), sourceMask)) {
+                result = (device->*getStateFunc)(sourceMask, code);
+            }
+        }
+    } else {
+        size_t numDevices = mDevices.size();
+        for (size_t i = 0; i < numDevices; i++) {
+            InputDevice* device = mDevices.valueAt(i);
+            if (! device->isIgnored() && sourcesMatchMask(device->getSources(), sourceMask)) {
+                // If any device reports AKEY_STATE_DOWN or AKEY_STATE_VIRTUAL, return that
+                // value.  Otherwise, return AKEY_STATE_UP as long as one device reports it.
+                int32_t currentResult = (device->*getStateFunc)(sourceMask, code);
+                if (currentResult >= AKEY_STATE_DOWN) {
+                    return currentResult;
+                } else if (currentResult == AKEY_STATE_UP) {
+                    result = currentResult;
+                }
+            }
+        }
+    }
+    return result;
+}
+
+bool InputReader::hasKeys(int32_t deviceId, uint32_t sourceMask,
+        size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) {
+    AutoMutex _l(mLock);
+
+    memset(outFlags, 0, numCodes);
+    return markSupportedKeyCodesLocked(deviceId, sourceMask, numCodes, keyCodes, outFlags);
+}
+
+bool InputReader::markSupportedKeyCodesLocked(int32_t deviceId, uint32_t sourceMask,
+        size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) {
+    bool result = false;
+    if (deviceId >= 0) {
+        ssize_t deviceIndex = mDevices.indexOfKey(deviceId);
+        if (deviceIndex >= 0) {
+            InputDevice* device = mDevices.valueAt(deviceIndex);
+            if (! device->isIgnored() && sourcesMatchMask(device->getSources(), sourceMask)) {
+                result = device->markSupportedKeyCodes(sourceMask,
+                        numCodes, keyCodes, outFlags);
+            }
+        }
+    } else {
+        size_t numDevices = mDevices.size();
+        for (size_t i = 0; i < numDevices; i++) {
+            InputDevice* device = mDevices.valueAt(i);
+            if (! device->isIgnored() && sourcesMatchMask(device->getSources(), sourceMask)) {
+                result |= device->markSupportedKeyCodes(sourceMask,
+                        numCodes, keyCodes, outFlags);
+            }
+        }
+    }
+    return result;
+}
+
+void InputReader::requestRefreshConfiguration(uint32_t changes) {
+    AutoMutex _l(mLock);
+
+    if (changes) {
+        bool needWake = !mConfigurationChangesToRefresh;
+        mConfigurationChangesToRefresh |= changes;
+
+        if (needWake) {
+            mEventHub->wake();
+        }
+    }
+}
+
+void InputReader::vibrate(int32_t deviceId, const nsecs_t* pattern, size_t patternSize,
+        ssize_t repeat, int32_t token) {
+    AutoMutex _l(mLock);
+
+    ssize_t deviceIndex = mDevices.indexOfKey(deviceId);
+    if (deviceIndex >= 0) {
+        InputDevice* device = mDevices.valueAt(deviceIndex);
+        device->vibrate(pattern, patternSize, repeat, token);
+    }
+}
+
+void InputReader::cancelVibrate(int32_t deviceId, int32_t token) {
+    AutoMutex _l(mLock);
+
+    ssize_t deviceIndex = mDevices.indexOfKey(deviceId);
+    if (deviceIndex >= 0) {
+        InputDevice* device = mDevices.valueAt(deviceIndex);
+        device->cancelVibrate(token);
+    }
+}
+
+void InputReader::dump(String8& dump) {
+    AutoMutex _l(mLock);
+
+    mEventHub->dump(dump);
+    dump.append("\n");
+
+    dump.append("Input Reader State:\n");
+
+    for (size_t i = 0; i < mDevices.size(); i++) {
+        mDevices.valueAt(i)->dump(dump);
+    }
+
+    dump.append(INDENT "Configuration:\n");
+    dump.append(INDENT2 "ExcludedDeviceNames: [");
+    for (size_t i = 0; i < mConfig.excludedDeviceNames.size(); i++) {
+        if (i != 0) {
+            dump.append(", ");
+        }
+        dump.append(mConfig.excludedDeviceNames.itemAt(i).string());
+    }
+    dump.append("]\n");
+    dump.appendFormat(INDENT2 "VirtualKeyQuietTime: %0.1fms\n",
+            mConfig.virtualKeyQuietTime * 0.000001f);
+
+    dump.appendFormat(INDENT2 "PointerVelocityControlParameters: "
+            "scale=%0.3f, lowThreshold=%0.3f, highThreshold=%0.3f, acceleration=%0.3f\n",
+            mConfig.pointerVelocityControlParameters.scale,
+            mConfig.pointerVelocityControlParameters.lowThreshold,
+            mConfig.pointerVelocityControlParameters.highThreshold,
+            mConfig.pointerVelocityControlParameters.acceleration);
+
+    dump.appendFormat(INDENT2 "WheelVelocityControlParameters: "
+            "scale=%0.3f, lowThreshold=%0.3f, highThreshold=%0.3f, acceleration=%0.3f\n",
+            mConfig.wheelVelocityControlParameters.scale,
+            mConfig.wheelVelocityControlParameters.lowThreshold,
+            mConfig.wheelVelocityControlParameters.highThreshold,
+            mConfig.wheelVelocityControlParameters.acceleration);
+
+    dump.appendFormat(INDENT2 "PointerGesture:\n");
+    dump.appendFormat(INDENT3 "Enabled: %s\n",
+            toString(mConfig.pointerGesturesEnabled));
+    dump.appendFormat(INDENT3 "QuietInterval: %0.1fms\n",
+            mConfig.pointerGestureQuietInterval * 0.000001f);
+    dump.appendFormat(INDENT3 "DragMinSwitchSpeed: %0.1fpx/s\n",
+            mConfig.pointerGestureDragMinSwitchSpeed);
+    dump.appendFormat(INDENT3 "TapInterval: %0.1fms\n",
+            mConfig.pointerGestureTapInterval * 0.000001f);
+    dump.appendFormat(INDENT3 "TapDragInterval: %0.1fms\n",
+            mConfig.pointerGestureTapDragInterval * 0.000001f);
+    dump.appendFormat(INDENT3 "TapSlop: %0.1fpx\n",
+            mConfig.pointerGestureTapSlop);
+    dump.appendFormat(INDENT3 "MultitouchSettleInterval: %0.1fms\n",
+            mConfig.pointerGestureMultitouchSettleInterval * 0.000001f);
+    dump.appendFormat(INDENT3 "MultitouchMinDistance: %0.1fpx\n",
+            mConfig.pointerGestureMultitouchMinDistance);
+    dump.appendFormat(INDENT3 "SwipeTransitionAngleCosine: %0.1f\n",
+            mConfig.pointerGestureSwipeTransitionAngleCosine);
+    dump.appendFormat(INDENT3 "SwipeMaxWidthRatio: %0.1f\n",
+            mConfig.pointerGestureSwipeMaxWidthRatio);
+    dump.appendFormat(INDENT3 "MovementSpeedRatio: %0.1f\n",
+            mConfig.pointerGestureMovementSpeedRatio);
+    dump.appendFormat(INDENT3 "ZoomSpeedRatio: %0.1f\n",
+            mConfig.pointerGestureZoomSpeedRatio);
+}
+
+void InputReader::monitor() {
+    // Acquire and release the lock to ensure that the reader has not deadlocked.
+    mLock.lock();
+    mEventHub->wake();
+    mReaderIsAliveCondition.wait(mLock);
+    mLock.unlock();
+
+    // Check the EventHub
+    mEventHub->monitor();
+}
+
+
+// --- InputReader::ContextImpl ---
+
+InputReader::ContextImpl::ContextImpl(InputReader* reader) :
+        mReader(reader) {
+}
+
+void InputReader::ContextImpl::updateGlobalMetaState() {
+    // lock is already held by the input loop
+    mReader->updateGlobalMetaStateLocked();
+}
+
+int32_t InputReader::ContextImpl::getGlobalMetaState() {
+    // lock is already held by the input loop
+    return mReader->getGlobalMetaStateLocked();
+}
+
+void InputReader::ContextImpl::disableVirtualKeysUntil(nsecs_t time) {
+    // lock is already held by the input loop
+    mReader->disableVirtualKeysUntilLocked(time);
+}
+
+bool InputReader::ContextImpl::shouldDropVirtualKey(nsecs_t now,
+        InputDevice* device, int32_t keyCode, int32_t scanCode) {
+    // lock is already held by the input loop
+    return mReader->shouldDropVirtualKeyLocked(now, device, keyCode, scanCode);
+}
+
+void InputReader::ContextImpl::fadePointer() {
+    // lock is already held by the input loop
+    mReader->fadePointerLocked();
+}
+
+void InputReader::ContextImpl::requestTimeoutAtTime(nsecs_t when) {
+    // lock is already held by the input loop
+    mReader->requestTimeoutAtTimeLocked(when);
+}
+
+int32_t InputReader::ContextImpl::bumpGeneration() {
+    // lock is already held by the input loop
+    return mReader->bumpGenerationLocked();
+}
+
+void InputReader::ContextImpl::getExternalStylusDevices(Vector<InputDeviceInfo>& outDevices) {
+    // lock is already held by whatever called refreshConfigurationLocked
+    mReader->getExternalStylusDevicesLocked(outDevices);
+}
+
+void InputReader::ContextImpl::dispatchExternalStylusState(const StylusState& state) {
+    mReader->dispatchExternalStylusState(state);
+}
+
+InputReaderPolicyInterface* InputReader::ContextImpl::getPolicy() {
+    return mReader->mPolicy.get();
+}
+
+InputListenerInterface* InputReader::ContextImpl::getListener() {
+    return mReader->mQueuedListener.get();
+}
+
+EventHubInterface* InputReader::ContextImpl::getEventHub() {
+    return mReader->mEventHub.get();
+}
+
+
+// --- InputReaderThread ---
+
+InputReaderThread::InputReaderThread(const sp<InputReaderInterface>& reader) :
+        Thread(/*canCallJava*/ true), mReader(reader) {
+}
+
+InputReaderThread::~InputReaderThread() {
+}
+
+bool InputReaderThread::threadLoop() {
+    mReader->loopOnce();
+    return true;
+}
+
+
+// --- InputDevice ---
+
+InputDevice::InputDevice(InputReaderContext* context, int32_t id, int32_t generation,
+        int32_t controllerNumber, const InputDeviceIdentifier& identifier, uint32_t classes) :
+        mContext(context), mId(id), mGeneration(generation), mControllerNumber(controllerNumber),
+        mIdentifier(identifier), mClasses(classes),
+        mSources(0), mIsExternal(false), mHasMic(false), mDropUntilNextSync(false) {
+}
+
+InputDevice::~InputDevice() {
+    size_t numMappers = mMappers.size();
+    for (size_t i = 0; i < numMappers; i++) {
+        delete mMappers[i];
+    }
+    mMappers.clear();
+}
+
+void InputDevice::dump(String8& dump) {
+    InputDeviceInfo deviceInfo;
+    getDeviceInfo(& deviceInfo);
+
+    dump.appendFormat(INDENT "Device %d: %s\n", deviceInfo.getId(),
+            deviceInfo.getDisplayName().string());
+    dump.appendFormat(INDENT2 "Generation: %d\n", mGeneration);
+    dump.appendFormat(INDENT2 "IsExternal: %s\n", toString(mIsExternal));
+    dump.appendFormat(INDENT2 "HasMic:     %s\n", toString(mHasMic));
+    dump.appendFormat(INDENT2 "Sources: 0x%08x\n", deviceInfo.getSources());
+    dump.appendFormat(INDENT2 "KeyboardType: %d\n", deviceInfo.getKeyboardType());
+
+    const Vector<InputDeviceInfo::MotionRange>& ranges = deviceInfo.getMotionRanges();
+    if (!ranges.isEmpty()) {
+        dump.append(INDENT2 "Motion Ranges:\n");
+        for (size_t i = 0; i < ranges.size(); i++) {
+            const InputDeviceInfo::MotionRange& range = ranges.itemAt(i);
+            const char* label = getAxisLabel(range.axis);
+            char name[32];
+            if (label) {
+                strncpy(name, label, sizeof(name));
+                name[sizeof(name) - 1] = '\0';
+            } else {
+                snprintf(name, sizeof(name), "%d", range.axis);
+            }
+            dump.appendFormat(INDENT3 "%s: source=0x%08x, "
+                    "min=%0.3f, max=%0.3f, flat=%0.3f, fuzz=%0.3f, resolution=%0.3f\n",
+                    name, range.source, range.min, range.max, range.flat, range.fuzz,
+                    range.resolution);
+        }
+    }
+
+    size_t numMappers = mMappers.size();
+    for (size_t i = 0; i < numMappers; i++) {
+        InputMapper* mapper = mMappers[i];
+        mapper->dump(dump);
+    }
+}
+
+void InputDevice::addMapper(InputMapper* mapper) {
+    mMappers.add(mapper);
+}
+
+void InputDevice::configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes) {
+    mSources = 0;
+
+    if (!isIgnored()) {
+        if (!changes) { // first time only
+            mContext->getEventHub()->getConfiguration(mId, &mConfiguration);
+        }
+
+        if (!changes || (changes & InputReaderConfiguration::CHANGE_KEYBOARD_LAYOUTS)) {
+            if (!(mClasses & INPUT_DEVICE_CLASS_VIRTUAL)) {
+                sp<KeyCharacterMap> keyboardLayout =
+                        mContext->getPolicy()->getKeyboardLayoutOverlay(mIdentifier);
+                if (mContext->getEventHub()->setKeyboardLayoutOverlay(mId, keyboardLayout)) {
+                    bumpGeneration();
+                }
+            }
+        }
+
+        if (!changes || (changes & InputReaderConfiguration::CHANGE_DEVICE_ALIAS)) {
+            if (!(mClasses & INPUT_DEVICE_CLASS_VIRTUAL)) {
+                String8 alias = mContext->getPolicy()->getDeviceAlias(mIdentifier);
+                if (mAlias != alias) {
+                    mAlias = alias;
+                    bumpGeneration();
+                }
+            }
+        }
+
+        size_t numMappers = mMappers.size();
+        for (size_t i = 0; i < numMappers; i++) {
+            InputMapper* mapper = mMappers[i];
+            mapper->configure(when, config, changes);
+            mSources |= mapper->getSources();
+        }
+    }
+}
+
+void InputDevice::reset(nsecs_t when) {
+    size_t numMappers = mMappers.size();
+    for (size_t i = 0; i < numMappers; i++) {
+        InputMapper* mapper = mMappers[i];
+        mapper->reset(when);
+    }
+
+    mContext->updateGlobalMetaState();
+
+    notifyReset(when);
+}
+
+void InputDevice::process(const RawEvent* rawEvents, size_t count) {
+    // Process all of the events in order for each mapper.
+    // We cannot simply ask each mapper to process them in bulk because mappers may
+    // have side-effects that must be interleaved.  For example, joystick movement events and
+    // gamepad button presses are handled by different mappers but they should be dispatched
+    // in the order received.
+    size_t numMappers = mMappers.size();
+    for (const RawEvent* rawEvent = rawEvents; count--; rawEvent++) {
+#if DEBUG_RAW_EVENTS
+        ALOGD("Input event: device=%d type=0x%04x code=0x%04x value=0x%08x when=%lld",
+                rawEvent->deviceId, rawEvent->type, rawEvent->code, rawEvent->value,
+                rawEvent->when);
+#endif
+
+        if (mDropUntilNextSync) {
+            if (rawEvent->type == EV_SYN && rawEvent->code == SYN_REPORT) {
+                mDropUntilNextSync = false;
+#if DEBUG_RAW_EVENTS
+                ALOGD("Recovered from input event buffer overrun.");
+#endif
+            } else {
+#if DEBUG_RAW_EVENTS
+                ALOGD("Dropped input event while waiting for next input sync.");
+#endif
+            }
+        } else if (rawEvent->type == EV_SYN && rawEvent->code == SYN_DROPPED) {
+            ALOGI("Detected input event buffer overrun for device %s.", getName().string());
+            mDropUntilNextSync = true;
+            reset(rawEvent->when);
+        } else {
+            for (size_t i = 0; i < numMappers; i++) {
+                InputMapper* mapper = mMappers[i];
+                mapper->process(rawEvent);
+            }
+        }
+    }
+}
+
+void InputDevice::timeoutExpired(nsecs_t when) {
+    size_t numMappers = mMappers.size();
+    for (size_t i = 0; i < numMappers; i++) {
+        InputMapper* mapper = mMappers[i];
+        mapper->timeoutExpired(when);
+    }
+}
+
+void InputDevice::updateExternalStylusState(const StylusState& state) {
+    size_t numMappers = mMappers.size();
+    for (size_t i = 0; i < numMappers; i++) {
+        InputMapper* mapper = mMappers[i];
+        mapper->updateExternalStylusState(state);
+    }
+}
+
+void InputDevice::getDeviceInfo(InputDeviceInfo* outDeviceInfo) {
+    outDeviceInfo->initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias,
+            mIsExternal, mHasMic);
+    size_t numMappers = mMappers.size();
+    for (size_t i = 0; i < numMappers; i++) {
+        InputMapper* mapper = mMappers[i];
+        mapper->populateDeviceInfo(outDeviceInfo);
+    }
+}
+
+int32_t InputDevice::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) {
+    return getState(sourceMask, keyCode, & InputMapper::getKeyCodeState);
+}
+
+int32_t InputDevice::getScanCodeState(uint32_t sourceMask, int32_t scanCode) {
+    return getState(sourceMask, scanCode, & InputMapper::getScanCodeState);
+}
+
+int32_t InputDevice::getSwitchState(uint32_t sourceMask, int32_t switchCode) {
+    return getState(sourceMask, switchCode, & InputMapper::getSwitchState);
+}
+
+int32_t InputDevice::getState(uint32_t sourceMask, int32_t code, GetStateFunc getStateFunc) {
+    int32_t result = AKEY_STATE_UNKNOWN;
+    size_t numMappers = mMappers.size();
+    for (size_t i = 0; i < numMappers; i++) {
+        InputMapper* mapper = mMappers[i];
+        if (sourcesMatchMask(mapper->getSources(), sourceMask)) {
+            // If any mapper reports AKEY_STATE_DOWN or AKEY_STATE_VIRTUAL, return that
+            // value.  Otherwise, return AKEY_STATE_UP as long as one mapper reports it.
+            int32_t currentResult = (mapper->*getStateFunc)(sourceMask, code);
+            if (currentResult >= AKEY_STATE_DOWN) {
+                return currentResult;
+            } else if (currentResult == AKEY_STATE_UP) {
+                result = currentResult;
+            }
+        }
+    }
+    return result;
+}
+
+bool InputDevice::markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes,
+        const int32_t* keyCodes, uint8_t* outFlags) {
+    bool result = false;
+    size_t numMappers = mMappers.size();
+    for (size_t i = 0; i < numMappers; i++) {
+        InputMapper* mapper = mMappers[i];
+        if (sourcesMatchMask(mapper->getSources(), sourceMask)) {
+            result |= mapper->markSupportedKeyCodes(sourceMask, numCodes, keyCodes, outFlags);
+        }
+    }
+    return result;
+}
+
+void InputDevice::vibrate(const nsecs_t* pattern, size_t patternSize, ssize_t repeat,
+        int32_t token) {
+    size_t numMappers = mMappers.size();
+    for (size_t i = 0; i < numMappers; i++) {
+        InputMapper* mapper = mMappers[i];
+        mapper->vibrate(pattern, patternSize, repeat, token);
+    }
+}
+
+void InputDevice::cancelVibrate(int32_t token) {
+    size_t numMappers = mMappers.size();
+    for (size_t i = 0; i < numMappers; i++) {
+        InputMapper* mapper = mMappers[i];
+        mapper->cancelVibrate(token);
+    }
+}
+
+void InputDevice::cancelTouch(nsecs_t when) {
+    size_t numMappers = mMappers.size();
+    for (size_t i = 0; i < numMappers; i++) {
+        InputMapper* mapper = mMappers[i];
+        mapper->cancelTouch(when);
+    }
+}
+
+int32_t InputDevice::getMetaState() {
+    int32_t result = 0;
+    size_t numMappers = mMappers.size();
+    for (size_t i = 0; i < numMappers; i++) {
+        InputMapper* mapper = mMappers[i];
+        result |= mapper->getMetaState();
+    }
+    return result;
+}
+
+void InputDevice::fadePointer() {
+    size_t numMappers = mMappers.size();
+    for (size_t i = 0; i < numMappers; i++) {
+        InputMapper* mapper = mMappers[i];
+        mapper->fadePointer();
+    }
+}
+
+void InputDevice::bumpGeneration() {
+    mGeneration = mContext->bumpGeneration();
+}
+
+void InputDevice::notifyReset(nsecs_t when) {
+    NotifyDeviceResetArgs args(when, mId);
+    mContext->getListener()->notifyDeviceReset(&args);
+}
+
+
+// --- CursorButtonAccumulator ---
+
+CursorButtonAccumulator::CursorButtonAccumulator() {
+    clearButtons();
+}
+
+void CursorButtonAccumulator::reset(InputDevice* device) {
+    mBtnLeft = device->isKeyPressed(BTN_LEFT);
+    mBtnRight = device->isKeyPressed(BTN_RIGHT);
+    mBtnMiddle = device->isKeyPressed(BTN_MIDDLE);
+    mBtnBack = device->isKeyPressed(BTN_BACK);
+    mBtnSide = device->isKeyPressed(BTN_SIDE);
+    mBtnForward = device->isKeyPressed(BTN_FORWARD);
+    mBtnExtra = device->isKeyPressed(BTN_EXTRA);
+    mBtnTask = device->isKeyPressed(BTN_TASK);
+}
+
+void CursorButtonAccumulator::clearButtons() {
+    mBtnLeft = 0;
+    mBtnRight = 0;
+    mBtnMiddle = 0;
+    mBtnBack = 0;
+    mBtnSide = 0;
+    mBtnForward = 0;
+    mBtnExtra = 0;
+    mBtnTask = 0;
+}
+
+void CursorButtonAccumulator::process(const RawEvent* rawEvent) {
+    if (rawEvent->type == EV_KEY) {
+        switch (rawEvent->code) {
+        case BTN_LEFT:
+            mBtnLeft = rawEvent->value;
+            break;
+        case BTN_RIGHT:
+            mBtnRight = rawEvent->value;
+            break;
+        case BTN_MIDDLE:
+            mBtnMiddle = rawEvent->value;
+            break;
+        case BTN_BACK:
+            mBtnBack = rawEvent->value;
+            break;
+        case BTN_SIDE:
+            mBtnSide = rawEvent->value;
+            break;
+        case BTN_FORWARD:
+            mBtnForward = rawEvent->value;
+            break;
+        case BTN_EXTRA:
+            mBtnExtra = rawEvent->value;
+            break;
+        case BTN_TASK:
+            mBtnTask = rawEvent->value;
+            break;
+        }
+    }
+}
+
+uint32_t CursorButtonAccumulator::getButtonState() const {
+    uint32_t result = 0;
+    if (mBtnLeft) {
+        result |= AMOTION_EVENT_BUTTON_PRIMARY;
+    }
+    if (mBtnRight) {
+        result |= AMOTION_EVENT_BUTTON_SECONDARY;
+    }
+    if (mBtnMiddle) {
+        result |= AMOTION_EVENT_BUTTON_TERTIARY;
+    }
+    if (mBtnBack || mBtnSide) {
+        result |= AMOTION_EVENT_BUTTON_BACK;
+    }
+    if (mBtnForward || mBtnExtra) {
+        result |= AMOTION_EVENT_BUTTON_FORWARD;
+    }
+    return result;
+}
+
+
+// --- CursorMotionAccumulator ---
+
+CursorMotionAccumulator::CursorMotionAccumulator() {
+    clearRelativeAxes();
+}
+
+void CursorMotionAccumulator::reset(InputDevice* device) {
+    clearRelativeAxes();
+}
+
+void CursorMotionAccumulator::clearRelativeAxes() {
+    mRelX = 0;
+    mRelY = 0;
+}
+
+void CursorMotionAccumulator::process(const RawEvent* rawEvent) {
+    if (rawEvent->type == EV_REL) {
+        switch (rawEvent->code) {
+        case REL_X:
+            mRelX = rawEvent->value;
+            break;
+        case REL_Y:
+            mRelY = rawEvent->value;
+            break;
+        }
+    }
+}
+
+void CursorMotionAccumulator::finishSync() {
+    clearRelativeAxes();
+}
+
+
+// --- CursorScrollAccumulator ---
+
+CursorScrollAccumulator::CursorScrollAccumulator() :
+        mHaveRelWheel(false), mHaveRelHWheel(false) {
+    clearRelativeAxes();
+}
+
+void CursorScrollAccumulator::configure(InputDevice* device) {
+    mHaveRelWheel = device->getEventHub()->hasRelativeAxis(device->getId(), REL_WHEEL);
+    mHaveRelHWheel = device->getEventHub()->hasRelativeAxis(device->getId(), REL_HWHEEL);
+}
+
+void CursorScrollAccumulator::reset(InputDevice* device) {
+    clearRelativeAxes();
+}
+
+void CursorScrollAccumulator::clearRelativeAxes() {
+    mRelWheel = 0;
+    mRelHWheel = 0;
+}
+
+void CursorScrollAccumulator::process(const RawEvent* rawEvent) {
+    if (rawEvent->type == EV_REL) {
+        switch (rawEvent->code) {
+        case REL_WHEEL:
+            mRelWheel = rawEvent->value;
+            break;
+        case REL_HWHEEL:
+            mRelHWheel = rawEvent->value;
+            break;
+        }
+    }
+}
+
+void CursorScrollAccumulator::finishSync() {
+    clearRelativeAxes();
+}
+
+
+// --- TouchButtonAccumulator ---
+
+TouchButtonAccumulator::TouchButtonAccumulator() :
+        mHaveBtnTouch(false), mHaveStylus(false) {
+    clearButtons();
+}
+
+void TouchButtonAccumulator::configure(InputDevice* device) {
+    mHaveBtnTouch = device->hasKey(BTN_TOUCH);
+    mHaveStylus = device->hasKey(BTN_TOOL_PEN)
+            || device->hasKey(BTN_TOOL_RUBBER)
+            || device->hasKey(BTN_TOOL_BRUSH)
+            || device->hasKey(BTN_TOOL_PENCIL)
+            || device->hasKey(BTN_TOOL_AIRBRUSH);
+}
+
+void TouchButtonAccumulator::reset(InputDevice* device) {
+    mBtnTouch = device->isKeyPressed(BTN_TOUCH);
+    mBtnStylus = device->isKeyPressed(BTN_STYLUS);
+    // BTN_0 is what gets mapped for the HID usage Digitizers.SecondaryBarrelSwitch
+    mBtnStylus2 =
+            device->isKeyPressed(BTN_STYLUS2) || device->isKeyPressed(BTN_0);
+    mBtnToolFinger = device->isKeyPressed(BTN_TOOL_FINGER);
+    mBtnToolPen = device->isKeyPressed(BTN_TOOL_PEN);
+    mBtnToolRubber = device->isKeyPressed(BTN_TOOL_RUBBER);
+    mBtnToolBrush = device->isKeyPressed(BTN_TOOL_BRUSH);
+    mBtnToolPencil = device->isKeyPressed(BTN_TOOL_PENCIL);
+    mBtnToolAirbrush = device->isKeyPressed(BTN_TOOL_AIRBRUSH);
+    mBtnToolMouse = device->isKeyPressed(BTN_TOOL_MOUSE);
+    mBtnToolLens = device->isKeyPressed(BTN_TOOL_LENS);
+    mBtnToolDoubleTap = device->isKeyPressed(BTN_TOOL_DOUBLETAP);
+    mBtnToolTripleTap = device->isKeyPressed(BTN_TOOL_TRIPLETAP);
+    mBtnToolQuadTap = device->isKeyPressed(BTN_TOOL_QUADTAP);
+}
+
+void TouchButtonAccumulator::clearButtons() {
+    mBtnTouch = 0;
+    mBtnStylus = 0;
+    mBtnStylus2 = 0;
+    mBtnToolFinger = 0;
+    mBtnToolPen = 0;
+    mBtnToolRubber = 0;
+    mBtnToolBrush = 0;
+    mBtnToolPencil = 0;
+    mBtnToolAirbrush = 0;
+    mBtnToolMouse = 0;
+    mBtnToolLens = 0;
+    mBtnToolDoubleTap = 0;
+    mBtnToolTripleTap = 0;
+    mBtnToolQuadTap = 0;
+}
+
+void TouchButtonAccumulator::process(const RawEvent* rawEvent) {
+    if (rawEvent->type == EV_KEY) {
+        switch (rawEvent->code) {
+        case BTN_TOUCH:
+            mBtnTouch = rawEvent->value;
+            break;
+        case BTN_STYLUS:
+            mBtnStylus = rawEvent->value;
+            break;
+        case BTN_STYLUS2:
+        case BTN_0:// BTN_0 is what gets mapped for the HID usage Digitizers.SecondaryBarrelSwitch
+            mBtnStylus2 = rawEvent->value;
+            break;
+        case BTN_TOOL_FINGER:
+            mBtnToolFinger = rawEvent->value;
+            break;
+        case BTN_TOOL_PEN:
+            mBtnToolPen = rawEvent->value;
+            break;
+        case BTN_TOOL_RUBBER:
+            mBtnToolRubber = rawEvent->value;
+            break;
+        case BTN_TOOL_BRUSH:
+            mBtnToolBrush = rawEvent->value;
+            break;
+        case BTN_TOOL_PENCIL:
+            mBtnToolPencil = rawEvent->value;
+            break;
+        case BTN_TOOL_AIRBRUSH:
+            mBtnToolAirbrush = rawEvent->value;
+            break;
+        case BTN_TOOL_MOUSE:
+            mBtnToolMouse = rawEvent->value;
+            break;
+        case BTN_TOOL_LENS:
+            mBtnToolLens = rawEvent->value;
+            break;
+        case BTN_TOOL_DOUBLETAP:
+            mBtnToolDoubleTap = rawEvent->value;
+            break;
+        case BTN_TOOL_TRIPLETAP:
+            mBtnToolTripleTap = rawEvent->value;
+            break;
+        case BTN_TOOL_QUADTAP:
+            mBtnToolQuadTap = rawEvent->value;
+            break;
+        }
+    }
+}
+
+uint32_t TouchButtonAccumulator::getButtonState() const {
+    uint32_t result = 0;
+    if (mBtnStylus) {
+        result |= AMOTION_EVENT_BUTTON_STYLUS_PRIMARY;
+    }
+    if (mBtnStylus2) {
+        result |= AMOTION_EVENT_BUTTON_STYLUS_SECONDARY;
+    }
+    return result;
+}
+
+int32_t TouchButtonAccumulator::getToolType() const {
+    if (mBtnToolMouse || mBtnToolLens) {
+        return AMOTION_EVENT_TOOL_TYPE_MOUSE;
+    }
+    if (mBtnToolRubber) {
+        return AMOTION_EVENT_TOOL_TYPE_ERASER;
+    }
+    if (mBtnToolPen || mBtnToolBrush || mBtnToolPencil || mBtnToolAirbrush) {
+        return AMOTION_EVENT_TOOL_TYPE_STYLUS;
+    }
+    if (mBtnToolFinger || mBtnToolDoubleTap || mBtnToolTripleTap || mBtnToolQuadTap) {
+        return AMOTION_EVENT_TOOL_TYPE_FINGER;
+    }
+    return AMOTION_EVENT_TOOL_TYPE_UNKNOWN;
+}
+
+bool TouchButtonAccumulator::isToolActive() const {
+    return mBtnTouch || mBtnToolFinger || mBtnToolPen || mBtnToolRubber
+            || mBtnToolBrush || mBtnToolPencil || mBtnToolAirbrush
+            || mBtnToolMouse || mBtnToolLens
+            || mBtnToolDoubleTap || mBtnToolTripleTap || mBtnToolQuadTap;
+}
+
+bool TouchButtonAccumulator::isHovering() const {
+    return mHaveBtnTouch && !mBtnTouch;
+}
+
+bool TouchButtonAccumulator::hasStylus() const {
+    return mHaveStylus;
+}
+
+
+// --- RawPointerAxes ---
+
+RawPointerAxes::RawPointerAxes() {
+    clear();
+}
+
+void RawPointerAxes::clear() {
+    x.clear();
+    y.clear();
+    pressure.clear();
+    touchMajor.clear();
+    touchMinor.clear();
+    toolMajor.clear();
+    toolMinor.clear();
+    orientation.clear();
+    distance.clear();
+    tiltX.clear();
+    tiltY.clear();
+    trackingId.clear();
+    slot.clear();
+}
+
+
+// --- RawPointerData ---
+
+RawPointerData::RawPointerData() {
+    clear();
+}
+
+void RawPointerData::clear() {
+    pointerCount = 0;
+    clearIdBits();
+}
+
+void RawPointerData::copyFrom(const RawPointerData& other) {
+    pointerCount = other.pointerCount;
+    hoveringIdBits = other.hoveringIdBits;
+    touchingIdBits = other.touchingIdBits;
+
+    for (uint32_t i = 0; i < pointerCount; i++) {
+        pointers[i] = other.pointers[i];
+
+        int id = pointers[i].id;
+        idToIndex[id] = other.idToIndex[id];
+    }
+}
+
+void RawPointerData::getCentroidOfTouchingPointers(float* outX, float* outY) const {
+    float x = 0, y = 0;
+    uint32_t count = touchingIdBits.count();
+    if (count) {
+        for (BitSet32 idBits(touchingIdBits); !idBits.isEmpty(); ) {
+            uint32_t id = idBits.clearFirstMarkedBit();
+            const Pointer& pointer = pointerForId(id);
+            x += pointer.x;
+            y += pointer.y;
+        }
+        x /= count;
+        y /= count;
+    }
+    *outX = x;
+    *outY = y;
+}
+
+
+// --- CookedPointerData ---
+
+CookedPointerData::CookedPointerData() {
+    clear();
+}
+
+void CookedPointerData::clear() {
+    pointerCount = 0;
+    hoveringIdBits.clear();
+    touchingIdBits.clear();
+}
+
+void CookedPointerData::copyFrom(const CookedPointerData& other) {
+    pointerCount = other.pointerCount;
+    hoveringIdBits = other.hoveringIdBits;
+    touchingIdBits = other.touchingIdBits;
+
+    for (uint32_t i = 0; i < pointerCount; i++) {
+        pointerProperties[i].copyFrom(other.pointerProperties[i]);
+        pointerCoords[i].copyFrom(other.pointerCoords[i]);
+
+        int id = pointerProperties[i].id;
+        idToIndex[id] = other.idToIndex[id];
+    }
+}
+
+
+// --- SingleTouchMotionAccumulator ---
+
+SingleTouchMotionAccumulator::SingleTouchMotionAccumulator() {
+    clearAbsoluteAxes();
+}
+
+void SingleTouchMotionAccumulator::reset(InputDevice* device) {
+    mAbsX = device->getAbsoluteAxisValue(ABS_X);
+    mAbsY = device->getAbsoluteAxisValue(ABS_Y);
+    mAbsPressure = device->getAbsoluteAxisValue(ABS_PRESSURE);
+    mAbsToolWidth = device->getAbsoluteAxisValue(ABS_TOOL_WIDTH);
+    mAbsDistance = device->getAbsoluteAxisValue(ABS_DISTANCE);
+    mAbsTiltX = device->getAbsoluteAxisValue(ABS_TILT_X);
+    mAbsTiltY = device->getAbsoluteAxisValue(ABS_TILT_Y);
+}
+
+void SingleTouchMotionAccumulator::clearAbsoluteAxes() {
+    mAbsX = 0;
+    mAbsY = 0;
+    mAbsPressure = 0;
+    mAbsToolWidth = 0;
+    mAbsDistance = 0;
+    mAbsTiltX = 0;
+    mAbsTiltY = 0;
+}
+
+void SingleTouchMotionAccumulator::process(const RawEvent* rawEvent) {
+    if (rawEvent->type == EV_ABS) {
+        switch (rawEvent->code) {
+        case ABS_X:
+            mAbsX = rawEvent->value;
+            break;
+        case ABS_Y:
+            mAbsY = rawEvent->value;
+            break;
+        case ABS_PRESSURE:
+            mAbsPressure = rawEvent->value;
+            break;
+        case ABS_TOOL_WIDTH:
+            mAbsToolWidth = rawEvent->value;
+            break;
+        case ABS_DISTANCE:
+            mAbsDistance = rawEvent->value;
+            break;
+        case ABS_TILT_X:
+            mAbsTiltX = rawEvent->value;
+            break;
+        case ABS_TILT_Y:
+            mAbsTiltY = rawEvent->value;
+            break;
+        }
+    }
+}
+
+
+// --- MultiTouchMotionAccumulator ---
+
+MultiTouchMotionAccumulator::MultiTouchMotionAccumulator() :
+        mCurrentSlot(-1), mSlots(NULL), mSlotCount(0), mUsingSlotsProtocol(false),
+        mHaveStylus(false) {
+}
+
+MultiTouchMotionAccumulator::~MultiTouchMotionAccumulator() {
+    delete[] mSlots;
+}
+
+void MultiTouchMotionAccumulator::configure(InputDevice* device,
+        size_t slotCount, bool usingSlotsProtocol) {
+    mSlotCount = slotCount;
+    mUsingSlotsProtocol = usingSlotsProtocol;
+    mHaveStylus = device->hasAbsoluteAxis(ABS_MT_TOOL_TYPE);
+
+    delete[] mSlots;
+    mSlots = new Slot[slotCount];
+}
+
+void MultiTouchMotionAccumulator::reset(InputDevice* device) {
+    // Unfortunately there is no way to read the initial contents of the slots.
+    // So when we reset the accumulator, we must assume they are all zeroes.
+    if (mUsingSlotsProtocol) {
+        // Query the driver for the current slot index and use it as the initial slot
+        // before we start reading events from the device.  It is possible that the
+        // current slot index will not be the same as it was when the first event was
+        // written into the evdev buffer, which means the input mapper could start
+        // out of sync with the initial state of the events in the evdev buffer.
+        // In the extremely unlikely case that this happens, the data from
+        // two slots will be confused until the next ABS_MT_SLOT event is received.
+        // This can cause the touch point to "jump", but at least there will be
+        // no stuck touches.
+        int32_t initialSlot;
+        status_t status = device->getEventHub()->getAbsoluteAxisValue(device->getId(),
+                ABS_MT_SLOT, &initialSlot);
+        if (status) {
+            ALOGD("Could not retrieve current multitouch slot index.  status=%d", status);
+            initialSlot = -1;
+        }
+        clearSlots(initialSlot);
+    } else {
+        clearSlots(-1);
+    }
+}
+
+void MultiTouchMotionAccumulator::clearSlots(int32_t initialSlot) {
+    if (mSlots) {
+        for (size_t i = 0; i < mSlotCount; i++) {
+            mSlots[i].clear();
+        }
+    }
+    mCurrentSlot = initialSlot;
+}
+
+void MultiTouchMotionAccumulator::process(const RawEvent* rawEvent) {
+    if (rawEvent->type == EV_ABS) {
+        bool newSlot = false;
+        if (mUsingSlotsProtocol) {
+            if (rawEvent->code == ABS_MT_SLOT) {
+                mCurrentSlot = rawEvent->value;
+                newSlot = true;
+            }
+        } else if (mCurrentSlot < 0) {
+            mCurrentSlot = 0;
+        }
+
+        if (mCurrentSlot < 0 || size_t(mCurrentSlot) >= mSlotCount) {
+#if DEBUG_POINTERS
+            if (newSlot) {
+                ALOGW("MultiTouch device emitted invalid slot index %d but it "
+                        "should be between 0 and %d; ignoring this slot.",
+                        mCurrentSlot, mSlotCount - 1);
+            }
+#endif
+        } else {
+            Slot* slot = &mSlots[mCurrentSlot];
+
+            switch (rawEvent->code) {
+            case ABS_MT_POSITION_X:
+                slot->mInUse = true;
+                slot->mAbsMTPositionX = rawEvent->value;
+                break;
+            case ABS_MT_POSITION_Y:
+                slot->mInUse = true;
+                slot->mAbsMTPositionY = rawEvent->value;
+                break;
+            case ABS_MT_TOUCH_MAJOR:
+                slot->mInUse = true;
+                slot->mAbsMTTouchMajor = rawEvent->value;
+                break;
+            case ABS_MT_TOUCH_MINOR:
+                slot->mInUse = true;
+                slot->mAbsMTTouchMinor = rawEvent->value;
+                slot->mHaveAbsMTTouchMinor = true;
+                break;
+            case ABS_MT_WIDTH_MAJOR:
+                slot->mInUse = true;
+                slot->mAbsMTWidthMajor = rawEvent->value;
+                break;
+            case ABS_MT_WIDTH_MINOR:
+                slot->mInUse = true;
+                slot->mAbsMTWidthMinor = rawEvent->value;
+                slot->mHaveAbsMTWidthMinor = true;
+                break;
+            case ABS_MT_ORIENTATION:
+                slot->mInUse = true;
+                slot->mAbsMTOrientation = rawEvent->value;
+                break;
+            case ABS_MT_TRACKING_ID:
+                if (mUsingSlotsProtocol && rawEvent->value < 0) {
+                    // The slot is no longer in use but it retains its previous contents,
+                    // which may be reused for subsequent touches.
+                    slot->mInUse = false;
+                } else {
+                    slot->mInUse = true;
+                    slot->mAbsMTTrackingId = rawEvent->value;
+                }
+                break;
+            case ABS_MT_PRESSURE:
+                slot->mInUse = true;
+                slot->mAbsMTPressure = rawEvent->value;
+                break;
+            case ABS_MT_DISTANCE:
+                slot->mInUse = true;
+                slot->mAbsMTDistance = rawEvent->value;
+                break;
+            case ABS_MT_TOOL_TYPE:
+                slot->mInUse = true;
+                slot->mAbsMTToolType = rawEvent->value;
+                slot->mHaveAbsMTToolType = true;
+                break;
+            }
+        }
+    } else if (rawEvent->type == EV_SYN && rawEvent->code == SYN_MT_REPORT) {
+        // MultiTouch Sync: The driver has returned all data for *one* of the pointers.
+        mCurrentSlot += 1;
+    }
+}
+
+void MultiTouchMotionAccumulator::finishSync() {
+    if (!mUsingSlotsProtocol) {
+        clearSlots(-1);
+    }
+}
+
+bool MultiTouchMotionAccumulator::hasStylus() const {
+    return mHaveStylus;
+}
+
+
+// --- MultiTouchMotionAccumulator::Slot ---
+
+MultiTouchMotionAccumulator::Slot::Slot() {
+    clear();
+}
+
+void MultiTouchMotionAccumulator::Slot::clear() {
+    mInUse = false;
+    mHaveAbsMTTouchMinor = false;
+    mHaveAbsMTWidthMinor = false;
+    mHaveAbsMTToolType = false;
+    mAbsMTPositionX = 0;
+    mAbsMTPositionY = 0;
+    mAbsMTTouchMajor = 0;
+    mAbsMTTouchMinor = 0;
+    mAbsMTWidthMajor = 0;
+    mAbsMTWidthMinor = 0;
+    mAbsMTOrientation = 0;
+    mAbsMTTrackingId = -1;
+    mAbsMTPressure = 0;
+    mAbsMTDistance = 0;
+    mAbsMTToolType = 0;
+}
+
+int32_t MultiTouchMotionAccumulator::Slot::getToolType() const {
+    if (mHaveAbsMTToolType) {
+        switch (mAbsMTToolType) {
+        case MT_TOOL_FINGER:
+            return AMOTION_EVENT_TOOL_TYPE_FINGER;
+        case MT_TOOL_PEN:
+            return AMOTION_EVENT_TOOL_TYPE_STYLUS;
+        }
+    }
+    return AMOTION_EVENT_TOOL_TYPE_UNKNOWN;
+}
+
+
+// --- InputMapper ---
+
+InputMapper::InputMapper(InputDevice* device) :
+        mDevice(device), mContext(device->getContext()) {
+}
+
+InputMapper::~InputMapper() {
+}
+
+void InputMapper::populateDeviceInfo(InputDeviceInfo* info) {
+    info->addSource(getSources());
+}
+
+void InputMapper::dump(String8& dump) {
+}
+
+void InputMapper::configure(nsecs_t when,
+        const InputReaderConfiguration* config, uint32_t changes) {
+}
+
+void InputMapper::reset(nsecs_t when) {
+}
+
+void InputMapper::timeoutExpired(nsecs_t when) {
+}
+
+int32_t InputMapper::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) {
+    return AKEY_STATE_UNKNOWN;
+}
+
+int32_t InputMapper::getScanCodeState(uint32_t sourceMask, int32_t scanCode) {
+    return AKEY_STATE_UNKNOWN;
+}
+
+int32_t InputMapper::getSwitchState(uint32_t sourceMask, int32_t switchCode) {
+    return AKEY_STATE_UNKNOWN;
+}
+
+bool InputMapper::markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes,
+        const int32_t* keyCodes, uint8_t* outFlags) {
+    return false;
+}
+
+void InputMapper::vibrate(const nsecs_t* pattern, size_t patternSize, ssize_t repeat,
+        int32_t token) {
+}
+
+void InputMapper::cancelVibrate(int32_t token) {
+}
+
+void InputMapper::cancelTouch(nsecs_t when) {
+}
+
+int32_t InputMapper::getMetaState() {
+    return 0;
+}
+
+void InputMapper::updateExternalStylusState(const StylusState& state) {
+
+}
+
+void InputMapper::fadePointer() {
+}
+
+status_t InputMapper::getAbsoluteAxisInfo(int32_t axis, RawAbsoluteAxisInfo* axisInfo) {
+    return getEventHub()->getAbsoluteAxisInfo(getDeviceId(), axis, axisInfo);
+}
+
+void InputMapper::bumpGeneration() {
+    mDevice->bumpGeneration();
+}
+
+void InputMapper::dumpRawAbsoluteAxisInfo(String8& dump,
+        const RawAbsoluteAxisInfo& axis, const char* name) {
+    if (axis.valid) {
+        dump.appendFormat(INDENT4 "%s: min=%d, max=%d, flat=%d, fuzz=%d, resolution=%d\n",
+                name, axis.minValue, axis.maxValue, axis.flat, axis.fuzz, axis.resolution);
+    } else {
+        dump.appendFormat(INDENT4 "%s: unknown range\n", name);
+    }
+}
+
+void InputMapper::dumpStylusState(String8& dump, const StylusState& state) {
+    dump.appendFormat(INDENT4 "When: %" PRId64 "\n", state.when);
+    dump.appendFormat(INDENT4 "Pressure: %f\n", state.pressure);
+    dump.appendFormat(INDENT4 "Button State: 0x%08x\n", state.buttons);
+    dump.appendFormat(INDENT4 "Tool Type: %" PRId32 "\n", state.toolType);
+}
+
+// --- SwitchInputMapper ---
+
+SwitchInputMapper::SwitchInputMapper(InputDevice* device) :
+        InputMapper(device), mSwitchValues(0), mUpdatedSwitchMask(0) {
+}
+
+SwitchInputMapper::~SwitchInputMapper() {
+}
+
+uint32_t SwitchInputMapper::getSources() {
+    return AINPUT_SOURCE_SWITCH;
+}
+
+void SwitchInputMapper::process(const RawEvent* rawEvent) {
+    switch (rawEvent->type) {
+    case EV_SW:
+        processSwitch(rawEvent->code, rawEvent->value);
+        break;
+
+    case EV_SYN:
+        if (rawEvent->code == SYN_REPORT) {
+            sync(rawEvent->when);
+        }
+    }
+}
+
+void SwitchInputMapper::processSwitch(int32_t switchCode, int32_t switchValue) {
+    if (switchCode >= 0 && switchCode < 32) {
+        if (switchValue) {
+            mSwitchValues |= 1 << switchCode;
+        } else {
+            mSwitchValues &= ~(1 << switchCode);
+        }
+        mUpdatedSwitchMask |= 1 << switchCode;
+    }
+}
+
+void SwitchInputMapper::sync(nsecs_t when) {
+    if (mUpdatedSwitchMask) {
+        uint32_t updatedSwitchValues = mSwitchValues & mUpdatedSwitchMask;
+        NotifySwitchArgs args(when, 0, updatedSwitchValues, mUpdatedSwitchMask);
+        getListener()->notifySwitch(&args);
+
+        mUpdatedSwitchMask = 0;
+    }
+}
+
+int32_t SwitchInputMapper::getSwitchState(uint32_t sourceMask, int32_t switchCode) {
+    return getEventHub()->getSwitchState(getDeviceId(), switchCode);
+}
+
+void SwitchInputMapper::dump(String8& dump) {
+    dump.append(INDENT2 "Switch Input Mapper:\n");
+    dump.appendFormat(INDENT3 "SwitchValues: %x\n", mSwitchValues);
+}
+
+// --- VibratorInputMapper ---
+
+VibratorInputMapper::VibratorInputMapper(InputDevice* device) :
+        InputMapper(device), mVibrating(false) {
+}
+
+VibratorInputMapper::~VibratorInputMapper() {
+}
+
+uint32_t VibratorInputMapper::getSources() {
+    return 0;
+}
+
+void VibratorInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
+    InputMapper::populateDeviceInfo(info);
+
+    info->setVibrator(true);
+}
+
+void VibratorInputMapper::process(const RawEvent* rawEvent) {
+    // TODO: Handle FF_STATUS, although it does not seem to be widely supported.
+}
+
+void VibratorInputMapper::vibrate(const nsecs_t* pattern, size_t patternSize, ssize_t repeat,
+        int32_t token) {
+#if DEBUG_VIBRATOR
+    String8 patternStr;
+    for (size_t i = 0; i < patternSize; i++) {
+        if (i != 0) {
+            patternStr.append(", ");
+        }
+        patternStr.appendFormat("%lld", pattern[i]);
+    }
+    ALOGD("vibrate: deviceId=%d, pattern=[%s], repeat=%ld, token=%d",
+            getDeviceId(), patternStr.string(), repeat, token);
+#endif
+
+    mVibrating = true;
+    memcpy(mPattern, pattern, patternSize * sizeof(nsecs_t));
+    mPatternSize = patternSize;
+    mRepeat = repeat;
+    mToken = token;
+    mIndex = -1;
+
+    nextStep();
+}
+
+void VibratorInputMapper::cancelVibrate(int32_t token) {
+#if DEBUG_VIBRATOR
+    ALOGD("cancelVibrate: deviceId=%d, token=%d", getDeviceId(), token);
+#endif
+
+    if (mVibrating && mToken == token) {
+        stopVibrating();
+    }
+}
+
+void VibratorInputMapper::timeoutExpired(nsecs_t when) {
+    if (mVibrating) {
+        if (when >= mNextStepTime) {
+            nextStep();
+        } else {
+            getContext()->requestTimeoutAtTime(mNextStepTime);
+        }
+    }
+}
+
+void VibratorInputMapper::nextStep() {
+    mIndex += 1;
+    if (size_t(mIndex) >= mPatternSize) {
+        if (mRepeat < 0) {
+            // We are done.
+            stopVibrating();
+            return;
+        }
+        mIndex = mRepeat;
+    }
+
+    bool vibratorOn = mIndex & 1;
+    nsecs_t duration = mPattern[mIndex];
+    if (vibratorOn) {
+#if DEBUG_VIBRATOR
+        ALOGD("nextStep: sending vibrate deviceId=%d, duration=%lld",
+                getDeviceId(), duration);
+#endif
+        getEventHub()->vibrate(getDeviceId(), duration);
+    } else {
+#if DEBUG_VIBRATOR
+        ALOGD("nextStep: sending cancel vibrate deviceId=%d", getDeviceId());
+#endif
+        getEventHub()->cancelVibrate(getDeviceId());
+    }
+    nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);
+    mNextStepTime = now + duration;
+    getContext()->requestTimeoutAtTime(mNextStepTime);
+#if DEBUG_VIBRATOR
+    ALOGD("nextStep: scheduled timeout in %0.3fms", duration * 0.000001f);
+#endif
+}
+
+void VibratorInputMapper::stopVibrating() {
+    mVibrating = false;
+#if DEBUG_VIBRATOR
+    ALOGD("stopVibrating: sending cancel vibrate deviceId=%d", getDeviceId());
+#endif
+    getEventHub()->cancelVibrate(getDeviceId());
+}
+
+void VibratorInputMapper::dump(String8& dump) {
+    dump.append(INDENT2 "Vibrator Input Mapper:\n");
+    dump.appendFormat(INDENT3 "Vibrating: %s\n", toString(mVibrating));
+}
+
+
+// --- KeyboardInputMapper ---
+
+KeyboardInputMapper::KeyboardInputMapper(InputDevice* device,
+        uint32_t source, int32_t keyboardType) :
+        InputMapper(device), mSource(source),
+        mKeyboardType(keyboardType) {
+}
+
+KeyboardInputMapper::~KeyboardInputMapper() {
+}
+
+uint32_t KeyboardInputMapper::getSources() {
+    return mSource;
+}
+
+void KeyboardInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
+    InputMapper::populateDeviceInfo(info);
+
+    info->setKeyboardType(mKeyboardType);
+    info->setKeyCharacterMap(getEventHub()->getKeyCharacterMap(getDeviceId()));
+}
+
+void KeyboardInputMapper::dump(String8& dump) {
+    dump.append(INDENT2 "Keyboard Input Mapper:\n");
+    dumpParameters(dump);
+    dump.appendFormat(INDENT3 "KeyboardType: %d\n", mKeyboardType);
+    dump.appendFormat(INDENT3 "Orientation: %d\n", mOrientation);
+    dump.appendFormat(INDENT3 "KeyDowns: %zu keys currently down\n", mKeyDowns.size());
+    dump.appendFormat(INDENT3 "MetaState: 0x%0x\n", mMetaState);
+    dump.appendFormat(INDENT3 "DownTime: %lld\n", (long long)mDownTime);
+}
+
+
+void KeyboardInputMapper::configure(nsecs_t when,
+        const InputReaderConfiguration* config, uint32_t changes) {
+    InputMapper::configure(when, config, changes);
+
+    if (!changes) { // first time only
+        // Configure basic parameters.
+        configureParameters();
+    }
+
+    if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
+        if (mParameters.orientationAware && mParameters.hasAssociatedDisplay) {
+            DisplayViewport v;
+            if (config->getDisplayInfo(false /*external*/, &v)) {
+                mOrientation = v.orientation;
+            } else {
+                mOrientation = DISPLAY_ORIENTATION_0;
+            }
+        } else {
+            mOrientation = DISPLAY_ORIENTATION_0;
+        }
+    }
+}
+
+void KeyboardInputMapper::configureParameters() {
+    mParameters.orientationAware = false;
+    getDevice()->getConfiguration().tryGetProperty(String8("keyboard.orientationAware"),
+            mParameters.orientationAware);
+
+    mParameters.hasAssociatedDisplay = false;
+    if (mParameters.orientationAware) {
+        mParameters.hasAssociatedDisplay = true;
+    }
+
+    mParameters.handlesKeyRepeat = false;
+    getDevice()->getConfiguration().tryGetProperty(String8("keyboard.handlesKeyRepeat"),
+            mParameters.handlesKeyRepeat);
+}
+
+void KeyboardInputMapper::dumpParameters(String8& dump) {
+    dump.append(INDENT3 "Parameters:\n");
+    dump.appendFormat(INDENT4 "HasAssociatedDisplay: %s\n",
+            toString(mParameters.hasAssociatedDisplay));
+    dump.appendFormat(INDENT4 "OrientationAware: %s\n",
+            toString(mParameters.orientationAware));
+    dump.appendFormat(INDENT4 "HandlesKeyRepeat: %s\n",
+            toString(mParameters.handlesKeyRepeat));
+}
+
+void KeyboardInputMapper::reset(nsecs_t when) {
+    mMetaState = AMETA_NONE;
+    mDownTime = 0;
+    mKeyDowns.clear();
+    mCurrentHidUsage = 0;
+
+    resetLedState();
+
+    InputMapper::reset(when);
+}
+
+void KeyboardInputMapper::process(const RawEvent* rawEvent) {
+    switch (rawEvent->type) {
+    case EV_KEY: {
+        int32_t scanCode = rawEvent->code;
+        int32_t usageCode = mCurrentHidUsage;
+        mCurrentHidUsage = 0;
+
+        if (isKeyboardOrGamepadKey(scanCode)) {
+            processKey(rawEvent->when, rawEvent->value != 0, scanCode, usageCode);
+        }
+        break;
+    }
+    case EV_MSC: {
+        if (rawEvent->code == MSC_SCAN) {
+            mCurrentHidUsage = rawEvent->value;
+        }
+        break;
+    }
+    case EV_SYN: {
+        if (rawEvent->code == SYN_REPORT) {
+            mCurrentHidUsage = 0;
+        }
+    }
+    }
+}
+
+bool KeyboardInputMapper::isKeyboardOrGamepadKey(int32_t scanCode) {
+    return scanCode < BTN_MOUSE
+        || scanCode >= KEY_OK
+        || (scanCode >= BTN_MISC && scanCode < BTN_MOUSE)
+        || (scanCode >= BTN_JOYSTICK && scanCode < BTN_DIGI);
+}
+
+void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t scanCode,
+        int32_t usageCode) {
+    int32_t keyCode;
+    int32_t keyMetaState;
+    uint32_t policyFlags;
+
+    if (getEventHub()->mapKey(getDeviceId(), scanCode, usageCode, mMetaState,
+                              &keyCode, &keyMetaState, &policyFlags)) {
+        keyCode = AKEYCODE_UNKNOWN;
+        keyMetaState = mMetaState;
+        policyFlags = 0;
+    }
+
+    if (down) {
+        // Rotate key codes according to orientation if needed.
+        if (mParameters.orientationAware && mParameters.hasAssociatedDisplay) {
+            keyCode = rotateKeyCode(keyCode, mOrientation);
+        }
+
+        // Add key down.
+        ssize_t keyDownIndex = findKeyDown(scanCode);
+        if (keyDownIndex >= 0) {
+            // key repeat, be sure to use same keycode as before in case of rotation
+            keyCode = mKeyDowns.itemAt(keyDownIndex).keyCode;
+        } else {
+            // key down
+            if ((policyFlags & POLICY_FLAG_VIRTUAL)
+                    && mContext->shouldDropVirtualKey(when,
+                            getDevice(), keyCode, scanCode)) {
+                return;
+            }
+            if (policyFlags & POLICY_FLAG_GESTURE) {
+                mDevice->cancelTouch(when);
+            }
+
+            mKeyDowns.push();
+            KeyDown& keyDown = mKeyDowns.editTop();
+            keyDown.keyCode = keyCode;
+            keyDown.scanCode = scanCode;
+        }
+
+        mDownTime = when;
+    } else {
+        // Remove key down.
+        ssize_t keyDownIndex = findKeyDown(scanCode);
+        if (keyDownIndex >= 0) {
+            // key up, be sure to use same keycode as before in case of rotation
+            keyCode = mKeyDowns.itemAt(keyDownIndex).keyCode;
+            mKeyDowns.removeAt(size_t(keyDownIndex));
+        } else {
+            // key was not actually down
+            ALOGI("Dropping key up from device %s because the key was not down.  "
+                    "keyCode=%d, scanCode=%d",
+                    getDeviceName().string(), keyCode, scanCode);
+            return;
+        }
+    }
+
+    int32_t oldMetaState = mMetaState;
+    int32_t newMetaState = updateMetaState(keyCode, down, oldMetaState);
+    bool metaStateChanged = oldMetaState != newMetaState;
+    if (metaStateChanged) {
+        mMetaState = newMetaState;
+        updateLedState(false);
+
+        // If global meta state changed send it along with the key.
+        // If it has not changed then we'll use what keymap gave us,
+        // since key replacement logic might temporarily reset a few
+        // meta bits for given key.
+        keyMetaState = newMetaState;
+    }
+
+    nsecs_t downTime = mDownTime;
+
+    // Key down on external an keyboard should wake the device.
+    // We don't do this for internal keyboards to prevent them from waking up in your pocket.
+    // For internal keyboards, the key layout file should specify the policy flags for
+    // each wake key individually.
+    // TODO: Use the input device configuration to control this behavior more finely.
+    if (down && getDevice()->isExternal()) {
+        policyFlags |= POLICY_FLAG_WAKE;
+    }
+
+    if (mParameters.handlesKeyRepeat) {
+        policyFlags |= POLICY_FLAG_DISABLE_KEY_REPEAT;
+    }
+
+    if (metaStateChanged) {
+        getContext()->updateGlobalMetaState();
+    }
+
+    if (down && !isMetaKey(keyCode)) {
+        getContext()->fadePointer();
+    }
+
+    NotifyKeyArgs args(when, getDeviceId(), mSource, policyFlags,
+            down ? AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP,
+            AKEY_EVENT_FLAG_FROM_SYSTEM, keyCode, scanCode, keyMetaState, downTime);
+    getListener()->notifyKey(&args);
+}
+
+ssize_t KeyboardInputMapper::findKeyDown(int32_t scanCode) {
+    size_t n = mKeyDowns.size();
+    for (size_t i = 0; i < n; i++) {
+        if (mKeyDowns[i].scanCode == scanCode) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+int32_t KeyboardInputMapper::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) {
+    return getEventHub()->getKeyCodeState(getDeviceId(), keyCode);
+}
+
+int32_t KeyboardInputMapper::getScanCodeState(uint32_t sourceMask, int32_t scanCode) {
+    return getEventHub()->getScanCodeState(getDeviceId(), scanCode);
+}
+
+bool KeyboardInputMapper::markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes,
+        const int32_t* keyCodes, uint8_t* outFlags) {
+    return getEventHub()->markSupportedKeyCodes(getDeviceId(), numCodes, keyCodes, outFlags);
+}
+
+int32_t KeyboardInputMapper::getMetaState() {
+    return mMetaState;
+}
+
+void KeyboardInputMapper::resetLedState() {
+    initializeLedState(mCapsLockLedState, ALED_CAPS_LOCK);
+    initializeLedState(mNumLockLedState, ALED_NUM_LOCK);
+    initializeLedState(mScrollLockLedState, ALED_SCROLL_LOCK);
+
+    updateLedState(true);
+}
+
+void KeyboardInputMapper::initializeLedState(LedState& ledState, int32_t led) {
+    ledState.avail = getEventHub()->hasLed(getDeviceId(), led);
+    ledState.on = false;
+}
+
+void KeyboardInputMapper::updateLedState(bool reset) {
+    updateLedStateForModifier(mCapsLockLedState, ALED_CAPS_LOCK,
+            AMETA_CAPS_LOCK_ON, reset);
+    updateLedStateForModifier(mNumLockLedState, ALED_NUM_LOCK,
+            AMETA_NUM_LOCK_ON, reset);
+    updateLedStateForModifier(mScrollLockLedState, ALED_SCROLL_LOCK,
+            AMETA_SCROLL_LOCK_ON, reset);
+}
+
+void KeyboardInputMapper::updateLedStateForModifier(LedState& ledState,
+        int32_t led, int32_t modifier, bool reset) {
+    if (ledState.avail) {
+        bool desiredState = (mMetaState & modifier) != 0;
+        if (reset || ledState.on != desiredState) {
+            getEventHub()->setLedState(getDeviceId(), led, desiredState);
+            ledState.on = desiredState;
+        }
+    }
+}
+
+
+// --- CursorInputMapper ---
+
+CursorInputMapper::CursorInputMapper(InputDevice* device) :
+        InputMapper(device) {
+}
+
+CursorInputMapper::~CursorInputMapper() {
+}
+
+uint32_t CursorInputMapper::getSources() {
+    return mSource;
+}
+
+void CursorInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
+    InputMapper::populateDeviceInfo(info);
+
+    if (mParameters.mode == Parameters::MODE_POINTER) {
+        float minX, minY, maxX, maxY;
+        if (mPointerController->getBounds(&minX, &minY, &maxX, &maxY)) {
+            info->addMotionRange(AMOTION_EVENT_AXIS_X, mSource, minX, maxX, 0.0f, 0.0f, 0.0f);
+            info->addMotionRange(AMOTION_EVENT_AXIS_Y, mSource, minY, maxY, 0.0f, 0.0f, 0.0f);
+        }
+    } else {
+        info->addMotionRange(AMOTION_EVENT_AXIS_X, mSource, -1.0f, 1.0f, 0.0f, mXScale, 0.0f);
+        info->addMotionRange(AMOTION_EVENT_AXIS_Y, mSource, -1.0f, 1.0f, 0.0f, mYScale, 0.0f);
+    }
+    info->addMotionRange(AMOTION_EVENT_AXIS_PRESSURE, mSource, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f);
+
+    if (mCursorScrollAccumulator.haveRelativeVWheel()) {
+        info->addMotionRange(AMOTION_EVENT_AXIS_VSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
+    }
+    if (mCursorScrollAccumulator.haveRelativeHWheel()) {
+        info->addMotionRange(AMOTION_EVENT_AXIS_HSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
+    }
+}
+
+void CursorInputMapper::dump(String8& dump) {
+    dump.append(INDENT2 "Cursor Input Mapper:\n");
+    dumpParameters(dump);
+    dump.appendFormat(INDENT3 "XScale: %0.3f\n", mXScale);
+    dump.appendFormat(INDENT3 "YScale: %0.3f\n", mYScale);
+    dump.appendFormat(INDENT3 "XPrecision: %0.3f\n", mXPrecision);
+    dump.appendFormat(INDENT3 "YPrecision: %0.3f\n", mYPrecision);
+    dump.appendFormat(INDENT3 "HaveVWheel: %s\n",
+            toString(mCursorScrollAccumulator.haveRelativeVWheel()));
+    dump.appendFormat(INDENT3 "HaveHWheel: %s\n",
+            toString(mCursorScrollAccumulator.haveRelativeHWheel()));
+    dump.appendFormat(INDENT3 "VWheelScale: %0.3f\n", mVWheelScale);
+    dump.appendFormat(INDENT3 "HWheelScale: %0.3f\n", mHWheelScale);
+    dump.appendFormat(INDENT3 "Orientation: %d\n", mOrientation);
+    dump.appendFormat(INDENT3 "ButtonState: 0x%08x\n", mButtonState);
+    dump.appendFormat(INDENT3 "Down: %s\n", toString(isPointerDown(mButtonState)));
+    dump.appendFormat(INDENT3 "DownTime: %lld\n", (long long)mDownTime);
+}
+
+void CursorInputMapper::configure(nsecs_t when,
+        const InputReaderConfiguration* config, uint32_t changes) {
+    InputMapper::configure(when, config, changes);
+
+    if (!changes) { // first time only
+        mCursorScrollAccumulator.configure(getDevice());
+
+        // Configure basic parameters.
+        configureParameters();
+
+        // Configure device mode.
+        switch (mParameters.mode) {
+        case Parameters::MODE_POINTER:
+            mSource = AINPUT_SOURCE_MOUSE;
+            mXPrecision = 1.0f;
+            mYPrecision = 1.0f;
+            mXScale = 1.0f;
+            mYScale = 1.0f;
+            mPointerController = getPolicy()->obtainPointerController(getDeviceId());
+            break;
+        case Parameters::MODE_NAVIGATION:
+            mSource = AINPUT_SOURCE_TRACKBALL;
+            mXPrecision = TRACKBALL_MOVEMENT_THRESHOLD;
+            mYPrecision = TRACKBALL_MOVEMENT_THRESHOLD;
+            mXScale = 1.0f / TRACKBALL_MOVEMENT_THRESHOLD;
+            mYScale = 1.0f / TRACKBALL_MOVEMENT_THRESHOLD;
+            break;
+        }
+
+        mVWheelScale = 1.0f;
+        mHWheelScale = 1.0f;
+    }
+
+    if (!changes || (changes & InputReaderConfiguration::CHANGE_POINTER_SPEED)) {
+        mPointerVelocityControl.setParameters(config->pointerVelocityControlParameters);
+        mWheelXVelocityControl.setParameters(config->wheelVelocityControlParameters);
+        mWheelYVelocityControl.setParameters(config->wheelVelocityControlParameters);
+    }
+
+    if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
+        if (mParameters.orientationAware && mParameters.hasAssociatedDisplay) {
+            DisplayViewport v;
+            if (config->getDisplayInfo(false /*external*/, &v)) {
+                mOrientation = v.orientation;
+            } else {
+                mOrientation = DISPLAY_ORIENTATION_0;
+            }
+        } else {
+            mOrientation = DISPLAY_ORIENTATION_0;
+        }
+        bumpGeneration();
+    }
+}
+
+void CursorInputMapper::configureParameters() {
+    mParameters.mode = Parameters::MODE_POINTER;
+    String8 cursorModeString;
+    if (getDevice()->getConfiguration().tryGetProperty(String8("cursor.mode"), cursorModeString)) {
+        if (cursorModeString == "navigation") {
+            mParameters.mode = Parameters::MODE_NAVIGATION;
+        } else if (cursorModeString != "pointer" && cursorModeString != "default") {
+            ALOGW("Invalid value for cursor.mode: '%s'", cursorModeString.string());
+        }
+    }
+
+    mParameters.orientationAware = false;
+    getDevice()->getConfiguration().tryGetProperty(String8("cursor.orientationAware"),
+            mParameters.orientationAware);
+
+    mParameters.hasAssociatedDisplay = false;
+    if (mParameters.mode == Parameters::MODE_POINTER || mParameters.orientationAware) {
+        mParameters.hasAssociatedDisplay = true;
+    }
+}
+
+void CursorInputMapper::dumpParameters(String8& dump) {
+    dump.append(INDENT3 "Parameters:\n");
+    dump.appendFormat(INDENT4 "HasAssociatedDisplay: %s\n",
+            toString(mParameters.hasAssociatedDisplay));
+
+    switch (mParameters.mode) {
+    case Parameters::MODE_POINTER:
+        dump.append(INDENT4 "Mode: pointer\n");
+        break;
+    case Parameters::MODE_NAVIGATION:
+        dump.append(INDENT4 "Mode: navigation\n");
+        break;
+    default:
+        ALOG_ASSERT(false);
+    }
+
+    dump.appendFormat(INDENT4 "OrientationAware: %s\n",
+            toString(mParameters.orientationAware));
+}
+
+void CursorInputMapper::reset(nsecs_t when) {
+    mButtonState = 0;
+    mDownTime = 0;
+
+    mPointerVelocityControl.reset();
+    mWheelXVelocityControl.reset();
+    mWheelYVelocityControl.reset();
+
+    mCursorButtonAccumulator.reset(getDevice());
+    mCursorMotionAccumulator.reset(getDevice());
+    mCursorScrollAccumulator.reset(getDevice());
+
+    InputMapper::reset(when);
+}
+
+void CursorInputMapper::process(const RawEvent* rawEvent) {
+    mCursorButtonAccumulator.process(rawEvent);
+    mCursorMotionAccumulator.process(rawEvent);
+    mCursorScrollAccumulator.process(rawEvent);
+
+    if (rawEvent->type == EV_SYN && rawEvent->code == SYN_REPORT) {
+        sync(rawEvent->when);
+    }
+}
+
+void CursorInputMapper::sync(nsecs_t when) {
+    int32_t lastButtonState = mButtonState;
+    int32_t currentButtonState = mCursorButtonAccumulator.getButtonState();
+    mButtonState = currentButtonState;
+
+    bool wasDown = isPointerDown(lastButtonState);
+    bool down = isPointerDown(currentButtonState);
+    bool downChanged;
+    if (!wasDown && down) {
+        mDownTime = when;
+        downChanged = true;
+    } else if (wasDown && !down) {
+        downChanged = true;
+    } else {
+        downChanged = false;
+    }
+    nsecs_t downTime = mDownTime;
+    bool buttonsChanged = currentButtonState != lastButtonState;
+    int32_t buttonsPressed = currentButtonState & ~lastButtonState;
+    int32_t buttonsReleased = lastButtonState & ~currentButtonState;
+
+    float deltaX = mCursorMotionAccumulator.getRelativeX() * mXScale;
+    float deltaY = mCursorMotionAccumulator.getRelativeY() * mYScale;
+    bool moved = deltaX != 0 || deltaY != 0;
+
+    // Rotate delta according to orientation if needed.
+    if (mParameters.orientationAware && mParameters.hasAssociatedDisplay
+            && (deltaX != 0.0f || deltaY != 0.0f)) {
+        rotateDelta(mOrientation, &deltaX, &deltaY);
+    }
+
+    // Move the pointer.
+    PointerProperties pointerProperties;
+    pointerProperties.clear();
+    pointerProperties.id = 0;
+    pointerProperties.toolType = AMOTION_EVENT_TOOL_TYPE_MOUSE;
+
+    PointerCoords pointerCoords;
+    pointerCoords.clear();
+
+    float vscroll = mCursorScrollAccumulator.getRelativeVWheel();
+    float hscroll = mCursorScrollAccumulator.getRelativeHWheel();
+    bool scrolled = vscroll != 0 || hscroll != 0;
+
+    mWheelYVelocityControl.move(when, NULL, &vscroll);
+    mWheelXVelocityControl.move(when, &hscroll, NULL);
+
+    mPointerVelocityControl.move(when, &deltaX, &deltaY);
+
+    int32_t displayId;
+    if (mPointerController != NULL) {
+        if (moved || scrolled || buttonsChanged) {
+            mPointerController->setPresentation(
+                    PointerControllerInterface::PRESENTATION_POINTER);
+
+            if (moved) {
+                mPointerController->move(deltaX, deltaY);
+            }
+
+            if (buttonsChanged) {
+                mPointerController->setButtonState(currentButtonState);
+            }
+
+            mPointerController->unfade(PointerControllerInterface::TRANSITION_IMMEDIATE);
+        }
+
+        float x, y;
+        mPointerController->getPosition(&x, &y);
+        pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x);
+        pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y);
+        displayId = ADISPLAY_ID_DEFAULT;
+    } else {
+        pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, deltaX);
+        pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, deltaY);
+        displayId = ADISPLAY_ID_NONE;
+    }
+
+    pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, down ? 1.0f : 0.0f);
+
+    // Moving an external trackball or mouse should wake the device.
+    // We don't do this for internal cursor devices to prevent them from waking up
+    // the device in your pocket.
+    // TODO: Use the input device configuration to control this behavior more finely.
+    uint32_t policyFlags = 0;
+    if ((buttonsPressed || moved || scrolled) && getDevice()->isExternal()) {
+        policyFlags |= POLICY_FLAG_WAKE;
+    }
+
+    // Synthesize key down from buttons if needed.
+    synthesizeButtonKeys(getContext(), AKEY_EVENT_ACTION_DOWN, when, getDeviceId(), mSource,
+            policyFlags, lastButtonState, currentButtonState);
+
+    // Send motion event.
+    if (downChanged || moved || scrolled || buttonsChanged) {
+        int32_t metaState = mContext->getGlobalMetaState();
+        int32_t buttonState = lastButtonState;
+        int32_t motionEventAction;
+        if (downChanged) {
+            motionEventAction = down ? AMOTION_EVENT_ACTION_DOWN : AMOTION_EVENT_ACTION_UP;
+        } else if (down || mPointerController == NULL) {
+            motionEventAction = AMOTION_EVENT_ACTION_MOVE;
+        } else {
+            motionEventAction = AMOTION_EVENT_ACTION_HOVER_MOVE;
+        }
+
+        if (buttonsReleased) {
+            BitSet32 released(buttonsReleased);
+            while (!released.isEmpty()) {
+                int32_t actionButton = BitSet32::valueForBit(released.clearFirstMarkedBit());
+                buttonState &= ~actionButton;
+                NotifyMotionArgs releaseArgs(when, getDeviceId(), mSource, policyFlags,
+                        AMOTION_EVENT_ACTION_BUTTON_RELEASE, actionButton, 0,
+                        metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
+                        displayId, 1, &pointerProperties, &pointerCoords,
+                        mXPrecision, mYPrecision, downTime);
+                getListener()->notifyMotion(&releaseArgs);
+            }
+        }
+
+        NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
+                motionEventAction, 0, 0, metaState, currentButtonState,
+                AMOTION_EVENT_EDGE_FLAG_NONE,
+                displayId, 1, &pointerProperties, &pointerCoords,
+                mXPrecision, mYPrecision, downTime);
+        getListener()->notifyMotion(&args);
+
+        if (buttonsPressed) {
+            BitSet32 pressed(buttonsPressed);
+            while (!pressed.isEmpty()) {
+                int32_t actionButton = BitSet32::valueForBit(pressed.clearFirstMarkedBit());
+                buttonState |= actionButton;
+                NotifyMotionArgs pressArgs(when, getDeviceId(), mSource, policyFlags,
+                        AMOTION_EVENT_ACTION_BUTTON_PRESS, actionButton, 0,
+                        metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
+                        displayId, 1, &pointerProperties, &pointerCoords,
+                        mXPrecision, mYPrecision, downTime);
+                getListener()->notifyMotion(&pressArgs);
+            }
+        }
+
+        ALOG_ASSERT(buttonState == currentButtonState);
+
+        // Send hover move after UP to tell the application that the mouse is hovering now.
+        if (motionEventAction == AMOTION_EVENT_ACTION_UP
+                && mPointerController != NULL) {
+            NotifyMotionArgs hoverArgs(when, getDeviceId(), mSource, policyFlags,
+                    AMOTION_EVENT_ACTION_HOVER_MOVE, 0, 0,
+                    metaState, currentButtonState, AMOTION_EVENT_EDGE_FLAG_NONE,
+                    displayId, 1, &pointerProperties, &pointerCoords,
+                    mXPrecision, mYPrecision, downTime);
+            getListener()->notifyMotion(&hoverArgs);
+        }
+
+        // Send scroll events.
+        if (scrolled) {
+            pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_VSCROLL, vscroll);
+            pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_HSCROLL, hscroll);
+
+            NotifyMotionArgs scrollArgs(when, getDeviceId(), mSource, policyFlags,
+                    AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, currentButtonState,
+                    AMOTION_EVENT_EDGE_FLAG_NONE,
+                    displayId, 1, &pointerProperties, &pointerCoords,
+                    mXPrecision, mYPrecision, downTime);
+            getListener()->notifyMotion(&scrollArgs);
+        }
+    }
+
+    // Synthesize key up from buttons if needed.
+    synthesizeButtonKeys(getContext(), AKEY_EVENT_ACTION_UP, when, getDeviceId(), mSource,
+            policyFlags, lastButtonState, currentButtonState);
+
+    mCursorMotionAccumulator.finishSync();
+    mCursorScrollAccumulator.finishSync();
+}
+
+int32_t CursorInputMapper::getScanCodeState(uint32_t sourceMask, int32_t scanCode) {
+    if (scanCode >= BTN_MOUSE && scanCode < BTN_JOYSTICK) {
+        return getEventHub()->getScanCodeState(getDeviceId(), scanCode);
+    } else {
+        return AKEY_STATE_UNKNOWN;
+    }
+}
+
+void CursorInputMapper::fadePointer() {
+    if (mPointerController != NULL) {
+        mPointerController->fade(PointerControllerInterface::TRANSITION_GRADUAL);
+    }
+}
+
+
+// --- TouchInputMapper ---
+
+TouchInputMapper::TouchInputMapper(InputDevice* device) :
+        InputMapper(device),
+        mSource(0), mDeviceMode(DEVICE_MODE_DISABLED),
+        mSurfaceWidth(-1), mSurfaceHeight(-1), mSurfaceLeft(0), mSurfaceTop(0),
+        mSurfaceOrientation(DISPLAY_ORIENTATION_0) {
+}
+
+TouchInputMapper::~TouchInputMapper() {
+}
+
+uint32_t TouchInputMapper::getSources() {
+    return mSource;
+}
+
+void TouchInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
+    InputMapper::populateDeviceInfo(info);
+
+    if (mDeviceMode != DEVICE_MODE_DISABLED) {
+        info->addMotionRange(mOrientedRanges.x);
+        info->addMotionRange(mOrientedRanges.y);
+        info->addMotionRange(mOrientedRanges.pressure);
+
+        if (mOrientedRanges.haveSize) {
+            info->addMotionRange(mOrientedRanges.size);
+        }
+
+        if (mOrientedRanges.haveTouchSize) {
+            info->addMotionRange(mOrientedRanges.touchMajor);
+            info->addMotionRange(mOrientedRanges.touchMinor);
+        }
+
+        if (mOrientedRanges.haveToolSize) {
+            info->addMotionRange(mOrientedRanges.toolMajor);
+            info->addMotionRange(mOrientedRanges.toolMinor);
+        }
+
+        if (mOrientedRanges.haveOrientation) {
+            info->addMotionRange(mOrientedRanges.orientation);
+        }
+
+        if (mOrientedRanges.haveDistance) {
+            info->addMotionRange(mOrientedRanges.distance);
+        }
+
+        if (mOrientedRanges.haveTilt) {
+            info->addMotionRange(mOrientedRanges.tilt);
+        }
+
+        if (mCursorScrollAccumulator.haveRelativeVWheel()) {
+            info->addMotionRange(AMOTION_EVENT_AXIS_VSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f,
+                    0.0f);
+        }
+        if (mCursorScrollAccumulator.haveRelativeHWheel()) {
+            info->addMotionRange(AMOTION_EVENT_AXIS_HSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f,
+                    0.0f);
+        }
+        if (mCalibration.coverageCalibration == Calibration::COVERAGE_CALIBRATION_BOX) {
+            const InputDeviceInfo::MotionRange& x = mOrientedRanges.x;
+            const InputDeviceInfo::MotionRange& y = mOrientedRanges.y;
+            info->addMotionRange(AMOTION_EVENT_AXIS_GENERIC_1, mSource, x.min, x.max, x.flat,
+                    x.fuzz, x.resolution);
+            info->addMotionRange(AMOTION_EVENT_AXIS_GENERIC_2, mSource, y.min, y.max, y.flat,
+                    y.fuzz, y.resolution);
+            info->addMotionRange(AMOTION_EVENT_AXIS_GENERIC_3, mSource, x.min, x.max, x.flat,
+                    x.fuzz, x.resolution);
+            info->addMotionRange(AMOTION_EVENT_AXIS_GENERIC_4, mSource, y.min, y.max, y.flat,
+                    y.fuzz, y.resolution);
+        }
+        info->setButtonUnderPad(mParameters.hasButtonUnderPad);
+    }
+}
+
+void TouchInputMapper::dump(String8& dump) {
+    dump.append(INDENT2 "Touch Input Mapper:\n");
+    dumpParameters(dump);
+    dumpVirtualKeys(dump);
+    dumpRawPointerAxes(dump);
+    dumpCalibration(dump);
+    dumpAffineTransformation(dump);
+    dumpSurface(dump);
+
+    dump.appendFormat(INDENT3 "Translation and Scaling Factors:\n");
+    dump.appendFormat(INDENT4 "XTranslate: %0.3f\n", mXTranslate);
+    dump.appendFormat(INDENT4 "YTranslate: %0.3f\n", mYTranslate);
+    dump.appendFormat(INDENT4 "XScale: %0.3f\n", mXScale);
+    dump.appendFormat(INDENT4 "YScale: %0.3f\n", mYScale);
+    dump.appendFormat(INDENT4 "XPrecision: %0.3f\n", mXPrecision);
+    dump.appendFormat(INDENT4 "YPrecision: %0.3f\n", mYPrecision);
+    dump.appendFormat(INDENT4 "GeometricScale: %0.3f\n", mGeometricScale);
+    dump.appendFormat(INDENT4 "PressureScale: %0.3f\n", mPressureScale);
+    dump.appendFormat(INDENT4 "SizeScale: %0.3f\n", mSizeScale);
+    dump.appendFormat(INDENT4 "OrientationScale: %0.3f\n", mOrientationScale);
+    dump.appendFormat(INDENT4 "DistanceScale: %0.3f\n", mDistanceScale);
+    dump.appendFormat(INDENT4 "HaveTilt: %s\n", toString(mHaveTilt));
+    dump.appendFormat(INDENT4 "TiltXCenter: %0.3f\n", mTiltXCenter);
+    dump.appendFormat(INDENT4 "TiltXScale: %0.3f\n", mTiltXScale);
+    dump.appendFormat(INDENT4 "TiltYCenter: %0.3f\n", mTiltYCenter);
+    dump.appendFormat(INDENT4 "TiltYScale: %0.3f\n", mTiltYScale);
+
+    dump.appendFormat(INDENT3 "Last Raw Button State: 0x%08x\n", mLastRawState.buttonState);
+    dump.appendFormat(INDENT3 "Last Raw Touch: pointerCount=%d\n",
+            mLastRawState.rawPointerData.pointerCount);
+    for (uint32_t i = 0; i < mLastRawState.rawPointerData.pointerCount; i++) {
+        const RawPointerData::Pointer& pointer = mLastRawState.rawPointerData.pointers[i];
+        dump.appendFormat(INDENT4 "[%d]: id=%d, x=%d, y=%d, pressure=%d, "
+                "touchMajor=%d, touchMinor=%d, toolMajor=%d, toolMinor=%d, "
+                "orientation=%d, tiltX=%d, tiltY=%d, distance=%d, "
+                "toolType=%d, isHovering=%s\n", i,
+                pointer.id, pointer.x, pointer.y, pointer.pressure,
+                pointer.touchMajor, pointer.touchMinor,
+                pointer.toolMajor, pointer.toolMinor,
+                pointer.orientation, pointer.tiltX, pointer.tiltY, pointer.distance,
+                pointer.toolType, toString(pointer.isHovering));
+    }
+
+    dump.appendFormat(INDENT3 "Last Cooked Button State: 0x%08x\n", mLastCookedState.buttonState);
+    dump.appendFormat(INDENT3 "Last Cooked Touch: pointerCount=%d\n",
+            mLastCookedState.cookedPointerData.pointerCount);
+    for (uint32_t i = 0; i < mLastCookedState.cookedPointerData.pointerCount; i++) {
+        const PointerProperties& pointerProperties =
+                mLastCookedState.cookedPointerData.pointerProperties[i];
+        const PointerCoords& pointerCoords = mLastCookedState.cookedPointerData.pointerCoords[i];
+        dump.appendFormat(INDENT4 "[%d]: id=%d, x=%0.3f, y=%0.3f, pressure=%0.3f, "
+                "touchMajor=%0.3f, touchMinor=%0.3f, toolMajor=%0.3f, toolMinor=%0.3f, "
+                "orientation=%0.3f, tilt=%0.3f, distance=%0.3f, "
+                "toolType=%d, isHovering=%s\n", i,
+                pointerProperties.id,
+                pointerCoords.getX(),
+                pointerCoords.getY(),
+                pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE),
+                pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR),
+                pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR),
+                pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR),
+                pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR),
+                pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION),
+                pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_TILT),
+                pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_DISTANCE),
+                pointerProperties.toolType,
+                toString(mLastCookedState.cookedPointerData.isHovering(i)));
+    }
+
+    dump.append(INDENT3 "Stylus Fusion:\n");
+    dump.appendFormat(INDENT4 "ExternalStylusConnected: %s\n",
+            toString(mExternalStylusConnected));
+    dump.appendFormat(INDENT4 "External Stylus ID: %" PRId64 "\n", mExternalStylusId);
+    dump.appendFormat(INDENT4 "External Stylus Data Timeout: %" PRId64 "\n",
+            mExternalStylusFusionTimeout);
+    dump.append(INDENT3 "External Stylus State:\n");
+    dumpStylusState(dump, mExternalStylusState);
+
+    if (mDeviceMode == DEVICE_MODE_POINTER) {
+        dump.appendFormat(INDENT3 "Pointer Gesture Detector:\n");
+        dump.appendFormat(INDENT4 "XMovementScale: %0.3f\n",
+                mPointerXMovementScale);
+        dump.appendFormat(INDENT4 "YMovementScale: %0.3f\n",
+                mPointerYMovementScale);
+        dump.appendFormat(INDENT4 "XZoomScale: %0.3f\n",
+                mPointerXZoomScale);
+        dump.appendFormat(INDENT4 "YZoomScale: %0.3f\n",
+                mPointerYZoomScale);
+        dump.appendFormat(INDENT4 "MaxSwipeWidth: %f\n",
+                mPointerGestureMaxSwipeWidth);
+    }
+}
+
+void TouchInputMapper::configure(nsecs_t when,
+        const InputReaderConfiguration* config, uint32_t changes) {
+    InputMapper::configure(when, config, changes);
+
+    mConfig = *config;
+
+    if (!changes) { // first time only
+        // Configure basic parameters.
+        configureParameters();
+
+        // Configure common accumulators.
+        mCursorScrollAccumulator.configure(getDevice());
+        mTouchButtonAccumulator.configure(getDevice());
+
+        // Configure absolute axis information.
+        configureRawPointerAxes();
+
+        // Prepare input device calibration.
+        parseCalibration();
+        resolveCalibration();
+    }
+
+    if (!changes || (changes & InputReaderConfiguration::CHANGE_TOUCH_AFFINE_TRANSFORMATION)) {
+        // Update location calibration to reflect current settings
+        updateAffineTransformation();
+    }
+
+    if (!changes || (changes & InputReaderConfiguration::CHANGE_POINTER_SPEED)) {
+        // Update pointer speed.
+        mPointerVelocityControl.setParameters(mConfig.pointerVelocityControlParameters);
+        mWheelXVelocityControl.setParameters(mConfig.wheelVelocityControlParameters);
+        mWheelYVelocityControl.setParameters(mConfig.wheelVelocityControlParameters);
+    }
+
+    bool resetNeeded = false;
+    if (!changes || (changes & (InputReaderConfiguration::CHANGE_DISPLAY_INFO
+            | InputReaderConfiguration::CHANGE_POINTER_GESTURE_ENABLEMENT
+            | InputReaderConfiguration::CHANGE_SHOW_TOUCHES
+            | InputReaderConfiguration::CHANGE_EXTERNAL_STYLUS_PRESENCE))) {
+        // Configure device sources, surface dimensions, orientation and
+        // scaling factors.
+        configureSurface(when, &resetNeeded);
+    }
+
+    if (changes && resetNeeded) {
+        // Send reset, unless this is the first time the device has been configured,
+        // in which case the reader will call reset itself after all mappers are ready.
+        getDevice()->notifyReset(when);
+    }
+}
+
+void TouchInputMapper::resolveExternalStylusPresence() {
+    Vector<InputDeviceInfo> devices;
+    mContext->getExternalStylusDevices(devices);
+    mExternalStylusConnected = !devices.isEmpty();
+
+    if (!mExternalStylusConnected) {
+        resetExternalStylus();
+    }
+}
+
+void TouchInputMapper::configureParameters() {
+    // Use the pointer presentation mode for devices that do not support distinct
+    // multitouch.  The spot-based presentation relies on being able to accurately
+    // locate two or more fingers on the touch pad.
+    mParameters.gestureMode = getEventHub()->hasInputProperty(getDeviceId(), INPUT_PROP_SEMI_MT)
+            ? Parameters::GESTURE_MODE_POINTER : Parameters::GESTURE_MODE_SPOTS;
+
+    String8 gestureModeString;
+    if (getDevice()->getConfiguration().tryGetProperty(String8("touch.gestureMode"),
+            gestureModeString)) {
+        if (gestureModeString == "pointer") {
+            mParameters.gestureMode = Parameters::GESTURE_MODE_POINTER;
+        } else if (gestureModeString == "spots") {
+            mParameters.gestureMode = Parameters::GESTURE_MODE_SPOTS;
+        } else if (gestureModeString != "default") {
+            ALOGW("Invalid value for touch.gestureMode: '%s'", gestureModeString.string());
+        }
+    }
+
+    if (getEventHub()->hasInputProperty(getDeviceId(), INPUT_PROP_DIRECT)) {
+        // The device is a touch screen.
+        mParameters.deviceType = Parameters::DEVICE_TYPE_TOUCH_SCREEN;
+    } else if (getEventHub()->hasInputProperty(getDeviceId(), INPUT_PROP_POINTER)) {
+        // The device is a pointing device like a track pad.
+        mParameters.deviceType = Parameters::DEVICE_TYPE_POINTER;
+    } else if (getEventHub()->hasRelativeAxis(getDeviceId(), REL_X)
+            || getEventHub()->hasRelativeAxis(getDeviceId(), REL_Y)) {
+        // The device is a cursor device with a touch pad attached.
+        // By default don't use the touch pad to move the pointer.
+        mParameters.deviceType = Parameters::DEVICE_TYPE_TOUCH_PAD;
+    } else {
+        // The device is a touch pad of unknown purpose.
+        mParameters.deviceType = Parameters::DEVICE_TYPE_POINTER;
+    }
+
+    mParameters.hasButtonUnderPad=
+            getEventHub()->hasInputProperty(getDeviceId(), INPUT_PROP_BUTTONPAD);
+
+    String8 deviceTypeString;
+    if (getDevice()->getConfiguration().tryGetProperty(String8("touch.deviceType"),
+            deviceTypeString)) {
+        if (deviceTypeString == "touchScreen") {
+            mParameters.deviceType = Parameters::DEVICE_TYPE_TOUCH_SCREEN;
+        } else if (deviceTypeString == "touchPad") {
+            mParameters.deviceType = Parameters::DEVICE_TYPE_TOUCH_PAD;
+        } else if (deviceTypeString == "touchNavigation") {
+            mParameters.deviceType = Parameters::DEVICE_TYPE_TOUCH_NAVIGATION;
+        } else if (deviceTypeString == "pointer") {
+            mParameters.deviceType = Parameters::DEVICE_TYPE_POINTER;
+        } else if (deviceTypeString != "default") {
+            ALOGW("Invalid value for touch.deviceType: '%s'", deviceTypeString.string());
+        }
+    }
+
+    mParameters.orientationAware = mParameters.deviceType == Parameters::DEVICE_TYPE_TOUCH_SCREEN;
+    getDevice()->getConfiguration().tryGetProperty(String8("touch.orientationAware"),
+            mParameters.orientationAware);
+
+    mParameters.hasAssociatedDisplay = false;
+    mParameters.associatedDisplayIsExternal = false;
+    if (mParameters.orientationAware
+            || mParameters.deviceType == Parameters::DEVICE_TYPE_TOUCH_SCREEN
+            || mParameters.deviceType == Parameters::DEVICE_TYPE_POINTER) {
+        mParameters.hasAssociatedDisplay = true;
+        mParameters.associatedDisplayIsExternal =
+                mParameters.deviceType == Parameters::DEVICE_TYPE_TOUCH_SCREEN
+                        && getDevice()->isExternal();
+    }
+
+    // Initial downs on external touch devices should wake the device.
+    // Normally we don't do this for internal touch screens to prevent them from waking
+    // up in your pocket but you can enable it using the input device configuration.
+    mParameters.wake = getDevice()->isExternal();
+    getDevice()->getConfiguration().tryGetProperty(String8("touch.wake"),
+            mParameters.wake);
+}
+
+void TouchInputMapper::dumpParameters(String8& dump) {
+    dump.append(INDENT3 "Parameters:\n");
+
+    switch (mParameters.gestureMode) {
+    case Parameters::GESTURE_MODE_POINTER:
+        dump.append(INDENT4 "GestureMode: pointer\n");
+        break;
+    case Parameters::GESTURE_MODE_SPOTS:
+        dump.append(INDENT4 "GestureMode: spots\n");
+        break;
+    default:
+        assert(false);
+    }
+
+    switch (mParameters.deviceType) {
+    case Parameters::DEVICE_TYPE_TOUCH_SCREEN:
+        dump.append(INDENT4 "DeviceType: touchScreen\n");
+        break;
+    case Parameters::DEVICE_TYPE_TOUCH_PAD:
+        dump.append(INDENT4 "DeviceType: touchPad\n");
+        break;
+    case Parameters::DEVICE_TYPE_TOUCH_NAVIGATION:
+        dump.append(INDENT4 "DeviceType: touchNavigation\n");
+        break;
+    case Parameters::DEVICE_TYPE_POINTER:
+        dump.append(INDENT4 "DeviceType: pointer\n");
+        break;
+    default:
+        ALOG_ASSERT(false);
+    }
+
+    dump.appendFormat(INDENT4 "AssociatedDisplay: hasAssociatedDisplay=%s, isExternal=%s\n",
+            toString(mParameters.hasAssociatedDisplay),
+            toString(mParameters.associatedDisplayIsExternal));
+    dump.appendFormat(INDENT4 "OrientationAware: %s\n",
+            toString(mParameters.orientationAware));
+}
+
+void TouchInputMapper::configureRawPointerAxes() {
+    mRawPointerAxes.clear();
+}
+
+void TouchInputMapper::dumpRawPointerAxes(String8& dump) {
+    dump.append(INDENT3 "Raw Touch Axes:\n");
+    dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.x, "X");
+    dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.y, "Y");
+    dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.pressure, "Pressure");
+    dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.touchMajor, "TouchMajor");
+    dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.touchMinor, "TouchMinor");
+    dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.toolMajor, "ToolMajor");
+    dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.toolMinor, "ToolMinor");
+    dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.orientation, "Orientation");
+    dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.distance, "Distance");
+    dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.tiltX, "TiltX");
+    dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.tiltY, "TiltY");
+    dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.trackingId, "TrackingId");
+    dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.slot, "Slot");
+}
+
+bool TouchInputMapper::hasExternalStylus() const {
+    return mExternalStylusConnected;
+}
+
+void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
+    int32_t oldDeviceMode = mDeviceMode;
+
+    resolveExternalStylusPresence();
+
+    // Determine device mode.
+    if (mParameters.deviceType == Parameters::DEVICE_TYPE_POINTER
+            && mConfig.pointerGesturesEnabled) {
+        mSource = AINPUT_SOURCE_MOUSE;
+        mDeviceMode = DEVICE_MODE_POINTER;
+        if (hasStylus()) {
+            mSource |= AINPUT_SOURCE_STYLUS;
+        }
+    } else if (mParameters.deviceType == Parameters::DEVICE_TYPE_TOUCH_SCREEN
+            && mParameters.hasAssociatedDisplay) {
+        mSource = AINPUT_SOURCE_TOUCHSCREEN;
+        mDeviceMode = DEVICE_MODE_DIRECT;
+        if (hasStylus()) {
+            mSource |= AINPUT_SOURCE_STYLUS;
+        }
+        if (hasExternalStylus()) {
+            mSource |= AINPUT_SOURCE_BLUETOOTH_STYLUS;
+        }
+    } else if (mParameters.deviceType == Parameters::DEVICE_TYPE_TOUCH_NAVIGATION) {
+        mSource = AINPUT_SOURCE_TOUCH_NAVIGATION;
+        mDeviceMode = DEVICE_MODE_NAVIGATION;
+    } else {
+        mSource = AINPUT_SOURCE_TOUCHPAD;
+        mDeviceMode = DEVICE_MODE_UNSCALED;
+    }
+
+    // Ensure we have valid X and Y axes.
+    if (!mRawPointerAxes.x.valid || !mRawPointerAxes.y.valid) {
+        ALOGW(INDENT "Touch device '%s' did not report support for X or Y axis!  "
+                "The device will be inoperable.", getDeviceName().string());
+        mDeviceMode = DEVICE_MODE_DISABLED;
+        return;
+    }
+
+    // Raw width and height in the natural orientation.
+    int32_t rawWidth = mRawPointerAxes.x.maxValue - mRawPointerAxes.x.minValue + 1;
+    int32_t rawHeight = mRawPointerAxes.y.maxValue - mRawPointerAxes.y.minValue + 1;
+
+    // Get associated display dimensions.
+    DisplayViewport newViewport;
+    if (mParameters.hasAssociatedDisplay) {
+        if (!mConfig.getDisplayInfo(mParameters.associatedDisplayIsExternal, &newViewport)) {
+            ALOGI(INDENT "Touch device '%s' could not query the properties of its associated "
+                    "display.  The device will be inoperable until the display size "
+                    "becomes available.",
+                    getDeviceName().string());
+            mDeviceMode = DEVICE_MODE_DISABLED;
+            return;
+        }
+    } else {
+        newViewport.setNonDisplayViewport(rawWidth, rawHeight);
+    }
+    bool viewportChanged = mViewport != newViewport;
+    if (viewportChanged) {
+        mViewport = newViewport;
+
+        if (mDeviceMode == DEVICE_MODE_DIRECT || mDeviceMode == DEVICE_MODE_POINTER) {
+            // Convert rotated viewport to natural surface coordinates.
+            int32_t naturalLogicalWidth, naturalLogicalHeight;
+            int32_t naturalPhysicalWidth, naturalPhysicalHeight;
+            int32_t naturalPhysicalLeft, naturalPhysicalTop;
+            int32_t naturalDeviceWidth, naturalDeviceHeight;
+            switch (mViewport.orientation) {
+            case DISPLAY_ORIENTATION_90:
+                naturalLogicalWidth = mViewport.logicalBottom - mViewport.logicalTop;
+                naturalLogicalHeight = mViewport.logicalRight - mViewport.logicalLeft;
+                naturalPhysicalWidth = mViewport.physicalBottom - mViewport.physicalTop;
+                naturalPhysicalHeight = mViewport.physicalRight - mViewport.physicalLeft;
+                naturalPhysicalLeft = mViewport.deviceHeight - mViewport.physicalBottom;
+                naturalPhysicalTop = mViewport.physicalLeft;
+                naturalDeviceWidth = mViewport.deviceHeight;
+                naturalDeviceHeight = mViewport.deviceWidth;
+                break;
+            case DISPLAY_ORIENTATION_180:
+                naturalLogicalWidth = mViewport.logicalRight - mViewport.logicalLeft;
+                naturalLogicalHeight = mViewport.logicalBottom - mViewport.logicalTop;
+                naturalPhysicalWidth = mViewport.physicalRight - mViewport.physicalLeft;
+                naturalPhysicalHeight = mViewport.physicalBottom - mViewport.physicalTop;
+                naturalPhysicalLeft = mViewport.deviceWidth - mViewport.physicalRight;
+                naturalPhysicalTop = mViewport.deviceHeight - mViewport.physicalBottom;
+                naturalDeviceWidth = mViewport.deviceWidth;
+                naturalDeviceHeight = mViewport.deviceHeight;
+                break;
+            case DISPLAY_ORIENTATION_270:
+                naturalLogicalWidth = mViewport.logicalBottom - mViewport.logicalTop;
+                naturalLogicalHeight = mViewport.logicalRight - mViewport.logicalLeft;
+                naturalPhysicalWidth = mViewport.physicalBottom - mViewport.physicalTop;
+                naturalPhysicalHeight = mViewport.physicalRight - mViewport.physicalLeft;
+                naturalPhysicalLeft = mViewport.physicalTop;
+                naturalPhysicalTop = mViewport.deviceWidth - mViewport.physicalRight;
+                naturalDeviceWidth = mViewport.deviceHeight;
+                naturalDeviceHeight = mViewport.deviceWidth;
+                break;
+            case DISPLAY_ORIENTATION_0:
+            default:
+                naturalLogicalWidth = mViewport.logicalRight - mViewport.logicalLeft;
+                naturalLogicalHeight = mViewport.logicalBottom - mViewport.logicalTop;
+                naturalPhysicalWidth = mViewport.physicalRight - mViewport.physicalLeft;
+                naturalPhysicalHeight = mViewport.physicalBottom - mViewport.physicalTop;
+                naturalPhysicalLeft = mViewport.physicalLeft;
+                naturalPhysicalTop = mViewport.physicalTop;
+                naturalDeviceWidth = mViewport.deviceWidth;
+                naturalDeviceHeight = mViewport.deviceHeight;
+                break;
+            }
+
+            mSurfaceWidth = naturalLogicalWidth * naturalDeviceWidth / naturalPhysicalWidth;
+            mSurfaceHeight = naturalLogicalHeight * naturalDeviceHeight / naturalPhysicalHeight;
+            mSurfaceLeft = naturalPhysicalLeft * naturalLogicalWidth / naturalPhysicalWidth;
+            mSurfaceTop = naturalPhysicalTop * naturalLogicalHeight / naturalPhysicalHeight;
+
+            mSurfaceOrientation = mParameters.orientationAware ?
+                    mViewport.orientation : DISPLAY_ORIENTATION_0;
+        } else {
+            mSurfaceWidth = rawWidth;
+            mSurfaceHeight = rawHeight;
+            mSurfaceLeft = 0;
+            mSurfaceTop = 0;
+            mSurfaceOrientation = DISPLAY_ORIENTATION_0;
+        }
+    }
+
+    // If moving between pointer modes, need to reset some state.
+    bool deviceModeChanged = mDeviceMode != oldDeviceMode;
+    if (deviceModeChanged) {
+        mOrientedRanges.clear();
+    }
+
+    // Create pointer controller if needed.
+    if (mDeviceMode == DEVICE_MODE_POINTER ||
+            (mDeviceMode == DEVICE_MODE_DIRECT && mConfig.showTouches)) {
+        if (mPointerController == NULL) {
+            mPointerController = getPolicy()->obtainPointerController(getDeviceId());
+        }
+    } else {
+        mPointerController.clear();
+    }
+
+    if (viewportChanged || deviceModeChanged) {
+        ALOGI("Device reconfigured: id=%d, name='%s', size %dx%d, orientation %d, mode %d, "
+                "display id %d",
+                getDeviceId(), getDeviceName().string(), mSurfaceWidth, mSurfaceHeight,
+                mSurfaceOrientation, mDeviceMode, mViewport.displayId);
+
+        // Configure X and Y factors.
+        mXScale = float(mSurfaceWidth) / rawWidth;
+        mYScale = float(mSurfaceHeight) / rawHeight;
+        mXTranslate = -mSurfaceLeft;
+        mYTranslate = -mSurfaceTop;
+        mXPrecision = 1.0f / mXScale;
+        mYPrecision = 1.0f / mYScale;
+
+        mOrientedRanges.x.axis = AMOTION_EVENT_AXIS_X;
+        mOrientedRanges.x.source = mSource;
+        mOrientedRanges.y.axis = AMOTION_EVENT_AXIS_Y;
+        mOrientedRanges.y.source = mSource;
+
+        configureVirtualKeys();
+
+        // Scale factor for terms that are not oriented in a particular axis.
+        // If the pixels are square then xScale == yScale otherwise we fake it
+        // by choosing an average.
+        mGeometricScale = avg(mXScale, mYScale);
+
+        // Size of diagonal axis.
+        float diagonalSize = hypotf(mSurfaceWidth, mSurfaceHeight);
+
+        // Size factors.
+        if (mCalibration.sizeCalibration != Calibration::SIZE_CALIBRATION_NONE) {
+            if (mRawPointerAxes.touchMajor.valid
+                    && mRawPointerAxes.touchMajor.maxValue != 0) {
+                mSizeScale = 1.0f / mRawPointerAxes.touchMajor.maxValue;
+            } else if (mRawPointerAxes.toolMajor.valid
+                    && mRawPointerAxes.toolMajor.maxValue != 0) {
+                mSizeScale = 1.0f / mRawPointerAxes.toolMajor.maxValue;
+            } else {
+                mSizeScale = 0.0f;
+            }
+
+            mOrientedRanges.haveTouchSize = true;
+            mOrientedRanges.haveToolSize = true;
+            mOrientedRanges.haveSize = true;
+
+            mOrientedRanges.touchMajor.axis = AMOTION_EVENT_AXIS_TOUCH_MAJOR;
+            mOrientedRanges.touchMajor.source = mSource;
+            mOrientedRanges.touchMajor.min = 0;
+            mOrientedRanges.touchMajor.max = diagonalSize;
+            mOrientedRanges.touchMajor.flat = 0;
+            mOrientedRanges.touchMajor.fuzz = 0;
+            mOrientedRanges.touchMajor.resolution = 0;
+
+            mOrientedRanges.touchMinor = mOrientedRanges.touchMajor;
+            mOrientedRanges.touchMinor.axis = AMOTION_EVENT_AXIS_TOUCH_MINOR;
+
+            mOrientedRanges.toolMajor.axis = AMOTION_EVENT_AXIS_TOOL_MAJOR;
+            mOrientedRanges.toolMajor.source = mSource;
+            mOrientedRanges.toolMajor.min = 0;
+            mOrientedRanges.toolMajor.max = diagonalSize;
+            mOrientedRanges.toolMajor.flat = 0;
+            mOrientedRanges.toolMajor.fuzz = 0;
+            mOrientedRanges.toolMajor.resolution = 0;
+
+            mOrientedRanges.toolMinor = mOrientedRanges.toolMajor;
+            mOrientedRanges.toolMinor.axis = AMOTION_EVENT_AXIS_TOOL_MINOR;
+
+            mOrientedRanges.size.axis = AMOTION_EVENT_AXIS_SIZE;
+            mOrientedRanges.size.source = mSource;
+            mOrientedRanges.size.min = 0;
+            mOrientedRanges.size.max = 1.0;
+            mOrientedRanges.size.flat = 0;
+            mOrientedRanges.size.fuzz = 0;
+            mOrientedRanges.size.resolution = 0;
+        } else {
+            mSizeScale = 0.0f;
+        }
+
+        // Pressure factors.
+        mPressureScale = 0;
+        if (mCalibration.pressureCalibration == Calibration::PRESSURE_CALIBRATION_PHYSICAL
+                || mCalibration.pressureCalibration
+                        == Calibration::PRESSURE_CALIBRATION_AMPLITUDE) {
+            if (mCalibration.havePressureScale) {
+                mPressureScale = mCalibration.pressureScale;
+            } else if (mRawPointerAxes.pressure.valid
+                    && mRawPointerAxes.pressure.maxValue != 0) {
+                mPressureScale = 1.0f / mRawPointerAxes.pressure.maxValue;
+            }
+        }
+
+        mOrientedRanges.pressure.axis = AMOTION_EVENT_AXIS_PRESSURE;
+        mOrientedRanges.pressure.source = mSource;
+        mOrientedRanges.pressure.min = 0;
+        mOrientedRanges.pressure.max = 1.0;
+        mOrientedRanges.pressure.flat = 0;
+        mOrientedRanges.pressure.fuzz = 0;
+        mOrientedRanges.pressure.resolution = 0;
+
+        // Tilt
+        mTiltXCenter = 0;
+        mTiltXScale = 0;
+        mTiltYCenter = 0;
+        mTiltYScale = 0;
+        mHaveTilt = mRawPointerAxes.tiltX.valid && mRawPointerAxes.tiltY.valid;
+        if (mHaveTilt) {
+            mTiltXCenter = avg(mRawPointerAxes.tiltX.minValue,
+                    mRawPointerAxes.tiltX.maxValue);
+            mTiltYCenter = avg(mRawPointerAxes.tiltY.minValue,
+                    mRawPointerAxes.tiltY.maxValue);
+            mTiltXScale = M_PI / 180;
+            mTiltYScale = M_PI / 180;
+
+            mOrientedRanges.haveTilt = true;
+
+            mOrientedRanges.tilt.axis = AMOTION_EVENT_AXIS_TILT;
+            mOrientedRanges.tilt.source = mSource;
+            mOrientedRanges.tilt.min = 0;
+            mOrientedRanges.tilt.max = M_PI_2;
+            mOrientedRanges.tilt.flat = 0;
+            mOrientedRanges.tilt.fuzz = 0;
+            mOrientedRanges.tilt.resolution = 0;
+        }
+
+        // Orientation
+        mOrientationScale = 0;
+        if (mHaveTilt) {
+            mOrientedRanges.haveOrientation = true;
+
+            mOrientedRanges.orientation.axis = AMOTION_EVENT_AXIS_ORIENTATION;
+            mOrientedRanges.orientation.source = mSource;
+            mOrientedRanges.orientation.min = -M_PI;
+            mOrientedRanges.orientation.max = M_PI;
+            mOrientedRanges.orientation.flat = 0;
+            mOrientedRanges.orientation.fuzz = 0;
+            mOrientedRanges.orientation.resolution = 0;
+        } else if (mCalibration.orientationCalibration !=
+                Calibration::ORIENTATION_CALIBRATION_NONE) {
+            if (mCalibration.orientationCalibration
+                    == Calibration::ORIENTATION_CALIBRATION_INTERPOLATED) {
+                if (mRawPointerAxes.orientation.valid) {
+                    if (mRawPointerAxes.orientation.maxValue > 0) {
+                        mOrientationScale = M_PI_2 / mRawPointerAxes.orientation.maxValue;
+                    } else if (mRawPointerAxes.orientation.minValue < 0) {
+                        mOrientationScale = -M_PI_2 / mRawPointerAxes.orientation.minValue;
+                    } else {
+                        mOrientationScale = 0;
+                    }
+                }
+            }
+
+            mOrientedRanges.haveOrientation = true;
+
+            mOrientedRanges.orientation.axis = AMOTION_EVENT_AXIS_ORIENTATION;
+            mOrientedRanges.orientation.source = mSource;
+            mOrientedRanges.orientation.min = -M_PI_2;
+            mOrientedRanges.orientation.max = M_PI_2;
+            mOrientedRanges.orientation.flat = 0;
+            mOrientedRanges.orientation.fuzz = 0;
+            mOrientedRanges.orientation.resolution = 0;
+        }
+
+        // Distance
+        mDistanceScale = 0;
+        if (mCalibration.distanceCalibration != Calibration::DISTANCE_CALIBRATION_NONE) {
+            if (mCalibration.distanceCalibration
+                    == Calibration::DISTANCE_CALIBRATION_SCALED) {
+                if (mCalibration.haveDistanceScale) {
+                    mDistanceScale = mCalibration.distanceScale;
+                } else {
+                    mDistanceScale = 1.0f;
+                }
+            }
+
+            mOrientedRanges.haveDistance = true;
+
+            mOrientedRanges.distance.axis = AMOTION_EVENT_AXIS_DISTANCE;
+            mOrientedRanges.distance.source = mSource;
+            mOrientedRanges.distance.min =
+                    mRawPointerAxes.distance.minValue * mDistanceScale;
+            mOrientedRanges.distance.max =
+                    mRawPointerAxes.distance.maxValue * mDistanceScale;
+            mOrientedRanges.distance.flat = 0;
+            mOrientedRanges.distance.fuzz =
+                    mRawPointerAxes.distance.fuzz * mDistanceScale;
+            mOrientedRanges.distance.resolution = 0;
+        }
+
+        // Compute oriented precision, scales and ranges.
+        // Note that the maximum value reported is an inclusive maximum value so it is one
+        // unit less than the total width or height of surface.
+        switch (mSurfaceOrientation) {
+        case DISPLAY_ORIENTATION_90:
+        case DISPLAY_ORIENTATION_270:
+            mOrientedXPrecision = mYPrecision;
+            mOrientedYPrecision = mXPrecision;
+
+            mOrientedRanges.x.min = mYTranslate;
+            mOrientedRanges.x.max = mSurfaceHeight + mYTranslate - 1;
+            mOrientedRanges.x.flat = 0;
+            mOrientedRanges.x.fuzz = 0;
+            mOrientedRanges.x.resolution = mRawPointerAxes.y.resolution * mYScale;
+
+            mOrientedRanges.y.min = mXTranslate;
+            mOrientedRanges.y.max = mSurfaceWidth + mXTranslate - 1;
+            mOrientedRanges.y.flat = 0;
+            mOrientedRanges.y.fuzz = 0;
+            mOrientedRanges.y.resolution = mRawPointerAxes.x.resolution * mXScale;
+            break;
+
+        default:
+            mOrientedXPrecision = mXPrecision;
+            mOrientedYPrecision = mYPrecision;
+
+            mOrientedRanges.x.min = mXTranslate;
+            mOrientedRanges.x.max = mSurfaceWidth + mXTranslate - 1;
+            mOrientedRanges.x.flat = 0;
+            mOrientedRanges.x.fuzz = 0;
+            mOrientedRanges.x.resolution = mRawPointerAxes.x.resolution * mXScale;
+
+            mOrientedRanges.y.min = mYTranslate;
+            mOrientedRanges.y.max = mSurfaceHeight + mYTranslate - 1;
+            mOrientedRanges.y.flat = 0;
+            mOrientedRanges.y.fuzz = 0;
+            mOrientedRanges.y.resolution = mRawPointerAxes.y.resolution * mYScale;
+            break;
+        }
+
+        // Location
+        updateAffineTransformation();
+
+        if (mDeviceMode == DEVICE_MODE_POINTER) {
+            // Compute pointer gesture detection parameters.
+            float rawDiagonal = hypotf(rawWidth, rawHeight);
+            float displayDiagonal = hypotf(mSurfaceWidth, mSurfaceHeight);
+
+            // Scale movements such that one whole swipe of the touch pad covers a
+            // given area relative to the diagonal size of the display when no acceleration
+            // is applied.
+            // Assume that the touch pad has a square aspect ratio such that movements in
+            // X and Y of the same number of raw units cover the same physical distance.
+            mPointerXMovementScale = mConfig.pointerGestureMovementSpeedRatio
+                    * displayDiagonal / rawDiagonal;
+            mPointerYMovementScale = mPointerXMovementScale;
+
+            // Scale zooms to cover a smaller range of the display than movements do.
+            // This value determines the area around the pointer that is affected by freeform
+            // pointer gestures.
+            mPointerXZoomScale = mConfig.pointerGestureZoomSpeedRatio
+                    * displayDiagonal / rawDiagonal;
+            mPointerYZoomScale = mPointerXZoomScale;
+
+            // Max width between pointers to detect a swipe gesture is more than some fraction
+            // of the diagonal axis of the touch pad.  Touches that are wider than this are
+            // translated into freeform gestures.
+            mPointerGestureMaxSwipeWidth =
+                    mConfig.pointerGestureSwipeMaxWidthRatio * rawDiagonal;
+
+            // Abort current pointer usages because the state has changed.
+            abortPointerUsage(when, 0 /*policyFlags*/);
+        }
+
+        // Inform the dispatcher about the changes.
+        *outResetNeeded = true;
+        bumpGeneration();
+    }
+}
+
+void TouchInputMapper::dumpSurface(String8& dump) {
+    dump.appendFormat(INDENT3 "Viewport: displayId=%d, orientation=%d, "
+            "logicalFrame=[%d, %d, %d, %d], "
+            "physicalFrame=[%d, %d, %d, %d], "
+            "deviceSize=[%d, %d]\n",
+            mViewport.displayId, mViewport.orientation,
+            mViewport.logicalLeft, mViewport.logicalTop,
+            mViewport.logicalRight, mViewport.logicalBottom,
+            mViewport.physicalLeft, mViewport.physicalTop,
+            mViewport.physicalRight, mViewport.physicalBottom,
+            mViewport.deviceWidth, mViewport.deviceHeight);
+
+    dump.appendFormat(INDENT3 "SurfaceWidth: %dpx\n", mSurfaceWidth);
+    dump.appendFormat(INDENT3 "SurfaceHeight: %dpx\n", mSurfaceHeight);
+    dump.appendFormat(INDENT3 "SurfaceLeft: %d\n", mSurfaceLeft);
+    dump.appendFormat(INDENT3 "SurfaceTop: %d\n", mSurfaceTop);
+    dump.appendFormat(INDENT3 "SurfaceOrientation: %d\n", mSurfaceOrientation);
+}
+
+void TouchInputMapper::configureVirtualKeys() {
+    Vector<VirtualKeyDefinition> virtualKeyDefinitions;
+    getEventHub()->getVirtualKeyDefinitions(getDeviceId(), virtualKeyDefinitions);
+
+    mVirtualKeys.clear();
+
+    if (virtualKeyDefinitions.size() == 0) {
+        return;
+    }
+
+    mVirtualKeys.setCapacity(virtualKeyDefinitions.size());
+
+    int32_t touchScreenLeft = mRawPointerAxes.x.minValue;
+    int32_t touchScreenTop = mRawPointerAxes.y.minValue;
+    int32_t touchScreenWidth = mRawPointerAxes.x.maxValue - mRawPointerAxes.x.minValue + 1;
+    int32_t touchScreenHeight = mRawPointerAxes.y.maxValue - mRawPointerAxes.y.minValue + 1;
+
+    for (size_t i = 0; i < virtualKeyDefinitions.size(); i++) {
+        const VirtualKeyDefinition& virtualKeyDefinition =
+                virtualKeyDefinitions[i];
+
+        mVirtualKeys.add();
+        VirtualKey& virtualKey = mVirtualKeys.editTop();
+
+        virtualKey.scanCode = virtualKeyDefinition.scanCode;
+        int32_t keyCode;
+        int32_t dummyKeyMetaState;
+        uint32_t flags;
+        if (getEventHub()->mapKey(getDeviceId(), virtualKey.scanCode, 0, 0,
+                                  &keyCode, &dummyKeyMetaState, &flags)) {
+            ALOGW(INDENT "VirtualKey %d: could not obtain key code, ignoring",
+                    virtualKey.scanCode);
+            mVirtualKeys.pop(); // drop the key
+            continue;
+        }
+
+        virtualKey.keyCode = keyCode;
+        virtualKey.flags = flags;
+
+        // convert the key definition's display coordinates into touch coordinates for a hit box
+        int32_t halfWidth = virtualKeyDefinition.width / 2;
+        int32_t halfHeight = virtualKeyDefinition.height / 2;
+
+        virtualKey.hitLeft = (virtualKeyDefinition.centerX - halfWidth)
+                * touchScreenWidth / mSurfaceWidth + touchScreenLeft;
+        virtualKey.hitRight= (virtualKeyDefinition.centerX + halfWidth)
+                * touchScreenWidth / mSurfaceWidth + touchScreenLeft;
+        virtualKey.hitTop = (virtualKeyDefinition.centerY - halfHeight)
+                * touchScreenHeight / mSurfaceHeight + touchScreenTop;
+        virtualKey.hitBottom = (virtualKeyDefinition.centerY + halfHeight)
+                * touchScreenHeight / mSurfaceHeight + touchScreenTop;
+    }
+}
+
+void TouchInputMapper::dumpVirtualKeys(String8& dump) {
+    if (!mVirtualKeys.isEmpty()) {
+        dump.append(INDENT3 "Virtual Keys:\n");
+
+        for (size_t i = 0; i < mVirtualKeys.size(); i++) {
+            const VirtualKey& virtualKey = mVirtualKeys.itemAt(i);
+            dump.appendFormat(INDENT4 "%zu: scanCode=%d, keyCode=%d, "
+                    "hitLeft=%d, hitRight=%d, hitTop=%d, hitBottom=%d\n",
+                    i, virtualKey.scanCode, virtualKey.keyCode,
+                    virtualKey.hitLeft, virtualKey.hitRight,
+                    virtualKey.hitTop, virtualKey.hitBottom);
+        }
+    }
+}
+
+void TouchInputMapper::parseCalibration() {
+    const PropertyMap& in = getDevice()->getConfiguration();
+    Calibration& out = mCalibration;
+
+    // Size
+    out.sizeCalibration = Calibration::SIZE_CALIBRATION_DEFAULT;
+    String8 sizeCalibrationString;
+    if (in.tryGetProperty(String8("touch.size.calibration"), sizeCalibrationString)) {
+        if (sizeCalibrationString == "none") {
+            out.sizeCalibration = Calibration::SIZE_CALIBRATION_NONE;
+        } else if (sizeCalibrationString == "geometric") {
+            out.sizeCalibration = Calibration::SIZE_CALIBRATION_GEOMETRIC;
+        } else if (sizeCalibrationString == "diameter") {
+            out.sizeCalibration = Calibration::SIZE_CALIBRATION_DIAMETER;
+        } else if (sizeCalibrationString == "box") {
+            out.sizeCalibration = Calibration::SIZE_CALIBRATION_BOX;
+        } else if (sizeCalibrationString == "area") {
+            out.sizeCalibration = Calibration::SIZE_CALIBRATION_AREA;
+        } else if (sizeCalibrationString != "default") {
+            ALOGW("Invalid value for touch.size.calibration: '%s'",
+                    sizeCalibrationString.string());
+        }
+    }
+
+    out.haveSizeScale = in.tryGetProperty(String8("touch.size.scale"),
+            out.sizeScale);
+    out.haveSizeBias = in.tryGetProperty(String8("touch.size.bias"),
+            out.sizeBias);
+    out.haveSizeIsSummed = in.tryGetProperty(String8("touch.size.isSummed"),
+            out.sizeIsSummed);
+
+    // Pressure
+    out.pressureCalibration = Calibration::PRESSURE_CALIBRATION_DEFAULT;
+    String8 pressureCalibrationString;
+    if (in.tryGetProperty(String8("touch.pressure.calibration"), pressureCalibrationString)) {
+        if (pressureCalibrationString == "none") {
+            out.pressureCalibration = Calibration::PRESSURE_CALIBRATION_NONE;
+        } else if (pressureCalibrationString == "physical") {
+            out.pressureCalibration = Calibration::PRESSURE_CALIBRATION_PHYSICAL;
+        } else if (pressureCalibrationString == "amplitude") {
+            out.pressureCalibration = Calibration::PRESSURE_CALIBRATION_AMPLITUDE;
+        } else if (pressureCalibrationString != "default") {
+            ALOGW("Invalid value for touch.pressure.calibration: '%s'",
+                    pressureCalibrationString.string());
+        }
+    }
+
+    out.havePressureScale = in.tryGetProperty(String8("touch.pressure.scale"),
+            out.pressureScale);
+
+    // Orientation
+    out.orientationCalibration = Calibration::ORIENTATION_CALIBRATION_DEFAULT;
+    String8 orientationCalibrationString;
+    if (in.tryGetProperty(String8("touch.orientation.calibration"), orientationCalibrationString)) {
+        if (orientationCalibrationString == "none") {
+            out.orientationCalibration = Calibration::ORIENTATION_CALIBRATION_NONE;
+        } else if (orientationCalibrationString == "interpolated") {
+            out.orientationCalibration = Calibration::ORIENTATION_CALIBRATION_INTERPOLATED;
+        } else if (orientationCalibrationString == "vector") {
+            out.orientationCalibration = Calibration::ORIENTATION_CALIBRATION_VECTOR;
+        } else if (orientationCalibrationString != "default") {
+            ALOGW("Invalid value for touch.orientation.calibration: '%s'",
+                    orientationCalibrationString.string());
+        }
+    }
+
+    // Distance
+    out.distanceCalibration = Calibration::DISTANCE_CALIBRATION_DEFAULT;
+    String8 distanceCalibrationString;
+    if (in.tryGetProperty(String8("touch.distance.calibration"), distanceCalibrationString)) {
+        if (distanceCalibrationString == "none") {
+            out.distanceCalibration = Calibration::DISTANCE_CALIBRATION_NONE;
+        } else if (distanceCalibrationString == "scaled") {
+            out.distanceCalibration = Calibration::DISTANCE_CALIBRATION_SCALED;
+        } else if (distanceCalibrationString != "default") {
+            ALOGW("Invalid value for touch.distance.calibration: '%s'",
+                    distanceCalibrationString.string());
+        }
+    }
+
+    out.haveDistanceScale = in.tryGetProperty(String8("touch.distance.scale"),
+            out.distanceScale);
+
+    out.coverageCalibration = Calibration::COVERAGE_CALIBRATION_DEFAULT;
+    String8 coverageCalibrationString;
+    if (in.tryGetProperty(String8("touch.coverage.calibration"), coverageCalibrationString)) {
+        if (coverageCalibrationString == "none") {
+            out.coverageCalibration = Calibration::COVERAGE_CALIBRATION_NONE;
+        } else if (coverageCalibrationString == "box") {
+            out.coverageCalibration = Calibration::COVERAGE_CALIBRATION_BOX;
+        } else if (coverageCalibrationString != "default") {
+            ALOGW("Invalid value for touch.coverage.calibration: '%s'",
+                    coverageCalibrationString.string());
+        }
+    }
+}
+
+void TouchInputMapper::resolveCalibration() {
+    // Size
+    if (mRawPointerAxes.touchMajor.valid || mRawPointerAxes.toolMajor.valid) {
+        if (mCalibration.sizeCalibration == Calibration::SIZE_CALIBRATION_DEFAULT) {
+            mCalibration.sizeCalibration = Calibration::SIZE_CALIBRATION_GEOMETRIC;
+        }
+    } else {
+        mCalibration.sizeCalibration = Calibration::SIZE_CALIBRATION_NONE;
+    }
+
+    // Pressure
+    if (mRawPointerAxes.pressure.valid) {
+        if (mCalibration.pressureCalibration == Calibration::PRESSURE_CALIBRATION_DEFAULT) {
+            mCalibration.pressureCalibration = Calibration::PRESSURE_CALIBRATION_PHYSICAL;
+        }
+    } else {
+        mCalibration.pressureCalibration = Calibration::PRESSURE_CALIBRATION_NONE;
+    }
+
+    // Orientation
+    if (mRawPointerAxes.orientation.valid) {
+        if (mCalibration.orientationCalibration == Calibration::ORIENTATION_CALIBRATION_DEFAULT) {
+            mCalibration.orientationCalibration = Calibration::ORIENTATION_CALIBRATION_INTERPOLATED;
+        }
+    } else {
+        mCalibration.orientationCalibration = Calibration::ORIENTATION_CALIBRATION_NONE;
+    }
+
+    // Distance
+    if (mRawPointerAxes.distance.valid) {
+        if (mCalibration.distanceCalibration == Calibration::DISTANCE_CALIBRATION_DEFAULT) {
+            mCalibration.distanceCalibration = Calibration::DISTANCE_CALIBRATION_SCALED;
+        }
+    } else {
+        mCalibration.distanceCalibration = Calibration::DISTANCE_CALIBRATION_NONE;
+    }
+
+    // Coverage
+    if (mCalibration.coverageCalibration == Calibration::COVERAGE_CALIBRATION_DEFAULT) {
+        mCalibration.coverageCalibration = Calibration::COVERAGE_CALIBRATION_NONE;
+    }
+}
+
+void TouchInputMapper::dumpCalibration(String8& dump) {
+    dump.append(INDENT3 "Calibration:\n");
+
+    // Size
+    switch (mCalibration.sizeCalibration) {
+    case Calibration::SIZE_CALIBRATION_NONE:
+        dump.append(INDENT4 "touch.size.calibration: none\n");
+        break;
+    case Calibration::SIZE_CALIBRATION_GEOMETRIC:
+        dump.append(INDENT4 "touch.size.calibration: geometric\n");
+        break;
+    case Calibration::SIZE_CALIBRATION_DIAMETER:
+        dump.append(INDENT4 "touch.size.calibration: diameter\n");
+        break;
+    case Calibration::SIZE_CALIBRATION_BOX:
+        dump.append(INDENT4 "touch.size.calibration: box\n");
+        break;
+    case Calibration::SIZE_CALIBRATION_AREA:
+        dump.append(INDENT4 "touch.size.calibration: area\n");
+        break;
+    default:
+        ALOG_ASSERT(false);
+    }
+
+    if (mCalibration.haveSizeScale) {
+        dump.appendFormat(INDENT4 "touch.size.scale: %0.3f\n",
+                mCalibration.sizeScale);
+    }
+
+    if (mCalibration.haveSizeBias) {
+        dump.appendFormat(INDENT4 "touch.size.bias: %0.3f\n",
+                mCalibration.sizeBias);
+    }
+
+    if (mCalibration.haveSizeIsSummed) {
+        dump.appendFormat(INDENT4 "touch.size.isSummed: %s\n",
+                toString(mCalibration.sizeIsSummed));
+    }
+
+    // Pressure
+    switch (mCalibration.pressureCalibration) {
+    case Calibration::PRESSURE_CALIBRATION_NONE:
+        dump.append(INDENT4 "touch.pressure.calibration: none\n");
+        break;
+    case Calibration::PRESSURE_CALIBRATION_PHYSICAL:
+        dump.append(INDENT4 "touch.pressure.calibration: physical\n");
+        break;
+    case Calibration::PRESSURE_CALIBRATION_AMPLITUDE:
+        dump.append(INDENT4 "touch.pressure.calibration: amplitude\n");
+        break;
+    default:
+        ALOG_ASSERT(false);
+    }
+
+    if (mCalibration.havePressureScale) {
+        dump.appendFormat(INDENT4 "touch.pressure.scale: %0.3f\n",
+                mCalibration.pressureScale);
+    }
+
+    // Orientation
+    switch (mCalibration.orientationCalibration) {
+    case Calibration::ORIENTATION_CALIBRATION_NONE:
+        dump.append(INDENT4 "touch.orientation.calibration: none\n");
+        break;
+    case Calibration::ORIENTATION_CALIBRATION_INTERPOLATED:
+        dump.append(INDENT4 "touch.orientation.calibration: interpolated\n");
+        break;
+    case Calibration::ORIENTATION_CALIBRATION_VECTOR:
+        dump.append(INDENT4 "touch.orientation.calibration: vector\n");
+        break;
+    default:
+        ALOG_ASSERT(false);
+    }
+
+    // Distance
+    switch (mCalibration.distanceCalibration) {
+    case Calibration::DISTANCE_CALIBRATION_NONE:
+        dump.append(INDENT4 "touch.distance.calibration: none\n");
+        break;
+    case Calibration::DISTANCE_CALIBRATION_SCALED:
+        dump.append(INDENT4 "touch.distance.calibration: scaled\n");
+        break;
+    default:
+        ALOG_ASSERT(false);
+    }
+
+    if (mCalibration.haveDistanceScale) {
+        dump.appendFormat(INDENT4 "touch.distance.scale: %0.3f\n",
+                mCalibration.distanceScale);
+    }
+
+    switch (mCalibration.coverageCalibration) {
+    case Calibration::COVERAGE_CALIBRATION_NONE:
+        dump.append(INDENT4 "touch.coverage.calibration: none\n");
+        break;
+    case Calibration::COVERAGE_CALIBRATION_BOX:
+        dump.append(INDENT4 "touch.coverage.calibration: box\n");
+        break;
+    default:
+        ALOG_ASSERT(false);
+    }
+}
+
+void TouchInputMapper::dumpAffineTransformation(String8& dump) {
+    dump.append(INDENT3 "Affine Transformation:\n");
+
+    dump.appendFormat(INDENT4 "X scale: %0.3f\n", mAffineTransform.x_scale);
+    dump.appendFormat(INDENT4 "X ymix: %0.3f\n", mAffineTransform.x_ymix);
+    dump.appendFormat(INDENT4 "X offset: %0.3f\n", mAffineTransform.x_offset);
+    dump.appendFormat(INDENT4 "Y xmix: %0.3f\n", mAffineTransform.y_xmix);
+    dump.appendFormat(INDENT4 "Y scale: %0.3f\n", mAffineTransform.y_scale);
+    dump.appendFormat(INDENT4 "Y offset: %0.3f\n", mAffineTransform.y_offset);
+}
+
+void TouchInputMapper::updateAffineTransformation() {
+    mAffineTransform = getPolicy()->getTouchAffineTransformation(mDevice->getDescriptor(),
+            mSurfaceOrientation);
+}
+
+void TouchInputMapper::reset(nsecs_t when) {
+    mCursorButtonAccumulator.reset(getDevice());
+    mCursorScrollAccumulator.reset(getDevice());
+    mTouchButtonAccumulator.reset(getDevice());
+
+    mPointerVelocityControl.reset();
+    mWheelXVelocityControl.reset();
+    mWheelYVelocityControl.reset();
+
+    mRawStatesPending.clear();
+    mCurrentRawState.clear();
+    mCurrentCookedState.clear();
+    mLastRawState.clear();
+    mLastCookedState.clear();
+    mPointerUsage = POINTER_USAGE_NONE;
+    mSentHoverEnter = false;
+    mHavePointerIds = false;
+    mCurrentMotionAborted = false;
+    mDownTime = 0;
+
+    mCurrentVirtualKey.down = false;
+
+    mPointerGesture.reset();
+    mPointerSimple.reset();
+    resetExternalStylus();
+
+    if (mPointerController != NULL) {
+        mPointerController->fade(PointerControllerInterface::TRANSITION_GRADUAL);
+        mPointerController->clearSpots();
+    }
+
+    InputMapper::reset(when);
+}
+
+void TouchInputMapper::resetExternalStylus() {
+    mExternalStylusState.clear();
+    mExternalStylusId = -1;
+    mExternalStylusFusionTimeout = LLONG_MAX;
+    mExternalStylusDataPending = false;
+}
+
+void TouchInputMapper::clearStylusDataPendingFlags() {
+    mExternalStylusDataPending = false;
+    mExternalStylusFusionTimeout = LLONG_MAX;
+}
+
+void TouchInputMapper::process(const RawEvent* rawEvent) {
+    mCursorButtonAccumulator.process(rawEvent);
+    mCursorScrollAccumulator.process(rawEvent);
+    mTouchButtonAccumulator.process(rawEvent);
+
+    if (rawEvent->type == EV_SYN && rawEvent->code == SYN_REPORT) {
+        sync(rawEvent->when);
+    }
+}
+
+void TouchInputMapper::sync(nsecs_t when) {
+    const RawState* last = mRawStatesPending.isEmpty() ?
+            &mCurrentRawState : &mRawStatesPending.top();
+
+    // Push a new state.
+    mRawStatesPending.push();
+    RawState* next = &mRawStatesPending.editTop();
+    next->clear();
+    next->when = when;
+
+    // Sync button state.
+    next->buttonState = mTouchButtonAccumulator.getButtonState()
+            | mCursorButtonAccumulator.getButtonState();
+
+    // Sync scroll
+    next->rawVScroll = mCursorScrollAccumulator.getRelativeVWheel();
+    next->rawHScroll = mCursorScrollAccumulator.getRelativeHWheel();
+    mCursorScrollAccumulator.finishSync();
+
+    // Sync touch
+    syncTouch(when, next);
+
+    // Assign pointer ids.
+    if (!mHavePointerIds) {
+        assignPointerIds(last, next);
+    }
+
+#if DEBUG_RAW_EVENTS
+    ALOGD("syncTouch: pointerCount %d -> %d, touching ids 0x%08x -> 0x%08x, "
+            "hovering ids 0x%08x -> 0x%08x",
+            last->rawPointerData.pointerCount,
+            next->rawPointerData.pointerCount,
+            last->rawPointerData.touchingIdBits.value,
+            next->rawPointerData.touchingIdBits.value,
+            last->rawPointerData.hoveringIdBits.value,
+            next->rawPointerData.hoveringIdBits.value);
+#endif
+
+    processRawTouches(false /*timeout*/);
+}
+
+void TouchInputMapper::processRawTouches(bool timeout) {
+    if (mDeviceMode == DEVICE_MODE_DISABLED) {
+        // Drop all input if the device is disabled.
+        mCurrentRawState.clear();
+        mRawStatesPending.clear();
+        return;
+    }
+
+    // Drain any pending touch states. The invariant here is that the mCurrentRawState is always
+    // valid and must go through the full cook and dispatch cycle. This ensures that anything
+    // touching the current state will only observe the events that have been dispatched to the
+    // rest of the pipeline.
+    const size_t N = mRawStatesPending.size();
+    size_t count;
+    for(count = 0; count < N; count++) {
+        const RawState& next = mRawStatesPending[count];
+
+        // A failure to assign the stylus id means that we're waiting on stylus data
+        // and so should defer the rest of the pipeline.
+        if (assignExternalStylusId(next, timeout)) {
+            break;
+        }
+
+        // All ready to go.
+        clearStylusDataPendingFlags();
+        mCurrentRawState.copyFrom(next);
+        if (mCurrentRawState.when < mLastRawState.when) {
+            mCurrentRawState.when = mLastRawState.when;
+        }
+        cookAndDispatch(mCurrentRawState.when);
+    }
+    if (count != 0) {
+        mRawStatesPending.removeItemsAt(0, count);
+    }
+
+    if (mExternalStylusDataPending) {
+        if (timeout) {
+            nsecs_t when = mExternalStylusFusionTimeout - STYLUS_DATA_LATENCY;
+            clearStylusDataPendingFlags();
+            mCurrentRawState.copyFrom(mLastRawState);
+#if DEBUG_STYLUS_FUSION
+            ALOGD("Timeout expired, synthesizing event with new stylus data");
+#endif
+            cookAndDispatch(when);
+        } else if (mExternalStylusFusionTimeout == LLONG_MAX) {
+            mExternalStylusFusionTimeout = mExternalStylusState.when + TOUCH_DATA_TIMEOUT;
+            getContext()->requestTimeoutAtTime(mExternalStylusFusionTimeout);
+        }
+    }
+}
+
+void TouchInputMapper::cookAndDispatch(nsecs_t when) {
+    // Always start with a clean state.
+    mCurrentCookedState.clear();
+
+    // Apply stylus buttons to current raw state.
+    applyExternalStylusButtonState(when);
+
+    // Handle policy on initial down or hover events.
+    bool initialDown = mLastRawState.rawPointerData.pointerCount == 0
+            && mCurrentRawState.rawPointerData.pointerCount != 0;
+
+    uint32_t policyFlags = 0;
+    bool buttonsPressed = mCurrentRawState.buttonState & ~mLastRawState.buttonState;
+    if (initialDown || buttonsPressed) {
+        // If this is a touch screen, hide the pointer on an initial down.
+        if (mDeviceMode == DEVICE_MODE_DIRECT) {
+            getContext()->fadePointer();
+        }
+
+        if (mParameters.wake) {
+            policyFlags |= POLICY_FLAG_WAKE;
+        }
+    }
+
+    // Consume raw off-screen touches before cooking pointer data.
+    // If touches are consumed, subsequent code will not receive any pointer data.
+    if (consumeRawTouches(when, policyFlags)) {
+        mCurrentRawState.rawPointerData.clear();
+    }
+
+    // Cook pointer data.  This call populates the mCurrentCookedState.cookedPointerData structure
+    // with cooked pointer data that has the same ids and indices as the raw data.
+    // The following code can use either the raw or cooked data, as needed.
+    cookPointerData();
+
+    // Apply stylus pressure to current cooked state.
+    applyExternalStylusTouchState(when);
+
+    // Synthesize key down from raw buttons if needed.
+    synthesizeButtonKeys(getContext(), AKEY_EVENT_ACTION_DOWN, when, getDeviceId(), mSource,
+            policyFlags, mLastCookedState.buttonState, mCurrentCookedState.buttonState);
+
+    // Dispatch the touches either directly or by translation through a pointer on screen.
+    if (mDeviceMode == DEVICE_MODE_POINTER) {
+        for (BitSet32 idBits(mCurrentRawState.rawPointerData.touchingIdBits);
+                !idBits.isEmpty(); ) {
+            uint32_t id = idBits.clearFirstMarkedBit();
+            const RawPointerData::Pointer& pointer =
+                    mCurrentRawState.rawPointerData.pointerForId(id);
+            if (pointer.toolType == AMOTION_EVENT_TOOL_TYPE_STYLUS
+                    || pointer.toolType == AMOTION_EVENT_TOOL_TYPE_ERASER) {
+                mCurrentCookedState.stylusIdBits.markBit(id);
+            } else if (pointer.toolType == AMOTION_EVENT_TOOL_TYPE_FINGER
+                    || pointer.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
+                mCurrentCookedState.fingerIdBits.markBit(id);
+            } else if (pointer.toolType == AMOTION_EVENT_TOOL_TYPE_MOUSE) {
+                mCurrentCookedState.mouseIdBits.markBit(id);
+            }
+        }
+        for (BitSet32 idBits(mCurrentRawState.rawPointerData.hoveringIdBits);
+                !idBits.isEmpty(); ) {
+            uint32_t id = idBits.clearFirstMarkedBit();
+            const RawPointerData::Pointer& pointer =
+                    mCurrentRawState.rawPointerData.pointerForId(id);
+            if (pointer.toolType == AMOTION_EVENT_TOOL_TYPE_STYLUS
+                    || pointer.toolType == AMOTION_EVENT_TOOL_TYPE_ERASER) {
+                mCurrentCookedState.stylusIdBits.markBit(id);
+            }
+        }
+
+        // Stylus takes precedence over all tools, then mouse, then finger.
+        PointerUsage pointerUsage = mPointerUsage;
+        if (!mCurrentCookedState.stylusIdBits.isEmpty()) {
+            mCurrentCookedState.mouseIdBits.clear();
+            mCurrentCookedState.fingerIdBits.clear();
+            pointerUsage = POINTER_USAGE_STYLUS;
+        } else if (!mCurrentCookedState.mouseIdBits.isEmpty()) {
+            mCurrentCookedState.fingerIdBits.clear();
+            pointerUsage = POINTER_USAGE_MOUSE;
+        } else if (!mCurrentCookedState.fingerIdBits.isEmpty() ||
+                isPointerDown(mCurrentRawState.buttonState)) {
+            pointerUsage = POINTER_USAGE_GESTURES;
+        }
+
+        dispatchPointerUsage(when, policyFlags, pointerUsage);
+    } else {
+        if (mDeviceMode == DEVICE_MODE_DIRECT
+                && mConfig.showTouches && mPointerController != NULL) {
+            mPointerController->setPresentation(PointerControllerInterface::PRESENTATION_SPOT);
+            mPointerController->fade(PointerControllerInterface::TRANSITION_GRADUAL);
+
+            mPointerController->setButtonState(mCurrentRawState.buttonState);
+            mPointerController->setSpots(mCurrentCookedState.cookedPointerData.pointerCoords,
+                    mCurrentCookedState.cookedPointerData.idToIndex,
+                    mCurrentCookedState.cookedPointerData.touchingIdBits);
+        }
+
+        if (!mCurrentMotionAborted) {
+            dispatchButtonRelease(when, policyFlags);
+            dispatchHoverExit(when, policyFlags);
+            dispatchTouches(when, policyFlags);
+            dispatchHoverEnterAndMove(when, policyFlags);
+            dispatchButtonPress(when, policyFlags);
+        }
+
+        if (mCurrentCookedState.cookedPointerData.pointerCount == 0) {
+            mCurrentMotionAborted = false;
+        }
+    }
+
+    // Synthesize key up from raw buttons if needed.
+    synthesizeButtonKeys(getContext(), AKEY_EVENT_ACTION_UP, when, getDeviceId(), mSource,
+            policyFlags, mLastCookedState.buttonState, mCurrentCookedState.buttonState);
+
+    // Clear some transient state.
+    mCurrentRawState.rawVScroll = 0;
+    mCurrentRawState.rawHScroll = 0;
+
+    // Copy current touch to last touch in preparation for the next cycle.
+    mLastRawState.copyFrom(mCurrentRawState);
+    mLastCookedState.copyFrom(mCurrentCookedState);
+}
+
+void TouchInputMapper::applyExternalStylusButtonState(nsecs_t when) {
+    if (mDeviceMode == DEVICE_MODE_DIRECT && hasExternalStylus() && mExternalStylusId != -1) {
+        mCurrentRawState.buttonState |= mExternalStylusState.buttons;
+    }
+}
+
+void TouchInputMapper::applyExternalStylusTouchState(nsecs_t when) {
+    CookedPointerData& currentPointerData = mCurrentCookedState.cookedPointerData;
+    const CookedPointerData& lastPointerData = mLastCookedState.cookedPointerData;
+
+    if (mExternalStylusId != -1 && currentPointerData.isTouching(mExternalStylusId)) {
+        float pressure = mExternalStylusState.pressure;
+        if (pressure == 0.0f && lastPointerData.isTouching(mExternalStylusId)) {
+            const PointerCoords& coords = lastPointerData.pointerCoordsForId(mExternalStylusId);
+            pressure = coords.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE);
+        }
+        PointerCoords& coords = currentPointerData.editPointerCoordsWithId(mExternalStylusId);
+        coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, pressure);
+
+        PointerProperties& properties =
+                currentPointerData.editPointerPropertiesWithId(mExternalStylusId);
+        if (mExternalStylusState.toolType != AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
+            properties.toolType = mExternalStylusState.toolType;
+        }
+    }
+}
+
+bool TouchInputMapper::assignExternalStylusId(const RawState& state, bool timeout) {
+    if (mDeviceMode != DEVICE_MODE_DIRECT || !hasExternalStylus()) {
+        return false;
+    }
+
+    const bool initialDown = mLastRawState.rawPointerData.pointerCount == 0
+            && state.rawPointerData.pointerCount != 0;
+    if (initialDown) {
+        if (mExternalStylusState.pressure != 0.0f) {
+#if DEBUG_STYLUS_FUSION
+            ALOGD("Have both stylus and touch data, beginning fusion");
+#endif
+            mExternalStylusId = state.rawPointerData.touchingIdBits.firstMarkedBit();
+        } else if (timeout) {
+#if DEBUG_STYLUS_FUSION
+            ALOGD("Timeout expired, assuming touch is not a stylus.");
+#endif
+            resetExternalStylus();
+        } else {
+            if (mExternalStylusFusionTimeout == LLONG_MAX) {
+                mExternalStylusFusionTimeout = state.when + EXTERNAL_STYLUS_DATA_TIMEOUT;
+            }
+#if DEBUG_STYLUS_FUSION
+            ALOGD("No stylus data but stylus is connected, requesting timeout "
+                    "(%" PRId64 "ms)", mExternalStylusFusionTimeout);
+#endif
+            getContext()->requestTimeoutAtTime(mExternalStylusFusionTimeout);
+            return true;
+        }
+    }
+
+    // Check if the stylus pointer has gone up.
+    if (mExternalStylusId != -1 &&
+            !state.rawPointerData.touchingIdBits.hasBit(mExternalStylusId)) {
+#if DEBUG_STYLUS_FUSION
+            ALOGD("Stylus pointer is going up");
+#endif
+        mExternalStylusId = -1;
+    }
+
+    return false;
+}
+
+void TouchInputMapper::timeoutExpired(nsecs_t when) {
+    if (mDeviceMode == DEVICE_MODE_POINTER) {
+        if (mPointerUsage == POINTER_USAGE_GESTURES) {
+            dispatchPointerGestures(when, 0 /*policyFlags*/, true /*isTimeout*/);
+        }
+    } else if (mDeviceMode == DEVICE_MODE_DIRECT) {
+        if (mExternalStylusFusionTimeout < when) {
+            processRawTouches(true /*timeout*/);
+        } else if (mExternalStylusFusionTimeout != LLONG_MAX) {
+            getContext()->requestTimeoutAtTime(mExternalStylusFusionTimeout);
+        }
+    }
+}
+
+void TouchInputMapper::updateExternalStylusState(const StylusState& state) {
+    mExternalStylusState.copyFrom(state);
+    if (mExternalStylusId != -1 || mExternalStylusFusionTimeout != LLONG_MAX) {
+        // We're either in the middle of a fused stream of data or we're waiting on data before
+        // dispatching the initial down, so go ahead and dispatch now that we have fresh stylus
+        // data.
+        mExternalStylusDataPending = true;
+        processRawTouches(false /*timeout*/);
+    }
+}
+
+bool TouchInputMapper::consumeRawTouches(nsecs_t when, uint32_t policyFlags) {
+    // Check for release of a virtual key.
+    if (mCurrentVirtualKey.down) {
+        if (mCurrentRawState.rawPointerData.touchingIdBits.isEmpty()) {
+            // Pointer went up while virtual key was down.
+            mCurrentVirtualKey.down = false;
+            if (!mCurrentVirtualKey.ignored) {
+#if DEBUG_VIRTUAL_KEYS
+                ALOGD("VirtualKeys: Generating key up: keyCode=%d, scanCode=%d",
+                        mCurrentVirtualKey.keyCode, mCurrentVirtualKey.scanCode);
+#endif
+                dispatchVirtualKey(when, policyFlags,
+                        AKEY_EVENT_ACTION_UP,
+                        AKEY_EVENT_FLAG_FROM_SYSTEM | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY);
+            }
+            return true;
+        }
+
+        if (mCurrentRawState.rawPointerData.touchingIdBits.count() == 1) {
+            uint32_t id = mCurrentRawState.rawPointerData.touchingIdBits.firstMarkedBit();
+            const RawPointerData::Pointer& pointer =
+                    mCurrentRawState.rawPointerData.pointerForId(id);
+            const VirtualKey* virtualKey = findVirtualKeyHit(pointer.x, pointer.y);
+            if (virtualKey && virtualKey->keyCode == mCurrentVirtualKey.keyCode) {
+                // Pointer is still within the space of the virtual key.
+                return true;
+            }
+        }
+
+        // Pointer left virtual key area or another pointer also went down.
+        // Send key cancellation but do not consume the touch yet.
+        // This is useful when the user swipes through from the virtual key area
+        // into the main display surface.
+        mCurrentVirtualKey.down = false;
+        if (!mCurrentVirtualKey.ignored) {
+#if DEBUG_VIRTUAL_KEYS
+            ALOGD("VirtualKeys: Canceling key: keyCode=%d, scanCode=%d",
+                    mCurrentVirtualKey.keyCode, mCurrentVirtualKey.scanCode);
+#endif
+            dispatchVirtualKey(when, policyFlags,
+                    AKEY_EVENT_ACTION_UP,
+                    AKEY_EVENT_FLAG_FROM_SYSTEM | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY
+                            | AKEY_EVENT_FLAG_CANCELED);
+        }
+    }
+
+    if (mLastRawState.rawPointerData.touchingIdBits.isEmpty()
+            && !mCurrentRawState.rawPointerData.touchingIdBits.isEmpty()) {
+        // Pointer just went down.  Check for virtual key press or off-screen touches.
+        uint32_t id = mCurrentRawState.rawPointerData.touchingIdBits.firstMarkedBit();
+        const RawPointerData::Pointer& pointer = mCurrentRawState.rawPointerData.pointerForId(id);
+        if (!isPointInsideSurface(pointer.x, pointer.y)) {
+            // If exactly one pointer went down, check for virtual key hit.
+            // Otherwise we will drop the entire stroke.
+            if (mCurrentRawState.rawPointerData.touchingIdBits.count() == 1) {
+                const VirtualKey* virtualKey = findVirtualKeyHit(pointer.x, pointer.y);
+                if (virtualKey) {
+                    mCurrentVirtualKey.down = true;
+                    mCurrentVirtualKey.downTime = when;
+                    mCurrentVirtualKey.keyCode = virtualKey->keyCode;
+                    mCurrentVirtualKey.scanCode = virtualKey->scanCode;
+                    mCurrentVirtualKey.ignored = mContext->shouldDropVirtualKey(
+                            when, getDevice(), virtualKey->keyCode, virtualKey->scanCode);
+
+                    if (!mCurrentVirtualKey.ignored) {
+#if DEBUG_VIRTUAL_KEYS
+                        ALOGD("VirtualKeys: Generating key down: keyCode=%d, scanCode=%d",
+                                mCurrentVirtualKey.keyCode,
+                                mCurrentVirtualKey.scanCode);
+#endif
+                        dispatchVirtualKey(when, policyFlags,
+                                AKEY_EVENT_ACTION_DOWN,
+                                AKEY_EVENT_FLAG_FROM_SYSTEM | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY);
+                    }
+                }
+            }
+            return true;
+        }
+    }
+
+    // Disable all virtual key touches that happen within a short time interval of the
+    // most recent touch within the screen area.  The idea is to filter out stray
+    // virtual key presses when interacting with the touch screen.
+    //
+    // Problems we're trying to solve:
+    //
+    // 1. While scrolling a list or dragging the window shade, the user swipes down into a
+    //    virtual key area that is implemented by a separate touch panel and accidentally
+    //    triggers a virtual key.
+    //
+    // 2. While typing in the on screen keyboard, the user taps slightly outside the screen
+    //    area and accidentally triggers a virtual key.  This often happens when virtual keys
+    //    are layed out below the screen near to where the on screen keyboard's space bar
+    //    is displayed.
+    if (mConfig.virtualKeyQuietTime > 0 &&
+            !mCurrentRawState.rawPointerData.touchingIdBits.isEmpty()) {
+        mContext->disableVirtualKeysUntil(when + mConfig.virtualKeyQuietTime);
+    }
+    return false;
+}
+
+void TouchInputMapper::dispatchVirtualKey(nsecs_t when, uint32_t policyFlags,
+        int32_t keyEventAction, int32_t keyEventFlags) {
+    int32_t keyCode = mCurrentVirtualKey.keyCode;
+    int32_t scanCode = mCurrentVirtualKey.scanCode;
+    nsecs_t downTime = mCurrentVirtualKey.downTime;
+    int32_t metaState = mContext->getGlobalMetaState();
+    policyFlags |= POLICY_FLAG_VIRTUAL;
+
+    NotifyKeyArgs args(when, getDeviceId(), AINPUT_SOURCE_KEYBOARD, policyFlags,
+            keyEventAction, keyEventFlags, keyCode, scanCode, metaState, downTime);
+    getListener()->notifyKey(&args);
+}
+
+void TouchInputMapper::abortTouches(nsecs_t when, uint32_t policyFlags) {
+    BitSet32 currentIdBits = mCurrentCookedState.cookedPointerData.touchingIdBits;
+    if (!currentIdBits.isEmpty()) {
+        int32_t metaState = getContext()->getGlobalMetaState();
+        int32_t buttonState = mCurrentCookedState.buttonState;
+        dispatchMotion(when, policyFlags, mSource, AMOTION_EVENT_ACTION_CANCEL, 0, 0,
+                metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
+                mCurrentCookedState.cookedPointerData.pointerProperties,
+                mCurrentCookedState.cookedPointerData.pointerCoords,
+                mCurrentCookedState.cookedPointerData.idToIndex,
+                currentIdBits, -1,
+                mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+        mCurrentMotionAborted = true;
+    }
+}
+
+void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) {
+    BitSet32 currentIdBits = mCurrentCookedState.cookedPointerData.touchingIdBits;
+    BitSet32 lastIdBits = mLastCookedState.cookedPointerData.touchingIdBits;
+    int32_t metaState = getContext()->getGlobalMetaState();
+    int32_t buttonState = mCurrentCookedState.buttonState;
+
+    if (currentIdBits == lastIdBits) {
+        if (!currentIdBits.isEmpty()) {
+            // No pointer id changes so this is a move event.
+            // The listener takes care of batching moves so we don't have to deal with that here.
+            dispatchMotion(when, policyFlags, mSource,
+                    AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState, buttonState,
+                    AMOTION_EVENT_EDGE_FLAG_NONE,
+                    mCurrentCookedState.cookedPointerData.pointerProperties,
+                    mCurrentCookedState.cookedPointerData.pointerCoords,
+                    mCurrentCookedState.cookedPointerData.idToIndex,
+                    currentIdBits, -1,
+                    mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+        }
+    } else {
+        // There may be pointers going up and pointers going down and pointers moving
+        // all at the same time.
+        BitSet32 upIdBits(lastIdBits.value & ~currentIdBits.value);
+        BitSet32 downIdBits(currentIdBits.value & ~lastIdBits.value);
+        BitSet32 moveIdBits(lastIdBits.value & currentIdBits.value);
+        BitSet32 dispatchedIdBits(lastIdBits.value);
+
+        // Update last coordinates of pointers that have moved so that we observe the new
+        // pointer positions at the same time as other pointers that have just gone up.
+        bool moveNeeded = updateMovedPointers(
+                mCurrentCookedState.cookedPointerData.pointerProperties,
+                mCurrentCookedState.cookedPointerData.pointerCoords,
+                mCurrentCookedState.cookedPointerData.idToIndex,
+                mLastCookedState.cookedPointerData.pointerProperties,
+                mLastCookedState.cookedPointerData.pointerCoords,
+                mLastCookedState.cookedPointerData.idToIndex,
+                moveIdBits);
+        if (buttonState != mLastCookedState.buttonState) {
+            moveNeeded = true;
+        }
+
+        // Dispatch pointer up events.
+        while (!upIdBits.isEmpty()) {
+            uint32_t upId = upIdBits.clearFirstMarkedBit();
+
+            dispatchMotion(when, policyFlags, mSource,
+                    AMOTION_EVENT_ACTION_POINTER_UP, 0, 0, metaState, buttonState, 0,
+                    mLastCookedState.cookedPointerData.pointerProperties,
+                    mLastCookedState.cookedPointerData.pointerCoords,
+                    mLastCookedState.cookedPointerData.idToIndex,
+                    dispatchedIdBits, upId, mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+            dispatchedIdBits.clearBit(upId);
+        }
+
+        // Dispatch move events if any of the remaining pointers moved from their old locations.
+        // Although applications receive new locations as part of individual pointer up
+        // events, they do not generally handle them except when presented in a move event.
+        if (moveNeeded && !moveIdBits.isEmpty()) {
+            ALOG_ASSERT(moveIdBits.value == dispatchedIdBits.value);
+            dispatchMotion(when, policyFlags, mSource,
+                    AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState, buttonState, 0,
+                    mCurrentCookedState.cookedPointerData.pointerProperties,
+                    mCurrentCookedState.cookedPointerData.pointerCoords,
+                    mCurrentCookedState.cookedPointerData.idToIndex,
+                    dispatchedIdBits, -1, mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+        }
+
+        // Dispatch pointer down events using the new pointer locations.
+        while (!downIdBits.isEmpty()) {
+            uint32_t downId = downIdBits.clearFirstMarkedBit();
+            dispatchedIdBits.markBit(downId);
+
+            if (dispatchedIdBits.count() == 1) {
+                // First pointer is going down.  Set down time.
+                mDownTime = when;
+            }
+
+            dispatchMotion(when, policyFlags, mSource,
+                    AMOTION_EVENT_ACTION_POINTER_DOWN, 0, 0, metaState, buttonState, 0,
+                    mCurrentCookedState.cookedPointerData.pointerProperties,
+                    mCurrentCookedState.cookedPointerData.pointerCoords,
+                    mCurrentCookedState.cookedPointerData.idToIndex,
+                    dispatchedIdBits, downId, mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+        }
+    }
+}
+
+void TouchInputMapper::dispatchHoverExit(nsecs_t when, uint32_t policyFlags) {
+    if (mSentHoverEnter &&
+            (mCurrentCookedState.cookedPointerData.hoveringIdBits.isEmpty()
+                    || !mCurrentCookedState.cookedPointerData.touchingIdBits.isEmpty())) {
+        int32_t metaState = getContext()->getGlobalMetaState();
+        dispatchMotion(when, policyFlags, mSource,
+                AMOTION_EVENT_ACTION_HOVER_EXIT, 0, 0, metaState, mLastCookedState.buttonState, 0,
+                mLastCookedState.cookedPointerData.pointerProperties,
+                mLastCookedState.cookedPointerData.pointerCoords,
+                mLastCookedState.cookedPointerData.idToIndex,
+                mLastCookedState.cookedPointerData.hoveringIdBits, -1,
+                mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+        mSentHoverEnter = false;
+    }
+}
+
+void TouchInputMapper::dispatchHoverEnterAndMove(nsecs_t when, uint32_t policyFlags) {
+    if (mCurrentCookedState.cookedPointerData.touchingIdBits.isEmpty()
+            && !mCurrentCookedState.cookedPointerData.hoveringIdBits.isEmpty()) {
+        int32_t metaState = getContext()->getGlobalMetaState();
+        if (!mSentHoverEnter) {
+            dispatchMotion(when, policyFlags, mSource, AMOTION_EVENT_ACTION_HOVER_ENTER,
+                    0, 0, metaState, mCurrentRawState.buttonState, 0,
+                    mCurrentCookedState.cookedPointerData.pointerProperties,
+                    mCurrentCookedState.cookedPointerData.pointerCoords,
+                    mCurrentCookedState.cookedPointerData.idToIndex,
+                    mCurrentCookedState.cookedPointerData.hoveringIdBits, -1,
+                    mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+            mSentHoverEnter = true;
+        }
+
+        dispatchMotion(when, policyFlags, mSource,
+                AMOTION_EVENT_ACTION_HOVER_MOVE, 0, 0, metaState,
+                mCurrentRawState.buttonState, 0,
+                mCurrentCookedState.cookedPointerData.pointerProperties,
+                mCurrentCookedState.cookedPointerData.pointerCoords,
+                mCurrentCookedState.cookedPointerData.idToIndex,
+                mCurrentCookedState.cookedPointerData.hoveringIdBits, -1,
+                mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+    }
+}
+
+void TouchInputMapper::dispatchButtonRelease(nsecs_t when, uint32_t policyFlags) {
+    BitSet32 releasedButtons(mLastCookedState.buttonState & ~mCurrentCookedState.buttonState);
+    const BitSet32& idBits = findActiveIdBits(mLastCookedState.cookedPointerData);
+    const int32_t metaState = getContext()->getGlobalMetaState();
+    int32_t buttonState = mLastCookedState.buttonState;
+    while (!releasedButtons.isEmpty()) {
+        int32_t actionButton = BitSet32::valueForBit(releasedButtons.clearFirstMarkedBit());
+        buttonState &= ~actionButton;
+        dispatchMotion(when, policyFlags, mSource,
+                    AMOTION_EVENT_ACTION_BUTTON_RELEASE, actionButton,
+                    0, metaState, buttonState, 0,
+                    mCurrentCookedState.cookedPointerData.pointerProperties,
+                    mCurrentCookedState.cookedPointerData.pointerCoords,
+                    mCurrentCookedState.cookedPointerData.idToIndex, idBits, -1,
+                    mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+    }
+}
+
+void TouchInputMapper::dispatchButtonPress(nsecs_t when, uint32_t policyFlags) {
+    BitSet32 pressedButtons(mCurrentCookedState.buttonState & ~mLastCookedState.buttonState);
+    const BitSet32& idBits = findActiveIdBits(mCurrentCookedState.cookedPointerData);
+    const int32_t metaState = getContext()->getGlobalMetaState();
+    int32_t buttonState = mLastCookedState.buttonState;
+    while (!pressedButtons.isEmpty()) {
+        int32_t actionButton = BitSet32::valueForBit(pressedButtons.clearFirstMarkedBit());
+        buttonState |= actionButton;
+        dispatchMotion(when, policyFlags, mSource, AMOTION_EVENT_ACTION_BUTTON_PRESS, actionButton,
+                    0, metaState, buttonState, 0,
+                    mCurrentCookedState.cookedPointerData.pointerProperties,
+                    mCurrentCookedState.cookedPointerData.pointerCoords,
+                    mCurrentCookedState.cookedPointerData.idToIndex, idBits, -1,
+                    mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+    }
+}
+
+const BitSet32& TouchInputMapper::findActiveIdBits(const CookedPointerData& cookedPointerData) {
+    if (!cookedPointerData.touchingIdBits.isEmpty()) {
+        return cookedPointerData.touchingIdBits;
+    }
+    return cookedPointerData.hoveringIdBits;
+}
+
+void TouchInputMapper::cookPointerData() {
+    uint32_t currentPointerCount = mCurrentRawState.rawPointerData.pointerCount;
+
+    mCurrentCookedState.cookedPointerData.clear();
+    mCurrentCookedState.cookedPointerData.pointerCount = currentPointerCount;
+    mCurrentCookedState.cookedPointerData.hoveringIdBits =
+            mCurrentRawState.rawPointerData.hoveringIdBits;
+    mCurrentCookedState.cookedPointerData.touchingIdBits =
+            mCurrentRawState.rawPointerData.touchingIdBits;
+
+    if (mCurrentCookedState.cookedPointerData.pointerCount == 0) {
+        mCurrentCookedState.buttonState = 0;
+    } else {
+        mCurrentCookedState.buttonState = mCurrentRawState.buttonState;
+    }
+
+    // Walk through the the active pointers and map device coordinates onto
+    // surface coordinates and adjust for display orientation.
+    for (uint32_t i = 0; i < currentPointerCount; i++) {
+        const RawPointerData::Pointer& in = mCurrentRawState.rawPointerData.pointers[i];
+
+        // Size
+        float touchMajor, touchMinor, toolMajor, toolMinor, size;
+        switch (mCalibration.sizeCalibration) {
+        case Calibration::SIZE_CALIBRATION_GEOMETRIC:
+        case Calibration::SIZE_CALIBRATION_DIAMETER:
+        case Calibration::SIZE_CALIBRATION_BOX:
+        case Calibration::SIZE_CALIBRATION_AREA:
+            if (mRawPointerAxes.touchMajor.valid && mRawPointerAxes.toolMajor.valid) {
+                touchMajor = in.touchMajor;
+                touchMinor = mRawPointerAxes.touchMinor.valid ? in.touchMinor : in.touchMajor;
+                toolMajor = in.toolMajor;
+                toolMinor = mRawPointerAxes.toolMinor.valid ? in.toolMinor : in.toolMajor;
+                size = mRawPointerAxes.touchMinor.valid
+                        ? avg(in.touchMajor, in.touchMinor) : in.touchMajor;
+            } else if (mRawPointerAxes.touchMajor.valid) {
+                toolMajor = touchMajor = in.touchMajor;
+                toolMinor = touchMinor = mRawPointerAxes.touchMinor.valid
+                        ? in.touchMinor : in.touchMajor;
+                size = mRawPointerAxes.touchMinor.valid
+                        ? avg(in.touchMajor, in.touchMinor) : in.touchMajor;
+            } else if (mRawPointerAxes.toolMajor.valid) {
+                touchMajor = toolMajor = in.toolMajor;
+                touchMinor = toolMinor = mRawPointerAxes.toolMinor.valid
+                        ? in.toolMinor : in.toolMajor;
+                size = mRawPointerAxes.toolMinor.valid
+                        ? avg(in.toolMajor, in.toolMinor) : in.toolMajor;
+            } else {
+                ALOG_ASSERT(false, "No touch or tool axes.  "
+                        "Size calibration should have been resolved to NONE.");
+                touchMajor = 0;
+                touchMinor = 0;
+                toolMajor = 0;
+                toolMinor = 0;
+                size = 0;
+            }
+
+            if (mCalibration.haveSizeIsSummed && mCalibration.sizeIsSummed) {
+                uint32_t touchingCount =
+                        mCurrentRawState.rawPointerData.touchingIdBits.count();
+                if (touchingCount > 1) {
+                    touchMajor /= touchingCount;
+                    touchMinor /= touchingCount;
+                    toolMajor /= touchingCount;
+                    toolMinor /= touchingCount;
+                    size /= touchingCount;
+                }
+            }
+
+            if (mCalibration.sizeCalibration == Calibration::SIZE_CALIBRATION_GEOMETRIC) {
+                touchMajor *= mGeometricScale;
+                touchMinor *= mGeometricScale;
+                toolMajor *= mGeometricScale;
+                toolMinor *= mGeometricScale;
+            } else if (mCalibration.sizeCalibration == Calibration::SIZE_CALIBRATION_AREA) {
+                touchMajor = touchMajor > 0 ? sqrtf(touchMajor) : 0;
+                touchMinor = touchMajor;
+                toolMajor = toolMajor > 0 ? sqrtf(toolMajor) : 0;
+                toolMinor = toolMajor;
+            } else if (mCalibration.sizeCalibration == Calibration::SIZE_CALIBRATION_DIAMETER) {
+                touchMinor = touchMajor;
+                toolMinor = toolMajor;
+            }
+
+            mCalibration.applySizeScaleAndBias(&touchMajor);
+            mCalibration.applySizeScaleAndBias(&touchMinor);
+            mCalibration.applySizeScaleAndBias(&toolMajor);
+            mCalibration.applySizeScaleAndBias(&toolMinor);
+            size *= mSizeScale;
+            break;
+        default:
+            touchMajor = 0;
+            touchMinor = 0;
+            toolMajor = 0;
+            toolMinor = 0;
+            size = 0;
+            break;
+        }
+
+        // Pressure
+        float pressure;
+        switch (mCalibration.pressureCalibration) {
+        case Calibration::PRESSURE_CALIBRATION_PHYSICAL:
+        case Calibration::PRESSURE_CALIBRATION_AMPLITUDE:
+            pressure = in.pressure * mPressureScale;
+            break;
+        default:
+            pressure = in.isHovering ? 0 : 1;
+            break;
+        }
+
+        // Tilt and Orientation
+        float tilt;
+        float orientation;
+        if (mHaveTilt) {
+            float tiltXAngle = (in.tiltX - mTiltXCenter) * mTiltXScale;
+            float tiltYAngle = (in.tiltY - mTiltYCenter) * mTiltYScale;
+            orientation = atan2f(-sinf(tiltXAngle), sinf(tiltYAngle));
+            tilt = acosf(cosf(tiltXAngle) * cosf(tiltYAngle));
+        } else {
+            tilt = 0;
+
+            switch (mCalibration.orientationCalibration) {
+            case Calibration::ORIENTATION_CALIBRATION_INTERPOLATED:
+                orientation = in.orientation * mOrientationScale;
+                break;
+            case Calibration::ORIENTATION_CALIBRATION_VECTOR: {
+                int32_t c1 = signExtendNybble((in.orientation & 0xf0) >> 4);
+                int32_t c2 = signExtendNybble(in.orientation & 0x0f);
+                if (c1 != 0 || c2 != 0) {
+                    orientation = atan2f(c1, c2) * 0.5f;
+                    float confidence = hypotf(c1, c2);
+                    float scale = 1.0f + confidence / 16.0f;
+                    touchMajor *= scale;
+                    touchMinor /= scale;
+                    toolMajor *= scale;
+                    toolMinor /= scale;
+                } else {
+                    orientation = 0;
+                }
+                break;
+            }
+            default:
+                orientation = 0;
+            }
+        }
+
+        // Distance
+        float distance;
+        switch (mCalibration.distanceCalibration) {
+        case Calibration::DISTANCE_CALIBRATION_SCALED:
+            distance = in.distance * mDistanceScale;
+            break;
+        default:
+            distance = 0;
+        }
+
+        // Coverage
+        int32_t rawLeft, rawTop, rawRight, rawBottom;
+        switch (mCalibration.coverageCalibration) {
+        case Calibration::COVERAGE_CALIBRATION_BOX:
+            rawLeft = (in.toolMinor & 0xffff0000) >> 16;
+            rawRight = in.toolMinor & 0x0000ffff;
+            rawBottom = in.toolMajor & 0x0000ffff;
+            rawTop = (in.toolMajor & 0xffff0000) >> 16;
+            break;
+        default:
+            rawLeft = rawTop = rawRight = rawBottom = 0;
+            break;
+        }
+
+        // Adjust X,Y coords for device calibration
+        // TODO: Adjust coverage coords?
+        float xTransformed = in.x, yTransformed = in.y;
+        mAffineTransform.applyTo(xTransformed, yTransformed);
+
+        // Adjust X, Y, and coverage coords for surface orientation.
+        float x, y;
+        float left, top, right, bottom;
+
+        switch (mSurfaceOrientation) {
+        case DISPLAY_ORIENTATION_90:
+            x = float(yTransformed - mRawPointerAxes.y.minValue) * mYScale + mYTranslate;
+            y = float(mRawPointerAxes.x.maxValue - xTransformed) * mXScale + mXTranslate;
+            left = float(rawTop - mRawPointerAxes.y.minValue) * mYScale + mYTranslate;
+            right = float(rawBottom- mRawPointerAxes.y.minValue) * mYScale + mYTranslate;
+            bottom = float(mRawPointerAxes.x.maxValue - rawLeft) * mXScale + mXTranslate;
+            top = float(mRawPointerAxes.x.maxValue - rawRight) * mXScale + mXTranslate;
+            orientation -= M_PI_2;
+            if (mOrientedRanges.haveOrientation && orientation < mOrientedRanges.orientation.min) {
+                orientation += (mOrientedRanges.orientation.max - mOrientedRanges.orientation.min);
+            }
+            break;
+        case DISPLAY_ORIENTATION_180:
+            x = float(mRawPointerAxes.x.maxValue - xTransformed) * mXScale + mXTranslate;
+            y = float(mRawPointerAxes.y.maxValue - yTransformed) * mYScale + mYTranslate;
+            left = float(mRawPointerAxes.x.maxValue - rawRight) * mXScale + mXTranslate;
+            right = float(mRawPointerAxes.x.maxValue - rawLeft) * mXScale + mXTranslate;
+            bottom = float(mRawPointerAxes.y.maxValue - rawTop) * mYScale + mYTranslate;
+            top = float(mRawPointerAxes.y.maxValue - rawBottom) * mYScale + mYTranslate;
+            orientation -= M_PI;
+            if (mOrientedRanges.haveOrientation && orientation < mOrientedRanges.orientation.min) {
+                orientation += (mOrientedRanges.orientation.max - mOrientedRanges.orientation.min);
+            }
+            break;
+        case DISPLAY_ORIENTATION_270:
+            x = float(mRawPointerAxes.y.maxValue - yTransformed) * mYScale + mYTranslate;
+            y = float(xTransformed - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
+            left = float(mRawPointerAxes.y.maxValue - rawBottom) * mYScale + mYTranslate;
+            right = float(mRawPointerAxes.y.maxValue - rawTop) * mYScale + mYTranslate;
+            bottom = float(rawRight - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
+            top = float(rawLeft - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
+            orientation += M_PI_2;
+            if (mOrientedRanges.haveOrientation && orientation > mOrientedRanges.orientation.max) {
+                orientation -= (mOrientedRanges.orientation.max - mOrientedRanges.orientation.min);
+            }
+            break;
+        default:
+            x = float(xTransformed - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
+            y = float(yTransformed - mRawPointerAxes.y.minValue) * mYScale + mYTranslate;
+            left = float(rawLeft - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
+            right = float(rawRight - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
+            bottom = float(rawBottom - mRawPointerAxes.y.minValue) * mYScale + mYTranslate;
+            top = float(rawTop - mRawPointerAxes.y.minValue) * mYScale + mYTranslate;
+            break;
+        }
+
+        // Write output coords.
+        PointerCoords& out = mCurrentCookedState.cookedPointerData.pointerCoords[i];
+        out.clear();
+        out.setAxisValue(AMOTION_EVENT_AXIS_X, x);
+        out.setAxisValue(AMOTION_EVENT_AXIS_Y, y);
+        out.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, pressure);
+        out.setAxisValue(AMOTION_EVENT_AXIS_SIZE, size);
+        out.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, touchMajor);
+        out.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, touchMinor);
+        out.setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, orientation);
+        out.setAxisValue(AMOTION_EVENT_AXIS_TILT, tilt);
+        out.setAxisValue(AMOTION_EVENT_AXIS_DISTANCE, distance);
+        if (mCalibration.coverageCalibration == Calibration::COVERAGE_CALIBRATION_BOX) {
+            out.setAxisValue(AMOTION_EVENT_AXIS_GENERIC_1, left);
+            out.setAxisValue(AMOTION_EVENT_AXIS_GENERIC_2, top);
+            out.setAxisValue(AMOTION_EVENT_AXIS_GENERIC_3, right);
+            out.setAxisValue(AMOTION_EVENT_AXIS_GENERIC_4, bottom);
+        } else {
+            out.setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, toolMajor);
+            out.setAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, toolMinor);
+        }
+
+        // Write output properties.
+        PointerProperties& properties =
+                mCurrentCookedState.cookedPointerData.pointerProperties[i];
+        uint32_t id = in.id;
+        properties.clear();
+        properties.id = id;
+        properties.toolType = in.toolType;
+
+        // Write id index.
+        mCurrentCookedState.cookedPointerData.idToIndex[id] = i;
+    }
+}
+
+void TouchInputMapper::dispatchPointerUsage(nsecs_t when, uint32_t policyFlags,
+        PointerUsage pointerUsage) {
+    if (pointerUsage != mPointerUsage) {
+        abortPointerUsage(when, policyFlags);
+        mPointerUsage = pointerUsage;
+    }
+
+    switch (mPointerUsage) {
+    case POINTER_USAGE_GESTURES:
+        dispatchPointerGestures(when, policyFlags, false /*isTimeout*/);
+        break;
+    case POINTER_USAGE_STYLUS:
+        dispatchPointerStylus(when, policyFlags);
+        break;
+    case POINTER_USAGE_MOUSE:
+        dispatchPointerMouse(when, policyFlags);
+        break;
+    default:
+        break;
+    }
+}
+
+void TouchInputMapper::abortPointerUsage(nsecs_t when, uint32_t policyFlags) {
+    switch (mPointerUsage) {
+    case POINTER_USAGE_GESTURES:
+        abortPointerGestures(when, policyFlags);
+        break;
+    case POINTER_USAGE_STYLUS:
+        abortPointerStylus(when, policyFlags);
+        break;
+    case POINTER_USAGE_MOUSE:
+        abortPointerMouse(when, policyFlags);
+        break;
+    default:
+        break;
+    }
+
+    mPointerUsage = POINTER_USAGE_NONE;
+}
+
+void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlags,
+        bool isTimeout) {
+    // Update current gesture coordinates.
+    bool cancelPreviousGesture, finishPreviousGesture;
+    bool sendEvents = preparePointerGestures(when,
+            &cancelPreviousGesture, &finishPreviousGesture, isTimeout);
+    if (!sendEvents) {
+        return;
+    }
+    if (finishPreviousGesture) {
+        cancelPreviousGesture = false;
+    }
+
+    // Update the pointer presentation and spots.
+    if (mParameters.gestureMode == Parameters::GESTURE_MODE_SPOTS) {
+        mPointerController->setPresentation(PointerControllerInterface::PRESENTATION_SPOT);
+        if (finishPreviousGesture || cancelPreviousGesture) {
+            mPointerController->clearSpots();
+        }
+        mPointerController->setSpots(mPointerGesture.currentGestureCoords,
+                mPointerGesture.currentGestureIdToIndex,
+                mPointerGesture.currentGestureIdBits);
+    } else {
+        mPointerController->setPresentation(PointerControllerInterface::PRESENTATION_POINTER);
+    }
+
+    // Show or hide the pointer if needed.
+    switch (mPointerGesture.currentGestureMode) {
+    case PointerGesture::NEUTRAL:
+    case PointerGesture::QUIET:
+        if (mParameters.gestureMode == Parameters::GESTURE_MODE_SPOTS
+                && (mPointerGesture.lastGestureMode == PointerGesture::SWIPE
+                        || mPointerGesture.lastGestureMode == PointerGesture::FREEFORM)) {
+            // Remind the user of where the pointer is after finishing a gesture with spots.
+            mPointerController->unfade(PointerControllerInterface::TRANSITION_GRADUAL);
+        }
+        break;
+    case PointerGesture::TAP:
+    case PointerGesture::TAP_DRAG:
+    case PointerGesture::BUTTON_CLICK_OR_DRAG:
+    case PointerGesture::HOVER:
+    case PointerGesture::PRESS:
+        // Unfade the pointer when the current gesture manipulates the
+        // area directly under the pointer.
+        mPointerController->unfade(PointerControllerInterface::TRANSITION_IMMEDIATE);
+        break;
+    case PointerGesture::SWIPE:
+    case PointerGesture::FREEFORM:
+        // Fade the pointer when the current gesture manipulates a different
+        // area and there are spots to guide the user experience.
+        if (mParameters.gestureMode == Parameters::GESTURE_MODE_SPOTS) {
+            mPointerController->fade(PointerControllerInterface::TRANSITION_GRADUAL);
+        } else {
+            mPointerController->unfade(PointerControllerInterface::TRANSITION_IMMEDIATE);
+        }
+        break;
+    }
+
+    // Send events!
+    int32_t metaState = getContext()->getGlobalMetaState();
+    int32_t buttonState = mCurrentCookedState.buttonState;
+
+    // Update last coordinates of pointers that have moved so that we observe the new
+    // pointer positions at the same time as other pointers that have just gone up.
+    bool down = mPointerGesture.currentGestureMode == PointerGesture::TAP
+            || mPointerGesture.currentGestureMode == PointerGesture::TAP_DRAG
+            || mPointerGesture.currentGestureMode == PointerGesture::BUTTON_CLICK_OR_DRAG
+            || mPointerGesture.currentGestureMode == PointerGesture::PRESS
+            || mPointerGesture.currentGestureMode == PointerGesture::SWIPE
+            || mPointerGesture.currentGestureMode == PointerGesture::FREEFORM;
+    bool moveNeeded = false;
+    if (down && !cancelPreviousGesture && !finishPreviousGesture
+            && !mPointerGesture.lastGestureIdBits.isEmpty()
+            && !mPointerGesture.currentGestureIdBits.isEmpty()) {
+        BitSet32 movedGestureIdBits(mPointerGesture.currentGestureIdBits.value
+                & mPointerGesture.lastGestureIdBits.value);
+        moveNeeded = updateMovedPointers(mPointerGesture.currentGestureProperties,
+                mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex,
+                mPointerGesture.lastGestureProperties,
+                mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex,
+                movedGestureIdBits);
+        if (buttonState != mLastCookedState.buttonState) {
+            moveNeeded = true;
+        }
+    }
+
+    // Send motion events for all pointers that went up or were canceled.
+    BitSet32 dispatchedGestureIdBits(mPointerGesture.lastGestureIdBits);
+    if (!dispatchedGestureIdBits.isEmpty()) {
+        if (cancelPreviousGesture) {
+            dispatchMotion(when, policyFlags, mSource,
+                    AMOTION_EVENT_ACTION_CANCEL, 0, 0, metaState, buttonState,
+                    AMOTION_EVENT_EDGE_FLAG_NONE,
+                    mPointerGesture.lastGestureProperties,
+                    mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex,
+                    dispatchedGestureIdBits, -1, 0,
+                    0, mPointerGesture.downTime);
+
+            dispatchedGestureIdBits.clear();
+        } else {
+            BitSet32 upGestureIdBits;
+            if (finishPreviousGesture) {
+                upGestureIdBits = dispatchedGestureIdBits;
+            } else {
+                upGestureIdBits.value = dispatchedGestureIdBits.value
+                        & ~mPointerGesture.currentGestureIdBits.value;
+            }
+            while (!upGestureIdBits.isEmpty()) {
+                uint32_t id = upGestureIdBits.clearFirstMarkedBit();
+
+                dispatchMotion(when, policyFlags, mSource,
+                        AMOTION_EVENT_ACTION_POINTER_UP, 0, 0,
+                        metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
+                        mPointerGesture.lastGestureProperties,
+                        mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex,
+                        dispatchedGestureIdBits, id,
+                        0, 0, mPointerGesture.downTime);
+
+                dispatchedGestureIdBits.clearBit(id);
+            }
+        }
+    }
+
+    // Send motion events for all pointers that moved.
+    if (moveNeeded) {
+        dispatchMotion(when, policyFlags, mSource,
+                AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState, buttonState,
+                AMOTION_EVENT_EDGE_FLAG_NONE,
+                mPointerGesture.currentGestureProperties,
+                mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex,
+                dispatchedGestureIdBits, -1,
+                0, 0, mPointerGesture.downTime);
+    }
+
+    // Send motion events for all pointers that went down.
+    if (down) {
+        BitSet32 downGestureIdBits(mPointerGesture.currentGestureIdBits.value
+                & ~dispatchedGestureIdBits.value);
+        while (!downGestureIdBits.isEmpty()) {
+            uint32_t id = downGestureIdBits.clearFirstMarkedBit();
+            dispatchedGestureIdBits.markBit(id);
+
+            if (dispatchedGestureIdBits.count() == 1) {
+                mPointerGesture.downTime = when;
+            }
+
+            dispatchMotion(when, policyFlags, mSource,
+                    AMOTION_EVENT_ACTION_POINTER_DOWN, 0, 0, metaState, buttonState, 0,
+                    mPointerGesture.currentGestureProperties,
+                    mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex,
+                    dispatchedGestureIdBits, id,
+                    0, 0, mPointerGesture.downTime);
+        }
+    }
+
+    // Send motion events for hover.
+    if (mPointerGesture.currentGestureMode == PointerGesture::HOVER) {
+        dispatchMotion(when, policyFlags, mSource,
+                AMOTION_EVENT_ACTION_HOVER_MOVE, 0, 0,
+                metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
+                mPointerGesture.currentGestureProperties,
+                mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex,
+                mPointerGesture.currentGestureIdBits, -1,
+                0, 0, mPointerGesture.downTime);
+    } else if (dispatchedGestureIdBits.isEmpty()
+            && !mPointerGesture.lastGestureIdBits.isEmpty()) {
+        // Synthesize a hover move event after all pointers go up to indicate that
+        // the pointer is hovering again even if the user is not currently touching
+        // the touch pad.  This ensures that a view will receive a fresh hover enter
+        // event after a tap.
+        float x, y;
+        mPointerController->getPosition(&x, &y);
+
+        PointerProperties pointerProperties;
+        pointerProperties.clear();
+        pointerProperties.id = 0;
+        pointerProperties.toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+
+        PointerCoords pointerCoords;
+        pointerCoords.clear();
+        pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x);
+        pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y);
+
+        NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
+                AMOTION_EVENT_ACTION_HOVER_MOVE, 0, 0,
+                metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
+                mViewport.displayId, 1, &pointerProperties, &pointerCoords,
+                0, 0, mPointerGesture.downTime);
+        getListener()->notifyMotion(&args);
+    }
+
+    // Update state.
+    mPointerGesture.lastGestureMode = mPointerGesture.currentGestureMode;
+    if (!down) {
+        mPointerGesture.lastGestureIdBits.clear();
+    } else {
+        mPointerGesture.lastGestureIdBits = mPointerGesture.currentGestureIdBits;
+        for (BitSet32 idBits(mPointerGesture.currentGestureIdBits); !idBits.isEmpty(); ) {
+            uint32_t id = idBits.clearFirstMarkedBit();
+            uint32_t index = mPointerGesture.currentGestureIdToIndex[id];
+            mPointerGesture.lastGestureProperties[index].copyFrom(
+                    mPointerGesture.currentGestureProperties[index]);
+            mPointerGesture.lastGestureCoords[index].copyFrom(
+                    mPointerGesture.currentGestureCoords[index]);
+            mPointerGesture.lastGestureIdToIndex[id] = index;
+        }
+    }
+}
+
+void TouchInputMapper::abortPointerGestures(nsecs_t when, uint32_t policyFlags) {
+    // Cancel previously dispatches pointers.
+    if (!mPointerGesture.lastGestureIdBits.isEmpty()) {
+        int32_t metaState = getContext()->getGlobalMetaState();
+        int32_t buttonState = mCurrentRawState.buttonState;
+        dispatchMotion(when, policyFlags, mSource,
+                AMOTION_EVENT_ACTION_CANCEL, 0, 0, metaState, buttonState,
+                AMOTION_EVENT_EDGE_FLAG_NONE,
+                mPointerGesture.lastGestureProperties,
+                mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex,
+                mPointerGesture.lastGestureIdBits, -1,
+                0, 0, mPointerGesture.downTime);
+    }
+
+    // Reset the current pointer gesture.
+    mPointerGesture.reset();
+    mPointerVelocityControl.reset();
+
+    // Remove any current spots.
+    if (mPointerController != NULL) {
+        mPointerController->fade(PointerControllerInterface::TRANSITION_GRADUAL);
+        mPointerController->clearSpots();
+    }
+}
+
+bool TouchInputMapper::preparePointerGestures(nsecs_t when,
+        bool* outCancelPreviousGesture, bool* outFinishPreviousGesture, bool isTimeout) {
+    *outCancelPreviousGesture = false;
+    *outFinishPreviousGesture = false;
+
+    // Handle TAP timeout.
+    if (isTimeout) {
+#if DEBUG_GESTURES
+        ALOGD("Gestures: Processing timeout");
+#endif
+
+        if (mPointerGesture.lastGestureMode == PointerGesture::TAP) {
+            if (when <= mPointerGesture.tapUpTime + mConfig.pointerGestureTapDragInterval) {
+                // The tap/drag timeout has not yet expired.
+                getContext()->requestTimeoutAtTime(mPointerGesture.tapUpTime
+                        + mConfig.pointerGestureTapDragInterval);
+            } else {
+                // The tap is finished.
+#if DEBUG_GESTURES
+                ALOGD("Gestures: TAP finished");
+#endif
+                *outFinishPreviousGesture = true;
+
+                mPointerGesture.activeGestureId = -1;
+                mPointerGesture.currentGestureMode = PointerGesture::NEUTRAL;
+                mPointerGesture.currentGestureIdBits.clear();
+
+                mPointerVelocityControl.reset();
+                return true;
+            }
+        }
+
+        // We did not handle this timeout.
+        return false;
+    }
+
+    const uint32_t currentFingerCount = mCurrentCookedState.fingerIdBits.count();
+    const uint32_t lastFingerCount = mLastCookedState.fingerIdBits.count();
+
+    // Update the velocity tracker.
+    {
+        VelocityTracker::Position positions[MAX_POINTERS];
+        uint32_t count = 0;
+        for (BitSet32 idBits(mCurrentCookedState.fingerIdBits); !idBits.isEmpty(); count++) {
+            uint32_t id = idBits.clearFirstMarkedBit();
+            const RawPointerData::Pointer& pointer =
+                    mCurrentRawState.rawPointerData.pointerForId(id);
+            positions[count].x = pointer.x * mPointerXMovementScale;
+            positions[count].y = pointer.y * mPointerYMovementScale;
+        }
+        mPointerGesture.velocityTracker.addMovement(when,
+                mCurrentCookedState.fingerIdBits, positions);
+    }
+
+    // If the gesture ever enters a mode other than TAP, HOVER or TAP_DRAG, without first returning
+    // to NEUTRAL, then we should not generate tap event.
+    if (mPointerGesture.lastGestureMode != PointerGesture::HOVER
+            && mPointerGesture.lastGestureMode != PointerGesture::TAP
+            && mPointerGesture.lastGestureMode != PointerGesture::TAP_DRAG) {
+        mPointerGesture.resetTap();
+    }
+
+    // Pick a new active touch id if needed.
+    // Choose an arbitrary pointer that just went down, if there is one.
+    // Otherwise choose an arbitrary remaining pointer.
+    // This guarantees we always have an active touch id when there is at least one pointer.
+    // We keep the same active touch id for as long as possible.
+    bool activeTouchChanged = false;
+    int32_t lastActiveTouchId = mPointerGesture.activeTouchId;
+    int32_t activeTouchId = lastActiveTouchId;
+    if (activeTouchId < 0) {
+        if (!mCurrentCookedState.fingerIdBits.isEmpty()) {
+            activeTouchChanged = true;
+            activeTouchId = mPointerGesture.activeTouchId =
+                    mCurrentCookedState.fingerIdBits.firstMarkedBit();
+            mPointerGesture.firstTouchTime = when;
+        }
+    } else if (!mCurrentCookedState.fingerIdBits.hasBit(activeTouchId)) {
+        activeTouchChanged = true;
+        if (!mCurrentCookedState.fingerIdBits.isEmpty()) {
+            activeTouchId = mPointerGesture.activeTouchId =
+                    mCurrentCookedState.fingerIdBits.firstMarkedBit();
+        } else {
+            activeTouchId = mPointerGesture.activeTouchId = -1;
+        }
+    }
+
+    // Determine whether we are in quiet time.
+    bool isQuietTime = false;
+    if (activeTouchId < 0) {
+        mPointerGesture.resetQuietTime();
+    } else {
+        isQuietTime = when < mPointerGesture.quietTime + mConfig.pointerGestureQuietInterval;
+        if (!isQuietTime) {
+            if ((mPointerGesture.lastGestureMode == PointerGesture::PRESS
+                    || mPointerGesture.lastGestureMode == PointerGesture::SWIPE
+                    || mPointerGesture.lastGestureMode == PointerGesture::FREEFORM)
+                    && currentFingerCount < 2) {
+                // Enter quiet time when exiting swipe or freeform state.
+                // This is to prevent accidentally entering the hover state and flinging the
+                // pointer when finishing a swipe and there is still one pointer left onscreen.
+                isQuietTime = true;
+            } else if (mPointerGesture.lastGestureMode == PointerGesture::BUTTON_CLICK_OR_DRAG
+                    && currentFingerCount >= 2
+                    && !isPointerDown(mCurrentRawState.buttonState)) {
+                // Enter quiet time when releasing the button and there are still two or more
+                // fingers down.  This may indicate that one finger was used to press the button
+                // but it has not gone up yet.
+                isQuietTime = true;
+            }
+            if (isQuietTime) {
+                mPointerGesture.quietTime = when;
+            }
+        }
+    }
+
+    // Switch states based on button and pointer state.
+    if (isQuietTime) {
+        // Case 1: Quiet time. (QUIET)
+#if DEBUG_GESTURES
+        ALOGD("Gestures: QUIET for next %0.3fms", (mPointerGesture.quietTime
+                + mConfig.pointerGestureQuietInterval - when) * 0.000001f);
+#endif
+        if (mPointerGesture.lastGestureMode != PointerGesture::QUIET) {
+            *outFinishPreviousGesture = true;
+        }
+
+        mPointerGesture.activeGestureId = -1;
+        mPointerGesture.currentGestureMode = PointerGesture::QUIET;
+        mPointerGesture.currentGestureIdBits.clear();
+
+        mPointerVelocityControl.reset();
+    } else if (isPointerDown(mCurrentRawState.buttonState)) {
+        // Case 2: Button is pressed. (BUTTON_CLICK_OR_DRAG)
+        // The pointer follows the active touch point.
+        // Emit DOWN, MOVE, UP events at the pointer location.
+        //
+        // Only the active touch matters; other fingers are ignored.  This policy helps
+        // to handle the case where the user places a second finger on the touch pad
+        // to apply the necessary force to depress an integrated button below the surface.
+        // We don't want the second finger to be delivered to applications.
+        //
+        // For this to work well, we need to make sure to track the pointer that is really
+        // active.  If the user first puts one finger down to click then adds another
+        // finger to drag then the active pointer should switch to the finger that is
+        // being dragged.
+#if DEBUG_GESTURES
+        ALOGD("Gestures: BUTTON_CLICK_OR_DRAG activeTouchId=%d, "
+                "currentFingerCount=%d", activeTouchId, currentFingerCount);
+#endif
+        // Reset state when just starting.
+        if (mPointerGesture.lastGestureMode != PointerGesture::BUTTON_CLICK_OR_DRAG) {
+            *outFinishPreviousGesture = true;
+            mPointerGesture.activeGestureId = 0;
+        }
+
+        // Switch pointers if needed.
+        // Find the fastest pointer and follow it.
+        if (activeTouchId >= 0 && currentFingerCount > 1) {
+            int32_t bestId = -1;
+            float bestSpeed = mConfig.pointerGestureDragMinSwitchSpeed;
+            for (BitSet32 idBits(mCurrentCookedState.fingerIdBits); !idBits.isEmpty(); ) {
+                uint32_t id = idBits.clearFirstMarkedBit();
+                float vx, vy;
+                if (mPointerGesture.velocityTracker.getVelocity(id, &vx, &vy)) {
+                    float speed = hypotf(vx, vy);
+                    if (speed > bestSpeed) {
+                        bestId = id;
+                        bestSpeed = speed;
+                    }
+                }
+            }
+            if (bestId >= 0 && bestId != activeTouchId) {
+                mPointerGesture.activeTouchId = activeTouchId = bestId;
+                activeTouchChanged = true;
+#if DEBUG_GESTURES
+                ALOGD("Gestures: BUTTON_CLICK_OR_DRAG switched pointers, "
+                        "bestId=%d, bestSpeed=%0.3f", bestId, bestSpeed);
+#endif
+            }
+        }
+
+        if (activeTouchId >= 0 && mLastCookedState.fingerIdBits.hasBit(activeTouchId)) {
+            const RawPointerData::Pointer& currentPointer =
+                    mCurrentRawState.rawPointerData.pointerForId(activeTouchId);
+            const RawPointerData::Pointer& lastPointer =
+                    mLastRawState.rawPointerData.pointerForId(activeTouchId);
+            float deltaX = (currentPointer.x - lastPointer.x) * mPointerXMovementScale;
+            float deltaY = (currentPointer.y - lastPointer.y) * mPointerYMovementScale;
+
+            rotateDelta(mSurfaceOrientation, &deltaX, &deltaY);
+            mPointerVelocityControl.move(when, &deltaX, &deltaY);
+
+            // Move the pointer using a relative motion.
+            // When using spots, the click will occur at the position of the anchor
+            // spot and all other spots will move there.
+            mPointerController->move(deltaX, deltaY);
+        } else {
+            mPointerVelocityControl.reset();
+        }
+
+        float x, y;
+        mPointerController->getPosition(&x, &y);
+
+        mPointerGesture.currentGestureMode = PointerGesture::BUTTON_CLICK_OR_DRAG;
+        mPointerGesture.currentGestureIdBits.clear();
+        mPointerGesture.currentGestureIdBits.markBit(mPointerGesture.activeGestureId);
+        mPointerGesture.currentGestureIdToIndex[mPointerGesture.activeGestureId] = 0;
+        mPointerGesture.currentGestureProperties[0].clear();
+        mPointerGesture.currentGestureProperties[0].id = mPointerGesture.activeGestureId;
+        mPointerGesture.currentGestureProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+        mPointerGesture.currentGestureCoords[0].clear();
+        mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, x);
+        mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, y);
+        mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
+    } else if (currentFingerCount == 0) {
+        // Case 3. No fingers down and button is not pressed. (NEUTRAL)
+        if (mPointerGesture.lastGestureMode != PointerGesture::NEUTRAL) {
+            *outFinishPreviousGesture = true;
+        }
+
+        // Watch for taps coming out of HOVER or TAP_DRAG mode.
+        // Checking for taps after TAP_DRAG allows us to detect double-taps.
+        bool tapped = false;
+        if ((mPointerGesture.lastGestureMode == PointerGesture::HOVER
+                || mPointerGesture.lastGestureMode == PointerGesture::TAP_DRAG)
+                && lastFingerCount == 1) {
+            if (when <= mPointerGesture.tapDownTime + mConfig.pointerGestureTapInterval) {
+                float x, y;
+                mPointerController->getPosition(&x, &y);
+                if (fabs(x - mPointerGesture.tapX) <= mConfig.pointerGestureTapSlop
+                        && fabs(y - mPointerGesture.tapY) <= mConfig.pointerGestureTapSlop) {
+#if DEBUG_GESTURES
+                    ALOGD("Gestures: TAP");
+#endif
+
+                    mPointerGesture.tapUpTime = when;
+                    getContext()->requestTimeoutAtTime(when
+                            + mConfig.pointerGestureTapDragInterval);
+
+                    mPointerGesture.activeGestureId = 0;
+                    mPointerGesture.currentGestureMode = PointerGesture::TAP;
+                    mPointerGesture.currentGestureIdBits.clear();
+                    mPointerGesture.currentGestureIdBits.markBit(
+                            mPointerGesture.activeGestureId);
+                    mPointerGesture.currentGestureIdToIndex[
+                            mPointerGesture.activeGestureId] = 0;
+                    mPointerGesture.currentGestureProperties[0].clear();
+                    mPointerGesture.currentGestureProperties[0].id =
+                            mPointerGesture.activeGestureId;
+                    mPointerGesture.currentGestureProperties[0].toolType =
+                            AMOTION_EVENT_TOOL_TYPE_FINGER;
+                    mPointerGesture.currentGestureCoords[0].clear();
+                    mPointerGesture.currentGestureCoords[0].setAxisValue(
+                            AMOTION_EVENT_AXIS_X, mPointerGesture.tapX);
+                    mPointerGesture.currentGestureCoords[0].setAxisValue(
+                            AMOTION_EVENT_AXIS_Y, mPointerGesture.tapY);
+                    mPointerGesture.currentGestureCoords[0].setAxisValue(
+                            AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
+
+                    tapped = true;
+                } else {
+#if DEBUG_GESTURES
+                    ALOGD("Gestures: Not a TAP, deltaX=%f, deltaY=%f",
+                            x - mPointerGesture.tapX,
+                            y - mPointerGesture.tapY);
+#endif
+                }
+            } else {
+#if DEBUG_GESTURES
+                if (mPointerGesture.tapDownTime != LLONG_MIN) {
+                    ALOGD("Gestures: Not a TAP, %0.3fms since down",
+                            (when - mPointerGesture.tapDownTime) * 0.000001f);
+                } else {
+                    ALOGD("Gestures: Not a TAP, incompatible mode transitions");
+                }
+#endif
+            }
+        }
+
+        mPointerVelocityControl.reset();
+
+        if (!tapped) {
+#if DEBUG_GESTURES
+            ALOGD("Gestures: NEUTRAL");
+#endif
+            mPointerGesture.activeGestureId = -1;
+            mPointerGesture.currentGestureMode = PointerGesture::NEUTRAL;
+            mPointerGesture.currentGestureIdBits.clear();
+        }
+    } else if (currentFingerCount == 1) {
+        // Case 4. Exactly one finger down, button is not pressed. (HOVER or TAP_DRAG)
+        // The pointer follows the active touch point.
+        // When in HOVER, emit HOVER_MOVE events at the pointer location.
+        // When in TAP_DRAG, emit MOVE events at the pointer location.
+        ALOG_ASSERT(activeTouchId >= 0);
+
+        mPointerGesture.currentGestureMode = PointerGesture::HOVER;
+        if (mPointerGesture.lastGestureMode == PointerGesture::TAP) {
+            if (when <= mPointerGesture.tapUpTime + mConfig.pointerGestureTapDragInterval) {
+                float x, y;
+                mPointerController->getPosition(&x, &y);
+                if (fabs(x - mPointerGesture.tapX) <= mConfig.pointerGestureTapSlop
+                        && fabs(y - mPointerGesture.tapY) <= mConfig.pointerGestureTapSlop) {
+                    mPointerGesture.currentGestureMode = PointerGesture::TAP_DRAG;
+                } else {
+#if DEBUG_GESTURES
+                    ALOGD("Gestures: Not a TAP_DRAG, deltaX=%f, deltaY=%f",
+                            x - mPointerGesture.tapX,
+                            y - mPointerGesture.tapY);
+#endif
+                }
+            } else {
+#if DEBUG_GESTURES
+                ALOGD("Gestures: Not a TAP_DRAG, %0.3fms time since up",
+                        (when - mPointerGesture.tapUpTime) * 0.000001f);
+#endif
+            }
+        } else if (mPointerGesture.lastGestureMode == PointerGesture::TAP_DRAG) {
+            mPointerGesture.currentGestureMode = PointerGesture::TAP_DRAG;
+        }
+
+        if (mLastCookedState.fingerIdBits.hasBit(activeTouchId)) {
+            const RawPointerData::Pointer& currentPointer =
+                    mCurrentRawState.rawPointerData.pointerForId(activeTouchId);
+            const RawPointerData::Pointer& lastPointer =
+                    mLastRawState.rawPointerData.pointerForId(activeTouchId);
+            float deltaX = (currentPointer.x - lastPointer.x)
+                    * mPointerXMovementScale;
+            float deltaY = (currentPointer.y - lastPointer.y)
+                    * mPointerYMovementScale;
+
+            rotateDelta(mSurfaceOrientation, &deltaX, &deltaY);
+            mPointerVelocityControl.move(when, &deltaX, &deltaY);
+
+            // Move the pointer using a relative motion.
+            // When using spots, the hover or drag will occur at the position of the anchor spot.
+            mPointerController->move(deltaX, deltaY);
+        } else {
+            mPointerVelocityControl.reset();
+        }
+
+        bool down;
+        if (mPointerGesture.currentGestureMode == PointerGesture::TAP_DRAG) {
+#if DEBUG_GESTURES
+            ALOGD("Gestures: TAP_DRAG");
+#endif
+            down = true;
+        } else {
+#if DEBUG_GESTURES
+            ALOGD("Gestures: HOVER");
+#endif
+            if (mPointerGesture.lastGestureMode != PointerGesture::HOVER) {
+                *outFinishPreviousGesture = true;
+            }
+            mPointerGesture.activeGestureId = 0;
+            down = false;
+        }
+
+        float x, y;
+        mPointerController->getPosition(&x, &y);
+
+        mPointerGesture.currentGestureIdBits.clear();
+        mPointerGesture.currentGestureIdBits.markBit(mPointerGesture.activeGestureId);
+        mPointerGesture.currentGestureIdToIndex[mPointerGesture.activeGestureId] = 0;
+        mPointerGesture.currentGestureProperties[0].clear();
+        mPointerGesture.currentGestureProperties[0].id = mPointerGesture.activeGestureId;
+        mPointerGesture.currentGestureProperties[0].toolType =
+                AMOTION_EVENT_TOOL_TYPE_FINGER;
+        mPointerGesture.currentGestureCoords[0].clear();
+        mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, x);
+        mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, y);
+        mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE,
+                down ? 1.0f : 0.0f);
+
+        if (lastFingerCount == 0 && currentFingerCount != 0) {
+            mPointerGesture.resetTap();
+            mPointerGesture.tapDownTime = when;
+            mPointerGesture.tapX = x;
+            mPointerGesture.tapY = y;
+        }
+    } else {
+        // Case 5. At least two fingers down, button is not pressed. (PRESS, SWIPE or FREEFORM)
+        // We need to provide feedback for each finger that goes down so we cannot wait
+        // for the fingers to move before deciding what to do.
+        //
+        // The ambiguous case is deciding what to do when there are two fingers down but they
+        // have not moved enough to determine whether they are part of a drag or part of a
+        // freeform gesture, or just a press or long-press at the pointer location.
+        //
+        // When there are two fingers we start with the PRESS hypothesis and we generate a
+        // down at the pointer location.
+        //
+        // When the two fingers move enough or when additional fingers are added, we make
+        // a decision to transition into SWIPE or FREEFORM mode accordingly.
+        ALOG_ASSERT(activeTouchId >= 0);
+
+        bool settled = when >= mPointerGesture.firstTouchTime
+                + mConfig.pointerGestureMultitouchSettleInterval;
+        if (mPointerGesture.lastGestureMode != PointerGesture::PRESS
+                && mPointerGesture.lastGestureMode != PointerGesture::SWIPE
+                && mPointerGesture.lastGestureMode != PointerGesture::FREEFORM) {
+            *outFinishPreviousGesture = true;
+        } else if (!settled && currentFingerCount > lastFingerCount) {
+            // Additional pointers have gone down but not yet settled.
+            // Reset the gesture.
+#if DEBUG_GESTURES
+            ALOGD("Gestures: Resetting gesture since additional pointers went down for MULTITOUCH, "
+                    "settle time remaining %0.3fms", (mPointerGesture.firstTouchTime
+                            + mConfig.pointerGestureMultitouchSettleInterval - when)
+                            * 0.000001f);
+#endif
+            *outCancelPreviousGesture = true;
+        } else {
+            // Continue previous gesture.
+            mPointerGesture.currentGestureMode = mPointerGesture.lastGestureMode;
+        }
+
+        if (*outFinishPreviousGesture || *outCancelPreviousGesture) {
+            mPointerGesture.currentGestureMode = PointerGesture::PRESS;
+            mPointerGesture.activeGestureId = 0;
+            mPointerGesture.referenceIdBits.clear();
+            mPointerVelocityControl.reset();
+
+            // Use the centroid and pointer location as the reference points for the gesture.
+#if DEBUG_GESTURES
+            ALOGD("Gestures: Using centroid as reference for MULTITOUCH, "
+                    "settle time remaining %0.3fms", (mPointerGesture.firstTouchTime
+                            + mConfig.pointerGestureMultitouchSettleInterval - when)
+                            * 0.000001f);
+#endif
+            mCurrentRawState.rawPointerData.getCentroidOfTouchingPointers(
+                    &mPointerGesture.referenceTouchX,
+                    &mPointerGesture.referenceTouchY);
+            mPointerController->getPosition(&mPointerGesture.referenceGestureX,
+                    &mPointerGesture.referenceGestureY);
+        }
+
+        // Clear the reference deltas for fingers not yet included in the reference calculation.
+        for (BitSet32 idBits(mCurrentCookedState.fingerIdBits.value
+                & ~mPointerGesture.referenceIdBits.value); !idBits.isEmpty(); ) {
+            uint32_t id = idBits.clearFirstMarkedBit();
+            mPointerGesture.referenceDeltas[id].dx = 0;
+            mPointerGesture.referenceDeltas[id].dy = 0;
+        }
+        mPointerGesture.referenceIdBits = mCurrentCookedState.fingerIdBits;
+
+        // Add delta for all fingers and calculate a common movement delta.
+        float commonDeltaX = 0, commonDeltaY = 0;
+        BitSet32 commonIdBits(mLastCookedState.fingerIdBits.value
+                & mCurrentCookedState.fingerIdBits.value);
+        for (BitSet32 idBits(commonIdBits); !idBits.isEmpty(); ) {
+            bool first = (idBits == commonIdBits);
+            uint32_t id = idBits.clearFirstMarkedBit();
+            const RawPointerData::Pointer& cpd = mCurrentRawState.rawPointerData.pointerForId(id);
+            const RawPointerData::Pointer& lpd = mLastRawState.rawPointerData.pointerForId(id);
+            PointerGesture::Delta& delta = mPointerGesture.referenceDeltas[id];
+            delta.dx += cpd.x - lpd.x;
+            delta.dy += cpd.y - lpd.y;
+
+            if (first) {
+                commonDeltaX = delta.dx;
+                commonDeltaY = delta.dy;
+            } else {
+                commonDeltaX = calculateCommonVector(commonDeltaX, delta.dx);
+                commonDeltaY = calculateCommonVector(commonDeltaY, delta.dy);
+            }
+        }
+
+        // Consider transitions from PRESS to SWIPE or MULTITOUCH.
+        if (mPointerGesture.currentGestureMode == PointerGesture::PRESS) {
+            float dist[MAX_POINTER_ID + 1];
+            int32_t distOverThreshold = 0;
+            for (BitSet32 idBits(mPointerGesture.referenceIdBits); !idBits.isEmpty(); ) {
+                uint32_t id = idBits.clearFirstMarkedBit();
+                PointerGesture::Delta& delta = mPointerGesture.referenceDeltas[id];
+                dist[id] = hypotf(delta.dx * mPointerXZoomScale,
+                        delta.dy * mPointerYZoomScale);
+                if (dist[id] > mConfig.pointerGestureMultitouchMinDistance) {
+                    distOverThreshold += 1;
+                }
+            }
+
+            // Only transition when at least two pointers have moved further than
+            // the minimum distance threshold.
+            if (distOverThreshold >= 2) {
+                if (currentFingerCount > 2) {
+                    // There are more than two pointers, switch to FREEFORM.
+#if DEBUG_GESTURES
+                    ALOGD("Gestures: PRESS transitioned to FREEFORM, number of pointers %d > 2",
+                            currentFingerCount);
+#endif
+                    *outCancelPreviousGesture = true;
+                    mPointerGesture.currentGestureMode = PointerGesture::FREEFORM;
+                } else {
+                    // There are exactly two pointers.
+                    BitSet32 idBits(mCurrentCookedState.fingerIdBits);
+                    uint32_t id1 = idBits.clearFirstMarkedBit();
+                    uint32_t id2 = idBits.firstMarkedBit();
+                    const RawPointerData::Pointer& p1 =
+                            mCurrentRawState.rawPointerData.pointerForId(id1);
+                    const RawPointerData::Pointer& p2 =
+                            mCurrentRawState.rawPointerData.pointerForId(id2);
+                    float mutualDistance = distance(p1.x, p1.y, p2.x, p2.y);
+                    if (mutualDistance > mPointerGestureMaxSwipeWidth) {
+                        // There are two pointers but they are too far apart for a SWIPE,
+                        // switch to FREEFORM.
+#if DEBUG_GESTURES
+                        ALOGD("Gestures: PRESS transitioned to FREEFORM, distance %0.3f > %0.3f",
+                                mutualDistance, mPointerGestureMaxSwipeWidth);
+#endif
+                        *outCancelPreviousGesture = true;
+                        mPointerGesture.currentGestureMode = PointerGesture::FREEFORM;
+                    } else {
+                        // There are two pointers.  Wait for both pointers to start moving
+                        // before deciding whether this is a SWIPE or FREEFORM gesture.
+                        float dist1 = dist[id1];
+                        float dist2 = dist[id2];
+                        if (dist1 >= mConfig.pointerGestureMultitouchMinDistance
+                                && dist2 >= mConfig.pointerGestureMultitouchMinDistance) {
+                            // Calculate the dot product of the displacement vectors.
+                            // When the vectors are oriented in approximately the same direction,
+                            // the angle betweeen them is near zero and the cosine of the angle
+                            // approches 1.0.  Recall that dot(v1, v2) = cos(angle) * mag(v1) * mag(v2).
+                            PointerGesture::Delta& delta1 = mPointerGesture.referenceDeltas[id1];
+                            PointerGesture::Delta& delta2 = mPointerGesture.referenceDeltas[id2];
+                            float dx1 = delta1.dx * mPointerXZoomScale;
+                            float dy1 = delta1.dy * mPointerYZoomScale;
+                            float dx2 = delta2.dx * mPointerXZoomScale;
+                            float dy2 = delta2.dy * mPointerYZoomScale;
+                            float dot = dx1 * dx2 + dy1 * dy2;
+                            float cosine = dot / (dist1 * dist2); // denominator always > 0
+                            if (cosine >= mConfig.pointerGestureSwipeTransitionAngleCosine) {
+                                // Pointers are moving in the same direction.  Switch to SWIPE.
+#if DEBUG_GESTURES
+                                ALOGD("Gestures: PRESS transitioned to SWIPE, "
+                                        "dist1 %0.3f >= %0.3f, dist2 %0.3f >= %0.3f, "
+                                        "cosine %0.3f >= %0.3f",
+                                        dist1, mConfig.pointerGestureMultitouchMinDistance,
+                                        dist2, mConfig.pointerGestureMultitouchMinDistance,
+                                        cosine, mConfig.pointerGestureSwipeTransitionAngleCosine);
+#endif
+                                mPointerGesture.currentGestureMode = PointerGesture::SWIPE;
+                            } else {
+                                // Pointers are moving in different directions.  Switch to FREEFORM.
+#if DEBUG_GESTURES
+                                ALOGD("Gestures: PRESS transitioned to FREEFORM, "
+                                        "dist1 %0.3f >= %0.3f, dist2 %0.3f >= %0.3f, "
+                                        "cosine %0.3f < %0.3f",
+                                        dist1, mConfig.pointerGestureMultitouchMinDistance,
+                                        dist2, mConfig.pointerGestureMultitouchMinDistance,
+                                        cosine, mConfig.pointerGestureSwipeTransitionAngleCosine);
+#endif
+                                *outCancelPreviousGesture = true;
+                                mPointerGesture.currentGestureMode = PointerGesture::FREEFORM;
+                            }
+                        }
+                    }
+                }
+            }
+        } else if (mPointerGesture.currentGestureMode == PointerGesture::SWIPE) {
+            // Switch from SWIPE to FREEFORM if additional pointers go down.
+            // Cancel previous gesture.
+            if (currentFingerCount > 2) {
+#if DEBUG_GESTURES
+                ALOGD("Gestures: SWIPE transitioned to FREEFORM, number of pointers %d > 2",
+                        currentFingerCount);
+#endif
+                *outCancelPreviousGesture = true;
+                mPointerGesture.currentGestureMode = PointerGesture::FREEFORM;
+            }
+        }
+
+        // Move the reference points based on the overall group motion of the fingers
+        // except in PRESS mode while waiting for a transition to occur.
+        if (mPointerGesture.currentGestureMode != PointerGesture::PRESS
+                && (commonDeltaX || commonDeltaY)) {
+            for (BitSet32 idBits(mPointerGesture.referenceIdBits); !idBits.isEmpty(); ) {
+                uint32_t id = idBits.clearFirstMarkedBit();
+                PointerGesture::Delta& delta = mPointerGesture.referenceDeltas[id];
+                delta.dx = 0;
+                delta.dy = 0;
+            }
+
+            mPointerGesture.referenceTouchX += commonDeltaX;
+            mPointerGesture.referenceTouchY += commonDeltaY;
+
+            commonDeltaX *= mPointerXMovementScale;
+            commonDeltaY *= mPointerYMovementScale;
+
+            rotateDelta(mSurfaceOrientation, &commonDeltaX, &commonDeltaY);
+            mPointerVelocityControl.move(when, &commonDeltaX, &commonDeltaY);
+
+            mPointerGesture.referenceGestureX += commonDeltaX;
+            mPointerGesture.referenceGestureY += commonDeltaY;
+        }
+
+        // Report gestures.
+        if (mPointerGesture.currentGestureMode == PointerGesture::PRESS
+                || mPointerGesture.currentGestureMode == PointerGesture::SWIPE) {
+            // PRESS or SWIPE mode.
+#if DEBUG_GESTURES
+            ALOGD("Gestures: PRESS or SWIPE activeTouchId=%d,"
+                    "activeGestureId=%d, currentTouchPointerCount=%d",
+                    activeTouchId, mPointerGesture.activeGestureId, currentFingerCount);
+#endif
+            ALOG_ASSERT(mPointerGesture.activeGestureId >= 0);
+
+            mPointerGesture.currentGestureIdBits.clear();
+            mPointerGesture.currentGestureIdBits.markBit(mPointerGesture.activeGestureId);
+            mPointerGesture.currentGestureIdToIndex[mPointerGesture.activeGestureId] = 0;
+            mPointerGesture.currentGestureProperties[0].clear();
+            mPointerGesture.currentGestureProperties[0].id = mPointerGesture.activeGestureId;
+            mPointerGesture.currentGestureProperties[0].toolType =
+                    AMOTION_EVENT_TOOL_TYPE_FINGER;
+            mPointerGesture.currentGestureCoords[0].clear();
+            mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X,
+                    mPointerGesture.referenceGestureX);
+            mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y,
+                    mPointerGesture.referenceGestureY);
+            mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
+        } else if (mPointerGesture.currentGestureMode == PointerGesture::FREEFORM) {
+            // FREEFORM mode.
+#if DEBUG_GESTURES
+            ALOGD("Gestures: FREEFORM activeTouchId=%d,"
+                    "activeGestureId=%d, currentTouchPointerCount=%d",
+                    activeTouchId, mPointerGesture.activeGestureId, currentFingerCount);
+#endif
+            ALOG_ASSERT(mPointerGesture.activeGestureId >= 0);
+
+            mPointerGesture.currentGestureIdBits.clear();
+
+            BitSet32 mappedTouchIdBits;
+            BitSet32 usedGestureIdBits;
+            if (mPointerGesture.lastGestureMode != PointerGesture::FREEFORM) {
+                // Initially, assign the active gesture id to the active touch point
+                // if there is one.  No other touch id bits are mapped yet.
+                if (!*outCancelPreviousGesture) {
+                    mappedTouchIdBits.markBit(activeTouchId);
+                    usedGestureIdBits.markBit(mPointerGesture.activeGestureId);
+                    mPointerGesture.freeformTouchToGestureIdMap[activeTouchId] =
+                            mPointerGesture.activeGestureId;
+                } else {
+                    mPointerGesture.activeGestureId = -1;
+                }
+            } else {
+                // Otherwise, assume we mapped all touches from the previous frame.
+                // Reuse all mappings that are still applicable.
+                mappedTouchIdBits.value = mLastCookedState.fingerIdBits.value
+                        & mCurrentCookedState.fingerIdBits.value;
+                usedGestureIdBits = mPointerGesture.lastGestureIdBits;
+
+                // Check whether we need to choose a new active gesture id because the
+                // current went went up.
+                for (BitSet32 upTouchIdBits(mLastCookedState.fingerIdBits.value
+                        & ~mCurrentCookedState.fingerIdBits.value);
+                        !upTouchIdBits.isEmpty(); ) {
+                    uint32_t upTouchId = upTouchIdBits.clearFirstMarkedBit();
+                    uint32_t upGestureId = mPointerGesture.freeformTouchToGestureIdMap[upTouchId];
+                    if (upGestureId == uint32_t(mPointerGesture.activeGestureId)) {
+                        mPointerGesture.activeGestureId = -1;
+                        break;
+                    }
+                }
+            }
+
+#if DEBUG_GESTURES
+            ALOGD("Gestures: FREEFORM follow up "
+                    "mappedTouchIdBits=0x%08x, usedGestureIdBits=0x%08x, "
+                    "activeGestureId=%d",
+                    mappedTouchIdBits.value, usedGestureIdBits.value,
+                    mPointerGesture.activeGestureId);
+#endif
+
+            BitSet32 idBits(mCurrentCookedState.fingerIdBits);
+            for (uint32_t i = 0; i < currentFingerCount; i++) {
+                uint32_t touchId = idBits.clearFirstMarkedBit();
+                uint32_t gestureId;
+                if (!mappedTouchIdBits.hasBit(touchId)) {
+                    gestureId = usedGestureIdBits.markFirstUnmarkedBit();
+                    mPointerGesture.freeformTouchToGestureIdMap[touchId] = gestureId;
+#if DEBUG_GESTURES
+                    ALOGD("Gestures: FREEFORM "
+                            "new mapping for touch id %d -> gesture id %d",
+                            touchId, gestureId);
+#endif
+                } else {
+                    gestureId = mPointerGesture.freeformTouchToGestureIdMap[touchId];
+#if DEBUG_GESTURES
+                    ALOGD("Gestures: FREEFORM "
+                            "existing mapping for touch id %d -> gesture id %d",
+                            touchId, gestureId);
+#endif
+                }
+                mPointerGesture.currentGestureIdBits.markBit(gestureId);
+                mPointerGesture.currentGestureIdToIndex[gestureId] = i;
+
+                const RawPointerData::Pointer& pointer =
+                        mCurrentRawState.rawPointerData.pointerForId(touchId);
+                float deltaX = (pointer.x - mPointerGesture.referenceTouchX)
+                        * mPointerXZoomScale;
+                float deltaY = (pointer.y - mPointerGesture.referenceTouchY)
+                        * mPointerYZoomScale;
+                rotateDelta(mSurfaceOrientation, &deltaX, &deltaY);
+
+                mPointerGesture.currentGestureProperties[i].clear();
+                mPointerGesture.currentGestureProperties[i].id = gestureId;
+                mPointerGesture.currentGestureProperties[i].toolType =
+                        AMOTION_EVENT_TOOL_TYPE_FINGER;
+                mPointerGesture.currentGestureCoords[i].clear();
+                mPointerGesture.currentGestureCoords[i].setAxisValue(
+                        AMOTION_EVENT_AXIS_X, mPointerGesture.referenceGestureX + deltaX);
+                mPointerGesture.currentGestureCoords[i].setAxisValue(
+                        AMOTION_EVENT_AXIS_Y, mPointerGesture.referenceGestureY + deltaY);
+                mPointerGesture.currentGestureCoords[i].setAxisValue(
+                        AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
+            }
+
+            if (mPointerGesture.activeGestureId < 0) {
+                mPointerGesture.activeGestureId =
+                        mPointerGesture.currentGestureIdBits.firstMarkedBit();
+#if DEBUG_GESTURES
+                ALOGD("Gestures: FREEFORM new "
+                        "activeGestureId=%d", mPointerGesture.activeGestureId);
+#endif
+            }
+        }
+    }
+
+    mPointerController->setButtonState(mCurrentRawState.buttonState);
+
+#if DEBUG_GESTURES
+    ALOGD("Gestures: finishPreviousGesture=%s, cancelPreviousGesture=%s, "
+            "currentGestureMode=%d, currentGestureIdBits=0x%08x, "
+            "lastGestureMode=%d, lastGestureIdBits=0x%08x",
+            toString(*outFinishPreviousGesture), toString(*outCancelPreviousGesture),
+            mPointerGesture.currentGestureMode, mPointerGesture.currentGestureIdBits.value,
+            mPointerGesture.lastGestureMode, mPointerGesture.lastGestureIdBits.value);
+    for (BitSet32 idBits = mPointerGesture.currentGestureIdBits; !idBits.isEmpty(); ) {
+        uint32_t id = idBits.clearFirstMarkedBit();
+        uint32_t index = mPointerGesture.currentGestureIdToIndex[id];
+        const PointerProperties& properties = mPointerGesture.currentGestureProperties[index];
+        const PointerCoords& coords = mPointerGesture.currentGestureCoords[index];
+        ALOGD("  currentGesture[%d]: index=%d, toolType=%d, "
+                "x=%0.3f, y=%0.3f, pressure=%0.3f",
+                id, index, properties.toolType,
+                coords.getAxisValue(AMOTION_EVENT_AXIS_X),
+                coords.getAxisValue(AMOTION_EVENT_AXIS_Y),
+                coords.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE));
+    }
+    for (BitSet32 idBits = mPointerGesture.lastGestureIdBits; !idBits.isEmpty(); ) {
+        uint32_t id = idBits.clearFirstMarkedBit();
+        uint32_t index = mPointerGesture.lastGestureIdToIndex[id];
+        const PointerProperties& properties = mPointerGesture.lastGestureProperties[index];
+        const PointerCoords& coords = mPointerGesture.lastGestureCoords[index];
+        ALOGD("  lastGesture[%d]: index=%d, toolType=%d, "
+                "x=%0.3f, y=%0.3f, pressure=%0.3f",
+                id, index, properties.toolType,
+                coords.getAxisValue(AMOTION_EVENT_AXIS_X),
+                coords.getAxisValue(AMOTION_EVENT_AXIS_Y),
+                coords.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE));
+    }
+#endif
+    return true;
+}
+
+void TouchInputMapper::dispatchPointerStylus(nsecs_t when, uint32_t policyFlags) {
+    mPointerSimple.currentCoords.clear();
+    mPointerSimple.currentProperties.clear();
+
+    bool down, hovering;
+    if (!mCurrentCookedState.stylusIdBits.isEmpty()) {
+        uint32_t id = mCurrentCookedState.stylusIdBits.firstMarkedBit();
+        uint32_t index = mCurrentCookedState.cookedPointerData.idToIndex[id];
+        float x = mCurrentCookedState.cookedPointerData.pointerCoords[index].getX();
+        float y = mCurrentCookedState.cookedPointerData.pointerCoords[index].getY();
+        mPointerController->setPosition(x, y);
+
+        hovering = mCurrentCookedState.cookedPointerData.hoveringIdBits.hasBit(id);
+        down = !hovering;
+
+        mPointerController->getPosition(&x, &y);
+        mPointerSimple.currentCoords.copyFrom(
+                mCurrentCookedState.cookedPointerData.pointerCoords[index]);
+        mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x);
+        mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y);
+        mPointerSimple.currentProperties.id = 0;
+        mPointerSimple.currentProperties.toolType =
+                mCurrentCookedState.cookedPointerData.pointerProperties[index].toolType;
+    } else {
+        down = false;
+        hovering = false;
+    }
+
+    dispatchPointerSimple(when, policyFlags, down, hovering);
+}
+
+void TouchInputMapper::abortPointerStylus(nsecs_t when, uint32_t policyFlags) {
+    abortPointerSimple(when, policyFlags);
+}
+
+void TouchInputMapper::dispatchPointerMouse(nsecs_t when, uint32_t policyFlags) {
+    mPointerSimple.currentCoords.clear();
+    mPointerSimple.currentProperties.clear();
+
+    bool down, hovering;
+    if (!mCurrentCookedState.mouseIdBits.isEmpty()) {
+        uint32_t id = mCurrentCookedState.mouseIdBits.firstMarkedBit();
+        uint32_t currentIndex = mCurrentRawState.rawPointerData.idToIndex[id];
+        if (mLastCookedState.mouseIdBits.hasBit(id)) {
+            uint32_t lastIndex = mCurrentRawState.rawPointerData.idToIndex[id];
+            float deltaX = (mCurrentRawState.rawPointerData.pointers[currentIndex].x
+                    - mLastRawState.rawPointerData.pointers[lastIndex].x)
+                    * mPointerXMovementScale;
+            float deltaY = (mCurrentRawState.rawPointerData.pointers[currentIndex].y
+                    - mLastRawState.rawPointerData.pointers[lastIndex].y)
+                    * mPointerYMovementScale;
+
+            rotateDelta(mSurfaceOrientation, &deltaX, &deltaY);
+            mPointerVelocityControl.move(when, &deltaX, &deltaY);
+
+            mPointerController->move(deltaX, deltaY);
+        } else {
+            mPointerVelocityControl.reset();
+        }
+
+        down = isPointerDown(mCurrentRawState.buttonState);
+        hovering = !down;
+
+        float x, y;
+        mPointerController->getPosition(&x, &y);
+        mPointerSimple.currentCoords.copyFrom(
+                mCurrentCookedState.cookedPointerData.pointerCoords[currentIndex]);
+        mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x);
+        mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y);
+        mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE,
+                hovering ? 0.0f : 1.0f);
+        mPointerSimple.currentProperties.id = 0;
+        mPointerSimple.currentProperties.toolType =
+                mCurrentCookedState.cookedPointerData.pointerProperties[currentIndex].toolType;
+    } else {
+        mPointerVelocityControl.reset();
+
+        down = false;
+        hovering = false;
+    }
+
+    dispatchPointerSimple(when, policyFlags, down, hovering);
+}
+
+void TouchInputMapper::abortPointerMouse(nsecs_t when, uint32_t policyFlags) {
+    abortPointerSimple(when, policyFlags);
+
+    mPointerVelocityControl.reset();
+}
+
+void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
+        bool down, bool hovering) {
+    int32_t metaState = getContext()->getGlobalMetaState();
+
+    if (mPointerController != NULL) {
+        if (down || hovering) {
+            mPointerController->setPresentation(PointerControllerInterface::PRESENTATION_POINTER);
+            mPointerController->clearSpots();
+            mPointerController->setButtonState(mCurrentRawState.buttonState);
+            mPointerController->unfade(PointerControllerInterface::TRANSITION_IMMEDIATE);
+        } else if (!down && !hovering && (mPointerSimple.down || mPointerSimple.hovering)) {
+            mPointerController->fade(PointerControllerInterface::TRANSITION_GRADUAL);
+        }
+    }
+
+    if (mPointerSimple.down && !down) {
+        mPointerSimple.down = false;
+
+        // Send up.
+        NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
+                 AMOTION_EVENT_ACTION_UP, 0, 0, metaState, mLastRawState.buttonState, 0,
+                 mViewport.displayId,
+                 1, &mPointerSimple.lastProperties, &mPointerSimple.lastCoords,
+                 mOrientedXPrecision, mOrientedYPrecision,
+                 mPointerSimple.downTime);
+        getListener()->notifyMotion(&args);
+    }
+
+    if (mPointerSimple.hovering && !hovering) {
+        mPointerSimple.hovering = false;
+
+        // Send hover exit.
+        NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
+                AMOTION_EVENT_ACTION_HOVER_EXIT, 0, 0, metaState, mLastRawState.buttonState, 0,
+                mViewport.displayId,
+                1, &mPointerSimple.lastProperties, &mPointerSimple.lastCoords,
+                mOrientedXPrecision, mOrientedYPrecision,
+                mPointerSimple.downTime);
+        getListener()->notifyMotion(&args);
+    }
+
+    if (down) {
+        if (!mPointerSimple.down) {
+            mPointerSimple.down = true;
+            mPointerSimple.downTime = when;
+
+            // Send down.
+            NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
+                    AMOTION_EVENT_ACTION_DOWN, 0, 0, metaState, mCurrentRawState.buttonState, 0,
+                    mViewport.displayId,
+                    1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
+                    mOrientedXPrecision, mOrientedYPrecision,
+                    mPointerSimple.downTime);
+            getListener()->notifyMotion(&args);
+        }
+
+        // Send move.
+        NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
+                AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState, mCurrentRawState.buttonState, 0,
+                mViewport.displayId,
+                1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
+                mOrientedXPrecision, mOrientedYPrecision,
+                mPointerSimple.downTime);
+        getListener()->notifyMotion(&args);
+    }
+
+    if (hovering) {
+        if (!mPointerSimple.hovering) {
+            mPointerSimple.hovering = true;
+
+            // Send hover enter.
+            NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
+                    AMOTION_EVENT_ACTION_HOVER_ENTER, 0, 0, metaState,
+                    mCurrentRawState.buttonState, 0,
+                    mViewport.displayId,
+                    1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
+                    mOrientedXPrecision, mOrientedYPrecision,
+                    mPointerSimple.downTime);
+            getListener()->notifyMotion(&args);
+        }
+
+        // Send hover move.
+        NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
+                AMOTION_EVENT_ACTION_HOVER_MOVE, 0, 0, metaState,
+                mCurrentRawState.buttonState, 0,
+                mViewport.displayId,
+                1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
+                mOrientedXPrecision, mOrientedYPrecision,
+                mPointerSimple.downTime);
+        getListener()->notifyMotion(&args);
+    }
+
+    if (mCurrentRawState.rawVScroll || mCurrentRawState.rawHScroll) {
+        float vscroll = mCurrentRawState.rawVScroll;
+        float hscroll = mCurrentRawState.rawHScroll;
+        mWheelYVelocityControl.move(when, NULL, &vscroll);
+        mWheelXVelocityControl.move(when, &hscroll, NULL);
+
+        // Send scroll.
+        PointerCoords pointerCoords;
+        pointerCoords.copyFrom(mPointerSimple.currentCoords);
+        pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_VSCROLL, vscroll);
+        pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_HSCROLL, hscroll);
+
+        NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
+                AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, mCurrentRawState.buttonState, 0,
+                mViewport.displayId,
+                1, &mPointerSimple.currentProperties, &pointerCoords,
+                mOrientedXPrecision, mOrientedYPrecision,
+                mPointerSimple.downTime);
+        getListener()->notifyMotion(&args);
+    }
+
+    // Save state.
+    if (down || hovering) {
+        mPointerSimple.lastCoords.copyFrom(mPointerSimple.currentCoords);
+        mPointerSimple.lastProperties.copyFrom(mPointerSimple.currentProperties);
+    } else {
+        mPointerSimple.reset();
+    }
+}
+
+void TouchInputMapper::abortPointerSimple(nsecs_t when, uint32_t policyFlags) {
+    mPointerSimple.currentCoords.clear();
+    mPointerSimple.currentProperties.clear();
+
+    dispatchPointerSimple(when, policyFlags, false, false);
+}
+
+void TouchInputMapper::dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32_t source,
+        int32_t action, int32_t actionButton, int32_t flags,
+        int32_t metaState, int32_t buttonState, int32_t edgeFlags,
+        const PointerProperties* properties, const PointerCoords* coords,
+        const uint32_t* idToIndex, BitSet32 idBits, int32_t changedId,
+        float xPrecision, float yPrecision, nsecs_t downTime) {
+    PointerCoords pointerCoords[MAX_POINTERS];
+    PointerProperties pointerProperties[MAX_POINTERS];
+    uint32_t pointerCount = 0;
+    while (!idBits.isEmpty()) {
+        uint32_t id = idBits.clearFirstMarkedBit();
+        uint32_t index = idToIndex[id];
+        pointerProperties[pointerCount].copyFrom(properties[index]);
+        pointerCoords[pointerCount].copyFrom(coords[index]);
+
+        if (changedId >= 0 && id == uint32_t(changedId)) {
+            action |= pointerCount << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
+        }
+
+        pointerCount += 1;
+    }
+
+    ALOG_ASSERT(pointerCount != 0);
+
+    if (changedId >= 0 && pointerCount == 1) {
+        // Replace initial down and final up action.
+        // We can compare the action without masking off the changed pointer index
+        // because we know the index is 0.
+        if (action == AMOTION_EVENT_ACTION_POINTER_DOWN) {
+            action = AMOTION_EVENT_ACTION_DOWN;
+        } else if (action == AMOTION_EVENT_ACTION_POINTER_UP) {
+            action = AMOTION_EVENT_ACTION_UP;
+        } else {
+            // Can't happen.
+            ALOG_ASSERT(false);
+        }
+    }
+
+    NotifyMotionArgs args(when, getDeviceId(), source, policyFlags,
+            action, actionButton, flags, metaState, buttonState, edgeFlags,
+            mViewport.displayId, pointerCount, pointerProperties, pointerCoords,
+            xPrecision, yPrecision, downTime);
+    getListener()->notifyMotion(&args);
+}
+
+bool TouchInputMapper::updateMovedPointers(const PointerProperties* inProperties,
+        const PointerCoords* inCoords, const uint32_t* inIdToIndex,
+        PointerProperties* outProperties, PointerCoords* outCoords, const uint32_t* outIdToIndex,
+        BitSet32 idBits) const {
+    bool changed = false;
+    while (!idBits.isEmpty()) {
+        uint32_t id = idBits.clearFirstMarkedBit();
+        uint32_t inIndex = inIdToIndex[id];
+        uint32_t outIndex = outIdToIndex[id];
+
+        const PointerProperties& curInProperties = inProperties[inIndex];
+        const PointerCoords& curInCoords = inCoords[inIndex];
+        PointerProperties& curOutProperties = outProperties[outIndex];
+        PointerCoords& curOutCoords = outCoords[outIndex];
+
+        if (curInProperties != curOutProperties) {
+            curOutProperties.copyFrom(curInProperties);
+            changed = true;
+        }
+
+        if (curInCoords != curOutCoords) {
+            curOutCoords.copyFrom(curInCoords);
+            changed = true;
+        }
+    }
+    return changed;
+}
+
+void TouchInputMapper::fadePointer() {
+    if (mPointerController != NULL) {
+        mPointerController->fade(PointerControllerInterface::TRANSITION_GRADUAL);
+    }
+}
+
+void TouchInputMapper::cancelTouch(nsecs_t when) {
+    abortPointerUsage(when, 0 /*policyFlags*/);
+    abortTouches(when, 0 /* policyFlags*/);
+}
+
+bool TouchInputMapper::isPointInsideSurface(int32_t x, int32_t y) {
+    return x >= mRawPointerAxes.x.minValue && x <= mRawPointerAxes.x.maxValue
+            && y >= mRawPointerAxes.y.minValue && y <= mRawPointerAxes.y.maxValue;
+}
+
+const TouchInputMapper::VirtualKey* TouchInputMapper::findVirtualKeyHit(
+        int32_t x, int32_t y) {
+    size_t numVirtualKeys = mVirtualKeys.size();
+    for (size_t i = 0; i < numVirtualKeys; i++) {
+        const VirtualKey& virtualKey = mVirtualKeys[i];
+
+#if DEBUG_VIRTUAL_KEYS
+        ALOGD("VirtualKeys: Hit test (%d, %d): keyCode=%d, scanCode=%d, "
+                "left=%d, top=%d, right=%d, bottom=%d",
+                x, y,
+                virtualKey.keyCode, virtualKey.scanCode,
+                virtualKey.hitLeft, virtualKey.hitTop,
+                virtualKey.hitRight, virtualKey.hitBottom);
+#endif
+
+        if (virtualKey.isHit(x, y)) {
+            return & virtualKey;
+        }
+    }
+
+    return NULL;
+}
+
+void TouchInputMapper::assignPointerIds(const RawState* last, RawState* current) {
+    uint32_t currentPointerCount = current->rawPointerData.pointerCount;
+    uint32_t lastPointerCount = last->rawPointerData.pointerCount;
+
+    current->rawPointerData.clearIdBits();
+
+    if (currentPointerCount == 0) {
+        // No pointers to assign.
+        return;
+    }
+
+    if (lastPointerCount == 0) {
+        // All pointers are new.
+        for (uint32_t i = 0; i < currentPointerCount; i++) {
+            uint32_t id = i;
+            current->rawPointerData.pointers[i].id = id;
+            current->rawPointerData.idToIndex[id] = i;
+            current->rawPointerData.markIdBit(id, current->rawPointerData.isHovering(i));
+        }
+        return;
+    }
+
+    if (currentPointerCount == 1 && lastPointerCount == 1
+            && current->rawPointerData.pointers[0].toolType
+                    == last->rawPointerData.pointers[0].toolType) {
+        // Only one pointer and no change in count so it must have the same id as before.
+        uint32_t id = last->rawPointerData.pointers[0].id;
+        current->rawPointerData.pointers[0].id = id;
+        current->rawPointerData.idToIndex[id] = 0;
+        current->rawPointerData.markIdBit(id, current->rawPointerData.isHovering(0));
+        return;
+    }
+
+    // General case.
+    // We build a heap of squared euclidean distances between current and last pointers
+    // associated with the current and last pointer indices.  Then, we find the best
+    // match (by distance) for each current pointer.
+    // The pointers must have the same tool type but it is possible for them to
+    // transition from hovering to touching or vice-versa while retaining the same id.
+    PointerDistanceHeapElement heap[MAX_POINTERS * MAX_POINTERS];
+
+    uint32_t heapSize = 0;
+    for (uint32_t currentPointerIndex = 0; currentPointerIndex < currentPointerCount;
+            currentPointerIndex++) {
+        for (uint32_t lastPointerIndex = 0; lastPointerIndex < lastPointerCount;
+                lastPointerIndex++) {
+            const RawPointerData::Pointer& currentPointer =
+                    current->rawPointerData.pointers[currentPointerIndex];
+            const RawPointerData::Pointer& lastPointer =
+                    last->rawPointerData.pointers[lastPointerIndex];
+            if (currentPointer.toolType == lastPointer.toolType) {
+                int64_t deltaX = currentPointer.x - lastPointer.x;
+                int64_t deltaY = currentPointer.y - lastPointer.y;
+
+                uint64_t distance = uint64_t(deltaX * deltaX + deltaY * deltaY);
+
+                // Insert new element into the heap (sift up).
+                heap[heapSize].currentPointerIndex = currentPointerIndex;
+                heap[heapSize].lastPointerIndex = lastPointerIndex;
+                heap[heapSize].distance = distance;
+                heapSize += 1;
+            }
+        }
+    }
+
+    // Heapify
+    for (uint32_t startIndex = heapSize / 2; startIndex != 0; ) {
+        startIndex -= 1;
+        for (uint32_t parentIndex = startIndex; ;) {
+            uint32_t childIndex = parentIndex * 2 + 1;
+            if (childIndex >= heapSize) {
+                break;
+            }
+
+            if (childIndex + 1 < heapSize
+                    && heap[childIndex + 1].distance < heap[childIndex].distance) {
+                childIndex += 1;
+            }
+
+            if (heap[parentIndex].distance <= heap[childIndex].distance) {
+                break;
+            }
+
+            swap(heap[parentIndex], heap[childIndex]);
+            parentIndex = childIndex;
+        }
+    }
+
+#if DEBUG_POINTER_ASSIGNMENT
+    ALOGD("assignPointerIds - initial distance min-heap: size=%d", heapSize);
+    for (size_t i = 0; i < heapSize; i++) {
+        ALOGD("  heap[%d]: cur=%d, last=%d, distance=%lld",
+                i, heap[i].currentPointerIndex, heap[i].lastPointerIndex,
+                heap[i].distance);
+    }
+#endif
+
+    // Pull matches out by increasing order of distance.
+    // To avoid reassigning pointers that have already been matched, the loop keeps track
+    // of which last and current pointers have been matched using the matchedXXXBits variables.
+    // It also tracks the used pointer id bits.
+    BitSet32 matchedLastBits(0);
+    BitSet32 matchedCurrentBits(0);
+    BitSet32 usedIdBits(0);
+    bool first = true;
+    for (uint32_t i = min(currentPointerCount, lastPointerCount); heapSize > 0 && i > 0; i--) {
+        while (heapSize > 0) {
+            if (first) {
+                // The first time through the loop, we just consume the root element of
+                // the heap (the one with smallest distance).
+                first = false;
+            } else {
+                // Previous iterations consumed the root element of the heap.
+                // Pop root element off of the heap (sift down).
+                heap[0] = heap[heapSize];
+                for (uint32_t parentIndex = 0; ;) {
+                    uint32_t childIndex = parentIndex * 2 + 1;
+                    if (childIndex >= heapSize) {
+                        break;
+                    }
+
+                    if (childIndex + 1 < heapSize
+                            && heap[childIndex + 1].distance < heap[childIndex].distance) {
+                        childIndex += 1;
+                    }
+
+                    if (heap[parentIndex].distance <= heap[childIndex].distance) {
+                        break;
+                    }
+
+                    swap(heap[parentIndex], heap[childIndex]);
+                    parentIndex = childIndex;
+                }
+
+#if DEBUG_POINTER_ASSIGNMENT
+                ALOGD("assignPointerIds - reduced distance min-heap: size=%d", heapSize);
+                for (size_t i = 0; i < heapSize; i++) {
+                    ALOGD("  heap[%d]: cur=%d, last=%d, distance=%lld",
+                            i, heap[i].currentPointerIndex, heap[i].lastPointerIndex,
+                            heap[i].distance);
+                }
+#endif
+            }
+
+            heapSize -= 1;
+
+            uint32_t currentPointerIndex = heap[0].currentPointerIndex;
+            if (matchedCurrentBits.hasBit(currentPointerIndex)) continue; // already matched
+
+            uint32_t lastPointerIndex = heap[0].lastPointerIndex;
+            if (matchedLastBits.hasBit(lastPointerIndex)) continue; // already matched
+
+            matchedCurrentBits.markBit(currentPointerIndex);
+            matchedLastBits.markBit(lastPointerIndex);
+
+            uint32_t id = last->rawPointerData.pointers[lastPointerIndex].id;
+            current->rawPointerData.pointers[currentPointerIndex].id = id;
+            current->rawPointerData.idToIndex[id] = currentPointerIndex;
+            current->rawPointerData.markIdBit(id,
+                    current->rawPointerData.isHovering(currentPointerIndex));
+            usedIdBits.markBit(id);
+
+#if DEBUG_POINTER_ASSIGNMENT
+            ALOGD("assignPointerIds - matched: cur=%d, last=%d, id=%d, distance=%lld",
+                    lastPointerIndex, currentPointerIndex, id, heap[0].distance);
+#endif
+            break;
+        }
+    }
+
+    // Assign fresh ids to pointers that were not matched in the process.
+    for (uint32_t i = currentPointerCount - matchedCurrentBits.count(); i != 0; i--) {
+        uint32_t currentPointerIndex = matchedCurrentBits.markFirstUnmarkedBit();
+        uint32_t id = usedIdBits.markFirstUnmarkedBit();
+
+        current->rawPointerData.pointers[currentPointerIndex].id = id;
+        current->rawPointerData.idToIndex[id] = currentPointerIndex;
+        current->rawPointerData.markIdBit(id,
+                current->rawPointerData.isHovering(currentPointerIndex));
+
+#if DEBUG_POINTER_ASSIGNMENT
+        ALOGD("assignPointerIds - assigned: cur=%d, id=%d",
+                currentPointerIndex, id);
+#endif
+    }
+}
+
+int32_t TouchInputMapper::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) {
+    if (mCurrentVirtualKey.down && mCurrentVirtualKey.keyCode == keyCode) {
+        return AKEY_STATE_VIRTUAL;
+    }
+
+    size_t numVirtualKeys = mVirtualKeys.size();
+    for (size_t i = 0; i < numVirtualKeys; i++) {
+        const VirtualKey& virtualKey = mVirtualKeys[i];
+        if (virtualKey.keyCode == keyCode) {
+            return AKEY_STATE_UP;
+        }
+    }
+
+    return AKEY_STATE_UNKNOWN;
+}
+
+int32_t TouchInputMapper::getScanCodeState(uint32_t sourceMask, int32_t scanCode) {
+    if (mCurrentVirtualKey.down && mCurrentVirtualKey.scanCode == scanCode) {
+        return AKEY_STATE_VIRTUAL;
+    }
+
+    size_t numVirtualKeys = mVirtualKeys.size();
+    for (size_t i = 0; i < numVirtualKeys; i++) {
+        const VirtualKey& virtualKey = mVirtualKeys[i];
+        if (virtualKey.scanCode == scanCode) {
+            return AKEY_STATE_UP;
+        }
+    }
+
+    return AKEY_STATE_UNKNOWN;
+}
+
+bool TouchInputMapper::markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes,
+        const int32_t* keyCodes, uint8_t* outFlags) {
+    size_t numVirtualKeys = mVirtualKeys.size();
+    for (size_t i = 0; i < numVirtualKeys; i++) {
+        const VirtualKey& virtualKey = mVirtualKeys[i];
+
+        for (size_t i = 0; i < numCodes; i++) {
+            if (virtualKey.keyCode == keyCodes[i]) {
+                outFlags[i] = 1;
+            }
+        }
+    }
+
+    return true;
+}
+
+
+// --- SingleTouchInputMapper ---
+
+SingleTouchInputMapper::SingleTouchInputMapper(InputDevice* device) :
+        TouchInputMapper(device) {
+}
+
+SingleTouchInputMapper::~SingleTouchInputMapper() {
+}
+
+void SingleTouchInputMapper::reset(nsecs_t when) {
+    mSingleTouchMotionAccumulator.reset(getDevice());
+
+    TouchInputMapper::reset(when);
+}
+
+void SingleTouchInputMapper::process(const RawEvent* rawEvent) {
+    TouchInputMapper::process(rawEvent);
+
+    mSingleTouchMotionAccumulator.process(rawEvent);
+}
+
+void SingleTouchInputMapper::syncTouch(nsecs_t when, RawState* outState) {
+    if (mTouchButtonAccumulator.isToolActive()) {
+        outState->rawPointerData.pointerCount = 1;
+        outState->rawPointerData.idToIndex[0] = 0;
+
+        bool isHovering = mTouchButtonAccumulator.getToolType() != AMOTION_EVENT_TOOL_TYPE_MOUSE
+                && (mTouchButtonAccumulator.isHovering()
+                        || (mRawPointerAxes.pressure.valid
+                                && mSingleTouchMotionAccumulator.getAbsolutePressure() <= 0));
+        outState->rawPointerData.markIdBit(0, isHovering);
+
+        RawPointerData::Pointer& outPointer = outState->rawPointerData.pointers[0];
+        outPointer.id = 0;
+        outPointer.x = mSingleTouchMotionAccumulator.getAbsoluteX();
+        outPointer.y = mSingleTouchMotionAccumulator.getAbsoluteY();
+        outPointer.pressure = mSingleTouchMotionAccumulator.getAbsolutePressure();
+        outPointer.touchMajor = 0;
+        outPointer.touchMinor = 0;
+        outPointer.toolMajor = mSingleTouchMotionAccumulator.getAbsoluteToolWidth();
+        outPointer.toolMinor = mSingleTouchMotionAccumulator.getAbsoluteToolWidth();
+        outPointer.orientation = 0;
+        outPointer.distance = mSingleTouchMotionAccumulator.getAbsoluteDistance();
+        outPointer.tiltX = mSingleTouchMotionAccumulator.getAbsoluteTiltX();
+        outPointer.tiltY = mSingleTouchMotionAccumulator.getAbsoluteTiltY();
+        outPointer.toolType = mTouchButtonAccumulator.getToolType();
+        if (outPointer.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
+            outPointer.toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+        }
+        outPointer.isHovering = isHovering;
+    }
+}
+
+void SingleTouchInputMapper::configureRawPointerAxes() {
+    TouchInputMapper::configureRawPointerAxes();
+
+    getAbsoluteAxisInfo(ABS_X, &mRawPointerAxes.x);
+    getAbsoluteAxisInfo(ABS_Y, &mRawPointerAxes.y);
+    getAbsoluteAxisInfo(ABS_PRESSURE, &mRawPointerAxes.pressure);
+    getAbsoluteAxisInfo(ABS_TOOL_WIDTH, &mRawPointerAxes.toolMajor);
+    getAbsoluteAxisInfo(ABS_DISTANCE, &mRawPointerAxes.distance);
+    getAbsoluteAxisInfo(ABS_TILT_X, &mRawPointerAxes.tiltX);
+    getAbsoluteAxisInfo(ABS_TILT_Y, &mRawPointerAxes.tiltY);
+}
+
+bool SingleTouchInputMapper::hasStylus() const {
+    return mTouchButtonAccumulator.hasStylus();
+}
+
+
+// --- MultiTouchInputMapper ---
+
+MultiTouchInputMapper::MultiTouchInputMapper(InputDevice* device) :
+        TouchInputMapper(device) {
+}
+
+MultiTouchInputMapper::~MultiTouchInputMapper() {
+}
+
+void MultiTouchInputMapper::reset(nsecs_t when) {
+    mMultiTouchMotionAccumulator.reset(getDevice());
+
+    mPointerIdBits.clear();
+
+    TouchInputMapper::reset(when);
+}
+
+void MultiTouchInputMapper::process(const RawEvent* rawEvent) {
+    TouchInputMapper::process(rawEvent);
+
+    mMultiTouchMotionAccumulator.process(rawEvent);
+}
+
+void MultiTouchInputMapper::syncTouch(nsecs_t when, RawState* outState) {
+    size_t inCount = mMultiTouchMotionAccumulator.getSlotCount();
+    size_t outCount = 0;
+    BitSet32 newPointerIdBits;
+
+    for (size_t inIndex = 0; inIndex < inCount; inIndex++) {
+        const MultiTouchMotionAccumulator::Slot* inSlot =
+                mMultiTouchMotionAccumulator.getSlot(inIndex);
+        if (!inSlot->isInUse()) {
+            continue;
+        }
+
+        if (outCount >= MAX_POINTERS) {
+#if DEBUG_POINTERS
+            ALOGD("MultiTouch device %s emitted more than maximum of %d pointers; "
+                    "ignoring the rest.",
+                    getDeviceName().string(), MAX_POINTERS);
+#endif
+            break; // too many fingers!
+        }
+
+        RawPointerData::Pointer& outPointer = outState->rawPointerData.pointers[outCount];
+        outPointer.x = inSlot->getX();
+        outPointer.y = inSlot->getY();
+        outPointer.pressure = inSlot->getPressure();
+        outPointer.touchMajor = inSlot->getTouchMajor();
+        outPointer.touchMinor = inSlot->getTouchMinor();
+        outPointer.toolMajor = inSlot->getToolMajor();
+        outPointer.toolMinor = inSlot->getToolMinor();
+        outPointer.orientation = inSlot->getOrientation();
+        outPointer.distance = inSlot->getDistance();
+        outPointer.tiltX = 0;
+        outPointer.tiltY = 0;
+
+        outPointer.toolType = inSlot->getToolType();
+        if (outPointer.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
+            outPointer.toolType = mTouchButtonAccumulator.getToolType();
+            if (outPointer.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
+                outPointer.toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+            }
+        }
+
+        bool isHovering = mTouchButtonAccumulator.getToolType() != AMOTION_EVENT_TOOL_TYPE_MOUSE
+                && (mTouchButtonAccumulator.isHovering()
+                        || (mRawPointerAxes.pressure.valid && inSlot->getPressure() <= 0));
+        outPointer.isHovering = isHovering;
+
+        // Assign pointer id using tracking id if available.
+        mHavePointerIds = true;
+        int32_t trackingId = inSlot->getTrackingId();
+        int32_t id = -1;
+        if (trackingId >= 0) {
+            for (BitSet32 idBits(mPointerIdBits); !idBits.isEmpty(); ) {
+                uint32_t n = idBits.clearFirstMarkedBit();
+                if (mPointerTrackingIdMap[n] == trackingId) {
+                    id = n;
+                }
+            }
+
+            if (id < 0 && !mPointerIdBits.isFull()) {
+                id = mPointerIdBits.markFirstUnmarkedBit();
+                mPointerTrackingIdMap[id] = trackingId;
+            }
+        }
+        if (id < 0) {
+            mHavePointerIds = false;
+            outState->rawPointerData.clearIdBits();
+            newPointerIdBits.clear();
+        } else {
+            outPointer.id = id;
+            outState->rawPointerData.idToIndex[id] = outCount;
+            outState->rawPointerData.markIdBit(id, isHovering);
+            newPointerIdBits.markBit(id);
+        }
+
+        outCount += 1;
+    }
+
+    outState->rawPointerData.pointerCount = outCount;
+    mPointerIdBits = newPointerIdBits;
+
+    mMultiTouchMotionAccumulator.finishSync();
+}
+
+void MultiTouchInputMapper::configureRawPointerAxes() {
+    TouchInputMapper::configureRawPointerAxes();
+
+    getAbsoluteAxisInfo(ABS_MT_POSITION_X, &mRawPointerAxes.x);
+    getAbsoluteAxisInfo(ABS_MT_POSITION_Y, &mRawPointerAxes.y);
+    getAbsoluteAxisInfo(ABS_MT_TOUCH_MAJOR, &mRawPointerAxes.touchMajor);
+    getAbsoluteAxisInfo(ABS_MT_TOUCH_MINOR, &mRawPointerAxes.touchMinor);
+    getAbsoluteAxisInfo(ABS_MT_WIDTH_MAJOR, &mRawPointerAxes.toolMajor);
+    getAbsoluteAxisInfo(ABS_MT_WIDTH_MINOR, &mRawPointerAxes.toolMinor);
+    getAbsoluteAxisInfo(ABS_MT_ORIENTATION, &mRawPointerAxes.orientation);
+    getAbsoluteAxisInfo(ABS_MT_PRESSURE, &mRawPointerAxes.pressure);
+    getAbsoluteAxisInfo(ABS_MT_DISTANCE, &mRawPointerAxes.distance);
+    getAbsoluteAxisInfo(ABS_MT_TRACKING_ID, &mRawPointerAxes.trackingId);
+    getAbsoluteAxisInfo(ABS_MT_SLOT, &mRawPointerAxes.slot);
+
+    if (mRawPointerAxes.trackingId.valid
+            && mRawPointerAxes.slot.valid
+            && mRawPointerAxes.slot.minValue == 0 && mRawPointerAxes.slot.maxValue > 0) {
+        size_t slotCount = mRawPointerAxes.slot.maxValue + 1;
+        if (slotCount > MAX_SLOTS) {
+            ALOGW("MultiTouch Device %s reported %zu slots but the framework "
+                    "only supports a maximum of %zu slots at this time.",
+                    getDeviceName().string(), slotCount, MAX_SLOTS);
+            slotCount = MAX_SLOTS;
+        }
+        mMultiTouchMotionAccumulator.configure(getDevice(),
+                slotCount, true /*usingSlotsProtocol*/);
+    } else {
+        mMultiTouchMotionAccumulator.configure(getDevice(),
+                MAX_POINTERS, false /*usingSlotsProtocol*/);
+    }
+}
+
+bool MultiTouchInputMapper::hasStylus() const {
+    return mMultiTouchMotionAccumulator.hasStylus()
+            || mTouchButtonAccumulator.hasStylus();
+}
+
+// --- ExternalStylusInputMapper
+
+ExternalStylusInputMapper::ExternalStylusInputMapper(InputDevice* device) :
+    InputMapper(device) {
+
+}
+
+uint32_t ExternalStylusInputMapper::getSources() {
+    return AINPUT_SOURCE_STYLUS;
+}
+
+void ExternalStylusInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
+    InputMapper::populateDeviceInfo(info);
+    info->addMotionRange(AMOTION_EVENT_AXIS_PRESSURE, AINPUT_SOURCE_STYLUS,
+            0.0f, 1.0f, 0.0f, 0.0f, 0.0f);
+}
+
+void ExternalStylusInputMapper::dump(String8& dump) {
+    dump.append(INDENT2 "External Stylus Input Mapper:\n");
+    dump.append(INDENT3 "Raw Stylus Axes:\n");
+    dumpRawAbsoluteAxisInfo(dump, mRawPressureAxis, "Pressure");
+    dump.append(INDENT3 "Stylus State:\n");
+    dumpStylusState(dump, mStylusState);
+}
+
+void ExternalStylusInputMapper::configure(nsecs_t when,
+        const InputReaderConfiguration* config, uint32_t changes) {
+    getAbsoluteAxisInfo(ABS_PRESSURE, &mRawPressureAxis);
+    mTouchButtonAccumulator.configure(getDevice());
+}
+
+void ExternalStylusInputMapper::reset(nsecs_t when) {
+    InputDevice* device = getDevice();
+    mSingleTouchMotionAccumulator.reset(device);
+    mTouchButtonAccumulator.reset(device);
+    InputMapper::reset(when);
+}
+
+void ExternalStylusInputMapper::process(const RawEvent* rawEvent) {
+    mSingleTouchMotionAccumulator.process(rawEvent);
+    mTouchButtonAccumulator.process(rawEvent);
+
+    if (rawEvent->type == EV_SYN && rawEvent->code == SYN_REPORT) {
+        sync(rawEvent->when);
+    }
+}
+
+void ExternalStylusInputMapper::sync(nsecs_t when) {
+    mStylusState.clear();
+
+    mStylusState.when = when;
+
+    mStylusState.toolType = mTouchButtonAccumulator.getToolType();
+    if (mStylusState.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
+        mStylusState.toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+    }
+
+    int32_t pressure = mSingleTouchMotionAccumulator.getAbsolutePressure();
+    if (mRawPressureAxis.valid) {
+        mStylusState.pressure = float(pressure) / mRawPressureAxis.maxValue;
+    } else if (mTouchButtonAccumulator.isToolActive()) {
+        mStylusState.pressure = 1.0f;
+    } else {
+        mStylusState.pressure = 0.0f;
+    }
+
+    mStylusState.buttons = mTouchButtonAccumulator.getButtonState();
+
+    mContext->dispatchExternalStylusState(mStylusState);
+}
+
+
+// --- JoystickInputMapper ---
+
+JoystickInputMapper::JoystickInputMapper(InputDevice* device) :
+        InputMapper(device) {
+}
+
+JoystickInputMapper::~JoystickInputMapper() {
+}
+
+uint32_t JoystickInputMapper::getSources() {
+    return AINPUT_SOURCE_JOYSTICK;
+}
+
+void JoystickInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
+    InputMapper::populateDeviceInfo(info);
+
+    for (size_t i = 0; i < mAxes.size(); i++) {
+        const Axis& axis = mAxes.valueAt(i);
+        addMotionRange(axis.axisInfo.axis, axis, info);
+
+        if (axis.axisInfo.mode == AxisInfo::MODE_SPLIT) {
+            addMotionRange(axis.axisInfo.highAxis, axis, info);
+
+        }
+    }
+}
+
+void JoystickInputMapper::addMotionRange(int32_t axisId, const Axis& axis,
+        InputDeviceInfo* info) {
+    info->addMotionRange(axisId, AINPUT_SOURCE_JOYSTICK,
+            axis.min, axis.max, axis.flat, axis.fuzz, axis.resolution);
+    /* In order to ease the transition for developers from using the old axes
+     * to the newer, more semantically correct axes, we'll continue to register
+     * the old axes as duplicates of their corresponding new ones.  */
+    int32_t compatAxis = getCompatAxis(axisId);
+    if (compatAxis >= 0) {
+        info->addMotionRange(compatAxis, AINPUT_SOURCE_JOYSTICK,
+                axis.min, axis.max, axis.flat, axis.fuzz, axis.resolution);
+    }
+}
+
+/* A mapping from axes the joystick actually has to the axes that should be
+ * artificially created for compatibility purposes.
+ * Returns -1 if no compatibility axis is needed. */
+int32_t JoystickInputMapper::getCompatAxis(int32_t axis) {
+    switch(axis) {
+    case AMOTION_EVENT_AXIS_LTRIGGER:
+        return AMOTION_EVENT_AXIS_BRAKE;
+    case AMOTION_EVENT_AXIS_RTRIGGER:
+        return AMOTION_EVENT_AXIS_GAS;
+    }
+    return -1;
+}
+
+void JoystickInputMapper::dump(String8& dump) {
+    dump.append(INDENT2 "Joystick Input Mapper:\n");
+
+    dump.append(INDENT3 "Axes:\n");
+    size_t numAxes = mAxes.size();
+    for (size_t i = 0; i < numAxes; i++) {
+        const Axis& axis = mAxes.valueAt(i);
+        const char* label = getAxisLabel(axis.axisInfo.axis);
+        if (label) {
+            dump.appendFormat(INDENT4 "%s", label);
+        } else {
+            dump.appendFormat(INDENT4 "%d", axis.axisInfo.axis);
+        }
+        if (axis.axisInfo.mode == AxisInfo::MODE_SPLIT) {
+            label = getAxisLabel(axis.axisInfo.highAxis);
+            if (label) {
+                dump.appendFormat(" / %s (split at %d)", label, axis.axisInfo.splitValue);
+            } else {
+                dump.appendFormat(" / %d (split at %d)", axis.axisInfo.highAxis,
+                        axis.axisInfo.splitValue);
+            }
+        } else if (axis.axisInfo.mode == AxisInfo::MODE_INVERT) {
+            dump.append(" (invert)");
+        }
+
+        dump.appendFormat(": min=%0.5f, max=%0.5f, flat=%0.5f, fuzz=%0.5f, resolution=%0.5f\n",
+                axis.min, axis.max, axis.flat, axis.fuzz, axis.resolution);
+        dump.appendFormat(INDENT4 "  scale=%0.5f, offset=%0.5f, "
+                "highScale=%0.5f, highOffset=%0.5f\n",
+                axis.scale, axis.offset, axis.highScale, axis.highOffset);
+        dump.appendFormat(INDENT4 "  rawAxis=%d, rawMin=%d, rawMax=%d, "
+                "rawFlat=%d, rawFuzz=%d, rawResolution=%d\n",
+                mAxes.keyAt(i), axis.rawAxisInfo.minValue, axis.rawAxisInfo.maxValue,
+                axis.rawAxisInfo.flat, axis.rawAxisInfo.fuzz, axis.rawAxisInfo.resolution);
+    }
+}
+
+void JoystickInputMapper::configure(nsecs_t when,
+        const InputReaderConfiguration* config, uint32_t changes) {
+    InputMapper::configure(when, config, changes);
+
+    if (!changes) { // first time only
+        // Collect all axes.
+        for (int32_t abs = 0; abs <= ABS_MAX; abs++) {
+            if (!(getAbsAxisUsage(abs, getDevice()->getClasses())
+                    & INPUT_DEVICE_CLASS_JOYSTICK)) {
+                continue; // axis must be claimed by a different device
+            }
+
+            RawAbsoluteAxisInfo rawAxisInfo;
+            getAbsoluteAxisInfo(abs, &rawAxisInfo);
+            if (rawAxisInfo.valid) {
+                // Map axis.
+                AxisInfo axisInfo;
+                bool explicitlyMapped = !getEventHub()->mapAxis(getDeviceId(), abs, &axisInfo);
+                if (!explicitlyMapped) {
+                    // Axis is not explicitly mapped, will choose a generic axis later.
+                    axisInfo.mode = AxisInfo::MODE_NORMAL;
+                    axisInfo.axis = -1;
+                }
+
+                // Apply flat override.
+                int32_t rawFlat = axisInfo.flatOverride < 0
+                        ? rawAxisInfo.flat : axisInfo.flatOverride;
+
+                // Calculate scaling factors and limits.
+                Axis axis;
+                if (axisInfo.mode == AxisInfo::MODE_SPLIT) {
+                    float scale = 1.0f / (axisInfo.splitValue - rawAxisInfo.minValue);
+                    float highScale = 1.0f / (rawAxisInfo.maxValue - axisInfo.splitValue);
+                    axis.initialize(rawAxisInfo, axisInfo, explicitlyMapped,
+                            scale, 0.0f, highScale, 0.0f,
+                            0.0f, 1.0f, rawFlat * scale, rawAxisInfo.fuzz * scale,
+                            rawAxisInfo.resolution * scale);
+                } else if (isCenteredAxis(axisInfo.axis)) {
+                    float scale = 2.0f / (rawAxisInfo.maxValue - rawAxisInfo.minValue);
+                    float offset = avg(rawAxisInfo.minValue, rawAxisInfo.maxValue) * -scale;
+                    axis.initialize(rawAxisInfo, axisInfo, explicitlyMapped,
+                            scale, offset, scale, offset,
+                            -1.0f, 1.0f, rawFlat * scale, rawAxisInfo.fuzz * scale,
+                            rawAxisInfo.resolution * scale);
+                } else {
+                    float scale = 1.0f / (rawAxisInfo.maxValue - rawAxisInfo.minValue);
+                    axis.initialize(rawAxisInfo, axisInfo, explicitlyMapped,
+                            scale, 0.0f, scale, 0.0f,
+                            0.0f, 1.0f, rawFlat * scale, rawAxisInfo.fuzz * scale,
+                            rawAxisInfo.resolution * scale);
+                }
+
+                // To eliminate noise while the joystick is at rest, filter out small variations
+                // in axis values up front.
+                axis.filter = axis.fuzz ? axis.fuzz : axis.flat * 0.25f;
+
+                mAxes.add(abs, axis);
+            }
+        }
+
+        // If there are too many axes, start dropping them.
+        // Prefer to keep explicitly mapped axes.
+        if (mAxes.size() > PointerCoords::MAX_AXES) {
+            ALOGI("Joystick '%s' has %zu axes but the framework only supports a maximum of %d.",
+                    getDeviceName().string(), mAxes.size(), PointerCoords::MAX_AXES);
+            pruneAxes(true);
+            pruneAxes(false);
+        }
+
+        // Assign generic axis ids to remaining axes.
+        int32_t nextGenericAxisId = AMOTION_EVENT_AXIS_GENERIC_1;
+        size_t numAxes = mAxes.size();
+        for (size_t i = 0; i < numAxes; i++) {
+            Axis& axis = mAxes.editValueAt(i);
+            if (axis.axisInfo.axis < 0) {
+                while (nextGenericAxisId <= AMOTION_EVENT_AXIS_GENERIC_16
+                        && haveAxis(nextGenericAxisId)) {
+                    nextGenericAxisId += 1;
+                }
+
+                if (nextGenericAxisId <= AMOTION_EVENT_AXIS_GENERIC_16) {
+                    axis.axisInfo.axis = nextGenericAxisId;
+                    nextGenericAxisId += 1;
+                } else {
+                    ALOGI("Ignoring joystick '%s' axis %d because all of the generic axis ids "
+                            "have already been assigned to other axes.",
+                            getDeviceName().string(), mAxes.keyAt(i));
+                    mAxes.removeItemsAt(i--);
+                    numAxes -= 1;
+                }
+            }
+        }
+    }
+}
+
+bool JoystickInputMapper::haveAxis(int32_t axisId) {
+    size_t numAxes = mAxes.size();
+    for (size_t i = 0; i < numAxes; i++) {
+        const Axis& axis = mAxes.valueAt(i);
+        if (axis.axisInfo.axis == axisId
+                || (axis.axisInfo.mode == AxisInfo::MODE_SPLIT
+                        && axis.axisInfo.highAxis == axisId)) {
+            return true;
+        }
+    }
+    return false;
+}
+
+void JoystickInputMapper::pruneAxes(bool ignoreExplicitlyMappedAxes) {
+    size_t i = mAxes.size();
+    while (mAxes.size() > PointerCoords::MAX_AXES && i-- > 0) {
+        if (ignoreExplicitlyMappedAxes && mAxes.valueAt(i).explicitlyMapped) {
+            continue;
+        }
+        ALOGI("Discarding joystick '%s' axis %d because there are too many axes.",
+                getDeviceName().string(), mAxes.keyAt(i));
+        mAxes.removeItemsAt(i);
+    }
+}
+
+bool JoystickInputMapper::isCenteredAxis(int32_t axis) {
+    switch (axis) {
+    case AMOTION_EVENT_AXIS_X:
+    case AMOTION_EVENT_AXIS_Y:
+    case AMOTION_EVENT_AXIS_Z:
+    case AMOTION_EVENT_AXIS_RX:
+    case AMOTION_EVENT_AXIS_RY:
+    case AMOTION_EVENT_AXIS_RZ:
+    case AMOTION_EVENT_AXIS_HAT_X:
+    case AMOTION_EVENT_AXIS_HAT_Y:
+    case AMOTION_EVENT_AXIS_ORIENTATION:
+    case AMOTION_EVENT_AXIS_RUDDER:
+    case AMOTION_EVENT_AXIS_WHEEL:
+        return true;
+    default:
+        return false;
+    }
+}
+
+void JoystickInputMapper::reset(nsecs_t when) {
+    // Recenter all axes.
+    size_t numAxes = mAxes.size();
+    for (size_t i = 0; i < numAxes; i++) {
+        Axis& axis = mAxes.editValueAt(i);
+        axis.resetValue();
+    }
+
+    InputMapper::reset(when);
+}
+
+void JoystickInputMapper::process(const RawEvent* rawEvent) {
+    switch (rawEvent->type) {
+    case EV_ABS: {
+        ssize_t index = mAxes.indexOfKey(rawEvent->code);
+        if (index >= 0) {
+            Axis& axis = mAxes.editValueAt(index);
+            float newValue, highNewValue;
+            switch (axis.axisInfo.mode) {
+            case AxisInfo::MODE_INVERT:
+                newValue = (axis.rawAxisInfo.maxValue - rawEvent->value)
+                        * axis.scale + axis.offset;
+                highNewValue = 0.0f;
+                break;
+            case AxisInfo::MODE_SPLIT:
+                if (rawEvent->value < axis.axisInfo.splitValue) {
+                    newValue = (axis.axisInfo.splitValue - rawEvent->value)
+                            * axis.scale + axis.offset;
+                    highNewValue = 0.0f;
+                } else if (rawEvent->value > axis.axisInfo.splitValue) {
+                    newValue = 0.0f;
+                    highNewValue = (rawEvent->value - axis.axisInfo.splitValue)
+                            * axis.highScale + axis.highOffset;
+                } else {
+                    newValue = 0.0f;
+                    highNewValue = 0.0f;
+                }
+                break;
+            default:
+                newValue = rawEvent->value * axis.scale + axis.offset;
+                highNewValue = 0.0f;
+                break;
+            }
+            axis.newValue = newValue;
+            axis.highNewValue = highNewValue;
+        }
+        break;
+    }
+
+    case EV_SYN:
+        switch (rawEvent->code) {
+        case SYN_REPORT:
+            sync(rawEvent->when, false /*force*/);
+            break;
+        }
+        break;
+    }
+}
+
+void JoystickInputMapper::sync(nsecs_t when, bool force) {
+    if (!filterAxes(force)) {
+        return;
+    }
+
+    int32_t metaState = mContext->getGlobalMetaState();
+    int32_t buttonState = 0;
+
+    PointerProperties pointerProperties;
+    pointerProperties.clear();
+    pointerProperties.id = 0;
+    pointerProperties.toolType = AMOTION_EVENT_TOOL_TYPE_UNKNOWN;
+
+    PointerCoords pointerCoords;
+    pointerCoords.clear();
+
+    size_t numAxes = mAxes.size();
+    for (size_t i = 0; i < numAxes; i++) {
+        const Axis& axis = mAxes.valueAt(i);
+        setPointerCoordsAxisValue(&pointerCoords, axis.axisInfo.axis, axis.currentValue);
+        if (axis.axisInfo.mode == AxisInfo::MODE_SPLIT) {
+            setPointerCoordsAxisValue(&pointerCoords, axis.axisInfo.highAxis,
+                    axis.highCurrentValue);
+        }
+    }
+
+    // Moving a joystick axis should not wake the device because joysticks can
+    // be fairly noisy even when not in use.  On the other hand, pushing a gamepad
+    // button will likely wake the device.
+    // TODO: Use the input device configuration to control this behavior more finely.
+    uint32_t policyFlags = 0;
+
+    NotifyMotionArgs args(when, getDeviceId(), AINPUT_SOURCE_JOYSTICK, policyFlags,
+            AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
+            ADISPLAY_ID_NONE, 1, &pointerProperties, &pointerCoords, 0, 0, 0);
+    getListener()->notifyMotion(&args);
+}
+
+void JoystickInputMapper::setPointerCoordsAxisValue(PointerCoords* pointerCoords,
+        int32_t axis, float value) {
+    pointerCoords->setAxisValue(axis, value);
+    /* In order to ease the transition for developers from using the old axes
+     * to the newer, more semantically correct axes, we'll continue to produce
+     * values for the old axes as mirrors of the value of their corresponding
+     * new axes. */
+    int32_t compatAxis = getCompatAxis(axis);
+    if (compatAxis >= 0) {
+        pointerCoords->setAxisValue(compatAxis, value);
+    }
+}
+
+bool JoystickInputMapper::filterAxes(bool force) {
+    bool atLeastOneSignificantChange = force;
+    size_t numAxes = mAxes.size();
+    for (size_t i = 0; i < numAxes; i++) {
+        Axis& axis = mAxes.editValueAt(i);
+        if (force || hasValueChangedSignificantly(axis.filter,
+                axis.newValue, axis.currentValue, axis.min, axis.max)) {
+            axis.currentValue = axis.newValue;
+            atLeastOneSignificantChange = true;
+        }
+        if (axis.axisInfo.mode == AxisInfo::MODE_SPLIT) {
+            if (force || hasValueChangedSignificantly(axis.filter,
+                    axis.highNewValue, axis.highCurrentValue, axis.min, axis.max)) {
+                axis.highCurrentValue = axis.highNewValue;
+                atLeastOneSignificantChange = true;
+            }
+        }
+    }
+    return atLeastOneSignificantChange;
+}
+
+bool JoystickInputMapper::hasValueChangedSignificantly(
+        float filter, float newValue, float currentValue, float min, float max) {
+    if (newValue != currentValue) {
+        // Filter out small changes in value unless the value is converging on the axis
+        // bounds or center point.  This is intended to reduce the amount of information
+        // sent to applications by particularly noisy joysticks (such as PS3).
+        if (fabs(newValue - currentValue) > filter
+                || hasMovedNearerToValueWithinFilteredRange(filter, newValue, currentValue, min)
+                || hasMovedNearerToValueWithinFilteredRange(filter, newValue, currentValue, max)
+                || hasMovedNearerToValueWithinFilteredRange(filter, newValue, currentValue, 0)) {
+            return true;
+        }
+    }
+    return false;
+}
+
+bool JoystickInputMapper::hasMovedNearerToValueWithinFilteredRange(
+        float filter, float newValue, float currentValue, float thresholdValue) {
+    float newDistance = fabs(newValue - thresholdValue);
+    if (newDistance < filter) {
+        float oldDistance = fabs(currentValue - thresholdValue);
+        if (newDistance < oldDistance) {
+            return true;
+        }
+    }
+    return false;
+}
+
+} // namespace android
diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h
new file mode 100644
index 0000000..30c84b1
--- /dev/null
+++ b/services/inputflinger/InputReader.h
@@ -0,0 +1,2006 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _UI_INPUT_READER_H
+#define _UI_INPUT_READER_H
+
+#include "EventHub.h"
+#include "PointerControllerInterface.h"
+#include "InputListener.h"
+
+#include <input/Input.h>
+#include <input/VelocityControl.h>
+#include <input/VelocityTracker.h>
+#include <ui/DisplayInfo.h>
+#include <utils/KeyedVector.h>
+#include <utils/threads.h>
+#include <utils/Timers.h>
+#include <utils/RefBase.h>
+#include <utils/String8.h>
+#include <utils/BitSet.h>
+
+#include <stddef.h>
+#include <unistd.h>
+
+// Maximum supported size of a vibration pattern.
+// Must be at least 2.
+#define MAX_VIBRATE_PATTERN_SIZE 100
+
+// Maximum allowable delay value in a vibration pattern before
+// which the delay will be truncated.
+#define MAX_VIBRATE_PATTERN_DELAY_NSECS (1000000 * 1000000000LL)
+
+namespace android {
+
+class InputDevice;
+class InputMapper;
+
+/*
+ * Describes how coordinates are mapped on a physical display.
+ * See com.android.server.display.DisplayViewport.
+ */
+struct DisplayViewport {
+    int32_t displayId; // -1 if invalid
+    int32_t orientation;
+    int32_t logicalLeft;
+    int32_t logicalTop;
+    int32_t logicalRight;
+    int32_t logicalBottom;
+    int32_t physicalLeft;
+    int32_t physicalTop;
+    int32_t physicalRight;
+    int32_t physicalBottom;
+    int32_t deviceWidth;
+    int32_t deviceHeight;
+
+    DisplayViewport() :
+            displayId(ADISPLAY_ID_NONE), orientation(DISPLAY_ORIENTATION_0),
+            logicalLeft(0), logicalTop(0), logicalRight(0), logicalBottom(0),
+            physicalLeft(0), physicalTop(0), physicalRight(0), physicalBottom(0),
+            deviceWidth(0), deviceHeight(0) {
+    }
+
+    bool operator==(const DisplayViewport& other) const {
+        return displayId == other.displayId
+                && orientation == other.orientation
+                && logicalLeft == other.logicalLeft
+                && logicalTop == other.logicalTop
+                && logicalRight == other.logicalRight
+                && logicalBottom == other.logicalBottom
+                && physicalLeft == other.physicalLeft
+                && physicalTop == other.physicalTop
+                && physicalRight == other.physicalRight
+                && physicalBottom == other.physicalBottom
+                && deviceWidth == other.deviceWidth
+                && deviceHeight == other.deviceHeight;
+    }
+
+    bool operator!=(const DisplayViewport& other) const {
+        return !(*this == other);
+    }
+
+    inline bool isValid() const {
+        return displayId >= 0;
+    }
+
+    void setNonDisplayViewport(int32_t width, int32_t height) {
+        displayId = ADISPLAY_ID_NONE;
+        orientation = DISPLAY_ORIENTATION_0;
+        logicalLeft = 0;
+        logicalTop = 0;
+        logicalRight = width;
+        logicalBottom = height;
+        physicalLeft = 0;
+        physicalTop = 0;
+        physicalRight = width;
+        physicalBottom = height;
+        deviceWidth = width;
+        deviceHeight = height;
+    }
+};
+
+/*
+ * Input reader configuration.
+ *
+ * Specifies various options that modify the behavior of the input reader.
+ */
+struct InputReaderConfiguration {
+    // Describes changes that have occurred.
+    enum {
+        // The pointer speed changed.
+        CHANGE_POINTER_SPEED = 1 << 0,
+
+        // The pointer gesture control changed.
+        CHANGE_POINTER_GESTURE_ENABLEMENT = 1 << 1,
+
+        // The display size or orientation changed.
+        CHANGE_DISPLAY_INFO = 1 << 2,
+
+        // The visible touches option changed.
+        CHANGE_SHOW_TOUCHES = 1 << 3,
+
+        // The keyboard layouts must be reloaded.
+        CHANGE_KEYBOARD_LAYOUTS = 1 << 4,
+
+        // The device name alias supplied by the may have changed for some devices.
+        CHANGE_DEVICE_ALIAS = 1 << 5,
+
+        // The location calibration matrix changed.
+        CHANGE_TOUCH_AFFINE_TRANSFORMATION = 1 << 6,
+
+        // The presence of an external stylus has changed.
+        CHANGE_EXTERNAL_STYLUS_PRESENCE = 1 << 7,
+
+        // All devices must be reopened.
+        CHANGE_MUST_REOPEN = 1 << 31,
+    };
+
+    // Gets the amount of time to disable virtual keys after the screen is touched
+    // in order to filter out accidental virtual key presses due to swiping gestures
+    // or taps near the edge of the display.  May be 0 to disable the feature.
+    nsecs_t virtualKeyQuietTime;
+
+    // The excluded device names for the platform.
+    // Devices with these names will be ignored.
+    Vector<String8> excludedDeviceNames;
+
+    // Velocity control parameters for mouse pointer movements.
+    VelocityControlParameters pointerVelocityControlParameters;
+
+    // Velocity control parameters for mouse wheel movements.
+    VelocityControlParameters wheelVelocityControlParameters;
+
+    // True if pointer gestures are enabled.
+    bool pointerGesturesEnabled;
+
+    // Quiet time between certain pointer gesture transitions.
+    // Time to allow for all fingers or buttons to settle into a stable state before
+    // starting a new gesture.
+    nsecs_t pointerGestureQuietInterval;
+
+    // The minimum speed that a pointer must travel for us to consider switching the active
+    // touch pointer to it during a drag.  This threshold is set to avoid switching due
+    // to noise from a finger resting on the touch pad (perhaps just pressing it down).
+    float pointerGestureDragMinSwitchSpeed; // in pixels per second
+
+    // Tap gesture delay time.
+    // The time between down and up must be less than this to be considered a tap.
+    nsecs_t pointerGestureTapInterval;
+
+    // Tap drag gesture delay time.
+    // The time between the previous tap's up and the next down must be less than
+    // this to be considered a drag.  Otherwise, the previous tap is finished and a
+    // new tap begins.
+    //
+    // Note that the previous tap will be held down for this entire duration so this
+    // interval must be shorter than the long press timeout.
+    nsecs_t pointerGestureTapDragInterval;
+
+    // The distance in pixels that the pointer is allowed to move from initial down
+    // to up and still be called a tap.
+    float pointerGestureTapSlop; // in pixels
+
+    // Time after the first touch points go down to settle on an initial centroid.
+    // This is intended to be enough time to handle cases where the user puts down two
+    // fingers at almost but not quite exactly the same time.
+    nsecs_t pointerGestureMultitouchSettleInterval;
+
+    // The transition from PRESS to SWIPE or FREEFORM gesture mode is made when
+    // at least two pointers have moved at least this far from their starting place.
+    float pointerGestureMultitouchMinDistance; // in pixels
+
+    // The transition from PRESS to SWIPE gesture mode can only occur when the
+    // cosine of the angle between the two vectors is greater than or equal to than this value
+    // which indicates that the vectors are oriented in the same direction.
+    // When the vectors are oriented in the exactly same direction, the cosine is 1.0.
+    // (In exactly opposite directions, the cosine is -1.0.)
+    float pointerGestureSwipeTransitionAngleCosine;
+
+    // The transition from PRESS to SWIPE gesture mode can only occur when the
+    // fingers are no more than this far apart relative to the diagonal size of
+    // the touch pad.  For example, a ratio of 0.5 means that the fingers must be
+    // no more than half the diagonal size of the touch pad apart.
+    float pointerGestureSwipeMaxWidthRatio;
+
+    // The gesture movement speed factor relative to the size of the display.
+    // Movement speed applies when the fingers are moving in the same direction.
+    // Without acceleration, a full swipe of the touch pad diagonal in movement mode
+    // will cover this portion of the display diagonal.
+    float pointerGestureMovementSpeedRatio;
+
+    // The gesture zoom speed factor relative to the size of the display.
+    // Zoom speed applies when the fingers are mostly moving relative to each other
+    // to execute a scale gesture or similar.
+    // Without acceleration, a full swipe of the touch pad diagonal in zoom mode
+    // will cover this portion of the display diagonal.
+    float pointerGestureZoomSpeedRatio;
+
+    // True to show the location of touches on the touch screen as spots.
+    bool showTouches;
+
+    InputReaderConfiguration() :
+            virtualKeyQuietTime(0),
+            pointerVelocityControlParameters(1.0f, 500.0f, 3000.0f, 3.0f),
+            wheelVelocityControlParameters(1.0f, 15.0f, 50.0f, 4.0f),
+            pointerGesturesEnabled(true),
+            pointerGestureQuietInterval(100 * 1000000LL), // 100 ms
+            pointerGestureDragMinSwitchSpeed(50), // 50 pixels per second
+            pointerGestureTapInterval(150 * 1000000LL), // 150 ms
+            pointerGestureTapDragInterval(150 * 1000000LL), // 150 ms
+            pointerGestureTapSlop(10.0f), // 10 pixels
+            pointerGestureMultitouchSettleInterval(100 * 1000000LL), // 100 ms
+            pointerGestureMultitouchMinDistance(15), // 15 pixels
+            pointerGestureSwipeTransitionAngleCosine(0.2588f), // cosine of 75 degrees
+            pointerGestureSwipeMaxWidthRatio(0.25f),
+            pointerGestureMovementSpeedRatio(0.8f),
+            pointerGestureZoomSpeedRatio(0.3f),
+            showTouches(false) { }
+
+    bool getDisplayInfo(bool external, DisplayViewport* outViewport) const;
+    void setDisplayInfo(bool external, const DisplayViewport& viewport);
+
+private:
+    DisplayViewport mInternalDisplay;
+    DisplayViewport mExternalDisplay;
+};
+
+
+struct TouchAffineTransformation {
+    float x_scale;
+    float x_ymix;
+    float x_offset;
+    float y_xmix;
+    float y_scale;
+    float y_offset;
+
+    TouchAffineTransformation() :
+        x_scale(1.0f), x_ymix(0.0f), x_offset(0.0f),
+        y_xmix(0.0f), y_scale(1.0f), y_offset(0.0f) {
+    }
+
+    TouchAffineTransformation(float xscale, float xymix, float xoffset,
+            float yxmix, float yscale, float yoffset) :
+        x_scale(xscale), x_ymix(xymix), x_offset(xoffset),
+        y_xmix(yxmix), y_scale(yscale), y_offset(yoffset) {
+    }
+
+    void applyTo(float& x, float& y) const;
+};
+
+
+/*
+ * Input reader policy interface.
+ *
+ * The input reader policy is used by the input reader to interact with the Window Manager
+ * and other system components.
+ *
+ * The actual implementation is partially supported by callbacks into the DVM
+ * via JNI.  This interface is also mocked in the unit tests.
+ *
+ * These methods must NOT re-enter the input reader since they may be called while
+ * holding the input reader lock.
+ */
+class InputReaderPolicyInterface : public virtual RefBase {
+protected:
+    InputReaderPolicyInterface() { }
+    virtual ~InputReaderPolicyInterface() { }
+
+public:
+    /* Gets the input reader configuration. */
+    virtual void getReaderConfiguration(InputReaderConfiguration* outConfig) = 0;
+
+    /* Gets a pointer controller associated with the specified cursor device (ie. a mouse). */
+    virtual sp<PointerControllerInterface> obtainPointerController(int32_t deviceId) = 0;
+
+    /* Notifies the input reader policy that some input devices have changed
+     * and provides information about all current input devices.
+     */
+    virtual void notifyInputDevicesChanged(const Vector<InputDeviceInfo>& inputDevices) = 0;
+
+    /* Gets the keyboard layout for a particular input device. */
+    virtual sp<KeyCharacterMap> getKeyboardLayoutOverlay(
+            const InputDeviceIdentifier& identifier) = 0;
+
+    /* Gets a user-supplied alias for a particular input device, or an empty string if none. */
+    virtual String8 getDeviceAlias(const InputDeviceIdentifier& identifier) = 0;
+
+    /* Gets the affine calibration associated with the specified device. */
+    virtual TouchAffineTransformation getTouchAffineTransformation(
+            const String8& inputDeviceDescriptor, int32_t surfaceRotation) = 0;
+};
+
+
+/* Processes raw input events and sends cooked event data to an input listener. */
+class InputReaderInterface : public virtual RefBase {
+protected:
+    InputReaderInterface() { }
+    virtual ~InputReaderInterface() { }
+
+public:
+    /* Dumps the state of the input reader.
+     *
+     * This method may be called on any thread (usually by the input manager). */
+    virtual void dump(String8& dump) = 0;
+
+    /* Called by the heatbeat to ensures that the reader has not deadlocked. */
+    virtual void monitor() = 0;
+
+    /* Runs a single iteration of the processing loop.
+     * Nominally reads and processes one incoming message from the EventHub.
+     *
+     * This method should be called on the input reader thread.
+     */
+    virtual void loopOnce() = 0;
+
+    /* Gets information about all input devices.
+     *
+     * This method may be called on any thread (usually by the input manager).
+     */
+    virtual void getInputDevices(Vector<InputDeviceInfo>& outInputDevices) = 0;
+
+    /* Query current input state. */
+    virtual int32_t getScanCodeState(int32_t deviceId, uint32_t sourceMask,
+            int32_t scanCode) = 0;
+    virtual int32_t getKeyCodeState(int32_t deviceId, uint32_t sourceMask,
+            int32_t keyCode) = 0;
+    virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask,
+            int32_t sw) = 0;
+
+    /* Determine whether physical keys exist for the given framework-domain key codes. */
+    virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask,
+            size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) = 0;
+
+    /* Requests that a reconfiguration of all input devices.
+     * The changes flag is a bitfield that indicates what has changed and whether
+     * the input devices must all be reopened. */
+    virtual void requestRefreshConfiguration(uint32_t changes) = 0;
+
+    /* Controls the vibrator of a particular input device. */
+    virtual void vibrate(int32_t deviceId, const nsecs_t* pattern, size_t patternSize,
+            ssize_t repeat, int32_t token) = 0;
+    virtual void cancelVibrate(int32_t deviceId, int32_t token) = 0;
+};
+
+struct StylusState {
+    /* Time the stylus event was received. */
+    nsecs_t when;
+    /* Pressure as reported by the stylus, normalized to the range [0, 1.0]. */
+    float pressure;
+    /* The state of the stylus buttons as a bitfield (e.g. AMOTION_EVENT_BUTTON_SECONDARY). */
+    uint32_t buttons;
+    /* Which tool type the stylus is currently using (e.g. AMOTION_EVENT_TOOL_TYPE_ERASER). */
+    int32_t toolType;
+
+    void copyFrom(const StylusState& other) {
+        when = other.when;
+        pressure = other.pressure;
+        buttons = other.buttons;
+        toolType = other.toolType;
+    }
+
+    void clear() {
+        when = LLONG_MAX;
+        pressure = 0.f;
+        buttons = 0;
+        toolType = AMOTION_EVENT_TOOL_TYPE_UNKNOWN;
+    }
+};
+
+
+/* Internal interface used by individual input devices to access global input device state
+ * and parameters maintained by the input reader.
+ */
+class InputReaderContext {
+public:
+    InputReaderContext() { }
+    virtual ~InputReaderContext() { }
+
+    virtual void updateGlobalMetaState() = 0;
+    virtual int32_t getGlobalMetaState() = 0;
+
+    virtual void disableVirtualKeysUntil(nsecs_t time) = 0;
+    virtual bool shouldDropVirtualKey(nsecs_t now,
+            InputDevice* device, int32_t keyCode, int32_t scanCode) = 0;
+
+    virtual void fadePointer() = 0;
+
+    virtual void requestTimeoutAtTime(nsecs_t when) = 0;
+    virtual int32_t bumpGeneration() = 0;
+
+    virtual void getExternalStylusDevices(Vector<InputDeviceInfo>& outDevices) = 0;
+    virtual void dispatchExternalStylusState(const StylusState& outState) = 0;
+
+    virtual InputReaderPolicyInterface* getPolicy() = 0;
+    virtual InputListenerInterface* getListener() = 0;
+    virtual EventHubInterface* getEventHub() = 0;
+};
+
+
+/* The input reader reads raw event data from the event hub and processes it into input events
+ * that it sends to the input listener.  Some functions of the input reader, such as early
+ * event filtering in low power states, are controlled by a separate policy object.
+ *
+ * The InputReader owns a collection of InputMappers.  Most of the work it does happens
+ * on the input reader thread but the InputReader can receive queries from other system
+ * components running on arbitrary threads.  To keep things manageable, the InputReader
+ * uses a single Mutex to guard its state.  The Mutex may be held while calling into the
+ * EventHub or the InputReaderPolicy but it is never held while calling into the
+ * InputListener.
+ */
+class InputReader : public InputReaderInterface {
+public:
+    InputReader(const sp<EventHubInterface>& eventHub,
+            const sp<InputReaderPolicyInterface>& policy,
+            const sp<InputListenerInterface>& listener);
+    virtual ~InputReader();
+
+    virtual void dump(String8& dump);
+    virtual void monitor();
+
+    virtual void loopOnce();
+
+    virtual void getInputDevices(Vector<InputDeviceInfo>& outInputDevices);
+
+    virtual int32_t getScanCodeState(int32_t deviceId, uint32_t sourceMask,
+            int32_t scanCode);
+    virtual int32_t getKeyCodeState(int32_t deviceId, uint32_t sourceMask,
+            int32_t keyCode);
+    virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask,
+            int32_t sw);
+
+    virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask,
+            size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags);
+
+    virtual void requestRefreshConfiguration(uint32_t changes);
+
+    virtual void vibrate(int32_t deviceId, const nsecs_t* pattern, size_t patternSize,
+            ssize_t repeat, int32_t token);
+    virtual void cancelVibrate(int32_t deviceId, int32_t token);
+
+protected:
+    // These members are protected so they can be instrumented by test cases.
+    virtual InputDevice* createDeviceLocked(int32_t deviceId, int32_t controllerNumber,
+            const InputDeviceIdentifier& identifier, uint32_t classes);
+
+    class ContextImpl : public InputReaderContext {
+        InputReader* mReader;
+
+    public:
+        ContextImpl(InputReader* reader);
+
+        virtual void updateGlobalMetaState();
+        virtual int32_t getGlobalMetaState();
+        virtual void disableVirtualKeysUntil(nsecs_t time);
+        virtual bool shouldDropVirtualKey(nsecs_t now,
+                InputDevice* device, int32_t keyCode, int32_t scanCode);
+        virtual void fadePointer();
+        virtual void requestTimeoutAtTime(nsecs_t when);
+        virtual int32_t bumpGeneration();
+        virtual void getExternalStylusDevices(Vector<InputDeviceInfo>& outDevices);
+        virtual void dispatchExternalStylusState(const StylusState& outState);
+        virtual InputReaderPolicyInterface* getPolicy();
+        virtual InputListenerInterface* getListener();
+        virtual EventHubInterface* getEventHub();
+    } mContext;
+
+    friend class ContextImpl;
+
+private:
+    Mutex mLock;
+
+    Condition mReaderIsAliveCondition;
+
+    sp<EventHubInterface> mEventHub;
+    sp<InputReaderPolicyInterface> mPolicy;
+    sp<QueuedInputListener> mQueuedListener;
+
+    InputReaderConfiguration mConfig;
+
+    // The event queue.
+    static const int EVENT_BUFFER_SIZE = 256;
+    RawEvent mEventBuffer[EVENT_BUFFER_SIZE];
+
+    KeyedVector<int32_t, InputDevice*> mDevices;
+
+    // low-level input event decoding and device management
+    void processEventsLocked(const RawEvent* rawEvents, size_t count);
+
+    void addDeviceLocked(nsecs_t when, int32_t deviceId);
+    void removeDeviceLocked(nsecs_t when, int32_t deviceId);
+    void processEventsForDeviceLocked(int32_t deviceId, const RawEvent* rawEvents, size_t count);
+    void timeoutExpiredLocked(nsecs_t when);
+
+    void handleConfigurationChangedLocked(nsecs_t when);
+
+    int32_t mGlobalMetaState;
+    void updateGlobalMetaStateLocked();
+    int32_t getGlobalMetaStateLocked();
+
+    void notifyExternalStylusPresenceChanged();
+    void getExternalStylusDevicesLocked(Vector<InputDeviceInfo>& outDevices);
+    void dispatchExternalStylusState(const StylusState& state);
+
+    void fadePointerLocked();
+
+    int32_t mGeneration;
+    int32_t bumpGenerationLocked();
+
+    void getInputDevicesLocked(Vector<InputDeviceInfo>& outInputDevices);
+
+    nsecs_t mDisableVirtualKeysTimeout;
+    void disableVirtualKeysUntilLocked(nsecs_t time);
+    bool shouldDropVirtualKeyLocked(nsecs_t now,
+            InputDevice* device, int32_t keyCode, int32_t scanCode);
+
+    nsecs_t mNextTimeout;
+    void requestTimeoutAtTimeLocked(nsecs_t when);
+
+    uint32_t mConfigurationChangesToRefresh;
+    void refreshConfigurationLocked(uint32_t changes);
+
+    // state queries
+    typedef int32_t (InputDevice::*GetStateFunc)(uint32_t sourceMask, int32_t code);
+    int32_t getStateLocked(int32_t deviceId, uint32_t sourceMask, int32_t code,
+            GetStateFunc getStateFunc);
+    bool markSupportedKeyCodesLocked(int32_t deviceId, uint32_t sourceMask, size_t numCodes,
+            const int32_t* keyCodes, uint8_t* outFlags);
+};
+
+
+/* Reads raw events from the event hub and processes them, endlessly. */
+class InputReaderThread : public Thread {
+public:
+    InputReaderThread(const sp<InputReaderInterface>& reader);
+    virtual ~InputReaderThread();
+
+private:
+    sp<InputReaderInterface> mReader;
+
+    virtual bool threadLoop();
+};
+
+
+/* Represents the state of a single input device. */
+class InputDevice {
+public:
+    InputDevice(InputReaderContext* context, int32_t id, int32_t generation, int32_t
+            controllerNumber, const InputDeviceIdentifier& identifier, uint32_t classes);
+    ~InputDevice();
+
+    inline InputReaderContext* getContext() { return mContext; }
+    inline int32_t getId() const { return mId; }
+    inline int32_t getControllerNumber() const { return mControllerNumber; }
+    inline int32_t getGeneration() const { return mGeneration; }
+    inline const String8& getName() const { return mIdentifier.name; }
+    inline const String8& getDescriptor() { return mIdentifier.descriptor; }
+    inline uint32_t getClasses() const { return mClasses; }
+    inline uint32_t getSources() const { return mSources; }
+
+    inline bool isExternal() { return mIsExternal; }
+    inline void setExternal(bool external) { mIsExternal = external; }
+
+    inline void setMic(bool hasMic) { mHasMic = hasMic; }
+    inline bool hasMic() const { return mHasMic; }
+
+    inline bool isIgnored() { return mMappers.isEmpty(); }
+
+    void dump(String8& dump);
+    void addMapper(InputMapper* mapper);
+    void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
+    void reset(nsecs_t when);
+    void process(const RawEvent* rawEvents, size_t count);
+    void timeoutExpired(nsecs_t when);
+    void updateExternalStylusState(const StylusState& state);
+
+    void getDeviceInfo(InputDeviceInfo* outDeviceInfo);
+    int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode);
+    int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode);
+    int32_t getSwitchState(uint32_t sourceMask, int32_t switchCode);
+    bool markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes,
+            const int32_t* keyCodes, uint8_t* outFlags);
+    void vibrate(const nsecs_t* pattern, size_t patternSize, ssize_t repeat, int32_t token);
+    void cancelVibrate(int32_t token);
+    void cancelTouch(nsecs_t when);
+
+    int32_t getMetaState();
+
+    void fadePointer();
+
+    void bumpGeneration();
+
+    void notifyReset(nsecs_t when);
+
+    inline const PropertyMap& getConfiguration() { return mConfiguration; }
+    inline EventHubInterface* getEventHub() { return mContext->getEventHub(); }
+
+    bool hasKey(int32_t code) {
+        return getEventHub()->hasScanCode(mId, code);
+    }
+
+    bool hasAbsoluteAxis(int32_t code) {
+        RawAbsoluteAxisInfo info;
+        getEventHub()->getAbsoluteAxisInfo(mId, code, &info);
+        return info.valid;
+    }
+
+    bool isKeyPressed(int32_t code) {
+        return getEventHub()->getScanCodeState(mId, code) == AKEY_STATE_DOWN;
+    }
+
+    int32_t getAbsoluteAxisValue(int32_t code) {
+        int32_t value;
+        getEventHub()->getAbsoluteAxisValue(mId, code, &value);
+        return value;
+    }
+
+private:
+    InputReaderContext* mContext;
+    int32_t mId;
+    int32_t mGeneration;
+    int32_t mControllerNumber;
+    InputDeviceIdentifier mIdentifier;
+    String8 mAlias;
+    uint32_t mClasses;
+
+    Vector<InputMapper*> mMappers;
+
+    uint32_t mSources;
+    bool mIsExternal;
+    bool mHasMic;
+    bool mDropUntilNextSync;
+
+    typedef int32_t (InputMapper::*GetStateFunc)(uint32_t sourceMask, int32_t code);
+    int32_t getState(uint32_t sourceMask, int32_t code, GetStateFunc getStateFunc);
+
+    PropertyMap mConfiguration;
+};
+
+
+/* Keeps track of the state of mouse or touch pad buttons. */
+class CursorButtonAccumulator {
+public:
+    CursorButtonAccumulator();
+    void reset(InputDevice* device);
+
+    void process(const RawEvent* rawEvent);
+
+    uint32_t getButtonState() const;
+
+private:
+    bool mBtnLeft;
+    bool mBtnRight;
+    bool mBtnMiddle;
+    bool mBtnBack;
+    bool mBtnSide;
+    bool mBtnForward;
+    bool mBtnExtra;
+    bool mBtnTask;
+
+    void clearButtons();
+};
+
+
+/* Keeps track of cursor movements. */
+
+class CursorMotionAccumulator {
+public:
+    CursorMotionAccumulator();
+    void reset(InputDevice* device);
+
+    void process(const RawEvent* rawEvent);
+    void finishSync();
+
+    inline int32_t getRelativeX() const { return mRelX; }
+    inline int32_t getRelativeY() const { return mRelY; }
+
+private:
+    int32_t mRelX;
+    int32_t mRelY;
+
+    void clearRelativeAxes();
+};
+
+
+/* Keeps track of cursor scrolling motions. */
+
+class CursorScrollAccumulator {
+public:
+    CursorScrollAccumulator();
+    void configure(InputDevice* device);
+    void reset(InputDevice* device);
+
+    void process(const RawEvent* rawEvent);
+    void finishSync();
+
+    inline bool haveRelativeVWheel() const { return mHaveRelWheel; }
+    inline bool haveRelativeHWheel() const { return mHaveRelHWheel; }
+
+    inline int32_t getRelativeX() const { return mRelX; }
+    inline int32_t getRelativeY() const { return mRelY; }
+    inline int32_t getRelativeVWheel() const { return mRelWheel; }
+    inline int32_t getRelativeHWheel() const { return mRelHWheel; }
+
+private:
+    bool mHaveRelWheel;
+    bool mHaveRelHWheel;
+
+    int32_t mRelX;
+    int32_t mRelY;
+    int32_t mRelWheel;
+    int32_t mRelHWheel;
+
+    void clearRelativeAxes();
+};
+
+
+/* Keeps track of the state of touch, stylus and tool buttons. */
+class TouchButtonAccumulator {
+public:
+    TouchButtonAccumulator();
+    void configure(InputDevice* device);
+    void reset(InputDevice* device);
+
+    void process(const RawEvent* rawEvent);
+
+    uint32_t getButtonState() const;
+    int32_t getToolType() const;
+    bool isToolActive() const;
+    bool isHovering() const;
+    bool hasStylus() const;
+
+private:
+    bool mHaveBtnTouch;
+    bool mHaveStylus;
+
+    bool mBtnTouch;
+    bool mBtnStylus;
+    bool mBtnStylus2;
+    bool mBtnToolFinger;
+    bool mBtnToolPen;
+    bool mBtnToolRubber;
+    bool mBtnToolBrush;
+    bool mBtnToolPencil;
+    bool mBtnToolAirbrush;
+    bool mBtnToolMouse;
+    bool mBtnToolLens;
+    bool mBtnToolDoubleTap;
+    bool mBtnToolTripleTap;
+    bool mBtnToolQuadTap;
+
+    void clearButtons();
+};
+
+
+/* Raw axis information from the driver. */
+struct RawPointerAxes {
+    RawAbsoluteAxisInfo x;
+    RawAbsoluteAxisInfo y;
+    RawAbsoluteAxisInfo pressure;
+    RawAbsoluteAxisInfo touchMajor;
+    RawAbsoluteAxisInfo touchMinor;
+    RawAbsoluteAxisInfo toolMajor;
+    RawAbsoluteAxisInfo toolMinor;
+    RawAbsoluteAxisInfo orientation;
+    RawAbsoluteAxisInfo distance;
+    RawAbsoluteAxisInfo tiltX;
+    RawAbsoluteAxisInfo tiltY;
+    RawAbsoluteAxisInfo trackingId;
+    RawAbsoluteAxisInfo slot;
+
+    RawPointerAxes();
+    void clear();
+};
+
+
+/* Raw data for a collection of pointers including a pointer id mapping table. */
+struct RawPointerData {
+    struct Pointer {
+        uint32_t id;
+        int32_t x;
+        int32_t y;
+        int32_t pressure;
+        int32_t touchMajor;
+        int32_t touchMinor;
+        int32_t toolMajor;
+        int32_t toolMinor;
+        int32_t orientation;
+        int32_t distance;
+        int32_t tiltX;
+        int32_t tiltY;
+        int32_t toolType; // a fully decoded AMOTION_EVENT_TOOL_TYPE constant
+        bool isHovering;
+    };
+
+    uint32_t pointerCount;
+    Pointer pointers[MAX_POINTERS];
+    BitSet32 hoveringIdBits, touchingIdBits;
+    uint32_t idToIndex[MAX_POINTER_ID + 1];
+
+    RawPointerData();
+    void clear();
+    void copyFrom(const RawPointerData& other);
+    void getCentroidOfTouchingPointers(float* outX, float* outY) const;
+
+    inline void markIdBit(uint32_t id, bool isHovering) {
+        if (isHovering) {
+            hoveringIdBits.markBit(id);
+        } else {
+            touchingIdBits.markBit(id);
+        }
+    }
+
+    inline void clearIdBits() {
+        hoveringIdBits.clear();
+        touchingIdBits.clear();
+    }
+
+    inline const Pointer& pointerForId(uint32_t id) const {
+        return pointers[idToIndex[id]];
+    }
+
+    inline bool isHovering(uint32_t pointerIndex) {
+        return pointers[pointerIndex].isHovering;
+    }
+};
+
+
+/* Cooked data for a collection of pointers including a pointer id mapping table. */
+struct CookedPointerData {
+    uint32_t pointerCount;
+    PointerProperties pointerProperties[MAX_POINTERS];
+    PointerCoords pointerCoords[MAX_POINTERS];
+    BitSet32 hoveringIdBits, touchingIdBits;
+    uint32_t idToIndex[MAX_POINTER_ID + 1];
+
+    CookedPointerData();
+    void clear();
+    void copyFrom(const CookedPointerData& other);
+
+    inline const PointerCoords& pointerCoordsForId(uint32_t id) const {
+        return pointerCoords[idToIndex[id]];
+    }
+
+    inline PointerCoords& editPointerCoordsWithId(uint32_t id) {
+        return pointerCoords[idToIndex[id]];
+    }
+
+    inline PointerProperties& editPointerPropertiesWithId(uint32_t id) {
+        return pointerProperties[idToIndex[id]];
+    }
+
+    inline bool isHovering(uint32_t pointerIndex) const {
+        return hoveringIdBits.hasBit(pointerProperties[pointerIndex].id);
+    }
+
+    inline bool isTouching(uint32_t pointerIndex) const {
+        return touchingIdBits.hasBit(pointerProperties[pointerIndex].id);
+    }
+};
+
+
+/* Keeps track of the state of single-touch protocol. */
+class SingleTouchMotionAccumulator {
+public:
+    SingleTouchMotionAccumulator();
+
+    void process(const RawEvent* rawEvent);
+    void reset(InputDevice* device);
+
+    inline int32_t getAbsoluteX() const { return mAbsX; }
+    inline int32_t getAbsoluteY() const { return mAbsY; }
+    inline int32_t getAbsolutePressure() const { return mAbsPressure; }
+    inline int32_t getAbsoluteToolWidth() const { return mAbsToolWidth; }
+    inline int32_t getAbsoluteDistance() const { return mAbsDistance; }
+    inline int32_t getAbsoluteTiltX() const { return mAbsTiltX; }
+    inline int32_t getAbsoluteTiltY() const { return mAbsTiltY; }
+
+private:
+    int32_t mAbsX;
+    int32_t mAbsY;
+    int32_t mAbsPressure;
+    int32_t mAbsToolWidth;
+    int32_t mAbsDistance;
+    int32_t mAbsTiltX;
+    int32_t mAbsTiltY;
+
+    void clearAbsoluteAxes();
+};
+
+
+/* Keeps track of the state of multi-touch protocol. */
+class MultiTouchMotionAccumulator {
+public:
+    class Slot {
+    public:
+        inline bool isInUse() const { return mInUse; }
+        inline int32_t getX() const { return mAbsMTPositionX; }
+        inline int32_t getY() const { return mAbsMTPositionY; }
+        inline int32_t getTouchMajor() const { return mAbsMTTouchMajor; }
+        inline int32_t getTouchMinor() const {
+            return mHaveAbsMTTouchMinor ? mAbsMTTouchMinor : mAbsMTTouchMajor; }
+        inline int32_t getToolMajor() const { return mAbsMTWidthMajor; }
+        inline int32_t getToolMinor() const {
+            return mHaveAbsMTWidthMinor ? mAbsMTWidthMinor : mAbsMTWidthMajor; }
+        inline int32_t getOrientation() const { return mAbsMTOrientation; }
+        inline int32_t getTrackingId() const { return mAbsMTTrackingId; }
+        inline int32_t getPressure() const { return mAbsMTPressure; }
+        inline int32_t getDistance() const { return mAbsMTDistance; }
+        inline int32_t getToolType() const;
+
+    private:
+        friend class MultiTouchMotionAccumulator;
+
+        bool mInUse;
+        bool mHaveAbsMTTouchMinor;
+        bool mHaveAbsMTWidthMinor;
+        bool mHaveAbsMTToolType;
+
+        int32_t mAbsMTPositionX;
+        int32_t mAbsMTPositionY;
+        int32_t mAbsMTTouchMajor;
+        int32_t mAbsMTTouchMinor;
+        int32_t mAbsMTWidthMajor;
+        int32_t mAbsMTWidthMinor;
+        int32_t mAbsMTOrientation;
+        int32_t mAbsMTTrackingId;
+        int32_t mAbsMTPressure;
+        int32_t mAbsMTDistance;
+        int32_t mAbsMTToolType;
+
+        Slot();
+        void clear();
+    };
+
+    MultiTouchMotionAccumulator();
+    ~MultiTouchMotionAccumulator();
+
+    void configure(InputDevice* device, size_t slotCount, bool usingSlotsProtocol);
+    void reset(InputDevice* device);
+    void process(const RawEvent* rawEvent);
+    void finishSync();
+    bool hasStylus() const;
+
+    inline size_t getSlotCount() const { return mSlotCount; }
+    inline const Slot* getSlot(size_t index) const { return &mSlots[index]; }
+
+private:
+    int32_t mCurrentSlot;
+    Slot* mSlots;
+    size_t mSlotCount;
+    bool mUsingSlotsProtocol;
+    bool mHaveStylus;
+
+    void clearSlots(int32_t initialSlot);
+};
+
+
+/* An input mapper transforms raw input events into cooked event data.
+ * A single input device can have multiple associated input mappers in order to interpret
+ * different classes of events.
+ *
+ * InputMapper lifecycle:
+ * - create
+ * - configure with 0 changes
+ * - reset
+ * - process, process, process (may occasionally reconfigure with non-zero changes or reset)
+ * - reset
+ * - destroy
+ */
+class InputMapper {
+public:
+    InputMapper(InputDevice* device);
+    virtual ~InputMapper();
+
+    inline InputDevice* getDevice() { return mDevice; }
+    inline int32_t getDeviceId() { return mDevice->getId(); }
+    inline const String8 getDeviceName() { return mDevice->getName(); }
+    inline InputReaderContext* getContext() { return mContext; }
+    inline InputReaderPolicyInterface* getPolicy() { return mContext->getPolicy(); }
+    inline InputListenerInterface* getListener() { return mContext->getListener(); }
+    inline EventHubInterface* getEventHub() { return mContext->getEventHub(); }
+
+    virtual uint32_t getSources() = 0;
+    virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
+    virtual void dump(String8& dump);
+    virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
+    virtual void reset(nsecs_t when);
+    virtual void process(const RawEvent* rawEvent) = 0;
+    virtual void timeoutExpired(nsecs_t when);
+
+    virtual int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode);
+    virtual int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode);
+    virtual int32_t getSwitchState(uint32_t sourceMask, int32_t switchCode);
+    virtual bool markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes,
+            const int32_t* keyCodes, uint8_t* outFlags);
+    virtual void vibrate(const nsecs_t* pattern, size_t patternSize, ssize_t repeat,
+            int32_t token);
+    virtual void cancelVibrate(int32_t token);
+    virtual void cancelTouch(nsecs_t when);
+
+    virtual int32_t getMetaState();
+
+    virtual void updateExternalStylusState(const StylusState& state);
+
+    virtual void fadePointer();
+
+protected:
+    InputDevice* mDevice;
+    InputReaderContext* mContext;
+
+    status_t getAbsoluteAxisInfo(int32_t axis, RawAbsoluteAxisInfo* axisInfo);
+    void bumpGeneration();
+
+    static void dumpRawAbsoluteAxisInfo(String8& dump,
+            const RawAbsoluteAxisInfo& axis, const char* name);
+    static void dumpStylusState(String8& dump, const StylusState& state);
+};
+
+
+class SwitchInputMapper : public InputMapper {
+public:
+    SwitchInputMapper(InputDevice* device);
+    virtual ~SwitchInputMapper();
+
+    virtual uint32_t getSources();
+    virtual void process(const RawEvent* rawEvent);
+
+    virtual int32_t getSwitchState(uint32_t sourceMask, int32_t switchCode);
+    virtual void dump(String8& dump);
+
+private:
+    uint32_t mSwitchValues;
+    uint32_t mUpdatedSwitchMask;
+
+    void processSwitch(int32_t switchCode, int32_t switchValue);
+    void sync(nsecs_t when);
+};
+
+
+class VibratorInputMapper : public InputMapper {
+public:
+    VibratorInputMapper(InputDevice* device);
+    virtual ~VibratorInputMapper();
+
+    virtual uint32_t getSources();
+    virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
+    virtual void process(const RawEvent* rawEvent);
+
+    virtual void vibrate(const nsecs_t* pattern, size_t patternSize, ssize_t repeat,
+            int32_t token);
+    virtual void cancelVibrate(int32_t token);
+    virtual void timeoutExpired(nsecs_t when);
+    virtual void dump(String8& dump);
+
+private:
+    bool mVibrating;
+    nsecs_t mPattern[MAX_VIBRATE_PATTERN_SIZE];
+    size_t mPatternSize;
+    ssize_t mRepeat;
+    int32_t mToken;
+    ssize_t mIndex;
+    nsecs_t mNextStepTime;
+
+    void nextStep();
+    void stopVibrating();
+};
+
+
+class KeyboardInputMapper : public InputMapper {
+public:
+    KeyboardInputMapper(InputDevice* device, uint32_t source, int32_t keyboardType);
+    virtual ~KeyboardInputMapper();
+
+    virtual uint32_t getSources();
+    virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
+    virtual void dump(String8& dump);
+    virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
+    virtual void reset(nsecs_t when);
+    virtual void process(const RawEvent* rawEvent);
+
+    virtual int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode);
+    virtual int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode);
+    virtual bool markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes,
+            const int32_t* keyCodes, uint8_t* outFlags);
+
+    virtual int32_t getMetaState();
+
+private:
+    struct KeyDown {
+        int32_t keyCode;
+        int32_t scanCode;
+    };
+
+    uint32_t mSource;
+    int32_t mKeyboardType;
+
+    int32_t mOrientation; // orientation for dpad keys
+
+    Vector<KeyDown> mKeyDowns; // keys that are down
+    int32_t mMetaState;
+    nsecs_t mDownTime; // time of most recent key down
+
+    int32_t mCurrentHidUsage; // most recent HID usage seen this packet, or 0 if none
+
+    struct LedState {
+        bool avail; // led is available
+        bool on;    // we think the led is currently on
+    };
+    LedState mCapsLockLedState;
+    LedState mNumLockLedState;
+    LedState mScrollLockLedState;
+
+    // Immutable configuration parameters.
+    struct Parameters {
+        bool hasAssociatedDisplay;
+        bool orientationAware;
+        bool handlesKeyRepeat;
+    } mParameters;
+
+    void configureParameters();
+    void dumpParameters(String8& dump);
+
+    bool isKeyboardOrGamepadKey(int32_t scanCode);
+
+    void processKey(nsecs_t when, bool down, int32_t scanCode, int32_t usageCode);
+
+    ssize_t findKeyDown(int32_t scanCode);
+
+    void resetLedState();
+    void initializeLedState(LedState& ledState, int32_t led);
+    void updateLedState(bool reset);
+    void updateLedStateForModifier(LedState& ledState, int32_t led,
+            int32_t modifier, bool reset);
+};
+
+
+class CursorInputMapper : public InputMapper {
+public:
+    CursorInputMapper(InputDevice* device);
+    virtual ~CursorInputMapper();
+
+    virtual uint32_t getSources();
+    virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
+    virtual void dump(String8& dump);
+    virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
+    virtual void reset(nsecs_t when);
+    virtual void process(const RawEvent* rawEvent);
+
+    virtual int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode);
+
+    virtual void fadePointer();
+
+private:
+    // Amount that trackball needs to move in order to generate a key event.
+    static const int32_t TRACKBALL_MOVEMENT_THRESHOLD = 6;
+
+    // Immutable configuration parameters.
+    struct Parameters {
+        enum Mode {
+            MODE_POINTER,
+            MODE_NAVIGATION,
+        };
+
+        Mode mode;
+        bool hasAssociatedDisplay;
+        bool orientationAware;
+    } mParameters;
+
+    CursorButtonAccumulator mCursorButtonAccumulator;
+    CursorMotionAccumulator mCursorMotionAccumulator;
+    CursorScrollAccumulator mCursorScrollAccumulator;
+
+    int32_t mSource;
+    float mXScale;
+    float mYScale;
+    float mXPrecision;
+    float mYPrecision;
+
+    float mVWheelScale;
+    float mHWheelScale;
+
+    // Velocity controls for mouse pointer and wheel movements.
+    // The controls for X and Y wheel movements are separate to keep them decoupled.
+    VelocityControl mPointerVelocityControl;
+    VelocityControl mWheelXVelocityControl;
+    VelocityControl mWheelYVelocityControl;
+
+    int32_t mOrientation;
+
+    sp<PointerControllerInterface> mPointerController;
+
+    int32_t mButtonState;
+    nsecs_t mDownTime;
+
+    void configureParameters();
+    void dumpParameters(String8& dump);
+
+    void sync(nsecs_t when);
+};
+
+
+class TouchInputMapper : public InputMapper {
+public:
+    TouchInputMapper(InputDevice* device);
+    virtual ~TouchInputMapper();
+
+    virtual uint32_t getSources();
+    virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
+    virtual void dump(String8& dump);
+    virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
+    virtual void reset(nsecs_t when);
+    virtual void process(const RawEvent* rawEvent);
+
+    virtual int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode);
+    virtual int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode);
+    virtual bool markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes,
+            const int32_t* keyCodes, uint8_t* outFlags);
+
+    virtual void fadePointer();
+    virtual void cancelTouch(nsecs_t when);
+    virtual void timeoutExpired(nsecs_t when);
+    virtual void updateExternalStylusState(const StylusState& state);
+
+protected:
+    CursorButtonAccumulator mCursorButtonAccumulator;
+    CursorScrollAccumulator mCursorScrollAccumulator;
+    TouchButtonAccumulator mTouchButtonAccumulator;
+
+    struct VirtualKey {
+        int32_t keyCode;
+        int32_t scanCode;
+        uint32_t flags;
+
+        // computed hit box, specified in touch screen coords based on known display size
+        int32_t hitLeft;
+        int32_t hitTop;
+        int32_t hitRight;
+        int32_t hitBottom;
+
+        inline bool isHit(int32_t x, int32_t y) const {
+            return x >= hitLeft && x <= hitRight && y >= hitTop && y <= hitBottom;
+        }
+    };
+
+    // Input sources and device mode.
+    uint32_t mSource;
+
+    enum DeviceMode {
+        DEVICE_MODE_DISABLED, // input is disabled
+        DEVICE_MODE_DIRECT, // direct mapping (touchscreen)
+        DEVICE_MODE_UNSCALED, // unscaled mapping (touchpad)
+        DEVICE_MODE_NAVIGATION, // unscaled mapping with assist gesture (touch navigation)
+        DEVICE_MODE_POINTER, // pointer mapping (pointer)
+    };
+    DeviceMode mDeviceMode;
+
+    // The reader's configuration.
+    InputReaderConfiguration mConfig;
+
+    // Immutable configuration parameters.
+    struct Parameters {
+        enum DeviceType {
+            DEVICE_TYPE_TOUCH_SCREEN,
+            DEVICE_TYPE_TOUCH_PAD,
+            DEVICE_TYPE_TOUCH_NAVIGATION,
+            DEVICE_TYPE_POINTER,
+        };
+
+        DeviceType deviceType;
+        bool hasAssociatedDisplay;
+        bool associatedDisplayIsExternal;
+        bool orientationAware;
+        bool hasButtonUnderPad;
+
+        enum GestureMode {
+            GESTURE_MODE_POINTER,
+            GESTURE_MODE_SPOTS,
+        };
+        GestureMode gestureMode;
+
+        bool wake;
+    } mParameters;
+
+    // Immutable calibration parameters in parsed form.
+    struct Calibration {
+        // Size
+        enum SizeCalibration {
+            SIZE_CALIBRATION_DEFAULT,
+            SIZE_CALIBRATION_NONE,
+            SIZE_CALIBRATION_GEOMETRIC,
+            SIZE_CALIBRATION_DIAMETER,
+            SIZE_CALIBRATION_BOX,
+            SIZE_CALIBRATION_AREA,
+        };
+
+        SizeCalibration sizeCalibration;
+
+        bool haveSizeScale;
+        float sizeScale;
+        bool haveSizeBias;
+        float sizeBias;
+        bool haveSizeIsSummed;
+        bool sizeIsSummed;
+
+        // Pressure
+        enum PressureCalibration {
+            PRESSURE_CALIBRATION_DEFAULT,
+            PRESSURE_CALIBRATION_NONE,
+            PRESSURE_CALIBRATION_PHYSICAL,
+            PRESSURE_CALIBRATION_AMPLITUDE,
+        };
+
+        PressureCalibration pressureCalibration;
+        bool havePressureScale;
+        float pressureScale;
+
+        // Orientation
+        enum OrientationCalibration {
+            ORIENTATION_CALIBRATION_DEFAULT,
+            ORIENTATION_CALIBRATION_NONE,
+            ORIENTATION_CALIBRATION_INTERPOLATED,
+            ORIENTATION_CALIBRATION_VECTOR,
+        };
+
+        OrientationCalibration orientationCalibration;
+
+        // Distance
+        enum DistanceCalibration {
+            DISTANCE_CALIBRATION_DEFAULT,
+            DISTANCE_CALIBRATION_NONE,
+            DISTANCE_CALIBRATION_SCALED,
+        };
+
+        DistanceCalibration distanceCalibration;
+        bool haveDistanceScale;
+        float distanceScale;
+
+        enum CoverageCalibration {
+            COVERAGE_CALIBRATION_DEFAULT,
+            COVERAGE_CALIBRATION_NONE,
+            COVERAGE_CALIBRATION_BOX,
+        };
+
+        CoverageCalibration coverageCalibration;
+
+        inline void applySizeScaleAndBias(float* outSize) const {
+            if (haveSizeScale) {
+                *outSize *= sizeScale;
+            }
+            if (haveSizeBias) {
+                *outSize += sizeBias;
+            }
+            if (*outSize < 0) {
+                *outSize = 0;
+            }
+        }
+    } mCalibration;
+
+    // Affine location transformation/calibration
+    struct TouchAffineTransformation mAffineTransform;
+
+    RawPointerAxes mRawPointerAxes;
+
+    struct RawState {
+        nsecs_t when;
+
+        // Raw pointer sample data.
+        RawPointerData rawPointerData;
+
+        int32_t buttonState;
+
+        // Scroll state.
+        int32_t rawVScroll;
+        int32_t rawHScroll;
+
+        void copyFrom(const RawState& other) {
+            when = other.when;
+            rawPointerData.copyFrom(other.rawPointerData);
+            buttonState = other.buttonState;
+            rawVScroll = other.rawVScroll;
+            rawHScroll = other.rawHScroll;
+        }
+
+        void clear() {
+            when = 0;
+            rawPointerData.clear();
+            buttonState = 0;
+            rawVScroll = 0;
+            rawHScroll = 0;
+        }
+    };
+
+    struct CookedState {
+        // Cooked pointer sample data.
+        CookedPointerData cookedPointerData;
+
+        // Id bits used to differentiate fingers, stylus and mouse tools.
+        BitSet32 fingerIdBits;
+        BitSet32 stylusIdBits;
+        BitSet32 mouseIdBits;
+
+        int32_t buttonState;
+
+        void copyFrom(const CookedState& other) {
+            cookedPointerData.copyFrom(other.cookedPointerData);
+            fingerIdBits = other.fingerIdBits;
+            stylusIdBits = other.stylusIdBits;
+            mouseIdBits = other.mouseIdBits;
+            buttonState = other.buttonState;
+        }
+
+        void clear() {
+            cookedPointerData.clear();
+            fingerIdBits.clear();
+            stylusIdBits.clear();
+            mouseIdBits.clear();
+            buttonState = 0;
+        }
+    };
+
+    Vector<RawState> mRawStatesPending;
+    RawState mCurrentRawState;
+    CookedState mCurrentCookedState;
+    RawState mLastRawState;
+    CookedState mLastCookedState;
+
+    // State provided by an external stylus
+    StylusState mExternalStylusState;
+    int64_t mExternalStylusId;
+    nsecs_t mExternalStylusFusionTimeout;
+    bool mExternalStylusDataPending;
+
+    // True if we sent a HOVER_ENTER event.
+    bool mSentHoverEnter;
+
+    // Have we assigned pointer IDs for this stream
+    bool mHavePointerIds;
+
+    // Is the current stream of direct touch events aborted
+    bool mCurrentMotionAborted;
+
+    // The time the primary pointer last went down.
+    nsecs_t mDownTime;
+
+    // The pointer controller, or null if the device is not a pointer.
+    sp<PointerControllerInterface> mPointerController;
+
+    Vector<VirtualKey> mVirtualKeys;
+
+    virtual void configureParameters();
+    virtual void dumpParameters(String8& dump);
+    virtual void configureRawPointerAxes();
+    virtual void dumpRawPointerAxes(String8& dump);
+    virtual void configureSurface(nsecs_t when, bool* outResetNeeded);
+    virtual void dumpSurface(String8& dump);
+    virtual void configureVirtualKeys();
+    virtual void dumpVirtualKeys(String8& dump);
+    virtual void parseCalibration();
+    virtual void resolveCalibration();
+    virtual void dumpCalibration(String8& dump);
+    virtual void updateAffineTransformation();
+    virtual void dumpAffineTransformation(String8& dump);
+    virtual void resolveExternalStylusPresence();
+    virtual bool hasStylus() const = 0;
+    virtual bool hasExternalStylus() const;
+
+    virtual void syncTouch(nsecs_t when, RawState* outState) = 0;
+
+private:
+    // The current viewport.
+    // The components of the viewport are specified in the display's rotated orientation.
+    DisplayViewport mViewport;
+
+    // The surface orientation, width and height set by configureSurface().
+    // The width and height are derived from the viewport but are specified
+    // in the natural orientation.
+    // The surface origin specifies how the surface coordinates should be translated
+    // to align with the logical display coordinate space.
+    // The orientation may be different from the viewport orientation as it specifies
+    // the rotation of the surface coordinates required to produce the viewport's
+    // requested orientation, so it will depend on whether the device is orientation aware.
+    int32_t mSurfaceWidth;
+    int32_t mSurfaceHeight;
+    int32_t mSurfaceLeft;
+    int32_t mSurfaceTop;
+    int32_t mSurfaceOrientation;
+
+    // Translation and scaling factors, orientation-independent.
+    float mXTranslate;
+    float mXScale;
+    float mXPrecision;
+
+    float mYTranslate;
+    float mYScale;
+    float mYPrecision;
+
+    float mGeometricScale;
+
+    float mPressureScale;
+
+    float mSizeScale;
+
+    float mOrientationScale;
+
+    float mDistanceScale;
+
+    bool mHaveTilt;
+    float mTiltXCenter;
+    float mTiltXScale;
+    float mTiltYCenter;
+    float mTiltYScale;
+
+    bool mExternalStylusConnected;
+
+    // Oriented motion ranges for input device info.
+    struct OrientedRanges {
+        InputDeviceInfo::MotionRange x;
+        InputDeviceInfo::MotionRange y;
+        InputDeviceInfo::MotionRange pressure;
+
+        bool haveSize;
+        InputDeviceInfo::MotionRange size;
+
+        bool haveTouchSize;
+        InputDeviceInfo::MotionRange touchMajor;
+        InputDeviceInfo::MotionRange touchMinor;
+
+        bool haveToolSize;
+        InputDeviceInfo::MotionRange toolMajor;
+        InputDeviceInfo::MotionRange toolMinor;
+
+        bool haveOrientation;
+        InputDeviceInfo::MotionRange orientation;
+
+        bool haveDistance;
+        InputDeviceInfo::MotionRange distance;
+
+        bool haveTilt;
+        InputDeviceInfo::MotionRange tilt;
+
+        OrientedRanges() {
+            clear();
+        }
+
+        void clear() {
+            haveSize = false;
+            haveTouchSize = false;
+            haveToolSize = false;
+            haveOrientation = false;
+            haveDistance = false;
+            haveTilt = false;
+        }
+    } mOrientedRanges;
+
+    // Oriented dimensions and precision.
+    float mOrientedXPrecision;
+    float mOrientedYPrecision;
+
+    struct CurrentVirtualKeyState {
+        bool down;
+        bool ignored;
+        nsecs_t downTime;
+        int32_t keyCode;
+        int32_t scanCode;
+    } mCurrentVirtualKey;
+
+    // Scale factor for gesture or mouse based pointer movements.
+    float mPointerXMovementScale;
+    float mPointerYMovementScale;
+
+    // Scale factor for gesture based zooming and other freeform motions.
+    float mPointerXZoomScale;
+    float mPointerYZoomScale;
+
+    // The maximum swipe width.
+    float mPointerGestureMaxSwipeWidth;
+
+    struct PointerDistanceHeapElement {
+        uint32_t currentPointerIndex : 8;
+        uint32_t lastPointerIndex : 8;
+        uint64_t distance : 48; // squared distance
+    };
+
+    enum PointerUsage {
+        POINTER_USAGE_NONE,
+        POINTER_USAGE_GESTURES,
+        POINTER_USAGE_STYLUS,
+        POINTER_USAGE_MOUSE,
+    };
+    PointerUsage mPointerUsage;
+
+    struct PointerGesture {
+        enum Mode {
+            // No fingers, button is not pressed.
+            // Nothing happening.
+            NEUTRAL,
+
+            // No fingers, button is not pressed.
+            // Tap detected.
+            // Emits DOWN and UP events at the pointer location.
+            TAP,
+
+            // Exactly one finger dragging following a tap.
+            // Pointer follows the active finger.
+            // Emits DOWN, MOVE and UP events at the pointer location.
+            //
+            // Detect double-taps when the finger goes up while in TAP_DRAG mode.
+            TAP_DRAG,
+
+            // Button is pressed.
+            // Pointer follows the active finger if there is one.  Other fingers are ignored.
+            // Emits DOWN, MOVE and UP events at the pointer location.
+            BUTTON_CLICK_OR_DRAG,
+
+            // Exactly one finger, button is not pressed.
+            // Pointer follows the active finger.
+            // Emits HOVER_MOVE events at the pointer location.
+            //
+            // Detect taps when the finger goes up while in HOVER mode.
+            HOVER,
+
+            // Exactly two fingers but neither have moved enough to clearly indicate
+            // whether a swipe or freeform gesture was intended.  We consider the
+            // pointer to be pressed so this enables clicking or long-pressing on buttons.
+            // Pointer does not move.
+            // Emits DOWN, MOVE and UP events with a single stationary pointer coordinate.
+            PRESS,
+
+            // Exactly two fingers moving in the same direction, button is not pressed.
+            // Pointer does not move.
+            // Emits DOWN, MOVE and UP events with a single pointer coordinate that
+            // follows the midpoint between both fingers.
+            SWIPE,
+
+            // Two or more fingers moving in arbitrary directions, button is not pressed.
+            // Pointer does not move.
+            // Emits DOWN, POINTER_DOWN, MOVE, POINTER_UP and UP events that follow
+            // each finger individually relative to the initial centroid of the finger.
+            FREEFORM,
+
+            // Waiting for quiet time to end before starting the next gesture.
+            QUIET,
+        };
+
+        // Time the first finger went down.
+        nsecs_t firstTouchTime;
+
+        // The active pointer id from the raw touch data.
+        int32_t activeTouchId; // -1 if none
+
+        // The active pointer id from the gesture last delivered to the application.
+        int32_t activeGestureId; // -1 if none
+
+        // Pointer coords and ids for the current and previous pointer gesture.
+        Mode currentGestureMode;
+        BitSet32 currentGestureIdBits;
+        uint32_t currentGestureIdToIndex[MAX_POINTER_ID + 1];
+        PointerProperties currentGestureProperties[MAX_POINTERS];
+        PointerCoords currentGestureCoords[MAX_POINTERS];
+
+        Mode lastGestureMode;
+        BitSet32 lastGestureIdBits;
+        uint32_t lastGestureIdToIndex[MAX_POINTER_ID + 1];
+        PointerProperties lastGestureProperties[MAX_POINTERS];
+        PointerCoords lastGestureCoords[MAX_POINTERS];
+
+        // Time the pointer gesture last went down.
+        nsecs_t downTime;
+
+        // Time when the pointer went down for a TAP.
+        nsecs_t tapDownTime;
+
+        // Time when the pointer went up for a TAP.
+        nsecs_t tapUpTime;
+
+        // Location of initial tap.
+        float tapX, tapY;
+
+        // Time we started waiting for quiescence.
+        nsecs_t quietTime;
+
+        // Reference points for multitouch gestures.
+        float referenceTouchX;    // reference touch X/Y coordinates in surface units
+        float referenceTouchY;
+        float referenceGestureX;  // reference gesture X/Y coordinates in pixels
+        float referenceGestureY;
+
+        // Distance that each pointer has traveled which has not yet been
+        // subsumed into the reference gesture position.
+        BitSet32 referenceIdBits;
+        struct Delta {
+            float dx, dy;
+        };
+        Delta referenceDeltas[MAX_POINTER_ID + 1];
+
+        // Describes how touch ids are mapped to gesture ids for freeform gestures.
+        uint32_t freeformTouchToGestureIdMap[MAX_POINTER_ID + 1];
+
+        // A velocity tracker for determining whether to switch active pointers during drags.
+        VelocityTracker velocityTracker;
+
+        void reset() {
+            firstTouchTime = LLONG_MIN;
+            activeTouchId = -1;
+            activeGestureId = -1;
+            currentGestureMode = NEUTRAL;
+            currentGestureIdBits.clear();
+            lastGestureMode = NEUTRAL;
+            lastGestureIdBits.clear();
+            downTime = 0;
+            velocityTracker.clear();
+            resetTap();
+            resetQuietTime();
+        }
+
+        void resetTap() {
+            tapDownTime = LLONG_MIN;
+            tapUpTime = LLONG_MIN;
+        }
+
+        void resetQuietTime() {
+            quietTime = LLONG_MIN;
+        }
+    } mPointerGesture;
+
+    struct PointerSimple {
+        PointerCoords currentCoords;
+        PointerProperties currentProperties;
+        PointerCoords lastCoords;
+        PointerProperties lastProperties;
+
+        // True if the pointer is down.
+        bool down;
+
+        // True if the pointer is hovering.
+        bool hovering;
+
+        // Time the pointer last went down.
+        nsecs_t downTime;
+
+        void reset() {
+            currentCoords.clear();
+            currentProperties.clear();
+            lastCoords.clear();
+            lastProperties.clear();
+            down = false;
+            hovering = false;
+            downTime = 0;
+        }
+    } mPointerSimple;
+
+    // The pointer and scroll velocity controls.
+    VelocityControl mPointerVelocityControl;
+    VelocityControl mWheelXVelocityControl;
+    VelocityControl mWheelYVelocityControl;
+
+    void resetExternalStylus();
+    void clearStylusDataPendingFlags();
+
+    void sync(nsecs_t when);
+
+    bool consumeRawTouches(nsecs_t when, uint32_t policyFlags);
+    void processRawTouches(bool timeout);
+    void cookAndDispatch(nsecs_t when);
+    void dispatchVirtualKey(nsecs_t when, uint32_t policyFlags,
+            int32_t keyEventAction, int32_t keyEventFlags);
+
+    void dispatchTouches(nsecs_t when, uint32_t policyFlags);
+    void dispatchHoverExit(nsecs_t when, uint32_t policyFlags);
+    void dispatchHoverEnterAndMove(nsecs_t when, uint32_t policyFlags);
+    void dispatchButtonRelease(nsecs_t when, uint32_t policyFlags);
+    void dispatchButtonPress(nsecs_t when, uint32_t policyFlags);
+    const BitSet32& findActiveIdBits(const CookedPointerData& cookedPointerData);
+    void cookPointerData();
+    void abortTouches(nsecs_t when, uint32_t policyFlags);
+
+    void dispatchPointerUsage(nsecs_t when, uint32_t policyFlags, PointerUsage pointerUsage);
+    void abortPointerUsage(nsecs_t when, uint32_t policyFlags);
+
+    void dispatchPointerGestures(nsecs_t when, uint32_t policyFlags, bool isTimeout);
+    void abortPointerGestures(nsecs_t when, uint32_t policyFlags);
+    bool preparePointerGestures(nsecs_t when,
+            bool* outCancelPreviousGesture, bool* outFinishPreviousGesture,
+            bool isTimeout);
+
+    void dispatchPointerStylus(nsecs_t when, uint32_t policyFlags);
+    void abortPointerStylus(nsecs_t when, uint32_t policyFlags);
+
+    void dispatchPointerMouse(nsecs_t when, uint32_t policyFlags);
+    void abortPointerMouse(nsecs_t when, uint32_t policyFlags);
+
+    void dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
+            bool down, bool hovering);
+    void abortPointerSimple(nsecs_t when, uint32_t policyFlags);
+
+    bool assignExternalStylusId(const RawState& state, bool timeout);
+    void applyExternalStylusButtonState(nsecs_t when);
+    void applyExternalStylusTouchState(nsecs_t when);
+
+    // Dispatches a motion event.
+    // If the changedId is >= 0 and the action is POINTER_DOWN or POINTER_UP, the
+    // method will take care of setting the index and transmuting the action to DOWN or UP
+    // it is the first / last pointer to go down / up.
+    void dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32_t source,
+            int32_t action, int32_t actionButton,
+            int32_t flags, int32_t metaState, int32_t buttonState, int32_t edgeFlags,
+            const PointerProperties* properties, const PointerCoords* coords,
+            const uint32_t* idToIndex, BitSet32 idBits,
+            int32_t changedId, float xPrecision, float yPrecision, nsecs_t downTime);
+
+    // Updates pointer coords and properties for pointers with specified ids that have moved.
+    // Returns true if any of them changed.
+    bool updateMovedPointers(const PointerProperties* inProperties,
+            const PointerCoords* inCoords, const uint32_t* inIdToIndex,
+            PointerProperties* outProperties, PointerCoords* outCoords,
+            const uint32_t* outIdToIndex, BitSet32 idBits) const;
+
+    bool isPointInsideSurface(int32_t x, int32_t y);
+    const VirtualKey* findVirtualKeyHit(int32_t x, int32_t y);
+
+    static void assignPointerIds(const RawState* last, RawState* current);
+};
+
+
+class SingleTouchInputMapper : public TouchInputMapper {
+public:
+    SingleTouchInputMapper(InputDevice* device);
+    virtual ~SingleTouchInputMapper();
+
+    virtual void reset(nsecs_t when);
+    virtual void process(const RawEvent* rawEvent);
+
+protected:
+    virtual void syncTouch(nsecs_t when, RawState* outState);
+    virtual void configureRawPointerAxes();
+    virtual bool hasStylus() const;
+
+private:
+    SingleTouchMotionAccumulator mSingleTouchMotionAccumulator;
+};
+
+
+class MultiTouchInputMapper : public TouchInputMapper {
+public:
+    MultiTouchInputMapper(InputDevice* device);
+    virtual ~MultiTouchInputMapper();
+
+    virtual void reset(nsecs_t when);
+    virtual void process(const RawEvent* rawEvent);
+
+protected:
+    virtual void syncTouch(nsecs_t when, RawState* outState);
+    virtual void configureRawPointerAxes();
+    virtual bool hasStylus() const;
+
+private:
+    MultiTouchMotionAccumulator mMultiTouchMotionAccumulator;
+
+    // Specifies the pointer id bits that are in use, and their associated tracking id.
+    BitSet32 mPointerIdBits;
+    int32_t mPointerTrackingIdMap[MAX_POINTER_ID + 1];
+};
+
+class ExternalStylusInputMapper : public InputMapper {
+public:
+    ExternalStylusInputMapper(InputDevice* device);
+    virtual ~ExternalStylusInputMapper() = default;
+
+    virtual uint32_t getSources();
+    virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
+    virtual void dump(String8& dump);
+    virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
+    virtual void reset(nsecs_t when);
+    virtual void process(const RawEvent* rawEvent);
+    virtual void sync(nsecs_t when);
+
+private:
+    SingleTouchMotionAccumulator mSingleTouchMotionAccumulator;
+    RawAbsoluteAxisInfo mRawPressureAxis;
+    TouchButtonAccumulator mTouchButtonAccumulator;
+
+    StylusState mStylusState;
+};
+
+
+class JoystickInputMapper : public InputMapper {
+public:
+    JoystickInputMapper(InputDevice* device);
+    virtual ~JoystickInputMapper();
+
+    virtual uint32_t getSources();
+    virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
+    virtual void dump(String8& dump);
+    virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
+    virtual void reset(nsecs_t when);
+    virtual void process(const RawEvent* rawEvent);
+
+private:
+    struct Axis {
+        RawAbsoluteAxisInfo rawAxisInfo;
+        AxisInfo axisInfo;
+
+        bool explicitlyMapped; // true if the axis was explicitly assigned an axis id
+
+        float scale;   // scale factor from raw to normalized values
+        float offset;  // offset to add after scaling for normalization
+        float highScale;  // scale factor from raw to normalized values of high split
+        float highOffset; // offset to add after scaling for normalization of high split
+
+        float min;        // normalized inclusive minimum
+        float max;        // normalized inclusive maximum
+        float flat;       // normalized flat region size
+        float fuzz;       // normalized error tolerance
+        float resolution; // normalized resolution in units/mm
+
+        float filter;  // filter out small variations of this size
+        float currentValue; // current value
+        float newValue; // most recent value
+        float highCurrentValue; // current value of high split
+        float highNewValue; // most recent value of high split
+
+        void initialize(const RawAbsoluteAxisInfo& rawAxisInfo, const AxisInfo& axisInfo,
+                bool explicitlyMapped, float scale, float offset,
+                float highScale, float highOffset,
+                float min, float max, float flat, float fuzz, float resolution) {
+            this->rawAxisInfo = rawAxisInfo;
+            this->axisInfo = axisInfo;
+            this->explicitlyMapped = explicitlyMapped;
+            this->scale = scale;
+            this->offset = offset;
+            this->highScale = highScale;
+            this->highOffset = highOffset;
+            this->min = min;
+            this->max = max;
+            this->flat = flat;
+            this->fuzz = fuzz;
+            this->resolution = resolution;
+            this->filter = 0;
+            resetValue();
+        }
+
+        void resetValue() {
+            this->currentValue = 0;
+            this->newValue = 0;
+            this->highCurrentValue = 0;
+            this->highNewValue = 0;
+        }
+    };
+
+    // Axes indexed by raw ABS_* axis index.
+    KeyedVector<int32_t, Axis> mAxes;
+
+    void sync(nsecs_t when, bool force);
+
+    bool haveAxis(int32_t axisId);
+    void pruneAxes(bool ignoreExplicitlyMappedAxes);
+    bool filterAxes(bool force);
+
+    static bool hasValueChangedSignificantly(float filter,
+            float newValue, float currentValue, float min, float max);
+    static bool hasMovedNearerToValueWithinFilteredRange(float filter,
+            float newValue, float currentValue, float thresholdValue);
+
+    static bool isCenteredAxis(int32_t axis);
+    static int32_t getCompatAxis(int32_t axis);
+
+    static void addMotionRange(int32_t axisId, const Axis& axis, InputDeviceInfo* info);
+    static void setPointerCoordsAxisValue(PointerCoords* pointerCoords, int32_t axis,
+            float value);
+};
+
+} // namespace android
+
+#endif // _UI_INPUT_READER_H
diff --git a/services/inputflinger/InputWindow.cpp b/services/inputflinger/InputWindow.cpp
new file mode 100644
index 0000000..fda3ffa
--- /dev/null
+++ b/services/inputflinger/InputWindow.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "InputWindow"
+#define LOG_NDEBUG 0
+
+#include "InputWindow.h"
+
+#include <cutils/log.h>
+
+#include <ui/Rect.h>
+#include <ui/Region.h>
+
+namespace android {
+
+// --- InputWindowInfo ---
+void InputWindowInfo::addTouchableRegion(const Rect& region) {
+    touchableRegion.orSelf(region);
+}
+
+bool InputWindowInfo::touchableRegionContainsPoint(int32_t x, int32_t y) const {
+    return touchableRegion.contains(x,y);
+}
+
+bool InputWindowInfo::frameContainsPoint(int32_t x, int32_t y) const {
+    return x >= frameLeft && x <= frameRight
+            && y >= frameTop && y <= frameBottom;
+}
+
+bool InputWindowInfo::isTrustedOverlay() const {
+    return layoutParamsType == TYPE_INPUT_METHOD
+            || layoutParamsType == TYPE_INPUT_METHOD_DIALOG
+            || layoutParamsType == TYPE_MAGNIFICATION_OVERLAY
+            || layoutParamsType == TYPE_SECURE_SYSTEM_OVERLAY;
+}
+
+bool InputWindowInfo::supportsSplitTouch() const {
+    return layoutParamsFlags & FLAG_SPLIT_TOUCH;
+}
+
+
+// --- InputWindowHandle ---
+
+InputWindowHandle::InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle) :
+    inputApplicationHandle(inputApplicationHandle), mInfo(NULL) {
+}
+
+InputWindowHandle::~InputWindowHandle() {
+    delete mInfo;
+}
+
+void InputWindowHandle::releaseInfo() {
+    if (mInfo) {
+        delete mInfo;
+        mInfo = NULL;
+    }
+}
+
+} // namespace android
diff --git a/services/inputflinger/InputWindow.h b/services/inputflinger/InputWindow.h
new file mode 100644
index 0000000..42457ce
--- /dev/null
+++ b/services/inputflinger/InputWindow.h
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _UI_INPUT_WINDOW_H
+#define _UI_INPUT_WINDOW_H
+
+#include <input/Input.h>
+#include <input/InputTransport.h>
+#include <ui/Rect.h>
+#include <ui/Region.h>
+#include <utils/RefBase.h>
+#include <utils/Timers.h>
+#include <utils/String8.h>
+
+#include "InputApplication.h"
+
+namespace android {
+
+
+/*
+ * Describes the properties of a window that can receive input.
+ */
+struct InputWindowInfo {
+    // Window flags from WindowManager.LayoutParams
+    enum {
+        FLAG_ALLOW_LOCK_WHILE_SCREEN_ON     = 0x00000001,
+        FLAG_DIM_BEHIND        = 0x00000002,
+        FLAG_BLUR_BEHIND        = 0x00000004,
+        FLAG_NOT_FOCUSABLE      = 0x00000008,
+        FLAG_NOT_TOUCHABLE      = 0x00000010,
+        FLAG_NOT_TOUCH_MODAL    = 0x00000020,
+        FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040,
+        FLAG_KEEP_SCREEN_ON     = 0x00000080,
+        FLAG_LAYOUT_IN_SCREEN   = 0x00000100,
+        FLAG_LAYOUT_NO_LIMITS   = 0x00000200,
+        FLAG_FULLSCREEN      = 0x00000400,
+        FLAG_FORCE_NOT_FULLSCREEN   = 0x00000800,
+        FLAG_DITHER             = 0x00001000,
+        FLAG_SECURE             = 0x00002000,
+        FLAG_SCALED             = 0x00004000,
+        FLAG_IGNORE_CHEEK_PRESSES    = 0x00008000,
+        FLAG_LAYOUT_INSET_DECOR = 0x00010000,
+        FLAG_ALT_FOCUSABLE_IM = 0x00020000,
+        FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000,
+        FLAG_SHOW_WHEN_LOCKED = 0x00080000,
+        FLAG_SHOW_WALLPAPER = 0x00100000,
+        FLAG_TURN_SCREEN_ON = 0x00200000,
+        FLAG_DISMISS_KEYGUARD = 0x00400000,
+        FLAG_SPLIT_TOUCH = 0x00800000,
+        FLAG_SLIPPERY = 0x20000000,
+        FLAG_NEEDS_MENU_KEY = 0x40000000,
+    };
+
+    // Window types from WindowManager.LayoutParams
+    enum {
+        FIRST_APPLICATION_WINDOW = 1,
+        TYPE_BASE_APPLICATION   = 1,
+        TYPE_APPLICATION        = 2,
+        TYPE_APPLICATION_STARTING = 3,
+        LAST_APPLICATION_WINDOW = 99,
+        FIRST_SUB_WINDOW        = 1000,
+        TYPE_APPLICATION_PANEL  = FIRST_SUB_WINDOW,
+        TYPE_APPLICATION_MEDIA  = FIRST_SUB_WINDOW+1,
+        TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2,
+        TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3,
+        TYPE_APPLICATION_MEDIA_OVERLAY  = FIRST_SUB_WINDOW+4,
+        LAST_SUB_WINDOW         = 1999,
+        FIRST_SYSTEM_WINDOW     = 2000,
+        TYPE_STATUS_BAR         = FIRST_SYSTEM_WINDOW,
+        TYPE_SEARCH_BAR         = FIRST_SYSTEM_WINDOW+1,
+        TYPE_PHONE              = FIRST_SYSTEM_WINDOW+2,
+        TYPE_SYSTEM_ALERT       = FIRST_SYSTEM_WINDOW+3,
+        TYPE_KEYGUARD           = FIRST_SYSTEM_WINDOW+4,
+        TYPE_TOAST              = FIRST_SYSTEM_WINDOW+5,
+        TYPE_SYSTEM_OVERLAY     = FIRST_SYSTEM_WINDOW+6,
+        TYPE_PRIORITY_PHONE     = FIRST_SYSTEM_WINDOW+7,
+        TYPE_SYSTEM_DIALOG      = FIRST_SYSTEM_WINDOW+8,
+        TYPE_KEYGUARD_DIALOG    = FIRST_SYSTEM_WINDOW+9,
+        TYPE_SYSTEM_ERROR       = FIRST_SYSTEM_WINDOW+10,
+        TYPE_INPUT_METHOD       = FIRST_SYSTEM_WINDOW+11,
+        TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12,
+        TYPE_WALLPAPER          = FIRST_SYSTEM_WINDOW+13,
+        TYPE_STATUS_BAR_PANEL   = FIRST_SYSTEM_WINDOW+14,
+        TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15,
+        TYPE_DRAG               = FIRST_SYSTEM_WINDOW+16,
+        TYPE_STATUS_BAR_SUB_PANEL  = FIRST_SYSTEM_WINDOW+17,
+        TYPE_POINTER            = FIRST_SYSTEM_WINDOW+18,
+        TYPE_NAVIGATION_BAR     = FIRST_SYSTEM_WINDOW+19,
+        TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20,
+        TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21,
+        TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+22,
+        LAST_SYSTEM_WINDOW      = 2999,
+    };
+
+    enum {
+        INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES = 0x00000001,
+        INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002,
+        INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004,
+    };
+
+    sp<InputChannel> inputChannel;
+    String8 name;
+    int32_t layoutParamsFlags;
+    int32_t layoutParamsType;
+    nsecs_t dispatchingTimeout;
+    int32_t frameLeft;
+    int32_t frameTop;
+    int32_t frameRight;
+    int32_t frameBottom;
+    float scaleFactor;
+    Region touchableRegion;
+    bool visible;
+    bool canReceiveKeys;
+    bool hasFocus;
+    bool hasWallpaper;
+    bool paused;
+    int32_t layer;
+    int32_t ownerPid;
+    int32_t ownerUid;
+    int32_t inputFeatures;
+    int32_t displayId;
+
+    void addTouchableRegion(const Rect& region);
+
+    bool touchableRegionContainsPoint(int32_t x, int32_t y) const;
+    bool frameContainsPoint(int32_t x, int32_t y) const;
+
+    /* Returns true if the window is of a trusted type that is allowed to silently
+     * overlay other windows for the purpose of implementing the secure views feature.
+     * Trusted overlays, such as IME windows, can partly obscure other windows without causing
+     * motion events to be delivered to them with AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED.
+     */
+    bool isTrustedOverlay() const;
+
+    bool supportsSplitTouch() const;
+};
+
+
+/*
+ * Handle for a window that can receive input.
+ *
+ * Used by the native input dispatcher to indirectly refer to the window manager objects
+ * that describe a window.
+ */
+class InputWindowHandle : public RefBase {
+public:
+    const sp<InputApplicationHandle> inputApplicationHandle;
+
+    inline const InputWindowInfo* getInfo() const {
+        return mInfo;
+    }
+
+    inline sp<InputChannel> getInputChannel() const {
+        return mInfo ? mInfo->inputChannel : NULL;
+    }
+
+    inline String8 getName() const {
+        return mInfo ? mInfo->name : String8("<invalid>");
+    }
+
+    inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const {
+        return mInfo ? mInfo->dispatchingTimeout : defaultValue;
+    }
+
+    /**
+     * Requests that the state of this object be updated to reflect
+     * the most current available information about the application.
+     *
+     * This method should only be called from within the input dispatcher's
+     * critical section.
+     *
+     * Returns true on success, or false if the handle is no longer valid.
+     */
+    virtual bool updateInfo() = 0;
+
+    /**
+     * Releases the storage used by the associated information when it is
+     * no longer needed.
+     */
+    void releaseInfo();
+
+protected:
+    InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle);
+    virtual ~InputWindowHandle();
+
+    InputWindowInfo* mInfo;
+};
+
+} // namespace android
+
+#endif // _UI_INPUT_WINDOW_H
diff --git a/services/inputflinger/PointerControllerInterface.h b/services/inputflinger/PointerControllerInterface.h
new file mode 100644
index 0000000..e94dd94
--- /dev/null
+++ b/services/inputflinger/PointerControllerInterface.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _INPUTFLINGER_POINTER_CONTROLLER_INTERFACE_H
+#define _INPUTFLINGER_POINTER_CONTROLLER_INTERFACE_H
+
+#include <input/Input.h>
+#include <utils/BitSet.h>
+#include <utils/RefBase.h>
+
+namespace android {
+
+/**
+ * Interface for tracking a mouse / touch pad pointer and touch pad spots.
+ *
+ * The spots are sprites on screen that visually represent the positions of
+ * fingers
+ *
+ * The pointer controller is responsible for providing synchronization and for tracking
+ * display orientation changes if needed.
+ */
+class PointerControllerInterface : public virtual RefBase {
+protected:
+    PointerControllerInterface() { }
+    virtual ~PointerControllerInterface() { }
+
+public:
+    /* Gets the bounds of the region that the pointer can traverse.
+     * Returns true if the bounds are available. */
+    virtual bool getBounds(float* outMinX, float* outMinY,
+            float* outMaxX, float* outMaxY) const = 0;
+
+    /* Move the pointer. */
+    virtual void move(float deltaX, float deltaY) = 0;
+
+    /* Sets a mask that indicates which buttons are pressed. */
+    virtual void setButtonState(int32_t buttonState) = 0;
+
+    /* Gets a mask that indicates which buttons are pressed. */
+    virtual int32_t getButtonState() const = 0;
+
+    /* Sets the absolute location of the pointer. */
+    virtual void setPosition(float x, float y) = 0;
+
+    /* Gets the absolute location of the pointer. */
+    virtual void getPosition(float* outX, float* outY) const = 0;
+
+    enum Transition {
+        // Fade/unfade immediately.
+        TRANSITION_IMMEDIATE,
+        // Fade/unfade gradually.
+        TRANSITION_GRADUAL,
+    };
+
+    /* Fades the pointer out now. */
+    virtual void fade(Transition transition) = 0;
+
+    /* Makes the pointer visible if it has faded out.
+     * The pointer never unfades itself automatically.  This method must be called
+     * by the client whenever the pointer is moved or a button is pressed and it
+     * wants to ensure that the pointer becomes visible again. */
+    virtual void unfade(Transition transition) = 0;
+
+    enum Presentation {
+        // Show the mouse pointer.
+        PRESENTATION_POINTER,
+        // Show spots and a spot anchor in place of the mouse pointer.
+        PRESENTATION_SPOT,
+    };
+
+    /* Sets the mode of the pointer controller. */
+    virtual void setPresentation(Presentation presentation) = 0;
+
+    /* Sets the spots for the current gesture.
+     * The spots are not subject to the inactivity timeout like the pointer
+     * itself it since they are expected to remain visible for so long as
+     * the fingers are on the touch pad.
+     *
+     * The values of the AMOTION_EVENT_AXIS_PRESSURE axis is significant.
+     * For spotCoords, pressure != 0 indicates that the spot's location is being
+     * pressed (not hovering).
+     */
+    virtual void setSpots(const PointerCoords* spotCoords, const uint32_t* spotIdToIndex,
+            BitSet32 spotIdBits) = 0;
+
+    /* Removes all spots. */
+    virtual void clearSpots() = 0;
+};
+
+} // namespace android
+
+#endif // _INPUTFLINGER_POINTER_CONTROLLER_INTERFACE_H
diff --git a/services/inputflinger/host/Android.mk b/services/inputflinger/host/Android.mk
new file mode 100644
index 0000000..b828175
--- /dev/null
+++ b/services/inputflinger/host/Android.mk
@@ -0,0 +1,62 @@
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_CLANG := true
+
+LOCAL_SRC_FILES:= \
+    InputFlinger.cpp \
+    InputDriver.cpp \
+    InputHost.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+    libbinder \
+    libcrypto \
+    libcutils \
+    libinput \
+    liblog \
+    libutils \
+    libhardware
+
+
+# TODO: Move inputflinger to its own process and mark it hidden
+#LOCAL_CFLAGS += -fvisibility=hidden
+
+LOCAL_CFLAGS += -Wno-unused-parameter
+
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
+
+LOCAL_MODULE := libinputflingerhost
+
+include $(BUILD_SHARED_LIBRARY)
+
+########################################################################
+# build input flinger executable
+include $(CLEAR_VARS)
+
+LOCAL_CLANG := true
+
+LOCAL_SRC_FILES:= \
+	main.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+	libbinder \
+	libinputflingerhost \
+	libutils
+
+LOCAL_MODULE := inputflinger
+
+include $(BUILD_EXECUTABLE)
diff --git a/services/inputflinger/host/InputDriver.cpp b/services/inputflinger/host/InputDriver.cpp
new file mode 100644
index 0000000..630a596
--- /dev/null
+++ b/services/inputflinger/host/InputDriver.cpp
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#define LOG_TAG "InputDriver"
+
+#define LOG_NDEBUG 0
+
+#include "InputDriver.h"
+#include "InputHost.h"
+
+#include <hardware/input.h>
+#include <utils/Log.h>
+#include <utils/String8.h>
+
+#define INDENT2 "    "
+
+namespace android {
+
+static input_host_callbacks_t kCallbacks = {
+    .create_device_identifier = create_device_identifier,
+    .create_device_definition = create_device_definition,
+    .create_input_report_definition = create_input_report_definition,
+    .create_output_report_definition = create_output_report_definition,
+    .input_device_definition_add_report = input_device_definition_add_report,
+    .input_report_definition_add_collection = input_report_definition_add_collection,
+    .input_report_definition_declare_usage_int = input_report_definition_declare_usage_int,
+    .input_report_definition_declare_usages_bool = input_report_definition_declare_usages_bool,
+    .register_device = register_device,
+    .input_allocate_report = input_allocate_report,
+    .input_report_set_usage_int = input_report_set_usage_int,
+    .input_report_set_usage_bool = input_report_set_usage_bool,
+    .report_event = report_event,
+    .input_get_device_property_map = input_get_device_property_map,
+    .input_get_device_property = input_get_device_property,
+    .input_get_property_key = input_get_property_key,
+    .input_get_property_value = input_get_property_value,
+    .input_free_device_property = input_free_device_property,
+    .input_free_device_property_map = input_free_device_property_map,
+};
+
+InputDriver::InputDriver(const char* name) : mName(String8(name)) {
+    const hw_module_t* module;
+    int err = input_open(&module, name);
+    LOG_ALWAYS_FATAL_IF(err != 0, "Input module %s not found", name);
+    mHal = reinterpret_cast<const input_module_t*>(module);
+}
+
+void InputDriver::init(InputHostInterface* host) {
+    mHal->init(mHal, static_cast<input_host_t*>(host), kCallbacks);
+}
+
+void InputDriver::dump(String8& result) {
+    result.appendFormat(INDENT2 "HAL Input Driver (%s)\n", mName.string());
+}
+
+
+// HAL wrapper functions
+
+input_device_identifier_t* create_device_identifier(input_host_t* host,
+        const char* name, int32_t product_id, int32_t vendor_id,
+        input_bus_t bus, const char* unique_id) {
+    return nullptr;
+}
+
+input_device_definition_t* create_device_definition(input_host_t* host) {
+    return nullptr;
+}
+
+input_report_definition_t* create_input_report_definition(input_host_t* host) {
+    return nullptr;
+}
+
+input_report_definition_t* create_output_report_definition(input_host_t* host) {
+    return nullptr;
+}
+
+void input_device_definition_add_report(input_host_t* host,
+        input_device_definition_t* d, input_report_definition_t* r) { }
+
+void input_report_definition_add_collection(input_host_t* host,
+        input_report_definition_t* report, input_collection_id_t id, int32_t arity) { }
+
+void input_report_definition_declare_usage_int(input_host_t* host,
+        input_report_definition_t* report, input_collection_id_t id,
+        input_usage_t usage, int32_t min, int32_t max, float resolution) { }
+
+void input_report_definition_declare_usages_bool(input_host_t* host,
+        input_report_definition_t* report, input_collection_id_t id,
+        input_usage_t* usage, size_t usage_count) { }
+
+
+input_device_handle_t* register_device(input_host_t* host,
+        input_device_identifier_t* id, input_device_definition_t* d) {
+    return nullptr;
+}
+
+input_report_t* input_allocate_report(input_host_t* host, input_report_definition_t* r) {
+    return nullptr;
+}
+void input_report_set_usage_int(input_host_t* host, input_report_t* r,
+        input_collection_id_t id, input_usage_t usage, int32_t value, int32_t arity_index) { }
+
+void input_report_set_usage_bool(input_host_t* host, input_report_t* r,
+        input_collection_id_t id, input_usage_t usage, bool value, int32_t arity_index) { }
+
+void report_event(input_host_t* host, input_device_handle_t* d, input_report_t* report) { }
+
+input_property_map_t* input_get_device_property_map(input_host_t* host,
+        input_device_identifier_t* id) {
+    return nullptr;
+}
+
+input_property_t* input_get_device_property(input_host_t* host, input_property_map_t* map,
+        const char* key) {
+    return nullptr;
+}
+
+const char* input_get_property_key(input_host_t* host, input_property_t* property) {
+    return nullptr;
+}
+
+const char* input_get_property_value(input_host_t* host, input_property_t* property) {
+    return nullptr;
+}
+
+void input_free_device_property(input_host_t* host, input_property_t* property) { }
+
+void input_free_device_property_map(input_host_t* host, input_property_map_t* map) { }
+
+} // namespace android
diff --git a/services/inputflinger/host/InputDriver.h b/services/inputflinger/host/InputDriver.h
new file mode 100644
index 0000000..7734ac2
--- /dev/null
+++ b/services/inputflinger/host/InputDriver.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_INPUT_DRIVER_H
+#define ANDROID_INPUT_DRIVER_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include "InputHost.h"
+
+#include <hardware/input.h>
+#include <utils/RefBase.h>
+#include <utils/String8.h>
+
+namespace android {
+
+class InputHostInterface;
+
+class InputDriverInterface : public virtual RefBase {
+protected:
+    InputDriverInterface() = default;
+    virtual ~InputDriverInterface() = default;
+
+public:
+    virtual void init(InputHostInterface* host) = 0;
+
+    virtual void dump(String8& result) = 0;
+};
+
+class InputDriver : public InputDriverInterface {
+public:
+    InputDriver(const char* name);
+    virtual ~InputDriver() = default;
+
+    virtual void init(InputHostInterface* host) override;
+
+    virtual void dump(String8& result) override;
+
+private:
+    String8 mName;
+    const input_module_t* mHal;
+};
+
+
+extern "C" {
+
+input_device_identifier_t* create_device_identifier(input_host_t* host,
+        const char* name, int32_t product_id, int32_t vendor_id,
+        input_bus_t bus, const char* unique_id);
+
+input_device_definition_t* create_device_definition(input_host_t* host);
+
+input_report_definition_t* create_input_report_definition(input_host_t* host);
+
+input_report_definition_t* create_output_report_definition(input_host_t* host);
+
+void input_device_definition_add_report(input_host_t* host,
+        input_device_definition_t* d, input_report_definition_t* r);
+
+void input_report_definition_add_collection(input_host_t* host,
+        input_report_definition_t* report, input_collection_id_t id, int32_t arity);
+
+void input_report_definition_declare_usage_int(input_host_t* host,
+        input_report_definition_t* report, input_collection_id_t id,
+        input_usage_t usage, int32_t min, int32_t max, float resolution);
+
+void input_report_definition_declare_usages_bool(input_host_t* host,
+        input_report_definition_t* report, input_collection_id_t id,
+        input_usage_t* usage, size_t usage_count);
+
+
+input_device_handle_t* register_device(input_host_t* host,
+        input_device_identifier_t* id, input_device_definition_t* d);
+
+void unregister_device(input_host_t* host, input_device_handle_t* handle);
+
+input_report_t* input_allocate_report(input_host_t* host, input_report_definition_t* r);
+
+void input_report_set_usage_int(input_host_t* host, input_report_t* r,
+        input_collection_id_t id, input_usage_t usage, int32_t value, int32_t arity_index);
+
+void input_report_set_usage_bool(input_host_t* host, input_report_t* r,
+        input_collection_id_t id, input_usage_t usage, bool value, int32_t arity_index);
+
+void report_event(input_host_t* host, input_device_handle_t* d, input_report_t* report);
+
+input_property_map_t* input_get_device_property_map(input_host_t* host,
+        input_device_identifier_t* id);
+
+input_property_t* input_get_device_property(input_host_t* host, input_property_map_t* map,
+        const char* key);
+
+const char* input_get_property_key(input_host_t* host, input_property_t* property);
+
+const char* input_get_property_value(input_host_t* host, input_property_t* property);
+
+void input_free_device_property(input_host_t* host, input_property_t* property);
+
+void input_free_device_property_map(input_host_t* host, input_property_map_t* map);
+}
+
+} // namespace android
+#endif // ANDROID_INPUT_DRIVER_H
diff --git a/services/inputflinger/host/InputFlinger.cpp b/services/inputflinger/host/InputFlinger.cpp
new file mode 100644
index 0000000..859c3b8
--- /dev/null
+++ b/services/inputflinger/host/InputFlinger.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "InputFlinger"
+
+
+#include <stdint.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+
+#include "InputFlinger.h"
+#include "InputDriver.h"
+
+#include <binder/IPCThreadState.h>
+#include <binder/PermissionCache.h>
+#include <hardware/input.h>
+#include <cutils/log.h>
+#include <private/android_filesystem_config.h>
+
+namespace android {
+
+const String16 sAccessInputFlingerPermission("android.permission.ACCESS_INPUT_FLINGER");
+const String16 sDumpPermission("android.permission.DUMP");
+
+
+InputFlinger::InputFlinger() :
+        BnInputFlinger() {
+    ALOGI("InputFlinger is starting");
+    mHost = new InputHost();
+    mHost->registerInputDriver(new InputDriver(INPUT_INSTANCE_EVDEV));
+}
+
+InputFlinger::~InputFlinger() {
+}
+
+status_t InputFlinger::dump(int fd, const Vector<String16>& args) {
+    String8 result;
+    const IPCThreadState* ipc = IPCThreadState::self();
+    const int pid = ipc->getCallingPid();
+    const int uid = ipc->getCallingUid();
+    if ((uid != AID_SHELL)
+            && !PermissionCache::checkPermission(sDumpPermission, pid, uid)) {
+        result.appendFormat("Permission Denial: "
+                "can't dump SurfaceFlinger from pid=%d, uid=%d\n", pid, uid);
+    } else {
+        dumpInternal(result);
+    }
+    write(fd, result.string(), result.size());
+    return OK;
+}
+
+void InputFlinger::dumpInternal(String8& result) {
+    result.append("INPUT FLINGER (dumpsys inputflinger)\n");
+    mHost->dump(result);
+}
+
+}; // namespace android
diff --git a/services/inputflinger/host/InputFlinger.h b/services/inputflinger/host/InputFlinger.h
new file mode 100644
index 0000000..39e69e5
--- /dev/null
+++ b/services/inputflinger/host/InputFlinger.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_INPUT_FLINGER_H
+#define ANDROID_INPUT_FLINGER_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include "InputHost.h"
+
+#include <cutils/compiler.h>
+#include <input/IInputFlinger.h>
+#include <utils/String8.h>
+#include <utils/String16.h>
+#include <utils/StrongPointer.h>
+
+namespace android {
+
+class InputFlinger : public BnInputFlinger {
+public:
+    static char const* getServiceName() ANDROID_API {
+        return "inputflinger";
+    }
+
+    InputFlinger() ANDROID_API;
+
+    virtual status_t dump(int fd, const Vector<String16>& args);
+
+private:
+    virtual ~InputFlinger();
+
+    void dumpInternal(String8& result);
+
+    sp<InputHostInterface> mHost;
+};
+
+} // namespace android
+
+#endif // ANDROID_INPUT_FLINGER_H
diff --git a/services/inputflinger/host/InputHost.cpp b/services/inputflinger/host/InputHost.cpp
new file mode 100644
index 0000000..51d3e6b
--- /dev/null
+++ b/services/inputflinger/host/InputHost.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vector>
+
+#include "InputDriver.h"
+#include "InputHost.h"
+
+#include <utils/Log.h>
+#include <utils/String8.h>
+
+#define INDENT "  "
+
+namespace android {
+
+void InputHost::registerInputDriver(InputDriverInterface* driver) {
+    LOG_ALWAYS_FATAL_IF(driver == nullptr, "Cannot register a nullptr as an InputDriver!");
+    driver->init(this);
+    mDrivers.push_back(driver);
+}
+
+void InputHost::dump(String8& result) {
+    result.append(INDENT "Input Drivers:\n");
+    for (size_t i = 0; i < mDrivers.size(); i++) {
+        mDrivers[i]->dump(result);
+    }
+}
+
+} // namespace android
diff --git a/services/inputflinger/host/InputHost.h b/services/inputflinger/host/InputHost.h
new file mode 100644
index 0000000..42a66e0
--- /dev/null
+++ b/services/inputflinger/host/InputHost.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_INPUT_HOST_H
+#define ANDROID_INPUT_HOST_H
+
+#include <vector>
+
+#include <hardware/input.h>
+#include <utils/RefBase.h>
+#include <utils/String8.h>
+#include <utils/StrongPointer.h>
+
+#include "InputDriver.h"
+
+// Declare a concrete type for the HAL
+struct input_host {
+};
+
+namespace android {
+
+class InputDriverInterface;
+
+class InputHostInterface : public input_host_t, public virtual RefBase {
+protected:
+    InputHostInterface() = default;
+    virtual ~InputHostInterface() = default;
+
+public:
+
+    virtual void registerInputDriver(InputDriverInterface* driver) = 0;
+
+    virtual void dump(String8& result) = 0;
+};
+
+class InputHost : public InputHostInterface {
+public:
+    InputHost() = default;
+
+    virtual void registerInputDriver(InputDriverInterface* driver) override;
+
+    virtual void dump(String8& result) override;
+
+private:
+    std::vector<sp<InputDriverInterface>> mDrivers;
+};
+
+} // namespace android
+#endif // ANDRIOD_INPUT_HOST_H
diff --git a/cmds/dumpstate/libdumpstate_default.c b/services/inputflinger/host/main.cpp
similarity index 71%
copy from cmds/dumpstate/libdumpstate_default.c
copy to services/inputflinger/host/main.cpp
index fd840df..0a517cc 100644
--- a/cmds/dumpstate/libdumpstate_default.c
+++ b/services/inputflinger/host/main.cpp
@@ -14,9 +14,13 @@
  * limitations under the License.
  */
 
-#include "dumpstate.h"
+#include <binder/BinderService.h>
+#include "InputFlinger.h"
 
-void dumpstate_board(void)
-{
+using namespace android;
+
+int main(int, char**) {
+    ProcessState::self()->setThreadPoolMaxThreadCount(4);
+    BinderService<InputFlinger>::publishAndJoinThreadPool(true);
+    return 0;
 }
-
diff --git a/services/inputflinger/tests/Android.mk b/services/inputflinger/tests/Android.mk
new file mode 100644
index 0000000..4c43392
--- /dev/null
+++ b/services/inputflinger/tests/Android.mk
@@ -0,0 +1,40 @@
+# Build the unit tests.
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+# Build the unit tests.
+test_src_files := \
+    InputReader_test.cpp \
+    InputDispatcher_test.cpp
+
+shared_libraries := \
+    libcutils \
+    liblog \
+    libutils \
+    libhardware \
+    libhardware_legacy \
+    libui \
+    libskia \
+    libinput \
+    libinputflinger \
+    libinputservice
+
+c_includes := \
+    external/skia/include/core
+
+
+module_tags := tests
+
+$(foreach file,$(test_src_files), \
+    $(eval include $(CLEAR_VARS)) \
+    $(eval LOCAL_SHARED_LIBRARIES := $(shared_libraries)) \
+    $(eval LOCAL_C_INCLUDES := $(c_includes)) \
+    $(eval LOCAL_CFLAGS += -Wno-unused-parameter) \
+    $(eval LOCAL_SRC_FILES := $(file)) \
+    $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \
+    $(eval LOCAL_MODULE_TAGS := $(module_tags)) \
+    $(eval include $(BUILD_NATIVE_TEST)) \
+)
+
+# Build the manual test programs.
+include $(call all-makefiles-under, $(LOCAL_PATH))
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
new file mode 100644
index 0000000..7ae36d8
--- /dev/null
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -0,0 +1,256 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "../InputDispatcher.h"
+
+#include <gtest/gtest.h>
+#include <linux/input.h>
+
+namespace android {
+
+// An arbitrary time value.
+static const nsecs_t ARBITRARY_TIME = 1234;
+
+// An arbitrary device id.
+static const int32_t DEVICE_ID = 1;
+
+// An arbitrary display id.
+static const int32_t DISPLAY_ID = 0;
+
+// An arbitrary injector pid / uid pair that has permission to inject events.
+static const int32_t INJECTOR_PID = 999;
+static const int32_t INJECTOR_UID = 1001;
+
+
+// --- FakeInputDispatcherPolicy ---
+
+class FakeInputDispatcherPolicy : public InputDispatcherPolicyInterface {
+    InputDispatcherConfiguration mConfig;
+
+protected:
+    virtual ~FakeInputDispatcherPolicy() {
+    }
+
+public:
+    FakeInputDispatcherPolicy() {
+    }
+
+private:
+    virtual void notifyConfigurationChanged(nsecs_t) {
+    }
+
+    virtual nsecs_t notifyANR(const sp<InputApplicationHandle>&,
+            const sp<InputWindowHandle>&,
+            const String8&) {
+        return 0;
+    }
+
+    virtual void notifyInputChannelBroken(const sp<InputWindowHandle>&) {
+    }
+
+    virtual void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) {
+        *outConfig = mConfig;
+    }
+
+    virtual bool filterInputEvent(const InputEvent*, uint32_t) {
+        return true;
+    }
+
+    virtual void interceptKeyBeforeQueueing(const KeyEvent*, uint32_t&) {
+    }
+
+    virtual void interceptMotionBeforeQueueing(nsecs_t, uint32_t&) {
+    }
+
+    virtual nsecs_t interceptKeyBeforeDispatching(const sp<InputWindowHandle>&,
+            const KeyEvent*, uint32_t) {
+        return 0;
+    }
+
+    virtual bool dispatchUnhandledKey(const sp<InputWindowHandle>&,
+            const KeyEvent*, uint32_t, KeyEvent*) {
+        return false;
+    }
+
+    virtual void notifySwitch(nsecs_t, uint32_t, uint32_t, uint32_t) {
+    }
+
+    virtual void pokeUserActivity(nsecs_t, int32_t) {
+    }
+
+    virtual bool checkInjectEventsPermissionNonReentrant(int32_t, int32_t) {
+        return false;
+    }
+};
+
+
+// --- InputDispatcherTest ---
+
+class InputDispatcherTest : public testing::Test {
+protected:
+    sp<FakeInputDispatcherPolicy> mFakePolicy;
+    sp<InputDispatcher> mDispatcher;
+
+    virtual void SetUp() {
+        mFakePolicy = new FakeInputDispatcherPolicy();
+        mDispatcher = new InputDispatcher(mFakePolicy);
+    }
+
+    virtual void TearDown() {
+        mFakePolicy.clear();
+        mDispatcher.clear();
+    }
+};
+
+
+TEST_F(InputDispatcherTest, InjectInputEvent_ValidatesKeyEvents) {
+    KeyEvent event;
+
+    // Rejects undefined key actions.
+    event.initialize(DEVICE_ID, AINPUT_SOURCE_KEYBOARD,
+            /*action*/ -1, 0,
+            AKEYCODE_A, KEY_A, AMETA_NONE, 0, ARBITRARY_TIME, ARBITRARY_TIME);
+    ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
+            &event, DISPLAY_ID,
+            INJECTOR_PID, INJECTOR_UID, INPUT_EVENT_INJECTION_SYNC_NONE, 0, 0))
+            << "Should reject key events with undefined action.";
+
+    // Rejects ACTION_MULTIPLE since it is not supported despite being defined in the API.
+    event.initialize(DEVICE_ID, AINPUT_SOURCE_KEYBOARD,
+            AKEY_EVENT_ACTION_MULTIPLE, 0,
+            AKEYCODE_A, KEY_A, AMETA_NONE, 0, ARBITRARY_TIME, ARBITRARY_TIME);
+    ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
+            &event, DISPLAY_ID,
+            INJECTOR_PID, INJECTOR_UID, INPUT_EVENT_INJECTION_SYNC_NONE, 0, 0))
+            << "Should reject key events with ACTION_MULTIPLE.";
+}
+
+TEST_F(InputDispatcherTest, InjectInputEvent_ValidatesMotionEvents) {
+    MotionEvent event;
+    PointerProperties pointerProperties[MAX_POINTERS + 1];
+    PointerCoords pointerCoords[MAX_POINTERS + 1];
+    for (int i = 0; i <= MAX_POINTERS; i++) {
+        pointerProperties[i].clear();
+        pointerProperties[i].id = i;
+        pointerCoords[i].clear();
+    }
+
+    // Rejects undefined motion actions.
+    event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
+            /*action*/ -1, 0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
+            ARBITRARY_TIME, ARBITRARY_TIME,
+            /*pointerCount*/ 1, pointerProperties, pointerCoords);
+    ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
+            &event, DISPLAY_ID,
+            INJECTOR_PID, INJECTOR_UID, INPUT_EVENT_INJECTION_SYNC_NONE, 0, 0))
+            << "Should reject motion events with undefined action.";
+
+    // Rejects pointer down with invalid index.
+    event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
+            AMOTION_EVENT_ACTION_POINTER_DOWN | (1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
+            ARBITRARY_TIME, ARBITRARY_TIME,
+            /*pointerCount*/ 1, pointerProperties, pointerCoords);
+    ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
+            &event, DISPLAY_ID,
+            INJECTOR_PID, INJECTOR_UID, INPUT_EVENT_INJECTION_SYNC_NONE, 0, 0))
+            << "Should reject motion events with pointer down index too large.";
+
+    event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
+            AMOTION_EVENT_ACTION_POINTER_DOWN | (~0U << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
+            ARBITRARY_TIME, ARBITRARY_TIME,
+            /*pointerCount*/ 1, pointerProperties, pointerCoords);
+    ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
+            &event, DISPLAY_ID,
+            INJECTOR_PID, INJECTOR_UID, INPUT_EVENT_INJECTION_SYNC_NONE, 0, 0))
+            << "Should reject motion events with pointer down index too small.";
+
+    // Rejects pointer up with invalid index.
+    event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
+            AMOTION_EVENT_ACTION_POINTER_UP | (1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
+            ARBITRARY_TIME, ARBITRARY_TIME,
+            /*pointerCount*/ 1, pointerProperties, pointerCoords);
+    ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
+            &event, DISPLAY_ID,
+            INJECTOR_PID, INJECTOR_UID, INPUT_EVENT_INJECTION_SYNC_NONE, 0, 0))
+            << "Should reject motion events with pointer up index too large.";
+
+    event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
+            AMOTION_EVENT_ACTION_POINTER_UP | (~0U << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
+            ARBITRARY_TIME, ARBITRARY_TIME,
+            /*pointerCount*/ 1, pointerProperties, pointerCoords);
+    ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
+            &event, DISPLAY_ID,
+            INJECTOR_PID, INJECTOR_UID, INPUT_EVENT_INJECTION_SYNC_NONE, 0, 0))
+            << "Should reject motion events with pointer up index too small.";
+
+    // Rejects motion events with invalid number of pointers.
+    event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
+            AMOTION_EVENT_ACTION_DOWN, 0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
+            ARBITRARY_TIME, ARBITRARY_TIME,
+            /*pointerCount*/ 0, pointerProperties, pointerCoords);
+    ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
+            &event, DISPLAY_ID,
+            INJECTOR_PID, INJECTOR_UID, INPUT_EVENT_INJECTION_SYNC_NONE, 0, 0))
+            << "Should reject motion events with 0 pointers.";
+
+    event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
+            AMOTION_EVENT_ACTION_DOWN, 0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
+            ARBITRARY_TIME, ARBITRARY_TIME,
+            /*pointerCount*/ MAX_POINTERS + 1, pointerProperties, pointerCoords);
+    ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
+            &event, DISPLAY_ID,
+            INJECTOR_PID, INJECTOR_UID, INPUT_EVENT_INJECTION_SYNC_NONE, 0, 0))
+            << "Should reject motion events with more than MAX_POINTERS pointers.";
+
+    // Rejects motion events with invalid pointer ids.
+    pointerProperties[0].id = -1;
+    event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
+            AMOTION_EVENT_ACTION_DOWN, 0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
+            ARBITRARY_TIME, ARBITRARY_TIME,
+            /*pointerCount*/ 1, pointerProperties, pointerCoords);
+    ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
+            &event, DISPLAY_ID,
+            INJECTOR_PID, INJECTOR_UID, INPUT_EVENT_INJECTION_SYNC_NONE, 0, 0))
+            << "Should reject motion events with pointer ids less than 0.";
+
+    pointerProperties[0].id = MAX_POINTER_ID + 1;
+    event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
+            AMOTION_EVENT_ACTION_DOWN, 0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
+            ARBITRARY_TIME, ARBITRARY_TIME,
+            /*pointerCount*/ 1, pointerProperties, pointerCoords);
+    ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
+            &event, DISPLAY_ID,
+            INJECTOR_PID, INJECTOR_UID, INPUT_EVENT_INJECTION_SYNC_NONE, 0, 0))
+            << "Should reject motion events with pointer ids greater than MAX_POINTER_ID.";
+
+    // Rejects motion events with duplicate pointer ids.
+    pointerProperties[0].id = 1;
+    pointerProperties[1].id = 1;
+    event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
+            AMOTION_EVENT_ACTION_DOWN, 0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
+            ARBITRARY_TIME, ARBITRARY_TIME,
+            /*pointerCount*/ 2, pointerProperties, pointerCoords);
+    ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
+            &event, DISPLAY_ID,
+            INJECTOR_PID, INJECTOR_UID, INPUT_EVENT_INJECTION_SYNC_NONE, 0, 0))
+            << "Should reject motion events with duplicate pointer ids.";
+}
+
+} // namespace android
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
new file mode 100644
index 0000000..f12320d
--- /dev/null
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -0,0 +1,5161 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "../InputReader.h"
+
+#include <utils/List.h>
+#include <gtest/gtest.h>
+#include <math.h>
+
+namespace android {
+
+// An arbitrary time value.
+static const nsecs_t ARBITRARY_TIME = 1234;
+
+// Arbitrary display properties.
+static const int32_t DISPLAY_ID = 0;
+static const int32_t DISPLAY_WIDTH = 480;
+static const int32_t DISPLAY_HEIGHT = 800;
+
+// Error tolerance for floating point assertions.
+static const float EPSILON = 0.001f;
+
+template<typename T>
+static inline T min(T a, T b) {
+    return a < b ? a : b;
+}
+
+static inline float avg(float x, float y) {
+    return (x + y) / 2;
+}
+
+
+// --- FakePointerController ---
+
+class FakePointerController : public PointerControllerInterface {
+    bool mHaveBounds;
+    float mMinX, mMinY, mMaxX, mMaxY;
+    float mX, mY;
+    int32_t mButtonState;
+
+protected:
+    virtual ~FakePointerController() { }
+
+public:
+    FakePointerController() :
+        mHaveBounds(false), mMinX(0), mMinY(0), mMaxX(0), mMaxY(0), mX(0), mY(0),
+        mButtonState(0) {
+    }
+
+    void setBounds(float minX, float minY, float maxX, float maxY) {
+        mHaveBounds = true;
+        mMinX = minX;
+        mMinY = minY;
+        mMaxX = maxX;
+        mMaxY = maxY;
+    }
+
+    virtual void setPosition(float x, float y) {
+        mX = x;
+        mY = y;
+    }
+
+    virtual void setButtonState(int32_t buttonState) {
+        mButtonState = buttonState;
+    }
+
+    virtual int32_t getButtonState() const {
+        return mButtonState;
+    }
+
+    virtual void getPosition(float* outX, float* outY) const {
+        *outX = mX;
+        *outY = mY;
+    }
+
+private:
+    virtual bool getBounds(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const {
+        *outMinX = mMinX;
+        *outMinY = mMinY;
+        *outMaxX = mMaxX;
+        *outMaxY = mMaxY;
+        return mHaveBounds;
+    }
+
+    virtual void move(float deltaX, float deltaY) {
+        mX += deltaX;
+        if (mX < mMinX) mX = mMinX;
+        if (mX > mMaxX) mX = mMaxX;
+        mY += deltaY;
+        if (mY < mMinY) mY = mMinY;
+        if (mY > mMaxY) mY = mMaxY;
+    }
+
+    virtual void fade(Transition) {
+    }
+
+    virtual void unfade(Transition) {
+    }
+
+    virtual void setPresentation(Presentation) {
+    }
+
+    virtual void setSpots(const PointerCoords*, const uint32_t*, BitSet32) {
+    }
+
+    virtual void clearSpots() {
+    }
+};
+
+
+// --- FakeInputReaderPolicy ---
+
+class FakeInputReaderPolicy : public InputReaderPolicyInterface {
+    InputReaderConfiguration mConfig;
+    KeyedVector<int32_t, sp<FakePointerController> > mPointerControllers;
+    Vector<InputDeviceInfo> mInputDevices;
+    TouchAffineTransformation transform;
+
+protected:
+    virtual ~FakeInputReaderPolicy() { }
+
+public:
+    FakeInputReaderPolicy() {
+    }
+
+    void setDisplayInfo(int32_t displayId, int32_t width, int32_t height, int32_t orientation) {
+        // Set the size of both the internal and external display at the same time.
+        bool isRotated = (orientation == DISPLAY_ORIENTATION_90
+                || orientation == DISPLAY_ORIENTATION_270);
+        DisplayViewport v;
+        v.displayId = displayId;
+        v.orientation = orientation;
+        v.logicalLeft = 0;
+        v.logicalTop = 0;
+        v.logicalRight = isRotated ? height : width;
+        v.logicalBottom = isRotated ? width : height;
+        v.physicalLeft = 0;
+        v.physicalTop = 0;
+        v.physicalRight = isRotated ? height : width;
+        v.physicalBottom = isRotated ? width : height;
+        v.deviceWidth = isRotated ? height : width;
+        v.deviceHeight = isRotated ? width : height;
+        mConfig.setDisplayInfo(false /*external*/, v);
+        mConfig.setDisplayInfo(true /*external*/, v);
+    }
+
+    void addExcludedDeviceName(const String8& deviceName) {
+        mConfig.excludedDeviceNames.push(deviceName);
+    }
+
+    void setPointerController(int32_t deviceId, const sp<FakePointerController>& controller) {
+        mPointerControllers.add(deviceId, controller);
+    }
+
+    const InputReaderConfiguration* getReaderConfiguration() const {
+        return &mConfig;
+    }
+
+    const Vector<InputDeviceInfo>& getInputDevices() const {
+        return mInputDevices;
+    }
+
+    TouchAffineTransformation getTouchAffineTransformation(const String8& inputDeviceDescriptor,
+            int32_t surfaceRotation) {
+        return transform;
+    }
+
+    void setTouchAffineTransformation(const TouchAffineTransformation t) {
+        transform = t;
+    }
+
+private:
+    virtual void getReaderConfiguration(InputReaderConfiguration* outConfig) {
+        *outConfig = mConfig;
+    }
+
+    virtual sp<PointerControllerInterface> obtainPointerController(int32_t deviceId) {
+        return mPointerControllers.valueFor(deviceId);
+    }
+
+    virtual void notifyInputDevicesChanged(const Vector<InputDeviceInfo>& inputDevices) {
+        mInputDevices = inputDevices;
+    }
+
+    virtual sp<KeyCharacterMap> getKeyboardLayoutOverlay(const InputDeviceIdentifier&) {
+        return NULL;
+    }
+
+    virtual String8 getDeviceAlias(const InputDeviceIdentifier&) {
+        return String8::empty();
+    }
+};
+
+
+// --- FakeInputListener ---
+
+class FakeInputListener : public InputListenerInterface {
+private:
+    List<NotifyConfigurationChangedArgs> mNotifyConfigurationChangedArgsQueue;
+    List<NotifyDeviceResetArgs> mNotifyDeviceResetArgsQueue;
+    List<NotifyKeyArgs> mNotifyKeyArgsQueue;
+    List<NotifyMotionArgs> mNotifyMotionArgsQueue;
+    List<NotifySwitchArgs> mNotifySwitchArgsQueue;
+
+protected:
+    virtual ~FakeInputListener() { }
+
+public:
+    FakeInputListener() {
+    }
+
+    void assertNotifyConfigurationChangedWasCalled(
+            NotifyConfigurationChangedArgs* outEventArgs = NULL) {
+        ASSERT_FALSE(mNotifyConfigurationChangedArgsQueue.empty())
+                << "Expected notifyConfigurationChanged() to have been called.";
+        if (outEventArgs) {
+            *outEventArgs = *mNotifyConfigurationChangedArgsQueue.begin();
+        }
+        mNotifyConfigurationChangedArgsQueue.erase(mNotifyConfigurationChangedArgsQueue.begin());
+    }
+
+    void assertNotifyDeviceResetWasCalled(
+            NotifyDeviceResetArgs* outEventArgs = NULL) {
+        ASSERT_FALSE(mNotifyDeviceResetArgsQueue.empty())
+                << "Expected notifyDeviceReset() to have been called.";
+        if (outEventArgs) {
+            *outEventArgs = *mNotifyDeviceResetArgsQueue.begin();
+        }
+        mNotifyDeviceResetArgsQueue.erase(mNotifyDeviceResetArgsQueue.begin());
+    }
+
+    void assertNotifyKeyWasCalled(NotifyKeyArgs* outEventArgs = NULL) {
+        ASSERT_FALSE(mNotifyKeyArgsQueue.empty())
+                << "Expected notifyKey() to have been called.";
+        if (outEventArgs) {
+            *outEventArgs = *mNotifyKeyArgsQueue.begin();
+        }
+        mNotifyKeyArgsQueue.erase(mNotifyKeyArgsQueue.begin());
+    }
+
+    void assertNotifyKeyWasNotCalled() {
+        ASSERT_TRUE(mNotifyKeyArgsQueue.empty())
+                << "Expected notifyKey() to not have been called.";
+    }
+
+    void assertNotifyMotionWasCalled(NotifyMotionArgs* outEventArgs = NULL) {
+        ASSERT_FALSE(mNotifyMotionArgsQueue.empty())
+                << "Expected notifyMotion() to have been called.";
+        if (outEventArgs) {
+            *outEventArgs = *mNotifyMotionArgsQueue.begin();
+        }
+        mNotifyMotionArgsQueue.erase(mNotifyMotionArgsQueue.begin());
+    }
+
+    void assertNotifyMotionWasNotCalled() {
+        ASSERT_TRUE(mNotifyMotionArgsQueue.empty())
+                << "Expected notifyMotion() to not have been called.";
+    }
+
+    void assertNotifySwitchWasCalled(NotifySwitchArgs* outEventArgs = NULL) {
+        ASSERT_FALSE(mNotifySwitchArgsQueue.empty())
+                << "Expected notifySwitch() to have been called.";
+        if (outEventArgs) {
+            *outEventArgs = *mNotifySwitchArgsQueue.begin();
+        }
+        mNotifySwitchArgsQueue.erase(mNotifySwitchArgsQueue.begin());
+    }
+
+private:
+    virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) {
+        mNotifyConfigurationChangedArgsQueue.push_back(*args);
+    }
+
+    virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args) {
+        mNotifyDeviceResetArgsQueue.push_back(*args);
+    }
+
+    virtual void notifyKey(const NotifyKeyArgs* args) {
+        mNotifyKeyArgsQueue.push_back(*args);
+    }
+
+    virtual void notifyMotion(const NotifyMotionArgs* args) {
+        mNotifyMotionArgsQueue.push_back(*args);
+    }
+
+    virtual void notifySwitch(const NotifySwitchArgs* args) {
+        mNotifySwitchArgsQueue.push_back(*args);
+    }
+};
+
+
+// --- FakeEventHub ---
+
+class FakeEventHub : public EventHubInterface {
+    struct KeyInfo {
+        int32_t keyCode;
+        uint32_t flags;
+    };
+
+    struct Device {
+        InputDeviceIdentifier identifier;
+        uint32_t classes;
+        PropertyMap configuration;
+        KeyedVector<int, RawAbsoluteAxisInfo> absoluteAxes;
+        KeyedVector<int, bool> relativeAxes;
+        KeyedVector<int32_t, int32_t> keyCodeStates;
+        KeyedVector<int32_t, int32_t> scanCodeStates;
+        KeyedVector<int32_t, int32_t> switchStates;
+        KeyedVector<int32_t, int32_t> absoluteAxisValue;
+        KeyedVector<int32_t, KeyInfo> keysByScanCode;
+        KeyedVector<int32_t, KeyInfo> keysByUsageCode;
+        KeyedVector<int32_t, bool> leds;
+        Vector<VirtualKeyDefinition> virtualKeys;
+
+        explicit Device(uint32_t classes) :
+                classes(classes) {
+        }
+    };
+
+    KeyedVector<int32_t, Device*> mDevices;
+    Vector<String8> mExcludedDevices;
+    List<RawEvent> mEvents;
+
+protected:
+    virtual ~FakeEventHub() {
+        for (size_t i = 0; i < mDevices.size(); i++) {
+            delete mDevices.valueAt(i);
+        }
+    }
+
+public:
+    FakeEventHub() { }
+
+    void addDevice(int32_t deviceId, const String8& name, uint32_t classes) {
+        Device* device = new Device(classes);
+        device->identifier.name = name;
+        mDevices.add(deviceId, device);
+
+        enqueueEvent(ARBITRARY_TIME, deviceId, EventHubInterface::DEVICE_ADDED, 0, 0);
+    }
+
+    void removeDevice(int32_t deviceId) {
+        delete mDevices.valueFor(deviceId);
+        mDevices.removeItem(deviceId);
+
+        enqueueEvent(ARBITRARY_TIME, deviceId, EventHubInterface::DEVICE_REMOVED, 0, 0);
+    }
+
+    void finishDeviceScan() {
+        enqueueEvent(ARBITRARY_TIME, 0, EventHubInterface::FINISHED_DEVICE_SCAN, 0, 0);
+    }
+
+    void addConfigurationProperty(int32_t deviceId, const String8& key, const String8& value) {
+        Device* device = getDevice(deviceId);
+        device->configuration.addProperty(key, value);
+    }
+
+    void addConfigurationMap(int32_t deviceId, const PropertyMap* configuration) {
+        Device* device = getDevice(deviceId);
+        device->configuration.addAll(configuration);
+    }
+
+    void addAbsoluteAxis(int32_t deviceId, int axis,
+            int32_t minValue, int32_t maxValue, int flat, int fuzz, int resolution = 0) {
+        Device* device = getDevice(deviceId);
+
+        RawAbsoluteAxisInfo info;
+        info.valid = true;
+        info.minValue = minValue;
+        info.maxValue = maxValue;
+        info.flat = flat;
+        info.fuzz = fuzz;
+        info.resolution = resolution;
+        device->absoluteAxes.add(axis, info);
+    }
+
+    void addRelativeAxis(int32_t deviceId, int32_t axis) {
+        Device* device = getDevice(deviceId);
+        device->relativeAxes.add(axis, true);
+    }
+
+    void setKeyCodeState(int32_t deviceId, int32_t keyCode, int32_t state) {
+        Device* device = getDevice(deviceId);
+        device->keyCodeStates.replaceValueFor(keyCode, state);
+    }
+
+    void setScanCodeState(int32_t deviceId, int32_t scanCode, int32_t state) {
+        Device* device = getDevice(deviceId);
+        device->scanCodeStates.replaceValueFor(scanCode, state);
+    }
+
+    void setSwitchState(int32_t deviceId, int32_t switchCode, int32_t state) {
+        Device* device = getDevice(deviceId);
+        device->switchStates.replaceValueFor(switchCode, state);
+    }
+
+    void setAbsoluteAxisValue(int32_t deviceId, int32_t axis, int32_t value) {
+        Device* device = getDevice(deviceId);
+        device->absoluteAxisValue.replaceValueFor(axis, value);
+    }
+
+    void addKey(int32_t deviceId, int32_t scanCode, int32_t usageCode,
+            int32_t keyCode, uint32_t flags) {
+        Device* device = getDevice(deviceId);
+        KeyInfo info;
+        info.keyCode = keyCode;
+        info.flags = flags;
+        if (scanCode) {
+            device->keysByScanCode.add(scanCode, info);
+        }
+        if (usageCode) {
+            device->keysByUsageCode.add(usageCode, info);
+        }
+    }
+
+    void addLed(int32_t deviceId, int32_t led, bool initialState) {
+        Device* device = getDevice(deviceId);
+        device->leds.add(led, initialState);
+    }
+
+    bool getLedState(int32_t deviceId, int32_t led) {
+        Device* device = getDevice(deviceId);
+        return device->leds.valueFor(led);
+    }
+
+    Vector<String8>& getExcludedDevices() {
+        return mExcludedDevices;
+    }
+
+    void addVirtualKeyDefinition(int32_t deviceId, const VirtualKeyDefinition& definition) {
+        Device* device = getDevice(deviceId);
+        device->virtualKeys.push(definition);
+    }
+
+    void enqueueEvent(nsecs_t when, int32_t deviceId, int32_t type,
+            int32_t code, int32_t value) {
+        RawEvent event;
+        event.when = when;
+        event.deviceId = deviceId;
+        event.type = type;
+        event.code = code;
+        event.value = value;
+        mEvents.push_back(event);
+
+        if (type == EV_ABS) {
+            setAbsoluteAxisValue(deviceId, code, value);
+        }
+    }
+
+    void assertQueueIsEmpty() {
+        ASSERT_EQ(size_t(0), mEvents.size())
+                << "Expected the event queue to be empty (fully consumed).";
+    }
+
+private:
+    Device* getDevice(int32_t deviceId) const {
+        ssize_t index = mDevices.indexOfKey(deviceId);
+        return index >= 0 ? mDevices.valueAt(index) : NULL;
+    }
+
+    virtual uint32_t getDeviceClasses(int32_t deviceId) const {
+        Device* device = getDevice(deviceId);
+        return device ? device->classes : 0;
+    }
+
+    virtual InputDeviceIdentifier getDeviceIdentifier(int32_t deviceId) const {
+        Device* device = getDevice(deviceId);
+        return device ? device->identifier : InputDeviceIdentifier();
+    }
+
+    virtual int32_t getDeviceControllerNumber(int32_t) const {
+        return 0;
+    }
+
+    virtual void getConfiguration(int32_t deviceId, PropertyMap* outConfiguration) const {
+        Device* device = getDevice(deviceId);
+        if (device) {
+            *outConfiguration = device->configuration;
+        }
+    }
+
+    virtual status_t getAbsoluteAxisInfo(int32_t deviceId, int axis,
+            RawAbsoluteAxisInfo* outAxisInfo) const {
+        Device* device = getDevice(deviceId);
+        if (device) {
+            ssize_t index = device->absoluteAxes.indexOfKey(axis);
+            if (index >= 0) {
+                *outAxisInfo = device->absoluteAxes.valueAt(index);
+                return OK;
+            }
+        }
+        outAxisInfo->clear();
+        return -1;
+    }
+
+    virtual bool hasRelativeAxis(int32_t deviceId, int axis) const {
+        Device* device = getDevice(deviceId);
+        if (device) {
+            return device->relativeAxes.indexOfKey(axis) >= 0;
+        }
+        return false;
+    }
+
+    virtual bool hasInputProperty(int32_t, int) const {
+        return false;
+    }
+
+    virtual status_t mapKey(int32_t deviceId,
+            int32_t scanCode, int32_t usageCode, int32_t metaState,
+            int32_t* outKeycode, int32_t *outMetaState, uint32_t* outFlags) const {
+        Device* device = getDevice(deviceId);
+        if (device) {
+            const KeyInfo* key = getKey(device, scanCode, usageCode);
+            if (key) {
+                if (outKeycode) {
+                    *outKeycode = key->keyCode;
+                }
+                if (outFlags) {
+                    *outFlags = key->flags;
+                }
+                if (outMetaState) {
+                    *outMetaState = metaState;
+                }
+                return OK;
+            }
+        }
+        return NAME_NOT_FOUND;
+    }
+
+    const KeyInfo* getKey(Device* device, int32_t scanCode, int32_t usageCode) const {
+        if (usageCode) {
+            ssize_t index = device->keysByUsageCode.indexOfKey(usageCode);
+            if (index >= 0) {
+                return &device->keysByUsageCode.valueAt(index);
+            }
+        }
+        if (scanCode) {
+            ssize_t index = device->keysByScanCode.indexOfKey(scanCode);
+            if (index >= 0) {
+                return &device->keysByScanCode.valueAt(index);
+            }
+        }
+        return NULL;
+    }
+
+    virtual status_t mapAxis(int32_t, int32_t, AxisInfo*) const {
+        return NAME_NOT_FOUND;
+    }
+
+    virtual void setExcludedDevices(const Vector<String8>& devices) {
+        mExcludedDevices = devices;
+    }
+
+    virtual size_t getEvents(int, RawEvent* buffer, size_t) {
+        if (mEvents.empty()) {
+            return 0;
+        }
+
+        *buffer = *mEvents.begin();
+        mEvents.erase(mEvents.begin());
+        return 1;
+    }
+
+    virtual int32_t getScanCodeState(int32_t deviceId, int32_t scanCode) const {
+        Device* device = getDevice(deviceId);
+        if (device) {
+            ssize_t index = device->scanCodeStates.indexOfKey(scanCode);
+            if (index >= 0) {
+                return device->scanCodeStates.valueAt(index);
+            }
+        }
+        return AKEY_STATE_UNKNOWN;
+    }
+
+    virtual int32_t getKeyCodeState(int32_t deviceId, int32_t keyCode) const {
+        Device* device = getDevice(deviceId);
+        if (device) {
+            ssize_t index = device->keyCodeStates.indexOfKey(keyCode);
+            if (index >= 0) {
+                return device->keyCodeStates.valueAt(index);
+            }
+        }
+        return AKEY_STATE_UNKNOWN;
+    }
+
+    virtual int32_t getSwitchState(int32_t deviceId, int32_t sw) const {
+        Device* device = getDevice(deviceId);
+        if (device) {
+            ssize_t index = device->switchStates.indexOfKey(sw);
+            if (index >= 0) {
+                return device->switchStates.valueAt(index);
+            }
+        }
+        return AKEY_STATE_UNKNOWN;
+    }
+
+    virtual status_t getAbsoluteAxisValue(int32_t deviceId, int32_t axis,
+            int32_t* outValue) const {
+        Device* device = getDevice(deviceId);
+        if (device) {
+            ssize_t index = device->absoluteAxisValue.indexOfKey(axis);
+            if (index >= 0) {
+                *outValue = device->absoluteAxisValue.valueAt(index);
+                return OK;
+            }
+        }
+        *outValue = 0;
+        return -1;
+    }
+
+    virtual bool markSupportedKeyCodes(int32_t deviceId, size_t numCodes, const int32_t* keyCodes,
+            uint8_t* outFlags) const {
+        bool result = false;
+        Device* device = getDevice(deviceId);
+        if (device) {
+            for (size_t i = 0; i < numCodes; i++) {
+                for (size_t j = 0; j < device->keysByScanCode.size(); j++) {
+                    if (keyCodes[i] == device->keysByScanCode.valueAt(j).keyCode) {
+                        outFlags[i] = 1;
+                        result = true;
+                    }
+                }
+                for (size_t j = 0; j < device->keysByUsageCode.size(); j++) {
+                    if (keyCodes[i] == device->keysByUsageCode.valueAt(j).keyCode) {
+                        outFlags[i] = 1;
+                        result = true;
+                    }
+                }
+            }
+        }
+        return result;
+    }
+
+    virtual bool hasScanCode(int32_t deviceId, int32_t scanCode) const {
+        Device* device = getDevice(deviceId);
+        if (device) {
+            ssize_t index = device->keysByScanCode.indexOfKey(scanCode);
+            return index >= 0;
+        }
+        return false;
+    }
+
+    virtual bool hasLed(int32_t deviceId, int32_t led) const {
+        Device* device = getDevice(deviceId);
+        return device && device->leds.indexOfKey(led) >= 0;
+    }
+
+    virtual void setLedState(int32_t deviceId, int32_t led, bool on) {
+        Device* device = getDevice(deviceId);
+        if (device) {
+            ssize_t index = device->leds.indexOfKey(led);
+            if (index >= 0) {
+                device->leds.replaceValueAt(led, on);
+            } else {
+                ADD_FAILURE()
+                        << "Attempted to set the state of an LED that the EventHub declared "
+                        "was not present.  led=" << led;
+            }
+        }
+    }
+
+    virtual void getVirtualKeyDefinitions(int32_t deviceId,
+            Vector<VirtualKeyDefinition>& outVirtualKeys) const {
+        outVirtualKeys.clear();
+
+        Device* device = getDevice(deviceId);
+        if (device) {
+            outVirtualKeys.appendVector(device->virtualKeys);
+        }
+    }
+
+    virtual sp<KeyCharacterMap> getKeyCharacterMap(int32_t) const {
+        return NULL;
+    }
+
+    virtual bool setKeyboardLayoutOverlay(int32_t, const sp<KeyCharacterMap>&) {
+        return false;
+    }
+
+    virtual void vibrate(int32_t, nsecs_t) {
+    }
+
+    virtual void cancelVibrate(int32_t) {
+    }
+
+    virtual bool isExternal(int32_t) const {
+        return false;
+    }
+
+    virtual void dump(String8&) {
+    }
+
+    virtual void monitor() {
+    }
+
+    virtual void requestReopenDevices() {
+    }
+
+    virtual void wake() {
+    }
+};
+
+
+// --- FakeInputReaderContext ---
+
+class FakeInputReaderContext : public InputReaderContext {
+    sp<EventHubInterface> mEventHub;
+    sp<InputReaderPolicyInterface> mPolicy;
+    sp<InputListenerInterface> mListener;
+    int32_t mGlobalMetaState;
+    bool mUpdateGlobalMetaStateWasCalled;
+    int32_t mGeneration;
+
+public:
+    FakeInputReaderContext(const sp<EventHubInterface>& eventHub,
+            const sp<InputReaderPolicyInterface>& policy,
+            const sp<InputListenerInterface>& listener) :
+            mEventHub(eventHub), mPolicy(policy), mListener(listener),
+            mGlobalMetaState(0) {
+    }
+
+    virtual ~FakeInputReaderContext() { }
+
+    void assertUpdateGlobalMetaStateWasCalled() {
+        ASSERT_TRUE(mUpdateGlobalMetaStateWasCalled)
+                << "Expected updateGlobalMetaState() to have been called.";
+        mUpdateGlobalMetaStateWasCalled = false;
+    }
+
+    void setGlobalMetaState(int32_t state) {
+        mGlobalMetaState = state;
+    }
+
+private:
+    virtual void updateGlobalMetaState() {
+        mUpdateGlobalMetaStateWasCalled = true;
+    }
+
+    virtual int32_t getGlobalMetaState() {
+        return mGlobalMetaState;
+    }
+
+    virtual EventHubInterface* getEventHub() {
+        return mEventHub.get();
+    }
+
+    virtual InputReaderPolicyInterface* getPolicy() {
+        return mPolicy.get();
+    }
+
+    virtual InputListenerInterface* getListener() {
+        return mListener.get();
+    }
+
+    virtual void disableVirtualKeysUntil(nsecs_t) {
+    }
+
+    virtual bool shouldDropVirtualKey(nsecs_t, InputDevice*, int32_t, int32_t) {
+        return false;
+    }
+
+    virtual void fadePointer() {
+    }
+
+    virtual void requestTimeoutAtTime(nsecs_t) {
+    }
+
+    virtual int32_t bumpGeneration() {
+        return ++mGeneration;
+    }
+
+    virtual void getExternalStylusDevices(Vector<InputDeviceInfo>& outDevices) {
+
+    }
+
+    virtual void dispatchExternalStylusState(const StylusState&) {
+
+    }
+};
+
+
+// --- FakeInputMapper ---
+
+class FakeInputMapper : public InputMapper {
+    uint32_t mSources;
+    int32_t mKeyboardType;
+    int32_t mMetaState;
+    KeyedVector<int32_t, int32_t> mKeyCodeStates;
+    KeyedVector<int32_t, int32_t> mScanCodeStates;
+    KeyedVector<int32_t, int32_t> mSwitchStates;
+    Vector<int32_t> mSupportedKeyCodes;
+    RawEvent mLastEvent;
+
+    bool mConfigureWasCalled;
+    bool mResetWasCalled;
+    bool mProcessWasCalled;
+
+public:
+    FakeInputMapper(InputDevice* device, uint32_t sources) :
+            InputMapper(device),
+            mSources(sources), mKeyboardType(AINPUT_KEYBOARD_TYPE_NONE),
+            mMetaState(0),
+            mConfigureWasCalled(false), mResetWasCalled(false), mProcessWasCalled(false) {
+    }
+
+    virtual ~FakeInputMapper() { }
+
+    void setKeyboardType(int32_t keyboardType) {
+        mKeyboardType = keyboardType;
+    }
+
+    void setMetaState(int32_t metaState) {
+        mMetaState = metaState;
+    }
+
+    void assertConfigureWasCalled() {
+        ASSERT_TRUE(mConfigureWasCalled)
+                << "Expected configure() to have been called.";
+        mConfigureWasCalled = false;
+    }
+
+    void assertResetWasCalled() {
+        ASSERT_TRUE(mResetWasCalled)
+                << "Expected reset() to have been called.";
+        mResetWasCalled = false;
+    }
+
+    void assertProcessWasCalled(RawEvent* outLastEvent = NULL) {
+        ASSERT_TRUE(mProcessWasCalled)
+                << "Expected process() to have been called.";
+        if (outLastEvent) {
+            *outLastEvent = mLastEvent;
+        }
+        mProcessWasCalled = false;
+    }
+
+    void setKeyCodeState(int32_t keyCode, int32_t state) {
+        mKeyCodeStates.replaceValueFor(keyCode, state);
+    }
+
+    void setScanCodeState(int32_t scanCode, int32_t state) {
+        mScanCodeStates.replaceValueFor(scanCode, state);
+    }
+
+    void setSwitchState(int32_t switchCode, int32_t state) {
+        mSwitchStates.replaceValueFor(switchCode, state);
+    }
+
+    void addSupportedKeyCode(int32_t keyCode) {
+        mSupportedKeyCodes.add(keyCode);
+    }
+
+private:
+    virtual uint32_t getSources() {
+        return mSources;
+    }
+
+    virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo) {
+        InputMapper::populateDeviceInfo(deviceInfo);
+
+        if (mKeyboardType != AINPUT_KEYBOARD_TYPE_NONE) {
+            deviceInfo->setKeyboardType(mKeyboardType);
+        }
+    }
+
+    virtual void configure(nsecs_t, const InputReaderConfiguration*, uint32_t) {
+        mConfigureWasCalled = true;
+    }
+
+    virtual void reset(nsecs_t) {
+        mResetWasCalled = true;
+    }
+
+    virtual void process(const RawEvent* rawEvent) {
+        mLastEvent = *rawEvent;
+        mProcessWasCalled = true;
+    }
+
+    virtual int32_t getKeyCodeState(uint32_t, int32_t keyCode) {
+        ssize_t index = mKeyCodeStates.indexOfKey(keyCode);
+        return index >= 0 ? mKeyCodeStates.valueAt(index) : AKEY_STATE_UNKNOWN;
+    }
+
+    virtual int32_t getScanCodeState(uint32_t, int32_t scanCode) {
+        ssize_t index = mScanCodeStates.indexOfKey(scanCode);
+        return index >= 0 ? mScanCodeStates.valueAt(index) : AKEY_STATE_UNKNOWN;
+    }
+
+    virtual int32_t getSwitchState(uint32_t, int32_t switchCode) {
+        ssize_t index = mSwitchStates.indexOfKey(switchCode);
+        return index >= 0 ? mSwitchStates.valueAt(index) : AKEY_STATE_UNKNOWN;
+    }
+
+    virtual bool markSupportedKeyCodes(uint32_t, size_t numCodes,
+            const int32_t* keyCodes, uint8_t* outFlags) {
+        bool result = false;
+        for (size_t i = 0; i < numCodes; i++) {
+            for (size_t j = 0; j < mSupportedKeyCodes.size(); j++) {
+                if (keyCodes[i] == mSupportedKeyCodes[j]) {
+                    outFlags[i] = 1;
+                    result = true;
+                }
+            }
+        }
+        return result;
+    }
+
+    virtual int32_t getMetaState() {
+        return mMetaState;
+    }
+
+    virtual void fadePointer() {
+    }
+};
+
+
+// --- InstrumentedInputReader ---
+
+class InstrumentedInputReader : public InputReader {
+    InputDevice* mNextDevice;
+
+public:
+    InstrumentedInputReader(const sp<EventHubInterface>& eventHub,
+            const sp<InputReaderPolicyInterface>& policy,
+            const sp<InputListenerInterface>& listener) :
+            InputReader(eventHub, policy, listener),
+            mNextDevice(NULL) {
+    }
+
+    virtual ~InstrumentedInputReader() {
+        if (mNextDevice) {
+            delete mNextDevice;
+        }
+    }
+
+    void setNextDevice(InputDevice* device) {
+        mNextDevice = device;
+    }
+
+    InputDevice* newDevice(int32_t deviceId, int32_t controllerNumber, const String8& name,
+            uint32_t classes) {
+        InputDeviceIdentifier identifier;
+        identifier.name = name;
+        int32_t generation = deviceId + 1;
+        return new InputDevice(&mContext, deviceId, generation, controllerNumber, identifier,
+                classes);
+    }
+
+protected:
+    virtual InputDevice* createDeviceLocked(int32_t deviceId, int32_t controllerNumber,
+            const InputDeviceIdentifier& identifier, uint32_t classes) {
+        if (mNextDevice) {
+            InputDevice* device = mNextDevice;
+            mNextDevice = NULL;
+            return device;
+        }
+        return InputReader::createDeviceLocked(deviceId, controllerNumber, identifier, classes);
+    }
+
+    friend class InputReaderTest;
+};
+
+
+// --- InputReaderTest ---
+
+class InputReaderTest : public testing::Test {
+protected:
+    sp<FakeInputListener> mFakeListener;
+    sp<FakeInputReaderPolicy> mFakePolicy;
+    sp<FakeEventHub> mFakeEventHub;
+    sp<InstrumentedInputReader> mReader;
+
+    virtual void SetUp() {
+        mFakeEventHub = new FakeEventHub();
+        mFakePolicy = new FakeInputReaderPolicy();
+        mFakeListener = new FakeInputListener();
+
+        mReader = new InstrumentedInputReader(mFakeEventHub, mFakePolicy, mFakeListener);
+    }
+
+    virtual void TearDown() {
+        mReader.clear();
+
+        mFakeListener.clear();
+        mFakePolicy.clear();
+        mFakeEventHub.clear();
+    }
+
+    void addDevice(int32_t deviceId, const String8& name, uint32_t classes,
+            const PropertyMap* configuration) {
+        mFakeEventHub->addDevice(deviceId, name, classes);
+
+        if (configuration) {
+            mFakeEventHub->addConfigurationMap(deviceId, configuration);
+        }
+        mFakeEventHub->finishDeviceScan();
+        mReader->loopOnce();
+        mReader->loopOnce();
+        mFakeEventHub->assertQueueIsEmpty();
+    }
+
+    FakeInputMapper* addDeviceWithFakeInputMapper(int32_t deviceId, int32_t controllerNumber,
+            const String8& name, uint32_t classes, uint32_t sources,
+            const PropertyMap* configuration) {
+        InputDevice* device = mReader->newDevice(deviceId, controllerNumber, name, classes);
+        FakeInputMapper* mapper = new FakeInputMapper(device, sources);
+        device->addMapper(mapper);
+        mReader->setNextDevice(device);
+        addDevice(deviceId, name, classes, configuration);
+        return mapper;
+    }
+};
+
+TEST_F(InputReaderTest, GetInputDevices) {
+    ASSERT_NO_FATAL_FAILURE(addDevice(1, String8("keyboard"),
+            INPUT_DEVICE_CLASS_KEYBOARD, NULL));
+    ASSERT_NO_FATAL_FAILURE(addDevice(2, String8("ignored"),
+            0, NULL)); // no classes so device will be ignored
+
+    Vector<InputDeviceInfo> inputDevices;
+    mReader->getInputDevices(inputDevices);
+
+    ASSERT_EQ(1U, inputDevices.size());
+    ASSERT_EQ(1, inputDevices[0].getId());
+    ASSERT_STREQ("keyboard", inputDevices[0].getIdentifier().name.string());
+    ASSERT_EQ(AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC, inputDevices[0].getKeyboardType());
+    ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, inputDevices[0].getSources());
+    ASSERT_EQ(size_t(0), inputDevices[0].getMotionRanges().size());
+
+    // Should also have received a notification describing the new input devices.
+    inputDevices = mFakePolicy->getInputDevices();
+    ASSERT_EQ(1U, inputDevices.size());
+    ASSERT_EQ(1, inputDevices[0].getId());
+    ASSERT_STREQ("keyboard", inputDevices[0].getIdentifier().name.string());
+    ASSERT_EQ(AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC, inputDevices[0].getKeyboardType());
+    ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, inputDevices[0].getSources());
+    ASSERT_EQ(size_t(0), inputDevices[0].getMotionRanges().size());
+}
+
+TEST_F(InputReaderTest, GetKeyCodeState_ForwardsRequestsToMappers) {
+    FakeInputMapper* mapper = NULL;
+    ASSERT_NO_FATAL_FAILURE(mapper = addDeviceWithFakeInputMapper(1, 0, String8("fake"),
+            INPUT_DEVICE_CLASS_KEYBOARD, AINPUT_SOURCE_KEYBOARD, NULL));
+    mapper->setKeyCodeState(AKEYCODE_A, AKEY_STATE_DOWN);
+
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mReader->getKeyCodeState(0,
+            AINPUT_SOURCE_ANY, AKEYCODE_A))
+            << "Should return unknown when the device id is >= 0 but unknown.";
+
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mReader->getKeyCodeState(1,
+            AINPUT_SOURCE_TRACKBALL, AKEYCODE_A))
+            << "Should return unknown when the device id is valid but the sources are not supported by the device.";
+
+    ASSERT_EQ(AKEY_STATE_DOWN, mReader->getKeyCodeState(1,
+            AINPUT_SOURCE_KEYBOARD | AINPUT_SOURCE_TRACKBALL, AKEYCODE_A))
+            << "Should return value provided by mapper when device id is valid and the device supports some of the sources.";
+
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mReader->getKeyCodeState(-1,
+            AINPUT_SOURCE_TRACKBALL, AKEYCODE_A))
+            << "Should return unknown when the device id is < 0 but the sources are not supported by any device.";
+
+    ASSERT_EQ(AKEY_STATE_DOWN, mReader->getKeyCodeState(-1,
+            AINPUT_SOURCE_KEYBOARD | AINPUT_SOURCE_TRACKBALL, AKEYCODE_A))
+            << "Should return value provided by mapper when device id is < 0 and one of the devices supports some of the sources.";
+}
+
+TEST_F(InputReaderTest, GetScanCodeState_ForwardsRequestsToMappers) {
+    FakeInputMapper* mapper = NULL;
+    ASSERT_NO_FATAL_FAILURE(mapper = addDeviceWithFakeInputMapper(1, 0, String8("fake"),
+            INPUT_DEVICE_CLASS_KEYBOARD, AINPUT_SOURCE_KEYBOARD, NULL));
+    mapper->setScanCodeState(KEY_A, AKEY_STATE_DOWN);
+
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mReader->getScanCodeState(0,
+            AINPUT_SOURCE_ANY, KEY_A))
+            << "Should return unknown when the device id is >= 0 but unknown.";
+
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mReader->getScanCodeState(1,
+            AINPUT_SOURCE_TRACKBALL, KEY_A))
+            << "Should return unknown when the device id is valid but the sources are not supported by the device.";
+
+    ASSERT_EQ(AKEY_STATE_DOWN, mReader->getScanCodeState(1,
+            AINPUT_SOURCE_KEYBOARD | AINPUT_SOURCE_TRACKBALL, KEY_A))
+            << "Should return value provided by mapper when device id is valid and the device supports some of the sources.";
+
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mReader->getScanCodeState(-1,
+            AINPUT_SOURCE_TRACKBALL, KEY_A))
+            << "Should return unknown when the device id is < 0 but the sources are not supported by any device.";
+
+    ASSERT_EQ(AKEY_STATE_DOWN, mReader->getScanCodeState(-1,
+            AINPUT_SOURCE_KEYBOARD | AINPUT_SOURCE_TRACKBALL, KEY_A))
+            << "Should return value provided by mapper when device id is < 0 and one of the devices supports some of the sources.";
+}
+
+TEST_F(InputReaderTest, GetSwitchState_ForwardsRequestsToMappers) {
+    FakeInputMapper* mapper = NULL;
+    ASSERT_NO_FATAL_FAILURE(mapper = addDeviceWithFakeInputMapper(1, 0, String8("fake"),
+            INPUT_DEVICE_CLASS_KEYBOARD, AINPUT_SOURCE_KEYBOARD, NULL));
+    mapper->setSwitchState(SW_LID, AKEY_STATE_DOWN);
+
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mReader->getSwitchState(0,
+            AINPUT_SOURCE_ANY, SW_LID))
+            << "Should return unknown when the device id is >= 0 but unknown.";
+
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mReader->getSwitchState(1,
+            AINPUT_SOURCE_TRACKBALL, SW_LID))
+            << "Should return unknown when the device id is valid but the sources are not supported by the device.";
+
+    ASSERT_EQ(AKEY_STATE_DOWN, mReader->getSwitchState(1,
+            AINPUT_SOURCE_KEYBOARD | AINPUT_SOURCE_TRACKBALL, SW_LID))
+            << "Should return value provided by mapper when device id is valid and the device supports some of the sources.";
+
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mReader->getSwitchState(-1,
+            AINPUT_SOURCE_TRACKBALL, SW_LID))
+            << "Should return unknown when the device id is < 0 but the sources are not supported by any device.";
+
+    ASSERT_EQ(AKEY_STATE_DOWN, mReader->getSwitchState(-1,
+            AINPUT_SOURCE_KEYBOARD | AINPUT_SOURCE_TRACKBALL, SW_LID))
+            << "Should return value provided by mapper when device id is < 0 and one of the devices supports some of the sources.";
+}
+
+TEST_F(InputReaderTest, MarkSupportedKeyCodes_ForwardsRequestsToMappers) {
+    FakeInputMapper* mapper = NULL;
+    ASSERT_NO_FATAL_FAILURE(mapper = addDeviceWithFakeInputMapper(1, 0, String8("fake"),
+            INPUT_DEVICE_CLASS_KEYBOARD, AINPUT_SOURCE_KEYBOARD, NULL));
+    mapper->addSupportedKeyCode(AKEYCODE_A);
+    mapper->addSupportedKeyCode(AKEYCODE_B);
+
+    const int32_t keyCodes[4] = { AKEYCODE_A, AKEYCODE_B, AKEYCODE_1, AKEYCODE_2 };
+    uint8_t flags[4] = { 0, 0, 0, 1 };
+
+    ASSERT_FALSE(mReader->hasKeys(0, AINPUT_SOURCE_ANY, 4, keyCodes, flags))
+            << "Should return false when device id is >= 0 but unknown.";
+    ASSERT_TRUE(!flags[0] && !flags[1] && !flags[2] && !flags[3]);
+
+    flags[3] = 1;
+    ASSERT_FALSE(mReader->hasKeys(1, AINPUT_SOURCE_TRACKBALL, 4, keyCodes, flags))
+            << "Should return false when device id is valid but the sources are not supported by the device.";
+    ASSERT_TRUE(!flags[0] && !flags[1] && !flags[2] && !flags[3]);
+
+    flags[3] = 1;
+    ASSERT_TRUE(mReader->hasKeys(1, AINPUT_SOURCE_KEYBOARD | AINPUT_SOURCE_TRACKBALL, 4, keyCodes, flags))
+            << "Should return value provided by mapper when device id is valid and the device supports some of the sources.";
+    ASSERT_TRUE(flags[0] && flags[1] && !flags[2] && !flags[3]);
+
+    flags[3] = 1;
+    ASSERT_FALSE(mReader->hasKeys(-1, AINPUT_SOURCE_TRACKBALL, 4, keyCodes, flags))
+            << "Should return false when the device id is < 0 but the sources are not supported by any device.";
+    ASSERT_TRUE(!flags[0] && !flags[1] && !flags[2] && !flags[3]);
+
+    flags[3] = 1;
+    ASSERT_TRUE(mReader->hasKeys(-1, AINPUT_SOURCE_KEYBOARD | AINPUT_SOURCE_TRACKBALL, 4, keyCodes, flags))
+            << "Should return value provided by mapper when device id is < 0 and one of the devices supports some of the sources.";
+    ASSERT_TRUE(flags[0] && flags[1] && !flags[2] && !flags[3]);
+}
+
+TEST_F(InputReaderTest, LoopOnce_WhenDeviceScanFinished_SendsConfigurationChanged) {
+    addDevice(1, String8("ignored"), INPUT_DEVICE_CLASS_KEYBOARD, NULL);
+
+    NotifyConfigurationChangedArgs args;
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyConfigurationChangedWasCalled(&args));
+    ASSERT_EQ(ARBITRARY_TIME, args.eventTime);
+}
+
+TEST_F(InputReaderTest, LoopOnce_ForwardsRawEventsToMappers) {
+    FakeInputMapper* mapper = NULL;
+    ASSERT_NO_FATAL_FAILURE(mapper = addDeviceWithFakeInputMapper(1, 0, String8("fake"),
+            INPUT_DEVICE_CLASS_KEYBOARD, AINPUT_SOURCE_KEYBOARD, NULL));
+
+    mFakeEventHub->enqueueEvent(0, 1, EV_KEY, KEY_A, 1);
+    mReader->loopOnce();
+    ASSERT_NO_FATAL_FAILURE(mFakeEventHub->assertQueueIsEmpty());
+
+    RawEvent event;
+    ASSERT_NO_FATAL_FAILURE(mapper->assertProcessWasCalled(&event));
+    ASSERT_EQ(0, event.when);
+    ASSERT_EQ(1, event.deviceId);
+    ASSERT_EQ(EV_KEY, event.type);
+    ASSERT_EQ(KEY_A, event.code);
+    ASSERT_EQ(1, event.value);
+}
+
+
+// --- InputDeviceTest ---
+
+class InputDeviceTest : public testing::Test {
+protected:
+    static const char* DEVICE_NAME;
+    static const int32_t DEVICE_ID;
+    static const int32_t DEVICE_GENERATION;
+    static const int32_t DEVICE_CONTROLLER_NUMBER;
+    static const uint32_t DEVICE_CLASSES;
+
+    sp<FakeEventHub> mFakeEventHub;
+    sp<FakeInputReaderPolicy> mFakePolicy;
+    sp<FakeInputListener> mFakeListener;
+    FakeInputReaderContext* mFakeContext;
+
+    InputDevice* mDevice;
+
+    virtual void SetUp() {
+        mFakeEventHub = new FakeEventHub();
+        mFakePolicy = new FakeInputReaderPolicy();
+        mFakeListener = new FakeInputListener();
+        mFakeContext = new FakeInputReaderContext(mFakeEventHub, mFakePolicy, mFakeListener);
+
+        mFakeEventHub->addDevice(DEVICE_ID, String8(DEVICE_NAME), 0);
+        InputDeviceIdentifier identifier;
+        identifier.name = DEVICE_NAME;
+        mDevice = new InputDevice(mFakeContext, DEVICE_ID, DEVICE_GENERATION,
+                DEVICE_CONTROLLER_NUMBER, identifier, DEVICE_CLASSES);
+    }
+
+    virtual void TearDown() {
+        delete mDevice;
+
+        delete mFakeContext;
+        mFakeListener.clear();
+        mFakePolicy.clear();
+        mFakeEventHub.clear();
+    }
+};
+
+const char* InputDeviceTest::DEVICE_NAME = "device";
+const int32_t InputDeviceTest::DEVICE_ID = 1;
+const int32_t InputDeviceTest::DEVICE_GENERATION = 2;
+const int32_t InputDeviceTest::DEVICE_CONTROLLER_NUMBER = 0;
+const uint32_t InputDeviceTest::DEVICE_CLASSES = INPUT_DEVICE_CLASS_KEYBOARD
+        | INPUT_DEVICE_CLASS_TOUCH | INPUT_DEVICE_CLASS_JOYSTICK;
+
+TEST_F(InputDeviceTest, ImmutableProperties) {
+    ASSERT_EQ(DEVICE_ID, mDevice->getId());
+    ASSERT_STREQ(DEVICE_NAME, mDevice->getName());
+    ASSERT_EQ(DEVICE_CLASSES, mDevice->getClasses());
+}
+
+TEST_F(InputDeviceTest, WhenNoMappersAreRegistered_DeviceIsIgnored) {
+    // Configuration.
+    InputReaderConfiguration config;
+    mDevice->configure(ARBITRARY_TIME, &config, 0);
+
+    // Reset.
+    mDevice->reset(ARBITRARY_TIME);
+
+    NotifyDeviceResetArgs resetArgs;
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs));
+    ASSERT_EQ(ARBITRARY_TIME, resetArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, resetArgs.deviceId);
+
+    // Metadata.
+    ASSERT_TRUE(mDevice->isIgnored());
+    ASSERT_EQ(AINPUT_SOURCE_UNKNOWN, mDevice->getSources());
+
+    InputDeviceInfo info;
+    mDevice->getDeviceInfo(&info);
+    ASSERT_EQ(DEVICE_ID, info.getId());
+    ASSERT_STREQ(DEVICE_NAME, info.getIdentifier().name.string());
+    ASSERT_EQ(AINPUT_KEYBOARD_TYPE_NONE, info.getKeyboardType());
+    ASSERT_EQ(AINPUT_SOURCE_UNKNOWN, info.getSources());
+
+    // State queries.
+    ASSERT_EQ(0, mDevice->getMetaState());
+
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mDevice->getKeyCodeState(AINPUT_SOURCE_KEYBOARD, 0))
+            << "Ignored device should return unknown key code state.";
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mDevice->getScanCodeState(AINPUT_SOURCE_KEYBOARD, 0))
+            << "Ignored device should return unknown scan code state.";
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mDevice->getSwitchState(AINPUT_SOURCE_KEYBOARD, 0))
+            << "Ignored device should return unknown switch state.";
+
+    const int32_t keyCodes[2] = { AKEYCODE_A, AKEYCODE_B };
+    uint8_t flags[2] = { 0, 1 };
+    ASSERT_FALSE(mDevice->markSupportedKeyCodes(AINPUT_SOURCE_KEYBOARD, 2, keyCodes, flags))
+            << "Ignored device should never mark any key codes.";
+    ASSERT_EQ(0, flags[0]) << "Flag for unsupported key should be unchanged.";
+    ASSERT_EQ(1, flags[1]) << "Flag for unsupported key should be unchanged.";
+}
+
+TEST_F(InputDeviceTest, WhenMappersAreRegistered_DeviceIsNotIgnoredAndForwardsRequestsToMappers) {
+    // Configuration.
+    mFakeEventHub->addConfigurationProperty(DEVICE_ID, String8("key"), String8("value"));
+
+    FakeInputMapper* mapper1 = new FakeInputMapper(mDevice, AINPUT_SOURCE_KEYBOARD);
+    mapper1->setKeyboardType(AINPUT_KEYBOARD_TYPE_ALPHABETIC);
+    mapper1->setMetaState(AMETA_ALT_ON);
+    mapper1->addSupportedKeyCode(AKEYCODE_A);
+    mapper1->addSupportedKeyCode(AKEYCODE_B);
+    mapper1->setKeyCodeState(AKEYCODE_A, AKEY_STATE_DOWN);
+    mapper1->setKeyCodeState(AKEYCODE_B, AKEY_STATE_UP);
+    mapper1->setScanCodeState(2, AKEY_STATE_DOWN);
+    mapper1->setScanCodeState(3, AKEY_STATE_UP);
+    mapper1->setSwitchState(4, AKEY_STATE_DOWN);
+    mDevice->addMapper(mapper1);
+
+    FakeInputMapper* mapper2 = new FakeInputMapper(mDevice, AINPUT_SOURCE_TOUCHSCREEN);
+    mapper2->setMetaState(AMETA_SHIFT_ON);
+    mDevice->addMapper(mapper2);
+
+    InputReaderConfiguration config;
+    mDevice->configure(ARBITRARY_TIME, &config, 0);
+
+    String8 propertyValue;
+    ASSERT_TRUE(mDevice->getConfiguration().tryGetProperty(String8("key"), propertyValue))
+            << "Device should have read configuration during configuration phase.";
+    ASSERT_STREQ("value", propertyValue.string());
+
+    ASSERT_NO_FATAL_FAILURE(mapper1->assertConfigureWasCalled());
+    ASSERT_NO_FATAL_FAILURE(mapper2->assertConfigureWasCalled());
+
+    // Reset
+    mDevice->reset(ARBITRARY_TIME);
+    ASSERT_NO_FATAL_FAILURE(mapper1->assertResetWasCalled());
+    ASSERT_NO_FATAL_FAILURE(mapper2->assertResetWasCalled());
+
+    NotifyDeviceResetArgs resetArgs;
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs));
+    ASSERT_EQ(ARBITRARY_TIME, resetArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, resetArgs.deviceId);
+
+    // Metadata.
+    ASSERT_FALSE(mDevice->isIgnored());
+    ASSERT_EQ(uint32_t(AINPUT_SOURCE_KEYBOARD | AINPUT_SOURCE_TOUCHSCREEN), mDevice->getSources());
+
+    InputDeviceInfo info;
+    mDevice->getDeviceInfo(&info);
+    ASSERT_EQ(DEVICE_ID, info.getId());
+    ASSERT_STREQ(DEVICE_NAME, info.getIdentifier().name.string());
+    ASSERT_EQ(AINPUT_KEYBOARD_TYPE_ALPHABETIC, info.getKeyboardType());
+    ASSERT_EQ(uint32_t(AINPUT_SOURCE_KEYBOARD | AINPUT_SOURCE_TOUCHSCREEN), info.getSources());
+
+    // State queries.
+    ASSERT_EQ(AMETA_ALT_ON | AMETA_SHIFT_ON, mDevice->getMetaState())
+            << "Should query mappers and combine meta states.";
+
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mDevice->getKeyCodeState(AINPUT_SOURCE_TRACKBALL, AKEYCODE_A))
+            << "Should return unknown key code state when source not supported.";
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mDevice->getScanCodeState(AINPUT_SOURCE_TRACKBALL, AKEYCODE_A))
+            << "Should return unknown scan code state when source not supported.";
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mDevice->getSwitchState(AINPUT_SOURCE_TRACKBALL, AKEYCODE_A))
+            << "Should return unknown switch state when source not supported.";
+
+    ASSERT_EQ(AKEY_STATE_DOWN, mDevice->getKeyCodeState(AINPUT_SOURCE_KEYBOARD, AKEYCODE_A))
+            << "Should query mapper when source is supported.";
+    ASSERT_EQ(AKEY_STATE_UP, mDevice->getScanCodeState(AINPUT_SOURCE_KEYBOARD, 3))
+            << "Should query mapper when source is supported.";
+    ASSERT_EQ(AKEY_STATE_DOWN, mDevice->getSwitchState(AINPUT_SOURCE_KEYBOARD, 4))
+            << "Should query mapper when source is supported.";
+
+    const int32_t keyCodes[4] = { AKEYCODE_A, AKEYCODE_B, AKEYCODE_1, AKEYCODE_2 };
+    uint8_t flags[4] = { 0, 0, 0, 1 };
+    ASSERT_FALSE(mDevice->markSupportedKeyCodes(AINPUT_SOURCE_TRACKBALL, 4, keyCodes, flags))
+            << "Should do nothing when source is unsupported.";
+    ASSERT_EQ(0, flags[0]) << "Flag should be unchanged when source is unsupported.";
+    ASSERT_EQ(0, flags[1]) << "Flag should be unchanged when source is unsupported.";
+    ASSERT_EQ(0, flags[2]) << "Flag should be unchanged when source is unsupported.";
+    ASSERT_EQ(1, flags[3]) << "Flag should be unchanged when source is unsupported.";
+
+    ASSERT_TRUE(mDevice->markSupportedKeyCodes(AINPUT_SOURCE_KEYBOARD, 4, keyCodes, flags))
+            << "Should query mapper when source is supported.";
+    ASSERT_EQ(1, flags[0]) << "Flag for supported key should be set.";
+    ASSERT_EQ(1, flags[1]) << "Flag for supported key should be set.";
+    ASSERT_EQ(0, flags[2]) << "Flag for unsupported key should be unchanged.";
+    ASSERT_EQ(1, flags[3]) << "Flag for unsupported key should be unchanged.";
+
+    // Event handling.
+    RawEvent event;
+    mDevice->process(&event, 1);
+
+    ASSERT_NO_FATAL_FAILURE(mapper1->assertProcessWasCalled());
+    ASSERT_NO_FATAL_FAILURE(mapper2->assertProcessWasCalled());
+}
+
+
+// --- InputMapperTest ---
+
+class InputMapperTest : public testing::Test {
+protected:
+    static const char* DEVICE_NAME;
+    static const int32_t DEVICE_ID;
+    static const int32_t DEVICE_GENERATION;
+    static const int32_t DEVICE_CONTROLLER_NUMBER;
+    static const uint32_t DEVICE_CLASSES;
+
+    sp<FakeEventHub> mFakeEventHub;
+    sp<FakeInputReaderPolicy> mFakePolicy;
+    sp<FakeInputListener> mFakeListener;
+    FakeInputReaderContext* mFakeContext;
+    InputDevice* mDevice;
+
+    virtual void SetUp() {
+        mFakeEventHub = new FakeEventHub();
+        mFakePolicy = new FakeInputReaderPolicy();
+        mFakeListener = new FakeInputListener();
+        mFakeContext = new FakeInputReaderContext(mFakeEventHub, mFakePolicy, mFakeListener);
+        InputDeviceIdentifier identifier;
+        identifier.name = DEVICE_NAME;
+        mDevice = new InputDevice(mFakeContext, DEVICE_ID, DEVICE_GENERATION,
+                DEVICE_CONTROLLER_NUMBER, identifier, DEVICE_CLASSES);
+
+        mFakeEventHub->addDevice(DEVICE_ID, String8(DEVICE_NAME), 0);
+    }
+
+    virtual void TearDown() {
+        delete mDevice;
+        delete mFakeContext;
+        mFakeListener.clear();
+        mFakePolicy.clear();
+        mFakeEventHub.clear();
+    }
+
+    void addConfigurationProperty(const char* key, const char* value) {
+        mFakeEventHub->addConfigurationProperty(DEVICE_ID, String8(key), String8(value));
+    }
+
+    void addMapperAndConfigure(InputMapper* mapper) {
+        mDevice->addMapper(mapper);
+        mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(), 0);
+        mDevice->reset(ARBITRARY_TIME);
+    }
+
+    void setDisplayInfoAndReconfigure(int32_t displayId, int32_t width, int32_t height,
+            int32_t orientation) {
+        mFakePolicy->setDisplayInfo(displayId, width, height, orientation);
+        mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
+                InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+    }
+
+    static void process(InputMapper* mapper, nsecs_t when, int32_t deviceId, int32_t type,
+            int32_t code, int32_t value) {
+        RawEvent event;
+        event.when = when;
+        event.deviceId = deviceId;
+        event.type = type;
+        event.code = code;
+        event.value = value;
+        mapper->process(&event);
+    }
+
+    static void assertMotionRange(const InputDeviceInfo& info,
+            int32_t axis, uint32_t source, float min, float max, float flat, float fuzz) {
+        const InputDeviceInfo::MotionRange* range = info.getMotionRange(axis, source);
+        ASSERT_TRUE(range != NULL) << "Axis: " << axis << " Source: " << source;
+        ASSERT_EQ(axis, range->axis) << "Axis: " << axis << " Source: " << source;
+        ASSERT_EQ(source, range->source) << "Axis: " << axis << " Source: " << source;
+        ASSERT_NEAR(min, range->min, EPSILON) << "Axis: " << axis << " Source: " << source;
+        ASSERT_NEAR(max, range->max, EPSILON) << "Axis: " << axis << " Source: " << source;
+        ASSERT_NEAR(flat, range->flat, EPSILON) << "Axis: " << axis << " Source: " << source;
+        ASSERT_NEAR(fuzz, range->fuzz, EPSILON) << "Axis: " << axis << " Source: " << source;
+    }
+
+    static void assertPointerCoords(const PointerCoords& coords,
+            float x, float y, float pressure, float size,
+            float touchMajor, float touchMinor, float toolMajor, float toolMinor,
+            float orientation, float distance) {
+        ASSERT_NEAR(x, coords.getAxisValue(AMOTION_EVENT_AXIS_X), 1);
+        ASSERT_NEAR(y, coords.getAxisValue(AMOTION_EVENT_AXIS_Y), 1);
+        ASSERT_NEAR(pressure, coords.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE), EPSILON);
+        ASSERT_NEAR(size, coords.getAxisValue(AMOTION_EVENT_AXIS_SIZE), EPSILON);
+        ASSERT_NEAR(touchMajor, coords.getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR), 1);
+        ASSERT_NEAR(touchMinor, coords.getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR), 1);
+        ASSERT_NEAR(toolMajor, coords.getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR), 1);
+        ASSERT_NEAR(toolMinor, coords.getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR), 1);
+        ASSERT_NEAR(orientation, coords.getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION), EPSILON);
+        ASSERT_NEAR(distance, coords.getAxisValue(AMOTION_EVENT_AXIS_DISTANCE), EPSILON);
+    }
+
+    static void assertPosition(const sp<FakePointerController>& controller, float x, float y) {
+        float actualX, actualY;
+        controller->getPosition(&actualX, &actualY);
+        ASSERT_NEAR(x, actualX, 1);
+        ASSERT_NEAR(y, actualY, 1);
+    }
+};
+
+const char* InputMapperTest::DEVICE_NAME = "device";
+const int32_t InputMapperTest::DEVICE_ID = 1;
+const int32_t InputMapperTest::DEVICE_GENERATION = 2;
+const int32_t InputMapperTest::DEVICE_CONTROLLER_NUMBER = 0;
+const uint32_t InputMapperTest::DEVICE_CLASSES = 0; // not needed for current tests
+
+
+// --- SwitchInputMapperTest ---
+
+class SwitchInputMapperTest : public InputMapperTest {
+protected:
+};
+
+TEST_F(SwitchInputMapperTest, GetSources) {
+    SwitchInputMapper* mapper = new SwitchInputMapper(mDevice);
+    addMapperAndConfigure(mapper);
+
+    ASSERT_EQ(uint32_t(AINPUT_SOURCE_SWITCH), mapper->getSources());
+}
+
+TEST_F(SwitchInputMapperTest, GetSwitchState) {
+    SwitchInputMapper* mapper = new SwitchInputMapper(mDevice);
+    addMapperAndConfigure(mapper);
+
+    mFakeEventHub->setSwitchState(DEVICE_ID, SW_LID, 1);
+    ASSERT_EQ(1, mapper->getSwitchState(AINPUT_SOURCE_ANY, SW_LID));
+
+    mFakeEventHub->setSwitchState(DEVICE_ID, SW_LID, 0);
+    ASSERT_EQ(0, mapper->getSwitchState(AINPUT_SOURCE_ANY, SW_LID));
+}
+
+TEST_F(SwitchInputMapperTest, Process) {
+    SwitchInputMapper* mapper = new SwitchInputMapper(mDevice);
+    addMapperAndConfigure(mapper);
+
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SW, SW_LID, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SW, SW_JACK_PHYSICAL_INSERT, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SW, SW_HEADPHONE_INSERT, 0);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+
+    NotifySwitchArgs args;
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifySwitchWasCalled(&args));
+    ASSERT_EQ(ARBITRARY_TIME, args.eventTime);
+    ASSERT_EQ((1U << SW_LID) | (1U << SW_JACK_PHYSICAL_INSERT), args.switchValues);
+    ASSERT_EQ((1U << SW_LID) | (1U << SW_JACK_PHYSICAL_INSERT) | (1 << SW_HEADPHONE_INSERT),
+            args.switchMask);
+    ASSERT_EQ(uint32_t(0), args.policyFlags);
+}
+
+
+// --- KeyboardInputMapperTest ---
+
+class KeyboardInputMapperTest : public InputMapperTest {
+protected:
+    void testDPadKeyRotation(KeyboardInputMapper* mapper,
+            int32_t originalScanCode, int32_t originalKeyCode, int32_t rotatedKeyCode);
+};
+
+void KeyboardInputMapperTest::testDPadKeyRotation(KeyboardInputMapper* mapper,
+        int32_t originalScanCode, int32_t, int32_t rotatedKeyCode) {
+    NotifyKeyArgs args;
+
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, originalScanCode, 1);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, args.action);
+    ASSERT_EQ(originalScanCode, args.scanCode);
+    ASSERT_EQ(rotatedKeyCode, args.keyCode);
+
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, originalScanCode, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, args.action);
+    ASSERT_EQ(originalScanCode, args.scanCode);
+    ASSERT_EQ(rotatedKeyCode, args.keyCode);
+}
+
+
+TEST_F(KeyboardInputMapperTest, GetSources) {
+    KeyboardInputMapper* mapper = new KeyboardInputMapper(mDevice,
+            AINPUT_SOURCE_KEYBOARD, AINPUT_KEYBOARD_TYPE_ALPHABETIC);
+    addMapperAndConfigure(mapper);
+
+    ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, mapper->getSources());
+}
+
+TEST_F(KeyboardInputMapperTest, Process_SimpleKeyPress) {
+    const int32_t USAGE_A = 0x070004;
+    const int32_t USAGE_UNKNOWN = 0x07ffff;
+    mFakeEventHub->addKey(DEVICE_ID, KEY_HOME, 0, AKEYCODE_HOME, POLICY_FLAG_WAKE);
+    mFakeEventHub->addKey(DEVICE_ID, 0, USAGE_A, AKEYCODE_A, POLICY_FLAG_WAKE);
+
+    KeyboardInputMapper* mapper = new KeyboardInputMapper(mDevice,
+            AINPUT_SOURCE_KEYBOARD, AINPUT_KEYBOARD_TYPE_ALPHABETIC);
+    addMapperAndConfigure(mapper);
+
+    // Key down by scan code.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_KEY, KEY_HOME, 1);
+    NotifyKeyArgs args;
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
+    ASSERT_EQ(DEVICE_ID, args.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, args.source);
+    ASSERT_EQ(ARBITRARY_TIME, args.eventTime);
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, args.action);
+    ASSERT_EQ(AKEYCODE_HOME, args.keyCode);
+    ASSERT_EQ(KEY_HOME, args.scanCode);
+    ASSERT_EQ(AMETA_NONE, args.metaState);
+    ASSERT_EQ(AKEY_EVENT_FLAG_FROM_SYSTEM, args.flags);
+    ASSERT_EQ(POLICY_FLAG_WAKE, args.policyFlags);
+    ASSERT_EQ(ARBITRARY_TIME, args.downTime);
+
+    // Key up by scan code.
+    process(mapper, ARBITRARY_TIME + 1, DEVICE_ID,
+            EV_KEY, KEY_HOME, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
+    ASSERT_EQ(DEVICE_ID, args.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, args.source);
+    ASSERT_EQ(ARBITRARY_TIME + 1, args.eventTime);
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, args.action);
+    ASSERT_EQ(AKEYCODE_HOME, args.keyCode);
+    ASSERT_EQ(KEY_HOME, args.scanCode);
+    ASSERT_EQ(AMETA_NONE, args.metaState);
+    ASSERT_EQ(AKEY_EVENT_FLAG_FROM_SYSTEM, args.flags);
+    ASSERT_EQ(POLICY_FLAG_WAKE, args.policyFlags);
+    ASSERT_EQ(ARBITRARY_TIME, args.downTime);
+
+    // Key down by usage code.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_MSC, MSC_SCAN, USAGE_A);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_KEY, 0, 1);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
+    ASSERT_EQ(DEVICE_ID, args.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, args.source);
+    ASSERT_EQ(ARBITRARY_TIME, args.eventTime);
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, args.action);
+    ASSERT_EQ(AKEYCODE_A, args.keyCode);
+    ASSERT_EQ(0, args.scanCode);
+    ASSERT_EQ(AMETA_NONE, args.metaState);
+    ASSERT_EQ(AKEY_EVENT_FLAG_FROM_SYSTEM, args.flags);
+    ASSERT_EQ(POLICY_FLAG_WAKE, args.policyFlags);
+    ASSERT_EQ(ARBITRARY_TIME, args.downTime);
+
+    // Key up by usage code.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_MSC, MSC_SCAN, USAGE_A);
+    process(mapper, ARBITRARY_TIME + 1, DEVICE_ID,
+            EV_KEY, 0, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
+    ASSERT_EQ(DEVICE_ID, args.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, args.source);
+    ASSERT_EQ(ARBITRARY_TIME + 1, args.eventTime);
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, args.action);
+    ASSERT_EQ(AKEYCODE_A, args.keyCode);
+    ASSERT_EQ(0, args.scanCode);
+    ASSERT_EQ(AMETA_NONE, args.metaState);
+    ASSERT_EQ(AKEY_EVENT_FLAG_FROM_SYSTEM, args.flags);
+    ASSERT_EQ(POLICY_FLAG_WAKE, args.policyFlags);
+    ASSERT_EQ(ARBITRARY_TIME, args.downTime);
+
+    // Key down with unknown scan code or usage code.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_MSC, MSC_SCAN, USAGE_UNKNOWN);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_KEY, KEY_UNKNOWN, 1);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
+    ASSERT_EQ(DEVICE_ID, args.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, args.source);
+    ASSERT_EQ(ARBITRARY_TIME, args.eventTime);
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, args.action);
+    ASSERT_EQ(0, args.keyCode);
+    ASSERT_EQ(KEY_UNKNOWN, args.scanCode);
+    ASSERT_EQ(AMETA_NONE, args.metaState);
+    ASSERT_EQ(AKEY_EVENT_FLAG_FROM_SYSTEM, args.flags);
+    ASSERT_EQ(0U, args.policyFlags);
+    ASSERT_EQ(ARBITRARY_TIME, args.downTime);
+
+    // Key up with unknown scan code or usage code.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_MSC, MSC_SCAN, USAGE_UNKNOWN);
+    process(mapper, ARBITRARY_TIME + 1, DEVICE_ID,
+            EV_KEY, KEY_UNKNOWN, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
+    ASSERT_EQ(DEVICE_ID, args.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, args.source);
+    ASSERT_EQ(ARBITRARY_TIME + 1, args.eventTime);
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, args.action);
+    ASSERT_EQ(0, args.keyCode);
+    ASSERT_EQ(KEY_UNKNOWN, args.scanCode);
+    ASSERT_EQ(AMETA_NONE, args.metaState);
+    ASSERT_EQ(AKEY_EVENT_FLAG_FROM_SYSTEM, args.flags);
+    ASSERT_EQ(0U, args.policyFlags);
+    ASSERT_EQ(ARBITRARY_TIME, args.downTime);
+}
+
+TEST_F(KeyboardInputMapperTest, Process_ShouldUpdateMetaState) {
+    mFakeEventHub->addKey(DEVICE_ID, KEY_LEFTSHIFT, 0, AKEYCODE_SHIFT_LEFT, 0);
+    mFakeEventHub->addKey(DEVICE_ID, KEY_A, 0, AKEYCODE_A, 0);
+
+    KeyboardInputMapper* mapper = new KeyboardInputMapper(mDevice,
+            AINPUT_SOURCE_KEYBOARD, AINPUT_KEYBOARD_TYPE_ALPHABETIC);
+    addMapperAndConfigure(mapper);
+
+    // Initial metastate.
+    ASSERT_EQ(AMETA_NONE, mapper->getMetaState());
+
+    // Metakey down.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_KEY, KEY_LEFTSHIFT, 1);
+    NotifyKeyArgs args;
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, args.metaState);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, mapper->getMetaState());
+    ASSERT_NO_FATAL_FAILURE(mFakeContext->assertUpdateGlobalMetaStateWasCalled());
+
+    // Key down.
+    process(mapper, ARBITRARY_TIME + 1, DEVICE_ID,
+            EV_KEY, KEY_A, 1);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, args.metaState);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, mapper->getMetaState());
+
+    // Key up.
+    process(mapper, ARBITRARY_TIME + 2, DEVICE_ID,
+            EV_KEY, KEY_A, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, args.metaState);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, mapper->getMetaState());
+
+    // Metakey up.
+    process(mapper, ARBITRARY_TIME + 3, DEVICE_ID,
+            EV_KEY, KEY_LEFTSHIFT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
+    ASSERT_EQ(AMETA_NONE, args.metaState);
+    ASSERT_EQ(AMETA_NONE, mapper->getMetaState());
+    ASSERT_NO_FATAL_FAILURE(mFakeContext->assertUpdateGlobalMetaStateWasCalled());
+}
+
+TEST_F(KeyboardInputMapperTest, Process_WhenNotOrientationAware_ShouldNotRotateDPad) {
+    mFakeEventHub->addKey(DEVICE_ID, KEY_UP, 0, AKEYCODE_DPAD_UP, 0);
+    mFakeEventHub->addKey(DEVICE_ID, KEY_RIGHT, 0, AKEYCODE_DPAD_RIGHT, 0);
+    mFakeEventHub->addKey(DEVICE_ID, KEY_DOWN, 0, AKEYCODE_DPAD_DOWN, 0);
+    mFakeEventHub->addKey(DEVICE_ID, KEY_LEFT, 0, AKEYCODE_DPAD_LEFT, 0);
+
+    KeyboardInputMapper* mapper = new KeyboardInputMapper(mDevice,
+            AINPUT_SOURCE_KEYBOARD, AINPUT_KEYBOARD_TYPE_ALPHABETIC);
+    addMapperAndConfigure(mapper);
+
+    setDisplayInfoAndReconfigure(DISPLAY_ID,
+            DISPLAY_WIDTH, DISPLAY_HEIGHT,
+            DISPLAY_ORIENTATION_90);
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_UP, AKEYCODE_DPAD_UP, AKEYCODE_DPAD_UP));
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_RIGHT, AKEYCODE_DPAD_RIGHT, AKEYCODE_DPAD_RIGHT));
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_DOWN, AKEYCODE_DPAD_DOWN, AKEYCODE_DPAD_DOWN));
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_LEFT, AKEYCODE_DPAD_LEFT, AKEYCODE_DPAD_LEFT));
+}
+
+TEST_F(KeyboardInputMapperTest, Process_WhenOrientationAware_ShouldRotateDPad) {
+    mFakeEventHub->addKey(DEVICE_ID, KEY_UP, 0, AKEYCODE_DPAD_UP, 0);
+    mFakeEventHub->addKey(DEVICE_ID, KEY_RIGHT, 0, AKEYCODE_DPAD_RIGHT, 0);
+    mFakeEventHub->addKey(DEVICE_ID, KEY_DOWN, 0, AKEYCODE_DPAD_DOWN, 0);
+    mFakeEventHub->addKey(DEVICE_ID, KEY_LEFT, 0, AKEYCODE_DPAD_LEFT, 0);
+
+    KeyboardInputMapper* mapper = new KeyboardInputMapper(mDevice,
+            AINPUT_SOURCE_KEYBOARD, AINPUT_KEYBOARD_TYPE_ALPHABETIC);
+    addConfigurationProperty("keyboard.orientationAware", "1");
+    addMapperAndConfigure(mapper);
+
+    setDisplayInfoAndReconfigure(DISPLAY_ID,
+            DISPLAY_WIDTH, DISPLAY_HEIGHT,
+            DISPLAY_ORIENTATION_0);
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_UP, AKEYCODE_DPAD_UP, AKEYCODE_DPAD_UP));
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_RIGHT, AKEYCODE_DPAD_RIGHT, AKEYCODE_DPAD_RIGHT));
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_DOWN, AKEYCODE_DPAD_DOWN, AKEYCODE_DPAD_DOWN));
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_LEFT, AKEYCODE_DPAD_LEFT, AKEYCODE_DPAD_LEFT));
+
+    setDisplayInfoAndReconfigure(DISPLAY_ID,
+            DISPLAY_WIDTH, DISPLAY_HEIGHT,
+            DISPLAY_ORIENTATION_90);
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_UP, AKEYCODE_DPAD_UP, AKEYCODE_DPAD_LEFT));
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_RIGHT, AKEYCODE_DPAD_RIGHT, AKEYCODE_DPAD_UP));
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_DOWN, AKEYCODE_DPAD_DOWN, AKEYCODE_DPAD_RIGHT));
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_LEFT, AKEYCODE_DPAD_LEFT, AKEYCODE_DPAD_DOWN));
+
+    setDisplayInfoAndReconfigure(DISPLAY_ID,
+            DISPLAY_WIDTH, DISPLAY_HEIGHT,
+            DISPLAY_ORIENTATION_180);
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_UP, AKEYCODE_DPAD_UP, AKEYCODE_DPAD_DOWN));
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_RIGHT, AKEYCODE_DPAD_RIGHT, AKEYCODE_DPAD_LEFT));
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_DOWN, AKEYCODE_DPAD_DOWN, AKEYCODE_DPAD_UP));
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_LEFT, AKEYCODE_DPAD_LEFT, AKEYCODE_DPAD_RIGHT));
+
+    setDisplayInfoAndReconfigure(DISPLAY_ID,
+            DISPLAY_WIDTH, DISPLAY_HEIGHT,
+            DISPLAY_ORIENTATION_270);
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_UP, AKEYCODE_DPAD_UP, AKEYCODE_DPAD_RIGHT));
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_RIGHT, AKEYCODE_DPAD_RIGHT, AKEYCODE_DPAD_DOWN));
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_DOWN, AKEYCODE_DPAD_DOWN, AKEYCODE_DPAD_LEFT));
+    ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
+            KEY_LEFT, AKEYCODE_DPAD_LEFT, AKEYCODE_DPAD_UP));
+
+    // Special case: if orientation changes while key is down, we still emit the same keycode
+    // in the key up as we did in the key down.
+    NotifyKeyArgs args;
+
+    setDisplayInfoAndReconfigure(DISPLAY_ID,
+            DISPLAY_WIDTH, DISPLAY_HEIGHT,
+            DISPLAY_ORIENTATION_270);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, KEY_UP, 1);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, args.action);
+    ASSERT_EQ(KEY_UP, args.scanCode);
+    ASSERT_EQ(AKEYCODE_DPAD_RIGHT, args.keyCode);
+
+    setDisplayInfoAndReconfigure(DISPLAY_ID,
+            DISPLAY_WIDTH, DISPLAY_HEIGHT,
+            DISPLAY_ORIENTATION_180);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, KEY_UP, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, args.action);
+    ASSERT_EQ(KEY_UP, args.scanCode);
+    ASSERT_EQ(AKEYCODE_DPAD_RIGHT, args.keyCode);
+}
+
+TEST_F(KeyboardInputMapperTest, GetKeyCodeState) {
+    KeyboardInputMapper* mapper = new KeyboardInputMapper(mDevice,
+            AINPUT_SOURCE_KEYBOARD, AINPUT_KEYBOARD_TYPE_ALPHABETIC);
+    addMapperAndConfigure(mapper);
+
+    mFakeEventHub->setKeyCodeState(DEVICE_ID, AKEYCODE_A, 1);
+    ASSERT_EQ(1, mapper->getKeyCodeState(AINPUT_SOURCE_ANY, AKEYCODE_A));
+
+    mFakeEventHub->setKeyCodeState(DEVICE_ID, AKEYCODE_A, 0);
+    ASSERT_EQ(0, mapper->getKeyCodeState(AINPUT_SOURCE_ANY, AKEYCODE_A));
+}
+
+TEST_F(KeyboardInputMapperTest, GetScanCodeState) {
+    KeyboardInputMapper* mapper = new KeyboardInputMapper(mDevice,
+            AINPUT_SOURCE_KEYBOARD, AINPUT_KEYBOARD_TYPE_ALPHABETIC);
+    addMapperAndConfigure(mapper);
+
+    mFakeEventHub->setScanCodeState(DEVICE_ID, KEY_A, 1);
+    ASSERT_EQ(1, mapper->getScanCodeState(AINPUT_SOURCE_ANY, KEY_A));
+
+    mFakeEventHub->setScanCodeState(DEVICE_ID, KEY_A, 0);
+    ASSERT_EQ(0, mapper->getScanCodeState(AINPUT_SOURCE_ANY, KEY_A));
+}
+
+TEST_F(KeyboardInputMapperTest, MarkSupportedKeyCodes) {
+    KeyboardInputMapper* mapper = new KeyboardInputMapper(mDevice,
+            AINPUT_SOURCE_KEYBOARD, AINPUT_KEYBOARD_TYPE_ALPHABETIC);
+    addMapperAndConfigure(mapper);
+
+    mFakeEventHub->addKey(DEVICE_ID, KEY_A, 0, AKEYCODE_A, 0);
+
+    const int32_t keyCodes[2] = { AKEYCODE_A, AKEYCODE_B };
+    uint8_t flags[2] = { 0, 0 };
+    ASSERT_TRUE(mapper->markSupportedKeyCodes(AINPUT_SOURCE_ANY, 1, keyCodes, flags));
+    ASSERT_TRUE(flags[0]);
+    ASSERT_FALSE(flags[1]);
+}
+
+TEST_F(KeyboardInputMapperTest, Process_LockedKeysShouldToggleMetaStateAndLeds) {
+    mFakeEventHub->addLed(DEVICE_ID, LED_CAPSL, true /*initially on*/);
+    mFakeEventHub->addLed(DEVICE_ID, LED_NUML, false /*initially off*/);
+    mFakeEventHub->addLed(DEVICE_ID, LED_SCROLLL, false /*initially off*/);
+    mFakeEventHub->addKey(DEVICE_ID, KEY_CAPSLOCK, 0, AKEYCODE_CAPS_LOCK, 0);
+    mFakeEventHub->addKey(DEVICE_ID, KEY_NUMLOCK, 0, AKEYCODE_NUM_LOCK, 0);
+    mFakeEventHub->addKey(DEVICE_ID, KEY_SCROLLLOCK, 0, AKEYCODE_SCROLL_LOCK, 0);
+
+    KeyboardInputMapper* mapper = new KeyboardInputMapper(mDevice,
+            AINPUT_SOURCE_KEYBOARD, AINPUT_KEYBOARD_TYPE_ALPHABETIC);
+    addMapperAndConfigure(mapper);
+
+    // Initialization should have turned all of the lights off.
+    ASSERT_FALSE(mFakeEventHub->getLedState(DEVICE_ID, LED_CAPSL));
+    ASSERT_FALSE(mFakeEventHub->getLedState(DEVICE_ID, LED_NUML));
+    ASSERT_FALSE(mFakeEventHub->getLedState(DEVICE_ID, LED_SCROLLL));
+
+    // Toggle caps lock on.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_KEY, KEY_CAPSLOCK, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_KEY, KEY_CAPSLOCK, 0);
+    ASSERT_TRUE(mFakeEventHub->getLedState(DEVICE_ID, LED_CAPSL));
+    ASSERT_FALSE(mFakeEventHub->getLedState(DEVICE_ID, LED_NUML));
+    ASSERT_FALSE(mFakeEventHub->getLedState(DEVICE_ID, LED_SCROLLL));
+    ASSERT_EQ(AMETA_CAPS_LOCK_ON, mapper->getMetaState());
+
+    // Toggle num lock on.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_KEY, KEY_NUMLOCK, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_KEY, KEY_NUMLOCK, 0);
+    ASSERT_TRUE(mFakeEventHub->getLedState(DEVICE_ID, LED_CAPSL));
+    ASSERT_TRUE(mFakeEventHub->getLedState(DEVICE_ID, LED_NUML));
+    ASSERT_FALSE(mFakeEventHub->getLedState(DEVICE_ID, LED_SCROLLL));
+    ASSERT_EQ(AMETA_CAPS_LOCK_ON | AMETA_NUM_LOCK_ON, mapper->getMetaState());
+
+    // Toggle caps lock off.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_KEY, KEY_CAPSLOCK, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_KEY, KEY_CAPSLOCK, 0);
+    ASSERT_FALSE(mFakeEventHub->getLedState(DEVICE_ID, LED_CAPSL));
+    ASSERT_TRUE(mFakeEventHub->getLedState(DEVICE_ID, LED_NUML));
+    ASSERT_FALSE(mFakeEventHub->getLedState(DEVICE_ID, LED_SCROLLL));
+    ASSERT_EQ(AMETA_NUM_LOCK_ON, mapper->getMetaState());
+
+    // Toggle scroll lock on.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_KEY, KEY_SCROLLLOCK, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_KEY, KEY_SCROLLLOCK, 0);
+    ASSERT_FALSE(mFakeEventHub->getLedState(DEVICE_ID, LED_CAPSL));
+    ASSERT_TRUE(mFakeEventHub->getLedState(DEVICE_ID, LED_NUML));
+    ASSERT_TRUE(mFakeEventHub->getLedState(DEVICE_ID, LED_SCROLLL));
+    ASSERT_EQ(AMETA_NUM_LOCK_ON | AMETA_SCROLL_LOCK_ON, mapper->getMetaState());
+
+    // Toggle num lock off.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_KEY, KEY_NUMLOCK, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_KEY, KEY_NUMLOCK, 0);
+    ASSERT_FALSE(mFakeEventHub->getLedState(DEVICE_ID, LED_CAPSL));
+    ASSERT_FALSE(mFakeEventHub->getLedState(DEVICE_ID, LED_NUML));
+    ASSERT_TRUE(mFakeEventHub->getLedState(DEVICE_ID, LED_SCROLLL));
+    ASSERT_EQ(AMETA_SCROLL_LOCK_ON, mapper->getMetaState());
+
+    // Toggle scroll lock off.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_KEY, KEY_SCROLLLOCK, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID,
+            EV_KEY, KEY_SCROLLLOCK, 0);
+    ASSERT_FALSE(mFakeEventHub->getLedState(DEVICE_ID, LED_CAPSL));
+    ASSERT_FALSE(mFakeEventHub->getLedState(DEVICE_ID, LED_NUML));
+    ASSERT_FALSE(mFakeEventHub->getLedState(DEVICE_ID, LED_SCROLLL));
+    ASSERT_EQ(AMETA_NONE, mapper->getMetaState());
+}
+
+
+// --- CursorInputMapperTest ---
+
+class CursorInputMapperTest : public InputMapperTest {
+protected:
+    static const int32_t TRACKBALL_MOVEMENT_THRESHOLD;
+
+    sp<FakePointerController> mFakePointerController;
+
+    virtual void SetUp() {
+        InputMapperTest::SetUp();
+
+        mFakePointerController = new FakePointerController();
+        mFakePolicy->setPointerController(DEVICE_ID, mFakePointerController);
+    }
+
+    void testMotionRotation(CursorInputMapper* mapper,
+            int32_t originalX, int32_t originalY, int32_t rotatedX, int32_t rotatedY);
+};
+
+const int32_t CursorInputMapperTest::TRACKBALL_MOVEMENT_THRESHOLD = 6;
+
+void CursorInputMapperTest::testMotionRotation(CursorInputMapper* mapper,
+        int32_t originalX, int32_t originalY, int32_t rotatedX, int32_t rotatedY) {
+    NotifyMotionArgs args;
+
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_REL, REL_X, originalX);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_REL, REL_Y, originalY);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, args.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            float(rotatedX) / TRACKBALL_MOVEMENT_THRESHOLD,
+            float(rotatedY) / TRACKBALL_MOVEMENT_THRESHOLD,
+            0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+}
+
+TEST_F(CursorInputMapperTest, WhenModeIsPointer_GetSources_ReturnsMouse) {
+    CursorInputMapper* mapper = new CursorInputMapper(mDevice);
+    addConfigurationProperty("cursor.mode", "pointer");
+    addMapperAndConfigure(mapper);
+
+    ASSERT_EQ(AINPUT_SOURCE_MOUSE, mapper->getSources());
+}
+
+TEST_F(CursorInputMapperTest, WhenModeIsNavigation_GetSources_ReturnsTrackball) {
+    CursorInputMapper* mapper = new CursorInputMapper(mDevice);
+    addConfigurationProperty("cursor.mode", "navigation");
+    addMapperAndConfigure(mapper);
+
+    ASSERT_EQ(AINPUT_SOURCE_TRACKBALL, mapper->getSources());
+}
+
+TEST_F(CursorInputMapperTest, WhenModeIsPointer_PopulateDeviceInfo_ReturnsRangeFromPointerController) {
+    CursorInputMapper* mapper = new CursorInputMapper(mDevice);
+    addConfigurationProperty("cursor.mode", "pointer");
+    addMapperAndConfigure(mapper);
+
+    InputDeviceInfo info;
+    mapper->populateDeviceInfo(&info);
+
+    // Initially there may not be a valid motion range.
+    ASSERT_EQ(NULL, info.getMotionRange(AINPUT_MOTION_RANGE_X, AINPUT_SOURCE_MOUSE));
+    ASSERT_EQ(NULL, info.getMotionRange(AINPUT_MOTION_RANGE_Y, AINPUT_SOURCE_MOUSE));
+    ASSERT_NO_FATAL_FAILURE(assertMotionRange(info,
+            AINPUT_MOTION_RANGE_PRESSURE, AINPUT_SOURCE_MOUSE, 0.0f, 1.0f, 0.0f, 0.0f));
+
+    // When the bounds are set, then there should be a valid motion range.
+    mFakePointerController->setBounds(1, 2, 800 - 1, 480 - 1);
+
+    InputDeviceInfo info2;
+    mapper->populateDeviceInfo(&info2);
+
+    ASSERT_NO_FATAL_FAILURE(assertMotionRange(info2,
+            AINPUT_MOTION_RANGE_X, AINPUT_SOURCE_MOUSE,
+            1, 800 - 1, 0.0f, 0.0f));
+    ASSERT_NO_FATAL_FAILURE(assertMotionRange(info2,
+            AINPUT_MOTION_RANGE_Y, AINPUT_SOURCE_MOUSE,
+            2, 480 - 1, 0.0f, 0.0f));
+    ASSERT_NO_FATAL_FAILURE(assertMotionRange(info2,
+            AINPUT_MOTION_RANGE_PRESSURE, AINPUT_SOURCE_MOUSE,
+            0.0f, 1.0f, 0.0f, 0.0f));
+}
+
+TEST_F(CursorInputMapperTest, WhenModeIsNavigation_PopulateDeviceInfo_ReturnsScaledRange) {
+    CursorInputMapper* mapper = new CursorInputMapper(mDevice);
+    addConfigurationProperty("cursor.mode", "navigation");
+    addMapperAndConfigure(mapper);
+
+    InputDeviceInfo info;
+    mapper->populateDeviceInfo(&info);
+
+    ASSERT_NO_FATAL_FAILURE(assertMotionRange(info,
+            AINPUT_MOTION_RANGE_X, AINPUT_SOURCE_TRACKBALL,
+            -1.0f, 1.0f, 0.0f, 1.0f / TRACKBALL_MOVEMENT_THRESHOLD));
+    ASSERT_NO_FATAL_FAILURE(assertMotionRange(info,
+            AINPUT_MOTION_RANGE_Y, AINPUT_SOURCE_TRACKBALL,
+            -1.0f, 1.0f, 0.0f, 1.0f / TRACKBALL_MOVEMENT_THRESHOLD));
+    ASSERT_NO_FATAL_FAILURE(assertMotionRange(info,
+            AINPUT_MOTION_RANGE_PRESSURE, AINPUT_SOURCE_TRACKBALL,
+            0.0f, 1.0f, 0.0f, 0.0f));
+}
+
+TEST_F(CursorInputMapperTest, Process_ShouldSetAllFieldsAndIncludeGlobalMetaState) {
+    CursorInputMapper* mapper = new CursorInputMapper(mDevice);
+    addConfigurationProperty("cursor.mode", "navigation");
+    addMapperAndConfigure(mapper);
+
+    mFakeContext->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
+
+    NotifyMotionArgs args;
+
+    // Button press.
+    // Mostly testing non x/y behavior here so we don't need to check again elsewhere.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MOUSE, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_EQ(ARBITRARY_TIME, args.eventTime);
+    ASSERT_EQ(DEVICE_ID, args.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TRACKBALL, args.source);
+    ASSERT_EQ(uint32_t(0), args.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, args.action);
+    ASSERT_EQ(0, args.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, args.metaState);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_PRIMARY, args.buttonState);
+    ASSERT_EQ(0, args.edgeFlags);
+    ASSERT_EQ(uint32_t(1), args.pointerCount);
+    ASSERT_EQ(0, args.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, args.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+    ASSERT_EQ(TRACKBALL_MOVEMENT_THRESHOLD, args.xPrecision);
+    ASSERT_EQ(TRACKBALL_MOVEMENT_THRESHOLD, args.yPrecision);
+    ASSERT_EQ(ARBITRARY_TIME, args.downTime);
+
+    // Button release.  Should have same down time.
+    process(mapper, ARBITRARY_TIME + 1, DEVICE_ID, EV_KEY, BTN_MOUSE, 0);
+    process(mapper, ARBITRARY_TIME + 1, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_EQ(ARBITRARY_TIME + 1, args.eventTime);
+    ASSERT_EQ(DEVICE_ID, args.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TRACKBALL, args.source);
+    ASSERT_EQ(uint32_t(0), args.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, args.action);
+    ASSERT_EQ(0, args.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, args.metaState);
+    ASSERT_EQ(0, args.buttonState);
+    ASSERT_EQ(0, args.edgeFlags);
+    ASSERT_EQ(uint32_t(1), args.pointerCount);
+    ASSERT_EQ(0, args.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, args.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+    ASSERT_EQ(TRACKBALL_MOVEMENT_THRESHOLD, args.xPrecision);
+    ASSERT_EQ(TRACKBALL_MOVEMENT_THRESHOLD, args.yPrecision);
+    ASSERT_EQ(ARBITRARY_TIME, args.downTime);
+}
+
+TEST_F(CursorInputMapperTest, Process_ShouldHandleIndependentXYUpdates) {
+    CursorInputMapper* mapper = new CursorInputMapper(mDevice);
+    addConfigurationProperty("cursor.mode", "navigation");
+    addMapperAndConfigure(mapper);
+
+    NotifyMotionArgs args;
+
+    // Motion in X but not Y.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_REL, REL_X, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, args.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            1.0f / TRACKBALL_MOVEMENT_THRESHOLD, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+    // Motion in Y but not X.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_REL, REL_Y, -2);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, args.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            0.0f, -2.0f / TRACKBALL_MOVEMENT_THRESHOLD, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+}
+
+TEST_F(CursorInputMapperTest, Process_ShouldHandleIndependentButtonUpdates) {
+    CursorInputMapper* mapper = new CursorInputMapper(mDevice);
+    addConfigurationProperty("cursor.mode", "navigation");
+    addMapperAndConfigure(mapper);
+
+    NotifyMotionArgs args;
+
+    // Button press.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MOUSE, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, args.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+    // Button release.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MOUSE, 0);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, args.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+}
+
+TEST_F(CursorInputMapperTest, Process_ShouldHandleCombinedXYAndButtonUpdates) {
+    CursorInputMapper* mapper = new CursorInputMapper(mDevice);
+    addConfigurationProperty("cursor.mode", "navigation");
+    addMapperAndConfigure(mapper);
+
+    NotifyMotionArgs args;
+
+    // Combined X, Y and Button.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_REL, REL_X, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_REL, REL_Y, -2);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MOUSE, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, args.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            1.0f / TRACKBALL_MOVEMENT_THRESHOLD, -2.0f / TRACKBALL_MOVEMENT_THRESHOLD,
+            1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+    // Move X, Y a bit while pressed.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_REL, REL_X, 2);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_REL, REL_Y, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, args.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            2.0f / TRACKBALL_MOVEMENT_THRESHOLD, 1.0f / TRACKBALL_MOVEMENT_THRESHOLD,
+            1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+    // Release Button.
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MOUSE, 0);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, args.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+}
+
+TEST_F(CursorInputMapperTest, Process_WhenNotOrientationAware_ShouldNotRotateMotions) {
+    CursorInputMapper* mapper = new CursorInputMapper(mDevice);
+    addConfigurationProperty("cursor.mode", "navigation");
+    addMapperAndConfigure(mapper);
+
+    setDisplayInfoAndReconfigure(DISPLAY_ID,
+            DISPLAY_WIDTH, DISPLAY_HEIGHT,
+            DISPLAY_ORIENTATION_90);
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  0,  1,  0,  1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  1,  1,  1,  1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  1,  0,  1,  0));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  1, -1,  1, -1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  0, -1,  0, -1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1, -1, -1, -1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1,  0, -1,  0));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1,  1, -1,  1));
+}
+
+TEST_F(CursorInputMapperTest, Process_WhenOrientationAware_ShouldRotateMotions) {
+    CursorInputMapper* mapper = new CursorInputMapper(mDevice);
+    addConfigurationProperty("cursor.mode", "navigation");
+    addConfigurationProperty("cursor.orientationAware", "1");
+    addMapperAndConfigure(mapper);
+
+    setDisplayInfoAndReconfigure(DISPLAY_ID,
+            DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_0);
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  0,  1,  0,  1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  1,  1,  1,  1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  1,  0,  1,  0));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  1, -1,  1, -1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  0, -1,  0, -1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1, -1, -1, -1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1,  0, -1,  0));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1,  1, -1,  1));
+
+    setDisplayInfoAndReconfigure(DISPLAY_ID,
+            DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_90);
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  0,  1,  1,  0));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  1,  1,  1, -1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  1,  0,  0, -1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  1, -1, -1, -1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  0, -1, -1,  0));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1, -1, -1,  1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1,  0,  0,  1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1,  1,  1,  1));
+
+    setDisplayInfoAndReconfigure(DISPLAY_ID,
+            DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_180);
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  0,  1,  0, -1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  1,  1, -1, -1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  1,  0, -1,  0));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  1, -1, -1,  1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  0, -1,  0,  1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1, -1,  1,  1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1,  0,  1,  0));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1,  1,  1, -1));
+
+    setDisplayInfoAndReconfigure(DISPLAY_ID,
+            DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_270);
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  0,  1, -1,  0));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  1,  1, -1,  1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  1,  0,  0,  1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  1, -1,  1,  1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper,  0, -1,  1,  0));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1, -1,  1, -1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1,  0,  0, -1));
+    ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1,  1, -1, -1));
+}
+
+TEST_F(CursorInputMapperTest, Process_ShouldHandleAllButtons) {
+    CursorInputMapper* mapper = new CursorInputMapper(mDevice);
+    addConfigurationProperty("cursor.mode", "pointer");
+    addMapperAndConfigure(mapper);
+
+    mFakePointerController->setBounds(0, 0, 800 - 1, 480 - 1);
+    mFakePointerController->setPosition(100, 200);
+    mFakePointerController->setButtonState(0);
+
+    NotifyMotionArgs motionArgs;
+    NotifyKeyArgs keyArgs;
+
+    // press BTN_LEFT, release BTN_LEFT
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_LEFT, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_PRIMARY, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_PRIMARY, mFakePointerController->getButtonState());
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            100.0f, 200.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_LEFT, 0);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, mFakePointerController->getButtonState());
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            100.0f, 200.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, mFakePointerController->getButtonState());
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            100.0f, 200.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+    // press BTN_RIGHT + BTN_MIDDLE, release BTN_RIGHT, release BTN_MIDDLE
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_RIGHT, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MIDDLE, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_SECONDARY | AMOTION_EVENT_BUTTON_TERTIARY,
+            motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_SECONDARY | AMOTION_EVENT_BUTTON_TERTIARY,
+            mFakePointerController->getButtonState());
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            100.0f, 200.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_RIGHT, 0);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_TERTIARY, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_TERTIARY, mFakePointerController->getButtonState());
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            100.0f, 200.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MIDDLE, 0);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, mFakePointerController->getButtonState());
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            100.0f, 200.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, mFakePointerController->getButtonState());
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            100.0f, 200.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+    // press BTN_BACK, release BTN_BACK
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_BACK, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_BACK, keyArgs.keyCode);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_BACK, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_BACK, mFakePointerController->getButtonState());
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            100.0f, 200.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_BACK, 0);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, mFakePointerController->getButtonState());
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            100.0f, 200.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_BACK, keyArgs.keyCode);
+
+    // press BTN_SIDE, release BTN_SIDE
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_SIDE, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_BACK, keyArgs.keyCode);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_BACK, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_BACK, mFakePointerController->getButtonState());
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            100.0f, 200.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_SIDE, 0);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, mFakePointerController->getButtonState());
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            100.0f, 200.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_BACK, keyArgs.keyCode);
+
+    // press BTN_FORWARD, release BTN_FORWARD
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_FORWARD, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_FORWARD, keyArgs.keyCode);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_FORWARD, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_FORWARD, mFakePointerController->getButtonState());
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            100.0f, 200.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_FORWARD, 0);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, mFakePointerController->getButtonState());
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            100.0f, 200.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_FORWARD, keyArgs.keyCode);
+
+    // press BTN_EXTRA, release BTN_EXTRA
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_EXTRA, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_FORWARD, keyArgs.keyCode);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_FORWARD, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_FORWARD, mFakePointerController->getButtonState());
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            100.0f, 200.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_EXTRA, 0);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, mFakePointerController->getButtonState());
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            100.0f, 200.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_FORWARD, keyArgs.keyCode);
+}
+
+TEST_F(CursorInputMapperTest, Process_WhenModeIsPointer_ShouldMoveThePointerAround) {
+    CursorInputMapper* mapper = new CursorInputMapper(mDevice);
+    addConfigurationProperty("cursor.mode", "pointer");
+    addMapperAndConfigure(mapper);
+
+    mFakePointerController->setBounds(0, 0, 800 - 1, 480 - 1);
+    mFakePointerController->setPosition(100, 200);
+    mFakePointerController->setButtonState(0);
+
+    NotifyMotionArgs args;
+
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_REL, REL_X, 10);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_REL, REL_Y, 20);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, args.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            110.0f, 220.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+    ASSERT_NO_FATAL_FAILURE(assertPosition(mFakePointerController, 110.0f, 220.0f));
+}
+
+
+// --- TouchInputMapperTest ---
+
+class TouchInputMapperTest : public InputMapperTest {
+protected:
+    static const int32_t RAW_X_MIN;
+    static const int32_t RAW_X_MAX;
+    static const int32_t RAW_Y_MIN;
+    static const int32_t RAW_Y_MAX;
+    static const int32_t RAW_TOUCH_MIN;
+    static const int32_t RAW_TOUCH_MAX;
+    static const int32_t RAW_TOOL_MIN;
+    static const int32_t RAW_TOOL_MAX;
+    static const int32_t RAW_PRESSURE_MIN;
+    static const int32_t RAW_PRESSURE_MAX;
+    static const int32_t RAW_ORIENTATION_MIN;
+    static const int32_t RAW_ORIENTATION_MAX;
+    static const int32_t RAW_DISTANCE_MIN;
+    static const int32_t RAW_DISTANCE_MAX;
+    static const int32_t RAW_TILT_MIN;
+    static const int32_t RAW_TILT_MAX;
+    static const int32_t RAW_ID_MIN;
+    static const int32_t RAW_ID_MAX;
+    static const int32_t RAW_SLOT_MIN;
+    static const int32_t RAW_SLOT_MAX;
+    static const float X_PRECISION;
+    static const float Y_PRECISION;
+
+    static const float GEOMETRIC_SCALE;
+    static const TouchAffineTransformation AFFINE_TRANSFORM;
+
+    static const VirtualKeyDefinition VIRTUAL_KEYS[2];
+
+    enum Axes {
+        POSITION = 1 << 0,
+        TOUCH = 1 << 1,
+        TOOL = 1 << 2,
+        PRESSURE = 1 << 3,
+        ORIENTATION = 1 << 4,
+        MINOR = 1 << 5,
+        ID = 1 << 6,
+        DISTANCE = 1 << 7,
+        TILT = 1 << 8,
+        SLOT = 1 << 9,
+        TOOL_TYPE = 1 << 10,
+    };
+
+    void prepareDisplay(int32_t orientation);
+    void prepareVirtualKeys();
+    void prepareLocationCalibration();
+    int32_t toRawX(float displayX);
+    int32_t toRawY(float displayY);
+    float toCookedX(float rawX, float rawY);
+    float toCookedY(float rawX, float rawY);
+    float toDisplayX(int32_t rawX);
+    float toDisplayY(int32_t rawY);
+};
+
+const int32_t TouchInputMapperTest::RAW_X_MIN = 25;
+const int32_t TouchInputMapperTest::RAW_X_MAX = 1019;
+const int32_t TouchInputMapperTest::RAW_Y_MIN = 30;
+const int32_t TouchInputMapperTest::RAW_Y_MAX = 1009;
+const int32_t TouchInputMapperTest::RAW_TOUCH_MIN = 0;
+const int32_t TouchInputMapperTest::RAW_TOUCH_MAX = 31;
+const int32_t TouchInputMapperTest::RAW_TOOL_MIN = 0;
+const int32_t TouchInputMapperTest::RAW_TOOL_MAX = 15;
+const int32_t TouchInputMapperTest::RAW_PRESSURE_MIN = RAW_TOUCH_MIN;
+const int32_t TouchInputMapperTest::RAW_PRESSURE_MAX = RAW_TOUCH_MAX;
+const int32_t TouchInputMapperTest::RAW_ORIENTATION_MIN = -7;
+const int32_t TouchInputMapperTest::RAW_ORIENTATION_MAX = 7;
+const int32_t TouchInputMapperTest::RAW_DISTANCE_MIN = 0;
+const int32_t TouchInputMapperTest::RAW_DISTANCE_MAX = 7;
+const int32_t TouchInputMapperTest::RAW_TILT_MIN = 0;
+const int32_t TouchInputMapperTest::RAW_TILT_MAX = 150;
+const int32_t TouchInputMapperTest::RAW_ID_MIN = 0;
+const int32_t TouchInputMapperTest::RAW_ID_MAX = 9;
+const int32_t TouchInputMapperTest::RAW_SLOT_MIN = 0;
+const int32_t TouchInputMapperTest::RAW_SLOT_MAX = 9;
+const float TouchInputMapperTest::X_PRECISION = float(RAW_X_MAX - RAW_X_MIN + 1) / DISPLAY_WIDTH;
+const float TouchInputMapperTest::Y_PRECISION = float(RAW_Y_MAX - RAW_Y_MIN + 1) / DISPLAY_HEIGHT;
+const TouchAffineTransformation TouchInputMapperTest::AFFINE_TRANSFORM =
+        TouchAffineTransformation(1, -2, 3, -4, 5, -6);
+
+const float TouchInputMapperTest::GEOMETRIC_SCALE =
+        avg(float(DISPLAY_WIDTH) / (RAW_X_MAX - RAW_X_MIN + 1),
+                float(DISPLAY_HEIGHT) / (RAW_Y_MAX - RAW_Y_MIN + 1));
+
+const VirtualKeyDefinition TouchInputMapperTest::VIRTUAL_KEYS[2] = {
+        { KEY_HOME, 60, DISPLAY_HEIGHT + 15, 20, 20 },
+        { KEY_MENU, DISPLAY_HEIGHT - 60, DISPLAY_WIDTH + 15, 20, 20 },
+};
+
+void TouchInputMapperTest::prepareDisplay(int32_t orientation) {
+    setDisplayInfoAndReconfigure(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, orientation);
+}
+
+void TouchInputMapperTest::prepareVirtualKeys() {
+    mFakeEventHub->addVirtualKeyDefinition(DEVICE_ID, VIRTUAL_KEYS[0]);
+    mFakeEventHub->addVirtualKeyDefinition(DEVICE_ID, VIRTUAL_KEYS[1]);
+    mFakeEventHub->addKey(DEVICE_ID, KEY_HOME, 0, AKEYCODE_HOME, POLICY_FLAG_WAKE);
+    mFakeEventHub->addKey(DEVICE_ID, KEY_MENU, 0, AKEYCODE_MENU, POLICY_FLAG_WAKE);
+}
+
+void TouchInputMapperTest::prepareLocationCalibration() {
+    mFakePolicy->setTouchAffineTransformation(AFFINE_TRANSFORM);
+}
+
+int32_t TouchInputMapperTest::toRawX(float displayX) {
+    return int32_t(displayX * (RAW_X_MAX - RAW_X_MIN + 1) / DISPLAY_WIDTH + RAW_X_MIN);
+}
+
+int32_t TouchInputMapperTest::toRawY(float displayY) {
+    return int32_t(displayY * (RAW_Y_MAX - RAW_Y_MIN + 1) / DISPLAY_HEIGHT + RAW_Y_MIN);
+}
+
+float TouchInputMapperTest::toCookedX(float rawX, float rawY) {
+    AFFINE_TRANSFORM.applyTo(rawX, rawY);
+    return rawX;
+}
+
+float TouchInputMapperTest::toCookedY(float rawX, float rawY) {
+    AFFINE_TRANSFORM.applyTo(rawX, rawY);
+    return rawY;
+}
+
+float TouchInputMapperTest::toDisplayX(int32_t rawX) {
+    return float(rawX - RAW_X_MIN) * DISPLAY_WIDTH / (RAW_X_MAX - RAW_X_MIN + 1);
+}
+
+float TouchInputMapperTest::toDisplayY(int32_t rawY) {
+    return float(rawY - RAW_Y_MIN) * DISPLAY_HEIGHT / (RAW_Y_MAX - RAW_Y_MIN + 1);
+}
+
+
+// --- SingleTouchInputMapperTest ---
+
+class SingleTouchInputMapperTest : public TouchInputMapperTest {
+protected:
+    void prepareButtons();
+    void prepareAxes(int axes);
+
+    void processDown(SingleTouchInputMapper* mapper, int32_t x, int32_t y);
+    void processMove(SingleTouchInputMapper* mapper, int32_t x, int32_t y);
+    void processUp(SingleTouchInputMapper* mappery);
+    void processPressure(SingleTouchInputMapper* mapper, int32_t pressure);
+    void processToolMajor(SingleTouchInputMapper* mapper, int32_t toolMajor);
+    void processDistance(SingleTouchInputMapper* mapper, int32_t distance);
+    void processTilt(SingleTouchInputMapper* mapper, int32_t tiltX, int32_t tiltY);
+    void processKey(SingleTouchInputMapper* mapper, int32_t code, int32_t value);
+    void processSync(SingleTouchInputMapper* mapper);
+};
+
+void SingleTouchInputMapperTest::prepareButtons() {
+    mFakeEventHub->addKey(DEVICE_ID, BTN_TOUCH, 0, AKEYCODE_UNKNOWN, 0);
+}
+
+void SingleTouchInputMapperTest::prepareAxes(int axes) {
+    if (axes & POSITION) {
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_X,
+                RAW_X_MIN, RAW_X_MAX, 0, 0);
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_Y,
+                RAW_Y_MIN, RAW_Y_MAX, 0, 0);
+    }
+    if (axes & PRESSURE) {
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_PRESSURE,
+                RAW_PRESSURE_MIN, RAW_PRESSURE_MAX, 0, 0);
+    }
+    if (axes & TOOL) {
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_TOOL_WIDTH,
+                RAW_TOOL_MIN, RAW_TOOL_MAX, 0, 0);
+    }
+    if (axes & DISTANCE) {
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_DISTANCE,
+                RAW_DISTANCE_MIN, RAW_DISTANCE_MAX, 0, 0);
+    }
+    if (axes & TILT) {
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_TILT_X,
+                RAW_TILT_MIN, RAW_TILT_MAX, 0, 0);
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_TILT_Y,
+                RAW_TILT_MIN, RAW_TILT_MAX, 0, 0);
+    }
+}
+
+void SingleTouchInputMapperTest::processDown(SingleTouchInputMapper* mapper, int32_t x, int32_t y) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_TOUCH, 1);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_X, x);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_Y, y);
+}
+
+void SingleTouchInputMapperTest::processMove(SingleTouchInputMapper* mapper, int32_t x, int32_t y) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_X, x);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_Y, y);
+}
+
+void SingleTouchInputMapperTest::processUp(SingleTouchInputMapper* mapper) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_TOUCH, 0);
+}
+
+void SingleTouchInputMapperTest::processPressure(
+        SingleTouchInputMapper* mapper, int32_t pressure) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_PRESSURE, pressure);
+}
+
+void SingleTouchInputMapperTest::processToolMajor(
+        SingleTouchInputMapper* mapper, int32_t toolMajor) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_TOOL_WIDTH, toolMajor);
+}
+
+void SingleTouchInputMapperTest::processDistance(
+        SingleTouchInputMapper* mapper, int32_t distance) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_DISTANCE, distance);
+}
+
+void SingleTouchInputMapperTest::processTilt(
+        SingleTouchInputMapper* mapper, int32_t tiltX, int32_t tiltY) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_TILT_X, tiltX);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_TILT_Y, tiltY);
+}
+
+void SingleTouchInputMapperTest::processKey(
+        SingleTouchInputMapper* mapper, int32_t code, int32_t value) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, code, value);
+}
+
+void SingleTouchInputMapperTest::processSync(SingleTouchInputMapper* mapper) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+}
+
+
+TEST_F(SingleTouchInputMapperTest, GetSources_WhenDeviceTypeIsNotSpecifiedAndNotACursor_ReturnsPointer) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    prepareButtons();
+    prepareAxes(POSITION);
+    addMapperAndConfigure(mapper);
+
+    ASSERT_EQ(AINPUT_SOURCE_MOUSE, mapper->getSources());
+}
+
+TEST_F(SingleTouchInputMapperTest, GetSources_WhenDeviceTypeIsNotSpecifiedAndIsACursor_ReturnsTouchPad) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    mFakeEventHub->addRelativeAxis(DEVICE_ID, REL_X);
+    mFakeEventHub->addRelativeAxis(DEVICE_ID, REL_Y);
+    prepareButtons();
+    prepareAxes(POSITION);
+    addMapperAndConfigure(mapper);
+
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHPAD, mapper->getSources());
+}
+
+TEST_F(SingleTouchInputMapperTest, GetSources_WhenDeviceTypeIsTouchPad_ReturnsTouchPad) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    prepareButtons();
+    prepareAxes(POSITION);
+    addConfigurationProperty("touch.deviceType", "touchPad");
+    addMapperAndConfigure(mapper);
+
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHPAD, mapper->getSources());
+}
+
+TEST_F(SingleTouchInputMapperTest, GetSources_WhenDeviceTypeIsTouchScreen_ReturnsTouchScreen) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    prepareButtons();
+    prepareAxes(POSITION);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    addMapperAndConfigure(mapper);
+
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, mapper->getSources());
+}
+
+TEST_F(SingleTouchInputMapperTest, GetKeyCodeState) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareButtons();
+    prepareAxes(POSITION);
+    prepareVirtualKeys();
+    addMapperAndConfigure(mapper);
+
+    // Unknown key.
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mapper->getKeyCodeState(AINPUT_SOURCE_ANY, AKEYCODE_A));
+
+    // Virtual key is down.
+    int32_t x = toRawX(VIRTUAL_KEYS[0].centerX);
+    int32_t y = toRawY(VIRTUAL_KEYS[0].centerY);
+    processDown(mapper, x, y);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled());
+
+    ASSERT_EQ(AKEY_STATE_VIRTUAL, mapper->getKeyCodeState(AINPUT_SOURCE_ANY, AKEYCODE_HOME));
+
+    // Virtual key is up.
+    processUp(mapper);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled());
+
+    ASSERT_EQ(AKEY_STATE_UP, mapper->getKeyCodeState(AINPUT_SOURCE_ANY, AKEYCODE_HOME));
+}
+
+TEST_F(SingleTouchInputMapperTest, GetScanCodeState) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareButtons();
+    prepareAxes(POSITION);
+    prepareVirtualKeys();
+    addMapperAndConfigure(mapper);
+
+    // Unknown key.
+    ASSERT_EQ(AKEY_STATE_UNKNOWN, mapper->getScanCodeState(AINPUT_SOURCE_ANY, KEY_A));
+
+    // Virtual key is down.
+    int32_t x = toRawX(VIRTUAL_KEYS[0].centerX);
+    int32_t y = toRawY(VIRTUAL_KEYS[0].centerY);
+    processDown(mapper, x, y);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled());
+
+    ASSERT_EQ(AKEY_STATE_VIRTUAL, mapper->getScanCodeState(AINPUT_SOURCE_ANY, KEY_HOME));
+
+    // Virtual key is up.
+    processUp(mapper);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled());
+
+    ASSERT_EQ(AKEY_STATE_UP, mapper->getScanCodeState(AINPUT_SOURCE_ANY, KEY_HOME));
+}
+
+TEST_F(SingleTouchInputMapperTest, MarkSupportedKeyCodes) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareButtons();
+    prepareAxes(POSITION);
+    prepareVirtualKeys();
+    addMapperAndConfigure(mapper);
+
+    const int32_t keys[2] = { AKEYCODE_HOME, AKEYCODE_A };
+    uint8_t flags[2] = { 0, 0 };
+    ASSERT_TRUE(mapper->markSupportedKeyCodes(AINPUT_SOURCE_ANY, 2, keys, flags));
+    ASSERT_TRUE(flags[0]);
+    ASSERT_FALSE(flags[1]);
+}
+
+TEST_F(SingleTouchInputMapperTest, Process_WhenVirtualKeyIsPressedAndReleasedNormally_SendsKeyDownAndKeyUp) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareButtons();
+    prepareAxes(POSITION);
+    prepareVirtualKeys();
+    addMapperAndConfigure(mapper);
+
+    mFakeContext->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
+
+    NotifyKeyArgs args;
+
+    // Press virtual key.
+    int32_t x = toRawX(VIRTUAL_KEYS[0].centerX);
+    int32_t y = toRawY(VIRTUAL_KEYS[0].centerY);
+    processDown(mapper, x, y);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
+    ASSERT_EQ(ARBITRARY_TIME, args.eventTime);
+    ASSERT_EQ(DEVICE_ID, args.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, args.source);
+    ASSERT_EQ(POLICY_FLAG_VIRTUAL, args.policyFlags);
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, args.action);
+    ASSERT_EQ(AKEY_EVENT_FLAG_FROM_SYSTEM | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY, args.flags);
+    ASSERT_EQ(AKEYCODE_HOME, args.keyCode);
+    ASSERT_EQ(KEY_HOME, args.scanCode);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, args.metaState);
+    ASSERT_EQ(ARBITRARY_TIME, args.downTime);
+
+    // Release virtual key.
+    processUp(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
+    ASSERT_EQ(ARBITRARY_TIME, args.eventTime);
+    ASSERT_EQ(DEVICE_ID, args.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, args.source);
+    ASSERT_EQ(POLICY_FLAG_VIRTUAL, args.policyFlags);
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, args.action);
+    ASSERT_EQ(AKEY_EVENT_FLAG_FROM_SYSTEM | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY, args.flags);
+    ASSERT_EQ(AKEYCODE_HOME, args.keyCode);
+    ASSERT_EQ(KEY_HOME, args.scanCode);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, args.metaState);
+    ASSERT_EQ(ARBITRARY_TIME, args.downTime);
+
+    // Should not have sent any motions.
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasNotCalled());
+}
+
+TEST_F(SingleTouchInputMapperTest, Process_WhenVirtualKeyIsPressedAndMovedOutOfBounds_SendsKeyDownAndKeyCancel) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareButtons();
+    prepareAxes(POSITION);
+    prepareVirtualKeys();
+    addMapperAndConfigure(mapper);
+
+    mFakeContext->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
+
+    NotifyKeyArgs keyArgs;
+
+    // Press virtual key.
+    int32_t x = toRawX(VIRTUAL_KEYS[0].centerX);
+    int32_t y = toRawY(VIRTUAL_KEYS[0].centerY);
+    processDown(mapper, x, y);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(ARBITRARY_TIME, keyArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, keyArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, keyArgs.source);
+    ASSERT_EQ(POLICY_FLAG_VIRTUAL, keyArgs.policyFlags);
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, keyArgs.action);
+    ASSERT_EQ(AKEY_EVENT_FLAG_FROM_SYSTEM | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY, keyArgs.flags);
+    ASSERT_EQ(AKEYCODE_HOME, keyArgs.keyCode);
+    ASSERT_EQ(KEY_HOME, keyArgs.scanCode);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, keyArgs.metaState);
+    ASSERT_EQ(ARBITRARY_TIME, keyArgs.downTime);
+
+    // Move out of bounds.  This should generate a cancel and a pointer down since we moved
+    // into the display area.
+    y -= 100;
+    processMove(mapper, x, y);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(ARBITRARY_TIME, keyArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, keyArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, keyArgs.source);
+    ASSERT_EQ(POLICY_FLAG_VIRTUAL, keyArgs.policyFlags);
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, keyArgs.action);
+    ASSERT_EQ(AKEY_EVENT_FLAG_FROM_SYSTEM | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY
+            | AKEY_EVENT_FLAG_CANCELED, keyArgs.flags);
+    ASSERT_EQ(AKEYCODE_HOME, keyArgs.keyCode);
+    ASSERT_EQ(KEY_HOME, keyArgs.scanCode);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, keyArgs.metaState);
+    ASSERT_EQ(ARBITRARY_TIME, keyArgs.downTime);
+
+    NotifyMotionArgs motionArgs;
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x), toDisplayY(y), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    // Keep moving out of bounds.  Should generate a pointer move.
+    y -= 50;
+    processMove(mapper, x, y);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x), toDisplayY(y), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    // Release out of bounds.  Should generate a pointer up.
+    processUp(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x), toDisplayY(y), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    // Should not have sent any more keys or motions.
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasNotCalled());
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
+}
+
+TEST_F(SingleTouchInputMapperTest, Process_WhenTouchStartsOutsideDisplayAndMovesIn_SendsDownAsTouchEntersDisplay) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareButtons();
+    prepareAxes(POSITION);
+    prepareVirtualKeys();
+    addMapperAndConfigure(mapper);
+
+    mFakeContext->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
+
+    NotifyMotionArgs motionArgs;
+
+    // Initially go down out of bounds.
+    int32_t x = -10;
+    int32_t y = -10;
+    processDown(mapper, x, y);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
+
+    // Move into the display area.  Should generate a pointer down.
+    x = 50;
+    y = 75;
+    processMove(mapper, x, y);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x), toDisplayY(y), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    // Release.  Should generate a pointer up.
+    processUp(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x), toDisplayY(y), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    // Should not have sent any more keys or motions.
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasNotCalled());
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
+}
+
+TEST_F(SingleTouchInputMapperTest, Process_NormalSingleTouchGesture) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareButtons();
+    prepareAxes(POSITION);
+    prepareVirtualKeys();
+    addMapperAndConfigure(mapper);
+
+    mFakeContext->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
+
+    NotifyMotionArgs motionArgs;
+
+    // Down.
+    int32_t x = 100;
+    int32_t y = 125;
+    processDown(mapper, x, y);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x), toDisplayY(y), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    // Move.
+    x += 50;
+    y += 75;
+    processMove(mapper, x, y);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x), toDisplayY(y), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    // Up.
+    processUp(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x), toDisplayY(y), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    // Should not have sent any more keys or motions.
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasNotCalled());
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
+}
+
+TEST_F(SingleTouchInputMapperTest, Process_WhenNotOrientationAware_DoesNotRotateMotions) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareButtons();
+    prepareAxes(POSITION);
+    addConfigurationProperty("touch.orientationAware", "0");
+    addMapperAndConfigure(mapper);
+
+    NotifyMotionArgs args;
+
+    // Rotation 90.
+    prepareDisplay(DISPLAY_ORIENTATION_90);
+    processDown(mapper, toRawX(50), toRawY(75));
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_NEAR(50, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X), 1);
+    ASSERT_NEAR(75, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y), 1);
+
+    processUp(mapper);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled());
+}
+
+TEST_F(SingleTouchInputMapperTest, Process_WhenOrientationAware_RotatesMotions) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareButtons();
+    prepareAxes(POSITION);
+    addMapperAndConfigure(mapper);
+
+    NotifyMotionArgs args;
+
+    // Rotation 0.
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    processDown(mapper, toRawX(50), toRawY(75));
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_NEAR(50, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X), 1);
+    ASSERT_NEAR(75, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y), 1);
+
+    processUp(mapper);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled());
+
+    // Rotation 90.
+    prepareDisplay(DISPLAY_ORIENTATION_90);
+    processDown(mapper, RAW_X_MAX - toRawX(75) + RAW_X_MIN, toRawY(50));
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_NEAR(50, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X), 1);
+    ASSERT_NEAR(75, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y), 1);
+
+    processUp(mapper);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled());
+
+    // Rotation 180.
+    prepareDisplay(DISPLAY_ORIENTATION_180);
+    processDown(mapper, RAW_X_MAX - toRawX(50) + RAW_X_MIN, RAW_Y_MAX - toRawY(75) + RAW_Y_MIN);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_NEAR(50, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X), 1);
+    ASSERT_NEAR(75, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y), 1);
+
+    processUp(mapper);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled());
+
+    // Rotation 270.
+    prepareDisplay(DISPLAY_ORIENTATION_270);
+    processDown(mapper, toRawX(75), RAW_Y_MAX - toRawY(50) + RAW_Y_MIN);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_NEAR(50, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X), 1);
+    ASSERT_NEAR(75, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y), 1);
+
+    processUp(mapper);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled());
+}
+
+TEST_F(SingleTouchInputMapperTest, Process_AllAxes_DefaultCalibration) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareButtons();
+    prepareAxes(POSITION | PRESSURE | TOOL | DISTANCE | TILT);
+    addMapperAndConfigure(mapper);
+
+    // These calculations are based on the input device calibration documentation.
+    int32_t rawX = 100;
+    int32_t rawY = 200;
+    int32_t rawPressure = 10;
+    int32_t rawToolMajor = 12;
+    int32_t rawDistance = 2;
+    int32_t rawTiltX = 30;
+    int32_t rawTiltY = 110;
+
+    float x = toDisplayX(rawX);
+    float y = toDisplayY(rawY);
+    float pressure = float(rawPressure) / RAW_PRESSURE_MAX;
+    float size = float(rawToolMajor) / RAW_TOOL_MAX;
+    float tool = float(rawToolMajor) * GEOMETRIC_SCALE;
+    float distance = float(rawDistance);
+
+    float tiltCenter = (RAW_TILT_MAX + RAW_TILT_MIN) * 0.5f;
+    float tiltScale = M_PI / 180;
+    float tiltXAngle = (rawTiltX - tiltCenter) * tiltScale;
+    float tiltYAngle = (rawTiltY - tiltCenter) * tiltScale;
+    float orientation = atan2f(-sinf(tiltXAngle), sinf(tiltYAngle));
+    float tilt = acosf(cosf(tiltXAngle) * cosf(tiltYAngle));
+
+    processDown(mapper, rawX, rawY);
+    processPressure(mapper, rawPressure);
+    processToolMajor(mapper, rawToolMajor);
+    processDistance(mapper, rawDistance);
+    processTilt(mapper, rawTiltX, rawTiltY);
+    processSync(mapper);
+
+    NotifyMotionArgs args;
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            x, y, pressure, size, tool, tool, tool, tool, orientation, distance));
+    ASSERT_EQ(tilt, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_TILT));
+}
+
+TEST_F(SingleTouchInputMapperTest, Process_XYAxes_AffineCalibration) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareLocationCalibration();
+    prepareButtons();
+    prepareAxes(POSITION);
+    addMapperAndConfigure(mapper);
+
+    int32_t rawX = 100;
+    int32_t rawY = 200;
+
+    float x = toDisplayX(toCookedX(rawX, rawY));
+    float y = toDisplayY(toCookedY(rawX, rawY));
+
+    processDown(mapper, rawX, rawY);
+    processSync(mapper);
+
+    NotifyMotionArgs args;
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            x, y, 1, 0, 0, 0, 0, 0, 0, 0));
+}
+
+TEST_F(SingleTouchInputMapperTest, Process_ShouldHandleAllButtons) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareButtons();
+    prepareAxes(POSITION);
+    addMapperAndConfigure(mapper);
+
+    NotifyMotionArgs motionArgs;
+    NotifyKeyArgs keyArgs;
+
+    processDown(mapper, 100, 200);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.buttonState);
+
+    // press BTN_LEFT, release BTN_LEFT
+    processKey(mapper, BTN_LEFT, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_PRIMARY, motionArgs.buttonState);
+
+    processKey(mapper, BTN_LEFT, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    // press BTN_RIGHT + BTN_MIDDLE, release BTN_RIGHT, release BTN_MIDDLE
+    processKey(mapper, BTN_RIGHT, 1);
+    processKey(mapper, BTN_MIDDLE, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_SECONDARY | AMOTION_EVENT_BUTTON_TERTIARY,
+            motionArgs.buttonState);
+
+    processKey(mapper, BTN_RIGHT, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_TERTIARY, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    processKey(mapper, BTN_MIDDLE, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    // press BTN_BACK, release BTN_BACK
+    processKey(mapper, BTN_BACK, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_BACK, keyArgs.keyCode);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_BACK, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    processKey(mapper, BTN_BACK, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_BACK, keyArgs.keyCode);
+
+    // press BTN_SIDE, release BTN_SIDE
+    processKey(mapper, BTN_SIDE, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_BACK, keyArgs.keyCode);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_BACK, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    processKey(mapper, BTN_SIDE, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_BACK, keyArgs.keyCode);
+
+    // press BTN_FORWARD, release BTN_FORWARD
+    processKey(mapper, BTN_FORWARD, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_FORWARD, keyArgs.keyCode);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_FORWARD, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    processKey(mapper, BTN_FORWARD, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_FORWARD, keyArgs.keyCode);
+
+    // press BTN_EXTRA, release BTN_EXTRA
+    processKey(mapper, BTN_EXTRA, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_FORWARD, keyArgs.keyCode);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_FORWARD, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    processKey(mapper, BTN_EXTRA, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_FORWARD, keyArgs.keyCode);
+
+    // press BTN_STYLUS, release BTN_STYLUS
+    processKey(mapper, BTN_STYLUS, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_SECONDARY, motionArgs.buttonState);
+
+    processKey(mapper, BTN_STYLUS, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    // press BTN_STYLUS2, release BTN_STYLUS2
+    processKey(mapper, BTN_STYLUS2, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_TERTIARY, motionArgs.buttonState);
+
+    processKey(mapper, BTN_STYLUS2, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    // release touch
+    processUp(mapper);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.buttonState);
+}
+
+TEST_F(SingleTouchInputMapperTest, Process_ShouldHandleAllToolTypes) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareButtons();
+    prepareAxes(POSITION);
+    addMapperAndConfigure(mapper);
+
+    NotifyMotionArgs motionArgs;
+
+    // default tool type is finger
+    processDown(mapper, 100, 200);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+    // eraser
+    processKey(mapper, BTN_TOOL_RUBBER, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_ERASER, motionArgs.pointerProperties[0].toolType);
+
+    // stylus
+    processKey(mapper, BTN_TOOL_RUBBER, 0);
+    processKey(mapper, BTN_TOOL_PEN, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+    // brush
+    processKey(mapper, BTN_TOOL_PEN, 0);
+    processKey(mapper, BTN_TOOL_BRUSH, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+    // pencil
+    processKey(mapper, BTN_TOOL_BRUSH, 0);
+    processKey(mapper, BTN_TOOL_PENCIL, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+    // airbrush
+    processKey(mapper, BTN_TOOL_PENCIL, 0);
+    processKey(mapper, BTN_TOOL_AIRBRUSH, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+    // mouse
+    processKey(mapper, BTN_TOOL_AIRBRUSH, 0);
+    processKey(mapper, BTN_TOOL_MOUSE, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+
+    // lens
+    processKey(mapper, BTN_TOOL_MOUSE, 0);
+    processKey(mapper, BTN_TOOL_LENS, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+
+    // double-tap
+    processKey(mapper, BTN_TOOL_LENS, 0);
+    processKey(mapper, BTN_TOOL_DOUBLETAP, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+    // triple-tap
+    processKey(mapper, BTN_TOOL_DOUBLETAP, 0);
+    processKey(mapper, BTN_TOOL_TRIPLETAP, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+    // quad-tap
+    processKey(mapper, BTN_TOOL_TRIPLETAP, 0);
+    processKey(mapper, BTN_TOOL_QUADTAP, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+    // finger
+    processKey(mapper, BTN_TOOL_QUADTAP, 0);
+    processKey(mapper, BTN_TOOL_FINGER, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+    // stylus trumps finger
+    processKey(mapper, BTN_TOOL_PEN, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+    // eraser trumps stylus
+    processKey(mapper, BTN_TOOL_RUBBER, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_ERASER, motionArgs.pointerProperties[0].toolType);
+
+    // mouse trumps eraser
+    processKey(mapper, BTN_TOOL_MOUSE, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+
+    // back to default tool type
+    processKey(mapper, BTN_TOOL_MOUSE, 0);
+    processKey(mapper, BTN_TOOL_RUBBER, 0);
+    processKey(mapper, BTN_TOOL_PEN, 0);
+    processKey(mapper, BTN_TOOL_FINGER, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+}
+
+TEST_F(SingleTouchInputMapperTest, Process_WhenBtnTouchPresent_HoversIfItsValueIsZero) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareButtons();
+    prepareAxes(POSITION);
+    mFakeEventHub->addKey(DEVICE_ID, BTN_TOOL_FINGER, 0, AKEYCODE_UNKNOWN, 0);
+    addMapperAndConfigure(mapper);
+
+    NotifyMotionArgs motionArgs;
+
+    // initially hovering because BTN_TOUCH not sent yet, pressure defaults to 0
+    processKey(mapper, BTN_TOOL_FINGER, 1);
+    processMove(mapper, 100, 200);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_ENTER, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(100), toDisplayY(200), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(100), toDisplayY(200), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    // move a little
+    processMove(mapper, 150, 250);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    // down when BTN_TOUCH is pressed, pressure defaults to 1
+    processKey(mapper, BTN_TOUCH, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_EXIT, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // up when BTN_TOUCH is released, hover restored
+    processKey(mapper, BTN_TOUCH, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_ENTER, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    // exit hover when pointer goes away
+    processKey(mapper, BTN_TOOL_FINGER, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_EXIT, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+}
+
+TEST_F(SingleTouchInputMapperTest, Process_WhenAbsPressureIsPresent_HoversIfItsValueIsZero) {
+    SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareButtons();
+    prepareAxes(POSITION | PRESSURE);
+    addMapperAndConfigure(mapper);
+
+    NotifyMotionArgs motionArgs;
+
+    // initially hovering because pressure is 0
+    processDown(mapper, 100, 200);
+    processPressure(mapper, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_ENTER, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(100), toDisplayY(200), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(100), toDisplayY(200), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    // move a little
+    processMove(mapper, 150, 250);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    // down when pressure is non-zero
+    processPressure(mapper, RAW_PRESSURE_MAX);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_EXIT, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // up when pressure becomes 0, hover restored
+    processPressure(mapper, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_ENTER, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    // exit hover when pointer goes away
+    processUp(mapper);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_EXIT, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+}
+
+
+// --- MultiTouchInputMapperTest ---
+
+class MultiTouchInputMapperTest : public TouchInputMapperTest {
+protected:
+    void prepareAxes(int axes);
+
+    void processPosition(MultiTouchInputMapper* mapper, int32_t x, int32_t y);
+    void processTouchMajor(MultiTouchInputMapper* mapper, int32_t touchMajor);
+    void processTouchMinor(MultiTouchInputMapper* mapper, int32_t touchMinor);
+    void processToolMajor(MultiTouchInputMapper* mapper, int32_t toolMajor);
+    void processToolMinor(MultiTouchInputMapper* mapper, int32_t toolMinor);
+    void processOrientation(MultiTouchInputMapper* mapper, int32_t orientation);
+    void processPressure(MultiTouchInputMapper* mapper, int32_t pressure);
+    void processDistance(MultiTouchInputMapper* mapper, int32_t distance);
+    void processId(MultiTouchInputMapper* mapper, int32_t id);
+    void processSlot(MultiTouchInputMapper* mapper, int32_t slot);
+    void processToolType(MultiTouchInputMapper* mapper, int32_t toolType);
+    void processKey(MultiTouchInputMapper* mapper, int32_t code, int32_t value);
+    void processMTSync(MultiTouchInputMapper* mapper);
+    void processSync(MultiTouchInputMapper* mapper);
+};
+
+void MultiTouchInputMapperTest::prepareAxes(int axes) {
+    if (axes & POSITION) {
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_MT_POSITION_X,
+                RAW_X_MIN, RAW_X_MAX, 0, 0);
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_MT_POSITION_Y,
+                RAW_Y_MIN, RAW_Y_MAX, 0, 0);
+    }
+    if (axes & TOUCH) {
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_MT_TOUCH_MAJOR,
+                RAW_TOUCH_MIN, RAW_TOUCH_MAX, 0, 0);
+        if (axes & MINOR) {
+            mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_MT_TOUCH_MINOR,
+                    RAW_TOUCH_MIN, RAW_TOUCH_MAX, 0, 0);
+        }
+    }
+    if (axes & TOOL) {
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_MT_WIDTH_MAJOR,
+                RAW_TOOL_MIN, RAW_TOOL_MAX, 0, 0);
+        if (axes & MINOR) {
+            mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_MT_WIDTH_MINOR,
+                    RAW_TOOL_MAX, RAW_TOOL_MAX, 0, 0);
+        }
+    }
+    if (axes & ORIENTATION) {
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_MT_ORIENTATION,
+                RAW_ORIENTATION_MIN, RAW_ORIENTATION_MAX, 0, 0);
+    }
+    if (axes & PRESSURE) {
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_MT_PRESSURE,
+                RAW_PRESSURE_MIN, RAW_PRESSURE_MAX, 0, 0);
+    }
+    if (axes & DISTANCE) {
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_MT_DISTANCE,
+                RAW_DISTANCE_MIN, RAW_DISTANCE_MAX, 0, 0);
+    }
+    if (axes & ID) {
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_MT_TRACKING_ID,
+                RAW_ID_MIN, RAW_ID_MAX, 0, 0);
+    }
+    if (axes & SLOT) {
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_MT_SLOT,
+                RAW_SLOT_MIN, RAW_SLOT_MAX, 0, 0);
+        mFakeEventHub->setAbsoluteAxisValue(DEVICE_ID, ABS_MT_SLOT, 0);
+    }
+    if (axes & TOOL_TYPE) {
+        mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_MT_TOOL_TYPE,
+                0, MT_TOOL_MAX, 0, 0);
+    }
+}
+
+void MultiTouchInputMapperTest::processPosition(
+        MultiTouchInputMapper* mapper, int32_t x, int32_t y) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_MT_POSITION_X, x);
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_MT_POSITION_Y, y);
+}
+
+void MultiTouchInputMapperTest::processTouchMajor(
+        MultiTouchInputMapper* mapper, int32_t touchMajor) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_MT_TOUCH_MAJOR, touchMajor);
+}
+
+void MultiTouchInputMapperTest::processTouchMinor(
+        MultiTouchInputMapper* mapper, int32_t touchMinor) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_MT_TOUCH_MINOR, touchMinor);
+}
+
+void MultiTouchInputMapperTest::processToolMajor(
+        MultiTouchInputMapper* mapper, int32_t toolMajor) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_MT_WIDTH_MAJOR, toolMajor);
+}
+
+void MultiTouchInputMapperTest::processToolMinor(
+        MultiTouchInputMapper* mapper, int32_t toolMinor) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_MT_WIDTH_MINOR, toolMinor);
+}
+
+void MultiTouchInputMapperTest::processOrientation(
+        MultiTouchInputMapper* mapper, int32_t orientation) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_MT_ORIENTATION, orientation);
+}
+
+void MultiTouchInputMapperTest::processPressure(
+        MultiTouchInputMapper* mapper, int32_t pressure) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_MT_PRESSURE, pressure);
+}
+
+void MultiTouchInputMapperTest::processDistance(
+        MultiTouchInputMapper* mapper, int32_t distance) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_MT_DISTANCE, distance);
+}
+
+void MultiTouchInputMapperTest::processId(
+        MultiTouchInputMapper* mapper, int32_t id) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_MT_TRACKING_ID, id);
+}
+
+void MultiTouchInputMapperTest::processSlot(
+        MultiTouchInputMapper* mapper, int32_t slot) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_MT_SLOT, slot);
+}
+
+void MultiTouchInputMapperTest::processToolType(
+        MultiTouchInputMapper* mapper, int32_t toolType) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_MT_TOOL_TYPE, toolType);
+}
+
+void MultiTouchInputMapperTest::processKey(
+        MultiTouchInputMapper* mapper, int32_t code, int32_t value) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, code, value);
+}
+
+void MultiTouchInputMapperTest::processMTSync(MultiTouchInputMapper* mapper) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_MT_REPORT, 0);
+}
+
+void MultiTouchInputMapperTest::processSync(MultiTouchInputMapper* mapper) {
+    process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0);
+}
+
+
+TEST_F(MultiTouchInputMapperTest, Process_NormalMultiTouchGesture_WithoutTrackingIds) {
+    MultiTouchInputMapper* mapper = new MultiTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareAxes(POSITION);
+    prepareVirtualKeys();
+    addMapperAndConfigure(mapper);
+
+    mFakeContext->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
+
+    NotifyMotionArgs motionArgs;
+
+    // Two fingers down at once.
+    int32_t x1 = 100, y1 = 125, x2 = 300, y2 = 500;
+    processPosition(mapper, x1, y1);
+    processMTSync(mapper);
+    processPosition(mapper, x2, y2);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_POINTER_DOWN | (1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(2), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    // Move.
+    x1 += 10; y1 += 15; x2 += 5; y2 -= 10;
+    processPosition(mapper, x1, y1);
+    processMTSync(mapper);
+    processPosition(mapper, x2, y2);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(2), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    // First finger up.
+    x2 += 15; y2 -= 20;
+    processPosition(mapper, x2, y2);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_POINTER_UP | (0 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(2), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(1, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    // Move.
+    x2 += 20; y2 -= 25;
+    processPosition(mapper, x2, y2);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(1, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    // New finger down.
+    int32_t x3 = 700, y3 = 300;
+    processPosition(mapper, x2, y2);
+    processMTSync(mapper);
+    processPosition(mapper, x3, y3);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_POINTER_DOWN | (0 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(2), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    // Second finger up.
+    x3 += 30; y3 -= 20;
+    processPosition(mapper, x3, y3);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_POINTER_UP | (1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(2), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    // Last finger up.
+    processMTSync(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.eventTime);
+    ASSERT_EQ(DEVICE_ID, motionArgs.deviceId);
+    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, motionArgs.source);
+    ASSERT_EQ(uint32_t(0), motionArgs.policyFlags);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.flags);
+    ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, motionArgs.metaState);
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(0, motionArgs.edgeFlags);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
+    ASSERT_NEAR(Y_PRECISION, motionArgs.yPrecision, EPSILON);
+    ASSERT_EQ(ARBITRARY_TIME, motionArgs.downTime);
+
+    // Should not have sent any more keys or motions.
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasNotCalled());
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
+}
+
+TEST_F(MultiTouchInputMapperTest, Process_NormalMultiTouchGesture_WithTrackingIds) {
+    MultiTouchInputMapper* mapper = new MultiTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareAxes(POSITION | ID);
+    prepareVirtualKeys();
+    addMapperAndConfigure(mapper);
+
+    mFakeContext->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
+
+    NotifyMotionArgs motionArgs;
+
+    // Two fingers down at once.
+    int32_t x1 = 100, y1 = 125, x2 = 300, y2 = 500;
+    processPosition(mapper, x1, y1);
+    processId(mapper, 1);
+    processMTSync(mapper);
+    processPosition(mapper, x2, y2);
+    processId(mapper, 2);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_POINTER_DOWN | (1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            motionArgs.action);
+    ASSERT_EQ(size_t(2), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // Move.
+    x1 += 10; y1 += 15; x2 += 5; y2 -= 10;
+    processPosition(mapper, x1, y1);
+    processId(mapper, 1);
+    processMTSync(mapper);
+    processPosition(mapper, x2, y2);
+    processId(mapper, 2);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(size_t(2), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // First finger up.
+    x2 += 15; y2 -= 20;
+    processPosition(mapper, x2, y2);
+    processId(mapper, 2);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_POINTER_UP | (0 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            motionArgs.action);
+    ASSERT_EQ(size_t(2), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(1, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // Move.
+    x2 += 20; y2 -= 25;
+    processPosition(mapper, x2, y2);
+    processId(mapper, 2);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(1, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // New finger down.
+    int32_t x3 = 700, y3 = 300;
+    processPosition(mapper, x2, y2);
+    processId(mapper, 2);
+    processMTSync(mapper);
+    processPosition(mapper, x3, y3);
+    processId(mapper, 3);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_POINTER_DOWN | (0 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            motionArgs.action);
+    ASSERT_EQ(size_t(2), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // Second finger up.
+    x3 += 30; y3 -= 20;
+    processPosition(mapper, x3, y3);
+    processId(mapper, 3);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_POINTER_UP | (1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            motionArgs.action);
+    ASSERT_EQ(size_t(2), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // Last finger up.
+    processMTSync(mapper);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // Should not have sent any more keys or motions.
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasNotCalled());
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
+}
+
+TEST_F(MultiTouchInputMapperTest, Process_NormalMultiTouchGesture_WithSlots) {
+    MultiTouchInputMapper* mapper = new MultiTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareAxes(POSITION | ID | SLOT);
+    prepareVirtualKeys();
+    addMapperAndConfigure(mapper);
+
+    mFakeContext->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
+
+    NotifyMotionArgs motionArgs;
+
+    // Two fingers down at once.
+    int32_t x1 = 100, y1 = 125, x2 = 300, y2 = 500;
+    processPosition(mapper, x1, y1);
+    processId(mapper, 1);
+    processSlot(mapper, 1);
+    processPosition(mapper, x2, y2);
+    processId(mapper, 2);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_POINTER_DOWN | (1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            motionArgs.action);
+    ASSERT_EQ(size_t(2), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // Move.
+    x1 += 10; y1 += 15; x2 += 5; y2 -= 10;
+    processSlot(mapper, 0);
+    processPosition(mapper, x1, y1);
+    processSlot(mapper, 1);
+    processPosition(mapper, x2, y2);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(size_t(2), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // First finger up.
+    x2 += 15; y2 -= 20;
+    processSlot(mapper, 0);
+    processId(mapper, -1);
+    processSlot(mapper, 1);
+    processPosition(mapper, x2, y2);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_POINTER_UP | (0 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            motionArgs.action);
+    ASSERT_EQ(size_t(2), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(1, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // Move.
+    x2 += 20; y2 -= 25;
+    processPosition(mapper, x2, y2);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(1, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // New finger down.
+    int32_t x3 = 700, y3 = 300;
+    processPosition(mapper, x2, y2);
+    processSlot(mapper, 0);
+    processId(mapper, 3);
+    processPosition(mapper, x3, y3);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_POINTER_DOWN | (0 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            motionArgs.action);
+    ASSERT_EQ(size_t(2), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // Second finger up.
+    x3 += 30; y3 -= 20;
+    processSlot(mapper, 1);
+    processId(mapper, -1);
+    processSlot(mapper, 0);
+    processPosition(mapper, x3, y3);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_POINTER_UP | (1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            motionArgs.action);
+    ASSERT_EQ(size_t(2), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
+            toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // Last finger up.
+    processId(mapper, -1);
+    processSync(mapper);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
+    ASSERT_EQ(size_t(1), motionArgs.pointerCount);
+    ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // Should not have sent any more keys or motions.
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasNotCalled());
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
+}
+
+TEST_F(MultiTouchInputMapperTest, Process_AllAxes_WithDefaultCalibration) {
+    MultiTouchInputMapper* mapper = new MultiTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareAxes(POSITION | TOUCH | TOOL | PRESSURE | ORIENTATION | ID | MINOR | DISTANCE);
+    addMapperAndConfigure(mapper);
+
+    // These calculations are based on the input device calibration documentation.
+    int32_t rawX = 100;
+    int32_t rawY = 200;
+    int32_t rawTouchMajor = 7;
+    int32_t rawTouchMinor = 6;
+    int32_t rawToolMajor = 9;
+    int32_t rawToolMinor = 8;
+    int32_t rawPressure = 11;
+    int32_t rawDistance = 0;
+    int32_t rawOrientation = 3;
+    int32_t id = 5;
+
+    float x = toDisplayX(rawX);
+    float y = toDisplayY(rawY);
+    float pressure = float(rawPressure) / RAW_PRESSURE_MAX;
+    float size = avg(rawTouchMajor, rawTouchMinor) / RAW_TOUCH_MAX;
+    float toolMajor = float(rawToolMajor) * GEOMETRIC_SCALE;
+    float toolMinor = float(rawToolMinor) * GEOMETRIC_SCALE;
+    float touchMajor = float(rawTouchMajor) * GEOMETRIC_SCALE;
+    float touchMinor = float(rawTouchMinor) * GEOMETRIC_SCALE;
+    float orientation = float(rawOrientation) / RAW_ORIENTATION_MAX * M_PI_2;
+    float distance = float(rawDistance);
+
+    processPosition(mapper, rawX, rawY);
+    processTouchMajor(mapper, rawTouchMajor);
+    processTouchMinor(mapper, rawTouchMinor);
+    processToolMajor(mapper, rawToolMajor);
+    processToolMinor(mapper, rawToolMinor);
+    processPressure(mapper, rawPressure);
+    processOrientation(mapper, rawOrientation);
+    processDistance(mapper, rawDistance);
+    processId(mapper, id);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    NotifyMotionArgs args;
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_EQ(0, args.pointerProperties[0].id);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            x, y, pressure, size, touchMajor, touchMinor, toolMajor, toolMinor,
+            orientation, distance));
+}
+
+TEST_F(MultiTouchInputMapperTest, Process_TouchAndToolAxes_GeometricCalibration) {
+    MultiTouchInputMapper* mapper = new MultiTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareAxes(POSITION | TOUCH | TOOL | MINOR);
+    addConfigurationProperty("touch.size.calibration", "geometric");
+    addMapperAndConfigure(mapper);
+
+    // These calculations are based on the input device calibration documentation.
+    int32_t rawX = 100;
+    int32_t rawY = 200;
+    int32_t rawTouchMajor = 140;
+    int32_t rawTouchMinor = 120;
+    int32_t rawToolMajor = 180;
+    int32_t rawToolMinor = 160;
+
+    float x = toDisplayX(rawX);
+    float y = toDisplayY(rawY);
+    float size = avg(rawTouchMajor, rawTouchMinor) / RAW_TOUCH_MAX;
+    float toolMajor = float(rawToolMajor) * GEOMETRIC_SCALE;
+    float toolMinor = float(rawToolMinor) * GEOMETRIC_SCALE;
+    float touchMajor = float(rawTouchMajor) * GEOMETRIC_SCALE;
+    float touchMinor = float(rawTouchMinor) * GEOMETRIC_SCALE;
+
+    processPosition(mapper, rawX, rawY);
+    processTouchMajor(mapper, rawTouchMajor);
+    processTouchMinor(mapper, rawTouchMinor);
+    processToolMajor(mapper, rawToolMajor);
+    processToolMinor(mapper, rawToolMinor);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    NotifyMotionArgs args;
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            x, y, 1.0f, size, touchMajor, touchMinor, toolMajor, toolMinor, 0, 0));
+}
+
+TEST_F(MultiTouchInputMapperTest, Process_TouchAndToolAxes_SummedLinearCalibration) {
+    MultiTouchInputMapper* mapper = new MultiTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareAxes(POSITION | TOUCH | TOOL);
+    addConfigurationProperty("touch.size.calibration", "diameter");
+    addConfigurationProperty("touch.size.scale", "10");
+    addConfigurationProperty("touch.size.bias", "160");
+    addConfigurationProperty("touch.size.isSummed", "1");
+    addMapperAndConfigure(mapper);
+
+    // These calculations are based on the input device calibration documentation.
+    // Note: We only provide a single common touch/tool value because the device is assumed
+    //       not to emit separate values for each pointer (isSummed = 1).
+    int32_t rawX = 100;
+    int32_t rawY = 200;
+    int32_t rawX2 = 150;
+    int32_t rawY2 = 250;
+    int32_t rawTouchMajor = 5;
+    int32_t rawToolMajor = 8;
+
+    float x = toDisplayX(rawX);
+    float y = toDisplayY(rawY);
+    float x2 = toDisplayX(rawX2);
+    float y2 = toDisplayY(rawY2);
+    float size = float(rawTouchMajor) / 2 / RAW_TOUCH_MAX;
+    float touch = float(rawTouchMajor) / 2 * 10.0f + 160.0f;
+    float tool = float(rawToolMajor) / 2 * 10.0f + 160.0f;
+
+    processPosition(mapper, rawX, rawY);
+    processTouchMajor(mapper, rawTouchMajor);
+    processToolMajor(mapper, rawToolMajor);
+    processMTSync(mapper);
+    processPosition(mapper, rawX2, rawY2);
+    processTouchMajor(mapper, rawTouchMajor);
+    processToolMajor(mapper, rawToolMajor);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    NotifyMotionArgs args;
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, args.action);
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_POINTER_DOWN | (1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+            args.action);
+    ASSERT_EQ(size_t(2), args.pointerCount);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            x, y, 1.0f, size, touch, touch, tool, tool, 0, 0));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[1],
+            x2, y2, 1.0f, size, touch, touch, tool, tool, 0, 0));
+}
+
+TEST_F(MultiTouchInputMapperTest, Process_TouchAndToolAxes_AreaCalibration) {
+    MultiTouchInputMapper* mapper = new MultiTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareAxes(POSITION | TOUCH | TOOL);
+    addConfigurationProperty("touch.size.calibration", "area");
+    addConfigurationProperty("touch.size.scale", "43");
+    addConfigurationProperty("touch.size.bias", "3");
+    addMapperAndConfigure(mapper);
+
+    // These calculations are based on the input device calibration documentation.
+    int32_t rawX = 100;
+    int32_t rawY = 200;
+    int32_t rawTouchMajor = 5;
+    int32_t rawToolMajor = 8;
+
+    float x = toDisplayX(rawX);
+    float y = toDisplayY(rawY);
+    float size = float(rawTouchMajor) / RAW_TOUCH_MAX;
+    float touch = sqrtf(rawTouchMajor) * 43.0f + 3.0f;
+    float tool = sqrtf(rawToolMajor) * 43.0f + 3.0f;
+
+    processPosition(mapper, rawX, rawY);
+    processTouchMajor(mapper, rawTouchMajor);
+    processToolMajor(mapper, rawToolMajor);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    NotifyMotionArgs args;
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            x, y, 1.0f, size, touch, touch, tool, tool, 0, 0));
+}
+
+TEST_F(MultiTouchInputMapperTest, Process_PressureAxis_AmplitudeCalibration) {
+    MultiTouchInputMapper* mapper = new MultiTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareAxes(POSITION | PRESSURE);
+    addConfigurationProperty("touch.pressure.calibration", "amplitude");
+    addConfigurationProperty("touch.pressure.scale", "0.01");
+    addMapperAndConfigure(mapper);
+
+    // These calculations are based on the input device calibration documentation.
+    int32_t rawX = 100;
+    int32_t rawY = 200;
+    int32_t rawPressure = 60;
+
+    float x = toDisplayX(rawX);
+    float y = toDisplayY(rawY);
+    float pressure = float(rawPressure) * 0.01f;
+
+    processPosition(mapper, rawX, rawY);
+    processPressure(mapper, rawPressure);
+    processMTSync(mapper);
+    processSync(mapper);
+
+    NotifyMotionArgs args;
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
+            x, y, pressure, 0, 0, 0, 0, 0, 0, 0));
+}
+
+TEST_F(MultiTouchInputMapperTest, Process_ShouldHandleAllButtons) {
+    MultiTouchInputMapper* mapper = new MultiTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareAxes(POSITION | ID | SLOT);
+    addMapperAndConfigure(mapper);
+
+    NotifyMotionArgs motionArgs;
+    NotifyKeyArgs keyArgs;
+
+    processId(mapper, 1);
+    processPosition(mapper, 100, 200);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.buttonState);
+
+    // press BTN_LEFT, release BTN_LEFT
+    processKey(mapper, BTN_LEFT, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_PRIMARY, motionArgs.buttonState);
+
+    processKey(mapper, BTN_LEFT, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    // press BTN_RIGHT + BTN_MIDDLE, release BTN_RIGHT, release BTN_MIDDLE
+    processKey(mapper, BTN_RIGHT, 1);
+    processKey(mapper, BTN_MIDDLE, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_SECONDARY | AMOTION_EVENT_BUTTON_TERTIARY,
+            motionArgs.buttonState);
+
+    processKey(mapper, BTN_RIGHT, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_TERTIARY, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    processKey(mapper, BTN_MIDDLE, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    // press BTN_BACK, release BTN_BACK
+    processKey(mapper, BTN_BACK, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_BACK, keyArgs.keyCode);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_BACK, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    processKey(mapper, BTN_BACK, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_BACK, keyArgs.keyCode);
+
+    // press BTN_SIDE, release BTN_SIDE
+    processKey(mapper, BTN_SIDE, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_BACK, keyArgs.keyCode);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_BACK, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    processKey(mapper, BTN_SIDE, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_BACK, keyArgs.keyCode);
+
+    // press BTN_FORWARD, release BTN_FORWARD
+    processKey(mapper, BTN_FORWARD, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_FORWARD, keyArgs.keyCode);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_FORWARD, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    processKey(mapper, BTN_FORWARD, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_FORWARD, keyArgs.keyCode);
+
+    // press BTN_EXTRA, release BTN_EXTRA
+    processKey(mapper, BTN_EXTRA, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_FORWARD, keyArgs.keyCode);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_FORWARD, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    processKey(mapper, BTN_EXTRA, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&keyArgs));
+    ASSERT_EQ(AKEY_EVENT_ACTION_UP, keyArgs.action);
+    ASSERT_EQ(AKEYCODE_FORWARD, keyArgs.keyCode);
+
+    // press BTN_STYLUS, release BTN_STYLUS
+    processKey(mapper, BTN_STYLUS, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_SECONDARY, motionArgs.buttonState);
+
+    processKey(mapper, BTN_STYLUS, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    // press BTN_STYLUS2, release BTN_STYLUS2
+    processKey(mapper, BTN_STYLUS2, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_BUTTON_TERTIARY, motionArgs.buttonState);
+
+    processKey(mapper, BTN_STYLUS2, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(0, motionArgs.buttonState);
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+
+    // release touch
+    processId(mapper, -1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
+    ASSERT_EQ(0, motionArgs.buttonState);
+}
+
+TEST_F(MultiTouchInputMapperTest, Process_ShouldHandleAllToolTypes) {
+    MultiTouchInputMapper* mapper = new MultiTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareAxes(POSITION | ID | SLOT | TOOL_TYPE);
+    addMapperAndConfigure(mapper);
+
+    NotifyMotionArgs motionArgs;
+
+    // default tool type is finger
+    processId(mapper, 1);
+    processPosition(mapper, 100, 200);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+    // eraser
+    processKey(mapper, BTN_TOOL_RUBBER, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_ERASER, motionArgs.pointerProperties[0].toolType);
+
+    // stylus
+    processKey(mapper, BTN_TOOL_RUBBER, 0);
+    processKey(mapper, BTN_TOOL_PEN, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+    // brush
+    processKey(mapper, BTN_TOOL_PEN, 0);
+    processKey(mapper, BTN_TOOL_BRUSH, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+    // pencil
+    processKey(mapper, BTN_TOOL_BRUSH, 0);
+    processKey(mapper, BTN_TOOL_PENCIL, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+    // airbrush
+    processKey(mapper, BTN_TOOL_PENCIL, 0);
+    processKey(mapper, BTN_TOOL_AIRBRUSH, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+    // mouse
+    processKey(mapper, BTN_TOOL_AIRBRUSH, 0);
+    processKey(mapper, BTN_TOOL_MOUSE, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+
+    // lens
+    processKey(mapper, BTN_TOOL_MOUSE, 0);
+    processKey(mapper, BTN_TOOL_LENS, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+
+    // double-tap
+    processKey(mapper, BTN_TOOL_LENS, 0);
+    processKey(mapper, BTN_TOOL_DOUBLETAP, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+    // triple-tap
+    processKey(mapper, BTN_TOOL_DOUBLETAP, 0);
+    processKey(mapper, BTN_TOOL_TRIPLETAP, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+    // quad-tap
+    processKey(mapper, BTN_TOOL_TRIPLETAP, 0);
+    processKey(mapper, BTN_TOOL_QUADTAP, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+    // finger
+    processKey(mapper, BTN_TOOL_QUADTAP, 0);
+    processKey(mapper, BTN_TOOL_FINGER, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+    // stylus trumps finger
+    processKey(mapper, BTN_TOOL_PEN, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+    // eraser trumps stylus
+    processKey(mapper, BTN_TOOL_RUBBER, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_ERASER, motionArgs.pointerProperties[0].toolType);
+
+    // mouse trumps eraser
+    processKey(mapper, BTN_TOOL_MOUSE, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+
+    // MT tool type trumps BTN tool types: MT_TOOL_FINGER
+    processToolType(mapper, MT_TOOL_FINGER); // this is the first time we send MT_TOOL_TYPE
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+    // MT tool type trumps BTN tool types: MT_TOOL_PEN
+    processToolType(mapper, MT_TOOL_PEN);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+    // back to default tool type
+    processToolType(mapper, -1); // use a deliberately undefined tool type, for testing
+    processKey(mapper, BTN_TOOL_MOUSE, 0);
+    processKey(mapper, BTN_TOOL_RUBBER, 0);
+    processKey(mapper, BTN_TOOL_PEN, 0);
+    processKey(mapper, BTN_TOOL_FINGER, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+    ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+}
+
+TEST_F(MultiTouchInputMapperTest, Process_WhenBtnTouchPresent_HoversIfItsValueIsZero) {
+    MultiTouchInputMapper* mapper = new MultiTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareAxes(POSITION | ID | SLOT);
+    mFakeEventHub->addKey(DEVICE_ID, BTN_TOUCH, 0, AKEYCODE_UNKNOWN, 0);
+    addMapperAndConfigure(mapper);
+
+    NotifyMotionArgs motionArgs;
+
+    // initially hovering because BTN_TOUCH not sent yet, pressure defaults to 0
+    processId(mapper, 1);
+    processPosition(mapper, 100, 200);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_ENTER, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(100), toDisplayY(200), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(100), toDisplayY(200), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    // move a little
+    processPosition(mapper, 150, 250);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    // down when BTN_TOUCH is pressed, pressure defaults to 1
+    processKey(mapper, BTN_TOUCH, 1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_EXIT, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // up when BTN_TOUCH is released, hover restored
+    processKey(mapper, BTN_TOUCH, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_ENTER, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    // exit hover when pointer goes away
+    processId(mapper, -1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_EXIT, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+}
+
+TEST_F(MultiTouchInputMapperTest, Process_WhenAbsMTPressureIsPresent_HoversIfItsValueIsZero) {
+    MultiTouchInputMapper* mapper = new MultiTouchInputMapper(mDevice);
+    addConfigurationProperty("touch.deviceType", "touchScreen");
+    prepareDisplay(DISPLAY_ORIENTATION_0);
+    prepareAxes(POSITION | ID | SLOT | PRESSURE);
+    addMapperAndConfigure(mapper);
+
+    NotifyMotionArgs motionArgs;
+
+    // initially hovering because pressure is 0
+    processId(mapper, 1);
+    processPosition(mapper, 100, 200);
+    processPressure(mapper, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_ENTER, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(100), toDisplayY(200), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(100), toDisplayY(200), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    // move a little
+    processPosition(mapper, 150, 250);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    // down when pressure becomes non-zero
+    processPressure(mapper, RAW_PRESSURE_MAX);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_EXIT, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    // up when pressure becomes 0, hover restored
+    processPressure(mapper, 0);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 1, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_ENTER, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+
+    // exit hover when pointer goes away
+    processId(mapper, -1);
+    processSync(mapper);
+    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_EXIT, motionArgs.action);
+    ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
+            toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
+}
+
+
+} // namespace android
diff --git a/services/nativeperms/.clang-format b/services/nativeperms/.clang-format
new file mode 100644
index 0000000..6006e6f
--- /dev/null
+++ b/services/nativeperms/.clang-format
@@ -0,0 +1,13 @@
+BasedOnStyle: Google
+AllowShortFunctionsOnASingleLine: Inline
+AllowShortIfStatementsOnASingleLine: true
+AllowShortLoopsOnASingleLine: true
+BinPackArguments: true
+BinPackParameters: true
+ColumnLimit: 80
+CommentPragmas: NOLINT:.*
+ContinuationIndentWidth: 8
+DerivePointerAlignment: false
+IndentWidth: 4
+PointerAlignment: Left
+TabWidth: 4
diff --git a/services/nativeperms/Android.mk b/services/nativeperms/Android.mk
new file mode 100644
index 0000000..34ccd0b
--- /dev/null
+++ b/services/nativeperms/Android.mk
@@ -0,0 +1,31 @@
+# Copyright 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := nativeperms
+LOCAL_SRC_FILES := \
+    nativeperms.cpp \
+    android/os/IPermissionController.aidl
+LOCAL_CFLAGS := -Wall -Werror
+LOCAL_SHARED_LIBRARIES := \
+    libbinder \
+    libbrillo \
+    libbrillo-binder \
+    libchrome \
+    libutils
+LOCAL_INIT_RC := nativeperms.rc
+include $(BUILD_EXECUTABLE)
diff --git a/services/nativeperms/android/os/IPermissionController.aidl b/services/nativeperms/android/os/IPermissionController.aidl
new file mode 100644
index 0000000..89db85c
--- /dev/null
+++ b/services/nativeperms/android/os/IPermissionController.aidl
@@ -0,0 +1,25 @@
+/* //device/java/android/android/os/IPowerManager.aidl
+**
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+package android.os;
+
+/** @hide */
+interface IPermissionController {
+    boolean checkPermission(String permission, int pid, int uid);
+    String[] getPackagesForUid(int uid);
+    boolean isRuntimePermission(String permission);
+}
diff --git a/services/nativeperms/android/os/README b/services/nativeperms/android/os/README
new file mode 100644
index 0000000..e414499
--- /dev/null
+++ b/services/nativeperms/android/os/README
@@ -0,0 +1,4 @@
+IPermissionController.aidl in this directory is a verbatim copy of
+https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/os/IPermissionController.aidl,
+because some Brillo manifests do not currently include the frameworks/base repo.
+TODO(jorgelo): Figure out a way to use the .aidl file in frameworks/base.
diff --git a/services/nativeperms/nativeperms.cpp b/services/nativeperms/nativeperms.cpp
new file mode 100644
index 0000000..7f03bed
--- /dev/null
+++ b/services/nativeperms/nativeperms.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <base/at_exit.h>
+#include <base/logging.h>
+#include <base/message_loop/message_loop.h>
+#include <binder/IServiceManager.h>
+#include <binder/Status.h>
+#include <brillo/binder_watcher.h>
+#include <brillo/message_loops/base_message_loop.h>
+#include <brillo/syslog_logging.h>
+#include <utils/String16.h>
+
+#include "android/os/BnPermissionController.h"
+
+namespace {
+static android::String16 serviceName("permission");
+}
+
+namespace android {
+
+class PermissionService : public android::os::BnPermissionController {
+   public:
+    ::android::binder::Status checkPermission(
+            const ::android::String16& permission, int32_t pid, int32_t uid,
+            bool* _aidl_return) {
+        (void)permission;
+        (void)pid;
+        (void)uid;
+        *_aidl_return = true;
+        return binder::Status::ok();
+    }
+
+    ::android::binder::Status getPackagesForUid(
+            int32_t uid, ::std::vector<::android::String16>* _aidl_return) {
+        (void)uid;
+        // Brillo doesn't currently have installable packages.
+        if (_aidl_return) {
+            _aidl_return->clear();
+        }
+        return binder::Status::ok();
+    }
+
+    ::android::binder::Status isRuntimePermission(
+            const ::android::String16& permission, bool* _aidl_return) {
+        (void)permission;
+        // Brillo doesn't currently have runtime permissions.
+        *_aidl_return = false;
+        return binder::Status::ok();
+    }
+};
+
+}  // namespace android
+
+int main() {
+    base::AtExitManager atExitManager;
+    brillo::InitLog(brillo::kLogToSyslog);
+    // Register the service with servicemanager.
+    android::status_t status = android::defaultServiceManager()->addService(
+            serviceName, new android::PermissionService());
+    CHECK(status == android::OK) << "Failed to get IPermissionController "
+                                    "binder from servicemanager.";
+
+    // Create a message loop.
+    base::MessageLoopForIO messageLoopForIo;
+    brillo::BaseMessageLoop messageLoop{&messageLoopForIo};
+
+    // Initialize a binder watcher.
+    brillo::BinderWatcher watcher(&messageLoop);
+    watcher.Init();
+
+    // Run the message loop.
+    messageLoop.Run();
+}
diff --git a/services/nativeperms/nativeperms.rc b/services/nativeperms/nativeperms.rc
new file mode 100644
index 0000000..704c0a2
--- /dev/null
+++ b/services/nativeperms/nativeperms.rc
@@ -0,0 +1,4 @@
+service nativeperms /system/bin/nativeperms
+    class main
+    user system
+    group system
diff --git a/services/powermanager/Android.mk b/services/powermanager/Android.mk
index d98b2da..4deb115 100644
--- a/services/powermanager/Android.mk
+++ b/services/powermanager/Android.mk
@@ -2,14 +2,18 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:= \
-	IPowerManager.cpp
+    IPowerManager.cpp
 
 LOCAL_SHARED_LIBRARIES := \
-	libutils \
-	libbinder
+    libutils \
+    libbinder
 
 LOCAL_MODULE:= libpowermanager
 
 LOCAL_MODULE_TAGS := optional
 
+LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
+
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../../include
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/services/powermanager/IPowerManager.cpp b/services/powermanager/IPowerManager.cpp
index 5ecd299..ea3a831 100644
--- a/services/powermanager/IPowerManager.cpp
+++ b/services/powermanager/IPowerManager.cpp
@@ -27,24 +27,16 @@
 
 namespace android {
 
-// must be kept in sync with IPowerManager.aidl
-enum {
-    ACQUIRE_WAKE_LOCK = IBinder::FIRST_CALL_TRANSACTION,
-    ACQUIRE_WAKE_LOCK_UID = IBinder::FIRST_CALL_TRANSACTION + 1,
-    RELEASE_WAKE_LOCK = IBinder::FIRST_CALL_TRANSACTION + 2,
-    UPDATE_WAKE_LOCK_UIDS = IBinder::FIRST_CALL_TRANSACTION + 3,
-};
-
 class BpPowerManager : public BpInterface<IPowerManager>
 {
 public:
-    BpPowerManager(const sp<IBinder>& impl)
+    explicit BpPowerManager(const sp<IBinder>& impl)
         : BpInterface<IPowerManager>(impl)
     {
     }
 
     virtual status_t acquireWakeLock(int flags, const sp<IBinder>& lock, const String16& tag,
-            const String16& packageName)
+            const String16& packageName, bool isOneWay)
     {
         Parcel data, reply;
         data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
@@ -54,11 +46,13 @@
         data.writeString16(tag);
         data.writeString16(packageName);
         data.writeInt32(0); // no WorkSource
-        return remote()->transact(ACQUIRE_WAKE_LOCK, data, &reply);
+        data.writeString16(NULL, 0); // no history tag
+        return remote()->transact(ACQUIRE_WAKE_LOCK, data, &reply,
+                isOneWay ? IBinder::FLAG_ONEWAY : 0);
     }
 
     virtual status_t acquireWakeLockWithUid(int flags, const sp<IBinder>& lock, const String16& tag,
-            const String16& packageName, int uid)
+            const String16& packageName, int uid, bool isOneWay)
     {
         Parcel data, reply;
         data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
@@ -68,26 +62,76 @@
         data.writeString16(tag);
         data.writeString16(packageName);
         data.writeInt32(uid); // uid to blame for the work
-        return remote()->transact(ACQUIRE_WAKE_LOCK_UID, data, &reply);
+        return remote()->transact(ACQUIRE_WAKE_LOCK_UID, data, &reply,
+                isOneWay ? IBinder::FLAG_ONEWAY : 0);
     }
 
-    virtual status_t releaseWakeLock(const sp<IBinder>& lock, int flags)
+    virtual status_t releaseWakeLock(const sp<IBinder>& lock, int flags, bool isOneWay)
     {
         Parcel data, reply;
         data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
         data.writeStrongBinder(lock);
         data.writeInt32(flags);
-        return remote()->transact(RELEASE_WAKE_LOCK, data, &reply);
+        return remote()->transact(RELEASE_WAKE_LOCK, data, &reply,
+                isOneWay ? IBinder::FLAG_ONEWAY : 0);
     }
 
-    virtual status_t updateWakeLockUids(const sp<IBinder>& lock, int len, const int *uids) {
+    virtual status_t updateWakeLockUids(const sp<IBinder>& lock, int len, const int *uids,
+            bool isOneWay) {
         Parcel data, reply;
         data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
         data.writeStrongBinder(lock);
         data.writeInt32Array(len, uids);
-        // We don't really care too much if this succeeds (there's nothing we can do if it doesn't)
-        // but it should return ASAP
-        return remote()->transact(UPDATE_WAKE_LOCK_UIDS, data, &reply, IBinder::FLAG_ONEWAY);
+        return remote()->transact(UPDATE_WAKE_LOCK_UIDS, data, &reply,
+                isOneWay ? IBinder::FLAG_ONEWAY : 0);
+    }
+
+    virtual status_t powerHint(int hintId, int param)
+    {
+        Parcel data, reply;
+        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
+        data.writeInt32(hintId);
+        data.writeInt32(param);
+        // This FLAG_ONEWAY is in the .aidl, so there is no way to disable it
+        return remote()->transact(POWER_HINT, data, &reply, IBinder::FLAG_ONEWAY);
+    }
+
+    virtual status_t goToSleep(int64_t event_time_ms, int reason, int flags)
+    {
+        Parcel data, reply;
+        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
+        data.writeInt64(event_time_ms);
+        data.writeInt32(reason);
+        data.writeInt32(flags);
+        return remote()->transact(GO_TO_SLEEP, data, &reply, 0);
+    }
+
+    virtual status_t reboot(bool confirm, const String16& reason, bool wait)
+    {
+        Parcel data, reply;
+        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
+        data.writeInt32(confirm);
+        data.writeString16(reason);
+        data.writeInt32(wait);
+        return remote()->transact(REBOOT, data, &reply, 0);
+    }
+
+    virtual status_t shutdown(bool confirm, const String16& reason, bool wait)
+    {
+        Parcel data, reply;
+        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
+        data.writeInt32(confirm);
+        data.writeString16(reason);
+        data.writeInt32(wait);
+        return remote()->transact(SHUTDOWN, data, &reply, 0);
+    }
+
+    virtual status_t crash(const String16& message)
+    {
+        Parcel data, reply;
+        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
+        data.writeString16(message);
+        return remote()->transact(CRASH, data, &reply, 0);
     }
 };
 
diff --git a/services/sensorservice/BatteryService.cpp b/services/sensorservice/BatteryService.cpp
index 38dc749..81f32cd 100644
--- a/services/sensorservice/BatteryService.cpp
+++ b/services/sensorservice/BatteryService.cpp
@@ -34,32 +34,10 @@
     const sp<IServiceManager> sm(defaultServiceManager());
     if (sm != NULL) {
         const String16 name("batterystats");
-        mBatteryStatService = sm->getService(name);
+        mBatteryStatService = interface_cast<IBatteryStats>(sm->getService(name));
     }
 }
 
-status_t BatteryService::noteStartSensor(int uid, int handle) {
-    Parcel data, reply;
-    data.writeInterfaceToken(DESCRIPTOR);
-    data.writeInt32(uid);
-    data.writeInt32(handle);
-    status_t err = mBatteryStatService->transact(
-            TRANSACTION_noteStartSensor, data, &reply, 0);
-    err = reply.readExceptionCode();
-    return err;
-}
-
-status_t BatteryService::noteStopSensor(int uid, int handle) {
-    Parcel data, reply;
-    data.writeInterfaceToken(DESCRIPTOR);
-    data.writeInt32(uid);
-    data.writeInt32(handle);
-    status_t err = mBatteryStatService->transact(
-            TRANSACTION_noteStopSensor, data, &reply, 0);
-    err = reply.readExceptionCode();
-    return err;
-}
-
 bool BatteryService::addSensor(uid_t uid, int handle) {
     Mutex::Autolock _l(mActivationsLock);
     Info key(uid, handle);
@@ -86,7 +64,7 @@
     if (mBatteryStatService != 0) {
         if (addSensor(uid, handle)) {
             int64_t identity = IPCThreadState::self()->clearCallingIdentity();
-            noteStartSensor(uid, handle);
+            mBatteryStatService->noteStartSensor(uid, handle);
             IPCThreadState::self()->restoreCallingIdentity(identity);
         }
     }
@@ -95,7 +73,7 @@
     if (mBatteryStatService != 0) {
         if (removeSensor(uid, handle)) {
             int64_t identity = IPCThreadState::self()->clearCallingIdentity();
-            noteStopSensor(uid, handle);
+            mBatteryStatService->noteStopSensor(uid, handle);
             IPCThreadState::self()->restoreCallingIdentity(identity);
         }
     }
@@ -105,10 +83,10 @@
     if (mBatteryStatService != 0) {
         Mutex::Autolock _l(mActivationsLock);
         int64_t identity = IPCThreadState::self()->clearCallingIdentity();
-        for (ssize_t i=0 ; i<mActivations.size() ; i++) {
+        for (size_t i=0 ; i<mActivations.size() ; i++) {
             const Info& info(mActivations[i]);
             if (info.uid == uid) {
-                noteStopSensor(info.uid, info.handle);
+                mBatteryStatService->noteStopSensor(info.uid, info.handle);
                 mActivations.removeAt(i);
                 i--;
             }
@@ -117,8 +95,6 @@
     }
 }
 
-const String16 BatteryService::DESCRIPTOR("com.android.internal.app.IBatteryStats");
-
 ANDROID_SINGLETON_STATIC_INSTANCE(BatteryService)
 
 // ---------------------------------------------------------------------------
diff --git a/services/sensorservice/BatteryService.h b/services/sensorservice/BatteryService.h
index 86cc884..08ba857 100644
--- a/services/sensorservice/BatteryService.h
+++ b/services/sensorservice/BatteryService.h
@@ -17,22 +17,18 @@
 #include <stdint.h>
 #include <sys/types.h>
 
+#include <binder/IBatteryStats.h>
 #include <utils/Singleton.h>
 
 namespace android {
 // ---------------------------------------------------------------------------
 
 class BatteryService : public Singleton<BatteryService> {
-    static const int TRANSACTION_noteStartSensor = IBinder::FIRST_CALL_TRANSACTION + 3;
-    static const int TRANSACTION_noteStopSensor = IBinder::FIRST_CALL_TRANSACTION + 4;
-    static const String16 DESCRIPTOR;
 
     friend class Singleton<BatteryService>;
-    sp<IBinder> mBatteryStatService;
+    sp<IBatteryStats> mBatteryStatService;
 
     BatteryService();
-    status_t noteStartSensor(int uid, int handle);
-    status_t noteStopSensor(int uid, int handle);
 
     void enableSensorImpl(uid_t uid, int handle);
     void disableSensorImpl(uid_t uid, int handle);
diff --git a/services/sensorservice/GravitySensor.cpp b/services/sensorservice/GravitySensor.cpp
index 3cb3745..61118bc 100644
--- a/services/sensorservice/GravitySensor.cpp
+++ b/services/sensorservice/GravitySensor.cpp
@@ -44,7 +44,6 @@
 bool GravitySensor::process(sensors_event_t* outEvent,
         const sensors_event_t& event)
 {
-    const static double NS2S = 1.0 / 1000000000.0;
     if (event.type == SENSOR_TYPE_ACCELEROMETER) {
         vec3_t g;
         if (!mSensorFusion.hasEstimate())
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
index 3b64f0a..40d596f 100644
--- a/services/sensorservice/SensorDevice.cpp
+++ b/services/sensorservice/SensorDevice.cpp
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-#include <stdint.h>
+#include <inttypes.h>
 #include <math.h>
+#include <stdint.h>
 #include <sys/types.h>
 
 #include <utils/Atomic.h>
@@ -53,6 +54,11 @@
                 SENSORS_HARDWARE_MODULE_ID, strerror(-err));
 
         if (mSensorDevice) {
+            if (mSensorDevice->common.version == SENSORS_DEVICE_API_VERSION_1_1 ||
+                mSensorDevice->common.version == SENSORS_DEVICE_API_VERSION_1_2) {
+                ALOGE(">>>> WARNING <<< Upgrade sensor HAL to version 1_3");
+            }
+
             sensor_t const* list;
             ssize_t count = mSensorModule->get_sensors_list(mSensorModule, &list);
             mActivationCount.setCapacity(count);
@@ -73,15 +79,17 @@
     sensor_t const* list;
     ssize_t count = mSensorModule->get_sensors_list(mSensorModule, &list);
 
+    result.appendFormat("halVersion 0x%08x\n", getHalDeviceVersion());
     result.appendFormat("%d h/w sensors:\n", int(count));
 
     Mutex::Autolock _l(mLock);
     for (size_t i=0 ; i<size_t(count) ; i++) {
         const Info& info = mActivationCount.valueFor(list[i].handle);
+        if (info.batchParams.isEmpty()) continue;
         result.appendFormat("handle=0x%08x, active-count=%zu, batch_period(ms)={ ", list[i].handle,
                             info.batchParams.size());
         for (size_t j = 0; j < info.batchParams.size(); j++) {
-            BatchParams params = info.batchParams.valueAt(j);
+            const BatchParams& params = info.batchParams.valueAt(j);
             result.appendFormat("%4.1f%s", params.batchDelay / 1e6f,
                                 j < info.batchParams.size() - 1 ? ", " : "");
         }
@@ -134,14 +142,18 @@
     Info& info( mActivationCount.editValueFor(handle) );
 
     ALOGD_IF(DEBUG_CONNECTIONS,
-             "SensorDevice::activate: ident=%p, handle=0x%08x, enabled=%d, count=%d",
+             "SensorDevice::activate: ident=%p, handle=0x%08x, enabled=%d, count=%zu",
              ident, handle, enabled, info.batchParams.size());
 
     if (enabled) {
-        ALOGD_IF(DEBUG_CONNECTIONS, "enable index=%d", info.batchParams.indexOfKey(ident));
+        ALOGD_IF(DEBUG_CONNECTIONS, "enable index=%zd", info.batchParams.indexOfKey(ident));
+
+        if (isClientDisabledLocked(ident)) {
+            return INVALID_OPERATION;
+        }
 
         if (info.batchParams.indexOfKey(ident) >= 0) {
-          if (info.batchParams.size() == 1) {
+          if (info.numActiveClients() == 1) {
               // This is the first connection, we need to activate the underlying h/w sensor.
               actuateHardware = true;
           }
@@ -150,10 +162,10 @@
             ALOGE("\t >>>ERROR: activate called without batch");
         }
     } else {
-        ALOGD_IF(DEBUG_CONNECTIONS, "disable index=%d", info.batchParams.indexOfKey(ident));
+        ALOGD_IF(DEBUG_CONNECTIONS, "disable index=%zd", info.batchParams.indexOfKey(ident));
 
         if (info.removeBatchParamsForIdent(ident) >= 0) {
-            if (info.batchParams.size() == 0) {
+            if (info.numActiveClients() == 0) {
                 // This is the last connection, we need to de-activate the underlying h/w sensor.
                 actuateHardware = true;
             } else {
@@ -163,7 +175,7 @@
                     // batch_rate and timeout. One of the apps has unregistered for sensor
                     // events, and the best effort batch parameters might have changed.
                     ALOGD_IF(DEBUG_CONNECTIONS,
-                             "\t>>> actuating h/w batch %d %d %lld %lld ", handle,
+                             "\t>>> actuating h/w batch %d %d %" PRId64 " %" PRId64, handle,
                              info.bestBatchParams.flags, info.bestBatchParams.batchDelay,
                              info.bestBatchParams.batchTimeout);
                     mSensorDevice->batch(mSensorDevice, handle,info.bestBatchParams.flags,
@@ -174,10 +186,15 @@
         } else {
             // sensor wasn't enabled for this ident
         }
+
+        if (isClientDisabledLocked(ident)) {
+            return NO_ERROR;
+        }
     }
 
     if (actuateHardware) {
-        ALOGD_IF(DEBUG_CONNECTIONS, "\t>>> actuating h/w activate handle=%d enabled=%d", handle, enabled);
+        ALOGD_IF(DEBUG_CONNECTIONS, "\t>>> actuating h/w activate handle=%d enabled=%d", handle,
+                 enabled);
         err = mSensorDevice->activate(
                 reinterpret_cast<struct sensors_poll_device_t *> (mSensorDevice), handle, enabled);
         ALOGE_IF(err, "Error %s sensor %d (%s)", enabled ? "activating" : "disabling", handle,
@@ -190,8 +207,8 @@
     }
 
     // On older devices which do not support batch, call setDelay().
-    if (getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_1 && info.batchParams.size() > 0) {
-        ALOGD_IF(DEBUG_CONNECTIONS, "\t>>> actuating h/w setDelay %d %lld ", handle,
+    if (getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_1 && info.numActiveClients() > 0) {
+        ALOGD_IF(DEBUG_CONNECTIONS, "\t>>> actuating h/w setDelay %d %" PRId64, handle,
                  info.bestBatchParams.batchDelay);
         mSensorDevice->setDelay(
                 reinterpret_cast<struct sensors_poll_device_t *>(mSensorDevice),
@@ -209,29 +226,13 @@
     }
 
     const int halVersion = getHalDeviceVersion();
-    if (halVersion >= SENSORS_DEVICE_API_VERSION_1_1) {
-        if (flags & SENSORS_BATCH_DRY_RUN) {
-            return mSensorDevice->batch(mSensorDevice, handle, flags, samplingPeriodNs,
-                                        maxBatchReportLatencyNs);
-        } else {
-            // Call h/w with dry run to see if the given parameters are feasible or not. Return if
-            // there is an error.
-            status_t errDryRun(NO_ERROR);
-            errDryRun = mSensorDevice->batch(mSensorDevice, handle, flags | SENSORS_BATCH_DRY_RUN,
-                                             samplingPeriodNs, maxBatchReportLatencyNs);
-            if (errDryRun != NO_ERROR) {
-                ALOGD_IF(DEBUG_CONNECTIONS, "SensorDevice::batch dry run error %s",
-                         strerror(-errDryRun));
-                return errDryRun;
-            }
-        }
-    } else if (maxBatchReportLatencyNs != 0) {
-        // Batch is not supported on older devices.
+    if (halVersion < SENSORS_DEVICE_API_VERSION_1_1 && maxBatchReportLatencyNs != 0) {
+        // Batch is not supported on older devices return invalid operation.
         return INVALID_OPERATION;
     }
 
     ALOGD_IF(DEBUG_CONNECTIONS,
-             "SensorDevice::batch: ident=%p, handle=0x%08x, flags=%d, period_ns=%lld timeout=%lld",
+             "SensorDevice::batch: ident=%p, handle=0x%08x, flags=%d, period_ns=%" PRId64 " timeout=%" PRId64,
              ident, handle, flags, samplingPeriodNs, maxBatchReportLatencyNs);
 
     Mutex::Autolock _l(mLock);
@@ -250,7 +251,8 @@
     info.selectBatchParams();
 
     ALOGD_IF(DEBUG_CONNECTIONS,
-             "\t>>> curr_period=%lld min_period=%lld curr_timeout=%lld min_timeout=%lld",
+             "\t>>> curr_period=%" PRId64 " min_period=%" PRId64
+             " curr_timeout=%" PRId64 " min_timeout=%" PRId64,
              prevBestBatchParams.batchDelay, info.bestBatchParams.batchDelay,
              prevBestBatchParams.batchTimeout, info.bestBatchParams.batchTimeout);
 
@@ -258,7 +260,7 @@
     // If the min period or min timeout has changed since the last batch call, call batch.
     if (prevBestBatchParams != info.bestBatchParams) {
         if (halVersion >= SENSORS_DEVICE_API_VERSION_1_1) {
-            ALOGD_IF(DEBUG_CONNECTIONS, "\t>>> actuating h/w BATCH %d %d %lld %lld ", handle,
+            ALOGD_IF(DEBUG_CONNECTIONS, "\t>>> actuating h/w BATCH %d %d %" PRId64 " %" PRId64, handle,
                      info.bestBatchParams.flags, info.bestBatchParams.batchDelay,
                      info.bestBatchParams.batchTimeout);
             err = mSensorDevice->batch(mSensorDevice, handle, info.bestBatchParams.flags,
@@ -270,7 +272,8 @@
             // call setDelay in SensorDevice::activate() method.
         }
         if (err != NO_ERROR) {
-            ALOGE("sensor batch failed %p %d %d %lld %lld err=%s", mSensorDevice, handle,
+            ALOGE("sensor batch failed %p %d %d %" PRId64 " %" PRId64 " err=%s",
+                  mSensorDevice, handle,
                   info.bestBatchParams.flags, info.bestBatchParams.batchDelay,
                   info.bestBatchParams.batchTimeout, strerror(-err));
             info.removeBatchParamsForIdent(ident);
@@ -286,6 +289,7 @@
         samplingPeriodNs = MINIMUM_EVENTS_PERIOD;
     }
     Mutex::Autolock _l(mLock);
+    if (isClientDisabledLocked(ident)) return INVALID_OPERATION;
     Info& info( mActivationCount.editValueFor(handle) );
     // If the underlying sensor is NOT in continuous mode, setDelay() should return an error.
     // Calling setDelay() in batch mode is an invalid operation.
@@ -305,26 +309,123 @@
 
 int SensorDevice::getHalDeviceVersion() const {
     if (!mSensorDevice) return -1;
-
     return mSensorDevice->common.version;
 }
 
-status_t SensorDevice::flush(void* /*ident*/, int handle) {
+status_t SensorDevice::flush(void* ident, int handle) {
     if (getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_1) {
         return INVALID_OPERATION;
     }
+    if (isClientDisabled(ident)) return INVALID_OPERATION;
     ALOGD_IF(DEBUG_CONNECTIONS, "\t>>> actuating h/w flush %d", handle);
     return mSensorDevice->flush(mSensorDevice, handle);
 }
 
+bool SensorDevice::isClientDisabled(void* ident) {
+    Mutex::Autolock _l(mLock);
+    return isClientDisabledLocked(ident);
+}
+
+bool SensorDevice::isClientDisabledLocked(void* ident) {
+    return mDisabledClients.indexOf(ident) >= 0;
+}
+
+void SensorDevice::enableAllSensors() {
+    Mutex::Autolock _l(mLock);
+    mDisabledClients.clear();
+    const int halVersion = getHalDeviceVersion();
+    for (size_t i = 0; i< mActivationCount.size(); ++i) {
+        Info& info = mActivationCount.editValueAt(i);
+        if (info.batchParams.isEmpty()) continue;
+        info.selectBatchParams();
+        const int sensor_handle = mActivationCount.keyAt(i);
+        ALOGD_IF(DEBUG_CONNECTIONS, "\t>> reenable actuating h/w sensor enable handle=%d ",
+                   sensor_handle);
+        status_t err(NO_ERROR);
+        if (halVersion > SENSORS_DEVICE_API_VERSION_1_0) {
+            err = mSensorDevice->batch(mSensorDevice, sensor_handle,
+                 info.bestBatchParams.flags, info.bestBatchParams.batchDelay,
+                 info.bestBatchParams.batchTimeout);
+            ALOGE_IF(err, "Error calling batch on sensor %d (%s)", sensor_handle, strerror(-err));
+        }
+
+        if (err == NO_ERROR) {
+            err = mSensorDevice->activate(
+                    reinterpret_cast<struct sensors_poll_device_t *>(mSensorDevice),
+                    sensor_handle, 1);
+            ALOGE_IF(err, "Error activating sensor %d (%s)", sensor_handle, strerror(-err));
+        }
+
+        if (halVersion <= SENSORS_DEVICE_API_VERSION_1_0) {
+             err = mSensorDevice->setDelay(
+                    reinterpret_cast<struct sensors_poll_device_t *>(mSensorDevice),
+                    sensor_handle, info.bestBatchParams.batchDelay);
+             ALOGE_IF(err, "Error calling setDelay sensor %d (%s)", sensor_handle, strerror(-err));
+        }
+    }
+}
+
+void SensorDevice::disableAllSensors() {
+    Mutex::Autolock _l(mLock);
+   for (size_t i = 0; i< mActivationCount.size(); ++i) {
+        const Info& info = mActivationCount.valueAt(i);
+        // Check if this sensor has been activated previously and disable it.
+        if (info.batchParams.size() > 0) {
+           const int sensor_handle = mActivationCount.keyAt(i);
+           ALOGD_IF(DEBUG_CONNECTIONS, "\t>> actuating h/w sensor disable handle=%d ",
+                   sensor_handle);
+           mSensorDevice->activate(
+                   reinterpret_cast<struct sensors_poll_device_t *> (mSensorDevice),
+                   sensor_handle, 0);
+           // Add all the connections that were registered for this sensor to the disabled
+           // clients list.
+           for (size_t j = 0; j < info.batchParams.size(); ++j) {
+               mDisabledClients.add(info.batchParams.keyAt(j));
+           }
+        }
+    }
+}
+
+status_t SensorDevice::injectSensorData(const sensors_event_t *injected_sensor_event) {
+      ALOGD_IF(DEBUG_CONNECTIONS,
+              "sensor_event handle=%d ts=%" PRId64 " data=%.2f, %.2f, %.2f %.2f %.2f %.2f",
+               injected_sensor_event->sensor,
+               injected_sensor_event->timestamp, injected_sensor_event->data[0],
+               injected_sensor_event->data[1], injected_sensor_event->data[2],
+               injected_sensor_event->data[3], injected_sensor_event->data[4],
+               injected_sensor_event->data[5]);
+      if (getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_4) {
+          return INVALID_OPERATION;
+      }
+      return mSensorDevice->inject_sensor_data(mSensorDevice, injected_sensor_event);
+}
+
+status_t SensorDevice::setMode(uint32_t mode) {
+     if (getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_4) {
+          return INVALID_OPERATION;
+     }
+     return mSensorModule->set_operation_mode(mode);
+}
+
 // ---------------------------------------------------------------------------
 
+int SensorDevice::Info::numActiveClients() {
+    SensorDevice& device(SensorDevice::getInstance());
+    int num = 0;
+    for (size_t i = 0; i < batchParams.size(); ++i) {
+        if (!device.isClientDisabledLocked(batchParams.keyAt(i))) {
+            ++num;
+        }
+    }
+    return num;
+}
+
 status_t SensorDevice::Info::setBatchParamsForIdent(void* ident, int flags,
                                                     int64_t samplingPeriodNs,
                                                     int64_t maxBatchReportLatencyNs) {
     ssize_t index = batchParams.indexOfKey(ident);
     if (index < 0) {
-        ALOGE("Info::setBatchParamsForIdent(ident=%p, period_ns=%lld timeout=%lld) failed (%s)",
+        ALOGE("Info::setBatchParamsForIdent(ident=%p, period_ns=%" PRId64 " timeout=%" PRId64 ") failed (%s)",
               ident, samplingPeriodNs, maxBatchReportLatencyNs, strerror(-index));
         return BAD_INDEX;
     }
@@ -336,19 +437,16 @@
 }
 
 void SensorDevice::Info::selectBatchParams() {
-    BatchParams bestParams(-1, -1, -1);
+    BatchParams bestParams(0, -1, -1);
+    SensorDevice& device(SensorDevice::getInstance());
 
-    if (batchParams.size() > 0) {
-        BatchParams params = batchParams.valueAt(0);
-        bestParams = params;
-    }
-
-    for (size_t i = 1; i < batchParams.size(); ++i) {
+    for (size_t i = 0; i < batchParams.size(); ++i) {
+        if (device.isClientDisabledLocked(batchParams.keyAt(i))) continue;
         BatchParams params = batchParams.valueAt(i);
-        if (params.batchDelay < bestParams.batchDelay) {
+        if (bestParams.batchDelay == -1 || params.batchDelay < bestParams.batchDelay) {
             bestParams.batchDelay = params.batchDelay;
         }
-        if (params.batchTimeout < bestParams.batchTimeout) {
+        if (bestParams.batchTimeout == -1 || params.batchTimeout < bestParams.batchTimeout) {
             bestParams.batchTimeout = params.batchTimeout;
         }
     }
diff --git a/services/sensorservice/SensorDevice.h b/services/sensorservice/SensorDevice.h
index 761b48c..c484849 100644
--- a/services/sensorservice/SensorDevice.h
+++ b/services/sensorservice/SensorDevice.h
@@ -42,6 +42,7 @@
     // Struct to store all the parameters(samplingPeriod, maxBatchReportLatency and flags) from
     // batch call. For continous mode clients, maxBatchReportLatency is set to zero.
     struct BatchParams {
+      // TODO: Get rid of flags parameter everywhere.
       int flags;
       nsecs_t batchDelay, batchTimeout;
       BatchParams() : flags(0), batchDelay(0), batchTimeout(0) {}
@@ -65,7 +66,7 @@
         // requested by the client.
         KeyedVector<void*, BatchParams> batchParams;
 
-        Info() : bestBatchParams(-1, -1, -1) {}
+        Info() : bestBatchParams(0, -1, -1) {}
         // Sets batch parameters for this ident. Returns error if this ident is not already present
         // in the KeyedVector above.
         status_t setBatchParamsForIdent(void* ident, int flags, int64_t samplingPeriodNs,
@@ -75,10 +76,17 @@
         // Removes batchParams for an ident and re-computes bestBatchParams. Returns the index of
         // the removed ident. If index >=0, ident is present and successfully removed.
         ssize_t removeBatchParamsForIdent(void* ident);
+
+        int numActiveClients();
     };
     DefaultKeyedVector<int, Info> mActivationCount;
 
+    // Use this vector to determine which client is activated or deactivated.
+    SortedVector<void *> mDisabledClients;
     SensorDevice();
+
+    bool isClientDisabled(void* ident);
+    bool isClientDisabledLocked(void* ident);
 public:
     ssize_t getSensorList(sensor_t const** list);
     status_t initCheck() const;
@@ -90,7 +98,11 @@
     // Call batch with timeout zero instead of calling setDelay() for newer devices.
     status_t setDelay(void* ident, int handle, int64_t ns);
     status_t flush(void* ident, int handle);
+    status_t setMode(uint32_t mode);
+    void disableAllSensors();
+    void enableAllSensors();
     void autoDisable(void *ident, int handle);
+    status_t injectSensorData(const sensors_event_t *event);
     void dump(String8& result);
 };
 
diff --git a/services/sensorservice/SensorFusion.cpp b/services/sensorservice/SensorFusion.cpp
index bb97286..6d93009 100644
--- a/services/sensorservice/SensorFusion.cpp
+++ b/services/sensorservice/SensorFusion.cpp
@@ -102,15 +102,6 @@
         }
     }
 
-    if (enabled) {
-        ALOGD_IF(DEBUG_CONNECTIONS, "SensorFusion calling batch ident=%p ", ident);
-        // Activating a sensor in continuous mode is equivalent to calling batch with the default
-        // period and timeout equal to ZERO, followed by a call to activate.
-        mSensorDevice.batch(ident, mAcc.getHandle(), 0, DEFAULT_EVENTS_PERIOD, 0);
-        mSensorDevice.batch(ident, mMag.getHandle(), 0, DEFAULT_EVENTS_PERIOD, 0);
-        mSensorDevice.batch(ident, mGyro.getHandle(), 0, DEFAULT_EVENTS_PERIOD, 0);
-    }
-
     mSensorDevice.activate(ident, mAcc.getHandle(), enabled);
     mSensorDevice.activate(ident, mMag.getHandle(), enabled);
     mSensorDevice.activate(ident, mGyro.getHandle(), enabled);
@@ -127,9 +118,10 @@
 }
 
 status_t SensorFusion::setDelay(void* ident, int64_t ns) {
-    mSensorDevice.setDelay(ident, mAcc.getHandle(), ns);
-    mSensorDevice.setDelay(ident, mMag.getHandle(), ms2ns(20));
-    mSensorDevice.setDelay(ident, mGyro.getHandle(), mTargetDelayNs);
+    // Call batch with timeout zero instead of setDelay().
+    mSensorDevice.batch(ident, mAcc.getHandle(), 0, ns, 0);
+    mSensorDevice.batch(ident, mMag.getHandle(), 0, ms2ns(20), 0);
+    mSensorDevice.batch(ident, mGyro.getHandle(), 0, mTargetDelayNs, 0);
     return NO_ERROR;
 }
 
diff --git a/services/sensorservice/SensorFusion.h b/services/sensorservice/SensorFusion.h
index b8f360f..432adbc 100644
--- a/services/sensorservice/SensorFusion.h
+++ b/services/sensorservice/SensorFusion.h
@@ -37,7 +37,6 @@
 
 class SensorFusion : public Singleton<SensorFusion> {
     friend class Singleton<SensorFusion>;
-    static const nsecs_t DEFAULT_EVENTS_PERIOD = 200000000;  //  5 Hz
 
     SensorDevice& mSensorDevice;
     Sensor mAcc;
diff --git a/services/sensorservice/SensorInterface.cpp b/services/sensorservice/SensorInterface.cpp
index 2bf5e72..970220b 100644
--- a/services/sensorservice/SensorInterface.cpp
+++ b/services/sensorservice/SensorInterface.cpp
@@ -17,8 +17,6 @@
 #include <stdint.h>
 #include <sys/types.h>
 
-#include <cutils/log.h>
-
 #include "SensorInterface.h"
 
 namespace android {
@@ -34,7 +32,6 @@
     : mSensorDevice(SensorDevice::getInstance()),
       mSensor(&sensor, mSensorDevice.getHalDeviceVersion())
 {
-    ALOGI("%s", sensor.name);
 }
 
 HardwareSensor::~HardwareSensor() {
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index 9cc75c6..db4a4db 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -18,6 +18,7 @@
 #include <math.h>
 #include <stdint.h>
 #include <sys/types.h>
+#include <sys/socket.h>
 
 #include <cutils/properties.h>
 
@@ -30,6 +31,7 @@
 #include <utils/Singleton.h>
 #include <utils/String16.h>
 
+#include <binder/AppOpsManager.h>
 #include <binder/BinderService.h>
 #include <binder/IServiceManager.h>
 #include <binder/PermissionCache.h>
@@ -62,17 +64,19 @@
  *
  */
 
-const char* SensorService::WAKE_LOCK_NAME = "SensorService";
+const char* SensorService::WAKE_LOCK_NAME = "SensorService_wakelock";
+// Permissions.
+static const String16 sDump("android.permission.DUMP");
 
 SensorService::SensorService()
-    : mInitCheck(NO_INIT)
+    : mInitCheck(NO_INIT), mSocketBufferSize(SOCKET_BUFFER_SIZE_NON_BATCHED),
+      mWakeLockAcquired(false)
 {
 }
 
 void SensorService::onFirstRef()
 {
     ALOGD("nuSensorService starting...");
-
     SensorDevice& dev(SensorDevice::getInstance());
 
     if (dev.initCheck() == NO_ERROR) {
@@ -80,7 +84,7 @@
         ssize_t count = dev.getSensorList(&list);
         if (count > 0) {
             ssize_t orientationIndex = -1;
-            bool hasGyro = false;
+            bool hasGyro = false, hasAccel = false, hasMag = false;
             uint32_t virtualSensorsNeeds =
                     (1<<SENSOR_TYPE_GRAVITY) |
                     (1<<SENSOR_TYPE_LINEAR_ACCELERATION) |
@@ -90,6 +94,12 @@
             for (ssize_t i=0 ; i<count ; i++) {
                 registerSensor( new HardwareSensor(list[i]) );
                 switch (list[i].type) {
+                    case SENSOR_TYPE_ACCELEROMETER:
+                        hasAccel = true;
+                        break;
+                    case SENSOR_TYPE_MAGNETIC_FIELD:
+                        hasMag = true;
+                        break;
                     case SENSOR_TYPE_ORIENTATION:
                         orientationIndex = i;
                         break;
@@ -108,12 +118,12 @@
             // it's safe to instantiate the SensorFusion object here
             // (it wants to be instantiated after h/w sensors have been
             // registered)
-            const SensorFusion& fusion(SensorFusion::getInstance());
+            SensorFusion::getInstance();
 
             // build the sensor list returned to users
             mUserSensorList = mSensorList;
 
-            if (hasGyro) {
+            if (hasGyro && hasAccel && hasMag) {
                 Sensor aSensor;
 
                 // Add Android virtual sensors if they're not already
@@ -149,23 +159,56 @@
             // debugging sensor list
             mUserSensorListDebug = mSensorList;
 
-            mSocketBufferSize = SOCKET_BUFFER_SIZE_NON_BATCHED;
+            // Check if the device really supports batching by looking at the FIFO event
+            // counts for each sensor.
+            bool batchingSupported = false;
+            for (size_t i = 0; i < mSensorList.size(); ++i) {
+                if (mSensorList[i].getFifoMaxEventCount() > 0) {
+                    batchingSupported = true;
+                    break;
+                }
+            }
+
+            if (batchingSupported) {
+                // Increase socket buffer size to a max of 100 KB for batching capabilities.
+                mSocketBufferSize = MAX_SOCKET_BUFFER_SIZE_BATCHED;
+            } else {
+                mSocketBufferSize = SOCKET_BUFFER_SIZE_NON_BATCHED;
+            }
+
+            // Compare the socketBufferSize value against the system limits and limit
+            // it to maxSystemSocketBufferSize if necessary.
             FILE *fp = fopen("/proc/sys/net/core/wmem_max", "r");
             char line[128];
             if (fp != NULL && fgets(line, sizeof(line), fp) != NULL) {
                 line[sizeof(line) - 1] = '\0';
-                sscanf(line, "%zu", &mSocketBufferSize);
-                if (mSocketBufferSize > MAX_SOCKET_BUFFER_SIZE_BATCHED) {
-                    mSocketBufferSize = MAX_SOCKET_BUFFER_SIZE_BATCHED;
+                size_t maxSystemSocketBufferSize;
+                sscanf(line, "%zu", &maxSystemSocketBufferSize);
+                if (mSocketBufferSize > maxSystemSocketBufferSize) {
+                    mSocketBufferSize = maxSystemSocketBufferSize;
                 }
             }
-            ALOGD("Max socket buffer size %u", mSocketBufferSize);
             if (fp) {
                 fclose(fp);
             }
 
-            run("SensorService", PRIORITY_URGENT_DISPLAY);
+            mWakeLockAcquired = false;
+            mLooper = new Looper(false);
+            const size_t minBufferSize = SensorEventQueue::MAX_RECEIVE_BUFFER_EVENT_COUNT;
+            mSensorEventBuffer = new sensors_event_t[minBufferSize];
+            mSensorEventScratch = new sensors_event_t[minBufferSize];
+            mMapFlushEventsToConnections = new SensorEventConnection const * [minBufferSize];
+            mCurrentOperatingMode = NORMAL;
+
+            mNextSensorRegIndex = 0;
+            for (int i = 0; i < SENSOR_REGISTRATIONS_BUF_SIZE; ++i) {
+                mLastNSensorRegistrations.push();
+            }
+
             mInitCheck = NO_ERROR;
+            mAckReceiver = new SensorEventAckReceiver(this);
+            mAckReceiver->run("SensorEventAckReceiver", PRIORITY_URGENT_DISPLAY);
+            run("SensorService", PRIORITY_URGENT_DISPLAY);
         }
     }
 }
@@ -181,7 +224,7 @@
     // add to our handle->SensorInterface mapping
     mSensorMap.add(sensor.getHandle(), s);
     // create an entry in the mLastEventSeen array
-    mLastEventSeen.add(sensor.getHandle(), event);
+    mLastEventSeen.add(sensor.getHandle(), NULL);
 
     return sensor;
 }
@@ -199,119 +242,222 @@
         delete mSensorMap.valueAt(i);
 }
 
-static const String16 sDump("android.permission.DUMP");
-
-status_t SensorService::dump(int fd, const Vector<String16>& /*args*/)
+status_t SensorService::dump(int fd, const Vector<String16>& args)
 {
     String8 result;
     if (!PermissionCache::checkCallingPermission(sDump)) {
         result.appendFormat("Permission Denial: "
-                "can't dump SurfaceFlinger from pid=%d, uid=%d\n",
+                "can't dump SensorService from pid=%d, uid=%d\n",
                 IPCThreadState::self()->getCallingPid(),
                 IPCThreadState::self()->getCallingUid());
     } else {
+        if (args.size() > 2) {
+           return INVALID_OPERATION;
+        }
         Mutex::Autolock _l(mLock);
-        result.append("Sensor List:\n");
-        for (size_t i=0 ; i<mSensorList.size() ; i++) {
-            const Sensor& s(mSensorList[i]);
-            const sensors_event_t& e(mLastEventSeen.valueFor(s.getHandle()));
-            result.appendFormat(
-                    "%-48s| %-32s | 0x%08x | ",
-                    s.getName().string(),
-                    s.getVendor().string(),
-                    s.getHandle());
-
-            if (s.getMinDelay() > 0) {
+        SensorDevice& dev(SensorDevice::getInstance());
+        if (args.size() == 2 && args[0] == String16("restrict")) {
+            // If already in restricted mode. Ignore.
+            if (mCurrentOperatingMode == RESTRICTED) {
+                return status_t(NO_ERROR);
+            }
+            // If in any mode other than normal, ignore.
+            if (mCurrentOperatingMode != NORMAL) {
+                return INVALID_OPERATION;
+            }
+            mCurrentOperatingMode = RESTRICTED;
+            dev.disableAllSensors();
+            // Clear all pending flush connections for all active sensors. If one of the active
+            // connections has called flush() and the underlying sensor has been disabled before a
+            // flush complete event is returned, we need to remove the connection from this queue.
+            for (size_t i=0 ; i< mActiveSensors.size(); ++i) {
+                mActiveSensors.valueAt(i)->clearAllPendingFlushConnections();
+            }
+            mWhiteListedPackage.setTo(String8(args[1]));
+            return status_t(NO_ERROR);
+        } else if (args.size() == 1 && args[0] == String16("enable")) {
+            // If currently in restricted mode, reset back to NORMAL mode else ignore.
+            if (mCurrentOperatingMode == RESTRICTED) {
+                mCurrentOperatingMode = NORMAL;
+                dev.enableAllSensors();
+            }
+            if (mCurrentOperatingMode == DATA_INJECTION) {
+               resetToNormalModeLocked();
+            }
+            mWhiteListedPackage.clear();
+            return status_t(NO_ERROR);
+        } else if (args.size() == 2 && args[0] == String16("data_injection")) {
+            if (mCurrentOperatingMode == NORMAL) {
+                dev.disableAllSensors();
+                status_t err = dev.setMode(DATA_INJECTION);
+                if (err == NO_ERROR) {
+                    mCurrentOperatingMode = DATA_INJECTION;
+                } else {
+                    // Re-enable sensors.
+                    dev.enableAllSensors();
+                }
+                mWhiteListedPackage.setTo(String8(args[1]));
+                return NO_ERROR;
+            } else if (mCurrentOperatingMode == DATA_INJECTION) {
+                // Already in DATA_INJECTION mode. Treat this as a no_op.
+                return NO_ERROR;
+            } else {
+                // Transition to data injection mode supported only from NORMAL mode.
+                return INVALID_OPERATION;
+            }
+        } else if (mSensorList.size() == 0) {
+            result.append("No Sensors on the device\n");
+        } else {
+            // Default dump the sensor list and debugging information.
+            result.append("Sensor List:\n");
+            for (size_t i=0 ; i<mSensorList.size() ; i++) {
+                const Sensor& s(mSensorList[i]);
                 result.appendFormat(
-                    "maxRate=%7.2fHz | ", 1e6f / s.getMinDelay());
-            } else {
-                result.append(s.getMinDelay() == 0
-                        ? "on-demand         | "
-                        : "one-shot          | ");
+                        "%-15s| %-10s| version=%d |%-20s| 0x%08x | \"%s\" | type=%d |",
+                        s.getName().string(),
+                        s.getVendor().string(),
+                        s.getVersion(),
+                        s.getStringType().string(),
+                        s.getHandle(),
+                        s.getRequiredPermission().string(),
+                        s.getType());
+
+                const int reportingMode = s.getReportingMode();
+                if (reportingMode == AREPORTING_MODE_CONTINUOUS) {
+                    result.append(" continuous | ");
+                } else if (reportingMode == AREPORTING_MODE_ON_CHANGE) {
+                    result.append(" on-change | ");
+                } else if (reportingMode == AREPORTING_MODE_ONE_SHOT) {
+                    result.append(" one-shot | ");
+                } else {
+                    result.append(" special-trigger | ");
+                }
+
+                if (s.getMaxDelay() > 0) {
+                    result.appendFormat("minRate=%.2fHz | ", 1e6f / s.getMaxDelay());
+                } else {
+                    result.appendFormat("maxDelay=%dus |", s.getMaxDelay());
+                }
+
+                if (s.getMinDelay() > 0) {
+                    result.appendFormat("maxRate=%.2fHz | ", 1e6f / s.getMinDelay());
+                } else {
+                    result.appendFormat("minDelay=%dus |", s.getMinDelay());
+                }
+
+                if (s.getFifoMaxEventCount() > 0) {
+                    result.appendFormat("FifoMax=%d events | ",
+                            s.getFifoMaxEventCount());
+                } else {
+                    result.append("no batching | ");
+                }
+
+                if (s.isWakeUpSensor()) {
+                    result.appendFormat("wakeUp | ");
+                } else {
+                    result.appendFormat("non-wakeUp | ");
+                }
+
+                int bufIndex = mLastEventSeen.indexOfKey(s.getHandle());
+                if (bufIndex >= 0) {
+                    const CircularBuffer* buf = mLastEventSeen.valueAt(bufIndex);
+                    if (buf != NULL && s.getRequiredPermission().isEmpty()) {
+                        buf->printBuffer(result);
+                    } else {
+                        result.append("last=<> \n");
+                    }
+                }
+                result.append("\n");
             }
-            if (s.getFifoMaxEventCount() > 0) {
-                result.appendFormat("getFifoMaxEventCount=%d events | ", s.getFifoMaxEventCount());
-            } else {
-                result.append("no batching support | ");
+            SensorFusion::getInstance().dump(result);
+            SensorDevice::getInstance().dump(result);
+
+            result.append("Active sensors:\n");
+            for (size_t i=0 ; i<mActiveSensors.size() ; i++) {
+                int handle = mActiveSensors.keyAt(i);
+                result.appendFormat("%s (handle=0x%08x, connections=%zu)\n",
+                        getSensorName(handle).string(),
+                        handle,
+                        mActiveSensors.valueAt(i)->getNumConnections());
             }
 
-            switch (s.getType()) {
-                case SENSOR_TYPE_ROTATION_VECTOR:
-                case SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR:
-                    result.appendFormat(
-                            "last=<%5.1f,%5.1f,%5.1f,%5.1f,%5.1f>\n",
-                            e.data[0], e.data[1], e.data[2], e.data[3], e.data[4]);
-                    break;
-                case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED:
-                case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED:
-                    result.appendFormat(
-                            "last=<%5.1f,%5.1f,%5.1f,%5.1f,%5.1f,%5.1f>\n",
-                            e.data[0], e.data[1], e.data[2], e.data[3], e.data[4], e.data[5]);
-                    break;
-                case SENSOR_TYPE_GAME_ROTATION_VECTOR:
-                    result.appendFormat(
-                            "last=<%5.1f,%5.1f,%5.1f,%5.1f>\n",
-                            e.data[0], e.data[1], e.data[2], e.data[3]);
-                    break;
-                case SENSOR_TYPE_SIGNIFICANT_MOTION:
-                case SENSOR_TYPE_STEP_DETECTOR:
-                    result.appendFormat( "last=<%f>\n", e.data[0]);
-                    break;
-                case SENSOR_TYPE_STEP_COUNTER:
-                    result.appendFormat( "last=<%" PRIu64 ">\n", e.u64.step_counter);
-                    break;
-                default:
-                    // default to 3 values
-                    result.appendFormat(
-                            "last=<%5.1f,%5.1f,%5.1f>\n",
-                            e.data[0], e.data[1], e.data[2]);
-                    break;
+            result.appendFormat("Socket Buffer size = %zd events\n",
+                                mSocketBufferSize/sizeof(sensors_event_t));
+            result.appendFormat("WakeLock Status: %s \n", mWakeLockAcquired ? "acquired" :
+                    "not held");
+            result.appendFormat("Mode :");
+            switch(mCurrentOperatingMode) {
+               case NORMAL:
+                   result.appendFormat(" NORMAL\n");
+                   break;
+               case RESTRICTED:
+                   result.appendFormat(" RESTRICTED : %s\n", mWhiteListedPackage.string());
+                   break;
+               case DATA_INJECTION:
+                   result.appendFormat(" DATA_INJECTION : %s\n", mWhiteListedPackage.string());
             }
-        }
-        SensorFusion::getInstance().dump(result);
-        SensorDevice::getInstance().dump(result);
+            result.appendFormat("%zd active connections\n", mActiveConnections.size());
 
-        result.append("Active sensors:\n");
-        for (size_t i=0 ; i<mActiveSensors.size() ; i++) {
-            int handle = mActiveSensors.keyAt(i);
-            result.appendFormat("%s (handle=0x%08x, connections=%zu)\n",
-                    getSensorName(handle).string(),
-                    handle,
-                    mActiveSensors.valueAt(i)->getNumConnections());
-        }
-
-        result.appendFormat("%zu Max Socket Buffer size\n", mSocketBufferSize);
-        result.appendFormat("%zd active connections\n", mActiveConnections.size());
-
-        for (size_t i=0 ; i < mActiveConnections.size() ; i++) {
-            sp<SensorEventConnection> connection(mActiveConnections[i].promote());
-            if (connection != 0) {
-                result.appendFormat("Connection Number: %zu \n", i);
-                connection->dump(result);
+            for (size_t i=0 ; i < mActiveConnections.size() ; i++) {
+                sp<SensorEventConnection> connection(mActiveConnections[i].promote());
+                if (connection != 0) {
+                    result.appendFormat("Connection Number: %zu \n", i);
+                    connection->dump(result);
+                }
             }
+
+            result.appendFormat("Previous Registrations:\n");
+            // Log in the reverse chronological order.
+            int currentIndex = (mNextSensorRegIndex - 1 + SENSOR_REGISTRATIONS_BUF_SIZE) %
+                SENSOR_REGISTRATIONS_BUF_SIZE;
+            const int startIndex = currentIndex;
+            do {
+                const SensorRegistrationInfo& reg_info = mLastNSensorRegistrations[currentIndex];
+                if (SensorRegistrationInfo::isSentinel(reg_info)) {
+                    // Ignore sentinel, proceed to next item.
+                    currentIndex = (currentIndex - 1 + SENSOR_REGISTRATIONS_BUF_SIZE) %
+                        SENSOR_REGISTRATIONS_BUF_SIZE;
+                    continue;
+                }
+                if (reg_info.mActivated) {
+                   result.appendFormat("%02d:%02d:%02d activated package=%s handle=0x%08x "
+                           "samplingRate=%dus maxReportLatency=%dus\n",
+                           reg_info.mHour, reg_info.mMin, reg_info.mSec,
+                           reg_info.mPackageName.string(), reg_info.mSensorHandle,
+                           reg_info.mSamplingRateUs, reg_info.mMaxReportLatencyUs);
+                } else {
+                   result.appendFormat("%02d:%02d:%02d de-activated package=%s handle=0x%08x\n",
+                           reg_info.mHour, reg_info.mMin, reg_info.mSec,
+                           reg_info.mPackageName.string(), reg_info.mSensorHandle);
+                }
+                currentIndex = (currentIndex - 1 + SENSOR_REGISTRATIONS_BUF_SIZE) %
+                        SENSOR_REGISTRATIONS_BUF_SIZE;
+            } while(startIndex != currentIndex);
         }
     }
     write(fd, result.string(), result.size());
     return NO_ERROR;
 }
 
-void SensorService::cleanupAutoDisabledSensor(const sp<SensorEventConnection>& connection,
+void SensorService::cleanupAutoDisabledSensorLocked(const sp<SensorEventConnection>& connection,
         sensors_event_t const* buffer, const int count) {
-    SensorInterface* sensor;
-    status_t err = NO_ERROR;
     for (int i=0 ; i<count ; i++) {
         int handle = buffer[i].sensor;
-        int type = buffer[i].type;
-        if (type == SENSOR_TYPE_SIGNIFICANT_MOTION) {
-            if (connection->hasSensor(handle)) {
-                sensor = mSensorMap.valueFor(handle);
-                if (sensor != NULL) {
-                    sensor->autoDisable(connection.get(), handle);
-                }
-                cleanupWithoutDisable(connection, handle);
-            }
+        if (buffer[i].type == SENSOR_TYPE_META_DATA) {
+            handle = buffer[i].meta_data.sensor;
         }
-    }
+        if (connection->hasSensor(handle)) {
+            SensorInterface* sensor = mSensorMap.valueFor(handle);
+            // If this buffer has an event from a one_shot sensor and this connection is registered
+            // for this particular one_shot sensor, try cleaning up the connection.
+            if (sensor != NULL &&
+                sensor->getSensor().getReportingMode() == AREPORTING_MODE_ONE_SHOT) {
+                sensor->autoDisable(connection.get(), handle);
+                cleanupWithoutDisableLocked(connection, handle);
+            }
+
+        }
+   }
 }
 
 bool SensorService::threadLoop()
@@ -324,40 +470,53 @@
     const size_t minBufferSize = SensorEventQueue::MAX_RECEIVE_BUFFER_EVENT_COUNT;
     const size_t numEventMax = minBufferSize / (1 + mVirtualSensorList.size());
 
-    sensors_event_t buffer[minBufferSize];
-    sensors_event_t scratch[minBufferSize];
     SensorDevice& device(SensorDevice::getInstance());
     const size_t vcount = mVirtualSensorList.size();
 
-    ssize_t count;
-    bool wakeLockAcquired = false;
     const int halVersion = device.getHalDeviceVersion();
     do {
-        count = device.poll(buffer, numEventMax);
-        if (count<0) {
+        ssize_t count = device.poll(mSensorEventBuffer, numEventMax);
+        if (count < 0) {
             ALOGE("sensor poll failed (%s)", strerror(-count));
             break;
         }
 
-        // Poll has returned. Hold a wakelock.
-        // Todo(): add a flag to the sensors definitions to indicate
-        // the sensors which can wake up the AP
+        // Reset sensors_event_t.flags to zero for all events in the buffer.
         for (int i = 0; i < count; i++) {
-            if (buffer[i].type == SENSOR_TYPE_SIGNIFICANT_MOTION) {
-                 acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_NAME);
-                 wakeLockAcquired = true;
-                 break;
+             mSensorEventBuffer[i].flags = 0;
+        }
+
+        // Make a copy of the connection vector as some connections may be removed during the
+        // course of this loop (especially when one-shot sensor events are present in the
+        // sensor_event buffer). Promote all connections to StrongPointers before the lock is
+        // acquired. If the destructor of the sp gets called when the lock is acquired, it may
+        // result in a deadlock as ~SensorEventConnection() needs to acquire mLock again for
+        // cleanup. So copy all the strongPointers to a vector before the lock is acquired.
+        SortedVector< sp<SensorEventConnection> > activeConnections;
+        populateActiveConnections(&activeConnections);
+        Mutex::Autolock _l(mLock);
+        // Poll has returned. Hold a wakelock if one of the events is from a wake up sensor. The
+        // rest of this loop is under a critical section protected by mLock. Acquiring a wakeLock,
+        // sending events to clients (incrementing SensorEventConnection::mWakeLockRefCount) should
+        // not be interleaved with decrementing SensorEventConnection::mWakeLockRefCount and
+        // releasing the wakelock.
+        bool bufferHasWakeUpEvent = false;
+        for (int i = 0; i < count; i++) {
+            if (isWakeUpSensorEvent(mSensorEventBuffer[i])) {
+                bufferHasWakeUpEvent = true;
+                break;
             }
         }
 
-        recordLastValue(buffer, count);
+        if (bufferHasWakeUpEvent && !mWakeLockAcquired) {
+            setWakeLockAcquiredLocked(true);
+        }
+        recordLastValueLocked(mSensorEventBuffer, count);
 
         // handle virtual sensors
         if (count && vcount) {
-            sensors_event_t const * const event = buffer;
-            const DefaultKeyedVector<int, SensorInterface*> virtualSensors(
-                    getActiveVirtualSensors());
-            const size_t activeVirtualSensorCount = virtualSensors.size();
+            sensors_event_t const * const event = mSensorEventBuffer;
+            const size_t activeVirtualSensorCount = mActiveVirtualSensors.size();
             if (activeVirtualSensorCount) {
                 size_t k = 0;
                 SensorFusion& fusion(SensorFusion::getInstance());
@@ -370,24 +529,24 @@
                     for (size_t j=0 ; j<activeVirtualSensorCount ; j++) {
                         if (count + k >= minBufferSize) {
                             ALOGE("buffer too small to hold all events: "
-                                    "count=%u, k=%u, size=%u",
+                                    "count=%zd, k=%zu, size=%zu",
                                     count, k, minBufferSize);
                             break;
                         }
                         sensors_event_t out;
-                        SensorInterface* si = virtualSensors.valueAt(j);
+                        SensorInterface* si = mActiveVirtualSensors.valueAt(j);
                         if (si->process(&out, event[i])) {
-                            buffer[count + k] = out;
+                            mSensorEventBuffer[count + k] = out;
                             k++;
                         }
                     }
                 }
                 if (k) {
                     // record the last synthesized values
-                    recordLastValue(&buffer[count], k);
+                    recordLastValueLocked(&mSensorEventBuffer[count], k);
                     count += k;
                     // sort the buffer by time-stamps
-                    sortEventBuffer(buffer, count);
+                    sortEventBuffer(mSensorEventBuffer, count);
                 }
             }
         }
@@ -395,52 +554,122 @@
         // handle backward compatibility for RotationVector sensor
         if (halVersion < SENSORS_DEVICE_API_VERSION_1_0) {
             for (int i = 0; i < count; i++) {
-                if (buffer[i].type == SENSOR_TYPE_ROTATION_VECTOR) {
+                if (mSensorEventBuffer[i].type == SENSOR_TYPE_ROTATION_VECTOR) {
                     // All the 4 components of the quaternion should be available
                     // No heading accuracy. Set it to -1
-                    buffer[i].data[4] = -1;
+                    mSensorEventBuffer[i].data[4] = -1;
                 }
             }
         }
 
-        // send our events to clients...
-        const SortedVector< wp<SensorEventConnection> > activeConnections(
-                getActiveConnections());
-        size_t numConnections = activeConnections.size();
-        for (size_t i=0 ; i<numConnections ; i++) {
-            sp<SensorEventConnection> connection(
-                    activeConnections[i].promote());
-            if (connection != 0) {
-                connection->sendEvents(buffer, count, scratch);
-                // Some sensors need to be auto disabled after the trigger
-                cleanupAutoDisabledSensor(connection, buffer, count);
+        // Map flush_complete_events in the buffer to SensorEventConnections which called
+        // flush on the hardware sensor. mapFlushEventsToConnections[i] will be the
+        // SensorEventConnection mapped to the corresponding flush_complete_event in
+        // mSensorEventBuffer[i] if such a mapping exists (NULL otherwise).
+        for (int i = 0; i < count; ++i) {
+            mMapFlushEventsToConnections[i] = NULL;
+            if (mSensorEventBuffer[i].type == SENSOR_TYPE_META_DATA) {
+                const int sensor_handle = mSensorEventBuffer[i].meta_data.sensor;
+                SensorRecord* rec = mActiveSensors.valueFor(sensor_handle);
+                if (rec != NULL) {
+                    mMapFlushEventsToConnections[i] = rec->getFirstPendingFlushConnection();
+                    rec->removeFirstPendingFlushConnection();
+                }
             }
         }
 
-        // We have read the data, upper layers should hold the wakelock.
-        if (wakeLockAcquired) release_wake_lock(WAKE_LOCK_NAME);
-    } while (count >= 0 || Thread::exitPending());
+        // Send our events to clients. Check the state of wake lock for each client and release the
+        // lock if none of the clients need it.
+        bool needsWakeLock = false;
+        size_t numConnections = activeConnections.size();
+        for (size_t i=0 ; i < numConnections; ++i) {
+            if (activeConnections[i] != 0) {
+                activeConnections[i]->sendEvents(mSensorEventBuffer, count, mSensorEventScratch,
+                        mMapFlushEventsToConnections);
+                needsWakeLock |= activeConnections[i]->needsWakeLock();
+                // If the connection has one-shot sensors, it may be cleaned up after first trigger.
+                // Early check for one-shot sensors.
+                if (activeConnections[i]->hasOneShotSensors()) {
+                    cleanupAutoDisabledSensorLocked(activeConnections[i], mSensorEventBuffer,
+                            count);
+                }
+            }
+        }
+
+        if (mWakeLockAcquired && !needsWakeLock) {
+            setWakeLockAcquiredLocked(false);
+        }
+    } while (!Thread::exitPending());
 
     ALOGW("Exiting SensorService::threadLoop => aborting...");
     abort();
     return false;
 }
 
-void SensorService::recordLastValue(
-        sensors_event_t const * buffer, size_t count)
-{
-    Mutex::Autolock _l(mLock);
-    // record the last event for each sensor
-    int32_t prev = buffer[0].sensor;
-    for (size_t i=1 ; i<count ; i++) {
-        // record the last event of each sensor type in this buffer
-        int32_t curr = buffer[i].sensor;
-        if (curr != prev) {
-            mLastEventSeen.editValueFor(prev) = buffer[i-1];
-            prev = curr;
+sp<Looper> SensorService::getLooper() const {
+    return mLooper;
+}
+
+void SensorService::resetAllWakeLockRefCounts() {
+    SortedVector< sp<SensorEventConnection> > activeConnections;
+    populateActiveConnections(&activeConnections);
+    {
+        Mutex::Autolock _l(mLock);
+        for (size_t i=0 ; i < activeConnections.size(); ++i) {
+            if (activeConnections[i] != 0) {
+                activeConnections[i]->resetWakeLockRefCount();
+            }
+        }
+        setWakeLockAcquiredLocked(false);
+    }
+}
+
+void SensorService::setWakeLockAcquiredLocked(bool acquire) {
+    if (acquire) {
+        if (!mWakeLockAcquired) {
+            acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_NAME);
+            mWakeLockAcquired = true;
+        }
+        mLooper->wake();
+    } else {
+        if (mWakeLockAcquired) {
+            release_wake_lock(WAKE_LOCK_NAME);
+            mWakeLockAcquired = false;
         }
     }
-    mLastEventSeen.editValueFor(prev) = buffer[count-1];
+}
+
+bool SensorService::isWakeLockAcquired() {
+    Mutex::Autolock _l(mLock);
+    return mWakeLockAcquired;
+}
+
+bool SensorService::SensorEventAckReceiver::threadLoop() {
+    ALOGD("new thread SensorEventAckReceiver");
+    sp<Looper> looper = mService->getLooper();
+    do {
+        bool wakeLockAcquired = mService->isWakeLockAcquired();
+        int timeout = -1;
+        if (wakeLockAcquired) timeout = 5000;
+        int ret = looper->pollOnce(timeout);
+        if (ret == ALOOPER_POLL_TIMEOUT) {
+           mService->resetAllWakeLockRefCounts();
+        }
+    } while(!Thread::exitPending());
+    return false;
+}
+
+void SensorService::recordLastValueLocked(
+        const sensors_event_t* buffer, size_t count) {
+    for (size_t i = 0; i < count; i++) {
+        if (buffer[i].type != SENSOR_TYPE_META_DATA) {
+            CircularBuffer* &circular_buf = mLastEventSeen.editValueFor(buffer[i].sensor);
+            if (circular_buf == NULL) {
+                circular_buf = new CircularBuffer(buffer[i].type);
+            }
+            circular_buf->addEvent(buffer[i]);
+        }
+    }
 }
 
 void SensorService::sortEventBuffer(sensors_event_t* buffer, size_t count)
@@ -455,20 +684,6 @@
     qsort(buffer, count, sizeof(sensors_event_t), compar::cmp);
 }
 
-SortedVector< wp<SensorService::SensorEventConnection> >
-SensorService::getActiveConnections() const
-{
-    Mutex::Autolock _l(mLock);
-    return mActiveConnections;
-}
-
-DefaultKeyedVector<int, SensorInterface*>
-SensorService::getActiveVirtualSensors() const
-{
-    Mutex::Autolock _l(mLock);
-    return mActiveVirtualSensors;
-}
-
 String8 SensorService::getSensorName(int handle) const {
     size_t count = mUserSensorList.size();
     for (size_t i=0 ; i<count ; i++) {
@@ -486,43 +701,108 @@
     return sensor->isVirtual();
 }
 
-Vector<Sensor> SensorService::getSensorList()
+bool SensorService::isWakeUpSensorEvent(const sensors_event_t& event) const {
+    int handle = event.sensor;
+    if (event.type == SENSOR_TYPE_META_DATA) {
+        handle = event.meta_data.sensor;
+    }
+    SensorInterface* sensor = mSensorMap.valueFor(handle);
+    return sensor != NULL && sensor->getSensor().isWakeUpSensor();
+}
+
+SensorService::SensorRecord * SensorService::getSensorRecord(int handle) {
+     return mActiveSensors.valueFor(handle);
+}
+
+Vector<Sensor> SensorService::getSensorList(const String16& opPackageName)
 {
     char value[PROPERTY_VALUE_MAX];
     property_get("debug.sensors", value, "0");
-    if (atoi(value)) {
-        return mUserSensorListDebug;
+    const Vector<Sensor>& initialSensorList = (atoi(value)) ?
+            mUserSensorListDebug : mUserSensorList;
+    Vector<Sensor> accessibleSensorList;
+    for (size_t i = 0; i < initialSensorList.size(); i++) {
+        Sensor sensor = initialSensorList[i];
+        if (canAccessSensor(sensor, "getSensorList", opPackageName)) {
+            accessibleSensorList.add(sensor);
+        } else {
+            ALOGI("Skipped sensor %s because it requires permission %s and app op %d",
+                  sensor.getName().string(),
+                  sensor.getRequiredPermission().string(),
+                  sensor.getRequiredAppOp());
+        }
     }
-    return mUserSensorList;
+    return accessibleSensorList;
 }
 
-sp<ISensorEventConnection> SensorService::createSensorEventConnection()
-{
+sp<ISensorEventConnection> SensorService::createSensorEventConnection(const String8& packageName,
+        int requestedMode, const String16& opPackageName) {
+    // Only 2 modes supported for a SensorEventConnection ... NORMAL and DATA_INJECTION.
+    if (requestedMode != NORMAL && requestedMode != DATA_INJECTION) {
+        return NULL;
+    }
+
+    Mutex::Autolock _l(mLock);
+    // To create a client in DATA_INJECTION mode to inject data, SensorService should already be
+    // operating in DI mode.
+    if (requestedMode == DATA_INJECTION) {
+        if (mCurrentOperatingMode != DATA_INJECTION) return NULL;
+        if (!isWhiteListedPackage(packageName)) return NULL;
+    }
+
     uid_t uid = IPCThreadState::self()->getCallingUid();
-    sp<SensorEventConnection> result(new SensorEventConnection(this, uid));
+    sp<SensorEventConnection> result(new SensorEventConnection(this, uid, packageName,
+            requestedMode == DATA_INJECTION, opPackageName));
+    if (requestedMode == DATA_INJECTION) {
+        if (mActiveConnections.indexOf(result) < 0) {
+            mActiveConnections.add(result);
+        }
+        // Add the associated file descriptor to the Looper for polling whenever there is data to
+        // be injected.
+        result->updateLooperRegistration(mLooper);
+    }
     return result;
 }
 
+int SensorService::isDataInjectionEnabled() {
+    Mutex::Autolock _l(mLock);
+    return (mCurrentOperatingMode == DATA_INJECTION);
+}
+
+status_t SensorService::resetToNormalMode() {
+    Mutex::Autolock _l(mLock);
+    return resetToNormalModeLocked();
+}
+
+status_t SensorService::resetToNormalModeLocked() {
+    SensorDevice& dev(SensorDevice::getInstance());
+    dev.enableAllSensors();
+    status_t err = dev.setMode(NORMAL);
+    mCurrentOperatingMode = NORMAL;
+    return err;
+}
+
 void SensorService::cleanupConnection(SensorEventConnection* c)
 {
     Mutex::Autolock _l(mLock);
     const wp<SensorEventConnection> connection(c);
     size_t size = mActiveSensors.size();
-    ALOGD_IF(DEBUG_CONNECTIONS, "%d active sensors", size);
+    ALOGD_IF(DEBUG_CONNECTIONS, "%zu active sensors", size);
     for (size_t i=0 ; i<size ; ) {
         int handle = mActiveSensors.keyAt(i);
         if (c->hasSensor(handle)) {
-            ALOGD_IF(DEBUG_CONNECTIONS, "%i: disabling handle=0x%08x", i, handle);
+            ALOGD_IF(DEBUG_CONNECTIONS, "%zu: disabling handle=0x%08x", i, handle);
             SensorInterface* sensor = mSensorMap.valueFor( handle );
             ALOGE_IF(!sensor, "mSensorMap[handle=0x%08x] is null!", handle);
             if (sensor) {
                 sensor->activate(c, false);
             }
+            c->removeSensor(handle);
         }
         SensorRecord* rec = mActiveSensors.valueAt(i);
-        ALOGE_IF(!rec, "mActiveSensors[%d] is null (handle=0x%08x)!", i, handle);
+        ALOGE_IF(!rec, "mActiveSensors[%zu] is null (handle=0x%08x)!", i, handle);
         ALOGD_IF(DEBUG_CONNECTIONS,
-                "removing connection %p for sensor[%d].handle=0x%08x",
+                "removing connection %p for sensor[%zu].handle=0x%08x",
                 c, i, handle);
 
         if (rec && rec->removeConnection(connection)) {
@@ -535,12 +815,21 @@
             i++;
         }
     }
+    c->updateLooperRegistration(mLooper);
     mActiveConnections.remove(connection);
     BatteryService::cleanup(c->getUid());
+    if (c->needsWakeLock()) {
+        checkWakeLockStateLocked();
+    }
+}
+
+Sensor SensorService::getSensorFromHandle(int handle) const {
+    return mSensorMap.valueFor(handle)->getSensor();
 }
 
 status_t SensorService::enable(const sp<SensorEventConnection>& connection,
-        int handle, nsecs_t samplingPeriodNs,  nsecs_t maxBatchReportLatencyNs, int reservedFlags)
+        int handle, nsecs_t samplingPeriodNs, nsecs_t maxBatchReportLatencyNs, int reservedFlags,
+        const String16& opPackageName)
 {
     if (mInitCheck != NO_ERROR)
         return mInitCheck;
@@ -549,7 +838,17 @@
     if (sensor == NULL) {
         return BAD_VALUE;
     }
+
+    if (!canAccessSensor(sensor->getSensor(), "Tried enabling", opPackageName)) {
+        return BAD_VALUE;
+    }
+
     Mutex::Autolock _l(mLock);
+    if ((mCurrentOperatingMode == RESTRICTED || mCurrentOperatingMode == DATA_INJECTION)
+           && !isWhiteListedPackage(connection->getPackageName())) {
+        return INVALID_OPERATION;
+    }
+
     SensorRecord* rec = mActiveSensors.valueFor(handle);
     if (rec == 0) {
         rec = new SensorRecord(connection);
@@ -559,15 +858,31 @@
         }
     } else {
         if (rec->addConnection(connection)) {
-            // this sensor is already activated, but we are adding a
-            // connection that uses it. Immediately send down the last
-            // known value of the requested sensor if it's not a
+            // this sensor is already activated, but we are adding a connection that uses it.
+            // Immediately send down the last known value of the requested sensor if it's not a
             // "continuous" sensor.
-            if (sensor->getSensor().getMinDelay() == 0) {
-                sensors_event_t scratch;
-                sensors_event_t& event(mLastEventSeen.editValueFor(handle));
-                if (event.version == sizeof(sensors_event_t)) {
-                    connection->sendEvents(&event, 1);
+            if (sensor->getSensor().getReportingMode() == AREPORTING_MODE_ON_CHANGE) {
+                // NOTE: The wake_up flag of this event may get set to
+                // WAKE_UP_SENSOR_EVENT_NEEDS_ACK if this is a wake_up event.
+                CircularBuffer *circular_buf = mLastEventSeen.valueFor(handle);
+                if (circular_buf) {
+                    sensors_event_t event;
+                    memset(&event, 0, sizeof(event));
+                    // It is unlikely that this buffer is empty as the sensor is already active.
+                    // One possible corner case may be two applications activating an on-change
+                    // sensor at the same time.
+                    if(circular_buf->populateLastEvent(&event)) {
+                        event.sensor = handle;
+                        if (event.version == sizeof(sensors_event_t)) {
+                            if (isWakeUpSensorEvent(event) && !mWakeLockAcquired) {
+                                setWakeLockAcquiredLocked(true);
+                            }
+                            connection->sendEvents(&event, 1, NULL);
+                            if (!connection->needsWakeLock() && mWakeLockAcquired) {
+                                checkWakeLockStateLocked();
+                            }
+                        }
+                    }
                 }
             }
         }
@@ -590,17 +905,29 @@
         samplingPeriodNs = minDelayNs;
     }
 
-    ALOGD_IF(DEBUG_CONNECTIONS, "Calling batch handle==%d flags=%d rate=%lld timeout== %lld",
+    ALOGD_IF(DEBUG_CONNECTIONS, "Calling batch handle==%d flags=%d"
+                                "rate=%" PRId64 " timeout== %" PRId64"",
              handle, reservedFlags, samplingPeriodNs, maxBatchReportLatencyNs);
 
-    status_t err = sensor->batch(connection.get(), handle, reservedFlags, samplingPeriodNs,
+    status_t err = sensor->batch(connection.get(), handle, 0, samplingPeriodNs,
                                  maxBatchReportLatencyNs);
-    if (err == NO_ERROR) {
+
+    // Call flush() before calling activate() on the sensor. Wait for a first
+    // flush complete event before sending events on this connection. Ignore
+    // one-shot sensors which don't support flush(). Ignore on-change sensors
+    // to maintain the on-change logic (any on-change events except the initial
+    // one should be trigger by a change in value). Also if this sensor isn't
+    // already active, don't call flush().
+    if (err == NO_ERROR &&
+            sensor->getSensor().getReportingMode() != AREPORTING_MODE_ONE_SHOT &&
+            sensor->getSensor().getReportingMode() != AREPORTING_MODE_ON_CHANGE &&
+            rec->getNumConnections() > 1) {
         connection->setFirstFlushPending(handle, true);
         status_t err_flush = sensor->flush(connection.get(), handle);
-        // Flush may return error if the sensor is not activated or the underlying h/w sensor does
-        // not support flush.
-        if (err_flush != NO_ERROR) {
+        // Flush may return error if the underlying h/w sensor uses an older HAL.
+        if (err_flush == NO_ERROR) {
+            rec->addPendingFlushConnection(connection.get());
+        } else {
             connection->setFirstFlushPending(handle, false);
         }
     }
@@ -610,6 +937,23 @@
         err = sensor->activate(connection.get(), true);
     }
 
+    if (err == NO_ERROR) {
+        connection->updateLooperRegistration(mLooper);
+        SensorRegistrationInfo &reg_info =
+            mLastNSensorRegistrations.editItemAt(mNextSensorRegIndex);
+        reg_info.mSensorHandle = handle;
+        reg_info.mSamplingRateUs = samplingPeriodNs/1000;
+        reg_info.mMaxReportLatencyUs = maxBatchReportLatencyNs/1000;
+        reg_info.mActivated = true;
+        reg_info.mPackageName = connection->getPackageName();
+        time_t rawtime = time(NULL);
+        struct tm * timeinfo = localtime(&rawtime);
+        reg_info.mHour = timeinfo->tm_hour;
+        reg_info.mMin = timeinfo->tm_min;
+        reg_info.mSec = timeinfo->tm_sec;
+        mNextSensorRegIndex = (mNextSensorRegIndex + 1) % SENSOR_REGISTRATIONS_BUF_SIZE;
+    }
+
     if (err != NO_ERROR) {
         // batch/activate has failed, reset our state.
         cleanupWithoutDisableLocked(connection, handle);
@@ -628,6 +972,20 @@
     if (err == NO_ERROR) {
         SensorInterface* sensor = mSensorMap.valueFor(handle);
         err = sensor ? sensor->activate(connection.get(), false) : status_t(BAD_VALUE);
+
+    }
+    if (err == NO_ERROR) {
+        SensorRegistrationInfo &reg_info =
+            mLastNSensorRegistrations.editItemAt(mNextSensorRegIndex);
+        reg_info.mActivated = false;
+        reg_info.mPackageName= connection->getPackageName();
+        reg_info.mSensorHandle = handle;
+        time_t rawtime = time(NULL);
+        struct tm * timeinfo = localtime(&rawtime);
+        reg_info.mHour = timeinfo->tm_hour;
+        reg_info.mMin = timeinfo->tm_min;
+        reg_info.mSec = timeinfo->tm_sec;
+        mNextSensorRegIndex = (mNextSensorRegIndex + 1) % SENSOR_REGISTRATIONS_BUF_SIZE;
     }
     return err;
 }
@@ -647,6 +1005,7 @@
             BatteryService::disableSensor(connection->getUid(), handle);
         }
         if (connection->hasAnySensor() == false) {
+            connection->updateLooperRegistration(mLooper);
             mActiveConnections.remove(connection);
         }
         // see if this sensor becomes inactive
@@ -661,7 +1020,7 @@
 }
 
 status_t SensorService::setEventRate(const sp<SensorEventConnection>& connection,
-        int handle, nsecs_t ns)
+        int handle, nsecs_t ns, const String16& opPackageName)
 {
     if (mInitCheck != NO_ERROR)
         return mInitCheck;
@@ -670,6 +1029,10 @@
     if (!sensor)
         return BAD_VALUE;
 
+    if (!canAccessSensor(sensor->getSensor(), "Tried configuring", opPackageName)) {
+        return BAD_VALUE;
+    }
+
     if (ns < 0)
         return BAD_VALUE;
 
@@ -682,20 +1045,150 @@
 }
 
 status_t SensorService::flushSensor(const sp<SensorEventConnection>& connection,
-                                    int handle) {
-  if (mInitCheck != NO_ERROR) return mInitCheck;
-  SensorInterface* sensor = mSensorMap.valueFor(handle);
-  if (sensor == NULL) {
-      return BAD_VALUE;
-  }
-  if (sensor->getSensor().getType() == SENSOR_TYPE_SIGNIFICANT_MOTION) {
-      ALOGE("flush called on Significant Motion sensor");
-      return INVALID_OPERATION;
-  }
-  return sensor->flush(connection.get(), handle);
+        const String16& opPackageName) {
+    if (mInitCheck != NO_ERROR) return mInitCheck;
+    SensorDevice& dev(SensorDevice::getInstance());
+    const int halVersion = dev.getHalDeviceVersion();
+    status_t err(NO_ERROR);
+    Mutex::Autolock _l(mLock);
+    // Loop through all sensors for this connection and call flush on each of them.
+    for (size_t i = 0; i < connection->mSensorInfo.size(); ++i) {
+        const int handle = connection->mSensorInfo.keyAt(i);
+        SensorInterface* sensor = mSensorMap.valueFor(handle);
+        if (sensor->getSensor().getReportingMode() == AREPORTING_MODE_ONE_SHOT) {
+            ALOGE("flush called on a one-shot sensor");
+            err = INVALID_OPERATION;
+            continue;
+        }
+        if (halVersion <= SENSORS_DEVICE_API_VERSION_1_0 || isVirtualSensor(handle)) {
+            // For older devices just increment pending flush count which will send a trivial
+            // flush complete event.
+            connection->incrementPendingFlushCount(handle);
+        } else {
+            if (!canAccessSensor(sensor->getSensor(), "Tried flushing", opPackageName)) {
+                err = INVALID_OPERATION;
+                continue;
+            }
+            status_t err_flush = sensor->flush(connection.get(), handle);
+            if (err_flush == NO_ERROR) {
+                SensorRecord* rec = mActiveSensors.valueFor(handle);
+                if (rec != NULL) rec->addPendingFlushConnection(connection);
+            }
+            err = (err_flush != NO_ERROR) ? err_flush : err;
+        }
+    }
+    return err;
 }
-// ---------------------------------------------------------------------------
 
+bool SensorService::canAccessSensor(const Sensor& sensor, const char* operation,
+        const String16& opPackageName) {
+    const String8& requiredPermission = sensor.getRequiredPermission();
+
+    if (requiredPermission.length() <= 0) {
+        return true;
+    }
+
+    bool hasPermission = false;
+
+    // Runtime permissions can't use the cache as they may change.
+    if (sensor.isRequiredPermissionRuntime()) {
+        hasPermission = checkPermission(String16(requiredPermission),
+                IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid());
+    } else {
+        hasPermission = PermissionCache::checkCallingPermission(String16(requiredPermission));
+    }
+
+    if (!hasPermission) {
+        ALOGE("%s a sensor (%s) without holding its required permission: %s",
+                operation, sensor.getName().string(), sensor.getRequiredPermission().string());
+        return false;
+    }
+
+    const int32_t opCode = sensor.getRequiredAppOp();
+    if (opCode >= 0) {
+        AppOpsManager appOps;
+        if (appOps.noteOp(opCode, IPCThreadState::self()->getCallingUid(), opPackageName)
+                        != AppOpsManager::MODE_ALLOWED) {
+            ALOGE("%s a sensor (%s) without enabled required app op: %d",
+                    operation, sensor.getName().string(), opCode);
+            return false;
+        }
+    }
+
+    return true;
+}
+
+void SensorService::checkWakeLockState() {
+    Mutex::Autolock _l(mLock);
+    checkWakeLockStateLocked();
+}
+
+void SensorService::checkWakeLockStateLocked() {
+    if (!mWakeLockAcquired) {
+        return;
+    }
+    bool releaseLock = true;
+    for (size_t i=0 ; i<mActiveConnections.size() ; i++) {
+        sp<SensorEventConnection> connection(mActiveConnections[i].promote());
+        if (connection != 0) {
+            if (connection->needsWakeLock()) {
+                releaseLock = false;
+                break;
+            }
+        }
+    }
+    if (releaseLock) {
+        setWakeLockAcquiredLocked(false);
+    }
+}
+
+void SensorService::sendEventsFromCache(const sp<SensorEventConnection>& connection) {
+    Mutex::Autolock _l(mLock);
+    connection->writeToSocketFromCache();
+    if (connection->needsWakeLock()) {
+        setWakeLockAcquiredLocked(true);
+    }
+}
+
+void SensorService::populateActiveConnections(
+        SortedVector< sp<SensorEventConnection> >* activeConnections) {
+    Mutex::Autolock _l(mLock);
+    for (size_t i=0 ; i < mActiveConnections.size(); ++i) {
+        sp<SensorEventConnection> connection(mActiveConnections[i].promote());
+        if (connection != 0) {
+            activeConnections->add(connection);
+        }
+    }
+}
+
+bool SensorService::isWhiteListedPackage(const String8& packageName) {
+    return (packageName.contains(mWhiteListedPackage.string()));
+}
+
+int SensorService::getNumEventsForSensorType(int sensor_event_type) {
+    switch (sensor_event_type) {
+        case SENSOR_TYPE_ROTATION_VECTOR:
+        case SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR:
+            return 5;
+
+        case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED:
+        case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED:
+            return 6;
+
+        case SENSOR_TYPE_GAME_ROTATION_VECTOR:
+            return 4;
+
+        case SENSOR_TYPE_SIGNIFICANT_MOTION:
+        case SENSOR_TYPE_STEP_DETECTOR:
+        case SENSOR_TYPE_STEP_COUNTER:
+            return 1;
+
+         default:
+            return 3;
+    }
+}
+
+// ---------------------------------------------------------------------------
 SensorService::SensorRecord::SensorRecord(
         const sp<SensorEventConnection>& connection)
 {
@@ -719,48 +1212,215 @@
     if (index >= 0) {
         mConnections.removeItemsAt(index, 1);
     }
+    // Remove this connections from the queue of flush() calls made on this sensor.
+    for (Vector< wp<SensorEventConnection> >::iterator it =
+            mPendingFlushConnections.begin(); it != mPendingFlushConnections.end();) {
+
+        if (it->unsafe_get() == connection.unsafe_get()) {
+            it = mPendingFlushConnections.erase(it);
+        } else {
+            ++it;
+        }
+    }
     return mConnections.size() ? false : true;
 }
 
+void SensorService::SensorRecord::addPendingFlushConnection(
+        const sp<SensorEventConnection>& connection) {
+    mPendingFlushConnections.add(connection);
+}
+
+void SensorService::SensorRecord::removeFirstPendingFlushConnection() {
+    if (mPendingFlushConnections.size() > 0) {
+        mPendingFlushConnections.removeAt(0);
+    }
+}
+
+SensorService::SensorEventConnection *
+SensorService::SensorRecord::getFirstPendingFlushConnection() {
+   if (mPendingFlushConnections.size() > 0) {
+        return mPendingFlushConnections[0].unsafe_get();
+    }
+    return NULL;
+}
+
+void SensorService::SensorRecord::clearAllPendingFlushConnections() {
+    mPendingFlushConnections.clear();
+}
+
+
+// ---------------------------------------------------------------------------
+SensorService::TrimmedSensorEvent::TrimmedSensorEvent(int sensorType) {
+    mTimestamp = -1;
+    const int numData = SensorService::getNumEventsForSensorType(sensorType);
+    if (sensorType == SENSOR_TYPE_STEP_COUNTER) {
+        mStepCounter = 0;
+    } else {
+        mData = new float[numData];
+        for (int i = 0; i < numData; ++i) {
+            mData[i] = -1.0;
+        }
+    }
+    mHour = mMin = mSec = INT32_MIN;
+}
+
+bool SensorService::TrimmedSensorEvent::isSentinel(const TrimmedSensorEvent& event) {
+    return (event.mHour == INT32_MIN && event.mMin == INT32_MIN && event.mSec == INT32_MIN);
+}
+// --------------------------------------------------------------------------
+SensorService::CircularBuffer::CircularBuffer(int sensor_event_type) {
+    mNextInd = 0;
+    mBufSize = CIRCULAR_BUF_SIZE;
+    if (sensor_event_type == SENSOR_TYPE_STEP_COUNTER ||
+            sensor_event_type == SENSOR_TYPE_SIGNIFICANT_MOTION ||
+            sensor_event_type == SENSOR_TYPE_ACCELEROMETER) {
+        mBufSize = CIRCULAR_BUF_SIZE * 5;
+    }
+    mTrimmedSensorEventArr = new TrimmedSensorEvent *[mBufSize];
+    mSensorType = sensor_event_type;
+    for (int i = 0; i < mBufSize; ++i) {
+        mTrimmedSensorEventArr[i] = new TrimmedSensorEvent(mSensorType);
+    }
+}
+
+void SensorService::CircularBuffer::addEvent(const sensors_event_t& sensor_event) {
+    TrimmedSensorEvent *curr_event = mTrimmedSensorEventArr[mNextInd];
+    curr_event->mTimestamp = sensor_event.timestamp;
+    if (mSensorType == SENSOR_TYPE_STEP_COUNTER) {
+        curr_event->mStepCounter = sensor_event.u64.step_counter;
+    } else {
+        memcpy(curr_event->mData, sensor_event.data,
+                 sizeof(float) * SensorService::getNumEventsForSensorType(mSensorType));
+    }
+    time_t rawtime = time(NULL);
+    struct tm * timeinfo = localtime(&rawtime);
+    curr_event->mHour = timeinfo->tm_hour;
+    curr_event->mMin = timeinfo->tm_min;
+    curr_event->mSec = timeinfo->tm_sec;
+    mNextInd = (mNextInd + 1) % mBufSize;
+}
+
+void SensorService::CircularBuffer::printBuffer(String8& result) const {
+    const int numData = SensorService::getNumEventsForSensorType(mSensorType);
+    int i = mNextInd, eventNum = 1;
+    result.appendFormat("last %d events = < ", mBufSize);
+    do {
+        if (TrimmedSensorEvent::isSentinel(*mTrimmedSensorEventArr[i])) {
+            // Sentinel, ignore.
+            i = (i + 1) % mBufSize;
+            continue;
+        }
+        result.appendFormat("%d) ", eventNum++);
+        if (mSensorType == SENSOR_TYPE_STEP_COUNTER) {
+            result.appendFormat("%" PRIu64 ",", mTrimmedSensorEventArr[i]->mStepCounter);
+        } else {
+            for (int j = 0; j < numData; ++j) {
+                result.appendFormat("%5.1f,", mTrimmedSensorEventArr[i]->mData[j]);
+            }
+        }
+        result.appendFormat("%" PRId64 " %02d:%02d:%02d ", mTrimmedSensorEventArr[i]->mTimestamp,
+                mTrimmedSensorEventArr[i]->mHour, mTrimmedSensorEventArr[i]->mMin,
+                mTrimmedSensorEventArr[i]->mSec);
+        i = (i + 1) % mBufSize;
+    } while (i != mNextInd);
+    result.appendFormat(">\n");
+}
+
+bool SensorService::CircularBuffer::populateLastEvent(sensors_event_t *event) {
+    int lastEventInd = (mNextInd - 1 + mBufSize) % mBufSize;
+    // Check if the buffer is empty.
+    if (TrimmedSensorEvent::isSentinel(*mTrimmedSensorEventArr[lastEventInd])) {
+        return false;
+    }
+    event->version = sizeof(sensors_event_t);
+    event->type = mSensorType;
+    event->timestamp = mTrimmedSensorEventArr[lastEventInd]->mTimestamp;
+    if (mSensorType == SENSOR_TYPE_STEP_COUNTER) {
+          event->u64.step_counter = mTrimmedSensorEventArr[lastEventInd]->mStepCounter;
+    } else {
+        memcpy(event->data, mTrimmedSensorEventArr[lastEventInd]->mData,
+                 sizeof(float) * SensorService::getNumEventsForSensorType(mSensorType));
+    }
+    return true;
+}
+
+SensorService::CircularBuffer::~CircularBuffer() {
+    for (int i = 0; i < mBufSize; ++i) {
+        delete mTrimmedSensorEventArr[i];
+    }
+    delete [] mTrimmedSensorEventArr;
+}
+
 // ---------------------------------------------------------------------------
 
 SensorService::SensorEventConnection::SensorEventConnection(
-        const sp<SensorService>& service, uid_t uid)
-    : mService(service), mUid(uid)
-{
-    const SensorDevice& device(SensorDevice::getInstance());
-    if (device.getHalDeviceVersion() >= SENSORS_DEVICE_API_VERSION_1_1) {
-        // Increase socket buffer size to 1MB for batching capabilities.
-        mChannel = new BitTube(service->mSocketBufferSize);
-    } else {
-        mChannel = new BitTube(SOCKET_BUFFER_SIZE_NON_BATCHED);
+        const sp<SensorService>& service, uid_t uid, String8 packageName, bool isDataInjectionMode,
+        const String16& opPackageName)
+    : mService(service), mUid(uid), mWakeLockRefCount(0), mHasLooperCallbacks(false),
+      mDead(false), mDataInjectionMode(isDataInjectionMode), mEventCache(NULL),
+      mCacheSize(0), mMaxCacheSize(0), mPackageName(packageName), mOpPackageName(opPackageName) {
+    mChannel = new BitTube(mService->mSocketBufferSize);
+#if DEBUG_CONNECTIONS
+    mEventsReceived = mEventsSentFromCache = mEventsSent = 0;
+    mTotalAcksNeeded = mTotalAcksReceived = 0;
+#endif
+}
+
+SensorService::SensorEventConnection::~SensorEventConnection() {
+    ALOGD_IF(DEBUG_CONNECTIONS, "~SensorEventConnection(%p)", this);
+    mService->cleanupConnection(this);
+    if (mEventCache != NULL) {
+        delete mEventCache;
     }
 }
 
-SensorService::SensorEventConnection::~SensorEventConnection()
-{
-    ALOGD_IF(DEBUG_CONNECTIONS, "~SensorEventConnection(%p)", this);
-    mService->cleanupConnection(this);
+void SensorService::SensorEventConnection::onFirstRef() {
+    LooperCallback::onFirstRef();
 }
 
-void SensorService::SensorEventConnection::onFirstRef()
-{
+bool SensorService::SensorEventConnection::needsWakeLock() {
+    Mutex::Autolock _l(mConnectionLock);
+    return !mDead && mWakeLockRefCount > 0;
+}
+
+void SensorService::SensorEventConnection::resetWakeLockRefCount() {
+    Mutex::Autolock _l(mConnectionLock);
+    mWakeLockRefCount = 0;
 }
 
 void SensorService::SensorEventConnection::dump(String8& result) {
     Mutex::Autolock _l(mConnectionLock);
+    result.appendFormat("\tOperating Mode: %s\n",mDataInjectionMode ? "DATA_INJECTION" : "NORMAL");
+    result.appendFormat("\t %s | WakeLockRefCount %d | uid %d | cache size %d | "
+            "max cache size %d\n", mPackageName.string(), mWakeLockRefCount, mUid, mCacheSize,
+            mMaxCacheSize);
     for (size_t i = 0; i < mSensorInfo.size(); ++i) {
         const FlushInfo& flushInfo = mSensorInfo.valueAt(i);
-        result.appendFormat("\t %s | status: %s | pending flush events %d\n",
+        result.appendFormat("\t %s 0x%08x | status: %s | pending flush events %d \n",
                             mService->getSensorName(mSensorInfo.keyAt(i)).string(),
+                            mSensorInfo.keyAt(i),
                             flushInfo.mFirstFlushPending ? "First flush pending" :
                                                            "active",
                             flushInfo.mPendingFlushEventsToSend);
     }
+#if DEBUG_CONNECTIONS
+    result.appendFormat("\t events recvd: %d | sent %d | cache %d | dropped %d |"
+            " total_acks_needed %d | total_acks_recvd %d\n",
+            mEventsReceived,
+            mEventsSent,
+            mEventsSentFromCache,
+            mEventsReceived - (mEventsSentFromCache + mEventsSent + mCacheSize),
+            mTotalAcksNeeded,
+            mTotalAcksReceived);
+#endif
 }
 
 bool SensorService::SensorEventConnection::addSensor(int32_t handle) {
     Mutex::Autolock _l(mConnectionLock);
+    if (!canAccessSensor(mService->getSensorFromHandle(handle),
+            "Tried adding", mOpPackageName)) {
+        return false;
+    }
     if (mSensorInfo.indexOfKey(handle) < 0) {
         mSensorInfo.add(handle, FlushInfo());
         return true;
@@ -786,6 +1446,21 @@
     return mSensorInfo.size() ? true : false;
 }
 
+bool SensorService::SensorEventConnection::hasOneShotSensors() const {
+    Mutex::Autolock _l(mConnectionLock);
+    for (size_t i = 0; i < mSensorInfo.size(); ++i) {
+        const int handle = mSensorInfo.keyAt(i);
+        if (mService->getSensorFromHandle(handle).getReportingMode() == AREPORTING_MODE_ONE_SHOT) {
+            return true;
+        }
+    }
+    return false;
+}
+
+String8 SensorService::SensorEventConnection::getPackageName() const {
+    return mPackageName;
+}
+
 void SensorService::SensorEventConnection::setFirstFlushPending(int32_t handle,
                                 bool value) {
     Mutex::Autolock _l(mConnectionLock);
@@ -796,96 +1471,328 @@
     }
 }
 
+void SensorService::SensorEventConnection::updateLooperRegistration(const sp<Looper>& looper) {
+    Mutex::Autolock _l(mConnectionLock);
+    updateLooperRegistrationLocked(looper);
+}
+
+void SensorService::SensorEventConnection::updateLooperRegistrationLocked(
+        const sp<Looper>& looper) {
+    bool isConnectionActive = (mSensorInfo.size() > 0 && !mDataInjectionMode) ||
+                              mDataInjectionMode;
+    // If all sensors are unregistered OR Looper has encountered an error, we
+    // can remove the Fd from the Looper if it has been previously added.
+    if (!isConnectionActive || mDead) {
+        if (mHasLooperCallbacks) {
+            ALOGD_IF(DEBUG_CONNECTIONS, "%p removeFd fd=%d", this, mChannel->getSendFd());
+            looper->removeFd(mChannel->getSendFd());
+            mHasLooperCallbacks = false;
+        }
+        return;
+    }
+
+    int looper_flags = 0;
+    if (mCacheSize > 0) looper_flags |= ALOOPER_EVENT_OUTPUT;
+    if (mDataInjectionMode) looper_flags |= ALOOPER_EVENT_INPUT;
+    for (size_t i = 0; i < mSensorInfo.size(); ++i) {
+        const int handle = mSensorInfo.keyAt(i);
+        if (mService->getSensorFromHandle(handle).isWakeUpSensor()) {
+            looper_flags |= ALOOPER_EVENT_INPUT;
+            break;
+        }
+    }
+    // If flags is still set to zero, we don't need to add this fd to the Looper, if
+    // the fd has already been added, remove it. This is likely to happen when ALL the
+    // events stored in the cache have been sent to the corresponding app.
+    if (looper_flags == 0) {
+        if (mHasLooperCallbacks) {
+            ALOGD_IF(DEBUG_CONNECTIONS, "removeFd fd=%d", mChannel->getSendFd());
+            looper->removeFd(mChannel->getSendFd());
+            mHasLooperCallbacks = false;
+        }
+        return;
+    }
+    // Add the file descriptor to the Looper for receiving acknowledegments if the app has
+    // registered for wake-up sensors OR for sending events in the cache.
+    int ret = looper->addFd(mChannel->getSendFd(), 0, looper_flags, this, NULL);
+    if (ret == 1) {
+        ALOGD_IF(DEBUG_CONNECTIONS, "%p addFd fd=%d", this, mChannel->getSendFd());
+        mHasLooperCallbacks = true;
+    } else {
+        ALOGE("Looper::addFd failed ret=%d fd=%d", ret, mChannel->getSendFd());
+    }
+}
+
+void SensorService::SensorEventConnection::incrementPendingFlushCount(int32_t handle) {
+    Mutex::Autolock _l(mConnectionLock);
+    ssize_t index = mSensorInfo.indexOfKey(handle);
+    if (index >= 0) {
+        FlushInfo& flushInfo = mSensorInfo.editValueAt(index);
+        flushInfo.mPendingFlushEventsToSend++;
+    }
+}
+
 status_t SensorService::SensorEventConnection::sendEvents(
         sensors_event_t const* buffer, size_t numEvents,
-        sensors_event_t* scratch)
-{
+        sensors_event_t* scratch,
+        SensorEventConnection const * const * mapFlushEventsToConnections) {
     // filter out events not for this connection
-    size_t count = 0;
-
+    int count = 0;
+    Mutex::Autolock _l(mConnectionLock);
     if (scratch) {
-        Mutex::Autolock _l(mConnectionLock);
         size_t i=0;
         while (i<numEvents) {
-            int32_t curr = buffer[i].sensor;
+            int32_t sensor_handle = buffer[i].sensor;
             if (buffer[i].type == SENSOR_TYPE_META_DATA) {
                 ALOGD_IF(DEBUG_CONNECTIONS, "flush complete event sensor==%d ",
-                         buffer[i].meta_data.sensor);
-                // Setting curr to the correct sensor to ensure the sensor events per connection are
-                // filtered correctly. buffer[i].sensor is zero for meta_data events.
-                curr = buffer[i].meta_data.sensor;
+                        buffer[i].meta_data.sensor);
+                // Setting sensor_handle to the correct sensor to ensure the sensor events per
+                // connection are filtered correctly.  buffer[i].sensor is zero for meta_data
+                // events.
+                sensor_handle = buffer[i].meta_data.sensor;
             }
-            ssize_t index = mSensorInfo.indexOfKey(curr);
-            if (index >= 0 && mSensorInfo[index].mFirstFlushPending == true &&
-                buffer[i].type == SENSOR_TYPE_META_DATA) {
-                // This is the first flush before activate is called. Events can now be sent for
-                // this sensor on this connection.
+            ssize_t index = mSensorInfo.indexOfKey(sensor_handle);
+            // Check if this connection has registered for this sensor. If not continue to the
+            // next sensor_event.
+            if (index < 0) {
+                ++i;
+                continue;
+            }
+
+            FlushInfo& flushInfo = mSensorInfo.editValueAt(index);
+            // Check if there is a pending flush_complete event for this sensor on this connection.
+            if (buffer[i].type == SENSOR_TYPE_META_DATA && flushInfo.mFirstFlushPending == true &&
+                    this == mapFlushEventsToConnections[i]) {
+                flushInfo.mFirstFlushPending = false;
                 ALOGD_IF(DEBUG_CONNECTIONS, "First flush event for sensor==%d ",
-                         buffer[i].meta_data.sensor);
-                mSensorInfo.editValueAt(index).mFirstFlushPending = false;
+                        buffer[i].meta_data.sensor);
+                ++i;
+                continue;
             }
-            if (index >= 0 && mSensorInfo[index].mFirstFlushPending == false)  {
-                do {
+
+            // If there is a pending flush complete event for this sensor on this connection,
+            // ignore the event and proceed to the next.
+            if (flushInfo.mFirstFlushPending) {
+                ++i;
+                continue;
+            }
+
+            do {
+                // Keep copying events into the scratch buffer as long as they are regular
+                // sensor_events are from the same sensor_handle OR they are flush_complete_events
+                // from the same sensor_handle AND the current connection is mapped to the
+                // corresponding flush_complete_event.
+                if (buffer[i].type == SENSOR_TYPE_META_DATA) {
+                    if (this == mapFlushEventsToConnections[i]) {
+                        scratch[count++] = buffer[i];
+                    }
+                    ++i;
+                } else {
+                    // Regular sensor event, just copy it to the scratch buffer.
                     scratch[count++] = buffer[i++];
-                } while ((i<numEvents) && ((buffer[i].sensor == curr) ||
-                         (buffer[i].type == SENSOR_TYPE_META_DATA  &&
-                          buffer[i].meta_data.sensor == curr)));
-            } else {
-                i++;
-            }
+                }
+            } while ((i<numEvents) && ((buffer[i].sensor == sensor_handle &&
+                                        buffer[i].type != SENSOR_TYPE_META_DATA) ||
+                                       (buffer[i].type == SENSOR_TYPE_META_DATA  &&
+                                        buffer[i].meta_data.sensor == sensor_handle)));
         }
     } else {
         scratch = const_cast<sensors_event_t *>(buffer);
         count = numEvents;
     }
 
-    // Send pending flush events (if any) before sending events from the cache.
-    {
-        ASensorEvent flushCompleteEvent;
-        flushCompleteEvent.type = SENSOR_TYPE_META_DATA;
-        flushCompleteEvent.sensor = 0;
-        Mutex::Autolock _l(mConnectionLock);
-        // Loop through all the sensors for this connection and check if there are any pending
-        // flush complete events to be sent.
-        for (size_t i = 0; i < mSensorInfo.size(); ++i) {
-            FlushInfo& flushInfo = mSensorInfo.editValueAt(i);
-            while (flushInfo.mPendingFlushEventsToSend > 0) {
-                flushCompleteEvent.meta_data.sensor = mSensorInfo.keyAt(i);
-                ssize_t size = SensorEventQueue::write(mChannel, &flushCompleteEvent, 1);
-                if (size < 0) {
-                    // ALOGW("dropping %d events on the floor", count);
-                    countFlushCompleteEventsLocked(scratch, count);
-                    return size;
-                }
-                ALOGD_IF(DEBUG_CONNECTIONS, "sent dropped flush complete event==%d ",
-                         flushCompleteEvent.meta_data.sensor);
-                flushInfo.mPendingFlushEventsToSend--;
-            }
-        }
-    }
-
+    sendPendingFlushEventsLocked();
     // Early return if there are no events for this connection.
     if (count == 0) {
         return status_t(NO_ERROR);
     }
 
-    // NOTE: ASensorEvent and sensors_event_t are the same type
+#if DEBUG_CONNECTIONS
+     mEventsReceived += count;
+#endif
+    if (mCacheSize != 0) {
+        // There are some events in the cache which need to be sent first. Copy this buffer to
+        // the end of cache.
+        if (mCacheSize + count <= mMaxCacheSize) {
+            memcpy(&mEventCache[mCacheSize], scratch, count * sizeof(sensors_event_t));
+            mCacheSize += count;
+        } else {
+            // Check if any new sensors have registered on this connection which may have increased
+            // the max cache size that is desired.
+            if (mCacheSize + count < computeMaxCacheSizeLocked()) {
+                reAllocateCacheLocked(scratch, count);
+                return status_t(NO_ERROR);
+            }
+            // Some events need to be dropped.
+            int remaningCacheSize = mMaxCacheSize - mCacheSize;
+            if (remaningCacheSize != 0) {
+                memcpy(&mEventCache[mCacheSize], scratch,
+                                                remaningCacheSize * sizeof(sensors_event_t));
+            }
+            int numEventsDropped = count - remaningCacheSize;
+            countFlushCompleteEventsLocked(mEventCache, numEventsDropped);
+            // Drop the first "numEventsDropped" in the cache.
+            memmove(mEventCache, &mEventCache[numEventsDropped],
+                    (mCacheSize - numEventsDropped) * sizeof(sensors_event_t));
+
+            // Copy the remainingEvents in scratch buffer to the end of cache.
+            memcpy(&mEventCache[mCacheSize - numEventsDropped], scratch + remaningCacheSize,
+                                            numEventsDropped * sizeof(sensors_event_t));
+        }
+        return status_t(NO_ERROR);
+    }
+
+    int index_wake_up_event = findWakeUpSensorEventLocked(scratch, count);
+    if (index_wake_up_event >= 0) {
+        scratch[index_wake_up_event].flags |= WAKE_UP_SENSOR_EVENT_NEEDS_ACK;
+        ++mWakeLockRefCount;
+#if DEBUG_CONNECTIONS
+        ++mTotalAcksNeeded;
+#endif
+    }
+
+    // NOTE: ASensorEvent and sensors_event_t are the same type.
     ssize_t size = SensorEventQueue::write(mChannel,
-            reinterpret_cast<ASensorEvent const*>(scratch), count);
-    if (size == -EAGAIN) {
-        // the destination doesn't accept events anymore, it's probably
-        // full. For now, we just drop the events on the floor.
-        // ALOGW("dropping %d events on the floor", count);
-        Mutex::Autolock _l(mConnectionLock);
-        countFlushCompleteEventsLocked(scratch, count);
+                                    reinterpret_cast<ASensorEvent const*>(scratch), count);
+    if (size < 0) {
+        // Write error, copy events to local cache.
+        if (index_wake_up_event >= 0) {
+            // If there was a wake_up sensor_event, reset the flag.
+            scratch[index_wake_up_event].flags &= ~WAKE_UP_SENSOR_EVENT_NEEDS_ACK;
+            if (mWakeLockRefCount > 0) {
+                --mWakeLockRefCount;
+            }
+#if DEBUG_CONNECTIONS
+            --mTotalAcksNeeded;
+#endif
+        }
+        if (mEventCache == NULL) {
+            mMaxCacheSize = computeMaxCacheSizeLocked();
+            mEventCache = new sensors_event_t[mMaxCacheSize];
+            mCacheSize = 0;
+        }
+        memcpy(&mEventCache[mCacheSize], scratch, count * sizeof(sensors_event_t));
+        mCacheSize += count;
+
+        // Add this file descriptor to the looper to get a callback when this fd is available for
+        // writing.
+        updateLooperRegistrationLocked(mService->getLooper());
         return size;
     }
 
+#if DEBUG_CONNECTIONS
+    if (size > 0) {
+        mEventsSent += count;
+    }
+#endif
+
     return size < 0 ? status_t(size) : status_t(NO_ERROR);
 }
 
+void SensorService::SensorEventConnection::reAllocateCacheLocked(sensors_event_t const* scratch,
+                                                                 int count) {
+    sensors_event_t *eventCache_new;
+    const int new_cache_size = computeMaxCacheSizeLocked();
+    // Allocate new cache, copy over events from the old cache & scratch, free up memory.
+    eventCache_new = new sensors_event_t[new_cache_size];
+    memcpy(eventCache_new, mEventCache, mCacheSize * sizeof(sensors_event_t));
+    memcpy(&eventCache_new[mCacheSize], scratch, count * sizeof(sensors_event_t));
+
+    ALOGD_IF(DEBUG_CONNECTIONS, "reAllocateCacheLocked maxCacheSize=%d %d", mMaxCacheSize,
+            new_cache_size);
+
+    delete mEventCache;
+    mEventCache = eventCache_new;
+    mCacheSize += count;
+    mMaxCacheSize = new_cache_size;
+}
+
+void SensorService::SensorEventConnection::sendPendingFlushEventsLocked() {
+    ASensorEvent flushCompleteEvent;
+    memset(&flushCompleteEvent, 0, sizeof(flushCompleteEvent));
+    flushCompleteEvent.type = SENSOR_TYPE_META_DATA;
+    // Loop through all the sensors for this connection and check if there are any pending
+    // flush complete events to be sent.
+    for (size_t i = 0; i < mSensorInfo.size(); ++i) {
+        FlushInfo& flushInfo = mSensorInfo.editValueAt(i);
+        while (flushInfo.mPendingFlushEventsToSend > 0) {
+            const int sensor_handle = mSensorInfo.keyAt(i);
+            flushCompleteEvent.meta_data.sensor = sensor_handle;
+            bool wakeUpSensor = mService->getSensorFromHandle(sensor_handle).isWakeUpSensor();
+            if (wakeUpSensor) {
+               ++mWakeLockRefCount;
+               flushCompleteEvent.flags |= WAKE_UP_SENSOR_EVENT_NEEDS_ACK;
+            }
+            ssize_t size = SensorEventQueue::write(mChannel, &flushCompleteEvent, 1);
+            if (size < 0) {
+                if (wakeUpSensor) --mWakeLockRefCount;
+                return;
+            }
+            ALOGD_IF(DEBUG_CONNECTIONS, "sent dropped flush complete event==%d ",
+                    flushCompleteEvent.meta_data.sensor);
+            flushInfo.mPendingFlushEventsToSend--;
+        }
+    }
+}
+
+void SensorService::SensorEventConnection::writeToSocketFromCache() {
+    // At a time write at most half the size of the receiver buffer in SensorEventQueue OR
+    // half the size of the socket buffer allocated in BitTube whichever is smaller.
+    const int maxWriteSize = helpers::min(SensorEventQueue::MAX_RECEIVE_BUFFER_EVENT_COUNT/2,
+            int(mService->mSocketBufferSize/(sizeof(sensors_event_t)*2)));
+    Mutex::Autolock _l(mConnectionLock);
+    // Send pending flush complete events (if any)
+    sendPendingFlushEventsLocked();
+    for (int numEventsSent = 0; numEventsSent < mCacheSize;) {
+        const int numEventsToWrite = helpers::min(mCacheSize - numEventsSent, maxWriteSize);
+        int index_wake_up_event =
+                  findWakeUpSensorEventLocked(mEventCache + numEventsSent, numEventsToWrite);
+        if (index_wake_up_event >= 0) {
+            mEventCache[index_wake_up_event + numEventsSent].flags |=
+                    WAKE_UP_SENSOR_EVENT_NEEDS_ACK;
+            ++mWakeLockRefCount;
+#if DEBUG_CONNECTIONS
+            ++mTotalAcksNeeded;
+#endif
+        }
+
+        ssize_t size = SensorEventQueue::write(mChannel,
+                          reinterpret_cast<ASensorEvent const*>(mEventCache + numEventsSent),
+                          numEventsToWrite);
+        if (size < 0) {
+            if (index_wake_up_event >= 0) {
+                // If there was a wake_up sensor_event, reset the flag.
+                mEventCache[index_wake_up_event + numEventsSent].flags  &=
+                        ~WAKE_UP_SENSOR_EVENT_NEEDS_ACK;
+                if (mWakeLockRefCount > 0) {
+                    --mWakeLockRefCount;
+                }
+#if DEBUG_CONNECTIONS
+                --mTotalAcksNeeded;
+#endif
+            }
+            memmove(mEventCache, &mEventCache[numEventsSent],
+                                 (mCacheSize - numEventsSent) * sizeof(sensors_event_t));
+            ALOGD_IF(DEBUG_CONNECTIONS, "wrote %d events from cache size==%d ",
+                    numEventsSent, mCacheSize);
+            mCacheSize -= numEventsSent;
+            return;
+        }
+        numEventsSent += numEventsToWrite;
+#if DEBUG_CONNECTIONS
+        mEventsSentFromCache += numEventsToWrite;
+#endif
+    }
+    ALOGD_IF(DEBUG_CONNECTIONS, "wrote all events from cache size=%d ", mCacheSize);
+    // All events from the cache have been sent. Reset cache size to zero.
+    mCacheSize = 0;
+    // There are no more events in the cache. We don't need to poll for write on the fd.
+    // Update Looper registration.
+    updateLooperRegistrationLocked(mService->getLooper());
+}
+
 void SensorService::SensorEventConnection::countFlushCompleteEventsLocked(
-                sensors_event_t* scratch, const int numEventsDropped) {
+                sensors_event_t const* scratch, const int numEventsDropped) {
     ALOGD_IF(DEBUG_CONNECTIONS, "dropping %d events ", numEventsDropped);
     // Count flushComplete events in the events that are about to the dropped. These will be sent
     // separately before the next batch of events.
@@ -900,6 +1807,16 @@
     return;
 }
 
+int SensorService::SensorEventConnection::findWakeUpSensorEventLocked(
+                       sensors_event_t const* scratch, const int count) {
+    for (int i = 0; i < count; ++i) {
+        if (mService->isWakeUpSensorEvent(scratch[i])) {
+            return i;
+        }
+    }
+    return -1;
+}
+
 sp<BitTube> SensorService::SensorEventConnection::getSensorChannel() const
 {
     return mChannel;
@@ -912,7 +1829,8 @@
     status_t err;
     if (enabled) {
         err = mService->enable(this, handle, samplingPeriodNs, maxBatchReportLatencyNs,
-                               reservedFlags);
+                               reservedFlags, mOpPackageName);
+
     } else {
         err = mService->disable(this, handle);
     }
@@ -922,31 +1840,125 @@
 status_t SensorService::SensorEventConnection::setEventRate(
         int handle, nsecs_t samplingPeriodNs)
 {
-    return mService->setEventRate(this, handle, samplingPeriodNs);
+    return mService->setEventRate(this, handle, samplingPeriodNs, mOpPackageName);
 }
 
 status_t  SensorService::SensorEventConnection::flush() {
-    SensorDevice& dev(SensorDevice::getInstance());
-    const int halVersion = dev.getHalDeviceVersion();
-    Mutex::Autolock _l(mConnectionLock);
-    status_t err(NO_ERROR);
-    // Loop through all sensors for this connection and call flush on each of them.
-    for (size_t i = 0; i < mSensorInfo.size(); ++i) {
-        const int handle = mSensorInfo.keyAt(i);
-        if (halVersion < SENSORS_DEVICE_API_VERSION_1_1 || mService->isVirtualSensor(handle)) {
-            // For older devices just increment pending flush count which will send a trivial
-            // flush complete event.
-            FlushInfo& flushInfo = mSensorInfo.editValueFor(handle);
-            flushInfo.mPendingFlushEventsToSend++;
-        } else {
-            status_t err_flush = mService->flushSensor(this, handle);
-            if (err_flush != NO_ERROR) {
-                ALOGE("Flush error handle=%d %s", handle, strerror(-err_flush));
-            }
-            err = (err_flush != NO_ERROR) ? err_flush : err;
+    return  mService->flushSensor(this, mOpPackageName);
+}
+
+int SensorService::SensorEventConnection::handleEvent(int fd, int events, void* /*data*/) {
+    if (events & ALOOPER_EVENT_HANGUP || events & ALOOPER_EVENT_ERROR) {
+        {
+            // If the Looper encounters some error, set the flag mDead, reset mWakeLockRefCount,
+            // and remove the fd from Looper. Call checkWakeLockState to know if SensorService
+            // can release the wake-lock.
+            ALOGD_IF(DEBUG_CONNECTIONS, "%p Looper error %d", this, fd);
+            Mutex::Autolock _l(mConnectionLock);
+            mDead = true;
+            mWakeLockRefCount = 0;
+            updateLooperRegistrationLocked(mService->getLooper());
         }
+        mService->checkWakeLockState();
+        if (mDataInjectionMode) {
+            // If the Looper has encountered some error in data injection mode, reset SensorService
+            // back to normal mode.
+            mService->resetToNormalMode();
+            mDataInjectionMode = false;
+        }
+        return 1;
     }
-    return err;
+
+    if (events & ALOOPER_EVENT_INPUT) {
+        unsigned char buf[sizeof(sensors_event_t)];
+        ssize_t numBytesRead = ::recv(fd, buf, sizeof(buf), MSG_DONTWAIT);
+        {
+           Mutex::Autolock _l(mConnectionLock);
+           if (numBytesRead == sizeof(sensors_event_t)) {
+               if (!mDataInjectionMode) {
+                   ALOGE("Data injected in normal mode, dropping event"
+                         "package=%s uid=%d", mPackageName.string(), mUid);
+                   // Unregister call backs.
+                   return 0;
+               }
+               SensorDevice& dev(SensorDevice::getInstance());
+               sensors_event_t sensor_event;
+               memset(&sensor_event, 0, sizeof(sensor_event));
+               memcpy(&sensor_event, buf, sizeof(sensors_event_t));
+               Sensor sensor = mService->getSensorFromHandle(sensor_event.sensor);
+               sensor_event.type = sensor.getType();
+               dev.injectSensorData(&sensor_event);
+#if DEBUG_CONNECTIONS
+               ++mEventsReceived;
+#endif
+           } else if (numBytesRead == sizeof(uint32_t)) {
+               uint32_t numAcks = 0;
+               memcpy(&numAcks, buf, numBytesRead);
+               // Sanity check to ensure  there are no read errors in recv, numAcks is always
+               // within the range and not zero. If any of the above don't hold reset
+               // mWakeLockRefCount to zero.
+               if (numAcks > 0 && numAcks < mWakeLockRefCount) {
+                   mWakeLockRefCount -= numAcks;
+               } else {
+                   mWakeLockRefCount = 0;
+               }
+#if DEBUG_CONNECTIONS
+               mTotalAcksReceived += numAcks;
+#endif
+           } else {
+               // Read error, reset wakelock refcount.
+               mWakeLockRefCount = 0;
+           }
+        }
+        // Check if wakelock can be released by sensorservice. mConnectionLock needs to be released
+        // here as checkWakeLockState() will need it.
+        if (mWakeLockRefCount == 0) {
+            mService->checkWakeLockState();
+        }
+        // continue getting callbacks.
+        return 1;
+    }
+
+    if (events & ALOOPER_EVENT_OUTPUT) {
+        // send sensor data that is stored in mEventCache for this connection.
+        mService->sendEventsFromCache(this);
+    }
+    return 1;
+}
+
+int SensorService::SensorEventConnection::computeMaxCacheSizeLocked() const {
+    size_t fifoWakeUpSensors = 0;
+    size_t fifoNonWakeUpSensors = 0;
+    for (size_t i = 0; i < mSensorInfo.size(); ++i) {
+        const Sensor& sensor = mService->getSensorFromHandle(mSensorInfo.keyAt(i));
+        if (sensor.getFifoReservedEventCount() == sensor.getFifoMaxEventCount()) {
+            // Each sensor has a reserved fifo. Sum up the fifo sizes for all wake up sensors and
+            // non wake_up sensors.
+            if (sensor.isWakeUpSensor()) {
+                fifoWakeUpSensors += sensor.getFifoReservedEventCount();
+            } else {
+                fifoNonWakeUpSensors += sensor.getFifoReservedEventCount();
+            }
+        } else {
+            // Shared fifo. Compute the max of the fifo sizes for wake_up and non_wake up sensors.
+            if (sensor.isWakeUpSensor()) {
+                fifoWakeUpSensors = fifoWakeUpSensors > sensor.getFifoMaxEventCount() ?
+                                          fifoWakeUpSensors : sensor.getFifoMaxEventCount();
+
+            } else {
+                fifoNonWakeUpSensors = fifoNonWakeUpSensors > sensor.getFifoMaxEventCount() ?
+                                          fifoNonWakeUpSensors : sensor.getFifoMaxEventCount();
+
+            }
+        }
+   }
+   if (fifoWakeUpSensors + fifoNonWakeUpSensors == 0) {
+       // It is extremely unlikely that there is a write failure in non batch mode. Return a cache
+       // size that is equal to that of the batch mode.
+       // ALOGW("Write failure in non-batch mode");
+       return MAX_SOCKET_BUFFER_SIZE_BATCHED/sizeof(sensors_event_t);
+   }
+   return fifoWakeUpSensors + fifoNonWakeUpSensors;
 }
 
 // ---------------------------------------------------------------------------
diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h
index c968319..6df0aae 100644
--- a/services/sensorservice/SensorService.h
+++ b/services/sensorservice/SensorService.h
@@ -24,7 +24,10 @@
 #include <utils/SortedVector.h>
 #include <utils/KeyedVector.h>
 #include <utils/threads.h>
+#include <utils/AndroidThreads.h>
 #include <utils/RefBase.h>
+#include <utils/Looper.h>
+#include <utils/String8.h>
 
 #include <binder/BinderService.h>
 
@@ -35,12 +38,23 @@
 
 #include "SensorInterface.h"
 
+#if __clang__
+// Clang warns about SensorEventConnection::dump hiding BBinder::dump
+// The cause isn't fixable without changing the API, so let's tell clang
+// this is indeed intentional.
+#pragma clang diagnostic ignored "-Woverloaded-virtual"
+#endif
+
 // ---------------------------------------------------------------------------
 
 #define DEBUG_CONNECTIONS   false
-// Max size is 1 MB which is enough to accept a batch of about 10k events.
-#define MAX_SOCKET_BUFFER_SIZE_BATCHED 1024 * 1024
-#define SOCKET_BUFFER_SIZE_NON_BATCHED 4 * 1024
+// Max size is 100 KB which is enough to accept a batch of about 1000 events.
+#define MAX_SOCKET_BUFFER_SIZE_BATCHED (100 * 1024)
+// For older HALs which don't support batching, use a smaller socket buffer size.
+#define SOCKET_BUFFER_SIZE_NON_BATCHED (4 * 1024)
+
+#define CIRCULAR_BUF_SIZE 10
+#define SENSOR_REGISTRATIONS_BUF_SIZE 20
 
 struct sensors_poll_device_t;
 struct sensors_module_t;
@@ -55,6 +69,51 @@
 {
     friend class BinderService<SensorService>;
 
+    enum Mode {
+       // The regular operating mode where any application can register/unregister/call flush on
+       // sensors.
+       NORMAL = 0,
+       // This mode is only used for testing purposes. Not all HALs support this mode. In this
+       // mode, the HAL ignores the sensor data provided by physical sensors and accepts the data
+       // that is injected from the SensorService as if it were the real sensor data. This mode
+       // is primarily used for testing various algorithms like vendor provided SensorFusion,
+       // Step Counter and Step Detector etc. Typically in this mode, there will be a client
+       // (a SensorEventConnection) which will be injecting sensor data into the HAL. Normal apps
+       // can unregister and register for any sensor that supports injection. Registering to sensors
+       // that do not support injection will give an error.
+       // TODO(aakella) : Allow exactly one client to inject sensor data at a time.
+       DATA_INJECTION = 1,
+       // This mode is used only for testing sensors. Each sensor can be tested in isolation with
+       // the required sampling_rate and maxReportLatency parameters without having to think about
+       // the data rates requested by other applications. End user devices are always expected to be
+       // in NORMAL mode. When this mode is first activated, all active sensors from all connections
+       // are disabled. Calling flush() will return an error. In this mode, only the requests from
+       // selected apps whose package names are whitelisted are allowed (typically CTS apps).  Only
+       // these apps can register/unregister/call flush() on sensors. If SensorService switches to
+       // NORMAL mode again, all sensors that were previously registered to are activated with the
+       // corresponding paramaters if the application hasn't unregistered for sensors in the mean
+       // time.
+       // NOTE: Non whitelisted app whose sensors were previously deactivated may still receive
+       // events if a whitelisted app requests data from the same sensor.
+       RESTRICTED = 2
+
+      // State Transitions supported.
+      //     RESTRICTED   <---  NORMAL   ---> DATA_INJECTION
+      //                  --->           <---
+
+      // Shell commands to switch modes in SensorService.
+      // 1) Put SensorService in RESTRICTED mode with packageName .cts. If it is already in
+      // restricted mode it is treated as a NO_OP (and packageName is NOT changed).
+      // $ adb shell dumpsys sensorservice restrict .cts.
+      //
+      // 2) Put SensorService in DATA_INJECTION mode with packageName .xts. If it is already in
+      // data_injection mode it is treated as a NO_OP (and packageName is NOT changed).
+      // $ adb shell dumpsys sensorservice data_injection .xts.
+      //
+      // 3) Reset sensorservice back to NORMAL mode.
+      // $ adb shell dumpsys sensorservice enable
+    };
+
     static const char* WAKE_LOCK_NAME;
 
     static char const* getServiceName() ANDROID_API { return "sensorservice"; }
@@ -67,12 +126,14 @@
     virtual bool threadLoop();
 
     // ISensorServer interface
-    virtual Vector<Sensor> getSensorList();
-    virtual sp<ISensorEventConnection> createSensorEventConnection();
+    virtual Vector<Sensor> getSensorList(const String16& opPackageName);
+    virtual sp<ISensorEventConnection> createSensorEventConnection(const String8& packageName,
+             int requestedMode, const String16& opPackageName);
+    virtual int isDataInjectionEnabled();
     virtual status_t dump(int fd, const Vector<String16>& args);
 
-
-    class SensorEventConnection : public BnSensorEventConnection {
+    class SensorEventConnection : public BnSensorEventConnection, public LooperCallback {
+        friend class SensorService;
         virtual ~SensorEventConnection();
         virtual void onFirstRef();
         virtual sp<BitTube> getSensorChannel() const;
@@ -83,13 +144,70 @@
         // Count the number of flush complete events which are about to be dropped in the buffer.
         // Increment mPendingFlushEventsToSend in mSensorInfo. These flush complete events will be
         // sent separately before the next batch of events.
-        void countFlushCompleteEventsLocked(sensors_event_t* scratch, int numEventsDropped);
+        void countFlushCompleteEventsLocked(sensors_event_t const* scratch, int numEventsDropped);
+
+        // Check if there are any wake up events in the buffer. If yes, return the index of the
+        // first wake_up sensor event in the buffer else return -1. This wake_up sensor event will
+        // have the flag WAKE_UP_SENSOR_EVENT_NEEDS_ACK set. Exactly one event per packet will have
+        // the wake_up flag set. SOCK_SEQPACKET ensures that either the entire packet is read or
+        // dropped.
+        int findWakeUpSensorEventLocked(sensors_event_t const* scratch, int count);
+
+        // Send pending flush_complete events. There may have been flush_complete_events that are
+        // dropped which need to be sent separately before other events. On older HALs (1_0) this
+        // method emulates the behavior of flush().
+        void sendPendingFlushEventsLocked();
+
+        // Writes events from mEventCache to the socket.
+        void writeToSocketFromCache();
+
+        // Compute the approximate cache size from the FIFO sizes of various sensors registered for
+        // this connection. Wake up and non-wake up sensors have separate FIFOs but FIFO may be
+        // shared amongst wake-up sensors and non-wake up sensors.
+        int computeMaxCacheSizeLocked() const;
+
+        // When more sensors register, the maximum cache size desired may change. Compute max cache
+        // size, reallocate memory and copy over events from the older cache.
+        void reAllocateCacheLocked(sensors_event_t const* scratch, int count);
+
+        // LooperCallback method. If there is data to read on this fd, it is an ack from the
+        // app that it has read events from a wake up sensor, decrement mWakeLockRefCount.
+        // If this fd is available for writing send the data from the cache.
+        virtual int handleEvent(int fd, int events, void* data);
+
+        // Increment mPendingFlushEventsToSend for the given sensor handle.
+        void incrementPendingFlushCount(int32_t handle);
+
+        // Add or remove the file descriptor associated with the BitTube to the looper. If mDead is
+        // set to true or there are no more sensors for this connection, the file descriptor is
+        // removed if it has been previously added to the Looper. Depending on the state of the
+        // connection FD may be added to the Looper. The flags to set are determined by the internal
+        // state of the connection. FDs are added to the looper when wake-up sensors are registered
+        // (to poll for acknowledgements) and when write fails on the socket when there are too many
+        // error and the other end hangs up or when this client unregisters for this connection.
+        void updateLooperRegistration(const sp<Looper>& looper);
+        void updateLooperRegistrationLocked(const sp<Looper>& looper);
 
         sp<SensorService> const mService;
         sp<BitTube> mChannel;
         uid_t mUid;
         mutable Mutex mConnectionLock;
+        // Number of events from wake up sensors which are still pending and haven't been delivered
+        // to the corresponding application. It is incremented by one unit for each write to the
+        // socket.
+        uint32_t mWakeLockRefCount;
 
+        // If this flag is set to true, it means that the file descriptor associated with the
+        // BitTube has been added to the Looper in SensorService. This flag is typically set when
+        // this connection has wake-up sensors associated with it or when write has failed on this
+        // connection and we're storing some events in the cache.
+        bool mHasLooperCallbacks;
+        // If there are any errors associated with the Looper this flag is set to true and
+        // mWakeLockRefCount is reset to zero. needsWakeLock method will always return false, if
+        // this flag is set.
+        bool mDead;
+
+        bool mDataInjectionMode;
         struct FlushInfo {
             // The number of flush complete events dropped for this sensor is stored here.
             // They are sent separately before the next batch of events.
@@ -101,37 +219,122 @@
         };
         // protected by SensorService::mLock. Key for this vector is the sensor handle.
         KeyedVector<int, FlushInfo> mSensorInfo;
+        sensors_event_t *mEventCache;
+        int mCacheSize, mMaxCacheSize;
+        String8 mPackageName;
+        const String16 mOpPackageName;
+#if DEBUG_CONNECTIONS
+        int mEventsReceived, mEventsSent, mEventsSentFromCache;
+        int mTotalAcksNeeded, mTotalAcksReceived;
+#endif
 
     public:
-        SensorEventConnection(const sp<SensorService>& service, uid_t uid);
+        SensorEventConnection(const sp<SensorService>& service, uid_t uid, String8 packageName,
+                 bool isDataInjectionMode, const String16& opPackageName);
 
         status_t sendEvents(sensors_event_t const* buffer, size_t count,
-                sensors_event_t* scratch = NULL);
+                sensors_event_t* scratch,
+                SensorEventConnection const * const * mapFlushEventsToConnections = NULL);
         bool hasSensor(int32_t handle) const;
         bool hasAnySensor() const;
+        bool hasOneShotSensors() const;
         bool addSensor(int32_t handle);
         bool removeSensor(int32_t handle);
         void setFirstFlushPending(int32_t handle, bool value);
         void dump(String8& result);
+        bool needsWakeLock();
+        void resetWakeLockRefCount();
+        String8 getPackageName() const;
 
         uid_t getUid() const { return mUid; }
     };
 
     class SensorRecord {
         SortedVector< wp<SensorEventConnection> > mConnections;
+        // A queue of all flush() calls made on this sensor. Flush complete events will be
+        // sent in this order.
+        Vector< wp<SensorEventConnection> > mPendingFlushConnections;
     public:
         SensorRecord(const sp<SensorEventConnection>& connection);
         bool addConnection(const sp<SensorEventConnection>& connection);
         bool removeConnection(const wp<SensorEventConnection>& connection);
         size_t getNumConnections() const { return mConnections.size(); }
+
+        void addPendingFlushConnection(const sp<SensorEventConnection>& connection);
+        void removeFirstPendingFlushConnection();
+        SensorEventConnection * getFirstPendingFlushConnection();
+        void clearAllPendingFlushConnections();
     };
 
-    SortedVector< wp<SensorEventConnection> > getActiveConnections() const;
-    DefaultKeyedVector<int, SensorInterface*> getActiveVirtualSensors() const;
+    class SensorEventAckReceiver : public Thread {
+        sp<SensorService> const mService;
+    public:
+        virtual bool threadLoop();
+        SensorEventAckReceiver(const sp<SensorService>& service): mService(service) {}
+    };
 
+    // sensor_event_t with only the data and the timestamp.
+    struct TrimmedSensorEvent {
+        union {
+            float *mData;
+            uint64_t mStepCounter;
+        };
+        // Timestamp from the sensor_event.
+        int64_t mTimestamp;
+        // HH:MM:SS local time at which this sensor event is read at SensorService. Useful
+        // for debugging.
+        int32_t mHour, mMin, mSec;
+
+        TrimmedSensorEvent(int sensorType);
+        static bool isSentinel(const TrimmedSensorEvent& event);
+
+        ~TrimmedSensorEvent() {
+            delete [] mData;
+        }
+    };
+
+    // A circular buffer of TrimmedSensorEvents. The size of this buffer is typically 10. The
+    // last N events generated from the sensor are stored in this buffer. The buffer is NOT
+    // cleared when the sensor unregisters and as a result one may see very old data in the
+    // dumpsys output but this is WAI.
+    class CircularBuffer {
+        int mNextInd;
+        int mSensorType;
+        int mBufSize;
+        TrimmedSensorEvent ** mTrimmedSensorEventArr;
+    public:
+        CircularBuffer(int sensor_event_type);
+        void addEvent(const sensors_event_t& sensor_event);
+        void printBuffer(String8& buffer) const;
+        bool populateLastEvent(sensors_event_t *event);
+        ~CircularBuffer();
+    };
+
+    struct SensorRegistrationInfo {
+        int32_t mSensorHandle;
+        String8 mPackageName;
+        bool mActivated;
+        int32_t mSamplingRateUs;
+        int32_t mMaxReportLatencyUs;
+        int32_t mHour, mMin, mSec;
+
+        SensorRegistrationInfo() : mPackageName() {
+            mSensorHandle = mSamplingRateUs = mMaxReportLatencyUs = INT32_MIN;
+            mHour = mMin = mSec = INT32_MIN;
+            mActivated = false;
+        }
+
+        static bool isSentinel(const SensorRegistrationInfo& info) {
+           return (info.mHour == INT32_MIN && info.mMin == INT32_MIN && info.mSec == INT32_MIN);
+        }
+    };
+
+    static int getNumEventsForSensorType(int sensor_event_type);
     String8 getSensorName(int handle) const;
     bool isVirtualSensor(int handle) const;
-    void recordLastValue(sensors_event_t const * buffer, size_t count);
+    Sensor getSensorFromHandle(int handle) const;
+    bool isWakeUpSensor(int type) const;
+    void recordLastValueLocked(sensors_event_t const* buffer, size_t count);
     static void sortEventBuffer(sensors_event_t* buffer, size_t count);
     Sensor registerSensor(SensorInterface* sensor);
     Sensor registerVirtualSensor(SensorInterface* sensor);
@@ -139,8 +342,46 @@
             const sp<SensorEventConnection>& connection, int handle);
     status_t cleanupWithoutDisableLocked(
             const sp<SensorEventConnection>& connection, int handle);
-    void cleanupAutoDisabledSensor(const sp<SensorEventConnection>& connection,
+    void cleanupAutoDisabledSensorLocked(const sp<SensorEventConnection>& connection,
             sensors_event_t const* buffer, const int count);
+    static bool canAccessSensor(const Sensor& sensor, const char* operation,
+            const String16& opPackageName);
+    // SensorService acquires a partial wakelock for delivering events from wake up sensors. This
+    // method checks whether all the events from these wake up sensors have been delivered to the
+    // corresponding applications, if yes the wakelock is released.
+    void checkWakeLockState();
+    void checkWakeLockStateLocked();
+    bool isWakeLockAcquired();
+    bool isWakeUpSensorEvent(const sensors_event_t& event) const;
+
+    SensorRecord * getSensorRecord(int handle);
+
+    sp<Looper> getLooper() const;
+
+    // Reset mWakeLockRefCounts for all SensorEventConnections to zero. This may happen if
+    // SensorService did not receive any acknowledgements from apps which have registered for
+    // wake_up sensors.
+    void resetAllWakeLockRefCounts();
+
+    // Acquire or release wake_lock. If wake_lock is acquired, set the timeout in the looper to
+    // 5 seconds and wake the looper.
+    void setWakeLockAcquiredLocked(bool acquire);
+
+    // Send events from the event cache for this particular connection.
+    void sendEventsFromCache(const sp<SensorEventConnection>& connection);
+
+    // Promote all weak referecences in mActiveConnections vector to strong references and add them
+    // to the output vector.
+    void populateActiveConnections(SortedVector< sp<SensorEventConnection> >* activeConnections);
+
+    // If SensorService is operating in RESTRICTED mode, only select whitelisted packages are
+    // allowed to register for or call flush on sensors. Typically only cts test packages are
+    // allowed.
+    bool isWhiteListedPackage(const String8& packageName);
+
+    // Reset the state of SensorService to NORMAL mode.
+    status_t resetToNormalMode();
+    status_t resetToNormalModeLocked();
 
     // constants
     Vector<Sensor> mSensorList;
@@ -149,24 +390,42 @@
     DefaultKeyedVector<int, SensorInterface*> mSensorMap;
     Vector<SensorInterface *> mVirtualSensorList;
     status_t mInitCheck;
-    size_t mSocketBufferSize;
+    // Socket buffersize used to initialize BitTube. This size depends on whether batching is
+    // supported or not.
+    uint32_t mSocketBufferSize;
+    sp<Looper> mLooper;
+    sp<SensorEventAckReceiver> mAckReceiver;
 
     // protected by mLock
     mutable Mutex mLock;
     DefaultKeyedVector<int, SensorRecord*> mActiveSensors;
     DefaultKeyedVector<int, SensorInterface*> mActiveVirtualSensors;
     SortedVector< wp<SensorEventConnection> > mActiveConnections;
+    bool mWakeLockAcquired;
+    sensors_event_t *mSensorEventBuffer, *mSensorEventScratch;
+    SensorEventConnection const **mMapFlushEventsToConnections;
+    Mode mCurrentOperatingMode;
+    // This packagaName is set when SensorService is in RESTRICTED or DATA_INJECTION mode. Only
+    // applications with this packageName are allowed to activate/deactivate or call flush on
+    // sensors. To run CTS this is can be set to ".cts." and only CTS tests will get access to
+    // sensors.
+    String8 mWhiteListedPackage;
 
     // The size of this vector is constant, only the items are mutable
-    KeyedVector<int32_t, sensors_event_t> mLastEventSeen;
+    KeyedVector<int32_t, CircularBuffer *> mLastEventSeen;
 
+    int mNextSensorRegIndex;
+    Vector<SensorRegistrationInfo> mLastNSensorRegistrations;
 public:
     void cleanupConnection(SensorEventConnection* connection);
     status_t enable(const sp<SensorEventConnection>& connection, int handle,
-                    nsecs_t samplingPeriodNs,  nsecs_t maxBatchReportLatencyNs, int reservedFlags);
+                    nsecs_t samplingPeriodNs,  nsecs_t maxBatchReportLatencyNs, int reservedFlags,
+                    const String16& opPackageName);
     status_t disable(const sp<SensorEventConnection>& connection, int handle);
-    status_t setEventRate(const sp<SensorEventConnection>& connection, int handle, nsecs_t ns);
-    status_t flushSensor(const sp<SensorEventConnection>& connection, int handle);
+    status_t setEventRate(const sp<SensorEventConnection>& connection, int handle, nsecs_t ns,
+                          const String16& opPackageName);
+    status_t flushSensor(const sp<SensorEventConnection>& connection,
+                         const String16& opPackageName);
 };
 
 // ---------------------------------------------------------------------------
diff --git a/services/sensorservice/main_sensorservice.cpp b/services/sensorservice/main_sensorservice.cpp
index 0a96f42..01bb0e7 100644
--- a/services/sensorservice/main_sensorservice.cpp
+++ b/services/sensorservice/main_sensorservice.cpp
@@ -20,6 +20,7 @@
 using namespace android;
 
 int main(int /*argc*/, char** /*argv*/) {
+    signal(SIGPIPE, SIG_IGN);
     SensorService::publishAndJoinThreadPool();
     return 0;
 }
diff --git a/services/sensorservice/tests/sensorservicetest.cpp b/services/sensorservice/tests/sensorservicetest.cpp
index 1025fa8..cfdf6a3 100644
--- a/services/sensorservice/tests/sensorservicetest.cpp
+++ b/services/sensorservice/tests/sensorservicetest.cpp
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <inttypes.h>
 #include <android/sensor.h>
 #include <gui/Sensor.h>
 #include <gui/SensorManager.h>
@@ -25,7 +26,7 @@
 static nsecs_t sStartTime = 0;
 
 
-int receiver(int fd, int events, void* data)
+int receiver(__unused int fd, __unused int events, void* data)
 {
     sp<SensorEventQueue> q((SensorEventQueue*)data);
     ssize_t n;
@@ -44,7 +45,7 @@
             oldTimeStamp = buffer[i].timestamp;
 
             if (buffer[i].type == Sensor::TYPE_ACCELEROMETER) {
-                printf("%lld\t%8f\t%8f\t%8f\t%f\n",
+                printf("%" PRId64 "\t%8f\t%8f\t%8f\t%f\n",
                         buffer[i].timestamp,
                         buffer[i].data[0], buffer[i].data[1], buffer[i].data[2],
                         1.0/t);
@@ -59,9 +60,9 @@
 }
 
 
-int main(int argc, char** argv)
+int main()
 {
-    SensorManager& mgr(SensorManager::getInstance());
+    SensorManager mgr(String16("Sensor Service Test"));
 
     Sensor const* const* list;
     ssize_t count = mgr.getSensorList(&list);
diff --git a/services/sensorservice/vec.h b/services/sensorservice/vec.h
index 24f30ff..a142bad 100644
--- a/services/sensorservice/vec.h
+++ b/services/sensorservice/vec.h
@@ -37,7 +37,7 @@
 class vec;
 
 template <typename TYPE, size_t SIZE>
-class vbase;
+struct vbase;
 
 namespace helpers {
 
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index 49a017f..17ca10e 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -1,7 +1,10 @@
-LOCAL_PATH:= $(call my-dir)
+LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES:= \
+LOCAL_CLANG := true
+
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+LOCAL_SRC_FILES := \
     Client.cpp \
     DisplayDevice.cpp \
     DispSync.cpp \
@@ -11,9 +14,9 @@
     Layer.cpp \
     LayerDim.cpp \
     MessageQueue.cpp \
+    MonitoredProducer.cpp \
     SurfaceFlinger.cpp \
     SurfaceFlingerConsumer.cpp \
-    SurfaceTextureLayer.cpp \
     Transform.cpp \
     DisplayHardware/FramebufferSurface.cpp \
     DisplayHardware/HWComposer.cpp \
@@ -34,21 +37,18 @@
     RenderEngine/GLES20RenderEngine.cpp
 
 
-LOCAL_CFLAGS:= -DLOG_TAG=\"SurfaceFlinger\"
+LOCAL_CFLAGS := -DLOG_TAG=\"SurfaceFlinger\"
 LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
 
-ifeq ($(TARGET_BOARD_PLATFORM),omap3)
-	LOCAL_CFLAGS += -DNO_RGBX_8888
-endif
 ifeq ($(TARGET_BOARD_PLATFORM),omap4)
-	LOCAL_CFLAGS += -DHAS_CONTEXT_PRIORITY
+    LOCAL_CFLAGS += -DHAS_CONTEXT_PRIORITY
 endif
 ifeq ($(TARGET_BOARD_PLATFORM),s5pc110)
-	LOCAL_CFLAGS += -DHAS_CONTEXT_PRIORITY
+    LOCAL_CFLAGS += -DHAS_CONTEXT_PRIORITY
 endif
 
 ifeq ($(TARGET_DISABLE_TRIPLE_BUFFERING),true)
-	LOCAL_CFLAGS += -DTARGET_DISABLE_TRIPLE_BUFFERING
+    LOCAL_CFLAGS += -DTARGET_DISABLE_TRIPLE_BUFFERING
 endif
 
 ifeq ($(TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS),true)
@@ -56,7 +56,7 @@
 endif
 
 ifneq ($(NUM_FRAMEBUFFER_SURFACE_BUFFERS),)
-  LOCAL_CFLAGS += -DNUM_FRAMEBUFFER_SURFACE_BUFFERS=$(NUM_FRAMEBUFFER_SURFACE_BUFFERS)
+    LOCAL_CFLAGS += -DNUM_FRAMEBUFFER_SURFACE_BUFFERS=$(NUM_FRAMEBUFFER_SURFACE_BUFFERS)
 endif
 
 ifeq ($(TARGET_RUNNING_WITHOUT_SYNC_FRAMEWORK),true)
@@ -83,22 +83,32 @@
     LOCAL_CFLAGS += -DPRESENT_TIME_OFFSET_FROM_VSYNC_NS=0
 endif
 
-LOCAL_CFLAGS += -fvisibility=hidden
+ifneq ($(MAX_VIRTUAL_DISPLAY_DIMENSION),)
+    LOCAL_CFLAGS += -DMAX_VIRTUAL_DISPLAY_DIMENSION=$(MAX_VIRTUAL_DISPLAY_DIMENSION)
+else
+    LOCAL_CFLAGS += -DMAX_VIRTUAL_DISPLAY_DIMENSION=0
+endif
+
+LOCAL_CFLAGS += -fvisibility=hidden -Werror=format
+LOCAL_CFLAGS += -std=c++11
 
 LOCAL_SHARED_LIBRARIES := \
-	libcutils \
-	liblog \
-	libdl \
-	libhardware \
-	libutils \
-	libEGL \
-	libGLESv1_CM \
-	libGLESv2 \
-	libbinder \
-	libui \
-	libgui
+    libcutils \
+    liblog \
+    libdl \
+    libhardware \
+    libutils \
+    libEGL \
+    libGLESv1_CM \
+    libGLESv2 \
+    libbinder \
+    libui \
+    libgui \
+    libpowermanager
 
-LOCAL_MODULE:= libsurfaceflinger
+LOCAL_MODULE := libsurfaceflinger
+
+LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
 
 include $(BUILD_SHARED_LIBRARY)
 
@@ -106,41 +116,58 @@
 # build surfaceflinger's executable
 include $(CLEAR_VARS)
 
-LOCAL_CFLAGS:= -DLOG_TAG=\"SurfaceFlinger\"
+LOCAL_CLANG := true
 
-LOCAL_SRC_FILES:= \
-	main_surfaceflinger.cpp 
+LOCAL_LDFLAGS := -Wl,--version-script,art/sigchainlib/version-script.txt -Wl,--export-dynamic
+LOCAL_CFLAGS := -DLOG_TAG=\"SurfaceFlinger\"
+LOCAL_CPPFLAGS := -std=c++11
+
+LOCAL_INIT_RC := surfaceflinger.rc
+
+LOCAL_SRC_FILES := \
+    main_surfaceflinger.cpp
 
 LOCAL_SHARED_LIBRARIES := \
-	libsurfaceflinger \
-	libcutils \
-	liblog \
-	libbinder \
-	libutils
+    libsurfaceflinger \
+    libcutils \
+    liblog \
+    libbinder \
+    libutils \
+    libdl
 
-LOCAL_MODULE:= surfaceflinger
+LOCAL_WHOLE_STATIC_LIBRARIES := libsigchain
+
+LOCAL_MODULE := surfaceflinger
 
 ifdef TARGET_32_BIT_SURFACEFLINGER
 LOCAL_32_BIT_ONLY := true
 endif
 
+LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
+
 include $(BUILD_EXECUTABLE)
 
 ###############################################################
 # uses jni which may not be available in PDK
 ifneq ($(wildcard libnativehelper/include),)
 include $(CLEAR_VARS)
-LOCAL_CFLAGS:= -DLOG_TAG=\"SurfaceFlinger\"
 
-LOCAL_SRC_FILES:= \
+LOCAL_CLANG := true
+
+LOCAL_CFLAGS := -DLOG_TAG=\"SurfaceFlinger\"
+LOCAL_CPPFLAGS := -std=c++11
+
+LOCAL_SRC_FILES := \
     DdmConnection.cpp
 
 LOCAL_SHARED_LIBRARIES := \
-	libcutils \
-	liblog \
-	libdl
+    libcutils \
+    liblog \
+    libdl
 
-LOCAL_MODULE:= libsurfaceflinger_ddmconnection
+LOCAL_MODULE := libsurfaceflinger_ddmconnection
+
+LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
 
 include $(BUILD_SHARED_LIBRARY)
 endif # libnativehelper
diff --git a/services/surfaceflinger/Barrier.h b/services/surfaceflinger/Barrier.h
index 6f8507e..3e9d443 100644
--- a/services/surfaceflinger/Barrier.h
+++ b/services/surfaceflinger/Barrier.h
@@ -28,15 +28,25 @@
 public:
     inline Barrier() : state(CLOSED) { }
     inline ~Barrier() { }
+
+    // Release any threads waiting at the Barrier.
+    // Provides release semantics: preceding loads and stores will be visible
+    // to other threads before they wake up.
     void open() {
         Mutex::Autolock _l(lock);
         state = OPENED;
         cv.broadcast();
     }
+
+    // Reset the Barrier, so wait() will block until open() has been called.
     void close() {
         Mutex::Autolock _l(lock);
         state = CLOSED;
     }
+
+    // Wait until the Barrier is OPEN.
+    // Provides acquire semantics: no subsequent loads or stores will occur
+    // until wait() returns.
     void wait() const {
         Mutex::Autolock _l(lock);
         while (state == CLOSED) {
diff --git a/services/surfaceflinger/Client.cpp b/services/surfaceflinger/Client.cpp
index 975631c..49389e0 100644
--- a/services/surfaceflinger/Client.cpp
+++ b/services/surfaceflinger/Client.cpp
@@ -93,7 +93,7 @@
      const int pid = ipc->getCallingPid();
      const int uid = ipc->getCallingUid();
      const int self_pid = getpid();
-     if (CC_UNLIKELY(pid != self_pid && uid != AID_GRAPHICS && uid != 0)) {
+     if (CC_UNLIKELY(pid != self_pid && uid != AID_GRAPHICS && uid != AID_SYSTEM && uid != 0)) {
          // we're called from a different process, do the real check
          if (!PermissionCache::checkCallingPermission(sAccessSurfaceFlinger))
          {
@@ -155,5 +155,23 @@
     return mFlinger->onLayerRemoved(this, handle);
 }
 
+status_t Client::clearLayerFrameStats(const sp<IBinder>& handle) const {
+    sp<Layer> layer = getLayerUser(handle);
+    if (layer == NULL) {
+        return NAME_NOT_FOUND;
+    }
+    layer->clearFrameStats();
+    return NO_ERROR;
+}
+
+status_t Client::getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const {
+    sp<Layer> layer = getLayerUser(handle);
+    if (layer == NULL) {
+        return NAME_NOT_FOUND;
+    }
+    layer->getFrameStats(outStats);
+    return NO_ERROR;
+}
+
 // ---------------------------------------------------------------------------
 }; // namespace android
diff --git a/services/surfaceflinger/Client.h b/services/surfaceflinger/Client.h
index 84e649f..b6d7381 100644
--- a/services/surfaceflinger/Client.h
+++ b/services/surfaceflinger/Client.h
@@ -60,6 +60,10 @@
 
     virtual status_t destroySurface(const sp<IBinder>& handle);
 
+    virtual status_t clearLayerFrameStats(const sp<IBinder>& handle) const;
+
+    virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const;
+
     virtual status_t onTransact(
         uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
 
diff --git a/services/surfaceflinger/DdmConnection.cpp b/services/surfaceflinger/DdmConnection.cpp
index d2c977d..659c2c8 100644
--- a/services/surfaceflinger/DdmConnection.cpp
+++ b/services/surfaceflinger/DdmConnection.cpp
@@ -45,23 +45,28 @@
     args.ignoreUnrecognized = JNI_FALSE;
 
 
-    void* libdvm_dso = dlopen("libdvm.so", RTLD_NOW);
-    ALOGE_IF(!libdvm_dso, "DdmConnection: %s", dlerror());
+    // TODO: Should this just link against libnativehelper and use its
+    // JNI_CreateJavaVM wrapper that essential does this dlopen/dlsym
+    // work based on the current system default runtime?
+    void* libart_dso = dlopen("libart.so", RTLD_NOW);
+    ALOGE_IF(!libart_dso, "DdmConnection: %s", dlerror());
 
     void* libandroid_runtime_dso = dlopen("libandroid_runtime.so", RTLD_NOW);
     ALOGE_IF(!libandroid_runtime_dso, "DdmConnection: %s", dlerror());
 
-    if (!libdvm_dso || !libandroid_runtime_dso) {
+    if (!libart_dso || !libandroid_runtime_dso) {
         goto error;
     }
 
     jint (*JNI_CreateJavaVM)(JavaVM** p_vm, JNIEnv** p_env, void* vm_args);
-    JNI_CreateJavaVM = (typeof JNI_CreateJavaVM)dlsym(libdvm_dso, "JNI_CreateJavaVM");
+    JNI_CreateJavaVM = reinterpret_cast<decltype(JNI_CreateJavaVM)>(
+            dlsym(libart_dso, "JNI_CreateJavaVM"));
     ALOGE_IF(!JNI_CreateJavaVM, "DdmConnection: %s", dlerror());
 
     jint (*registerNatives)(JNIEnv* env, jclass clazz);
-    registerNatives = (typeof registerNatives)dlsym(libandroid_runtime_dso,
-        "Java_com_android_internal_util_WithFramework_registerNatives");
+    registerNatives = reinterpret_cast<decltype(registerNatives)>(
+            dlsym(libandroid_runtime_dso,
+                "Java_com_android_internal_util_WithFramework_registerNatives"));
     ALOGE_IF(!registerNatives, "DdmConnection: %s", dlerror());
 
     if (!JNI_CreateJavaVM || !registerNatives) {
@@ -104,8 +109,8 @@
     if (libandroid_runtime_dso) {
         dlclose(libandroid_runtime_dso);
     }
-    if (libdvm_dso) {
-        dlclose(libdvm_dso);
+    if (libart_dso) {
+        dlclose(libart_dso);
     }
 }
 
diff --git a/services/surfaceflinger/DispSync.cpp b/services/surfaceflinger/DispSync.cpp
index 602f20a..3738a55 100644
--- a/services/surfaceflinger/DispSync.cpp
+++ b/services/surfaceflinger/DispSync.cpp
@@ -37,25 +37,17 @@
 
 // Setting this to true enables verbose tracing that can be used to debug
 // vsync event model or phase issues.
-static const bool traceDetailedInfo = false;
+static const bool kTraceDetailedInfo = false;
 
 // This is the threshold used to determine when hardware vsync events are
 // needed to re-synchronize the software vsync model with the hardware.  The
 // error metric used is the mean of the squared difference between each
 // present time and the nearest software-predicted vsync.
-static const nsecs_t errorThreshold = 160000000000;
-
-// This works around the lack of support for the sync framework on some
-// devices.
-#ifdef RUNNING_WITHOUT_SYNC_FRAMEWORK
-static const bool runningWithoutSyncFramework = true;
-#else
-static const bool runningWithoutSyncFramework = false;
-#endif
+static const nsecs_t kErrorThreshold = 160000000000;    // 400 usec squared
 
 // This is the offset from the present fence timestamps to the corresponding
 // vsync event.
-static const int64_t presentTimeOffset = PRESENT_TIME_OFFSET_FROM_VSYNC_NS;
+static const int64_t kPresentTimeOffset = PRESENT_TIME_OFFSET_FROM_VSYNC_NS;
 
 class DispSyncThread: public Thread {
 public:
@@ -135,7 +127,7 @@
                         // Don't correct by more than 500 us
                         mWakeupLatency = 500000;
                     }
-                    if (traceDetailedInfo) {
+                    if (kTraceDetailedInfo) {
                         ATRACE_INT64("DispSync:WakeupLat", now - nextEventTime);
                         ATRACE_INT64("DispSync:AvgWakeupLat", mWakeupLatency);
                     }
@@ -193,8 +185,7 @@
         return BAD_VALUE;
     }
 
-    // This method is only here to handle the runningWithoutSyncFramework
-    // case.
+    // This method is only here to handle the kIgnorePresentFences case.
     bool hasAnyEventListeners() {
         Mutex::Autolock lock(mMutex);
         return !mEventListeners.empty();
@@ -296,19 +287,22 @@
     bool mParity;
 };
 
-DispSync::DispSync() {
-    mThread = new DispSyncThread();
+DispSync::DispSync() :
+        mRefreshSkipCount(0),
+        mThread(new DispSyncThread()) {
+
     mThread->run("DispSync", PRIORITY_URGENT_DISPLAY + PRIORITY_MORE_FAVORABLE);
 
     reset();
     beginResync();
 
-    if (traceDetailedInfo) {
-        // If runningWithoutSyncFramework is true then the ZeroPhaseTracer
+    if (kTraceDetailedInfo) {
+        // If we're not getting present fences then the ZeroPhaseTracer
         // would prevent HW vsync event from ever being turned off.
-        // Furthermore the zero-phase tracing is not needed because any time
-        // there is an event registered we will turn on the HW vsync events.
-        if (!runningWithoutSyncFramework) {
+        // Even if we're just ignoring the fences, the zero-phase tracing is
+        // not needed because any time there is an event registered we will
+        // turn on the HW vsync events.
+        if (!kIgnorePresentFences) {
             addEventListener(0, new ZeroPhaseTracer());
         }
     }
@@ -339,14 +333,14 @@
             nsecs_t t = f->getSignalTime();
             if (t < INT64_MAX) {
                 mPresentFences[i].clear();
-                mPresentTimes[i] = t + presentTimeOffset;
+                mPresentTimes[i] = t + kPresentTimeOffset;
             }
         }
     }
 
     updateErrorLocked();
 
-    return mPeriod == 0 || mError > errorThreshold;
+    return mPeriod == 0 || mError > kErrorThreshold;
 }
 
 void DispSync::beginResync() {
@@ -373,7 +367,7 @@
         resetErrorLocked();
     }
 
-    if (runningWithoutSyncFramework) {
+    if (kIgnorePresentFences) {
         // If we don't have the sync framework we will never have
         // addPresentFence called.  This means we have no way to know whether
         // or not we're synchronized with the HW vsyncs, so we just request
@@ -382,7 +376,7 @@
         return mThread->hasAnyEventListeners();
     }
 
-    return mPeriod == 0 || mError > errorThreshold;
+    return mPeriod == 0 || mError > kErrorThreshold;
 }
 
 void DispSync::endResync() {
@@ -395,6 +389,13 @@
     return mThread->addEventListener(phase, callback);
 }
 
+void DispSync::setRefreshSkipCount(int count) {
+    Mutex::Autolock lock(mMutex);
+    ALOGD("setRefreshSkipCount(%d)", count);
+    mRefreshSkipCount = count;
+    updateModelLocked();
+}
+
 status_t DispSync::removeEventListener(const sp<Callback>& callback) {
     Mutex::Autolock lock(mMutex);
     return mThread->removeEventListener(callback);
@@ -407,6 +408,12 @@
     mThread->updateModel(mPeriod, mPhase);
 }
 
+nsecs_t DispSync::getPeriod() {
+    // lock mutex as mPeriod changes multiple times in updateModelLocked
+    Mutex::Autolock lock(mMutex);
+    return mPeriod;
+}
+
 void DispSync::updateModelLocked() {
     if (mNumResyncSamples >= MIN_RESYNC_SAMPLES_FOR_UPDATE) {
         nsecs_t durationSum = 0;
@@ -438,11 +445,14 @@
             mPhase += mPeriod;
         }
 
-        if (traceDetailedInfo) {
+        if (kTraceDetailedInfo) {
             ATRACE_INT64("DispSync:Period", mPeriod);
             ATRACE_INT64("DispSync:Phase", mPhase);
         }
 
+        // Artificially inflate the period if requested.
+        mPeriod += mPeriod * mRefreshSkipCount;
+
         mThread->updateModel(mPeriod, mPhase);
     }
 }
@@ -452,15 +462,19 @@
         return;
     }
 
+    // Need to compare present fences against the un-adjusted refresh period,
+    // since they might arrive between two events.
+    nsecs_t period = mPeriod / (1 + mRefreshSkipCount);
+
     int numErrSamples = 0;
     nsecs_t sqErrSum = 0;
 
     for (size_t i = 0; i < NUM_PRESENT_SAMPLES; i++) {
         nsecs_t sample = mPresentTimes[i];
         if (sample > mPhase) {
-            nsecs_t sampleErr = (sample - mPhase) % mPeriod;
-            if (sampleErr > mPeriod / 2) {
-                sampleErr -= mPeriod;
+            nsecs_t sampleErr = (sample - mPhase) % period;
+            if (sampleErr > period / 2) {
+                sampleErr -= period;
             }
             sqErrSum += sampleErr * sampleErr;
             numErrSamples++;
@@ -473,7 +487,7 @@
         mError = 0;
     }
 
-    if (traceDetailedInfo) {
+    if (kTraceDetailedInfo) {
         ATRACE_INT64("DispSync:Error", mError);
     }
 }
@@ -487,4 +501,65 @@
     }
 }
 
+nsecs_t DispSync::computeNextRefresh(int periodOffset) const {
+    Mutex::Autolock lock(mMutex);
+    nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);
+    return (((now - mPhase) / mPeriod) + periodOffset + 1) * mPeriod + mPhase;
+}
+
+void DispSync::dump(String8& result) const {
+    Mutex::Autolock lock(mMutex);
+    result.appendFormat("present fences are %s\n",
+            kIgnorePresentFences ? "ignored" : "used");
+    result.appendFormat("mPeriod: %" PRId64 " ns (%.3f fps; skipCount=%d)\n",
+            mPeriod, 1000000000.0 / mPeriod, mRefreshSkipCount);
+    result.appendFormat("mPhase: %" PRId64 " ns\n", mPhase);
+    result.appendFormat("mError: %" PRId64 " ns (sqrt=%.1f)\n",
+            mError, sqrt(mError));
+    result.appendFormat("mNumResyncSamplesSincePresent: %d (limit %d)\n",
+            mNumResyncSamplesSincePresent, MAX_RESYNC_SAMPLES_WITHOUT_PRESENT);
+    result.appendFormat("mNumResyncSamples: %zd (max %d)\n",
+            mNumResyncSamples, MAX_RESYNC_SAMPLES);
+
+    result.appendFormat("mResyncSamples:\n");
+    nsecs_t previous = -1;
+    for (size_t i = 0; i < mNumResyncSamples; i++) {
+        size_t idx = (mFirstResyncSample + i) % MAX_RESYNC_SAMPLES;
+        nsecs_t sampleTime = mResyncSamples[idx];
+        if (i == 0) {
+            result.appendFormat("  %" PRId64 "\n", sampleTime);
+        } else {
+            result.appendFormat("  %" PRId64 " (+%" PRId64 ")\n",
+                    sampleTime, sampleTime - previous);
+        }
+        previous = sampleTime;
+    }
+
+    result.appendFormat("mPresentFences / mPresentTimes [%d]:\n",
+            NUM_PRESENT_SAMPLES);
+    nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);
+    previous = 0;
+    for (size_t i = 0; i < NUM_PRESENT_SAMPLES; i++) {
+        size_t idx = (i + mPresentSampleOffset) % NUM_PRESENT_SAMPLES;
+        bool signaled = mPresentFences[idx] == NULL;
+        nsecs_t presentTime = mPresentTimes[idx];
+        if (!signaled) {
+            result.appendFormat("  [unsignaled fence]\n");
+        } else if (presentTime == 0) {
+            result.appendFormat("  0\n");
+        } else if (previous == 0) {
+            result.appendFormat("  %" PRId64 "  (%.3f ms ago)\n", presentTime,
+                    (now - presentTime) / 1000000.0);
+        } else {
+            result.appendFormat("  %" PRId64 " (+%" PRId64 " / %.3f)  (%.3f ms ago)\n",
+                    presentTime, presentTime - previous,
+                    (presentTime - previous) / (double) mPeriod,
+                    (now - presentTime) / 1000000.0);
+        }
+        previous = presentTime;
+    }
+
+    result.appendFormat("current monotonic time: %" PRId64 "\n", now);
+}
+
 } // namespace android
diff --git a/services/surfaceflinger/DispSync.h b/services/surfaceflinger/DispSync.h
index c4280aa..67142b6 100644
--- a/services/surfaceflinger/DispSync.h
+++ b/services/surfaceflinger/DispSync.h
@@ -25,6 +25,18 @@
 
 namespace android {
 
+// Ignore present (retire) fences if the device doesn't have support for the
+// sync framework, or if all phase offsets are zero.  The latter is useful
+// because it allows us to avoid resync bursts on devices that don't need
+// phase-offset VSYNC events.
+#if defined(RUNNING_WITHOUT_SYNC_FRAMEWORK) || \
+        (VSYNC_EVENT_PHASE_OFFSET_NS == 0 && SF_VSYNC_EVENT_PHASE_OFFSET_NS == 0)
+static const bool kIgnorePresentFences = true;
+#else
+static const bool kIgnorePresentFences = false;
+#endif
+
+
 class String8;
 class Fence;
 class DispSyncThread;
@@ -55,6 +67,7 @@
     DispSync();
     ~DispSync();
 
+    // reset clears the resync samples and error value.
     void reset();
 
     // addPresentFence adds a fence for use in validating the current vsync
@@ -83,11 +96,20 @@
     bool addResyncSample(nsecs_t timestamp);
     void endResync();
 
-    // The setPreiod method sets the vsync event model's period to a specific
+    // The setPeriod method sets the vsync event model's period to a specific
     // value.  This should be used to prime the model when a display is first
     // turned on.  It should NOT be used after that.
     void setPeriod(nsecs_t period);
 
+    // The getPeriod method returns the current vsync period.
+    nsecs_t getPeriod();
+
+    // setRefreshSkipCount specifies an additional number of refresh
+    // cycles to skip.  For example, on a 60Hz display, a skip count of 1
+    // will result in events happening at 30Hz.  Default is zero.  The idea
+    // is to sacrifice smoothness for battery life.
+    void setRefreshSkipCount(int count);
+
     // addEventListener registers a callback to be called repeatedly at the
     // given phase offset from the hardware vsync events.  The callback is
     // called from a separate thread and it should return reasonably quickly
@@ -99,6 +121,15 @@
     // DispSync object.
     status_t removeEventListener(const sp<Callback>& callback);
 
+    // computeNextRefresh computes when the next refresh is expected to begin.
+    // The periodOffset value can be used to move forward or backward; an
+    // offset of zero is the next refresh, -1 is the previous refresh, 1 is
+    // the refresh after next. etc.
+    nsecs_t computeNextRefresh(int periodOffset) const;
+
+    // dump appends human-readable debug info to the result string.
+    void dump(String8& result) const;
+
 private:
 
     void updateModelLocked();
@@ -108,7 +139,7 @@
     enum { MAX_RESYNC_SAMPLES = 32 };
     enum { MIN_RESYNC_SAMPLES_FOR_UPDATE = 3 };
     enum { NUM_PRESENT_SAMPLES = 8 };
-    enum { MAX_RESYNC_SAMPLES_WITHOUT_PRESENT = 12 };
+    enum { MAX_RESYNC_SAMPLES_WITHOUT_PRESENT = 4 };
 
     // mPeriod is the computed period of the modeled vsync events in
     // nanoseconds.
@@ -137,6 +168,8 @@
     nsecs_t mPresentTimes[NUM_PRESENT_SAMPLES];
     size_t mPresentSampleOffset;
 
+    int mRefreshSkipCount;
+
     // mThread is the thread from which all the callbacks are called.
     sp<DispSyncThread> mThread;
 
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index a1430b9..bdf8f74 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -44,6 +44,18 @@
 using namespace android;
 // ----------------------------------------------------------------------------
 
+#ifdef EGL_ANDROID_swap_rectangle
+static constexpr bool kEGLAndroidSwapRectangle = true;
+#else
+static constexpr bool kEGLAndroidSwapRectangle = false;
+#endif
+
+#if !defined(EGL_EGLEXT_PROTOTYPES) || !defined(EGL_ANDROID_swap_rectangle)
+// Dummy implementation in case it is missing.
+inline void eglSetSwapRectangleANDROID (EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint) {
+}
+#endif
+
 /*
  * Initialize the display to the specified values.
  *
@@ -59,7 +71,8 @@
         const sp<DisplaySurface>& displaySurface,
         const sp<IGraphicBufferProducer>& producer,
         EGLConfig config)
-    : mFlinger(flinger),
+    : lastCompositionHadVisibleLayers(false),
+      mFlinger(flinger),
       mType(type), mHwcDisplayId(hwcId),
       mDisplayToken(displayToken),
       mDisplaySurface(displaySurface),
@@ -70,26 +83,27 @@
       mPageFlipCount(),
       mIsSecure(isSecure),
       mSecureLayerVisible(false),
-      mScreenAcquired(false),
       mLayerStack(NO_LAYER_STACK),
-      mOrientation()
+      mOrientation(),
+      mPowerMode(HWC_POWER_MODE_OFF),
+      mActiveConfig(0)
 {
-    mNativeWindow = new Surface(producer, false);
+    Surface* surface;
+    mNativeWindow = surface = new Surface(producer, false);
     ANativeWindow* const window = mNativeWindow.get();
 
     /*
      * Create our display's surface
      */
 
-    EGLSurface surface;
-    EGLint w, h;
+    EGLSurface eglSurface;
     EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
     if (config == EGL_NO_CONFIG) {
         config = RenderEngine::chooseEglConfig(display, format);
     }
-    surface = eglCreateWindowSurface(display, config, window, NULL);
-    eglQuerySurface(display, surface, EGL_WIDTH,  &mDisplayWidth);
-    eglQuerySurface(display, surface, EGL_HEIGHT, &mDisplayHeight);
+    eglSurface = eglCreateWindowSurface(display, config, window, NULL);
+    eglQuerySurface(display, eglSurface, EGL_WIDTH,  &mDisplayWidth);
+    eglQuerySurface(display, eglSurface, EGL_HEIGHT, &mDisplayHeight);
 
     // Make sure that composition can never be stalled by a virtual display
     // consumer that isn't processing buffers fast enough. We have to do this
@@ -101,15 +115,17 @@
     if (mType >= DisplayDevice::DISPLAY_VIRTUAL)
         window->setSwapInterval(window, 0);
 
+    mConfig = config;
     mDisplay = display;
-    mSurface = surface;
+    mSurface = eglSurface;
     mFormat  = format;
     mPageFlipCount = 0;
     mViewport.makeInvalid();
     mFrame.makeInvalid();
 
     // virtual displays are always considered enabled
-    mScreenAcquired = (mType >= DisplayDevice::DISPLAY_VIRTUAL);
+    mPowerMode = (mType >= DisplayDevice::DISPLAY_VIRTUAL) ?
+                  HWC_POWER_MODE_NORMAL : HWC_POWER_MODE_OFF;
 
     // Name the display.  The name will be replaced shortly if the display
     // was created with createDisplay().
@@ -127,6 +143,10 @@
 
     // initialize the display orientation transform.
     setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
+
+#ifdef NUM_FRAMEBUFFER_SURFACE_BUFFERS
+    surface->allocateBuffers();
+#endif
 }
 
 DisplayDevice::~DisplayDevice() {
@@ -184,23 +204,20 @@
 {
     mFlinger->getRenderEngine().checkErrors();
 
-    EGLDisplay dpy = mDisplay;
-    EGLSurface surface = mSurface;
-
-#ifdef EGL_ANDROID_swap_rectangle
-    if (mFlags & SWAP_RECTANGLE) {
-        const Region newDirty(dirty.intersect(bounds()));
-        const Rect b(newDirty.getBounds());
-        eglSetSwapRectangleANDROID(dpy, surface,
-                b.left, b.top, b.width(), b.height());
+    if (kEGLAndroidSwapRectangle) {
+        if (mFlags & SWAP_RECTANGLE) {
+            const Region newDirty(dirty.intersect(bounds()));
+            const Rect b(newDirty.getBounds());
+            eglSetSwapRectangleANDROID(mDisplay, mSurface,
+                    b.left, b.top, b.width(), b.height());
+        }
     }
-#endif
 
     mPageFlipCount++;
 }
 
-status_t DisplayDevice::beginFrame() const {
-    return mDisplaySurface->beginFrame();
+status_t DisplayDevice::beginFrame(bool mustRecompose) const {
+    return mDisplaySurface->beginFrame(mustRecompose);
 }
 
 status_t DisplayDevice::prepareFrame(const HWComposer& hwc) const {
@@ -281,7 +298,9 @@
 void DisplayDevice::setViewportAndProjection() const {
     size_t w = mDisplayWidth;
     size_t h = mDisplayHeight;
-    mFlinger->getRenderEngine().setViewportAndProjection(w, h, w, h, false);
+    Rect sourceCrop(0, 0, w, h);
+    mFlinger->getRenderEngine().setViewportAndProjection(w, h, sourceCrop, h,
+        false, Transform::ROT_0);
 }
 
 // ----------------------------------------------------------------------------
@@ -319,21 +338,25 @@
 }
 
 // ----------------------------------------------------------------------------
-
-bool DisplayDevice::canDraw() const {
-    return mScreenAcquired;
+void DisplayDevice::setPowerMode(int mode) {
+    mPowerMode = mode;
 }
 
-void DisplayDevice::releaseScreen() const {
-    mScreenAcquired = false;
+int DisplayDevice::getPowerMode()  const {
+    return mPowerMode;
 }
 
-void DisplayDevice::acquireScreen() const {
-    mScreenAcquired = true;
+bool DisplayDevice::isDisplayOn() const {
+    return (mPowerMode != HWC_POWER_MODE_OFF);
 }
 
-bool DisplayDevice::isScreenAcquired() const {
-    return mScreenAcquired;
+// ----------------------------------------------------------------------------
+void DisplayDevice::setActiveConfig(int mode) {
+    mActiveConfig = mode;
+}
+
+int DisplayDevice::getActiveConfig()  const {
+    return mActiveConfig;
 }
 
 // ----------------------------------------------------------------------------
@@ -388,6 +411,27 @@
     return NO_ERROR;
 }
 
+void DisplayDevice::setDisplaySize(const int newWidth, const int newHeight) {
+    dirtyRegion.set(getBounds());
+
+    if (mSurface != EGL_NO_SURFACE) {
+        eglDestroySurface(mDisplay, mSurface);
+        mSurface = EGL_NO_SURFACE;
+    }
+
+    mDisplaySurface->resizeBuffers(newWidth, newHeight);
+
+    ANativeWindow* const window = mNativeWindow.get();
+    mSurface = eglCreateWindowSurface(mDisplay, mConfig, window, NULL);
+    eglQuerySurface(mDisplay, mSurface, EGL_WIDTH,  &mDisplayWidth);
+    eglQuerySurface(mDisplay, mSurface, EGL_HEIGHT, &mDisplayHeight);
+
+    LOG_FATAL_IF(mDisplayWidth != newWidth,
+                "Unable to set new width to %d", newWidth);
+    LOG_FATAL_IF(mDisplayHeight != newHeight,
+                "Unable to set new height to %d", newHeight);
+}
+
 void DisplayDevice::setProjection(int orientation,
         const Rect& newViewport, const Rect& newFrame) {
     Rect viewport(newViewport);
@@ -462,13 +506,14 @@
     result.appendFormat(
         "+ DisplayDevice: %s\n"
         "   type=%x, hwcId=%d, layerStack=%u, (%4dx%4d), ANativeWindow=%p, orient=%2d (type=%08x), "
-        "flips=%u, isSecure=%d, secureVis=%d, acquired=%d, numLayers=%zu\n"
+        "flips=%u, isSecure=%d, secureVis=%d, powerMode=%d, activeConfig=%d, numLayers=%zu\n"
         "   v:[%d,%d,%d,%d], f:[%d,%d,%d,%d], s:[%d,%d,%d,%d],"
         "transform:[[%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f]]\n",
         mDisplayName.string(), mType, mHwcDisplayId,
         mLayerStack, mDisplayWidth, mDisplayHeight, mNativeWindow.get(),
         mOrientation, tr.getType(), getPageFlipCount(),
-        mIsSecure, mSecureLayerVisible, mScreenAcquired, mVisibleLayersSortedByZ.size(),
+        mIsSecure, mSecureLayerVisible, mPowerMode, mActiveConfig,
+        mVisibleLayersSortedByZ.size(),
         mViewport.left, mViewport.top, mViewport.right, mViewport.bottom,
         mFrame.left, mFrame.top, mFrame.right, mFrame.bottom,
         mScissor.left, mScissor.top, mScissor.right, mScissor.bottom,
@@ -477,6 +522,6 @@
         tr[0][2], tr[1][2], tr[2][2]);
 
     String8 surfaceDump;
-    mDisplaySurface->dump(surfaceDump);
+    mDisplaySurface->dumpAsString(surfaceDump);
     result.append(surfaceDump);
 }
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index 01a9d2e..8695a44 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -37,7 +37,7 @@
 
 namespace android {
 
-class DisplayInfo;
+struct DisplayInfo;
 class DisplaySurface;
 class IGraphicBufferProducer;
 class Layer;
@@ -53,6 +53,7 @@
     mutable Region swapRegion;
     // region in screen space
     Region undefinedRegion;
+    bool lastCompositionHadVisibleLayers;
 
     enum DisplayType {
         DISPLAY_ID_INVALID = -1,
@@ -109,6 +110,7 @@
     Region                  getDirtyRegion(bool repaintEverything) const;
 
     void                    setLayerStack(uint32_t stack);
+    void                    setDisplaySize(const int newWidth, const int newHeight);
     void                    setProjection(int orientation, const Rect& viewport, const Rect& frame);
 
     int                     getOrientation() const { return mOrientation; }
@@ -124,7 +126,9 @@
     int32_t                 getHwcDisplayId() const { return mHwcDisplayId; }
     const wp<IBinder>&      getDisplayToken() const { return mDisplayToken; }
 
-    status_t beginFrame() const;
+    // We pass in mustRecompose so we can keep VirtualDisplaySurface's state
+    // machine happy without actually queueing a buffer if nothing has changed
+    status_t beginFrame(bool mustRecompose) const;
     status_t prepareFrame(const HWComposer& hwc) const;
 
     void swapBuffers(HWComposer& hwc) const;
@@ -145,12 +149,17 @@
     void setViewportAndProjection() const;
 
     /* ------------------------------------------------------------------------
-     * blank / unblank management
+     * Display power mode management.
      */
-    void releaseScreen() const;
-    void acquireScreen() const;
-    bool isScreenAcquired() const;
-    bool canDraw() const;
+    int getPowerMode() const;
+    void setPowerMode(int mode);
+    bool isDisplayOn() const;
+
+    /* ------------------------------------------------------------------------
+     * Display active config management.
+     */
+    int getActiveConfig() const;
+    void setActiveConfig(int mode);
 
     // release HWC resources (if any) for removable displays
     void disconnect(HWComposer& hwc);
@@ -174,6 +183,7 @@
     sp<ANativeWindow> mNativeWindow;
     sp<DisplaySurface> mDisplaySurface;
 
+    EGLConfig       mConfig;
     EGLDisplay      mDisplay;
     EGLSurface      mSurface;
     int             mDisplayWidth;
@@ -195,9 +205,6 @@
     // Whether we have a visible secure layer on this display
     bool mSecureLayerVisible;
 
-    // Whether the screen is blanked;
-    mutable int mScreenAcquired;
-
 
     /*
      * Transaction state
@@ -215,6 +222,10 @@
     Rect mScissor;
     Transform mGlobalTransform;
     bool mNeedsFiltering;
+    // Current power mode
+    int mPowerMode;
+    // Current active config
+    int mActiveConfig;
 };
 
 }; // namespace android
diff --git a/services/surfaceflinger/DisplayHardware/DisplaySurface.h b/services/surfaceflinger/DisplayHardware/DisplaySurface.h
index 48bf3f2..2f743c1 100644
--- a/services/surfaceflinger/DisplayHardware/DisplaySurface.h
+++ b/services/surfaceflinger/DisplayHardware/DisplaySurface.h
@@ -33,7 +33,9 @@
     // beginFrame is called at the beginning of the composition loop, before
     // the configuration is known. The DisplaySurface should do anything it
     // needs to do to enable HWComposer to decide how to compose the frame.
-    virtual status_t beginFrame() = 0;
+    // We pass in mustRecompose so we can keep VirtualDisplaySurface's state
+    // machine happy without actually queueing a buffer if nothing has changed.
+    virtual status_t beginFrame(bool mustRecompose) = 0;
 
     // prepareFrame is called after the composition configuration is known but
     // before composition takes place. The DisplaySurface can use the
@@ -68,7 +70,9 @@
     // frame's buffer.
     virtual void onFrameCommitted() = 0;
 
-    virtual void dump(String8& result) const = 0;
+    virtual void dumpAsString(String8& result) const = 0;
+
+    virtual void resizeBuffers(const uint32_t w, const uint32_t h) = 0;
 
 protected:
     DisplaySurface() {}
diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
index 7d4b196..70af656 100644
--- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
+++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
@@ -29,8 +29,9 @@
 #include <EGL/egl.h>
 
 #include <hardware/hardware.h>
-#include <gui/Surface.h>
+#include <gui/BufferItem.h>
 #include <gui/GraphicBufferAlloc.h>
+#include <gui/Surface.h>
 #include <ui/GraphicBuffer.h>
 
 #include "FramebufferSurface.h"
@@ -66,9 +67,10 @@
     mConsumer->setDefaultBufferFormat(mHwc.getFormat(disp));
     mConsumer->setDefaultBufferSize(mHwc.getWidth(disp),  mHwc.getHeight(disp));
     mConsumer->setDefaultMaxBufferCount(NUM_FRAMEBUFFER_SURFACE_BUFFERS);
+    mConsumer->setMaxAcquiredBufferCount(NUM_FRAMEBUFFER_SURFACE_BUFFERS - 1);
 }
 
-status_t FramebufferSurface::beginFrame() {
+status_t FramebufferSurface::beginFrame(bool /*mustRecompose*/) {
     return NO_ERROR;
 }
 
@@ -86,7 +88,7 @@
 status_t FramebufferSurface::nextBuffer(sp<GraphicBuffer>& outBuffer, sp<Fence>& outFence) {
     Mutex::Autolock lock(mMutex);
 
-    BufferQueue::BufferItem item;
+    BufferItem item;
     status_t err = acquireBufferLocked(&item, 0);
     if (err == BufferQueue::NO_BUFFER_AVAILABLE) {
         outBuffer = mCurrentBuffer;
@@ -122,7 +124,7 @@
 }
 
 // Overrides ConsumerBase::onFrameAvailable(), does not call base class impl.
-void FramebufferSurface::onFrameAvailable() {
+void FramebufferSurface::onFrameAvailable(const BufferItem& /* item */) {
     sp<GraphicBuffer> buf;
     sp<Fence> acquireFence;
     status_t err = nextBuffer(buf, acquireFence);
@@ -160,23 +162,7 @@
     return mHwc.fbCompositionComplete();
 }
 
-// Since DisplaySurface and ConsumerBase both have a method with this
-// signature, results will vary based on the static pointer type the caller is
-// using:
-//   void dump(FrameBufferSurface* fbs, String8& s) {
-//       // calls FramebufferSurface::dump()
-//       fbs->dump(s);
-//
-//       // calls ConsumerBase::dump() since it is non-virtual
-//       static_cast<ConsumerBase*>(fbs)->dump(s);
-//
-//       // calls FramebufferSurface::dump() since it is virtual
-//       static_cast<DisplaySurface*>(fbs)->dump(s);
-//   }
-// To make sure that all of these end up doing the same thing, we just redirect
-// to ConsumerBase::dump() here. It will take the internal lock, and then call
-// virtual dumpLocked(), which is where the real work happens.
-void FramebufferSurface::dump(String8& result) const {
+void FramebufferSurface::dumpAsString(String8& result) const {
     ConsumerBase::dump(result);
 }
 
diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h
index 1d67446..3d17840 100644
--- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h
+++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h
@@ -39,20 +39,21 @@
 public:
     FramebufferSurface(HWComposer& hwc, int disp, const sp<IGraphicBufferConsumer>& consumer);
 
-    virtual status_t beginFrame();
+    virtual status_t beginFrame(bool mustRecompose);
     virtual status_t prepareFrame(CompositionType compositionType);
     virtual status_t compositionComplete();
     virtual status_t advanceFrame();
     virtual void onFrameCommitted();
+    virtual void dumpAsString(String8& result) const;
 
-    // Implementation of DisplaySurface::dump(). Note that ConsumerBase also
-    // has a non-virtual dump() with the same signature.
-    virtual void dump(String8& result) const;
+    // Cannot resize a buffers in a FramebufferSurface. Only works with virtual
+    // displays.
+    virtual void resizeBuffers(const uint32_t /*w*/, const uint32_t /*h*/) { };
 
 private:
     virtual ~FramebufferSurface() { }; // this class cannot be overloaded
 
-    virtual void onFrameAvailable();
+    virtual void onFrameAvailable(const BufferItem& item);
     virtual void freeBufferLocked(int slotIndex);
 
     virtual void dumpLocked(String8& result, const char* prefix) const;
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index a48582e..d37fcb2 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -24,9 +24,9 @@
 #include <string.h>
 #include <sys/types.h>
 
-#include <utils/CallStack.h>
 #include <utils/Errors.h>
 #include <utils/misc.h>
+#include <utils/NativeHandle.h>
 #include <utils/String8.h>
 #include <utils/Thread.h>
 #include <utils/Trace.h>
@@ -170,20 +170,15 @@
 
         DisplayData& disp(mDisplayData[HWC_DISPLAY_PRIMARY]);
         disp.connected = true;
-        disp.width = mFbDev->width;
-        disp.height = mFbDev->height;
         disp.format = mFbDev->format;
-        disp.xdpi = mFbDev->xdpi;
-        disp.ydpi = mFbDev->ydpi;
-        if (disp.refresh == 0) {
-            disp.refresh = nsecs_t(1e9 / mFbDev->fps);
-            ALOGW("getting VSYNC period from fb HAL: %lld", disp.refresh);
-        }
-        if (disp.refresh == 0) {
-            disp.refresh = nsecs_t(1e9 / 60.0);
-            ALOGW("getting VSYNC period from thin air: %lld",
-                    mDisplayData[HWC_DISPLAY_PRIMARY].refresh);
-        }
+        DisplayConfig config = DisplayConfig();
+        config.width = mFbDev->width;
+        config.height = mFbDev->height;
+        config.xdpi = mFbDev->xdpi;
+        config.ydpi = mFbDev->ydpi;
+        config.refresh = nsecs_t(1e9 / mFbDev->fps);
+        disp.configs.push_back(config);
+        disp.currentConfig = 0;
     } else if (mHwc) {
         // here we're guaranteed to have at least HWC 1.1
         for (size_t i =0 ; i<NUM_BUILTIN_DISPLAYS ; i++) {
@@ -293,7 +288,7 @@
             // is a bug in the HWC implementation, but filter the extra events
             // out here so they don't cause havoc downstream.
             if (timestamp == mLastHwVSync[disp]) {
-                ALOGW("Ignoring duplicate VSYNC event from HWC (t=%lld)",
+                ALOGW("Ignoring duplicate VSYNC event from HWC (t=%" PRId64 ")",
                         timestamp);
                 return;
             }
@@ -310,18 +305,29 @@
 }
 
 void HWComposer::hotplug(int disp, int connected) {
-    if (disp == HWC_DISPLAY_PRIMARY || disp >= VIRTUAL_DISPLAY_ID_BASE) {
+    if (disp >= VIRTUAL_DISPLAY_ID_BASE) {
         ALOGE("hotplug event received for invalid display: disp=%d connected=%d",
                 disp, connected);
         return;
     }
     queryDisplayProperties(disp);
-    mEventHandler.onHotplugReceived(disp, bool(connected));
+    // Do not teardown or recreate the primary display
+    if (disp != HWC_DISPLAY_PRIMARY) {
+        mEventHandler.onHotplugReceived(disp, bool(connected));
+    }
 }
 
-static float getDefaultDensity(uint32_t height) {
-    if (height >= 1080) return ACONFIGURATION_DENSITY_XHIGH;
-    else                return ACONFIGURATION_DENSITY_TV;
+static float getDefaultDensity(uint32_t width, uint32_t height) {
+    // Default density is based on TVs: 1080p displays get XHIGH density,
+    // lower-resolution displays get TV density. Maybe eventually we'll need
+    // to update it for 4K displays, though hopefully those just report
+    // accurate DPI information to begin with. This is also used for virtual
+    // displays and even primary displays with older hwcomposers, so be
+    // careful about orientation.
+
+    uint32_t h = width < height ? width : height;
+    if (h >= 1080) return ACONFIGURATION_DENSITY_XHIGH;
+    else           return ACONFIGURATION_DENSITY_TV;
 }
 
 static const uint32_t DISPLAY_ATTRIBUTES[] = {
@@ -330,10 +336,20 @@
     HWC_DISPLAY_HEIGHT,
     HWC_DISPLAY_DPI_X,
     HWC_DISPLAY_DPI_Y,
+    HWC_DISPLAY_COLOR_TRANSFORM,
     HWC_DISPLAY_NO_ATTRIBUTE,
 };
 #define NUM_DISPLAY_ATTRIBUTES (sizeof(DISPLAY_ATTRIBUTES) / sizeof(DISPLAY_ATTRIBUTES)[0])
 
+static const uint32_t PRE_HWC15_DISPLAY_ATTRIBUTES[] = {
+    HWC_DISPLAY_VSYNC_PERIOD,
+    HWC_DISPLAY_WIDTH,
+    HWC_DISPLAY_HEIGHT,
+    HWC_DISPLAY_DPI_X,
+    HWC_DISPLAY_DPI_Y,
+    HWC_DISPLAY_NO_ATTRIBUTE,
+};
+
 status_t HWComposer::queryDisplayProperties(int disp) {
 
     LOG_ALWAYS_FATAL_IF(!mHwc || !hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1));
@@ -342,55 +358,72 @@
     int32_t values[NUM_DISPLAY_ATTRIBUTES - 1];
     memset(values, 0, sizeof(values));
 
-    uint32_t config;
-    size_t numConfigs = 1;
-    status_t err = mHwc->getDisplayConfigs(mHwc, disp, &config, &numConfigs);
+    const size_t MAX_NUM_CONFIGS = 128;
+    uint32_t configs[MAX_NUM_CONFIGS] = {0};
+    size_t numConfigs = MAX_NUM_CONFIGS;
+    status_t err = mHwc->getDisplayConfigs(mHwc, disp, configs, &numConfigs);
     if (err != NO_ERROR) {
         // this can happen if an unpluggable display is not connected
         mDisplayData[disp].connected = false;
         return err;
     }
 
-    err = mHwc->getDisplayAttributes(mHwc, disp, config, DISPLAY_ATTRIBUTES, values);
-    if (err != NO_ERROR) {
-        // we can't get this display's info. turn it off.
-        mDisplayData[disp].connected = false;
-        return err;
-    }
-
-    int32_t w = 0, h = 0;
-    for (size_t i = 0; i < NUM_DISPLAY_ATTRIBUTES - 1; i++) {
-        switch (DISPLAY_ATTRIBUTES[i]) {
-        case HWC_DISPLAY_VSYNC_PERIOD:
-            mDisplayData[disp].refresh = nsecs_t(values[i]);
-            break;
-        case HWC_DISPLAY_WIDTH:
-            mDisplayData[disp].width = values[i];
-            break;
-        case HWC_DISPLAY_HEIGHT:
-            mDisplayData[disp].height = values[i];
-            break;
-        case HWC_DISPLAY_DPI_X:
-            mDisplayData[disp].xdpi = values[i] / 1000.0f;
-            break;
-        case HWC_DISPLAY_DPI_Y:
-            mDisplayData[disp].ydpi = values[i] / 1000.0f;
-            break;
-        default:
-            ALOG_ASSERT(false, "unknown display attribute[%d] %#x",
-                    i, DISPLAY_ATTRIBUTES[i]);
-            break;
+    mDisplayData[disp].currentConfig = 0;
+    for (size_t c = 0; c < numConfigs; ++c) {
+        err = mHwc->getDisplayAttributes(mHwc, disp, configs[c],
+                DISPLAY_ATTRIBUTES, values);
+        // If this is a pre-1.5 HWC, it may not know about color transform, so
+        // try again with a smaller set of attributes
+        if (err != NO_ERROR) {
+            err = mHwc->getDisplayAttributes(mHwc, disp, configs[c],
+                    PRE_HWC15_DISPLAY_ATTRIBUTES, values);
         }
+        if (err != NO_ERROR) {
+            // we can't get this display's info. turn it off.
+            mDisplayData[disp].connected = false;
+            return err;
+        }
+
+        DisplayConfig config = DisplayConfig();
+        for (size_t i = 0; i < NUM_DISPLAY_ATTRIBUTES - 1; i++) {
+            switch (DISPLAY_ATTRIBUTES[i]) {
+                case HWC_DISPLAY_VSYNC_PERIOD:
+                    config.refresh = nsecs_t(values[i]);
+                    break;
+                case HWC_DISPLAY_WIDTH:
+                    config.width = values[i];
+                    break;
+                case HWC_DISPLAY_HEIGHT:
+                    config.height = values[i];
+                    break;
+                case HWC_DISPLAY_DPI_X:
+                    config.xdpi = values[i] / 1000.0f;
+                    break;
+                case HWC_DISPLAY_DPI_Y:
+                    config.ydpi = values[i] / 1000.0f;
+                    break;
+                case HWC_DISPLAY_COLOR_TRANSFORM:
+                    config.colorTransform = values[i];
+                    break;
+                default:
+                    ALOG_ASSERT(false, "unknown display attribute[%zu] %#x",
+                            i, DISPLAY_ATTRIBUTES[i]);
+                    break;
+            }
+        }
+
+        if (config.xdpi == 0.0f || config.ydpi == 0.0f) {
+            float dpi = getDefaultDensity(config.width, config.height);
+            config.xdpi = dpi;
+            config.ydpi = dpi;
+        }
+
+        mDisplayData[disp].configs.push_back(config);
     }
 
     // FIXME: what should we set the format to?
     mDisplayData[disp].format = HAL_PIXEL_FORMAT_RGBA_8888;
     mDisplayData[disp].connected = true;
-    if (mDisplayData[disp].xdpi == 0.0f || mDisplayData[disp].ydpi == 0.0f) {
-        float dpi = getDefaultDensity(h);
-        mDisplayData[disp].xdpi = dpi;
-        mDisplayData[disp].ydpi = dpi;
-    }
     return NO_ERROR;
 }
 
@@ -400,10 +433,12 @@
             !mAllocatedDisplayIDs.hasBit(id)) {
         return BAD_INDEX;
     }
-    mDisplayData[id].width = w;
-    mDisplayData[id].height = h;
+    size_t configId = mDisplayData[id].currentConfig;
     mDisplayData[id].format = format;
-    mDisplayData[id].xdpi = mDisplayData[id].ydpi = getDefaultDensity(h);
+    DisplayConfig& config = mDisplayData[id].configs.editItemAt(configId);
+    config.width = w;
+    config.height = h;
+    config.xdpi = config.ydpi = getDefaultDensity(w, h);
     return NO_ERROR;
 }
 
@@ -414,6 +449,8 @@
     int32_t id = mAllocatedDisplayIDs.firstUnmarkedBit();
     mAllocatedDisplayIDs.markBit(id);
     mDisplayData[id].connected = true;
+    mDisplayData[id].configs.resize(1);
+    mDisplayData[id].currentConfig = 0;
     return id;
 }
 
@@ -430,49 +467,64 @@
     return NO_ERROR;
 }
 
-nsecs_t HWComposer::getRefreshPeriod(int disp) const {
-    return mDisplayData[disp].refresh;
-}
-
 nsecs_t HWComposer::getRefreshTimestamp(int disp) const {
     // this returns the last refresh timestamp.
     // if the last one is not available, we estimate it based on
     // the refresh period and whatever closest timestamp we have.
     Mutex::Autolock _l(mLock);
     nsecs_t now = systemTime(CLOCK_MONOTONIC);
-    return now - ((now - mLastHwVSync[disp]) %  mDisplayData[disp].refresh);
+    size_t configId = mDisplayData[disp].currentConfig;
+    return now - ((now - mLastHwVSync[disp]) %
+            mDisplayData[disp].configs[configId].refresh);
 }
 
 sp<Fence> HWComposer::getDisplayFence(int disp) const {
     return mDisplayData[disp].lastDisplayFence;
 }
 
-uint32_t HWComposer::getWidth(int disp) const {
-    return mDisplayData[disp].width;
-}
-
-uint32_t HWComposer::getHeight(int disp) const {
-    return mDisplayData[disp].height;
-}
-
 uint32_t HWComposer::getFormat(int disp) const {
-    if (uint32_t(disp)>31 || !mAllocatedDisplayIDs.hasBit(disp)) {
+    if (static_cast<uint32_t>(disp) >= MAX_HWC_DISPLAYS || !mAllocatedDisplayIDs.hasBit(disp)) {
         return HAL_PIXEL_FORMAT_RGBA_8888;
     } else {
         return mDisplayData[disp].format;
     }
 }
 
+bool HWComposer::isConnected(int disp) const {
+    return mDisplayData[disp].connected;
+}
+
+uint32_t HWComposer::getWidth(int disp) const {
+    size_t currentConfig = mDisplayData[disp].currentConfig;
+    return mDisplayData[disp].configs[currentConfig].width;
+}
+
+uint32_t HWComposer::getHeight(int disp) const {
+    size_t currentConfig = mDisplayData[disp].currentConfig;
+    return mDisplayData[disp].configs[currentConfig].height;
+}
+
 float HWComposer::getDpiX(int disp) const {
-    return mDisplayData[disp].xdpi;
+    size_t currentConfig = mDisplayData[disp].currentConfig;
+    return mDisplayData[disp].configs[currentConfig].xdpi;
 }
 
 float HWComposer::getDpiY(int disp) const {
-    return mDisplayData[disp].ydpi;
+    size_t currentConfig = mDisplayData[disp].currentConfig;
+    return mDisplayData[disp].configs[currentConfig].ydpi;
 }
 
-bool HWComposer::isConnected(int disp) const {
-    return mDisplayData[disp].connected;
+nsecs_t HWComposer::getRefreshPeriod(int disp) const {
+    size_t currentConfig = mDisplayData[disp].currentConfig;
+    return mDisplayData[disp].configs[currentConfig].refresh;
+}
+
+const Vector<HWComposer::DisplayConfig>& HWComposer::getConfigs(int disp) const {
+    return mDisplayData[disp].configs;
+}
+
+size_t HWComposer::getCurrentConfig(int disp) const {
+    return mDisplayData[disp].currentConfig;
 }
 
 void HWComposer::eventControl(int disp, int event, int enabled) {
@@ -502,6 +554,10 @@
             if (!err) {
                 int32_t& events(mDisplayData[disp].events);
                 events = (events & ~eventBit) | newValue;
+
+                char tag[16];
+                snprintf(tag, sizeof(tag), "HW_VSYNC_ON_%1u", disp);
+                ATRACE_INT(tag, enabled);
             }
         }
         // error here should not happen -- not sure what we should
@@ -536,7 +592,10 @@
         if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
             disp.framebufferTarget = &disp.list->hwLayers[numLayers - 1];
             memset(disp.framebufferTarget, 0, sizeof(hwc_layer_1_t));
-            const hwc_rect_t r = { 0, 0, (int) disp.width, (int) disp.height };
+            const DisplayConfig& currentConfig =
+                    disp.configs[disp.currentConfig];
+            const hwc_rect_t r = { 0, 0,
+                    (int) currentConfig.width, (int) currentConfig.height };
             disp.framebufferTarget->compositionType = HWC_FRAMEBUFFER_TARGET;
             disp.framebufferTarget->hints = 0;
             disp.framebufferTarget->flags = 0;
@@ -546,8 +605,10 @@
             if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_3)) {
                 disp.framebufferTarget->sourceCropf.left = 0;
                 disp.framebufferTarget->sourceCropf.top = 0;
-                disp.framebufferTarget->sourceCropf.right = disp.width;
-                disp.framebufferTarget->sourceCropf.bottom = disp.height;
+                disp.framebufferTarget->sourceCropf.right =
+                        currentConfig.width;
+                disp.framebufferTarget->sourceCropf.bottom =
+                        currentConfig.height;
             } else {
                 disp.framebufferTarget->sourceCrop = r;
             }
@@ -593,6 +654,7 @@
 }
 
 status_t HWComposer::prepare() {
+    Mutex::Autolock _l(mDisplayLock);
     for (size_t i=0 ; i<mNumDisplays ; i++) {
         DisplayData& disp(mDisplayData[i]);
         if (disp.framebufferTarget) {
@@ -604,7 +666,7 @@
             disp.framebufferTarget->compositionType = HWC_FRAMEBUFFER_TARGET;
         }
         if (!disp.connected && disp.list != NULL) {
-            ALOGW("WARNING: disp %d: connected, non-null list, layers=%d",
+            ALOGW("WARNING: disp %zu: connected, non-null list, layers=%zu",
                   i, disp.list->numHwLayers);
         }
         mLists[i] = disp.list;
@@ -654,6 +716,9 @@
                     if (l.compositionType == HWC_OVERLAY) {
                         disp.hasOvComp = true;
                     }
+                    if (l.compositionType == HWC_CURSOR_OVERLAY) {
+                        disp.hasOvComp = true;
+                    }
                 }
                 if (disp.list->numHwLayers == (disp.framebufferTarget ? 1 : 0)) {
                     disp.hasFbComp = true;
@@ -732,19 +797,30 @@
     return (status_t)err;
 }
 
-status_t HWComposer::release(int disp) {
+status_t HWComposer::setPowerMode(int disp, int mode) {
     LOG_FATAL_IF(disp >= VIRTUAL_DISPLAY_ID_BASE);
     if (mHwc) {
-        eventControl(disp, HWC_EVENT_VSYNC, 0);
-        return (status_t)mHwc->blank(mHwc, disp, 1);
+        if (mode == HWC_POWER_MODE_OFF) {
+            eventControl(disp, HWC_EVENT_VSYNC, 0);
+        }
+        if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_4)) {
+            return (status_t)mHwc->setPowerMode(mHwc, disp, mode);
+        } else {
+            return (status_t)mHwc->blank(mHwc, disp,
+                    mode == HWC_POWER_MODE_OFF ? 1 : 0);
+        }
     }
     return NO_ERROR;
 }
 
-status_t HWComposer::acquire(int disp) {
+status_t HWComposer::setActiveConfig(int disp, int mode) {
     LOG_FATAL_IF(disp >= VIRTUAL_DISPLAY_ID_BASE);
-    if (mHwc) {
-        return (status_t)mHwc->blank(mHwc, disp, 0);
+    DisplayData& dd(mDisplayData[disp]);
+    dd.currentConfig = mode;
+    if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_4)) {
+        return (status_t)mHwc->setActiveConfig(mHwc, disp, mode);
+    } else {
+        LOG_FATAL_IF(mode != 0);
     }
     return NO_ERROR;
 }
@@ -760,6 +836,9 @@
     dd.lastRetireFence = Fence::NO_FENCE;
     dd.lastDisplayFence = Fence::NO_FENCE;
     dd.outbufAcquireFence = Fence::NO_FENCE;
+    // clear all the previous configs and repopulate when a new
+    // device is added
+    dd.configs.clear();
 }
 
 int HWComposer::getVisualID() const {
@@ -821,12 +900,22 @@
     return NO_ERROR;
 }
 
-sp<Fence> HWComposer::getLastRetireFence(int32_t id) {
+sp<Fence> HWComposer::getLastRetireFence(int32_t id) const {
     if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
         return Fence::NO_FENCE;
     return mDisplayData[id].lastRetireFence;
 }
 
+status_t HWComposer::setCursorPositionAsync(int32_t id, const Rect& pos)
+{
+    if (mHwc->setCursorPositionAsync) {
+        return (status_t)mHwc->setCursorPositionAsync(mHwc, id, pos.left, pos.top);
+    }
+    else {
+        return NO_ERROR;
+    }
+}
+
 /*
  * Helper template to implement a concrete HWCLayer
  * This holds the pointer to the concrete hwc layer type
@@ -909,6 +998,16 @@
             getLayer()->flags &= ~HWC_SKIP_LAYER;
         }
     }
+    virtual void setIsCursorLayerHint(bool isCursor) {
+        if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_4)) {
+            if (isCursor) {
+                getLayer()->flags |= HWC_IS_CURSOR_LAYER;
+            }
+            else {
+                getLayer()->flags &= ~HWC_IS_CURSOR_LAYER;
+            }
+        }
+    }
     virtual void setBlending(uint32_t blending) {
         getLayer()->blending = blending;
     }
@@ -937,12 +1036,31 @@
         }
     }
     virtual void setVisibleRegionScreen(const Region& reg) {
-        // Region::getSharedBuffer creates a reference to the underlying
-        // SharedBuffer of this Region, this reference is freed
-        // in onDisplayed()
         hwc_region_t& visibleRegion = getLayer()->visibleRegionScreen;
-        SharedBuffer const* sb = reg.getSharedBuffer(&visibleRegion.numRects);
-        visibleRegion.rects = reinterpret_cast<hwc_rect_t const *>(sb->data());
+        mVisibleRegion = reg;
+        visibleRegion.rects = reinterpret_cast<hwc_rect_t const *>(
+                mVisibleRegion.getArray(&visibleRegion.numRects));
+    }
+    virtual void setSurfaceDamage(const Region& reg) {
+        if (!hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_5)) {
+            return;
+        }
+        hwc_region_t& surfaceDamage = getLayer()->surfaceDamage;
+        // We encode default full-screen damage as INVALID_RECT upstream, but as
+        // 0 rects for HWComposer
+        if (reg.isRect() && reg.getBounds() == Rect::INVALID_RECT) {
+            surfaceDamage.numRects = 0;
+            surfaceDamage.rects = NULL;
+            return;
+        }
+        mSurfaceDamage = reg;
+        surfaceDamage.rects = reinterpret_cast<hwc_rect_t const *>(
+                mSurfaceDamage.getArray(&surfaceDamage.numRects));
+    }
+    virtual void setSidebandStream(const sp<NativeHandle>& stream) {
+        ALOG_ASSERT(stream->handle() != NULL);
+        getLayer()->compositionType = HWC_SIDEBAND;
+        getLayer()->sidebandStream = stream->handle();
     }
     virtual void setBuffer(const sp<GraphicBuffer>& buffer) {
         if (buffer == 0 || buffer->handle == 0) {
@@ -950,21 +1068,24 @@
             getLayer()->flags |= HWC_SKIP_LAYER;
             getLayer()->handle = 0;
         } else {
+            if (getLayer()->compositionType == HWC_SIDEBAND) {
+                // If this was a sideband layer but the stream was removed, reset
+                // it to FRAMEBUFFER. The HWC can change it to OVERLAY in prepare.
+                getLayer()->compositionType = HWC_FRAMEBUFFER;
+            }
             getLayer()->handle = buffer->handle;
         }
     }
     virtual void onDisplayed() {
-        hwc_region_t& visibleRegion = getLayer()->visibleRegionScreen;
-        SharedBuffer const* sb = SharedBuffer::bufferFromData(visibleRegion.rects);
-        if (sb) {
-            sb->release();
-            // not technically needed but safer
-            visibleRegion.numRects = 0;
-            visibleRegion.rects = NULL;
-        }
-
         getLayer()->acquireFenceFd = -1;
     }
+
+protected:
+    // We need to hold "copies" of these for memory management purposes. The
+    // actual hwc_layer_1_t holds pointers to the memory within. Vector<>
+    // internally doesn't copy the memory unless one of the copies is modified.
+    Region mVisibleRegion;
+    Region mSurfaceDamage;
 };
 
 /*
@@ -1010,9 +1131,28 @@
     return getLayerIterator(id, numLayers);
 }
 
+// Converts a PixelFormat to a human-readable string.  Max 11 chars.
+// (Could use a table of prefab String8 objects.)
+static String8 getFormatStr(PixelFormat format) {
+    switch (format) {
+    case PIXEL_FORMAT_RGBA_8888:    return String8("RGBA_8888");
+    case PIXEL_FORMAT_RGBX_8888:    return String8("RGBx_8888");
+    case PIXEL_FORMAT_RGB_888:      return String8("RGB_888");
+    case PIXEL_FORMAT_RGB_565:      return String8("RGB_565");
+    case PIXEL_FORMAT_BGRA_8888:    return String8("BGRA_8888");
+    case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
+                                    return String8("ImplDef");
+    default:
+        String8 result;
+        result.appendFormat("? %08x", format);
+        return result;
+    }
+}
+
 void HWComposer::dump(String8& result) const {
+    Mutex::Autolock _l(mDisplayLock);
     if (mHwc) {
-        result.appendFormat("Hardware Composer state (version %8x):\n", hwcApiVersion(mHwc));
+        result.appendFormat("Hardware Composer state (version %08x):\n", hwcApiVersion(mHwc));
         result.appendFormat("  mDebugForceFakeVSync=%d\n", mDebugForceFakeVSync);
         for (size_t i=0 ; i<mNumDisplays ; i++) {
             const DisplayData& disp(mDisplayData[i]);
@@ -1022,9 +1162,16 @@
             const Vector< sp<Layer> >& visibleLayersSortedByZ =
                     mFlinger->getLayerSortedByZForHwcDisplay(i);
 
-            result.appendFormat(
-                    "  Display[%zd] : %ux%u, xdpi=%f, ydpi=%f, refresh=%" PRId64 "\n",
-                    i, disp.width, disp.height, disp.xdpi, disp.ydpi, disp.refresh);
+
+            result.appendFormat("  Display[%zd] configurations (* current):\n", i);
+            for (size_t c = 0; c < disp.configs.size(); ++c) {
+                const DisplayConfig& config(disp.configs[c]);
+                result.appendFormat("    %s%zd: %ux%u, xdpi=%f, ydpi=%f"
+                        ", refresh=%" PRId64 ", colorTransform=%d\n",
+                        c == disp.currentConfig ? "* " : "", c,
+                        config.width, config.height, config.xdpi, config.ydpi,
+                        config.refresh, config.colorTransform);
+            }
 
             if (disp.list) {
                 result.appendFormat(
@@ -1032,9 +1179,9 @@
                         disp.list->numHwLayers, disp.list->flags);
 
                 result.append(
-                        "    type    |  handle  |   hints  |   flags  | tr | blend |  format  |          source crop            |           frame           name \n"
-                        "------------+----------+----------+----------+----+-------+----------+---------------------------------+--------------------------------\n");
-                //      " __________ | ________ | ________ | ________ | __ | _____ | ________ | [_____._,_____._,_____._,_____._] | [_____,_____,_____,_____]
+                        "    type   |  handle  | hint | flag | tr | blnd |   format    |     source crop (l,t,r,b)      |          frame         | name \n"
+                        "-----------+----------+------+------+----+------+-------------+--------------------------------+------------------------+------\n");
+                //      " _________ | ________ | ____ | ____ | __ | ____ | ___________ |_____._,_____._,_____._,_____._ |_____,_____,_____,_____ | ___...
                 for (size_t i=0 ; i<disp.list->numHwLayers ; i++) {
                     const hwc_layer_1_t&l = disp.list->hwLayers[i];
                     int32_t format = -1;
@@ -1059,25 +1206,28 @@
                     static char const* compositionTypeName[] = {
                             "GLES",
                             "HWC",
-                            "BACKGROUND",
+                            "BKGND",
                             "FB TARGET",
+                            "SIDEBAND",
+                            "HWC_CURSOR",
                             "UNKNOWN"};
                     if (type >= NELEM(compositionTypeName))
                         type = NELEM(compositionTypeName) - 1;
 
+                    String8 formatStr = getFormatStr(format);
                     if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_3)) {
                         result.appendFormat(
-                                " %10s | %08" PRIxPTR " | %08x | %08x | %02x | %05x | %08x | [%7.1f,%7.1f,%7.1f,%7.1f] | [%5d,%5d,%5d,%5d] %s\n",
+                                " %9s | %08" PRIxPTR " | %04x | %04x | %02x | %04x | %-11s |%7.1f,%7.1f,%7.1f,%7.1f |%5d,%5d,%5d,%5d | %s\n",
                                         compositionTypeName[type],
-                                        intptr_t(l.handle), l.hints, l.flags, l.transform, l.blending, format,
+                                        intptr_t(l.handle), l.hints, l.flags, l.transform, l.blending, formatStr.string(),
                                         l.sourceCropf.left, l.sourceCropf.top, l.sourceCropf.right, l.sourceCropf.bottom,
                                         l.displayFrame.left, l.displayFrame.top, l.displayFrame.right, l.displayFrame.bottom,
                                         name.string());
                     } else {
                         result.appendFormat(
-                                " %10s | %08" PRIxPTR " | %08x | %08x | %02x | %05x | %08x | [%7d,%7d,%7d,%7d] | [%5d,%5d,%5d,%5d] %s\n",
+                                " %9s | %08" PRIxPTR " | %04x | %04x | %02x | %04x | %-11s |%7d,%7d,%7d,%7d |%5d,%5d,%5d,%5d | %s\n",
                                         compositionTypeName[type],
-                                        intptr_t(l.handle), l.hints, l.flags, l.transform, l.blending, format,
+                                        intptr_t(l.handle), l.hints, l.flags, l.transform, l.blending, formatStr.string(),
                                         l.sourceCrop.left, l.sourceCrop.top, l.sourceCrop.right, l.sourceCrop.bottom,
                                         l.displayFrame.left, l.displayFrame.top, l.displayFrame.right, l.displayFrame.bottom,
                                         name.string());
@@ -1152,9 +1302,9 @@
 }
 
 HWComposer::DisplayData::DisplayData()
-:   width(0), height(0), format(HAL_PIXEL_FORMAT_RGBA_8888),
-    xdpi(0.0f), ydpi(0.0f),
-    refresh(0),
+:   configs(),
+    currentConfig(0),
+    format(HAL_PIXEL_FORMAT_RGBA_8888),
     connected(false),
     hasFbComp(false), hasOvComp(false),
     capacity(0), list(NULL),
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h
index 9f96113..5e0b3d8 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.h
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.h
@@ -45,9 +45,10 @@
 namespace android {
 // ---------------------------------------------------------------------------
 
-class GraphicBuffer;
 class Fence;
 class FloatRect;
+class GraphicBuffer;
+class NativeHandle;
 class Region;
 class String8;
 class SurfaceFlinger;
@@ -96,11 +97,11 @@
     // commits the list
     status_t commit();
 
-    // release hardware resources and blank screen
-    status_t release(int disp);
+    // set power mode
+    status_t setPowerMode(int disp, int mode);
 
-    // acquire hardware resources and unblank screen
-    status_t acquire(int disp);
+    // set active config
+    status_t setActiveConfig(int disp, int mode);
 
     // reset state when an external, non-virtual display is disconnected
     void disconnectDisplay(int disp);
@@ -141,7 +142,9 @@
     // signal when the h/w composer is completely finished with the frame.
     // For physical displays, it is no longer being displayed. For virtual
     // displays, writes to the output buffer are complete.
-    sp<Fence> getLastRetireFence(int32_t id);
+    sp<Fence> getLastRetireFence(int32_t id) const;
+
+    status_t setCursorPositionAsync(int32_t id, const Rect &pos);
 
     /*
      * Interface to hardware composer's layers functionality.
@@ -159,11 +162,14 @@
         virtual sp<Fence> getAndResetReleaseFence() = 0;
         virtual void setDefaultState() = 0;
         virtual void setSkip(bool skip) = 0;
+        virtual void setIsCursorLayerHint(bool isCursor = true) = 0;
         virtual void setBlending(uint32_t blending) = 0;
         virtual void setTransform(uint32_t transform) = 0;
         virtual void setFrame(const Rect& frame) = 0;
         virtual void setCrop(const FloatRect& crop) = 0;
         virtual void setVisibleRegionScreen(const Region& reg) = 0;
+        virtual void setSurfaceDamage(const Region& reg) = 0;
+        virtual void setSidebandStream(const sp<NativeHandle>& stream) = 0;
         virtual void setBuffer(const sp<GraphicBuffer>& buffer) = 0;
         virtual void setAcquireFenceFd(int fenceFd) = 0;
         virtual void setPlaneAlpha(uint8_t alpha) = 0;
@@ -191,7 +197,7 @@
      * This behaves more or less like a forward iterator.
      */
     class LayerListIterator {
-        friend struct HWComposer;
+        friend class HWComposer;
         HWCLayer* const mLayerList;
         size_t mIndex;
 
@@ -245,17 +251,32 @@
 
     void eventControl(int disp, int event, int enabled);
 
+    struct DisplayConfig {
+        uint32_t width;
+        uint32_t height;
+        float xdpi;
+        float ydpi;
+        nsecs_t refresh;
+        int colorTransform;
+    };
+
     // Query display parameters.  Pass in a display index (e.g.
     // HWC_DISPLAY_PRIMARY).
-    nsecs_t getRefreshPeriod(int disp) const;
     nsecs_t getRefreshTimestamp(int disp) const;
     sp<Fence> getDisplayFence(int disp) const;
+    uint32_t getFormat(int disp) const;
+    bool isConnected(int disp) const;
+
+    // These return the values for the current config of a given display index.
+    // To get the values for all configs, use getConfigs below.
     uint32_t getWidth(int disp) const;
     uint32_t getHeight(int disp) const;
-    uint32_t getFormat(int disp) const;
     float getDpiX(int disp) const;
     float getDpiY(int disp) const;
-    bool isConnected(int disp) const;
+    nsecs_t getRefreshPeriod(int disp) const;
+
+    const Vector<DisplayConfig>& getConfigs(int disp) const;
+    size_t getCurrentConfig(int disp) const;
 
     status_t setVirtualDisplayProperties(int32_t id, uint32_t w, uint32_t h,
             uint32_t format);
@@ -304,16 +325,12 @@
     status_t setFramebufferTarget(int32_t id,
             const sp<Fence>& acquireFence, const sp<GraphicBuffer>& buf);
 
-
     struct DisplayData {
         DisplayData();
         ~DisplayData();
-        uint32_t width;
-        uint32_t height;
+        Vector<DisplayConfig> configs;
+        size_t currentConfig;
         uint32_t format;    // pixel format from FB hal, for pre-hwc-1.1
-        float xdpi;
-        float ydpi;
-        nsecs_t refresh;
         bool connected;
         bool hasFbComp;
         bool hasOvComp;
@@ -338,6 +355,8 @@
     // mLists[i>0] can be NULL. that display is to be ignored
     struct hwc_display_contents_1*  mLists[MAX_HWC_DISPLAYS];
     DisplayData                     mDisplayData[MAX_HWC_DISPLAYS];
+    // protect mDisplayData from races between prepare and dump
+    mutable Mutex mDisplayLock;
     size_t                          mNumDisplays;
 
     cb_context*                     mCBContext;
diff --git a/services/surfaceflinger/DisplayHardware/PowerHAL.cpp b/services/surfaceflinger/DisplayHardware/PowerHAL.cpp
index e41fbbc..bd50b4a 100644
--- a/services/surfaceflinger/DisplayHardware/PowerHAL.cpp
+++ b/services/surfaceflinger/DisplayHardware/PowerHAL.cpp
@@ -20,38 +20,30 @@
 #include <cutils/log.h>
 #include <utils/Errors.h>
 
+#include <binder/IServiceManager.h>
+#include <powermanager/IPowerManager.h>
+#include <powermanager/PowerManager.h>
+
 #include "PowerHAL.h"
 
 namespace android {
 // ---------------------------------------------------------------------------
 
-PowerHAL::PowerHAL() : mPowerModule(0), mVSyncHintEnabled(false) {
-    int err = hw_get_module(POWER_HARDWARE_MODULE_ID,
-            (const hw_module_t **)&mPowerModule);
-    ALOGW_IF(err, "%s module not found", POWER_HARDWARE_MODULE_ID);
-}
-
-PowerHAL::~PowerHAL() {
-}
-
-status_t PowerHAL::initCheck() const {
-    return mPowerModule ? NO_ERROR : NO_INIT;
-}
-
 status_t PowerHAL::vsyncHint(bool enabled) {
-    if (!mPowerModule) {
-        return NO_INIT;
-    }
-    if (mPowerModule->common.module_api_version >= POWER_MODULE_API_VERSION_0_2) {
-        if (mPowerModule->powerHint) {
-            if (mVSyncHintEnabled != bool(enabled)) {
-                mPowerModule->powerHint(mPowerModule,
-                        POWER_HINT_VSYNC, (void*)enabled);
-                mVSyncHintEnabled = bool(enabled);
-            }
+    Mutex::Autolock _l(mlock);
+    if (mPowerManager == NULL) {
+        const String16 serviceName("power");
+        sp<IBinder> bs = defaultServiceManager()->checkService(serviceName);
+        if (bs == NULL) {
+            return NAME_NOT_FOUND;
         }
+        mPowerManager = interface_cast<IPowerManager>(bs);
     }
-    return NO_ERROR;
+    status_t status = mPowerManager->powerHint(POWER_HINT_VSYNC, enabled ? 1 : 0);
+    if(status == DEAD_OBJECT) {
+        mPowerManager = NULL;
+    }
+    return status;
 }
 
 // ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/DisplayHardware/PowerHAL.h b/services/surfaceflinger/DisplayHardware/PowerHAL.h
index ef67b8f..e5f82a9 100644
--- a/services/surfaceflinger/DisplayHardware/PowerHAL.h
+++ b/services/surfaceflinger/DisplayHardware/PowerHAL.h
@@ -19,7 +19,9 @@
 
 #include <stdint.h>
 #include <sys/types.h>
+#include <utils/Mutex.h>
 
+#include <powermanager/IPowerManager.h>
 #include <hardware/power.h>
 
 namespace android {
@@ -28,15 +30,11 @@
 class PowerHAL
 {
 public:
-    PowerHAL();
-    ~PowerHAL();
-
-    status_t initCheck() const;
     status_t vsyncHint(bool enabled);
 
 private:
-    power_module_t*   mPowerModule;
-    bool mVSyncHintEnabled;
+    sp<IPowerManager> mPowerManager;
+    Mutex mlock;
 };
 
 // ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
index d7fef8c..ba4c198 100644
--- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
+++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
@@ -18,6 +18,8 @@
 #include "VirtualDisplaySurface.h"
 #include "HWComposer.h"
 
+#include <gui/BufferItem.h>
+
 // ---------------------------------------------------------------------------
 namespace android {
 // ---------------------------------------------------------------------------
@@ -28,11 +30,11 @@
 static const bool sForceHwcCopy = false;
 #endif
 
-#define VDS_LOGE(msg, ...) ALOGE("[%s] "msg, \
+#define VDS_LOGE(msg, ...) ALOGE("[%s] " msg, \
         mDisplayName.string(), ##__VA_ARGS__)
-#define VDS_LOGW_IF(cond, msg, ...) ALOGW_IF(cond, "[%s] "msg, \
+#define VDS_LOGW_IF(cond, msg, ...) ALOGW_IF(cond, "[%s] " msg, \
         mDisplayName.string(), ##__VA_ARGS__)
-#define VDS_LOGV(msg, ...) ALOGV("[%s] "msg, \
+#define VDS_LOGV(msg, ...) ALOGV("[%s] " msg, \
         mDisplayName.string(), ##__VA_ARGS__)
 
 static const char* dbgCompositionTypeStr(DisplaySurface::CompositionType type) {
@@ -47,25 +49,29 @@
 
 VirtualDisplaySurface::VirtualDisplaySurface(HWComposer& hwc, int32_t dispId,
         const sp<IGraphicBufferProducer>& sink,
-        const sp<BufferQueue>& bq,
+        const sp<IGraphicBufferProducer>& bqProducer,
+        const sp<IGraphicBufferConsumer>& bqConsumer,
         const String8& name)
-:   ConsumerBase(bq),
+:   ConsumerBase(bqConsumer),
     mHwc(hwc),
     mDisplayId(dispId),
     mDisplayName(name),
     mOutputUsage(GRALLOC_USAGE_HW_COMPOSER),
     mProducerSlotSource(0),
     mDbgState(DBG_STATE_IDLE),
-    mDbgLastCompositionType(COMPOSITION_UNKNOWN)
+    mDbgLastCompositionType(COMPOSITION_UNKNOWN),
+    mMustRecompose(false)
 {
     mSource[SOURCE_SINK] = sink;
-    mSource[SOURCE_SCRATCH] = bq;
+    mSource[SOURCE_SCRATCH] = bqProducer;
 
     resetPerFrameState();
 
     int sinkWidth, sinkHeight;
     sink->query(NATIVE_WINDOW_WIDTH, &sinkWidth);
     sink->query(NATIVE_WINDOW_HEIGHT, &sinkHeight);
+    mSinkBufferWidth = sinkWidth;
+    mSinkBufferHeight = sinkHeight;
 
     // Pick the buffer format to request from the sink when not rendering to it
     // with GLES. If the consumer needs CPU access, use the default format
@@ -92,18 +98,16 @@
 VirtualDisplaySurface::~VirtualDisplaySurface() {
 }
 
-status_t VirtualDisplaySurface::beginFrame() {
+status_t VirtualDisplaySurface::beginFrame(bool mustRecompose) {
     if (mDisplayId < 0)
         return NO_ERROR;
 
+    mMustRecompose = mustRecompose;
+
     VDS_LOGW_IF(mDbgState != DBG_STATE_IDLE,
             "Unexpected beginFrame() in %s state", dbgStateStr());
     mDbgState = DBG_STATE_BEGUN;
 
-    uint32_t transformHint, numPendingBuffers;
-    mQueueBufferOutput.deflate(&mSinkBufferWidth, &mSinkBufferHeight,
-            &transformHint, &numPendingBuffers);
-
     return refreshOutputBuffer();
 }
 
@@ -228,27 +232,48 @@
         QueueBufferOutput qbo;
         sp<Fence> outFence = mHwc.getLastRetireFence(mDisplayId);
         VDS_LOGV("onFrameCommitted: queue sink sslot=%d", sslot);
-        status_t result = mSource[SOURCE_SINK]->queueBuffer(sslot,
-                QueueBufferInput(
-                    systemTime(), false /* isAutoTimestamp */,
-                    Rect(mSinkBufferWidth, mSinkBufferHeight),
-                    NATIVE_WINDOW_SCALING_MODE_FREEZE, 0 /* transform */,
-                    true /* async*/,
-                    outFence),
-                &qbo);
-        if (result == NO_ERROR) {
-            updateQueueBufferOutput(qbo);
+        if (mMustRecompose) {
+            status_t result = mSource[SOURCE_SINK]->queueBuffer(sslot,
+                    QueueBufferInput(
+                        systemTime(), false /* isAutoTimestamp */,
+                        HAL_DATASPACE_UNKNOWN,
+                        Rect(mSinkBufferWidth, mSinkBufferHeight),
+                        NATIVE_WINDOW_SCALING_MODE_FREEZE, 0 /* transform */,
+                        true /* async*/,
+                        outFence),
+                    &qbo);
+            if (result == NO_ERROR) {
+                updateQueueBufferOutput(qbo);
+            }
+        } else {
+            // If the surface hadn't actually been updated, then we only went
+            // through the motions of updating the display to keep our state
+            // machine happy. We cancel the buffer to avoid triggering another
+            // re-composition and causing an infinite loop.
+            mSource[SOURCE_SINK]->cancelBuffer(sslot, outFence);
         }
     }
 
     resetPerFrameState();
 }
 
-void VirtualDisplaySurface::dump(String8& result) const {
+void VirtualDisplaySurface::dumpAsString(String8& /* result */) const {
+}
+
+void VirtualDisplaySurface::resizeBuffers(const uint32_t w, const uint32_t h) {
+    uint32_t tmpW, tmpH, transformHint, numPendingBuffers;
+    mQueueBufferOutput.deflate(&tmpW, &tmpH, &transformHint, &numPendingBuffers);
+    mQueueBufferOutput.inflate(w, h, transformHint, numPendingBuffers);
+
+    mSinkBufferWidth = w;
+    mSinkBufferHeight = h;
 }
 
 status_t VirtualDisplaySurface::requestBuffer(int pslot,
         sp<GraphicBuffer>* outBuf) {
+    if (mDisplayId < 0)
+        return mSource[SOURCE_SINK]->requestBuffer(pslot, outBuf);
+
     VDS_LOGW_IF(mDbgState != DBG_STATE_GLES,
             "Unexpected requestBuffer pslot=%d in %s state",
             pslot, dbgStateStr());
@@ -262,7 +287,8 @@
 }
 
 status_t VirtualDisplaySurface::dequeueBuffer(Source source,
-        uint32_t format, uint32_t usage, int* sslot, sp<Fence>* fence) {
+        PixelFormat format, uint32_t usage, int* sslot, sp<Fence>* fence) {
+    LOG_FATAL_IF(mDisplayId < 0, "mDisplayId=%d but should not be < 0.", mDisplayId);
     // Don't let a slow consumer block us
     bool async = (source == SOURCE_SINK);
 
@@ -273,24 +299,29 @@
     int pslot = mapSource2ProducerSlot(source, *sslot);
     VDS_LOGV("dequeueBuffer(%s): sslot=%d pslot=%d result=%d",
             dbgSourceStr(source), *sslot, pslot, result);
-    uint32_t sourceBit = static_cast<uint32_t>(source) << pslot;
+    uint64_t sourceBit = static_cast<uint64_t>(source) << pslot;
 
-    if ((mProducerSlotSource & (1u << pslot)) != sourceBit) {
+    if ((mProducerSlotSource & (1ULL << pslot)) != sourceBit) {
         // This slot was previously dequeued from the other source; must
         // re-request the buffer.
         result |= BUFFER_NEEDS_REALLOCATION;
-        mProducerSlotSource &= ~(1u << pslot);
+        mProducerSlotSource &= ~(1ULL << pslot);
         mProducerSlotSource |= sourceBit;
     }
 
     if (result & RELEASE_ALL_BUFFERS) {
         for (uint32_t i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
-            if ((mProducerSlotSource & (1u << i)) == sourceBit)
+            if ((mProducerSlotSource & (1ULL << i)) == sourceBit)
                 mProducerBuffers[i].clear();
         }
     }
     if (result & BUFFER_NEEDS_REALLOCATION) {
-        mSource[source]->requestBuffer(*sslot, &mProducerBuffers[pslot]);
+        result = mSource[source]->requestBuffer(*sslot, &mProducerBuffers[pslot]);
+        if (result < 0) {
+            mProducerBuffers[pslot].clear();
+            mSource[source]->cancelBuffer(*sslot, *fence);
+            return result;
+        }
         VDS_LOGV("dequeueBuffer(%s): buffers[%d]=%p fmt=%d usage=%#x",
                 dbgSourceStr(source), pslot, mProducerBuffers[pslot].get(),
                 mProducerBuffers[pslot]->getPixelFormat(),
@@ -301,7 +332,10 @@
 }
 
 status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence, bool async,
-        uint32_t w, uint32_t h, uint32_t format, uint32_t usage) {
+        uint32_t w, uint32_t h, PixelFormat format, uint32_t usage) {
+    if (mDisplayId < 0)
+        return mSource[SOURCE_SINK]->dequeueBuffer(pslot, fence, async, w, h, format, usage);
+
     VDS_LOGW_IF(mDbgState != DBG_STATE_PREPARED,
             "Unexpected dequeueBuffer() in %s state", dbgStateStr());
     mDbgState = DBG_STATE_GLES;
@@ -333,7 +367,7 @@
         usage |= GRALLOC_USAGE_HW_COMPOSER;
         const sp<GraphicBuffer>& buf = mProducerBuffers[mOutputProducerSlot];
         if ((usage & ~buf->getUsage()) != 0 ||
-                (format != 0 && format != (uint32_t)buf->getPixelFormat()) ||
+                (format != 0 && format != buf->getPixelFormat()) ||
                 (w != 0 && w != mSinkBufferWidth) ||
                 (h != 0 && h != mSinkBufferHeight)) {
             VDS_LOGV("dequeueBuffer: dequeueing new output buffer: "
@@ -363,8 +397,28 @@
     return result;
 }
 
+status_t VirtualDisplaySurface::detachBuffer(int /* slot */) {
+    VDS_LOGE("detachBuffer is not available for VirtualDisplaySurface");
+    return INVALID_OPERATION;
+}
+
+status_t VirtualDisplaySurface::detachNextBuffer(
+        sp<GraphicBuffer>* /* outBuffer */, sp<Fence>* /* outFence */) {
+    VDS_LOGE("detachNextBuffer is not available for VirtualDisplaySurface");
+    return INVALID_OPERATION;
+}
+
+status_t VirtualDisplaySurface::attachBuffer(int* /* outSlot */,
+        const sp<GraphicBuffer>& /* buffer */) {
+    VDS_LOGE("attachBuffer is not available for VirtualDisplaySurface");
+    return INVALID_OPERATION;
+}
+
 status_t VirtualDisplaySurface::queueBuffer(int pslot,
         const QueueBufferInput& input, QueueBufferOutput* output) {
+    if (mDisplayId < 0)
+        return mSource[SOURCE_SINK]->queueBuffer(pslot, input, output);
+
     VDS_LOGW_IF(mDbgState != DBG_STATE_GLES,
             "Unexpected queueBuffer(pslot=%d) in %s state", pslot,
             dbgStateStr());
@@ -384,7 +438,7 @@
         // Now acquire the buffer from the scratch pool -- should be the same
         // slot and fence as we just queued.
         Mutex::Autolock lock(mMutex);
-        BufferQueue::BufferItem item;
+        BufferItem item;
         result = acquireBufferLocked(&item, 0);
         if (result != NO_ERROR)
             return result;
@@ -402,12 +456,13 @@
         // Extract the GLES release fence for HWC to acquire
         int64_t timestamp;
         bool isAutoTimestamp;
+        android_dataspace dataSpace;
         Rect crop;
         int scalingMode;
         uint32_t transform;
         bool async;
-        input.deflate(&timestamp, &isAutoTimestamp, &crop, &scalingMode,
-                &transform, &async, &mFbFence);
+        input.deflate(&timestamp, &isAutoTimestamp, &dataSpace, &crop,
+                &scalingMode, &transform, &async, &mFbFence);
 
         mFbProducerSlot = pslot;
         mOutputFence = mFbFence;
@@ -418,6 +473,9 @@
 }
 
 void VirtualDisplaySurface::cancelBuffer(int pslot, const sp<Fence>& fence) {
+    if (mDisplayId < 0)
+        return mSource[SOURCE_SINK]->cancelBuffer(mapProducer2SourceSlot(SOURCE_SINK, pslot), fence);
+
     VDS_LOGW_IF(mDbgState != DBG_STATE_GLES,
             "Unexpected cancelBuffer(pslot=%d) in %s state", pslot,
             dbgStateStr());
@@ -428,14 +486,25 @@
 }
 
 int VirtualDisplaySurface::query(int what, int* value) {
-    return mSource[SOURCE_SINK]->query(what, value);
+    switch (what) {
+        case NATIVE_WINDOW_WIDTH:
+            *value = mSinkBufferWidth;
+            break;
+        case NATIVE_WINDOW_HEIGHT:
+            *value = mSinkBufferHeight;
+            break;
+        default:
+            return mSource[SOURCE_SINK]->query(what, value);
+    }
+    return NO_ERROR;
 }
 
-status_t VirtualDisplaySurface::connect(const sp<IBinder>& token,
+status_t VirtualDisplaySurface::connect(const sp<IProducerListener>& listener,
         int api, bool producerControlledByApp,
         QueueBufferOutput* output) {
     QueueBufferOutput qbo;
-    status_t result = mSource[SOURCE_SINK]->connect(token, api, producerControlledByApp, &qbo);
+    status_t result = mSource[SOURCE_SINK]->connect(listener, api,
+            producerControlledByApp, &qbo);
     if (result == NO_ERROR) {
         updateQueueBufferOutput(qbo);
         *output = mQueueBufferOutput;
@@ -447,6 +516,29 @@
     return mSource[SOURCE_SINK]->disconnect(api);
 }
 
+status_t VirtualDisplaySurface::setSidebandStream(const sp<NativeHandle>& /*stream*/) {
+    return INVALID_OPERATION;
+}
+
+void VirtualDisplaySurface::allocateBuffers(bool /* async */,
+        uint32_t /* width */, uint32_t /* height */, PixelFormat /* format */,
+        uint32_t /* usage */) {
+    // TODO: Should we actually allocate buffers for a virtual display?
+}
+
+status_t VirtualDisplaySurface::allowAllocation(bool /* allow */) {
+    return INVALID_OPERATION;
+}
+
+status_t VirtualDisplaySurface::setGenerationNumber(uint32_t /* generation */) {
+    ALOGE("setGenerationNumber not supported on VirtualDisplaySurface");
+    return INVALID_OPERATION;
+}
+
+String8 VirtualDisplaySurface::getConsumerName() const {
+    return String8("VirtualDisplaySurface");
+}
+
 void VirtualDisplaySurface::updateQueueBufferOutput(
         const QueueBufferOutput& qbo) {
     uint32_t w, h, transformHint, numPendingBuffers;
@@ -456,8 +548,6 @@
 
 void VirtualDisplaySurface::resetPerFrameState() {
     mCompositionType = COMPOSITION_UNKNOWN;
-    mSinkBufferWidth = 0;
-    mSinkBufferHeight = 0;
     mFbFence = Fence::NO_FENCE;
     mOutputFence = Fence::NO_FENCE;
     mOutputProducerSlot = -1;
diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
index 1e85ac4..6298751 100644
--- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
+++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
@@ -27,6 +27,7 @@
 // ---------------------------------------------------------------------------
 
 class HWComposer;
+class IProducerListener;
 
 /* This DisplaySurface implementation supports virtual displays, where GLES
  * and/or HWC compose into a buffer that is then passed to an arbitrary
@@ -73,18 +74,20 @@
 public:
     VirtualDisplaySurface(HWComposer& hwc, int32_t dispId,
             const sp<IGraphicBufferProducer>& sink,
-            const sp<BufferQueue>& bq,
+            const sp<IGraphicBufferProducer>& bqProducer,
+            const sp<IGraphicBufferConsumer>& bqConsumer,
             const String8& name);
 
     //
     // DisplaySurface interface
     //
-    virtual status_t beginFrame();
+    virtual status_t beginFrame(bool mustRecompose);
     virtual status_t prepareFrame(CompositionType compositionType);
     virtual status_t compositionComplete();
     virtual status_t advanceFrame();
     virtual void onFrameCommitted();
-    virtual void dump(String8& result) const;
+    virtual void dumpAsString(String8& result) const;
+    virtual void resizeBuffers(const uint32_t w, const uint32_t h);
 
 private:
     enum Source {SOURCE_SINK = 0, SOURCE_SCRATCH = 1};
@@ -97,20 +100,30 @@
     virtual status_t requestBuffer(int pslot, sp<GraphicBuffer>* outBuf);
     virtual status_t setBufferCount(int bufferCount);
     virtual status_t dequeueBuffer(int* pslot, sp<Fence>* fence, bool async,
-            uint32_t w, uint32_t h, uint32_t format, uint32_t usage);
+            uint32_t w, uint32_t h, PixelFormat format, uint32_t usage);
+    virtual status_t detachBuffer(int slot);
+    virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
+            sp<Fence>* outFence);
+    virtual status_t attachBuffer(int* slot, const sp<GraphicBuffer>& buffer);
     virtual status_t queueBuffer(int pslot,
             const QueueBufferInput& input, QueueBufferOutput* output);
     virtual void cancelBuffer(int pslot, const sp<Fence>& fence);
     virtual int query(int what, int* value);
-    virtual status_t connect(const sp<IBinder>& token,
+    virtual status_t connect(const sp<IProducerListener>& listener,
             int api, bool producerControlledByApp, QueueBufferOutput* output);
     virtual status_t disconnect(int api);
+    virtual status_t setSidebandStream(const sp<NativeHandle>& stream);
+    virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
+            PixelFormat format, uint32_t usage);
+    virtual status_t allowAllocation(bool allow);
+    virtual status_t setGenerationNumber(uint32_t generationNumber);
+    virtual String8 getConsumerName() const override;
 
     //
     // Utility methods
     //
     static Source fbSourceForCompositionType(CompositionType type);
-    status_t dequeueBuffer(Source source, uint32_t format, uint32_t usage,
+    status_t dequeueBuffer(Source source, PixelFormat format, uint32_t usage,
             int* sslot, sp<Fence>* fence);
     void updateQueueBufferOutput(const QueueBufferOutput& qbo);
     void resetPerFrameState();
@@ -148,10 +161,10 @@
     // Since we present a single producer interface to the GLES driver, but
     // are internally muxing between the sink and scratch producers, we have
     // to keep track of which source last returned each producer slot from
-    // dequeueBuffer. Each bit in mLastSlotSource corresponds to a producer
+    // dequeueBuffer. Each bit in mProducerSlotSource corresponds to a producer
     // slot. Both mProducerSlotSource and mProducerBuffers are indexed by a
     // "producer slot"; see the mapSlot*() functions.
-    uint32_t mProducerSlotSource;
+    uint64_t mProducerSlotSource;
     sp<GraphicBuffer> mProducerBuffers[BufferQueue::NUM_BUFFER_SLOTS];
 
     // The QueueBufferOutput with the latest info from the sink, and with the
@@ -159,6 +172,10 @@
     // to the sink, we have to return the previous version.
     QueueBufferOutput mQueueBufferOutput;
 
+    // Details of the current sink buffer. These become valid when a buffer is
+    // dequeued from the sink, and are used when queueing the buffer.
+    uint32_t mSinkBufferWidth, mSinkBufferHeight;
+
     //
     // Intra-frame state
     //
@@ -167,10 +184,6 @@
     // Valid after prepareFrame(), cleared in onFrameCommitted.
     CompositionType mCompositionType;
 
-    // Details of the current sink buffer. These become valid when a buffer is
-    // dequeued from the sink, and are used when queueing the buffer.
-    uint32_t mSinkBufferWidth, mSinkBufferHeight;
-
     // mFbFence is the fence HWC should wait for before reading the framebuffer
     // target buffer.
     sp<Fence> mFbFence;
@@ -222,6 +235,8 @@
 
     const char* dbgStateStr() const;
     static const char* dbgSourceStr(Source s);
+
+    bool mMustRecompose;
 };
 
 // ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/Effects/Daltonizer.cpp b/services/surfaceflinger/Effects/Daltonizer.cpp
index f384ba4..feb8936 100644
--- a/services/surfaceflinger/Effects/Daltonizer.cpp
+++ b/services/surfaceflinger/Effects/Daltonizer.cpp
@@ -148,9 +148,6 @@
     // set to identity, errp, errd, errt ([0] for simulation only)
     mat4 correction(0);
 
-    // control: simulation post-correction (used for debugging):
-    // set to identity or lms2lmsp, lms2lmsd, lms2lmst
-    mat4 control;
     switch (mType) {
         case protanopia:
         case protanomaly:
@@ -172,12 +169,8 @@
             break;
     }
 
-    if (true) {
-        control = simulation;
-    }
-
-    mColorTransform = lms2rgb * control *
-            (simulation * rgb2lms + correction * (rgb2lms - simulation * rgb2lms));
+    mColorTransform = lms2rgb *
+        (simulation * rgb2lms + correction * (rgb2lms - simulation * rgb2lms));
 }
 
 } /* namespace android */
diff --git a/services/surfaceflinger/EventThread.cpp b/services/surfaceflinger/EventThread.cpp
index d868f32..f760200 100644
--- a/services/surfaceflinger/EventThread.cpp
+++ b/services/surfaceflinger/EventThread.cpp
@@ -35,12 +35,21 @@
 // ---------------------------------------------------------------------------
 namespace android {
 // ---------------------------------------------------------------------------
+// time to wait between VSYNC requests before sending a VSYNC OFF power hint: 40msec.
+const long vsyncHintOffDelay = 40000000;
+
+static void vsyncOffCallback(union sigval val) {
+    EventThread *ev = (EventThread *)val.sival_ptr;
+    ev->sendVsyncHintOff();
+    return;
+}
 
 EventThread::EventThread(const sp<VSyncSource>& src)
     : mVSyncSource(src),
       mUseSoftwareVSync(false),
       mVsyncEnabled(false),
-      mDebugVsyncEnabled(false) {
+      mDebugVsyncEnabled(false),
+      mVsyncHintSent(false) {
 
     for (int32_t i=0 ; i<DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES ; i++) {
         mVSyncEvent[i].header.type = DisplayEventReceiver::DISPLAY_EVENT_VSYNC;
@@ -48,6 +57,36 @@
         mVSyncEvent[i].header.timestamp = 0;
         mVSyncEvent[i].vsync.count =  0;
     }
+    struct sigevent se;
+    se.sigev_notify = SIGEV_THREAD;
+    se.sigev_value.sival_ptr = this;
+    se.sigev_notify_function = vsyncOffCallback;
+    se.sigev_notify_attributes = NULL;
+    timer_create(CLOCK_MONOTONIC, &se, &mTimerId);
+}
+
+void EventThread::sendVsyncHintOff() {
+    Mutex::Autolock _l(mLock);
+    mPowerHAL.vsyncHint(false);
+    mVsyncHintSent = false;
+}
+
+void EventThread::setPhaseOffset(nsecs_t phaseOffset) {
+    Mutex::Autolock _l(mLock);
+    mVSyncSource->setPhaseOffset(phaseOffset);
+}
+
+void EventThread::sendVsyncHintOnLocked() {
+    struct itimerspec ts;
+    if(!mVsyncHintSent) {
+        mPowerHAL.vsyncHint(true);
+        mVsyncHintSent = true;
+    }
+    ts.it_value.tv_sec = 0;
+    ts.it_value.tv_nsec = vsyncHintOffDelay;
+    ts.it_interval.tv_sec = 0;
+    ts.it_interval.tv_nsec = 0;
+    timer_settime(mTimerId, 0, &ts, NULL);
 }
 
 void EventThread::onFirstRef() {
@@ -307,17 +346,16 @@
             mVsyncEnabled = true;
             mVSyncSource->setCallback(static_cast<VSyncSource::Callback*>(this));
             mVSyncSource->setVSyncEnabled(true);
-            mPowerHAL.vsyncHint(true);
         }
     }
     mDebugVsyncEnabled = true;
+    sendVsyncHintOnLocked();
 }
 
 void EventThread::disableVSyncLocked() {
     if (mVsyncEnabled) {
         mVsyncEnabled = false;
         mVSyncSource->setVSyncEnabled(false);
-        mPowerHAL.vsyncHint(false);
         mDebugVsyncEnabled = false;
     }
 }
diff --git a/services/surfaceflinger/EventThread.h b/services/surfaceflinger/EventThread.h
index f6ab4a7..9ba179a 100644
--- a/services/surfaceflinger/EventThread.h
+++ b/services/surfaceflinger/EventThread.h
@@ -51,6 +51,7 @@
     virtual ~VSyncSource() {}
     virtual void setVSyncEnabled(bool enable) = 0;
     virtual void setCallback(const sp<Callback>& callback) = 0;
+    virtual void setPhaseOffset(nsecs_t phaseOffset) = 0;
 };
 
 class EventThread : public Thread, private VSyncSource::Callback {
@@ -97,6 +98,9 @@
             DisplayEventReceiver::Event* event);
 
     void dump(String8& result) const;
+    void sendVsyncHintOff();
+
+    void setPhaseOffset(nsecs_t phaseOffset);
 
 private:
     virtual bool        threadLoop();
@@ -107,6 +111,7 @@
     void removeDisplayEventConnection(const wp<Connection>& connection);
     void enableVSyncLocked();
     void disableVSyncLocked();
+    void sendVsyncHintOnLocked();
 
     // constants
     sp<VSyncSource> mVSyncSource;
@@ -124,6 +129,9 @@
 
     // for debugging
     bool mDebugVsyncEnabled;
+
+    bool mVsyncHintSent;
+    timer_t mTimerId;
 };
 
 // ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/FrameTracker.cpp b/services/surfaceflinger/FrameTracker.cpp
index 2fb665e..c09bbe4 100644
--- a/services/surfaceflinger/FrameTracker.cpp
+++ b/services/surfaceflinger/FrameTracker.cpp
@@ -22,6 +22,7 @@
 #include <cutils/log.h>
 
 #include <ui/Fence.h>
+#include <ui/FrameStats.h>
 
 #include <utils/String8.h>
 
@@ -100,7 +101,7 @@
     processFencesLocked();
 }
 
-void FrameTracker::clear() {
+void FrameTracker::clearStats() {
     Mutex::Autolock lock(mMutex);
     for (size_t i = 0; i < NUM_FRAME_RECORDS; i++) {
         mFrameRecords[i].desiredPresentTime = 0;
@@ -115,6 +116,32 @@
     mFrameRecords[mOffset].actualPresentTime = INT64_MAX;
 }
 
+void FrameTracker::getStats(FrameStats* outStats) const {
+    Mutex::Autolock lock(mMutex);
+    processFencesLocked();
+
+    outStats->refreshPeriodNano = mDisplayPeriod;
+
+    const size_t offset = mOffset;
+    for (size_t i = 1; i < NUM_FRAME_RECORDS; i++) {
+        const size_t index = (offset + i) % NUM_FRAME_RECORDS;
+
+        // Skip frame records with no data (if buffer not yet full).
+        if (mFrameRecords[index].desiredPresentTime == 0) {
+            continue;
+        }
+
+        nsecs_t desiredPresentTimeNano = mFrameRecords[index].desiredPresentTime;
+        outStats->desiredPresentTimesNano.push_back(desiredPresentTimeNano);
+
+        nsecs_t actualPresentTimeNano = mFrameRecords[index].actualPresentTime;
+        outStats->actualPresentTimesNano.push_back(actualPresentTimeNano);
+
+        nsecs_t frameReadyTimeNano = mFrameRecords[index].frameReadyTime;
+        outStats->frameReadyTimesNano.push_back(frameReadyTimeNano);
+    }
+}
+
 void FrameTracker::logAndResetStats(const String8& name) {
     Mutex::Autolock lock(mMutex);
     logStatsLocked(name);
@@ -206,7 +233,7 @@
             mFrameRecords[idx].actualPresentTime < INT64_MAX;
 }
 
-void FrameTracker::dump(String8& result) const {
+void FrameTracker::dumpStats(String8& result) const {
     Mutex::Autolock lock(mMutex);
     processFencesLocked();
 
diff --git a/services/surfaceflinger/FrameTracker.h b/services/surfaceflinger/FrameTracker.h
index 9233247..cd5e3f3 100644
--- a/services/surfaceflinger/FrameTracker.h
+++ b/services/surfaceflinger/FrameTracker.h
@@ -78,15 +78,18 @@
     // advanceFrame advances the frame tracker to the next frame.
     void advanceFrame();
 
-    // clear resets all the tracked frame data to zero.
-    void clear();
+    // clearStats clears the tracked frame stats.
+    void clearStats();
+
+    // getStats gets the tracked frame stats.
+    void getStats(FrameStats* outStats) const;
 
     // logAndResetStats dumps the current statistics to the binary event log
     // and then resets the accumulated statistics to their initial values.
     void logAndResetStats(const String8& name);
 
-    // dump appends the current frame display time history to the result string.
-    void dump(String8& result) const;
+    // dumpStats dump appends the current frame display time history to the result string.
+    void dumpStats(String8& result) const;
 
 private:
     struct FrameRecord {
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 61af51f..4a701e8 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -27,20 +27,22 @@
 
 #include <utils/Errors.h>
 #include <utils/Log.h>
+#include <utils/NativeHandle.h>
 #include <utils/StopWatch.h>
 #include <utils/Trace.h>
 
 #include <ui/GraphicBuffer.h>
 #include <ui/PixelFormat.h>
 
+#include <gui/BufferItem.h>
 #include <gui/Surface.h>
 
 #include "clz.h"
 #include "Colorizer.h"
 #include "DisplayDevice.h"
 #include "Layer.h"
+#include "MonitoredProducer.h"
 #include "SurfaceFlinger.h"
-#include "SurfaceTextureLayer.h"
 
 #include "DisplayHardware/HWComposer.h"
 
@@ -62,11 +64,10 @@
         mTextureName(-1U),
         mPremultipliedAlpha(true),
         mName("unnamed"),
-        mDebug(false),
         mFormat(PIXEL_FORMAT_NONE),
-        mOpaqueLayer(true),
         mTransactionFlags(0),
         mQueuedFrames(0),
+        mSidebandStreamChanged(false),
         mCurrentTransform(0),
         mCurrentScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
         mCurrentOpacity(true),
@@ -75,10 +76,15 @@
         mFiltering(false),
         mNeedsFiltering(false),
         mMesh(Mesh::TRIANGLE_FAN, 4, 2, 2),
-        mSecure(false),
         mProtectedByApp(false),
         mHasSurface(false),
-        mClientRef(client)
+        mClientRef(client),
+        mPotentialCursor(false),
+        mQueueItemLock(),
+        mQueueItemCondition(),
+        mQueueItems(),
+        mLastFrameNumberReceived(0),
+        mUpdateTexImageFailed(false)
 {
     mCurrentCrop.makeInvalid();
     mFlinger->getRenderEngine().genTextures(1, &mTextureName);
@@ -86,7 +92,11 @@
 
     uint32_t layerFlags = 0;
     if (flags & ISurfaceComposerClient::eHidden)
-        layerFlags = layer_state_t::eLayerHidden;
+        layerFlags |= layer_state_t::eLayerHidden;
+    if (flags & ISurfaceComposerClient::eOpaque)
+        layerFlags |= layer_state_t::eLayerOpaque;
+    if (flags & ISurfaceComposerClient::eSecure)
+        layerFlags |= layer_state_t::eLayerSecure;
 
     if (flags & ISurfaceComposerClient::eNonPremultiplied)
         mPremultipliedAlpha = false;
@@ -114,14 +124,16 @@
 
 void Layer::onFirstRef() {
     // Creates a custom BufferQueue for SurfaceFlingerConsumer to use
-    mBufferQueue = new SurfaceTextureLayer(mFlinger);
-    mSurfaceFlingerConsumer = new SurfaceFlingerConsumer(mBufferQueue, mTextureName);
+    sp<IGraphicBufferProducer> producer;
+    sp<IGraphicBufferConsumer> consumer;
+    BufferQueue::createBufferQueue(&producer, &consumer);
+    mProducer = new MonitoredProducer(producer, mFlinger);
+    mSurfaceFlingerConsumer = new SurfaceFlingerConsumer(consumer, mTextureName);
     mSurfaceFlingerConsumer->setConsumerUsageBits(getEffectiveUsage(0));
-    mSurfaceFlingerConsumer->setFrameAvailableListener(this);
+    mSurfaceFlingerConsumer->setContentsChangedListener(this);
     mSurfaceFlingerConsumer->setName(mName);
 
 #ifdef TARGET_DISABLE_TRIPLE_BUFFERING
-#warning "disabling triple buffering"
     mSurfaceFlingerConsumer->setDefaultMaxBufferCount(2);
 #else
     mSurfaceFlingerConsumer->setDefaultMaxBufferCount(3);
@@ -144,7 +156,7 @@
 // callbacks
 // ---------------------------------------------------------------------------
 
-void Layer::onLayerDisplayed(const sp<const DisplayDevice>& hw,
+void Layer::onLayerDisplayed(const sp<const DisplayDevice>& /* hw */,
         HWComposer::HWCLayerInterface* layer) {
     if (layer) {
         layer->onDisplayed();
@@ -152,11 +164,67 @@
     }
 }
 
-void Layer::onFrameAvailable() {
-    android_atomic_inc(&mQueuedFrames);
+void Layer::onFrameAvailable(const BufferItem& item) {
+    // Add this buffer from our internal queue tracker
+    { // Autolock scope
+        Mutex::Autolock lock(mQueueItemLock);
+
+        // Reset the frame number tracker when we receive the first buffer after
+        // a frame number reset
+        if (item.mFrameNumber == 1) {
+            mLastFrameNumberReceived = 0;
+        }
+
+        // Ensure that callbacks are handled in order
+        while (item.mFrameNumber != mLastFrameNumberReceived + 1) {
+            status_t result = mQueueItemCondition.waitRelative(mQueueItemLock,
+                    ms2ns(500));
+            if (result != NO_ERROR) {
+                ALOGE("[%s] Timed out waiting on callback", mName.string());
+            }
+        }
+
+        mQueueItems.push_back(item);
+        android_atomic_inc(&mQueuedFrames);
+
+        // Wake up any pending callbacks
+        mLastFrameNumberReceived = item.mFrameNumber;
+        mQueueItemCondition.broadcast();
+    }
+
     mFlinger->signalLayerUpdate();
 }
 
+void Layer::onFrameReplaced(const BufferItem& item) {
+    Mutex::Autolock lock(mQueueItemLock);
+
+    // Ensure that callbacks are handled in order
+    while (item.mFrameNumber != mLastFrameNumberReceived + 1) {
+        status_t result = mQueueItemCondition.waitRelative(mQueueItemLock,
+                ms2ns(500));
+        if (result != NO_ERROR) {
+            ALOGE("[%s] Timed out waiting on callback", mName.string());
+        }
+    }
+
+    if (mQueueItems.empty()) {
+        ALOGE("Can't replace a frame on an empty queue");
+        return;
+    }
+    mQueueItems.editItemAt(0) = item;
+
+    // Wake up any pending callbacks
+    mLastFrameNumberReceived = item.mFrameNumber;
+    mQueueItemCondition.broadcast();
+}
+
+void Layer::onSidebandStreamChanged() {
+    if (android_atomic_release_cas(false, true, &mSidebandStreamChanged) == 0) {
+        // mSidebandStreamChanged was false
+        mFlinger->signalLayerUpdate();
+    }
+}
+
 // called with SurfaceFlinger::mStateLock from the drawing thread after
 // the layer has been remove from the current state list (and just before
 // it's removed from the drawing state list)
@@ -187,9 +255,8 @@
 
     mFormat = format;
 
-    mSecure = (flags & ISurfaceComposerClient::eSecure) ? true : false;
+    mPotentialCursor = (flags & ISurfaceComposerClient::eCursorWindow) ? true : false;
     mProtectedByApp = (flags & ISurfaceComposerClient::eProtectedByApp) ? true : false;
-    mOpaqueLayer = (flags & ISurfaceComposerClient::eOpaque);
     mCurrentOpacity = getOpacityForFormat(format);
 
     mSurfaceFlingerConsumer->setDefaultBufferSize(w, h);
@@ -227,8 +294,8 @@
     return new Handle(mFlinger, this);
 }
 
-sp<IGraphicBufferProducer> Layer::getBufferQueue() const {
-    return mBufferQueue;
+sp<IGraphicBufferProducer> Layer::getProducer() const {
+    return mProducer;
 }
 
 // ---------------------------------------------------------------------------
@@ -264,12 +331,17 @@
 
 Rect Layer::computeBounds() const {
     const Layer::State& s(getDrawingState());
+    return computeBounds(s.activeTransparentRegion);
+}
+
+Rect Layer::computeBounds(const Region& activeTransparentRegion) const {
+    const Layer::State& s(getDrawingState());
     Rect win(s.active.w, s.active.h);
     if (!s.active.crop.isEmpty()) {
         win.intersect(s.active.crop, &win);
     }
     // subtract the transparent region and snap to the bounds
-    return reduce(win, s.activeTransparentRegion);
+    return reduce(win, activeTransparentRegion);
 }
 
 FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const {
@@ -297,8 +369,12 @@
     activeCrop.intersect(hw->getViewport(), &activeCrop);
     activeCrop = s.transform.inverse().transform(activeCrop);
 
-    // paranoia: make sure the window-crop is constrained in the
-    // window's bounds
+    // This needs to be here as transform.transform(Rect) computes the
+    // transformed rect and then takes the bounding box of the result before
+    // returning. This means
+    // transform.inverse().transform(transform.transform(Rect)) != Rect
+    // in which case we need to make sure the final rect is clipped to the
+    // display bounds.
     activeCrop.intersect(Rect(s.active.w, s.active.h), &activeCrop);
 
     // subtract the transparent region and snap to the bounds
@@ -309,11 +385,42 @@
         // which means using the inverse of the current transform set on the
         // SurfaceFlingerConsumer.
         uint32_t invTransform = mCurrentTransform;
+        if (mSurfaceFlingerConsumer->getTransformToDisplayInverse()) {
+            /*
+             * the code below applies the display's inverse transform to the buffer
+             */
+            uint32_t invTransformOrient = hw->getOrientationTransform();
+            // calculate the inverse transform
+            if (invTransformOrient & NATIVE_WINDOW_TRANSFORM_ROT_90) {
+                invTransformOrient ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
+                        NATIVE_WINDOW_TRANSFORM_FLIP_H;
+                // If the transform has been rotated the axis of flip has been swapped
+                // so we need to swap which flip operations we are performing
+                bool is_h_flipped = (invTransform & NATIVE_WINDOW_TRANSFORM_FLIP_H) != 0;
+                bool is_v_flipped = (invTransform & NATIVE_WINDOW_TRANSFORM_FLIP_V) != 0;
+                if (is_h_flipped != is_v_flipped) {
+                    invTransform ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
+                            NATIVE_WINDOW_TRANSFORM_FLIP_H;
+                }
+            }
+            // and apply to the current transform
+            invTransform = (Transform(invTransform) * Transform(invTransformOrient)).getOrientation();
+        }
+
         int winWidth = s.active.w;
         int winHeight = s.active.h;
         if (invTransform & NATIVE_WINDOW_TRANSFORM_ROT_90) {
-            invTransform ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
-                    NATIVE_WINDOW_TRANSFORM_FLIP_H;
+            // If the activeCrop has been rotate the ends are rotated but not
+            // the space itself so when transforming ends back we can't rely on
+            // a modification of the axes of rotation. To account for this we
+            // need to reorient the inverse rotation in terms of the current
+            // axes of rotation.
+            bool is_h_flipped = (invTransform & NATIVE_WINDOW_TRANSFORM_FLIP_H) != 0;
+            bool is_v_flipped = (invTransform & NATIVE_WINDOW_TRANSFORM_FLIP_V) != 0;
+            if (is_h_flipped == is_v_flipped) {
+                invTransform ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
+                        NATIVE_WINDOW_TRANSFORM_FLIP_H;
+            }
             winWidth = s.active.h;
             winHeight = s.active.w;
         }
@@ -326,7 +433,7 @@
 
         float insetL = winCrop.left                 * xScale;
         float insetT = winCrop.top                  * yScale;
-        float insetR = (winWidth  - winCrop.right ) * xScale;
+        float insetR = (winWidth - winCrop.right )  * xScale;
         float insetB = (winHeight - winCrop.bottom) * yScale;
 
         crop.left   += insetL;
@@ -352,7 +459,7 @@
 
     // this gives us only the "orientation" component of the transform
     const State& s(getDrawingState());
-    if (!isOpaque() || s.alpha != 0xFF) {
+    if (!isOpaque(s) || s.alpha != 0xFF) {
         layer.setBlending(mPremultipliedAlpha ?
                 HWC_BLENDING_PREMULT :
                 HWC_BLENDING_COVERAGE);
@@ -360,7 +467,29 @@
 
     // apply the layer's transform, followed by the display's global transform
     // here we're guaranteed that the layer's transform preserves rects
-    Rect frame(s.transform.transform(computeBounds()));
+    Region activeTransparentRegion(s.activeTransparentRegion);
+    if (!s.active.crop.isEmpty()) {
+        Rect activeCrop(s.active.crop);
+        activeCrop = s.transform.transform(activeCrop);
+        activeCrop.intersect(hw->getViewport(), &activeCrop);
+        activeCrop = s.transform.inverse().transform(activeCrop);
+        // This needs to be here as transform.transform(Rect) computes the
+        // transformed rect and then takes the bounding box of the result before
+        // returning. This means
+        // transform.inverse().transform(transform.transform(Rect)) != Rect
+        // in which case we need to make sure the final rect is clipped to the
+        // display bounds.
+        activeCrop.intersect(Rect(s.active.w, s.active.h), &activeCrop);
+        // mark regions outside the crop as transparent
+        activeTransparentRegion.orSelf(Rect(0, 0, s.active.w, activeCrop.top));
+        activeTransparentRegion.orSelf(Rect(0, activeCrop.bottom,
+                s.active.w, s.active.h));
+        activeTransparentRegion.orSelf(Rect(0, activeCrop.top,
+                activeCrop.left, activeCrop.bottom));
+        activeTransparentRegion.orSelf(Rect(activeCrop.right, activeCrop.top,
+                s.active.w, activeCrop.bottom));
+    }
+    Rect frame(s.transform.transform(computeBounds(activeTransparentRegion)));
     frame.intersect(hw->getViewport(), &frame);
     const Transform& tr(hw->getTransform());
     layer.setFrame(tr.transform(frame));
@@ -383,13 +512,22 @@
          * the code below applies the display's inverse transform to the buffer
          */
         uint32_t invTransform = hw->getOrientationTransform();
+        uint32_t t_orientation = transform.getOrientation();
         // calculate the inverse transform
         if (invTransform & NATIVE_WINDOW_TRANSFORM_ROT_90) {
             invTransform ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
                     NATIVE_WINDOW_TRANSFORM_FLIP_H;
+            // If the transform has been rotated the axis of flip has been swapped
+            // so we need to swap which flip operations we are performing
+            bool is_h_flipped = (t_orientation & NATIVE_WINDOW_TRANSFORM_FLIP_H) != 0;
+            bool is_v_flipped = (t_orientation & NATIVE_WINDOW_TRANSFORM_FLIP_V) != 0;
+            if (is_h_flipped != is_v_flipped) {
+                t_orientation ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
+                        NATIVE_WINDOW_TRANSFORM_FLIP_H;
+            }
         }
         // and apply to the current transform
-        transform = transform * Transform(invTransform);
+        transform = Transform(t_orientation) * Transform(invTransform);
     }
 
     // this gives us only the "orientation" component of the transform
@@ -412,20 +550,25 @@
     const Transform& tr = hw->getTransform();
     Region visible = tr.transform(visibleRegion.intersect(hw->getViewport()));
     layer.setVisibleRegionScreen(visible);
+    layer.setSurfaceDamage(surfaceDamageRegion);
 
-    // NOTE: buffer can be NULL if the client never drew into this
-    // layer yet, or if we ran out of memory
-    layer.setBuffer(mActiveBuffer);
+    if (mSidebandStream.get()) {
+        layer.setSidebandStream(mSidebandStream);
+    } else {
+        // NOTE: buffer can be NULL if the client never drew into this
+        // layer yet, or if we ran out of memory
+        layer.setBuffer(mActiveBuffer);
+    }
 }
 
-void Layer::setAcquireFence(const sp<const DisplayDevice>& hw,
+void Layer::setAcquireFence(const sp<const DisplayDevice>& /* hw */,
         HWComposer::HWCLayerInterface& layer) {
     int fenceFd = -1;
 
     // TODO: there is a possible optimization here: we only need to set the
     // acquire fence the first time a new buffer is acquired on EACH display.
 
-    if (layer.getCompositionType() == HWC_OVERLAY) {
+    if (layer.getCompositionType() == HWC_OVERLAY || layer.getCompositionType() == HWC_CURSOR_OVERLAY) {
         sp<Fence> fence = mSurfaceFlingerConsumer->getCurrentFence();
         if (fence->isValid()) {
             fenceFd = fence->dup();
@@ -437,19 +580,45 @@
     layer.setAcquireFenceFd(fenceFd);
 }
 
+Rect Layer::getPosition(
+    const sp<const DisplayDevice>& hw)
+{
+    // this gives us only the "orientation" component of the transform
+    const State& s(getCurrentState());
+
+    // apply the layer's transform, followed by the display's global transform
+    // here we're guaranteed that the layer's transform preserves rects
+    Rect win(s.active.w, s.active.h);
+    if (!s.active.crop.isEmpty()) {
+        win.intersect(s.active.crop, &win);
+    }
+    // subtract the transparent region and snap to the bounds
+    Rect bounds = reduce(win, s.activeTransparentRegion);
+    Rect frame(s.transform.transform(bounds));
+    frame.intersect(hw->getViewport(), &frame);
+    const Transform& tr(hw->getTransform());
+    return Rect(tr.transform(frame));
+}
+
 // ---------------------------------------------------------------------------
 // drawing...
 // ---------------------------------------------------------------------------
 
 void Layer::draw(const sp<const DisplayDevice>& hw, const Region& clip) const {
-    onDraw(hw, clip);
+    onDraw(hw, clip, false);
 }
 
-void Layer::draw(const sp<const DisplayDevice>& hw) {
-    onDraw( hw, Region(hw->bounds()) );
+void Layer::draw(const sp<const DisplayDevice>& hw,
+        bool useIdentityTransform) const {
+    onDraw(hw, Region(hw->bounds()), useIdentityTransform);
 }
 
-void Layer::onDraw(const sp<const DisplayDevice>& hw, const Region& clip) const
+void Layer::draw(const sp<const DisplayDevice>& hw) const {
+    onDraw(hw, Region(hw->bounds()), false);
+}
+
+void Layer::onDraw(const sp<const DisplayDevice>& hw, const Region& clip,
+        bool useIdentityTransform) const
 {
     ATRACE_CALL();
 
@@ -540,16 +709,17 @@
     } else {
         engine.setupLayerBlackedOut();
     }
-    drawWithOpenGL(hw, clip);
+    drawWithOpenGL(hw, clip, useIdentityTransform);
     engine.disableTexturing();
 }
 
 
-void Layer::clearWithOpenGL(const sp<const DisplayDevice>& hw, const Region& clip,
-        float red, float green, float blue, float alpha) const
+void Layer::clearWithOpenGL(const sp<const DisplayDevice>& hw,
+        const Region& /* clip */, float red, float green, float blue,
+        float alpha) const
 {
     RenderEngine& engine(mFlinger->getRenderEngine());
-    computeGeometry(hw, mMesh);
+    computeGeometry(hw, mMesh, false);
     engine.setupFillWithColor(red, green, blue, alpha);
     engine.drawMesh(mMesh);
 }
@@ -559,12 +729,11 @@
     clearWithOpenGL(hw, clip, 0,0,0,0);
 }
 
-void Layer::drawWithOpenGL(
-        const sp<const DisplayDevice>& hw, const Region& clip) const {
-    const uint32_t fbHeight = hw->getHeight();
+void Layer::drawWithOpenGL(const sp<const DisplayDevice>& hw,
+        const Region& /* clip */, bool useIdentityTransform) const {
     const State& s(getDrawingState());
 
-    computeGeometry(hw, mMesh);
+    computeGeometry(hw, mMesh, useIdentityTransform);
 
     /*
      * NOTE: the way we compute the texture coordinates here produces
@@ -596,11 +765,22 @@
     texCoords[3] = vec2(right, 1.0f - top);
 
     RenderEngine& engine(mFlinger->getRenderEngine());
-    engine.setupLayerBlending(mPremultipliedAlpha, isOpaque(), s.alpha);
+    engine.setupLayerBlending(mPremultipliedAlpha, isOpaque(s), s.alpha);
     engine.drawMesh(mMesh);
     engine.disableBlending();
 }
 
+uint32_t Layer::getProducerStickyTransform() const {
+    int producerStickyTransform = 0;
+    int ret = mProducer->query(NATIVE_WINDOW_STICKY_TRANSFORM, &producerStickyTransform);
+    if (ret != OK) {
+        ALOGW("%s: Error %s (%d) while querying window sticky transform.", __FUNCTION__,
+                strerror(-ret), ret);
+        return 0;
+    }
+    return static_cast<uint32_t>(producerStickyTransform);
+}
+
 void Layer::setFiltering(bool filtering) {
     mFiltering = filtering;
 }
@@ -623,7 +803,6 @@
     switch (format) {
         case HAL_PIXEL_FORMAT_RGBA_8888:
         case HAL_PIXEL_FORMAT_BGRA_8888:
-        case HAL_PIXEL_FORMAT_sRGB_A_8888:
             return false;
     }
     // in all other case, we have no blending (also for unknown formats)
@@ -634,10 +813,12 @@
 // local state
 // ----------------------------------------------------------------------------
 
-void Layer::computeGeometry(const sp<const DisplayDevice>& hw, Mesh& mesh) const
+void Layer::computeGeometry(const sp<const DisplayDevice>& hw, Mesh& mesh,
+        bool useIdentityTransform) const
 {
     const Layer::State& s(getDrawingState());
-    const Transform tr(hw->getTransform() * s.transform);
+    const Transform tr(useIdentityTransform ?
+            hw->getTransform() : hw->getTransform() * s.transform);
     const uint32_t hw_h = hw->getHeight();
     Rect win(s.active.w, s.active.h);
     if (!s.active.crop.isEmpty()) {
@@ -656,7 +837,7 @@
     }
 }
 
-bool Layer::isOpaque() const
+bool Layer::isOpaque(const Layer::State& s) const
 {
     // if we don't have a buffer yet, we're translucent regardless of the
     // layer's opaque flag.
@@ -666,7 +847,13 @@
 
     // if the layer has the opaque flag, then we're always opaque,
     // otherwise we use the current buffer's format.
-    return mOpaqueLayer || mCurrentOpacity;
+    return ((s.flags & layer_state_t::eLayerOpaque) != 0) || mCurrentOpacity;
+}
+
+bool Layer::isSecure() const
+{
+    const Layer::State& s(mDrawingState);
+    return (s.flags & layer_state_t::eLayerSecure);
 }
 
 bool Layer::isProtected() const
@@ -766,7 +953,7 @@
         const bool resizePending = (c.requested.w != c.active.w) ||
                                    (c.requested.h != c.active.h);
 
-        if (resizePending) {
+        if (resizePending && mSidebandStream == NULL) {
             // don't let Layer::doTransaction update the drawing state
             // if we have a pending resize, unless we are in fixed-size mode.
             // the drawing state will be updated only once we receive a buffer
@@ -775,6 +962,10 @@
             // in particular, we want to make sure the clip (which is part
             // of the geometry state) is latched together with the size but is
             // latched immediately when no resizing is involved.
+            //
+            // If a sideband stream is attached, however, we want to skip this
+            // optimization so that transactions aren't missed when a buffer
+            // never arrives
 
             flags |= eDontUpdateGeometryState;
         }
@@ -892,13 +1083,48 @@
     return true;
 }
 
+void Layer::useSurfaceDamage() {
+    if (mFlinger->mForceFullDamage) {
+        surfaceDamageRegion = Region::INVALID_REGION;
+    } else {
+        surfaceDamageRegion = mSurfaceFlingerConsumer->getSurfaceDamage();
+    }
+}
+
+void Layer::useEmptyDamage() {
+    surfaceDamageRegion.clear();
+}
+
 // ----------------------------------------------------------------------------
 // pageflip handling...
 // ----------------------------------------------------------------------------
 
+bool Layer::shouldPresentNow(const DispSync& dispSync) const {
+    if (mSidebandStreamChanged) {
+        return true;
+    }
+
+    Mutex::Autolock lock(mQueueItemLock);
+    if (mQueueItems.empty()) {
+        return false;
+    }
+    auto timestamp = mQueueItems[0].mTimestamp;
+    nsecs_t expectedPresent =
+            mSurfaceFlingerConsumer->computeExpectedPresent(dispSync);
+
+    // Ignore timestamps more than a second in the future
+    bool isPlausible = timestamp < (expectedPresent + s2ns(1));
+    ALOGW_IF(!isPlausible, "[%s] Timestamp %" PRId64 " seems implausible "
+            "relative to expectedPresent %" PRId64, mName.string(), timestamp,
+            expectedPresent);
+
+    bool isDue = timestamp < expectedPresent;
+    return isDue || !isPlausible;
+}
+
 bool Layer::onPreComposition() {
     mRefreshPending = false;
-    return mQueuedFrames > 0;
+    return mQueuedFrames > 0 || mSidebandStreamChanged;
 }
 
 void Layer::onPostComposition() {
@@ -934,13 +1160,26 @@
 bool Layer::isVisible() const {
     const Layer::State& s(mDrawingState);
     return !(s.flags & layer_state_t::eLayerHidden) && s.alpha
-            && (mActiveBuffer != NULL);
+            && (mActiveBuffer != NULL || mSidebandStream != NULL);
 }
 
 Region Layer::latchBuffer(bool& recomputeVisibleRegions)
 {
     ATRACE_CALL();
 
+    if (android_atomic_acquire_cas(true, false, &mSidebandStreamChanged) == 0) {
+        // mSidebandStreamChanged was true
+        mSidebandStream = mSurfaceFlingerConsumer->getSidebandStream();
+        if (mSidebandStream != NULL) {
+            setTransactionFlags(eTransactionNeeded);
+            mFlinger->setTransactionFlags(eTraversalNeeded);
+        }
+        recomputeVisibleRegions = true;
+
+        const State& s(getDrawingState());
+        return s.transform.transform(Region(Rect(s.active.w, s.active.h)));
+    }
+
     Region outDirtyRegion;
     if (mQueuedFrames > 0) {
 
@@ -954,21 +1193,24 @@
         }
 
         // Capture the old state of the layer for comparisons later
-        const bool oldOpacity = isOpaque();
+        const State& s(getDrawingState());
+        const bool oldOpacity = isOpaque(s);
         sp<GraphicBuffer> oldActiveBuffer = mActiveBuffer;
 
         struct Reject : public SurfaceFlingerConsumer::BufferRejecter {
             Layer::State& front;
             Layer::State& current;
             bool& recomputeVisibleRegions;
+            bool stickyTransformSet;
             Reject(Layer::State& front, Layer::State& current,
-                    bool& recomputeVisibleRegions)
+                    bool& recomputeVisibleRegions, bool stickySet)
                 : front(front), current(current),
-                  recomputeVisibleRegions(recomputeVisibleRegions) {
+                  recomputeVisibleRegions(recomputeVisibleRegions),
+                  stickyTransformSet(stickySet) {
             }
 
             virtual bool reject(const sp<GraphicBuffer>& buf,
-                    const IGraphicBufferConsumer::BufferItem& item) {
+                    const BufferItem& item) {
                 if (buf == NULL) {
                     return false;
                 }
@@ -1027,12 +1269,12 @@
                             front.requested.crop.getHeight());
                 }
 
-                if (!isFixedSize) {
+                if (!isFixedSize && !stickyTransformSet) {
                     if (front.active.w != bufWidth ||
                         front.active.h != bufHeight) {
                         // reject this buffer
-                        //ALOGD("rejecting buffer: bufWidth=%d, bufHeight=%d, front.active.{w=%d, h=%d}",
-                        //        bufWidth, bufHeight, front.active.w, front.active.h);
+                        ALOGE("rejecting buffer: bufWidth=%d, bufHeight=%d, front.active.{w=%d, h=%d}",
+                                bufWidth, bufHeight, front.active.w, front.active.h);
                         return true;
                     }
                 }
@@ -1061,17 +1303,65 @@
             }
         };
 
+        Reject r(mDrawingState, getCurrentState(), recomputeVisibleRegions,
+                getProducerStickyTransform() != 0);
 
-        Reject r(mDrawingState, getCurrentState(), recomputeVisibleRegions);
+        uint64_t maxFrameNumber = 0;
+        {
+            Mutex::Autolock lock(mQueueItemLock);
+            maxFrameNumber = mLastFrameNumberReceived;
+        }
 
-        status_t updateResult = mSurfaceFlingerConsumer->updateTexImage(&r);
+        status_t updateResult = mSurfaceFlingerConsumer->updateTexImage(&r,
+                mFlinger->mPrimaryDispSync, maxFrameNumber);
         if (updateResult == BufferQueue::PRESENT_LATER) {
             // Producer doesn't want buffer to be displayed yet.  Signal a
             // layer update so we check again at the next opportunity.
             mFlinger->signalLayerUpdate();
             return outDirtyRegion;
+        } else if (updateResult == SurfaceFlingerConsumer::BUFFER_REJECTED) {
+            // If the buffer has been rejected, remove it from the shadow queue
+            // and return early
+            Mutex::Autolock lock(mQueueItemLock);
+            mQueueItems.removeAt(0);
+            android_atomic_dec(&mQueuedFrames);
+            return outDirtyRegion;
+        } else if (updateResult != NO_ERROR || mUpdateTexImageFailed) {
+            // This can occur if something goes wrong when trying to create the
+            // EGLImage for this buffer. If this happens, the buffer has already
+            // been released, so we need to clean up the queue and bug out
+            // early.
+            {
+                Mutex::Autolock lock(mQueueItemLock);
+                mQueueItems.clear();
+                android_atomic_and(0, &mQueuedFrames);
+            }
+
+            // Once we have hit this state, the shadow queue may no longer
+            // correctly reflect the incoming BufferQueue's contents, so even if
+            // updateTexImage starts working, the only safe course of action is
+            // to continue to ignore updates.
+            mUpdateTexImageFailed = true;
+
+            return outDirtyRegion;
         }
 
+        { // Autolock scope
+            auto currentFrameNumber = mSurfaceFlingerConsumer->getFrameNumber();
+
+            Mutex::Autolock lock(mQueueItemLock);
+
+            // Remove any stale buffers that have been dropped during
+            // updateTexImage
+            while (mQueueItems[0].mFrameNumber != currentFrameNumber) {
+                mQueueItems.removeAt(0);
+                android_atomic_dec(&mQueuedFrames);
+            }
+
+            mQueueItems.removeAt(0);
+        }
+
+
         // Decrement the queued-frames count.  Signal another event if we
         // have more frames pending.
         if (android_atomic_dec(&mQueuedFrames) > 1) {
@@ -1122,12 +1412,11 @@
         }
 
         mCurrentOpacity = getOpacityForFormat(mActiveBuffer->format);
-        if (oldOpacity != isOpaque()) {
+        if (oldOpacity != isOpaque(s)) {
             recomputeVisibleRegions = true;
         }
 
         // FIXME: postedRegion should be dirty & bounds
-        const Layer::State& s(getDrawingState());
         Region dirtyRegion(Rect(s.active.w, s.active.h));
 
         // transform the dirty region to window-manager space
@@ -1143,6 +1432,9 @@
         // need a hardware-protected path to external video sink
         usage |= GraphicBuffer::USAGE_PROTECTED;
     }
+    if (mPotentialCursor) {
+        usage |= GraphicBuffer::USAGE_CURSOR;
+    }
     usage |= GraphicBuffer::USAGE_HW_COMPOSER;
     return usage;
 }
@@ -1178,6 +1470,7 @@
 
     s.activeTransparentRegion.dump(result, "transparentRegion");
     visibleRegion.dump(result, "visibleRegion");
+    surfaceDamageRegion.dump(result, "surfaceDamageRegion");
     sp<Client> client(mClientRef.promote());
 
     result.appendFormat(            "      "
@@ -1188,7 +1481,7 @@
             s.layerStack, s.z, s.transform.tx(), s.transform.ty(), s.active.w, s.active.h,
             s.active.crop.left, s.active.crop.top,
             s.active.crop.right, s.active.crop.bottom,
-            isOpaque(), contentDirty,
+            isOpaque(s), contentDirty,
             s.alpha, s.flags,
             s.transform[0][0], s.transform[0][1],
             s.transform[1][0], s.transform[1][1],
@@ -1214,18 +1507,22 @@
     }
 }
 
-void Layer::dumpStats(String8& result) const {
-    mFrameTracker.dump(result);
+void Layer::dumpFrameStats(String8& result) const {
+    mFrameTracker.dumpStats(result);
 }
 
-void Layer::clearStats() {
-    mFrameTracker.clear();
+void Layer::clearFrameStats() {
+    mFrameTracker.clearStats();
 }
 
 void Layer::logFrameStats() {
     mFrameTracker.logAndResetStats(mName);
 }
 
+void Layer::getFrameStats(FrameStats* outStats) const {
+    mFrameTracker.getStats(outStats);
+}
+
 // ---------------------------------------------------------------------------
 
 Layer::LayerCleaner::LayerCleaner(const sp<SurfaceFlinger>& flinger,
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index ef4a7e9..c1e5e9f 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -27,6 +27,7 @@
 #include <utils/String8.h>
 #include <utils/Timers.h>
 
+#include <ui/FrameStats.h>
 #include <ui/GraphicBuffer.h>
 #include <ui/PixelFormat.h>
 #include <ui/Region.h>
@@ -37,9 +38,9 @@
 
 #include "FrameTracker.h"
 #include "Client.h"
+#include "MonitoredProducer.h"
 #include "SurfaceFlinger.h"
 #include "SurfaceFlingerConsumer.h"
-#include "SurfaceTextureLayer.h"
 #include "Transform.h"
 
 #include "DisplayHardware/HWComposer.h"
@@ -66,7 +67,7 @@
  * This also implements onFrameAvailable(), which notifies SurfaceFlinger
  * that new data has arrived.
  */
-class Layer : public SurfaceFlingerConsumer::FrameAvailableListener {
+class Layer : public SurfaceFlingerConsumer::ContentsChangedListener {
     static int32_t sSequence;
 
 public:
@@ -75,6 +76,11 @@
     Region visibleRegion;
     Region coveredRegion;
     Region visibleNonTransparentRegion;
+    Region surfaceDamageRegion;
+
+    // Layer serial number.  This gives layers an explicit ordering, so we
+    // have a stable sort order when their layer stack and Z-order are
+    // the same.
     int32_t sequence;
 
     enum { // flags for doTransaction()
@@ -132,14 +138,22 @@
     bool setCrop(const Rect& crop);
     bool setLayerStack(uint32_t layerStack);
 
+    // If we have received a new buffer this frame, we will pass its surface
+    // damage down to hardware composer. Otherwise, we must send a region with
+    // one empty rect.
+    void useSurfaceDamage();
+    void useEmptyDamage();
+
     uint32_t getTransactionFlags(uint32_t flags);
     uint32_t setTransactionFlags(uint32_t flags);
 
-    void computeGeometry(const sp<const DisplayDevice>& hw, Mesh& mesh) const;
+    void computeGeometry(const sp<const DisplayDevice>& hw, Mesh& mesh,
+            bool useIdentityTransform) const;
+    Rect computeBounds(const Region& activeTransparentRegion) const;
     Rect computeBounds() const;
 
     sp<IBinder> getHandle();
-    sp<IGraphicBufferProducer> getBufferQueue() const;
+    sp<IGraphicBufferProducer> getProducer() const;
     const String8& getName() const;
 
     // -----------------------------------------------------------------------
@@ -149,14 +163,18 @@
 
     /*
      * isOpaque - true if this surface is opaque
+     *
+     * This takes into account the buffer format (i.e. whether or not the
+     * pixel format includes an alpha channel) and the "opaque" flag set
+     * on the layer.  It does not examine the current plane alpha value.
      */
-    virtual bool isOpaque() const;
+    virtual bool isOpaque(const Layer::State& s) const;
 
     /*
      * isSecure - true if this surface is secure, that is if it prevents
      * screenshots or VNC servers.
      */
-    virtual bool isSecure() const           { return mSecure; }
+    virtual bool isSecure() const;
 
     /*
      * isProtected - true if the layer may contain protected content in the
@@ -178,7 +196,8 @@
     /*
      * onDraw - draws the surface.
      */
-    virtual void onDraw(const sp<const DisplayDevice>& hw, const Region& clip) const;
+    virtual void onDraw(const sp<const DisplayDevice>& hw, const Region& clip,
+            bool useIdentityTransform) const;
 
 public:
     // -----------------------------------------------------------------------
@@ -190,12 +209,16 @@
     void setAcquireFence(const sp<const DisplayDevice>& hw,
             HWComposer::HWCLayerInterface& layer);
 
+    Rect getPosition(const sp<const DisplayDevice>& hw);
+
     /*
      * called after page-flip
      */
     void onLayerDisplayed(const sp<const DisplayDevice>& hw,
             HWComposer::HWCLayerInterface* layer);
 
+    bool shouldPresentNow(const DispSync& dispSync) const;
+
     /*
      * called before composition.
      * returns true if the layer has pending updates.
@@ -212,7 +235,8 @@
      * and calls onDraw().
      */
     void draw(const sp<const DisplayDevice>& hw, const Region& clip) const;
-    void draw(const sp<const DisplayDevice>& hw);
+    void draw(const sp<const DisplayDevice>& hw, bool useIdentityTransform) const;
+    void draw(const sp<const DisplayDevice>& hw) const;
 
     /*
      * doTransaction - process the transaction. This is a good place to figure
@@ -248,6 +272,8 @@
      */
     Region latchBuffer(bool& recomputeVisibleRegions);
 
+    bool isPotentialCursor() const { return mPotentialCursor;}
+
     /*
      * called with the state lock when the surface is removed from the
      * current list
@@ -265,6 +291,11 @@
      */
     Rect getContentCrop() const;
 
+    /*
+     * Returns if a frame is queued.
+     */
+    bool hasQueuedFrame() const { return mQueuedFrames > 0 || mSidebandStreamChanged; }
+
     // -----------------------------------------------------------------------
 
     void clearWithOpenGL(const sp<const DisplayDevice>& hw, const Region& clip) const;
@@ -281,9 +312,10 @@
 
     /* always call base class first */
     void dump(String8& result, Colorizer& colorizer) const;
-    void dumpStats(String8& result) const;
-    void clearStats();
+    void dumpFrameStats(String8& result) const;
+    void clearFrameStats();
     void logFrameStats();
+    void getFrameStats(FrameStats* outStats) const;
 
 protected:
     // constant
@@ -306,8 +338,10 @@
 
 
 private:
-    // Interface implementation for SurfaceFlingerConsumer::FrameAvailableListener
-    virtual void onFrameAvailable();
+    // Interface implementation for SurfaceFlingerConsumer::ContentsChangedListener
+    virtual void onFrameAvailable(const BufferItem& item) override;
+    virtual void onFrameReplaced(const BufferItem& item) override;
+    virtual void onSidebandStreamChanged() override;
 
     void commitTransaction();
 
@@ -322,20 +356,22 @@
     // drawing
     void clearWithOpenGL(const sp<const DisplayDevice>& hw, const Region& clip,
             float r, float g, float b, float alpha) const;
-    void drawWithOpenGL(const sp<const DisplayDevice>& hw, const Region& clip) const;
+    void drawWithOpenGL(const sp<const DisplayDevice>& hw, const Region& clip,
+            bool useIdentityTransform) const;
+
+    // Temporary - Used only for LEGACY camera mode.
+    uint32_t getProducerStickyTransform() const;
 
 
     // -----------------------------------------------------------------------
 
     // constants
     sp<SurfaceFlingerConsumer> mSurfaceFlingerConsumer;
-    sp<BufferQueue> mBufferQueue;
-    uint32_t mTextureName;
+    sp<IGraphicBufferProducer> mProducer;
+    uint32_t mTextureName;      // from GLES
     bool mPremultipliedAlpha;
     String8 mName;
-    mutable bool mDebug;
     PixelFormat mFormat;
-    bool mOpaqueLayer;
 
     // these are protected by an external lock
     State mCurrentState;
@@ -344,10 +380,12 @@
 
     // thread-safe
     volatile int32_t mQueuedFrames;
+    volatile int32_t mSidebandStreamChanged; // used like an atomic boolean
     FrameTracker mFrameTracker;
 
     // main thread
     sp<GraphicBuffer> mActiveBuffer;
+    sp<NativeHandle> mSidebandStream;
     Rect mCurrentCrop;
     uint32_t mCurrentTransform;
     uint32_t mCurrentScalingMode;
@@ -360,11 +398,10 @@
     bool mNeedsFiltering;
     // The mesh used to draw the layer in GLES composition mode
     mutable Mesh mMesh;
-    // The mesh used to draw the layer in GLES composition mode
+    // The texture used to draw the layer in GLES composition mode
     mutable Texture mTexture;
 
     // page-flip thread (currently main thread)
-    bool mSecure; // no screenshots
     bool mProtectedByApp; // application requires protected path to external sink
 
     // protected by mLock
@@ -372,6 +409,16 @@
     // Set to true once we've returned this surface's handle
     mutable bool mHasSurface;
     const wp<Client> mClientRef;
+
+    // This layer can be a cursor on some displays.
+    bool mPotentialCursor;
+
+    // Local copy of the queued contents of the incoming BufferQueue
+    mutable Mutex mQueueItemLock;
+    Condition mQueueItemCondition;
+    Vector<BufferItem> mQueueItems;
+    uint64_t mLastFrameNumberReceived;
+    bool mUpdateTexImageFailed; // This is only modified from the main thread
 };
 
 // ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/LayerDim.cpp b/services/surfaceflinger/LayerDim.cpp
index 4e82bab..14aa328 100644
--- a/services/surfaceflinger/LayerDim.cpp
+++ b/services/surfaceflinger/LayerDim.cpp
@@ -39,12 +39,13 @@
 LayerDim::~LayerDim() {
 }
 
-void LayerDim::onDraw(const sp<const DisplayDevice>& hw, const Region& clip) const
+void LayerDim::onDraw(const sp<const DisplayDevice>& hw,
+        const Region& /* clip */, bool useIdentityTransform) const
 {
     const State& s(getDrawingState());
     if (s.alpha>0) {
         Mesh mesh(Mesh::TRIANGLE_FAN, 4, 2);
-        computeGeometry(hw, mesh);
+        computeGeometry(hw, mesh, useIdentityTransform);
         RenderEngine& engine(mFlinger->getRenderEngine());
         engine.setupDimLayerBlending(s.alpha);
         engine.drawMesh(mesh);
diff --git a/services/surfaceflinger/LayerDim.h b/services/surfaceflinger/LayerDim.h
index 6561d7f..a0cfca9 100644
--- a/services/surfaceflinger/LayerDim.h
+++ b/services/surfaceflinger/LayerDim.h
@@ -28,14 +28,15 @@
 
 class LayerDim : public Layer
 {
-public:    
+public:
                 LayerDim(SurfaceFlinger* flinger, const sp<Client>& client,
                         const String8& name, uint32_t w, uint32_t h, uint32_t flags);
         virtual ~LayerDim();
 
     virtual const char* getTypeId() const { return "LayerDim"; }
-    virtual void onDraw(const sp<const DisplayDevice>& hw, const Region& clip) const;
-    virtual bool isOpaque() const         { return false; }
+    virtual void onDraw(const sp<const DisplayDevice>& hw, const Region& clip,
+            bool useIdentityTransform) const;
+    virtual bool isOpaque(const Layer::State&) const { return false; }
     virtual bool isSecure() const         { return false; }
     virtual bool isFixedSize() const      { return true; }
     virtual bool isVisible() const;
diff --git a/services/surfaceflinger/MonitoredProducer.cpp b/services/surfaceflinger/MonitoredProducer.cpp
new file mode 100644
index 0000000..fb7af97
--- /dev/null
+++ b/services/surfaceflinger/MonitoredProducer.cpp
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "MessageQueue.h"
+#include "MonitoredProducer.h"
+#include "SurfaceFlinger.h"
+
+namespace android {
+
+MonitoredProducer::MonitoredProducer(const sp<IGraphicBufferProducer>& producer,
+        const sp<SurfaceFlinger>& flinger) :
+    mProducer(producer),
+    mFlinger(flinger) {}
+
+MonitoredProducer::~MonitoredProducer() {
+    // Remove ourselves from SurfaceFlinger's list. We do this asynchronously
+    // because we don't know where this destructor is called from. It could be
+    // called with the mStateLock held, leading to a dead-lock (it actually
+    // happens).
+    class MessageCleanUpList : public MessageBase {
+    public:
+        MessageCleanUpList(const sp<SurfaceFlinger>& flinger,
+                const wp<IBinder>& producer)
+            : mFlinger(flinger), mProducer(producer) {}
+
+        virtual ~MessageCleanUpList() {}
+
+        virtual bool handler() {
+            Mutex::Autolock _l(mFlinger->mStateLock);
+            mFlinger->mGraphicBufferProducerList.remove(mProducer);
+            return true;
+        }
+
+    private:
+        sp<SurfaceFlinger> mFlinger;
+        wp<IBinder> mProducer;
+    };
+
+    mFlinger->postMessageAsync(new MessageCleanUpList(mFlinger, asBinder(this)));
+}
+
+status_t MonitoredProducer::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
+    return mProducer->requestBuffer(slot, buf);
+}
+
+status_t MonitoredProducer::setBufferCount(int bufferCount) {
+    return mProducer->setBufferCount(bufferCount);
+}
+
+status_t MonitoredProducer::dequeueBuffer(int* slot, sp<Fence>* fence,
+        bool async, uint32_t w, uint32_t h, PixelFormat format, uint32_t usage) {
+    return mProducer->dequeueBuffer(slot, fence, async, w, h, format, usage);
+}
+
+status_t MonitoredProducer::detachBuffer(int slot) {
+    return mProducer->detachBuffer(slot);
+}
+
+status_t MonitoredProducer::detachNextBuffer(sp<GraphicBuffer>* outBuffer,
+        sp<Fence>* outFence) {
+    return mProducer->detachNextBuffer(outBuffer, outFence);
+}
+
+status_t MonitoredProducer::attachBuffer(int* outSlot,
+        const sp<GraphicBuffer>& buffer) {
+    return mProducer->attachBuffer(outSlot, buffer);
+}
+
+status_t MonitoredProducer::queueBuffer(int slot, const QueueBufferInput& input,
+        QueueBufferOutput* output) {
+    return mProducer->queueBuffer(slot, input, output);
+}
+
+void MonitoredProducer::cancelBuffer(int slot, const sp<Fence>& fence) {
+    mProducer->cancelBuffer(slot, fence);
+}
+
+int MonitoredProducer::query(int what, int* value) {
+    return mProducer->query(what, value);
+}
+
+status_t MonitoredProducer::connect(const sp<IProducerListener>& listener,
+        int api, bool producerControlledByApp, QueueBufferOutput* output) {
+    return mProducer->connect(listener, api, producerControlledByApp, output);
+}
+
+status_t MonitoredProducer::disconnect(int api) {
+    return mProducer->disconnect(api);
+}
+
+status_t MonitoredProducer::setSidebandStream(const sp<NativeHandle>& stream) {
+    return mProducer->setSidebandStream(stream);
+}
+
+void MonitoredProducer::allocateBuffers(bool async, uint32_t width,
+        uint32_t height, PixelFormat format, uint32_t usage) {
+    mProducer->allocateBuffers(async, width, height, format, usage);
+}
+
+status_t MonitoredProducer::allowAllocation(bool allow) {
+    return mProducer->allowAllocation(allow);
+}
+
+status_t MonitoredProducer::setGenerationNumber(uint32_t generationNumber) {
+    return mProducer->setGenerationNumber(generationNumber);
+}
+
+String8 MonitoredProducer::getConsumerName() const {
+    return mProducer->getConsumerName();
+}
+
+IBinder* MonitoredProducer::onAsBinder() {
+    return IInterface::asBinder(mProducer).get();
+}
+
+// ---------------------------------------------------------------------------
+}; // namespace android
diff --git a/services/surfaceflinger/MonitoredProducer.h b/services/surfaceflinger/MonitoredProducer.h
new file mode 100644
index 0000000..da95766
--- /dev/null
+++ b/services/surfaceflinger/MonitoredProducer.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_MONITORED_PRODUCER_H
+#define ANDROID_MONITORED_PRODUCER_H
+
+#include <gui/IGraphicBufferProducer.h>
+
+namespace android {
+
+class IProducerListener;
+class NativeHandle;
+class SurfaceFlinger;
+
+// MonitoredProducer wraps an IGraphicBufferProducer so that SurfaceFlinger will
+// be notified upon its destruction
+class MonitoredProducer : public IGraphicBufferProducer {
+public:
+    MonitoredProducer(const sp<IGraphicBufferProducer>& producer,
+            const sp<SurfaceFlinger>& flinger);
+    virtual ~MonitoredProducer();
+
+    // From IGraphicBufferProducer
+    virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf);
+    virtual status_t setBufferCount(int bufferCount);
+    virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, bool async,
+            uint32_t w, uint32_t h, PixelFormat format, uint32_t usage);
+    virtual status_t detachBuffer(int slot);
+    virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
+            sp<Fence>* outFence);
+    virtual status_t attachBuffer(int* outSlot,
+            const sp<GraphicBuffer>& buffer);
+    virtual status_t queueBuffer(int slot, const QueueBufferInput& input,
+            QueueBufferOutput* output);
+    virtual void cancelBuffer(int slot, const sp<Fence>& fence);
+    virtual int query(int what, int* value);
+    virtual status_t connect(const sp<IProducerListener>& token, int api,
+            bool producerControlledByApp, QueueBufferOutput* output);
+    virtual status_t disconnect(int api);
+    virtual status_t setSidebandStream(const sp<NativeHandle>& stream);
+    virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
+            PixelFormat format, uint32_t usage);
+    virtual status_t allowAllocation(bool allow);
+    virtual status_t setGenerationNumber(uint32_t generationNumber);
+    virtual String8 getConsumerName() const override;
+    virtual IBinder* onAsBinder();
+
+private:
+    sp<IGraphicBufferProducer> mProducer;
+    sp<SurfaceFlinger> mFlinger;
+};
+
+}; // namespace android
+
+#endif // ANDROID_MONITORED_PRODUCER_H
diff --git a/services/surfaceflinger/RenderEngine/Description.cpp b/services/surfaceflinger/RenderEngine/Description.cpp
index 1adcd1f..0dab872 100644
--- a/services/surfaceflinger/RenderEngine/Description.cpp
+++ b/services/surfaceflinger/RenderEngine/Description.cpp
@@ -88,5 +88,9 @@
     mColorMatrixEnabled = (mtx != identity);
 }
 
+const mat4& Description::getColorMatrix() const {
+    return mColorMatrix;
+}
+
 
 } /* namespace android */
diff --git a/services/surfaceflinger/RenderEngine/Description.h b/services/surfaceflinger/RenderEngine/Description.h
index 43b835f..8a3447c 100644
--- a/services/surfaceflinger/RenderEngine/Description.h
+++ b/services/surfaceflinger/RenderEngine/Description.h
@@ -66,6 +66,7 @@
     void setColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
     void setProjectionMatrix(const mat4& mtx);
     void setColorMatrix(const mat4& mtx);
+    const mat4& getColorMatrix() const;
 
 private:
     bool mUniformsDirty;
diff --git a/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp b/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp
index cbff320..1a9f59b 100644
--- a/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp
@@ -17,8 +17,11 @@
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
+#include <ui/Rect.h>
+
 #include <utils/String8.h>
 #include <cutils/compiler.h>
+#include <gui/ISurfaceComposer.h>
 
 #include "GLES11RenderEngine.h"
 #include "Mesh.h"
@@ -40,12 +43,6 @@
     glDisable(GL_DITHER);
     glDisable(GL_CULL_FACE);
 
-    struct pack565 {
-        inline uint16_t operator() (int r, int g, int b) const {
-            return (r<<11)|(g<<5)|b;
-        }
-    } pack565;
-
     const uint16_t protTexData[] = { 0 };
     glGenTextures(1, &mProtectedTexName);
     glBindTexture(GL_TEXTURE_2D, mProtectedTexName);
@@ -72,13 +69,41 @@
 }
 
 void GLES11RenderEngine::setViewportAndProjection(
-        size_t vpw, size_t vph, size_t w, size_t h, bool yswap) {
+        size_t vpw, size_t vph, Rect sourceCrop, size_t hwh, bool yswap,
+        Transform::orientation_flags rotation) {
     glViewport(0, 0, vpw, vph);
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
-    // put the origin in the left-bottom corner
-    if (yswap)  glOrthof(0, w, h, 0, 0, 1);
-    else        glOrthof(0, w, 0, h, 0, 1);
+
+    size_t l = sourceCrop.left;
+    size_t r = sourceCrop.right;
+
+    // In GL, (0, 0) is the bottom-left corner, so flip y coordinates
+    size_t t = hwh - sourceCrop.top;
+    size_t b = hwh - sourceCrop.bottom;
+
+    if (yswap) {
+        glOrthof(l, r, t, b, 0, 1);
+    } else {
+        glOrthof(l, r, b, t, 0, 1);
+    }
+
+    switch (rotation) {
+        case Transform::ROT_0:
+            break;
+        case Transform::ROT_90:
+            glRotatef(90, 0, 0, 1);
+            break;
+        case Transform::ROT_180:
+            glRotatef(180, 0, 0, 1);
+            break;
+        case Transform::ROT_270:
+            glRotatef(270, 0, 0, 1);
+            break;
+        default:
+            break;
+    }
+
     glMatrixMode(GL_MODELVIEW);
 }
 
@@ -237,14 +262,6 @@
     }
 }
 
-void GLES11RenderEngine::beginGroup(const mat4& /*colorTransform*/) {
-    // doesn't do anything in GLES 1.1
-}
-
-void GLES11RenderEngine::endGroup() {
-    // doesn't do anything in GLES 1.1
-}
-
 void GLES11RenderEngine::dump(String8& result) {
     RenderEngine::dump(result);
 }
diff --git a/services/surfaceflinger/RenderEngine/GLES11RenderEngine.h b/services/surfaceflinger/RenderEngine/GLES11RenderEngine.h
index cd53aab..08de646 100644
--- a/services/surfaceflinger/RenderEngine/GLES11RenderEngine.h
+++ b/services/surfaceflinger/RenderEngine/GLES11RenderEngine.h
@@ -22,6 +22,7 @@
 #include <sys/types.h>
 
 #include <GLES/gl.h>
+#include <Transform.h>
 
 #include "RenderEngine.h"
 
@@ -49,7 +50,8 @@
     virtual ~GLES11RenderEngine();
 
     virtual void dump(String8& result);
-    virtual void setViewportAndProjection(size_t vpw, size_t vph, size_t w, size_t h, bool yswap);
+    virtual void setViewportAndProjection(size_t vpw, size_t vph,
+            Rect sourceCrop, size_t hwh, bool yswap, Transform::orientation_flags rotation);
     virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, int alpha);
     virtual void setupDimLayerBlending(int alpha);
     virtual void setupLayerTexturing(const Texture& texture);
@@ -60,9 +62,6 @@
 
     virtual void drawMesh(const Mesh& mesh);
 
-    virtual void beginGroup(const mat4& colorTransform);
-    virtual void endGroup();
-
     virtual size_t getMaxTextureSize() const;
     virtual size_t getMaxViewportDims() const;
 };
diff --git a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
index a2a6270..1fabaf5 100644
--- a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
@@ -19,10 +19,14 @@
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 
+#include <ui/Rect.h>
+
 #include <utils/String8.h>
 #include <utils/Trace.h>
 
 #include <cutils/compiler.h>
+#include <gui/ISurfaceComposer.h>
+#include <math.h>
 
 #include "GLES20RenderEngine.h"
 #include "Program.h"
@@ -44,12 +48,6 @@
     glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
     glPixelStorei(GL_PACK_ALIGNMENT, 4);
 
-    struct pack565 {
-        inline uint16_t operator() (int r, int g, int b) const {
-            return (r<<11)|(g<<5)|b;
-        }
-    } pack565;
-
     const uint16_t protTexData[] = { 0 };
     glGenTextures(1, &mProtectedTexName);
     glBindTexture(GL_TEXTURE_2D, mProtectedTexName);
@@ -78,10 +76,40 @@
 }
 
 void GLES20RenderEngine::setViewportAndProjection(
-        size_t vpw, size_t vph, size_t w, size_t h, bool yswap) {
+        size_t vpw, size_t vph, Rect sourceCrop, size_t hwh, bool yswap,
+        Transform::orientation_flags rotation) {
+
+    size_t l = sourceCrop.left;
+    size_t r = sourceCrop.right;
+
+    // In GL, (0, 0) is the bottom-left corner, so flip y coordinates
+    size_t t = hwh - sourceCrop.top;
+    size_t b = hwh - sourceCrop.bottom;
+
     mat4 m;
-    if (yswap)  m = mat4::ortho(0, w, h, 0, 0, 1);
-    else        m = mat4::ortho(0, w, 0, h, 0, 1);
+    if (yswap) {
+        m = mat4::ortho(l, r, t, b, 0, 1);
+    } else {
+        m = mat4::ortho(l, r, b, t, 0, 1);
+    }
+
+    // Apply custom rotation to the projection.
+    float rot90InRadians = 2.0f * static_cast<float>(M_PI) / 4.0f;
+    switch (rotation) {
+        case Transform::ROT_0:
+            break;
+        case Transform::ROT_90:
+            m = mat4::rotate(rot90InRadians, vec3(0,0,1)) * m;
+            break;
+        case Transform::ROT_180:
+            m = mat4::rotate(rot90InRadians * 2.0f, vec3(0,0,1)) * m;
+            break;
+        case Transform::ROT_270:
+            m = mat4::rotate(rot90InRadians * 3.0f, vec3(0,0,1)) * m;
+            break;
+        default:
+            break;
+    }
 
     glViewport(0, 0, vpw, vph);
     mState.setProjectionMatrix(m);
@@ -141,6 +169,12 @@
     mState.setTexture(texture);
 }
 
+mat4 GLES20RenderEngine::setupColorTransform(const mat4& colorTransform) {
+    mat4 oldTransform = mState.getColorMatrix();
+    mState.setColorMatrix(colorTransform);
+    return oldTransform;
+}
+
 void GLES20RenderEngine::disableTexturing() {
     mState.disableTexture();
 }
@@ -209,78 +243,6 @@
     }
 }
 
-void GLES20RenderEngine::beginGroup(const mat4& colorTransform) {
-
-    GLuint tname, name;
-    // create the texture
-    glGenTextures(1, &tname);
-    glBindTexture(GL_TEXTURE_2D, tname);
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mVpWidth, mVpHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
-
-    // create a Framebuffer Object to render into
-    glGenFramebuffers(1, &name);
-    glBindFramebuffer(GL_FRAMEBUFFER, name);
-    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tname, 0);
-
-    Group group;
-    group.texture = tname;
-    group.fbo = name;
-    group.width = mVpWidth;
-    group.height = mVpHeight;
-    group.colorTransform = colorTransform;
-
-    mGroupStack.push(group);
-}
-
-void GLES20RenderEngine::endGroup() {
-
-    const Group group(mGroupStack.top());
-    mGroupStack.pop();
-
-    // activate the previous render target
-    GLuint fbo = 0;
-    if (!mGroupStack.isEmpty()) {
-        fbo = mGroupStack.top().fbo;
-    }
-    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
-
-    // set our state
-    Texture texture(Texture::TEXTURE_2D, group.texture);
-    texture.setDimensions(group.width, group.height);
-    glBindTexture(GL_TEXTURE_2D, group.texture);
-
-    mState.setPlaneAlpha(1.0f);
-    mState.setPremultipliedAlpha(true);
-    mState.setOpaque(false);
-    mState.setTexture(texture);
-    mState.setColorMatrix(group.colorTransform);
-    glDisable(GL_BLEND);
-
-    Mesh mesh(Mesh::TRIANGLE_FAN, 4, 2, 2);
-    Mesh::VertexArray<vec2> position(mesh.getPositionArray<vec2>());
-    Mesh::VertexArray<vec2> texCoord(mesh.getTexCoordArray<vec2>());
-    position[0] = vec2(0, 0);
-    position[1] = vec2(group.width, 0);
-    position[2] = vec2(group.width, group.height);
-    position[3] = vec2(0, group.height);
-    texCoord[0] = vec2(0, 0);
-    texCoord[1] = vec2(1, 0);
-    texCoord[2] = vec2(1, 1);
-    texCoord[3] = vec2(0, 1);
-    drawMesh(mesh);
-
-    // reset color matrix
-    mState.setColorMatrix(mat4());
-
-    // free our fbo and texture
-    glDeleteFramebuffers(1, &group.fbo);
-    glDeleteTextures(1, &group.texture);
-}
-
 void GLES20RenderEngine::dump(String8& result) {
     RenderEngine::dump(result);
 }
diff --git a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.h b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.h
index 8b67fcc..819356a 100644
--- a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.h
+++ b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.h
@@ -22,6 +22,7 @@
 #include <sys/types.h>
 
 #include <GLES2/gl2.h>
+#include <Transform.h>
 
 #include "RenderEngine.h"
 #include "ProgramCache.h"
@@ -64,20 +65,19 @@
     virtual ~GLES20RenderEngine();
 
     virtual void dump(String8& result);
-    virtual void setViewportAndProjection(size_t vpw, size_t vph, size_t w, size_t h, bool yswap);
+    virtual void setViewportAndProjection(size_t vpw, size_t vph,
+            Rect sourceCrop, size_t hwh, bool yswap, Transform::orientation_flags rotation);
     virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, int alpha);
     virtual void setupDimLayerBlending(int alpha);
     virtual void setupLayerTexturing(const Texture& texture);
     virtual void setupLayerBlackedOut();
     virtual void setupFillWithColor(float r, float g, float b, float a);
+    virtual mat4 setupColorTransform(const mat4& colorTransform);
     virtual void disableTexturing();
     virtual void disableBlending();
 
     virtual void drawMesh(const Mesh& mesh);
 
-    virtual void beginGroup(const mat4& colorTransform);
-    virtual void endGroup();
-
     virtual size_t getMaxTextureSize() const;
     virtual size_t getMaxViewportDims() const;
 };
diff --git a/services/surfaceflinger/RenderEngine/Mesh.cpp b/services/surfaceflinger/RenderEngine/Mesh.cpp
index 3f50cb0..ffd9be2 100644
--- a/services/surfaceflinger/RenderEngine/Mesh.cpp
+++ b/services/surfaceflinger/RenderEngine/Mesh.cpp
@@ -16,14 +16,40 @@
 
 #include "Mesh.h"
 
+#include <utils/Log.h>
+
 namespace android {
 
 Mesh::Mesh(Primitive primitive, size_t vertexCount, size_t vertexSize, size_t texCoordSize)
     : mVertexCount(vertexCount), mVertexSize(vertexSize), mTexCoordsSize(texCoordSize),
       mPrimitive(primitive)
 {
-    mVertices = new float[(vertexSize + texCoordSize) * vertexCount];
-    mStride = mVertexSize + mTexCoordsSize;
+    if (vertexCount == 0) {
+        mVertices = new float[1];
+        mVertices[0] = 0.0f;
+        mStride = 0;
+        return;
+    }
+
+    size_t stride = vertexSize + texCoordSize;
+    size_t remainder = (stride * vertexCount) / vertexCount;
+    // Since all of the input parameters are unsigned, if stride is less than
+    // either vertexSize or texCoordSize, it must have overflowed. remainder
+    // will be equal to stride as long as stride * vertexCount doesn't overflow.
+    if ((stride < vertexSize) || (remainder != stride)) {
+        ALOGE("Overflow in Mesh(..., %zu, %zu, %zu)", vertexCount, vertexSize,
+                texCoordSize);
+        mVertices = new float[1];
+        mVertices[0] = 0.0f;
+        mVertexCount = 0;
+        mVertexSize = 0;
+        mTexCoordsSize = 0;
+        mStride = 0;
+        return;
+    }
+
+    mVertices = new float[stride * vertexCount];
+    mStride = stride;
 }
 
 Mesh::~Mesh() {
diff --git a/services/surfaceflinger/RenderEngine/ProgramCache.cpp b/services/surfaceflinger/RenderEngine/ProgramCache.cpp
index 09b0ddc..ba11259 100644
--- a/services/surfaceflinger/RenderEngine/ProgramCache.cpp
+++ b/services/surfaceflinger/RenderEngine/ProgramCache.cpp
@@ -77,13 +77,44 @@
 
 ANDROID_SINGLETON_STATIC_INSTANCE(ProgramCache)
 
-
 ProgramCache::ProgramCache() {
+    // Until surfaceflinger has a dependable blob cache on the filesystem,
+    // generate shaders on initialization so as to avoid jank.
+    primeCache();
 }
 
 ProgramCache::~ProgramCache() {
 }
 
+void ProgramCache::primeCache() {
+    uint32_t shaderCount = 0;
+    uint32_t keyMask = Key::BLEND_MASK | Key::OPACITY_MASK |
+                       Key::PLANE_ALPHA_MASK | Key::TEXTURE_MASK;
+    // Prime the cache for all combinations of the above masks,
+    // leaving off the experimental color matrix mask options.
+
+    nsecs_t timeBefore = systemTime();
+    for (uint32_t keyVal = 0; keyVal <= keyMask; keyVal++) {
+        Key shaderKey;
+        shaderKey.set(keyMask, keyVal);
+        uint32_t tex = shaderKey.getTextureTarget();
+        if (tex != Key::TEXTURE_OFF &&
+            tex != Key::TEXTURE_EXT &&
+            tex != Key::TEXTURE_2D) {
+            continue;
+        }
+        Program* program = mCache.valueFor(shaderKey);
+        if (program == NULL) {
+            program = generateProgram(shaderKey);
+            mCache.add(shaderKey, program);
+            shaderCount++;
+        }
+    }
+    nsecs_t timeAfter = systemTime();
+    float compileTimeMs = static_cast<float>(timeAfter - timeBefore) / 1.0E6;
+    ALOGD("shader cache generated - %u shaders in %f ms\n", shaderCount, compileTimeMs);
+}
+
 ProgramCache::Key ProgramCache::computeKey(const Description& description) {
     Key needs;
     needs.set(Key::TEXTURE_MASK,
@@ -168,9 +199,8 @@
             // un-premultiply if needed before linearization
             fs << "gl_FragColor.rgb = gl_FragColor.rgb/gl_FragColor.a;";
         }
-        fs << "gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(2.2));";
-        fs << "gl_FragColor     = colorMatrix*gl_FragColor;";
-        fs << "gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(1.0 / 2.2));";
+        fs << "vec4 transformed = colorMatrix * vec4(gl_FragColor.rgb, 1);";
+        fs << "gl_FragColor.rgb = transformed.rgb/transformed.a;";
         if (!needs.isOpaque() && needs.isPremultiplied()) {
             // and re-premultiply if needed after gamma correction
             fs << "gl_FragColor.rgb = gl_FragColor.rgb*gl_FragColor.a;";
diff --git a/services/surfaceflinger/RenderEngine/ProgramCache.h b/services/surfaceflinger/RenderEngine/ProgramCache.h
index e8b9dcd..1fa53d3 100644
--- a/services/surfaceflinger/RenderEngine/ProgramCache.h
+++ b/services/surfaceflinger/RenderEngine/ProgramCache.h
@@ -112,6 +112,8 @@
     void useProgram(const Description& description);
 
 private:
+    // Generate shaders to populate the cache
+    void primeCache();
     // compute a cache Key from a Description
     static Key computeKey(const Description& description);
     // generates a program from the Key
diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.cpp b/services/surfaceflinger/RenderEngine/RenderEngine.cpp
index 2871ce9..7cd42e4 100644
--- a/services/surfaceflinger/RenderEngine/RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/RenderEngine.cpp
@@ -139,8 +139,8 @@
     ALOGI("renderer  : %s", extensions.getRenderer());
     ALOGI("version   : %s", extensions.getVersion());
     ALOGI("extensions: %s", extensions.getExtension());
-    ALOGI("GL_MAX_TEXTURE_SIZE = %d", engine->getMaxTextureSize());
-    ALOGI("GL_MAX_VIEWPORT_DIMS = %d", engine->getMaxViewportDims());
+    ALOGI("GL_MAX_TEXTURE_SIZE = %zu", engine->getMaxTextureSize());
+    ALOGI("GL_MAX_VIEWPORT_DIMS = %zu", engine->getMaxViewportDims());
 
     eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
     eglDestroySurface(display, dummy);
@@ -219,6 +219,10 @@
     drawMesh(mesh);
 }
 
+void RenderEngine::flush() {
+    glFlush();
+}
+
 void RenderEngine::clearWithColor(float red, float green, float blue, float alpha) {
     glClearColor(red, green, blue, alpha);
     glClear(GL_COLOR_BUFFER_BIT);
@@ -279,7 +283,6 @@
 
 static status_t selectConfigForAttribute(EGLDisplay dpy, EGLint const* attrs,
         EGLint attribute, EGLint wanted, EGLConfig* outConfig) {
-    EGLConfig config = NULL;
     EGLint numConfigs = -1, n = 0;
     eglGetConfigs(dpy, NULL, 0, &numConfigs);
     EGLConfig* const configs = new EGLConfig[numConfigs];
diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.h b/services/surfaceflinger/RenderEngine/RenderEngine.h
index 577dc0a..31a961e 100644
--- a/services/surfaceflinger/RenderEngine/RenderEngine.h
+++ b/services/surfaceflinger/RenderEngine/RenderEngine.h
@@ -24,6 +24,7 @@
 #include <EGL/egl.h>
 #include <EGL/eglext.h>
 #include <ui/mat4.h>
+#include <Transform.h>
 
 #define EGL_NO_CONFIG ((EGLConfig)0)
 
@@ -66,6 +67,7 @@
     virtual void dump(String8& result);
 
     // helpers
+    void flush();
     void clearWithColor(float red, float green, float blue, float alpha);
     void fillRegionWithColor(const Region& region, uint32_t height,
             float red, float green, float blue, float alpha);
@@ -89,25 +91,24 @@
 
     // set-up
     virtual void checkErrors() const;
-    virtual void setViewportAndProjection(size_t vpw, size_t vph, size_t w, size_t h, bool yswap) = 0;
+    virtual void setViewportAndProjection(size_t vpw, size_t vph,
+            Rect sourceCrop, size_t hwh, bool yswap, Transform::orientation_flags rotation) = 0;
     virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, int alpha) = 0;
     virtual void setupDimLayerBlending(int alpha) = 0;
     virtual void setupLayerTexturing(const Texture& texture) = 0;
     virtual void setupLayerBlackedOut() = 0;
     virtual void setupFillWithColor(float r, float g, float b, float a) = 0;
 
+    virtual mat4 setupColorTransform(const mat4& /* colorTransform */) {
+        return mat4();
+    }
+
     virtual void disableTexturing() = 0;
     virtual void disableBlending() = 0;
 
     // drawing
     virtual void drawMesh(const Mesh& mesh) = 0;
 
-    // grouping
-    // creates a color-transform group, everything drawn in the group will be
-    // transformed by the given color transform when endGroup() is called.
-    virtual void beginGroup(const mat4& colorTransform) = 0;
-    virtual void endGroup() = 0;
-
     // queries
     virtual size_t getMaxTextureSize() const = 0;
     virtual size_t getMaxViewportDims() const = 0;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 943ed02..5742f6f 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -22,6 +22,7 @@
 #include <math.h>
 #include <dlfcn.h>
 #include <inttypes.h>
+#include <stdatomic.h>
 
 #include <EGL/egl.h>
 
@@ -34,6 +35,7 @@
 #include <binder/PermissionCache.h>
 
 #include <ui/DisplayInfo.h>
+#include <ui/DisplayStatInfo.h>
 
 #include <gui/BitTube.h>
 #include <gui/BufferQueue.h>
@@ -86,15 +88,20 @@
 
 EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name);
 
-namespace android {
-
-// This works around the lack of support for the sync framework on some
-// devices.
-#ifdef RUNNING_WITHOUT_SYNC_FRAMEWORK
-static const bool runningWithoutSyncFramework = true;
-#else
-static const bool runningWithoutSyncFramework = false;
+// Workaround for b/30067360: /proc/self/environ inaccessible in SurfaceFlinger
+// => ASan fails to read ASAN_OPTIONS => alloc-dealloc-mismatch bug is not
+// suppressed and prevents the device from booting.
+#ifndef __has_feature
+#define __has_feature(x) 0
 #endif
+#if __has_feature(address_sanitizer)
+__attribute__((visibility("default")))
+extern "C" const char* __asan_default_options() {
+  return "alloc_dealloc_mismatch=0";
+}
+#endif
+
+namespace android {
 
 // This is the phase offset in nanoseconds of the software vsync event
 // relative to the vsync event reported by HWComposer.  The software vsync
@@ -151,9 +158,15 @@
         mDebugInTransaction(0),
         mLastTransactionTime(0),
         mBootFinished(false),
+        mForceFullDamage(false),
         mPrimaryHWVsyncEnabled(false),
         mHWVsyncAvailable(false),
-        mDaltonize(false)
+        mDaltonize(false),
+        mHasColorMatrix(false),
+        mHasPoweredOff(false),
+        mFrameBuckets(),
+        mTotalTime(0),
+        mLastSwapTime(0)
 {
     ALOGI("SurfaceFlinger is starting");
 
@@ -163,6 +176,9 @@
     property_get("ro.bq.gpu_to_cpu_unsupported", value, "0");
     mGpuToCpuSupported = !atoi(value);
 
+    property_get("debug.sf.drop_missed_frames", value, "0");
+    mDropMissedFrames = atoi(value);
+
     property_get("debug.sf.showupdates", value, "0");
     mDebugRegion = atoi(value);
 
@@ -190,7 +206,7 @@
     eglTerminate(display);
 }
 
-void SurfaceFlinger::binderDied(const wp<IBinder>& who)
+void SurfaceFlinger::binderDied(const wp<IBinder>& /* who */)
 {
     // the window manager died on us. prepare its eulogy.
 
@@ -321,17 +337,23 @@
 
 class DispSyncSource : public VSyncSource, private DispSync::Callback {
 public:
-    DispSyncSource(DispSync* dispSync, nsecs_t phaseOffset, bool traceVsync) :
+    DispSyncSource(DispSync* dispSync, nsecs_t phaseOffset, bool traceVsync,
+        const char* label) :
             mValue(0),
-            mPhaseOffset(phaseOffset),
             mTraceVsync(traceVsync),
-            mDispSync(dispSync) {}
+            mVsyncOnLabel(String8::format("VsyncOn-%s", label)),
+            mVsyncEventLabel(String8::format("VSYNC-%s", label)),
+            mDispSync(dispSync),
+            mCallbackMutex(),
+            mCallback(),
+            mVsyncMutex(),
+            mPhaseOffset(phaseOffset),
+            mEnabled(false) {}
 
     virtual ~DispSyncSource() {}
 
     virtual void setVSyncEnabled(bool enable) {
-        // Do NOT lock the mutex here so as to avoid any mutex ordering issues
-        // with locking it in the onDispSyncEvent callback.
+        Mutex::Autolock lock(mVsyncMutex);
         if (enable) {
             status_t err = mDispSync->addEventListener(mPhaseOffset,
                     static_cast<DispSync::Callback*>(this));
@@ -339,7 +361,7 @@
                 ALOGE("error registering vsync callback: %s (%d)",
                         strerror(-err), err);
             }
-            ATRACE_INT("VsyncOn", 1);
+            //ATRACE_INT(mVsyncOnLabel.string(), 1);
         } else {
             status_t err = mDispSync->removeEventListener(
                     static_cast<DispSync::Callback*>(this));
@@ -347,25 +369,61 @@
                 ALOGE("error unregistering vsync callback: %s (%d)",
                         strerror(-err), err);
             }
-            ATRACE_INT("VsyncOn", 0);
+            //ATRACE_INT(mVsyncOnLabel.string(), 0);
         }
+        mEnabled = enable;
     }
 
     virtual void setCallback(const sp<VSyncSource::Callback>& callback) {
-        Mutex::Autolock lock(mMutex);
+        Mutex::Autolock lock(mCallbackMutex);
         mCallback = callback;
     }
 
+    virtual void setPhaseOffset(nsecs_t phaseOffset) {
+        Mutex::Autolock lock(mVsyncMutex);
+
+        // Normalize phaseOffset to [0, period)
+        auto period = mDispSync->getPeriod();
+        phaseOffset %= period;
+        if (phaseOffset < 0) {
+            // If we're here, then phaseOffset is in (-period, 0). After this
+            // operation, it will be in (0, period)
+            phaseOffset += period;
+        }
+        mPhaseOffset = phaseOffset;
+
+        // If we're not enabled, we don't need to mess with the listeners
+        if (!mEnabled) {
+            return;
+        }
+
+        // Remove the listener with the old offset
+        status_t err = mDispSync->removeEventListener(
+                static_cast<DispSync::Callback*>(this));
+        if (err != NO_ERROR) {
+            ALOGE("error unregistering vsync callback: %s (%d)",
+                    strerror(-err), err);
+        }
+
+        // Add a listener with the new offset
+        err = mDispSync->addEventListener(mPhaseOffset,
+                static_cast<DispSync::Callback*>(this));
+        if (err != NO_ERROR) {
+            ALOGE("error registering vsync callback: %s (%d)",
+                    strerror(-err), err);
+        }
+    }
+
 private:
     virtual void onDispSyncEvent(nsecs_t when) {
         sp<VSyncSource::Callback> callback;
         {
-            Mutex::Autolock lock(mMutex);
+            Mutex::Autolock lock(mCallbackMutex);
             callback = mCallback;
 
             if (mTraceVsync) {
                 mValue = (mValue + 1) % 2;
-                ATRACE_INT("VSYNC", mValue);
+                ATRACE_INT(mVsyncEventLabel.string(), mValue);
             }
         }
 
@@ -376,25 +434,39 @@
 
     int mValue;
 
-    const nsecs_t mPhaseOffset;
     const bool mTraceVsync;
+    const String8 mVsyncOnLabel;
+    const String8 mVsyncEventLabel;
 
     DispSync* mDispSync;
+
+    Mutex mCallbackMutex; // Protects the following
     sp<VSyncSource::Callback> mCallback;
-    Mutex mMutex;
+
+    Mutex mVsyncMutex; // Protects the following
+    nsecs_t mPhaseOffset;
+    bool mEnabled;
 };
 
 void SurfaceFlinger::init() {
     ALOGI(  "SurfaceFlinger's main thread ready to run. "
             "Initializing graphics H/W...");
 
-    status_t err;
     Mutex::Autolock _l(mStateLock);
 
     // initialize EGL for the default display
     mEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
     eglInitialize(mEGLDisplay, NULL, NULL);
 
+    // start the EventThread
+    sp<VSyncSource> vsyncSrc = new DispSyncSource(&mPrimaryDispSync,
+            vsyncPhaseOffsetNs, true, "app");
+    mEventThread = new EventThread(vsyncSrc);
+    sp<VSyncSource> sfVsyncSrc = new DispSyncSource(&mPrimaryDispSync,
+            sfVsyncPhaseOffsetNs, true, "sf");
+    mSFEventThread = new EventThread(sfVsyncSrc);
+    mEventQueue.setEventThread(mSFEventThread);
+
     // Initialize the H/W composer object.  There may or may not be an
     // actual hardware composer underneath.
     mHwc = new HWComposer(this,
@@ -419,19 +491,24 @@
             createBuiltinDisplayLocked(type);
             wp<IBinder> token = mBuiltinDisplays[i];
 
-            sp<BufferQueue> bq = new BufferQueue(new GraphicBufferAlloc());
-            sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc, i, bq);
+            sp<IGraphicBufferProducer> producer;
+            sp<IGraphicBufferConsumer> consumer;
+            BufferQueue::createBufferQueue(&producer, &consumer,
+                    new GraphicBufferAlloc());
+
+            sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc, i,
+                    consumer);
             int32_t hwcId = allocateHwcDisplayId(type);
             sp<DisplayDevice> hw = new DisplayDevice(this,
                     type, hwcId, mHwc->getFormat(hwcId), isSecure, token,
-                    fbs, bq,
+                    fbs, producer,
                     mRenderEngine->getEGLConfig());
             if (i > DisplayDevice::DISPLAY_PRIMARY) {
                 // FIXME: currently we don't get blank/unblank requests
                 // for displays other than the main display, so we always
                 // assume a connected display is unblanked.
                 ALOGD("marking display %zu as acquired/unblanked", i);
-                hw->acquireScreen();
+                hw->setPowerMode(HWC_POWER_MODE_NORMAL);
             }
             mDisplays.add(token, hw);
         }
@@ -441,15 +518,6 @@
     // (which may happens before we render something)
     getDefaultDisplayDevice()->makeCurrent(mEGLDisplay, mEGLContext);
 
-    // start the EventThread
-    sp<VSyncSource> vsyncSrc = new DispSyncSource(&mPrimaryDispSync,
-            vsyncPhaseOffsetNs, true);
-    mEventThread = new EventThread(vsyncSrc);
-    sp<VSyncSource> sfVsyncSrc = new DispSyncSource(&mPrimaryDispSync,
-            sfVsyncPhaseOffsetNs, false);
-    mSFEventThread = new EventThread(sfVsyncSrc);
-    mEventQueue.setEventThread(mSFEventThread);
-
     mEventControlThread = new EventControlThread(this);
     mEventControlThread->run("EventControl", PRIORITY_URGENT_DISPLAY);
 
@@ -492,11 +560,19 @@
 bool SurfaceFlinger::authenticateSurfaceTexture(
         const sp<IGraphicBufferProducer>& bufferProducer) const {
     Mutex::Autolock _l(mStateLock);
-    sp<IBinder> surfaceTextureBinder(bufferProducer->asBinder());
+    sp<IBinder> surfaceTextureBinder(IInterface::asBinder(bufferProducer));
     return mGraphicBufferProducerList.indexOf(surfaceTextureBinder) >= 0;
 }
 
-status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) {
+status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display,
+        Vector<DisplayInfo>* configs) {
+    if ((configs == NULL) || (display.get() == NULL)) {
+        return BAD_VALUE;
+    }
+
+    if (!display.get())
+        return NAME_NOT_FOUND;
+
     int32_t type = NAME_NOT_FOUND;
     for (int i=0 ; i<DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES ; i++) {
         if (display == mBuiltinDisplays[i]) {
@@ -509,10 +585,6 @@
         return type;
     }
 
-    const HWComposer& hwc(getHwComposer());
-    float xdpi = hwc.getDpiX(type);
-    float ydpi = hwc.getDpiY(type);
-
     // TODO: Not sure if display density should handled by SF any longer
     class Density {
         static int getDensityFromProperty(char const* propName) {
@@ -530,41 +602,159 @@
             return getDensityFromProperty("ro.sf.lcd_density"); }
     };
 
-    if (type == DisplayDevice::DISPLAY_PRIMARY) {
-        // The density of the device is provided by a build property
-        float density = Density::getBuildDensity() / 160.0f;
-        if (density == 0) {
-            // the build doesn't provide a density -- this is wrong!
-            // use xdpi instead
-            ALOGE("ro.sf.lcd_density must be defined as a build property");
-            density = xdpi / 160.0f;
-        }
-        if (Density::getEmuDensity()) {
-            // if "qemu.sf.lcd_density" is specified, it overrides everything
-            xdpi = ydpi = density = Density::getEmuDensity();
-            density /= 160.0f;
-        }
-        info->density = density;
+    configs->clear();
 
-        // TODO: this needs to go away (currently needed only by webkit)
-        sp<const DisplayDevice> hw(getDefaultDisplayDevice());
-        info->orientation = hw->getOrientation();
-    } else {
-        // TODO: where should this value come from?
-        static const int TV_DENSITY = 213;
-        info->density = TV_DENSITY / 160.0f;
-        info->orientation = 0;
+    const Vector<HWComposer::DisplayConfig>& hwConfigs =
+            getHwComposer().getConfigs(type);
+    for (size_t c = 0; c < hwConfigs.size(); ++c) {
+        const HWComposer::DisplayConfig& hwConfig = hwConfigs[c];
+        DisplayInfo info = DisplayInfo();
+
+        float xdpi = hwConfig.xdpi;
+        float ydpi = hwConfig.ydpi;
+
+        if (type == DisplayDevice::DISPLAY_PRIMARY) {
+            // The density of the device is provided by a build property
+            float density = Density::getBuildDensity() / 160.0f;
+            if (density == 0) {
+                // the build doesn't provide a density -- this is wrong!
+                // use xdpi instead
+                ALOGE("ro.sf.lcd_density must be defined as a build property");
+                density = xdpi / 160.0f;
+            }
+            if (Density::getEmuDensity()) {
+                // if "qemu.sf.lcd_density" is specified, it overrides everything
+                xdpi = ydpi = density = Density::getEmuDensity();
+                density /= 160.0f;
+            }
+            info.density = density;
+
+            // TODO: this needs to go away (currently needed only by webkit)
+            sp<const DisplayDevice> hw(getDefaultDisplayDevice());
+            info.orientation = hw->getOrientation();
+        } else {
+            // TODO: where should this value come from?
+            static const int TV_DENSITY = 213;
+            info.density = TV_DENSITY / 160.0f;
+            info.orientation = 0;
+        }
+
+        info.w = hwConfig.width;
+        info.h = hwConfig.height;
+        info.xdpi = xdpi;
+        info.ydpi = ydpi;
+        info.fps = float(1e9 / hwConfig.refresh);
+        info.appVsyncOffset = VSYNC_EVENT_PHASE_OFFSET_NS;
+        info.colorTransform = hwConfig.colorTransform;
+
+        // This is how far in advance a buffer must be queued for
+        // presentation at a given time.  If you want a buffer to appear
+        // on the screen at time N, you must submit the buffer before
+        // (N - presentationDeadline).
+        //
+        // Normally it's one full refresh period (to give SF a chance to
+        // latch the buffer), but this can be reduced by configuring a
+        // DispSync offset.  Any additional delays introduced by the hardware
+        // composer or panel must be accounted for here.
+        //
+        // We add an additional 1ms to allow for processing time and
+        // differences between the ideal and actual refresh rate.
+        info.presentationDeadline =
+                hwConfig.refresh - SF_VSYNC_EVENT_PHASE_OFFSET_NS + 1000000;
+
+        // All non-virtual displays are currently considered secure.
+        info.secure = true;
+
+        configs->push_back(info);
     }
 
-    info->w = hwc.getWidth(type);
-    info->h = hwc.getHeight(type);
-    info->xdpi = xdpi;
-    info->ydpi = ydpi;
-    info->fps = float(1e9 / hwc.getRefreshPeriod(type));
+    return NO_ERROR;
+}
 
-    // All non-virtual displays are currently considered secure.
-    info->secure = true;
+status_t SurfaceFlinger::getDisplayStats(const sp<IBinder>& /* display */,
+        DisplayStatInfo* stats) {
+    if (stats == NULL) {
+        return BAD_VALUE;
+    }
 
+    // FIXME for now we always return stats for the primary display
+    memset(stats, 0, sizeof(*stats));
+    stats->vsyncTime   = mPrimaryDispSync.computeNextRefresh(0);
+    stats->vsyncPeriod = mPrimaryDispSync.getPeriod();
+    return NO_ERROR;
+}
+
+int SurfaceFlinger::getActiveConfig(const sp<IBinder>& display) {
+    sp<DisplayDevice> device(getDisplayDevice(display));
+    if (device != NULL) {
+        return device->getActiveConfig();
+    }
+    return BAD_VALUE;
+}
+
+void SurfaceFlinger::setActiveConfigInternal(const sp<DisplayDevice>& hw, int mode) {
+    ALOGD("Set active config mode=%d, type=%d flinger=%p", mode, hw->getDisplayType(),
+          this);
+    int32_t type = hw->getDisplayType();
+    int currentMode = hw->getActiveConfig();
+
+    if (mode == currentMode) {
+        ALOGD("Screen type=%d is already mode=%d", hw->getDisplayType(), mode);
+        return;
+    }
+
+    if (type >= DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) {
+        ALOGW("Trying to set config for virtual display");
+        return;
+    }
+
+    hw->setActiveConfig(mode);
+    getHwComposer().setActiveConfig(type, mode);
+}
+
+status_t SurfaceFlinger::setActiveConfig(const sp<IBinder>& display, int mode) {
+    class MessageSetActiveConfig: public MessageBase {
+        SurfaceFlinger& mFlinger;
+        sp<IBinder> mDisplay;
+        int mMode;
+    public:
+        MessageSetActiveConfig(SurfaceFlinger& flinger, const sp<IBinder>& disp,
+                               int mode) :
+            mFlinger(flinger), mDisplay(disp) { mMode = mode; }
+        virtual bool handler() {
+            Vector<DisplayInfo> configs;
+            mFlinger.getDisplayConfigs(mDisplay, &configs);
+            if (mMode < 0 || mMode >= static_cast<int>(configs.size())) {
+                ALOGE("Attempt to set active config = %d for display with %zu configs",
+                        mMode, configs.size());
+            }
+            sp<DisplayDevice> hw(mFlinger.getDisplayDevice(mDisplay));
+            if (hw == NULL) {
+                ALOGE("Attempt to set active config = %d for null display %p",
+                        mMode, mDisplay.get());
+            } else if (hw->getDisplayType() >= DisplayDevice::DISPLAY_VIRTUAL) {
+                ALOGW("Attempt to set active config = %d for virtual display",
+                        mMode);
+            } else {
+                mFlinger.setActiveConfigInternal(hw, mMode);
+            }
+            return true;
+        }
+    };
+    sp<MessageBase> msg = new MessageSetActiveConfig(*this, display, mode);
+    postMessageSync(msg);
+    return NO_ERROR;
+}
+
+status_t SurfaceFlinger::clearAnimationFrameStats() {
+    Mutex::Autolock _l(mStateLock);
+    mAnimFrameTracker.clearStats();
+    return NO_ERROR;
+}
+
+status_t SurfaceFlinger::getAnimationFrameStats(FrameStats* outStats) const {
+    Mutex::Autolock _l(mStateLock);
+    mAnimFrameTracker.getStats(outStats);
     return NO_ERROR;
 }
 
@@ -593,12 +783,12 @@
 }
 
 status_t SurfaceFlinger::postMessageAsync(const sp<MessageBase>& msg,
-        nsecs_t reltime, uint32_t flags) {
+        nsecs_t reltime, uint32_t /* flags */) {
     return mEventQueue.postMessage(msg, reltime);
 }
 
 status_t SurfaceFlinger::postMessageSync(const sp<MessageBase>& msg,
-        nsecs_t reltime, uint32_t flags) {
+        nsecs_t reltime, uint32_t /* flags */) {
     status_t res = mEventQueue.postMessage(msg, reltime);
     if (res == NO_ERROR) {
         msg->wait();
@@ -707,40 +897,70 @@
 void SurfaceFlinger::onMessageReceived(int32_t what) {
     ATRACE_CALL();
     switch (what) {
-    case MessageQueue::TRANSACTION:
-        handleMessageTransaction();
-        break;
-    case MessageQueue::INVALIDATE:
-        handleMessageTransaction();
-        handleMessageInvalidate();
-        signalRefresh();
-        break;
-    case MessageQueue::REFRESH:
-        handleMessageRefresh();
-        break;
+        case MessageQueue::TRANSACTION: {
+            handleMessageTransaction();
+            break;
+        }
+        case MessageQueue::INVALIDATE: {
+            bool refreshNeeded = handleMessageTransaction();
+            refreshNeeded |= handleMessageInvalidate();
+            refreshNeeded |= mRepaintEverything;
+            if (refreshNeeded) {
+                // Signal a refresh if a transaction modified the window state,
+                // a new buffer was latched, or if HWC has requested a full
+                // repaint
+                signalRefresh();
+            }
+            break;
+        }
+        case MessageQueue::REFRESH: {
+            handleMessageRefresh();
+            break;
+        }
     }
 }
 
-void SurfaceFlinger::handleMessageTransaction() {
+bool SurfaceFlinger::handleMessageTransaction() {
     uint32_t transactionFlags = peekTransactionFlags(eTransactionMask);
     if (transactionFlags) {
         handleTransaction(transactionFlags);
+        return true;
     }
+    return false;
 }
 
-void SurfaceFlinger::handleMessageInvalidate() {
+bool SurfaceFlinger::handleMessageInvalidate() {
     ATRACE_CALL();
-    handlePageFlip();
+    return handlePageFlip();
 }
 
 void SurfaceFlinger::handleMessageRefresh() {
     ATRACE_CALL();
-    preComposition();
-    rebuildLayerStacks();
-    setUpHWComposer();
-    doDebugFlashRegions();
-    doComposition();
-    postComposition();
+
+    static nsecs_t previousExpectedPresent = 0;
+    nsecs_t expectedPresent = mPrimaryDispSync.computeNextRefresh(0);
+    static bool previousFrameMissed = false;
+    bool frameMissed = (expectedPresent == previousExpectedPresent);
+    if (frameMissed != previousFrameMissed) {
+        ATRACE_INT("FrameMissed", static_cast<int>(frameMissed));
+    }
+    previousFrameMissed = frameMissed;
+
+    if (CC_UNLIKELY(mDropMissedFrames && frameMissed)) {
+        // Latch buffers, but don't send anything to HWC, then signal another
+        // wakeup for the next vsync
+        preComposition();
+        repaintEverything();
+    } else {
+        preComposition();
+        rebuildLayerStacks();
+        setUpHWComposer();
+        doDebugFlashRegions();
+        doComposition();
+        postComposition();
+    }
+
+    previousExpectedPresent = mPrimaryDispSync.computeNextRefresh(0);
 }
 
 void SurfaceFlinger::doDebugFlashRegions()
@@ -752,7 +972,7 @@
     const bool repaintEverything = mRepaintEverything;
     for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) {
         const sp<DisplayDevice>& hw(mDisplays[dpy]);
-        if (hw->canDraw()) {
+        if (hw->isDisplayOn()) {
             // transform the dirty region into this screen's coordinate space
             const Region dirtyRegion(hw->getDirtyRegion(repaintEverything));
             if (!dirtyRegion.isEmpty()) {
@@ -817,9 +1037,9 @@
         }
     }
 
-    if (runningWithoutSyncFramework) {
-        const sp<const DisplayDevice> hw(getDefaultDisplayDevice());
-        if (hw->isScreenAcquired()) {
+    const sp<const DisplayDevice> hw(getDefaultDisplayDevice());
+    if (kIgnorePresentFences) {
+        if (hw->isDisplayOn()) {
             enableHardwareVsync();
         }
     }
@@ -837,6 +1057,26 @@
         }
         mAnimFrameTracker.advanceFrame();
     }
+
+    if (hw->getPowerMode() == HWC_POWER_MODE_OFF) {
+        return;
+    }
+
+    nsecs_t currentTime = systemTime();
+    if (mHasPoweredOff) {
+        mHasPoweredOff = false;
+    } else {
+        nsecs_t period = mPrimaryDispSync.getPeriod();
+        nsecs_t elapsedTime = currentTime - mLastSwapTime;
+        size_t numPeriods = static_cast<size_t>(elapsedTime / period);
+        if (numPeriods < NUM_BUCKETS - 1) {
+            mFrameBuckets[numPeriods] += elapsedTime;
+        } else {
+            mFrameBuckets[NUM_BUCKETS - 1] += elapsedTime;
+        }
+        mTotalTime += elapsedTime;
+    }
+    mLastSwapTime = currentTime;
 }
 
 void SurfaceFlinger::rebuildLayerStacks() {
@@ -854,7 +1094,7 @@
             const sp<DisplayDevice>& hw(mDisplays[dpy]);
             const Transform& tr(hw->getTransform());
             const Rect bounds(hw->getBounds());
-            if (hw->canDraw()) {
+            if (hw->isDisplayOn()) {
                 SurfaceFlinger::computeVisibleRegions(layers,
                         hw->getLayerStack(), dirtyRegion, opaqueRegion);
 
@@ -882,7 +1122,32 @@
 
 void SurfaceFlinger::setUpHWComposer() {
     for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) {
-        mDisplays[dpy]->beginFrame();
+        bool dirty = !mDisplays[dpy]->getDirtyRegion(false).isEmpty();
+        bool empty = mDisplays[dpy]->getVisibleLayersSortedByZ().size() == 0;
+        bool wasEmpty = !mDisplays[dpy]->lastCompositionHadVisibleLayers;
+
+        // If nothing has changed (!dirty), don't recompose.
+        // If something changed, but we don't currently have any visible layers,
+        //   and didn't when we last did a composition, then skip it this time.
+        // The second rule does two things:
+        // - When all layers are removed from a display, we'll emit one black
+        //   frame, then nothing more until we get new layers.
+        // - When a display is created with a private layer stack, we won't
+        //   emit any black frames until a layer is added to the layer stack.
+        bool mustRecompose = dirty && !(empty && wasEmpty);
+
+        ALOGV_IF(mDisplays[dpy]->getDisplayType() == DisplayDevice::DISPLAY_VIRTUAL,
+                "dpy[%zu]: %s composition (%sdirty %sempty %swasEmpty)", dpy,
+                mustRecompose ? "doing" : "skipping",
+                dirty ? "+" : "-",
+                empty ? "+" : "-",
+                wasEmpty ? "+" : "-");
+
+        mDisplays[dpy]->beginFrame(mustRecompose);
+
+        if (mustRecompose) {
+            mDisplays[dpy]->lastCompositionHadVisibleLayers = !empty;
+        }
     }
 
     HWComposer& hwc(getHwComposer());
@@ -903,7 +1168,7 @@
                         for (size_t i=0 ; cur!=end && i<count ; ++i, ++cur) {
                             const sp<Layer>& layer(currentLayers[i]);
                             layer->setGeometry(hw, *cur);
-                            if (mDebugDisableHWC || mDebugRegion || mDaltonize) {
+                            if (mDebugDisableHWC || mDebugRegion || mDaltonize || mHasColorMatrix) {
                                 cur->setSkip(true);
                             }
                         }
@@ -933,6 +1198,26 @@
             }
         }
 
+        // If possible, attempt to use the cursor overlay on each display.
+        for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) {
+            sp<const DisplayDevice> hw(mDisplays[dpy]);
+            const int32_t id = hw->getHwcDisplayId();
+            if (id >= 0) {
+                const Vector< sp<Layer> >& currentLayers(
+                    hw->getVisibleLayersSortedByZ());
+                const size_t count = currentLayers.size();
+                HWComposer::LayerListIterator cur = hwc.begin(id);
+                const HWComposer::LayerListIterator end = hwc.end(id);
+                for (size_t i=0 ; cur!=end && i<count ; ++i, ++cur) {
+                    const sp<Layer>& layer(currentLayers[i]);
+                    if (layer->isPotentialCursor()) {
+                        cur->setIsCursorLayerHint();
+                        break;
+                    }
+                }
+            }
+        }
+
         status_t err = hwc.prepare();
         ALOGE_IF(err, "HWComposer::prepare failed (%s)", strerror(-err));
 
@@ -948,7 +1233,7 @@
     const bool repaintEverything = android_atomic_and(0, &mRepaintEverything);
     for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) {
         const sp<DisplayDevice>& hw(mDisplays[dpy]);
-        if (hw->canDraw()) {
+        if (hw->isDisplayOn()) {
             // transform the dirty region into this screen's coordinate space
             const Region dirtyRegion(hw->getDirtyRegion(repaintEverything));
 
@@ -1110,7 +1395,9 @@
                     // this display is in both lists. see if something changed.
                     const DisplayDeviceState& state(curr[j]);
                     const wp<IBinder>& display(curr.keyAt(j));
-                    if (state.surface->asBinder() != draw[i].surface->asBinder()) {
+                    const sp<IBinder> state_binder = IInterface::asBinder(state.surface);
+                    const sp<IBinder> draw_binder = IInterface::asBinder(draw[i].surface);
+                    if (state_binder != draw_binder) {
                         // changing the surface is like destroying and
                         // recreating the DisplayDevice, so we just remove it
                         // from the drawing state, so that it get re-added
@@ -1137,6 +1424,9 @@
                             disp->setProjection(state.orientation,
                                     state.viewport, state.frame);
                         }
+                        if (state.width != draw[i].width || state.height != draw[i].height) {
+                            disp->setDisplaySize(state.width, state.height);
+                        }
                     }
                 }
             }
@@ -1149,7 +1439,10 @@
 
                     sp<DisplaySurface> dispSurface;
                     sp<IGraphicBufferProducer> producer;
-                    sp<BufferQueue> bq = new BufferQueue(new GraphicBufferAlloc());
+                    sp<IGraphicBufferProducer> bqProducer;
+                    sp<IGraphicBufferConsumer> bqConsumer;
+                    BufferQueue::createBufferQueue(&bqProducer, &bqConsumer,
+                            new GraphicBufferAlloc());
 
                     int32_t hwcDisplayId = -1;
                     if (state.isVirtualDisplay()) {
@@ -1158,19 +1451,28 @@
                         // etc.) but no internal state (i.e. a DisplayDevice).
                         if (state.surface != NULL) {
 
-                            hwcDisplayId = allocateHwcDisplayId(state.type);
+                            int width = 0;
+                            int status = state.surface->query(
+                                    NATIVE_WINDOW_WIDTH, &width);
+                            ALOGE_IF(status != NO_ERROR,
+                                    "Unable to query width (%d)", status);
+                            int height = 0;
+                            status = state.surface->query(
+                                    NATIVE_WINDOW_HEIGHT, &height);
+                            ALOGE_IF(status != NO_ERROR,
+                                    "Unable to query height (%d)", status);
+                            if (MAX_VIRTUAL_DISPLAY_DIMENSION == 0 ||
+                                    (width <= MAX_VIRTUAL_DISPLAY_DIMENSION &&
+                                     height <= MAX_VIRTUAL_DISPLAY_DIMENSION)) {
+                                hwcDisplayId = allocateHwcDisplayId(state.type);
+                            }
+
                             sp<VirtualDisplaySurface> vds = new VirtualDisplaySurface(
-                                    *mHwc, hwcDisplayId, state.surface, bq,
-                                    state.displayName);
+                                    *mHwc, hwcDisplayId, state.surface,
+                                    bqProducer, bqConsumer, state.displayName);
 
                             dispSurface = vds;
-                            if (hwcDisplayId >= 0) {
-                                producer = vds;
-                            } else {
-                                // There won't be any interaction with HWC for this virtual display,
-                                // so the GLES driver can pass buffers directly to the sink.
-                                producer = state.surface;
-                            }
+                            producer = vds;
                         }
                     } else {
                         ALOGE_IF(state.surface!=NULL,
@@ -1180,8 +1482,9 @@
                         hwcDisplayId = allocateHwcDisplayId(state.type);
                         // for supported (by hwc) displays we provide our
                         // own rendering surface
-                        dispSurface = new FramebufferSurface(*mHwc, state.type, bq);
-                        producer = bq;
+                        dispSurface = new FramebufferSurface(*mHwc, state.type,
+                                bqConsumer);
+                        producer = bqProducer;
                     }
 
                     const wp<IBinder>& display(curr.keyAt(i));
@@ -1303,6 +1606,34 @@
     }
 
     commitTransaction();
+
+    updateCursorAsync();
+}
+
+void SurfaceFlinger::updateCursorAsync()
+{
+    HWComposer& hwc(getHwComposer());
+    for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) {
+        sp<const DisplayDevice> hw(mDisplays[dpy]);
+        const int32_t id = hw->getHwcDisplayId();
+        if (id < 0) {
+            continue;
+        }
+        const Vector< sp<Layer> >& currentLayers(
+            hw->getVisibleLayersSortedByZ());
+        const size_t count = currentLayers.size();
+        HWComposer::LayerListIterator cur = hwc.begin(id);
+        const HWComposer::LayerListIterator end = hwc.end(id);
+        for (size_t i=0 ; cur!=end && i<count ; ++i, ++cur) {
+            if (cur->getCompositionType() != HWC_CURSOR_OVERLAY) {
+                continue;
+            }
+            const sp<Layer>& layer(currentLayers[i]);
+            Rect cursorPos = layer->getPosition(hw);
+            hwc.setCursorPositionAsync(id, cursorPos);
+            break;
+        }
+    }
 }
 
 void SurfaceFlinger::commitTransaction()
@@ -1380,7 +1711,7 @@
 
         // handle hidden surfaces by setting the visible region to empty
         if (CC_LIKELY(layer->isVisible())) {
-            const bool translucent = !layer->isOpaque();
+            const bool translucent = !layer->isOpaque(s);
             Rect bounds(s.transform.transform(layer->computeBounds()));
             visibleRegion.set(bounds);
             if (!visibleRegion.isEmpty()) {
@@ -1474,21 +1805,56 @@
     }
 }
 
-void SurfaceFlinger::handlePageFlip()
+bool SurfaceFlinger::handlePageFlip()
 {
     Region dirtyRegion;
 
     bool visibleRegions = false;
     const LayerVector& layers(mDrawingState.layersSortedByZ);
-    const size_t count = layers.size();
-    for (size_t i=0 ; i<count ; i++) {
+    bool frameQueued = false;
+
+    // Store the set of layers that need updates. This set must not change as
+    // buffers are being latched, as this could result in a deadlock.
+    // Example: Two producers share the same command stream and:
+    // 1.) Layer 0 is latched
+    // 2.) Layer 0 gets a new frame
+    // 2.) Layer 1 gets a new frame
+    // 3.) Layer 1 is latched.
+    // Display is now waiting on Layer 1's frame, which is behind layer 0's
+    // second frame. But layer 0's second frame could be waiting on display.
+    Vector<Layer*> layersWithQueuedFrames;
+    for (size_t i = 0, count = layers.size(); i<count ; i++) {
         const sp<Layer>& layer(layers[i]);
+        if (layer->hasQueuedFrame()) {
+            frameQueued = true;
+            if (layer->shouldPresentNow(mPrimaryDispSync)) {
+                layersWithQueuedFrames.push_back(layer.get());
+            } else {
+                layer->useEmptyDamage();
+            }
+        } else {
+            layer->useEmptyDamage();
+        }
+    }
+    for (size_t i = 0, count = layersWithQueuedFrames.size() ; i<count ; i++) {
+        Layer* layer = layersWithQueuedFrames[i];
         const Region dirty(layer->latchBuffer(visibleRegions));
+        layer->useSurfaceDamage();
         const Layer::State& s(layer->getDrawingState());
         invalidateLayerStack(s.layerStack, dirty);
     }
 
     mVisibleRegionsDirty |= visibleRegions;
+
+    // If we will need to wake up at some time in the future to deal with a
+    // queued frame that shouldn't be displayed during this vsync period, wake
+    // up during the next vsync period to check again.
+    if (frameQueued && layersWithQueuedFrames.empty()) {
+        signalLayerUpdate();
+    }
+
+    // Only continue with the refresh if there is actually new work to do
+    return !layersWithQueuedFrames.empty();
 }
 
 void SurfaceFlinger::invalidateHwcGeometry()
@@ -1500,6 +1866,15 @@
 void SurfaceFlinger::doDisplayComposition(const sp<const DisplayDevice>& hw,
         const Region& inDirtyRegion)
 {
+    // We only need to actually compose the display if:
+    // 1) It is being handled by hardware composer, which may need this to
+    //    keep its virtual display state machine in sync, or
+    // 2) There is work to be done (the dirty region isn't empty)
+    bool isHwcDisplay = hw->getHwcDisplayId() >= 0;
+    if (!isHwcDisplay && inDirtyRegion.isEmpty()) {
+        return;
+    }
+
     Region dirtyRegion(inDirtyRegion);
 
     // compute the invalid region
@@ -1525,13 +1900,17 @@
         }
     }
 
-    if (CC_LIKELY(!mDaltonize)) {
-        doComposeSurfaces(hw, dirtyRegion);
+    if (CC_LIKELY(!mDaltonize && !mHasColorMatrix)) {
+        if (!doComposeSurfaces(hw, dirtyRegion)) return;
     } else {
         RenderEngine& engine(getRenderEngine());
-        engine.beginGroup(mDaltonizer());
+        mat4 colorMatrix = mColorMatrix;
+        if (mDaltonize) {
+            colorMatrix = colorMatrix * mDaltonizer();
+        }
+        mat4 oldMatrix = engine.setupColorTransform(colorMatrix);
         doComposeSurfaces(hw, dirtyRegion);
-        engine.endGroup();
+        engine.setupColorTransform(oldMatrix);
     }
 
     // update the swap region and clear the dirty region
@@ -1541,7 +1920,7 @@
     hw->swapBuffers(getHwComposer());
 }
 
-void SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& hw, const Region& dirty)
+bool SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& hw, const Region& dirty)
 {
     RenderEngine& engine(getRenderEngine());
     const int32_t id = hw->getHwcDisplayId();
@@ -1554,7 +1933,11 @@
         if (!hw->makeCurrent(mEGLDisplay, mEGLContext)) {
             ALOGW("DisplayDevice::makeCurrent failed. Aborting surface composition for display %s",
                   hw->getDisplayName().string());
-            return;
+            eglMakeCurrent(mEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+            if(!getDefaultDisplayDevice()->makeCurrent(mEGLDisplay, mEGLContext)) {
+              ALOGE("DisplayDevice::makeCurrent on default display failed. Aborting.");
+            }
+            return false;
         }
 
         // Never touch the framebuffer if we don't have any framebuffer layers
@@ -1621,11 +2004,12 @@
             const Region clip(dirty.intersect(tr.transform(layer->visibleRegion)));
             if (!clip.isEmpty()) {
                 switch (cur->getCompositionType()) {
+                    case HWC_CURSOR_OVERLAY:
                     case HWC_OVERLAY: {
                         const Layer::State& state(layer->getDrawingState());
                         if ((cur->getHints() & HWC_HINT_CLEAR_FB)
                                 && i
-                                && layer->isOpaque() && (state.alpha == 0xFF)
+                                && layer->isOpaque(state) && (state.alpha == 0xFF)
                                 && hasGlesComposition) {
                             // never clear the very first layer since we're
                             // guaranteed the FB is already cleared
@@ -1661,6 +2045,7 @@
 
     // disable scissor at the end of the frame
     engine.disableScissor();
+    return true;
 }
 
 void SurfaceFlinger::drawWormhole(const sp<const DisplayDevice>& hw, const Region& region) const {
@@ -1669,18 +2054,25 @@
     engine.fillRegionWithColor(region, height, 0, 0, 0, 0);
 }
 
-void SurfaceFlinger::addClientLayer(const sp<Client>& client,
+status_t SurfaceFlinger::addClientLayer(const sp<Client>& client,
         const sp<IBinder>& handle,
         const sp<IGraphicBufferProducer>& gbc,
         const sp<Layer>& lbc)
 {
+    // add this layer to the current state list
+    {
+        Mutex::Autolock _l(mStateLock);
+        if (mCurrentState.layersSortedByZ.size() >= MAX_LAYERS) {
+            return NO_MEMORY;
+        }
+        mCurrentState.layersSortedByZ.add(lbc);
+        mGraphicBufferProducerList.add(IInterface::asBinder(gbc));
+    }
+
     // attach this layer to the client
     client->attachLayer(handle, lbc);
 
-    // add this layer to the current state list
-    Mutex::Autolock _l(mStateLock);
-    mCurrentState.layersSortedByZ.add(lbc);
-    mGraphicBufferProducerList.add(gbc->asBinder());
+    return NO_ERROR;
 }
 
 status_t SurfaceFlinger::removeLayer(const sp<Layer>& layer) {
@@ -1695,7 +2087,7 @@
     return status_t(index);
 }
 
-uint32_t SurfaceFlinger::peekTransactionFlags(uint32_t flags) {
+uint32_t SurfaceFlinger::peekTransactionFlags(uint32_t /* flags */) {
     return android_atomic_release_load(&mTransactionFlags);
 }
 
@@ -1753,7 +2145,7 @@
         // NOTE: it would be better to use RTTI as we could directly check
         // that we have a Client*. however, RTTI is disabled in Android.
         if (s.client != NULL) {
-            sp<IBinder> binder = s.client->asBinder();
+            sp<IBinder> binder = IInterface::asBinder(s.client);
             if (binder != NULL) {
                 String16 desc(binder->getInterfaceDescriptor());
                 if (desc == ISurfaceComposerClient::descriptor) {
@@ -1800,7 +2192,7 @@
     if (disp.isValid()) {
         const uint32_t what = s.what;
         if (what & DisplayState::eSurfaceChanged) {
-            if (disp.surface->asBinder() != s.surface->asBinder()) {
+            if (IInterface::asBinder(disp.surface) != IInterface::asBinder(s.surface)) {
                 disp.surface = s.surface;
                 flags |= eDisplayTransactionNeeded;
             }
@@ -1825,6 +2217,16 @@
                 flags |= eDisplayTransactionNeeded;
             }
         }
+        if (what & DisplayState::eDisplaySizeChanged) {
+            if (disp.width != s.width) {
+                disp.width = s.width;
+                flags |= eDisplayTransactionNeeded;
+            }
+            if (disp.height != s.height) {
+                disp.height = s.height;
+                flags |= eDisplayTransactionNeeded;
+            }
+        }
     }
     return flags;
 }
@@ -1869,7 +2271,7 @@
             if (layer->setTransparentRegionHint(s.transparentRegion))
                 flags |= eTraversalNeeded;
         }
-        if (what & layer_state_t::eVisibilityChanged) {
+        if (what & layer_state_t::eFlagsChanged) {
             if (layer->setFlags(s.flags, s.mask))
                 flags |= eTraversalNeeded;
         }
@@ -1925,10 +2327,16 @@
             break;
     }
 
-    if (result == NO_ERROR) {
-        addClientLayer(client, *handle, *gbp, layer);
-        setTransactionFlags(eTransactionNeeded);
+    if (result != NO_ERROR) {
+        return result;
     }
+
+    result = addClientLayer(client, *handle, *gbp, layer);
+    if (result != NO_ERROR) {
+        return result;
+    }
+
+    setTransactionFlags(eTransactionNeeded);
     return result;
 }
 
@@ -1943,24 +2351,15 @@
         format = PIXEL_FORMAT_RGBA_8888;
         break;
     case PIXEL_FORMAT_OPAQUE:
-#ifdef NO_RGBX_8888
-        format = PIXEL_FORMAT_RGB_565;
-#else
         format = PIXEL_FORMAT_RGBX_8888;
-#endif
         break;
     }
 
-#ifdef NO_RGBX_8888
-    if (format == PIXEL_FORMAT_RGBX_8888)
-        format = PIXEL_FORMAT_RGBA_8888;
-#endif
-
     *outLayer = new Layer(this, client, name, w, h, flags);
     status_t err = (*outLayer)->setBuffers(w, h, format, flags);
     if (err == NO_ERROR) {
         *handle = (*outLayer)->getHandle();
-        *gbp = (*outLayer)->getBufferQueue();
+        *gbp = (*outLayer)->getProducer();
     }
 
     ALOGE_IF(err, "createNormalLayer() failed (%s)", strerror(-err));
@@ -1973,7 +2372,7 @@
 {
     *outLayer = new LayerDim(this, client, name, w, h, flags);
     *handle = (*outLayer)->getHandle();
-    *gbp = (*outLayer)->getBufferQueue();
+    *gbp = (*outLayer)->getProducer();
     return NO_ERROR;
 }
 
@@ -2018,9 +2417,11 @@
     d.orientation = DisplayState::eOrientationDefault;
     d.frame.makeInvalid();
     d.viewport.makeInvalid();
+    d.width = 0;
+    d.height = 0;
     displays.add(d);
     setTransactionState(state, displays, 0);
-    onScreenAcquired(getDefaultDisplayDevice());
+    setPowerModeInternal(getDisplayDevice(d.token), HWC_POWER_MODE_NORMAL);
 
     const nsecs_t period =
             getHwComposer().getRefreshPeriod(HWC_DISPLAY_PRIMARY);
@@ -2041,42 +2442,36 @@
     postMessageAsync(msg);  // we may be called from main thread, use async message
 }
 
+void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& hw,
+        int mode) {
+    ALOGD("Set power mode=%d, type=%d flinger=%p", mode, hw->getDisplayType(),
+            this);
+    int32_t type = hw->getDisplayType();
+    int currentMode = hw->getPowerMode();
 
-void SurfaceFlinger::onScreenAcquired(const sp<const DisplayDevice>& hw) {
-    ALOGD("Screen acquired, type=%d flinger=%p", hw->getDisplayType(), this);
-    if (hw->isScreenAcquired()) {
-        // this is expected, e.g. when power manager wakes up during boot
-        ALOGD(" screen was previously acquired");
+    if (mode == currentMode) {
+        ALOGD("Screen type=%d is already mode=%d", hw->getDisplayType(), mode);
         return;
     }
 
-    hw->acquireScreen();
-    int32_t type = hw->getDisplayType();
-    if (type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) {
-        // built-in display, tell the HWC
-        getHwComposer().acquire(type);
+    hw->setPowerMode(mode);
+    if (type >= DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) {
+        ALOGW("Trying to set power mode for virtual display");
+        return;
+    }
 
+    if (currentMode == HWC_POWER_MODE_OFF) {
+        getHwComposer().setPowerMode(type, mode);
         if (type == DisplayDevice::DISPLAY_PRIMARY) {
             // FIXME: eventthread only knows about the main display right now
             mEventThread->onScreenAcquired();
-
             resyncToHardwareVsync(true);
         }
-    }
-    mVisibleRegionsDirty = true;
-    repaintEverything();
-}
 
-void SurfaceFlinger::onScreenReleased(const sp<const DisplayDevice>& hw) {
-    ALOGD("Screen released, type=%d flinger=%p", hw->getDisplayType(), this);
-    if (!hw->isScreenAcquired()) {
-        ALOGD(" screen was previously released");
-        return;
-    }
-
-    hw->releaseScreen();
-    int32_t type = hw->getDisplayType();
-    if (type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) {
+        mVisibleRegionsDirty = true;
+        mHasPoweredOff = true;
+        repaintEverything();
+    } else if (mode == HWC_POWER_MODE_OFF) {
         if (type == DisplayDevice::DISPLAY_PRIMARY) {
             disableHardwareVsync(true); // also cancels any in-progress resync
 
@@ -2084,56 +2479,38 @@
             mEventThread->onScreenReleased();
         }
 
-        // built-in display, tell the HWC
-        getHwComposer().release(type);
+        getHwComposer().setPowerMode(type, mode);
+        mVisibleRegionsDirty = true;
+        // from this point on, SF will stop drawing on this display
+    } else {
+        getHwComposer().setPowerMode(type, mode);
     }
-    mVisibleRegionsDirty = true;
-    // from this point on, SF will stop drawing on this display
 }
 
-void SurfaceFlinger::unblank(const sp<IBinder>& display) {
-    class MessageScreenAcquired : public MessageBase {
+void SurfaceFlinger::setPowerMode(const sp<IBinder>& display, int mode) {
+    class MessageSetPowerMode: public MessageBase {
         SurfaceFlinger& mFlinger;
         sp<IBinder> mDisplay;
+        int mMode;
     public:
-        MessageScreenAcquired(SurfaceFlinger& flinger,
-                const sp<IBinder>& disp) : mFlinger(flinger), mDisplay(disp) { }
+        MessageSetPowerMode(SurfaceFlinger& flinger,
+                const sp<IBinder>& disp, int mode) : mFlinger(flinger),
+                    mDisplay(disp) { mMode = mode; }
         virtual bool handler() {
-            const sp<DisplayDevice> hw(mFlinger.getDisplayDevice(mDisplay));
+            sp<DisplayDevice> hw(mFlinger.getDisplayDevice(mDisplay));
             if (hw == NULL) {
-                ALOGE("Attempt to unblank null display %p", mDisplay.get());
+                ALOGE("Attempt to set power mode = %d for null display %p",
+                        mMode, mDisplay.get());
             } else if (hw->getDisplayType() >= DisplayDevice::DISPLAY_VIRTUAL) {
-                ALOGW("Attempt to unblank virtual display");
+                ALOGW("Attempt to set power mode = %d for virtual display",
+                        mMode);
             } else {
-                mFlinger.onScreenAcquired(hw);
+                mFlinger.setPowerModeInternal(hw, mMode);
             }
             return true;
         }
     };
-    sp<MessageBase> msg = new MessageScreenAcquired(*this, display);
-    postMessageSync(msg);
-}
-
-void SurfaceFlinger::blank(const sp<IBinder>& display) {
-    class MessageScreenReleased : public MessageBase {
-        SurfaceFlinger& mFlinger;
-        sp<IBinder> mDisplay;
-    public:
-        MessageScreenReleased(SurfaceFlinger& flinger,
-                const sp<IBinder>& disp) : mFlinger(flinger), mDisplay(disp) { }
-        virtual bool handler() {
-            const sp<DisplayDevice> hw(mFlinger.getDisplayDevice(mDisplay));
-            if (hw == NULL) {
-                ALOGE("Attempt to blank null display %p", mDisplay.get());
-            } else if (hw->getDisplayType() >= DisplayDevice::DISPLAY_VIRTUAL) {
-                ALOGW("Attempt to blank virtual display");
-            } else {
-                mFlinger.onScreenReleased(hw);
-            }
-            return true;
-        }
-    };
-    sp<MessageBase> msg = new MessageScreenReleased(*this, display);
+    sp<MessageBase> msg = new MessageSetPowerMode(*this, display, mode);
     postMessageSync(msg);
 }
 
@@ -2151,18 +2528,15 @@
         result.appendFormat("Permission Denial: "
                 "can't dump SurfaceFlinger from pid=%d, uid=%d\n", pid, uid);
     } else {
-        // Try to get the main lock, but don't insist if we can't
+        // Try to get the main lock, but give up after one second
         // (this would indicate SF is stuck, but we want to be able to
         // print something in dumpsys).
-        int retry = 3;
-        while (mStateLock.tryLock()<0 && --retry>=0) {
-            usleep(1000000);
-        }
-        const bool locked(retry >= 0);
+        status_t err = mStateLock.timedLock(s2ns(1));
+        bool locked = (err == NO_ERROR);
         if (!locked) {
-            result.append(
-                    "SurfaceFlinger appears to be unresponsive, "
-                    "dumping anyways (no locks held)\n");
+            result.appendFormat(
+                    "SurfaceFlinger appears to be unresponsive (%s [%d]), "
+                    "dumping anyways (no locks held)\n", strerror(-err), err);
         }
 
         bool dumpAll = true;
@@ -2189,6 +2563,20 @@
                 clearStatsLocked(args, index, result);
                 dumpAll = false;
             }
+
+            if ((index < numArgs) &&
+                    (args[index] == String16("--dispsync"))) {
+                index++;
+                mPrimaryDispSync.dump(result);
+                dumpAll = false;
+            }
+
+            if ((index < numArgs) &&
+                    (args[index] == String16("--static-screen"))) {
+                index++;
+                dumpStaticScreenStats(result);
+                dumpAll = false;
+            }
         }
 
         if (dumpAll) {
@@ -2203,8 +2591,8 @@
     return NO_ERROR;
 }
 
-void SurfaceFlinger::listLayersLocked(const Vector<String16>& args, size_t& index,
-        String8& result) const
+void SurfaceFlinger::listLayersLocked(const Vector<String16>& /* args */,
+        size_t& /* index */, String8& result) const
 {
     const LayerVector& currentLayers = mCurrentState.layersSortedByZ;
     const size_t count = currentLayers.size();
@@ -2228,21 +2616,21 @@
     result.appendFormat("%" PRId64 "\n", period);
 
     if (name.isEmpty()) {
-        mAnimFrameTracker.dump(result);
+        mAnimFrameTracker.dumpStats(result);
     } else {
         const LayerVector& currentLayers = mCurrentState.layersSortedByZ;
         const size_t count = currentLayers.size();
         for (size_t i=0 ; i<count ; i++) {
             const sp<Layer>& layer(currentLayers[i]);
             if (name == layer->getName()) {
-                layer->dumpStats(result);
+                layer->dumpFrameStats(result);
             }
         }
     }
 }
 
 void SurfaceFlinger::clearStatsLocked(const Vector<String16>& args, size_t& index,
-        String8& result)
+        String8& /* result */)
 {
     String8 name;
     if (index < args.size()) {
@@ -2255,11 +2643,11 @@
     for (size_t i=0 ; i<count ; i++) {
         const sp<Layer>& layer(currentLayers[i]);
         if (name.isEmpty() || (name == layer->getName())) {
-            layer->clearStats();
+            layer->clearFrameStats();
         }
     }
 
-    mAnimFrameTracker.clear();
+    mAnimFrameTracker.clearStats();
 }
 
 // This should only be called from the main thread.  Otherwise it would need
@@ -2279,9 +2667,6 @@
 {
     static const char* config =
             " [sf"
-#ifdef NO_RGBX_8888
-            " NO_RGBX_8888"
-#endif
 #ifdef HAS_CONTEXT_PRIORITY
             " HAS_CONTEXT_PRIORITY"
 #endif
@@ -2295,6 +2680,23 @@
     result.append(config);
 }
 
+void SurfaceFlinger::dumpStaticScreenStats(String8& result) const
+{
+    result.appendFormat("Static screen stats:\n");
+    for (size_t b = 0; b < NUM_BUCKETS - 1; ++b) {
+        float bucketTimeSec = mFrameBuckets[b] / 1e9;
+        float percent = 100.0f *
+                static_cast<float>(mFrameBuckets[b]) / mTotalTime;
+        result.appendFormat("  < %zd frames: %.3f s (%.1f%%)\n",
+                b + 1, bucketTimeSec, percent);
+    }
+    float bucketTimeSec = mFrameBuckets[NUM_BUCKETS - 1] / 1e9;
+    float percent = 100.0f *
+            static_cast<float>(mFrameBuckets[NUM_BUCKETS - 1]) / mTotalTime;
+    result.appendFormat("  %zd+ frames: %.3f s (%.1f%%)\n",
+            NUM_BUCKETS - 1, bucketTimeSec, percent);
+}
+
 void SurfaceFlinger::dumpAllLocked(const Vector<String16>& args, size_t& index,
         String8& result) const
 {
@@ -2332,6 +2734,20 @@
     result.append(SyncFeatures::getInstance().toString());
     result.append("\n");
 
+    colorizer.bold(result);
+    result.append("DispSync configuration: ");
+    colorizer.reset(result);
+    result.appendFormat("app phase %" PRId64 " ns, sf phase %" PRId64 " ns, "
+            "present offset %d ns (refresh %" PRId64 " ns)",
+        vsyncPhaseOffsetNs, sfVsyncPhaseOffsetNs, PRESENT_TIME_OFFSET_FROM_VSYNC_NS,
+        mHwc->getRefreshPeriod(HWC_DISPLAY_PRIMARY));
+    result.append("\n");
+
+    // Dump static screen stats
+    result.append("\n");
+    dumpStaticScreenStats(result);
+    result.append("\n");
+
     /*
      * Dump the visible layer list
      */
@@ -2378,8 +2794,8 @@
     mRenderEngine->dump(result);
 
     hw->undefinedRegion.dump(result, "undefinedRegion");
-    result.appendFormat("  orientation=%d, canDraw=%d\n",
-            hw->getOrientation(), hw->canDraw());
+    result.appendFormat("  orientation=%d, isDisplayOn=%d\n",
+            hw->getOrientation(), hw->isDisplayOn());
     result.appendFormat(
             "  last eglSwapBuffers() time: %f us\n"
             "  last transaction time     : %f us\n"
@@ -2416,7 +2832,8 @@
     colorizer.reset(result);
     result.appendFormat("  h/w composer %s and %s\n",
             hwc.initCheck()==NO_ERROR ? "present" : "not present",
-                    (mDebugDisableHWC || mDebugRegion || mDaltonize) ? "disabled" : "enabled");
+                    (mDebugDisableHWC || mDebugRegion || mDaltonize
+                            || mHasColorMatrix) ? "disabled" : "enabled");
     hwc.dump(result);
 
     /*
@@ -2453,7 +2870,7 @@
     }
     void (*DdmConnection_start)(const char* name);
     DdmConnection_start =
-            (typeof DdmConnection_start)dlsym(libddmconnection_dso, "DdmConnection_start");
+            (decltype(DdmConnection_start))dlsym(libddmconnection_dso, "DdmConnection_start");
     if (!DdmConnection_start) {
         dlclose(libddmconnection_dso);
         return false;
@@ -2470,14 +2887,15 @@
         case CREATE_DISPLAY:
         case SET_TRANSACTION_STATE:
         case BOOT_FINISHED:
-        case BLANK:
-        case UNBLANK:
+        case CLEAR_ANIMATION_FRAME_STATS:
+        case GET_ANIMATION_FRAME_STATS:
+        case SET_POWER_MODE:
         {
             // codes that require permission check
             IPCThreadState* ipc = IPCThreadState::self();
             const int pid = ipc->getCallingPid();
             const int uid = ipc->getCallingUid();
-            if ((uid != AID_GRAPHICS) &&
+            if ((uid != AID_GRAPHICS && uid != AID_SYSTEM) &&
                     !PermissionCache::checkPermission(sAccessSurfaceFlinger, pid, uid)) {
                 ALOGE("Permission Denial: "
                         "can't access SurfaceFlinger pid=%d, uid=%d", pid, uid);
@@ -2579,8 +2997,50 @@
                 mDaltonize = n > 0;
                 invalidateHwcGeometry();
                 repaintEverything();
+                return NO_ERROR;
             }
-            return NO_ERROR;
+            case 1015: {
+                // apply a color matrix
+                n = data.readInt32();
+                mHasColorMatrix = n ? 1 : 0;
+                if (n) {
+                    // color matrix is sent as mat3 matrix followed by vec3
+                    // offset, then packed into a mat4 where the last row is
+                    // the offset and extra values are 0
+                    for (size_t i = 0 ; i < 4; i++) {
+                      for (size_t j = 0; j < 4; j++) {
+                          mColorMatrix[i][j] = data.readFloat();
+                      }
+                    }
+                } else {
+                    mColorMatrix = mat4();
+                }
+                invalidateHwcGeometry();
+                repaintEverything();
+                return NO_ERROR;
+            }
+            // This is an experimental interface
+            // Needs to be shifted to proper binder interface when we productize
+            case 1016: {
+                n = data.readInt32();
+                mPrimaryDispSync.setRefreshSkipCount(n);
+                return NO_ERROR;
+            }
+            case 1017: {
+                n = data.readInt32();
+                mForceFullDamage = static_cast<bool>(n);
+                return NO_ERROR;
+            }
+            case 1018: { // Modify Choreographer's phase offset
+                n = data.readInt32();
+                mEventThread->setPhaseOffset(static_cast<nsecs_t>(n));
+                return NO_ERROR;
+            }
+            case 1019: { // Modify SurfaceFlinger's phase offset
+                n = data.readInt32();
+                mSFEventThread->setPhaseOffset(static_cast<nsecs_t>(n));
+                return NO_ERROR;
+            }
         }
     }
     return err;
@@ -2598,20 +3058,32 @@
 /* The code below is here to handle b/8734824
  *
  * We create a IGraphicBufferProducer wrapper that forwards all calls
- * to the calling binder thread, where they are executed. This allows
- * the calling thread to be reused (on the other side) and not
- * depend on having "enough" binder threads to handle the requests.
- *
+ * from the surfaceflinger thread to the calling binder thread, where they
+ * are executed. This allows the calling thread in the calling process to be
+ * reused and not depend on having "enough" binder threads to handle the
+ * requests.
  */
-
 class GraphicProducerWrapper : public BBinder, public MessageHandler {
+    /* Parts of GraphicProducerWrapper are run on two different threads,
+     * communicating by sending messages via Looper but also by shared member
+     * data. Coherence maintenance is subtle and in places implicit (ugh).
+     *
+     * Don't rely on Looper's sendMessage/handleMessage providing
+     * release/acquire semantics for any data not actually in the Message.
+     * Data going from surfaceflinger to binder threads needs to be
+     * synchronized explicitly.
+     *
+     * Barrier open/wait do provide release/acquire semantics. This provides
+     * implicit synchronization for data coming back from binder to
+     * surfaceflinger threads.
+     */
+
     sp<IGraphicBufferProducer> impl;
     sp<Looper> looper;
     status_t result;
     bool exitPending;
     bool exitRequested;
-    mutable Barrier barrier;
-    volatile int32_t memoryBarrier;
+    Barrier barrier;
     uint32_t code;
     Parcel const* data;
     Parcel* reply;
@@ -2622,20 +3094,26 @@
     };
 
     /*
-     * this is called by our "fake" BpGraphicBufferProducer. We package the
-     * data and reply Parcel and forward them to the calling thread.
+     * Called on surfaceflinger thread. This is called by our "fake"
+     * BpGraphicBufferProducer. We package the data and reply Parcel and
+     * forward them to the binder thread.
      */
     virtual status_t transact(uint32_t code,
-            const Parcel& data, Parcel* reply, uint32_t flags) {
+            const Parcel& data, Parcel* reply, uint32_t /* flags */) {
         this->code = code;
         this->data = &data;
         this->reply = reply;
-        android_atomic_acquire_store(0, &memoryBarrier);
         if (exitPending) {
-            // if we've exited, we run the message synchronously right here
+            // if we've exited, we run the message synchronously right here.
+            // note (JH): as far as I can tell from looking at the code, this
+            // never actually happens. if it does, i'm not sure if it happens
+            // on the surfaceflinger or binder thread.
             handleMessage(Message(MSG_API_CALL));
         } else {
             barrier.close();
+            // Prevent stores to this->{code, data, reply} from being
+            // reordered later than the construction of Message.
+            atomic_thread_fence(memory_order_release);
             looper->sendMessage(this, Message(MSG_API_CALL));
             barrier.wait();
         }
@@ -2643,25 +3121,30 @@
     }
 
     /*
-     * here we run on the binder calling thread. All we've got to do is
+     * here we run on the binder thread. All we've got to do is
      * call the real BpGraphicBufferProducer.
      */
     virtual void handleMessage(const Message& message) {
-        android_atomic_release_load(&memoryBarrier);
-        if (message.what == MSG_API_CALL) {
-            result = impl->asBinder()->transact(code, data[0], reply);
+        int what = message.what;
+        // Prevent reads below from happening before the read from Message
+        atomic_thread_fence(memory_order_acquire);
+        if (what == MSG_API_CALL) {
+            result = IInterface::asBinder(impl)->transact(code, data[0], reply);
             barrier.open();
-        } else if (message.what == MSG_EXIT) {
+        } else if (what == MSG_EXIT) {
             exitRequested = true;
         }
     }
 
 public:
-    GraphicProducerWrapper(const sp<IGraphicBufferProducer>& impl) :
-        impl(impl), looper(new Looper(true)), result(NO_ERROR),
-        exitPending(false), exitRequested(false) {
-    }
+    GraphicProducerWrapper(const sp<IGraphicBufferProducer>& impl)
+    :   impl(impl),
+        looper(new Looper(true)),
+        exitPending(false),
+        exitRequested(false)
+    {}
 
+    // Binder thread
     status_t waitForResponse() {
         do {
             looper->pollOnce(-1);
@@ -2669,9 +3152,13 @@
         return result;
     }
 
+    // Client thread
     void exit(status_t result) {
         this->result = result;
         exitPending = true;
+        // Ensure this->result is visible to the binder thread before it
+        // handles the message.
+        atomic_thread_fence(memory_order_release);
         looper->sendMessage(this, Message(MSG_EXIT));
     }
 };
@@ -2679,8 +3166,9 @@
 
 status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display,
         const sp<IGraphicBufferProducer>& producer,
-        uint32_t reqWidth, uint32_t reqHeight,
-        uint32_t minLayerZ, uint32_t maxLayerZ) {
+        Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
+        uint32_t minLayerZ, uint32_t maxLayerZ,
+        bool useIdentityTransform, ISurfaceComposer::Rotation rotation) {
 
     if (CC_UNLIKELY(display == 0))
         return BAD_VALUE;
@@ -2691,7 +3179,7 @@
     // if we have secure windows on this display, never allow the screen capture
     // unless the producer interface is local (i.e.: we can take a screenshot for
     // ourselves).
-    if (!producer->asBinder()->localBinder()) {
+    if (!IInterface::asBinder(producer)->localBinder()) {
         Mutex::Autolock _l(mStateLock);
         sp<const DisplayDevice> hw(getDisplayDevice(display));
         if (hw->getSecureLayerVisible()) {
@@ -2700,22 +3188,49 @@
         }
     }
 
+    // Convert to surfaceflinger's internal rotation type.
+    Transform::orientation_flags rotationFlags;
+    switch (rotation) {
+        case ISurfaceComposer::eRotateNone:
+            rotationFlags = Transform::ROT_0;
+            break;
+        case ISurfaceComposer::eRotate90:
+            rotationFlags = Transform::ROT_90;
+            break;
+        case ISurfaceComposer::eRotate180:
+            rotationFlags = Transform::ROT_180;
+            break;
+        case ISurfaceComposer::eRotate270:
+            rotationFlags = Transform::ROT_270;
+            break;
+        default:
+            rotationFlags = Transform::ROT_0;
+            ALOGE("Invalid rotation passed to captureScreen(): %d\n", rotation);
+            break;
+    }
+
     class MessageCaptureScreen : public MessageBase {
         SurfaceFlinger* flinger;
         sp<IBinder> display;
         sp<IGraphicBufferProducer> producer;
+        Rect sourceCrop;
         uint32_t reqWidth, reqHeight;
         uint32_t minLayerZ,maxLayerZ;
+        bool useIdentityTransform;
+        Transform::orientation_flags rotation;
         status_t result;
     public:
         MessageCaptureScreen(SurfaceFlinger* flinger,
                 const sp<IBinder>& display,
                 const sp<IGraphicBufferProducer>& producer,
-                uint32_t reqWidth, uint32_t reqHeight,
-                uint32_t minLayerZ, uint32_t maxLayerZ)
+                Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
+                uint32_t minLayerZ, uint32_t maxLayerZ,
+                bool useIdentityTransform, Transform::orientation_flags rotation)
             : flinger(flinger), display(display), producer(producer),
-              reqWidth(reqWidth), reqHeight(reqHeight),
+              sourceCrop(sourceCrop), reqWidth(reqWidth), reqHeight(reqHeight),
               minLayerZ(minLayerZ), maxLayerZ(maxLayerZ),
+              useIdentityTransform(useIdentityTransform),
+              rotation(rotation),
               result(PERMISSION_DENIED)
         {
         }
@@ -2725,9 +3240,10 @@
         virtual bool handler() {
             Mutex::Autolock _l(flinger->mStateLock);
             sp<const DisplayDevice> hw(flinger->getDisplayDevice(display));
-            result = flinger->captureScreenImplLocked(hw,
-                    producer, reqWidth, reqHeight, minLayerZ, maxLayerZ);
-            static_cast<GraphicProducerWrapper*>(producer->asBinder().get())->exit(result);
+            result = flinger->captureScreenImplLocked(hw, producer,
+                    sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
+                    useIdentityTransform, rotation);
+            static_cast<GraphicProducerWrapper*>(IInterface::asBinder(producer).get())->exit(result);
             return true;
         }
     };
@@ -2748,7 +3264,8 @@
     // which does the marshaling work forwards to our "fake remote" above.
     sp<MessageBase> msg = new MessageCaptureScreen(this,
             display, IGraphicBufferProducer::asInterface( wrapper ),
-            reqWidth, reqHeight, minLayerZ, maxLayerZ);
+            sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
+            useIdentityTransform, rotationFlags);
 
     status_t res = postMessageAsync(msg);
     if (res == NO_ERROR) {
@@ -2760,23 +3277,46 @@
 
 void SurfaceFlinger::renderScreenImplLocked(
         const sp<const DisplayDevice>& hw,
-        uint32_t reqWidth, uint32_t reqHeight,
+        Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
         uint32_t minLayerZ, uint32_t maxLayerZ,
-        bool yswap)
+        bool yswap, bool useIdentityTransform, Transform::orientation_flags rotation)
 {
     ATRACE_CALL();
     RenderEngine& engine(getRenderEngine());
 
     // get screen geometry
-    const uint32_t hw_w = hw->getWidth();
-    const uint32_t hw_h = hw->getHeight();
-    const bool filtering = reqWidth != hw_w || reqWidth != hw_h;
+    const int32_t hw_w = hw->getWidth();
+    const int32_t hw_h = hw->getHeight();
+    const bool filtering = static_cast<int32_t>(reqWidth) != hw_w ||
+                           static_cast<int32_t>(reqHeight) != hw_h;
+
+    // if a default or invalid sourceCrop is passed in, set reasonable values
+    if (sourceCrop.width() == 0 || sourceCrop.height() == 0 ||
+            !sourceCrop.isValid()) {
+        sourceCrop.setLeftTop(Point(0, 0));
+        sourceCrop.setRightBottom(Point(hw_w, hw_h));
+    }
+
+    // ensure that sourceCrop is inside screen
+    if (sourceCrop.left < 0) {
+        ALOGE("Invalid crop rect: l = %d (< 0)", sourceCrop.left);
+    }
+    if (sourceCrop.right > hw_w) {
+        ALOGE("Invalid crop rect: r = %d (> %d)", sourceCrop.right, hw_w);
+    }
+    if (sourceCrop.top < 0) {
+        ALOGE("Invalid crop rect: t = %d (< 0)", sourceCrop.top);
+    }
+    if (sourceCrop.bottom > hw_h) {
+        ALOGE("Invalid crop rect: b = %d (> %d)", sourceCrop.bottom, hw_h);
+    }
 
     // make sure to clear all GL error flags
     engine.checkErrors();
 
     // set-up our viewport
-    engine.setViewportAndProjection(reqWidth, reqHeight, hw_w, hw_h, yswap);
+    engine.setViewportAndProjection(
+        reqWidth, reqHeight, sourceCrop, hw_h, yswap, rotation);
     engine.disableTexturing();
 
     // redraw the screen entirely...
@@ -2791,7 +3331,7 @@
             if (state.z >= minLayerZ && state.z <= maxLayerZ) {
                 if (layer->isVisible()) {
                     if (filtering) layer->setFiltering(true);
-                    layer->draw(hw);
+                    layer->draw(hw, useIdentityTransform);
                     if (filtering) layer->setFiltering(false);
                 }
             }
@@ -2807,14 +3347,19 @@
 status_t SurfaceFlinger::captureScreenImplLocked(
         const sp<const DisplayDevice>& hw,
         const sp<IGraphicBufferProducer>& producer,
-        uint32_t reqWidth, uint32_t reqHeight,
-        uint32_t minLayerZ, uint32_t maxLayerZ)
+        Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
+        uint32_t minLayerZ, uint32_t maxLayerZ,
+        bool useIdentityTransform, Transform::orientation_flags rotation)
 {
     ATRACE_CALL();
 
     // get screen geometry
-    const uint32_t hw_w = hw->getWidth();
-    const uint32_t hw_h = hw->getHeight();
+    uint32_t hw_w = hw->getWidth();
+    uint32_t hw_h = hw->getHeight();
+
+    if (rotation & Transform::ROT_90) {
+        std::swap(hw_w, hw_h);
+    }
 
     if ((reqWidth > hw_w) || (reqHeight > hw_h)) {
         ALOGE("size mismatch (%d, %d) > (%d, %d)",
@@ -2830,8 +3375,8 @@
     sp<Surface> sur = new Surface(producer, false);
     ANativeWindow* window = sur.get();
 
-    status_t result = NO_ERROR;
-    if (native_window_api_connect(window, NATIVE_WINDOW_API_EGL) == NO_ERROR) {
+    status_t result = native_window_api_connect(window, NATIVE_WINDOW_API_EGL);
+    if (result == NO_ERROR) {
         uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN |
                         GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;
 
@@ -2848,6 +3393,7 @@
              */
             result = native_window_dequeue_buffer_and_wait(window,  &buffer);
             if (result == NO_ERROR) {
+                int syncFd = -1;
                 // create an EGLImage from the buffer so we can later
                 // turn it into a texture
                 EGLImageKHR image = eglCreateImageKHR(mEGLDisplay, EGL_NO_CONTEXT,
@@ -2861,30 +3407,47 @@
                         // via an FBO, which means we didn't have to create
                         // an EGLSurface and therefore we're not
                         // dependent on the context's EGLConfig.
-                        renderScreenImplLocked(hw, reqWidth, reqHeight,
-                                minLayerZ, maxLayerZ, true);
+                        renderScreenImplLocked(
+                            hw, sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ, true,
+                            useIdentityTransform, rotation);
 
-                        // Create a sync point and wait on it, so we know the buffer is
-                        // ready before we pass it along.  We can't trivially call glFlush(),
-                        // so we use a wait flag instead.
-                        // TODO: pass a sync fd to queueBuffer() and let the consumer wait.
-                        EGLSyncKHR sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_FENCE_KHR, NULL);
-                        if (sync != EGL_NO_SYNC_KHR) {
-                            EGLint result = eglClientWaitSyncKHR(mEGLDisplay, sync,
-                                    EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, 2000000000 /*2 sec*/);
-                            EGLint eglErr = eglGetError();
-                            eglDestroySyncKHR(mEGLDisplay, sync);
-                            if (result == EGL_TIMEOUT_EXPIRED_KHR) {
-                                ALOGW("captureScreen: fence wait timed out");
-                            } else {
-                                ALOGW_IF(eglErr != EGL_SUCCESS,
-                                        "captureScreen: error waiting on EGL fence: %#x", eglErr);
-                            }
+                        // Attempt to create a sync khr object that can produce a sync point. If that
+                        // isn't available, create a non-dupable sync object in the fallback path and
+                        // wait on it directly.
+                        EGLSyncKHR sync;
+                        if (!DEBUG_SCREENSHOTS) {
+                           sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
+                           // native fence fd will not be populated until flush() is done.
+                           getRenderEngine().flush();
                         } else {
-                            ALOGW("captureScreen: error creating EGL fence: %#x", eglGetError());
-                            // not fatal
+                            sync = EGL_NO_SYNC_KHR;
                         }
-
+                        if (sync != EGL_NO_SYNC_KHR) {
+                            // get the sync fd
+                            syncFd = eglDupNativeFenceFDANDROID(mEGLDisplay, sync);
+                            if (syncFd == EGL_NO_NATIVE_FENCE_FD_ANDROID) {
+                                ALOGW("captureScreen: failed to dup sync khr object");
+                                syncFd = -1;
+                            }
+                            eglDestroySyncKHR(mEGLDisplay, sync);
+                        } else {
+                            // fallback path
+                            sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_FENCE_KHR, NULL);
+                            if (sync != EGL_NO_SYNC_KHR) {
+                                EGLint result = eglClientWaitSyncKHR(mEGLDisplay, sync,
+                                    EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, 2000000000 /*2 sec*/);
+                                EGLint eglErr = eglGetError();
+                                if (result == EGL_TIMEOUT_EXPIRED_KHR) {
+                                    ALOGW("captureScreen: fence wait timed out");
+                                } else {
+                                    ALOGW_IF(eglErr != EGL_SUCCESS,
+                                            "captureScreen: error waiting on EGL fence: %#x", eglErr);
+                                }
+                                eglDestroySyncKHR(mEGLDisplay, sync);
+                            } else {
+                                ALOGW("captureScreen: error creating EGL fence: %#x", eglGetError());
+                            }
+                        }
                         if (DEBUG_SCREENSHOTS) {
                             uint32_t* pixels = new uint32_t[reqWidth*reqHeight];
                             getRenderEngine().readPixels(0, 0, reqWidth, reqHeight, pixels);
@@ -2902,7 +3465,8 @@
                 } else {
                     result = BAD_VALUE;
                 }
-                window->queueBuffer(window, buffer, -1);
+                // queueBuffer takes ownership of syncFd
+                result = window->queueBuffer(window, buffer, syncFd);
             }
         } else {
             result = BAD_VALUE;
@@ -2973,11 +3537,11 @@
 // ---------------------------------------------------------------------------
 
 SurfaceFlinger::DisplayDeviceState::DisplayDeviceState()
-    : type(DisplayDevice::DISPLAY_ID_INVALID) {
+    : type(DisplayDevice::DISPLAY_ID_INVALID), width(0), height(0) {
 }
 
 SurfaceFlinger::DisplayDeviceState::DisplayDeviceState(DisplayDevice::DisplayType type)
-    : type(type), layerStack(DisplayDevice::NO_LAYER_STACK), orientation(0) {
+    : type(type), layerStack(DisplayDevice::NO_LAYER_STACK), orientation(0), width(0), height(0) {
     viewport.makeInvalid();
     frame.makeInvalid();
 }
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 80bb619..b3baadd 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -38,6 +38,7 @@
 #include <binder/IMemory.h>
 
 #include <ui/PixelFormat.h>
+#include <ui/mat4.h>
 
 #include <gui/ISurfaceComposer.h>
 #include <gui/ISurfaceComposerClient.h>
@@ -137,12 +138,14 @@
     friend class Client;
     friend class DisplayEventConnection;
     friend class Layer;
-    friend class SurfaceTextureLayer;
+    friend class MonitoredProducer;
 
     // This value is specified in number of frames.  Log frame stats at most
     // every half hour.
     enum { LOG_FRAME_STATS_PERIOD =  30*60*60 };
 
+    static const size_t MAX_LAYERS = 4096;
+
     // We're reference counted, never destroy SurfaceFlinger directly
     virtual ~SurfaceFlinger();
 
@@ -169,6 +172,7 @@
         Rect viewport;
         Rect frame;
         uint8_t orientation;
+        uint32_t width, height;
         String8 displayName;
         bool isSecure;
     };
@@ -201,13 +205,18 @@
     virtual sp<IDisplayEventConnection> createDisplayEventConnection();
     virtual status_t captureScreen(const sp<IBinder>& display,
             const sp<IGraphicBufferProducer>& producer,
-            uint32_t reqWidth, uint32_t reqHeight,
-            uint32_t minLayerZ, uint32_t maxLayerZ);
-    // called when screen needs to turn off
-    virtual void blank(const sp<IBinder>& display);
-    // called when screen is turning back on
-    virtual void unblank(const sp<IBinder>& display);
-    virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info);
+            Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
+            uint32_t minLayerZ, uint32_t maxLayerZ,
+            bool useIdentityTransform, ISurfaceComposer::Rotation rotation);
+    virtual status_t getDisplayStats(const sp<IBinder>& display,
+            DisplayStatInfo* stats);
+    virtual status_t getDisplayConfigs(const sp<IBinder>& display,
+            Vector<DisplayInfo>* configs);
+    virtual int getActiveConfig(const sp<IBinder>& display);
+    virtual void setPowerMode(const sp<IBinder>& display, int mode);
+    virtual status_t setActiveConfig(const sp<IBinder>& display, int id);
+    virtual status_t clearAnimationFrameStats();
+    virtual status_t getAnimationFrameStats(FrameStats* outStats) const;
 
     /* ------------------------------------------------------------------------
      * DeathRecipient interface
@@ -235,22 +244,29 @@
 
     // called on the main thread in response to initializeDisplays()
     void onInitializeDisplays();
-    // called on the main thread in response to blank()
-    void onScreenReleased(const sp<const DisplayDevice>& hw);
-    // called on the main thread in response to unblank()
-    void onScreenAcquired(const sp<const DisplayDevice>& hw);
+    // called on the main thread in response to setActiveConfig()
+    void setActiveConfigInternal(const sp<DisplayDevice>& hw, int mode);
+    // called on the main thread in response to setPowerMode()
+    void setPowerModeInternal(const sp<DisplayDevice>& hw, int mode);
 
-    void handleMessageTransaction();
-    void handleMessageInvalidate();
+    // Returns whether the transaction actually modified any state
+    bool handleMessageTransaction();
+
+    // Returns whether a new buffer has been latched (see handlePageFlip())
+    bool handleMessageInvalidate();
+
     void handleMessageRefresh();
 
     void handleTransaction(uint32_t transactionFlags);
     void handleTransactionLocked(uint32_t transactionFlags);
 
-    /* handlePageFilp: this is were we latch a new buffer
-     * if available and compute the dirty region.
+    void updateCursorAsync();
+
+    /* handlePageFlip - latch a new buffer if available and compute the dirty
+     * region. Returns whether a new buffer has been latched, i.e., whether it
+     * is necessary to perform a refresh during this vsync.
      */
-    void handlePageFlip();
+    bool handlePageFlip();
 
     /* ------------------------------------------------------------------------
      * Transactions
@@ -291,7 +307,7 @@
     status_t removeLayer(const sp<Layer>& layer);
 
     // add a layer to SurfaceFlinger
-    void addClientLayer(const sp<Client>& client,
+    status_t addClientLayer(const sp<Client>& client,
             const sp<IBinder>& handle,
             const sp<IGraphicBufferProducer>& gbc,
             const sp<Layer>& lbc);
@@ -304,15 +320,16 @@
 
     void renderScreenImplLocked(
             const sp<const DisplayDevice>& hw,
-            uint32_t reqWidth, uint32_t reqHeight,
+            Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
             uint32_t minLayerZ, uint32_t maxLayerZ,
-            bool yswap);
+            bool yswap, bool useIdentityTransform, Transform::orientation_flags rotation);
 
     status_t captureScreenImplLocked(
             const sp<const DisplayDevice>& hw,
             const sp<IGraphicBufferProducer>& producer,
-            uint32_t reqWidth, uint32_t reqHeight,
-            uint32_t minLayerZ, uint32_t maxLayerZ);
+            Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
+            uint32_t minLayerZ, uint32_t maxLayerZ,
+            bool useIdentityTransform, Transform::orientation_flags rotation);
 
     /* ------------------------------------------------------------------------
      * EGL
@@ -367,7 +384,10 @@
     void doComposition();
     void doDebugFlashRegions();
     void doDisplayComposition(const sp<const DisplayDevice>& hw, const Region& dirtyRegion);
-    void doComposeSurfaces(const sp<const DisplayDevice>& hw, const Region& dirty);
+
+    // compose surfaces for display hw. this fails if using GL and the surface
+    // has been destroyed and is no longer valid.
+    bool doComposeSurfaces(const sp<const DisplayDevice>& hw, const Region& dirty);
 
     void postFramebuffer();
     void drawWormhole(const sp<const DisplayDevice>& hw, const Region& region) const;
@@ -398,6 +418,8 @@
 
     void logFrameStats();
 
+    void dumpStaticScreenStats(String8& result) const;
+
     /* ------------------------------------------------------------------------
      * Attributes
      */
@@ -423,6 +445,7 @@
     RenderEngine* mRenderEngine;
     nsecs_t mBootTime;
     bool mGpuToCpuSupported;
+    bool mDropMissedFrames;
     sp<EventThread> mEventThread;
     sp<EventThread> mSFEventThread;
     sp<EventControlThread> mEventControlThread;
@@ -451,6 +474,7 @@
     volatile nsecs_t mDebugInTransaction;
     nsecs_t mLastTransactionTime;
     bool mBootFinished;
+    bool mForceFullDamage;
 
     // these are thread safe
     mutable MessageQueue mEventQueue;
@@ -472,6 +496,16 @@
 
     Daltonizer mDaltonizer;
     bool mDaltonize;
+
+    mat4 mColorMatrix;
+    bool mHasColorMatrix;
+
+    // Static screen stats
+    bool mHasPoweredOff;
+    static const size_t NUM_BUCKETS = 8; // < 1-7, 7+
+    nsecs_t mFrameBuckets[NUM_BUCKETS];
+    nsecs_t mTotalTime;
+    nsecs_t mLastSwapTime;
 };
 
 }; // namespace android
diff --git a/services/surfaceflinger/SurfaceFlingerConsumer.cpp b/services/surfaceflinger/SurfaceFlingerConsumer.cpp
index 6dc093e..ed1f31b 100644
--- a/services/surfaceflinger/SurfaceFlingerConsumer.cpp
+++ b/services/surfaceflinger/SurfaceFlingerConsumer.cpp
@@ -21,14 +21,18 @@
 
 #include <private/gui/SyncFeatures.h>
 
-#include <utils/Trace.h>
+#include <gui/BufferItem.h>
+
 #include <utils/Errors.h>
+#include <utils/NativeHandle.h>
+#include <utils/Trace.h>
 
 namespace android {
 
 // ---------------------------------------------------------------------------
 
-status_t SurfaceFlingerConsumer::updateTexImage(BufferRejecter* rejecter)
+status_t SurfaceFlingerConsumer::updateTexImage(BufferRejecter* rejecter,
+        const DispSync& dispSync, uint64_t maxFrameNumber)
 {
     ATRACE_CALL();
     ALOGV("updateTexImage");
@@ -45,12 +49,13 @@
         return err;
     }
 
-    BufferQueue::BufferItem item;
+    BufferItem item;
 
     // Acquire the next buffer.
     // In asynchronous mode the list is guaranteed to be one buffer
     // deep, while in synchronous mode we use the oldest buffer.
-    err = acquireBufferLocked(&item, computeExpectedPresent());
+    err = acquireBufferLocked(&item, computeExpectedPresent(dispSync),
+            maxFrameNumber);
     if (err != NO_ERROR) {
         if (err == BufferQueue::NO_BUFFER_AVAILABLE) {
             err = NO_ERROR;
@@ -70,7 +75,7 @@
     int buf = item.mBuf;
     if (rejecter && rejecter->reject(mSlots[buf].mGraphicBuffer, item)) {
         releaseBufferLocked(buf, mSlots[buf].mGraphicBuffer, EGL_NO_SYNC_KHR);
-        return NO_ERROR;
+        return BUFFER_REJECTED;
     }
 
     // Release the previous buffer.
@@ -99,11 +104,13 @@
     return bindTextureImageLocked();
 }
 
-status_t SurfaceFlingerConsumer::acquireBufferLocked(
-        BufferQueue::BufferItem *item, nsecs_t presentWhen) {
-    status_t result = GLConsumer::acquireBufferLocked(item, presentWhen);
+status_t SurfaceFlingerConsumer::acquireBufferLocked(BufferItem* item,
+        nsecs_t presentWhen, uint64_t maxFrameNumber) {
+    status_t result = GLConsumer::acquireBufferLocked(item, presentWhen,
+            maxFrameNumber);
     if (result == NO_ERROR) {
         mTransformToDisplayInverse = item->mTransformToDisplayInverse;
+        mSurfaceDamage = item->mSurfaceDamage;
     }
     return result;
 }
@@ -112,6 +119,14 @@
     return mTransformToDisplayInverse;
 }
 
+const Region& SurfaceFlingerConsumer::getSurfaceDamage() const {
+    return mSurfaceDamage;
+}
+
+sp<NativeHandle> SurfaceFlingerConsumer::getSidebandStream() const {
+    return mConsumer->getSidebandStream();
+}
+
 // We need to determine the time when a buffer acquired now will be
 // displayed.  This can be calculated:
 //   time when previous buffer's actual-present fence was signaled
@@ -123,35 +138,61 @@
 // will be slightly later then the actual-present timing.  If we get a
 // desired-present time that is unintentionally a hair after the next
 // vsync, we'll hold the frame when we really want to display it.  We
-// want to use an expected-presentation time that is slightly late to
-// avoid this sort of edge case.
-nsecs_t SurfaceFlingerConsumer::computeExpectedPresent()
+// need to take the offset between actual-present and reported-vsync
+// into account.
+//
+// If the system is configured without a DispSync phase offset for the app,
+// we also want to throw in a bit of padding to avoid edge cases where we
+// just barely miss.  We want to do it here, not in every app.  A major
+// source of trouble is the app's use of the display's ideal refresh time
+// (via Display.getRefreshRate()), which could be off of the actual refresh
+// by a few percent, with the error multiplied by the number of frames
+// between now and when the buffer should be displayed.
+//
+// If the refresh reported to the app has a phase offset, we shouldn't need
+// to tweak anything here.
+nsecs_t SurfaceFlingerConsumer::computeExpectedPresent(const DispSync& dispSync)
 {
-    // Don't yet have an easy way to get actual buffer flip time for
-    // the specific display, so use the current time.  This is typically
-    // 1.3ms past the vsync event time.
-    const nsecs_t prevVsync = systemTime(CLOCK_MONOTONIC);
-
-    // Given a SurfaceFlinger reference, and information about what display
-    // we're destined for, we could query the HWC for the refresh rate.  This
-    // could change over time, e.g. we could switch to 24fps for a movie.
-    // For now, assume 60fps.
-    //const nsecs_t vsyncPeriod =
-    //        getHwComposer().getRefreshPeriod(HWC_DISPLAY_PRIMARY);
-    const nsecs_t vsyncPeriod = 16700000;
-
     // The HWC doesn't currently have a way to report additional latency.
-    // Assume that whatever we submit now will appear on the next flip,
-    // i.e. 1 frame of latency w.r.t. the previous flip.
-    const uint32_t hwcLatency = 1;
+    // Assume that whatever we submit now will appear right after the flip.
+    // For a smart panel this might be 1.  This is expressed in frames,
+    // rather than time, because we expect to have a constant frame delay
+    // regardless of the refresh rate.
+    const uint32_t hwcLatency = 0;
 
-    // A little extra padding to compensate for slack between actual vsync
-    // time and vsync event receipt.  Currently not needed since we're
-    // using "now" instead of a vsync time.
-    const nsecs_t extraPadding = 0;
+    // Ask DispSync when the next refresh will be (CLOCK_MONOTONIC).
+    const nsecs_t nextRefresh = dispSync.computeNextRefresh(hwcLatency);
 
-    // Total it up.
-    return prevVsync + hwcLatency * vsyncPeriod + extraPadding;
+    // The DispSync time is already adjusted for the difference between
+    // vsync and reported-vsync (PRESENT_TIME_OFFSET_FROM_VSYNC_NS), so
+    // we don't need to factor that in here.  Pad a little to avoid
+    // weird effects if apps might be requesting times right on the edge.
+    nsecs_t extraPadding = 0;
+    if (VSYNC_EVENT_PHASE_OFFSET_NS == 0) {
+        extraPadding = 1000000;        // 1ms (6% of 60Hz)
+    }
+
+    return nextRefresh + extraPadding;
+}
+
+void SurfaceFlingerConsumer::setContentsChangedListener(
+        const wp<ContentsChangedListener>& listener) {
+    setFrameAvailableListener(listener);
+    Mutex::Autolock lock(mMutex);
+    mContentsChangedListener = listener;
+}
+
+void SurfaceFlingerConsumer::onSidebandStreamChanged() {
+    sp<ContentsChangedListener> listener;
+    {   // scope for the lock
+        Mutex::Autolock lock(mMutex);
+        ALOG_ASSERT(mFrameAvailableListener.unsafe_get() == mContentsChangedListener.unsafe_get());
+        listener = mContentsChangedListener.promote();
+    }
+
+    if (listener != NULL) {
+        listener->onSidebandStreamChanged();
+    }
 }
 
 // ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/SurfaceFlingerConsumer.h b/services/surfaceflinger/SurfaceFlingerConsumer.h
index 688ad32..779e5b7 100644
--- a/services/surfaceflinger/SurfaceFlingerConsumer.h
+++ b/services/surfaceflinger/SurfaceFlingerConsumer.h
@@ -17,6 +17,7 @@
 #ifndef ANDROID_SURFACEFLINGERCONSUMER_H
 #define ANDROID_SURFACEFLINGERCONSUMER_H
 
+#include "DispSync.h"
 #include <gui/GLConsumer.h>
 
 namespace android {
@@ -27,40 +28,64 @@
  */
 class SurfaceFlingerConsumer : public GLConsumer {
 public:
-    SurfaceFlingerConsumer(const sp<BufferQueue>& bq, uint32_t tex)
-        : GLConsumer(bq, tex, GLConsumer::TEXTURE_EXTERNAL, false)
+    static const status_t BUFFER_REJECTED = UNKNOWN_ERROR + 8;
+
+    struct ContentsChangedListener: public FrameAvailableListener {
+        virtual void onSidebandStreamChanged() = 0;
+    };
+
+    SurfaceFlingerConsumer(const sp<IGraphicBufferConsumer>& consumer,
+            uint32_t tex)
+        : GLConsumer(consumer, tex, GLConsumer::TEXTURE_EXTERNAL, false, false),
+          mTransformToDisplayInverse(false), mSurfaceDamage()
     {}
 
     class BufferRejecter {
         friend class SurfaceFlingerConsumer;
         virtual bool reject(const sp<GraphicBuffer>& buf,
-                const IGraphicBufferConsumer::BufferItem& item) = 0;
+                const BufferItem& item) = 0;
 
     protected:
         virtual ~BufferRejecter() { }
     };
 
-    virtual status_t acquireBufferLocked(BufferQueue::BufferItem *item, nsecs_t presentWhen);
+    virtual status_t acquireBufferLocked(BufferItem *item, nsecs_t presentWhen,
+            uint64_t maxFrameNumber = 0) override;
 
     // This version of updateTexImage() takes a functor that may be used to
     // reject the newly acquired buffer.  Unlike the GLConsumer version,
     // this does not guarantee that the buffer has been bound to the GL
     // texture.
-    status_t updateTexImage(BufferRejecter* rejecter);
+    status_t updateTexImage(BufferRejecter* rejecter, const DispSync& dispSync,
+            uint64_t maxFrameNumber = 0);
 
     // See GLConsumer::bindTextureImageLocked().
     status_t bindTextureImage();
 
     // must be called from SF main thread
     bool getTransformToDisplayInverse() const;
+    const Region& getSurfaceDamage() const;
+
+    // Sets the contents changed listener. This should be used instead of
+    // ConsumerBase::setFrameAvailableListener().
+    void setContentsChangedListener(const wp<ContentsChangedListener>& listener);
+
+    sp<NativeHandle> getSidebandStream() const;
+
+    nsecs_t computeExpectedPresent(const DispSync& dispSync);
 
 private:
-    nsecs_t computeExpectedPresent();
+    virtual void onSidebandStreamChanged();
+
+    wp<ContentsChangedListener> mContentsChangedListener;
 
     // Indicates this buffer must be transformed by the inverse transform of the screen
     // it is displayed onto. This is applied after GLConsumer::mCurrentTransform.
     // This must be set/read from SurfaceFlinger's main thread.
     bool mTransformToDisplayInverse;
+
+    // The portion of this surface that has changed since the previous frame
+    Region mSurfaceDamage;
 };
 
 // ----------------------------------------------------------------------------
diff --git a/services/surfaceflinger/SurfaceTextureLayer.cpp b/services/surfaceflinger/SurfaceTextureLayer.cpp
deleted file mode 100644
index 9d79ce2..0000000
--- a/services/surfaceflinger/SurfaceTextureLayer.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <utils/Errors.h>
-
-#include "SurfaceFlinger.h"
-#include "SurfaceTextureLayer.h"
-
-namespace android {
-// ---------------------------------------------------------------------------
-
-
-SurfaceTextureLayer::SurfaceTextureLayer(const sp<SurfaceFlinger>& flinger)
-    : BufferQueue(), flinger(flinger) {
-}
-
-SurfaceTextureLayer::~SurfaceTextureLayer() {
-    // remove ourselves from SurfaceFlinger's list. We do this asynchronously
-    // because we don't know where this dtor is called from, it could be
-    // called with the mStateLock held, leading to a dead-lock (it actually
-    // happens).
-    class MessageCleanUpList : public MessageBase {
-        sp<SurfaceFlinger> flinger;
-        wp<IBinder> gbp;
-    public:
-        MessageCleanUpList(const sp<SurfaceFlinger>& flinger, const wp<IBinder>& gbp)
-            : flinger(flinger), gbp(gbp) { }
-        virtual bool handler() {
-            Mutex::Autolock _l(flinger->mStateLock);
-            flinger->mGraphicBufferProducerList.remove(gbp);
-            return true;
-        }
-    };
-    flinger->postMessageAsync(
-            new MessageCleanUpList(flinger, static_cast<BnGraphicBufferProducer*>(this)) );
-}
-
-// ---------------------------------------------------------------------------
-}; // namespace android
diff --git a/services/surfaceflinger/SurfaceTextureLayer.h b/services/surfaceflinger/SurfaceTextureLayer.h
deleted file mode 100644
index 5f5e4ef..0000000
--- a/services/surfaceflinger/SurfaceTextureLayer.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_SURFACE_TEXTURE_LAYER_H
-#define ANDROID_SURFACE_TEXTURE_LAYER_H
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <utils/Errors.h>
-#include <gui/BufferQueue.h>
-
-namespace android {
-// ---------------------------------------------------------------------------
-
-class Layer;
-class SurfaceFlinger;
-
-/*
- * This is a thin wrapper around BufferQueue, used by the Layer class.
- */
-class SurfaceTextureLayer : public BufferQueue {
-    sp<SurfaceFlinger> flinger;
-public:
-    SurfaceTextureLayer(const sp<SurfaceFlinger>& flinger);
-    virtual ~SurfaceTextureLayer();
-};
-
-// ---------------------------------------------------------------------------
-}; // namespace android
-
-#endif // ANDROID_SURFACE_TEXTURE_LAYER_H
diff --git a/services/surfaceflinger/Transform.cpp b/services/surfaceflinger/Transform.cpp
index 3456abf..35e7e7d 100644
--- a/services/surfaceflinger/Transform.cpp
+++ b/services/surfaceflinger/Transform.cpp
@@ -301,16 +301,16 @@
     // (T*M)^-1 = M^-1 * T^-1
     Transform result;
     if (mType <= TRANSLATE) {
-        // 1 0 x
-        // 0 1 y
-        // 0 0 1
+        // 1 0 0
+        // 0 1 0
+        // x y 1
         result = *this;
         result.mMatrix[2][0] = -result.mMatrix[2][0];
         result.mMatrix[2][1] = -result.mMatrix[2][1];
     } else {
-        // a c x
-        // b d y
-        // 0 0 1
+        // a c 0
+        // b d 0
+        // x y 1
         const mat33& M(mMatrix);
         const float a = M[0][0];
         const float b = M[1][0];
@@ -319,16 +319,17 @@
         const float x = M[2][0];
         const float y = M[2][1];
 
-        Transform R, T;
         const float idet = 1.0 / (a*d - b*c);
-        R.mMatrix[0][0] =  d*idet;    R.mMatrix[0][1] = -c*idet;
-        R.mMatrix[1][0] = -b*idet;    R.mMatrix[1][1] =  a*idet;
-        R.mType = mType &= ~TRANSLATE;
+        result.mMatrix[0][0] =  d*idet;
+        result.mMatrix[0][1] = -c*idet;
+        result.mMatrix[1][0] = -b*idet;
+        result.mMatrix[1][1] =  a*idet;
+        result.mType = mType;
 
-        T.mMatrix[2][0] = -x;
-        T.mMatrix[2][1] = -y;
-        T.mType = TRANSLATE;
-        result =  R * T;
+        vec2 T(-x, -y);
+        T = result.transform(T);
+        result.mMatrix[2][0] = T[0];
+        result.mMatrix[2][1] = T[1];
     }
     return result;
 }
diff --git a/services/surfaceflinger/main_surfaceflinger.cpp b/services/surfaceflinger/main_surfaceflinger.cpp
index b161480..ca81aaa 100644
--- a/services/surfaceflinger/main_surfaceflinger.cpp
+++ b/services/surfaceflinger/main_surfaceflinger.cpp
@@ -14,9 +14,7 @@
  * limitations under the License.
  */
 
-#if defined(HAVE_PTHREADS)
 #include <sys/resource.h>
-#endif
 
 #include <cutils/sched_policy.h>
 #include <binder/IServiceManager.h>
@@ -27,7 +25,8 @@
 
 using namespace android;
 
-int main(int argc, char** argv) {
+int main(int, char**) {
+    signal(SIGPIPE, SIG_IGN);
     // When SF is launched in its own process, limit the number of
     // binder threads to 4.
     ProcessState::self()->setThreadPoolMaxThreadCount(4);
@@ -39,9 +38,8 @@
     // instantiate surfaceflinger
     sp<SurfaceFlinger> flinger = new SurfaceFlinger();
 
-#if defined(HAVE_PTHREADS)
     setpriority(PRIO_PROCESS, 0, PRIORITY_URGENT_DISPLAY);
-#endif
+
     set_sched_policy(0, SP_FOREGROUND);
 
     // initialize before clients can connect
diff --git a/services/surfaceflinger/surfaceflinger.rc b/services/surfaceflinger/surfaceflinger.rc
new file mode 100644
index 0000000..1d6e20f
--- /dev/null
+++ b/services/surfaceflinger/surfaceflinger.rc
@@ -0,0 +1,6 @@
+service surfaceflinger /system/bin/surfaceflinger
+    class core
+    user system
+    group graphics drmrpc readproc
+    onrestart restart zygote
+    writepid /dev/cpuset/system-background/tasks /sys/fs/cgroup/stune/foreground/tasks
diff --git a/services/surfaceflinger/tests/Android.mk b/services/surfaceflinger/tests/Android.mk
index e210860..979062e 100644
--- a/services/surfaceflinger/tests/Android.mk
+++ b/services/surfaceflinger/tests/Android.mk
@@ -1,6 +1,7 @@
 # Build the unit tests,
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 
 LOCAL_MODULE := SurfaceFlinger_test
 
@@ -15,16 +16,9 @@
 	libbinder \
 	libcutils \
 	libgui \
-	libstlport \
 	libui \
 	libutils \
 
-LOCAL_C_INCLUDES := \
-    bionic \
-    bionic/libstdc++/include \
-    external/gtest/include \
-    external/stlport/stlport \
-
 # Build the binary to $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
 # to integrate with auto-test framework.
 include $(BUILD_NATIVE_TEST)
diff --git a/services/surfaceflinger/tests/Transaction_test.cpp b/services/surfaceflinger/tests/Transaction_test.cpp
index 4d363c8..dcde512 100644
--- a/services/surfaceflinger/tests/Transaction_test.cpp
+++ b/services/surfaceflinger/tests/Transaction_test.cpp
@@ -16,6 +16,8 @@
 
 #include <gtest/gtest.h>
 
+#include <android/native_window.h>
+
 #include <binder/IMemory.h>
 
 #include <gui/ISurfaceComposer.h>
@@ -53,21 +55,23 @@
 class ScreenCapture : public RefBase {
 public:
     static void captureScreen(sp<ScreenCapture>* sc) {
-        sp<IMemoryHeap> heap;
-        uint32_t w=0, h=0;
-        PixelFormat fmt=0;
+        sp<IGraphicBufferProducer> producer;
+        sp<IGraphicBufferConsumer> consumer;
+        BufferQueue::createBufferQueue(&producer, &consumer);
+        IGraphicBufferProducer::QueueBufferOutput bufferOutput;
+        sp<CpuConsumer> cpuConsumer = new CpuConsumer(consumer, 1);
         sp<ISurfaceComposer> sf(ComposerService::getComposerService());
-        sp<IBinder> display(sf->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain));
-        ASSERT_EQ(NO_ERROR, sf->captureScreen(display, &heap, &w, &h, &fmt, 0, 0,
-                0, INT_MAX));
-        ASSERT_TRUE(heap != NULL);
-        ASSERT_EQ(PIXEL_FORMAT_RGBA_8888, fmt);
-        *sc = new ScreenCapture(w, h, heap);
+        sp<IBinder> display(sf->getBuiltInDisplay(
+                ISurfaceComposer::eDisplayIdMain));
+        ASSERT_EQ(NO_ERROR, sf->captureScreen(display, producer, Rect(), 0, 0,
+                0, INT_MAX, false));
+        *sc = new ScreenCapture(cpuConsumer);
     }
 
     void checkPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t b) {
-        const uint8_t* img = reinterpret_cast<const uint8_t*>(mHeap->base());
-        const uint8_t* pixel = img + (4 * (y*mWidth + x));
+        ASSERT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, mBuf.format);
+        const uint8_t* img = static_cast<const uint8_t*>(mBuf.data);
+        const uint8_t* pixel = img + (4 * (y * mBuf.stride + x));
         if (r != pixel[0] || g != pixel[1] || b != pixel[2]) {
             String8 err(String8::format("pixel @ (%3d, %3d): "
                     "expected [%3d, %3d, %3d], got [%3d, %3d, %3d]",
@@ -77,15 +81,17 @@
     }
 
 private:
-    ScreenCapture(uint32_t w, uint32_t h, const sp<IMemoryHeap>& heap) :
-        mWidth(w),
-        mHeight(h),
-        mHeap(heap)
-    {}
+    ScreenCapture(const sp<CpuConsumer>& cc) :
+        mCC(cc) {
+        EXPECT_EQ(NO_ERROR, mCC->lockNextBuffer(&mBuf));
+    }
 
-    const uint32_t mWidth;
-    const uint32_t mHeight;
-    sp<IMemoryHeap> mHeap;
+    ~ScreenCapture() {
+        mCC->unlockBuffer(mBuf);
+    }
+
+    sp<CpuConsumer> mCC;
+    CpuConsumer::LockedBuffer mBuf;
 };
 
 class LayerUpdateTest : public ::testing::Test {
diff --git a/services/surfaceflinger/tests/vsync/vsync.cpp b/services/surfaceflinger/tests/vsync/vsync.cpp
index b0d54c4..aa72c79 100644
--- a/services/surfaceflinger/tests/vsync/vsync.cpp
+++ b/services/surfaceflinger/tests/vsync/vsync.cpp
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <android/looper.h>
 #include <gui/DisplayEventReceiver.h>
 #include <utils/Looper.h>
 
diff --git a/services/surfaceflinger/tests/waitforvsync/waitforvsync.cpp b/services/surfaceflinger/tests/waitforvsync/waitforvsync.cpp
index 279b88b..b88b04a 100644
--- a/services/surfaceflinger/tests/waitforvsync/waitforvsync.cpp
+++ b/services/surfaceflinger/tests/waitforvsync/waitforvsync.cpp
@@ -23,6 +23,7 @@
 #include <errno.h>
 #include <string.h>
 #include <stdio.h>
+#include <unistd.h>
 
 #ifndef FBIO_WAITFORVSYNC
 #define FBIO_WAITFORVSYNC   _IOW('F', 0x20, __u32)